on master help sign in
Merge pull request #1041 from laszlopandy/expected-js-tests
616aff9Evan Czaplicki
tests/Test/Compiler.hs+116−25
@@ -1,32 +1,45 @@
1{-# OPTIONS_GHC -W #-}
1{-# OPTIONS_GHC -W #-}
2+{-# LANGUAGE ScopedTypeVariables #-}
2module Test.Compiler (compilerTests) where
3module Test.Compiler (compilerTests) where
3
4
5+import Control.Exception (try, IOException)
6+
4import qualified Data.Map as Map
7import qualified Data.Map as Map
8+import Data.Maybe (isJust)
5import Data.Traversable (traverse)
9import Data.Traversable (traverse)
6
10
7−import System.FilePath ((</>))
11+import System.Directory (createDirectoryIfMissing)
12+import System.Environment (lookupEnv)
13+import System.FilePath ((</>), (<.>), dropFileName, joinPath, splitDirectories)
8import System.FilePath.Find (find, (==?), extension)
14import System.FilePath.Find (find, (==?), extension)
9
15
10import Test.Framework
16import Test.Framework
11import Test.Framework.Providers.HUnit (testCase)
17import Test.Framework.Providers.HUnit (testCase)
12−import Test.HUnit (Assertion, assertFailure, assertBool)
18+import Test.HUnit (Assertion, assertFailure, assertBool, assertEqual)
13
19
14import qualified Elm.Compiler as Compiler
20import qualified Elm.Compiler as Compiler
15import qualified Elm.Package as Package
21import qualified Elm.Package as Package
16
22
23+writeExpectedJsEnvVarName :: String
24+writeExpectedJsEnvVarName =
25+ "ELM_WRITE_NEW_EXPECTED"
26+
27+
17compilerTests :: Test
28compilerTests :: Test
18compilerTests =
29compilerTests =
19− buildTest $ do
30+ buildTest $
20− goods <- testIf isSuccess =<< getElms "good"
31+ do goods <- testIf isSuccess =<< getElms "good"
21− bads <- testIf isFailure =<< getElms "bad"
32+ bads <- testIf isFailure =<< getElms "bad"
33+ expectedJsTests <- testMatchesExpected "good" "good-expected-js"
22− return $
34+ return $
23− testGroup "Compile Tests"
35+ testGroup "Compile Tests"
24− [ testGroup "Good Tests" goods
36+ [ testGroup "Good Tests" goods
25− , testGroup "Bad Tests" bads
37+ , testGroup "Bad Tests" bads
38+ , testGroup "Expected JS Tests" expectedJsTests
26− ]
39+ ]
27
40
28
41
29−-- GATHER ELM FILES
42+-- GATHER FILES
30
43
31getElms :: FilePath -> IO [FilePath]
44getElms :: FilePath -> IO [FilePath]
32getElms filePath =
45getElms filePath =
@@ -40,29 +53,91 @@ testsDir :: FilePath
40testsDir =
53testsDir =
41 "tests" </> "test-files"
54 "tests" </> "test-files"
42
55
56+convertToExpectedJsFilePath :: String -> FilePath -> FilePath
57+convertToExpectedJsFilePath expectedJsDir filePath =
58+ testsDir
59+ </> expectedJsDir
60+ </> joinPath (drop 3 (splitDirectories filePath))
61+ <.> ".js"
62+
63+
64+-- TEST HELPERS
65+
66+compileString :: FilePath -> String -> Either String Compiler.Result
67+compileString filePath source =
68+ let context =
69+ Compiler.Context Package.coreName True False []
70+ (dealiaser, _warnings, result) =
71+ Compiler.compile context source Map.empty
72+ formatErrors errors =
73+ concatMap (Compiler.errorToString dealiaser filePath source) errors
74+ in
75+ either (Left . formatErrors) Right result
43
76
44−-- RUN COMPILER
77+
78+readFileOrErrorStr :: FilePath -> IO String
79+readFileOrErrorStr filePath =
80+ do strOrExc <- try $ readFile filePath
81+ case strOrExc of
82+ Right s ->
83+ return s
84+
85+ Left (e :: IOException) ->
86+ return (show e)
87+
88+
89+-- RUN TESTS
45
90
46testIf
91testIf
47 :: (Either String Compiler.Result -> Assertion)
92 :: (Either String Compiler.Result -> Assertion)
48 -> [FilePath]
93 -> [FilePath]
49 -> IO [Test]
94 -> IO [Test]
50testIf handleResult filePaths =
95testIf handleResult filePaths =
96+ let doTest filePath =
97+ do source <- readFile filePath
98+ let formattedResult = compileString filePath source
99+ return $ testCase filePath (handleResult formattedResult)
100+ in
51− traverse setupTest filePaths
101+ traverse doTest filePaths
52− where
102+
53− setupTest filePath = do
103+
54− source <- readFile filePath
104+doMatchesExpectedTest :: String -> FilePath -> IO Test
105+doMatchesExpectedTest expectedJsDir filePath =
106+ do source <- readFile filePath
107+ expectedJs <- readFileOrErrorStr (convertToExpectedJsFilePath expectedJsDir filePath)
55
108
56− let context =
109+ let formattedResult = compileString filePath source
57− Compiler.Context Package.coreName True False []
110+ let assertion = matchesExpected expectedJs formattedResult
58− let (dealiaser, _warnings, result) =
59− Compiler.compile context source Map.empty
60− let formatErrors errors =
61− concatMap (Compiler.errorToString dealiaser filePath source) errors
62− let formattedResult =
63− either (Left . formatErrors) Right result
64
111
65− return $ testCase filePath (handleResult formattedResult)
112+ return $ testCase filePath assertion
113+
114+
115+doWriteNewExpectedTest :: String -> FilePath -> IO Test
116+doWriteNewExpectedTest expectedJsDir filePath =
117+ do source <- readFile filePath
118+ let formattedResult = compileString filePath source
119+ let expectedFilePath = convertToExpectedJsFilePath expectedJsDir filePath
120+ let assertion =
121+ case formattedResult of
122+ Right (Compiler.Result _ _ js) ->
123+ do createDirectoryIfMissing True (dropFileName expectedFilePath)
124+ writeFile expectedFilePath js
125+ assertFailure ("Wrote new expected js: " ++ expectedFilePath)
126+
127+ _ ->
128+ assertFailure "Compile failed. Could not write new expected js."
129+ return $ testCase filePath assertion
130+
131+
132+testMatchesExpected :: String -> String -> IO [Test]
133+testMatchesExpected elmDir expectedJsDir =
134+ do elmFiles <- getElms elmDir
135+ envVar <- lookupEnv writeExpectedJsEnvVarName
136+ if isJust envVar
137+ then
138+ traverse (doWriteNewExpectedTest expectedJsDir) elmFiles
139+ else
140+ traverse (doMatchesExpectedTest expectedJsDir) elmFiles
66
141
67
142
68-- CHECK RESULTS
143-- CHECK RESULTS
@@ -86,3 +161,19 @@ isFailure result =
86 Left _ ->
161 Left _ ->
87 assertBool "" True
162 assertBool "" True
88
163
164+
165+matchesExpected :: String -> Either String Compiler.Result -> Assertion
166+matchesExpected expectedJs result =
167+ case result of
168+ Right (Compiler.Result _ _ js) ->
169+ assertEqual matchFailureMessage expectedJs js
170+
171+ Left errorMessages ->
172+ assertFailure $ "Compile failed:\n" ++ errorMessages
173+
174+
175+matchFailureMessage :: String
176+matchFailureMessage =
177+ "Compiled JS did not match expected JS." ++
178+ "\n If the change is intentional, rerun " ++
179+ "the tests with environment variable: " ++ writeExpectedJsEnvVarName ++ "=1"
tests/test-files/good-expected-js/AliasSubstitution.elm.jsnew file+19
@@ -0,0 +1,19 @@
1+Elm.Main = Elm.Main || {};
2+Elm.Main.make = function (_elm) {
3+ "use strict";
4+ _elm.Main = _elm.Main || {};
5+ if (_elm.Main.values)
6+ return _elm.Main.values;
7+ var _op = {},
8+ _N = Elm.Native,
9+ _U = _N.Utils.make(_elm),
10+ _L = _N.List.make(_elm),
11+ $moduleName = "Main";
12+ var extractVec = function (v) {
13+ return {_: {},x: v.x,y: v.y};
14+ };
15+ _elm.Main.values = {_op: _op
16+ ,Vec2Ext: Vec2Ext
17+ ,extractVec: extractVec};
18+ return _elm.Main.values;
19+};
tests/test-files/good-expected-js/Lists/EmptyList.elm.jsnew file+16
@@ -0,0 +1,16 @@
1+Elm.Main = Elm.Main || {};
2+Elm.Main.make = function (_elm) {
3+ "use strict";
4+ _elm.Main = _elm.Main || {};
5+ if (_elm.Main.values)
6+ return _elm.Main.values;
7+ var _op = {},
8+ _N = Elm.Native,
9+ _U = _N.Utils.make(_elm),
10+ _L = _N.List.make(_elm),
11+ $moduleName = "Main";
12+ var emptyList = _L.fromArray([]);
13+ _elm.Main.values = {_op: _op
14+ ,emptyList: emptyList};
15+ return _elm.Main.values;
16+};
tests/test-files/good-expected-js/Lists/ListRange.elm.jsnew file+16
@@ -0,0 +1,16 @@
1+Elm.Main = Elm.Main || {};
2+Elm.Main.make = function (_elm) {
3+ "use strict";
4+ _elm.Main = _elm.Main || {};
5+ if (_elm.Main.values)
6+ return _elm.Main.values;
7+ var _op = {},
8+ _N = Elm.Native,
9+ _U = _N.Utils.make(_elm),
10+ _L = _N.List.make(_elm),
11+ $moduleName = "Main";
12+ var listRange = _L.range(2,10);
13+ _elm.Main.values = {_op: _op
14+ ,listRange: listRange};
15+ return _elm.Main.values;
16+};
tests/test-files/good-expected-js/Lists/NonEmptyList.elm.jsnew file+18
@@ -0,0 +1,18 @@
1+Elm.Main = Elm.Main || {};
2+Elm.Main.make = function (_elm) {
3+ "use strict";
4+ _elm.Main = _elm.Main || {};
5+ if (_elm.Main.values)
6+ return _elm.Main.values;
7+ var _op = {},
8+ _N = Elm.Native,
9+ _U = _N.Utils.make(_elm),
10+ _L = _N.List.make(_elm),
11+ $moduleName = "Main";
12+ var nonEmptyList = _L.fromArray([1
13+ ,4
14+ ,5]);
15+ _elm.Main.values = {_op: _op
16+ ,nonEmptyList: nonEmptyList};
17+ return _elm.Main.values;
18+};
tests/test-files/good-expected-js/NoExpressions.elm.jsnew file+14
@@ -0,0 +1,14 @@
1+Elm.Main = Elm.Main || {};
2+Elm.Main.make = function (_elm) {
3+ "use strict";
4+ _elm.Main = _elm.Main || {};
5+ if (_elm.Main.values)
6+ return _elm.Main.values;
7+ var _op = {},
8+ _N = Elm.Native,
9+ _U = _N.Utils.make(_elm),
10+ _L = _N.List.make(_elm),
11+ $moduleName = "Main";
12+ _elm.Main.values = {_op: _op};
13+ return _elm.Main.values;
14+};
tests/test-files/good-expected-js/Otherwise.elm.jsnew file+18
@@ -0,0 +1,18 @@
1+Elm.Otherwise = Elm.Otherwise || {};
2+Elm.Otherwise.make = function (_elm) {
3+ "use strict";
4+ _elm.Otherwise = _elm.Otherwise || {};
5+ if (_elm.Otherwise.values)
6+ return _elm.Otherwise.values;
7+ var _op = {},
8+ _N = Elm.Native,
9+ _U = _N.Utils.make(_elm),
10+ _L = _N.List.make(_elm),
11+ $moduleName = "Otherwise";
12+ var boo = false ? "Yay" : "Boo";
13+ var otherwise = 3;
14+ _elm.Otherwise.values = {_op: _op
15+ ,otherwise: otherwise
16+ ,boo: boo};
17+ return _elm.Otherwise.values;
18+};
tests/test-files/good-expected-js/Ports.elm.jsnew file+74
@@ -0,0 +1,74 @@
1+Elm.Main = Elm.Main || {};
2+Elm.Main.make = function (_elm) {
3+ "use strict";
4+ _elm.Main = _elm.Main || {};
5+ if (_elm.Main.values)
6+ return _elm.Main.values;
7+ var _op = {},
8+ _N = Elm.Native,
9+ _U = _N.Utils.make(_elm),
10+ _L = _N.List.make(_elm),
11+ $moduleName = "Main";
12+ var students = Elm.Native.Port.make(_elm).outbound("students",
13+ function (v) {
14+ return Elm.Native.List.make(_elm).toArray(v).map(function (v) {
15+ return {name: v.name
16+ ,age: v.age};
17+ });
18+ },
19+ _L.fromArray([{_: {}
20+ ,age: 42
21+ ,name: "Tom"}]));
22+ var time = Elm.Native.Port.make(_elm).outbound("time",
23+ function (v) {
24+ return v;
25+ },
26+ 3.14);
27+ var fortyTwo = Elm.Native.Port.make(_elm).outbound("fortyTwo",
28+ function (v) {
29+ return v;
30+ },
31+ 42);
32+ var record = Elm.Native.Port.make(_elm).inbound("record",
33+ "{ x : Float, y : Float }",
34+ function (v) {
35+ return typeof v === "object" && "x" in v && "y" in v ? {_: {}
36+ ,x: typeof v.x === "number" ? v.x : _U.badPort("a number",
37+ v.x)
38+ ,y: typeof v.y === "number" ? v.y : _U.badPort("a number",
39+ v.y)} : _U.badPort("an object with fields `x`, `y`",
40+ v);
41+ });
42+ var array = Elm.Native.Port.make(_elm).inbound("array",
43+ "List Int",
44+ function (v) {
45+ return typeof v === "object" && v instanceof Array ? Elm.Native.List.make(_elm).fromArray(v.map(function (v) {
46+ return typeof v === "number" ? v : _U.badPort("a number",
47+ v);
48+ })) : _U.badPort("an array",v);
49+ });
50+ var tuple = Elm.Native.Port.make(_elm).inbound("tuple",
51+ "(Float, Bool)",
52+ function (v) {
53+ return typeof v === "object" && v instanceof Array ? {ctor: "_Tuple2"
54+ ,_0: typeof v[0] === "number" ? v[0] : _U.badPort("a number",
55+ v[0])
56+ ,_1: typeof v[1] === "boolean" ? v[1] : _U.badPort("a boolean (true or false)",
57+ v[1])} : _U.badPort("an array",
58+ v);
59+ });
60+ var number = Elm.Native.Port.make(_elm).inbound("number",
61+ "Int",
62+ function (v) {
63+ return typeof v === "number" ? v : _U.badPort("a number",
64+ v);
65+ });
66+ var userID = Elm.Native.Port.make(_elm).inbound("userID",
67+ "String",
68+ function (v) {
69+ return typeof v === "string" || typeof v === "object" && v instanceof String ? v : _U.badPort("a string",
70+ v);
71+ });
72+ _elm.Main.values = {_op: _op};
73+ return _elm.Main.values;
74+};
tests/test-files/good-expected-js/PortsWithTypeAliases.elm.jsnew file+38
@@ -0,0 +1,38 @@
1+Elm.Main = Elm.Main || {};
2+Elm.Main.make = function (_elm) {
3+ "use strict";
4+ _elm.Main = _elm.Main || {};
5+ if (_elm.Main.values)
6+ return _elm.Main.values;
7+ var _op = {},
8+ _N = Elm.Native,
9+ _U = _N.Utils.make(_elm),
10+ _L = _N.List.make(_elm),
11+ $moduleName = "Main";
12+ var pairs = Elm.Native.Port.make(_elm).inbound("pairs",
13+ "Main.Point String String",
14+ function (v) {
15+ return typeof v === "object" && "x" in v && "y" in v ? {_: {}
16+ ,x: typeof v.x === "string" || typeof v.x === "object" && v.x instanceof String ? v.x : _U.badPort("a string",
17+ v.x)
18+ ,y: typeof v.y === "string" || typeof v.y === "object" && v.y instanceof String ? v.y : _U.badPort("a string",
19+ v.y)} : _U.badPort("an object with fields `x`, `y`",
20+ v);
21+ });
22+ var points = Elm.Native.Port.make(_elm).inbound("points",
23+ "Main.Point2D",
24+ function (v) {
25+ return typeof v === "object" && "x" in v && "y" in v ? {_: {}
26+ ,x: typeof v.x === "number" ? v.x : _U.badPort("a number",
27+ v.x)
28+ ,y: typeof v.y === "number" ? v.y : _U.badPort("a number",
29+ v.y)} : _U.badPort("an object with fields `x`, `y`",
30+ v);
31+ });
32+ var Point = F2(function (a,b) {
33+ return {_: {},x: a,y: b};
34+ });
35+ _elm.Main.values = {_op: _op
36+ ,Point: Point};
37+ return _elm.Main.values;
38+};
tests/test-files/good-expected-js/QuotesAndComments.elm.jsnew file+25
@@ -0,0 +1,25 @@
1+Elm.Main = Elm.Main || {};
2+Elm.Main.make = function (_elm) {
3+ "use strict";
4+ _elm.Main = _elm.Main || {};
5+ if (_elm.Main.values)
6+ return _elm.Main.values;
7+ var _op = {},
8+ _N = Elm.Native,
9+ _U = _N.Utils.make(_elm),
10+ _L = _N.List.make(_elm),
11+ $moduleName = "Main";
12+ var commentStart = "{-";
13+ var singleQuote = _U.chr("\'");
14+ var doubleQuote = _U.chr("\"");
15+ var variablesWithPrimes = function (x) {
16+ var x$ = x;
17+ return x$;
18+ };
19+ _elm.Main.values = {_op: _op
20+ ,variablesWithPrimes: variablesWithPrimes
21+ ,doubleQuote: doubleQuote
22+ ,singleQuote: singleQuote
23+ ,commentStart: commentStart};
24+ return _elm.Main.values;
25+};
tests/test-files/good-expected-js/Soundness/Apply.elm.jsnew file+21
@@ -0,0 +1,21 @@
1+Elm.Main = Elm.Main || {};
2+Elm.Main.make = function (_elm) {
3+ "use strict";
4+ _elm.Main = _elm.Main || {};
5+ if (_elm.Main.values)
6+ return _elm.Main.values;
7+ var _op = {},
8+ _N = Elm.Native,
9+ _U = _N.Utils.make(_elm),
10+ _L = _N.List.make(_elm),
11+ $moduleName = "Main";
12+ var apply = function (f) {
13+ var g = function (x) {
14+ return f(x);
15+ };
16+ return g;
17+ };
18+ _elm.Main.values = {_op: _op
19+ ,apply: apply};
20+ return _elm.Main.values;
21+};
tests/test-files/good-expected-js/Soundness/ApplyAnnotated.elm.jsnew file+21
@@ -0,0 +1,21 @@
1+Elm.Main = Elm.Main || {};
2+Elm.Main.make = function (_elm) {
3+ "use strict";
4+ _elm.Main = _elm.Main || {};
5+ if (_elm.Main.values)
6+ return _elm.Main.values;
7+ var _op = {},
8+ _N = Elm.Native,
9+ _U = _N.Utils.make(_elm),
10+ _L = _N.List.make(_elm),
11+ $moduleName = "Main";
12+ var apply = function (f) {
13+ var g = function (x) {
14+ return f(x);
15+ };
16+ return g;
17+ };
18+ _elm.Main.values = {_op: _op
19+ ,apply: apply};
20+ return _elm.Main.values;
21+};
tests/test-files/good-expected-js/Soundness/Id.elm.jsnew file+21
@@ -0,0 +1,21 @@
1+Elm.Main = Elm.Main || {};
2+Elm.Main.make = function (_elm) {
3+ "use strict";
4+ _elm.Main = _elm.Main || {};
5+ if (_elm.Main.values)
6+ return _elm.Main.values;
7+ var _op = {},
8+ _N = Elm.Native,
9+ _U = _N.Utils.make(_elm),
10+ _L = _N.List.make(_elm),
11+ $moduleName = "Main";
12+ var myId = function () {
13+ var id = function (x) {
14+ return x;
15+ };
16+ return id;
17+ }();
18+ _elm.Main.values = {_op: _op
19+ ,myId: myId};
20+ return _elm.Main.values;
21+};
tests/test-files/good-expected-js/Soundness/IdAnnotated.elm.jsnew file+21
@@ -0,0 +1,21 @@
1+Elm.Main = Elm.Main || {};
2+Elm.Main.make = function (_elm) {
3+ "use strict";
4+ _elm.Main = _elm.Main || {};
5+ if (_elm.Main.values)
6+ return _elm.Main.values;
7+ var _op = {},
8+ _N = Elm.Native,
9+ _U = _N.Utils.make(_elm),
10+ _L = _N.List.make(_elm),
11+ $moduleName = "Main";
12+ var myId = function () {
13+ var id = function (x) {
14+ return x;
15+ };
16+ return id;
17+ }();
18+ _elm.Main.values = {_op: _op
19+ ,myId: myId};
20+ return _elm.Main.values;
21+};
tests/test-files/good-expected-js/Soundness/TrickyId.elm.jsnew file+19
@@ -0,0 +1,19 @@
1+Elm.Main = Elm.Main || {};
2+Elm.Main.make = function (_elm) {
3+ "use strict";
4+ _elm.Main = _elm.Main || {};
5+ if (_elm.Main.values)
6+ return _elm.Main.values;
7+ var _op = {},
8+ _N = Elm.Native,
9+ _U = _N.Utils.make(_elm),
10+ _L = _N.List.make(_elm),
11+ $moduleName = "Main";
12+ var myId = function (x) {
13+ var y = x;
14+ return y;
15+ };
16+ _elm.Main.values = {_op: _op
17+ ,myId: myId};
18+ return _elm.Main.values;
19+};
tests/test-files/good-expected-js/Soundness/TrickyIdAnnotated.elm.jsnew file+19
@@ -0,0 +1,19 @@
1+Elm.Main = Elm.Main || {};
2+Elm.Main.make = function (_elm) {
3+ "use strict";
4+ _elm.Main = _elm.Main || {};
5+ if (_elm.Main.values)
6+ return _elm.Main.values;
7+ var _op = {},
8+ _N = Elm.Native,
9+ _U = _N.Utils.make(_elm),
10+ _L = _N.List.make(_elm),
11+ $moduleName = "Main";
12+ var myId = function (x) {
13+ var y = x;
14+ return y;
15+ };
16+ _elm.Main.values = {_op: _op
17+ ,myId: myId};
18+ return _elm.Main.values;
19+};
tests/test-files/good-expected-js/Strings/Multiline.elm.jsnew file+16
@@ -0,0 +1,16 @@
1+Elm.Main = Elm.Main || {};
2+Elm.Main.make = function (_elm) {
3+ "use strict";
4+ _elm.Main = _elm.Main || {};
5+ if (_elm.Main.values)
6+ return _elm.Main.values;
7+ var _op = {},
8+ _N = Elm.Native,
9+ _U = _N.Utils.make(_elm),
10+ _L = _N.List.make(_elm),
11+ $moduleName = "Main";
12+ var s = "\nhere\'s a quote: \"\n\n";
13+ _elm.Main.values = {_op: _op
14+ ,s: s};
15+ return _elm.Main.values;
16+};
tests/test-files/good-expected-js/Strings/MultilineNormal.elm.jsnew file+16
@@ -0,0 +1,16 @@
1+Elm.Main = Elm.Main || {};
2+Elm.Main.make = function (_elm) {
3+ "use strict";
4+ _elm.Main = _elm.Main || {};
5+ if (_elm.Main.values)
6+ return _elm.Main.values;
7+ var _op = {},
8+ _N = Elm.Native,
9+ _U = _N.Utils.make(_elm),
10+ _L = _N.List.make(_elm),
11+ $moduleName = "Main";
12+ var s = "\nhere\'s a quote: \"\n\n";
13+ _elm.Main.values = {_op: _op
14+ ,s: s};
15+ return _elm.Main.values;
16+};
tests/test-files/good-expected-js/TailRecursive.elm.jsnew file+28
@@ -0,0 +1,28 @@
1+Elm.Main = Elm.Main || {};
2+Elm.Main.make = function (_elm) {
3+ "use strict";
4+ _elm.Main = _elm.Main || {};
5+ if (_elm.Main.values)
6+ return _elm.Main.values;
7+ var _op = {},
8+ _N = Elm.Native,
9+ _U = _N.Utils.make(_elm),
10+ _L = _N.List.make(_elm),
11+ $moduleName = "Main";
12+ var any = F2(function (f,l) {
13+ _v0: while (true) {
14+ switch (l.ctor)
15+ {case "::": if (f(l._0))
16+ return true; else {
17+ var _v4 = f,_v5 = l._1;
18+ f = _v4;
19+ l = _v5;
20+ continue _v0;
21+ }}
22+ return false;
23+ }
24+ });
25+ _elm.Main.values = {_op: _op
26+ ,any: any};
27+ return _elm.Main.values;
28+};
tests/test-files/good-expected-js/Unify/NonHomogeneousRecords.elm.jsnew file+24
@@ -0,0 +1,24 @@
1+Elm.Main = Elm.Main || {};
2+Elm.Main.make = function (_elm) {
3+ "use strict";
4+ _elm.Main = _elm.Main || {};
5+ if (_elm.Main.values)
6+ return _elm.Main.values;
7+ var _op = {},
8+ _N = Elm.Native,
9+ _U = _N.Utils.make(_elm),
10+ _L = _N.List.make(_elm),
11+ $moduleName = "Main";
12+ var f = function (t) {
13+ var y = t.y;
14+ var x = t.x;
15+ return t;
16+ };
17+ var Thing = F2(function (a,b) {
18+ return {_: {},x: a,y: b};
19+ });
20+ _elm.Main.values = {_op: _op
21+ ,Thing: Thing
22+ ,f: f};
23+ return _elm.Main.values;
24+};
tests/test-files/good/Lists/EmptyList.elmnew file+2
@@ -0,0 +1,2 @@
1+
2+emptyList = []
tests/test-files/good/Lists/ListRange.elmnew file+2
@@ -0,0 +1,2 @@
1+
2+listRange = [2..10]
tests/test-files/good/Lists/NonEmptyList.elmnew file+2
@@ -0,0 +1,2 @@
1+
2+nonEmptyList = [1,4,5]
tests/test-files/good/TailRecursive.elmnew file+10
@@ -0,0 +1,10 @@
1+
2+any f l =
3+ case l of
4+ x :: xs ->
5+ if f x then
6+ True
7+ else
8+ any f xs
9+ _ ->
10+ False