git.iko.soy/rowtype-yoga/purescript-native
on golang help sign in
Merge pull request #2087 from purescript/multi-file-tests
339c7aeGary Burgess
examples/failing/1733.purs−7
@@ -1,13 +1,6 @@
1-- @shouldFailWith UnknownValue
1-- @shouldFailWith UnknownValue
2−
3module Main where
2module Main where
4
3
5import Thingy as Thing
4import Thingy as Thing
6
5
7main = Thing.doesntExist "hi"
6main = Thing.doesntExist "hi"
8−
9−module Thingy where
10−
11−foo :: Int
12−foo = 1
13−
examples/failing/1733/Thingy.pursnew file+4
@@ -0,0 +1,4 @@
1+module Thingy where
2+
3+foo :: Int
4+foo = 1
examples/manual/failing/ArgLengthMismatch.purs → examples/failing/ArgLengthMismatch.pursrenamed+7−6
@@ -1,6 +1,7 @@
1+-- @shouldFailWith ArgListLengthsDiffer
1−module ArgLengthMismatch where
2+module ArgLengthMismatch where
2−
3+
3−import Prelude
4+import Prelude
4−
5+
5−f x y = true
6+f x y = true
6−f = false
7+f = false
examples/failing/ConflictingExports.purs−10
@@ -1,14 +1,4 @@
1-- @shouldFailWith ScopeConflict
1-- @shouldFailWith ScopeConflict
2−module A where
3−
4− thing :: Int
5− thing = 1
6−
7−module B where
8−
9− thing :: Int
10− thing = 2
11−
12-- Fails here because re-exporting forces any scope conflicts to be resolved
2-- Fails here because re-exporting forces any scope conflicts to be resolved
13module Main (module A, module B) where
3module Main (module A, module B) where
14
4
examples/failing/ConflictingExports/A.pursnew file+4
@@ -0,0 +1,4 @@
1+module A where
2+
3+thing :: Int
4+thing = 1
examples/failing/ConflictingExports/B.pursnew file+4
@@ -0,0 +1,4 @@
1+module B where
2+
3+thing :: Int
4+thing = 2
examples/failing/ConflictingImports.purs+5−15
@@ -1,19 +1,9 @@
1-- @shouldFailWith ScopeConflict
1-- @shouldFailWith ScopeConflict
2−module A where
3−
4− thing :: Int
5− thing = 1
6−
7−module B where
8−
9− thing :: Int
10− thing = 2
11−
12module Main where
2module Main where
13
3
14− import A
4+import A
15− import B
5+import B
16
6
17− -- Error due to referencing `thing` which is in scope as A.thing and B.thing
7+-- Error due to referencing `thing` which is in scope as A.thing and B.thing
18− what :: Int
8+what :: Int
19− what = thing
9+what = thing
examples/failing/ConflictingImports/A.pursnew file+4
@@ -0,0 +1,4 @@
1+module A where
2+
3+thing :: Int
4+thing = 1
examples/failing/ConflictingImports/B.pursnew file+4
@@ -0,0 +1,4 @@
1+module B where
2+
3+thing :: Int
4+thing = 2
examples/failing/ConflictingImports2.purs+6−16
@@ -1,20 +1,10 @@
1-- @shouldFailWith ScopeConflict
1-- @shouldFailWith ScopeConflict
2−module A where
3−
4− thing :: Int
5− thing = 1
6−
7−module B where
8−
9− thing :: Int
10− thing = 2
11−
12module Main where
2module Main where
13
3
14− import A (thing)
4+import A (thing)
15− import B (thing)
5+import B (thing)
16
6
17− -- Error due to referencing `thing` which is explicitly in scope as A.thing
7+-- Error due to referencing `thing` which is explicitly in scope as A.thing
18− -- and B.thing
8+-- and B.thing
19− what :: Int
9+what :: Int
20− what = thing
10+what = thing
examples/failing/ConflictingImports2/A.pursnew file+4
@@ -0,0 +1,4 @@
1+module A where
2+
3+thing :: Int
4+thing = 1
examples/failing/ConflictingImports2/B.pursnew file+4
@@ -0,0 +1,4 @@
1+module B where
2+
3+thing :: Int
4+thing = 2
examples/failing/ConflictingQualifiedImports.purs+3−13
@@ -1,17 +1,7 @@
1-- @shouldFailWith ScopeConflict
1-- @shouldFailWith ScopeConflict
2−module A where
3−
4− thing :: Int
5− thing = 1
6−
7−module B where
8−
9− thing :: Int
10− thing = 2
11−
12module Main where
2module Main where
13
3
14− import A as X
4+import A as X
15− import B as X
5+import B as X
16
6
17− foo = X.thing
7+foo = X.thing
examples/failing/ConflictingQualifiedImports/A.pursnew file+4
@@ -0,0 +1,4 @@
1+module A where
2+
3+thing :: Int
4+thing = 1
examples/failing/ConflictingQualifiedImports/B.pursnew file+4
@@ -0,0 +1,4 @@
1+module B where
2+
3+thing :: Int
4+thing = 2
examples/failing/ConflictingQualifiedImports2.purs+2−12
@@ -1,15 +1,5 @@
1-- @shouldFailWith ScopeConflict
1-- @shouldFailWith ScopeConflict
2−module A where
3−
4− thing :: Int
5− thing = 1
6−
7−module B where
8−
9− thing :: Int
10− thing = 2
11−
12module Main (module X) where
2module Main (module X) where
13
3
14− import A as X
4+import A as X
15− import B as X
5+import B as X
examples/failing/ConflictingQualifiedImports2/A.pursnew file+4
@@ -0,0 +1,4 @@
1+module A where
2+
3+thing :: Int
4+thing = 1
examples/failing/ConflictingQualifiedImports2/B.pursnew file+4
@@ -0,0 +1,4 @@
1+module B where
2+
3+thing :: Int
4+thing = 2
examples/manual/failing/ExportExplicit.purs → examples/failing/ExportExplicit.pursrenamed+8−7
@@ -1,7 +1,8 @@
1+-- @shouldFailWith UnknownExportValue
1−-- should fail as z does not exist in the module
2+-- should fail as z does not exist in the module
2−module M1 (x, y, z) where
3+module M1 (x, y, z) where
3−
4+
4−import Prelude
5+import Prelude
5−
6+
6−x = 1
7+x = 1
7−y = 2
8+y = 2
examples/failing/ExportExplicit1.pursnew file+11
@@ -0,0 +1,11 @@
1+-- @shouldFailWith UnknownDataConstructor
2+module Main where
3+
4+import M1
5+
6+testX = X
7+
8+-- should fail as Y constructor is not exported from M1
9+testY = Y
10+
11+main = Control.Monad.Eff.Console.log "Done"
examples/failing/ExportExplicit1/M1.pursnew file+3
@@ -0,0 +1,3 @@
1+module M1 (X(X)) where
2+
3+data X = X | Y
examples/manual/failing/ExportExplicit2.purs → examples/failing/ExportExplicit2.pursrenamed+8−7
@@ -1,7 +1,8 @@
1+-- @shouldFailWith UnknownExportDataConstructor
1−-- should fail as Y is not a data constructor for X
2+-- should fail as Y is not a data constructor for X
2−module M1 (X(Y)) where
3+module M1 (X(Y)) where
3−
4+
4−import Prelude
5+import Prelude
5−
6+
6−data X = X
7+data X = X
7−data Y = Y
8+data Y = Y
examples/failing/ExportExplicit3.pursnew file+9
@@ -0,0 +1,9 @@
1+-- @shouldFailWith UnknownDataConstructor
2+module Main where
3+
4+import M1
5+
6+-- should fail as Z is not exported from M1
7+testZ = M1.Z
8+
9+main = Control.Monad.Eff.Console.log "Done"
examples/failing/ExportExplicit3/M1.pursnew file+4
@@ -0,0 +1,4 @@
1+module M1 (X(..)) where
2+
3+data X = X | Y
4+data Z = Z
examples/failing/ImportExplicit.pursnew file+4
@@ -0,0 +1,4 @@
1+-- @shouldFailWith UnknownImportType
2+module Main where
3+
4+import M1 (X(..))
examples/failing/ImportExplicit/M1.pursnew file+3
@@ -0,0 +1,3 @@
1+module M1 where
2+
3+foo = "foo"
examples/failing/ImportExplicit2.pursnew file+4
@@ -0,0 +1,4 @@
1+-- @shouldFailWith UnknownImportDataConstructor
2+module Main where
3+
4+import M1 (X(Z, Q))
examples/failing/ImportExplicit2/M1.pursnew file+3
@@ -0,0 +1,3 @@
1+module M1 where
2+
3+data X = Y
examples/failing/ImportHidingModule.purs+4−10
@@ -1,10 +1,4 @@
1−-- @shouldFailWith ImportHidingModule
1+-- @shouldFailWith ImportHidingModule
2−module A where
2+module Main where
3− x = 1
3+
4−
5−module B (module B, module A) where
6− import A
7− y = 1
8−
9−module C where
10− import B hiding (module A)
4+import B hiding (module A)
examples/failing/ImportHidingModule/A.pursnew file+2
@@ -0,0 +1,2 @@
1+module A where
2+x = 1
examples/failing/ImportHidingModule/B.pursnew file+3
@@ -0,0 +1,3 @@
1+module B (module B, module A) where
2+import A
3+y = 1
examples/failing/ImportModule.pursnew file+4
@@ -0,0 +1,4 @@
1+-- @shouldFailWith UnknownModule
2+module Main where
3+
4+import M1
examples/failing/ImportModule/M2.pursnew file+3
@@ -0,0 +1,3 @@
1+module M2 where
2+
3+data X = X
examples/failing/InstanceExport.purs+7−19
@@ -1,19 +1,7 @@
1−-- @shouldFailWith TransitiveExportError
1+-- @shouldFailWith TransitiveExportError
2−module InstanceExport (S(..), f) where
3−
4−import Prelude
5−
6−newtype S = S String
7−
8−class F a where
9− f :: a -> String
10−
11−instance fs :: F S where
12− f (S s) = s
13−
14−module Test where
2+module Test where
15−
3+
16−import InstanceExport
4+import InstanceExport
17−import Prelude
5+import Prelude
18−
6+
19−test = f $ S "Test"
7+test = f $ S "Test"
examples/failing/InstanceExport/InstanceExport.pursnew file+11
@@ -0,0 +1,11 @@
1+module InstanceExport (S(..), f) where
2+
3+import Prelude
4+
5+newtype S = S String
6+
7+class F a where
8+ f :: a -> String
9+
10+instance fs :: F S where
11+ f (S s) = s
examples/failing/OrphanInstance.purs+7−12
@@ -1,12 +1,7 @@
1−-- @shouldFailWith OrphanInstance
1+-- @shouldFailWith OrphanInstance
2−module Class where
3−
4− class C a where
5− op :: a -> a
6−
7−module Test where
2+module Test where
8−
3+
9− import Class
4+import Class
10−
5+
11− instance cBoolean :: C Boolean where
6+instance cBoolean :: C Boolean where
12− op a = a
7+ op a = a
examples/failing/OrphanInstance/Class.pursnew file+4
@@ -0,0 +1,4 @@
1+module Class where
2+
3+class C a where
4+ op :: a -> a
examples/manual/failing/OrphanTypeDecl.purs → examples/failing/OrphanTypeDecl.pursrenamed+4−3
@@ -1,3 +1,4 @@
1+-- @shouldFailWith OrphanTypeDeclaration
1−module OrphanTypeDecl where
2+module OrphanTypeDecl where
2−
3+
3−fn :: Number -> Boolean
4+fn :: Number -> Boolean
examples/failing/OverlappingReExport.purs+3−8
@@ -1,10 +1,5 @@
1-- @shouldFailWith DuplicateValueExport
1-- @shouldFailWith DuplicateValueExport
2−module A where
3− x = true
4−
5−module B where
6− x = false
7−
8module C (module A, module M2) where
2module C (module A, module M2) where
3+
9− import A
4+import A
10− import B as M2
5+import B as M2
examples/failing/OverlappingReExport/A.pursnew file+2
@@ -0,0 +1,2 @@
1+module A where
2+x = true
examples/failing/OverlappingReExport/B.pursnew file+2
@@ -0,0 +1,2 @@
1+module B where
2+x = false
examples/manual/failing/RedefinedFixity.purs → examples/failing/RedefinedFixity.pursrenamed+9−8
@@ -1,8 +1,9 @@
1+-- @shouldFailWith MultipleFixities
1−module RedefinedFixity where
2+module RedefinedFixity where
2−
3+
3−import Prelude
4+import Prelude
4−
5+
5−(!?) x y = x + y
6+(!?) x y = x + y
6−
7+
7−infix 2 !?
8+infix 2 !?
8−infix 2 !?
9+infix 2 !?
examples/manual/failing/RequiredHiddenType.purs → examples/failing/RequiredHiddenType.pursrenamed+9−8
@@ -1,8 +1,9 @@
1+-- @shouldFailWith TransitiveExportError
1−-- exporting `a` should fail as `A` is hidden
2+-- exporting `a` should fail as `A` is hidden
2−module Foo (B(..), a, b) where
3+module Foo (B(..), a, b) where
3−
4+
4−data A = A
5+data A = A
5−data B = B
6+data B = B
6−
7+
7−a = A
8+a = A
8−b = B
9+b = B
examples/manual/QualifiedNames.pursdeleted−13
@@ -1,13 +0,0 @@
1−module Data.Either where
2−
3−import Prelude
4−
5−data Either a b = Left a | Right b
6−
7−module Main where
8−
9−either :: forall a b c. (a -> c) -> (b -> c) -> Data.Either.Either a b -> c
10−either f _ (Data.Either.Left x) = f x
11−either _ g (Data.Either.Right y) = g y
12−
13−main = Control.Monad.Eff.Console.log (either id id (Data.Either.Left "Done"))
examples/manual/failing/ExportExplicit1.pursdeleted−14
@@ -1,14 +0,0 @@
1−module M1 (X(X)) where
2−
3− data X = X | Y
4−
5−module Main where
6−
7− import M1
8−
9− testX = X
10−
11− -- should fail as Y constructor is not exported from M1
12− testY = Y
13−
14− main = Control.Monad.Eff.Console.log "Done"
examples/manual/failing/ExportExplicit3.pursdeleted−13
@@ -1,13 +0,0 @@
1−module M1 (X(..)) where
2−
3− data X = X | Y
4− data Z = Z
5−
6−module Main where
7−
8− import M1
9−
10− -- should fail as Z is not exported from M1
11− testZ = M1.Z
12−
13− main = Control.Monad.Eff.Console.log "Done"
examples/manual/failing/ImportExplicit.pursdeleted−7
@@ -1,7 +0,0 @@
1−module M1 where
2−
3− foo = "foo"
4−
5−module Main where
6−
7− import M1 (X(..))
examples/manual/failing/ImportExplicit2.pursdeleted−7
@@ -1,7 +0,0 @@
1−module M1 where
2−
3− data X = Y
4−
5−module Main where
6−
7− import M1 (X(Z, Q))
examples/manual/failing/ImportModule.pursdeleted−7
@@ -1,7 +0,0 @@
1−module M2 where
2−
3− data X = X
4−
5−module Main where
6−
7− import M1
examples/manual/passing/ExportExplicit.pursdeleted−20
@@ -1,20 +0,0 @@
1−module M1 (X(X), Z(..), foo) where
2−
3− data X = X | Y
4− data Z = Z
5−
6− foo :: Number
7− foo = 0
8−
9− bar :: Number
10− bar = 1
11−
12−module Main where
13−
14− import M1
15−
16− testX = X
17− testZ = Z
18− testFoo = foo
19−
20− main = Control.Monad.Eff.Console.log "Done"
examples/manual/passing/ExportExplicit2.pursdeleted−15
@@ -1,15 +0,0 @@
1−module M1 (bar) where
2−
3− foo :: Number
4− foo = 0
5−
6− bar :: Number
7− bar = foo
8−
9−module Main where
10−
11− import M1
12−
13− testBar = bar
14−
15− main = Control.Monad.Eff.Console.log "Done"
examples/manual/passing/Import.pursdeleted−19
@@ -1,19 +0,0 @@
1−module M1 where
2−
3− import Prelude ()
4−
5− id :: forall a. a -> a
6− id = \x -> x
7−
8− foo = id
9−
10−module M2 where
11−
12− import Prelude ()
13− import M1
14−
15− main = \_ -> foo 42
16−
17−module Main where
18−
19−main = Control.Monad.Eff.Console.log "Done"
examples/manual/passing/ImportExplicit.pursdeleted−14
@@ -1,14 +0,0 @@
1−module M1 where
2−
3− data X = X | Y
4− data Z = Z
5−
6−module Main where
7−
8− import M1 (X(..))
9−
10− testX :: X
11− testX = X
12− testY = Y
13−
14− main = Control.Monad.Eff.Console.log "Done"
examples/manual/passing/ImportQualified.pursdeleted−12
@@ -1,12 +0,0 @@
1−module M1 where
2−
3− log x = x
4−
5−module Main where
6−
7− import Prelude
8− import Control.Monad.Eff
9− import M1
10− import qualified Control.Monad.Eff.Console as C
11−
12− main = C.log (log "Done")
examples/manual/passing/Module.pursdeleted−28
@@ -1,28 +0,0 @@
1−module M1 where
2−
3− import Prelude
4−
5− data Foo = Foo String
6−
7− foo :: M1.Foo -> String
8− foo = \f -> case f of Foo s -> s <> "foo"
9−
10− bar :: Foo -> String
11− bar = foo
12−
13− incr :: Number -> Number
14− incr x = x + 1
15−
16−module M2 where
17−
18− import Prelude
19−
20− baz :: M1.Foo -> String
21− baz = M1.foo
22−
23− match :: M1.Foo -> String
24− match = \f -> case f of M1.Foo s -> s <> "foo"
25−
26−module Main where
27−
28−main = Control.Monad.Eff.Console.log "Done"
examples/manual/passing/ModuleDeps.pursdeleted−17
@@ -1,17 +0,0 @@
1−module M1 where
2−
3−import M2
4−
5−foo = M3.baz
6−
7−module M2 where
8−
9−bar = M3.baz
10−
11−module M3 where
12−
13−baz = 1
14−
15−module Main where
16−
17−main = Control.Monad.Eff.Console.log "Done"
examples/manual/passing/RedefinedFixity.pursdeleted−24
@@ -1,24 +0,0 @@
1−module M1 where
2−
3−import Prelude ()
4−
5−($) f a = f a
6−
7−infixr 1000 $
8−
9−module M2 where
10−
11−import Prelude ()
12−
13−import M1
14−
15−module M3 where
16−
17−import Prelude ()
18−
19−import M1
20−import M2
21−
22−module Main where
23−
24−main = Control.Monad.Eff.Console.log "Done"
examples/manual/passing/TransitiveImport.pursdeleted−24
@@ -1,24 +0,0 @@
1−module Test where
2−
3− import Prelude
4−
5− class TestCls a where
6− test :: a -> a
7−
8− instance unitTestCls :: TestCls Unit where
9− test _ = unit
10−
11−module Middle where
12−
13− middle = Test.test
14−
15−module Main where
16−
17− import Prelude
18− import Middle
19− import Control.Monad.Eff.Console
20−
21− main = do
22− logShow (middle unit)
23− trace "Done"
24− pure unit
examples/passing/2018.purs−13
@@ -1,15 +1,3 @@
1−module B where
2−
3− data Foo = X | Y
4−
5−module A where
6−
7− import B as Main
8−
9− -- Prior to the 2018 fix this would be detected as a cycle between A and Main.
10− foo ∷ Main.Foo → Main.Foo
11− foo x = x
12−
13module Main where
1module Main where
14
2
15import Prelude
3import Prelude
@@ -22,4 +10,3 @@ main :: forall e. Eff (console :: CONSOLE | e) Unit
22main = do
10main = do
23 let tmp = foo X
11 let tmp = foo X
24 log "Done"
12 log "Done"
25−
examples/passing/2018/A.pursnew file+7
@@ -0,0 +1,7 @@
1+module A where
2+
3+import B as Main
4+
5+-- Prior to the 2018 fix this would be detected as a cycle between A and Main.
6+foo ∷ Main.Foo → Main.Foo
7+foo x = x
examples/passing/2018/B.pursnew file+3
@@ -0,0 +1,3 @@
1+module B where
2+
3+data Foo = X | Y
examples/passing/ClassRefSyntax.purs−5
@@ -1,8 +1,3 @@
1−module Lib (class X, go) where
2−
3− class X a where
4− go :: a -> a
5−
6module Main where
1module Main where
7
2
8 import Lib (class X, go)
3 import Lib (class X, go)
examples/passing/ClassRefSyntax/Lib.pursnew file+4
@@ -0,0 +1,4 @@
1+module Lib (class X, go) where
2+
3+class X a where
4+ go :: a -> a
examples/passing/DctorOperatorAlias.purs+2−8
@@ -1,17 +1,11 @@
1−module Data.List where
2−
3− data List a = Cons a (List a) | Nil
4−
5− infixr 6 Cons as :
6−
7module Main where
1module Main where
8
2
9 import Prelude (Unit, bind, (==))
3 import Prelude (Unit, bind, (==))
10 import Control.Monad.Eff (Eff)
4 import Control.Monad.Eff (Eff)
11 import Control.Monad.Eff.Console (CONSOLE, log)
5 import Control.Monad.Eff.Console (CONSOLE, log)
12 import Test.Assert (ASSERT, assert')
6 import Test.Assert (ASSERT, assert')
13− import Data.List (List(..), (:))
7+ import List (List(..), (:))
14− import Data.List as L
8+ import List as L
15
9
16 -- unqualified
10 -- unqualified
17 infixl 6 Cons as !
11 infixl 6 Cons as !
examples/passing/DctorOperatorAlias/List.pursnew file+5
@@ -0,0 +1,5 @@
1+module List where
2+
3+data List a = Cons a (List a) | Nil
4+
5+infixr 6 Cons as :
examples/passing/ExplicitImportReExport.purs+11−16
@@ -1,16 +1,11 @@
1−-- from #1244
1+-- from #1244
2−module Foo where
2+module Main where
3−
3+
4− foo :: Int
4+import Prelude
5− foo = 3
5+import Control.Monad.Eff.Console (log)
6−
7−module Bar (module Foo) where
8−
9− import Foo
10−
11−module Baz where
12−
13− import Bar (foo)
6+import Bar (foo)
14−
7+
15− baz :: Int
8+baz :: Int
16− baz = foo
9+baz = foo
10+
11+main = log "Done"
examples/passing/ExplicitImportReExport/Bar.pursnew file+3
@@ -0,0 +1,3 @@
1+module Bar (module Foo) where
2+
3+import Foo
examples/passing/ExplicitImportReExport/Foo.pursnew file+4
@@ -0,0 +1,4 @@
1+module Foo where
2+
3+foo :: Int
4+foo = 3
examples/passing/ExportExplicit.pursnew file+9
@@ -0,0 +1,9 @@
1+module Main where
2+
3+import M1
4+
5+testX = X
6+testZ = Z
7+testFoo = foo
8+
9+main = Control.Monad.Eff.Console.log "Done"
examples/passing/ExportExplicit/M1.pursnew file+10
@@ -0,0 +1,10 @@
1+module M1 (X(X), Z(..), foo) where
2+
3+data X = X | Y
4+data Z = Z
5+
6+foo :: Int
7+foo = 0
8+
9+bar :: Int
10+bar = 1
examples/passing/ExportExplicit2.pursnew file+7
@@ -0,0 +1,7 @@
1+module Main where
2+
3+import M1
4+
5+testBar = bar
6+
7+main = Control.Monad.Eff.Console.log "Done"
examples/passing/ExportExplicit2/M1.pursnew file+7
@@ -0,0 +1,7 @@
1+module M1 (bar) where
2+
3+foo :: Int
4+foo = 0
5+
6+bar :: Int
7+bar = foo
examples/manual/passing/ExportedInstanceDeclarations.purs → examples/passing/ExportedInstanceDeclarations.pursrenamed+44−43
@@ -1,43 +1,44 @@
1−
2−-- Tests that instances for non-exported classes / types do not appear in the
1+-- Tests that instances for non-exported classes / types do not appear in the
3−-- result of `exportedDeclarations`.
2+-- result of `exportedDeclarations`.
4−
5−module ExportedInstanceDeclarations
3+module ExportedInstanceDeclarations
6− ( Const(..)
4+ ( Const(..)
7− , Foo
5+ , class Foo
8− , foo
6+ , foo
9− ) where
7+ ) where
10−
8+
11−import Prelude
9+import Prelude
12−
10+import Control.Monad.Eff.Console (log)
11+
13−data Const a b = Const a
12+data Const a b = Const a
14−
13+
15−class Foo a where
14+class Foo a where
16− foo :: a
15+ foo :: a
17−
16+
18−data NonexportedType = NonexportedType
17+data NonexportedType = NonexportedType
19−
18+
20−class NonexportedClass a where
19+class NonexportedClass a where
21− notExported :: a
20+ notExported :: a
22−
21+
23−-- There are three places that a nonexported type or type class can occur,
22+-- There are three places that a nonexported type or type class can occur,
24−-- leading an instance to count as non-exported:
23+-- leading an instance to count as non-exported:
25−-- * Constraints
24+-- * Constraints
26−-- * The type class itself
25+-- * The type class itself
27−-- * The instance types
26+-- * The instance types
28−
27+
29−-- Case 1: constraints
28+-- Case 1: constraints
30−instance nonExportedFoo :: (NonexportedClass a) => Foo a where
29+instance nonExportedFoo :: (NonexportedClass a) => Foo a where
31− foo = notExported
30+ foo = notExported
32−
31+
33−-- Another instance of case 1:
32+-- Another instance of case 1:
34−instance nonExportedFoo2 :: (Foo NonexportedType) => Foo (a -> a) where
33+instance nonExportedFoo2 :: (Foo NonexportedType) => Foo (a -> a) where
35− foo = id
34+ foo = id
36−
35+
37−-- Case 2: type class
36+-- Case 2: type class
38−instance nonExportedNonexportedType :: NonexportedClass (Const Number a) where
37+instance nonExportedNonexportedType :: NonexportedClass (Const Int a) where
39− notExported = Const 0
38+ notExported = Const 0
40−
39+
41−-- Case 3: instance types
40+-- Case 3: instance types
42−instance constFoo :: Foo (Const NonexportedType b) where
41+instance constFoo :: Foo (Const NonexportedType b) where
43− foo = Const NonexportedType
42+ foo = Const NonexportedType
43+
44+main = log "Done"
examples/passing/Import.pursnew file+5
@@ -0,0 +1,5 @@
1+module Main where
2+
3+import M2
4+
5+main = Control.Monad.Eff.Console.log "Done"
examples/passing/Import/M1.pursnew file+8
@@ -0,0 +1,8 @@
1+module M1 where
2+
3+import Prelude ()
4+
5+id :: forall a. a -> a
6+id = \x -> x
7+
8+foo = id
examples/passing/Import/M2.pursnew file+6
@@ -0,0 +1,6 @@
1+module M2 where
2+
3+import Prelude ()
4+import M1
5+
6+main = \_ -> foo 42
examples/passing/ImportExplicit.pursnew file+9
@@ -0,0 +1,9 @@
1+module Main where
2+
3+import M1 (X(..))
4+
5+testX :: X
6+testX = X
7+testY = Y
8+
9+main = Control.Monad.Eff.Console.log "Done"
examples/passing/ImportExplicit/M1.pursnew file+4
@@ -0,0 +1,4 @@
1+module M1 where
2+
3+data X = X | Y
4+data Z = Z
examples/passing/ImportQualified.pursnew file+8
@@ -0,0 +1,8 @@
1+module Main where
2+
3+import Prelude
4+import Control.Monad.Eff
5+import M1
6+import Control.Monad.Eff.Console as C
7+
8+main = C.log (log "Done")
examples/passing/ImportQualified/M1.pursnew file+3
@@ -0,0 +1,3 @@
1+module M1 where
2+
3+log x = x
examples/passing/Module.pursnew file+6
@@ -0,0 +1,6 @@
1+module Main where
2+
3+import M1
4+import M2
5+
6+main = Control.Monad.Eff.Console.log "Done"
examples/passing/Module/M1.pursnew file+14
@@ -0,0 +1,14 @@
1+module M1 where
2+
3+import Prelude
4+
5+data Foo = Foo String
6+
7+foo :: M1.Foo -> String
8+foo = \f -> case f of Foo s -> s <> "foo"
9+
10+bar :: Foo -> String
11+bar = foo
12+
13+incr :: Int -> Int
14+incr x = x + 1
examples/passing/Module/M2.pursnew file+9
@@ -0,0 +1,9 @@
1+module M2 where
2+
3+import Prelude
4+
5+baz :: M1.Foo -> String
6+baz = M1.foo
7+
8+match :: M1.Foo -> String
9+match = \f -> case f of M1.Foo s -> s <> "foo"
examples/passing/ModuleDeps.pursnew file+5
@@ -0,0 +1,5 @@
1+module Main where
2+
3+import M1
4+
5+main = Control.Monad.Eff.Console.log "Done"
examples/passing/ModuleDeps/M1.pursnew file+5
@@ -0,0 +1,5 @@
1+module M1 where
2+
3+import M2
4+
5+foo = M2.bar
examples/passing/ModuleDeps/M2.pursnew file+5
@@ -0,0 +1,5 @@
1+module M2 where
2+
3+import M3
4+
5+bar = M3.baz
examples/passing/ModuleDeps/M3.pursnew file+3
@@ -0,0 +1,3 @@
1+module M3 where
2+
3+baz = 1
examples/passing/ModuleExport.purs+6−8
@@ -1,10 +1,8 @@
1−module A (module Prelude) where
2− import Prelude
3−
4module Main where
1module Main where
5− import Control.Monad.Eff.Console (log, logShow)
6− import A
7
2
3+import Control.Monad.Eff.Console (log, logShow)
4+import A
5+
8− main = do
6+main = do
9− logShow (show 1.0)
7+ logShow (show 1.0)
10− log "Done"
8+ log "Done"
examples/passing/ModuleExport/A.pursnew file+3
@@ -0,0 +1,3 @@
1+module A (module Prelude) where
2+
3+import Prelude
examples/passing/ModuleExportDupes.purs+1−10
@@ -1,14 +1,5 @@
1−module A (module Prelude) where
2− import Prelude
3−
4−module B (module Prelude) where
5− import Prelude
6−
7−module C (module Prelude, module A) where
8− import Prelude
9− import A
10−
11module Main where
1module Main where
2+
12 import Control.Monad.Eff.Console
3 import Control.Monad.Eff.Console
13 import A
4 import A
14 import B
5 import B
examples/passing/ModuleExportDupes/A.pursnew file+3
@@ -0,0 +1,3 @@
1+module A (module Prelude) where
2+
3+import Prelude
examples/passing/ModuleExportDupes/B.pursnew file+3
@@ -0,0 +1,3 @@
1+module B (module Prelude) where
2+
3+import Prelude
examples/passing/ModuleExportDupes/C.pursnew file+4
@@ -0,0 +1,4 @@
1+module C (module Prelude, module A) where
2+
3+import Prelude
4+import A
examples/passing/ModuleExportExcluded.purs+8−13
@@ -1,16 +1,11 @@
1−module A (module Prelude, foo) where
2− import Prelude
3−
4− foo :: Number -> Number
5− foo _ = 0.0
6−
7module Main where
1module Main where
8− import Prelude
9− import Control.Monad.Eff.Console (log, logShow)
10− import A (foo)
11
2
3+import Prelude
4+import Control.Monad.Eff.Console (log, logShow)
5+import A (foo)
6+
12− otherwise = false
7+otherwise = false
13
8
14− main = do
9+main = do
15− logShow "1.0"
10+ logShow "1.0"
16− log "Done"
11+ log "Done"
examples/passing/ModuleExportExcluded/A.pursnew file+6
@@ -0,0 +1,6 @@
1+module A (module Prelude, foo) where
2+
3+import Prelude
4+
5+foo :: Number -> Number
6+foo _ = 0.0
examples/passing/ModuleExportQualified.purs+7−9
@@ -1,11 +1,9 @@
1−module A (module Prelude) where
2− import Prelude
3−
4module Main where
1module Main where
5− import Prelude
6− import Control.Monad.Eff.Console (log, logShow)
7− import A as B
8
2
3+import Prelude
4+import Control.Monad.Eff.Console (log, logShow)
5+import A as B
6+
9− main = do
7+main = do
10− logShow (B.show 1.0)
8+ logShow (B.show 1.0)
11− log "Done"
9+ log "Done"
examples/passing/ModuleExportQualified/A.pursnew file+3
@@ -0,0 +1,3 @@
1+module A (module Prelude) where
2+
3+import Prelude
examples/passing/ModuleExportSelf.purs+8−12
@@ -1,15 +1,11 @@
1−module A (module A, module Prelude) where
2− import Prelude
3−
4− type Foo = Boolean
5−
6module Main where
1module Main where
7− import Control.Monad.Eff.Console
8− import A
9
2
3+import Control.Monad.Eff.Console
4+import A
5+
10− bar :: Foo
6+bar :: Foo
11− bar = true
7+bar = true
12
8
13− main = do
9+main = do
14− logShow (show bar)
10+ logShow (show bar)
15− log "Done"
11+ log "Done"
examples/passing/ModuleExportSelf/A.pursnew file+5
@@ -0,0 +1,5 @@
1+module A (module A, module Prelude) where
2+
3+import Prelude
4+
5+type Foo = Boolean
examples/passing/NonConflictingExports.purs−5
@@ -1,8 +1,3 @@
1−module A where
2−
3− thing :: Int
4− thing = 1
5−
6-- No failure here as the export `thing` only refers to Main.thing
1-- No failure here as the export `thing` only refers to Main.thing
7module Main (thing, main) where
2module Main (thing, main) where
8
3
examples/passing/NonConflictingExports/A.pursnew file+4
@@ -0,0 +1,4 @@
1+module A where
2+
3+thing :: Int
4+thing = 1
examples/passing/OperatorAliasElsewhere.purs−5
@@ -1,8 +1,3 @@
1−module Def where
2−
3−what :: forall a b. a -> b -> a
4−what a _ = a
5−
6module Main where
1module Main where
7
2
8import Prelude
3import Prelude
examples/passing/OperatorAliasElsewhere/Def.pursnew file+4
@@ -0,0 +1,4 @@
1+module Def where
2+
3+what :: forall a b. a -> b -> a
4+what a _ = a
examples/passing/PendingConflictingImports.purs+4−14
@@ -1,17 +1,7 @@
1−module A where
2−
3− thing :: Int
4− thing = 1
5−
6−module B where
7−
8− thing :: Int
9− thing = 2
10−
11module Main where
1module Main where
12
2
13− -- No error as we never force `thing` to be resolved in `Main`
3+-- No error as we never force `thing` to be resolved in `Main`
14− import A
4+import A
15− import B
5+import B
16
6
17− main = Control.Monad.Eff.Console.log "Done"
7+main = Control.Monad.Eff.Console.log "Done"
examples/passing/PendingConflictingImports/A.pursnew file+4
@@ -0,0 +1,4 @@
1+module A where
2+
3+thing :: Int
4+thing = 1
examples/passing/PendingConflictingImports/B.pursnew file+4
@@ -0,0 +1,4 @@
1+module B where
2+
3+thing :: Int
4+thing = 2
examples/passing/PendingConflictingImports2.purs−5
@@ -1,8 +1,3 @@
1−module A where
2−
3− thing :: Int
4− thing = 1
5−
6module Main where
1module Main where
7
2
8 import A
3 import A
examples/passing/PendingConflictingImports2/A.pursnew file+4
@@ -0,0 +1,4 @@
1+module A where
2+
3+thing :: Int
4+thing = 1
examples/passing/QualifiedNames.pursnew file+9
@@ -0,0 +1,9 @@
1+module Main where
2+
3+import Prelude
4+
5+either :: forall a b c. (a -> c) -> (b -> c) -> Either.Either a b -> c
6+either f _ (Either.Left x) = f x
7+either _ g (Either.Right y) = g y
8+
9+main = Control.Monad.Eff.Console.log (either id id (Either.Left "Done"))
examples/passing/QualifiedNames/Either.pursnew file+5
@@ -0,0 +1,5 @@
1+module Either where
2+
3+import Prelude
4+
5+data Either a b = Left a | Right b
examples/passing/ReExportQualified.purs+3−13
@@ -1,16 +1,6 @@
1−module A where
2− x = "Do"
3−
4−module B where
5− y = "ne"
6−
7−module C (module A, module M2) where
8− import A
9− import B as M2
10−
11module Main where
1module Main where
12
2
13− import Prelude
3+import Prelude
14− import C
4+import C
15
5
16− main = Control.Monad.Eff.Console.log (x <> y)
6+main = Control.Monad.Eff.Console.log (x <> y)
examples/passing/ReExportQualified/A.pursnew file+3
@@ -0,0 +1,3 @@
1+module A where
2+
3+x = "Do"
examples/passing/ReExportQualified/B.pursnew file+3
@@ -0,0 +1,3 @@
1+module B where
2+
3+y = "ne"
examples/passing/ReExportQualified/C.pursnew file+4
@@ -0,0 +1,4 @@
1+module C (module A, module M2) where
2+
3+import A
4+import B as M2
examples/passing/RedefinedFixity.pursnew file+5
@@ -0,0 +1,5 @@
1+module Main where
2+
3+import M3
4+
5+main = Control.Monad.Eff.Console.log "Done"
examples/passing/RedefinedFixity/M1.pursnew file+7
@@ -0,0 +1,7 @@
1+module M1 where
2+
3+import Prelude ()
4+
5+($) f a = f a
6+
7+infixr 1000 $
examples/passing/RedefinedFixity/M2.pursnew file+5
@@ -0,0 +1,5 @@
1+module M2 where
2+
3+import Prelude ()
4+
5+import M1
examples/passing/RedefinedFixity/M3.pursnew file+6
@@ -0,0 +1,6 @@
1+module M3 where
2+
3+import Prelude ()
4+
5+import M1
6+import M2
examples/passing/ResolvableScopeConflict.purs+8−21
@@ -1,25 +1,12 @@
1−module A where
2−
3− thing :: Int
4− thing = 1
5−
6−module B where
7−
8− thing :: Int
9− thing = 2
10−
11− zing :: Int
12− zing = 3
13−
14module Main where
1module Main where
15
2
16− import A (thing)
3+import A (thing)
17− import B
4+import B
18
5
19− -- Not an error as although we have `thing` in scope from both A and B, it is
6+-- Not an error as although we have `thing` in scope from both A and B, it is
20− -- imported explicitly from A, giving it a resolvable solution.
7+-- imported explicitly from A, giving it a resolvable solution.
21− what :: Boolean -> Int
8+what :: Boolean -> Int
22− what true = thing
9+what true = thing
23− what false = zing
10+what false = zing
24
11
25− main = Control.Monad.Eff.Console.log "Done"
12+main = Control.Monad.Eff.Console.log "Done"
examples/passing/ResolvableScopeConflict/A.pursnew file+4
@@ -0,0 +1,4 @@
1+module A where
2+
3+thing :: Int
4+thing = 1
examples/passing/ResolvableScopeConflict/B.pursnew file+7
@@ -0,0 +1,7 @@
1+module B where
2+
3+thing :: Int
4+thing = 2
5+
6+zing :: Int
7+zing = 3
examples/passing/ResolvableScopeConflict2.purs+9−17
@@ -1,22 +1,14 @@
1−module A where
2−
3− thing :: Int
4− thing = 2
5−
6− zing :: Int
7− zing = 3
8−
9module Main where
1module Main where
10
2
11− import A
3+import A
12
4
13− thing :: Int
5+thing :: Int
14− thing = 1
6+thing = 1
15
7
16− -- Not an error as although we have `thing` in scope from both Main and A,
8+-- Not an error as although we have `thing` in scope from both Main and A,
17− -- as the local declaration takes precedence over the implicit import
9+-- as the local declaration takes precedence over the implicit import
18− what :: Boolean -> Int
10+what :: Boolean -> Int
19− what true = thing
11+what true = thing
20− what false = zing
12+what false = zing
21
13
22− main = Control.Monad.Eff.Console.log "Done"
14+main = Control.Monad.Eff.Console.log "Done"
examples/passing/ResolvableScopeConflict2/A.pursnew file+7
@@ -0,0 +1,7 @@
1+module A where
2+
3+thing :: Int
4+thing = 2
5+
6+zing :: Int
7+zing = 3
examples/passing/ResolvableScopeConflict3.purs+4−11
@@ -1,15 +1,8 @@
1−module A where
2−
3− thing :: Int
4− thing = 1
5−
6module Main (thing, main, module A) where
1module Main (thing, main, module A) where
7
2
8− import A
3+import A
9−
10− thing :: Int
11− thing = 2
12−
13− main = Control.Monad.Eff.Console.log "Done"
14
4
5+thing :: Int
6+thing = 2
15
7
8+main = Control.Monad.Eff.Console.log "Done"
examples/passing/ResolvableScopeConflict3/A.pursnew file+4
@@ -0,0 +1,4 @@
1+module A where
2+
3+thing :: Int
4+thing = 1
examples/passing/ShadowedModuleName.purs+4−11
@@ -1,15 +1,8 @@
1−module Test where
2−
3− data Z = Z String
4−
5− runZ :: Z -> String
6− runZ (Z s) = s
7−
8module Main where
1module Main where
9
2
10− import Test
3+import Test
11− import Control.Monad.Eff.Console
4+import Control.Monad.Eff.Console
12
5
13− data Test = Test
6+data Test = Test
14
7
15− main = log (runZ (Z "Done"))
8+main = log (runZ (Z "Done"))
examples/passing/ShadowedModuleName/Test.pursnew file+6
@@ -0,0 +1,6 @@
1+module Test where
2+
3+data Z = Z String
4+
5+runZ :: Z -> String
6+runZ (Z s) = s
examples/manual/passing/ShadowedName.purs → examples/passing/ShadowedName.pursrenamed+10−10
@@ -1,10 +1,10 @@
1−module Main where
1+module Main where
2−
2+
3−import Prelude
3+import Prelude
4−import Control.Monad.Eff.Console
4+import Control.Monad.Eff.Console
5−
5+
6−done :: String
6+done :: String
7−done = let str = "Not yet done" in
7+done = let str = "Not yet done" in
8− let str = "Done" in str
8+ let str = "Done" in str
9−
9+
10−main = Control.Monad.Eff.Console.log done
10+main = Control.Monad.Eff.Console.log done
examples/passing/TransitiveImport.pursnew file+9
@@ -0,0 +1,9 @@
1+module Main where
2+
3+ import Prelude
4+ import Middle
5+ import Control.Monad.Eff.Console
6+
7+ main = do
8+ logShow (middle unit)
9+ log "Done"
examples/passing/TransitiveImport/Middle.pursnew file+3
@@ -0,0 +1,3 @@
1+module Middle where
2+
3+middle = Test.test
examples/passing/TransitiveImport/Test.pursnew file+9
@@ -0,0 +1,9 @@
1+module Test where
2+
3+import Prelude
4+
5+class TestCls a where
6+ test :: a -> a
7+
8+instance unitTestCls :: TestCls Unit where
9+ test _ = unit
examples/passing/TypeOperators.purs+6−29
@@ -1,34 +1,11 @@
1−module A
2− ( Tuple(..)
3− , type (/\)
4− , (/\)
5− , Natural
6− , type (~>)
7− ) where
8−
9− data Tuple a b = Tuple a b
10−
11− infixl 6 Tuple as /\
12− infixl 6 type Tuple as /\
13−
14− type Natural f g = ∀ a. f a → g a
15−
16− infixr 0 type Natural as ~>
17−
18− tup ∷ ∀ a b. a → b → b /\ a
19− tup a b = b /\ a
20−
21− tupX ∷ ∀ a b c. a /\ b /\ c → c
22− tupX (a /\ b /\ c) = c
23−
24module Main where
1module Main where
25
2
26− import A (type (~>), type (/\), (/\))
3+import A (type (~>), type (/\), (/\))
27
4
28− natty ∷ ∀ f. f ~> f
5+natty ∷ ∀ f. f ~> f
29− natty x = x
6+natty x = x
30
7
31− swap ∷ ∀ a b. a /\ b → b /\ a
8+swap ∷ ∀ a b. a /\ b → b /\ a
32− swap (a /\ b) = b /\ a
9+swap (a /\ b) = b /\ a
33
10
34− main = Control.Monad.Eff.Console.log "Done"
11+main = Control.Monad.Eff.Console.log "Done"
examples/passing/TypeOperators/A.pursnew file+22
@@ -0,0 +1,22 @@
1+module A
2+( Tuple(..)
3+, type (/\)
4+, (/\)
5+, Natural
6+, type (~>)
7+) where
8+
9+data Tuple a b = Tuple a b
10+
11+infixl 6 Tuple as /\
12+infixl 6 type Tuple as /\
13+
14+type Natural f g = ∀ a. f a → g a
15+
16+infixr 0 type Natural as ~>
17+
18+tup ∷ ∀ a b. a → b → b /\ a
19+tup a b = b /\ a
20+
21+tupX ∷ ∀ a b c. a /\ b /\ c → c
22+tupX (a /\ b /\ c) = c
examples/passing/TypeWithoutParens.purs+6−11
@@ -1,16 +1,11 @@
1−module Lib (X, Y) where
2−
3− data X = X
4− type Y = X
5−
6module Main where
1module Main where
7
2
8− import Lib (X, Y)
3+import Lib (X, Y)
9
4
10− idX :: X -> X
5+idX :: X -> X
11− idX x = x
6+idX x = x
12
7
13− idY :: Y -> Y
8+idY :: Y -> Y
14− idY y = y
9+idY y = y
15
10
16− main = Control.Monad.Eff.Console.log "Done"
11+main = Control.Monad.Eff.Console.log "Done"
examples/passing/TypeWithoutParens/Lib.pursnew file+4
@@ -0,0 +1,4 @@
1+module Lib (X, Y) where
2+
3+data X = X
4+type Y = X
examples/manual/passing/WildcardType.purs → examples/passing/WildcardType.pursrenamed+13−13
@@ -1,13 +1,13 @@
1−module Main where
1+module Main where
2−
2+
3−import Prelude
3+import Prelude
4−import Control.Monad.Eff.Console
4+import Control.Monad.Eff.Console
5−
5+
6−f1 :: (_ -> _) -> _
6+f1 :: (_ -> _) -> _
7−f1 g = g 1
7+f1 g = g 1
8−
8+
9−f2 :: _ -> _
9+f2 :: _ -> _
10−f2 _ = "Done"
10+f2 _ = "Done"
11−
11+
12−main = Control.Monad.Eff.Console.log $ f1 f2
12+main = Control.Monad.Eff.Console.log $ f1 f2
13−
13+
purescript.cabal+45
@@ -20,7 +20,52 @@ author: Phil Freeman <paf31@cantab.net>,
20tested-with: GHC==7.10.3
20tested-with: GHC==7.10.3
21
21
22extra-source-files: examples/passing/*.purs
22extra-source-files: examples/passing/*.purs
23+ , examples/passing/2018/*.purs
24+ , examples/passing/ClassRefSyntax/*.purs
25+ , examples/passing/DctorOperatorAlias/*.purs
26+ , examples/passing/ExplicitImportReExport/*.purs
27+ , examples/passing/ExportExplicit/*.purs
28+ , examples/passing/ExportExplicit2/*.purs
29+ , examples/passing/Import/*.purs
30+ , examples/passing/ImportExplicit/*.purs
31+ , examples/passing/ImportQualified/*.purs
32+ , examples/passing/Module/*.purs
33+ , examples/passing/ModuleDeps/*.purs
34+ , examples/passing/ModuleExport/*.purs
35+ , examples/passing/ModuleExportDupes/*.purs
36+ , examples/passing/ModuleExportExcluded/*.purs
37+ , examples/passing/ModuleExportQualified/*.purs
38+ , examples/passing/ModuleExportSelf/*.purs
39+ , examples/passing/NonConflictingExports/*.purs
40+ , examples/passing/OperatorAliasElsewhere/*.purs
41+ , examples/passing/PendingConflictingImports/*.purs
42+ , examples/passing/PendingConflictingImports2/*.purs
43+ , examples/passing/QualifiedNames/*.purs
44+ , examples/passing/RedefinedFixity/*.purs
45+ , examples/passing/ReExportQualified/*.purs
46+ , examples/passing/ResolvableScopeConflict/*.purs
47+ , examples/passing/ResolvableScopeConflict2/*.purs
48+ , examples/passing/ResolvableScopeConflict3/*.purs
49+ , examples/passing/ShadowedModuleName/*.purs
50+ , examples/passing/TransitiveImport/*.purs
51+ , examples/passing/TypeOperators/*.purs
52+ , examples/passing/TypeWithoutParens/*.purs
23 , examples/failing/*.purs
53 , examples/failing/*.purs
54+ , examples/failing/1733/*.purs
55+ , examples/failing/ConflictingExports/*.purs
56+ , examples/failing/ConflictingImports/*.purs
57+ , examples/failing/ConflictingImports2/*.purs
58+ , examples/failing/ConflictingQualifiedImports/*.purs
59+ , examples/failing/ConflictingQualifiedImports2/*.purs
60+ , examples/failing/ExportExplicit1/*.purs
61+ , examples/failing/ExportExplicit3/*.purs
62+ , examples/failing/ImportExplicit/*.purs
63+ , examples/failing/ImportExplicit2/*.purs
64+ , examples/failing/ImportHidingModule/*.purs
65+ , examples/failing/ImportModule/*.purs
66+ , examples/failing/InstanceExport/*.purs
67+ , examples/failing/OrphanInstance/*.purs
68+ , examples/failing/OverlappingReExport/*.purs
24 , examples/docs/bower_components/purescript-prelude/src/*.purs
69 , examples/docs/bower_components/purescript-prelude/src/*.purs
25 , examples/docs/bower.json
70 , examples/docs/bower.json
26 , examples/docs/src/*.purs
71 , examples/docs/src/*.purs
tests/TestCompiler.hs+61−24
@@ -26,8 +26,9 @@ import Prelude.Compat
26import qualified Language.PureScript as P
26import qualified Language.PureScript as P
27
27
28import Data.Char (isSpace)
28import Data.Char (isSpace)
29+import Data.Function (on)
30+import Data.List (sort, stripPrefix, intercalate, groupBy, sortBy, partition)
29import Data.Maybe (mapMaybe)
31import Data.Maybe (mapMaybe)
30−import Data.List (isSuffixOf, sort, stripPrefix, intercalate)
31import Data.Time.Clock (UTCTime())
32import Data.Time.Clock (UTCTime())
32
33
33import qualified Data.Map as M
34import qualified Data.Map as M
@@ -55,39 +56,75 @@ main = hspec spec
55
56
56spec :: Spec
57spec :: Spec
57spec = do
58spec = do
58− (supportPurs, foreigns, passing, passingTestCases, failing, failingTestCases) <- runIO $ do
59− cwd <- getCurrentDirectory
60−
61− let supportDir = cwd </> "tests" </> "support" </> "bower_components"
62− let supportFiles ext = Glob.globDir1 (Glob.compile ("purescript-*/**/*." ++ ext)) supportDir
63−
64− supportPurs <- supportFiles "purs"
65− supportJS <- supportFiles "js"
66−
67− foreignFiles <- forM supportJS (\f -> (f,) <$> readUTF8File f)
68− Right (foreigns, _) <- runExceptT $ runWriterT $ P.parseForeignModulesFromFiles foreignFiles
69
59
60+ (supportPurs, supportForeigns, passingTestCases, failingTestCases) <- runIO $ do
61+ cwd <- getCurrentDirectory
70 let passing = cwd </> "examples" </> "passing"
62 let passing = cwd </> "examples" </> "passing"
71− passingTestCases <- sort . filter (".purs" `isSuffixOf`) <$> getDirectoryContents passing
72−
73 let failing = cwd </> "examples" </> "failing"
63 let failing = cwd </> "examples" </> "failing"
74− failingTestCases <- sort . filter (".purs" `isSuffixOf`) <$> getDirectoryContents failing
64+ let supportDir = cwd </> "tests" </> "support" </> "bower_components"
75−
65+ let supportFiles ext = Glob.globDir1 (Glob.compile ("purescript-*/**/*." ++ ext)) supportDir
76− return (supportPurs, foreigns, passing, passingTestCases, failing, failingTestCases)
66+ passingFiles <- getTestFiles passing <$> testGlob passing
67+ failingFiles <- getTestFiles failing <$> testGlob failing
68+ supportPurs <- supportFiles "purs"
69+ supportForeigns <- loadForeigns =<< supportFiles "js"
70+ return (supportPurs, supportForeigns, passingFiles, failingFiles)
77
71
78 context ("Passing examples") $ do
72 context ("Passing examples") $ do
79− forM_ passingTestCases $ \inputFile ->
73+ forM_ passingTestCases $ \(testPurs, testJS) ->
80− it ("'" <> inputFile <> "' should compile and run without error") $ do
74+ it ("'" <> takeFileName (getTestMain testPurs) <> "' should compile and run without error") $ do
75+ testForeigns <- loadForeigns testJS
81− assertCompiles (supportPurs ++ [passing </> inputFile]) foreigns
76+ assertCompiles (supportPurs ++ testPurs) (supportForeigns <> testForeigns)
82
77
83 context ("Failing examples") $ do
78 context ("Failing examples") $ do
84− forM_ failingTestCases $ \inputFile -> do
79+ forM_ failingTestCases $ \(testPurs, testJS) -> do
80+ let mainPath = getTestMain testPurs
85− expectedFailures <- runIO $ getShouldFailWith (failing </> inputFile)
81+ expectedFailures <- runIO $ getShouldFailWith mainPath
86− it ("'" <> inputFile <> "' should fail with '" <> intercalate "', '" expectedFailures <> "'") $ do
82+ it ("'" <> takeFileName mainPath <> "' should fail with '" <> intercalate "', '" expectedFailures <> "'") $ do
83+ testForeigns <- loadForeigns testJS
87− assertDoesNotCompile (supportPurs ++ [failing </> inputFile]) foreigns expectedFailures
84+ assertDoesNotCompile (supportPurs ++ testPurs) (supportForeigns <> testForeigns) expectedFailures
88
85
89 where
86 where
90
87
88+ -- A glob for all purs and js files within a test directory
89+ testGlob :: FilePath -> IO [FilePath]
90+ testGlob dir = join . fst <$> Glob.globDir (map Glob.compile ["**/*.purs", "**/*.js"]) dir
91+
92+ -- Loads foreign modules from source files
93+ loadForeigns :: [FilePath] -> IO (M.Map P.ModuleName FilePath)
94+ loadForeigns paths = do
95+ files <- forM paths (\f -> (f,) <$> readUTF8File f)
96+ Right (foreigns, _) <- runExceptT $ runWriterT $ P.parseForeignModulesFromFiles files
97+ return foreigns
98+
99+ -- Groups the test files so that a top-level file can have dependencies in a
100+ -- subdirectory of the same name. The inner tuple contains a list of the
101+ -- .purs files and the .js files for the test case.
102+ getTestFiles :: FilePath -> [FilePath] -> [([FilePath], [FilePath])]
103+ getTestFiles baseDir
104+ = map (partition ((== ".purs") . takeExtensions))
105+ . map (map (baseDir </>))
106+ . groupBy ((==) `on` extractPrefix)
107+ . sortBy (compare `on` extractPrefix)
108+ . map (makeRelative baseDir)
109+
110+ -- Takes the test entry point from a group of purs files - this is determined
111+ -- by the file with the shortest path name, as everything but the main file
112+ -- will be under a subdirectory.
113+ getTestMain :: [FilePath] -> FilePath
114+ getTestMain = head . sortBy (compare `on` length)
115+
116+ -- Extracts the filename part of a .purs file, or if the file is in a
117+ -- subdirectory, the first part of that directory path.
118+ extractPrefix :: FilePath -> FilePath
119+ extractPrefix fp =
120+ let dir = takeDirectory fp
121+ ext = reverse ".purs"
122+ in if dir == "."
123+ then maybe fp reverse $ stripPrefix ext $ reverse fp
124+ else dir
125+
126+ -- Scans a file for @shouldFailWith directives in the comments, used to
127+ -- determine expected failures
91 getShouldFailWith :: FilePath -> IO [String]
128 getShouldFailWith :: FilePath -> IO [String]
92 getShouldFailWith = fmap extractFailWiths . readUTF8File
129 getShouldFailWith = fmap extractFailWiths . readUTF8File
93 where
130 where