on master help sign in
Get rid of library tests that now live in elm-lang/core
commita8001a0770a2d99f7bfcb26f53dbc3c0a2b44af5 authorEvan Czaplicki <info@elm-lang.org> dateFri 28 Nov 2014, 21:06 (12 years ago) parent8910e5a
12 files changed−523
tests/libraries/LibraryTest.hs−55 tests/libraries/Test.elm−42 tests/libraries/Test/Array.elm−80 tests/libraries/Test/Basics.elm−20 tests/libraries/Test/Char.elm−15 tests/libraries/Test/CodeGen.elm−55 tests/libraries/Test/Dict.elm−49 tests/libraries/Test/Equality.elm−24 tests/libraries/Test/List.elm−90 tests/libraries/Test/Set.elm−27 tests/libraries/Test/String.elm−37 tests/libraries/Test/Trampoline.elm−29
tests/libraries/LibraryTest.hsdeleted−55
@@ -1,55 +0,0 @@
1−module Main where
2−
3−import Control.Monad (unless)
4−import Data.List (isInfixOf)
5−import System.Directory
6−import System.Exit
7−import System.FilePath
8−import System.Process
9−
10−import Elm.Internal.Paths as Elm
11−
12−main :: IO ()
13−main = do
14− top <- getCurrentDirectory
15−
16− -- setup submodules and npm
17− runCmd "git" ["submodule", "update", "--init"]
18− out <- readProcess "npm" ["ls", "--parseable"] ""
19− unless ("jsdom" `isInfixOf` out) $ runCmd "npm" ["install","jsdom"]
20−
21− -- setup actual library tests
22− let localCompiler = joinPath [ "dist", "build", "elm", "elm" ]
23− runCmd localCompiler [ "--make"
24− , "--only-js"
25− , "--src-dir=IO"
26− , "--src-dir=Elm-Test"
27− , "--src-dir=" ++ "tests" </> "libraries"
28− , testFile <.> "elm"
29− ]
30−
31− -- run tests
32− let files = [ "IO" </> "share" </> "prescript.js"
33− , Elm.runtime
34− , "build" </> testFile <.> "js"
35− , "IO" </> "share" </> "handler.js"
36− ]
37− testRunner = "build" </> "TestRunner.js"
38− exe <- readProcess "cat" files ""
39− writeFile testRunner exe
40− exitCode <- rawSystem "node" [testRunner]
41− removeDirectoryRecursive "cache"
42− removeDirectoryRecursive "build"
43− exitWith exitCode
44− where
45− testFile = "tests" </> "libraries" </> "Test"
46−
47−runCmd :: String -> [String] -> IO ()
48−runCmd cmd args = do
49− putStrLn (cmd ++ " " ++ unwords args)
50− (exitCode, stdout, stderr) <- readProcessWithExitCode cmd args ""
51− putStr stdout
52− putStr stderr
53− case exitCode of
54− ExitSuccess -> return ()
55− ExitFailure _ -> exitWith exitCode
tests/libraries/Test.elmdeleted−42
@@ -1,42 +0,0 @@
1−module Main where
2−
3−import ElmTest.Assertion as A
4−import ElmTest.Run as R
5−import ElmTest.Runner.Console (runDisplay)
6−import ElmTest.Test (..)
7−import IO.IO (..)
8−import IO.Runner (Request, Response)
9−import IO.Runner as Run
10−
11−import Test.Array as Array
12−import Test.Basics as Basics
13−import Test.Char as Char
14−import Test.CodeGen as CodeGen
15−import Test.Dict as Dict
16−import Test.Equality as Equality
17−import Test.List as List
18−import Test.Set as Set
19−import Test.String as String
20−import Test.Trampoline as Trampoline
21−
22−tests : Test
23−tests = suite "Elm Standard Library Tests"
24− [ Array.tests
25− , Basics.tests
26− , Char.tests
27− , CodeGen.tests
28− , Dict.tests
29− , Equality.tests
30− , List.tests
31− , Set.tests
32− , String.tests
33− , Trampoline.tests
34− ]
35−
36−console : IO ()
37−console = runDisplay tests
38−
39−port requests : Signal Request
40−port requests = Run.run responses console
41−
42−port responses : Signal Response
tests/libraries/Test/Array.elmdeleted−80
@@ -1,80 +0,0 @@
1−module Test.Array (tests) where
2−
3−import List
4−import Array
5−import Native.Array
6−
7−import ElmTest.Assertion (..)
8−import ElmTest.Test (..)
9−
10−mergeSplit : Int -> Array.Array a -> Array.Array a
11−mergeSplit n arr =
12− let left = Array.slice 0 n arr
13− right = Array.slice n (Array.length arr) arr
14− in Array.append left right
15−
16−holeArray : Array.Array Int
17−holeArray = foldl mergeSplit (Array.fromList [0..100]) [0..100]
18−
19−tests : Test
20−tests =
21− let creationTests = suite "Creation"
22− [ test "empty" <| assertEqual Array.empty (Array.fromList [])
23− , test "initialize" <| assertEqual (Array.initialize 4 identity) (Array.fromList [0,1,2,3])
24− , test "initialize 2" <| assertEqual (Array.initialize 4 (\n -> n*n)) (Array.fromList [0,1,4,9])
25− , test "initialize 3" <| assertEqual (Array.initialize 4 (always 0)) (Array.fromList [0,0,0,0])
26− , test "initialize Empty" <| assertEqual (Array.initialize 0 identity) Array.empty
27− , test "initialize 4" <| assertEqual (Array.initialize 2 (always 0)) (Array.fromList [0,0])
28− , test "repeat" <| assertEqual (Array.repeat 5 40) (Array.fromList [40,40,40,40,40])
29− , test "repeat 2" <| assertEqual (Array.repeat 5 0) (Array.fromList [0,0,0,0,0])
30− , test "repeat 3" <| assertEqual (Array.repeat 3 "cat") (Array.fromList ["cat","cat","cat"])
31− , test "fromList" <| assertEqual (Array.fromList []) Array.empty
32− ]
33− basicsTests = suite "Basics"
34− [ test "length" <| assertEqual 3 (Array.length (Array.fromList [1,2,3]))
35− , test "length - Long" <| assertEqual 10000 (Array.length (Array.repeat 10000 0))
36− , test "push" <| assertEqual (Array.fromList [1,2,3]) (Array.push 3 (Array.fromList [1,2]))
37− , test "append" <| assertEqual [42,42,81,81,81] (Array.toList (Array.append (Array.repeat 2 42) (Array.repeat 3 81)))
38− , test "appendEmpty 1" <| assertEqual [1..33] (Array.toList (Array.append Array.empty (Array.fromList [1..33])))
39− , test "appendEmpty 2" <| assertEqual [1..33] (Array.toList (Array.append (Array.fromList [1..33]) Array.empty))
40− , test "appendSmall 1" <| assertEqual [1..33] (Array.toList (Array.append (Array.fromList [1..30]) (Array.fromList [31..33])))
41− , test "appendSmall 2" <| assertEqual [1..33] (Array.toList (Array.append (Array.fromList [1..3]) (Array.fromList [4..33])))
42− , test "appendAndSlice" <| assertEqual [0..100] (Array.toList holeArray)
43− ]
44− getAndSetTests = suite "Get and Set"
45− [ test "get" <| assertEqual (Just 2) (Array.get 1 (Array.fromList [3,2,1]))
46− , test "get 2" <| assertEqual Nothing (Array.get 5 (Array.fromList [3,2,1]))
47− , test "get 3" <| assertEqual Nothing (Array.get -1 (Array.fromList [3,2,1]))
48− , test "getOrElse 1" <| assertEqual 1 (Array.getOrElse 0 2 (Array.fromList [3,2,1]))
49− , test "getOrElse 2" <| assertEqual 0 (Array.getOrElse 0 5 (Array.fromList [3,2,1]))
50− , test "getOrFail" <| assertEqual 1 (Array.getOrFail 2 (Array.fromList [3,2,1]))
51− , test "set" <| assertEqual (Array.fromList [1,7,3]) (Array.set 1 7 (Array.fromList [1,2,3]))
52− ]
53− takingArraysApartTests = suite "Taking Arrays Apart"
54− [ test "toList" <| assertEqual [3,5,8] (Array.toList (Array.fromList [3,5,8]))
55− , test "toIndexedList" <| assertEqual [(0,"cat"), (1,"dog")] (Array.toIndexedList (Array.fromList ["cat","dog"]))
56− , test "slice 1" <| assertEqual (Array.fromList [0,1,2]) (Array.slice 0 3 (Array.fromList [0,1,2,3,4]))
57− , test "slice 2" <| assertEqual (Array.fromList [1,2,3]) (Array.slice 1 4 (Array.fromList [0,1,2,3,4]))
58− , test "slice 3" <| assertEqual (Array.fromList [1,2,3]) (Array.slice 1 -1 (Array.fromList [0,1,2,3,4]))
59− , test "slice 4" <| assertEqual (Array.fromList [2]) (Array.slice -3 -2 (Array.fromList [0,1,2,3,4]))
60− , test "slice 5" <| assertEqual 63 (Array.length <| Array.slice 65 (65 + 63) <| Array.fromList [1..200])
61− ]
62− mappingAndFoldingTests = suite "Mapping and Folding"
63− [ test "map" <| assertEqual (Array.fromList [1,2,3]) (Array.map sqrt (Array.fromList [1,4,9]))
64− , test "indexedMap 1" <| assertEqual (Array.fromList [0,5,10]) (Array.indexedMap (*) (Array.fromList [5,5,5]))
65− , test "indexedMap 2" <| assertEqual [0..99] (Array.toList (Array.indexedMap always (Array.repeat 100 0)))
66− , test "foldl 1" <| assertEqual [3,2,1] (Array.foldl (::) [] (Array.fromList [1,2,3]))
67− , test "foldl 2" <| assertEqual 33 (Array.foldl (+) 0 (Array.repeat 33 1))
68− , test "foldr 1" <| assertEqual 15 (Array.foldr (+) 0 (Array.repeat 3 5))
69− , test "foldr 2" <| assertEqual [1,2,3] (Array.foldr (::) [] (Array.fromList [1,2,3]))
70− , test "foldr 3" <| assertEqual 53 (Array.foldr (-) 54 (Array.fromList [10,11]))
71− , test "filter" <| assertEqual (Array.fromList [2,4,6]) (Array.filter (\x -> x % 2 == 0) (Array.fromList [1..6]))
72− ]
73− nativeTests = suite "Conversion to JS Arrays"
74− [ test "jsArrays" <| assertEqual (Array.fromList [1..1100]) (Native.Array.fromJSArray (Native.Array.toJSArray (Array.fromList [1..1100])))
75− ]
76− in
77− suite "Array"
78− [ creationTests, basicsTests, getAndSetTests
79− , takingArraysApartTests, mappingAndFoldingTests, nativeTests
80− ]
tests/libraries/Test/Basics.elmdeleted−20
@@ -1,20 +0,0 @@
1−module Test.Basics (tests) where
2−
3−import ElmTest.Assertion (..)
4−import ElmTest.Test (..)
5−
6−tests : Test
7−tests =
8− let comparison =
9− suite "Comparison"
10− [ test "max" <| assertEqual 42 (max 32 42)
11− , test "min" <| assertEqual 42 (min 91 42)
12− , test "clamp low" <| assertEqual 10 (clamp 10 20 5)
13− , test "clamp mid" <| assertEqual 15 (clamp 10 20 15)
14− , test "clamp high" <| assertEqual 20 (clamp 10 20 25)
15− ]
16−
17− in
18− suite "Basics"
19− [ comparison
20− ]
tests/libraries/Test/Char.elmdeleted−15
@@ -1,15 +0,0 @@
1−module Test.Char (tests) where
2−
3−import Char
4−
5−import ElmTest.Assertion (..)
6−import ElmTest.Test (..)
7−
8−tests : Test
9−tests =
10− suite "Char"
11− [ test "toUpper" <| assertEqual 'C' <| Char.toUpper 'c'
12− , test "toLower" <| assertEqual 'c' <| Char.toLower 'C'
13− , test "toLocaleUpper" <| assertEqual 'C' <| Char.toLocaleUpper 'c'
14− , test "toLocaleLower" <| assertEqual 'c' <| Char.toLocaleLower 'C'
15− ]
tests/libraries/Test/CodeGen.elmdeleted−55
@@ -1,55 +0,0 @@
1−module Test.CodeGen (tests) where
2−
3−import ElmTest.Assertion (..)
4−import ElmTest.Test (..)
5−
6−import Maybe
7−import Maybe (..)
8−
9−casePrime m' =
10− case m' of
11− Just x -> x
12− Nothing -> 0
13−
14−patternPrime =
15− case Just 42 of
16− Just x' -> x'
17− Nothing -> 0
18−
19−letQualified =
20− let (Maybe.Just x) = Just 42
21− in x
22−
23−caseQualified =
24− case Just 42 of
25− Maybe.Just x -> x
26− Nothing -> 0
27−
28−caseScope : String
29−caseScope =
30− case "Not this one!" of
31− string ->
32− case "Hi" of
33− string -> string
34−
35−tests : Test
36−tests =
37− let primes =
38− suite "Primes"
39− [ test "case" <| assertEqual 42 (casePrime (Just 42))
40− , test "pattern" <| assertEqual 42 patternPrime
41− ]
42− qualifiedPatterns =
43− suite "Qualified Patterns"
44− [ test "let" <| assertEqual 42 letQualified
45− , test "case" <| assertEqual 42 caseQualified
46− ]
47− scope =
48− suite "Scoping"
49− [ test "case" <| assertEqual "Hi" caseScope ]
50− in
51− suite "CodeGen"
52− [ primes
53− , qualifiedPatterns
54− , scope
55− ]
tests/libraries/Test/Dict.elmdeleted−49
@@ -1,49 +0,0 @@
1−module Test.Dict (tests) where
2−
3−import Dict
4−import List
5−
6−import ElmTest.Assertion (..)
7−import ElmTest.Test (..)
8−
9−animals : Dict.Dict String String
10−animals = Dict.fromList [ ("Tom", "cat"), ("Jerry", "mouse") ]
11−
12−tests : Test
13−tests =
14− let buildTests = suite "build Tests"
15− [ test "empty" <| assertEqual (Dict.fromList []) (Dict.empty)
16− , test "singleton" <| assertEqual (Dict.fromList [("k","v")]) (Dict.singleton "k" "v")
17− , test "insert" <| assertEqual (Dict.fromList [("k","v")]) (Dict.insert "k" "v" Dict.empty)
18− , test "insert replace" <| assertEqual (Dict.fromList [("k","vv")]) (Dict.insert "k" "vv" (Dict.singleton "k" "v"))
19− , test "update" <| assertEqual (Dict.fromList [("k","vv")]) (Dict.update "k" (\v->Just "vv") (Dict.singleton "k" "v"))
20− , test "update Nothing" <| assertEqual Dict.empty (Dict.update "k" (\v->Nothing) (Dict.singleton "k" "v"))
21− , test "remove" <| assertEqual Dict.empty (Dict.remove "k" (Dict.singleton "k" "v"))
22− , test "remove not found" <| assertEqual (Dict.singleton "k" "v") (Dict.remove "kk" (Dict.singleton "k" "v"))
23− ]
24− queryTests = suite "query Tests"
25− [ test "member 1" <| assertEqual True (Dict.member "Tom" animals)
26− , test "member 2" <| assertEqual False (Dict.member "Spike" animals)
27− , test "get 1" <| assertEqual (Just "cat") (Dict.get "Tom" animals)
28− , test "get 2" <| assertEqual Nothing (Dict.get "Spike" animals)
29− , test "getOrElse 1" <| assertEqual "mouse" (Dict.getOrElse "dog" "Jerry" animals)
30− , test "getOrElse 2" <| assertEqual "dog" (Dict.getOrElse "dog" "Spike" animals)
31− , test "getOrFail" <| assertEqual "cat" (Dict.getOrFail "Tom" animals)
32− ]
33− combineTests = suite "combine Tests"
34− [ test "union" <| assertEqual animals (Dict.union (Dict.singleton "Jerry" "mouse") (Dict.singleton "Tom" "cat"))
35− , test "union collison" <| assertEqual (Dict.singleton "Tom" "cat") (Dict.union (Dict.singleton "Tom" "cat") (Dict.singleton "Tom" "mouse"))
36− , test "intersect" <| assertEqual (Dict.singleton "Tom" "cat") (Dict.intersect animals (Dict.singleton "Tom" "cat"))
37− , test "diff" <| assertEqual (Dict.singleton "Jerry" "mouse") (Dict.diff animals (Dict.singleton "Tom" "cat"))
38− ]
39− transformTests = suite "transform Tests"
40− [ test "filter" <| assertEqual (Dict.singleton "Tom" "cat") (Dict.filter (\k v -> k == "Tom") animals)
41− , test "partition" <| assertEqual (Dict.singleton "Tom" "cat", Dict.singleton "Jerry" "mouse") (Dict.partition (\k v -> k == "Tom") animals)
42− ]
43− in
44− suite "Dict Tests"
45− [ buildTests
46− , queryTests
47− , combineTests
48− , transformTests
49− ]
tests/libraries/Test/Equality.elmdeleted−24
@@ -1,24 +0,0 @@
1−module Test.Equality (tests) where
2−
3−import ElmTest.Assertion (..)
4−import ElmTest.Test (..)
5−
6−data Different
7− = A String
8− | B [Int]
9−
10−tests : Test
11−tests =
12− let diffTests = suite "ADT equality"
13− [ test "As eq" <| assert (A "a" == A "a")
14− , test "Bs eq" <| assert (B [1] == B [1])
15− , test "A left neq" <| assert (A "a" /= B [1])
16− , test "A left neq" <| assert (B [1] /= A "a")
17− ]
18− recordTests = suite "Record equality"
19− [ test "empty same" <| assert ({} == {})
20− , test "ctor same" <| assert ({ctor = Just 3} == {ctor = Just 3})
21− , test "ctor diff" <| assert ({ctor = Just 3} /= {ctor = Nothing})
22− ]
23− in
24− suite "Equality Tests" [diffTests, recordTests]
tests/libraries/Test/List.elmdeleted−90
@@ -1,90 +0,0 @@
1−module Test.List (tests) where
2−
3−import List
4−import String
5−
6−import ElmTest.Assertion (..)
7−import ElmTest.Test (..)
8−
9−largeNumber = 100000
10−trueList = repeat largeNumber True
11−falseList = repeat largeNumber False
12−
13−lessThanThree x = x < 3
14−isEven n = n % 2 == 0
15−
16−alice = { name="Alice", height=1.62 }
17−bob = { name="Bob" , height=1.85 }
18−chuck = { name="Chuck", height=1.76 }
19−
20−flippedComparison a b =
21− case compare a b of
22− LT -> GT
23− EQ -> EQ
24− GT -> LT
25−
26−tests : Test
27−tests =
28− let partitionTests = suite "partition Tests"
29− [ test "simple partition" <| assertEqual ([True],[False]) (List.partition identity [False, True])
30− , test "order check" <| assertEqual ([2,1], [5,6]) (List.partition lessThanThree [2,5,6,1])
31− , test "partition doc check 1" <| assertEqual ([0,1,2], [3,4,5]) (partition lessThanThree [0..5])
32− , test "partition doc check 2" <| assertEqual ([0,2,4], [1,3,5]) (partition isEven [0..5])
33− , test "partition stress test" <| assertEqual (trueList, falseList) (partition identity (falseList ++ trueList))
34− ]
35− unzipTests = suite "unzip Tests"
36− [ test "unzip doc check" <| assertEqual ([0,17,1337],[True,False,True]) (unzip [(0, True), (17, False), (1337, True)])
37− , test "unzip stress test" <| assertEqual (trueList, falseList) (unzip (zip trueList falseList))
38− ]
39− concatTests = suite "concat Tests"
40− [ test "concat doc check 1" <| assertEqual [1,2,3,4,5] (concat [[1,2],[3],[4,5]])
41− , test "concat doc check 2" <| assertEqual "treehouse" (concat ["tree","house"])
42− ]
43− joinTests = suite "join Tests"
44− [ test "join doc check" <| assertEqual "Hawaiian" (join "a" ["H","w","ii","n"])
45− , test "join list check" <| assertEqual [1,0,2,0,3] (join [0] [[1],[2],[3]])
46− ]
47− intersperseTests = suite "intersperse Tests"
48− [ test "intersperse doc check" <| assertEqual ["turtles","on","turtles","on","turtles"] (intersperse "on" ["turtles","turtles","turtles"])
49− , test "intersperse stress test" <| assertEqual (tail <| List.concat <| zipWith (\x y -> [x,y]) falseList trueList) (intersperse False trueList)
50− ]
51− zipTests = suite "zip Tests"
52− [ test "zip doc check 1" <| assertEqual [(1,6),(2,7)] (zip [1,2,3] [6,7])
53− , test "zip doc check 2" <| assertEqual (zipWith (,) [1,2,3] [6,7]) (zip [1,2,3] [6,7])
54− ]
55− filterMapTests = suite "filterMap Tests"
56− [ test "filterMap doc check" <| assertEqual [3,5] (filterMap String.toInt ["3","4.0","5","hats"])
57− ]
58− concatMapTests = suite "concatMap Tests"
59− [ test "simple concatMap check" <| assertEqual [1,1,2,2] (concatMap (repeat 2) [1,2])
60− ]
61− indexedMapTests = suite "indexedMap Tests"
62− [ test "indexedMap doc check" <| assertEqual [(0,"Tom"),(1,"Sue"),(2,"Bob")] (indexedMap (,) ["Tom", "Sue", "Bob"])
63− ]
64− sortTests = suite "sort Tests"
65− [ test "sort doc check" <| assertEqual [1,3,5] (sort [3,1,5])
66− , test "sort string check" <| assertEqual ["a","c","e"] (sort ["c","a","e"])
67− ]
68− sortByTests = suite "sortBy Tests"
69− [ test "sortBy doc check" <| assertEqual ["cat","mouse"] (sortBy String.length ["mouse","cat"])
70− , test "sortby derived property check 1" <| assertEqual [alice,bob,chuck] (sortBy .name [chuck,alice,bob])
71− , test "sortby derived property check 2" <| assertEqual [alice,chuck,bob] (sortBy .height [chuck,alice,bob])
72− ]
73− sortWithTests = suite "sortWith Tests"
74− [ test "sortWith doc check" <| assertEqual [5,4,3,2,1] (sortWith flippedComparison [1..5])
75− ]
76− in
77− suite "List Tests"
78− [ partitionTests
79− , unzipTests
80− , concatTests
81− , joinTests
82− , intersperseTests
83− , zipTests
84− , filterMapTests
85− , concatMapTests
86− , indexedMapTests
87− , sortTests
88− , sortByTests
89− , sortWithTests
90− ]
tests/libraries/Test/Set.elmdeleted−27
@@ -1,27 +0,0 @@
1−module Test.Set (tests) where
2−
3−import Set
4−import Set (Set)
5−import List
6−
7−import ElmTest.Assertion (..)
8−import ElmTest.Test (..)
9−
10−set : Set Int
11−set = Set.fromList [1..100]
12−
13−setPart1 : Set Int
14−setPart1 = Set.fromList [1..50]
15−
16−setPart2 : Set Int
17−setPart2 = Set.fromList [51..100]
18−
19−pred : Int -> Bool
20−pred x = x <= 50
21−
22−tests : Test
23−tests =
24− let
25− filterTests = suite "filter Tests" [test "Simple filter" <| assertEqual setPart1 <| Set.filter pred set]
26− partitionTests = suite "partition Tests" [test "Simple partition" <| assertEqual (setPart1, setPart2) <| Set.partition pred set]
27− in suite "Set Tests" [partitionTests, filterTests]
tests/libraries/Test/String.elmdeleted−37
@@ -1,37 +0,0 @@
1−module Test.String (tests) where
2−
3−import List
4−import String
5−
6−import ElmTest.Assertion (..)
7−import ElmTest.Test (..)
8−
9−tests : Test
10−tests =
11− let simpleTests = suite "Simple Stuff"
12− [ test "is empty" <| assert (String.isEmpty "")
13− , test "is not empty" <| assert (not (String.isEmpty ("the world")))
14− , test "length" <| assertEqual 11 (String.length "innumerable")
15− , test "endsWith" (assert <| String.endsWith "ship" "spaceship")
16− , test "reverse" <| assertEqual "desserts" (String.reverse "stressed")
17− , test "repeat" <| assertEqual "hahaha" (String.repeat 3 "ha")
18− ]
19−
20− combiningTests = suite "Combining Strings"
21− [ test "uncons non-empty" <| assertEqual (Just ('a',"bc")) (String.uncons "abc")
22− , test "uncons empty" <| assertEqual Nothing (String.uncons "")
23− , test "append 1" <| assertEqual "butterfly" (String.append "butter" "fly")
24− , test "append 2" <| assertEqual "butter" (String.append "butter" "")
25− , test "append 3" <| assertEqual "butter" (String.append "" "butter")
26− , test "concat" <| assertEqual "nevertheless" (concat ["never","the","less"])
27− , test "split commas" <| assertEqual ["cat","dog","cow"] (String.split "," "cat,dog,cow")
28− , test "split slashes"<| assertEqual ["home","steve","Desktop", ""] (String.split "/" "home/steve/Desktop/")
29− , test "join spaces" <| assertEqual "cat dog cow" (String.join " " ["cat","dog","cow"])
30− , test "join slashes" <| assertEqual "home/steve/Desktop" (String.join "/" ["home","steve","Desktop"])
31− , test "slice 1" <| assertEqual "c" (String.slice 2 3 "abcd")
32− , test "slice 2" <| assertEqual "abc" (String.slice 0 3 "abcd")
33− , test "slice 3" <| assertEqual "abc" (String.slice 0 -1 "abcd")
34− , test "slice 4" <| assertEqual "cd" (String.slice -2 4 "abcd")
35− ]
36− in
37− suite "String" [ simpleTests, combiningTests ]
tests/libraries/Test/Trampoline.elmdeleted−29
@@ -1,29 +0,0 @@
1−module Test.Trampoline (tests) where
2−
3−import Trampoline (..)
4−
5−import ElmTest.Assertion (..)
6−import ElmTest.Test (..)
7−
8−badSum : Int -> Int
9−badSum n =
10− let loop x acc =
11− case x of
12− 0 -> acc
13− _ -> loop (x-1) (acc+x)
14− in loop n 0
15−
16−goodSum : Int -> Int
17−goodSum n =
18− let sumT x acc =
19− case x of
20− 0 -> Done acc
21− _ -> Continue (\_ -> sumT (x-1) (acc+x))
22− in trampoline <| sumT n 0
23−
24−tests : Test
25−tests =
26− let mkLoopCheck n = test ("Equivalent Loop Check #"++ show n) (assertEqual (badSum n) (goodSum n))
27− loopChecks = suite "Equivalent to untrampolined Tests" <| map mkLoopCheck [0..25]
28− noStackOverflow = test "Trampoline Deep Recursion Test" (assertEqual 500000500000 (goodSum 1000000))
29− in suite "Trampoline Tests" [noStackOverflow, loopChecks]