mirror of
https://github.com/mdgriffith/elm-optimize-level-2.git
synced 2024-11-22 06:56:11 +03:00
add basic tests for replacments
This commit is contained in:
parent
9b173b8650
commit
f270cefaee
28
elm.json
Normal file
28
elm.json
Normal file
@ -0,0 +1,28 @@
|
||||
{
|
||||
"type": "application",
|
||||
"source-directories": [
|
||||
"src"
|
||||
],
|
||||
"elm-version": "0.19.1",
|
||||
"dependencies": {
|
||||
"direct": {
|
||||
"elm/browser": "1.0.2",
|
||||
"elm/core": "1.0.5",
|
||||
"elm/html": "1.0.0"
|
||||
},
|
||||
"indirect": {
|
||||
"elm/json": "1.1.3",
|
||||
"elm/time": "1.0.0",
|
||||
"elm/url": "1.0.0",
|
||||
"elm/virtual-dom": "1.0.2"
|
||||
}
|
||||
},
|
||||
"test-dependencies": {
|
||||
"direct": {
|
||||
"elm-explorations/test": "1.2.2"
|
||||
},
|
||||
"indirect": {
|
||||
"elm/random": "1.0.0"
|
||||
}
|
||||
}
|
||||
}
|
75
tests/Replacements.elm
Normal file
75
tests/Replacements.elm
Normal file
@ -0,0 +1,75 @@
|
||||
module Replacements exposing (..)
|
||||
|
||||
import Expect exposing (Expectation)
|
||||
import Fuzz exposing (Fuzzer, int, list, string)
|
||||
import Test exposing (..)
|
||||
|
||||
|
||||
suite : Test
|
||||
suite =
|
||||
describe "Tests for js code replacements"
|
||||
[ list
|
||||
, string
|
||||
]
|
||||
|
||||
|
||||
list : Test
|
||||
list =
|
||||
describe "List"
|
||||
[ test "List.all" <|
|
||||
\_ ->
|
||||
Expect.equal True
|
||||
(List.all (\i -> i == 1) [ 1, 1, 1, 1 ])
|
||||
, test "List.append" <|
|
||||
\_ ->
|
||||
Expect.equal [ 1, 2, 3, 4, 5, 6 ]
|
||||
(List.append [ 1, 2, 3 ] [ 4, 5, 6 ])
|
||||
, test "List.concat" <|
|
||||
\_ ->
|
||||
Expect.equal [ 1, 2, 3, 4, 5, 6 ]
|
||||
(List.concat [ [ 1, 2, 3 ], [ 4, 5, 6 ] ])
|
||||
, test "List.concatMap" <|
|
||||
\_ ->
|
||||
Expect.equal [ 1, 2, 3, 4, 5, 6 ]
|
||||
(List.concatMap identity [ [ 1, 2, 3 ], [ 4, 5, 6 ] ])
|
||||
, test "List.filter" <|
|
||||
\_ ->
|
||||
Expect.equal [ 1, 2, 3, 4, 5, 6 ]
|
||||
(List.filter (\_ -> True) [ 1, 2, 3, 4, 5, 6 ])
|
||||
, test "List.filter (only even)" <|
|
||||
\_ ->
|
||||
Expect.equal [ 2, 4, 6 ]
|
||||
(List.filter (\i -> modBy 2 i == 0) [ 1, 2, 3, 4, 5, 6 ])
|
||||
, test "List.indexedMap" <|
|
||||
\_ ->
|
||||
Expect.equal [ 0, 1, 2, 3, 4, 5 ]
|
||||
(List.indexedMap (\i n -> i) [ 1, 2, 3, 4, 5, 6 ])
|
||||
, test "List.intersperse" <|
|
||||
\_ ->
|
||||
Expect.equal [ 1, 10, 2, 10, 3, 10, 4, 10, 5, 10, 6 ]
|
||||
(List.intersperse 10 [ 1, 2, 3, 4, 5, 6 ])
|
||||
, test "List.take" <|
|
||||
\_ ->
|
||||
Expect.equal [ 1, 2 ]
|
||||
(List.take 2 [ 1, 2, 3, 4, 5, 6 ])
|
||||
, test "List.unzip" <|
|
||||
\_ ->
|
||||
Expect.equal ( [ 1, 2 ], [ 3, 4 ] )
|
||||
(List.unzip [ ( 1, 3 ), ( 2, 4 ) ])
|
||||
]
|
||||
|
||||
|
||||
string : Test
|
||||
string =
|
||||
describe "String"
|
||||
[ test "String.repeat 4" <|
|
||||
\_ ->
|
||||
Expect.equal
|
||||
"nananana"
|
||||
(String.repeat 4 "na")
|
||||
, test "String.repeat 10" <|
|
||||
\_ ->
|
||||
Expect.equal
|
||||
"nananananananananana"
|
||||
(String.repeat 10 "na")
|
||||
]
|
Loading…
Reference in New Issue
Block a user