git.iko.soy/rowtype-yoga/purescript-native
on golang help sign in
cabal tests
7c83932Phil Freeman
PureScript.cabal+11−3
@@ -1,6 +1,6 @@
1−name: Purescript
1+name: purescript
2version: 0.0.1
2version: 0.0.1
3−cabal-version: >=1.2
3+cabal-version: >=1.8
4build-type: Simple
4build-type: Simple
5license: MIT
5license: MIT
6license-file: LICENSE
6license-file: LICENSE
@@ -33,9 +33,17 @@ library
33 hs-source-dirs: src
33 hs-source-dirs: src
34 other-modules:
34 other-modules:
35
35
36+Test-Suite tests
37+ type: exitcode-stdio-1.0
38+ main-is: Main.hs
39+ hs-source-dirs: tests
40+ build-depends: base -any, syb -any, directory -any, filepath -any,
41+ containers -any, mtl -any, transformers -any, parsec -any,
42+ utf8-string -any, purescript -any
43+
36executable psc
44executable psc
37 build-depends: base -any, cmdtheline -any, containers -any,
45 build-depends: base -any, cmdtheline -any, containers -any,
38− mtl -any, transformers -any, parsec -any, utf8-string -any
46+ mtl -any, transformers -any, parsec -any, utf8-string -any, syb -any
39 main-is: Main.hs
47 main-is: Main.hs
40 buildable: True
48 buildable: True
41 hs-source-dirs: src
49 hs-source-dirs: src
examples/.gitignore+1−1
@@ -1 +1 @@
1−tests
1+shelltest/tests
examples/Arrays.ps → examples/passing/Arrays.psrenamed

The content is the same.

examples/Assign.ps → examples/passing/Assign.psrenamed

The content is the same.

examples/Conditional.ps → examples/passing/Conditional.psrenamed

The content is the same.

examples/Console.ps → examples/passing/Console.psrenamed

The content is the same.

examples/ExternData.ps → examples/passing/ExternData.psrenamed

The content is the same.

examples/FFI.ps → examples/passing/FFI.psrenamed

The content is the same.

examples/Foreach.ps → examples/passing/Foreach.psrenamed

The content is the same.

examples/Guards.ps → examples/passing/Guards.psrenamed

The content is the same.

examples/IfThenElse.ps → examples/passing/IfThenElse.psrenamed

The content is the same.

examples/List.ps → examples/passing/List.psrenamed

The content is the same.

examples/Match.ps → examples/passing/Match.psrenamed

The content is the same.

examples/Maybe.ps → examples/passing/Maybe.psrenamed

The content is the same.

examples/NamedPatterns.ps → examples/passing/NamedPatterns.psrenamed

The content is the same.

examples/Nested.ps → examples/passing/Nested.psrenamed

The content is the same.

examples/Objects.ps → examples/passing/Objects.psrenamed

The content is the same.

examples/Operators.ps → examples/passing/Operators.psrenamed

The content is the same.

examples/Patterns.ps → examples/passing/Patterns.psrenamed

The content is the same.

examples/Person.ps → examples/passing/Person.psrenamed

The content is the same.

examples/Recursion.ps → examples/passing/Recursion.psrenamed

The content is the same.

examples/TypeDecl.ps → examples/passing/TypeDecl.psrenamed

The content is the same.

examples/TypeSynonyms.ps → examples/passing/TypeSynonyms.psrenamed

The content is the same.

examples/iota.ps → examples/passing/iota.psrenamed

The content is the same.

examples/s.ps → examples/passing/s.psrenamed

The content is the same.

examples/runAll.testdeleted−23
@@ -1,23 +0,0 @@
1−# Maybe
2−mkdir -p tests && ../dist/build/psc/psc Maybe.ps -o tests/Maybe.js && cat tests/Maybe.js Maybe.js | node
3−<<<
4−>>>
5−{ ctor: 'Just', value: 'ab' }
6−>>>2
7−>>>= 0
8−
9−# List
10−mkdir -p tests && ../dist/build/psc/psc List.ps -o tests/List.js && cat tests/List.js List.js | node
11−<<<
12−>>>
13−[ 1, 2 ]
14−>>>2
15−>>>= 0
16−
17−# Foreach
18−mkdir -p tests && ../dist/build/psc/psc Foreach.ps -o tests/Foreach.js && cat tests/Foreach.js Foreach.js | node
19−<<<
20−>>>
21−15
22−>>>2
23−>>>= 0
examples/Console.js → examples/shelltest/Console.jsrenamed

The content is the same.

examples/Foreach.js → examples/shelltest/Foreach.jsrenamed

The content is the same.

examples/List.js → examples/shelltest/List.jsrenamed

The content is the same.

examples/Maybe.js → examples/shelltest/Maybe.jsrenamed

The content is the same.

examples/shelltest/runAll.testnew file+23
@@ -0,0 +1,23 @@
1+# Maybe
2+mkdir -p tests && ../../dist/build/psc/psc ../passing/Maybe.ps -o tests/Maybe.js && cat tests/Maybe.js Maybe.js | node
3+<<<
4+>>>
5+{ ctor: 'Just', value: 'ab' }
6+>>>2
7+>>>= 0
8+
9+# List
10+mkdir -p tests && ../../dist/build/psc/psc ../passing/List.ps -o tests/List.js && cat tests/List.js List.js | node
11+<<<
12+>>>
13+[ 1, 2 ]
14+>>>2
15+>>>= 0
16+
17+# Foreach
18+mkdir -p tests && ../../dist/build/psc/psc ../passing/Foreach.ps -o tests/Foreach.js && cat tests/Foreach.js Foreach.js | node
19+<<<
20+>>>
21+15
22+>>>2
23+>>>= 0
examples/runMain.js → examples/shelltest/runMain.jsrenamed

The content is the same.

src/PureScript/Types.hs+1−1
@@ -31,7 +31,7 @@ data Type
31 | TypeApp Type Type
31 | TypeApp Type Type
32 | SaturatedTypeSynonym String [Type] deriving (Show, Eq, Data, Typeable)
32 | SaturatedTypeSynonym String [Type] deriving (Show, Eq, Data, Typeable)
33
33
34−data PolyType = PolyType [String] Type deriving (Show, Data, Typeable)
34+data PolyType = PolyType [String] Type deriving (Show, Eq, Data, Typeable)
35
35
36data Row
36data Row
37 = RUnknown Int
37 = RUnknown Int
tests/Main.hsnew file+71
@@ -0,0 +1,71 @@
1+-----------------------------------------------------------------------------
2+--
3+-- Module : Main
4+-- Copyright : (c) Phil Freeman 2013
5+-- License : MIT
6+--
7+-- Maintainer : Phil Freeman <paf31@cantab.net>
8+-- Stability : experimental
9+-- Portability :
10+--
11+-- |
12+--
13+-----------------------------------------------------------------------------
14+
15+module Main (main) where
16+
17+import PureScript
18+import PureScript.CodeGen.Pretty.Types
19+
20+import Data.List (isSuffixOf)
21+import Control.Applicative
22+import Control.Monad
23+import System.Exit (exitSuccess, exitFailure)
24+import System.FilePath (pathSeparator)
25+import System.Directory (getCurrentDirectory, getDirectoryContents)
26+import qualified System.IO.UTF8 as U
27+import qualified Data.Map as M
28+
29+compile :: FilePath -> IO (Either String Environment)
30+compile inputFile = do
31+ ast <- runIndentParser parseDeclarations <$> U.readFile inputFile
32+ case ast of
33+ Left parseError -> do
34+ return (Left $ show parseError)
35+ Right decls -> do
36+ case check (typeCheckAll decls) of
37+ Left typeError -> do
38+ return (Left typeError)
39+ Right (_, env) -> do
40+ return (Right env)
41+
42+assert :: FilePath -> (Either String Environment -> Maybe String) -> IO ()
43+assert inputFile f = do
44+ e <- compile inputFile
45+ case f e of
46+ Just err -> exitFailure
47+ Nothing -> return ()
48+
49+assertCompiles :: FilePath -> IO ()
50+assertCompiles inputFile = do
51+ putStrLn $ "assert " ++ inputFile ++ " compiles successfully"
52+ assert inputFile $ either Just (const Nothing)
53+
54+assertDoesNotCompile :: FilePath -> IO ()
55+assertDoesNotCompile inputFile = do
56+ putStrLn $ "assert " ++ inputFile ++ " does not compile"
57+ assert inputFile $ either (const Nothing) (const $ Just "Should not have compiled")
58+
59+main :: IO ()
60+main = do
61+ cd <- getCurrentDirectory
62+ let examples = cd ++ pathSeparator : "examples"
63+ let passing = examples ++ pathSeparator : "passing"
64+ passingTestCases <- getDirectoryContents passing
65+ forM_ passingTestCases $ \inputFile -> when (".ps" `isSuffixOf` inputFile) $
66+ assertCompiles (passing ++ pathSeparator : inputFile)
67+ let failing = examples ++ pathSeparator : "failing"
68+ failingTestCases <- getDirectoryContents failing
69+ forM_ failingTestCases $ \inputFile -> when (".ps" `isSuffixOf` inputFile) $
70+ assertDoesNotCompile (failing ++ pathSeparator : inputFile)
71+ exitSuccess