git.iko.soy/rowtype-yoga/purescript-native
on golang help sign in
Expect 'Done' from passing tests
b87b0f7Gary Burgess
examples/passing/1335.purs+14−12
@@ -1,12 +1,14 @@
1−module Main where
1+module Main where
2−
2+
3−import Prelude
3+import Prelude
4−import Control.Monad.Eff.Console (log)
4+import Control.Monad.Eff.Console (log)
5−
5+
6−x :: forall a. a -> String
6+x :: forall a. a -> String
7−x a = y "Done"
7+x a = y "Test"
8− where
8+ where
9− y :: forall a. (Show a) => a -> String
9+ y :: forall a. (Show a) => a -> String
10− y a = show (a :: a)
10+ y a = show (a :: a)
11−
11+
12+main = do
12−main = log (x 0)
13+ log (x 0)
14+ log "Done"
examples/passing/AutoPrelude.purs+11−9
@@ -1,9 +1,11 @@
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 (log)
5−
5+
6−f x = x * 10.0
6+f x = x * 10.0
7−g y = y - 10.0
7+g y = y - 10.0
8−
8+
9+main = do
9−main = log $ show $ (f <<< g) 100.0
10+ log $ show $ (f <<< g) 100.0
11+ log "Done"
examples/passing/Collatz.purs+4−1
@@ -3,6 +3,7 @@ module Main where
3import Prelude
3import Prelude
4import Control.Monad.Eff
4import Control.Monad.Eff
5import Control.Monad.ST
5import Control.Monad.ST
6+import Control.Monad.Eff.Console (log, logShow)
6
7
7collatz :: Int -> Int
8collatz :: Int -> Int
8collatz n = runPure (runST (do
9collatz n = runPure (runST (do
@@ -15,4 +16,6 @@ collatz n = runPure (runST (do
15 pure $ m == 1
16 pure $ m == 1
16 readSTRef count))
17 readSTRef count))
17
18
19+main = do
18−main = Control.Monad.Eff.Console.logShow $ collatz 1000
20+ logShow $ collatz 1000
21+ log "Done"
examples/passing/Comparisons.purs+15−15
@@ -1,15 +1,15 @@
1−module Main where
1+module Main where
2−
2+
3−import Prelude
3+import Prelude
4−import Control.Monad.Eff
4+import Control.Monad.Eff
5−import Control.Monad.Eff.Console
5+import Control.Monad.Eff.Console
6−import Test.Assert
6+import Test.Assert
7−
7+
8−main = do
8+main = do
9− assert (1.0 < 2.0)
9+ assert (1.0 < 2.0)
10− assert (2.0 == 2.0)
10+ assert (2.0 == 2.0)
11− assert (3.0 > 1.0)
11+ assert (3.0 > 1.0)
12− assert ("a" < "b")
12+ assert ("a" < "b")
13− assert ("a" == "a")
13+ assert ("a" == "a")
14− assert ("z" > "a")
14+ assert ("z" > "a")
15− log "Done!"
15+ log "Done"
examples/passing/Console.purs+3−1
@@ -10,4 +10,6 @@ replicateM_ n act = do
10 act
10 act
11 replicateM_ (n - 1.0) act
11 replicateM_ (n - 1.0) act
12
12
13+main = do
13−main = replicateM_ 10.0 (log "Hello World!")
14+ replicateM_ 10.0 (log "Hello World!")
15+ log "Done"
examples/passing/ConstraintInference.purs+5−2
@@ -1,7 +1,10 @@
1module Main where
1module Main where
2
2
3import Prelude
3import Prelude
4+import Control.Monad.Eff.Console (log)
4
5
5−shout = Control.Monad.Eff.Console.log <<< (_ <> "!") <<< show
6+shout = log <<< (_ <> "!") <<< show
6
7
8+main = do
7−main = shout "Done"
9+ shout "Test"
10+ log "Done"
examples/passing/ContextSimplification.purs+3−1
@@ -10,4 +10,6 @@ shout = log <<< (_ <> "!") <<< show
10usesShowTwice true = shout
10usesShowTwice true = shout
11usesShowTwice false = logShow
11usesShowTwice false = logShow
12
12
13+main = do
13−main = usesShowTwice true "Done"
14+ usesShowTwice true "Test"
15+ log "Done"
examples/passing/DeepCase.purs+4−4
@@ -1,9 +1,7 @@
1module Main where
1module Main where
2
2
3import Prelude
3import Prelude
4−import Control.Monad.Eff.Console
4+import Control.Monad.Eff.Console (log, logShow)
5−import Control.Monad.Eff
6−import Control.Monad.ST
7
5
8f x y =
6f x y =
9 let
7 let
@@ -12,4 +10,6 @@ f x y =
12 x -> 1.0 + x * x
10 x -> 1.0 + x * x
13 in g + x + y
11 in g + x + y
14
12
13+main = do
15−main = logShow $ f 1.0 10.0
14+ logShow $ f 1.0 10.0
15+ log "Done"
examples/passing/Deriving.purs+5−2
@@ -1,6 +1,7 @@
1module Main where
1module Main where
2
2
3import Prelude
3import Prelude
4+import Control.Monad.Eff.Console (log)
4import Test.Assert
5import Test.Assert
5
6
6data V
7data V
@@ -27,5 +28,7 @@ main = do
27 assert $ X 0 < X 1
28 assert $ X 0 < X 1
28 assert $ X 0 < Y "Foo"
29 assert $ X 0 < Y "Foo"
29 assert $ Y "Bar" < Y "Baz"
30 assert $ Y "Bar" < Y "Baz"
30− assert $ z == z where
31+ assert $ z == z
32+ log "Done"
33+ where
31− z = Z { left: X 0, right: Y "Foo" }
34+ z = Z { left: X 0, right: Y "Foo" }
examples/passing/Eff.purs+4−3
@@ -3,7 +3,7 @@ module Main where
3import Prelude
3import Prelude
4import Control.Monad.Eff
4import Control.Monad.Eff
5import Control.Monad.ST
5import Control.Monad.ST
6−import Control.Monad.Eff.Console
6+import Control.Monad.Eff.Console (log, logShow)
7
7
8test1 = do
8test1 = do
9 log "Line 1"
9 log "Line 1"
@@ -21,5 +21,6 @@ test3 = pureST (do
21
21
22main = do
22main = do
23 test1
23 test1
24− Control.Monad.Eff.Console.logShow test2
24+ logShow test2
25− Control.Monad.Eff.Console.logShow test3
25+ logShow test3
26+ log "Done"
examples/passing/EqOrd.purs+4−1
@@ -1,6 +1,7 @@
1module Main where
1module Main where
2
2
3import Prelude
3import Prelude
4+import Control.Monad.Eff.Console (log, logShow)
4
5
5data Pair a b = Pair a b
6data Pair a b = Pair a b
6
7
@@ -12,4 +13,6 @@ instance ordPair :: (Ord a, Ord b) => Ord (Pair a b) where
12instance eqPair :: (Eq a, Eq b) => Eq (Pair a b) where
13instance eqPair :: (Eq a, Eq b) => Eq (Pair a b) where
13 eq (Pair a1 b1) (Pair a2 b2) = a1 == a2 && b1 == b2
14 eq (Pair a1 b1) (Pair a2 b2) = a1 == a2 && b1 == b2
14
15
16+main = do
15−main = Control.Monad.Eff.Console.logShow $ Pair 1.0 2.0 == Pair 1.0 2.0
17+ logShow $ Pair 1.0 2.0 == Pair 1.0 2.0
18+ log "Done"
examples/passing/ExtendedInfixOperators.purs+5−2
@@ -1,9 +1,11 @@
1module Main where
1module Main where
2
2
3import Prelude
3import Prelude
4+import Control.Monad.Eff.Console (log, logShow)
5+import Data.Function (on)
4
6
5comparing :: forall a b. (Ord b) => (a -> b) -> a -> a -> Ordering
7comparing :: forall a b. (Ord b) => (a -> b) -> a -> a -> Ordering
6−comparing f = compare `Data.Function.on` f
8+comparing f = compare `on` f
7
9
8null [] = true
10null [] = true
9null _ = false
11null _ = false
@@ -11,4 +13,5 @@ null _ = false
11test = [1.0, 2.0, 3.0] `comparing null` [4.0, 5.0, 6.0]
13test = [1.0, 2.0, 3.0] `comparing null` [4.0, 5.0, 6.0]
12
14
13main = do
15main = do
14− Control.Monad.Eff.Console.logShow test
16+ logShow test
17+ log "Done"
examples/passing/Fib.purs+14−11
@@ -1,15 +1,18 @@
1module Main where
1module Main where
2
2
3import Prelude
3import Prelude
4−import Control.Monad.Eff
4+import Control.Monad.Eff (whileE)
5+import Control.Monad.Eff.Console (log, logShow)
5−import Control.Monad.ST
6+import Control.Monad.ST (runST, newSTRef, readSTRef, writeSTRef)
6
7
8+main = do
7−main = runST (do
9+ runST do
8− n1 <- newSTRef 1.0
10+ n1 <- newSTRef 1.0
9− n2 <- newSTRef 1.0
11+ n2 <- newSTRef 1.0
10− whileE ((>) 1000.0 <$> readSTRef n1) $ do
12+ whileE ((>) 1000.0 <$> readSTRef n1) $ do
11− n1' <- readSTRef n1
13+ n1' <- readSTRef n1
12− n2' <- readSTRef n2
14+ n2' <- readSTRef n2
13− writeSTRef n2 $ n1' + n2'
15+ writeSTRef n2 $ n1' + n2'
14− writeSTRef n1 n2'
16+ writeSTRef n1 n2'
15− Control.Monad.Eff.Console.logShow n2')
17+ logShow n2'
18+ log "Done"
examples/passing/FieldConsPuns.purs+13−10
@@ -1,10 +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 (log, logShow)
5−
5+
6−greet { greeting, name } = log $ greeting <> ", " <> name <> "."
6+greet { greeting, name } = log $ greeting <> ", " <> name <> "."
7−
7+
8+main = do
8−main = greet { greeting, name} where
9+ greet { greeting, name }
10+ log "Done"
11+ where
9− greeting = "Hello"
12+ greeting = "Hello"
10− name = "World"
13+ name = "World"
examples/passing/FieldPuns.purs+10−8
@@ -1,8 +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−greet { greeting, name } = log $ greeting <> ", " <> name <> "."
6+greet { greeting, name } = log $ greeting <> ", " <> name <> "."
7−
7+
8+main = do
8−main = greet { greeting: "Hello", name: "World" }
9+ greet { greeting: "Hello", name: "World" }
10+ log "Done"
examples/passing/FinalTagless.purs+4−1
@@ -1,6 +1,7 @@
1module Main where
1module Main where
2
2
3import Prelude hiding (add)
3import Prelude hiding (add)
4+import Control.Monad.Eff.Console (log, logShow)
4
5
5class E e where
6class E e where
6 num :: Number -> e Number
7 num :: Number -> e Number
@@ -19,4 +20,6 @@ runId (Id a) = a
19three :: Expr Number
20three :: Expr Number
20three = add (num 1.0) (num 2.0)
21three = add (num 1.0) (num 2.0)
21
22
23+main = do
22−main = Control.Monad.Eff.Console.logShow $ runId three
24+ logShow $ runId three
25+ log "Done"
examples/passing/Generalization1.purs+2−1
@@ -1,10 +1,11 @@
1module Main where
1module Main where
2
2
3import Prelude
3import Prelude
4−import Control.Monad.Eff.Console (logShow)
4+import Control.Monad.Eff.Console (logShow, log)
5
5
6main = do
6main = do
7 logShow (sum 1.0 2.0)
7 logShow (sum 1.0 2.0)
8 logShow (sum 1 2)
8 logShow (sum 1 2)
9+ log "Done"
9
10
10sum x y = x + y
11sum x y = x + y
examples/passing/ImportHiding.purs+1
@@ -16,3 +16,4 @@ data Unit = X | Y
16
16
17main = do
17main = do
18 logShow show
18 logShow show
19+ log "Done"
examples/passing/InferRecFunWithConstrainedArgument.purs+4−1
@@ -1,8 +1,11 @@
1module Main where
1module Main where
2
2
3import Prelude
3import Prelude
4+import Control.Monad.Eff.Console (log, logShow)
4
5
5test 100.0 = 100.0
6test 100.0 = 100.0
6test n = test(1.0 + n)
7test n = test(1.0 + n)
7
8
9+main = do
8−main = Control.Monad.Eff.Console.logShow $ test 0.0
10+ logShow $ test 0.0
11+ log "Done"
examples/passing/Let.purs+9−7
@@ -2,6 +2,7 @@ module Main where
2
2
3import Prelude
3import Prelude
4import Control.Monad.Eff
4import Control.Monad.Eff
5+import Control.Monad.Eff.Console (log, logShow)
5import Control.Monad.ST
6import Control.Monad.ST
6
7
7test1 x = let
8test1 x = let
@@ -44,10 +45,11 @@ test10 _ =
44 in f 10.0
45 in f 10.0
45
46
46main = do
47main = do
47− Control.Monad.Eff.Console.logShow (test1 1.0)
48+ logShow (test1 1.0)
48− Control.Monad.Eff.Console.logShow (test2 1.0 2.0)
49+ logShow (test2 1.0 2.0)
49− Control.Monad.Eff.Console.logShow test3
50+ logShow test3
50− Control.Monad.Eff.Console.logShow test4
51+ logShow test4
51− Control.Monad.Eff.Console.logShow test5
52+ logShow test5
52− Control.Monad.Eff.Console.logShow test7
53+ logShow test7
53− Control.Monad.Eff.Console.logShow (test8 100.0)
54+ logShow (test8 100.0)
55+ log "Done"
examples/passing/Let2.purs+4−1
@@ -1,6 +1,7 @@
1module Main where
1module Main where
2
2
3import Prelude
3import Prelude
4+import Control.Monad.Eff.Console (log, logShow)
4
5
5test =
6test =
6 let f :: Number -> Boolean
7 let f :: Number -> Boolean
@@ -14,4 +15,6 @@ test =
14 x = f 1.0
15 x = f 1.0
15 in not x
16 in not x
16
17
18+main = do
17−main = Control.Monad.Eff.Console.logShow test
19+ logShow test
20+ log "Done"
examples/passing/ModuleExport.purs+2−1
@@ -2,8 +2,9 @@ module A (module Prelude) where
2 import Prelude
2 import Prelude
3
3
4module Main where
4module Main where
5− import Control.Monad.Eff.Console
5+ import Control.Monad.Eff.Console (log, logShow)
6 import A
6 import A
7
7
8 main = do
8 main = do
9 logShow (show 1.0)
9 logShow (show 1.0)
10+ log "Done"
examples/passing/ModuleExportDupes.purs+1
@@ -17,3 +17,4 @@ module Main where
17
17
18 main = do
18 main = do
19 logShow (show 1.0)
19 logShow (show 1.0)
20+ log "Done"
examples/passing/ModuleExportExcluded.purs+3−1
@@ -5,10 +5,12 @@ module A (module Prelude, foo) where
5 foo _ = 0.0
5 foo _ = 0.0
6
6
7module Main where
7module Main where
8+ import Prelude
8− import Control.Monad.Eff.Console
9+ import Control.Monad.Eff.Console (log, logShow)
9 import A (foo)
10 import A (foo)
10
11
11 otherwise = false
12 otherwise = false
12
13
13 main = do
14 main = do
14 logShow "1.0"
15 logShow "1.0"
16+ log "Done"
examples/passing/ModuleExportQualified.purs+3−1
@@ -2,8 +2,10 @@ module A (module Prelude) where
2 import Prelude
2 import Prelude
3
3
4module Main where
4module Main where
5+ import Prelude
5− import Control.Monad.Eff.Console
6+ import Control.Monad.Eff.Console (log, logShow)
6 import A as B
7 import A as B
7
8
8 main = do
9 main = do
9 logShow (B.show 1.0)
10 logShow (B.show 1.0)
11+ log "Done"
examples/passing/ModuleExportSelf.purs+1
@@ -12,3 +12,4 @@ module Main where
12
12
13 main = do
13 main = do
14 logShow (show bar)
14 logShow (show bar)
15+ log "Done"
examples/passing/MonadState.purs+3−1
@@ -58,4 +58,6 @@ modify f =
58 same :: forall a. (a -> a) -> (a -> a)
58 same :: forall a. (a -> a) -> (a -> a)
59 same = id
59 same = id
60
60
61+main = do
61−main = logShow $ runState 0 (modify (_ + 1))
62+ logShow $ runState 0 (modify (_ + 1))
63+ log "Done"
examples/passing/MultiArgFunctions.purs+1−1
@@ -24,4 +24,4 @@ main = do
24 runFn9 (mkFn9 $ \a b c d e f g h i -> log $ show [a, b, c, d, e, f, g, h, i]) 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0
24 runFn9 (mkFn9 $ \a b c d e f g h i -> log $ show [a, b, c, d, e, f, g, h, i]) 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0
25 runFn10 (mkFn10 $ \a b c d e f g h i j-> log $ show [a, b, c, d, e, f, g, h, i, j]) 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0
25 runFn10 (mkFn10 $ \a b c d e f g h i j-> log $ show [a, b, c, d, e, f, g, h, i, j]) 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0
26 logShow $ runFn2 g 0.0 0.0
26 logShow $ runFn2 g 0.0 0.0
27− log "Done!"
27+ log "Done"
examples/passing/NestedTypeSynonyms.purs+2−1
@@ -1,6 +1,7 @@
1module Main where
1module Main where
2
2
3import Prelude
3import Prelude
4+import Control.Monad.Eff.Console (log)
4
5
5type X = String
6type X = String
6type Y = X -> X
7type Y = X -> X
@@ -8,4 +9,4 @@ type Y = X -> X
8fn :: Y
9fn :: Y
9fn a = a
10fn a = a
10
11
11−main = Control.Monad.Eff.Console.logShow (fn "Done")
12+main = log (fn "Done")
examples/passing/ObjectGetter.purs+5−4
@@ -1,13 +1,14 @@
1module Main where
1module Main where
2
2
3import Prelude
3import Prelude
4+import Control.Monad.Eff.Console (log, logShow)
4
5
5getX = _.x
6getX = _.x
6
7
7point = { x: 1.0, y: 0.0 }
8point = { x: 1.0, y: 0.0 }
8
9
9main = do
10main = do
10− Control.Monad.Eff.Console.logShow $ getX point
11+ logShow $ getX point
11− Control.Monad.Eff.Console.log $ _." 123 string Prop Name " { " 123 string Prop Name ": "OK" }
12+ log $ _." 123 string Prop Name " { " 123 string Prop Name ": "OK" }
12− Control.Monad.Eff.Console.log $ (_.x >>> _.y) { x: { y: "Nested" } }
13+ log $ (_.x >>> _.y) { x: { y: "Nested" } }
13− Control.Monad.Eff.Console.log $ _.value { value: "Done!" }
14+ log $ _.value { value: "Done" }
examples/passing/ObjectUpdate.purs+23−20
@@ -1,20 +1,23 @@
1−module Main where
1+module Main where
2−
2+
3−import Prelude
3+import Prelude
4−
4+import Control.Monad.Eff.Console (log)
5+
5−update1 = \o -> o { foo = "Foo" }
6+update1 = \o -> o { foo = "Foo" }
6−
7+
7−update2 :: forall r. { foo :: String | r } -> { foo :: String | r }
8+update2 :: forall r. { foo :: String | r } -> { foo :: String | r }
8−update2 = \o -> o { foo = "Foo" }
9+update2 = \o -> o { foo = "Foo" }
9−
10+
10−replace = \o -> case o of
11+replace = \o -> case o of
11− { foo = "Foo" } -> o { foo = "Bar" }
12+ { foo = "Foo" } -> o { foo = "Bar" }
12− { foo = "Bar" } -> o { bar = "Baz" }
13+ { foo = "Bar" } -> o { bar = "Baz" }
13− o -> o
14+ o -> o
14−
15+
15−polyUpdate :: forall a r. { foo :: a | r } -> { foo :: String | r }
16+polyUpdate :: forall a r. { foo :: a | r } -> { foo :: String | r }
16−polyUpdate = \o -> o { foo = "Foo" }
17+polyUpdate = \o -> o { foo = "Foo" }
17−
18+
18−inferPolyUpdate = \o -> o { foo = "Foo" }
19+inferPolyUpdate = \o -> o { foo = "Foo" }
19−
20+
21+main = do
20−main = Control.Monad.Eff.Console.log ((update1 {foo: ""}).foo)
22+ log ((update1 {foo: ""}).foo)
23+ log "Done"
examples/passing/ObjectUpdater.purs+2
@@ -22,3 +22,5 @@ main = do
22
22
23 let record2 = (_ { x = _ }) { x: 0.0 } 10.0
23 let record2 = (_ { x = _ }) { x: 0.0 } 10.0
24 assert $ record2.x == 10.0
24 assert $ record2.x == 10.0
25+
26+ log "Done"
examples/passing/ObjectWildcards.purs+1−1
@@ -17,4 +17,4 @@ main = do
17 point <- { x: _, y: x } <$> pure 2.0
17 point <- { x: _, y: x } <$> pure 2.0
18 assert $ point.x == 2.0
18 assert $ point.x == 2.0
19 assert $ point.y == 1.0
19 assert $ point.y == 1.0
20− log (mkRecord 1.0 "Done!").bar
20+ log (mkRecord 1.0 "Done").bar
examples/passing/OperatorAssociativity.purs+25−25
@@ -1,25 +1,25 @@
1−module Main where
1+module Main where
2−
2+
3−import Prelude
3+import Prelude
4−import Control.Monad.Eff
4+import Control.Monad.Eff
5−import Control.Monad.Eff.Console
5+import Control.Monad.Eff.Console
6−import Test.Assert
6+import Test.Assert
7−
7+
8−bug :: Number -> Number -> Number
8+bug :: Number -> Number -> Number
9−bug a b = 0.0 - (a - b)
9+bug a b = 0.0 - (a - b)
10−
10+
11−main = do
11+main = do
12− assert (bug 0.0 2.0 == 2.0)
12+ assert (bug 0.0 2.0 == 2.0)
13− assert (0.0 - (0.0 - 2.0) == 2.0)
13+ assert (0.0 - (0.0 - 2.0) == 2.0)
14− assert (0.0 - (0.0 + 2.0) == -2.0)
14+ assert (0.0 - (0.0 + 2.0) == -2.0)
15− assert (6.0 / (3.0 * 2.0) == 1.0)
15+ assert (6.0 / (3.0 * 2.0) == 1.0)
16− assert ((6.0 / 3.0) * 2.0 == 4.0)
16+ assert ((6.0 / 3.0) * 2.0 == 4.0)
17− assert (not (1.0 < 0.0) == true)
17+ assert (not (1.0 < 0.0) == true)
18− assert (not ((negate 1.0) < 0.0) == false)
18+ assert (not ((negate 1.0) < 0.0) == false)
19− assert (negate (1.0 + 10.0) == -11.0)
19+ assert (negate (1.0 + 10.0) == -11.0)
20− assert (2.0 * 3.0 / 4.0 == 1.5)
20+ assert (2.0 * 3.0 / 4.0 == 1.5)
21− assert (1.0 * 2.0 * 3.0 * 4.0 * 5.0 / 6.0 == 20.0)
21+ assert (1.0 * 2.0 * 3.0 * 4.0 * 5.0 / 6.0 == 20.0)
22− assert (1.0 + 10.0 - 5.0 == 6.0)
22+ assert (1.0 + 10.0 - 5.0 == 6.0)
23− assert (1.0 + 10.0 * 5.0 == 51.0)
23+ assert (1.0 + 10.0 * 5.0 == 51.0)
24− assert (10.0 * 5.0 - 1.0 == 49.0)
24+ assert (10.0 * 5.0 - 1.0 == 49.0)
25− log "Success!"
25+ log "Done"
examples/passing/OperatorInlining.purs+3−1
@@ -1,7 +1,7 @@
1module Main where
1module Main where
2
2
3import Prelude
3import Prelude
4−import Control.Monad.Eff.Console
4+import Control.Monad.Eff.Console (logShow, log)
5
5
6main = do
6main = do
7
7
@@ -44,3 +44,5 @@ main = do
44
44
45 -- complementedLatticeBoolean
45 -- complementedLatticeBoolean
46 logShow (not true)
46 logShow (not true)
47+
48+ log "Done"
examples/passing/OperatorSections.purs+2−1
@@ -1,6 +1,7 @@
1module Main where
1module Main where
2
2
3import Prelude
3import Prelude
4+import Control.Monad.Eff.Console (log)
4import Test.Assert
5import Test.Assert
5
6
6main = do
7main = do
@@ -14,4 +15,4 @@ main = do
14 let (//) x y = x.x / y.x
15 let (//) x y = x.x / y.x
15 assert $ (_ // foo { x = 4.0 }) { x: 4.0 } == 1.0
16 assert $ (_ // foo { x = 4.0 }) { x: 4.0 } == 1.0
16 assert $ (foo { x = 4.0 } // _) { x: 4.0 } == 1.0
17 assert $ (foo { x = 4.0 } // _) { x: 4.0 } == 1.0
17− Control.Monad.Eff.Console.log "Done!"
18+ log "Done"
examples/passing/OptionalQualified.purs+1−1
@@ -8,5 +8,5 @@ import Control.Monad.Eff.Console as Console
8bind = P.bind
8bind = P.bind
9
9
10main = do
10main = do
11− message <- P.pure "success!"
11+ message <- P.pure "Done"
12 Console.log message
12 Console.log message
examples/passing/OverlappingInstances.purs+17−13
@@ -1,13 +1,17 @@
1−module Main where
1+module Main where
2−
2+
3−import Prelude
3+import Prelude
4−
4+import Control.Monad.Eff.Console (log)
5+import Test.Assert (assert)
6+
5−data A = A
7+data A = A
6−
8+
7−instance showA1 :: Show A where
9+instance showA1 :: Show A where
8− show A = "Instance 1"
10+ show A = "Instance 1"
9−
11+
10−instance showA2 :: Show A where
12+instance showA2 :: Show A where
11− show A = "Instance 2"
13+ show A = "Instance 2"
12−
14+
15+main = do
13−main = Test.Assert.assert $ show A == "Instance 1"
16+ assert $ show A == "Instance 1"
17+ log "Done"
examples/passing/OverlappingInstances2.purs+27−23
@@ -1,23 +1,27 @@
1−module Main where
1+module Main where
2−
2+
3−import Prelude
3+import Prelude
4−
4+import Control.Monad.Eff.Console (log)
5+import Test.Assert (assert)
6+
5−data A = A | B
7+data A = A | B
6−
8+
7−instance eqA1 :: Eq A where
9+instance eqA1 :: Eq A where
8− eq A A = true
10+ eq A A = true
9− eq B B = true
11+ eq B B = true
10− eq _ _ = false
12+ eq _ _ = false
11−
13+
12−instance eqA2 :: Eq A where
14+instance eqA2 :: Eq A where
13− eq _ _ = true
15+ eq _ _ = true
14−
16+
15−instance ordA :: Ord A where
17+instance ordA :: Ord A where
16− compare A B = LT
18+ compare A B = LT
17− compare B A = GT
19+ compare B A = GT
18− compare _ _ = EQ
20+ compare _ _ = EQ
19−
21+
20−test :: forall a. (Ord a) => a -> a -> String
22+test :: forall a. (Ord a) => a -> a -> String
21−test x y = show $ x == y
23+test x y = show $ x == y
22−
24+
25+main = do
23−main = Test.Assert.assert $ test A B == "false"
26+ assert $ test A B == "false"
27+ log "Done"
examples/passing/OverlappingInstances3.purs+20−16
@@ -1,16 +1,20 @@
1−module Main where
1+module Main where
2−
2+
3−import Prelude
3+import Prelude
4−
4+import Control.Monad.Eff.Console (log)
5+import Test.Assert (assert)
6+
5−class Foo a
7+class Foo a
6−
8+
7−instance foo1 :: Foo Number
9+instance foo1 :: Foo Number
8−
10+
9−instance foo2 :: Foo Number
11+instance foo2 :: Foo Number
10−
12+
11−test :: forall a. (Foo a) => a -> a
13+test :: forall a. (Foo a) => a -> a
12−test a = a
14+test a = a
13−
15+
14−test1 = test 0.0
16+test1 = test 0.0
15−
17+
18+main = do
16−main = Test.Assert.assert (test1 == 0.0)
19+ assert (test1 == 0.0)
20+ log "Done"
examples/passing/PartialFunction.purs+13−10
@@ -1,10 +1,13 @@
1−module Main where
1+module Main where
2−
2+
3−import Prelude
3+import Prelude
4+import Control.Monad.Eff.Console (log)
4−import Test.Assert
5+import Test.Assert (assertThrows)
5−
6+
6−fn :: Number -> Number
7+fn :: Number -> Number
7−fn 0.0 = 0.0
8+fn 0.0 = 0.0
8−fn 1.0 = 2.0
9+fn 1.0 = 2.0
9−
10+
11+main = do
10−main = assertThrows $ \_ -> fn 2.0
12+ assertThrows $ \_ -> fn 2.0
13+ log "Done"
examples/passing/QualifiedQualifiedImports.purs+1−1
@@ -3,4 +3,4 @@ module Main where
3-- qualified import with qualified imported names
3-- qualified import with qualified imported names
4import Control.Monad.Eff.Console (log) as Console
4import Control.Monad.Eff.Console (log) as Console
5
5
6−main = Console.log "Success!"
6+main = Console.log "Done"
examples/passing/Rank2Data.purs+30−29
@@ -1,29 +1,30 @@
1−module Main where
1+module Main where
2−
2+
3−import Prelude hiding (add)
3+import Prelude hiding (add)
4−
4+import Control.Monad.Eff.Console (log)
5+
5−data Id = Id forall a. a -> a
6+data Id = Id forall a. a -> a
6−
7+
7−runId = \id a -> case id of
8+runId = \id a -> case id of
8− Id f -> f a
9+ Id f -> f a
9−
10+
10−data Nat = Nat forall r. r -> (r -> r) -> r
11+data Nat = Nat forall r. r -> (r -> r) -> r
11−
12+
12−runNat = \nat -> case nat of
13+runNat = \nat -> case nat of
13− Nat f -> f 0.0 (\n -> n + 1.0)
14+ Nat f -> f 0.0 (\n -> n + 1.0)
14−
15+
15−zero' = Nat (\zero' _ -> zero')
16+zero' = Nat (\zero' _ -> zero')
16−
17+
17−succ = \n -> case n of
18+succ = \n -> case n of
18− Nat f -> Nat (\zero' succ -> succ (f zero' succ))
19+ Nat f -> Nat (\zero' succ -> succ (f zero' succ))
19−
20+
20−add = \n m -> case n of
21+add = \n m -> case n of
21− Nat f -> case m of
22+ Nat f -> case m of
22− Nat g -> Nat (\zero' succ -> g (f zero' succ) succ)
23+ Nat g -> Nat (\zero' succ -> g (f zero' succ) succ)
23−
24+
24−one' = succ zero'
25+one' = succ zero'
25−two = succ zero'
26+two = succ zero'
26−four = add two two
27+four = add two two
27−fourNumber = runNat four
28+fourNumber = runNat four
28−
29+
29−main = Control.Monad.Eff.Console.log "Done'"
30+main = log "Done"
examples/passing/Rank2TypeSynonym.purs+3−2
@@ -1,7 +1,7 @@
1module Main where
1module Main where
2
2
3import Prelude
3import Prelude
4−import Control.Monad.Eff
4+import Control.Monad.Eff.Console (log, logShow)
5
5
6type Foo a = forall f. (Monad f) => f a
6type Foo a = forall f. (Monad f) => f a
7
7
@@ -13,4 +13,5 @@ bar = foo 3.0
13
13
14main = do
14main = do
15 x <- bar
15 x <- bar
16− Control.Monad.Eff.Console.logShow x
16+ logShow x
17+ log "Done"
examples/passing/RebindableSyntax.purs+41−39
@@ -1,39 +1,41 @@
1−module Main where
1+module Main where
2−
2+
3−import Prelude
3+import Prelude
4−
4+import Control.Monad.Eff.Console (log)
5+
5−example1 :: String
6+example1 :: String
6−example1 = do
7+example1 = do
7− "Do"
8+ "Do"
8− " notation"
9+ " notation"
9− " for"
10+ " for"
10− " Semigroup"
11+ " Semigroup"
11− where
12+ where
12− bind x f = x <> f unit
13+ bind x f = x <> f unit
13−
14+
14−(*>) :: forall f a b. (Apply f) => f a -> f b -> f b
15+(*>) :: forall f a b. (Apply f) => f a -> f b -> f b
15−(*>) fa fb = const id <$> fa <*> fb
16+(*>) fa fb = const id <$> fa <*> fb
16−
17+
17−newtype Const a b = Const a
18+newtype Const a b = Const a
18−
19+
19−runConst :: forall a b. Const a b -> a
20+runConst :: forall a b. Const a b -> a
20−runConst (Const a) = a
21+runConst (Const a) = a
21−
22+
22−instance functorConst :: Functor (Const a) where
23+instance functorConst :: Functor (Const a) where
23− map _ (Const a) = Const a
24+ map _ (Const a) = Const a
24−
25+
25−instance applyConst :: (Semigroup a) => Apply (Const a) where
26+instance applyConst :: (Semigroup a) => Apply (Const a) where
26− apply (Const a1) (Const a2) = Const (a1 <> a2)
27+ apply (Const a1) (Const a2) = Const (a1 <> a2)
27−
28+
28−example2 :: Const String Unit
29+example2 :: Const String Unit
29−example2 = do
30+example2 = do
30− Const "Do"
31+ Const "Do"
31− Const " notation"
32+ Const " notation"
32− Const " for"
33+ Const " for"
33− Const " Apply"
34+ Const " Apply"
34− where
35+ where
35− bind x f = x *> f unit
36+ bind x f = x *> f unit
36−
37+
37−main = do
38+main = do
38− Control.Monad.Eff.Console.log example1
39+ log example1
39− Control.Monad.Eff.Console.log $ runConst example2
40+ log $ runConst example2
41+ log "Done"
examples/passing/RuntimeScopeIssue.purs+4−1
@@ -1,6 +1,7 @@
1module Main where
1module Main where
2
2
3import Prelude
3import Prelude
4+import Control.Monad.Eff.Console (log, logShow)
4
5
5class A a where
6class A a where
6 a :: a -> Boolean
7 a :: a -> Boolean
@@ -16,4 +17,6 @@ instance bNumber :: B Number where
16 b 0.0 = false
17 b 0.0 = false
17 b n = a (n - 1.0)
18 b n = a (n - 1.0)
18
19
20+main = do
19−main = Control.Monad.Eff.Console.logShow $ a 10.0
21+ logShow $ a 10.0
22+ log "Done"
examples/passing/ShadowedModuleName.purs+1−1
@@ -12,4 +12,4 @@ module Main where
12
12
13 data Test = Test
13 data Test = Test
14
14
15− main = log (runZ (Z "done"))
15+ main = log (runZ (Z "Done"))
examples/passing/ShadowedTCO.purs+21−18
@@ -1,18 +1,21 @@
1−module Main where
1+module Main where
2−
2+
3−import Prelude hiding (add)
3+import Prelude hiding (add)
4−
4+import Control.Monad.Eff.Console (log)
5+
5−runNat f = f 0.0 (\n -> n + 1.0)
6+runNat f = f 0.0 (\n -> n + 1.0)
6−
7+
7−zero' z _ = z
8+zero' z _ = z
8−
9+
9−succ f zero' succ = succ (f zero' succ)
10+succ f zero' succ = succ (f zero' succ)
10−
11+
11−add f g zero' succ = g (f zero' succ) succ
12+add f g zero' succ = g (f zero' succ) succ
12−
13+
13−one' = succ zero'
14+one' = succ zero'
14−two = succ one'
15+two = succ one'
15−four = add two two
16+four = add two two
16−fourNumber = runNat four
17+fourNumber = runNat four
17−
18+
19+main = do
18−main = Control.Monad.Eff.Console.log $ show fourNumber
20+ log $ show fourNumber
21+ log "Done"
examples/passing/ShadowedTCOLet.purs+12−9
@@ -1,9 +1,12 @@
1−module Main where
1+module Main where
2−
2+
3−import Prelude
3+import Prelude
4−
5−f x y z =
6− let f 1.0 2.0 3.0 = 1.0
7− in f x z y
8−
9−main = Control.Monad.Eff.Console.log $ show $ f 1.0 3.0 2.0
4+import Control.Monad.Eff.Console (log)
5+
6+f x y z =
7+ let f 1.0 2.0 3.0 = 1.0
8+ in f x z y
9+
10+main = do
11+ log $ show $ f 1.0 3.0 2.0
12+ log "Done"
examples/passing/StringEscapes.purs+17−15
@@ -1,15 +1,17 @@
1−module Main where
1+module Main where
2−
2+
3−import Prelude ((==), bind)
3+import Prelude ((==), bind)
4−import Test.Assert (assert)
4+import Test.Assert (assert)
5−
5+import Control.Monad.Eff.Console (log)
6+
6−singleCharacter = "\0\b\t\n\v\f\r\"\\" == "\x0\x8\x9\xA\xB\xC\xD\x22\x5C"
7+singleCharacter = "\0\b\t\n\v\f\r\"\\" == "\x0\x8\x9\xA\xB\xC\xD\x22\x5C"
7−hex = "\x1D306\x2603\x3C6\xE0\x0" == "𝌆☃φà\0"
8+hex = "\x1D306\x2603\x3C6\xE0\x0" == "𝌆☃φà\0"
8−decimal = "\119558\9731\966\224\0" == "𝌆☃φà\0"
9+decimal = "\119558\9731\966\224\0" == "𝌆☃φà\0"
9−surrogatePair = "\xD834\xDF06" == "\x1D306"
10+surrogatePair = "\xD834\xDF06" == "\x1D306"
10−
11+
11−main = do
12+main = do
12− assert singleCharacter
13+ assert singleCharacter
13− assert hex
14+ assert hex
14− assert decimal
15+ assert decimal
15− assert surrogatePair
16+ assert surrogatePair
17+ log "Done"
examples/passing/Superclasses1.purs+4−1
@@ -1,6 +1,7 @@
1module Main where
1module Main where
2
2
3import Prelude
3import Prelude
4+import Control.Monad.Eff.Console (log, logShow)
4
5
5class Su a where
6class Su a where
6 su :: a -> a
7 su :: a -> a
@@ -17,4 +18,6 @@ instance clNumber :: Cl Number where
17test :: forall a. (Cl a) => a -> a
18test :: forall a. (Cl a) => a -> a
18test a = su (cl a a)
19test a = su (cl a a)
19
20
21+main = do
20−main = Control.Monad.Eff.Console.logShow $ test 10.0
22+ logShow $ test 10.0
23+ log "Done"
examples/passing/TCO.purs+2−2
@@ -1,7 +1,7 @@
1module Main where
1module Main where
2
2
3import Prelude
3import Prelude
4−import Control.Monad.Eff.Console (logShow)
4+import Control.Monad.Eff.Console (log, logShow)
5
5
6main = do
6main = do
7 let f x = x + 1
7 let f x = x + 1
@@ -11,10 +11,10 @@ main = do
11 logShow (applyN 2 f v)
11 logShow (applyN 2 f v)
12 logShow (applyN 3 f v)
12 logShow (applyN 3 f v)
13 logShow (applyN 4 f v)
13 logShow (applyN 4 f v)
14+ log "Done"
14
15
15applyN :: forall a. Int -> (a -> a) -> a -> a
16applyN :: forall a. Int -> (a -> a) -> a -> a
16applyN = go id
17applyN = go id
17 where
18 where
18 go f n _ | n <= 0 = f
19 go f n _ | n <= 0 = f
19 go f n g = go (f >>> g) (n - 1) g
20 go f n g = go (f >>> g) (n - 1) g
20−
examples/passing/TailCall.purs+4−1
@@ -1,6 +1,7 @@
1module Main where
1module Main where
2
2
3import Prelude
3import Prelude
4+import Control.Monad.Eff.Console (log, logShow)
4
5
5data L a = C a (L a) | N
6data L a = C a (L a) | N
6
7
@@ -14,4 +15,6 @@ loop x = loop (x + 1.0)
14notATailCall = \x ->
15notATailCall = \x ->
15 (\notATailCall -> notATailCall x) (\x -> x)
16 (\notATailCall -> notATailCall x) (\x -> x)
16
17
18+main = do
17−main = Control.Monad.Eff.Console.logShow (test 0.0 (1.0 `C` (2.0 `C` (3.0 `C` N))))
19+ logShow (test 0.0 (1.0 `C` (2.0 `C` (3.0 `C` N))))
20+ log "Done"
examples/passing/TypeClassMemberOrderChange.purs+16−13
@@ -1,13 +1,16 @@
1−module Main where
1+module Main where
2−
2+
3−import Prelude
3+import Prelude
4−
4+import Control.Monad.Eff.Console (log)
5+
5−class Test a where
6+class Test a where
6− fn :: a -> a -> a
7+ fn :: a -> a -> a
7− val :: a
8+ val :: a
8−
9+
9−instance testBoolean :: Test Boolean where
10+instance testBoolean :: Test Boolean where
10− val = true
11+ val = true
11− fn x y = y
12+ fn x y = y
12−
13+
14+main = do
13−main = Control.Monad.Eff.Console.log (show (fn true val))
15+ log (show (fn true val))
16+ log "Done"
examples/passing/TypeClasses.purs+4−2
@@ -1,6 +1,7 @@
1module Main where
1module Main where
2
2
3import Prelude
3import Prelude
4+import Control.Monad.Eff.Console (log)
4
5
5test1 = \_ -> show "testing"
6test1 = \_ -> show "testing"
6
7
@@ -65,5 +66,6 @@ test9 _ = runReader 0.0 $ do
65 n <- ask
66 n <- ask
66 pure $ n + 1.0
67 pure $ n + 1.0
67
68
68−main = Control.Monad.Eff.Console.log (test7 "Done")
69+main = do
69−
70+ log (test7 "Hello")
71+ log "Done"
examples/passing/UTF8Sourcefile.purs+8−10
@@ -1,10 +1,8 @@
1−module Main where
1+module Main where
2−
2+
3−import Control.Monad.Eff.Console
3+import Control.Monad.Eff.Console
4−
4+
5−-- '→' is multibyte sequence \u2192.
5+-- '→' is multibyte sequence \u2192.
6−utf8multibyte = "Hello λ→ world!!"
6+utf8multibyte = "Hello λ→ world!!"
7−
7+
8−main = do
8+main = log "Done"
9− log "done"
10−
examples/passing/Unit.purs+4−2
@@ -1,6 +1,8 @@
1module Main where
1module Main where
2
2
3import Prelude
3import Prelude
4−import Control.Monad.Eff.Console
4+import Control.Monad.Eff.Console (logShow, log)
5
5
6+main = do
6−main = logShow (const unit $ "Hello world")
7+ logShow (const unit $ "Hello world")
8+ log "Done"
examples/passing/Where.purs+9−12
@@ -1,8 +1,7 @@
1module Main where
1module Main where
2
2
3import Prelude
3import Prelude
4−import Control.Monad.Eff
4+import Control.Monad.Eff.Console (logShow, log)
5−import Control.Monad.ST
6
5
7test1 x = y
6test1 x = y
8 where
7 where
@@ -14,15 +13,12 @@ test2 x y = x' + y'
14 x' = x + 1.0
13 x' = x + 1.0
15 y' = y + 1.0
14 y' = y + 1.0
16
15
17−
18test3 = f 1.0 2.0 3.0
16test3 = f 1.0 2.0 3.0
19 where f x y z = x + y + z
17 where f x y z = x + y + z
20
18
21−
22test4 = f (+) [1.0, 2.0]
19test4 = f (+) [1.0, 2.0]
23 where f x [y, z] = x y z
20 where f x [y, z] = x y z
24
21
25−
26test5 = g 10.0
22test5 = g 10.0
27 where
23 where
28 f x | x > 0.0 = g (x / 2.0) + 1.0
24 f x | x > 0.0 = g (x / 2.0) + 1.0
@@ -40,10 +36,11 @@ test7 x = go x
40 go y = go $ (y + x / y) / 2.0
36 go y = go $ (y + x / y) / 2.0
41
37
42main = do
38main = do
43− Control.Monad.Eff.Console.logShow (test1 1.0)
39+ logShow (test1 1.0)
44− Control.Monad.Eff.Console.logShow (test2 1.0 2.0)
40+ logShow (test2 1.0 2.0)
45− Control.Monad.Eff.Console.logShow test3
41+ logShow test3
46− Control.Monad.Eff.Console.logShow test4
42+ logShow test4
47− Control.Monad.Eff.Console.logShow test5
43+ logShow test5
48− Control.Monad.Eff.Console.logShow test6
44+ logShow test6
49− Control.Monad.Eff.Console.logShow (test7 100.0)
45+ logShow (test7 100.0)
46+ log "Done"
tests/TestCompiler.hs+7−2
@@ -92,7 +92,9 @@ spec = do
92 getShouldFailWith = fmap extractFailWiths . readUTF8File
92 getShouldFailWith = fmap extractFailWiths . readUTF8File
93 where
93 where
94 extractFailWiths = lines >>> mapMaybe (stripPrefix "-- @shouldFailWith ") >>> map trim
94 extractFailWiths = lines >>> mapMaybe (stripPrefix "-- @shouldFailWith ") >>> map trim
95+
96+trim :: String -> String
95− trim = dropWhile isSpace >>> reverse >>> dropWhile isSpace >>> reverse
97+trim = dropWhile isSpace >>> reverse >>> dropWhile isSpace >>> reverse
96
98
97modulesDir :: FilePath
99modulesDir :: FilePath
98modulesDir = ".test_modules" </> "node_modules"
100modulesDir = ".test_modules" </> "node_modules"
@@ -156,7 +158,10 @@ assertCompiles inputFiles foreigns = do
156 writeFile entryPoint "require('Main').main()"
158 writeFile entryPoint "require('Main').main()"
157 result <- traverse (\node -> readProcessWithExitCode node [entryPoint] "") process
159 result <- traverse (\node -> readProcessWithExitCode node [entryPoint] "") process
158 case result of
160 case result of
159− Just (ExitSuccess, _, _) -> return Nothing
161+ Just (ExitSuccess, out, err)
162+ | not (null err) -> return $ Just $ "Test wrote to stderr:\n\n" <> err
163+ | trim (last (lines out)) == "Done" -> return Nothing
164+ | otherwise -> return $ Just $ "Test did not finish with 'Done':\n\n" <> out
160 Just (ExitFailure _, _, err) -> return $ Just err
165 Just (ExitFailure _, _, err) -> return $ Just err
161 Nothing -> return $ Just "Couldn't find node.js executable"
166 Nothing -> return $ Just "Couldn't find node.js executable"
162
167