File tree Expand file tree Collapse file tree 3 files changed +45
-0
lines changed Expand file tree Collapse file tree 3 files changed +45
-0
lines changed Original file line number Diff line number Diff line change 1
1
module Compiler.Platform exposing
2
2
( Platform(..)
3
+ , isCompatible
4
+ --
5
+ , toString
3
6
, toJson
4
7
, jsonDecoder
5
8
)
@@ -15,6 +18,19 @@ type Platform
15
18
| Common
16
19
17
20
21
+ isCompatible : Platform -> Platform -> Bool
22
+ isCompatible a b =
23
+ a == b || b == Common
24
+
25
+
26
+ toString : Platform -> String
27
+ toString platform =
28
+ when platform is
29
+ Common -> "common"
30
+ Browser -> "browser"
31
+ Node -> "node"
32
+
33
+
18
34
toJson : Platform -> Encode.Value
19
35
toJson platform =
20
36
when platform is
Original file line number Diff line number Diff line change @@ -9,6 +9,7 @@ import Test.SemanticVersionRange as SemanticVersionRange
9
9
import Test.Compiler.Dependencies as Dependencies
10
10
import Test.Compiler.PackageName as PackageName
11
11
import Test.Compiler.ModuleName as ModuleName
12
+ import Test.Compiler.Platform as Platform
12
13
import Test.String.EditDistance as EditDistance
13
14
import Node exposing (Program)
14
15
24
25
, SemanticVersionRange.tests
25
26
, PackageName.tests
26
27
, ModuleName.tests
28
+ , Platform.tests
27
29
, EditDistance.tests
28
30
]
Original file line number Diff line number Diff line change
1
+ module Test.Compiler.Platform exposing (tests)
2
+
3
+ import Expect exposing (Expectation)
4
+ import Test exposing (Test, describe, test)
5
+ import Fuzz exposing (Fuzzer)
6
+ import Compiler.Platform as P
7
+
8
+
9
+ tests : Test
10
+ tests =
11
+ describe "Platform"
12
+ [ describe "isCompatible"
13
+ [ test "equals" <| \{} ->
14
+ Expect.all
15
+ [ \_ -> Expect.equal True (P.isCompatible P.Node P.Node)
16
+ , \_ -> Expect.equal True (P.isCompatible P.Browser P.Browser)
17
+ , \_ -> Expect.equal True (P.isCompatible P.Common P.Common)
18
+ ]
19
+ {}
20
+ , test "common is always compatible" <| \{} ->
21
+ Expect.all
22
+ [ \_ -> Expect.equal True (P.isCompatible P.Node P.Common)
23
+ , \_ -> Expect.equal True (P.isCompatible P.Browser P.Common)
24
+ ]
25
+ {}
26
+ ]
27
+ ]
You can’t perform that action at this time.
0 commit comments