on master help sign in
Merge pull request #1041 from laszlopandy/expected-js-tests

Expected js output tests

commit616aff966f41d13a1c10dc1fe2df0bd9644d6349 authorEvan Czaplicki <info@elm-lang.org> dateWed 2 Sep 2015, 14:38 (11 years ago) parent7c72c5c5ed4eea
24 files changed+576−25
tests/Test/Compiler.hs+116−25 tests/test-files/good-expected-js/AliasSubstitution.elm.js+19 tests/test-files/good-expected-js/Lists/EmptyList.elm.js+16 tests/test-files/good-expected-js/Lists/ListRange.elm.js+16 tests/test-files/good-expected-js/Lists/NonEmptyList.elm.js+18 tests/test-files/good-expected-js/NoExpressions.elm.js+14 tests/test-files/good-expected-js/Otherwise.elm.js+18 tests/test-files/good-expected-js/Ports.elm.js+74 tests/test-files/good-expected-js/PortsWithTypeAliases.elm.js+38 tests/test-files/good-expected-js/QuotesAndComments.elm.js+25 tests/test-files/good-expected-js/Soundness/Apply.elm.js+21 tests/test-files/good-expected-js/Soundness/ApplyAnnotated.elm.js+21 tests/test-files/good-expected-js/Soundness/Id.elm.js+21 tests/test-files/good-expected-js/Soundness/IdAnnotated.elm.js+21 tests/test-files/good-expected-js/Soundness/TrickyId.elm.js+19 tests/test-files/good-expected-js/Soundness/TrickyIdAnnotated.elm.js+19 tests/test-files/good-expected-js/Strings/Multiline.elm.js+16 tests/test-files/good-expected-js/Strings/MultilineNormal.elm.js+16 tests/test-files/good-expected-js/TailRecursive.elm.js+28 tests/test-files/good-expected-js/Unify/NonHomogeneousRecords.elm.js+24 tests/test-files/good/Lists/EmptyList.elm+2 tests/test-files/good/Lists/ListRange.elm+2 tests/test-files/good/Lists/NonEmptyList.elm+2 tests/test-files/good/TailRecursive.elm+10
tests/Test/Compiler.hs+116−25
@@ -1,32 +1,45 @@
11{-# OPTIONS_GHC -W #-}
2+{-# LANGUAGE ScopedTypeVariables #-}
23module Test.Compiler (compilerTests) where
34
5+import Control.Exception (try, IOException)
6+
47import qualified Data.Map as Map
8+import Data.Maybe (isJust)
59import Data.Traversable (traverse)
610
7−import System.FilePath ((</>))
11+import System.Directory (createDirectoryIfMissing)
12+import System.Environment (lookupEnv)
13+import System.FilePath ((</>), (<.>), dropFileName, joinPath, splitDirectories)
814import System.FilePath.Find (find, (==?), extension)
915
1016import Test.Framework
1117import Test.Framework.Providers.HUnit (testCase)
12−import Test.HUnit (Assertion, assertFailure, assertBool)
18+import Test.HUnit (Assertion, assertFailure, assertBool, assertEqual)
1319
1420import qualified Elm.Compiler as Compiler
1521import qualified Elm.Package as Package
1622
23+writeExpectedJsEnvVarName :: String
24+writeExpectedJsEnvVarName =
25+ "ELM_WRITE_NEW_EXPECTED"
26+
27+
1728compilerTests :: Test
1829compilerTests =
19− buildTest $ do
20− goods <- testIf isSuccess =<< getElms "good"
21− bads <- testIf isFailure =<< getElms "bad"
22− return $
23− testGroup "Compile Tests"
24− [ testGroup "Good Tests" goods
25− , testGroup "Bad Tests" bads
26− ]
30+ buildTest $
31+ do goods <- testIf isSuccess =<< getElms "good"
32+ bads <- testIf isFailure =<< getElms "bad"
33+ expectedJsTests <- testMatchesExpected "good" "good-expected-js"
34+ return $
35+ testGroup "Compile Tests"
36+ [ testGroup "Good Tests" goods
37+ , testGroup "Bad Tests" bads
38+ , testGroup "Expected JS Tests" expectedJsTests
39+ ]
2740
2841
29−-- GATHER ELM FILES
42+-- GATHER FILES
3043
3144getElms :: FilePath -> IO [FilePath]
3245getElms filePath =
@@ -40,29 +53,91 @@ testsDir :: FilePath
4053testsDir =
4154 "tests" </> "test-files"
4255
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
4376
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
4590
4691testIf
4792 :: (Either String Compiler.Result -> Assertion)
4893 -> [FilePath]
4994 -> IO [Test]
5095testIf handleResult filePaths =
51− traverse setupTest filePaths
52− where
53− setupTest filePath = do
54− source <- readFile filePath
96+ let doTest filePath =
97+ do source <- readFile filePath
98+ let formattedResult = compileString filePath source
99+ return $ testCase filePath (handleResult formattedResult)
100+ in
101+ traverse doTest filePaths
102+
103+
104+doMatchesExpectedTest :: String -> FilePath -> IO Test
105+doMatchesExpectedTest expectedJsDir filePath =
106+ do source <- readFile filePath
107+ expectedJs <- readFileOrErrorStr (convertToExpectedJsFilePath expectedJsDir filePath)
55108
56− let context =
57− Compiler.Context Package.coreName True False []
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
109+ let formattedResult = compileString filePath source
110+ let assertion = matchesExpected expectedJs formattedResult
64111
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
66141
67142
68143-- CHECK RESULTS
@@ -86,3 +161,19 @@ isFailure result =
86161 Left _ ->
87162 assertBool "" True
88163
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