summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVoMinhThu <>2014-08-20 06:29:00 (GMT)
committerhdiff <hdiff@hdiff.luite.com>2014-08-20 06:29:00 (GMT)
commit81f856bc00b92aabb5ec9cb8a987d98cb238ef0e (patch)
tree47f75e07021b9557fa59903887ba1cfddb8fc769
parent16a9f6bac73e8b351d39353bdc8714a786364906 (diff)
version 0.1.00.1.0
-rw-r--r--bin/glsl-pprint.hs12
-rw-r--r--language-glsl.cabal19
-rw-r--r--tests/Tests.hs (renamed from Language/GLSL/Tests.hs)30
3 files changed, 36 insertions, 25 deletions
diff --git a/bin/glsl-pprint.hs b/bin/glsl-pprint.hs
index b082814..2d5dfa9 100644
--- a/bin/glsl-pprint.hs
+++ b/bin/glsl-pprint.hs
@@ -4,7 +4,6 @@ import System.Environment (getArgs)
import Text.PrettyPrint.HughesPJClass
import Language.GLSL
-import Language.GLSL.Tests (parsePrettyId, tests)
info :: [String]
info =
@@ -13,24 +12,15 @@ info =
usage :: [String]
usage = info ++
- ["usage:\n glsl-pprint [-p] filename\n glsl-pprint --run-tests"]
+ ["usage:\n glsl-pprint [-p] filename"]
main :: IO ()
main = do
args <- getArgs
case args of
- ["--run-tests"] -> tests
[fn] -> do
content <- readFile fn
putStrLn . show . parse $ content
- ["--check", fn] -> do
- content <- readFile fn
- case parse content of
- Left err -> putStrLn $ "parse error:\n" ++ show err
- Right ast ->
- if parsePrettyId ast
- then putStrLn "parse . pretty == id"
- else putStrLn "parse . pretty /= id"
["-p", fn] -> do
content <- readFile fn
case parse content of
diff --git a/language-glsl.cabal b/language-glsl.cabal
index 5ef47fd..e9e2650 100644
--- a/language-glsl.cabal
+++ b/language-glsl.cabal
@@ -1,5 +1,5 @@
name: language-glsl
-version: 0.0.2
+version: 0.1.0
Cabal-Version: >= 1.8
synopsis: GLSL abstract syntax tree, parser, and pretty-printer
description:
@@ -20,24 +20,33 @@ source-repository head
library
build-depends: base < 5,
- HUnit,
parsec,
prettyclass
ghc-options: -Wall
exposed-modules: Language.GLSL,
Language.GLSL.Parser,
Language.GLSL.Pretty,
- Language.GLSL.Syntax,
- Language.GLSL.Tests
+ Language.GLSL.Syntax
executable glsl-pprint
main-is: glsl-pprint.hs
hs-source-dirs: bin/
build-depends: base < 5,
- HUnit,
language-glsl,
parsec,
pretty,
prettyclass
ghc-options: -Wall
+Test-Suite tests
+ Type: exitcode-stdio-1.0
+ build-depends: base < 5,
+ HUnit,
+ language-glsl,
+ parsec,
+ prettyclass,
+ test-framework,
+ test-framework-hunit
+ ghc-options: -Wall
+ Hs-Source-Dirs: tests
+ main-is: Tests.hs
diff --git a/Language/GLSL/Tests.hs b/tests/Tests.hs
index a99190d..d9605b1 100644
--- a/Language/GLSL/Tests.hs
+++ b/tests/Tests.hs
@@ -1,21 +1,17 @@
-module Language.GLSL.Tests where
+module Main where
import Text.ParserCombinators.Parsec hiding (State, parse) -- TODO clean
import Text.PrettyPrint.HughesPJClass (prettyShow, Pretty)
import Test.HUnit
+import Test.Framework (defaultMain)
+import Test.Framework.Providers.HUnit (hUnitTestToTests)
import Language.GLSL.Syntax
import Language.GLSL.Parser
import Language.GLSL.Pretty ()
-----------------------------------------------------------------------
--- exported tests
-----------------------------------------------------------------------
-
-tests :: IO ()
-tests = do
- mapM_ runTestTT parsingTests
- return ()
+main :: IO ()
+main = defaultMain . hUnitTestToTests . TestList $ parsingTests
parsingTests :: [Test]
parsingTests =
@@ -34,6 +30,8 @@ parsingTests =
map declarationsId testDeclarationsTrue
, TestLabel "function definitions id" $ TestList $
map functionDefinitionsId testFunctionDefinitionsTrue
+
+ , sampleFileTest
]
----------------------------------------------------------------------
@@ -457,3 +455,17 @@ legalTranslationUnitsTests = TestLabel "legal translation unit" $
TestList $ map (doesParse translationUnit) $
testDeclarationsTrue ++ testFunctionDefinitionsTrue
+----------------------------------------------------------------------
+-- kitchen sink
+----------------------------------------------------------------------
+
+sampleFileTest :: Test
+sampleFileTest = TestLabel "Parse/Pretty glsl/sample-01.glsl test" . TestCase . assert $ do
+ content <- readFile $ "glsl/sample-01.glsl"
+ case parse content of
+ Left err -> do
+ putStrLn $ "parse error: \n" ++ show err
+ return False
+ Right ast ->
+ return $ parsePrettyId ast
+