Skip to content

Commit fe60dd9

Browse files
committed
Fix broken tests
1 parent dc19934 commit fe60dd9

23 files changed

+84
-159
lines changed

examples/passing/ArrayType.purs

Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,9 @@
11
module Main where
22

3-
import Prelude ()
4-
import Data.Array
3+
class Pointed p where
4+
point :: forall a. a -> p a
55

6-
test :: [] Number
7-
test = [1, 2, 3]
8-
9-
class Functor f where
10-
fmap :: forall a b. (a -> b) -> f a -> f b
11-
12-
instance functorArray :: Functor [] where
13-
fmap _ [] = []
14-
fmap f (x:xs) = f x : fmap f xs
6+
instance pointedArray :: Pointed [] where
7+
point a = [a]
158

169
main = Debug.Trace.trace "Done"

examples/passing/Arrays.purs

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
module Main where
22

33
import Prelude
4-
import Data.Array
54

65
test1 arr = arr !! 0 + arr !! 1 + 1
76

@@ -22,9 +21,4 @@ test4 = \arr -> case arr of
2221
[_] -> 0
2322
x : y : xs -> x * y + test4 xs
2423

25-
main = do
26-
let x = [3,2,1]
27-
let y = sort x
28-
if x == [3,2,1]
29-
then Debug.Trace.trace "Done"
30-
else Control.Monad.Eff.Error.throwError "Not done"
24+
main = Debug.Trace.trace "Done"
Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,16 @@
11
module Main where
22

33
import Prelude
4-
import Data.Array
54

6-
tails = map (\(_:xs) -> xs)
5+
tail = \(_:xs) -> xs
6+
7+
foreign import error
8+
"function error(msg) {\
9+
\ throw msg;\
10+
\}" :: forall a. String -> a
711

812
main =
9-
let ts = tails [[1, 2, 3], [4, 5], [6]] in
10-
if ts == [[2, 3], [5], []]
13+
let ts = tail [1, 2, 3] in
14+
if ts == [2, 3]
1115
then Debug.Trace.trace "Done"
12-
else Control.Monad.Eff.Error.throwError "Incorrect result from 'tails'."
16+
else error "Incorrect result from 'tails'."

examples/passing/CheckSynonymBug.purs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,11 @@ module Main where
44

55
type Foo a = [a]
66

7-
foo _ = Data.Array.length ([] :: Foo Number)
7+
foreign import length
8+
"function length(a) {\
9+
\ return a.length;\
10+
\}" :: forall a. [a] -> Number
11+
12+
foo _ = length ([] :: Foo Number)
813

914
main = Debug.Trace.trace "Done"

examples/passing/Cons.purs

Lines changed: 0 additions & 10 deletions
This file was deleted.

examples/passing/Eff.purs

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,19 +3,17 @@ module Main where
33
import Prelude
44
import Control.Monad.Eff
55
import Control.Monad.ST
6-
import Control.Monad.Eff.Error
76
import Debug.Trace
87

9-
test1 = catchError (\s -> return 0) $ do
10-
trace "Testing"
11-
throwError "Error!"
8+
test1 = do
9+
trace "Line 1"
10+
trace "Line 2"
1211

1312
test2 = runPure (runST (do
1413
ref <- newSTRef 0
1514
modifySTRef ref $ \n -> n + 1
1615
readSTRef ref))
1716

1817
main = do
19-
n <- test1
20-
Debug.Trace.print n
18+
test1
2119
Debug.Trace.print test2
Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
module Main where
22

33
import Prelude
4-
import Data.Array
54

65
data Z
76
data S n
@@ -11,10 +10,22 @@ data Array n a = Array [a]
1110
nil :: forall a. Array Z a
1211
nil = Array []
1312

13+
foreign import concat
14+
"function concat(l1) {\
15+
\ return function (l2) {\
16+
\ return l1.concat(l2);\
17+
\ };\
18+
\}" :: forall a. [a] -> [a] -> [a]
19+
1420
cons :: forall a n. a -> Array n a -> Array (S n) a
15-
cons x (Array xs) = Array $ x : xs
21+
cons x (Array xs) = Array $ concat [x] xs
22+
23+
foreign import error
24+
"function error(msg) {\
25+
\ throw msg;\
26+
\}" :: forall a. String -> a
1627

1728
main = let (Array xs) = cons 1 $ cons 2 $ cons 3 nil
1829
in if xs == [1, 2, 3]
1930
then Debug.Trace.trace "Done"
20-
else Control.Monad.Eff.Error.throwError "Failed"
31+
else error "Failed"

examples/passing/Foldable.purs

Lines changed: 0 additions & 19 deletions
This file was deleted.

examples/passing/FunctionScope.purs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,13 @@ module Main where
55
mkValue :: Number -> Number
66
mkValue id = id
77

8+
foreign import error
9+
"function error(msg) {\
10+
\ throw msg;\
11+
\}" :: forall a. String -> a
12+
813
main = do
914
let value = mkValue 1
1015
if value == 1
1116
then Debug.Trace.trace "Done"
12-
else Control.Monad.Eff.Error.throwError "Not done"
17+
else error "Not done"

examples/passing/Functions2.purs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,13 @@ module Main where
55
test :: forall a b. a -> b -> a
66
test = \const _ -> const
77

8+
foreign import error
9+
"function error(msg) {\
10+
\ throw msg;\
11+
\}" :: forall a. String -> a
12+
813
main = do
914
let value = test "Done" {}
1015
if value == "Done"
1116
then Debug.Trace.trace "Done"
12-
else Control.Monad.Eff.Error.throwError "Not done"
17+
else error "Not done"

0 commit comments

Comments
 (0)