git.iko.soy/rowtype-yoga/purescript-native
on golang help sign in
Multi-file test setup
commitd6ed70f735104fa486b22f9b5dca03441b6f31a0 authorGary Burgess <gary.burgess@gmail.com> dateTue 3 May 2016, 03:53 (10 years ago) parent66107e5
138 files changed+776−721
examples/failing/1733.purs−7 examples/failing/1733/Thingy.purs+4 examples/manual/failing/ArgLengthMismatch.purs → examples/failing/ArgLengthMismatch.purs+7−6 examples/failing/ConflictingExports.purs−10 examples/failing/ConflictingExports/A.purs+4 examples/failing/ConflictingExports/B.purs+4 examples/failing/ConflictingImports.purs+5−15 examples/failing/ConflictingImports/A.purs+4 examples/failing/ConflictingImports/B.purs+4 examples/failing/ConflictingImports2.purs+6−16 examples/failing/ConflictingImports2/A.purs+4 examples/failing/ConflictingImports2/B.purs+4 examples/failing/ConflictingQualifiedImports.purs+3−13 examples/failing/ConflictingQualifiedImports/A.purs+4 examples/failing/ConflictingQualifiedImports/B.purs+4 examples/failing/ConflictingQualifiedImports2.purs+2−12 examples/failing/ConflictingQualifiedImports2/A.purs+4 examples/failing/ConflictingQualifiedImports2/B.purs+4 examples/manual/failing/ExportExplicit.purs → examples/failing/ExportExplicit.purs+8−7 examples/failing/ExportExplicit1.purs+11 examples/failing/ExportExplicit1/M1.purs+3 examples/manual/failing/ExportExplicit2.purs → examples/failing/ExportExplicit2.purs+8−7 examples/failing/ExportExplicit3.purs+9 examples/failing/ExportExplicit3/M1.purs+4 examples/failing/ImportExplicit.purs+4 examples/failing/ImportExplicit/M1.purs+3 examples/failing/ImportExplicit2.purs+4 examples/failing/ImportExplicit2/M1.purs+3 examples/failing/ImportHidingModule.purs+4−10 examples/failing/ImportHidingModule/A.purs+2 examples/failing/ImportHidingModule/B.purs+3 examples/failing/ImportModule.purs+4 examples/failing/ImportModule/M2.purs+3 examples/failing/InstanceExport.purs+7−19 examples/failing/InstanceExport/InstanceExport.purs+11 examples/failing/OrphanInstance.purs+7−12 examples/failing/OrphanInstance/Class.purs+4 examples/manual/failing/OrphanTypeDecl.purs → examples/failing/OrphanTypeDecl.purs+4−3 examples/failing/OverlappingReExport.purs+3−8 examples/failing/OverlappingReExport/A.purs+2 examples/failing/OverlappingReExport/B.purs+2 examples/manual/failing/RedefinedFixity.purs → examples/failing/RedefinedFixity.purs+9−8 examples/manual/failing/RequiredHiddenType.purs → examples/failing/RequiredHiddenType.purs+9−8 examples/manual/QualifiedNames.purs−13 examples/manual/failing/ExportExplicit1.purs−14 examples/manual/failing/ExportExplicit3.purs−13 examples/manual/failing/ImportExplicit.purs−7 examples/manual/failing/ImportExplicit2.purs−7 examples/manual/failing/ImportModule.purs−7 examples/manual/passing/ExportExplicit.purs−20 examples/manual/passing/ExportExplicit2.purs−15 examples/manual/passing/Import.purs−19 examples/manual/passing/ImportExplicit.purs−14 examples/manual/passing/ImportQualified.purs−12 examples/manual/passing/Module.purs−28 examples/manual/passing/ModuleDeps.purs−17 examples/manual/passing/RedefinedFixity.purs−24 examples/manual/passing/TransitiveImport.purs−24 examples/passing/2018.purs−13 examples/passing/2018/A.purs+7 examples/passing/2018/B.purs+3 examples/passing/ClassRefSyntax.purs−5 examples/passing/ClassRefSyntax/Lib.purs+4 examples/passing/DctorOperatorAlias.purs+2−8 examples/passing/DctorOperatorAlias/List.purs+5 examples/passing/ExplicitImportReExport.purs+11−16 examples/passing/ExplicitImportReExport/Bar.purs+3 examples/passing/ExplicitImportReExport/Foo.purs+4 examples/passing/ExportExplicit.purs+9 examples/passing/ExportExplicit/M1.purs+10 examples/passing/ExportExplicit2.purs+7 examples/passing/ExportExplicit2/M1.purs+7 examples/manual/passing/ExportedInstanceDeclarations.purs → examples/passing/ExportedInstanceDeclarations.purs+44−43 examples/passing/Import.purs+5 examples/passing/Import/M1.purs+8 examples/passing/Import/M2.purs+6 examples/passing/ImportExplicit.purs+9 examples/passing/ImportExplicit/M1.purs+4 examples/passing/ImportQualified.purs+8 examples/passing/ImportQualified/M1.purs+3 examples/passing/Module.purs+6 examples/passing/Module/M1.purs+14 examples/passing/Module/M2.purs+9 examples/passing/ModuleDeps.purs+5 examples/passing/ModuleDeps/M1.purs+5 examples/passing/ModuleDeps/M2.purs+5 examples/passing/ModuleDeps/M3.purs+3 examples/passing/ModuleExport.purs+6−8 examples/passing/ModuleExport/A.purs+3 examples/passing/ModuleExportDupes.purs+1−10 examples/passing/ModuleExportDupes/A.purs+3 examples/passing/ModuleExportDupes/B.purs+3 examples/passing/ModuleExportDupes/C.purs+4 examples/passing/ModuleExportExcluded.purs+8−13 examples/passing/ModuleExportExcluded/A.purs+6 examples/passing/ModuleExportQualified.purs+7−9 examples/passing/ModuleExportQualified/A.purs+3 examples/passing/ModuleExportSelf.purs+8−12 examples/passing/ModuleExportSelf/A.purs+5 examples/passing/NonConflictingExports.purs−5 examples/passing/NonConflictingExports/A.purs+4 examples/passing/OperatorAliasElsewhere.purs−5 examples/passing/OperatorAliasElsewhere/Def.purs+4 examples/passing/PendingConflictingImports.purs+4−14 examples/passing/PendingConflictingImports/A.purs+4 examples/passing/PendingConflictingImports/B.purs+4 examples/passing/PendingConflictingImports2.purs−5 examples/passing/PendingConflictingImports2/A.purs+4 examples/passing/QualifiedNames.purs+9 examples/passing/QualifiedNames/Either.purs+5 examples/passing/ReExportQualified.purs+3−13 examples/passing/ReExportQualified/A.purs+3 examples/passing/ReExportQualified/B.purs+3 examples/passing/ReExportQualified/C.purs+4 examples/passing/RedefinedFixity.purs+5 examples/passing/RedefinedFixity/M1.purs+7 examples/passing/RedefinedFixity/M2.purs+5 examples/passing/RedefinedFixity/M3.purs+6 examples/passing/ResolvableScopeConflict.purs+8−21 examples/passing/ResolvableScopeConflict/A.purs+4 examples/passing/ResolvableScopeConflict/B.purs+7 examples/passing/ResolvableScopeConflict2.purs+9−17 examples/passing/ResolvableScopeConflict2/A.purs+7 examples/passing/ResolvableScopeConflict3.purs+4−11 examples/passing/ResolvableScopeConflict3/A.purs+4 examples/passing/ShadowedModuleName.purs+4−11 examples/passing/ShadowedModuleName/Test.purs+6 examples/manual/passing/ShadowedName.purs → examples/passing/ShadowedName.purs+10−10 examples/passing/TransitiveImport.purs+9 examples/passing/TransitiveImport/Middle.purs+3 examples/passing/TransitiveImport/Test.purs+9 examples/passing/TypeOperators.purs+6−29 examples/passing/TypeOperators/A.purs+22 examples/passing/TypeWithoutParens.purs+6−11 examples/passing/TypeWithoutParens/Lib.purs+4 examples/manual/passing/WildcardType.purs → examples/passing/WildcardType.purs+13−13 purescript.cabal+45 tests/TestCompiler.hs+61−24
examples/failing/1733.purs−7
@@ -1,13 +1,6 @@
11-- @shouldFailWith UnknownValue
2−
32module Main where
43
54import Thingy as Thing
65
76main = 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−module ArgLengthMismatch where
2−
3−import Prelude
4−
5−f x y = true
6−f = false
1+-- @shouldFailWith ArgListLengthsDiffer
2+module ArgLengthMismatch where
3+
4+import Prelude
5+
6+f x y = true
7+f = false
examples/failing/ConflictingExports.purs−10
@@ -1,14 +1,4 @@
11-- @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−
122-- Fails here because re-exporting forces any scope conflicts to be resolved
133module Main (module A, module B) where
144
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 @@
11-- @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−
122module Main where
133
14− import A
15− import B
4+import A
5+import B
166
17− -- Error due to referencing `thing` which is in scope as A.thing and B.thing
18− what :: Int
19− what = thing
7+-- Error due to referencing `thing` which is in scope as A.thing and B.thing
8+what :: Int
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 @@
11-- @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−
122module Main where
133
14− import A (thing)
15− import B (thing)
4+import A (thing)
5+import B (thing)
166
17− -- Error due to referencing `thing` which is explicitly in scope as A.thing
18− -- and B.thing
19− what :: Int
20− what = thing
7+-- Error due to referencing `thing` which is explicitly in scope as A.thing
8+-- and B.thing
9+what :: Int
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 @@
11-- @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−
122module Main where
133
14− import A as X
15− import B as X
4+import A as X
5+import B as X
166
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 @@
11-- @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−
122module Main (module X) where
133
14− import A as X
15− import B as X
4+import A 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−-- should fail as z does not exist in the module
2−module M1 (x, y, z) where
3−
4−import Prelude
5−
6−x = 1
7−y = 2
1+-- @shouldFailWith UnknownExportValue
2+-- should fail as z does not exist in the module
3+module M1 (x, y, z) where
4+
5+import Prelude
6+
7+x = 1
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−-- should fail as Y is not a data constructor for X
2−module M1 (X(Y)) where
3−
4−import Prelude
5−
6−data X = X
7−data Y = Y
1+-- @shouldFailWith UnknownExportDataConstructor
2+-- should fail as Y is not a data constructor for X
3+module M1 (X(Y)) where
4+
5+import Prelude
6+
7+data X = X
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
2−module A where
3− x = 1
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)
1+-- @shouldFailWith ImportHidingModule
2+module Main where
3+
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
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
15−
16−import InstanceExport
17−import Prelude
18−
19−test = f $ S "Test"
1+-- @shouldFailWith TransitiveExportError
2+module Test where
3+
4+import InstanceExport
5+import Prelude
6+
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
2−module Class where
3−
4− class C a where
5− op :: a -> a
6−
7−module Test where
8−
9− import Class
10−
11− instance cBoolean :: C Boolean where
12− op a = a
1+-- @shouldFailWith OrphanInstance
2+module Test where
3+
4+import Class
5+
6+instance cBoolean :: C Boolean where
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−module OrphanTypeDecl where
2−
3−fn :: Number -> Boolean
1+-- @shouldFailWith OrphanTypeDeclaration
2+module OrphanTypeDecl where
3+
4+fn :: Number -> Boolean
examples/failing/OverlappingReExport.purs+3−8
@@ -1,10 +1,5 @@
11-- @shouldFailWith DuplicateValueExport
2−module A where
3− x = true
4−
5−module B where
6− x = false
7−
82module C (module A, module M2) where
9− import A
10− import B as M2
3+
4+import A
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−module RedefinedFixity where
2−
3−import Prelude
4−
5−(!?) x y = x + y
6−
7−infix 2 !?
8−infix 2 !?
1+-- @shouldFailWith MultipleFixities
2+module RedefinedFixity where
3+
4+import Prelude
5+
6+(!?) x y = x + y
7+
8+infix 2 !?
9+infix 2 !?
examples/manual/failing/RequiredHiddenType.purs → examples/failing/RequiredHiddenType.pursrenamed+9−8
@@ -1,8 +1,9 @@
1−-- exporting `a` should fail as `A` is hidden
2−module Foo (B(..), a, b) where
3−
4−data A = A
5−data B = B
6−
7−a = A
8−b = B
1+-- @shouldFailWith TransitiveExportError
2+-- exporting `a` should fail as `A` is hidden
3+module Foo (B(..), a, b) where
4+
5+data A = A
6+data B = B
7+
8+a = A
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−
131module Main where
142
153import Prelude
@@ -22,4 +10,3 @@ main :: forall e. Eff (console :: CONSOLE | e) Unit
2210main = do
2311 let tmp = foo X
2412 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−
61module Main where
72
83 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−
71module Main where
82
93 import Prelude (Unit, bind, (==))
104 import Control.Monad.Eff (Eff)
115 import Control.Monad.Eff.Console (CONSOLE, log)
126 import Test.Assert (ASSERT, assert')
13− import Data.List (List(..), (:))
14− import Data.List as L
7+ import List (List(..), (:))
8+ import List as L
159
1610 -- unqualified
1711 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
2−module Foo where
3−
4− foo :: Int
5− foo = 3
6−
7−module Bar (module Foo) where
8−
9− import Foo
10−
11−module Baz where
12−
13− import Bar (foo)
14−
15− baz :: Int
16− baz = foo
1+-- from #1244
2+module Main where
3+
4+import Prelude
5+import Control.Monad.Eff.Console (log)
6+import Bar (foo)
7+
8+baz :: Int
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
3−-- result of `exportedDeclarations`.
4−
5−module ExportedInstanceDeclarations
6− ( Const(..)
7− , Foo
8− , foo
9− ) where
10−
11−import Prelude
12−
13−data Const a b = Const a
14−
15−class Foo a where
16− foo :: a
17−
18−data NonexportedType = NonexportedType
19−
20−class NonexportedClass a where
21− notExported :: a
22−
23−-- There are three places that a nonexported type or type class can occur,
24−-- leading an instance to count as non-exported:
25−-- * Constraints
26−-- * The type class itself
27−-- * The instance types
28−
29−-- Case 1: constraints
30−instance nonExportedFoo :: (NonexportedClass a) => Foo a where
31− foo = notExported
32−
33−-- Another instance of case 1:
34−instance nonExportedFoo2 :: (Foo NonexportedType) => Foo (a -> a) where
35− foo = id
36−
37−-- Case 2: type class
38−instance nonExportedNonexportedType :: NonexportedClass (Const Number a) where
39− notExported = Const 0
40−
41−-- Case 3: instance types
42−instance constFoo :: Foo (Const NonexportedType b) where
43− foo = Const NonexportedType
1+-- Tests that instances for non-exported classes / types do not appear in the
2+-- result of `exportedDeclarations`.
3+module ExportedInstanceDeclarations
4+ ( Const(..)
5+ , class Foo
6+ , foo
7+ ) where
8+
9+import Prelude
10+import Control.Monad.Eff.Console (log)
11+
12+data Const a b = Const a
13+
14+class Foo a where
15+ foo :: a
16+
17+data NonexportedType = NonexportedType
18+
19+class NonexportedClass a where
20+ notExported :: a
21+
22+-- There are three places that a nonexported type or type class can occur,
23+-- leading an instance to count as non-exported:
24+-- * Constraints
25+-- * The type class itself
26+-- * The instance types
27+
28+-- Case 1: constraints
29+instance nonExportedFoo :: (NonexportedClass a) => Foo a where
30+ foo = notExported
31+
32+-- Another instance of case 1:
33+instance nonExportedFoo2 :: (Foo NonexportedType) => Foo (a -> a) where
34+ foo = id
35+
36+-- Case 2: type class
37+instance nonExportedNonexportedType :: NonexportedClass (Const Int a) where
38+ notExported = Const 0
39+
40+-- Case 3: instance types
41+instance constFoo :: Foo (Const NonexportedType b) where
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−
41module Main where
5− import Control.Monad.Eff.Console (log, logShow)
6− import A
72
8− main = do
9− logShow (show 1.0)
10− log "Done"
3+import Control.Monad.Eff.Console (log, logShow)
4+import A
5+
6+main = do
7+ logShow (show 1.0)
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−
111module Main where
2+
123 import Control.Monad.Eff.Console
134 import A
145 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−
71module Main where
8− import Prelude
9− import Control.Monad.Eff.Console (log, logShow)
10− import A (foo)
112
12− otherwise = false
3+import Prelude
4+import Control.Monad.Eff.Console (log, logShow)
5+import A (foo)
6+
7+otherwise = false
138
14− main = do
15− logShow "1.0"
16− log "Done"
9+main = do
10+ logShow "1.0"
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−
41module Main where
5− import Prelude
6− import Control.Monad.Eff.Console (log, logShow)
7− import A as B
82
9− main = do
10− logShow (B.show 1.0)
11− log "Done"
3+import Prelude
4+import Control.Monad.Eff.Console (log, logShow)
5+import A as B
6+
7+main = do
8+ logShow (B.show 1.0)
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−
61module Main where
7− import Control.Monad.Eff.Console
8− import A
92
10− bar :: Foo
11− bar = true
3+import Control.Monad.Eff.Console
4+import A
5+
6+bar :: Foo
7+bar = true
128
13− main = do
14− logShow (show bar)
15− log "Done"
9+main = do
10+ logShow (show bar)
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−
61-- No failure here as the export `thing` only refers to Main.thing
72module Main (thing, main) where
83
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−
61module Main where
72
83import 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−
111module Main where
122
13− -- No error as we never force `thing` to be resolved in `Main`
14− import A
15− import B
3+-- No error as we never force `thing` to be resolved in `Main`
4+import A
5+import B
166
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−
61module Main where
72
83 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−
111module Main where
122
13− import Prelude
14− import C
3+import Prelude
4+import C
155
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−
141module Main where
152
16− import A (thing)
17− import B
3+import A (thing)
4+import B
185
19− -- 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.
21− what :: Boolean -> Int
22− what true = thing
23− what false = zing
6+-- Not an error as although we have `thing` in scope from both A and B, it is
7+-- imported explicitly from A, giving it a resolvable solution.
8+what :: Boolean -> Int
9+what true = thing
10+what false = zing
2411
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−
91module Main where
102
11− import A
3+import A
124
13− thing :: Int
14− thing = 1
5+thing :: Int
6+thing = 1
157
16− -- 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
18− what :: Boolean -> Int
19− what true = thing
20− what false = zing
8+-- Not an error as although we have `thing` in scope from both Main and A,
9+-- as the local declaration takes precedence over the implicit import
10+what :: Boolean -> Int
11+what true = thing
12+what false = zing
2113
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−
61module Main (thing, main, module A) where
72
8− import A
9−
10− thing :: Int
11− thing = 2
12−
13− main = Control.Monad.Eff.Console.log "Done"
3+import A
144
5+thing :: Int
6+thing = 2
157
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−
81module Main where
92
10− import Test
11− import Control.Monad.Eff.Console
3+import Test
4+import Control.Monad.Eff.Console
125
13− data Test = Test
6+data Test = Test
147
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
2−
3−import Prelude
4−import Control.Monad.Eff.Console
5−
6−done :: String
7−done = let str = "Not yet done" in
8− let str = "Done" in str
9−
10−main = Control.Monad.Eff.Console.log done
1+module Main where
2+
3+import Prelude
4+import Control.Monad.Eff.Console
5+
6+done :: String
7+done = let str = "Not yet done" in
8+ let str = "Done" in str
9+
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−
241module Main where
252
26− import A (type (~>), type (/\), (/\))
3+import A (type (~>), type (/\), (/\))
274
28− natty ∷ ∀ f. f ~> f
29− natty x = x
5+natty ∷ ∀ f. f ~> f
6+natty x = x
307
31− swap ∷ ∀ a b. a /\ b → b /\ a
32− swap (a /\ b) = b /\ a
8+swap ∷ ∀ a b. a /\ b → b /\ a
9+swap (a /\ b) = b /\ a
3310
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−
61module Main where
72
8− import Lib (X, Y)
3+import Lib (X, Y)
94
10− idX :: X -> X
11− idX x = x
5+idX :: X -> X
6+idX x = x
127
13− idY :: Y -> Y
14− idY y = y
8+idY :: Y -> Y
9+idY y = y
1510
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
2−
3−import Prelude
4−import Control.Monad.Eff.Console
5−
6−f1 :: (_ -> _) -> _
7−f1 g = g 1
8−
9−f2 :: _ -> _
10−f2 _ = "Done"
11−
12−main = Control.Monad.Eff.Console.log $ f1 f2
13−
1+module Main where
2+
3+import Prelude
4+import Control.Monad.Eff.Console
5+
6+f1 :: (_ -> _) -> _
7+f1 g = g 1
8+
9+f2 :: _ -> _
10+f2 _ = "Done"
11+
12+main = Control.Monad.Eff.Console.log $ f1 f2
13+
purescript.cabal+45
@@ -20,7 +20,52 @@ author: Phil Freeman <paf31@cantab.net>,
2020tested-with: GHC==7.10.3
2121
2222extra-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
2353 , 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
2469 , examples/docs/bower_components/purescript-prelude/src/*.purs
2570 , examples/docs/bower.json
2671 , examples/docs/src/*.purs
tests/TestCompiler.hs+61−24
@@ -26,8 +26,9 @@ import Prelude.Compat
2626import qualified Language.PureScript as P
2727
2828import Data.Char (isSpace)
29+import Data.Function (on)
30+import Data.List (sort, stripPrefix, intercalate, groupBy, sortBy, partition)
2931import Data.Maybe (mapMaybe)
30−import Data.List (isSuffixOf, sort, stripPrefix, intercalate)
3132import Data.Time.Clock (UTCTime())
3233
3334import qualified Data.Map as M
@@ -55,39 +56,75 @@ main = hspec spec
5556
5657spec :: Spec
5758spec = 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
6959
60+ (supportPurs, supportForeigns, passingTestCases, failingTestCases) <- runIO $ do
61+ cwd <- getCurrentDirectory
7062 let passing = cwd </> "examples" </> "passing"
71− passingTestCases <- sort . filter (".purs" `isSuffixOf`) <$> getDirectoryContents passing
72−
7363 let failing = cwd </> "examples" </> "failing"
74− failingTestCases <- sort . filter (".purs" `isSuffixOf`) <$> getDirectoryContents failing
75−
76− return (supportPurs, foreigns, passing, passingTestCases, failing, failingTestCases)
64+ let supportDir = cwd </> "tests" </> "support" </> "bower_components"
65+ let supportFiles ext = Glob.globDir1 (Glob.compile ("purescript-*/**/*." ++ ext)) supportDir
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)
7771
7872 context ("Passing examples") $ do
79− forM_ passingTestCases $ \inputFile ->
80− it ("'" <> inputFile <> "' should compile and run without error") $ do
81− assertCompiles (supportPurs ++ [passing </> inputFile]) foreigns
73+ forM_ passingTestCases $ \(testPurs, testJS) ->
74+ it ("'" <> takeFileName (getTestMain testPurs) <> "' should compile and run without error") $ do
75+ testForeigns <- loadForeigns testJS
76+ assertCompiles (supportPurs ++ testPurs) (supportForeigns <> testForeigns)
8277
8378 context ("Failing examples") $ do
84− forM_ failingTestCases $ \inputFile -> do
85− expectedFailures <- runIO $ getShouldFailWith (failing </> inputFile)
86− it ("'" <> inputFile <> "' should fail with '" <> intercalate "', '" expectedFailures <> "'") $ do
87− assertDoesNotCompile (supportPurs ++ [failing </> inputFile]) foreigns expectedFailures
79+ forM_ failingTestCases $ \(testPurs, testJS) -> do
80+ let mainPath = getTestMain testPurs
81+ expectedFailures <- runIO $ getShouldFailWith mainPath
82+ it ("'" <> takeFileName mainPath <> "' should fail with '" <> intercalate "', '" expectedFailures <> "'") $ do
83+ testForeigns <- loadForeigns testJS
84+ assertDoesNotCompile (supportPurs ++ testPurs) (supportForeigns <> testForeigns) expectedFailures
8885
8986 where
9087
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
91128 getShouldFailWith :: FilePath -> IO [String]
92129 getShouldFailWith = fmap extractFailWiths . readUTF8File
93130 where