on master help sign in
Merge branch 'master' into canonicalize

Conflicts: Elm.cabal

commit39020499d37a47fd409287078afb154ac7b56e31 authorEvan Czaplicki <info@elm-lang.org> dateWed 30 Apr 2014, 08:25 (13 years ago) parentab175216cdc6d4
15 files changed+155−94
Elm.cabal+8−5 changelog.md+8−6 compiler/Elm/Internal/Dependencies.hs+41−4 compiler/Elm/Internal/Name.hs+2−2 compiler/Type/Unify.hs+5−1 libraries/Array.elm+12−12 libraries/Dict.elm+20−20 libraries/elm_dependencies.json+6−5 tests/elm/Test.elm+8−2 tests/elm/Test/Array.elm+10−10 tests/elm/Test/Dict.elm+5−5 tests/elm/Test/List.elm+5−5 tests/elm/Test/Set.elm+4−4 tests/elm/Test/String.elm+18−10 tests/elm/Test/Trampoline.elm+3−3
Elm.cabal+8−5
@@ -1,5 +1,5 @@
11Name: Elm
2−Version: 0.12
2+Version: 0.12.1
33Synopsis: The Elm language module.
44Description: Elm aims to make client-side web-development more pleasant.
55 It is a statically/strongly typed, functional reactive
@@ -27,7 +27,7 @@ Cabal-version: >=1.9
2727
2828source-repository head
2929 type: git
30− location: git://github.com/evancz/Elm.git
30+ location: git://github.com/elm-lang/Elm.git
3131
3232Library
3333 exposed-modules: Elm.Internal.Dependencies,
@@ -96,6 +96,7 @@ Library
9696 Paths_Elm
9797
9898 Build-depends: aeson,
99+ aeson-pretty,
99100 base >=4.2 && <5,
100101 binary >= 0.7.0.0,
101102 blaze-html >= 0.5 && < 0.8,
@@ -180,6 +181,7 @@ Executable elm
180181 Paths_Elm
181182
182183 Build-depends: aeson,
184+ aeson-pretty,
183185 base >=4.2 && <5,
184186 binary >= 0.7.0.0,
185187 blaze-html >= 0.5 && < 0.8,
@@ -257,10 +259,11 @@ Test-Suite compiler-tests
257259 HUnit,
258260 QuickCheck >= 2 && < 3,
259261 aeson,
262+ aeson-pretty,
260263 base >=4.2 && <5,
261264 binary >= 0.7.0.0,
262− blaze-html == 0.5.* || == 0.6.*,
263− blaze-markup == 0.5.1.*,
265+ blaze-html,
266+ blaze-markup,
264267 bytestring,
265268 cmdargs,
266269 containers >= 0.3,
@@ -288,4 +291,4 @@ Test-Suite lib-tests
288291 directory,
289292 Elm,
290293 filepath,
291− process >= 1.2
294+ process
changelog.md+8−6
@@ -1,5 +1,12 @@
11
2−## 0.13
2+## 0.12.1
3+
4+## Improvements:
5+
6+ * New Array library (thanks entirely to @Xashili)
7+ * Json.Value can flow through ports
8+ * Improve speed and stack usage in List library (thanks to @maxsnew)
9+ * Add Dict.filter and Dict.partition (thanks to @hdgarrood)
310
411#### Breaking Changes:
512
@@ -7,11 +14,6 @@
714 * Revamp JavaScript.Experimental library to have slightly better names
815 * Remove JavaScript library which was made redundant by ports
916
10−## Improvements:
11−
12− * Json.Value can flow through ports, so you can bring in values even
13− if they don't conform to a consistent type.
14−
1517## 0.12
1618
1719#### Breaking Changes:
compiler/Elm/Internal/Dependencies.hs+41−4
@@ -5,9 +5,12 @@ import Control.Applicative
55import Control.Monad.Error
66import qualified Control.Exception as E
77import Data.Aeson
8+import Data.Aeson.Encode.Pretty
89import qualified Data.List as List
910import qualified Data.ByteString.Lazy as BS
1011import qualified Data.HashMap.Strict as Map
12+import qualified Data.Text as T
13+
1114import qualified Elm.Internal.Name as N
1215import qualified Elm.Internal.Version as V
1316import qualified Elm.Internal.Paths as Path
@@ -22,14 +25,32 @@ data Deps = Deps
2225 , exposed :: [String]
2326 , elmVersion :: V.Version
2427 , dependencies :: [(N.Name,V.Version)]
25− } deriving Show
28+ } deriving (Show, Eq, Ord)
2629
2730data MiniDeps = Mini [(N.Name,V.Version)]
31+ deriving (Show, Eq, Ord)
32+
33+instance ToJSON MiniDeps where
34+ toJSON (Mini m) = toJSON m
2835
2936instance FromJSON MiniDeps where
3037 parseJSON (Object obj) = Mini <$> getDependencies obj
3138 parseJSON _ = mzero
3239
40+instance ToJSON Deps where
41+ toJSON d = object [
42+ "version" .= version d,
43+ "summary" .= summary d,
44+ "description" .= description d,
45+ "license" .= license d,
46+ "repository" .= repo d,
47+ "exposed-modules" .= exposed d,
48+ "elm-version" .= elmVersion d,
49+ "dependencies" .= (jsonDeps . dependencies $ d)
50+ ]
51+ where jsonDeps = Map.fromList . map (mapFst (T.pack . show))
52+ mapFst f (a,b) = (f a, b)
53+
3354instance FromJSON Deps where
3455 parseJSON (Object obj) =
3556 do version <- get obj "version" "your projects version number"
@@ -110,8 +131,24 @@ withDeps handle path =
110131 case result of
111132 Right bytes -> return bytes
112133 Left _ -> throwError $
113− "could not find file " ++ path ++
114− "\n You may need to create a dependency file for your project."
134+ "could not find " ++ path ++ " file. You may need to create one.\n" ++
135+ " For an example of how to fill in the dependencies file, check out\n" ++
136+ " <https://github.com/evancz/automaton/blob/master/elm_dependencies.json>"
115137
116138depsAt :: FilePath -> ErrorT String IO Deps
117−depsAt = withDeps id
139+depsAt = withDeps id
140+
141+-- | Encode dependencies in a canonical JSON format
142+prettyJSON :: Deps -> BS.ByteString
143+prettyJSON = encodePretty' config
144+ where config = defConfig { confCompare = order }
145+ order = keyOrder [ "name",
146+ "version",
147+ "summary",
148+ "description",
149+ "license",
150+ "repo",
151+ "exposed-modules",
152+ "elm-version",
153+ "dependencies"
154+ ]
compiler/Elm/Internal/Name.hs+2−2
@@ -10,7 +10,7 @@ import qualified Data.Maybe as Maybe
1010import Data.Typeable
1111
1212data Name = Name { user :: String, project :: String }
13− deriving (Typeable,Eq)
13+ deriving (Typeable,Eq, Ord)
1414
1515instance Binary Name where
1616 get = Name <$> get <*> get
@@ -48,4 +48,4 @@ errorMsg string =
4848 unlines
4949 [ "Dependency file has an invalid name: " ++ string
5050 , "Must have format user/project and match a public github project."
51− ]
51+ ]
compiler/Type/Unify.hs+5−1
@@ -86,6 +86,10 @@ actuallyUnify region variable1 variable2 = do
8686 TS.addError region (Just $ Maybe.fromMaybe msg maybe) variable1 variable2
8787 where msg = "A comparable must be an Int, Float, Char, String, list, or tuple."
8888
89+ appendableError maybe =
90+ TS.addError region (Just $ Maybe.fromMaybe msg maybe) variable1 variable2
91+ where msg = "An appendable must be of type String, List, or Text."
92+
8993 unifyComparable var name
9094 | name `elem` ["Int","Float","Char","String","comparable"] = flexAndUnify var
9195 | otherwise = comparableError Nothing
@@ -108,7 +112,7 @@ actuallyUnify region variable1 variable2 = do
108112 do struct <- liftIO $ collectApps varFlex
109113 case struct of
110114 List _ -> flexAndUnify varSuper
111− _ -> comparableError Nothing
115+ _ -> appendableError Nothing
112116
113117 rigidError variable = TS.addError region (Just hint) variable1 variable2
114118 where
libraries/Array.elm+12−12
@@ -11,7 +11,7 @@ reads, updates, and appends.
1111@docs length, push, append
1212
1313# Get and Set
14−@docs get, getSafe, getUnsafe, set
14+@docs get, getOrElse, getOrFail, set
1515
1616# Taking Arrays Apart
1717@docs toList, toIndexedList, slice
@@ -122,14 +122,14 @@ push = Native.Array.push
122122
123123{-| Get the element at a particular index.
124124
125− getUnsafe 2 (A.fromList [3,2,1]) == 1
125+ getOrFail 2 (A.fromList [3,2,1]) == 1
126126
127127Warning: this function will result in a runtime error if the index is not found,
128−so it is best to use `get` or `getSafe` unless you are very confident the index
129−will be found.
128+so it is best to use `get` or `getOrElse` unless you are sure the index will be
129+found.
130130-}
131−getUnsafe : Int -> Array a -> a
132−getUnsafe = Native.Array.get
131+getOrFail : Int -> Array a -> a
132+getOrFail = Native.Array.get
133133
134134{-| Return Just the element at the index or Nothing if the index is out of range.
135135
@@ -143,14 +143,14 @@ get i array =
143143 then Just (Native.Array.get i array)
144144 else Nothing
145145
146−{-| Get the element at the index. If the index is out of range, the given default
147−element is returned.
146+{-| Get the element at the index. Or if the index is out of range, a default
147+value is returned.
148148
149− getSafe 0 2 (fromList [3,2,1]) == 1
150− getSafe 0 5 (fromList [3,2,1]) == 0
149+ getOrElse 0 2 (fromList [3,2,1]) == 1
150+ getOrElse 0 5 (fromList [3,2,1]) == 0
151151-}
152−getSafe : a -> Int -> Array a -> a
153−getSafe default i array =
152+getOrElse : a -> Int -> Array a -> a
153+getOrElse default i array =
154154 if 0 <= i && i < Native.Array.length array
155155 then Native.Array.get i array
156156 else default
libraries/Dict.elm+20−20
@@ -1,5 +1,5 @@
11module Dict (empty,singleton,insert,update
2− ,get,getSafe,getUnsafe
2+ ,get,getOrElse,getOrFail
33 ,remove,member
44 ,filter
55 ,partition
@@ -19,7 +19,7 @@ Insert, remove, and query operations all take *O(log n)* time.
1919@docs empty, singleton, insert, update, remove
2020
2121# Query
22−@docs member, get, getMaybe, getWithDefault
22+@docs member, get, getOrElse, getOrFail
2323
2424# Combine
2525@docs union, intersect, diff
@@ -96,7 +96,7 @@ dictionary.
9696 get "Mouse" animals == Just Mouse
9797 get "Spike" animals == Nothing
9898
99−The `getSafe` and `getUnsafe` are built-in ways to handle common ways of
99+The `getOrElse` and `getOrFail` are built-in ways to handle common ways of
100100using the resulting `Maybe`.
101101-}
102102get : comparable -> Dict comparable v -> Maybe v
@@ -114,41 +114,41 @@ return a default value.
114114
115115 animals = fromList [ ("Tom", Cat), ("Jerry", Mouse) ]
116116
117− getSafe Dog "Tom" animals == Cat
118− getSafe Dog "Mouse" animals == Mouse
119− getSafe Dog "Spike" animals == Dog
117+ getOrElse Dog "Tom" animals == Cat
118+ getOrElse Dog "Mouse" animals == Mouse
119+ getOrElse Dog "Spike" animals == Dog
120120-}
121−getSafe : v -> comparable -> Dict comparable v -> v
122−getSafe base k t =
121+getOrElse : v -> comparable -> Dict comparable v -> v
122+getOrElse base k t =
123123 case t of
124124 RBEmpty LBlack -> base
125125 RBNode _ k' v l r ->
126126 case Native.Utils.compare k k' of
127− LT -> getSafe base k l
127+ LT -> getOrElse base k l
128128 EQ -> v
129− GT -> getSafe base k r
129+ GT -> getOrElse base k r
130130
131131{-| Get the value associated with a key.
132132
133133 animals = fromList [ ("Tom", Cat), ("Jerry", Mouse) ]
134134
135− get "Tom" animals == Cat
136− get "Mouse" animals == Mouse
137− get "Spike" animals == -- Runtime Error!
135+ getOrFail "Tom" animals == Cat
136+ getOrFail "Mouse" animals == Mouse
137+ getOrFail "Spike" animals == -- Runtime Error!
138138
139139Warning: this function will result in a runtime error if the key is not found,
140−so it is best to use `get` or `getSafe` unless you are very confident the key
141−will be found.
140+so it is best to use `get` or `getOrElse` unless you are sure the key will be
141+found.
142142-}
143−getUnsafe : comparable -> Dict comparable v -> v
144−getUnsafe k t =
143+getOrFail : comparable -> Dict comparable v -> v
144+getOrFail k t =
145145 case t of
146− RBEmpty LBlack -> Native.Error.raise "key not found when using 'getUnsafe'"
146+ RBEmpty LBlack -> Native.Error.raise "key not found when using 'getOrFail'"
147147 RBNode _ k' v l r ->
148148 case Native.Utils.compare k k' of
149− LT -> getUnsafe k l
149+ LT -> getOrFail k l
150150 EQ -> v
151− GT -> getUnsafe k r
151+ GT -> getOrFail k r
152152
153153{-| Determine if a key is in a dictionary. -}
154154member : comparable -> Dict comparable v -> Bool
libraries/elm_dependencies.json+6−5
@@ -1,12 +1,13 @@
1−{ "version": "0.12"
1+{ "version": "0.12.1"
22, "summary": "Elm's standard libraries"
3−, "description": "The full set of standard libraries for Elm. This library is pegged to the version number of the compiler, so if you are using Elm 0.12, you should be using version 0.12 of the standard libraries."
3+, "description": "The full set of standard libraries for Elm. This library is pegged to the version number of the compiler, so if you are using Elm 0.12.1, you should be using version 0.12.1 of the standard libraries."
44, "license": "BSD3"
5−, "repository": "http://github.com/evancz/Elm.git"
6−, "elm-version": "0.12"
5+, "repository": "http://github.com/elm-lang/Elm.git"
6+, "elm-version": "0.12.1"
77, "dependencies": {}
88, "exposed-modules":
9− [ "Basics"
9+ [ "Array"
10+ , "Basics"
1011 , "Bitwise"
1112 , "Char"
1213 , "Color"
tests/elm/Test.elm+8−2
@@ -16,8 +16,14 @@ import Test.Set as Set
1616import Test.String as String
1717import Test.Trampoline as Trampoline
1818
19−tests : [Test]
20−tests = String.tests ++ Trampoline.tests ++ Array.tests ++ Dict.tests ++ Set.tests ++ List.tests
19+tests : Test
20+tests = suite "Elm Standard Library Tests" [ List.tests,
21+ String.tests,
22+ Trampoline.tests,
23+ Array.tests,
24+ Dict.tests,
25+ Set.tests
26+ ]
2127
2228console : IO ()
2329console = runDisplay tests
tests/elm/Test/Array.elm+10−10
@@ -6,9 +6,9 @@ import Array
66import ElmTest.Assertion (..)
77import ElmTest.Test (..)
88
9−tests : [Test]
9+tests : Test
1010tests =
11− let creationTests =
11+ let creationTests = suite "Creation"
1212 [ test "empty" <| assertEqual Array.empty (Array.fromList [])
1313 , test "initialize" <| assertEqual (Array.initialize 4 id) (Array.fromList [0,1,2,3])
1414 , test "initialize 2" <| assertEqual (Array.initialize 4 (\n -> n*n)) (Array.fromList [0,1,4,9])
@@ -20,29 +20,29 @@ tests =
2020 , test "repeat 3" <| assertEqual (Array.repeat 3 "cat") (Array.fromList ["cat","cat","cat"])
2121 , test "fromList" <| assertEqual (Array.fromList []) Array.empty
2222 ]
23− basicsTests =
23+ basicsTests = suite "Basics"
2424 [ test "length" <| assertEqual (Array.length (Array.fromList [1,2,3])) 3
2525 , test "length - Long" <| assertEqual (Array.length (Array.repeat 10000 0)) 10000
2626 , test "push" <| assertEqual (Array.push 3 (Array.fromList [1,2])) (Array.fromList [1,2,3])
2727 , test "append" <| assertEqual (Array.toList <| Array.append (Array.repeat 2 42) (Array.repeat 3 81)) ([42,42,81,81,81])
2828 ]
29− getAndSetTests =
29+ getAndSetTests = suite "Get and Set"
3030 [ test "get" <| assertEqual (Array.get 1 (Array.fromList [3,2,1])) (Just 2)
3131 , test "get 2" <| assertEqual (Array.get 5 (Array.fromList [3,2,1])) Nothing
3232 , test "get 3" <| assertEqual (Array.get -1 (Array.fromList [3,2,1])) Nothing
33− , test "getSafe 1" <| assertEqual (Array.getSafe 0 2 (Array.fromList [3,2,1])) 1
34− , test "getSafe 2" <| assertEqual (Array.getSafe 0 5 (Array.fromList [3,2,1])) 0
35− , test "getUnsafe" <| assertEqual (Array.getUnsafe 2 (Array.fromList [3,2,1])) 1
33+ , test "getOrElse 1" <| assertEqual (Array.getOrElse 0 2 (Array.fromList [3,2,1])) 1
34+ , test "getOrElse 2" <| assertEqual (Array.getOrElse 0 5 (Array.fromList [3,2,1])) 0
35+ , test "getOrFail" <| assertEqual (Array.getOrFail 2 (Array.fromList [3,2,1])) 1
3636 , test "set" <| assertEqual (Array.set 1 7 (Array.fromList [1,2,3])) (Array.fromList [1,7,3])
3737 ]
38− takingArraysApartTests =
38+ takingArraysApartTests = suite "Taking Arrays Apart"
3939 [ test "toList" <| assertEqual (Array.toList (Array.fromList [3,5,8])) [3,5,8]
4040 , test "toIndexedList" <| assertEqual (Array.toIndexedList (Array.fromList ["cat","dog"])) [(0,"cat"), (1,"dog")]
4141 , test "slice" <| assertEqual (Array.slice 1 2 (Array.fromList [0,1,2,3,4])) (Array.fromList [1,2])
4242 , test "slice 2" <| assertEqual (Array.slice 1 -2 (Array.fromList [0,1,2,3,4])) (Array.fromList [1,2,3])
4343 , test "slice 3" <| assertEqual (Array.slice -3 -2 (Array.fromList [0,1,2,3,4])) (Array.fromList [2,3])
4444 ]
45− mappingAndFoldingTests =
45+ mappingAndFoldingTests = suite "Mapping and Folding"
4646 [ test "map" <| assertEqual (Array.map sqrt (Array.fromList [1,4,9])) (Array.fromList [1,2,3])
4747 , test "indexedMap" <| assertEqual (Array.indexedMap (*) (Array.fromList [5,5,5])) (Array.fromList [0,5,10])
4848 , test "foldl" <| assertEqual (Array.foldl (::) [] (Array.fromList [1,2,3])) [3,2,1]
@@ -51,4 +51,4 @@ tests =
5151 , test "filter" <| assertEqual (Array.filter (\x -> x `mod` 2 == 0) (Array.fromList [1..6])) (Array.fromList [2,4,6])
5252 ]
5353 in
54− List.concat [creationTests, basicsTests, getAndSetTests, takingArraysApartTests, mappingAndFoldingTests]
54+ suite "Array Tests" [creationTests, basicsTests, getAndSetTests, takingArraysApartTests, mappingAndFoldingTests]
tests/elm/Test/Dict.elm+5−5
@@ -9,18 +9,18 @@ import ElmTest.Test (..)
99animals : Dict.Dict String String
1010animals = Dict.fromList [ ("Tom", "cat"), ("Jerry", "mouse") ]
1111
12−tests : [Test]
12+tests : Test
1313tests =
1414 let getTests =
1515 [ test "get 1" <| assertEqual (Just "cat") (Dict.get "Tom" animals)
1616 , test "get 2" <| assertEqual Nothing (Dict.get "Spike" animals)
17− , test "getSafe 1" <| assertEqual "mouse" (Dict.getSafe "dog" "Jerry" animals)
18− , test "getSafe 2" <| assertEqual "dog" (Dict.getSafe "dog" "Spike" animals)
19− , test "getUnsafe" <| assertEqual "cat" (Dict.getUnsafe "Tom" animals)
17+ , test "getOrElse 1" <| assertEqual "mouse" (Dict.getOrElse "dog" "Jerry" animals)
18+ , test "getOrElse 2" <| assertEqual "dog" (Dict.getOrElse "dog" "Spike" animals)
19+ , test "getOrFail" <| assertEqual "cat" (Dict.getOrFail "Tom" animals)
2020 ]
2121 filterTests =
2222 [ test "filter" <| assertEqual (Dict.singleton "Tom" "cat") (Dict.filter (\k v -> k == "Tom") animals)
2323 , test "partition" <| assertEqual (Dict.singleton "Tom" "cat", Dict.singleton "Jerry" "mouse") (Dict.partition (\k v -> k == "Tom") animals)
2424 ]
2525 in
26− List.concat [ getTests, filterTests ]
26+ suite "Dict Tests" <| List.concat [ getTests, filterTests ]
tests/elm/Test/List.elm+5−5
@@ -5,13 +5,13 @@ import List
55import ElmTest.Assertion (..)
66import ElmTest.Test (..)
77
8−tests : [Test]
8+tests : Test
99tests =
1010 let partitionTests =
1111 let p1 = id
1212 p2 x = x < 3
1313 isEven n = n `mod` 2 == 0
14− in [ test "simple partition" <| assertEqual ([True],[False]) (List.partition p1 [False, True]),
14+ in suite "partition Tests" [ test "simple partition" <| assertEqual ([True],[False]) (List.partition p1 [False, True]),
1515 test "order check" <| assertEqual ([2,1], [5,6]) (List.partition p2 [2,5,6,1]),
1616 test "partition doc check 1" <| assertEqual ([0,1,2], [3,4,5]) (partition p2 [0..5]),
1717 test "partition doc check 2" <| assertEqual ([0,2,4], [1,3,5]) (partition isEven [0..5]),
@@ -20,14 +20,14 @@ tests =
2020 fs = repeat n False
2121 in test "partition stress test" <| assertEqual (ts, fs) (partition p1 (fs++ts))
2222 ]
23− unzipTests = [
23+ unzipTests = suite "unzip Tests" [
2424 test "unzip doc check" <| assertEqual ([0,17,1337],[True,False,True]) (unzip [(0, True), (17, False), (1337, True)]),
2525 let n = 100000
2626 ts = repeat n True
2727 fs = repeat n False
2828 in test "unzip stress test" <| assertEqual (ts, fs) (unzip (zip ts fs))
2929 ]
30− intersperseTests = [
30+ intersperseTests = suite "intersperse Tests" [
3131 test "intersperse doc check" <| assertEqual ["turtles","on","turtles","on","turtles"] (intersperse "on" ["turtles","turtles","turtles"]),
3232 let n = 100000
3333 ts = repeat n True
@@ -35,4 +35,4 @@ tests =
3535 in test "intersperse stress test" <| assertEqual (tail . List.concat <| zipWith (\x y -> [x,y]) fs ts)
3636 (intersperse False ts)
3737 ]
38− in List.concat [partitionTests, unzipTests, intersperseTests]
38+ in suite "List Tests" [partitionTests, unzipTests, intersperseTests]
tests/elm/Test/Set.elm+4−4
@@ -19,9 +19,9 @@ setPart2 = Set.fromList [51..100]
1919pred : Int -> Bool
2020pred x = x <= 50
2121
22−tests : [Test]
22+tests : Test
2323tests =
2424 let
25− filterTests = [test "Simple filter" <| assertEqual setPart1 <| Set.filter pred set]
26− partitionTests = [test "Simple partition" <| assertEqual (setPart1, setPart2) <| Set.partition pred set]
27− in List.concat [partitionTests, filterTests]
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/elm/Test/String.elm+18−10
@@ -6,21 +6,29 @@ import String (..)
66import ElmTest.Assertion (..)
77import ElmTest.Test (..)
88
9−tests : [Test]
9+tests : Test
1010tests =
11− let isEmptyTests = [test "empty is empty" <| assert <| isEmpty "",
12− test "not empty" <| assert <| not . isEmpty <| "the world"]
11+ let isEmptyTests = suite "isEmpty Tests" [
12+ test "empty is empty" <| assert <| isEmpty "",
13+ test "not empty" <| assert <| not . isEmpty <| "the world"
14+ ]
1315 lengthTest = test "length of innumerable" <| assertEqual 11 (length "innumerable")
1416 reverseTest = test "reverse test" <| assertEqual "desserts" (reverse "stressed")
1517 repeatTest = test "repeat test" <| assertEqual "hahaha" (repeat 3 "ha")
16− unconsTests = [test "nonempty uncons" <| assertEqual (Just ('a',"bc")) (uncons "abc"),
17− test "empty uncons" <| assertEqual Nothing (uncons "")]
18+ unconsTests = suite "uncons Tests" [
19+ test "nonempty uncons" <| assertEqual (Just ('a',"bc")) (uncons "abc"),
20+ test "empty uncons" <| assertEqual Nothing (uncons "")
21+ ]
1822 appendTest = test "append test" <| assertEqual "butterfly" (append "butter" "fly")
1923 concatTest = test "concat test" <| assertEqual "nevertheless" (concat ["never","the","less"])
20− splitTests = [test "split commas" <| assertEqual ["cat","dog","cow"] (split "," "cat,dog,cow"),
21− test "split slashes"<| assertEqual ["home","evan","Desktop", ""] (split "/" "home/evan/Desktop/")]
22− joinTests = [test "join spaces" <| assertEqual "cat dog cow" (join " " ["cat","dog","cow"]),
23− test "join slashes" <| assertEqual "home/evan/Desktop" (join "/" ["home","evan","Desktop"])]
24+ splitTests = suite "split Tests" [
25+ test "split commas" <| assertEqual ["cat","dog","cow"] (split "," "cat,dog,cow"),
26+ test "split slashes"<| assertEqual ["home","evan","Desktop", ""] (split "/" "home/evan/Desktop/")
27+ ]
28+ joinTests = suite "join Tests" [
29+ test "join spaces" <| assertEqual "cat dog cow" (join " " ["cat","dog","cow"]),
30+ test "join slashes" <| assertEqual "home/evan/Desktop" (join "/" ["home","evan","Desktop"])
31+ ]
2432
2533 endsWithTest = test "endsWith Check" (assert <| endsWith "h" "th")
26− in List.concat [isEmptyTests, [lengthTest, reverseTest, repeatTest], unconsTests, [appendTest, concatTest], splitTests, joinTests, [endsWithTest]]
34+ in suite "String Tests" [isEmptyTests, lengthTest, reverseTest, repeatTest, unconsTests, appendTest, concatTest, splitTests, joinTests, endsWithTest]
tests/elm/Test/Trampoline.elm+3−3
@@ -21,9 +21,9 @@ goodSum n =
2121 _ -> Continue (\_ -> sumT (x-1) (acc+x))
2222 in trampoline <| sumT n 0
2323
24−tests : [Test]
24+tests : Test
2525tests =
2626 let mkLoopCheck n = test ("Equivalent Loop Check #"++ show n) (assertEqual (badSum n) (goodSum n))
27− loopChecks = map mkLoopCheck [0..25]
27+ loopChecks = suite "Equivalent to untrampolined Tests" <| map mkLoopCheck [0..25]
2828 noStackOverflow = test "Trampoline Deep Recursion Test" (assertEqual 500000500000 (goodSum 1000000))
29− in noStackOverflow :: loopChecks
29+ in suite "Trampoline Tests" [noStackOverflow, loopChecks]