diff --git a/CHANGELOG.md b/CHANGELOG.md index 0b9f8c3366..3c4d4ed6b9 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -62,6 +62,7 @@ - Move `ounit_tests` into the `tests` folder. https://github.com/rescript-lang/rescript-compiler/pull/7096 - Move `syntax_tests` into the `tests` folder. https://github.com/rescript-lang/rescript-compiler/pull/7090 https://github.com/rescript-lang/rescript-compiler/pull/7097 - Capitalize runtime filenames. https://github.com/rescript-lang/rescript-compiler/pull/7110 +- Build mocha tests as esmodule / .mjs. https://github.com/rescript-lang/rescript-compiler/pull/7115 # 12.0.0-alpha.3 diff --git a/biome.json b/biome.json index d0163d504c..9899a7bbc5 100644 --- a/biome.json +++ b/biome.json @@ -23,7 +23,6 @@ "ignore": [ "tests/build_tests/**", "tests/tests/**", - "tests/tests_esmodule/**", "lib/**", "ninja/**", "playground/**", diff --git a/scripts/test.js b/scripts/test.js index ebba6688c9..f55482b211 100644 --- a/scripts/test.js +++ b/scripts/test.js @@ -65,12 +65,7 @@ async function runTests() { stdio: [0, 1, 2], }); - cp.execSync(rescript_exe, { - cwd: path.join(__dirname, "..", "tests/tests_esmodule"), - stdio: [0, 1, 2], - }); - - cp.execSync(`npx mocha -t 10000 tests/tests/**/*_test.js`, { + cp.execSync(`npx mocha -t 10000 tests/tests/**/*_test.mjs`, { cwd: path.join(__dirname, ".."), stdio: [0, 1, 2], }); diff --git a/tests/tests/rescript.json b/tests/tests/rescript.json index 69ceca9c90..c7dfdd6f05 100644 --- a/tests/tests/rescript.json +++ b/tests/tests/rescript.json @@ -7,8 +7,9 @@ } ], "package-specs": { - "module": "commonjs", - "in-source": true + "module": "esmodule", + "in-source": true, + "suffix": ".mjs" }, "bsc-flags": [ "-w -3-6-26-27-29-30-32..40-44-45-52-60-9-106+104", diff --git a/tests/tests/src/AsInUncurriedExternals.js b/tests/tests/src/AsInUncurriedExternals.js deleted file mode 100644 index 70125156e8..0000000000 --- a/tests/tests/src/AsInUncurriedExternals.js +++ /dev/null @@ -1,26 +0,0 @@ -// Generated by ReScript, PLEASE EDIT WITH CARE -'use strict'; - - -function mo(prim0, prim1) { - return { - objectMode: false, - name: prim0, - someOther: true - }; -} - -let options = { - objectMode: false, - name: "foo", - someOther: true -}; - -function shouldNotFail(objectMode, name) { - return 3; -} - -exports.mo = mo; -exports.options = options; -exports.shouldNotFail = shouldNotFail; -/* No side effect */ diff --git a/tests/tests/src/AsInUncurriedExternals.mjs b/tests/tests/src/AsInUncurriedExternals.mjs new file mode 100644 index 0000000000..28e4aa1779 --- /dev/null +++ b/tests/tests/src/AsInUncurriedExternals.mjs @@ -0,0 +1,27 @@ +// Generated by ReScript, PLEASE EDIT WITH CARE + + +function mo(prim0, prim1) { + return { + objectMode: false, + name: prim0, + someOther: true + }; +} + +let options = { + objectMode: false, + name: "foo", + someOther: true +}; + +function shouldNotFail(objectMode, name) { + return 3; +} + +export { + mo, + options, + shouldNotFail, +} +/* No side effect */ diff --git a/tests/tests/src/Coercion.js b/tests/tests/src/Coercion.js deleted file mode 100644 index 2758b87ff9..0000000000 --- a/tests/tests/src/Coercion.js +++ /dev/null @@ -1,16 +0,0 @@ -// Generated by ReScript, PLEASE EDIT WITH CARE -'use strict'; - - -function foo(x) { - return x; -} - -let x = 1; - -let xx = 1; - -exports.x = x; -exports.xx = xx; -exports.foo = foo; -/* No side effect */ diff --git a/tests/tests/src/Coercion.mjs b/tests/tests/src/Coercion.mjs new file mode 100644 index 0000000000..09865533c0 --- /dev/null +++ b/tests/tests/src/Coercion.mjs @@ -0,0 +1,17 @@ +// Generated by ReScript, PLEASE EDIT WITH CARE + + +function foo(x) { + return x; +} + +let x = 1; + +let xx = 1; + +export { + x, + xx, + foo, +} +/* No side effect */ diff --git a/tests/tests/src/DerivingAccessorsCurried.js b/tests/tests/src/DerivingAccessorsCurried.js deleted file mode 100644 index 49a7d6079e..0000000000 --- a/tests/tests/src/DerivingAccessorsCurried.js +++ /dev/null @@ -1,56 +0,0 @@ -// Generated by ReScript, PLEASE EDIT WITH CARE -'use strict'; - - -function myField(param) { - return param.myField; -} - -function num(param_0) { - return { - TAG: "Num", - _0: param_0 - }; -} - -function doubleNum(param_0, param_1) { - return { - TAG: "DoubleNum", - _0: param_0, - _1: param_1 - }; -} - -function compose(a, accessor) { - return accessor(a); -} - -let _composedMyField = 1; - -let _composedNum = { - TAG: "Num", - _0: 1 -}; - -let noParam = "NoParam"; - -let _myFieldAlias = myField; - -let _noParamAlias = "NoParam"; - -let _numAlias = num; - -let _doubleNumAlias = doubleNum; - -exports.myField = myField; -exports.noParam = noParam; -exports.num = num; -exports.doubleNum = doubleNum; -exports._myFieldAlias = _myFieldAlias; -exports._noParamAlias = _noParamAlias; -exports._numAlias = _numAlias; -exports._doubleNumAlias = _doubleNumAlias; -exports.compose = compose; -exports._composedMyField = _composedMyField; -exports._composedNum = _composedNum; -/* No side effect */ diff --git a/tests/tests/src/DerivingAccessorsCurried.mjs b/tests/tests/src/DerivingAccessorsCurried.mjs new file mode 100644 index 0000000000..a816cc5575 --- /dev/null +++ b/tests/tests/src/DerivingAccessorsCurried.mjs @@ -0,0 +1,57 @@ +// Generated by ReScript, PLEASE EDIT WITH CARE + + +function myField(param) { + return param.myField; +} + +function num(param_0) { + return { + TAG: "Num", + _0: param_0 + }; +} + +function doubleNum(param_0, param_1) { + return { + TAG: "DoubleNum", + _0: param_0, + _1: param_1 + }; +} + +function compose(a, accessor) { + return accessor(a); +} + +let _composedMyField = 1; + +let _composedNum = { + TAG: "Num", + _0: 1 +}; + +let noParam = "NoParam"; + +let _myFieldAlias = myField; + +let _noParamAlias = "NoParam"; + +let _numAlias = num; + +let _doubleNumAlias = doubleNum; + +export { + myField, + noParam, + num, + doubleNum, + _myFieldAlias, + _noParamAlias, + _numAlias, + _doubleNumAlias, + compose, + _composedMyField, + _composedNum, +} +/* No side effect */ diff --git a/tests/tests/src/DerivingAccessorsUncurried.js b/tests/tests/src/DerivingAccessorsUncurried.js deleted file mode 100644 index 49a7d6079e..0000000000 --- a/tests/tests/src/DerivingAccessorsUncurried.js +++ /dev/null @@ -1,56 +0,0 @@ -// Generated by ReScript, PLEASE EDIT WITH CARE -'use strict'; - - -function myField(param) { - return param.myField; -} - -function num(param_0) { - return { - TAG: "Num", - _0: param_0 - }; -} - -function doubleNum(param_0, param_1) { - return { - TAG: "DoubleNum", - _0: param_0, - _1: param_1 - }; -} - -function compose(a, accessor) { - return accessor(a); -} - -let _composedMyField = 1; - -let _composedNum = { - TAG: "Num", - _0: 1 -}; - -let noParam = "NoParam"; - -let _myFieldAlias = myField; - -let _noParamAlias = "NoParam"; - -let _numAlias = num; - -let _doubleNumAlias = doubleNum; - -exports.myField = myField; -exports.noParam = noParam; -exports.num = num; -exports.doubleNum = doubleNum; -exports._myFieldAlias = _myFieldAlias; -exports._noParamAlias = _noParamAlias; -exports._numAlias = _numAlias; -exports._doubleNumAlias = _doubleNumAlias; -exports.compose = compose; -exports._composedMyField = _composedMyField; -exports._composedNum = _composedNum; -/* No side effect */ diff --git a/tests/tests/src/DerivingAccessorsUncurried.mjs b/tests/tests/src/DerivingAccessorsUncurried.mjs new file mode 100644 index 0000000000..a816cc5575 --- /dev/null +++ b/tests/tests/src/DerivingAccessorsUncurried.mjs @@ -0,0 +1,57 @@ +// Generated by ReScript, PLEASE EDIT WITH CARE + + +function myField(param) { + return param.myField; +} + +function num(param_0) { + return { + TAG: "Num", + _0: param_0 + }; +} + +function doubleNum(param_0, param_1) { + return { + TAG: "DoubleNum", + _0: param_0, + _1: param_1 + }; +} + +function compose(a, accessor) { + return accessor(a); +} + +let _composedMyField = 1; + +let _composedNum = { + TAG: "Num", + _0: 1 +}; + +let noParam = "NoParam"; + +let _myFieldAlias = myField; + +let _noParamAlias = "NoParam"; + +let _numAlias = num; + +let _doubleNumAlias = doubleNum; + +export { + myField, + noParam, + num, + doubleNum, + _myFieldAlias, + _noParamAlias, + _numAlias, + _doubleNumAlias, + compose, + _composedMyField, + _composedNum, +} +/* No side effect */ diff --git a/tests/tests/src/DictInference.js b/tests/tests/src/DictInference.js deleted file mode 100644 index 24a2e5dc63..0000000000 --- a/tests/tests/src/DictInference.js +++ /dev/null @@ -1,16 +0,0 @@ -// Generated by ReScript, PLEASE EDIT WITH CARE -'use strict'; - -let Js_dict = require("rescript/lib/js/Js_dict.js"); - -let dict = {}; - -dict["someKey1"] = 1; - -dict["someKey2"] = 2; - -let asArray = Js_dict.values(dict); - -exports.dict = dict; -exports.asArray = asArray; -/* Not a pure module */ diff --git a/tests/tests/src/DictInference.mjs b/tests/tests/src/DictInference.mjs new file mode 100644 index 0000000000..cbeae632fc --- /dev/null +++ b/tests/tests/src/DictInference.mjs @@ -0,0 +1,17 @@ +// Generated by ReScript, PLEASE EDIT WITH CARE + +import * as Js_dict from "rescript/lib/es6/Js_dict.js"; + +let dict = {}; + +dict["someKey1"] = 1; + +dict["someKey2"] = 2; + +let asArray = Js_dict.values(dict); + +export { + dict, + asArray, +} +/* Not a pure module */ diff --git a/tests/tests/src/DictInternalRepresentation.js b/tests/tests/src/DictInternalRepresentation.js deleted file mode 100644 index 641a311cdb..0000000000 --- a/tests/tests/src/DictInternalRepresentation.js +++ /dev/null @@ -1,28 +0,0 @@ -// Generated by ReScript, PLEASE EDIT WITH CARE -'use strict'; - - -let stringDict = { - first: "hello" -}; - -let intDict = { - first: 1 -}; - -function foo() { - let first = stringDict.first; - let first$1 = first !== undefined ? first + "2" : "hello"; - console.log(first$1); - let first$2 = intDict.first; - let second = first$2 !== undefined ? first$2 + 2 | 0 : 1; - console.log(second); - let first$3 = stringDict.first; - let third = first$3 !== undefined ? first$3 + "2" : "hello"; - console.log(third); -} - -exports.stringDict = stringDict; -exports.intDict = intDict; -exports.foo = foo; -/* No side effect */ diff --git a/tests/tests/src/DictInternalRepresentation.mjs b/tests/tests/src/DictInternalRepresentation.mjs new file mode 100644 index 0000000000..062d1755ae --- /dev/null +++ b/tests/tests/src/DictInternalRepresentation.mjs @@ -0,0 +1,29 @@ +// Generated by ReScript, PLEASE EDIT WITH CARE + + +let stringDict = { + first: "hello" +}; + +let intDict = { + first: 1 +}; + +function foo() { + let first = stringDict.first; + let first$1 = first !== undefined ? first + "2" : "hello"; + console.log(first$1); + let first$2 = intDict.first; + let second = first$2 !== undefined ? first$2 + 2 | 0 : 1; + console.log(second); + let first$3 = stringDict.first; + let third = first$3 !== undefined ? first$3 + "2" : "hello"; + console.log(third); +} + +export { + stringDict, + intDict, + foo, +} +/* No side effect */ diff --git a/tests/tests/src/DictTests.js b/tests/tests/src/DictTests.js deleted file mode 100644 index 5d9df63325..0000000000 --- a/tests/tests/src/DictTests.js +++ /dev/null @@ -1,63 +0,0 @@ -// Generated by ReScript, PLEASE EDIT WITH CARE -'use strict'; - - -let someString = "hello"; - -let createdDict = { - name: "hello", - age: "what", - more: "stuff", - otherStr: someString -}; - -let intDict = { - one: 1, - two: 2, - three: 3 -}; - -function inferDictByPattern(dict) { - let match = dict.one; - if (match === 1) { - let match$1 = dict.three; - if (match$1 === 3) { - let match$2 = dict.four; - if (match$2 === 4) { - dict["five"] = 5; - return; - } - - } - - } - let match$3 = dict.two; - if (match$3 === 1) { - console.log("two"); - } else { - console.log("not one"); - } -} - -function constrainedAsDict(dict) { - let match = dict.one; - if (match === 1) { - console.log("one"); - } else { - console.log("not one"); - } -} - -let PatternMatching = { - inferDictByPattern: inferDictByPattern, - constrainedAsDict: constrainedAsDict -}; - -let three = 3; - -exports.someString = someString; -exports.createdDict = createdDict; -exports.three = three; -exports.intDict = intDict; -exports.PatternMatching = PatternMatching; -/* No side effect */ diff --git a/tests/tests/src/DictTests.mjs b/tests/tests/src/DictTests.mjs new file mode 100644 index 0000000000..703caeb496 --- /dev/null +++ b/tests/tests/src/DictTests.mjs @@ -0,0 +1,64 @@ +// Generated by ReScript, PLEASE EDIT WITH CARE + + +let someString = "hello"; + +let createdDict = { + name: "hello", + age: "what", + more: "stuff", + otherStr: someString +}; + +let intDict = { + one: 1, + two: 2, + three: 3 +}; + +function inferDictByPattern(dict) { + let match = dict.one; + if (match === 1) { + let match$1 = dict.three; + if (match$1 === 3) { + let match$2 = dict.four; + if (match$2 === 4) { + dict["five"] = 5; + return; + } + + } + + } + let match$3 = dict.two; + if (match$3 === 1) { + console.log("two"); + } else { + console.log("not one"); + } +} + +function constrainedAsDict(dict) { + let match = dict.one; + if (match === 1) { + console.log("one"); + } else { + console.log("not one"); + } +} + +let PatternMatching = { + inferDictByPattern: inferDictByPattern, + constrainedAsDict: constrainedAsDict +}; + +let three = 3; + +export { + someString, + createdDict, + three, + intDict, + PatternMatching, +} +/* No side effect */ diff --git a/tests/tests/src/DisambiguateOptionalFields.js b/tests/tests/src/DisambiguateOptionalFields.js deleted file mode 100644 index 976d5e9947..0000000000 --- a/tests/tests/src/DisambiguateOptionalFields.js +++ /dev/null @@ -1,24 +0,0 @@ -// Generated by ReScript, PLEASE EDIT WITH CARE -'use strict'; - - -function f1(v) { - return v.x; -} - -function f2(v) { - return v.x; -} - -let res = 3; - -let v = { - x: 3, - y: 4 -}; - -exports.f1 = f1; -exports.f2 = f2; -exports.v = v; -exports.res = res; -/* No side effect */ diff --git a/tests/tests/src/DisambiguateOptionalFields.mjs b/tests/tests/src/DisambiguateOptionalFields.mjs new file mode 100644 index 0000000000..ac27a889db --- /dev/null +++ b/tests/tests/src/DisambiguateOptionalFields.mjs @@ -0,0 +1,25 @@ +// Generated by ReScript, PLEASE EDIT WITH CARE + + +function f1(v) { + return v.x; +} + +function f2(v) { + return v.x; +} + +let res = 3; + +let v = { + x: 3, + y: 4 +}; + +export { + f1, + f2, + v, + res, +} +/* No side effect */ diff --git a/tests/tests/src/DotDotDot.js b/tests/tests/src/DotDotDot.js deleted file mode 100644 index 0676103de3..0000000000 --- a/tests/tests/src/DotDotDot.js +++ /dev/null @@ -1,35 +0,0 @@ -// Generated by ReScript, PLEASE EDIT WITH CARE -'use strict'; - - -let MultipleDotDotDots = { - x: { - x: 10, - y: "abc" - } -}; - -let v = { - x: 10, - y: "", - z: "" -}; - -let v2 = { - x: 10, - y: "", - z: "", - v: 1.0, - w: 2.0 -}; - -let x = { - name: "test", - x: "test" -}; - -exports.v = v; -exports.v2 = v2; -exports.x = x; -exports.MultipleDotDotDots = MultipleDotDotDots; -/* No side effect */ diff --git a/tests/tests/src/DotDotDot.mjs b/tests/tests/src/DotDotDot.mjs new file mode 100644 index 0000000000..cd6bc310bc --- /dev/null +++ b/tests/tests/src/DotDotDot.mjs @@ -0,0 +1,36 @@ +// Generated by ReScript, PLEASE EDIT WITH CARE + + +let MultipleDotDotDots = { + x: { + x: 10, + y: "abc" + } +}; + +let v = { + x: 10, + y: "", + z: "" +}; + +let v2 = { + x: 10, + y: "", + z: "", + v: 1.0, + w: 2.0 +}; + +let x = { + name: "test", + x: "test" +}; + +export { + v, + v2, + x, + MultipleDotDotDots, +} +/* No side effect */ diff --git a/tests/tests/src/EmptyRecord.js b/tests/tests/src/EmptyRecord.js deleted file mode 100644 index 57aa613b2b..0000000000 --- a/tests/tests/src/EmptyRecord.js +++ /dev/null @@ -1,19 +0,0 @@ -// Generated by ReScript, PLEASE EDIT WITH CARE -'use strict'; - - -function construct(b) { - if (b) { - return { - n: 0 - }; - } else { - return {}; - } -} - -let er = {}; - -exports.construct = construct; -exports.er = er; -/* No side effect */ diff --git a/tests/tests/src/EmptyRecord.mjs b/tests/tests/src/EmptyRecord.mjs new file mode 100644 index 0000000000..de9024c1ab --- /dev/null +++ b/tests/tests/src/EmptyRecord.mjs @@ -0,0 +1,20 @@ +// Generated by ReScript, PLEASE EDIT WITH CARE + + +function construct(b) { + if (b) { + return { + n: 0 + }; + } else { + return {}; + } +} + +let er = {}; + +export { + construct, + er, +} +/* No side effect */ diff --git a/tests/tests/src/ExternalArity.js b/tests/tests/src/ExternalArity.js deleted file mode 100644 index 433cfc052c..0000000000 --- a/tests/tests/src/ExternalArity.js +++ /dev/null @@ -1,45 +0,0 @@ -// Generated by ReScript, PLEASE EDIT WITH CARE -'use strict'; - -let ReactIntl = require("react-intl"); -let JsxRuntime = require("react/jsx-runtime"); - -function f1(x) { - return v(x, x); -} - -function f2(x) { - return v(x, x); -} - -let test1 = foo1(10); - -let test2 = foo2(20); - -let test3 = foo3(undefined, 3); - -let FromTypeConstructor = { - test1: test1, - test2: test2, - test3: test3 -}; - -let React = {}; - -let FormattedMessage = {}; - -JsxRuntime.jsx(ReactIntl.FormattedMessage, { - id: "test", - defaultMessage: "Test" -}); - -let ReactTest = { - React: React, - FormattedMessage: FormattedMessage -}; - -exports.f1 = f1; -exports.f2 = f2; -exports.FromTypeConstructor = FromTypeConstructor; -exports.ReactTest = ReactTest; -/* test1 Not a pure module */ diff --git a/tests/tests/src/ExternalArity.mjs b/tests/tests/src/ExternalArity.mjs new file mode 100644 index 0000000000..1de3ab38f2 --- /dev/null +++ b/tests/tests/src/ExternalArity.mjs @@ -0,0 +1,46 @@ +// Generated by ReScript, PLEASE EDIT WITH CARE + +import * as ReactIntl from "react-intl"; +import * as JsxRuntime from "react/jsx-runtime"; + +function f1(x) { + return v(x, x); +} + +function f2(x) { + return v(x, x); +} + +let test1 = foo1(10); + +let test2 = foo2(20); + +let test3 = foo3(undefined, 3); + +let FromTypeConstructor = { + test1: test1, + test2: test2, + test3: test3 +}; + +let React = {}; + +let FormattedMessage = {}; + +JsxRuntime.jsx(ReactIntl.FormattedMessage, { + id: "test", + defaultMessage: "Test" +}); + +let ReactTest = { + React: React, + FormattedMessage: FormattedMessage +}; + +export { + f1, + f2, + FromTypeConstructor, + ReactTest, +} +/* test1 Not a pure module */ diff --git a/tests/tests/src/FFI.js b/tests/tests/src/FFI.js deleted file mode 100644 index bdcec5cad2..0000000000 --- a/tests/tests/src/FFI.js +++ /dev/null @@ -1,13 +0,0 @@ -// Generated by ReScript, PLEASE EDIT WITH CARE -'use strict'; - - -let canUseCanvas = (function canUseCanvas() { - return !!document.createElement('canvas').getContext; - }); - -let add = ((x,y)=>x+y); - -exports.canUseCanvas = canUseCanvas; -exports.add = add; -/* No side effect */ diff --git a/tests/tests/src/FFI.mjs b/tests/tests/src/FFI.mjs new file mode 100644 index 0000000000..5d3c2a968a --- /dev/null +++ b/tests/tests/src/FFI.mjs @@ -0,0 +1,14 @@ +// Generated by ReScript, PLEASE EDIT WITH CARE + + +let canUseCanvas = (function canUseCanvas() { + return !!document.createElement('canvas').getContext; + }); + +let add = ((x,y)=>x+y); + +export { + canUseCanvas, + add, +} +/* No side effect */ diff --git a/tests/tests/src/Import.js b/tests/tests/src/Import.js deleted file mode 100644 index c5ffd55992..0000000000 --- a/tests/tests/src/Import.js +++ /dev/null @@ -1,148 +0,0 @@ -// Generated by ReScript, PLEASE EDIT WITH CARE -'use strict'; - -let Js_promise = require("rescript/lib/js/Js_promise.js"); - -async function eachIntAsync(list, f) { - return (await import("rescript/lib/js/Belt_List.js").then(m => m.forEach))(list, f); -} - -function eachIntLazy(list, f) { - return Js_promise.then_(each => Promise.resolve(each(list, f)), import("rescript/lib/js/Belt_List.js").then(m => m.forEach)); -} - -eachIntLazy({ - hd: 1, - tl: { - hd: 2, - tl: { - hd: 3, - tl: /* [] */0 - } - } -}, n => { - console.log("lazy", n); -}); - -eachIntAsync({ - hd: 1, - tl: { - hd: 2, - tl: { - hd: 3, - tl: /* [] */0 - } - } -}, n => { - console.log("async", n); -}); - -let beltAsModule = await import("rescript/lib/js/Belt_List.js"); - -let M = await import("rescript/lib/js/Belt_List.js"); - -let N0 = await import("rescript/lib/js/Belt_List.js"); - -let O = await import("rescript/lib/js/Belt_List.js"); - -let N1_each = O.forEach; - -let N1 = { - O: O, - each: N1_each -}; - -let N2 = await import("rescript/lib/js/Belt_List.js"); - -let N_each = N2.forEach; - -let N = { - N0: N0, - N1: N1, - N2: N2, - each: N_each -}; - -let M0 = await import("rescript/lib/js/Belt_List.js"); - -let M1 = await import("rescript/lib/js/Belt_List.js"); - -async function f() { - return (await import("rescript/lib/js/Belt_List.js")).forEach; -} - -async function f1() { - return (await import("rescript/lib/js/Belt_List.js")).forEach; -} - -async function f2() { - let M3 = await import("rescript/lib/js/Belt_List.js"); - let M4 = await import("rescript/lib/js/Belt_List.js"); - return [ - M3.forEach, - M4.forEach - ]; -} - -async function f3() { - let M3 = await import("rescript/lib/js/Belt_List.js"); - let M4 = await import("rescript/lib/js/Belt_List.js"); - return [ - M3.forEach, - M4.forEach - ]; -} - -async function f4() { - return (await import("rescript/lib/js/Belt_Array.js")).forEach; -} - -async function f5() { - let A = await import("rescript/lib/js/Belt_Array.js"); - let O = await import("rescript/lib/js/Belt_Option.js"); - return [ - A.forEach, - O.forEach - ]; -} - -async function f6() { - let MS = await import("rescript/lib/js/Belt_MapString.js"); - let A = await import("rescript/lib/js/Belt_Array.js"); - return [ - 0, - MS.forEach, - A.forEach - ]; -} - -async function f7() { - await import("rescript/lib/js/Belt_MapInt.js"); - return 1; -} - -let each = M1.forEach; - -let M2; - -let each2 = O.forEach; - -exports.eachIntAsync = eachIntAsync; -exports.eachIntLazy = eachIntLazy; -exports.beltAsModule = beltAsModule; -exports.M = M; -exports.N = N; -exports.M0 = M0; -exports.M1 = M1; -exports.each = each; -exports.M2 = M2; -exports.each2 = each2; -exports.f = f; -exports.f1 = f1; -exports.f2 = f2; -exports.f3 = f3; -exports.f4 = f4; -exports.f5 = f5; -exports.f6 = f6; -exports.f7 = f7; -/* Not a pure module */ diff --git a/tests/tests/src/Import.mjs b/tests/tests/src/Import.mjs new file mode 100644 index 0000000000..88bd6e1554 --- /dev/null +++ b/tests/tests/src/Import.mjs @@ -0,0 +1,149 @@ +// Generated by ReScript, PLEASE EDIT WITH CARE + +import * as Js_promise from "rescript/lib/es6/Js_promise.js"; + +async function eachIntAsync(list, f) { + return (await import("rescript/lib/es6/Belt_List.js").then(m => m.forEach))(list, f); +} + +function eachIntLazy(list, f) { + return Js_promise.then_(each => Promise.resolve(each(list, f)), import("rescript/lib/es6/Belt_List.js").then(m => m.forEach)); +} + +eachIntLazy({ + hd: 1, + tl: { + hd: 2, + tl: { + hd: 3, + tl: /* [] */0 + } + } +}, n => { + console.log("lazy", n); +}); + +eachIntAsync({ + hd: 1, + tl: { + hd: 2, + tl: { + hd: 3, + tl: /* [] */0 + } + } +}, n => { + console.log("async", n); +}); + +let beltAsModule = await import("rescript/lib/es6/Belt_List.js"); + +let M = await import("rescript/lib/es6/Belt_List.js"); + +let N0 = await import("rescript/lib/es6/Belt_List.js"); + +let O = await import("rescript/lib/es6/Belt_List.js"); + +let N1_each = O.forEach; + +let N1 = { + O: O, + each: N1_each +}; + +let N2 = await import("rescript/lib/es6/Belt_List.js"); + +let N_each = N2.forEach; + +let N = { + N0: N0, + N1: N1, + N2: N2, + each: N_each +}; + +let M0 = await import("rescript/lib/es6/Belt_List.js"); + +let M1 = await import("rescript/lib/es6/Belt_List.js"); + +async function f() { + return (await import("rescript/lib/es6/Belt_List.js")).forEach; +} + +async function f1() { + return (await import("rescript/lib/es6/Belt_List.js")).forEach; +} + +async function f2() { + let M3 = await import("rescript/lib/es6/Belt_List.js"); + let M4 = await import("rescript/lib/es6/Belt_List.js"); + return [ + M3.forEach, + M4.forEach + ]; +} + +async function f3() { + let M3 = await import("rescript/lib/es6/Belt_List.js"); + let M4 = await import("rescript/lib/es6/Belt_List.js"); + return [ + M3.forEach, + M4.forEach + ]; +} + +async function f4() { + return (await import("rescript/lib/es6/Belt_Array.js")).forEach; +} + +async function f5() { + let A = await import("rescript/lib/es6/Belt_Array.js"); + let O = await import("rescript/lib/es6/Belt_Option.js"); + return [ + A.forEach, + O.forEach + ]; +} + +async function f6() { + let MS = await import("rescript/lib/es6/Belt_MapString.js"); + let A = await import("rescript/lib/es6/Belt_Array.js"); + return [ + 0, + MS.forEach, + A.forEach + ]; +} + +async function f7() { + await import("rescript/lib/es6/Belt_MapInt.js"); + return 1; +} + +let each = M1.forEach; + +let M2; + +let each2 = O.forEach; + +export { + eachIntAsync, + eachIntLazy, + beltAsModule, + M, + N, + M0, + M1, + each, + M2, + each2, + f, + f1, + f2, + f3, + f4, + f5, + f6, + f7, +} +/* Not a pure module */ diff --git a/tests/tests_esmodule/src/ImportAttributes.mjs b/tests/tests/src/ImportAttributes.mjs similarity index 100% rename from tests/tests_esmodule/src/ImportAttributes.mjs rename to tests/tests/src/ImportAttributes.mjs diff --git a/tests/tests_esmodule/src/ImportAttributes.res b/tests/tests/src/ImportAttributes.res similarity index 100% rename from tests/tests_esmodule/src/ImportAttributes.res rename to tests/tests/src/ImportAttributes.res diff --git a/tests/tests/src/PartialApplicationNoRuntimeCurry.js b/tests/tests/src/PartialApplicationNoRuntimeCurry.js deleted file mode 100644 index 1a69368f5f..0000000000 --- a/tests/tests/src/PartialApplicationNoRuntimeCurry.js +++ /dev/null @@ -1,16 +0,0 @@ -// Generated by ReScript, PLEASE EDIT WITH CARE -'use strict'; - - -function add(x) { - return (y, z) => (x + y | 0) + z | 0; -} - -function f(u) { - let f$1 = add(u); - return extra => f$1(1, extra); -} - -exports.add = add; -exports.f = f; -/* No side effect */ diff --git a/tests/tests/src/PartialApplicationNoRuntimeCurry.mjs b/tests/tests/src/PartialApplicationNoRuntimeCurry.mjs new file mode 100644 index 0000000000..5f6d3c4bbf --- /dev/null +++ b/tests/tests/src/PartialApplicationNoRuntimeCurry.mjs @@ -0,0 +1,17 @@ +// Generated by ReScript, PLEASE EDIT WITH CARE + + +function add(x) { + return (y, z) => (x + y | 0) + z | 0; +} + +function f(u) { + let f$1 = add(u); + return extra => f$1(1, extra); +} + +export { + add, + f, +} +/* No side effect */ diff --git a/tests/tests/src/RecordCoercion.js b/tests/tests/src/RecordCoercion.js deleted file mode 100644 index e9fa2b9606..0000000000 --- a/tests/tests/src/RecordCoercion.js +++ /dev/null @@ -1,16 +0,0 @@ -// Generated by ReScript, PLEASE EDIT WITH CARE -'use strict'; - - -let TestInlining_a = { - number: 42, - name: "a" -}; - -let TestInlining = { - a: TestInlining_a, - name: "a" -}; - -exports.TestInlining = TestInlining; -/* No side effect */ diff --git a/tests/tests/src/RecordCoercion.mjs b/tests/tests/src/RecordCoercion.mjs new file mode 100644 index 0000000000..5db90d2501 --- /dev/null +++ b/tests/tests/src/RecordCoercion.mjs @@ -0,0 +1,17 @@ +// Generated by ReScript, PLEASE EDIT WITH CARE + + +let TestInlining_a = { + number: 42, + name: "a" +}; + +let TestInlining = { + a: TestInlining_a, + name: "a" +}; + +export { + TestInlining, +} +/* No side effect */ diff --git a/tests/tests/src/RecordOrObject.js b/tests/tests/src/RecordOrObject.js deleted file mode 100644 index 9735fdfe20..0000000000 --- a/tests/tests/src/RecordOrObject.js +++ /dev/null @@ -1,16 +0,0 @@ -// Generated by ReScript, PLEASE EDIT WITH CARE -'use strict'; - - -let vxy = { - x: 10, - y: "abc" -}; - -let xxi = { - x: 10 -}; - -exports.vxy = vxy; -exports.xxi = xxi; -/* No side effect */ diff --git a/tests/tests/src/RecordOrObject.mjs b/tests/tests/src/RecordOrObject.mjs new file mode 100644 index 0000000000..582f738a42 --- /dev/null +++ b/tests/tests/src/RecordOrObject.mjs @@ -0,0 +1,17 @@ +// Generated by ReScript, PLEASE EDIT WITH CARE + + +let vxy = { + x: 10, + y: "abc" +}; + +let xxi = { + x: 10 +}; + +export { + vxy, + xxi, +} +/* No side effect */ diff --git a/tests/tests/src/SafePromises.js b/tests/tests/src/SafePromises.js deleted file mode 100644 index b809531c71..0000000000 --- a/tests/tests/src/SafePromises.js +++ /dev/null @@ -1,32 +0,0 @@ -// Generated by ReScript, PLEASE EDIT WITH CARE -'use strict'; - -let Js_promise = require("rescript/lib/js/Js_promise.js"); -let Js_promise2 = require("rescript/lib/js/Js_promise2.js"); - -async function nestedPromise(xxx) { - let xx = await xxx; - Js_promise2.then(xx, x => Promise.resolve((console.log("Promise2.then", x), undefined))); - Js_promise2.$$catch(xx, x => { - console.log("Promise2.catch_", x); - return Promise.resolve(0); - }); - Js_promise.then_(x => Promise.resolve((console.log("Promise.then_", x), undefined)), xx); -} - -async function create(x) { - console.log("create", x); - return x; -} - -let xx = create(10); - -let xxx = create(xx); - -nestedPromise(xxx); - -exports.nestedPromise = nestedPromise; -exports.create = create; -exports.xx = xx; -exports.xxx = xxx; -/* xx Not a pure module */ diff --git a/tests/tests/src/SafePromises.mjs b/tests/tests/src/SafePromises.mjs new file mode 100644 index 0000000000..4a38f9e2a8 --- /dev/null +++ b/tests/tests/src/SafePromises.mjs @@ -0,0 +1,33 @@ +// Generated by ReScript, PLEASE EDIT WITH CARE + +import * as Js_promise from "rescript/lib/es6/Js_promise.js"; +import * as Js_promise2 from "rescript/lib/es6/Js_promise2.js"; + +async function nestedPromise(xxx) { + let xx = await xxx; + Js_promise2.then(xx, x => Promise.resolve((console.log("Promise2.then", x), undefined))); + Js_promise2.$$catch(xx, x => { + console.log("Promise2.catch_", x); + return Promise.resolve(0); + }); + Js_promise.then_(x => Promise.resolve((console.log("Promise.then_", x), undefined)), xx); +} + +async function create(x) { + console.log("create", x); + return x; +} + +let xx = create(10); + +let xxx = create(xx); + +nestedPromise(xxx); + +export { + nestedPromise, + create, + xx, + xxx, +} +/* xx Not a pure module */ diff --git a/tests/tests/src/UncurriedAlways.js b/tests/tests/src/UncurriedAlways.js deleted file mode 100644 index 601d3bfe3a..0000000000 --- a/tests/tests/src/UncurriedAlways.js +++ /dev/null @@ -1,268 +0,0 @@ -// Generated by ReScript, PLEASE EDIT WITH CARE -'use strict'; - - -function foo(x, y) { - return x + y | 0; -} - -let z = 7; - -function bar(x, y) { - return x + y | 0; -} - -let b = 7; - -let w = 7; - -let a = 7; - -console.log(a); - -[1].map(x => x + 1 | 0); - -function ptl(extra) { - return 10 + extra | 0; -} - -function foo2(x, y) { - return x + y | 0; -} - -function bar2(__x) { - return __x + 3 | 0; -} - -function foo3(x, y, z) { - return (x + y | 0) + z | 0; -} - -function bar3(__x) { - return foo3(__x, 3, 4); -} - -function q(param) { - return null; -} - -function inl() { - -} - -function inl2(x, y) { - return x + y | 0; -} - -function foo$1(x, y, z) { - return [ - x, - y, - z - ]; -} - -function ptl$1(none, extra) { - return [ - none, - "y", - extra - ]; -} - -let a1 = [ - "x", - "y", - "z" -]; - -console.log("a1:", a1); - -let AllLabels = { - foo: foo$1, - ptl: ptl$1, - a1: a1 -}; - -function foo$2(x, y, z, dOpt) { - let d = dOpt !== undefined ? dOpt : "d=0"; - return [ - x, - y, - z, - d - ]; -} - -function ptl$2(none, extra, extra$1) { - return foo$2(none, "y", extra, extra$1); -} - -let b1 = ptl$2("x", "z", undefined); - -console.log("b1:", b1); - -let b2 = ptl$2("x", "z", "d<-100"); - -console.log("b2:", b2); - -let OptAtEnd = { - foo: foo$2, - ptl: ptl$2, - b1: b1, - b2: b2 -}; - -function foo$3(d1Opt, x, d2Opt, y, d3Opt, z, d4Opt, w, d5Opt) { - let d1 = d1Opt !== undefined ? d1Opt : "d1=0"; - let d2 = d2Opt !== undefined ? d2Opt : "d2=0"; - let d3 = d3Opt !== undefined ? d3Opt : "d3=0"; - let d4 = d4Opt !== undefined ? d4Opt : "d4=0"; - let d5 = d5Opt !== undefined ? d5Opt : "d5=0"; - return [ - d1, - x, - d2, - y, - d3, - z, - d4, - w, - d5 - ]; -} - -function ptl$3(none, none$1, none$2, none$3, none$4, none$5, extra) { - return foo$3(none, none$1, none$2, "y", none$3, none$4, none$5, "w", extra); -} - -let c1 = ptl$3(undefined, "x", undefined, undefined, "z", undefined, undefined); - -console.log("c1:", c1); - -let c2 = ptl$3("d1<-100", "x", undefined, undefined, "z", undefined, undefined); - -console.log("c2:", c2); - -let c3 = ptl$3(undefined, "x", "d2<-200", undefined, "z", "d4<-400", undefined); - -console.log("c3:", c3); - -let OptMixed = { - foo: foo$3, - ptl: ptl$3, - c1: c1, - c2: c2, - c3: c3 -}; - -function fn(cb) { - return cb(); -} - -console.log({ - NAME: "foo", - VAL: undefined -}); - -function fn1(a, b, param) { - return a() + b | 0; -} - -function a$1(__x) { - return 3; -} - -function f3(x, y, z) { - console.log(x); - return (x + y | 0) + z | 0; -} - -function fx(extra, extra$1) { - return f3(1, extra, extra$1); -} - -function fy(none, extra) { - return f3(none, 1, extra); -} - -function fz(none, none$1) { - return f3(none, none$1, 1); -} - -let fxyz = f3(1, 1, 1); - -let PartialApplication = { - f3: f3, - fx: fx, - fy: fy, - fz: fz, - fxyz: fxyz -}; - -function hello1(y, f) { - return f(y); -} - -function hello2(y, f) { - return f(y); -} - -let ReverseApplication = { - hello1: hello1, - hello2: hello2 -}; - -function f(a, b, c) { - return [ - b(a), - c(a) - ]; -} - -function f2(a, b, c, d, e) { - let __tuple_internal_obj = a(b); - let param_0 = c(__tuple_internal_obj, d); - let param_1 = d(__tuple_internal_obj, 1, 2); - let param_2 = e(__tuple_internal_obj); - return (param_0 + param_1 | 0) + param_2 | 0; -} - -function f3$1(foo, x) { - return foo(x); -} - -function f4(x, f) { - return f(x, 3); -} - -let Pipe = { - f: f, - f2: f2, - f3: f3$1, - f4: f4 -}; - -exports.foo = foo; -exports.z = z; -exports.bar = bar; -exports.b = b; -exports.w = w; -exports.ptl = ptl; -exports.foo2 = foo2; -exports.bar2 = bar2; -exports.foo3 = foo3; -exports.bar3 = bar3; -exports.q = q; -exports.inl = inl; -exports.inl2 = inl2; -exports.AllLabels = AllLabels; -exports.OptAtEnd = OptAtEnd; -exports.OptMixed = OptMixed; -exports.fn = fn; -exports.fn1 = fn1; -exports.a = a$1; -exports.PartialApplication = PartialApplication; -exports.ReverseApplication = ReverseApplication; -exports.Pipe = Pipe; -/* Not a pure module */ diff --git a/tests/tests/src/UncurriedAlways.mjs b/tests/tests/src/UncurriedAlways.mjs new file mode 100644 index 0000000000..ca17405188 --- /dev/null +++ b/tests/tests/src/UncurriedAlways.mjs @@ -0,0 +1,269 @@ +// Generated by ReScript, PLEASE EDIT WITH CARE + + +function foo(x, y) { + return x + y | 0; +} + +let z = 7; + +function bar(x, y) { + return x + y | 0; +} + +let b = 7; + +let w = 7; + +let a = 7; + +console.log(a); + +[1].map(x => x + 1 | 0); + +function ptl(extra) { + return 10 + extra | 0; +} + +function foo2(x, y) { + return x + y | 0; +} + +function bar2(__x) { + return __x + 3 | 0; +} + +function foo3(x, y, z) { + return (x + y | 0) + z | 0; +} + +function bar3(__x) { + return foo3(__x, 3, 4); +} + +function q(param) { + return null; +} + +function inl() { + +} + +function inl2(x, y) { + return x + y | 0; +} + +function foo$1(x, y, z) { + return [ + x, + y, + z + ]; +} + +function ptl$1(none, extra) { + return [ + none, + "y", + extra + ]; +} + +let a1 = [ + "x", + "y", + "z" +]; + +console.log("a1:", a1); + +let AllLabels = { + foo: foo$1, + ptl: ptl$1, + a1: a1 +}; + +function foo$2(x, y, z, dOpt) { + let d = dOpt !== undefined ? dOpt : "d=0"; + return [ + x, + y, + z, + d + ]; +} + +function ptl$2(none, extra, extra$1) { + return foo$2(none, "y", extra, extra$1); +} + +let b1 = ptl$2("x", "z", undefined); + +console.log("b1:", b1); + +let b2 = ptl$2("x", "z", "d<-100"); + +console.log("b2:", b2); + +let OptAtEnd = { + foo: foo$2, + ptl: ptl$2, + b1: b1, + b2: b2 +}; + +function foo$3(d1Opt, x, d2Opt, y, d3Opt, z, d4Opt, w, d5Opt) { + let d1 = d1Opt !== undefined ? d1Opt : "d1=0"; + let d2 = d2Opt !== undefined ? d2Opt : "d2=0"; + let d3 = d3Opt !== undefined ? d3Opt : "d3=0"; + let d4 = d4Opt !== undefined ? d4Opt : "d4=0"; + let d5 = d5Opt !== undefined ? d5Opt : "d5=0"; + return [ + d1, + x, + d2, + y, + d3, + z, + d4, + w, + d5 + ]; +} + +function ptl$3(none, none$1, none$2, none$3, none$4, none$5, extra) { + return foo$3(none, none$1, none$2, "y", none$3, none$4, none$5, "w", extra); +} + +let c1 = ptl$3(undefined, "x", undefined, undefined, "z", undefined, undefined); + +console.log("c1:", c1); + +let c2 = ptl$3("d1<-100", "x", undefined, undefined, "z", undefined, undefined); + +console.log("c2:", c2); + +let c3 = ptl$3(undefined, "x", "d2<-200", undefined, "z", "d4<-400", undefined); + +console.log("c3:", c3); + +let OptMixed = { + foo: foo$3, + ptl: ptl$3, + c1: c1, + c2: c2, + c3: c3 +}; + +function fn(cb) { + return cb(); +} + +console.log({ + NAME: "foo", + VAL: undefined +}); + +function fn1(a, b, param) { + return a() + b | 0; +} + +function a$1(__x) { + return 3; +} + +function f3(x, y, z) { + console.log(x); + return (x + y | 0) + z | 0; +} + +function fx(extra, extra$1) { + return f3(1, extra, extra$1); +} + +function fy(none, extra) { + return f3(none, 1, extra); +} + +function fz(none, none$1) { + return f3(none, none$1, 1); +} + +let fxyz = f3(1, 1, 1); + +let PartialApplication = { + f3: f3, + fx: fx, + fy: fy, + fz: fz, + fxyz: fxyz +}; + +function hello1(y, f) { + return f(y); +} + +function hello2(y, f) { + return f(y); +} + +let ReverseApplication = { + hello1: hello1, + hello2: hello2 +}; + +function f(a, b, c) { + return [ + b(a), + c(a) + ]; +} + +function f2(a, b, c, d, e) { + let __tuple_internal_obj = a(b); + let param_0 = c(__tuple_internal_obj, d); + let param_1 = d(__tuple_internal_obj, 1, 2); + let param_2 = e(__tuple_internal_obj); + return (param_0 + param_1 | 0) + param_2 | 0; +} + +function f3$1(foo, x) { + return foo(x); +} + +function f4(x, f) { + return f(x, 3); +} + +let Pipe = { + f: f, + f2: f2, + f3: f3$1, + f4: f4 +}; + +export { + foo, + z, + bar, + b, + w, + ptl, + foo2, + bar2, + foo3, + bar3, + q, + inl, + inl2, + AllLabels, + OptAtEnd, + OptMixed, + fn, + fn1, + a$1 as a, + PartialApplication, + ReverseApplication, + Pipe, +} +/* Not a pure module */ diff --git a/tests/tests/src/UncurriedExternals.js b/tests/tests/src/UncurriedExternals.js deleted file mode 100644 index c90461e203..0000000000 --- a/tests/tests/src/UncurriedExternals.js +++ /dev/null @@ -1,75 +0,0 @@ -// Generated by ReScript, PLEASE EDIT WITH CARE -'use strict'; - -let React = require("react"); - -function dd() { - throw { - RE_EXN_ID: "Not_found", - Error: new Error() - }; -} - -let h = sum(1.0, 2.0); - -let M = { - sum: (prim0, prim1) => sum(prim0, prim1) -}; - -let hh = M.sum(1.0, 2.0); - -function tg(arr) { - return arr[0]; -} - -let tc = Object.assign({}, "abc"); - -let te = { - RE_EXN_ID: "Not_found" -}; - -let tcr = {}; - -function tsiC(c) { - c.increment = function (amount) { - let me = this ; - console.log(me); - }; -} - -function tsiU(c) { - c.increment = function (amount) { - let me = this ; - console.log(me); - }; -} - -let match = React.useState(() => 3); - -let StandardNotation_get = match[0]; - -let StandardNotation_set = match[1]; - -let StandardNotation = { - dd: dd, - h: h, - M: M, - hh: hh, - tg: tg, - tc: tc, - te: te, - tcr: tcr, - tsiC: tsiC, - tsiU: tsiU, - get: StandardNotation_get, - set: StandardNotation_set -}; - -function methodWithAsync() { - let $$this = this ; - return async arg => $$this + arg | 0; -} - -exports.StandardNotation = StandardNotation; -exports.methodWithAsync = methodWithAsync; -/* h Not a pure module */ diff --git a/tests/tests/src/UncurriedExternals.mjs b/tests/tests/src/UncurriedExternals.mjs new file mode 100644 index 0000000000..a50b793b71 --- /dev/null +++ b/tests/tests/src/UncurriedExternals.mjs @@ -0,0 +1,76 @@ +// Generated by ReScript, PLEASE EDIT WITH CARE + +import * as React from "react"; + +function dd() { + throw { + RE_EXN_ID: "Not_found", + Error: new Error() + }; +} + +let h = sum(1.0, 2.0); + +let M = { + sum: (prim0, prim1) => sum(prim0, prim1) +}; + +let hh = M.sum(1.0, 2.0); + +function tg(arr) { + return arr[0]; +} + +let tc = Object.assign({}, "abc"); + +let te = { + RE_EXN_ID: "Not_found" +}; + +let tcr = {}; + +function tsiC(c) { + c.increment = function (amount) { + let me = this ; + console.log(me); + }; +} + +function tsiU(c) { + c.increment = function (amount) { + let me = this ; + console.log(me); + }; +} + +let match = React.useState(() => 3); + +let StandardNotation_get = match[0]; + +let StandardNotation_set = match[1]; + +let StandardNotation = { + dd: dd, + h: h, + M: M, + hh: hh, + tg: tg, + tc: tc, + te: te, + tcr: tcr, + tsiC: tsiC, + tsiU: tsiU, + get: StandardNotation_get, + set: StandardNotation_set +}; + +function methodWithAsync() { + let $$this = this ; + return async arg => $$this + arg | 0; +} + +export { + StandardNotation, + methodWithAsync, +} +/* h Not a pure module */ diff --git a/tests/tests/src/UncurriedPervasives.js b/tests/tests/src/UncurriedPervasives.js deleted file mode 100644 index 9bb777e72f..0000000000 --- a/tests/tests/src/UncurriedPervasives.js +++ /dev/null @@ -1,10 +0,0 @@ -// Generated by ReScript, PLEASE EDIT WITH CARE -'use strict'; - - -function n(prim) { - -} - -exports.n = n; -/* No side effect */ diff --git a/tests/tests/src/UncurriedPervasives.mjs b/tests/tests/src/UncurriedPervasives.mjs new file mode 100644 index 0000000000..bb2a137e5b --- /dev/null +++ b/tests/tests/src/UncurriedPervasives.mjs @@ -0,0 +1,11 @@ +// Generated by ReScript, PLEASE EDIT WITH CARE + + +function n(prim) { + +} + +export { + n, +} +/* No side effect */ diff --git a/tests/tests/src/UntaggedVariants.js b/tests/tests/src/UntaggedVariants.js deleted file mode 100644 index c819b5b3c7..0000000000 --- a/tests/tests/src/UntaggedVariants.js +++ /dev/null @@ -1,654 +0,0 @@ -// Generated by ReScript, PLEASE EDIT WITH CARE -'use strict'; - -let Js_dict = require("rescript/lib/js/Js_dict.js"); -let Belt_Array = require("rescript/lib/js/Belt_Array.js"); -let Primitive_array = require("rescript/lib/js/Primitive_array.js"); -let Primitive_option = require("rescript/lib/js/Primitive_option.js"); - -function classify(x) { - if (x === "A" && typeof x !== "number") { - return "A"; - } else if (typeof x === "number") { - return "An integer"; - } else { - return "A string" + x; - } -} - -function classify2(x) { - if (typeof x === "string") { - return "A string" + x; - } else { - return "A float"; - } -} - -function cls(x) { - if (typeof x !== "object") { - if (x === "One") { - return "one"; - } else { - return "two"; - } - } else { - return "object" + x.y; - } -} - -let ListWithTuples = {}; - -let ListWithObjects = {}; - -function tuplesToObjects(l) { - if (Array.isArray(l)) { - return { - hd: l[0], - tl: tuplesToObjects(l[1]) - }; - } else { - return null; - } -} - -let l1 = [ - 1, - [ - 2, - [ - 3, - undefined - ] - ] -]; - -let l2 = tuplesToObjects(l1); - -console.log("l1", l1); - -console.log("l2", l2); - -function isTrue(x) { - if (typeof x !== "object") { - return true; - } else { - return x.flag; - } -} - -let Truthy = { - isTrue: isTrue -}; - -function classify$1(x) { - if (x === null || typeof x !== "object") { - if (x === null) { - return "null"; - } else { - return "undefined"; - } - } else { - return "object" + x.name; - } -} - -let TwoObjects = { - classify: classify$1 -}; - -function classify$2(x) { - if (x === "A" || x === "B") { - if (x === "A") { - return "a"; - } else { - return "b"; - } - } - console.log(x); - return "Unknown"; -} - -let Unknown = { - classify: classify$2 -}; - -function classify$3(x) { - if (typeof x !== "object" && typeof x !== "number" && (x === "C" || x === "B" || x === "A" || x === "D")) { - switch (x) { - case "A" : - return "a"; - case "B" : - return "b"; - case "C" : - return "c"; - case "D" : - return "d"; - } - } else { - switch (typeof x) { - case "string" : - return "string"; - case "number" : - return "int"; - case "object" : - return "Object" + x.name; - } - } -} - -let MultipleBlocks = { - classify: classify$3 -}; - -function classify$4(x) { - switch (typeof x) { - case "string" : - return "string"; - case "number" : - return "int"; - case "object" : - return "Object" + x.name; - } -} - -let OnlyBlocks = { - classify: classify$4 -}; - -function classify$5(x) { - if (Array.isArray(x)) { - return "array"; - } - switch (typeof x) { - case "string" : - return "string"; - case "number" : - return "int"; - case "object" : - return "Object" + x.name; - } -} - -let WithArray = { - classify: classify$5 -}; - -function classify$6(x) { - if (!Array.isArray(x) && (x === null || typeof x !== "object") && typeof x !== "number" && typeof x !== "string") { - switch (x) { - case false : - return "JSONFalse"; - case true : - return "JSONTrue"; - case null : - return "JSONNull"; - } - } else { - if (Array.isArray(x)) { - return { - TAG: "JSONArray", - _0: x - }; - } - switch (typeof x) { - case "string" : - return { - TAG: "JSONString", - _0: x - }; - case "number" : - return { - TAG: "JSONNumber", - _0: x - }; - case "object" : - return { - TAG: "JSONObject", - _0: x - }; - } - } -} - -let Json = { - classify: classify$6 -}; - -function check(s, y) { - if (!Array.isArray(s)) { - return 42; - } - let x = s[0]; - if (!Array.isArray(x)) { - return 42; - } - let tmp = s[1]; - if (Array.isArray(tmp) || x === y) { - return 42; - } else { - return 41; - } -} - -let TrickyNested = { - check: check -}; - -function checkEnum(e) { - if (!(e === "Two" || e === "One" || e === "Three")) { - return "Something else..." + e; - } - switch (e) { - case "One" : - return "One!"; - case "Two" : - return "Two"; - case "Three" : - return "Threeeee"; - } -} - -let OverlapString = { - checkEnum: checkEnum -}; - -function checkEnum$1(e) { - if (!(e === "Two" || e === 1.0 || e === "Three")) { - return "Something else..."; - } - switch (e) { - case 1.0 : - return "One!"; - case "Two" : - return "Two"; - case "Three" : - return "Threeeee"; - } -} - -let OverlapNumber = { - checkEnum: checkEnum$1 -}; - -function checkEnum$2(e) { - if (!(e === null || typeof e !== "object")) { - return "Object..."; - } - switch (e) { - case null : - return "One!"; - case "Two" : - return "Two"; - case "Three" : - return "Threeeee"; - } -} - -let OverlapObject = { - checkEnum: checkEnum$2 -}; - -function classify$7(v) { - if (Array.isArray(v)) { - return Primitive_array.get(v, 0); - } else { - return v.x; - } -} - -let RecordIsObject = { - classify: classify$7 -}; - -function classify$8(v) { - if (typeof v === "object" && !Array.isArray(v)) { - return v.x; - } else { - return Primitive_array.get(v, 0); - } -} - -let ArrayAndObject = { - classify: classify$8 -}; - -function testHasNull(x) { - return x; -} - -function testHasUndefined(x) { - return Primitive_option.some(x); -} - -function untaggedWithOptionPayload(x) { - return Primitive_option.some(x); -} - -function untaggedWithIntPayload(x) { - return x; -} - -function untaggedInlineNoOptions(x) { - return x; -} - -function untaggedInlineUnaryWihtExplicitOption(x) { - return Primitive_option.some(x); -} - -function untaggedInlineUnaryWihtImplicitOption(x) { - return Primitive_option.some(x); -} - -function untaggedInlineMultinaryOption(x) { - return x; -} - -let OptionUnboxingHeuristic = { - testHasNull: testHasNull, - testHasUndefined: testHasUndefined, - untaggedWithOptionPayload: untaggedWithOptionPayload, - untaggedWithIntPayload: untaggedWithIntPayload, - untaggedInlineNoOptions: untaggedInlineNoOptions, - untaggedInlineUnaryWihtExplicitOption: untaggedInlineUnaryWihtExplicitOption, - untaggedInlineUnaryWihtImplicitOption: untaggedInlineUnaryWihtImplicitOption, - untaggedInlineMultinaryOption: untaggedInlineMultinaryOption -}; - -function classify$9(v) { - if (Array.isArray(v)) { - return Primitive_array.get(v, 0); - } - switch (typeof v) { - case "object" : - return v.x; - case "function" : - return v(3); - } -} - -let ff = x => x + 1 | 0; - -let TestFunctionCase = { - classify: classify$9, - ff: ff -}; - -let someJson = '[{"name": "Haan"}, {"name": "Mr"}, false]'; - -function check$1(s) { - if (!Array.isArray(s) && (s === null || typeof s !== "object") && typeof s !== "number" && typeof s !== "string") { - console.log("Nope..."); - return; - } - if (Array.isArray(s)) { - if (s.length !== 3) { - console.log("Nope..."); - return; - } - let match = s[0]; - if (match === true) { - let match$1 = s[1]; - if (match$1 === false) { - let match$2 = s[2]; - if (!Array.isArray(match$2) && (match$2 === null || typeof match$2 !== "object") && typeof match$2 !== "number" && typeof match$2 !== "string") { - console.log("Nope..."); - return; - } - if (Array.isArray(match$2)) { - if (match$2.length !== 2) { - console.log("Nope..."); - return; - } - let match$3 = match$2[0]; - if (!Array.isArray(match$3) && (match$3 === null || typeof match$3 !== "object") && typeof match$3 !== "number" && typeof match$3 !== "string") { - console.log("Nope..."); - return; - } - if (typeof match$3 === "string" && match$3 === "My name is") { - let match$4 = match$2[1]; - if (!Array.isArray(match$4) && (match$4 === null || typeof match$4 !== "object") && typeof match$4 !== "number" && typeof match$4 !== "string") { - console.log("Nope..."); - return; - } - if (typeof match$4 === "number") { - if (match$4 !== 10) { - console.log("Nope..."); - } else { - console.log("yup"); - } - return; - } - console.log("Nope..."); - return; - } else { - console.log("Nope..."); - return; - } - } else { - console.log("Nope..."); - return; - } - } else { - console.log("Nope..."); - return; - } - } else { - console.log("Nope..."); - return; - } - } else { - console.log("Nope..."); - return; - } -} - -let ComplexPattern = { - someJson: someJson, - check: check$1 -}; - -async function getUserName(u) { - if (u instanceof Promise) { - return (await u).name; - } - switch (typeof u) { - case "object" : - return u.name; - case "string" : - return u; - } -} - -async function awaitUser(u) { - if (u instanceof Promise) { - return (await u).name; - } - switch (typeof u) { - case "object" : - case "string" : - return "dummy"; - } -} - -let PromiseSync = { - getUserName: getUserName, - awaitUser: awaitUser -}; - -async function classify$10(a) { - if (typeof a !== "object" && !(a instanceof Promise) && (a === "test" || a === 12) && !Array.isArray(a)) { - if (a === "test") { - console.log("testing"); - return; - } - console.log(12); - return; - } else { - if (Array.isArray(a)) { - console.log(Belt_Array.joinWith(a, "-", x => x)); - return; - } - if (a instanceof Promise) { - console.log(await a); - return; - } - switch (typeof a) { - case "string" : - console.log(a); - return; - case "object" : - console.log(a.userName); - return; - } - } -} - -let Arr = { - classify: classify$10 -}; - -async function classifyAll(t) { - if (Array.isArray(t)) { - console.log(Belt_Array.joinWith(t, "-", x => x)); - return; - } - if (t instanceof Promise) { - console.log(await t); - return; - } - if (t instanceof Date) { - console.log(t.toString()); - return; - } - if (t instanceof RegExp) { - console.log(t.test("test")); - return; - } - if (t instanceof File) { - console.log(t.name); - return; - } - if (t instanceof Blob) { - console.log(t.size); - return; - } - switch (typeof t) { - case "string" : - console.log(t); - return; - case "object" : - console.log(t.userName); - return; - } -} - -let AllInstanceofTypes = { - classifyAll: classifyAll -}; - -function test(t) { - switch (typeof t) { - case "object" : - return Js_dict.get(t, "Hello"); - case "string" : - return t; - case "function" : - return t(); - } -} - -let Aliased = { - test: test -}; - -let OnlyOne = { - onlyOne: "OnlyOne" -}; - -function should_not_merge(x) { - if (Array.isArray(x)) { - return "do not merge"; - } - if (x instanceof Date) { - return "do not merge"; - } - switch (typeof x) { - case "boolean" : - return "boolean"; - case "object" : - return "do not merge"; - } -} - -function can_merge(x) { - if (Array.isArray(x)) { - return "do not merge"; - } - if (x instanceof Date) { - return "do not merge"; - } - switch (typeof x) { - case "boolean" : - case "object" : - return "merge"; - } -} - -let MergeCases = { - should_not_merge: should_not_merge, - can_merge: can_merge -}; - -let $$Array; - -let i = 42; - -let i2 = 42.5; - -let s = "abc"; - -let s2 = "abc"; - -let w = { - x: 10, - y: "" -}; - -exports.$$Array = $$Array; -exports.i = i; -exports.i2 = i2; -exports.s = s; -exports.s2 = s2; -exports.classify = classify; -exports.classify2 = classify2; -exports.w = w; -exports.cls = cls; -exports.ListWithTuples = ListWithTuples; -exports.ListWithObjects = ListWithObjects; -exports.tuplesToObjects = tuplesToObjects; -exports.l1 = l1; -exports.l2 = l2; -exports.Truthy = Truthy; -exports.TwoObjects = TwoObjects; -exports.Unknown = Unknown; -exports.MultipleBlocks = MultipleBlocks; -exports.OnlyBlocks = OnlyBlocks; -exports.WithArray = WithArray; -exports.Json = Json; -exports.TrickyNested = TrickyNested; -exports.OverlapString = OverlapString; -exports.OverlapNumber = OverlapNumber; -exports.OverlapObject = OverlapObject; -exports.RecordIsObject = RecordIsObject; -exports.ArrayAndObject = ArrayAndObject; -exports.OptionUnboxingHeuristic = OptionUnboxingHeuristic; -exports.TestFunctionCase = TestFunctionCase; -exports.ComplexPattern = ComplexPattern; -exports.PromiseSync = PromiseSync; -exports.Arr = Arr; -exports.AllInstanceofTypes = AllInstanceofTypes; -exports.Aliased = Aliased; -exports.OnlyOne = OnlyOne; -exports.MergeCases = MergeCases; -/* l2 Not a pure module */ diff --git a/tests/tests/src/UntaggedVariants.mjs b/tests/tests/src/UntaggedVariants.mjs new file mode 100644 index 0000000000..6f59067b7b --- /dev/null +++ b/tests/tests/src/UntaggedVariants.mjs @@ -0,0 +1,655 @@ +// Generated by ReScript, PLEASE EDIT WITH CARE + +import * as Js_dict from "rescript/lib/es6/Js_dict.js"; +import * as Belt_Array from "rescript/lib/es6/Belt_Array.js"; +import * as Primitive_array from "rescript/lib/es6/Primitive_array.js"; +import * as Primitive_option from "rescript/lib/es6/Primitive_option.js"; + +function classify(x) { + if (x === "A" && typeof x !== "number") { + return "A"; + } else if (typeof x === "number") { + return "An integer"; + } else { + return "A string" + x; + } +} + +function classify2(x) { + if (typeof x === "string") { + return "A string" + x; + } else { + return "A float"; + } +} + +function cls(x) { + if (typeof x !== "object") { + if (x === "One") { + return "one"; + } else { + return "two"; + } + } else { + return "object" + x.y; + } +} + +let ListWithTuples = {}; + +let ListWithObjects = {}; + +function tuplesToObjects(l) { + if (Array.isArray(l)) { + return { + hd: l[0], + tl: tuplesToObjects(l[1]) + }; + } else { + return null; + } +} + +let l1 = [ + 1, + [ + 2, + [ + 3, + undefined + ] + ] +]; + +let l2 = tuplesToObjects(l1); + +console.log("l1", l1); + +console.log("l2", l2); + +function isTrue(x) { + if (typeof x !== "object") { + return true; + } else { + return x.flag; + } +} + +let Truthy = { + isTrue: isTrue +}; + +function classify$1(x) { + if (x === null || typeof x !== "object") { + if (x === null) { + return "null"; + } else { + return "undefined"; + } + } else { + return "object" + x.name; + } +} + +let TwoObjects = { + classify: classify$1 +}; + +function classify$2(x) { + if (x === "A" || x === "B") { + if (x === "A") { + return "a"; + } else { + return "b"; + } + } + console.log(x); + return "Unknown"; +} + +let Unknown = { + classify: classify$2 +}; + +function classify$3(x) { + if (typeof x !== "object" && typeof x !== "number" && (x === "C" || x === "B" || x === "A" || x === "D")) { + switch (x) { + case "A" : + return "a"; + case "B" : + return "b"; + case "C" : + return "c"; + case "D" : + return "d"; + } + } else { + switch (typeof x) { + case "string" : + return "string"; + case "number" : + return "int"; + case "object" : + return "Object" + x.name; + } + } +} + +let MultipleBlocks = { + classify: classify$3 +}; + +function classify$4(x) { + switch (typeof x) { + case "string" : + return "string"; + case "number" : + return "int"; + case "object" : + return "Object" + x.name; + } +} + +let OnlyBlocks = { + classify: classify$4 +}; + +function classify$5(x) { + if (Array.isArray(x)) { + return "array"; + } + switch (typeof x) { + case "string" : + return "string"; + case "number" : + return "int"; + case "object" : + return "Object" + x.name; + } +} + +let WithArray = { + classify: classify$5 +}; + +function classify$6(x) { + if (!Array.isArray(x) && (x === null || typeof x !== "object") && typeof x !== "number" && typeof x !== "string") { + switch (x) { + case false : + return "JSONFalse"; + case true : + return "JSONTrue"; + case null : + return "JSONNull"; + } + } else { + if (Array.isArray(x)) { + return { + TAG: "JSONArray", + _0: x + }; + } + switch (typeof x) { + case "string" : + return { + TAG: "JSONString", + _0: x + }; + case "number" : + return { + TAG: "JSONNumber", + _0: x + }; + case "object" : + return { + TAG: "JSONObject", + _0: x + }; + } + } +} + +let Json = { + classify: classify$6 +}; + +function check(s, y) { + if (!Array.isArray(s)) { + return 42; + } + let x = s[0]; + if (!Array.isArray(x)) { + return 42; + } + let tmp = s[1]; + if (Array.isArray(tmp) || x === y) { + return 42; + } else { + return 41; + } +} + +let TrickyNested = { + check: check +}; + +function checkEnum(e) { + if (!(e === "Two" || e === "One" || e === "Three")) { + return "Something else..." + e; + } + switch (e) { + case "One" : + return "One!"; + case "Two" : + return "Two"; + case "Three" : + return "Threeeee"; + } +} + +let OverlapString = { + checkEnum: checkEnum +}; + +function checkEnum$1(e) { + if (!(e === "Two" || e === 1.0 || e === "Three")) { + return "Something else..."; + } + switch (e) { + case 1.0 : + return "One!"; + case "Two" : + return "Two"; + case "Three" : + return "Threeeee"; + } +} + +let OverlapNumber = { + checkEnum: checkEnum$1 +}; + +function checkEnum$2(e) { + if (!(e === null || typeof e !== "object")) { + return "Object..."; + } + switch (e) { + case null : + return "One!"; + case "Two" : + return "Two"; + case "Three" : + return "Threeeee"; + } +} + +let OverlapObject = { + checkEnum: checkEnum$2 +}; + +function classify$7(v) { + if (Array.isArray(v)) { + return Primitive_array.get(v, 0); + } else { + return v.x; + } +} + +let RecordIsObject = { + classify: classify$7 +}; + +function classify$8(v) { + if (typeof v === "object" && !Array.isArray(v)) { + return v.x; + } else { + return Primitive_array.get(v, 0); + } +} + +let ArrayAndObject = { + classify: classify$8 +}; + +function testHasNull(x) { + return x; +} + +function testHasUndefined(x) { + return Primitive_option.some(x); +} + +function untaggedWithOptionPayload(x) { + return Primitive_option.some(x); +} + +function untaggedWithIntPayload(x) { + return x; +} + +function untaggedInlineNoOptions(x) { + return x; +} + +function untaggedInlineUnaryWihtExplicitOption(x) { + return Primitive_option.some(x); +} + +function untaggedInlineUnaryWihtImplicitOption(x) { + return Primitive_option.some(x); +} + +function untaggedInlineMultinaryOption(x) { + return x; +} + +let OptionUnboxingHeuristic = { + testHasNull: testHasNull, + testHasUndefined: testHasUndefined, + untaggedWithOptionPayload: untaggedWithOptionPayload, + untaggedWithIntPayload: untaggedWithIntPayload, + untaggedInlineNoOptions: untaggedInlineNoOptions, + untaggedInlineUnaryWihtExplicitOption: untaggedInlineUnaryWihtExplicitOption, + untaggedInlineUnaryWihtImplicitOption: untaggedInlineUnaryWihtImplicitOption, + untaggedInlineMultinaryOption: untaggedInlineMultinaryOption +}; + +function classify$9(v) { + if (Array.isArray(v)) { + return Primitive_array.get(v, 0); + } + switch (typeof v) { + case "object" : + return v.x; + case "function" : + return v(3); + } +} + +let ff = x => x + 1 | 0; + +let TestFunctionCase = { + classify: classify$9, + ff: ff +}; + +let someJson = '[{"name": "Haan"}, {"name": "Mr"}, false]'; + +function check$1(s) { + if (!Array.isArray(s) && (s === null || typeof s !== "object") && typeof s !== "number" && typeof s !== "string") { + console.log("Nope..."); + return; + } + if (Array.isArray(s)) { + if (s.length !== 3) { + console.log("Nope..."); + return; + } + let match = s[0]; + if (match === true) { + let match$1 = s[1]; + if (match$1 === false) { + let match$2 = s[2]; + if (!Array.isArray(match$2) && (match$2 === null || typeof match$2 !== "object") && typeof match$2 !== "number" && typeof match$2 !== "string") { + console.log("Nope..."); + return; + } + if (Array.isArray(match$2)) { + if (match$2.length !== 2) { + console.log("Nope..."); + return; + } + let match$3 = match$2[0]; + if (!Array.isArray(match$3) && (match$3 === null || typeof match$3 !== "object") && typeof match$3 !== "number" && typeof match$3 !== "string") { + console.log("Nope..."); + return; + } + if (typeof match$3 === "string" && match$3 === "My name is") { + let match$4 = match$2[1]; + if (!Array.isArray(match$4) && (match$4 === null || typeof match$4 !== "object") && typeof match$4 !== "number" && typeof match$4 !== "string") { + console.log("Nope..."); + return; + } + if (typeof match$4 === "number") { + if (match$4 !== 10) { + console.log("Nope..."); + } else { + console.log("yup"); + } + return; + } + console.log("Nope..."); + return; + } else { + console.log("Nope..."); + return; + } + } else { + console.log("Nope..."); + return; + } + } else { + console.log("Nope..."); + return; + } + } else { + console.log("Nope..."); + return; + } + } else { + console.log("Nope..."); + return; + } +} + +let ComplexPattern = { + someJson: someJson, + check: check$1 +}; + +async function getUserName(u) { + if (u instanceof Promise) { + return (await u).name; + } + switch (typeof u) { + case "object" : + return u.name; + case "string" : + return u; + } +} + +async function awaitUser(u) { + if (u instanceof Promise) { + return (await u).name; + } + switch (typeof u) { + case "object" : + case "string" : + return "dummy"; + } +} + +let PromiseSync = { + getUserName: getUserName, + awaitUser: awaitUser +}; + +async function classify$10(a) { + if (typeof a !== "object" && !(a instanceof Promise) && (a === "test" || a === 12) && !Array.isArray(a)) { + if (a === "test") { + console.log("testing"); + return; + } + console.log(12); + return; + } else { + if (Array.isArray(a)) { + console.log(Belt_Array.joinWith(a, "-", x => x)); + return; + } + if (a instanceof Promise) { + console.log(await a); + return; + } + switch (typeof a) { + case "string" : + console.log(a); + return; + case "object" : + console.log(a.userName); + return; + } + } +} + +let Arr = { + classify: classify$10 +}; + +async function classifyAll(t) { + if (Array.isArray(t)) { + console.log(Belt_Array.joinWith(t, "-", x => x)); + return; + } + if (t instanceof Promise) { + console.log(await t); + return; + } + if (t instanceof Date) { + console.log(t.toString()); + return; + } + if (t instanceof RegExp) { + console.log(t.test("test")); + return; + } + if (t instanceof File) { + console.log(t.name); + return; + } + if (t instanceof Blob) { + console.log(t.size); + return; + } + switch (typeof t) { + case "string" : + console.log(t); + return; + case "object" : + console.log(t.userName); + return; + } +} + +let AllInstanceofTypes = { + classifyAll: classifyAll +}; + +function test(t) { + switch (typeof t) { + case "object" : + return Js_dict.get(t, "Hello"); + case "string" : + return t; + case "function" : + return t(); + } +} + +let Aliased = { + test: test +}; + +let OnlyOne = { + onlyOne: "OnlyOne" +}; + +function should_not_merge(x) { + if (Array.isArray(x)) { + return "do not merge"; + } + if (x instanceof Date) { + return "do not merge"; + } + switch (typeof x) { + case "boolean" : + return "boolean"; + case "object" : + return "do not merge"; + } +} + +function can_merge(x) { + if (Array.isArray(x)) { + return "do not merge"; + } + if (x instanceof Date) { + return "do not merge"; + } + switch (typeof x) { + case "boolean" : + case "object" : + return "merge"; + } +} + +let MergeCases = { + should_not_merge: should_not_merge, + can_merge: can_merge +}; + +let $$Array; + +let i = 42; + +let i2 = 42.5; + +let s = "abc"; + +let s2 = "abc"; + +let w = { + x: 10, + y: "" +}; + +export { + $$Array, + i, + i2, + s, + s2, + classify, + classify2, + w, + cls, + ListWithTuples, + ListWithObjects, + tuplesToObjects, + l1, + l2, + Truthy, + TwoObjects, + Unknown, + MultipleBlocks, + OnlyBlocks, + WithArray, + Json, + TrickyNested, + OverlapString, + OverlapNumber, + OverlapObject, + RecordIsObject, + ArrayAndObject, + OptionUnboxingHeuristic, + TestFunctionCase, + ComplexPattern, + PromiseSync, + Arr, + AllInstanceofTypes, + Aliased, + OnlyOne, + MergeCases, +} +/* l2 Not a pure module */ diff --git a/tests/tests/src/VariantCoercion.js b/tests/tests/src/VariantCoercion.js deleted file mode 100644 index 5913561e11..0000000000 --- a/tests/tests/src/VariantCoercion.js +++ /dev/null @@ -1,136 +0,0 @@ -// Generated by ReScript, PLEASE EDIT WITH CARE -'use strict'; - - -let x = { - kind: "One", - age: 1 -}; - -let CoerceVariants = { - a: 1.1, - b: 1.1, - x: x, - y: x -}; - -let a = "hello"; - -let c = 100; - -let CoerceWithPayload = { - a: a, - aa: "First", - b: a, - bb: "First", - c: c, - cc: 2, - d: c, - dd: 2 -}; - -let a$1 = "hello"; - -let aa = "First"; - -let c$1 = "Hi"; - -let CoerceFromStringToVariant = { - a: a$1, - aa: aa, - b: a$1, - bb: aa, - c: c$1, - cc: c$1 -}; - -let CoerceFromIntToVariant = { - a: 100, - aa: 1, - b: 100, - bb: 1, - c: 120, - cc: 120 -}; - -let CoerceFromFloatToVariant = { - a: 100, - aa: 1, - b: 100, - bb: 1, - c: 120, - cc: 120 -}; - -let CoerceFromBigintToVariant = { - a: 100n, - aa: 1n, - b: 100n, - bb: 1n, - c: 120n, - cc: 120n -}; - -let CoerceFromPolyvariantToVariant = { - simple: "One", - simpleP: "One", - withAs: "One", - withAsP: "One", - withMoreVariantConstructors: "One", - withMoreVariantConstructorsP: "One", - withUnboxedCatchAll: "One", - withUnboxedCatchAllP: "One" -}; - -function f1() { - return "b"; -} - -function f2() { - return "b"; -} - -for (let x$1 = 1; x$1 <= 2; ++x$1) { - console.log(x$1); -} - -let y = "one".length; - -let z = 1.5 + 2.0 + 1.5; - -let CoerceVariantBinaryOp = { - x: 2, - v: 2, - f1: f1, - f2: f2, - y: y, - z: z -}; - -let a$2 = "Three"; - -let b = "Three"; - -let i = 1; - -let d = 1; - -let ii = 1.1; - -let dd = 1.1; - -exports.a = a$2; -exports.b = b; -exports.i = i; -exports.d = d; -exports.ii = ii; -exports.dd = dd; -exports.CoerceVariants = CoerceVariants; -exports.CoerceWithPayload = CoerceWithPayload; -exports.CoerceFromStringToVariant = CoerceFromStringToVariant; -exports.CoerceFromIntToVariant = CoerceFromIntToVariant; -exports.CoerceFromFloatToVariant = CoerceFromFloatToVariant; -exports.CoerceFromBigintToVariant = CoerceFromBigintToVariant; -exports.CoerceFromPolyvariantToVariant = CoerceFromPolyvariantToVariant; -exports.CoerceVariantBinaryOp = CoerceVariantBinaryOp; -/* Not a pure module */ diff --git a/tests/tests/src/VariantCoercion.mjs b/tests/tests/src/VariantCoercion.mjs new file mode 100644 index 0000000000..dbd38a8b86 --- /dev/null +++ b/tests/tests/src/VariantCoercion.mjs @@ -0,0 +1,137 @@ +// Generated by ReScript, PLEASE EDIT WITH CARE + + +let x = { + kind: "One", + age: 1 +}; + +let CoerceVariants = { + a: 1.1, + b: 1.1, + x: x, + y: x +}; + +let a = "hello"; + +let c = 100; + +let CoerceWithPayload = { + a: a, + aa: "First", + b: a, + bb: "First", + c: c, + cc: 2, + d: c, + dd: 2 +}; + +let a$1 = "hello"; + +let aa = "First"; + +let c$1 = "Hi"; + +let CoerceFromStringToVariant = { + a: a$1, + aa: aa, + b: a$1, + bb: aa, + c: c$1, + cc: c$1 +}; + +let CoerceFromIntToVariant = { + a: 100, + aa: 1, + b: 100, + bb: 1, + c: 120, + cc: 120 +}; + +let CoerceFromFloatToVariant = { + a: 100, + aa: 1, + b: 100, + bb: 1, + c: 120, + cc: 120 +}; + +let CoerceFromBigintToVariant = { + a: 100n, + aa: 1n, + b: 100n, + bb: 1n, + c: 120n, + cc: 120n +}; + +let CoerceFromPolyvariantToVariant = { + simple: "One", + simpleP: "One", + withAs: "One", + withAsP: "One", + withMoreVariantConstructors: "One", + withMoreVariantConstructorsP: "One", + withUnboxedCatchAll: "One", + withUnboxedCatchAllP: "One" +}; + +function f1() { + return "b"; +} + +function f2() { + return "b"; +} + +for (let x$1 = 1; x$1 <= 2; ++x$1) { + console.log(x$1); +} + +let y = "one".length; + +let z = 1.5 + 2.0 + 1.5; + +let CoerceVariantBinaryOp = { + x: 2, + v: 2, + f1: f1, + f2: f2, + y: y, + z: z +}; + +let a$2 = "Three"; + +let b = "Three"; + +let i = 1; + +let d = 1; + +let ii = 1.1; + +let dd = 1.1; + +export { + a$2 as a, + b, + i, + d, + ii, + dd, + CoerceVariants, + CoerceWithPayload, + CoerceFromStringToVariant, + CoerceFromIntToVariant, + CoerceFromFloatToVariant, + CoerceFromBigintToVariant, + CoerceFromPolyvariantToVariant, + CoerceVariantBinaryOp, +} +/* Not a pure module */ diff --git a/tests/tests/src/VariantPatternMatchingSpreads.js b/tests/tests/src/VariantPatternMatchingSpreads.js deleted file mode 100644 index 6416532a50..0000000000 --- a/tests/tests/src/VariantPatternMatchingSpreads.js +++ /dev/null @@ -1,102 +0,0 @@ -// Generated by ReScript, PLEASE EDIT WITH CARE -'use strict'; - - -function doWithA(a) { - switch (a) { - case "One" : - console.log("aaa"); - return; - case "Two" : - console.log("twwwoooo"); - return; - case "Three" : - console.log("threeeee"); - return; - } -} - -function doWithB(b) { - if (b === "One") { - console.log("aaa"); - return; - } - console.log("twwwoooo"); -} - -function lookup(b) { - switch (b) { - case "Four" : - console.log("four"); - return; - case "Five" : - console.log("five"); - return; - default: - return doWithA(b); - } -} - -function lookup2(d) { - switch (d) { - case "Four" : - case "Five" : - return doWithB(d); - case "Six" : - case "Seven" : - console.log("Got rest of d"); - return; - default: - return doWithA(d); - } -} - -function lookupOpt(b) { - if (b !== undefined) { - switch (b) { - case "Four" : - console.log("four"); - return; - case "Five" : - console.log("five"); - return; - default: - return doWithA(b); - } - } else { - console.log("None"); - return; - } -} - -let Foo = {}; - -function doWithZ(z) { - if (z === "First") { - console.log("First"); - return; - } - console.log("Second"); -} - -function lookup3(d) { - switch (d) { - case "First" : - case "Second" : - console.log(d); - return; - case "Third" : - console.log("Third"); - return; - } -} - -exports.doWithA = doWithA; -exports.doWithB = doWithB; -exports.lookup = lookup; -exports.lookup2 = lookup2; -exports.lookupOpt = lookupOpt; -exports.Foo = Foo; -exports.doWithZ = doWithZ; -exports.lookup3 = lookup3; -/* No side effect */ diff --git a/tests/tests/src/VariantPatternMatchingSpreads.mjs b/tests/tests/src/VariantPatternMatchingSpreads.mjs new file mode 100644 index 0000000000..1f067413bb --- /dev/null +++ b/tests/tests/src/VariantPatternMatchingSpreads.mjs @@ -0,0 +1,103 @@ +// Generated by ReScript, PLEASE EDIT WITH CARE + + +function doWithA(a) { + switch (a) { + case "One" : + console.log("aaa"); + return; + case "Two" : + console.log("twwwoooo"); + return; + case "Three" : + console.log("threeeee"); + return; + } +} + +function doWithB(b) { + if (b === "One") { + console.log("aaa"); + return; + } + console.log("twwwoooo"); +} + +function lookup(b) { + switch (b) { + case "Four" : + console.log("four"); + return; + case "Five" : + console.log("five"); + return; + default: + return doWithA(b); + } +} + +function lookup2(d) { + switch (d) { + case "Four" : + case "Five" : + return doWithB(d); + case "Six" : + case "Seven" : + console.log("Got rest of d"); + return; + default: + return doWithA(d); + } +} + +function lookupOpt(b) { + if (b !== undefined) { + switch (b) { + case "Four" : + console.log("four"); + return; + case "Five" : + console.log("five"); + return; + default: + return doWithA(b); + } + } else { + console.log("None"); + return; + } +} + +let Foo = {}; + +function doWithZ(z) { + if (z === "First") { + console.log("First"); + return; + } + console.log("Second"); +} + +function lookup3(d) { + switch (d) { + case "First" : + case "Second" : + console.log(d); + return; + case "Third" : + console.log("Third"); + return; + } +} + +export { + doWithA, + doWithB, + lookup, + lookup2, + lookupOpt, + Foo, + doWithZ, + lookup3, +} +/* No side effect */ diff --git a/tests/tests/src/VariantPatternMatchingSpreadsWithPayloads.js b/tests/tests/src/VariantPatternMatchingSpreadsWithPayloads.js deleted file mode 100644 index 1bbdd55c51..0000000000 --- a/tests/tests/src/VariantPatternMatchingSpreadsWithPayloads.js +++ /dev/null @@ -1,74 +0,0 @@ -// Generated by ReScript, PLEASE EDIT WITH CARE -'use strict'; - - -function doWithA(a) { - if (typeof a !== "object") { - if (a === "One") { - console.log("aaa"); - return; - } - console.log("threeeee"); - return; - } else { - console.log("twwwoooo"); - return; - } -} - -function doWithB(b) { - if (typeof b !== "object") { - if (b === "One") { - console.log("aaa"); - return; - } - console.log("twwwoooo"); - return; - } else { - console.log("twwwoooo"); - return; - } -} - -function lookup(b) { - if (typeof b === "object") { - return doWithA(b); - } - switch (b) { - case "Four" : - console.log("four"); - return; - case "Five" : - console.log("five"); - return; - default: - return doWithA(b); - } -} - -function lookup2(d) { - if (typeof d !== "object") { - switch (d) { - case "Four" : - case "Five" : - return doWithB(d); - case "Six" : - console.log("Got rest of d"); - return; - default: - return doWithA(d); - } - } else { - if (d.TAG !== "Seven") { - return doWithA(d); - } - console.log("Got rest of d"); - return; - } -} - -exports.doWithA = doWithA; -exports.doWithB = doWithB; -exports.lookup = lookup; -exports.lookup2 = lookup2; -/* No side effect */ diff --git a/tests/tests/src/VariantPatternMatchingSpreadsWithPayloads.mjs b/tests/tests/src/VariantPatternMatchingSpreadsWithPayloads.mjs new file mode 100644 index 0000000000..af99457bd3 --- /dev/null +++ b/tests/tests/src/VariantPatternMatchingSpreadsWithPayloads.mjs @@ -0,0 +1,75 @@ +// Generated by ReScript, PLEASE EDIT WITH CARE + + +function doWithA(a) { + if (typeof a !== "object") { + if (a === "One") { + console.log("aaa"); + return; + } + console.log("threeeee"); + return; + } else { + console.log("twwwoooo"); + return; + } +} + +function doWithB(b) { + if (typeof b !== "object") { + if (b === "One") { + console.log("aaa"); + return; + } + console.log("twwwoooo"); + return; + } else { + console.log("twwwoooo"); + return; + } +} + +function lookup(b) { + if (typeof b === "object") { + return doWithA(b); + } + switch (b) { + case "Four" : + console.log("four"); + return; + case "Five" : + console.log("five"); + return; + default: + return doWithA(b); + } +} + +function lookup2(d) { + if (typeof d !== "object") { + switch (d) { + case "Four" : + case "Five" : + return doWithB(d); + case "Six" : + console.log("Got rest of d"); + return; + default: + return doWithA(d); + } + } else { + if (d.TAG !== "Seven") { + return doWithA(d); + } + console.log("Got rest of d"); + return; + } +} + +export { + doWithA, + doWithB, + lookup, + lookup2, +} +/* No side effect */ diff --git a/tests/tests/src/VariantSpreads.js b/tests/tests/src/VariantSpreads.js deleted file mode 100644 index b76df895a7..0000000000 --- a/tests/tests/src/VariantSpreads.js +++ /dev/null @@ -1,33 +0,0 @@ -// Generated by ReScript, PLEASE EDIT WITH CARE -'use strict'; - - -let S = {}; - -let b1 = "Two"; - -let b2 = { - TAG: "One", - _0: true, - _1: "Bar" -}; - -let c = { - TAG: "Five", - _0: 2 -}; - -let ddd = "Six"; - -let q = { - TAG: "One", - name: "hello" -}; - -exports.S = S; -exports.b1 = b1; -exports.b2 = b2; -exports.c = c; -exports.ddd = ddd; -exports.q = q; -/* No side effect */ diff --git a/tests/tests/src/VariantSpreads.mjs b/tests/tests/src/VariantSpreads.mjs new file mode 100644 index 0000000000..de211881e1 --- /dev/null +++ b/tests/tests/src/VariantSpreads.mjs @@ -0,0 +1,34 @@ +// Generated by ReScript, PLEASE EDIT WITH CARE + + +let S = {}; + +let b1 = "Two"; + +let b2 = { + TAG: "One", + _0: true, + _1: "Bar" +}; + +let c = { + TAG: "Five", + _0: 2 +}; + +let ddd = "Six"; + +let q = { + TAG: "One", + name: "hello" +}; + +export { + S, + b1, + b2, + c, + ddd, + q, +} +/* No side effect */ diff --git a/tests/tests/src/a.js b/tests/tests/src/a.js deleted file mode 100644 index 1eb4cada7a..0000000000 --- a/tests/tests/src/a.js +++ /dev/null @@ -1,12 +0,0 @@ -// Generated by ReScript, PLEASE EDIT WITH CARE -'use strict'; - - -function Make(U) { - return { - v: U.compare - }; -} - -exports.Make = Make; -/* No side effect */ diff --git a/tests/tests/src/a.mjs b/tests/tests/src/a.mjs new file mode 100644 index 0000000000..1e4a08ff78 --- /dev/null +++ b/tests/tests/src/a.mjs @@ -0,0 +1,13 @@ +// Generated by ReScript, PLEASE EDIT WITH CARE + + +function Make(U) { + return { + v: U.compare + }; +} + +export { + Make, +} +/* No side effect */ diff --git a/tests/tests/src/a_recursive_type.js b/tests/tests/src/a_recursive_type.js deleted file mode 100644 index 7727b37026..0000000000 --- a/tests/tests/src/a_recursive_type.js +++ /dev/null @@ -1,25 +0,0 @@ -// Generated by ReScript, PLEASE EDIT WITH CARE -'use strict'; - - -function g(x) { - return x._0(x); -} - -let loop = g({ - TAG: "A", - _0: g -}); - -let non_terminate = g({ - TAG: "A", - _0: g -}); - -let xx = {}; - -xx.xx = xx; - -exports.loop = loop; -exports.non_terminate = non_terminate; -/* loop Not a pure module */ diff --git a/tests/tests/src/a_recursive_type.mjs b/tests/tests/src/a_recursive_type.mjs new file mode 100644 index 0000000000..e4fd7b89ea --- /dev/null +++ b/tests/tests/src/a_recursive_type.mjs @@ -0,0 +1,26 @@ +// Generated by ReScript, PLEASE EDIT WITH CARE + + +function g(x) { + return x._0(x); +} + +let loop = g({ + TAG: "A", + _0: g +}); + +let non_terminate = g({ + TAG: "A", + _0: g +}); + +let xx = {}; + +xx.xx = xx; + +export { + loop, + non_terminate, +} +/* loop Not a pure module */ diff --git a/tests/tests/src/a_scope_bug.js b/tests/tests/src/a_scope_bug.js deleted file mode 100644 index 0e43a28a04..0000000000 --- a/tests/tests/src/a_scope_bug.js +++ /dev/null @@ -1,20 +0,0 @@ -// Generated by ReScript, PLEASE EDIT WITH CARE -'use strict'; - - -function odd(_z) { - while (true) { - let z = _z; - let even = Math.imul(z, z); - let a = (even + 4 | 0) + even | 0; - console.log(a.toString()); - _z = 32; - continue; - }; -} - -let even = odd; - -exports.odd = odd; -exports.even = even; -/* No side effect */ diff --git a/tests/tests/src/a_scope_bug.mjs b/tests/tests/src/a_scope_bug.mjs new file mode 100644 index 0000000000..157799023c --- /dev/null +++ b/tests/tests/src/a_scope_bug.mjs @@ -0,0 +1,21 @@ +// Generated by ReScript, PLEASE EDIT WITH CARE + + +function odd(_z) { + while (true) { + let z = _z; + let even = Math.imul(z, z); + let a = (even + 4 | 0) + even | 0; + console.log(a.toString()); + _z = 32; + continue; + }; +} + +let even = odd; + +export { + odd, + even, +} +/* No side effect */ diff --git a/tests/tests/src/abstract_type.js b/tests/tests/src/abstract_type.mjs similarity index 100% rename from tests/tests/src/abstract_type.js rename to tests/tests/src/abstract_type.mjs diff --git a/tests/tests/src/acyc/a0_a1.js b/tests/tests/src/acyc/a0_a1.js deleted file mode 100644 index e49a9a2be3..0000000000 --- a/tests/tests/src/acyc/a0_a1.js +++ /dev/null @@ -1,8 +0,0 @@ -// Generated by ReScript, PLEASE EDIT WITH CARE -'use strict'; - - -let v = 3; - -exports.v = v; -/* No side effect */ diff --git a/tests/tests/src/acyc/a0_a1.mjs b/tests/tests/src/acyc/a0_a1.mjs new file mode 100644 index 0000000000..cf0b79fe71 --- /dev/null +++ b/tests/tests/src/acyc/a0_a1.mjs @@ -0,0 +1,9 @@ +// Generated by ReScript, PLEASE EDIT WITH CARE + + +let v = 3; + +export { + v, +} +/* No side effect */ diff --git a/tests/tests/src/acyc/a1_a2.js b/tests/tests/src/acyc/a1_a2.js deleted file mode 100644 index 9b230e3fea..0000000000 --- a/tests/tests/src/acyc/a1_a2.js +++ /dev/null @@ -1,9 +0,0 @@ -// Generated by ReScript, PLEASE EDIT WITH CARE -'use strict'; - -let A0_a1 = require("./a0_a1.js"); - -let v = A0_a1.v; - -exports.v = v; -/* No side effect */ diff --git a/tests/tests/src/acyc/a1_a2.mjs b/tests/tests/src/acyc/a1_a2.mjs new file mode 100644 index 0000000000..79263a7207 --- /dev/null +++ b/tests/tests/src/acyc/a1_a2.mjs @@ -0,0 +1,10 @@ +// Generated by ReScript, PLEASE EDIT WITH CARE + +import * as A0_a1 from "./a0_a1.mjs"; + +let v = A0_a1.v; + +export { + v, +} +/* No side effect */ diff --git a/tests/tests/src/acyc/a2_a3.js b/tests/tests/src/acyc/a2_a3.js deleted file mode 100644 index e3e41ff5af..0000000000 --- a/tests/tests/src/acyc/a2_a3.js +++ /dev/null @@ -1,9 +0,0 @@ -// Generated by ReScript, PLEASE EDIT WITH CARE -'use strict'; - -let A1_a2 = require("./a1_a2.js"); - -let v = A1_a2.v; - -exports.v = v; -/* No side effect */ diff --git a/tests/tests/src/acyc/a2_a3.mjs b/tests/tests/src/acyc/a2_a3.mjs new file mode 100644 index 0000000000..3df0bd6ed5 --- /dev/null +++ b/tests/tests/src/acyc/a2_a3.mjs @@ -0,0 +1,10 @@ +// Generated by ReScript, PLEASE EDIT WITH CARE + +import * as A1_a2 from "./a1_a2.mjs"; + +let v = A1_a2.v; + +export { + v, +} +/* No side effect */ diff --git a/tests/tests/src/acyc/a3_a4.js b/tests/tests/src/acyc/a3_a4.js deleted file mode 100644 index c638a7135e..0000000000 --- a/tests/tests/src/acyc/a3_a4.js +++ /dev/null @@ -1,9 +0,0 @@ -// Generated by ReScript, PLEASE EDIT WITH CARE -'use strict'; - -let A2_a3 = require("./a2_a3.js"); - -let v = A2_a3.v; - -exports.v = v; -/* No side effect */ diff --git a/tests/tests/src/acyc/a3_a4.mjs b/tests/tests/src/acyc/a3_a4.mjs new file mode 100644 index 0000000000..118120bc7b --- /dev/null +++ b/tests/tests/src/acyc/a3_a4.mjs @@ -0,0 +1,10 @@ +// Generated by ReScript, PLEASE EDIT WITH CARE + +import * as A2_a3 from "./a2_a3.mjs"; + +let v = A2_a3.v; + +export { + v, +} +/* No side effect */ diff --git a/tests/tests/src/acyc/a4_a5.js b/tests/tests/src/acyc/a4_a5.js deleted file mode 100644 index 894b72a8b3..0000000000 --- a/tests/tests/src/acyc/a4_a5.js +++ /dev/null @@ -1,11 +0,0 @@ -// Generated by ReScript, PLEASE EDIT WITH CARE -'use strict'; - -let A3_a4 = require("./a3_a4.js"); - -console.log(A3_a4.v); - -let v = A3_a4.v; - -exports.v = v; -/* Not a pure module */ diff --git a/tests/tests/src/acyc/a4_a5.mjs b/tests/tests/src/acyc/a4_a5.mjs new file mode 100644 index 0000000000..b118ae0db2 --- /dev/null +++ b/tests/tests/src/acyc/a4_a5.mjs @@ -0,0 +1,12 @@ +// Generated by ReScript, PLEASE EDIT WITH CARE + +import * as A3_a4 from "./a3_a4.mjs"; + +console.log(A3_a4.v); + +let v = A3_a4.v; + +export { + v, +} +/* Not a pure module */ diff --git a/tests/tests/src/acyc/x.js b/tests/tests/src/acyc/x.js deleted file mode 100644 index 38508a0f7e..0000000000 --- a/tests/tests/src/acyc/x.js +++ /dev/null @@ -1,32 +0,0 @@ -// Generated by ReScript, PLEASE EDIT WITH CARE -'use strict'; - - -let A0_a1 = { - v: 3 -}; - -let A1_a2 = { - v: 3 -}; - -let A2_a3 = { - v: 3 -}; - -let A3_a4 = { - v: 3 -}; - -console.log(3); - -let A4_a5 = { - v: 3 -}; - -exports.A0_a1 = A0_a1; -exports.A1_a2 = A1_a2; -exports.A2_a3 = A2_a3; -exports.A3_a4 = A3_a4; -exports.A4_a5 = A4_a5; -/* Not a pure module */ diff --git a/tests/tests/src/acyc/x.mjs b/tests/tests/src/acyc/x.mjs new file mode 100644 index 0000000000..d9727ac5ad --- /dev/null +++ b/tests/tests/src/acyc/x.mjs @@ -0,0 +1,33 @@ +// Generated by ReScript, PLEASE EDIT WITH CARE + + +let A0_a1 = { + v: 3 +}; + +let A1_a2 = { + v: 3 +}; + +let A2_a3 = { + v: 3 +}; + +let A3_a4 = { + v: 3 +}; + +console.log(3); + +let A4_a5 = { + v: 3 +}; + +export { + A0_a1, + A1_a2, + A2_a3, + A3_a4, + A4_a5, +} +/* Not a pure module */ diff --git a/tests/tests/src/adt_optimize_test.js b/tests/tests/src/adt_optimize_test.js deleted file mode 100644 index ee9aab3edd..0000000000 --- a/tests/tests/src/adt_optimize_test.js +++ /dev/null @@ -1,208 +0,0 @@ -// Generated by ReScript, PLEASE EDIT WITH CARE -'use strict'; - - -function f(x) { - switch (x) { - case "A" : - return 1; - case "B" : - return 2; - case "C" : - return 3; - } -} - -function f_0(x) { - switch (x) { - case "A" : - return -1; - case "B" : - return 0; - case "C" : - return 1; - } -} - -function f2(x) { - if (x >= 3) { - return "T003"; - } - switch (x) { - case 0 : - return "T000"; - case 1 : - return "T001"; - case 2 : - return "T002"; - } -} - -function f3(x) { - switch (x) { - case "X0" : - return "Y0"; - case "X1" : - return "Y1"; - case "X2" : - return "Y2"; - case "X3" : - return "Y3"; - case "X4" : - return "Y4"; - } -} - -function f4(x) { - return 3; -} - -function f5(x) { - if (typeof x !== "object") { - switch (x) { - case "A" : - return 1; - case "B" : - return 3; - case "F" : - return 4; - } - } else { - switch (x.TAG) { - case "C" : - case "D" : - return 1; - case "E" : - return 2; - } - } -} - -function f6(x) { - if (typeof x === "object") { - return 1; - } - switch (x) { - case "A" : - case "B" : - return 0; - case "F" : - return 2; - } -} - -function f7(x) { - if (typeof x !== "object") { - switch (x) { - case "A" : - return 1; - case "B" : - return 2; - case "F" : - return -1; - } - } else { - switch (x.TAG) { - case "C" : - return 3; - case "D" : - return 4; - case "E" : - return -1; - } - } -} - -function f8(x) { - if (typeof x !== "object") { - switch (x) { - case "T60" : - case "T61" : - return 1; - default: - return 3; - } - } else { - switch (x.TAG) { - case "T64" : - case "T65" : - return 2; - default: - return 3; - } - } -} - -function f9(x) { - if (typeof x !== "object") { - if (x === "T63") { - return 3; - } else { - return 1; - } - } - switch (x.TAG) { - case "T64" : - case "T65" : - return 2; - case "T66" : - case "T68" : - return 3; - } -} - -function f10(x) { - if (typeof x !== "object") { - switch (x) { - case "T60" : - return 0; - case "T61" : - return 2; - case "T62" : - return 4; - case "T63" : - return 1; - } - } else { - switch (x.TAG) { - case "T64" : - case "T65" : - return 2; - case "T66" : - case "T68" : - return 3; - } - } -} - -function f11(x) { - if (typeof x !== "object") { - return 2; - } - if (x.TAG === "D") { - return 1; - } - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "adt_optimize_test.res", - 202, - 9 - ], - Error: new Error() - }; -} - -exports.f = f; -exports.f_0 = f_0; -exports.f2 = f2; -exports.f3 = f3; -exports.f4 = f4; -exports.f5 = f5; -exports.f6 = f6; -exports.f7 = f7; -exports.f8 = f8; -exports.f9 = f9; -exports.f10 = f10; -exports.f11 = f11; -/* No side effect */ diff --git a/tests/tests/src/adt_optimize_test.mjs b/tests/tests/src/adt_optimize_test.mjs new file mode 100644 index 0000000000..59784e1c18 --- /dev/null +++ b/tests/tests/src/adt_optimize_test.mjs @@ -0,0 +1,209 @@ +// Generated by ReScript, PLEASE EDIT WITH CARE + + +function f(x) { + switch (x) { + case "A" : + return 1; + case "B" : + return 2; + case "C" : + return 3; + } +} + +function f_0(x) { + switch (x) { + case "A" : + return -1; + case "B" : + return 0; + case "C" : + return 1; + } +} + +function f2(x) { + if (x >= 3) { + return "T003"; + } + switch (x) { + case 0 : + return "T000"; + case 1 : + return "T001"; + case 2 : + return "T002"; + } +} + +function f3(x) { + switch (x) { + case "X0" : + return "Y0"; + case "X1" : + return "Y1"; + case "X2" : + return "Y2"; + case "X3" : + return "Y3"; + case "X4" : + return "Y4"; + } +} + +function f4(x) { + return 3; +} + +function f5(x) { + if (typeof x !== "object") { + switch (x) { + case "A" : + return 1; + case "B" : + return 3; + case "F" : + return 4; + } + } else { + switch (x.TAG) { + case "C" : + case "D" : + return 1; + case "E" : + return 2; + } + } +} + +function f6(x) { + if (typeof x === "object") { + return 1; + } + switch (x) { + case "A" : + case "B" : + return 0; + case "F" : + return 2; + } +} + +function f7(x) { + if (typeof x !== "object") { + switch (x) { + case "A" : + return 1; + case "B" : + return 2; + case "F" : + return -1; + } + } else { + switch (x.TAG) { + case "C" : + return 3; + case "D" : + return 4; + case "E" : + return -1; + } + } +} + +function f8(x) { + if (typeof x !== "object") { + switch (x) { + case "T60" : + case "T61" : + return 1; + default: + return 3; + } + } else { + switch (x.TAG) { + case "T64" : + case "T65" : + return 2; + default: + return 3; + } + } +} + +function f9(x) { + if (typeof x !== "object") { + if (x === "T63") { + return 3; + } else { + return 1; + } + } + switch (x.TAG) { + case "T64" : + case "T65" : + return 2; + case "T66" : + case "T68" : + return 3; + } +} + +function f10(x) { + if (typeof x !== "object") { + switch (x) { + case "T60" : + return 0; + case "T61" : + return 2; + case "T62" : + return 4; + case "T63" : + return 1; + } + } else { + switch (x.TAG) { + case "T64" : + case "T65" : + return 2; + case "T66" : + case "T68" : + return 3; + } + } +} + +function f11(x) { + if (typeof x !== "object") { + return 2; + } + if (x.TAG === "D") { + return 1; + } + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "adt_optimize_test.res", + 202, + 9 + ], + Error: new Error() + }; +} + +export { + f, + f_0, + f2, + f3, + f4, + f5, + f6, + f7, + f8, + f9, + f10, + f11, +} +/* No side effect */ diff --git a/tests/tests/src/alias_default_value_test.js b/tests/tests/src/alias_default_value_test.js deleted file mode 100644 index 7d09bad077..0000000000 --- a/tests/tests/src/alias_default_value_test.js +++ /dev/null @@ -1,77 +0,0 @@ -// Generated by ReScript, PLEASE EDIT WITH CARE -'use strict'; - - -function Alias_default_value_test$C0(props) { - let __b = props.b; - let __a = props.a; - let a = __a !== undefined ? __a : 2; - let b = __b !== undefined ? __b : (a << 1); - return a + b | 0; -} - -let C0 = { - make: Alias_default_value_test$C0 -}; - -function Alias_default_value_test$C1(props) { - let __bar = props.foo; - if (__bar !== undefined) { - return __bar; - } else { - return ""; - } -} - -let C1 = { - make: Alias_default_value_test$C1 -}; - -function Alias_default_value_test$C2(props) { - let __a = props.a; - let __bar = props.foo; - let bar = __bar !== undefined ? __bar : ""; - let a = __a !== undefined ? __a : bar; - return bar + a + props.b; -} - -let C2 = { - make: Alias_default_value_test$C2 -}; - -function Alias_default_value_test$C3(props) { - let __text = props.text; - if (__text !== undefined) { - return __text; - } else { - return "Test"; - } -} - -let C3 = { - make: Alias_default_value_test$C3 -}; - -function Alias_default_value_test$C4(props) { - return props.a; -} - -let C4 = { - make: Alias_default_value_test$C4 -}; - -function Alias_default_value_test$C6(props) { - return props.comp.xx; -} - -let C6 = { - make: Alias_default_value_test$C6 -}; - -exports.C0 = C0; -exports.C1 = C1; -exports.C2 = C2; -exports.C3 = C3; -exports.C4 = C4; -exports.C6 = C6; -/* No side effect */ diff --git a/tests/tests/src/alias_default_value_test.mjs b/tests/tests/src/alias_default_value_test.mjs new file mode 100644 index 0000000000..ba7e994132 --- /dev/null +++ b/tests/tests/src/alias_default_value_test.mjs @@ -0,0 +1,78 @@ +// Generated by ReScript, PLEASE EDIT WITH CARE + + +function Alias_default_value_test$C0(props) { + let __b = props.b; + let __a = props.a; + let a = __a !== undefined ? __a : 2; + let b = __b !== undefined ? __b : (a << 1); + return a + b | 0; +} + +let C0 = { + make: Alias_default_value_test$C0 +}; + +function Alias_default_value_test$C1(props) { + let __bar = props.foo; + if (__bar !== undefined) { + return __bar; + } else { + return ""; + } +} + +let C1 = { + make: Alias_default_value_test$C1 +}; + +function Alias_default_value_test$C2(props) { + let __a = props.a; + let __bar = props.foo; + let bar = __bar !== undefined ? __bar : ""; + let a = __a !== undefined ? __a : bar; + return bar + a + props.b; +} + +let C2 = { + make: Alias_default_value_test$C2 +}; + +function Alias_default_value_test$C3(props) { + let __text = props.text; + if (__text !== undefined) { + return __text; + } else { + return "Test"; + } +} + +let C3 = { + make: Alias_default_value_test$C3 +}; + +function Alias_default_value_test$C4(props) { + return props.a; +} + +let C4 = { + make: Alias_default_value_test$C4 +}; + +function Alias_default_value_test$C6(props) { + return props.comp.xx; +} + +let C6 = { + make: Alias_default_value_test$C6 +}; + +export { + C0, + C1, + C2, + C3, + C4, + C6, +} +/* No side effect */ diff --git a/tests/tests/src/alias_test.js b/tests/tests/src/alias_test.js deleted file mode 100644 index 8ceff5cb6c..0000000000 --- a/tests/tests/src/alias_test.js +++ /dev/null @@ -1,31 +0,0 @@ -// Generated by ReScript, PLEASE EDIT WITH CARE -'use strict'; - - -let a10 = "hello world"; - -let a20 = a10 + "not"; - -let v = a20.codePointAt(0) === /* 'h' */104 ? 1 : 2; - -let a21 = a20 + a20; - -let a22 = "test " + (a21 + "hello"); - -function ff() { - return "cool " + a22; -} - -let a23 = ff(); - -let a15 = a10; - -let b15 = 111; - -exports.a15 = a15; -exports.b15 = b15; -exports.a21 = a21; -exports.v = v; -exports.a23 = a23; -exports.ff = ff; -/* v Not a pure module */ diff --git a/tests/tests/src/alias_test.mjs b/tests/tests/src/alias_test.mjs new file mode 100644 index 0000000000..0b97f7bb6c --- /dev/null +++ b/tests/tests/src/alias_test.mjs @@ -0,0 +1,32 @@ +// Generated by ReScript, PLEASE EDIT WITH CARE + + +let a10 = "hello world"; + +let a20 = a10 + "not"; + +let v = a20.codePointAt(0) === /* 'h' */104 ? 1 : 2; + +let a21 = a20 + a20; + +let a22 = "test " + (a21 + "hello"); + +function ff() { + return "cool " + a22; +} + +let a23 = ff(); + +let a15 = a10; + +let b15 = 111; + +export { + a15, + b15, + a21, + v, + a23, + ff, +} +/* v Not a pure module */ diff --git a/tests/tests/src/and_or_tailcall_test.js b/tests/tests/src/and_or_tailcall_test.js deleted file mode 100644 index 19a442c44f..0000000000 --- a/tests/tests/src/and_or_tailcall_test.js +++ /dev/null @@ -1,65 +0,0 @@ -// Generated by ReScript, PLEASE EDIT WITH CARE -'use strict'; - -let Mt = require("./mt.js"); - -function f(b, x, _n) { - while (true) { - let n = _n; - if (n > 100000) { - return false; - } - if (!b) { - return false; - } - _n = n + 1 | 0; - continue; - }; -} - -function or_f(b, x, _n) { - while (true) { - let n = _n; - if (n > 100000) { - return false; - } - if (b) { - return true; - } - _n = n + 1 | 0; - continue; - }; -} - -let suites_0 = [ - "and_tail", - param => ({ - TAG: "Eq", - _0: false, - _1: f(true, 1, 0) - }) -]; - -let suites_1 = { - hd: [ - "or_tail", - param => ({ - TAG: "Eq", - _0: false, - _1: or_f(false, 1, 0) - }) - ], - tl: /* [] */0 -}; - -let suites = { - hd: suites_0, - tl: suites_1 -}; - -Mt.from_pair_suites("And_or_tailcall_test", suites); - -exports.f = f; -exports.or_f = or_f; -exports.suites = suites; -/* Not a pure module */ diff --git a/tests/tests/src/and_or_tailcall_test.mjs b/tests/tests/src/and_or_tailcall_test.mjs new file mode 100644 index 0000000000..aa180944ad --- /dev/null +++ b/tests/tests/src/and_or_tailcall_test.mjs @@ -0,0 +1,66 @@ +// Generated by ReScript, PLEASE EDIT WITH CARE + +import * as Mt from "./mt.mjs"; + +function f(b, x, _n) { + while (true) { + let n = _n; + if (n > 100000) { + return false; + } + if (!b) { + return false; + } + _n = n + 1 | 0; + continue; + }; +} + +function or_f(b, x, _n) { + while (true) { + let n = _n; + if (n > 100000) { + return false; + } + if (b) { + return true; + } + _n = n + 1 | 0; + continue; + }; +} + +let suites_0 = [ + "and_tail", + param => ({ + TAG: "Eq", + _0: false, + _1: f(true, 1, 0) + }) +]; + +let suites_1 = { + hd: [ + "or_tail", + param => ({ + TAG: "Eq", + _0: false, + _1: or_f(false, 1, 0) + }) + ], + tl: /* [] */0 +}; + +let suites = { + hd: suites_0, + tl: suites_1 +}; + +Mt.from_pair_suites("And_or_tailcall_test", suites); + +export { + f, + or_f, + suites, +} +/* Not a pure module */ diff --git a/tests/tests/src/ari_regress_test.js b/tests/tests/src/ari_regress_test.js deleted file mode 100644 index 20043923ee..0000000000 --- a/tests/tests/src/ari_regress_test.js +++ /dev/null @@ -1,74 +0,0 @@ -// Generated by ReScript, PLEASE EDIT WITH CARE -'use strict'; - -let Mt = require("./mt.js"); - -let g = 7; - -let h = { - contents: 0 -}; - -function g1(x, y) { - let u = x + y | 0; - h.contents = h.contents + 1 | 0; - return (xx, yy) => (xx + yy | 0) + u | 0; -} - -let u = 8; - -let x = u + 6 | 0; - -function v(__x) { - return g1(3, 4)(6, __x); -} - -let suites_0 = [ - "curry", - param => ({ - TAG: "Eq", - _0: g, - _1: 7 - }) -]; - -let suites_1 = { - hd: [ - "curry2", - param => ({ - TAG: "Eq", - _0: 14, - _1: (v(1), v(1)) - }) - ], - tl: { - hd: [ - "curry3", - param => ({ - TAG: "Eq", - _0: x, - _1: 14 - }) - ], - tl: { - hd: [ - "File \"ari_regress_test.res\", line 35, characters 5-12", - param => ({ - TAG: "Eq", - _0: h.contents, - _1: 2 - }) - ], - tl: /* [] */0 - } - } -}; - -let suites = { - hd: suites_0, - tl: suites_1 -}; - -Mt.from_pair_suites("Ari_regress_test", suites); - -/* Not a pure module */ diff --git a/tests/tests/src/ari_regress_test.mjs b/tests/tests/src/ari_regress_test.mjs new file mode 100644 index 0000000000..d8cec46c27 --- /dev/null +++ b/tests/tests/src/ari_regress_test.mjs @@ -0,0 +1,73 @@ +// Generated by ReScript, PLEASE EDIT WITH CARE + +import * as Mt from "./mt.mjs"; + +let g = 7; + +let h = { + contents: 0 +}; + +function g1(x, y) { + let u = x + y | 0; + h.contents = h.contents + 1 | 0; + return (xx, yy) => (xx + yy | 0) + u | 0; +} + +let u = 8; + +let x = u + 6 | 0; + +function v(__x) { + return g1(3, 4)(6, __x); +} + +let suites_0 = [ + "curry", + param => ({ + TAG: "Eq", + _0: g, + _1: 7 + }) +]; + +let suites_1 = { + hd: [ + "curry2", + param => ({ + TAG: "Eq", + _0: 14, + _1: (v(1), v(1)) + }) + ], + tl: { + hd: [ + "curry3", + param => ({ + TAG: "Eq", + _0: x, + _1: 14 + }) + ], + tl: { + hd: [ + "File \"ari_regress_test.res\", line 35, characters 5-12", + param => ({ + TAG: "Eq", + _0: h.contents, + _1: 2 + }) + ], + tl: /* [] */0 + } + } +}; + +let suites = { + hd: suites_0, + tl: suites_1 +}; + +Mt.from_pair_suites("Ari_regress_test", suites); + +/* Not a pure module */ diff --git a/tests/tests/src/arith_syntax.js b/tests/tests/src/arith_syntax.js deleted file mode 100644 index 64ed0baced..0000000000 --- a/tests/tests/src/arith_syntax.js +++ /dev/null @@ -1,25 +0,0 @@ -// Generated by ReScript, PLEASE EDIT WITH CARE -'use strict'; - - -function str(e) { - switch (e.TAG) { - case "Numeral" : - return e._0.toString(); - case "Plus" : - return str(e._0) + ("+" + str(e._1)); - case "Minus" : - return str(e._0) + ("-" + str(e._1)); - case "Times" : - return str(e._0) + ("*" + str(e._1)); - case "Divide" : - return str(e._0) + ("/" + str(e._1)); - case "Negate" : - return "-" + str(e._0); - case "Variable" : - return e._0; - } -} - -exports.str = str; -/* No side effect */ diff --git a/tests/tests/src/arith_syntax.mjs b/tests/tests/src/arith_syntax.mjs new file mode 100644 index 0000000000..4ee789e812 --- /dev/null +++ b/tests/tests/src/arith_syntax.mjs @@ -0,0 +1,26 @@ +// Generated by ReScript, PLEASE EDIT WITH CARE + + +function str(e) { + switch (e.TAG) { + case "Numeral" : + return e._0.toString(); + case "Plus" : + return str(e._0) + ("+" + str(e._1)); + case "Minus" : + return str(e._0) + ("-" + str(e._1)); + case "Times" : + return str(e._0) + ("*" + str(e._1)); + case "Divide" : + return str(e._0) + ("/" + str(e._1)); + case "Negate" : + return "-" + str(e._0); + case "Variable" : + return e._0; + } +} + +export { + str, +} +/* No side effect */ diff --git a/tests/tests/src/arity.js b/tests/tests/src/arity.js deleted file mode 100644 index c102b0bb09..0000000000 --- a/tests/tests/src/arity.js +++ /dev/null @@ -1,40 +0,0 @@ -// Generated by ReScript, PLEASE EDIT WITH CARE -'use strict'; - - -function u(f, a, b) { - console.log(f(a, b)); - console.log(f(a, b)); -} - -function u2(f, a, b) { - console.log(f(a, b)); - console.log(f(a, b)); -} - -function f(x, y) { - return x + y | 0; -} - -function add(prim0, prim1) { - return prim0 + prim1 | 0; -} - -function h(u) { - let m = u.hi; - return m(1, 2); -} - -let nested = { - x: { - y: 3 - } -}; - -exports.u = u; -exports.u2 = u2; -exports.f = f; -exports.add = add; -exports.h = h; -exports.nested = nested; -/* No side effect */ diff --git a/tests/tests/src/arity.mjs b/tests/tests/src/arity.mjs new file mode 100644 index 0000000000..3545d46d5d --- /dev/null +++ b/tests/tests/src/arity.mjs @@ -0,0 +1,41 @@ +// Generated by ReScript, PLEASE EDIT WITH CARE + + +function u(f, a, b) { + console.log(f(a, b)); + console.log(f(a, b)); +} + +function u2(f, a, b) { + console.log(f(a, b)); + console.log(f(a, b)); +} + +function f(x, y) { + return x + y | 0; +} + +function add(prim0, prim1) { + return prim0 + prim1 | 0; +} + +function h(u) { + let m = u.hi; + return m(1, 2); +} + +let nested = { + x: { + y: 3 + } +}; + +export { + u, + u2, + f, + add, + h, + nested, +} +/* No side effect */ diff --git a/tests/tests/src/arity_deopt.js b/tests/tests/src/arity_deopt.js deleted file mode 100644 index 2ee8396746..0000000000 --- a/tests/tests/src/arity_deopt.js +++ /dev/null @@ -1,62 +0,0 @@ -// Generated by ReScript, PLEASE EDIT WITH CARE -'use strict'; - -let Mt = require("./mt.js"); - -let suites = { - contents: /* [] */0 -}; - -let test_id = { - contents: 0 -}; - -function eq(loc, x, y) { - test_id.contents = test_id.contents + 1 | 0; - suites.contents = { - hd: [ - loc + (" id " + test_id.contents.toString()), - () => ({ - TAG: "Eq", - _0: x, - _1: y - }) - ], - tl: suites.contents - }; -} - -function f0(x, y, z) { - return (x + y | 0) + z | 0; -} - -function f1(x) { - return (y, z) => (x + y | 0) + z | 0; -} - -function f2(x, y) { - return z => (x + y | 0) + z | 0; -} - -function f3(x) { - return (y, z) => (x + y | 0) + z | 0; -} - -eq("File \"arity_deopt.res\", line 50, characters 11-18", 6, 6); - -eq("File \"arity_deopt.res\", line 51, characters 11-18", 6, 6); - -eq("File \"arity_deopt.res\", line 52, characters 11-18", 6, 6); - -eq("File \"arity_deopt.res\", line 53, characters 11-18", 6, 6); - -Mt.from_pair_suites("Arity_deopt", suites.contents); - -exports.suites = suites; -exports.test_id = test_id; -exports.eq = eq; -exports.f0 = f0; -exports.f1 = f1; -exports.f2 = f2; -exports.f3 = f3; -/* Not a pure module */ diff --git a/tests/tests/src/arity_deopt.mjs b/tests/tests/src/arity_deopt.mjs new file mode 100644 index 0000000000..e12d7b1ffe --- /dev/null +++ b/tests/tests/src/arity_deopt.mjs @@ -0,0 +1,63 @@ +// Generated by ReScript, PLEASE EDIT WITH CARE + +import * as Mt from "./mt.mjs"; + +let suites = { + contents: /* [] */0 +}; + +let test_id = { + contents: 0 +}; + +function eq(loc, x, y) { + test_id.contents = test_id.contents + 1 | 0; + suites.contents = { + hd: [ + loc + (" id " + test_id.contents.toString()), + () => ({ + TAG: "Eq", + _0: x, + _1: y + }) + ], + tl: suites.contents + }; +} + +function f0(x, y, z) { + return (x + y | 0) + z | 0; +} + +function f1(x) { + return (y, z) => (x + y | 0) + z | 0; +} + +function f2(x, y) { + return z => (x + y | 0) + z | 0; +} + +function f3(x) { + return (y, z) => (x + y | 0) + z | 0; +} + +eq("File \"arity_deopt.res\", line 50, characters 11-18", 6, 6); + +eq("File \"arity_deopt.res\", line 51, characters 11-18", 6, 6); + +eq("File \"arity_deopt.res\", line 52, characters 11-18", 6, 6); + +eq("File \"arity_deopt.res\", line 53, characters 11-18", 6, 6); + +Mt.from_pair_suites("Arity_deopt", suites.contents); + +export { + suites, + test_id, + eq, + f0, + f1, + f2, + f3, +} +/* Not a pure module */ diff --git a/tests/tests/src/arity_infer.js b/tests/tests/src/arity_infer.js deleted file mode 100644 index 0e7fd13815..0000000000 --- a/tests/tests/src/arity_infer.js +++ /dev/null @@ -1,53 +0,0 @@ -// Generated by ReScript, PLEASE EDIT WITH CARE -'use strict'; - - -function f0(x) { - let tmp; - if (x > 3) { - tmp = x => x + 1 | 0; - } else { - throw { - RE_EXN_ID: "Not_found", - Error: new Error() - }; - } - return tmp(3); -} - -function f1(x) { - throw { - RE_EXN_ID: "Not_found", - Error: new Error() - }; - return undefined(x); -} - -function f3(x) { - let tmp; - switch (x) { - case 0 : - tmp = x => x + 1 | 0; - break; - case 1 : - tmp = x => x + 2 | 0; - break; - case 2 : - tmp = x => x + 3 | 0; - break; - case 3 : - tmp = x => x + 4 | 0; - break; - default: - throw { - RE_EXN_ID: "Not_found", - Error: new Error() - }; - } - return tmp(3); -} - -exports.f0 = f0; -exports.f1 = f1; -exports.f3 = f3; -/* No side effect */ diff --git a/tests/tests/src/arity_infer.mjs b/tests/tests/src/arity_infer.mjs new file mode 100644 index 0000000000..d009cbf9ae --- /dev/null +++ b/tests/tests/src/arity_infer.mjs @@ -0,0 +1,54 @@ +// Generated by ReScript, PLEASE EDIT WITH CARE + + +function f0(x) { + let tmp; + if (x > 3) { + tmp = x => x + 1 | 0; + } else { + throw { + RE_EXN_ID: "Not_found", + Error: new Error() + }; + } + return tmp(3); +} + +function f1(x) { + throw { + RE_EXN_ID: "Not_found", + Error: new Error() + }; + return undefined(x); +} + +function f3(x) { + let tmp; + switch (x) { + case 0 : + tmp = x => x + 1 | 0; + break; + case 1 : + tmp = x => x + 2 | 0; + break; + case 2 : + tmp = x => x + 3 | 0; + break; + case 3 : + tmp = x => x + 4 | 0; + break; + default: + throw { + RE_EXN_ID: "Not_found", + Error: new Error() + }; + } + return tmp(3); +} + +export { + f0, + f1, + f3, +} +/* No side effect */ diff --git a/tests/tests/src/array_data_util.js b/tests/tests/src/array_data_util.js deleted file mode 100644 index cb6db4f707..0000000000 --- a/tests/tests/src/array_data_util.js +++ /dev/null @@ -1,21 +0,0 @@ -// Generated by ReScript, PLEASE EDIT WITH CARE -'use strict'; - -let Belt_Array = require("rescript/lib/js/Belt_Array.js"); - -function range(i, j) { - return Belt_Array.makeBy((j - i | 0) + 1 | 0, k => k + i | 0); -} - -function randomRange(i, j) { - let v = Belt_Array.makeBy((j - i | 0) + 1 | 0, k => k + i | 0); - Belt_Array.shuffleInPlace(v); - return v; -} - -let A; - -exports.A = A; -exports.range = range; -exports.randomRange = randomRange; -/* No side effect */ diff --git a/tests/tests/src/array_data_util.mjs b/tests/tests/src/array_data_util.mjs new file mode 100644 index 0000000000..fed7896a91 --- /dev/null +++ b/tests/tests/src/array_data_util.mjs @@ -0,0 +1,22 @@ +// Generated by ReScript, PLEASE EDIT WITH CARE + +import * as Belt_Array from "rescript/lib/es6/Belt_Array.js"; + +function range(i, j) { + return Belt_Array.makeBy((j - i | 0) + 1 | 0, k => k + i | 0); +} + +function randomRange(i, j) { + let v = Belt_Array.makeBy((j - i | 0) + 1 | 0, k => k + i | 0); + Belt_Array.shuffleInPlace(v); + return v; +} + +let A; + +export { + A, + range, + randomRange, +} +/* No side effect */ diff --git a/tests/tests/src/array_safe_get.js b/tests/tests/src/array_safe_get.js deleted file mode 100644 index 1f08bf078c..0000000000 --- a/tests/tests/src/array_safe_get.js +++ /dev/null @@ -1,31 +0,0 @@ -// Generated by ReScript, PLEASE EDIT WITH CARE -'use strict'; - -let Primitive_array = require("rescript/lib/js/Primitive_array.js"); -let Primitive_exceptions = require("rescript/lib/js/Primitive_exceptions.js"); - -let x = [ - 1, - 2 -]; - -let y; - -try { - y = Primitive_array.get(x, 3); -} catch (raw_msg) { - let msg = Primitive_exceptions.internalToException(raw_msg); - if (msg.RE_EXN_ID === "Invalid_argument") { - console.log(msg._1); - y = 0; - } else { - throw msg; - } -} - -let $$Array; - -exports.$$Array = $$Array; -exports.x = x; -exports.y = y; -/* y Not a pure module */ diff --git a/tests/tests/src/array_safe_get.mjs b/tests/tests/src/array_safe_get.mjs new file mode 100644 index 0000000000..7ddd6113b7 --- /dev/null +++ b/tests/tests/src/array_safe_get.mjs @@ -0,0 +1,32 @@ +// Generated by ReScript, PLEASE EDIT WITH CARE + +import * as Primitive_array from "rescript/lib/es6/Primitive_array.js"; +import * as Primitive_exceptions from "rescript/lib/es6/Primitive_exceptions.js"; + +let x = [ + 1, + 2 +]; + +let y; + +try { + y = Primitive_array.get(x, 3); +} catch (raw_msg) { + let msg = Primitive_exceptions.internalToException(raw_msg); + if (msg.RE_EXN_ID === "Invalid_argument") { + console.log(msg._1); + y = 0; + } else { + throw msg; + } +} + +let $$Array; + +export { + $$Array, + x, + y, +} +/* y Not a pure module */ diff --git a/tests/tests/src/array_subtle_test.js b/tests/tests/src/array_subtle_test.js deleted file mode 100644 index c8d11befb2..0000000000 --- a/tests/tests/src/array_subtle_test.js +++ /dev/null @@ -1,143 +0,0 @@ -// Generated by ReScript, PLEASE EDIT WITH CARE -'use strict'; - -let Mt = require("./mt.js"); -let Primitive_array = require("rescript/lib/js/Primitive_array.js"); - -let suites = { - contents: /* [] */0 -}; - -let test_id = { - contents: 0 -}; - -function eq(loc, param) { - let y = param[1]; - let x = param[0]; - test_id.contents = test_id.contents + 1 | 0; - suites.contents = { - hd: [ - loc + (" id " + test_id.contents.toString()), - () => ({ - TAG: "Eq", - _0: x, - _1: y - }) - ], - tl: suites.contents - }; -} - -let v = [ - 1, - 2, - 3, - 3 -]; - -eq("File \"array_subtle_test.res\", line 16, characters 12-19", [ - 4, - v.length -]); - -eq("File \"array_subtle_test.res\", line 19, characters 5-12", [ - 5, - v.push(3) -]); - -eq("File \"array_subtle_test.res\", line 20, characters 5-12", [ - 5, - v.length -]); - -eq("File \"array_subtle_test.res\", line 21, characters 5-12", [ - 5, - v.length -]); - -eq("File \"array_subtle_test.res\", line 25, characters 5-12", [ - 3, - Primitive_array.get(v, 2) -]); - -Primitive_array.set(v, 2, 4); - -eq("File \"array_subtle_test.res\", line 27, characters 5-12", [ - 4, - Primitive_array.get(v, 2) -]); - -while (v.length > 0) { - v.pop(); -}; - -eq("File \"array_subtle_test.res\", line 34, characters 5-12", [ - 0, - v.length -]); - -function f(v) { - let x = v.pop(); - if (x !== undefined) { - console.log("hi"); - } else { - console.log("hi2"); - } - console.log((v.pop(), undefined)); -} - -function fff(x) { - return true; -} - -function fff2(x) { - if (x.length >= 10) { - console.log("hi"); - return; - } - -} - -function fff3(x) { - return 1; -} - -function fff4(x) { - if (x.length !== 0) { - return 1; - } else { - return 2; - } -} - -eq("File \"array_subtle_test.res\", line 66, characters 3-10", [ - fff3([]), - 1 -]); - -eq("File \"array_subtle_test.res\", line 67, characters 3-10", [ - fff4([]), - 2 -]); - -eq("File \"array_subtle_test.res\", line 68, characters 3-10", [ - fff4([1]), - 1 -]); - -Mt.from_pair_suites("Array_subtle_test", suites.contents); - -let $$Array; - -exports.$$Array = $$Array; -exports.suites = suites; -exports.test_id = test_id; -exports.eq = eq; -exports.v = v; -exports.f = f; -exports.fff = fff; -exports.fff2 = fff2; -exports.fff3 = fff3; -exports.fff4 = fff4; -/* Not a pure module */ diff --git a/tests/tests/src/array_subtle_test.mjs b/tests/tests/src/array_subtle_test.mjs new file mode 100644 index 0000000000..233c0680ee --- /dev/null +++ b/tests/tests/src/array_subtle_test.mjs @@ -0,0 +1,144 @@ +// Generated by ReScript, PLEASE EDIT WITH CARE + +import * as Mt from "./mt.mjs"; +import * as Primitive_array from "rescript/lib/es6/Primitive_array.js"; + +let suites = { + contents: /* [] */0 +}; + +let test_id = { + contents: 0 +}; + +function eq(loc, param) { + let y = param[1]; + let x = param[0]; + test_id.contents = test_id.contents + 1 | 0; + suites.contents = { + hd: [ + loc + (" id " + test_id.contents.toString()), + () => ({ + TAG: "Eq", + _0: x, + _1: y + }) + ], + tl: suites.contents + }; +} + +let v = [ + 1, + 2, + 3, + 3 +]; + +eq("File \"array_subtle_test.res\", line 16, characters 12-19", [ + 4, + v.length +]); + +eq("File \"array_subtle_test.res\", line 19, characters 5-12", [ + 5, + v.push(3) +]); + +eq("File \"array_subtle_test.res\", line 20, characters 5-12", [ + 5, + v.length +]); + +eq("File \"array_subtle_test.res\", line 21, characters 5-12", [ + 5, + v.length +]); + +eq("File \"array_subtle_test.res\", line 25, characters 5-12", [ + 3, + Primitive_array.get(v, 2) +]); + +Primitive_array.set(v, 2, 4); + +eq("File \"array_subtle_test.res\", line 27, characters 5-12", [ + 4, + Primitive_array.get(v, 2) +]); + +while (v.length > 0) { + v.pop(); +}; + +eq("File \"array_subtle_test.res\", line 34, characters 5-12", [ + 0, + v.length +]); + +function f(v) { + let x = v.pop(); + if (x !== undefined) { + console.log("hi"); + } else { + console.log("hi2"); + } + console.log((v.pop(), undefined)); +} + +function fff(x) { + return true; +} + +function fff2(x) { + if (x.length >= 10) { + console.log("hi"); + return; + } + +} + +function fff3(x) { + return 1; +} + +function fff4(x) { + if (x.length !== 0) { + return 1; + } else { + return 2; + } +} + +eq("File \"array_subtle_test.res\", line 66, characters 3-10", [ + fff3([]), + 1 +]); + +eq("File \"array_subtle_test.res\", line 67, characters 3-10", [ + fff4([]), + 2 +]); + +eq("File \"array_subtle_test.res\", line 68, characters 3-10", [ + fff4([1]), + 1 +]); + +Mt.from_pair_suites("Array_subtle_test", suites.contents); + +let $$Array; + +export { + $$Array, + suites, + test_id, + eq, + v, + f, + fff, + fff2, + fff3, + fff4, +} +/* Not a pure module */ diff --git a/tests/tests/src/as_inline_record_test.js b/tests/tests/src/as_inline_record_test.js deleted file mode 100644 index 7a320bb8bf..0000000000 --- a/tests/tests/src/as_inline_record_test.js +++ /dev/null @@ -1,32 +0,0 @@ -// Generated by ReScript, PLEASE EDIT WITH CARE -'use strict'; - - -function getName(t) { - return t.renamed; -} - -function getName$p(t) { - return t.renamed; -} - -function getAge(t) { - return t.age; -} - -function getAge$p(t) { - return t.age; -} - -let user = { - TAG: "User", - renamed: "Corentin", - age: 35 -}; - -exports.user = user; -exports.getName = getName; -exports.getName$p = getName$p; -exports.getAge = getAge; -exports.getAge$p = getAge$p; -/* No side effect */ diff --git a/tests/tests/src/as_inline_record_test.mjs b/tests/tests/src/as_inline_record_test.mjs new file mode 100644 index 0000000000..bde885a70e --- /dev/null +++ b/tests/tests/src/as_inline_record_test.mjs @@ -0,0 +1,33 @@ +// Generated by ReScript, PLEASE EDIT WITH CARE + + +function getName(t) { + return t.renamed; +} + +function getName$p(t) { + return t.renamed; +} + +function getAge(t) { + return t.age; +} + +function getAge$p(t) { + return t.age; +} + +let user = { + TAG: "User", + renamed: "Corentin", + age: 35 +}; + +export { + user, + getName, + getName$p, + getAge, + getAge$p, +} +/* No side effect */ diff --git a/tests/tests/src/ast_abstract_test.js b/tests/tests/src/ast_abstract_test.js deleted file mode 100644 index cda63897b2..0000000000 --- a/tests/tests/src/ast_abstract_test.js +++ /dev/null @@ -1,96 +0,0 @@ -// Generated by ReScript, PLEASE EDIT WITH CARE -'use strict'; - -let Mt = require("./mt.js"); -let Primitive_util = require("rescript/lib/js/Primitive_util.js"); - -let suites = { - contents: /* [] */0 -}; - -let test_id = { - contents: 0 -}; - -function eq(loc, x, y) { - test_id.contents = test_id.contents + 1 | 0; - suites.contents = { - hd: [ - loc + (" id " + test_id.contents.toString()), - () => ({ - TAG: "Eq", - _0: x, - _1: y - }) - ], - tl: suites.contents - }; -} - -function tToJs(param) { - return { - x: param.x, - y: param.y, - z: param.z - }; -} - -function tFromJs(param) { - return { - x: param.x, - y: param.y, - z: param.z - }; -} - -let v0 = { - x: 3, - y: false, - z: false -}; - -let v1 = { - x: 3, - y: false, - z: "" -}; - -let _map = {"a":"a","b":"b","c":"c"}; - -function xToJs(param) { - return param; -} - -function xFromJs(param) { - return Primitive_util.raiseWhenNotFound(_map[param]); -} - -function idx(v) { - eq("File \"ast_abstract_test.res\", line 29, characters 18-25", xFromJs(v), v); -} - -idx("a"); - -idx("b"); - -idx("c"); - -Mt.from_pair_suites("Ast_abstract_test", suites.contents); - -let x0 = "a"; - -let x1 = "b"; - -exports.suites = suites; -exports.test_id = test_id; -exports.eq = eq; -exports.tToJs = tToJs; -exports.tFromJs = tFromJs; -exports.v0 = v0; -exports.v1 = v1; -exports.xToJs = xToJs; -exports.xFromJs = xFromJs; -exports.idx = idx; -exports.x0 = x0; -exports.x1 = x1; -/* Not a pure module */ diff --git a/tests/tests/src/ast_abstract_test.mjs b/tests/tests/src/ast_abstract_test.mjs new file mode 100644 index 0000000000..4044c5b37f --- /dev/null +++ b/tests/tests/src/ast_abstract_test.mjs @@ -0,0 +1,97 @@ +// Generated by ReScript, PLEASE EDIT WITH CARE + +import * as Mt from "./mt.mjs"; +import * as Primitive_util from "rescript/lib/es6/Primitive_util.js"; + +let suites = { + contents: /* [] */0 +}; + +let test_id = { + contents: 0 +}; + +function eq(loc, x, y) { + test_id.contents = test_id.contents + 1 | 0; + suites.contents = { + hd: [ + loc + (" id " + test_id.contents.toString()), + () => ({ + TAG: "Eq", + _0: x, + _1: y + }) + ], + tl: suites.contents + }; +} + +function tToJs(param) { + return { + x: param.x, + y: param.y, + z: param.z + }; +} + +function tFromJs(param) { + return { + x: param.x, + y: param.y, + z: param.z + }; +} + +let v0 = { + x: 3, + y: false, + z: false +}; + +let v1 = { + x: 3, + y: false, + z: "" +}; + +let _map = {"a":"a","b":"b","c":"c"}; + +function xToJs(param) { + return param; +} + +function xFromJs(param) { + return Primitive_util.raiseWhenNotFound(_map[param]); +} + +function idx(v) { + eq("File \"ast_abstract_test.res\", line 29, characters 18-25", xFromJs(v), v); +} + +idx("a"); + +idx("b"); + +idx("c"); + +Mt.from_pair_suites("Ast_abstract_test", suites.contents); + +let x0 = "a"; + +let x1 = "b"; + +export { + suites, + test_id, + eq, + tToJs, + tFromJs, + v0, + v1, + xToJs, + xFromJs, + idx, + x0, + x1, +} +/* Not a pure module */ diff --git a/tests/tests/src/ast_mapper_unused_warning_test.js b/tests/tests/src/ast_mapper_unused_warning_test.mjs similarity index 100% rename from tests/tests/src/ast_mapper_unused_warning_test.js rename to tests/tests/src/ast_mapper_unused_warning_test.mjs diff --git a/tests/tests/src/async_await.js b/tests/tests/src/async_await.js deleted file mode 100644 index 670f6a7869..0000000000 --- a/tests/tests/src/async_await.js +++ /dev/null @@ -1,46 +0,0 @@ -// Generated by ReScript, PLEASE EDIT WITH CARE -'use strict'; - - -function next(n) { - return n + 1 | 0; -} - -async function useNext() { - return 4; -} - -function Make(I) { - let get = async key => await I.get(key); - return { - get: get - }; -} - -async function topFoo() { - return 1; -} - -let arr = [ - 1, - 2, - 3 -]; - -let toplevelAwait = await topFoo(); - -let toplevelAwait2 = arr[await topFoo()]; - -async function f(value) { - return await Promise.resolve(1); -} - -exports.next = next; -exports.useNext = useNext; -exports.Make = Make; -exports.topFoo = topFoo; -exports.arr = arr; -exports.toplevelAwait = toplevelAwait; -exports.toplevelAwait2 = toplevelAwait2; -exports.f = f; -/* toplevelAwait Not a pure module */ diff --git a/tests/tests/src/async_await.mjs b/tests/tests/src/async_await.mjs new file mode 100644 index 0000000000..1511a66cf3 --- /dev/null +++ b/tests/tests/src/async_await.mjs @@ -0,0 +1,47 @@ +// Generated by ReScript, PLEASE EDIT WITH CARE + + +function next(n) { + return n + 1 | 0; +} + +async function useNext() { + return 4; +} + +function Make(I) { + let get = async key => await I.get(key); + return { + get: get + }; +} + +async function topFoo() { + return 1; +} + +let arr = [ + 1, + 2, + 3 +]; + +let toplevelAwait = await topFoo(); + +let toplevelAwait2 = arr[await topFoo()]; + +async function f(value) { + return await Promise.resolve(1); +} + +export { + next, + useNext, + Make, + topFoo, + arr, + toplevelAwait, + toplevelAwait2, + f, +} +/* toplevelAwait Not a pure module */ diff --git a/tests/tests/src/async_inline.js b/tests/tests/src/async_inline.js deleted file mode 100644 index 247e22bdff..0000000000 --- a/tests/tests/src/async_inline.js +++ /dev/null @@ -1,95 +0,0 @@ -// Generated by ReScript, PLEASE EDIT WITH CARE -'use strict'; - -let React = require("react"); - -async function willBeInlined() { - return 3; -} - -let inlined = willBeInlined(); - -function wrapSomethingAsync() { - (async param => { - let test = await Promise.resolve("Test"); - console.log(test); - })(777); -} - -function wrapSomethingAsync2() { - (async () => { - let test = await Promise.resolve("Test"); - console.log(test); - })(); -} - -async function doSomethingAsync(someAsyncFunction) { - return await someAsyncFunction(); -} - -let broken = doSomethingAsync; - -let M = { - broken: broken -}; - -async function broken$1(someAsyncFunction) { - return await someAsyncFunction(); -} - -let broken$2 = broken$1; - -function curriedId(x) { - return x; -} - -async function curriedIdAsync(x) { - return x; -} - -function uncurriedId(x) { - return x; -} - -async function uncurriedIdAsync(x) { - return x; -} - -let tci = 3; - -let tcia = curriedIdAsync(3); - -let tui = 3; - -let tuia = uncurriedIdAsync(3); - -function nested1() { - return async y => await y; -} - -async function nested2() { - return async y => await y; -} - -function onSubmit() { - return React.useCallback(async b => await b); -} - -exports.willBeInlined = willBeInlined; -exports.inlined = inlined; -exports.wrapSomethingAsync = wrapSomethingAsync; -exports.wrapSomethingAsync2 = wrapSomethingAsync2; -exports.M = M; -exports.broken = broken$2; -exports.curriedId = curriedId; -exports.curriedIdAsync = curriedIdAsync; -exports.uncurriedId = uncurriedId; -exports.uncurriedIdAsync = uncurriedIdAsync; -exports.tci = tci; -exports.tcia = tcia; -exports.tui = tui; -exports.tuia = tuia; -exports.nested1 = nested1; -exports.nested2 = nested2; -exports.onSubmit = onSubmit; -/* inlined Not a pure module */ diff --git a/tests/tests/src/async_inline.mjs b/tests/tests/src/async_inline.mjs new file mode 100644 index 0000000000..e5d8b12954 --- /dev/null +++ b/tests/tests/src/async_inline.mjs @@ -0,0 +1,96 @@ +// Generated by ReScript, PLEASE EDIT WITH CARE + +import * as React from "react"; + +async function willBeInlined() { + return 3; +} + +let inlined = willBeInlined(); + +function wrapSomethingAsync() { + (async param => { + let test = await Promise.resolve("Test"); + console.log(test); + })(777); +} + +function wrapSomethingAsync2() { + (async () => { + let test = await Promise.resolve("Test"); + console.log(test); + })(); +} + +async function doSomethingAsync(someAsyncFunction) { + return await someAsyncFunction(); +} + +let broken = doSomethingAsync; + +let M = { + broken: broken +}; + +async function broken$1(someAsyncFunction) { + return await someAsyncFunction(); +} + +let broken$2 = broken$1; + +function curriedId(x) { + return x; +} + +async function curriedIdAsync(x) { + return x; +} + +function uncurriedId(x) { + return x; +} + +async function uncurriedIdAsync(x) { + return x; +} + +let tci = 3; + +let tcia = curriedIdAsync(3); + +let tui = 3; + +let tuia = uncurriedIdAsync(3); + +function nested1() { + return async y => await y; +} + +async function nested2() { + return async y => await y; +} + +function onSubmit() { + return React.useCallback(async b => await b); +} + +export { + willBeInlined, + inlined, + wrapSomethingAsync, + wrapSomethingAsync2, + M, + broken$2 as broken, + curriedId, + curriedIdAsync, + uncurriedId, + uncurriedIdAsync, + tci, + tcia, + tui, + tuia, + nested1, + nested2, + onSubmit, +} +/* inlined Not a pure module */ diff --git a/tests/tests/src/async_inside_loop.js b/tests/tests/src/async_inside_loop.js deleted file mode 100644 index 889065bf7e..0000000000 --- a/tests/tests/src/async_inside_loop.js +++ /dev/null @@ -1,18 +0,0 @@ -// Generated by ReScript, PLEASE EDIT WITH CARE -'use strict'; - - -async function topLevelAsyncFunction() { - for (let innerScopeVal = 0; innerScopeVal <= 3; ++innerScopeVal) { - let asyncClosureAccessingScopedVal = async () => { - console.log("Accessing scoped var inside loop", innerScopeVal); - return await Promise.resolve(); - }; - await asyncClosureAccessingScopedVal(); - } -} - -topLevelAsyncFunction(); - -exports.topLevelAsyncFunction = topLevelAsyncFunction; -/* Not a pure module */ diff --git a/tests/tests/src/async_inside_loop.mjs b/tests/tests/src/async_inside_loop.mjs new file mode 100644 index 0000000000..36298ce7d3 --- /dev/null +++ b/tests/tests/src/async_inside_loop.mjs @@ -0,0 +1,19 @@ +// Generated by ReScript, PLEASE EDIT WITH CARE + + +async function topLevelAsyncFunction() { + for (let innerScopeVal = 0; innerScopeVal <= 3; ++innerScopeVal) { + let asyncClosureAccessingScopedVal = async () => { + console.log("Accessing scoped var inside loop", innerScopeVal); + return await Promise.resolve(); + }; + await asyncClosureAccessingScopedVal(); + } +} + +topLevelAsyncFunction(); + +export { + topLevelAsyncFunction, +} +/* Not a pure module */ diff --git a/tests/tests/src/attr_test.js b/tests/tests/src/attr_test.js deleted file mode 100644 index 646d4e7de1..0000000000 --- a/tests/tests/src/attr_test.js +++ /dev/null @@ -1,28 +0,0 @@ -// Generated by ReScript, PLEASE EDIT WITH CARE -'use strict'; - - -function u(x, y) { - return x + y | 0; -} - -let h = 3; - -function max2(x, y) { - return x + y; -} - -let hh = 1 + 2; - -function f(x) { - des(x, () => { - console.log("hei"); - }); -} - -exports.u = u; -exports.h = h; -exports.max2 = max2; -exports.hh = hh; -exports.f = f; -/* No side effect */ diff --git a/tests/tests/src/attr_test.mjs b/tests/tests/src/attr_test.mjs new file mode 100644 index 0000000000..d839ca7232 --- /dev/null +++ b/tests/tests/src/attr_test.mjs @@ -0,0 +1,29 @@ +// Generated by ReScript, PLEASE EDIT WITH CARE + + +function u(x, y) { + return x + y | 0; +} + +let h = 3; + +function max2(x, y) { + return x + y; +} + +let hh = 1 + 2; + +function f(x) { + des(x, () => { + console.log("hei"); + }); +} + +export { + u, + h, + max2, + hh, + f, +} +/* No side effect */ diff --git a/tests/tests/src/b.js b/tests/tests/src/b.js deleted file mode 100644 index 350cd0e7d9..0000000000 --- a/tests/tests/src/b.js +++ /dev/null @@ -1,12 +0,0 @@ -// Generated by ReScript, PLEASE EDIT WITH CARE -'use strict'; - - -function f(point) { - let y = point.y; - let x = point.x; - return Math.pow(x * x + y * y, 2); -} - -exports.f = f; -/* No side effect */ diff --git a/tests/tests/src/b.mjs b/tests/tests/src/b.mjs new file mode 100644 index 0000000000..1738e2ec25 --- /dev/null +++ b/tests/tests/src/b.mjs @@ -0,0 +1,13 @@ +// Generated by ReScript, PLEASE EDIT WITH CARE + + +function f(point) { + let y = point.y; + let x = point.x; + return Math.pow(x * x + y * y, 2); +} + +export { + f, +} +/* No side effect */ diff --git a/tests/tests/src/bal_set_mini.js b/tests/tests/src/bal_set_mini.js deleted file mode 100644 index 3e5ebbf698..0000000000 --- a/tests/tests/src/bal_set_mini.js +++ /dev/null @@ -1,201 +0,0 @@ -// Generated by ReScript, PLEASE EDIT WITH CARE -'use strict'; - - -function height(x) { - if (typeof x !== "object") { - return 0; - } else { - return x._3; - } -} - -function create(l, v, r) { - let hl = height(l); - let hr = height(r); - return { - TAG: "Node", - _0: l, - _1: v, - _2: r, - _3: hl >= hr ? hl + 1 | 0 : hr + 1 | 0 - }; -} - -function bal(l, v, r) { - let hl = height(l); - let hr = height(r); - if (hl > (hr + 2 | 0)) { - if (typeof l !== "object") { - return "Empty"; - } - let lr = l._2; - let lv = l._1; - let ll = l._0; - if (height(ll) >= height(lr)) { - return create(ll, lv, create(lr, v, r)); - } else if (typeof lr !== "object") { - return "Empty"; - } else { - return create(create(ll, lv, lr._0), lr._1, create(lr._2, v, r)); - } - } - if (hr <= (hl + 2 | 0)) { - return { - TAG: "Node", - _0: l, - _1: v, - _2: r, - _3: hl >= hr ? hl + 1 | 0 : hr + 1 | 0 - }; - } - if (typeof r !== "object") { - return "Empty"; - } - let rr = r._2; - let rv = r._1; - let rl = r._0; - if (height(rr) >= height(rl)) { - return create(create(l, v, rl), rv, rr); - } else if (typeof rl !== "object") { - return "Empty"; - } else { - return create(create(l, v, rl._0), rl._1, create(rl._2, rv, rr)); - } -} - -function compare_int(x, y) { - if (x > y) { - return 1; - } else if (x === y) { - return 0; - } else { - return -1; - } -} - -function add(x, x_) { - if (typeof x_ !== "object") { - return { - TAG: "Node", - _0: "Empty", - _1: x, - _2: "Empty", - _3: 1 - }; - } - let r = x_._2; - let v = x_._1; - let l = x_._0; - let c = compare_int(x, v); - if (c === 0) { - return x_; - } else if (c < 0) { - return bal(add(x, l), v, r); - } else { - return bal(l, v, add(x, r)); - } -} - -function min_elt(_def, _x) { - while (true) { - let x = _x; - let def = _def; - if (typeof x !== "object") { - return def; - } - let l = x._0; - if (typeof l !== "object") { - return x._1; - } - _x = l; - _def = x._1; - continue; - }; -} - -function remove_min_elt(l, v, r) { - if (typeof l !== "object") { - return r; - } else { - return bal(remove_min_elt(l._0, l._1, l._2), v, r); - } -} - -function internal_merge(l, r) { - if (typeof l !== "object") { - return r; - } - if (typeof r !== "object") { - return l; - } - let rv = r._1; - return bal(l, min_elt(rv, r), remove_min_elt(r._0, rv, r._2)); -} - -function remove(x, tree) { - if (typeof tree !== "object") { - return "Empty"; - } - let r = tree._2; - let v = tree._1; - let l = tree._0; - let c = compare_int(x, v); - if (c === 0) { - return internal_merge(l, r); - } else if (c < 0) { - return bal(remove(x, l), v, r); - } else { - return bal(l, v, remove(x, r)); - } -} - -function mem(x, _x_) { - while (true) { - let x_ = _x_; - if (typeof x_ !== "object") { - return false; - } - let c = compare_int(x, x_._1); - if (c === 0) { - return true; - } - _x_ = c < 0 ? x_._0 : x_._2; - continue; - }; -} - -let v = "Empty"; - -for (let i = 0; i <= 100000; ++i) { - v = add(i, v); -} - -for (let i$1 = 0; i$1 <= 100000; ++i$1) { - if (!mem(i$1, v)) { - console.log("impossible"); - } - -} - -for (let i$2 = 0; i$2 <= 100000; ++i$2) { - v = remove(i$2, v); -} - -let match = v; - -if (typeof match === "object") { - console.log("impossible"); -} - -exports.height = height; -exports.create = create; -exports.bal = bal; -exports.compare_int = compare_int; -exports.add = add; -exports.min_elt = min_elt; -exports.remove_min_elt = remove_min_elt; -exports.internal_merge = internal_merge; -exports.remove = remove; -exports.mem = mem; -/* Not a pure module */ diff --git a/tests/tests/src/bal_set_mini.mjs b/tests/tests/src/bal_set_mini.mjs new file mode 100644 index 0000000000..11e12c7ba3 --- /dev/null +++ b/tests/tests/src/bal_set_mini.mjs @@ -0,0 +1,202 @@ +// Generated by ReScript, PLEASE EDIT WITH CARE + + +function height(x) { + if (typeof x !== "object") { + return 0; + } else { + return x._3; + } +} + +function create(l, v, r) { + let hl = height(l); + let hr = height(r); + return { + TAG: "Node", + _0: l, + _1: v, + _2: r, + _3: hl >= hr ? hl + 1 | 0 : hr + 1 | 0 + }; +} + +function bal(l, v, r) { + let hl = height(l); + let hr = height(r); + if (hl > (hr + 2 | 0)) { + if (typeof l !== "object") { + return "Empty"; + } + let lr = l._2; + let lv = l._1; + let ll = l._0; + if (height(ll) >= height(lr)) { + return create(ll, lv, create(lr, v, r)); + } else if (typeof lr !== "object") { + return "Empty"; + } else { + return create(create(ll, lv, lr._0), lr._1, create(lr._2, v, r)); + } + } + if (hr <= (hl + 2 | 0)) { + return { + TAG: "Node", + _0: l, + _1: v, + _2: r, + _3: hl >= hr ? hl + 1 | 0 : hr + 1 | 0 + }; + } + if (typeof r !== "object") { + return "Empty"; + } + let rr = r._2; + let rv = r._1; + let rl = r._0; + if (height(rr) >= height(rl)) { + return create(create(l, v, rl), rv, rr); + } else if (typeof rl !== "object") { + return "Empty"; + } else { + return create(create(l, v, rl._0), rl._1, create(rl._2, rv, rr)); + } +} + +function compare_int(x, y) { + if (x > y) { + return 1; + } else if (x === y) { + return 0; + } else { + return -1; + } +} + +function add(x, x_) { + if (typeof x_ !== "object") { + return { + TAG: "Node", + _0: "Empty", + _1: x, + _2: "Empty", + _3: 1 + }; + } + let r = x_._2; + let v = x_._1; + let l = x_._0; + let c = compare_int(x, v); + if (c === 0) { + return x_; + } else if (c < 0) { + return bal(add(x, l), v, r); + } else { + return bal(l, v, add(x, r)); + } +} + +function min_elt(_def, _x) { + while (true) { + let x = _x; + let def = _def; + if (typeof x !== "object") { + return def; + } + let l = x._0; + if (typeof l !== "object") { + return x._1; + } + _x = l; + _def = x._1; + continue; + }; +} + +function remove_min_elt(l, v, r) { + if (typeof l !== "object") { + return r; + } else { + return bal(remove_min_elt(l._0, l._1, l._2), v, r); + } +} + +function internal_merge(l, r) { + if (typeof l !== "object") { + return r; + } + if (typeof r !== "object") { + return l; + } + let rv = r._1; + return bal(l, min_elt(rv, r), remove_min_elt(r._0, rv, r._2)); +} + +function remove(x, tree) { + if (typeof tree !== "object") { + return "Empty"; + } + let r = tree._2; + let v = tree._1; + let l = tree._0; + let c = compare_int(x, v); + if (c === 0) { + return internal_merge(l, r); + } else if (c < 0) { + return bal(remove(x, l), v, r); + } else { + return bal(l, v, remove(x, r)); + } +} + +function mem(x, _x_) { + while (true) { + let x_ = _x_; + if (typeof x_ !== "object") { + return false; + } + let c = compare_int(x, x_._1); + if (c === 0) { + return true; + } + _x_ = c < 0 ? x_._0 : x_._2; + continue; + }; +} + +let v = "Empty"; + +for (let i = 0; i <= 100000; ++i) { + v = add(i, v); +} + +for (let i$1 = 0; i$1 <= 100000; ++i$1) { + if (!mem(i$1, v)) { + console.log("impossible"); + } + +} + +for (let i$2 = 0; i$2 <= 100000; ++i$2) { + v = remove(i$2, v); +} + +let match = v; + +if (typeof match === "object") { + console.log("impossible"); +} + +export { + height, + create, + bal, + compare_int, + add, + min_elt, + remove_min_elt, + internal_merge, + remove, + mem, +} +/* Not a pure module */ diff --git a/tests/tests/src/bb.js b/tests/tests/src/bb.js deleted file mode 100644 index 18f51ea211..0000000000 --- a/tests/tests/src/bb.js +++ /dev/null @@ -1,83 +0,0 @@ -// Generated by ReScript, PLEASE EDIT WITH CARE -'use strict'; - - -function f(x) { - if (x === "b") { - return "b"; - } else if (x === "c") { - return "c"; - } else { - return "a"; - } -} - -function ff(x) { - switch (x) { - case "a" : - return "a"; - case "b" : - return "b"; - case "c" : - return "c"; - default: - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "bb.res", - 13, - 9 - ], - Error: new Error() - }; - } -} - -function test(x) { - let match; - switch (x) { - case "a" : - match = "a"; - break; - case "b" : - match = "b"; - break; - case "c" : - match = "c"; - break; - default: - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "bb.res", - 21, - 9 - ], - Error: new Error() - }; - } - if (match === "b") { - return "b"; - } else if (match === "c") { - return "c"; - } else { - return "a"; - } -} - -let test_poly = "a"; - -let c = f("a"); - -let d = f("b"); - -let e = f("c"); - -exports.f = f; -exports.ff = ff; -exports.test = test; -exports.test_poly = test_poly; -exports.c = c; -exports.d = d; -exports.e = e; -/* c Not a pure module */ diff --git a/tests/tests/src/bb.mjs b/tests/tests/src/bb.mjs new file mode 100644 index 0000000000..e2f8c65852 --- /dev/null +++ b/tests/tests/src/bb.mjs @@ -0,0 +1,84 @@ +// Generated by ReScript, PLEASE EDIT WITH CARE + + +function f(x) { + if (x === "b") { + return "b"; + } else if (x === "c") { + return "c"; + } else { + return "a"; + } +} + +function ff(x) { + switch (x) { + case "a" : + return "a"; + case "b" : + return "b"; + case "c" : + return "c"; + default: + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "bb.res", + 13, + 9 + ], + Error: new Error() + }; + } +} + +function test(x) { + let match; + switch (x) { + case "a" : + match = "a"; + break; + case "b" : + match = "b"; + break; + case "c" : + match = "c"; + break; + default: + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "bb.res", + 21, + 9 + ], + Error: new Error() + }; + } + if (match === "b") { + return "b"; + } else if (match === "c") { + return "c"; + } else { + return "a"; + } +} + +let test_poly = "a"; + +let c = f("a"); + +let d = f("b"); + +let e = f("c"); + +export { + f, + ff, + test, + test_poly, + c, + d, + e, +} +/* c Not a pure module */ diff --git a/tests/tests/src/bdd.js b/tests/tests/src/bdd.js deleted file mode 100644 index 60d94b46e7..0000000000 --- a/tests/tests/src/bdd.js +++ /dev/null @@ -1,462 +0,0 @@ -// Generated by ReScript, PLEASE EDIT WITH CARE -'use strict'; - -let Belt_Array = require("rescript/lib/js/Belt_Array.js"); -let Primitive_array = require("rescript/lib/js/Primitive_array.js"); - -function $$eval(_bdd, vars) { - while (true) { - let bdd = _bdd; - if (typeof bdd !== "object") { - if (bdd === "One") { - return true; - } else { - return false; - } - } - if (Primitive_array.get(vars, bdd._1)) { - _bdd = bdd._3; - continue; - } - _bdd = bdd._0; - continue; - }; -} - -function getId(bdd) { - if (typeof bdd !== "object") { - if (bdd === "One") { - return 1; - } else { - return 0; - } - } else { - return bdd._2; - } -} - -let nodeC = { - contents: 1 -}; - -let sz_1 = { - contents: 8191 -}; - -let htab = { - contents: Belt_Array.make(sz_1.contents + 1 | 0, /* [] */0) -}; - -let n_items = { - contents: 0 -}; - -function hashVal(x, y, v) { - return ((x << 1) + y | 0) + (v << 2) | 0; -} - -function resize(newSize) { - let arr = htab.contents; - let newSz_1 = newSize - 1 | 0; - let newArr = Belt_Array.make(newSize, /* [] */0); - let copyBucket = _bucket => { - while (true) { - let bucket = _bucket; - if (!bucket) { - return; - } - let n = bucket.hd; - if (typeof n !== "object") { - if (n === "One") { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "bdd.res", - 62, - 13 - ], - Error: new Error() - }; - } - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "bdd.res", - 62, - 13 - ], - Error: new Error() - }; - } else { - let ind = hashVal(getId(n._0), getId(n._3), n._1) & newSz_1; - Primitive_array.set(newArr, ind, { - hd: n, - tl: Primitive_array.get(newArr, ind) - }); - _bucket = bucket.tl; - continue; - } - }; - }; - for (let n = 0, n_finish = sz_1.contents; n <= n_finish; ++n) { - copyBucket(Primitive_array.get(arr, n)); - } - htab.contents = newArr; - sz_1.contents = newSz_1; -} - -function insert(idl, idh, v, ind, bucket, newNode) { - if (n_items.contents <= sz_1.contents) { - Primitive_array.set(htab.contents, ind, { - hd: newNode, - tl: bucket - }); - n_items.contents = n_items.contents + 1 | 0; - return; - } - resize((sz_1.contents + sz_1.contents | 0) + 2 | 0); - let ind$1 = hashVal(idl, idh, v) & sz_1.contents; - Primitive_array.set(htab.contents, ind$1, { - hd: newNode, - tl: Primitive_array.get(htab.contents, ind$1) - }); -} - -function resetUnique() { - sz_1.contents = 8191; - htab.contents = Belt_Array.make(sz_1.contents + 1 | 0, /* [] */0); - n_items.contents = 0; - nodeC.contents = 1; -} - -function mkNode(low, v, high) { - let idl = getId(low); - let idh = getId(high); - if (idl === idh) { - return low; - } - let ind = hashVal(idl, idh, v) & sz_1.contents; - let bucket = Primitive_array.get(htab.contents, ind); - let _b = bucket; - while (true) { - let b = _b; - if (b) { - let n = b.hd; - if (typeof n !== "object") { - if (n === "One") { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "bdd.res", - 123, - 15 - ], - Error: new Error() - }; - } - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "bdd.res", - 123, - 15 - ], - Error: new Error() - }; - } else { - if (v === n._1 && idl === getId(n._0) && idh === getId(n._3)) { - return n; - } - _b = b.tl; - continue; - } - } else { - let n_2 = (nodeC.contents = nodeC.contents + 1 | 0, nodeC.contents); - let n$1 = { - TAG: "Node", - _0: low, - _1: v, - _2: n_2, - _3: high - }; - insert(getId(low), getId(high), v, ind, bucket, n$1); - return n$1; - } - }; -} - -function cmpVar(x, y) { - if (x < y) { - return "LESS"; - } else if (x > y) { - return "GREATER"; - } else { - return "EQUAL"; - } -} - -function mkVar(x) { - return mkNode("Zero", x, "One"); -} - -let andslot1 = Belt_Array.make(1999, 0); - -let andslot2 = Belt_Array.make(1999, 0); - -let andslot3 = Belt_Array.make(1999, "Zero"); - -let xorslot1 = Belt_Array.make(1999, 0); - -let xorslot2 = Belt_Array.make(1999, 0); - -let xorslot3 = Belt_Array.make(1999, "Zero"); - -let notslot1 = Belt_Array.make(1999, 0); - -let notslot2 = Belt_Array.make(1999, "One"); - -function hash(x, y) { - return ((x << 1) + y | 0) % 1999; -} - -function not(n) { - if (typeof n !== "object") { - if (n === "One") { - return "Zero"; - } else { - return "One"; - } - } - let id = n._2; - let h = id % 1999; - if (id === Primitive_array.get(notslot1, h)) { - return Primitive_array.get(notslot2, h); - } - let f = mkNode(not(n._0), n._1, not(n._3)); - Primitive_array.set(notslot1, h, id); - Primitive_array.set(notslot2, h, f); - return f; -} - -function and2(n1, n2) { - if (typeof n1 !== "object") { - if (n1 === "One") { - return n2; - } else { - return "Zero"; - } - } - let r1 = n1._3; - let i1 = n1._2; - let v1 = n1._1; - let l1 = n1._0; - if (typeof n2 !== "object") { - if (n2 === "One") { - return n1; - } else { - return "Zero"; - } - } - let r2 = n2._3; - let i2 = n2._2; - let v2 = n2._1; - let l2 = n2._0; - let h = hash(i1, i2); - if (i1 === Primitive_array.get(andslot1, h) && i2 === Primitive_array.get(andslot2, h)) { - return Primitive_array.get(andslot3, h); - } - let match = cmpVar(v1, v2); - let f; - switch (match) { - case "LESS" : - f = mkNode(and2(l1, n2), v1, and2(r1, n2)); - break; - case "EQUAL" : - f = mkNode(and2(l1, l2), v1, and2(r1, r2)); - break; - case "GREATER" : - f = mkNode(and2(n1, l2), v2, and2(n1, r2)); - break; - } - Primitive_array.set(andslot1, h, i1); - Primitive_array.set(andslot2, h, i2); - Primitive_array.set(andslot3, h, f); - return f; -} - -function xor(n1, n2) { - if (typeof n1 !== "object") { - if (n1 === "One") { - return not(n2); - } else { - return n2; - } - } - let r1 = n1._3; - let i1 = n1._2; - let v1 = n1._1; - let l1 = n1._0; - if (typeof n2 !== "object") { - if (n2 === "One") { - return not(n1); - } else { - return n1; - } - } - let r2 = n2._3; - let i2 = n2._2; - let v2 = n2._1; - let l2 = n2._0; - let h = hash(i1, i2); - if (i1 === Primitive_array.get(andslot1, h) && i2 === Primitive_array.get(andslot2, h)) { - return Primitive_array.get(andslot3, h); - } - let match = cmpVar(v1, v2); - let f; - switch (match) { - case "LESS" : - f = mkNode(xor(l1, n2), v1, xor(r1, n2)); - break; - case "EQUAL" : - f = mkNode(xor(l1, l2), v1, xor(r1, r2)); - break; - case "GREATER" : - f = mkNode(xor(n1, l2), v2, xor(n1, r2)); - break; - } - Primitive_array.set(andslot1, h, i1); - Primitive_array.set(andslot2, h, i2); - Primitive_array.set(andslot3, h, f); - return f; -} - -function hwb(n) { - let h = (i, j) => { - if (i === j) { - return mkNode("Zero", i, "One"); - } else { - return xor(and2(not(mkNode("Zero", j, "One")), h(i, j - 1 | 0)), and2(mkNode("Zero", j, "One"), g(i, j - 1 | 0))); - } - }; - let g = (i, j) => { - if (i === j) { - return mkNode("Zero", i, "One"); - } else { - return xor(and2(not(mkNode("Zero", i, "One")), h(i + 1 | 0, j)), and2(mkNode("Zero", i, "One"), g(i + 1 | 0, j))); - } - }; - return h(0, n - 1 | 0); -} - -let seed = { - contents: 0 -}; - -function random() { - seed.contents = Math.imul(seed.contents, 25173) + 17431 | 0; - return (seed.contents & 1) > 0; -} - -function random_vars(n) { - let vars = Belt_Array.make(n, false); - for (let i = 0; i < n; ++i) { - Primitive_array.set(vars, i, random()); - } - return vars; -} - -function bool_equal(a, b) { - if (a) { - if (b) { - return true; - } else { - return false; - } - } else if (b) { - return false; - } else { - return true; - } -} - -function test_hwb(bdd, vars) { - let ntrue = 0; - for (let i = 0, i_finish = vars.length; i < i_finish; ++i) { - if (Primitive_array.get(vars, i)) { - ntrue = ntrue + 1 | 0; - } - - } - return bool_equal($$eval(bdd, vars), ntrue > 0 ? Primitive_array.get(vars, ntrue - 1 | 0) : false); -} - -function main() { - let bdd = hwb(22); - let succeeded = true; - for (let i = 1; i <= 100; ++i) { - succeeded = succeeded && test_hwb(bdd, random_vars(22)); - } - if (succeeded) { - return; - } - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "bdd.res", - 304, - 2 - ], - Error: new Error() - }; -} - -main(); - -let $$Array; - -let initSize_1 = 8191; - -let zero = "Zero"; - -let one = "One"; - -let cacheSize = 1999; - -exports.$$Array = $$Array; -exports.$$eval = $$eval; -exports.getId = getId; -exports.initSize_1 = initSize_1; -exports.nodeC = nodeC; -exports.sz_1 = sz_1; -exports.htab = htab; -exports.n_items = n_items; -exports.hashVal = hashVal; -exports.resize = resize; -exports.insert = insert; -exports.resetUnique = resetUnique; -exports.mkNode = mkNode; -exports.cmpVar = cmpVar; -exports.zero = zero; -exports.one = one; -exports.mkVar = mkVar; -exports.cacheSize = cacheSize; -exports.andslot1 = andslot1; -exports.andslot2 = andslot2; -exports.andslot3 = andslot3; -exports.xorslot1 = xorslot1; -exports.xorslot2 = xorslot2; -exports.xorslot3 = xorslot3; -exports.notslot1 = notslot1; -exports.notslot2 = notslot2; -exports.hash = hash; -exports.not = not; -exports.and2 = and2; -exports.xor = xor; -exports.hwb = hwb; -exports.seed = seed; -exports.random = random; -exports.random_vars = random_vars; -exports.bool_equal = bool_equal; -exports.test_hwb = test_hwb; -exports.main = main; -/* htab Not a pure module */ diff --git a/tests/tests/src/bdd.mjs b/tests/tests/src/bdd.mjs new file mode 100644 index 0000000000..7f9dfe1b01 --- /dev/null +++ b/tests/tests/src/bdd.mjs @@ -0,0 +1,463 @@ +// Generated by ReScript, PLEASE EDIT WITH CARE + +import * as Belt_Array from "rescript/lib/es6/Belt_Array.js"; +import * as Primitive_array from "rescript/lib/es6/Primitive_array.js"; + +function $$eval(_bdd, vars) { + while (true) { + let bdd = _bdd; + if (typeof bdd !== "object") { + if (bdd === "One") { + return true; + } else { + return false; + } + } + if (Primitive_array.get(vars, bdd._1)) { + _bdd = bdd._3; + continue; + } + _bdd = bdd._0; + continue; + }; +} + +function getId(bdd) { + if (typeof bdd !== "object") { + if (bdd === "One") { + return 1; + } else { + return 0; + } + } else { + return bdd._2; + } +} + +let nodeC = { + contents: 1 +}; + +let sz_1 = { + contents: 8191 +}; + +let htab = { + contents: Belt_Array.make(sz_1.contents + 1 | 0, /* [] */0) +}; + +let n_items = { + contents: 0 +}; + +function hashVal(x, y, v) { + return ((x << 1) + y | 0) + (v << 2) | 0; +} + +function resize(newSize) { + let arr = htab.contents; + let newSz_1 = newSize - 1 | 0; + let newArr = Belt_Array.make(newSize, /* [] */0); + let copyBucket = _bucket => { + while (true) { + let bucket = _bucket; + if (!bucket) { + return; + } + let n = bucket.hd; + if (typeof n !== "object") { + if (n === "One") { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "bdd.res", + 62, + 13 + ], + Error: new Error() + }; + } + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "bdd.res", + 62, + 13 + ], + Error: new Error() + }; + } else { + let ind = hashVal(getId(n._0), getId(n._3), n._1) & newSz_1; + Primitive_array.set(newArr, ind, { + hd: n, + tl: Primitive_array.get(newArr, ind) + }); + _bucket = bucket.tl; + continue; + } + }; + }; + for (let n = 0, n_finish = sz_1.contents; n <= n_finish; ++n) { + copyBucket(Primitive_array.get(arr, n)); + } + htab.contents = newArr; + sz_1.contents = newSz_1; +} + +function insert(idl, idh, v, ind, bucket, newNode) { + if (n_items.contents <= sz_1.contents) { + Primitive_array.set(htab.contents, ind, { + hd: newNode, + tl: bucket + }); + n_items.contents = n_items.contents + 1 | 0; + return; + } + resize((sz_1.contents + sz_1.contents | 0) + 2 | 0); + let ind$1 = hashVal(idl, idh, v) & sz_1.contents; + Primitive_array.set(htab.contents, ind$1, { + hd: newNode, + tl: Primitive_array.get(htab.contents, ind$1) + }); +} + +function resetUnique() { + sz_1.contents = 8191; + htab.contents = Belt_Array.make(sz_1.contents + 1 | 0, /* [] */0); + n_items.contents = 0; + nodeC.contents = 1; +} + +function mkNode(low, v, high) { + let idl = getId(low); + let idh = getId(high); + if (idl === idh) { + return low; + } + let ind = hashVal(idl, idh, v) & sz_1.contents; + let bucket = Primitive_array.get(htab.contents, ind); + let _b = bucket; + while (true) { + let b = _b; + if (b) { + let n = b.hd; + if (typeof n !== "object") { + if (n === "One") { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "bdd.res", + 123, + 15 + ], + Error: new Error() + }; + } + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "bdd.res", + 123, + 15 + ], + Error: new Error() + }; + } else { + if (v === n._1 && idl === getId(n._0) && idh === getId(n._3)) { + return n; + } + _b = b.tl; + continue; + } + } else { + let n_2 = (nodeC.contents = nodeC.contents + 1 | 0, nodeC.contents); + let n$1 = { + TAG: "Node", + _0: low, + _1: v, + _2: n_2, + _3: high + }; + insert(getId(low), getId(high), v, ind, bucket, n$1); + return n$1; + } + }; +} + +function cmpVar(x, y) { + if (x < y) { + return "LESS"; + } else if (x > y) { + return "GREATER"; + } else { + return "EQUAL"; + } +} + +function mkVar(x) { + return mkNode("Zero", x, "One"); +} + +let andslot1 = Belt_Array.make(1999, 0); + +let andslot2 = Belt_Array.make(1999, 0); + +let andslot3 = Belt_Array.make(1999, "Zero"); + +let xorslot1 = Belt_Array.make(1999, 0); + +let xorslot2 = Belt_Array.make(1999, 0); + +let xorslot3 = Belt_Array.make(1999, "Zero"); + +let notslot1 = Belt_Array.make(1999, 0); + +let notslot2 = Belt_Array.make(1999, "One"); + +function hash(x, y) { + return ((x << 1) + y | 0) % 1999; +} + +function not(n) { + if (typeof n !== "object") { + if (n === "One") { + return "Zero"; + } else { + return "One"; + } + } + let id = n._2; + let h = id % 1999; + if (id === Primitive_array.get(notslot1, h)) { + return Primitive_array.get(notslot2, h); + } + let f = mkNode(not(n._0), n._1, not(n._3)); + Primitive_array.set(notslot1, h, id); + Primitive_array.set(notslot2, h, f); + return f; +} + +function and2(n1, n2) { + if (typeof n1 !== "object") { + if (n1 === "One") { + return n2; + } else { + return "Zero"; + } + } + let r1 = n1._3; + let i1 = n1._2; + let v1 = n1._1; + let l1 = n1._0; + if (typeof n2 !== "object") { + if (n2 === "One") { + return n1; + } else { + return "Zero"; + } + } + let r2 = n2._3; + let i2 = n2._2; + let v2 = n2._1; + let l2 = n2._0; + let h = hash(i1, i2); + if (i1 === Primitive_array.get(andslot1, h) && i2 === Primitive_array.get(andslot2, h)) { + return Primitive_array.get(andslot3, h); + } + let match = cmpVar(v1, v2); + let f; + switch (match) { + case "LESS" : + f = mkNode(and2(l1, n2), v1, and2(r1, n2)); + break; + case "EQUAL" : + f = mkNode(and2(l1, l2), v1, and2(r1, r2)); + break; + case "GREATER" : + f = mkNode(and2(n1, l2), v2, and2(n1, r2)); + break; + } + Primitive_array.set(andslot1, h, i1); + Primitive_array.set(andslot2, h, i2); + Primitive_array.set(andslot3, h, f); + return f; +} + +function xor(n1, n2) { + if (typeof n1 !== "object") { + if (n1 === "One") { + return not(n2); + } else { + return n2; + } + } + let r1 = n1._3; + let i1 = n1._2; + let v1 = n1._1; + let l1 = n1._0; + if (typeof n2 !== "object") { + if (n2 === "One") { + return not(n1); + } else { + return n1; + } + } + let r2 = n2._3; + let i2 = n2._2; + let v2 = n2._1; + let l2 = n2._0; + let h = hash(i1, i2); + if (i1 === Primitive_array.get(andslot1, h) && i2 === Primitive_array.get(andslot2, h)) { + return Primitive_array.get(andslot3, h); + } + let match = cmpVar(v1, v2); + let f; + switch (match) { + case "LESS" : + f = mkNode(xor(l1, n2), v1, xor(r1, n2)); + break; + case "EQUAL" : + f = mkNode(xor(l1, l2), v1, xor(r1, r2)); + break; + case "GREATER" : + f = mkNode(xor(n1, l2), v2, xor(n1, r2)); + break; + } + Primitive_array.set(andslot1, h, i1); + Primitive_array.set(andslot2, h, i2); + Primitive_array.set(andslot3, h, f); + return f; +} + +function hwb(n) { + let h = (i, j) => { + if (i === j) { + return mkNode("Zero", i, "One"); + } else { + return xor(and2(not(mkNode("Zero", j, "One")), h(i, j - 1 | 0)), and2(mkNode("Zero", j, "One"), g(i, j - 1 | 0))); + } + }; + let g = (i, j) => { + if (i === j) { + return mkNode("Zero", i, "One"); + } else { + return xor(and2(not(mkNode("Zero", i, "One")), h(i + 1 | 0, j)), and2(mkNode("Zero", i, "One"), g(i + 1 | 0, j))); + } + }; + return h(0, n - 1 | 0); +} + +let seed = { + contents: 0 +}; + +function random() { + seed.contents = Math.imul(seed.contents, 25173) + 17431 | 0; + return (seed.contents & 1) > 0; +} + +function random_vars(n) { + let vars = Belt_Array.make(n, false); + for (let i = 0; i < n; ++i) { + Primitive_array.set(vars, i, random()); + } + return vars; +} + +function bool_equal(a, b) { + if (a) { + if (b) { + return true; + } else { + return false; + } + } else if (b) { + return false; + } else { + return true; + } +} + +function test_hwb(bdd, vars) { + let ntrue = 0; + for (let i = 0, i_finish = vars.length; i < i_finish; ++i) { + if (Primitive_array.get(vars, i)) { + ntrue = ntrue + 1 | 0; + } + + } + return bool_equal($$eval(bdd, vars), ntrue > 0 ? Primitive_array.get(vars, ntrue - 1 | 0) : false); +} + +function main() { + let bdd = hwb(22); + let succeeded = true; + for (let i = 1; i <= 100; ++i) { + succeeded = succeeded && test_hwb(bdd, random_vars(22)); + } + if (succeeded) { + return; + } + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "bdd.res", + 304, + 2 + ], + Error: new Error() + }; +} + +main(); + +let $$Array; + +let initSize_1 = 8191; + +let zero = "Zero"; + +let one = "One"; + +let cacheSize = 1999; + +export { + $$Array, + $$eval, + getId, + initSize_1, + nodeC, + sz_1, + htab, + n_items, + hashVal, + resize, + insert, + resetUnique, + mkNode, + cmpVar, + zero, + one, + mkVar, + cacheSize, + andslot1, + andslot2, + andslot3, + xorslot1, + xorslot2, + xorslot3, + notslot1, + notslot2, + hash, + not, + and2, + xor, + hwb, + seed, + random, + random_vars, + bool_equal, + test_hwb, + main, +} +/* htab Not a pure module */ diff --git a/tests/tests/src/belt_float_test.js b/tests/tests/src/belt_float_test.js deleted file mode 100644 index 867b8a2f45..0000000000 --- a/tests/tests/src/belt_float_test.js +++ /dev/null @@ -1,46 +0,0 @@ -// Generated by ReScript, PLEASE EDIT WITH CARE -'use strict'; - -let Mocha = require("mocha"); -let Belt_Float = require("rescript/lib/js/Belt_Float.js"); -let Test_utils = require("./test_utils.js"); - -Mocha.describe("Belt_float_test", () => { - Mocha.test("fromInt", () => { - Test_utils.eq("File \"belt_float_test.res\", line 8, characters 7-14", 1, 1.0); - Test_utils.eq("File \"belt_float_test.res\", line 9, characters 7-14", -1, -1.0); - }); - Mocha.test("toInt", () => { - Test_utils.eq("File \"belt_float_test.res\", line 13, characters 7-14", 1, 1); - Test_utils.eq("File \"belt_float_test.res\", line 14, characters 7-14", 1, 1); - Test_utils.eq("File \"belt_float_test.res\", line 15, characters 7-14", 1, 1); - Test_utils.eq("File \"belt_float_test.res\", line 16, characters 7-14", -1, -1); - Test_utils.eq("File \"belt_float_test.res\", line 17, characters 7-14", -1, -1); - Test_utils.eq("File \"belt_float_test.res\", line 18, characters 7-14", -1, -1); - }); - Mocha.test("fromString", () => { - Test_utils.eq("File \"belt_float_test.res\", line 22, characters 7-14", Belt_Float.fromString("1"), 1.0); - Test_utils.eq("File \"belt_float_test.res\", line 23, characters 7-14", Belt_Float.fromString("-1"), -1.0); - Test_utils.eq("File \"belt_float_test.res\", line 24, characters 7-14", Belt_Float.fromString("1.7"), 1.7); - Test_utils.eq("File \"belt_float_test.res\", line 25, characters 7-14", Belt_Float.fromString("-1.0"), -1.0); - Test_utils.eq("File \"belt_float_test.res\", line 26, characters 7-14", Belt_Float.fromString("-1.5"), -1.5); - Test_utils.eq("File \"belt_float_test.res\", line 27, characters 7-14", Belt_Float.fromString("-1.7"), -1.7); - Test_utils.eq("File \"belt_float_test.res\", line 28, characters 7-14", Belt_Float.fromString("not a float"), undefined); - }); - Mocha.test("toString", () => { - Test_utils.eq("File \"belt_float_test.res\", line 32, characters 7-14", String(1.0), "1"); - Test_utils.eq("File \"belt_float_test.res\", line 33, characters 7-14", String(-1.0), "-1"); - Test_utils.eq("File \"belt_float_test.res\", line 34, characters 7-14", String(-1.5), "-1.5"); - }); - Mocha.test("operators", () => { - Test_utils.eq("File \"belt_float_test.res\", line 39, characters 7-14", 2.0 + 3.0, 5.0); - Test_utils.eq("File \"belt_float_test.res\", line 40, characters 7-14", 2.0 - 3.0, -1.0); - Test_utils.eq("File \"belt_float_test.res\", line 41, characters 7-14", 2.0 * 3.0, 6.0); - Test_utils.eq("File \"belt_float_test.res\", line 42, characters 7-14", 3.0 / 2.0, 1.5); - }); -}); - -let F; - -exports.F = F; -/* Not a pure module */ diff --git a/tests/tests/src/belt_float_test.mjs b/tests/tests/src/belt_float_test.mjs new file mode 100644 index 0000000000..b778b92cd0 --- /dev/null +++ b/tests/tests/src/belt_float_test.mjs @@ -0,0 +1,47 @@ +// Generated by ReScript, PLEASE EDIT WITH CARE + +import * as Mocha from "mocha"; +import * as Belt_Float from "rescript/lib/es6/Belt_Float.js"; +import * as Test_utils from "./test_utils.mjs"; + +Mocha.describe("Belt_float_test", () => { + Mocha.test("fromInt", () => { + Test_utils.eq("File \"belt_float_test.res\", line 8, characters 7-14", 1, 1.0); + Test_utils.eq("File \"belt_float_test.res\", line 9, characters 7-14", -1, -1.0); + }); + Mocha.test("toInt", () => { + Test_utils.eq("File \"belt_float_test.res\", line 13, characters 7-14", 1, 1); + Test_utils.eq("File \"belt_float_test.res\", line 14, characters 7-14", 1, 1); + Test_utils.eq("File \"belt_float_test.res\", line 15, characters 7-14", 1, 1); + Test_utils.eq("File \"belt_float_test.res\", line 16, characters 7-14", -1, -1); + Test_utils.eq("File \"belt_float_test.res\", line 17, characters 7-14", -1, -1); + Test_utils.eq("File \"belt_float_test.res\", line 18, characters 7-14", -1, -1); + }); + Mocha.test("fromString", () => { + Test_utils.eq("File \"belt_float_test.res\", line 22, characters 7-14", Belt_Float.fromString("1"), 1.0); + Test_utils.eq("File \"belt_float_test.res\", line 23, characters 7-14", Belt_Float.fromString("-1"), -1.0); + Test_utils.eq("File \"belt_float_test.res\", line 24, characters 7-14", Belt_Float.fromString("1.7"), 1.7); + Test_utils.eq("File \"belt_float_test.res\", line 25, characters 7-14", Belt_Float.fromString("-1.0"), -1.0); + Test_utils.eq("File \"belt_float_test.res\", line 26, characters 7-14", Belt_Float.fromString("-1.5"), -1.5); + Test_utils.eq("File \"belt_float_test.res\", line 27, characters 7-14", Belt_Float.fromString("-1.7"), -1.7); + Test_utils.eq("File \"belt_float_test.res\", line 28, characters 7-14", Belt_Float.fromString("not a float"), undefined); + }); + Mocha.test("toString", () => { + Test_utils.eq("File \"belt_float_test.res\", line 32, characters 7-14", String(1.0), "1"); + Test_utils.eq("File \"belt_float_test.res\", line 33, characters 7-14", String(-1.0), "-1"); + Test_utils.eq("File \"belt_float_test.res\", line 34, characters 7-14", String(-1.5), "-1.5"); + }); + Mocha.test("operators", () => { + Test_utils.eq("File \"belt_float_test.res\", line 39, characters 7-14", 2.0 + 3.0, 5.0); + Test_utils.eq("File \"belt_float_test.res\", line 40, characters 7-14", 2.0 - 3.0, -1.0); + Test_utils.eq("File \"belt_float_test.res\", line 41, characters 7-14", 2.0 * 3.0, 6.0); + Test_utils.eq("File \"belt_float_test.res\", line 42, characters 7-14", 3.0 / 2.0, 1.5); + }); +}); + +let F; + +export { + F, +} +/* Not a pure module */ diff --git a/tests/tests/src/belt_hashmap_test.js b/tests/tests/src/belt_hashmap_test.js deleted file mode 100644 index 7feb63329e..0000000000 --- a/tests/tests/src/belt_hashmap_test.js +++ /dev/null @@ -1,96 +0,0 @@ -// Generated by ReScript, PLEASE EDIT WITH CARE -'use strict'; - -let Mocha = require("mocha"); -let Belt_Id = require("rescript/lib/js/Belt_Id.js"); -let Belt_Array = require("rescript/lib/js/Belt_Array.js"); -let Test_utils = require("./test_utils.js"); -let Belt_HashMap = require("rescript/lib/js/Belt_HashMap.js"); -let Ocaml_Hashtbl = require("./ocaml_compat/Ocaml_Hashtbl.js"); -let Primitive_int = require("rescript/lib/js/Primitive_int.js"); -let Belt_SortArray = require("rescript/lib/js/Belt_SortArray.js"); -let Array_data_util = require("./array_data_util.js"); - -function intEq(x, y) { - return x === y; -} - -let intHash = Ocaml_Hashtbl.hash; - -let cmp = Primitive_int.compare; - -let Y = Belt_Id.hashable(intHash, intEq); - -let empty = Belt_HashMap.make(30, Y); - -Mocha.describe("Belt_hashmap_test", () => { - Mocha.test("fromArray", () => { - let u = Belt_Array.concat(Array_data_util.randomRange(30, 100), Array_data_util.randomRange(40, 120)); - let v = Belt_Array.zip(u, u); - let xx = Belt_HashMap.fromArray(v, Y); - Test_utils.eq("File \"belt_hashmap_test.res\", line 22, characters 7-14", Belt_HashMap.size(xx), 91); - Test_utils.eq("File \"belt_hashmap_test.res\", line 23, characters 7-14", Belt_SortArray.stableSortBy(Belt_HashMap.keysToArray(xx), cmp), Array_data_util.range(30, 120)); - }); - Mocha.test("mergeMany", () => { - Belt_HashMap.mergeMany(empty, [ - [ - 1, - 1 - ], - [ - 2, - 3 - ], - [ - 3, - 3 - ], - [ - 2, - 2 - ] - ]); - Test_utils.eq("File \"belt_hashmap_test.res\", line 28, characters 7-14", Belt_HashMap.get(empty, 2), 2); - Test_utils.eq("File \"belt_hashmap_test.res\", line 29, characters 7-14", Belt_HashMap.size(empty), 3); - }); - Mocha.test("remove", () => { - let u = Belt_Array.concat(Array_data_util.randomRange(0, 100000), Array_data_util.randomRange(0, 100)); - let v = Belt_HashMap.make(40, Y); - Belt_HashMap.mergeMany(v, Belt_Array.zip(u, u)); - Test_utils.eq("File \"belt_hashmap_test.res\", line 36, characters 7-14", Belt_HashMap.size(v), 100001); - for (let i = 0; i <= 1000; ++i) { - Belt_HashMap.remove(v, i); - } - Test_utils.eq("File \"belt_hashmap_test.res\", line 40, characters 7-14", Belt_HashMap.size(v), 99000); - for (let i$1 = 0; i$1 <= 2000; ++i$1) { - Belt_HashMap.remove(v, i$1); - } - Test_utils.eq("File \"belt_hashmap_test.res\", line 44, characters 7-14", Belt_HashMap.size(v), 98000); - Test_utils.ok("File \"belt_hashmap_test.res\", line 45, characters 7-14", Belt_Array.every(Array_data_util.range(2001, 100000), x => Belt_HashMap.has(v, x))); - }); -}); - -let Hashtbl; - -let N; - -let S; - -let I; - -let A; - -let So; - -exports.Hashtbl = Hashtbl; -exports.N = N; -exports.S = S; -exports.I = I; -exports.A = A; -exports.So = So; -exports.intEq = intEq; -exports.intHash = intHash; -exports.cmp = cmp; -exports.Y = Y; -exports.empty = empty; -/* Y Not a pure module */ diff --git a/tests/tests/src/belt_hashmap_test.mjs b/tests/tests/src/belt_hashmap_test.mjs new file mode 100644 index 0000000000..b1bb5c829f --- /dev/null +++ b/tests/tests/src/belt_hashmap_test.mjs @@ -0,0 +1,97 @@ +// Generated by ReScript, PLEASE EDIT WITH CARE + +import * as Mocha from "mocha"; +import * as Belt_Id from "rescript/lib/es6/Belt_Id.js"; +import * as Belt_Array from "rescript/lib/es6/Belt_Array.js"; +import * as Test_utils from "./test_utils.mjs"; +import * as Belt_HashMap from "rescript/lib/es6/Belt_HashMap.js"; +import * as Ocaml_Hashtbl from "./ocaml_compat/Ocaml_Hashtbl.mjs"; +import * as Primitive_int from "rescript/lib/es6/Primitive_int.js"; +import * as Belt_SortArray from "rescript/lib/es6/Belt_SortArray.js"; +import * as Array_data_util from "./array_data_util.mjs"; + +function intEq(x, y) { + return x === y; +} + +let intHash = Ocaml_Hashtbl.hash; + +let cmp = Primitive_int.compare; + +let Y = Belt_Id.hashable(intHash, intEq); + +let empty = Belt_HashMap.make(30, Y); + +Mocha.describe("Belt_hashmap_test", () => { + Mocha.test("fromArray", () => { + let u = Belt_Array.concat(Array_data_util.randomRange(30, 100), Array_data_util.randomRange(40, 120)); + let v = Belt_Array.zip(u, u); + let xx = Belt_HashMap.fromArray(v, Y); + Test_utils.eq("File \"belt_hashmap_test.res\", line 22, characters 7-14", Belt_HashMap.size(xx), 91); + Test_utils.eq("File \"belt_hashmap_test.res\", line 23, characters 7-14", Belt_SortArray.stableSortBy(Belt_HashMap.keysToArray(xx), cmp), Array_data_util.range(30, 120)); + }); + Mocha.test("mergeMany", () => { + Belt_HashMap.mergeMany(empty, [ + [ + 1, + 1 + ], + [ + 2, + 3 + ], + [ + 3, + 3 + ], + [ + 2, + 2 + ] + ]); + Test_utils.eq("File \"belt_hashmap_test.res\", line 28, characters 7-14", Belt_HashMap.get(empty, 2), 2); + Test_utils.eq("File \"belt_hashmap_test.res\", line 29, characters 7-14", Belt_HashMap.size(empty), 3); + }); + Mocha.test("remove", () => { + let u = Belt_Array.concat(Array_data_util.randomRange(0, 100000), Array_data_util.randomRange(0, 100)); + let v = Belt_HashMap.make(40, Y); + Belt_HashMap.mergeMany(v, Belt_Array.zip(u, u)); + Test_utils.eq("File \"belt_hashmap_test.res\", line 36, characters 7-14", Belt_HashMap.size(v), 100001); + for (let i = 0; i <= 1000; ++i) { + Belt_HashMap.remove(v, i); + } + Test_utils.eq("File \"belt_hashmap_test.res\", line 40, characters 7-14", Belt_HashMap.size(v), 99000); + for (let i$1 = 0; i$1 <= 2000; ++i$1) { + Belt_HashMap.remove(v, i$1); + } + Test_utils.eq("File \"belt_hashmap_test.res\", line 44, characters 7-14", Belt_HashMap.size(v), 98000); + Test_utils.ok("File \"belt_hashmap_test.res\", line 45, characters 7-14", Belt_Array.every(Array_data_util.range(2001, 100000), x => Belt_HashMap.has(v, x))); + }); +}); + +let Hashtbl; + +let N; + +let S; + +let I; + +let A; + +let So; + +export { + Hashtbl, + N, + S, + I, + A, + So, + intEq, + intHash, + cmp, + Y, + empty, +} +/* Y Not a pure module */ diff --git a/tests/tests/src/belt_hashset_int_test.js b/tests/tests/src/belt_hashset_int_test.js deleted file mode 100644 index f5caf5ae9c..0000000000 --- a/tests/tests/src/belt_hashset_int_test.js +++ /dev/null @@ -1,90 +0,0 @@ -// Generated by ReScript, PLEASE EDIT WITH CARE -'use strict'; - -let Mocha = require("mocha"); -let Belt_Array = require("rescript/lib/js/Belt_Array.js"); -let Test_utils = require("./test_utils.js"); -let Belt_SetInt = require("rescript/lib/js/Belt_SetInt.js"); -let Array_data_util = require("./array_data_util.js"); -let Belt_HashSetInt = require("rescript/lib/js/Belt_HashSetInt.js"); -let Belt_SortArrayInt = require("rescript/lib/js/Belt_SortArrayInt.js"); - -function add(x, y) { - return x + y | 0; -} - -function sum2(h) { - let v = { - contents: 0 - }; - Belt_HashSetInt.forEach(h, x => { - v.contents = v.contents + x | 0; - }); - return v.contents; -} - -Mocha.describe("Belt_hashset_int_test", () => { - Mocha.test("fromArray", () => { - let u = Belt_Array.concat(Array_data_util.randomRange(30, 100), Array_data_util.randomRange(40, 120)); - let v = Belt_HashSetInt.fromArray(u); - Test_utils.eq("File \"belt_hashset_int_test.res\", line 22, characters 7-14", Belt_HashSetInt.size(v), 91); - let xs = Belt_SetInt.toArray(Belt_SetInt.fromArray(Belt_HashSetInt.toArray(v))); - Test_utils.eq("File \"belt_hashset_int_test.res\", line 24, characters 7-14", xs, Array_data_util.range(30, 120)); - Test_utils.eq("File \"belt_hashset_int_test.res\", line 26, characters 7-14", Belt_HashSetInt.reduce(v, 0, add), 6825); - Test_utils.eq("File \"belt_hashset_int_test.res\", line 27, characters 7-14", sum2(v), 6825); - }); - Mocha.test("mergeMany", () => { - let u = Belt_Array.concat(Array_data_util.randomRange(0, 100000), Array_data_util.randomRange(0, 100)); - let v = Belt_HashSetInt.make(40); - Belt_HashSetInt.mergeMany(v, u); - Test_utils.eq("File \"belt_hashset_int_test.res\", line 34, characters 7-14", Belt_HashSetInt.size(v), 100001); - for (let i = 0; i <= 1000; ++i) { - Belt_HashSetInt.remove(v, i); - } - Test_utils.eq("File \"belt_hashset_int_test.res\", line 38, characters 7-14", Belt_HashSetInt.size(v), 99000); - for (let i$1 = 0; i$1 <= 2000; ++i$1) { - Belt_HashSetInt.remove(v, i$1); - } - Test_utils.eq("File \"belt_hashset_int_test.res\", line 42, characters 7-14", Belt_HashSetInt.size(v), 98000); - }); - Mocha.test("stableSortInPlace", () => { - let u0 = Belt_HashSetInt.fromArray(Array_data_util.randomRange(0, 100000)); - let u1 = Belt_HashSetInt.copy(u0); - Test_utils.eq("File \"belt_hashset_int_test.res\", line 48, characters 7-14", Belt_HashSetInt.toArray(u0), Belt_HashSetInt.toArray(u1)); - for (let i = 0; i <= 2000; ++i) { - Belt_HashSetInt.remove(u1, i); - } - for (let i$1 = 0; i$1 <= 1000; ++i$1) { - Belt_HashSetInt.remove(u0, i$1); - } - let v0 = Belt_Array.concat(Array_data_util.range(0, 1000), Belt_HashSetInt.toArray(u0)); - let v1 = Belt_Array.concat(Array_data_util.range(0, 2000), Belt_HashSetInt.toArray(u1)); - Belt_SortArrayInt.stableSortInPlace(v0); - Belt_SortArrayInt.stableSortInPlace(v1); - Test_utils.eq("File \"belt_hashset_int_test.res\", line 59, characters 7-14", v0, v1); - }); - Mocha.test("getBucketHistogram", () => { - let h = Belt_HashSetInt.fromArray(Array_data_util.randomRange(0, 1000000)); - let histo = Belt_HashSetInt.getBucketHistogram(h); - Test_utils.ok("File \"belt_hashset_int_test.res\", line 65, characters 7-14", histo.length <= 10); - }); -}); - -let N; - -let S; - -let I; - -let A; - -let SI; - -exports.N = N; -exports.S = S; -exports.I = I; -exports.A = A; -exports.SI = SI; -exports.add = add; -exports.sum2 = sum2; -/* Not a pure module */ diff --git a/tests/tests/src/belt_hashset_int_test.mjs b/tests/tests/src/belt_hashset_int_test.mjs new file mode 100644 index 0000000000..123c6be403 --- /dev/null +++ b/tests/tests/src/belt_hashset_int_test.mjs @@ -0,0 +1,91 @@ +// Generated by ReScript, PLEASE EDIT WITH CARE + +import * as Mocha from "mocha"; +import * as Belt_Array from "rescript/lib/es6/Belt_Array.js"; +import * as Test_utils from "./test_utils.mjs"; +import * as Belt_SetInt from "rescript/lib/es6/Belt_SetInt.js"; +import * as Array_data_util from "./array_data_util.mjs"; +import * as Belt_HashSetInt from "rescript/lib/es6/Belt_HashSetInt.js"; +import * as Belt_SortArrayInt from "rescript/lib/es6/Belt_SortArrayInt.js"; + +function add(x, y) { + return x + y | 0; +} + +function sum2(h) { + let v = { + contents: 0 + }; + Belt_HashSetInt.forEach(h, x => { + v.contents = v.contents + x | 0; + }); + return v.contents; +} + +Mocha.describe("Belt_hashset_int_test", () => { + Mocha.test("fromArray", () => { + let u = Belt_Array.concat(Array_data_util.randomRange(30, 100), Array_data_util.randomRange(40, 120)); + let v = Belt_HashSetInt.fromArray(u); + Test_utils.eq("File \"belt_hashset_int_test.res\", line 22, characters 7-14", Belt_HashSetInt.size(v), 91); + let xs = Belt_SetInt.toArray(Belt_SetInt.fromArray(Belt_HashSetInt.toArray(v))); + Test_utils.eq("File \"belt_hashset_int_test.res\", line 24, characters 7-14", xs, Array_data_util.range(30, 120)); + Test_utils.eq("File \"belt_hashset_int_test.res\", line 26, characters 7-14", Belt_HashSetInt.reduce(v, 0, add), 6825); + Test_utils.eq("File \"belt_hashset_int_test.res\", line 27, characters 7-14", sum2(v), 6825); + }); + Mocha.test("mergeMany", () => { + let u = Belt_Array.concat(Array_data_util.randomRange(0, 100000), Array_data_util.randomRange(0, 100)); + let v = Belt_HashSetInt.make(40); + Belt_HashSetInt.mergeMany(v, u); + Test_utils.eq("File \"belt_hashset_int_test.res\", line 34, characters 7-14", Belt_HashSetInt.size(v), 100001); + for (let i = 0; i <= 1000; ++i) { + Belt_HashSetInt.remove(v, i); + } + Test_utils.eq("File \"belt_hashset_int_test.res\", line 38, characters 7-14", Belt_HashSetInt.size(v), 99000); + for (let i$1 = 0; i$1 <= 2000; ++i$1) { + Belt_HashSetInt.remove(v, i$1); + } + Test_utils.eq("File \"belt_hashset_int_test.res\", line 42, characters 7-14", Belt_HashSetInt.size(v), 98000); + }); + Mocha.test("stableSortInPlace", () => { + let u0 = Belt_HashSetInt.fromArray(Array_data_util.randomRange(0, 100000)); + let u1 = Belt_HashSetInt.copy(u0); + Test_utils.eq("File \"belt_hashset_int_test.res\", line 48, characters 7-14", Belt_HashSetInt.toArray(u0), Belt_HashSetInt.toArray(u1)); + for (let i = 0; i <= 2000; ++i) { + Belt_HashSetInt.remove(u1, i); + } + for (let i$1 = 0; i$1 <= 1000; ++i$1) { + Belt_HashSetInt.remove(u0, i$1); + } + let v0 = Belt_Array.concat(Array_data_util.range(0, 1000), Belt_HashSetInt.toArray(u0)); + let v1 = Belt_Array.concat(Array_data_util.range(0, 2000), Belt_HashSetInt.toArray(u1)); + Belt_SortArrayInt.stableSortInPlace(v0); + Belt_SortArrayInt.stableSortInPlace(v1); + Test_utils.eq("File \"belt_hashset_int_test.res\", line 59, characters 7-14", v0, v1); + }); + Mocha.test("getBucketHistogram", () => { + let h = Belt_HashSetInt.fromArray(Array_data_util.randomRange(0, 1000000)); + let histo = Belt_HashSetInt.getBucketHistogram(h); + Test_utils.ok("File \"belt_hashset_int_test.res\", line 65, characters 7-14", histo.length <= 10); + }); +}); + +let N; + +let S; + +let I; + +let A; + +let SI; + +export { + N, + S, + I, + A, + SI, + add, + sum2, +} +/* Not a pure module */ diff --git a/tests/tests/src/belt_int_test.js b/tests/tests/src/belt_int_test.js deleted file mode 100644 index 590207344d..0000000000 --- a/tests/tests/src/belt_int_test.js +++ /dev/null @@ -1,45 +0,0 @@ -// Generated by ReScript, PLEASE EDIT WITH CARE -'use strict'; - -let Mocha = require("mocha"); -let Belt_Int = require("rescript/lib/js/Belt_Int.js"); -let Test_utils = require("./test_utils.js"); - -Mocha.describe("Belt_int_test", () => { - Mocha.test("toFloat", () => { - Test_utils.eq("File \"belt_int_test.res\", line 8, characters 7-14", 1, 1.0); - Test_utils.eq("File \"belt_int_test.res\", line 9, characters 7-14", -1, -1.0); - }); - Mocha.test("fromFloat", () => { - Test_utils.eq("File \"belt_int_test.res\", line 13, characters 7-14", 1, 1); - Test_utils.eq("File \"belt_int_test.res\", line 14, characters 7-14", 1, 1); - Test_utils.eq("File \"belt_int_test.res\", line 15, characters 7-14", 1, 1); - Test_utils.eq("File \"belt_int_test.res\", line 16, characters 7-14", -1, -1); - Test_utils.eq("File \"belt_int_test.res\", line 17, characters 7-14", -1, -1); - Test_utils.eq("File \"belt_int_test.res\", line 18, characters 7-14", -1, -1); - }); - Mocha.test("fromString", () => { - Test_utils.eq("File \"belt_int_test.res\", line 22, characters 7-14", Belt_Int.fromString("1"), 1); - Test_utils.eq("File \"belt_int_test.res\", line 23, characters 7-14", Belt_Int.fromString("-1"), -1); - Test_utils.eq("File \"belt_int_test.res\", line 24, characters 7-14", Belt_Int.fromString("1.7"), 1); - Test_utils.eq("File \"belt_int_test.res\", line 25, characters 7-14", Belt_Int.fromString("-1.0"), -1); - Test_utils.eq("File \"belt_int_test.res\", line 26, characters 7-14", Belt_Int.fromString("-1.5"), -1); - Test_utils.eq("File \"belt_int_test.res\", line 27, characters 7-14", Belt_Int.fromString("-1.7"), -1); - Test_utils.eq("File \"belt_int_test.res\", line 28, characters 7-14", Belt_Int.fromString("not an int"), undefined); - }); - Mocha.test("toString", () => { - Test_utils.eq("File \"belt_int_test.res\", line 32, characters 7-14", String(1), "1"); - Test_utils.eq("File \"belt_int_test.res\", line 33, characters 7-14", String(-1), "-1"); - }); - Mocha.test("operators", () => { - Test_utils.eq("File \"belt_int_test.res\", line 39, characters 7-14", 5, 5); - Test_utils.eq("File \"belt_int_test.res\", line 40, characters 7-14", -1, -1); - Test_utils.eq("File \"belt_int_test.res\", line 41, characters 7-14", 6, 6); - Test_utils.eq("File \"belt_int_test.res\", line 42, characters 7-14", 0, 0); - }); -}); - -let I; - -exports.I = I; -/* Not a pure module */ diff --git a/tests/tests/src/belt_int_test.mjs b/tests/tests/src/belt_int_test.mjs new file mode 100644 index 0000000000..1d4d38075f --- /dev/null +++ b/tests/tests/src/belt_int_test.mjs @@ -0,0 +1,46 @@ +// Generated by ReScript, PLEASE EDIT WITH CARE + +import * as Mocha from "mocha"; +import * as Belt_Int from "rescript/lib/es6/Belt_Int.js"; +import * as Test_utils from "./test_utils.mjs"; + +Mocha.describe("Belt_int_test", () => { + Mocha.test("toFloat", () => { + Test_utils.eq("File \"belt_int_test.res\", line 8, characters 7-14", 1, 1.0); + Test_utils.eq("File \"belt_int_test.res\", line 9, characters 7-14", -1, -1.0); + }); + Mocha.test("fromFloat", () => { + Test_utils.eq("File \"belt_int_test.res\", line 13, characters 7-14", 1, 1); + Test_utils.eq("File \"belt_int_test.res\", line 14, characters 7-14", 1, 1); + Test_utils.eq("File \"belt_int_test.res\", line 15, characters 7-14", 1, 1); + Test_utils.eq("File \"belt_int_test.res\", line 16, characters 7-14", -1, -1); + Test_utils.eq("File \"belt_int_test.res\", line 17, characters 7-14", -1, -1); + Test_utils.eq("File \"belt_int_test.res\", line 18, characters 7-14", -1, -1); + }); + Mocha.test("fromString", () => { + Test_utils.eq("File \"belt_int_test.res\", line 22, characters 7-14", Belt_Int.fromString("1"), 1); + Test_utils.eq("File \"belt_int_test.res\", line 23, characters 7-14", Belt_Int.fromString("-1"), -1); + Test_utils.eq("File \"belt_int_test.res\", line 24, characters 7-14", Belt_Int.fromString("1.7"), 1); + Test_utils.eq("File \"belt_int_test.res\", line 25, characters 7-14", Belt_Int.fromString("-1.0"), -1); + Test_utils.eq("File \"belt_int_test.res\", line 26, characters 7-14", Belt_Int.fromString("-1.5"), -1); + Test_utils.eq("File \"belt_int_test.res\", line 27, characters 7-14", Belt_Int.fromString("-1.7"), -1); + Test_utils.eq("File \"belt_int_test.res\", line 28, characters 7-14", Belt_Int.fromString("not an int"), undefined); + }); + Mocha.test("toString", () => { + Test_utils.eq("File \"belt_int_test.res\", line 32, characters 7-14", String(1), "1"); + Test_utils.eq("File \"belt_int_test.res\", line 33, characters 7-14", String(-1), "-1"); + }); + Mocha.test("operators", () => { + Test_utils.eq("File \"belt_int_test.res\", line 39, characters 7-14", 5, 5); + Test_utils.eq("File \"belt_int_test.res\", line 40, characters 7-14", -1, -1); + Test_utils.eq("File \"belt_int_test.res\", line 41, characters 7-14", 6, 6); + Test_utils.eq("File \"belt_int_test.res\", line 42, characters 7-14", 0, 0); + }); +}); + +let I; + +export { + I, +} +/* Not a pure module */ diff --git a/tests/tests/src/belt_internal_test.js b/tests/tests/src/belt_internal_test.js deleted file mode 100644 index c72bcdf600..0000000000 --- a/tests/tests/src/belt_internal_test.js +++ /dev/null @@ -1,31 +0,0 @@ -// Generated by ReScript, PLEASE EDIT WITH CARE -'use strict'; - - -function treeHeight(n) { - if (n !== undefined) { - return n.height; - } else { - return 0; - } -} - -function copy(n) { - if (n === undefined) { - return n; - } - let v = n.value; - let h = n.height; - let l = n.left; - let r = n.right; - return { - value: v, - height: h, - left: copy(l), - right: copy(r) - }; -} - -exports.treeHeight = treeHeight; -exports.copy = copy; -/* No side effect */ diff --git a/tests/tests/src/belt_internal_test.mjs b/tests/tests/src/belt_internal_test.mjs new file mode 100644 index 0000000000..c41166be73 --- /dev/null +++ b/tests/tests/src/belt_internal_test.mjs @@ -0,0 +1,32 @@ +// Generated by ReScript, PLEASE EDIT WITH CARE + + +function treeHeight(n) { + if (n !== undefined) { + return n.height; + } else { + return 0; + } +} + +function copy(n) { + if (n === undefined) { + return n; + } + let v = n.value; + let h = n.height; + let l = n.left; + let r = n.right; + return { + value: v, + height: h, + left: copy(l), + right: copy(r) + }; +} + +export { + treeHeight, + copy, +} +/* No side effect */ diff --git a/tests/tests/src/belt_list_test.js b/tests/tests/src/belt_list_test.js deleted file mode 100644 index f4a0b423ca..0000000000 --- a/tests/tests/src/belt_list_test.js +++ /dev/null @@ -1,2185 +0,0 @@ -// Generated by ReScript, PLEASE EDIT WITH CARE -'use strict'; - -let Mocha = require("mocha"); -let Belt_List = require("rescript/lib/js/Belt_List.js"); -let Belt_Array = require("rescript/lib/js/Belt_Array.js"); -let Test_utils = require("./test_utils.js"); -let Primitive_int = require("rescript/lib/js/Primitive_int.js"); -let Primitive_object = require("rescript/lib/js/Primitive_object.js"); - -function sum(xs) { - let v = { - contents: 0 - }; - Belt_List.forEach(xs, x => { - v.contents = v.contents + x | 0; - }); - return v.contents; -} - -function sum2(xs, ys) { - let v = { - contents: 0 - }; - Belt_List.forEach2(xs, ys, (x, y) => { - v.contents = (v.contents + x | 0) + y | 0; - }); - return v.contents; -} - -Mocha.describe("Belt_list_test", () => { - Mocha.test("makeBy", () => { - let u = Belt_List.makeBy(5, i => Math.imul(i, i)); - let f = i => Test_utils.eq("File \"belt_list_test.res\", line 23, characters 20-27", Belt_List.getExn(u, i), Math.imul(i, i)); - for (let i = 0; i <= 4; ++i) { - f(i); - } - Test_utils.eq("File \"belt_list_test.res\", line 27, characters 7-14", Belt_List.map(u, i => i + 1 | 0), { - hd: 1, - tl: { - hd: 2, - tl: { - hd: 5, - tl: { - hd: 10, - tl: { - hd: 17, - tl: /* [] */0 - } - } - } - } - }); - Test_utils.eq("File \"belt_list_test.res\", line 28, characters 7-14", Belt_List.getBy({ - hd: 1, - tl: { - hd: 4, - tl: { - hd: 3, - tl: { - hd: 2, - tl: /* [] */0 - } - } - } - }, x => x % 2 === 0), 4); - Test_utils.eq("File \"belt_list_test.res\", line 29, characters 7-14", Belt_List.getBy({ - hd: 1, - tl: { - hd: 4, - tl: { - hd: 3, - tl: { - hd: 2, - tl: /* [] */0 - } - } - } - }, x => x % 5 === 0), undefined); - }); - Mocha.test("flatten", () => { - Test_utils.eq("File \"belt_list_test.res\", line 34, characters 6-13", Belt_List.flatten({ - hd: { - hd: 1, - tl: /* [] */0 - }, - tl: { - hd: { - hd: 2, - tl: /* [] */0 - }, - tl: { - hd: { - hd: 3, - tl: /* [] */0 - }, - tl: { - hd: /* [] */0, - tl: { - hd: Belt_List.makeBy(4, i => i), - tl: /* [] */0 - } - } - } - } - }), { - hd: 1, - tl: { - hd: 2, - tl: { - hd: 3, - tl: { - hd: 0, - tl: { - hd: 1, - tl: { - hd: 2, - tl: { - hd: 3, - tl: /* [] */0 - } - } - } - } - } - } - }); - Test_utils.eq("File \"belt_list_test.res\", line 38, characters 7-14", Belt_List.flatten(/* [] */0), /* [] */0); - Test_utils.eq("File \"belt_list_test.res\", line 39, characters 7-14", Belt_List.flatten({ - hd: /* [] */0, - tl: { - hd: /* [] */0, - tl: { - hd: { - hd: 2, - tl: /* [] */0 - }, - tl: { - hd: { - hd: 1, - tl: /* [] */0 - }, - tl: { - hd: { - hd: 2, - tl: /* [] */0 - }, - tl: { - hd: /* [] */0, - tl: /* [] */0 - } - } - } - } - } - }), { - hd: 2, - tl: { - hd: 1, - tl: { - hd: 2, - tl: /* [] */0 - } - } - }); - }); - Mocha.test("concatMany", () => { - Test_utils.eq("File \"belt_list_test.res\", line 44, characters 6-13", Belt_List.concatMany([ - { - hd: 1, - tl: /* [] */0 - }, - { - hd: 2, - tl: /* [] */0 - }, - { - hd: 3, - tl: /* [] */0 - }, - /* [] */0, - Belt_List.makeBy(4, i => i) - ]), { - hd: 1, - tl: { - hd: 2, - tl: { - hd: 3, - tl: { - hd: 0, - tl: { - hd: 1, - tl: { - hd: 2, - tl: { - hd: 3, - tl: /* [] */0 - } - } - } - } - } - } - }); - Test_utils.eq("File \"belt_list_test.res\", line 48, characters 7-14", Belt_List.concatMany([]), /* [] */0); - Test_utils.eq("File \"belt_list_test.res\", line 49, characters 7-14", Belt_List.concatMany([ - /* [] */0, - /* [] */0, - { - hd: 2, - tl: /* [] */0 - }, - { - hd: 1, - tl: /* [] */0 - }, - { - hd: 2, - tl: /* [] */0 - }, - /* [] */0 - ]), { - hd: 2, - tl: { - hd: 1, - tl: { - hd: 2, - tl: /* [] */0 - } - } - }); - Test_utils.eq("File \"belt_list_test.res\", line 51, characters 6-13", Belt_List.concatMany([ - /* [] */0, - /* [] */0, - { - hd: 2, - tl: { - hd: 3, - tl: /* [] */0 - } - }, - { - hd: 1, - tl: /* [] */0 - }, - { - hd: 2, - tl: /* [] */0 - }, - /* [] */0 - ]), { - hd: 2, - tl: { - hd: 3, - tl: { - hd: 1, - tl: { - hd: 2, - tl: /* [] */0 - } - } - } - }); - Test_utils.eq("File \"belt_list_test.res\", line 55, characters 7-14", Belt_List.concatMany([{ - hd: 1, - tl: { - hd: 2, - tl: { - hd: 3, - tl: /* [] */0 - } - } - }]), { - hd: 1, - tl: { - hd: 2, - tl: { - hd: 3, - tl: /* [] */0 - } - } - }); - }); - Mocha.test("concat", () => { - Test_utils.eq("File \"belt_list_test.res\", line 60, characters 6-13", Belt_List.toArray(Belt_List.concat(Belt_List.makeBy(100, i => i), Belt_List.makeBy(100, i => i))), Belt_Array.concat(Belt_Array.makeBy(100, i => i), Belt_Array.makeBy(100, i => i))); - Test_utils.eq("File \"belt_list_test.res\", line 65, characters 7-14", Belt_List.concat({ - hd: 1, - tl: /* [] */0 - }, /* [] */0), { - hd: 1, - tl: /* [] */0 - }); - Test_utils.eq("File \"belt_list_test.res\", line 66, characters 7-14", Belt_List.concat(/* [] */0, { - hd: 1, - tl: /* [] */0 - }), { - hd: 1, - tl: /* [] */0 - }); - }); - Mocha.test("zip", () => { - Test_utils.eq("File \"belt_list_test.res\", line 70, characters 7-14", Belt_List.zip({ - hd: 1, - tl: { - hd: 2, - tl: { - hd: 3, - tl: /* [] */0 - } - } - }, { - hd: 3, - tl: { - hd: 4, - tl: /* [] */0 - } - }), { - hd: [ - 1, - 3 - ], - tl: { - hd: [ - 2, - 4 - ], - tl: /* [] */0 - } - }); - Test_utils.eq("File \"belt_list_test.res\", line 71, characters 7-14", Belt_List.zip(/* [] */0, { - hd: 1, - tl: /* [] */0 - }), /* [] */0); - Test_utils.eq("File \"belt_list_test.res\", line 72, characters 7-14", Belt_List.zip(/* [] */0, /* [] */0), /* [] */0); - Test_utils.eq("File \"belt_list_test.res\", line 73, characters 7-14", Belt_List.zip({ - hd: 1, - tl: { - hd: 2, - tl: { - hd: 3, - tl: /* [] */0 - } - } - }, /* [] */0), /* [] */0); - Test_utils.eq("File \"belt_list_test.res\", line 74, characters 7-14", Belt_List.zip({ - hd: 1, - tl: { - hd: 2, - tl: { - hd: 3, - tl: /* [] */0 - } - } - }, { - hd: 2, - tl: { - hd: 3, - tl: { - hd: 4, - tl: /* [] */0 - } - } - }), { - hd: [ - 1, - 2 - ], - tl: { - hd: [ - 2, - 3 - ], - tl: { - hd: [ - 3, - 4 - ], - tl: /* [] */0 - } - } - }); - }); - let mod2 = x => x % 2 === 0; - let evenIndex = (_x, i) => i % 2 === 0; - Mocha.test("partition", () => { - Test_utils.eq("File \"belt_list_test.res\", line 81, characters 7-14", Belt_List.partition({ - hd: 1, - tl: { - hd: 2, - tl: { - hd: 3, - tl: { - hd: 2, - tl: { - hd: 3, - tl: { - hd: 4, - tl: /* [] */0 - } - } - } - } - } - }, mod2), [ - { - hd: 2, - tl: { - hd: 2, - tl: { - hd: 4, - tl: /* [] */0 - } - } - }, - { - hd: 1, - tl: { - hd: 3, - tl: { - hd: 3, - tl: /* [] */0 - } - } - } - ]); - Test_utils.eq("File \"belt_list_test.res\", line 82, characters 7-14", Belt_List.partition({ - hd: 2, - tl: { - hd: 2, - tl: { - hd: 2, - tl: { - hd: 4, - tl: /* [] */0 - } - } - } - }, mod2), [ - { - hd: 2, - tl: { - hd: 2, - tl: { - hd: 2, - tl: { - hd: 4, - tl: /* [] */0 - } - } - } - }, - /* [] */0 - ]); - Test_utils.eq("File \"belt_list_test.res\", line 83, characters 7-14", Belt_List.partition({ - hd: 2, - tl: { - hd: 2, - tl: { - hd: 2, - tl: { - hd: 4, - tl: /* [] */0 - } - } - } - }, x => !mod2(x)), [ - /* [] */0, - { - hd: 2, - tl: { - hd: 2, - tl: { - hd: 2, - tl: { - hd: 4, - tl: /* [] */0 - } - } - } - } - ]); - Test_utils.eq("File \"belt_list_test.res\", line 84, characters 7-14", Belt_List.partition(/* [] */0, mod2), [ - /* [] */0, - /* [] */0 - ]); - }); - Mocha.test("unzip", () => { - Test_utils.eq("File \"belt_list_test.res\", line 88, characters 7-14", Belt_List.unzip(/* [] */0), [ - /* [] */0, - /* [] */0 - ]); - Test_utils.eq("File \"belt_list_test.res\", line 89, characters 7-14", Belt_List.unzip({ - hd: [ - 1, - 2 - ], - tl: /* [] */0 - }), [ - { - hd: 1, - tl: /* [] */0 - }, - { - hd: 2, - tl: /* [] */0 - } - ]); - Test_utils.eq("File \"belt_list_test.res\", line 90, characters 7-14", Belt_List.unzip({ - hd: [ - 1, - 2 - ], - tl: { - hd: [ - 3, - 4 - ], - tl: /* [] */0 - } - }), [ - { - hd: 1, - tl: { - hd: 3, - tl: /* [] */0 - } - }, - { - hd: 2, - tl: { - hd: 4, - tl: /* [] */0 - } - } - ]); - }); - Mocha.test("filter", () => { - Test_utils.eq("File \"belt_list_test.res\", line 94, characters 7-14", Belt_List.keep({ - hd: 1, - tl: { - hd: 2, - tl: { - hd: 3, - tl: { - hd: 4, - tl: /* [] */0 - } - } - } - }, mod2), { - hd: 2, - tl: { - hd: 4, - tl: /* [] */0 - } - }); - Test_utils.eq("File \"belt_list_test.res\", line 95, characters 7-14", Belt_List.keep({ - hd: 1, - tl: { - hd: 3, - tl: { - hd: 41, - tl: /* [] */0 - } - } - }, mod2), /* [] */0); - Test_utils.eq("File \"belt_list_test.res\", line 96, characters 7-14", Belt_List.keep(/* [] */0, mod2), /* [] */0); - Test_utils.eq("File \"belt_list_test.res\", line 97, characters 7-14", Belt_List.keep({ - hd: 2, - tl: { - hd: 2, - tl: { - hd: 2, - tl: { - hd: 4, - tl: { - hd: 6, - tl: /* [] */0 - } - } - } - } - }, mod2), { - hd: 2, - tl: { - hd: 2, - tl: { - hd: 2, - tl: { - hd: 4, - tl: { - hd: 6, - tl: /* [] */0 - } - } - } - } - }); - }); - Mocha.test("keepWithIndex", () => { - Test_utils.eq("File \"belt_list_test.res\", line 101, characters 7-14", Belt_List.keepWithIndex(/* [] */0, evenIndex), /* [] */0); - Test_utils.eq("File \"belt_list_test.res\", line 102, characters 7-14", Belt_List.keepWithIndex({ - hd: 1, - tl: { - hd: 2, - tl: { - hd: 3, - tl: { - hd: 4, - tl: /* [] */0 - } - } - } - }, evenIndex), { - hd: 1, - tl: { - hd: 3, - tl: /* [] */0 - } - }); - Test_utils.eq("File \"belt_list_test.res\", line 103, characters 7-14", Belt_List.keepWithIndex({ - hd: 0, - tl: { - hd: 1, - tl: { - hd: 2, - tl: { - hd: 3, - tl: { - hd: 4, - tl: { - hd: 5, - tl: { - hd: 6, - tl: { - hd: 7, - tl: /* [] */0 - } - } - } - } - } - } - } - }, evenIndex), { - hd: 0, - tl: { - hd: 2, - tl: { - hd: 4, - tl: { - hd: 6, - tl: /* [] */0 - } - } - } - }); - }); - let id = x => x; - Mocha.test("map", () => { - Test_utils.eq("File \"belt_list_test.res\", line 109, characters 7-14", Belt_List.map(Belt_List.makeBy(5, id), x => (x << 1)), { - hd: 0, - tl: { - hd: 2, - tl: { - hd: 4, - tl: { - hd: 6, - tl: { - hd: 8, - tl: /* [] */0 - } - } - } - } - }); - Test_utils.eq("File \"belt_list_test.res\", line 110, characters 7-14", Belt_List.map(/* [] */0, id), /* [] */0); - Test_utils.eq("File \"belt_list_test.res\", line 111, characters 7-14", Belt_List.map({ - hd: 1, - tl: /* [] */0 - }, x => -x | 0), { - hd: -1, - tl: /* [] */0 - }); - }); - let add = (a, b) => a + b | 0; - let length_10_id = Belt_List.makeBy(10, id); - let length_8_id = Belt_List.makeBy(8, id); - Mocha.test("mapWithIndex etc.", () => { - let d = Belt_List.makeBy(10, x => (x << 1)); - Test_utils.eq("File \"belt_list_test.res\", line 124, characters 7-14", Belt_List.zipBy(length_10_id, length_10_id, add), d); - Test_utils.eq("File \"belt_list_test.res\", line 125, characters 7-14", Belt_List.zipBy(/* [] */0, { - hd: 1, - tl: /* [] */0 - }, add), /* [] */0); - Test_utils.eq("File \"belt_list_test.res\", line 126, characters 7-14", Belt_List.zipBy({ - hd: 1, - tl: /* [] */0 - }, /* [] */0, add), /* [] */0); - Test_utils.eq("File \"belt_list_test.res\", line 127, characters 7-14", Belt_List.zipBy(/* [] */0, /* [] */0, add), /* [] */0); - Test_utils.eq("File \"belt_list_test.res\", line 128, characters 7-14", Belt_List.zipBy(length_10_id, length_10_id, add), Belt_List.concat(Belt_List.map(length_8_id, x => (x << 1)), { - hd: 16, - tl: { - hd: 18, - tl: /* [] */0 - } - })); - Test_utils.eq("File \"belt_list_test.res\", line 129, characters 7-14", Belt_List.zipBy(length_10_id, length_8_id, add), Belt_List.mapWithIndex(length_8_id, (i, x) => i + x | 0)); - Test_utils.eq("File \"belt_list_test.res\", line 131, characters 6-13", Belt_List.reverse(Belt_List.mapReverse2(length_10_id, length_10_id, add)), Belt_List.map(length_10_id, x => (x << 1))); - let xs = Belt_List.reverse(Belt_List.mapReverse2(length_8_id, length_10_id, add)); - Test_utils.eq("File \"belt_list_test.res\", line 136, characters 7-14", Belt_List.length(xs), 8); - Test_utils.eq("File \"belt_list_test.res\", line 137, characters 7-14", xs, Belt_List.zipBy(length_10_id, length_8_id, add)); - Test_utils.eq("File \"belt_list_test.res\", line 138, characters 7-14", Belt_List.mapReverse2({ - hd: 1, - tl: { - hd: 2, - tl: { - hd: 3, - tl: /* [] */0 - } - } - }, { - hd: 1, - tl: { - hd: 2, - tl: /* [] */0 - } - }, (x, y) => x + y | 0), { - hd: 4, - tl: { - hd: 2, - tl: /* [] */0 - } - }); - }); - Mocha.test("take", () => { - Test_utils.eq("File \"belt_list_test.res\", line 142, characters 7-14", Belt_List.take({ - hd: 1, - tl: { - hd: 2, - tl: { - hd: 3, - tl: /* [] */0 - } - } - }, 2), { - hd: 1, - tl: { - hd: 2, - tl: /* [] */0 - } - }); - Test_utils.eq("File \"belt_list_test.res\", line 143, characters 7-14", Belt_List.take(/* [] */0, 1), undefined); - Test_utils.eq("File \"belt_list_test.res\", line 144, characters 7-14", Belt_List.take({ - hd: 1, - tl: { - hd: 2, - tl: /* [] */0 - } - }, 3), undefined); - Test_utils.eq("File \"belt_list_test.res\", line 145, characters 7-14", Belt_List.take({ - hd: 1, - tl: { - hd: 2, - tl: /* [] */0 - } - }, 2), { - hd: 1, - tl: { - hd: 2, - tl: /* [] */0 - } - }); - Test_utils.eq("File \"belt_list_test.res\", line 146, characters 7-14", Belt_List.take(length_10_id, 8), length_8_id); - Test_utils.eq("File \"belt_list_test.res\", line 147, characters 7-14", Belt_List.take(length_10_id, 0), /* [] */0); - Test_utils.eq("File \"belt_list_test.res\", line 148, characters 7-14", Belt_List.take(length_8_id, -2), undefined); - }); - Mocha.test("droo", () => { - Test_utils.eq("File \"belt_list_test.res\", line 152, characters 7-14", Belt_List.drop(length_10_id, 10), /* [] */0); - Test_utils.eq("File \"belt_list_test.res\", line 153, characters 7-14", Belt_List.drop(length_10_id, 8), { - hd: 8, - tl: { - hd: 9, - tl: /* [] */0 - } - }); - Test_utils.eq("File \"belt_list_test.res\", line 154, characters 7-14", Belt_List.drop(length_10_id, 0), length_10_id); - Test_utils.eq("File \"belt_list_test.res\", line 155, characters 7-14", Belt_List.drop(length_8_id, -1), undefined); - }); - Mocha.test("splitAt", () => { - let a = Belt_List.makeBy(5, id); - Test_utils.eq("File \"belt_list_test.res\", line 160, characters 7-14", Belt_List.splitAt(/* [] */0, 1), undefined); - Test_utils.eq("File \"belt_list_test.res\", line 161, characters 7-14", Belt_List.splitAt(a, 6), undefined); - Test_utils.eq("File \"belt_list_test.res\", line 162, characters 7-14", Belt_List.splitAt(a, 5), [ - a, - /* [] */0 - ]); - Test_utils.eq("File \"belt_list_test.res\", line 163, characters 7-14", Belt_List.splitAt(a, 4), [ - { - hd: 0, - tl: { - hd: 1, - tl: { - hd: 2, - tl: { - hd: 3, - tl: /* [] */0 - } - } - } - }, - { - hd: 4, - tl: /* [] */0 - } - ]); - Test_utils.eq("File \"belt_list_test.res\", line 164, characters 7-14", Belt_List.splitAt(a, 3), [ - { - hd: 0, - tl: { - hd: 1, - tl: { - hd: 2, - tl: /* [] */0 - } - } - }, - { - hd: 3, - tl: { - hd: 4, - tl: /* [] */0 - } - } - ]); - Test_utils.eq("File \"belt_list_test.res\", line 165, characters 7-14", Belt_List.splitAt(a, 2), [ - { - hd: 0, - tl: { - hd: 1, - tl: /* [] */0 - } - }, - { - hd: 2, - tl: { - hd: 3, - tl: { - hd: 4, - tl: /* [] */0 - } - } - } - ]); - Test_utils.eq("File \"belt_list_test.res\", line 166, characters 7-14", Belt_List.splitAt(a, 1), [ - { - hd: 0, - tl: /* [] */0 - }, - { - hd: 1, - tl: { - hd: 2, - tl: { - hd: 3, - tl: { - hd: 4, - tl: /* [] */0 - } - } - } - } - ]); - Test_utils.eq("File \"belt_list_test.res\", line 167, characters 7-14", Belt_List.splitAt(a, 0), [ - /* [] */0, - a - ]); - Test_utils.eq("File \"belt_list_test.res\", line 168, characters 7-14", Belt_List.splitAt(a, -1), undefined); - }); - Mocha.test("removeAssoc", () => { - let eqx = (x, y) => x === y; - Test_utils.ok("File \"belt_list_test.res\", line 174, characters 7-14", Belt_List.hasAssoc({ - hd: [ - 1, - "1" - ], - tl: { - hd: [ - 2, - "2" - ], - tl: { - hd: [ - 3, - "3" - ], - tl: /* [] */0 - } - } - }, 2, (prim0, prim1) => prim0 === prim1)); - Test_utils.ok("File \"belt_list_test.res\", line 175, characters 7-14", !Belt_List.hasAssoc({ - hd: [ - 1, - "1" - ], - tl: { - hd: [ - 2, - "2" - ], - tl: { - hd: [ - 3, - "3" - ], - tl: /* [] */0 - } - } - }, 4, (prim0, prim1) => prim0 === prim1)); - Test_utils.ok("File \"belt_list_test.res\", line 176, characters 7-14", Belt_List.hasAssoc({ - hd: [ - 1, - "1" - ], - tl: { - hd: [ - 2, - "2" - ], - tl: { - hd: [ - 3, - "3" - ], - tl: /* [] */0 - } - } - }, 4, (x, y) => (x + 1 | 0) === y)); - Test_utils.eq("File \"belt_list_test.res\", line 178, characters 6-13", Belt_List.removeAssoc({ - hd: [ - 1, - "1" - ], - tl: { - hd: [ - 2, - "2" - ], - tl: { - hd: [ - 3, - "3" - ], - tl: /* [] */0 - } - } - }, 3, (prim0, prim1) => prim0 === prim1), { - hd: [ - 1, - "1" - ], - tl: { - hd: [ - 2, - "2" - ], - tl: /* [] */0 - } - }); - Test_utils.eq("File \"belt_list_test.res\", line 183, characters 6-13", Belt_List.removeAssoc({ - hd: [ - 1, - "1" - ], - tl: { - hd: [ - 2, - "2" - ], - tl: { - hd: [ - 3, - "3" - ], - tl: /* [] */0 - } - } - }, 1, (prim0, prim1) => prim0 === prim1), { - hd: [ - 2, - "2" - ], - tl: { - hd: [ - 3, - "3" - ], - tl: /* [] */0 - } - }); - Test_utils.eq("File \"belt_list_test.res\", line 188, characters 6-13", Belt_List.removeAssoc({ - hd: [ - 1, - "1" - ], - tl: { - hd: [ - 2, - "2" - ], - tl: { - hd: [ - 3, - "3" - ], - tl: /* [] */0 - } - } - }, 2, (prim0, prim1) => prim0 === prim1), { - hd: [ - 1, - "1" - ], - tl: { - hd: [ - 3, - "3" - ], - tl: /* [] */0 - } - }); - Test_utils.eq("File \"belt_list_test.res\", line 193, characters 6-13", Belt_List.removeAssoc({ - hd: [ - 1, - "1" - ], - tl: { - hd: [ - 2, - "2" - ], - tl: { - hd: [ - 3, - "3" - ], - tl: /* [] */0 - } - } - }, 0, (prim0, prim1) => prim0 === prim1), { - hd: [ - 1, - "1" - ], - tl: { - hd: [ - 2, - "2" - ], - tl: { - hd: [ - 3, - "3" - ], - tl: /* [] */0 - } - } - }); - Test_utils.eq("File \"belt_list_test.res\", line 198, characters 7-14", Belt_List.removeAssoc({ - hd: [ - 1, - "1" - ], - tl: { - hd: [ - 2, - "2" - ], - tl: { - hd: [ - 3, - "3" - ], - tl: /* [] */0 - } - } - }, 3, eqx), { - hd: [ - 1, - "1" - ], - tl: { - hd: [ - 2, - "2" - ], - tl: /* [] */0 - } - }); - Test_utils.eq("File \"belt_list_test.res\", line 199, characters 7-14", Belt_List.removeAssoc({ - hd: [ - 1, - "1" - ], - tl: { - hd: [ - 2, - "2" - ], - tl: { - hd: [ - 3, - "3" - ], - tl: /* [] */0 - } - } - }, 1, eqx), { - hd: [ - 2, - "2" - ], - tl: { - hd: [ - 3, - "3" - ], - tl: /* [] */0 - } - }); - Test_utils.eq("File \"belt_list_test.res\", line 200, characters 7-14", Belt_List.removeAssoc({ - hd: [ - 1, - "1" - ], - tl: { - hd: [ - 2, - "2" - ], - tl: { - hd: [ - 3, - "3" - ], - tl: /* [] */0 - } - } - }, 2, eqx), { - hd: [ - 1, - "1" - ], - tl: { - hd: [ - 3, - "3" - ], - tl: /* [] */0 - } - }); - Test_utils.eq("File \"belt_list_test.res\", line 201, characters 7-14", Belt_List.removeAssoc(/* [] */0, 2, eqx), /* [] */0); - let ll = { - hd: [ - 1, - "1" - ], - tl: { - hd: [ - 2, - "2" - ], - tl: { - hd: [ - 3, - "3" - ], - tl: /* [] */0 - } - } - }; - let ll0 = Belt_List.removeAssoc(ll, 0, eqx); - Test_utils.ok("File \"belt_list_test.res\", line 204, characters 7-14", ll === ll0); - let ll1 = Belt_List.setAssoc(ll, 2, "22", (prim0, prim1) => prim0 === prim1); - Test_utils.eq("File \"belt_list_test.res\", line 206, characters 7-14", ll1, { - hd: [ - 1, - "1" - ], - tl: { - hd: [ - 2, - "22" - ], - tl: { - hd: [ - 3, - "3" - ], - tl: /* [] */0 - } - } - }); - let ll2 = Belt_List.setAssoc(ll1, 22, "2", (prim0, prim1) => prim0 === prim1); - Test_utils.ok("File \"belt_list_test.res\", line 208, characters 7-14", Primitive_object.equal(ll2, { - hd: [ - 22, - "2" - ], - tl: ll1 - })); - Test_utils.ok("File \"belt_list_test.res\", line 209, characters 7-14", Belt_List.tailExn(ll2) === ll1); - Test_utils.ok("File \"belt_list_test.res\", line 211, characters 6-13", Primitive_object.equal(Belt_List.setAssoc({ - hd: [ - 1, - "a" - ], - tl: { - hd: [ - 2, - "b" - ], - tl: { - hd: [ - 3, - "c" - ], - tl: /* [] */0 - } - } - }, 2, "x", (prim0, prim1) => prim0 === prim1), { - hd: [ - 1, - "a" - ], - tl: { - hd: [ - 2, - "x" - ], - tl: { - hd: [ - 3, - "c" - ], - tl: /* [] */0 - } - } - })); - Test_utils.ok("File \"belt_list_test.res\", line 216, characters 6-13", Primitive_object.equal(Belt_List.setAssoc({ - hd: [ - 1, - "a" - ], - tl: { - hd: [ - 3, - "c" - ], - tl: /* [] */0 - } - }, 2, "2", (prim0, prim1) => prim0 === prim1), { - hd: [ - 2, - "2" - ], - tl: { - hd: [ - 1, - "a" - ], - tl: { - hd: [ - 3, - "c" - ], - tl: /* [] */0 - } - } - })); - Test_utils.eq("File \"belt_list_test.res\", line 219, characters 7-14", Belt_List.setAssoc(/* [] */0, 1, "1", (prim0, prim1) => prim0 === prim1), { - hd: [ - 1, - "1" - ], - tl: /* [] */0 - }); - Test_utils.eq("File \"belt_list_test.res\", line 220, characters 7-14", Belt_List.setAssoc({ - hd: [ - 1, - "2" - ], - tl: /* [] */0 - }, 1, "1", (prim0, prim1) => prim0 === prim1), { - hd: [ - 1, - "1" - ], - tl: /* [] */0 - }); - Test_utils.eq("File \"belt_list_test.res\", line 222, characters 7-14", Belt_List.setAssoc({ - hd: [ - 0, - "0" - ], - tl: { - hd: [ - 1, - "2" - ], - tl: /* [] */0 - } - }, 1, "1", (prim0, prim1) => prim0 === prim1), { - hd: [ - 0, - "0" - ], - tl: { - hd: [ - 1, - "1" - ], - tl: /* [] */0 - } - }); - Test_utils.ok("File \"belt_list_test.res\", line 223, characters 7-14", Primitive_object.equal(Belt_List.getAssoc({ - hd: [ - 1, - "a" - ], - tl: { - hd: [ - 2, - "b" - ], - tl: { - hd: [ - 3, - "c" - ], - tl: /* [] */0 - } - } - }, 2, (prim0, prim1) => prim0 === prim1), "b")); - Test_utils.ok("File \"belt_list_test.res\", line 224, characters 7-14", Belt_List.getAssoc({ - hd: [ - 1, - "a" - ], - tl: { - hd: [ - 2, - "b" - ], - tl: { - hd: [ - 3, - "c" - ], - tl: /* [] */0 - } - } - }, 4, (prim0, prim1) => prim0 === prim1) === undefined); - }); - Mocha.test("head/tail etc.", () => { - let succx = x => x + 1 | 0; - Test_utils.eq("File \"belt_list_test.res\", line 230, characters 7-14", [ - Belt_List.head(length_10_id), - Belt_List.tail(length_10_id) - ], [ - 0, - Belt_List.drop(length_10_id, 1) - ]); - Test_utils.eq("File \"belt_list_test.res\", line 231, characters 7-14", Belt_List.head(/* [] */0), undefined); - Test_utils.$$throw("File \"belt_list_test.res\", line 232, characters 10-17", () => Belt_List.headExn(/* [] */0)); - Test_utils.$$throw("File \"belt_list_test.res\", line 233, characters 10-17", () => { - Belt_List.tailExn(/* [] */0); - }); - Test_utils.$$throw("File \"belt_list_test.res\", line 234, characters 10-17", () => { - Belt_List.getExn({ - hd: 0, - tl: { - hd: 1, - tl: /* [] */0 - } - }, -1); - }); - Test_utils.$$throw("File \"belt_list_test.res\", line 235, characters 10-17", () => { - Belt_List.getExn({ - hd: 0, - tl: { - hd: 1, - tl: /* [] */0 - } - }, 2); - }); - Test_utils.eq("File \"belt_list_test.res\", line 236, characters 7-14", Belt_List.map({ - hd: 0, - tl: { - hd: 1, - tl: /* [] */0 - } - }, i => Belt_List.getExn({ - hd: 0, - tl: { - hd: 1, - tl: /* [] */0 - } - }, i)), { - hd: 0, - tl: { - hd: 1, - tl: /* [] */0 - } - }); - Test_utils.eq("File \"belt_list_test.res\", line 237, characters 7-14", Belt_List.headExn({ - hd: 1, - tl: /* [] */0 - }), 1); - Test_utils.eq("File \"belt_list_test.res\", line 238, characters 7-14", Belt_List.tailExn({ - hd: 1, - tl: /* [] */0 - }), /* [] */0); - Belt_List.forEachWithIndex(length_10_id, (i, x) => Test_utils.eq("File \"belt_list_test.res\", line 239, characters 50-57", Belt_List.get(length_10_id, i), x)); - Test_utils.eq("File \"belt_list_test.res\", line 240, characters 7-14", Belt_List.tail(/* [] */0), undefined); - Test_utils.eq("File \"belt_list_test.res\", line 241, characters 7-14", Belt_List.drop(/* [] */0, 3), undefined); - Test_utils.eq("File \"belt_list_test.res\", line 242, characters 7-14", Belt_List.mapWithIndex(/* [] */0, (i, x) => i + x | 0), /* [] */0); - Test_utils.eq("File \"belt_list_test.res\", line 243, characters 7-14", Belt_List.get(length_10_id, -1), undefined); - Test_utils.eq("File \"belt_list_test.res\", line 244, characters 7-14", Belt_List.get(length_10_id, 12), undefined); - Test_utils.eq("File \"belt_list_test.res\", line 245, characters 7-14", sum(/* [] */0), 0); - Test_utils.eq("File \"belt_list_test.res\", line 246, characters 7-14", sum(length_10_id), 45); - Test_utils.eq("File \"belt_list_test.res\", line 247, characters 7-14", Belt_List.makeBy(0, id), /* [] */0); - Test_utils.eq("File \"belt_list_test.res\", line 248, characters 7-14", Belt_List.reverse(Belt_List.reverse(length_10_id)), length_10_id); - Test_utils.eq("File \"belt_list_test.res\", line 249, characters 7-14", Belt_List.reverse(Belt_List.reverse(length_8_id)), length_8_id); - Test_utils.eq("File \"belt_list_test.res\", line 250, characters 7-14", Belt_List.reverse(/* [] */0), /* [] */0); - Test_utils.eq("File \"belt_list_test.res\", line 251, characters 7-14", Belt_List.reverse(Belt_List.mapReverse(length_10_id, succx)), Belt_List.map(length_10_id, succx)); - Test_utils.eq("File \"belt_list_test.res\", line 252, characters 7-14", Belt_List.reduce(length_10_id, 0, add), 45); - Test_utils.eq("File \"belt_list_test.res\", line 253, characters 7-14", Belt_List.reduceReverse(length_10_id, 0, add), 45); - Test_utils.eq("File \"belt_list_test.res\", line 254, characters 7-14", Belt_List.reduceReverse(Belt_List.makeBy(10000, i => i), 0, (prim0, prim1) => prim0 + prim1 | 0), 49995000); - Test_utils.eq("File \"belt_list_test.res\", line 257, characters 7-14", sum2(length_10_id, length_10_id), 90); - Test_utils.eq("File \"belt_list_test.res\", line 258, characters 7-14", sum2(length_8_id, length_10_id), 56); - Test_utils.eq("File \"belt_list_test.res\", line 259, characters 7-14", sum2(length_10_id, length_8_id), 56); - Test_utils.eq("File \"belt_list_test.res\", line 260, characters 7-14", Belt_List.reduce2(length_10_id, length_8_id, 0, (acc, x, y) => (acc + x | 0) + y | 0), 56); - Test_utils.eq("File \"belt_list_test.res\", line 261, characters 7-14", Belt_List.reduce2({ - hd: 1, - tl: { - hd: 2, - tl: { - hd: 3, - tl: /* [] */0 - } - } - }, { - hd: 2, - tl: { - hd: 4, - tl: { - hd: 6, - tl: /* [] */0 - } - } - }, 0, (a, b, c) => (a + b | 0) + c | 0), 18); - Test_utils.eq("File \"belt_list_test.res\", line 262, characters 7-14", Belt_List.reduceReverse2(length_10_id, length_8_id, 0, (acc, x, y) => (acc + x | 0) + y | 0), 56); - Test_utils.eq("File \"belt_list_test.res\", line 263, characters 7-14", Belt_List.reduceReverse2(length_10_id, length_10_id, 0, (acc, x, y) => (acc + x | 0) + y | 0), 90); - Test_utils.eq("File \"belt_list_test.res\", line 264, characters 7-14", Belt_List.reduceReverse2({ - hd: 1, - tl: { - hd: 2, - tl: { - hd: 3, - tl: /* [] */0 - } - } - }, { - hd: 1, - tl: { - hd: 2, - tl: /* [] */0 - } - }, 0, (acc, x, y) => (acc + x | 0) + y | 0), 6); - Test_utils.eq("File \"belt_list_test.res\", line 265, characters 7-14", Belt_List.every({ - hd: 2, - tl: { - hd: 4, - tl: { - hd: 6, - tl: /* [] */0 - } - } - }, mod2), true); - Test_utils.eq("File \"belt_list_test.res\", line 266, characters 7-14", Belt_List.every({ - hd: 1, - tl: /* [] */0 - }, mod2), false); - Test_utils.eq("File \"belt_list_test.res\", line 267, characters 7-14", Belt_List.every(/* [] */0, mod2), true); - Test_utils.eq("File \"belt_list_test.res\", line 268, characters 7-14", Belt_List.some({ - hd: 1, - tl: { - hd: 2, - tl: { - hd: 5, - tl: /* [] */0 - } - } - }, mod2), true); - Test_utils.eq("File \"belt_list_test.res\", line 269, characters 7-14", Belt_List.some({ - hd: 1, - tl: { - hd: 3, - tl: { - hd: 5, - tl: /* [] */0 - } - } - }, mod2), false); - Test_utils.eq("File \"belt_list_test.res\", line 270, characters 7-14", Belt_List.some(/* [] */0, mod2), false); - Test_utils.eq("File \"belt_list_test.res\", line 271, characters 7-14", Belt_List.has({ - hd: 1, - tl: { - hd: 2, - tl: { - hd: 3, - tl: /* [] */0 - } - } - }, "2", (x, s) => x.toString() === s), true); - Test_utils.eq("File \"belt_list_test.res\", line 272, characters 7-14", Belt_List.has({ - hd: 1, - tl: { - hd: 2, - tl: { - hd: 3, - tl: /* [] */0 - } - } - }, "0", (x, s) => x.toString() === s), false); - Test_utils.ok("File \"belt_list_test.res\", line 274, characters 7-14", Belt_List.reduceReverse({ - hd: 1, - tl: { - hd: 2, - tl: { - hd: 3, - tl: { - hd: 4, - tl: /* [] */0 - } - } - } - }, 0, (prim0, prim1) => prim0 + prim1 | 0) === 10); - Test_utils.ok("File \"belt_list_test.res\", line 275, characters 7-14", Belt_List.reduceReverse({ - hd: 1, - tl: { - hd: 2, - tl: { - hd: 3, - tl: { - hd: 4, - tl: /* [] */0 - } - } - } - }, 10, (prim0, prim1) => prim0 - prim1 | 0) === 0); - Test_utils.ok("File \"belt_list_test.res\", line 276, characters 7-14", Primitive_object.equal(Belt_List.reduceReverse({ - hd: 1, - tl: { - hd: 2, - tl: { - hd: 3, - tl: { - hd: 4, - tl: /* [] */0 - } - } - } - }, /* [] */0, Belt_List.add), { - hd: 1, - tl: { - hd: 2, - tl: { - hd: 3, - tl: { - hd: 4, - tl: /* [] */0 - } - } - } - })); - Test_utils.ok("File \"belt_list_test.res\", line 277, characters 7-14", Belt_List.reduce({ - hd: 1, - tl: { - hd: 2, - tl: { - hd: 3, - tl: { - hd: 4, - tl: /* [] */0 - } - } - } - }, 0, (prim0, prim1) => prim0 + prim1 | 0) === 10); - Test_utils.ok("File \"belt_list_test.res\", line 278, characters 7-14", Belt_List.reduce({ - hd: 1, - tl: { - hd: 2, - tl: { - hd: 3, - tl: { - hd: 4, - tl: /* [] */0 - } - } - } - }, 10, (prim0, prim1) => prim0 - prim1 | 0) === 0); - Test_utils.ok("File \"belt_list_test.res\", line 279, characters 7-14", Primitive_object.equal(Belt_List.reduce({ - hd: 1, - tl: { - hd: 2, - tl: { - hd: 3, - tl: { - hd: 4, - tl: /* [] */0 - } - } - } - }, /* [] */0, Belt_List.add), { - hd: 4, - tl: { - hd: 3, - tl: { - hd: 2, - tl: { - hd: 1, - tl: /* [] */0 - } - } - } - })); - Test_utils.ok("File \"belt_list_test.res\", line 280, characters 7-14", Belt_List.reduceWithIndex({ - hd: 1, - tl: { - hd: 2, - tl: { - hd: 3, - tl: { - hd: 4, - tl: /* [] */0 - } - } - } - }, 0, (acc, x, i) => (acc + x | 0) + i | 0) === 16); - Test_utils.ok("File \"belt_list_test.res\", line 281, characters 7-14", Belt_List.reduceReverse2({ - hd: 1, - tl: { - hd: 2, - tl: { - hd: 3, - tl: /* [] */0 - } - } - }, { - hd: 1, - tl: { - hd: 2, - tl: /* [] */0 - } - }, 0, (acc, x, y) => (acc + x | 0) + y | 0) === 6); - let a = Belt_List.makeBy(10000, i => i); - Test_utils.ok("File \"belt_list_test.res\", line 284, characters 6-13", Belt_List.reduceReverse2(a, { - hd: 0, - tl: a - }, 0, (acc, x, y) => (acc + x | 0) + y | 0) === 99980001); - }); - Mocha.test("every2", () => { - Test_utils.eq("File \"belt_list_test.res\", line 290, characters 7-14", Belt_List.every2(/* [] */0, { - hd: 1, - tl: /* [] */0 - }, (x, y) => x > y), true); - Test_utils.eq("File \"belt_list_test.res\", line 291, characters 7-14", Belt_List.every2({ - hd: 2, - tl: { - hd: 3, - tl: /* [] */0 - } - }, { - hd: 1, - tl: /* [] */0 - }, (x, y) => x > y), true); - Test_utils.eq("File \"belt_list_test.res\", line 292, characters 7-14", Belt_List.every2({ - hd: 2, - tl: /* [] */0 - }, { - hd: 1, - tl: /* [] */0 - }, (x, y) => x > y), true); - Test_utils.eq("File \"belt_list_test.res\", line 293, characters 7-14", Belt_List.every2({ - hd: 2, - tl: { - hd: 3, - tl: /* [] */0 - } - }, { - hd: 1, - tl: { - hd: 4, - tl: /* [] */0 - } - }, (x, y) => x > y), false); - Test_utils.eq("File \"belt_list_test.res\", line 294, characters 7-14", Belt_List.every2({ - hd: 2, - tl: { - hd: 3, - tl: /* [] */0 - } - }, { - hd: 1, - tl: { - hd: 0, - tl: /* [] */0 - } - }, (x, y) => x > y), true); - }); - Mocha.test("some2", () => { - Test_utils.eq("File \"belt_list_test.res\", line 298, characters 7-14", Belt_List.some2(/* [] */0, { - hd: 1, - tl: /* [] */0 - }, (x, y) => x > y), false); - Test_utils.eq("File \"belt_list_test.res\", line 299, characters 7-14", Belt_List.some2({ - hd: 2, - tl: { - hd: 3, - tl: /* [] */0 - } - }, { - hd: 1, - tl: /* [] */0 - }, (x, y) => x > y), true); - Test_utils.eq("File \"belt_list_test.res\", line 300, characters 7-14", Belt_List.some2({ - hd: 2, - tl: { - hd: 3, - tl: /* [] */0 - } - }, { - hd: 1, - tl: { - hd: 4, - tl: /* [] */0 - } - }, (x, y) => x > y), true); - Test_utils.eq("File \"belt_list_test.res\", line 301, characters 7-14", Belt_List.some2({ - hd: 0, - tl: { - hd: 3, - tl: /* [] */0 - } - }, { - hd: 1, - tl: { - hd: 4, - tl: /* [] */0 - } - }, (x, y) => x > y), false); - Test_utils.eq("File \"belt_list_test.res\", line 302, characters 7-14", Belt_List.some2({ - hd: 0, - tl: { - hd: 3, - tl: /* [] */0 - } - }, { - hd: 3, - tl: { - hd: 2, - tl: /* [] */0 - } - }, (x, y) => x > y), true); - Test_utils.eq("File \"belt_list_test.res\", line 303, characters 7-14", Belt_List.some2({ - hd: 1, - tl: { - hd: 2, - tl: { - hd: 3, - tl: /* [] */0 - } - } - }, { - hd: -1, - tl: { - hd: -2, - tl: /* [] */0 - } - }, (x, y) => x === y), false); - }); - Mocha.test("add", () => Test_utils.eq("File \"belt_list_test.res\", line 307, characters 7-14", Belt_List.add(Belt_List.add(/* [] */0, 3), 2), { - hd: 2, - tl: { - hd: 3, - tl: /* [] */0 - } - })); - Mocha.test("cmp", () => { - Test_utils.ok("File \"belt_list_test.res\", line 311, characters 7-14", Belt_List.cmp({ - hd: 1, - tl: { - hd: 2, - tl: { - hd: 3, - tl: /* [] */0 - } - } - }, { - hd: 0, - tl: { - hd: 1, - tl: { - hd: 2, - tl: { - hd: 3, - tl: /* [] */0 - } - } - } - }, Primitive_int.compare) > 0); - Test_utils.ok("File \"belt_list_test.res\", line 312, characters 7-14", Belt_List.cmp({ - hd: 1, - tl: { - hd: 2, - tl: { - hd: 3, - tl: { - hd: 4, - tl: /* [] */0 - } - } - } - }, { - hd: 1, - tl: { - hd: 2, - tl: { - hd: 3, - tl: /* [] */0 - } - } - }, Primitive_int.compare) > 0); - Test_utils.ok("File \"belt_list_test.res\", line 313, characters 7-14", Belt_List.cmp({ - hd: 1, - tl: { - hd: 2, - tl: { - hd: 3, - tl: /* [] */0 - } - } - }, { - hd: 1, - tl: { - hd: 2, - tl: { - hd: 3, - tl: { - hd: 4, - tl: /* [] */0 - } - } - } - }, Primitive_int.compare) < 0); - Test_utils.ok("File \"belt_list_test.res\", line 314, characters 7-14", Belt_List.cmp({ - hd: 1, - tl: { - hd: 2, - tl: { - hd: 3, - tl: /* [] */0 - } - } - }, { - hd: 0, - tl: { - hd: 1, - tl: { - hd: 2, - tl: /* [] */0 - } - } - }, Primitive_int.compare) > 0); - Test_utils.ok("File \"belt_list_test.res\", line 315, characters 7-14", Belt_List.cmp({ - hd: 1, - tl: { - hd: 2, - tl: { - hd: 3, - tl: /* [] */0 - } - } - }, { - hd: 1, - tl: { - hd: 2, - tl: { - hd: 3, - tl: /* [] */0 - } - } - }, Primitive_int.compare) === 0); - Test_utils.ok("File \"belt_list_test.res\", line 316, characters 7-14", Belt_List.cmp({ - hd: 1, - tl: { - hd: 2, - tl: { - hd: 4, - tl: /* [] */0 - } - } - }, { - hd: 1, - tl: { - hd: 2, - tl: { - hd: 3, - tl: /* [] */0 - } - } - }, Primitive_int.compare) > 0); - }); - Mocha.test("cmpByLength", () => { - Test_utils.ok("File \"belt_list_test.res\", line 320, characters 7-14", Belt_List.cmpByLength(/* [] */0, /* [] */0) === 0); - Test_utils.ok("File \"belt_list_test.res\", line 321, characters 7-14", Belt_List.cmpByLength({ - hd: 1, - tl: /* [] */0 - }, /* [] */0) > 0); - Test_utils.ok("File \"belt_list_test.res\", line 322, characters 7-14", Belt_List.cmpByLength(/* [] */0, { - hd: 1, - tl: /* [] */0 - }) < 0); - Test_utils.ok("File \"belt_list_test.res\", line 323, characters 7-14", Belt_List.cmpByLength({ - hd: 1, - tl: { - hd: 2, - tl: /* [] */0 - } - }, { - hd: 1, - tl: /* [] */0 - }) > 0); - Test_utils.ok("File \"belt_list_test.res\", line 324, characters 7-14", Belt_List.cmpByLength({ - hd: 1, - tl: /* [] */0 - }, { - hd: 1, - tl: { - hd: 2, - tl: /* [] */0 - } - }) < 0); - Test_utils.ok("File \"belt_list_test.res\", line 325, characters 7-14", Belt_List.cmpByLength({ - hd: 1, - tl: { - hd: 3, - tl: /* [] */0 - } - }, { - hd: 1, - tl: { - hd: 2, - tl: /* [] */0 - } - }) === 0); - }); - Mocha.test("makeBy", () => { - let makeTest = n => Test_utils.eq("File \"belt_list_test.res\", line 329, characters 27-34", Belt_List.make(n, 3), Belt_List.makeBy(n, param => 3)); - makeTest(0); - makeTest(1); - makeTest(2); - makeTest(3); - }); - Mocha.test("sort", () => { - let cmp = (a, b) => a - b | 0; - Test_utils.eq("File \"belt_list_test.res\", line 339, characters 7-14", Belt_List.sort({ - hd: 5, - tl: { - hd: 4, - tl: { - hd: 3, - tl: { - hd: 2, - tl: /* [] */0 - } - } - } - }, cmp), { - hd: 2, - tl: { - hd: 3, - tl: { - hd: 4, - tl: { - hd: 5, - tl: /* [] */0 - } - } - } - }); - Test_utils.eq("File \"belt_list_test.res\", line 340, characters 7-14", Belt_List.sort({ - hd: 3, - tl: { - hd: 9, - tl: { - hd: 37, - tl: { - hd: 3, - tl: { - hd: 1, - tl: /* [] */0 - } - } - } - } - }, cmp), { - hd: 1, - tl: { - hd: 3, - tl: { - hd: 3, - tl: { - hd: 9, - tl: { - hd: 37, - tl: /* [] */0 - } - } - } - } - }); - }); - Mocha.test("eq", () => { - Test_utils.ok("File \"belt_list_test.res\", line 344, characters 7-14", !Belt_List.eq({ - hd: 1, - tl: { - hd: 2, - tl: { - hd: 3, - tl: /* [] */0 - } - } - }, { - hd: 1, - tl: { - hd: 2, - tl: /* [] */0 - } - }, (x, y) => x === y)); - Test_utils.ok("File \"belt_list_test.res\", line 345, characters 7-14", Belt_List.eq({ - hd: 1, - tl: { - hd: 2, - tl: { - hd: 3, - tl: /* [] */0 - } - } - }, { - hd: 1, - tl: { - hd: 2, - tl: { - hd: 3, - tl: /* [] */0 - } - } - }, (x, y) => x === y)); - Test_utils.ok("File \"belt_list_test.res\", line 346, characters 7-14", !Belt_List.eq({ - hd: 1, - tl: { - hd: 2, - tl: { - hd: 3, - tl: /* [] */0 - } - } - }, { - hd: 1, - tl: { - hd: 2, - tl: { - hd: 4, - tl: /* [] */0 - } - } - }, (x, y) => x === y)); - Test_utils.ok("File \"belt_list_test.res\", line 347, characters 7-14", !Belt_List.eq({ - hd: 1, - tl: { - hd: 2, - tl: { - hd: 3, - tl: /* [] */0 - } - } - }, { - hd: 1, - tl: { - hd: 2, - tl: { - hd: 3, - tl: { - hd: 4, - tl: /* [] */0 - } - } - } - }, (prim0, prim1) => prim0 === prim1)); - }); - Mocha.test("keepMap", () => { - let u0 = Belt_List.makeBy(20, x => x); - let u1 = Belt_List.keepMap(u0, x => { - if (x % 7 === 0) { - return x + 1 | 0; - } - - }); - Test_utils.eq("File \"belt_list_test.res\", line 360, characters 7-14", u1, { - hd: 1, - tl: { - hd: 8, - tl: { - hd: 15, - tl: /* [] */0 - } - } - }); - Test_utils.ok("File \"belt_list_test.res\", line 362, characters 6-13", Primitive_object.equal(Belt_List.keepMap({ - hd: 1, - tl: { - hd: 2, - tl: { - hd: 3, - tl: { - hd: 4, - tl: /* [] */0 - } - } - } - }, x => { - if (x % 2 === 0) { - return -x | 0; - } - - }), { - hd: -2, - tl: { - hd: -4, - tl: /* [] */0 - } - })); - Test_utils.ok("File \"belt_list_test.res\", line 377, characters 6-13", Belt_List.keepMap({ - hd: 1, - tl: { - hd: 2, - tl: { - hd: 3, - tl: { - hd: 4, - tl: /* [] */0 - } - } - } - }, x => { - if (x % 5 === 0) { - return x; - } - - }) === /* [] */0); - }); -}); - -let N; - -let A; - -exports.N = N; -exports.A = A; -exports.sum = sum; -exports.sum2 = sum2; -/* Not a pure module */ diff --git a/tests/tests/src/belt_list_test.mjs b/tests/tests/src/belt_list_test.mjs new file mode 100644 index 0000000000..d31ec27bb5 --- /dev/null +++ b/tests/tests/src/belt_list_test.mjs @@ -0,0 +1,2186 @@ +// Generated by ReScript, PLEASE EDIT WITH CARE + +import * as Mocha from "mocha"; +import * as Belt_List from "rescript/lib/es6/Belt_List.js"; +import * as Belt_Array from "rescript/lib/es6/Belt_Array.js"; +import * as Test_utils from "./test_utils.mjs"; +import * as Primitive_int from "rescript/lib/es6/Primitive_int.js"; +import * as Primitive_object from "rescript/lib/es6/Primitive_object.js"; + +function sum(xs) { + let v = { + contents: 0 + }; + Belt_List.forEach(xs, x => { + v.contents = v.contents + x | 0; + }); + return v.contents; +} + +function sum2(xs, ys) { + let v = { + contents: 0 + }; + Belt_List.forEach2(xs, ys, (x, y) => { + v.contents = (v.contents + x | 0) + y | 0; + }); + return v.contents; +} + +Mocha.describe("Belt_list_test", () => { + Mocha.test("makeBy", () => { + let u = Belt_List.makeBy(5, i => Math.imul(i, i)); + let f = i => Test_utils.eq("File \"belt_list_test.res\", line 23, characters 20-27", Belt_List.getExn(u, i), Math.imul(i, i)); + for (let i = 0; i <= 4; ++i) { + f(i); + } + Test_utils.eq("File \"belt_list_test.res\", line 27, characters 7-14", Belt_List.map(u, i => i + 1 | 0), { + hd: 1, + tl: { + hd: 2, + tl: { + hd: 5, + tl: { + hd: 10, + tl: { + hd: 17, + tl: /* [] */0 + } + } + } + } + }); + Test_utils.eq("File \"belt_list_test.res\", line 28, characters 7-14", Belt_List.getBy({ + hd: 1, + tl: { + hd: 4, + tl: { + hd: 3, + tl: { + hd: 2, + tl: /* [] */0 + } + } + } + }, x => x % 2 === 0), 4); + Test_utils.eq("File \"belt_list_test.res\", line 29, characters 7-14", Belt_List.getBy({ + hd: 1, + tl: { + hd: 4, + tl: { + hd: 3, + tl: { + hd: 2, + tl: /* [] */0 + } + } + } + }, x => x % 5 === 0), undefined); + }); + Mocha.test("flatten", () => { + Test_utils.eq("File \"belt_list_test.res\", line 34, characters 6-13", Belt_List.flatten({ + hd: { + hd: 1, + tl: /* [] */0 + }, + tl: { + hd: { + hd: 2, + tl: /* [] */0 + }, + tl: { + hd: { + hd: 3, + tl: /* [] */0 + }, + tl: { + hd: /* [] */0, + tl: { + hd: Belt_List.makeBy(4, i => i), + tl: /* [] */0 + } + } + } + } + }), { + hd: 1, + tl: { + hd: 2, + tl: { + hd: 3, + tl: { + hd: 0, + tl: { + hd: 1, + tl: { + hd: 2, + tl: { + hd: 3, + tl: /* [] */0 + } + } + } + } + } + } + }); + Test_utils.eq("File \"belt_list_test.res\", line 38, characters 7-14", Belt_List.flatten(/* [] */0), /* [] */0); + Test_utils.eq("File \"belt_list_test.res\", line 39, characters 7-14", Belt_List.flatten({ + hd: /* [] */0, + tl: { + hd: /* [] */0, + tl: { + hd: { + hd: 2, + tl: /* [] */0 + }, + tl: { + hd: { + hd: 1, + tl: /* [] */0 + }, + tl: { + hd: { + hd: 2, + tl: /* [] */0 + }, + tl: { + hd: /* [] */0, + tl: /* [] */0 + } + } + } + } + } + }), { + hd: 2, + tl: { + hd: 1, + tl: { + hd: 2, + tl: /* [] */0 + } + } + }); + }); + Mocha.test("concatMany", () => { + Test_utils.eq("File \"belt_list_test.res\", line 44, characters 6-13", Belt_List.concatMany([ + { + hd: 1, + tl: /* [] */0 + }, + { + hd: 2, + tl: /* [] */0 + }, + { + hd: 3, + tl: /* [] */0 + }, + /* [] */0, + Belt_List.makeBy(4, i => i) + ]), { + hd: 1, + tl: { + hd: 2, + tl: { + hd: 3, + tl: { + hd: 0, + tl: { + hd: 1, + tl: { + hd: 2, + tl: { + hd: 3, + tl: /* [] */0 + } + } + } + } + } + } + }); + Test_utils.eq("File \"belt_list_test.res\", line 48, characters 7-14", Belt_List.concatMany([]), /* [] */0); + Test_utils.eq("File \"belt_list_test.res\", line 49, characters 7-14", Belt_List.concatMany([ + /* [] */0, + /* [] */0, + { + hd: 2, + tl: /* [] */0 + }, + { + hd: 1, + tl: /* [] */0 + }, + { + hd: 2, + tl: /* [] */0 + }, + /* [] */0 + ]), { + hd: 2, + tl: { + hd: 1, + tl: { + hd: 2, + tl: /* [] */0 + } + } + }); + Test_utils.eq("File \"belt_list_test.res\", line 51, characters 6-13", Belt_List.concatMany([ + /* [] */0, + /* [] */0, + { + hd: 2, + tl: { + hd: 3, + tl: /* [] */0 + } + }, + { + hd: 1, + tl: /* [] */0 + }, + { + hd: 2, + tl: /* [] */0 + }, + /* [] */0 + ]), { + hd: 2, + tl: { + hd: 3, + tl: { + hd: 1, + tl: { + hd: 2, + tl: /* [] */0 + } + } + } + }); + Test_utils.eq("File \"belt_list_test.res\", line 55, characters 7-14", Belt_List.concatMany([{ + hd: 1, + tl: { + hd: 2, + tl: { + hd: 3, + tl: /* [] */0 + } + } + }]), { + hd: 1, + tl: { + hd: 2, + tl: { + hd: 3, + tl: /* [] */0 + } + } + }); + }); + Mocha.test("concat", () => { + Test_utils.eq("File \"belt_list_test.res\", line 60, characters 6-13", Belt_List.toArray(Belt_List.concat(Belt_List.makeBy(100, i => i), Belt_List.makeBy(100, i => i))), Belt_Array.concat(Belt_Array.makeBy(100, i => i), Belt_Array.makeBy(100, i => i))); + Test_utils.eq("File \"belt_list_test.res\", line 65, characters 7-14", Belt_List.concat({ + hd: 1, + tl: /* [] */0 + }, /* [] */0), { + hd: 1, + tl: /* [] */0 + }); + Test_utils.eq("File \"belt_list_test.res\", line 66, characters 7-14", Belt_List.concat(/* [] */0, { + hd: 1, + tl: /* [] */0 + }), { + hd: 1, + tl: /* [] */0 + }); + }); + Mocha.test("zip", () => { + Test_utils.eq("File \"belt_list_test.res\", line 70, characters 7-14", Belt_List.zip({ + hd: 1, + tl: { + hd: 2, + tl: { + hd: 3, + tl: /* [] */0 + } + } + }, { + hd: 3, + tl: { + hd: 4, + tl: /* [] */0 + } + }), { + hd: [ + 1, + 3 + ], + tl: { + hd: [ + 2, + 4 + ], + tl: /* [] */0 + } + }); + Test_utils.eq("File \"belt_list_test.res\", line 71, characters 7-14", Belt_List.zip(/* [] */0, { + hd: 1, + tl: /* [] */0 + }), /* [] */0); + Test_utils.eq("File \"belt_list_test.res\", line 72, characters 7-14", Belt_List.zip(/* [] */0, /* [] */0), /* [] */0); + Test_utils.eq("File \"belt_list_test.res\", line 73, characters 7-14", Belt_List.zip({ + hd: 1, + tl: { + hd: 2, + tl: { + hd: 3, + tl: /* [] */0 + } + } + }, /* [] */0), /* [] */0); + Test_utils.eq("File \"belt_list_test.res\", line 74, characters 7-14", Belt_List.zip({ + hd: 1, + tl: { + hd: 2, + tl: { + hd: 3, + tl: /* [] */0 + } + } + }, { + hd: 2, + tl: { + hd: 3, + tl: { + hd: 4, + tl: /* [] */0 + } + } + }), { + hd: [ + 1, + 2 + ], + tl: { + hd: [ + 2, + 3 + ], + tl: { + hd: [ + 3, + 4 + ], + tl: /* [] */0 + } + } + }); + }); + let mod2 = x => x % 2 === 0; + let evenIndex = (_x, i) => i % 2 === 0; + Mocha.test("partition", () => { + Test_utils.eq("File \"belt_list_test.res\", line 81, characters 7-14", Belt_List.partition({ + hd: 1, + tl: { + hd: 2, + tl: { + hd: 3, + tl: { + hd: 2, + tl: { + hd: 3, + tl: { + hd: 4, + tl: /* [] */0 + } + } + } + } + } + }, mod2), [ + { + hd: 2, + tl: { + hd: 2, + tl: { + hd: 4, + tl: /* [] */0 + } + } + }, + { + hd: 1, + tl: { + hd: 3, + tl: { + hd: 3, + tl: /* [] */0 + } + } + } + ]); + Test_utils.eq("File \"belt_list_test.res\", line 82, characters 7-14", Belt_List.partition({ + hd: 2, + tl: { + hd: 2, + tl: { + hd: 2, + tl: { + hd: 4, + tl: /* [] */0 + } + } + } + }, mod2), [ + { + hd: 2, + tl: { + hd: 2, + tl: { + hd: 2, + tl: { + hd: 4, + tl: /* [] */0 + } + } + } + }, + /* [] */0 + ]); + Test_utils.eq("File \"belt_list_test.res\", line 83, characters 7-14", Belt_List.partition({ + hd: 2, + tl: { + hd: 2, + tl: { + hd: 2, + tl: { + hd: 4, + tl: /* [] */0 + } + } + } + }, x => !mod2(x)), [ + /* [] */0, + { + hd: 2, + tl: { + hd: 2, + tl: { + hd: 2, + tl: { + hd: 4, + tl: /* [] */0 + } + } + } + } + ]); + Test_utils.eq("File \"belt_list_test.res\", line 84, characters 7-14", Belt_List.partition(/* [] */0, mod2), [ + /* [] */0, + /* [] */0 + ]); + }); + Mocha.test("unzip", () => { + Test_utils.eq("File \"belt_list_test.res\", line 88, characters 7-14", Belt_List.unzip(/* [] */0), [ + /* [] */0, + /* [] */0 + ]); + Test_utils.eq("File \"belt_list_test.res\", line 89, characters 7-14", Belt_List.unzip({ + hd: [ + 1, + 2 + ], + tl: /* [] */0 + }), [ + { + hd: 1, + tl: /* [] */0 + }, + { + hd: 2, + tl: /* [] */0 + } + ]); + Test_utils.eq("File \"belt_list_test.res\", line 90, characters 7-14", Belt_List.unzip({ + hd: [ + 1, + 2 + ], + tl: { + hd: [ + 3, + 4 + ], + tl: /* [] */0 + } + }), [ + { + hd: 1, + tl: { + hd: 3, + tl: /* [] */0 + } + }, + { + hd: 2, + tl: { + hd: 4, + tl: /* [] */0 + } + } + ]); + }); + Mocha.test("filter", () => { + Test_utils.eq("File \"belt_list_test.res\", line 94, characters 7-14", Belt_List.keep({ + hd: 1, + tl: { + hd: 2, + tl: { + hd: 3, + tl: { + hd: 4, + tl: /* [] */0 + } + } + } + }, mod2), { + hd: 2, + tl: { + hd: 4, + tl: /* [] */0 + } + }); + Test_utils.eq("File \"belt_list_test.res\", line 95, characters 7-14", Belt_List.keep({ + hd: 1, + tl: { + hd: 3, + tl: { + hd: 41, + tl: /* [] */0 + } + } + }, mod2), /* [] */0); + Test_utils.eq("File \"belt_list_test.res\", line 96, characters 7-14", Belt_List.keep(/* [] */0, mod2), /* [] */0); + Test_utils.eq("File \"belt_list_test.res\", line 97, characters 7-14", Belt_List.keep({ + hd: 2, + tl: { + hd: 2, + tl: { + hd: 2, + tl: { + hd: 4, + tl: { + hd: 6, + tl: /* [] */0 + } + } + } + } + }, mod2), { + hd: 2, + tl: { + hd: 2, + tl: { + hd: 2, + tl: { + hd: 4, + tl: { + hd: 6, + tl: /* [] */0 + } + } + } + } + }); + }); + Mocha.test("keepWithIndex", () => { + Test_utils.eq("File \"belt_list_test.res\", line 101, characters 7-14", Belt_List.keepWithIndex(/* [] */0, evenIndex), /* [] */0); + Test_utils.eq("File \"belt_list_test.res\", line 102, characters 7-14", Belt_List.keepWithIndex({ + hd: 1, + tl: { + hd: 2, + tl: { + hd: 3, + tl: { + hd: 4, + tl: /* [] */0 + } + } + } + }, evenIndex), { + hd: 1, + tl: { + hd: 3, + tl: /* [] */0 + } + }); + Test_utils.eq("File \"belt_list_test.res\", line 103, characters 7-14", Belt_List.keepWithIndex({ + hd: 0, + tl: { + hd: 1, + tl: { + hd: 2, + tl: { + hd: 3, + tl: { + hd: 4, + tl: { + hd: 5, + tl: { + hd: 6, + tl: { + hd: 7, + tl: /* [] */0 + } + } + } + } + } + } + } + }, evenIndex), { + hd: 0, + tl: { + hd: 2, + tl: { + hd: 4, + tl: { + hd: 6, + tl: /* [] */0 + } + } + } + }); + }); + let id = x => x; + Mocha.test("map", () => { + Test_utils.eq("File \"belt_list_test.res\", line 109, characters 7-14", Belt_List.map(Belt_List.makeBy(5, id), x => (x << 1)), { + hd: 0, + tl: { + hd: 2, + tl: { + hd: 4, + tl: { + hd: 6, + tl: { + hd: 8, + tl: /* [] */0 + } + } + } + } + }); + Test_utils.eq("File \"belt_list_test.res\", line 110, characters 7-14", Belt_List.map(/* [] */0, id), /* [] */0); + Test_utils.eq("File \"belt_list_test.res\", line 111, characters 7-14", Belt_List.map({ + hd: 1, + tl: /* [] */0 + }, x => -x | 0), { + hd: -1, + tl: /* [] */0 + }); + }); + let add = (a, b) => a + b | 0; + let length_10_id = Belt_List.makeBy(10, id); + let length_8_id = Belt_List.makeBy(8, id); + Mocha.test("mapWithIndex etc.", () => { + let d = Belt_List.makeBy(10, x => (x << 1)); + Test_utils.eq("File \"belt_list_test.res\", line 124, characters 7-14", Belt_List.zipBy(length_10_id, length_10_id, add), d); + Test_utils.eq("File \"belt_list_test.res\", line 125, characters 7-14", Belt_List.zipBy(/* [] */0, { + hd: 1, + tl: /* [] */0 + }, add), /* [] */0); + Test_utils.eq("File \"belt_list_test.res\", line 126, characters 7-14", Belt_List.zipBy({ + hd: 1, + tl: /* [] */0 + }, /* [] */0, add), /* [] */0); + Test_utils.eq("File \"belt_list_test.res\", line 127, characters 7-14", Belt_List.zipBy(/* [] */0, /* [] */0, add), /* [] */0); + Test_utils.eq("File \"belt_list_test.res\", line 128, characters 7-14", Belt_List.zipBy(length_10_id, length_10_id, add), Belt_List.concat(Belt_List.map(length_8_id, x => (x << 1)), { + hd: 16, + tl: { + hd: 18, + tl: /* [] */0 + } + })); + Test_utils.eq("File \"belt_list_test.res\", line 129, characters 7-14", Belt_List.zipBy(length_10_id, length_8_id, add), Belt_List.mapWithIndex(length_8_id, (i, x) => i + x | 0)); + Test_utils.eq("File \"belt_list_test.res\", line 131, characters 6-13", Belt_List.reverse(Belt_List.mapReverse2(length_10_id, length_10_id, add)), Belt_List.map(length_10_id, x => (x << 1))); + let xs = Belt_List.reverse(Belt_List.mapReverse2(length_8_id, length_10_id, add)); + Test_utils.eq("File \"belt_list_test.res\", line 136, characters 7-14", Belt_List.length(xs), 8); + Test_utils.eq("File \"belt_list_test.res\", line 137, characters 7-14", xs, Belt_List.zipBy(length_10_id, length_8_id, add)); + Test_utils.eq("File \"belt_list_test.res\", line 138, characters 7-14", Belt_List.mapReverse2({ + hd: 1, + tl: { + hd: 2, + tl: { + hd: 3, + tl: /* [] */0 + } + } + }, { + hd: 1, + tl: { + hd: 2, + tl: /* [] */0 + } + }, (x, y) => x + y | 0), { + hd: 4, + tl: { + hd: 2, + tl: /* [] */0 + } + }); + }); + Mocha.test("take", () => { + Test_utils.eq("File \"belt_list_test.res\", line 142, characters 7-14", Belt_List.take({ + hd: 1, + tl: { + hd: 2, + tl: { + hd: 3, + tl: /* [] */0 + } + } + }, 2), { + hd: 1, + tl: { + hd: 2, + tl: /* [] */0 + } + }); + Test_utils.eq("File \"belt_list_test.res\", line 143, characters 7-14", Belt_List.take(/* [] */0, 1), undefined); + Test_utils.eq("File \"belt_list_test.res\", line 144, characters 7-14", Belt_List.take({ + hd: 1, + tl: { + hd: 2, + tl: /* [] */0 + } + }, 3), undefined); + Test_utils.eq("File \"belt_list_test.res\", line 145, characters 7-14", Belt_List.take({ + hd: 1, + tl: { + hd: 2, + tl: /* [] */0 + } + }, 2), { + hd: 1, + tl: { + hd: 2, + tl: /* [] */0 + } + }); + Test_utils.eq("File \"belt_list_test.res\", line 146, characters 7-14", Belt_List.take(length_10_id, 8), length_8_id); + Test_utils.eq("File \"belt_list_test.res\", line 147, characters 7-14", Belt_List.take(length_10_id, 0), /* [] */0); + Test_utils.eq("File \"belt_list_test.res\", line 148, characters 7-14", Belt_List.take(length_8_id, -2), undefined); + }); + Mocha.test("droo", () => { + Test_utils.eq("File \"belt_list_test.res\", line 152, characters 7-14", Belt_List.drop(length_10_id, 10), /* [] */0); + Test_utils.eq("File \"belt_list_test.res\", line 153, characters 7-14", Belt_List.drop(length_10_id, 8), { + hd: 8, + tl: { + hd: 9, + tl: /* [] */0 + } + }); + Test_utils.eq("File \"belt_list_test.res\", line 154, characters 7-14", Belt_List.drop(length_10_id, 0), length_10_id); + Test_utils.eq("File \"belt_list_test.res\", line 155, characters 7-14", Belt_List.drop(length_8_id, -1), undefined); + }); + Mocha.test("splitAt", () => { + let a = Belt_List.makeBy(5, id); + Test_utils.eq("File \"belt_list_test.res\", line 160, characters 7-14", Belt_List.splitAt(/* [] */0, 1), undefined); + Test_utils.eq("File \"belt_list_test.res\", line 161, characters 7-14", Belt_List.splitAt(a, 6), undefined); + Test_utils.eq("File \"belt_list_test.res\", line 162, characters 7-14", Belt_List.splitAt(a, 5), [ + a, + /* [] */0 + ]); + Test_utils.eq("File \"belt_list_test.res\", line 163, characters 7-14", Belt_List.splitAt(a, 4), [ + { + hd: 0, + tl: { + hd: 1, + tl: { + hd: 2, + tl: { + hd: 3, + tl: /* [] */0 + } + } + } + }, + { + hd: 4, + tl: /* [] */0 + } + ]); + Test_utils.eq("File \"belt_list_test.res\", line 164, characters 7-14", Belt_List.splitAt(a, 3), [ + { + hd: 0, + tl: { + hd: 1, + tl: { + hd: 2, + tl: /* [] */0 + } + } + }, + { + hd: 3, + tl: { + hd: 4, + tl: /* [] */0 + } + } + ]); + Test_utils.eq("File \"belt_list_test.res\", line 165, characters 7-14", Belt_List.splitAt(a, 2), [ + { + hd: 0, + tl: { + hd: 1, + tl: /* [] */0 + } + }, + { + hd: 2, + tl: { + hd: 3, + tl: { + hd: 4, + tl: /* [] */0 + } + } + } + ]); + Test_utils.eq("File \"belt_list_test.res\", line 166, characters 7-14", Belt_List.splitAt(a, 1), [ + { + hd: 0, + tl: /* [] */0 + }, + { + hd: 1, + tl: { + hd: 2, + tl: { + hd: 3, + tl: { + hd: 4, + tl: /* [] */0 + } + } + } + } + ]); + Test_utils.eq("File \"belt_list_test.res\", line 167, characters 7-14", Belt_List.splitAt(a, 0), [ + /* [] */0, + a + ]); + Test_utils.eq("File \"belt_list_test.res\", line 168, characters 7-14", Belt_List.splitAt(a, -1), undefined); + }); + Mocha.test("removeAssoc", () => { + let eqx = (x, y) => x === y; + Test_utils.ok("File \"belt_list_test.res\", line 174, characters 7-14", Belt_List.hasAssoc({ + hd: [ + 1, + "1" + ], + tl: { + hd: [ + 2, + "2" + ], + tl: { + hd: [ + 3, + "3" + ], + tl: /* [] */0 + } + } + }, 2, (prim0, prim1) => prim0 === prim1)); + Test_utils.ok("File \"belt_list_test.res\", line 175, characters 7-14", !Belt_List.hasAssoc({ + hd: [ + 1, + "1" + ], + tl: { + hd: [ + 2, + "2" + ], + tl: { + hd: [ + 3, + "3" + ], + tl: /* [] */0 + } + } + }, 4, (prim0, prim1) => prim0 === prim1)); + Test_utils.ok("File \"belt_list_test.res\", line 176, characters 7-14", Belt_List.hasAssoc({ + hd: [ + 1, + "1" + ], + tl: { + hd: [ + 2, + "2" + ], + tl: { + hd: [ + 3, + "3" + ], + tl: /* [] */0 + } + } + }, 4, (x, y) => (x + 1 | 0) === y)); + Test_utils.eq("File \"belt_list_test.res\", line 178, characters 6-13", Belt_List.removeAssoc({ + hd: [ + 1, + "1" + ], + tl: { + hd: [ + 2, + "2" + ], + tl: { + hd: [ + 3, + "3" + ], + tl: /* [] */0 + } + } + }, 3, (prim0, prim1) => prim0 === prim1), { + hd: [ + 1, + "1" + ], + tl: { + hd: [ + 2, + "2" + ], + tl: /* [] */0 + } + }); + Test_utils.eq("File \"belt_list_test.res\", line 183, characters 6-13", Belt_List.removeAssoc({ + hd: [ + 1, + "1" + ], + tl: { + hd: [ + 2, + "2" + ], + tl: { + hd: [ + 3, + "3" + ], + tl: /* [] */0 + } + } + }, 1, (prim0, prim1) => prim0 === prim1), { + hd: [ + 2, + "2" + ], + tl: { + hd: [ + 3, + "3" + ], + tl: /* [] */0 + } + }); + Test_utils.eq("File \"belt_list_test.res\", line 188, characters 6-13", Belt_List.removeAssoc({ + hd: [ + 1, + "1" + ], + tl: { + hd: [ + 2, + "2" + ], + tl: { + hd: [ + 3, + "3" + ], + tl: /* [] */0 + } + } + }, 2, (prim0, prim1) => prim0 === prim1), { + hd: [ + 1, + "1" + ], + tl: { + hd: [ + 3, + "3" + ], + tl: /* [] */0 + } + }); + Test_utils.eq("File \"belt_list_test.res\", line 193, characters 6-13", Belt_List.removeAssoc({ + hd: [ + 1, + "1" + ], + tl: { + hd: [ + 2, + "2" + ], + tl: { + hd: [ + 3, + "3" + ], + tl: /* [] */0 + } + } + }, 0, (prim0, prim1) => prim0 === prim1), { + hd: [ + 1, + "1" + ], + tl: { + hd: [ + 2, + "2" + ], + tl: { + hd: [ + 3, + "3" + ], + tl: /* [] */0 + } + } + }); + Test_utils.eq("File \"belt_list_test.res\", line 198, characters 7-14", Belt_List.removeAssoc({ + hd: [ + 1, + "1" + ], + tl: { + hd: [ + 2, + "2" + ], + tl: { + hd: [ + 3, + "3" + ], + tl: /* [] */0 + } + } + }, 3, eqx), { + hd: [ + 1, + "1" + ], + tl: { + hd: [ + 2, + "2" + ], + tl: /* [] */0 + } + }); + Test_utils.eq("File \"belt_list_test.res\", line 199, characters 7-14", Belt_List.removeAssoc({ + hd: [ + 1, + "1" + ], + tl: { + hd: [ + 2, + "2" + ], + tl: { + hd: [ + 3, + "3" + ], + tl: /* [] */0 + } + } + }, 1, eqx), { + hd: [ + 2, + "2" + ], + tl: { + hd: [ + 3, + "3" + ], + tl: /* [] */0 + } + }); + Test_utils.eq("File \"belt_list_test.res\", line 200, characters 7-14", Belt_List.removeAssoc({ + hd: [ + 1, + "1" + ], + tl: { + hd: [ + 2, + "2" + ], + tl: { + hd: [ + 3, + "3" + ], + tl: /* [] */0 + } + } + }, 2, eqx), { + hd: [ + 1, + "1" + ], + tl: { + hd: [ + 3, + "3" + ], + tl: /* [] */0 + } + }); + Test_utils.eq("File \"belt_list_test.res\", line 201, characters 7-14", Belt_List.removeAssoc(/* [] */0, 2, eqx), /* [] */0); + let ll = { + hd: [ + 1, + "1" + ], + tl: { + hd: [ + 2, + "2" + ], + tl: { + hd: [ + 3, + "3" + ], + tl: /* [] */0 + } + } + }; + let ll0 = Belt_List.removeAssoc(ll, 0, eqx); + Test_utils.ok("File \"belt_list_test.res\", line 204, characters 7-14", ll === ll0); + let ll1 = Belt_List.setAssoc(ll, 2, "22", (prim0, prim1) => prim0 === prim1); + Test_utils.eq("File \"belt_list_test.res\", line 206, characters 7-14", ll1, { + hd: [ + 1, + "1" + ], + tl: { + hd: [ + 2, + "22" + ], + tl: { + hd: [ + 3, + "3" + ], + tl: /* [] */0 + } + } + }); + let ll2 = Belt_List.setAssoc(ll1, 22, "2", (prim0, prim1) => prim0 === prim1); + Test_utils.ok("File \"belt_list_test.res\", line 208, characters 7-14", Primitive_object.equal(ll2, { + hd: [ + 22, + "2" + ], + tl: ll1 + })); + Test_utils.ok("File \"belt_list_test.res\", line 209, characters 7-14", Belt_List.tailExn(ll2) === ll1); + Test_utils.ok("File \"belt_list_test.res\", line 211, characters 6-13", Primitive_object.equal(Belt_List.setAssoc({ + hd: [ + 1, + "a" + ], + tl: { + hd: [ + 2, + "b" + ], + tl: { + hd: [ + 3, + "c" + ], + tl: /* [] */0 + } + } + }, 2, "x", (prim0, prim1) => prim0 === prim1), { + hd: [ + 1, + "a" + ], + tl: { + hd: [ + 2, + "x" + ], + tl: { + hd: [ + 3, + "c" + ], + tl: /* [] */0 + } + } + })); + Test_utils.ok("File \"belt_list_test.res\", line 216, characters 6-13", Primitive_object.equal(Belt_List.setAssoc({ + hd: [ + 1, + "a" + ], + tl: { + hd: [ + 3, + "c" + ], + tl: /* [] */0 + } + }, 2, "2", (prim0, prim1) => prim0 === prim1), { + hd: [ + 2, + "2" + ], + tl: { + hd: [ + 1, + "a" + ], + tl: { + hd: [ + 3, + "c" + ], + tl: /* [] */0 + } + } + })); + Test_utils.eq("File \"belt_list_test.res\", line 219, characters 7-14", Belt_List.setAssoc(/* [] */0, 1, "1", (prim0, prim1) => prim0 === prim1), { + hd: [ + 1, + "1" + ], + tl: /* [] */0 + }); + Test_utils.eq("File \"belt_list_test.res\", line 220, characters 7-14", Belt_List.setAssoc({ + hd: [ + 1, + "2" + ], + tl: /* [] */0 + }, 1, "1", (prim0, prim1) => prim0 === prim1), { + hd: [ + 1, + "1" + ], + tl: /* [] */0 + }); + Test_utils.eq("File \"belt_list_test.res\", line 222, characters 7-14", Belt_List.setAssoc({ + hd: [ + 0, + "0" + ], + tl: { + hd: [ + 1, + "2" + ], + tl: /* [] */0 + } + }, 1, "1", (prim0, prim1) => prim0 === prim1), { + hd: [ + 0, + "0" + ], + tl: { + hd: [ + 1, + "1" + ], + tl: /* [] */0 + } + }); + Test_utils.ok("File \"belt_list_test.res\", line 223, characters 7-14", Primitive_object.equal(Belt_List.getAssoc({ + hd: [ + 1, + "a" + ], + tl: { + hd: [ + 2, + "b" + ], + tl: { + hd: [ + 3, + "c" + ], + tl: /* [] */0 + } + } + }, 2, (prim0, prim1) => prim0 === prim1), "b")); + Test_utils.ok("File \"belt_list_test.res\", line 224, characters 7-14", Belt_List.getAssoc({ + hd: [ + 1, + "a" + ], + tl: { + hd: [ + 2, + "b" + ], + tl: { + hd: [ + 3, + "c" + ], + tl: /* [] */0 + } + } + }, 4, (prim0, prim1) => prim0 === prim1) === undefined); + }); + Mocha.test("head/tail etc.", () => { + let succx = x => x + 1 | 0; + Test_utils.eq("File \"belt_list_test.res\", line 230, characters 7-14", [ + Belt_List.head(length_10_id), + Belt_List.tail(length_10_id) + ], [ + 0, + Belt_List.drop(length_10_id, 1) + ]); + Test_utils.eq("File \"belt_list_test.res\", line 231, characters 7-14", Belt_List.head(/* [] */0), undefined); + Test_utils.$$throw("File \"belt_list_test.res\", line 232, characters 10-17", () => Belt_List.headExn(/* [] */0)); + Test_utils.$$throw("File \"belt_list_test.res\", line 233, characters 10-17", () => { + Belt_List.tailExn(/* [] */0); + }); + Test_utils.$$throw("File \"belt_list_test.res\", line 234, characters 10-17", () => { + Belt_List.getExn({ + hd: 0, + tl: { + hd: 1, + tl: /* [] */0 + } + }, -1); + }); + Test_utils.$$throw("File \"belt_list_test.res\", line 235, characters 10-17", () => { + Belt_List.getExn({ + hd: 0, + tl: { + hd: 1, + tl: /* [] */0 + } + }, 2); + }); + Test_utils.eq("File \"belt_list_test.res\", line 236, characters 7-14", Belt_List.map({ + hd: 0, + tl: { + hd: 1, + tl: /* [] */0 + } + }, i => Belt_List.getExn({ + hd: 0, + tl: { + hd: 1, + tl: /* [] */0 + } + }, i)), { + hd: 0, + tl: { + hd: 1, + tl: /* [] */0 + } + }); + Test_utils.eq("File \"belt_list_test.res\", line 237, characters 7-14", Belt_List.headExn({ + hd: 1, + tl: /* [] */0 + }), 1); + Test_utils.eq("File \"belt_list_test.res\", line 238, characters 7-14", Belt_List.tailExn({ + hd: 1, + tl: /* [] */0 + }), /* [] */0); + Belt_List.forEachWithIndex(length_10_id, (i, x) => Test_utils.eq("File \"belt_list_test.res\", line 239, characters 50-57", Belt_List.get(length_10_id, i), x)); + Test_utils.eq("File \"belt_list_test.res\", line 240, characters 7-14", Belt_List.tail(/* [] */0), undefined); + Test_utils.eq("File \"belt_list_test.res\", line 241, characters 7-14", Belt_List.drop(/* [] */0, 3), undefined); + Test_utils.eq("File \"belt_list_test.res\", line 242, characters 7-14", Belt_List.mapWithIndex(/* [] */0, (i, x) => i + x | 0), /* [] */0); + Test_utils.eq("File \"belt_list_test.res\", line 243, characters 7-14", Belt_List.get(length_10_id, -1), undefined); + Test_utils.eq("File \"belt_list_test.res\", line 244, characters 7-14", Belt_List.get(length_10_id, 12), undefined); + Test_utils.eq("File \"belt_list_test.res\", line 245, characters 7-14", sum(/* [] */0), 0); + Test_utils.eq("File \"belt_list_test.res\", line 246, characters 7-14", sum(length_10_id), 45); + Test_utils.eq("File \"belt_list_test.res\", line 247, characters 7-14", Belt_List.makeBy(0, id), /* [] */0); + Test_utils.eq("File \"belt_list_test.res\", line 248, characters 7-14", Belt_List.reverse(Belt_List.reverse(length_10_id)), length_10_id); + Test_utils.eq("File \"belt_list_test.res\", line 249, characters 7-14", Belt_List.reverse(Belt_List.reverse(length_8_id)), length_8_id); + Test_utils.eq("File \"belt_list_test.res\", line 250, characters 7-14", Belt_List.reverse(/* [] */0), /* [] */0); + Test_utils.eq("File \"belt_list_test.res\", line 251, characters 7-14", Belt_List.reverse(Belt_List.mapReverse(length_10_id, succx)), Belt_List.map(length_10_id, succx)); + Test_utils.eq("File \"belt_list_test.res\", line 252, characters 7-14", Belt_List.reduce(length_10_id, 0, add), 45); + Test_utils.eq("File \"belt_list_test.res\", line 253, characters 7-14", Belt_List.reduceReverse(length_10_id, 0, add), 45); + Test_utils.eq("File \"belt_list_test.res\", line 254, characters 7-14", Belt_List.reduceReverse(Belt_List.makeBy(10000, i => i), 0, (prim0, prim1) => prim0 + prim1 | 0), 49995000); + Test_utils.eq("File \"belt_list_test.res\", line 257, characters 7-14", sum2(length_10_id, length_10_id), 90); + Test_utils.eq("File \"belt_list_test.res\", line 258, characters 7-14", sum2(length_8_id, length_10_id), 56); + Test_utils.eq("File \"belt_list_test.res\", line 259, characters 7-14", sum2(length_10_id, length_8_id), 56); + Test_utils.eq("File \"belt_list_test.res\", line 260, characters 7-14", Belt_List.reduce2(length_10_id, length_8_id, 0, (acc, x, y) => (acc + x | 0) + y | 0), 56); + Test_utils.eq("File \"belt_list_test.res\", line 261, characters 7-14", Belt_List.reduce2({ + hd: 1, + tl: { + hd: 2, + tl: { + hd: 3, + tl: /* [] */0 + } + } + }, { + hd: 2, + tl: { + hd: 4, + tl: { + hd: 6, + tl: /* [] */0 + } + } + }, 0, (a, b, c) => (a + b | 0) + c | 0), 18); + Test_utils.eq("File \"belt_list_test.res\", line 262, characters 7-14", Belt_List.reduceReverse2(length_10_id, length_8_id, 0, (acc, x, y) => (acc + x | 0) + y | 0), 56); + Test_utils.eq("File \"belt_list_test.res\", line 263, characters 7-14", Belt_List.reduceReverse2(length_10_id, length_10_id, 0, (acc, x, y) => (acc + x | 0) + y | 0), 90); + Test_utils.eq("File \"belt_list_test.res\", line 264, characters 7-14", Belt_List.reduceReverse2({ + hd: 1, + tl: { + hd: 2, + tl: { + hd: 3, + tl: /* [] */0 + } + } + }, { + hd: 1, + tl: { + hd: 2, + tl: /* [] */0 + } + }, 0, (acc, x, y) => (acc + x | 0) + y | 0), 6); + Test_utils.eq("File \"belt_list_test.res\", line 265, characters 7-14", Belt_List.every({ + hd: 2, + tl: { + hd: 4, + tl: { + hd: 6, + tl: /* [] */0 + } + } + }, mod2), true); + Test_utils.eq("File \"belt_list_test.res\", line 266, characters 7-14", Belt_List.every({ + hd: 1, + tl: /* [] */0 + }, mod2), false); + Test_utils.eq("File \"belt_list_test.res\", line 267, characters 7-14", Belt_List.every(/* [] */0, mod2), true); + Test_utils.eq("File \"belt_list_test.res\", line 268, characters 7-14", Belt_List.some({ + hd: 1, + tl: { + hd: 2, + tl: { + hd: 5, + tl: /* [] */0 + } + } + }, mod2), true); + Test_utils.eq("File \"belt_list_test.res\", line 269, characters 7-14", Belt_List.some({ + hd: 1, + tl: { + hd: 3, + tl: { + hd: 5, + tl: /* [] */0 + } + } + }, mod2), false); + Test_utils.eq("File \"belt_list_test.res\", line 270, characters 7-14", Belt_List.some(/* [] */0, mod2), false); + Test_utils.eq("File \"belt_list_test.res\", line 271, characters 7-14", Belt_List.has({ + hd: 1, + tl: { + hd: 2, + tl: { + hd: 3, + tl: /* [] */0 + } + } + }, "2", (x, s) => x.toString() === s), true); + Test_utils.eq("File \"belt_list_test.res\", line 272, characters 7-14", Belt_List.has({ + hd: 1, + tl: { + hd: 2, + tl: { + hd: 3, + tl: /* [] */0 + } + } + }, "0", (x, s) => x.toString() === s), false); + Test_utils.ok("File \"belt_list_test.res\", line 274, characters 7-14", Belt_List.reduceReverse({ + hd: 1, + tl: { + hd: 2, + tl: { + hd: 3, + tl: { + hd: 4, + tl: /* [] */0 + } + } + } + }, 0, (prim0, prim1) => prim0 + prim1 | 0) === 10); + Test_utils.ok("File \"belt_list_test.res\", line 275, characters 7-14", Belt_List.reduceReverse({ + hd: 1, + tl: { + hd: 2, + tl: { + hd: 3, + tl: { + hd: 4, + tl: /* [] */0 + } + } + } + }, 10, (prim0, prim1) => prim0 - prim1 | 0) === 0); + Test_utils.ok("File \"belt_list_test.res\", line 276, characters 7-14", Primitive_object.equal(Belt_List.reduceReverse({ + hd: 1, + tl: { + hd: 2, + tl: { + hd: 3, + tl: { + hd: 4, + tl: /* [] */0 + } + } + } + }, /* [] */0, Belt_List.add), { + hd: 1, + tl: { + hd: 2, + tl: { + hd: 3, + tl: { + hd: 4, + tl: /* [] */0 + } + } + } + })); + Test_utils.ok("File \"belt_list_test.res\", line 277, characters 7-14", Belt_List.reduce({ + hd: 1, + tl: { + hd: 2, + tl: { + hd: 3, + tl: { + hd: 4, + tl: /* [] */0 + } + } + } + }, 0, (prim0, prim1) => prim0 + prim1 | 0) === 10); + Test_utils.ok("File \"belt_list_test.res\", line 278, characters 7-14", Belt_List.reduce({ + hd: 1, + tl: { + hd: 2, + tl: { + hd: 3, + tl: { + hd: 4, + tl: /* [] */0 + } + } + } + }, 10, (prim0, prim1) => prim0 - prim1 | 0) === 0); + Test_utils.ok("File \"belt_list_test.res\", line 279, characters 7-14", Primitive_object.equal(Belt_List.reduce({ + hd: 1, + tl: { + hd: 2, + tl: { + hd: 3, + tl: { + hd: 4, + tl: /* [] */0 + } + } + } + }, /* [] */0, Belt_List.add), { + hd: 4, + tl: { + hd: 3, + tl: { + hd: 2, + tl: { + hd: 1, + tl: /* [] */0 + } + } + } + })); + Test_utils.ok("File \"belt_list_test.res\", line 280, characters 7-14", Belt_List.reduceWithIndex({ + hd: 1, + tl: { + hd: 2, + tl: { + hd: 3, + tl: { + hd: 4, + tl: /* [] */0 + } + } + } + }, 0, (acc, x, i) => (acc + x | 0) + i | 0) === 16); + Test_utils.ok("File \"belt_list_test.res\", line 281, characters 7-14", Belt_List.reduceReverse2({ + hd: 1, + tl: { + hd: 2, + tl: { + hd: 3, + tl: /* [] */0 + } + } + }, { + hd: 1, + tl: { + hd: 2, + tl: /* [] */0 + } + }, 0, (acc, x, y) => (acc + x | 0) + y | 0) === 6); + let a = Belt_List.makeBy(10000, i => i); + Test_utils.ok("File \"belt_list_test.res\", line 284, characters 6-13", Belt_List.reduceReverse2(a, { + hd: 0, + tl: a + }, 0, (acc, x, y) => (acc + x | 0) + y | 0) === 99980001); + }); + Mocha.test("every2", () => { + Test_utils.eq("File \"belt_list_test.res\", line 290, characters 7-14", Belt_List.every2(/* [] */0, { + hd: 1, + tl: /* [] */0 + }, (x, y) => x > y), true); + Test_utils.eq("File \"belt_list_test.res\", line 291, characters 7-14", Belt_List.every2({ + hd: 2, + tl: { + hd: 3, + tl: /* [] */0 + } + }, { + hd: 1, + tl: /* [] */0 + }, (x, y) => x > y), true); + Test_utils.eq("File \"belt_list_test.res\", line 292, characters 7-14", Belt_List.every2({ + hd: 2, + tl: /* [] */0 + }, { + hd: 1, + tl: /* [] */0 + }, (x, y) => x > y), true); + Test_utils.eq("File \"belt_list_test.res\", line 293, characters 7-14", Belt_List.every2({ + hd: 2, + tl: { + hd: 3, + tl: /* [] */0 + } + }, { + hd: 1, + tl: { + hd: 4, + tl: /* [] */0 + } + }, (x, y) => x > y), false); + Test_utils.eq("File \"belt_list_test.res\", line 294, characters 7-14", Belt_List.every2({ + hd: 2, + tl: { + hd: 3, + tl: /* [] */0 + } + }, { + hd: 1, + tl: { + hd: 0, + tl: /* [] */0 + } + }, (x, y) => x > y), true); + }); + Mocha.test("some2", () => { + Test_utils.eq("File \"belt_list_test.res\", line 298, characters 7-14", Belt_List.some2(/* [] */0, { + hd: 1, + tl: /* [] */0 + }, (x, y) => x > y), false); + Test_utils.eq("File \"belt_list_test.res\", line 299, characters 7-14", Belt_List.some2({ + hd: 2, + tl: { + hd: 3, + tl: /* [] */0 + } + }, { + hd: 1, + tl: /* [] */0 + }, (x, y) => x > y), true); + Test_utils.eq("File \"belt_list_test.res\", line 300, characters 7-14", Belt_List.some2({ + hd: 2, + tl: { + hd: 3, + tl: /* [] */0 + } + }, { + hd: 1, + tl: { + hd: 4, + tl: /* [] */0 + } + }, (x, y) => x > y), true); + Test_utils.eq("File \"belt_list_test.res\", line 301, characters 7-14", Belt_List.some2({ + hd: 0, + tl: { + hd: 3, + tl: /* [] */0 + } + }, { + hd: 1, + tl: { + hd: 4, + tl: /* [] */0 + } + }, (x, y) => x > y), false); + Test_utils.eq("File \"belt_list_test.res\", line 302, characters 7-14", Belt_List.some2({ + hd: 0, + tl: { + hd: 3, + tl: /* [] */0 + } + }, { + hd: 3, + tl: { + hd: 2, + tl: /* [] */0 + } + }, (x, y) => x > y), true); + Test_utils.eq("File \"belt_list_test.res\", line 303, characters 7-14", Belt_List.some2({ + hd: 1, + tl: { + hd: 2, + tl: { + hd: 3, + tl: /* [] */0 + } + } + }, { + hd: -1, + tl: { + hd: -2, + tl: /* [] */0 + } + }, (x, y) => x === y), false); + }); + Mocha.test("add", () => Test_utils.eq("File \"belt_list_test.res\", line 307, characters 7-14", Belt_List.add(Belt_List.add(/* [] */0, 3), 2), { + hd: 2, + tl: { + hd: 3, + tl: /* [] */0 + } + })); + Mocha.test("cmp", () => { + Test_utils.ok("File \"belt_list_test.res\", line 311, characters 7-14", Belt_List.cmp({ + hd: 1, + tl: { + hd: 2, + tl: { + hd: 3, + tl: /* [] */0 + } + } + }, { + hd: 0, + tl: { + hd: 1, + tl: { + hd: 2, + tl: { + hd: 3, + tl: /* [] */0 + } + } + } + }, Primitive_int.compare) > 0); + Test_utils.ok("File \"belt_list_test.res\", line 312, characters 7-14", Belt_List.cmp({ + hd: 1, + tl: { + hd: 2, + tl: { + hd: 3, + tl: { + hd: 4, + tl: /* [] */0 + } + } + } + }, { + hd: 1, + tl: { + hd: 2, + tl: { + hd: 3, + tl: /* [] */0 + } + } + }, Primitive_int.compare) > 0); + Test_utils.ok("File \"belt_list_test.res\", line 313, characters 7-14", Belt_List.cmp({ + hd: 1, + tl: { + hd: 2, + tl: { + hd: 3, + tl: /* [] */0 + } + } + }, { + hd: 1, + tl: { + hd: 2, + tl: { + hd: 3, + tl: { + hd: 4, + tl: /* [] */0 + } + } + } + }, Primitive_int.compare) < 0); + Test_utils.ok("File \"belt_list_test.res\", line 314, characters 7-14", Belt_List.cmp({ + hd: 1, + tl: { + hd: 2, + tl: { + hd: 3, + tl: /* [] */0 + } + } + }, { + hd: 0, + tl: { + hd: 1, + tl: { + hd: 2, + tl: /* [] */0 + } + } + }, Primitive_int.compare) > 0); + Test_utils.ok("File \"belt_list_test.res\", line 315, characters 7-14", Belt_List.cmp({ + hd: 1, + tl: { + hd: 2, + tl: { + hd: 3, + tl: /* [] */0 + } + } + }, { + hd: 1, + tl: { + hd: 2, + tl: { + hd: 3, + tl: /* [] */0 + } + } + }, Primitive_int.compare) === 0); + Test_utils.ok("File \"belt_list_test.res\", line 316, characters 7-14", Belt_List.cmp({ + hd: 1, + tl: { + hd: 2, + tl: { + hd: 4, + tl: /* [] */0 + } + } + }, { + hd: 1, + tl: { + hd: 2, + tl: { + hd: 3, + tl: /* [] */0 + } + } + }, Primitive_int.compare) > 0); + }); + Mocha.test("cmpByLength", () => { + Test_utils.ok("File \"belt_list_test.res\", line 320, characters 7-14", Belt_List.cmpByLength(/* [] */0, /* [] */0) === 0); + Test_utils.ok("File \"belt_list_test.res\", line 321, characters 7-14", Belt_List.cmpByLength({ + hd: 1, + tl: /* [] */0 + }, /* [] */0) > 0); + Test_utils.ok("File \"belt_list_test.res\", line 322, characters 7-14", Belt_List.cmpByLength(/* [] */0, { + hd: 1, + tl: /* [] */0 + }) < 0); + Test_utils.ok("File \"belt_list_test.res\", line 323, characters 7-14", Belt_List.cmpByLength({ + hd: 1, + tl: { + hd: 2, + tl: /* [] */0 + } + }, { + hd: 1, + tl: /* [] */0 + }) > 0); + Test_utils.ok("File \"belt_list_test.res\", line 324, characters 7-14", Belt_List.cmpByLength({ + hd: 1, + tl: /* [] */0 + }, { + hd: 1, + tl: { + hd: 2, + tl: /* [] */0 + } + }) < 0); + Test_utils.ok("File \"belt_list_test.res\", line 325, characters 7-14", Belt_List.cmpByLength({ + hd: 1, + tl: { + hd: 3, + tl: /* [] */0 + } + }, { + hd: 1, + tl: { + hd: 2, + tl: /* [] */0 + } + }) === 0); + }); + Mocha.test("makeBy", () => { + let makeTest = n => Test_utils.eq("File \"belt_list_test.res\", line 329, characters 27-34", Belt_List.make(n, 3), Belt_List.makeBy(n, param => 3)); + makeTest(0); + makeTest(1); + makeTest(2); + makeTest(3); + }); + Mocha.test("sort", () => { + let cmp = (a, b) => a - b | 0; + Test_utils.eq("File \"belt_list_test.res\", line 339, characters 7-14", Belt_List.sort({ + hd: 5, + tl: { + hd: 4, + tl: { + hd: 3, + tl: { + hd: 2, + tl: /* [] */0 + } + } + } + }, cmp), { + hd: 2, + tl: { + hd: 3, + tl: { + hd: 4, + tl: { + hd: 5, + tl: /* [] */0 + } + } + } + }); + Test_utils.eq("File \"belt_list_test.res\", line 340, characters 7-14", Belt_List.sort({ + hd: 3, + tl: { + hd: 9, + tl: { + hd: 37, + tl: { + hd: 3, + tl: { + hd: 1, + tl: /* [] */0 + } + } + } + } + }, cmp), { + hd: 1, + tl: { + hd: 3, + tl: { + hd: 3, + tl: { + hd: 9, + tl: { + hd: 37, + tl: /* [] */0 + } + } + } + } + }); + }); + Mocha.test("eq", () => { + Test_utils.ok("File \"belt_list_test.res\", line 344, characters 7-14", !Belt_List.eq({ + hd: 1, + tl: { + hd: 2, + tl: { + hd: 3, + tl: /* [] */0 + } + } + }, { + hd: 1, + tl: { + hd: 2, + tl: /* [] */0 + } + }, (x, y) => x === y)); + Test_utils.ok("File \"belt_list_test.res\", line 345, characters 7-14", Belt_List.eq({ + hd: 1, + tl: { + hd: 2, + tl: { + hd: 3, + tl: /* [] */0 + } + } + }, { + hd: 1, + tl: { + hd: 2, + tl: { + hd: 3, + tl: /* [] */0 + } + } + }, (x, y) => x === y)); + Test_utils.ok("File \"belt_list_test.res\", line 346, characters 7-14", !Belt_List.eq({ + hd: 1, + tl: { + hd: 2, + tl: { + hd: 3, + tl: /* [] */0 + } + } + }, { + hd: 1, + tl: { + hd: 2, + tl: { + hd: 4, + tl: /* [] */0 + } + } + }, (x, y) => x === y)); + Test_utils.ok("File \"belt_list_test.res\", line 347, characters 7-14", !Belt_List.eq({ + hd: 1, + tl: { + hd: 2, + tl: { + hd: 3, + tl: /* [] */0 + } + } + }, { + hd: 1, + tl: { + hd: 2, + tl: { + hd: 3, + tl: { + hd: 4, + tl: /* [] */0 + } + } + } + }, (prim0, prim1) => prim0 === prim1)); + }); + Mocha.test("keepMap", () => { + let u0 = Belt_List.makeBy(20, x => x); + let u1 = Belt_List.keepMap(u0, x => { + if (x % 7 === 0) { + return x + 1 | 0; + } + + }); + Test_utils.eq("File \"belt_list_test.res\", line 360, characters 7-14", u1, { + hd: 1, + tl: { + hd: 8, + tl: { + hd: 15, + tl: /* [] */0 + } + } + }); + Test_utils.ok("File \"belt_list_test.res\", line 362, characters 6-13", Primitive_object.equal(Belt_List.keepMap({ + hd: 1, + tl: { + hd: 2, + tl: { + hd: 3, + tl: { + hd: 4, + tl: /* [] */0 + } + } + } + }, x => { + if (x % 2 === 0) { + return -x | 0; + } + + }), { + hd: -2, + tl: { + hd: -4, + tl: /* [] */0 + } + })); + Test_utils.ok("File \"belt_list_test.res\", line 377, characters 6-13", Belt_List.keepMap({ + hd: 1, + tl: { + hd: 2, + tl: { + hd: 3, + tl: { + hd: 4, + tl: /* [] */0 + } + } + } + }, x => { + if (x % 5 === 0) { + return x; + } + + }) === /* [] */0); + }); +}); + +let N; + +let A; + +export { + N, + A, + sum, + sum2, +} +/* Not a pure module */ diff --git a/tests/tests/src/belt_mapint_test.js b/tests/tests/src/belt_mapint_test.js deleted file mode 100644 index 138f665ed0..0000000000 --- a/tests/tests/src/belt_mapint_test.js +++ /dev/null @@ -1,27 +0,0 @@ -// Generated by ReScript, PLEASE EDIT WITH CARE -'use strict'; - -let Mocha = require("mocha"); -let Test_utils = require("./test_utils.js"); -let Belt_MapInt = require("rescript/lib/js/Belt_MapInt.js"); - -Mocha.describe("Belt_mapint_test", () => { - Mocha.test("set", () => { - let m; - for (let i = 0; i <= 999999; ++i) { - m = Belt_MapInt.set(m, i, i); - } - for (let i$1 = 0; i$1 <= 999999; ++i$1) { - Test_utils.ok("File \"belt_mapint_test.res\", line 17, characters 9-16", Belt_MapInt.get(m, i$1) !== undefined); - } - for (let i$2 = 0; i$2 <= 999999; ++i$2) { - m = Belt_MapInt.remove(m, i$2); - } - Test_utils.ok("File \"belt_mapint_test.res\", line 23, characters 7-14", Belt_MapInt.isEmpty(m)); - }); -}); - -let M; - -exports.M = M; -/* Not a pure module */ diff --git a/tests/tests/src/belt_mapint_test.mjs b/tests/tests/src/belt_mapint_test.mjs new file mode 100644 index 0000000000..48f68d7a35 --- /dev/null +++ b/tests/tests/src/belt_mapint_test.mjs @@ -0,0 +1,28 @@ +// Generated by ReScript, PLEASE EDIT WITH CARE + +import * as Mocha from "mocha"; +import * as Test_utils from "./test_utils.mjs"; +import * as Belt_MapInt from "rescript/lib/es6/Belt_MapInt.js"; + +Mocha.describe("Belt_mapint_test", () => { + Mocha.test("set", () => { + let m; + for (let i = 0; i <= 999999; ++i) { + m = Belt_MapInt.set(m, i, i); + } + for (let i$1 = 0; i$1 <= 999999; ++i$1) { + Test_utils.ok("File \"belt_mapint_test.res\", line 17, characters 9-16", Belt_MapInt.get(m, i$1) !== undefined); + } + for (let i$2 = 0; i$2 <= 999999; ++i$2) { + m = Belt_MapInt.remove(m, i$2); + } + Test_utils.ok("File \"belt_mapint_test.res\", line 23, characters 7-14", Belt_MapInt.isEmpty(m)); + }); +}); + +let M; + +export { + M, +} +/* Not a pure module */ diff --git a/tests/tests/src/belt_result_alias_test.js b/tests/tests/src/belt_result_alias_test.js deleted file mode 100644 index 49b887b852..0000000000 --- a/tests/tests/src/belt_result_alias_test.js +++ /dev/null @@ -1,16 +0,0 @@ -// Generated by ReScript, PLEASE EDIT WITH CARE -'use strict'; - -let Belt_Result = require("rescript/lib/js/Belt_Result.js"); - -Belt_Result.map({ - TAG: "Ok", - _0: "Test" -}, r => "Value: " + r); - -Belt_Result.getWithDefault(Belt_Result.map({ - TAG: "Error", - _0: "error" -}, r => "Value: " + r), "success"); - -/* Not a pure module */ diff --git a/tests/tests/src/belt_result_alias_test.mjs b/tests/tests/src/belt_result_alias_test.mjs new file mode 100644 index 0000000000..ae39edea54 --- /dev/null +++ b/tests/tests/src/belt_result_alias_test.mjs @@ -0,0 +1,15 @@ +// Generated by ReScript, PLEASE EDIT WITH CARE + +import * as Belt_Result from "rescript/lib/es6/Belt_Result.js"; + +Belt_Result.map({ + TAG: "Ok", + _0: "Test" +}, r => "Value: " + r); + +Belt_Result.getWithDefault(Belt_Result.map({ + TAG: "Error", + _0: "error" +}, r => "Value: " + r), "success"); + +/* Not a pure module */ diff --git a/tests/tests/src/belt_sortarray_test.js b/tests/tests/src/belt_sortarray_test.js deleted file mode 100644 index 2975a39075..0000000000 --- a/tests/tests/src/belt_sortarray_test.js +++ /dev/null @@ -1,345 +0,0 @@ -// Generated by ReScript, PLEASE EDIT WITH CARE -'use strict'; - -let Mocha = require("mocha"); -let Belt_Array = require("rescript/lib/js/Belt_Array.js"); -let Belt_Range = require("rescript/lib/js/Belt_Range.js"); -let Pervasives = require("rescript/lib/js/Pervasives.js"); -let Test_utils = require("./test_utils.js"); -let Belt_SortArray = require("rescript/lib/js/Belt_SortArray.js"); -let Array_data_util = require("./array_data_util.js"); -let Belt_SortArrayInt = require("rescript/lib/js/Belt_SortArrayInt.js"); - -function cmp(x, y) { - return x - y | 0; -} - -function unions(xs, ys) { - let lenX = xs.length; - let lenY = ys.length; - let o = new Array(lenX + lenY | 0); - let v = Belt_SortArray.union(xs, 0, lenX, ys, 0, lenY, o, 0, cmp); - o.length = v; - return o; -} - -function inters(xs, ys) { - let lenX = xs.length; - let lenY = ys.length; - let o = new Array(lenX); - let v = Belt_SortArray.intersect(xs, 0, lenX, ys, 0, lenY, o, 0, cmp); - o.length = v; - return o; -} - -function diffs(xs, ys) { - let lenX = xs.length; - let lenY = ys.length; - let o = new Array(lenX); - let v = Belt_SortArray.diff(xs, 0, lenX, ys, 0, lenY, o, 0, cmp); - o.length = v; - return o; -} - -Mocha.describe("Belt_sortarray_test", () => { - Mocha.test("union", () => { - Test_utils.eq("File \"belt_sortarray_test.res\", line 38, characters 7-14", unions(Array_data_util.range(1, 10), Array_data_util.range(3, 13)), Array_data_util.range(1, 13)); - Test_utils.eq("File \"belt_sortarray_test.res\", line 39, characters 7-14", unions(Array_data_util.range(1, 10), Array_data_util.range(9, 13)), Array_data_util.range(1, 13)); - Test_utils.eq("File \"belt_sortarray_test.res\", line 40, characters 7-14", unions(Array_data_util.range(8, 10), Array_data_util.range(9, 13)), Array_data_util.range(8, 13)); - Test_utils.eq("File \"belt_sortarray_test.res\", line 41, characters 7-14", unions(Array_data_util.range(0, 2), Array_data_util.range(4, 7)), [ - 0, - 1, - 2, - 4, - 5, - 6, - 7 - ]); - }); - Mocha.test("intersect", () => { - Test_utils.eq("File \"belt_sortarray_test.res\", line 45, characters 7-14", inters(Array_data_util.range(1, 10), Array_data_util.range(3, 13)), Array_data_util.range(3, 10)); - Test_utils.eq("File \"belt_sortarray_test.res\", line 46, characters 7-14", inters(Array_data_util.range(1, 10), Array_data_util.range(9, 13)), Array_data_util.range(9, 10)); - Test_utils.eq("File \"belt_sortarray_test.res\", line 47, characters 7-14", inters(Array_data_util.range(8, 10), Array_data_util.range(9, 13)), Array_data_util.range(9, 10)); - Test_utils.eq("File \"belt_sortarray_test.res\", line 48, characters 7-14", inters(Array_data_util.range(0, 2), Array_data_util.range(4, 7)), []); - }); - Mocha.test("diff", () => { - Test_utils.eq("File \"belt_sortarray_test.res\", line 52, characters 7-14", diffs(Array_data_util.range(1, 10), Array_data_util.range(3, 13)), Array_data_util.range(1, 2)); - Test_utils.eq("File \"belt_sortarray_test.res\", line 53, characters 7-14", diffs(Array_data_util.range(1, 10), Array_data_util.range(9, 13)), Array_data_util.range(1, 8)); - Test_utils.eq("File \"belt_sortarray_test.res\", line 54, characters 7-14", diffs(Array_data_util.range(8, 10), Array_data_util.range(9, 13)), Array_data_util.range(8, 8)); - Test_utils.eq("File \"belt_sortarray_test.res\", line 55, characters 7-14", diffs(Array_data_util.range(0, 2), Array_data_util.range(4, 7)), [ - 0, - 1, - 2 - ]); - }); - Mocha.test("isSorted", () => { - Test_utils.ok("File \"belt_sortarray_test.res\", line 59, characters 7-14", Belt_SortArray.isSorted([], cmp)); - Test_utils.ok("File \"belt_sortarray_test.res\", line 60, characters 7-14", Belt_SortArray.isSorted([0], cmp)); - Test_utils.ok("File \"belt_sortarray_test.res\", line 61, characters 7-14", Belt_SortArray.isSorted([ - 0, - 1 - ], cmp)); - Test_utils.ok("File \"belt_sortarray_test.res\", line 62, characters 7-14", !Belt_SortArray.isSorted([ - 1, - 0 - ], cmp)); - }); - Mocha.test("stableSortInPlaceBy", () => Test_utils.ok("File \"belt_sortarray_test.res\", line 67, characters 6-13", Belt_Range.every(0, 200, i => { - let v = Array_data_util.randomRange(0, i); - Belt_SortArray.stableSortInPlaceBy(v, cmp); - return Belt_SortArray.isSorted(v, cmp); - }))); - Mocha.test("stableSortInPlaceBy 2", () => { - let u = Array_data_util.randomRange(0, 1000000); - let u1 = u.slice(0); - Belt_SortArray.stableSortInPlaceBy(u, cmp); - Test_utils.ok("File \"belt_sortarray_test.res\", line 85, characters 7-14", Belt_SortArray.isSorted(u, cmp)); - Belt_SortArrayInt.stableSortInPlace(u1); - Test_utils.ok("File \"belt_sortarray_test.res\", line 87, characters 7-14", Belt_SortArray.isSorted(u1, cmp)); - }); - Mocha.test("stableSortInPlaceBy 3", () => { - let u = [ - [ - 1, - "a" - ], - [ - 1, - "b" - ], - [ - 2, - "a" - ] - ]; - Test_utils.eq("File \"belt_sortarray_test.res\", line 92, characters 7-14", Belt_SortArray.stableSortBy(u, (param, param$1) => param[0] - param$1[0] | 0), [ - [ - 1, - "a" - ], - [ - 1, - "b" - ], - [ - 2, - "a" - ] - ]); - let u$1 = [ - [ - 1, - "b" - ], - [ - 1, - "a" - ], - [ - 1, - "b" - ], - [ - 2, - "a" - ] - ]; - Test_utils.eq("File \"belt_sortarray_test.res\", line 95, characters 6-13", Belt_SortArray.stableSortBy(u$1, (param, param$1) => param[0] - param$1[0] | 0), [ - [ - 1, - "b" - ], - [ - 1, - "a" - ], - [ - 1, - "b" - ], - [ - 2, - "a" - ] - ]); - let u$2 = [ - [ - 1, - "c" - ], - [ - 1, - "b" - ], - [ - 1, - "a" - ], - [ - 1, - "b" - ], - [ - 1, - "c" - ], - [ - 2, - "a" - ] - ]; - Test_utils.eq("File \"belt_sortarray_test.res\", line 101, characters 6-13", Belt_SortArray.stableSortBy(u$2, (param, param$1) => param[0] - param$1[0] | 0), [ - [ - 1, - "c" - ], - [ - 1, - "b" - ], - [ - 1, - "a" - ], - [ - 1, - "b" - ], - [ - 1, - "c" - ], - [ - 2, - "a" - ] - ]); - }); - Mocha.test("binarySearchBy", () => { - Test_utils.eq("File \"belt_sortarray_test.res\", line 108, characters 7-14", Pervasives.lnot(Belt_SortArray.binarySearchBy([ - 1, - 3, - 5, - 7 - ], 4, cmp)), 2); - Test_utils.eq("File \"belt_sortarray_test.res\", line 109, characters 7-14", Belt_SortArray.binarySearchBy([ - 1, - 2, - 3, - 4, - 33, - 35, - 36 - ], 33, cmp), 4); - Test_utils.eq("File \"belt_sortarray_test.res\", line 110, characters 7-14", Belt_SortArray.binarySearchBy([ - 1, - 2, - 3, - 4, - 33, - 35, - 36 - ], 1, cmp), 0); - Test_utils.eq("File \"belt_sortarray_test.res\", line 111, characters 7-14", Belt_SortArray.binarySearchBy([ - 1, - 2, - 3, - 4, - 33, - 35, - 36 - ], 2, cmp), 1); - Test_utils.eq("File \"belt_sortarray_test.res\", line 112, characters 7-14", Belt_SortArray.binarySearchBy([ - 1, - 2, - 3, - 4, - 33, - 35, - 36 - ], 3, cmp), 2); - Test_utils.eq("File \"belt_sortarray_test.res\", line 113, characters 7-14", Belt_SortArray.binarySearchBy([ - 1, - 2, - 3, - 4, - 33, - 35, - 36 - ], 4, cmp), 3); - let aa = Array_data_util.range(0, 1000); - Test_utils.ok("File \"belt_sortarray_test.res\", line 115, characters 7-14", Belt_Range.every(0, 1000, i => Belt_SortArray.binarySearchBy(aa, i, cmp) === i)); - let cc = Belt_Array.map(Array_data_util.range(0, 2000), x => (x << 1)); - Test_utils.eq("File \"belt_sortarray_test.res\", line 118, characters 7-14", Pervasives.lnot(Belt_SortArray.binarySearchBy(cc, 5000, cmp)), 2001); - Test_utils.eq("File \"belt_sortarray_test.res\", line 119, characters 7-14", Pervasives.lnot(Belt_SortArray.binarySearchBy(cc, -1, cmp)), 0); - Test_utils.eq("File \"belt_sortarray_test.res\", line 120, characters 7-14", Belt_SortArray.binarySearchBy(cc, 0, cmp), 0); - Test_utils.eq("File \"belt_sortarray_test.res\", line 122, characters 7-14", Pervasives.lnot(Belt_SortArray.binarySearchBy(cc, 1, cmp)), 1); - Test_utils.ok("File \"belt_sortarray_test.res\", line 124, characters 6-13", Belt_Range.every(0, 1999, i => Pervasives.lnot(Belt_SortArray.binarySearchBy(cc, (i << 1) + 1 | 0, cmp)) === (i + 1 | 0))); - }); - Mocha.test("strictlySortedLength", () => { - let lt = (x, y) => x < y; - Test_utils.eq("File \"belt_sortarray_test.res\", line 133, characters 7-14", Belt_SortArray.strictlySortedLength([], lt), 0); - Test_utils.eq("File \"belt_sortarray_test.res\", line 134, characters 7-14", Belt_SortArray.strictlySortedLength([1], lt), 1); - Test_utils.eq("File \"belt_sortarray_test.res\", line 135, characters 7-14", Belt_SortArray.strictlySortedLength([ - 1, - 1 - ], lt), 1); - Test_utils.eq("File \"belt_sortarray_test.res\", line 136, characters 7-14", Belt_SortArray.strictlySortedLength([ - 1, - 1, - 2 - ], lt), 1); - Test_utils.eq("File \"belt_sortarray_test.res\", line 137, characters 7-14", Belt_SortArray.strictlySortedLength([ - 1, - 2 - ], lt), 2); - Test_utils.eq("File \"belt_sortarray_test.res\", line 138, characters 7-14", Belt_SortArray.strictlySortedLength([ - 1, - 2, - 3, - 4, - 3 - ], lt), 4); - Test_utils.eq("File \"belt_sortarray_test.res\", line 139, characters 7-14", Belt_SortArray.strictlySortedLength([ - 4, - 4, - 3, - 2, - 1 - ], lt), 1); - Test_utils.eq("File \"belt_sortarray_test.res\", line 140, characters 7-14", Belt_SortArray.strictlySortedLength([ - 4, - 3, - 2, - 1 - ], lt), -4); - Test_utils.eq("File \"belt_sortarray_test.res\", line 141, characters 7-14", Belt_SortArray.strictlySortedLength([ - 4, - 3, - 2, - 1, - 0 - ], lt), -5); - }); -}); - -let I; - -let R; - -let A; - -let S; - -let SI; - -exports.I = I; -exports.R = R; -exports.A = A; -exports.S = S; -exports.SI = SI; -exports.cmp = cmp; -exports.unions = unions; -exports.inters = inters; -exports.diffs = diffs; -/* Not a pure module */ diff --git a/tests/tests/src/belt_sortarray_test.mjs b/tests/tests/src/belt_sortarray_test.mjs new file mode 100644 index 0000000000..6c6ab7f7c4 --- /dev/null +++ b/tests/tests/src/belt_sortarray_test.mjs @@ -0,0 +1,346 @@ +// Generated by ReScript, PLEASE EDIT WITH CARE + +import * as Mocha from "mocha"; +import * as Belt_Array from "rescript/lib/es6/Belt_Array.js"; +import * as Belt_Range from "rescript/lib/es6/Belt_Range.js"; +import * as Pervasives from "rescript/lib/es6/Pervasives.js"; +import * as Test_utils from "./test_utils.mjs"; +import * as Belt_SortArray from "rescript/lib/es6/Belt_SortArray.js"; +import * as Array_data_util from "./array_data_util.mjs"; +import * as Belt_SortArrayInt from "rescript/lib/es6/Belt_SortArrayInt.js"; + +function cmp(x, y) { + return x - y | 0; +} + +function unions(xs, ys) { + let lenX = xs.length; + let lenY = ys.length; + let o = new Array(lenX + lenY | 0); + let v = Belt_SortArray.union(xs, 0, lenX, ys, 0, lenY, o, 0, cmp); + o.length = v; + return o; +} + +function inters(xs, ys) { + let lenX = xs.length; + let lenY = ys.length; + let o = new Array(lenX); + let v = Belt_SortArray.intersect(xs, 0, lenX, ys, 0, lenY, o, 0, cmp); + o.length = v; + return o; +} + +function diffs(xs, ys) { + let lenX = xs.length; + let lenY = ys.length; + let o = new Array(lenX); + let v = Belt_SortArray.diff(xs, 0, lenX, ys, 0, lenY, o, 0, cmp); + o.length = v; + return o; +} + +Mocha.describe("Belt_sortarray_test", () => { + Mocha.test("union", () => { + Test_utils.eq("File \"belt_sortarray_test.res\", line 38, characters 7-14", unions(Array_data_util.range(1, 10), Array_data_util.range(3, 13)), Array_data_util.range(1, 13)); + Test_utils.eq("File \"belt_sortarray_test.res\", line 39, characters 7-14", unions(Array_data_util.range(1, 10), Array_data_util.range(9, 13)), Array_data_util.range(1, 13)); + Test_utils.eq("File \"belt_sortarray_test.res\", line 40, characters 7-14", unions(Array_data_util.range(8, 10), Array_data_util.range(9, 13)), Array_data_util.range(8, 13)); + Test_utils.eq("File \"belt_sortarray_test.res\", line 41, characters 7-14", unions(Array_data_util.range(0, 2), Array_data_util.range(4, 7)), [ + 0, + 1, + 2, + 4, + 5, + 6, + 7 + ]); + }); + Mocha.test("intersect", () => { + Test_utils.eq("File \"belt_sortarray_test.res\", line 45, characters 7-14", inters(Array_data_util.range(1, 10), Array_data_util.range(3, 13)), Array_data_util.range(3, 10)); + Test_utils.eq("File \"belt_sortarray_test.res\", line 46, characters 7-14", inters(Array_data_util.range(1, 10), Array_data_util.range(9, 13)), Array_data_util.range(9, 10)); + Test_utils.eq("File \"belt_sortarray_test.res\", line 47, characters 7-14", inters(Array_data_util.range(8, 10), Array_data_util.range(9, 13)), Array_data_util.range(9, 10)); + Test_utils.eq("File \"belt_sortarray_test.res\", line 48, characters 7-14", inters(Array_data_util.range(0, 2), Array_data_util.range(4, 7)), []); + }); + Mocha.test("diff", () => { + Test_utils.eq("File \"belt_sortarray_test.res\", line 52, characters 7-14", diffs(Array_data_util.range(1, 10), Array_data_util.range(3, 13)), Array_data_util.range(1, 2)); + Test_utils.eq("File \"belt_sortarray_test.res\", line 53, characters 7-14", diffs(Array_data_util.range(1, 10), Array_data_util.range(9, 13)), Array_data_util.range(1, 8)); + Test_utils.eq("File \"belt_sortarray_test.res\", line 54, characters 7-14", diffs(Array_data_util.range(8, 10), Array_data_util.range(9, 13)), Array_data_util.range(8, 8)); + Test_utils.eq("File \"belt_sortarray_test.res\", line 55, characters 7-14", diffs(Array_data_util.range(0, 2), Array_data_util.range(4, 7)), [ + 0, + 1, + 2 + ]); + }); + Mocha.test("isSorted", () => { + Test_utils.ok("File \"belt_sortarray_test.res\", line 59, characters 7-14", Belt_SortArray.isSorted([], cmp)); + Test_utils.ok("File \"belt_sortarray_test.res\", line 60, characters 7-14", Belt_SortArray.isSorted([0], cmp)); + Test_utils.ok("File \"belt_sortarray_test.res\", line 61, characters 7-14", Belt_SortArray.isSorted([ + 0, + 1 + ], cmp)); + Test_utils.ok("File \"belt_sortarray_test.res\", line 62, characters 7-14", !Belt_SortArray.isSorted([ + 1, + 0 + ], cmp)); + }); + Mocha.test("stableSortInPlaceBy", () => Test_utils.ok("File \"belt_sortarray_test.res\", line 67, characters 6-13", Belt_Range.every(0, 200, i => { + let v = Array_data_util.randomRange(0, i); + Belt_SortArray.stableSortInPlaceBy(v, cmp); + return Belt_SortArray.isSorted(v, cmp); + }))); + Mocha.test("stableSortInPlaceBy 2", () => { + let u = Array_data_util.randomRange(0, 1000000); + let u1 = u.slice(0); + Belt_SortArray.stableSortInPlaceBy(u, cmp); + Test_utils.ok("File \"belt_sortarray_test.res\", line 85, characters 7-14", Belt_SortArray.isSorted(u, cmp)); + Belt_SortArrayInt.stableSortInPlace(u1); + Test_utils.ok("File \"belt_sortarray_test.res\", line 87, characters 7-14", Belt_SortArray.isSorted(u1, cmp)); + }); + Mocha.test("stableSortInPlaceBy 3", () => { + let u = [ + [ + 1, + "a" + ], + [ + 1, + "b" + ], + [ + 2, + "a" + ] + ]; + Test_utils.eq("File \"belt_sortarray_test.res\", line 92, characters 7-14", Belt_SortArray.stableSortBy(u, (param, param$1) => param[0] - param$1[0] | 0), [ + [ + 1, + "a" + ], + [ + 1, + "b" + ], + [ + 2, + "a" + ] + ]); + let u$1 = [ + [ + 1, + "b" + ], + [ + 1, + "a" + ], + [ + 1, + "b" + ], + [ + 2, + "a" + ] + ]; + Test_utils.eq("File \"belt_sortarray_test.res\", line 95, characters 6-13", Belt_SortArray.stableSortBy(u$1, (param, param$1) => param[0] - param$1[0] | 0), [ + [ + 1, + "b" + ], + [ + 1, + "a" + ], + [ + 1, + "b" + ], + [ + 2, + "a" + ] + ]); + let u$2 = [ + [ + 1, + "c" + ], + [ + 1, + "b" + ], + [ + 1, + "a" + ], + [ + 1, + "b" + ], + [ + 1, + "c" + ], + [ + 2, + "a" + ] + ]; + Test_utils.eq("File \"belt_sortarray_test.res\", line 101, characters 6-13", Belt_SortArray.stableSortBy(u$2, (param, param$1) => param[0] - param$1[0] | 0), [ + [ + 1, + "c" + ], + [ + 1, + "b" + ], + [ + 1, + "a" + ], + [ + 1, + "b" + ], + [ + 1, + "c" + ], + [ + 2, + "a" + ] + ]); + }); + Mocha.test("binarySearchBy", () => { + Test_utils.eq("File \"belt_sortarray_test.res\", line 108, characters 7-14", Pervasives.lnot(Belt_SortArray.binarySearchBy([ + 1, + 3, + 5, + 7 + ], 4, cmp)), 2); + Test_utils.eq("File \"belt_sortarray_test.res\", line 109, characters 7-14", Belt_SortArray.binarySearchBy([ + 1, + 2, + 3, + 4, + 33, + 35, + 36 + ], 33, cmp), 4); + Test_utils.eq("File \"belt_sortarray_test.res\", line 110, characters 7-14", Belt_SortArray.binarySearchBy([ + 1, + 2, + 3, + 4, + 33, + 35, + 36 + ], 1, cmp), 0); + Test_utils.eq("File \"belt_sortarray_test.res\", line 111, characters 7-14", Belt_SortArray.binarySearchBy([ + 1, + 2, + 3, + 4, + 33, + 35, + 36 + ], 2, cmp), 1); + Test_utils.eq("File \"belt_sortarray_test.res\", line 112, characters 7-14", Belt_SortArray.binarySearchBy([ + 1, + 2, + 3, + 4, + 33, + 35, + 36 + ], 3, cmp), 2); + Test_utils.eq("File \"belt_sortarray_test.res\", line 113, characters 7-14", Belt_SortArray.binarySearchBy([ + 1, + 2, + 3, + 4, + 33, + 35, + 36 + ], 4, cmp), 3); + let aa = Array_data_util.range(0, 1000); + Test_utils.ok("File \"belt_sortarray_test.res\", line 115, characters 7-14", Belt_Range.every(0, 1000, i => Belt_SortArray.binarySearchBy(aa, i, cmp) === i)); + let cc = Belt_Array.map(Array_data_util.range(0, 2000), x => (x << 1)); + Test_utils.eq("File \"belt_sortarray_test.res\", line 118, characters 7-14", Pervasives.lnot(Belt_SortArray.binarySearchBy(cc, 5000, cmp)), 2001); + Test_utils.eq("File \"belt_sortarray_test.res\", line 119, characters 7-14", Pervasives.lnot(Belt_SortArray.binarySearchBy(cc, -1, cmp)), 0); + Test_utils.eq("File \"belt_sortarray_test.res\", line 120, characters 7-14", Belt_SortArray.binarySearchBy(cc, 0, cmp), 0); + Test_utils.eq("File \"belt_sortarray_test.res\", line 122, characters 7-14", Pervasives.lnot(Belt_SortArray.binarySearchBy(cc, 1, cmp)), 1); + Test_utils.ok("File \"belt_sortarray_test.res\", line 124, characters 6-13", Belt_Range.every(0, 1999, i => Pervasives.lnot(Belt_SortArray.binarySearchBy(cc, (i << 1) + 1 | 0, cmp)) === (i + 1 | 0))); + }); + Mocha.test("strictlySortedLength", () => { + let lt = (x, y) => x < y; + Test_utils.eq("File \"belt_sortarray_test.res\", line 133, characters 7-14", Belt_SortArray.strictlySortedLength([], lt), 0); + Test_utils.eq("File \"belt_sortarray_test.res\", line 134, characters 7-14", Belt_SortArray.strictlySortedLength([1], lt), 1); + Test_utils.eq("File \"belt_sortarray_test.res\", line 135, characters 7-14", Belt_SortArray.strictlySortedLength([ + 1, + 1 + ], lt), 1); + Test_utils.eq("File \"belt_sortarray_test.res\", line 136, characters 7-14", Belt_SortArray.strictlySortedLength([ + 1, + 1, + 2 + ], lt), 1); + Test_utils.eq("File \"belt_sortarray_test.res\", line 137, characters 7-14", Belt_SortArray.strictlySortedLength([ + 1, + 2 + ], lt), 2); + Test_utils.eq("File \"belt_sortarray_test.res\", line 138, characters 7-14", Belt_SortArray.strictlySortedLength([ + 1, + 2, + 3, + 4, + 3 + ], lt), 4); + Test_utils.eq("File \"belt_sortarray_test.res\", line 139, characters 7-14", Belt_SortArray.strictlySortedLength([ + 4, + 4, + 3, + 2, + 1 + ], lt), 1); + Test_utils.eq("File \"belt_sortarray_test.res\", line 140, characters 7-14", Belt_SortArray.strictlySortedLength([ + 4, + 3, + 2, + 1 + ], lt), -4); + Test_utils.eq("File \"belt_sortarray_test.res\", line 141, characters 7-14", Belt_SortArray.strictlySortedLength([ + 4, + 3, + 2, + 1, + 0 + ], lt), -5); + }); +}); + +let I; + +let R; + +let A; + +let S; + +let SI; + +export { + I, + R, + A, + S, + SI, + cmp, + unions, + inters, + diffs, +} +/* Not a pure module */ diff --git a/tests/tests/src/bench.js b/tests/tests/src/bench.js deleted file mode 100644 index e1a94eab1c..0000000000 --- a/tests/tests/src/bench.js +++ /dev/null @@ -1,57 +0,0 @@ -// Generated by ReScript, PLEASE EDIT WITH CARE -'use strict'; - -let Belt_Array = require("rescript/lib/js/Belt_Array.js"); -let Pervasives = require("rescript/lib/js/Pervasives.js"); - -function map(f, a) { - let f$1 = x => f(x); - let l = a.length; - if (l === 0) { - return []; - } - let r = Belt_Array.make(l, f$1(a[0])); - for (let i = 1; i < l; ++i) { - r[i] = f$1(a[i]); - } - return r; -} - -function init(l, f) { - let f$1 = x => f(x); - if (l === 0) { - return []; - } - if (l < 0) { - return Pervasives.invalid_arg("Array.init"); - } - let res = Belt_Array.make(l, f$1(0)); - for (let i = 1; i < l; ++i) { - res[i] = f$1(i); - } - return res; -} - -function fold_left(f, x, a) { - let f$1 = (x, y) => f(x, y); - let r = x; - for (let i = 0, i_finish = a.length; i < i_finish; ++i) { - r = f$1(r, a[i]); - } - return r; -} - -function f2() { - let arr = init(3000000, i => i); - let b = map(i => i + i - 1, arr); - let v = fold_left((prim0, prim1) => prim0 + prim1, 0, b); - console.log("%f", v); -} - -f2(); - -exports.map = map; -exports.init = init; -exports.fold_left = fold_left; -exports.f2 = f2; -/* Not a pure module */ diff --git a/tests/tests/src/bench.mjs b/tests/tests/src/bench.mjs new file mode 100644 index 0000000000..d3009bf70a --- /dev/null +++ b/tests/tests/src/bench.mjs @@ -0,0 +1,58 @@ +// Generated by ReScript, PLEASE EDIT WITH CARE + +import * as Belt_Array from "rescript/lib/es6/Belt_Array.js"; +import * as Pervasives from "rescript/lib/es6/Pervasives.js"; + +function map(f, a) { + let f$1 = x => f(x); + let l = a.length; + if (l === 0) { + return []; + } + let r = Belt_Array.make(l, f$1(a[0])); + for (let i = 1; i < l; ++i) { + r[i] = f$1(a[i]); + } + return r; +} + +function init(l, f) { + let f$1 = x => f(x); + if (l === 0) { + return []; + } + if (l < 0) { + return Pervasives.invalid_arg("Array.init"); + } + let res = Belt_Array.make(l, f$1(0)); + for (let i = 1; i < l; ++i) { + res[i] = f$1(i); + } + return res; +} + +function fold_left(f, x, a) { + let f$1 = (x, y) => f(x, y); + let r = x; + for (let i = 0, i_finish = a.length; i < i_finish; ++i) { + r = f$1(r, a[i]); + } + return r; +} + +function f2() { + let arr = init(3000000, i => i); + let b = map(i => i + i - 1, arr); + let v = fold_left((prim0, prim1) => prim0 + prim1, 0, b); + console.log("%f", v); +} + +f2(); + +export { + map, + init, + fold_left, + f2, +} +/* Not a pure module */ diff --git a/tests/tests/src/big_enum.js b/tests/tests/src/big_enum.js deleted file mode 100644 index 108718e9cc..0000000000 --- a/tests/tests/src/big_enum.js +++ /dev/null @@ -1,1217 +0,0 @@ -// Generated by ReScript, PLEASE EDIT WITH CARE -'use strict'; - - -function to_enum(x) { - switch (x) { - case "A0" : - return 0; - case "A1" : - return 1; - case "A2" : - return 2; - case "A3" : - return 3; - case "A4" : - return 4; - case "A5" : - return 5; - case "A6" : - return 6; - case "A7" : - return 7; - case "A8" : - return 8; - case "A9" : - return 9; - case "A10" : - return 10; - case "A11" : - return 11; - case "A12" : - return 12; - case "A13" : - return 13; - case "A14" : - return 14; - case "A15" : - return 15; - case "A16" : - return 16; - case "A17" : - return 17; - case "A18" : - return 18; - case "A19" : - return 19; - case "A20" : - return 20; - case "A21" : - return 21; - case "A22" : - return 22; - case "A23" : - return 23; - case "A24" : - return 24; - case "A25" : - return 25; - case "A26" : - return 26; - case "A27" : - return 27; - case "A28" : - return 28; - case "A29" : - return 29; - case "A30" : - return 30; - case "A31" : - return 31; - case "A32" : - return 32; - case "A33" : - return 33; - case "A34" : - return 34; - case "A35" : - return 35; - case "A36" : - return 36; - case "A37" : - return 37; - case "A38" : - return 38; - case "A39" : - return 39; - case "A40" : - return 40; - case "A41" : - return 41; - case "A42" : - return 42; - case "A43" : - return 43; - case "A44" : - return 44; - case "A45" : - return 45; - case "A46" : - return 46; - case "A47" : - return 47; - case "A48" : - return 48; - case "A49" : - return 49; - case "A50" : - return 50; - case "A51" : - return 51; - case "A52" : - return 52; - case "A53" : - return 53; - case "A54" : - return 54; - case "A55" : - return 55; - case "A56" : - return 56; - case "A57" : - return 57; - case "A58" : - return 58; - case "A59" : - return 59; - case "A60" : - return 60; - case "A61" : - return 61; - case "A62" : - return 62; - case "A63" : - return 63; - case "A64" : - return 64; - case "A65" : - return 65; - case "A66" : - return 66; - case "A67" : - return 67; - case "A68" : - return 68; - case "A69" : - return 69; - case "A70" : - return 70; - case "A71" : - return 71; - case "A72" : - return 72; - case "A73" : - return 73; - case "A74" : - return 74; - case "A75" : - return 75; - case "A76" : - return 76; - case "A77" : - return 77; - case "A78" : - return 78; - case "A79" : - return 79; - case "A80" : - return 80; - case "A81" : - return 81; - case "A82" : - return 82; - case "A83" : - return 83; - case "A84" : - return 84; - case "A85" : - return 85; - case "A86" : - return 86; - case "A87" : - return 87; - case "A88" : - return 88; - case "A89" : - return 89; - case "A90" : - return 90; - case "A91" : - return 91; - case "A92" : - return 92; - case "A93" : - return 93; - case "A94" : - return 94; - case "A95" : - return 95; - case "A96" : - return 96; - case "A97" : - return 97; - case "A98" : - return 98; - case "A99" : - return 99; - case "A100" : - return 100; - case "A101" : - return 101; - case "A102" : - return 102; - case "A103" : - return 103; - case "A104" : - return 104; - case "A105" : - return 105; - case "A106" : - return 106; - case "A107" : - return 107; - case "A108" : - return 108; - case "A109" : - return 109; - case "A110" : - return 110; - case "A111" : - return 111; - case "A112" : - return 112; - case "A113" : - return 113; - case "A114" : - return 114; - case "A115" : - return 115; - case "A116" : - return 116; - case "A117" : - return 117; - case "A118" : - return 118; - case "A119" : - return 119; - case "A120" : - return 120; - case "A121" : - return 121; - case "A122" : - return 122; - case "A123" : - return 123; - case "A124" : - return 124; - case "A125" : - return 125; - case "A126" : - return 126; - case "A127" : - return 127; - case "A128" : - return 128; - case "A129" : - return 129; - case "A130" : - return 130; - case "A131" : - return 131; - case "A132" : - return 132; - case "A133" : - return 133; - case "A134" : - return 134; - case "A135" : - return 135; - case "A136" : - return 136; - case "A137" : - return 137; - case "A138" : - return 138; - case "A139" : - return 139; - case "A140" : - return 140; - case "A141" : - return 141; - case "A142" : - return 142; - case "A143" : - return 143; - case "A144" : - return 144; - case "A145" : - return 145; - case "A146" : - return 146; - case "A147" : - return 147; - case "A148" : - return 148; - case "A149" : - return 149; - case "A150" : - return 150; - case "A151" : - return 151; - case "A152" : - return 152; - case "A153" : - return 153; - case "A154" : - return 154; - case "A155" : - return 155; - case "A156" : - return 156; - case "A157" : - return 157; - case "A158" : - return 158; - case "A159" : - return 159; - case "A160" : - return 160; - case "A161" : - return 161; - case "A162" : - return 162; - case "A163" : - return 163; - case "A164" : - return 164; - case "A165" : - return 165; - case "A166" : - return 166; - case "A167" : - return 167; - case "A168" : - return 168; - case "A169" : - return 169; - case "A170" : - return 170; - case "A171" : - return 171; - case "A172" : - return 172; - case "A173" : - return 173; - case "A174" : - return 174; - case "A175" : - return 175; - case "A176" : - return 176; - case "A177" : - return 177; - case "A178" : - return 178; - case "A179" : - return 179; - case "A180" : - return 180; - case "A181" : - return 181; - case "A182" : - return 182; - case "A183" : - return 183; - case "A184" : - return 184; - case "A185" : - return 185; - case "A186" : - return 186; - case "A187" : - return 187; - case "A188" : - return 188; - case "A189" : - return 189; - case "A190" : - return 190; - case "A191" : - return 191; - case "A192" : - return 192; - case "A193" : - return 193; - case "A194" : - return 194; - case "A195" : - return 195; - case "A196" : - return 196; - case "A197" : - return 197; - case "A198" : - return 198; - case "A199" : - return 199; - case "A200" : - return 200; - case "A201" : - return 201; - case "A202" : - return 202; - case "A203" : - return 203; - case "A204" : - return 204; - case "A205" : - return 205; - case "A206" : - return 206; - case "A207" : - return 207; - case "A208" : - return 208; - case "A209" : - return 209; - case "A210" : - return 210; - case "A211" : - return 211; - case "A212" : - return 212; - case "A213" : - return 213; - case "A214" : - return 214; - case "A215" : - return 215; - case "A216" : - return 216; - case "A217" : - return 217; - case "A218" : - return 218; - case "A219" : - return 219; - case "A220" : - return 220; - case "A221" : - return 221; - case "A222" : - return 222; - case "A223" : - return 223; - case "A224" : - return 224; - case "A225" : - return 225; - case "A226" : - return 226; - case "A227" : - return 227; - case "A228" : - return 228; - case "A229" : - return 229; - case "A230" : - return 230; - case "A231" : - return 231; - case "A232" : - return 232; - case "A233" : - return 233; - case "A234" : - return 234; - case "A235" : - return 235; - case "A236" : - return 236; - case "A237" : - return 237; - case "A238" : - return 238; - case "A239" : - return 239; - case "A240" : - return 240; - case "A241" : - return 241; - case "A242" : - return 242; - case "A243" : - return 243; - case "A244" : - return 244; - case "A245" : - return 245; - case "A246" : - return 246; - case "A247" : - return 247; - case "A248" : - return 248; - case "A249" : - return 249; - case "A250" : - return 250; - case "A251" : - return 251; - case "A252" : - return 252; - case "A253" : - return 253; - case "A254" : - return 254; - case "A255" : - return 255; - case "A256" : - return 256; - case "A257" : - return 257; - case "A258" : - return 258; - case "A259" : - return 259; - case "A260" : - return 260; - case "A261" : - return 261; - case "A262" : - return 262; - case "A263" : - return 263; - case "A264" : - return 264; - case "A265" : - return 265; - case "A266" : - return 266; - case "A267" : - return 267; - case "A268" : - return 268; - case "A269" : - return 269; - case "A270" : - return 270; - case "A271" : - return 271; - case "A272" : - return 272; - case "A273" : - return 273; - case "A274" : - return 274; - case "A275" : - return 275; - case "A276" : - return 276; - case "A277" : - return 277; - case "A278" : - return 278; - case "A279" : - return 279; - case "A280" : - return 280; - case "A281" : - return 281; - case "A282" : - return 282; - case "A283" : - return 283; - case "A284" : - return 284; - case "A285" : - return 285; - case "A286" : - return 286; - case "A287" : - return 287; - case "A288" : - return 288; - case "A289" : - return 289; - case "A290" : - return 290; - case "A291" : - return 291; - case "A292" : - return 292; - case "A293" : - return 293; - case "A294" : - return 294; - case "A295" : - return 295; - case "A296" : - return 296; - case "A297" : - return 297; - case "A298" : - return 298; - case "A299" : - return 299; - } -} - -function to_string(x) { - switch (x) { - case "A0" : - return "A0"; - case "A1" : - return "A1"; - case "A2" : - return "A2"; - case "A3" : - return "A3"; - case "A4" : - return "A4"; - case "A5" : - return "A5"; - case "A6" : - return "A6"; - case "A7" : - return "A7"; - case "A8" : - return "A8"; - case "A9" : - return "A9"; - case "A10" : - return "A10"; - case "A11" : - return "A11"; - case "A12" : - return "A12"; - case "A13" : - return "A13"; - case "A14" : - return "A14"; - case "A15" : - return "A15"; - case "A16" : - return "A16"; - case "A17" : - return "A17"; - case "A18" : - return "A18"; - case "A19" : - return "A19"; - case "A20" : - return "A20"; - case "A21" : - return "A21"; - case "A22" : - return "A22"; - case "A23" : - return "A23"; - case "A24" : - return "A24"; - case "A25" : - return "A25"; - case "A26" : - return "A26"; - case "A27" : - return "A27"; - case "A28" : - return "A28"; - case "A29" : - return "A29"; - case "A30" : - return "A30"; - case "A31" : - return "A31"; - case "A32" : - return "A32"; - case "A33" : - return "A33"; - case "A34" : - return "A34"; - case "A35" : - return "A35"; - case "A36" : - return "A36"; - case "A37" : - return "A37"; - case "A38" : - return "A38"; - case "A39" : - return "A39"; - case "A40" : - return "A40"; - case "A41" : - return "A41"; - case "A42" : - return "A42"; - case "A43" : - return "A43"; - case "A44" : - return "A44"; - case "A45" : - return "A45"; - case "A46" : - return "A46"; - case "A47" : - return "A47"; - case "A48" : - return "A48"; - case "A49" : - return "A49"; - case "A50" : - return "A50"; - case "A51" : - return "A51"; - case "A52" : - return "A52"; - case "A53" : - return "A53"; - case "A54" : - return "A54"; - case "A55" : - return "A55"; - case "A56" : - return "A56"; - case "A57" : - return "A57"; - case "A58" : - return "A58"; - case "A59" : - return "A59"; - case "A60" : - return "A60"; - case "A61" : - return "A61"; - case "A62" : - return "A62"; - case "A63" : - return "A63"; - case "A64" : - return "A64"; - case "A65" : - return "A65"; - case "A66" : - return "A66"; - case "A67" : - return "A67"; - case "A68" : - return "A68"; - case "A69" : - return "A69"; - case "A70" : - return "A70"; - case "A71" : - return "A71"; - case "A72" : - return "A72"; - case "A73" : - return "A73"; - case "A74" : - return "A74"; - case "A75" : - return "A75"; - case "A76" : - return "A76"; - case "A77" : - return "A77"; - case "A78" : - return "A78"; - case "A79" : - return "A79"; - case "A80" : - return "A80"; - case "A81" : - return "A81"; - case "A82" : - return "A82"; - case "A83" : - return "A83"; - case "A84" : - return "A84"; - case "A85" : - return "A85"; - case "A86" : - return "A86"; - case "A87" : - return "A87"; - case "A88" : - return "A88"; - case "A89" : - return "A89"; - case "A90" : - return "A90"; - case "A91" : - return "A91"; - case "A92" : - return "A92"; - case "A93" : - return "A93"; - case "A94" : - return "A94"; - case "A95" : - return "A95"; - case "A96" : - return "A96"; - case "A97" : - return "A97"; - case "A98" : - return "A98"; - case "A99" : - return "A99"; - case "A100" : - return "A100"; - case "A101" : - return "A101"; - case "A102" : - return "A102"; - case "A103" : - return "A103"; - case "A104" : - return "A104"; - case "A105" : - return "A105"; - case "A106" : - return "A106"; - case "A107" : - return "A107"; - case "A108" : - return "A108"; - case "A109" : - return "A109"; - case "A110" : - return "A110"; - case "A111" : - return "A111"; - case "A112" : - return "A112"; - case "A113" : - return "A113"; - case "A114" : - return "A114"; - case "A115" : - return "A115"; - case "A116" : - return "A116"; - case "A117" : - return "A117"; - case "A118" : - return "A118"; - case "A119" : - return "A119"; - case "A120" : - return "A120"; - case "A121" : - return "A121"; - case "A122" : - return "A122"; - case "A123" : - return "A123"; - case "A124" : - return "A124"; - case "A125" : - return "A125"; - case "A126" : - return "A126"; - case "A127" : - return "A127"; - case "A128" : - return "A128"; - case "A129" : - return "A129"; - case "A130" : - return "A130"; - case "A131" : - return "A131"; - case "A132" : - return "A132"; - case "A133" : - return "A133"; - case "A134" : - return "A134"; - case "A135" : - return "A135"; - case "A136" : - return "A136"; - case "A137" : - return "A137"; - case "A138" : - return "A138"; - case "A139" : - return "A139"; - case "A140" : - return "A140"; - case "A141" : - return "A141"; - case "A142" : - return "A142"; - case "A143" : - return "A143"; - case "A144" : - return "A144"; - case "A145" : - return "A145"; - case "A146" : - return "A146"; - case "A147" : - return "A147"; - case "A148" : - return "A148"; - case "A149" : - return "A149"; - case "A150" : - return "A150"; - case "A151" : - return "A151"; - case "A152" : - return "A152"; - case "A153" : - return "A153"; - case "A154" : - return "A154"; - case "A155" : - return "A155"; - case "A156" : - return "A156"; - case "A157" : - return "A157"; - case "A158" : - return "A158"; - case "A159" : - return "A159"; - case "A160" : - return "A160"; - case "A161" : - return "A161"; - case "A162" : - return "A162"; - case "A163" : - return "A163"; - case "A164" : - return "A164"; - case "A165" : - return "A165"; - case "A166" : - return "A166"; - case "A167" : - return "A167"; - case "A168" : - return "A168"; - case "A169" : - return "A169"; - case "A170" : - return "A170"; - case "A171" : - return "A171"; - case "A172" : - return "A172"; - case "A173" : - return "A173"; - case "A174" : - return "A174"; - case "A175" : - return "A175"; - case "A176" : - return "A176"; - case "A177" : - return "A177"; - case "A178" : - return "A178"; - case "A179" : - return "A179"; - case "A180" : - return "A180"; - case "A181" : - return "A181"; - case "A182" : - return "A182"; - case "A183" : - return "A183"; - case "A184" : - return "A184"; - case "A185" : - return "A185"; - case "A186" : - return "A186"; - case "A187" : - return "A187"; - case "A188" : - return "A188"; - case "A189" : - return "A189"; - case "A190" : - return "A190"; - case "A191" : - return "A191"; - case "A192" : - return "A192"; - case "A193" : - return "A193"; - case "A194" : - return "A194"; - case "A195" : - return "A195"; - case "A196" : - return "A196"; - case "A197" : - return "A197"; - case "A198" : - return "A198"; - case "A199" : - return "A199"; - case "A200" : - return "A200"; - case "A201" : - return "A201"; - case "A202" : - return "A202"; - case "A203" : - return "A203"; - case "A204" : - return "A204"; - case "A205" : - return "A205"; - case "A206" : - return "A206"; - case "A207" : - return "A207"; - case "A208" : - return "A208"; - case "A209" : - return "A209"; - case "A210" : - return "A210"; - case "A211" : - return "A211"; - case "A212" : - return "A212"; - case "A213" : - return "A213"; - case "A214" : - return "A214"; - case "A215" : - return "A215"; - case "A216" : - return "A216"; - case "A217" : - return "A217"; - case "A218" : - return "A218"; - case "A219" : - return "A219"; - case "A220" : - return "A220"; - case "A221" : - return "A221"; - case "A222" : - return "A222"; - case "A223" : - return "A223"; - case "A224" : - return "A224"; - case "A225" : - return "A225"; - case "A226" : - return "A226"; - case "A227" : - return "A227"; - case "A228" : - return "A228"; - case "A229" : - return "A229"; - case "A230" : - return "A230"; - case "A231" : - return "A231"; - case "A232" : - return "A232"; - case "A233" : - return "A233"; - case "A234" : - return "A234"; - case "A235" : - return "A235"; - case "A236" : - return "A236"; - case "A237" : - return "A237"; - case "A238" : - return "A238"; - case "A239" : - return "A239"; - case "A240" : - return "A240"; - case "A241" : - return "A241"; - case "A242" : - return "A242"; - case "A243" : - return "A243"; - case "A244" : - return "A244"; - case "A245" : - return "A245"; - case "A246" : - return "A246"; - case "A247" : - return "A247"; - case "A248" : - return "A248"; - case "A249" : - return "A249"; - case "A250" : - return "A250"; - case "A251" : - return "A251"; - case "A252" : - return "A252"; - case "A253" : - return "A253"; - case "A254" : - return "A254"; - case "A255" : - return "A255"; - case "A256" : - return "A256"; - case "A257" : - return "A257"; - case "A258" : - return "A258"; - case "A259" : - return "A259"; - case "A260" : - return "A260"; - case "A261" : - return "A261"; - case "A262" : - return "A262"; - case "A263" : - return "A263"; - case "A264" : - return "A264"; - case "A265" : - return "A265"; - case "A266" : - return "A266"; - case "A267" : - return "A267"; - case "A268" : - return "A268"; - case "A269" : - return "A269"; - case "A270" : - return "A270"; - case "A271" : - return "A271"; - case "A272" : - return "A272"; - case "A273" : - return "A273"; - case "A274" : - return "A274"; - case "A275" : - return "A275"; - case "A276" : - return "A276"; - case "A277" : - return "A277"; - case "A278" : - return "A278"; - case "A279" : - return "A279"; - case "A280" : - return "A280"; - case "A281" : - return "A281"; - case "A282" : - return "A282"; - case "A283" : - return "A283"; - case "A284" : - return "A284"; - case "A285" : - return "A285"; - case "A286" : - return "A286"; - case "A287" : - return "A287"; - case "A288" : - return "A288"; - case "A289" : - return "A289"; - case "A290" : - return "A290"; - case "A291" : - return "A291"; - case "A292" : - return "A292"; - case "A293" : - return "A293"; - case "A294" : - return "A294"; - case "A295" : - return "A295"; - case "A296" : - return "A296"; - case "A297" : - return "A297"; - case "A298" : - return "A298"; - case "A299" : - return "A299"; - } -} - -exports.to_enum = to_enum; -exports.to_string = to_string; -/* No side effect */ diff --git a/tests/tests/src/big_enum.mjs b/tests/tests/src/big_enum.mjs new file mode 100644 index 0000000000..3e9964fed1 --- /dev/null +++ b/tests/tests/src/big_enum.mjs @@ -0,0 +1,1218 @@ +// Generated by ReScript, PLEASE EDIT WITH CARE + + +function to_enum(x) { + switch (x) { + case "A0" : + return 0; + case "A1" : + return 1; + case "A2" : + return 2; + case "A3" : + return 3; + case "A4" : + return 4; + case "A5" : + return 5; + case "A6" : + return 6; + case "A7" : + return 7; + case "A8" : + return 8; + case "A9" : + return 9; + case "A10" : + return 10; + case "A11" : + return 11; + case "A12" : + return 12; + case "A13" : + return 13; + case "A14" : + return 14; + case "A15" : + return 15; + case "A16" : + return 16; + case "A17" : + return 17; + case "A18" : + return 18; + case "A19" : + return 19; + case "A20" : + return 20; + case "A21" : + return 21; + case "A22" : + return 22; + case "A23" : + return 23; + case "A24" : + return 24; + case "A25" : + return 25; + case "A26" : + return 26; + case "A27" : + return 27; + case "A28" : + return 28; + case "A29" : + return 29; + case "A30" : + return 30; + case "A31" : + return 31; + case "A32" : + return 32; + case "A33" : + return 33; + case "A34" : + return 34; + case "A35" : + return 35; + case "A36" : + return 36; + case "A37" : + return 37; + case "A38" : + return 38; + case "A39" : + return 39; + case "A40" : + return 40; + case "A41" : + return 41; + case "A42" : + return 42; + case "A43" : + return 43; + case "A44" : + return 44; + case "A45" : + return 45; + case "A46" : + return 46; + case "A47" : + return 47; + case "A48" : + return 48; + case "A49" : + return 49; + case "A50" : + return 50; + case "A51" : + return 51; + case "A52" : + return 52; + case "A53" : + return 53; + case "A54" : + return 54; + case "A55" : + return 55; + case "A56" : + return 56; + case "A57" : + return 57; + case "A58" : + return 58; + case "A59" : + return 59; + case "A60" : + return 60; + case "A61" : + return 61; + case "A62" : + return 62; + case "A63" : + return 63; + case "A64" : + return 64; + case "A65" : + return 65; + case "A66" : + return 66; + case "A67" : + return 67; + case "A68" : + return 68; + case "A69" : + return 69; + case "A70" : + return 70; + case "A71" : + return 71; + case "A72" : + return 72; + case "A73" : + return 73; + case "A74" : + return 74; + case "A75" : + return 75; + case "A76" : + return 76; + case "A77" : + return 77; + case "A78" : + return 78; + case "A79" : + return 79; + case "A80" : + return 80; + case "A81" : + return 81; + case "A82" : + return 82; + case "A83" : + return 83; + case "A84" : + return 84; + case "A85" : + return 85; + case "A86" : + return 86; + case "A87" : + return 87; + case "A88" : + return 88; + case "A89" : + return 89; + case "A90" : + return 90; + case "A91" : + return 91; + case "A92" : + return 92; + case "A93" : + return 93; + case "A94" : + return 94; + case "A95" : + return 95; + case "A96" : + return 96; + case "A97" : + return 97; + case "A98" : + return 98; + case "A99" : + return 99; + case "A100" : + return 100; + case "A101" : + return 101; + case "A102" : + return 102; + case "A103" : + return 103; + case "A104" : + return 104; + case "A105" : + return 105; + case "A106" : + return 106; + case "A107" : + return 107; + case "A108" : + return 108; + case "A109" : + return 109; + case "A110" : + return 110; + case "A111" : + return 111; + case "A112" : + return 112; + case "A113" : + return 113; + case "A114" : + return 114; + case "A115" : + return 115; + case "A116" : + return 116; + case "A117" : + return 117; + case "A118" : + return 118; + case "A119" : + return 119; + case "A120" : + return 120; + case "A121" : + return 121; + case "A122" : + return 122; + case "A123" : + return 123; + case "A124" : + return 124; + case "A125" : + return 125; + case "A126" : + return 126; + case "A127" : + return 127; + case "A128" : + return 128; + case "A129" : + return 129; + case "A130" : + return 130; + case "A131" : + return 131; + case "A132" : + return 132; + case "A133" : + return 133; + case "A134" : + return 134; + case "A135" : + return 135; + case "A136" : + return 136; + case "A137" : + return 137; + case "A138" : + return 138; + case "A139" : + return 139; + case "A140" : + return 140; + case "A141" : + return 141; + case "A142" : + return 142; + case "A143" : + return 143; + case "A144" : + return 144; + case "A145" : + return 145; + case "A146" : + return 146; + case "A147" : + return 147; + case "A148" : + return 148; + case "A149" : + return 149; + case "A150" : + return 150; + case "A151" : + return 151; + case "A152" : + return 152; + case "A153" : + return 153; + case "A154" : + return 154; + case "A155" : + return 155; + case "A156" : + return 156; + case "A157" : + return 157; + case "A158" : + return 158; + case "A159" : + return 159; + case "A160" : + return 160; + case "A161" : + return 161; + case "A162" : + return 162; + case "A163" : + return 163; + case "A164" : + return 164; + case "A165" : + return 165; + case "A166" : + return 166; + case "A167" : + return 167; + case "A168" : + return 168; + case "A169" : + return 169; + case "A170" : + return 170; + case "A171" : + return 171; + case "A172" : + return 172; + case "A173" : + return 173; + case "A174" : + return 174; + case "A175" : + return 175; + case "A176" : + return 176; + case "A177" : + return 177; + case "A178" : + return 178; + case "A179" : + return 179; + case "A180" : + return 180; + case "A181" : + return 181; + case "A182" : + return 182; + case "A183" : + return 183; + case "A184" : + return 184; + case "A185" : + return 185; + case "A186" : + return 186; + case "A187" : + return 187; + case "A188" : + return 188; + case "A189" : + return 189; + case "A190" : + return 190; + case "A191" : + return 191; + case "A192" : + return 192; + case "A193" : + return 193; + case "A194" : + return 194; + case "A195" : + return 195; + case "A196" : + return 196; + case "A197" : + return 197; + case "A198" : + return 198; + case "A199" : + return 199; + case "A200" : + return 200; + case "A201" : + return 201; + case "A202" : + return 202; + case "A203" : + return 203; + case "A204" : + return 204; + case "A205" : + return 205; + case "A206" : + return 206; + case "A207" : + return 207; + case "A208" : + return 208; + case "A209" : + return 209; + case "A210" : + return 210; + case "A211" : + return 211; + case "A212" : + return 212; + case "A213" : + return 213; + case "A214" : + return 214; + case "A215" : + return 215; + case "A216" : + return 216; + case "A217" : + return 217; + case "A218" : + return 218; + case "A219" : + return 219; + case "A220" : + return 220; + case "A221" : + return 221; + case "A222" : + return 222; + case "A223" : + return 223; + case "A224" : + return 224; + case "A225" : + return 225; + case "A226" : + return 226; + case "A227" : + return 227; + case "A228" : + return 228; + case "A229" : + return 229; + case "A230" : + return 230; + case "A231" : + return 231; + case "A232" : + return 232; + case "A233" : + return 233; + case "A234" : + return 234; + case "A235" : + return 235; + case "A236" : + return 236; + case "A237" : + return 237; + case "A238" : + return 238; + case "A239" : + return 239; + case "A240" : + return 240; + case "A241" : + return 241; + case "A242" : + return 242; + case "A243" : + return 243; + case "A244" : + return 244; + case "A245" : + return 245; + case "A246" : + return 246; + case "A247" : + return 247; + case "A248" : + return 248; + case "A249" : + return 249; + case "A250" : + return 250; + case "A251" : + return 251; + case "A252" : + return 252; + case "A253" : + return 253; + case "A254" : + return 254; + case "A255" : + return 255; + case "A256" : + return 256; + case "A257" : + return 257; + case "A258" : + return 258; + case "A259" : + return 259; + case "A260" : + return 260; + case "A261" : + return 261; + case "A262" : + return 262; + case "A263" : + return 263; + case "A264" : + return 264; + case "A265" : + return 265; + case "A266" : + return 266; + case "A267" : + return 267; + case "A268" : + return 268; + case "A269" : + return 269; + case "A270" : + return 270; + case "A271" : + return 271; + case "A272" : + return 272; + case "A273" : + return 273; + case "A274" : + return 274; + case "A275" : + return 275; + case "A276" : + return 276; + case "A277" : + return 277; + case "A278" : + return 278; + case "A279" : + return 279; + case "A280" : + return 280; + case "A281" : + return 281; + case "A282" : + return 282; + case "A283" : + return 283; + case "A284" : + return 284; + case "A285" : + return 285; + case "A286" : + return 286; + case "A287" : + return 287; + case "A288" : + return 288; + case "A289" : + return 289; + case "A290" : + return 290; + case "A291" : + return 291; + case "A292" : + return 292; + case "A293" : + return 293; + case "A294" : + return 294; + case "A295" : + return 295; + case "A296" : + return 296; + case "A297" : + return 297; + case "A298" : + return 298; + case "A299" : + return 299; + } +} + +function to_string(x) { + switch (x) { + case "A0" : + return "A0"; + case "A1" : + return "A1"; + case "A2" : + return "A2"; + case "A3" : + return "A3"; + case "A4" : + return "A4"; + case "A5" : + return "A5"; + case "A6" : + return "A6"; + case "A7" : + return "A7"; + case "A8" : + return "A8"; + case "A9" : + return "A9"; + case "A10" : + return "A10"; + case "A11" : + return "A11"; + case "A12" : + return "A12"; + case "A13" : + return "A13"; + case "A14" : + return "A14"; + case "A15" : + return "A15"; + case "A16" : + return "A16"; + case "A17" : + return "A17"; + case "A18" : + return "A18"; + case "A19" : + return "A19"; + case "A20" : + return "A20"; + case "A21" : + return "A21"; + case "A22" : + return "A22"; + case "A23" : + return "A23"; + case "A24" : + return "A24"; + case "A25" : + return "A25"; + case "A26" : + return "A26"; + case "A27" : + return "A27"; + case "A28" : + return "A28"; + case "A29" : + return "A29"; + case "A30" : + return "A30"; + case "A31" : + return "A31"; + case "A32" : + return "A32"; + case "A33" : + return "A33"; + case "A34" : + return "A34"; + case "A35" : + return "A35"; + case "A36" : + return "A36"; + case "A37" : + return "A37"; + case "A38" : + return "A38"; + case "A39" : + return "A39"; + case "A40" : + return "A40"; + case "A41" : + return "A41"; + case "A42" : + return "A42"; + case "A43" : + return "A43"; + case "A44" : + return "A44"; + case "A45" : + return "A45"; + case "A46" : + return "A46"; + case "A47" : + return "A47"; + case "A48" : + return "A48"; + case "A49" : + return "A49"; + case "A50" : + return "A50"; + case "A51" : + return "A51"; + case "A52" : + return "A52"; + case "A53" : + return "A53"; + case "A54" : + return "A54"; + case "A55" : + return "A55"; + case "A56" : + return "A56"; + case "A57" : + return "A57"; + case "A58" : + return "A58"; + case "A59" : + return "A59"; + case "A60" : + return "A60"; + case "A61" : + return "A61"; + case "A62" : + return "A62"; + case "A63" : + return "A63"; + case "A64" : + return "A64"; + case "A65" : + return "A65"; + case "A66" : + return "A66"; + case "A67" : + return "A67"; + case "A68" : + return "A68"; + case "A69" : + return "A69"; + case "A70" : + return "A70"; + case "A71" : + return "A71"; + case "A72" : + return "A72"; + case "A73" : + return "A73"; + case "A74" : + return "A74"; + case "A75" : + return "A75"; + case "A76" : + return "A76"; + case "A77" : + return "A77"; + case "A78" : + return "A78"; + case "A79" : + return "A79"; + case "A80" : + return "A80"; + case "A81" : + return "A81"; + case "A82" : + return "A82"; + case "A83" : + return "A83"; + case "A84" : + return "A84"; + case "A85" : + return "A85"; + case "A86" : + return "A86"; + case "A87" : + return "A87"; + case "A88" : + return "A88"; + case "A89" : + return "A89"; + case "A90" : + return "A90"; + case "A91" : + return "A91"; + case "A92" : + return "A92"; + case "A93" : + return "A93"; + case "A94" : + return "A94"; + case "A95" : + return "A95"; + case "A96" : + return "A96"; + case "A97" : + return "A97"; + case "A98" : + return "A98"; + case "A99" : + return "A99"; + case "A100" : + return "A100"; + case "A101" : + return "A101"; + case "A102" : + return "A102"; + case "A103" : + return "A103"; + case "A104" : + return "A104"; + case "A105" : + return "A105"; + case "A106" : + return "A106"; + case "A107" : + return "A107"; + case "A108" : + return "A108"; + case "A109" : + return "A109"; + case "A110" : + return "A110"; + case "A111" : + return "A111"; + case "A112" : + return "A112"; + case "A113" : + return "A113"; + case "A114" : + return "A114"; + case "A115" : + return "A115"; + case "A116" : + return "A116"; + case "A117" : + return "A117"; + case "A118" : + return "A118"; + case "A119" : + return "A119"; + case "A120" : + return "A120"; + case "A121" : + return "A121"; + case "A122" : + return "A122"; + case "A123" : + return "A123"; + case "A124" : + return "A124"; + case "A125" : + return "A125"; + case "A126" : + return "A126"; + case "A127" : + return "A127"; + case "A128" : + return "A128"; + case "A129" : + return "A129"; + case "A130" : + return "A130"; + case "A131" : + return "A131"; + case "A132" : + return "A132"; + case "A133" : + return "A133"; + case "A134" : + return "A134"; + case "A135" : + return "A135"; + case "A136" : + return "A136"; + case "A137" : + return "A137"; + case "A138" : + return "A138"; + case "A139" : + return "A139"; + case "A140" : + return "A140"; + case "A141" : + return "A141"; + case "A142" : + return "A142"; + case "A143" : + return "A143"; + case "A144" : + return "A144"; + case "A145" : + return "A145"; + case "A146" : + return "A146"; + case "A147" : + return "A147"; + case "A148" : + return "A148"; + case "A149" : + return "A149"; + case "A150" : + return "A150"; + case "A151" : + return "A151"; + case "A152" : + return "A152"; + case "A153" : + return "A153"; + case "A154" : + return "A154"; + case "A155" : + return "A155"; + case "A156" : + return "A156"; + case "A157" : + return "A157"; + case "A158" : + return "A158"; + case "A159" : + return "A159"; + case "A160" : + return "A160"; + case "A161" : + return "A161"; + case "A162" : + return "A162"; + case "A163" : + return "A163"; + case "A164" : + return "A164"; + case "A165" : + return "A165"; + case "A166" : + return "A166"; + case "A167" : + return "A167"; + case "A168" : + return "A168"; + case "A169" : + return "A169"; + case "A170" : + return "A170"; + case "A171" : + return "A171"; + case "A172" : + return "A172"; + case "A173" : + return "A173"; + case "A174" : + return "A174"; + case "A175" : + return "A175"; + case "A176" : + return "A176"; + case "A177" : + return "A177"; + case "A178" : + return "A178"; + case "A179" : + return "A179"; + case "A180" : + return "A180"; + case "A181" : + return "A181"; + case "A182" : + return "A182"; + case "A183" : + return "A183"; + case "A184" : + return "A184"; + case "A185" : + return "A185"; + case "A186" : + return "A186"; + case "A187" : + return "A187"; + case "A188" : + return "A188"; + case "A189" : + return "A189"; + case "A190" : + return "A190"; + case "A191" : + return "A191"; + case "A192" : + return "A192"; + case "A193" : + return "A193"; + case "A194" : + return "A194"; + case "A195" : + return "A195"; + case "A196" : + return "A196"; + case "A197" : + return "A197"; + case "A198" : + return "A198"; + case "A199" : + return "A199"; + case "A200" : + return "A200"; + case "A201" : + return "A201"; + case "A202" : + return "A202"; + case "A203" : + return "A203"; + case "A204" : + return "A204"; + case "A205" : + return "A205"; + case "A206" : + return "A206"; + case "A207" : + return "A207"; + case "A208" : + return "A208"; + case "A209" : + return "A209"; + case "A210" : + return "A210"; + case "A211" : + return "A211"; + case "A212" : + return "A212"; + case "A213" : + return "A213"; + case "A214" : + return "A214"; + case "A215" : + return "A215"; + case "A216" : + return "A216"; + case "A217" : + return "A217"; + case "A218" : + return "A218"; + case "A219" : + return "A219"; + case "A220" : + return "A220"; + case "A221" : + return "A221"; + case "A222" : + return "A222"; + case "A223" : + return "A223"; + case "A224" : + return "A224"; + case "A225" : + return "A225"; + case "A226" : + return "A226"; + case "A227" : + return "A227"; + case "A228" : + return "A228"; + case "A229" : + return "A229"; + case "A230" : + return "A230"; + case "A231" : + return "A231"; + case "A232" : + return "A232"; + case "A233" : + return "A233"; + case "A234" : + return "A234"; + case "A235" : + return "A235"; + case "A236" : + return "A236"; + case "A237" : + return "A237"; + case "A238" : + return "A238"; + case "A239" : + return "A239"; + case "A240" : + return "A240"; + case "A241" : + return "A241"; + case "A242" : + return "A242"; + case "A243" : + return "A243"; + case "A244" : + return "A244"; + case "A245" : + return "A245"; + case "A246" : + return "A246"; + case "A247" : + return "A247"; + case "A248" : + return "A248"; + case "A249" : + return "A249"; + case "A250" : + return "A250"; + case "A251" : + return "A251"; + case "A252" : + return "A252"; + case "A253" : + return "A253"; + case "A254" : + return "A254"; + case "A255" : + return "A255"; + case "A256" : + return "A256"; + case "A257" : + return "A257"; + case "A258" : + return "A258"; + case "A259" : + return "A259"; + case "A260" : + return "A260"; + case "A261" : + return "A261"; + case "A262" : + return "A262"; + case "A263" : + return "A263"; + case "A264" : + return "A264"; + case "A265" : + return "A265"; + case "A266" : + return "A266"; + case "A267" : + return "A267"; + case "A268" : + return "A268"; + case "A269" : + return "A269"; + case "A270" : + return "A270"; + case "A271" : + return "A271"; + case "A272" : + return "A272"; + case "A273" : + return "A273"; + case "A274" : + return "A274"; + case "A275" : + return "A275"; + case "A276" : + return "A276"; + case "A277" : + return "A277"; + case "A278" : + return "A278"; + case "A279" : + return "A279"; + case "A280" : + return "A280"; + case "A281" : + return "A281"; + case "A282" : + return "A282"; + case "A283" : + return "A283"; + case "A284" : + return "A284"; + case "A285" : + return "A285"; + case "A286" : + return "A286"; + case "A287" : + return "A287"; + case "A288" : + return "A288"; + case "A289" : + return "A289"; + case "A290" : + return "A290"; + case "A291" : + return "A291"; + case "A292" : + return "A292"; + case "A293" : + return "A293"; + case "A294" : + return "A294"; + case "A295" : + return "A295"; + case "A296" : + return "A296"; + case "A297" : + return "A297"; + case "A298" : + return "A298"; + case "A299" : + return "A299"; + } +} + +export { + to_enum, + to_string, +} +/* No side effect */ diff --git a/tests/tests/src/big_polyvar_test.js b/tests/tests/src/big_polyvar_test.js deleted file mode 100644 index 20c276f20f..0000000000 --- a/tests/tests/src/big_polyvar_test.js +++ /dev/null @@ -1,7242 +0,0 @@ -// Generated by ReScript, PLEASE EDIT WITH CARE -'use strict'; - - -let _map = {"variant0":"variant0","variant1":"variant1","variant2":"variant2","variant3":"variant3","variant4":"variant4","variant5":"variant5","variant6":"variant6","variant7":"variant7","variant8":"variant8","variant9":"variant9","variant10":"variant10","variant11":"variant11","variant12":"variant12","variant13":"variant13","variant14":"variant14","variant15":"variant15","variant16":"variant16","variant17":"variant17","variant18":"variant18","variant19":"variant19","variant20":"variant20","variant21":"variant21","variant22":"variant22","variant23":"variant23","variant24":"variant24","variant25":"variant25","variant26":"variant26","variant27":"variant27","variant28":"variant28","variant29":"variant29","variant30":"variant30","variant31":"variant31","variant32":"variant32","variant33":"variant33","variant34":"variant34","variant35":"variant35","variant36":"variant36","variant37":"variant37","variant38":"variant38","variant39":"variant39","variant40":"variant40","variant41":"variant41","variant42":"variant42","variant43":"variant43","variant44":"variant44","variant45":"variant45","variant46":"variant46","variant47":"variant47","variant48":"variant48","variant49":"variant49","variant50":"variant50","variant51":"variant51","variant52":"variant52","variant53":"variant53","variant54":"variant54","variant55":"variant55","variant56":"variant56","variant57":"variant57","variant58":"variant58","variant59":"variant59","variant60":"variant60","variant61":"variant61","variant62":"variant62","variant63":"variant63","variant64":"variant64","variant65":"variant65","variant66":"variant66","variant67":"variant67","variant68":"variant68","variant69":"variant69","variant70":"variant70","variant71":"variant71","variant72":"variant72","variant73":"variant73","variant74":"variant74","variant75":"variant75","variant76":"variant76","variant77":"variant77","variant78":"variant78","variant79":"variant79","variant80":"variant80","variant81":"variant81","variant82":"variant82","variant83":"variant83","variant84":"variant84","variant85":"variant85","variant86":"variant86","variant87":"variant87","variant88":"variant88","variant89":"variant89","variant90":"variant90","variant91":"variant91","variant92":"variant92","variant93":"variant93","variant94":"variant94","variant95":"variant95","variant96":"variant96","variant97":"variant97","variant98":"variant98","variant99":"variant99","variant100":"variant100","variant101":"variant101","variant102":"variant102","variant103":"variant103","variant104":"variant104","variant105":"variant105","variant106":"variant106","variant107":"variant107","variant108":"variant108","variant109":"variant109","variant110":"variant110","variant111":"variant111","variant112":"variant112","variant113":"variant113","variant114":"variant114","variant115":"variant115","variant116":"variant116","variant117":"variant117","variant118":"variant118","variant119":"variant119","variant120":"variant120","variant121":"variant121","variant122":"variant122","variant123":"variant123","variant124":"variant124","variant125":"variant125","variant126":"variant126","variant127":"variant127","variant128":"variant128","variant129":"variant129","variant130":"variant130","variant131":"variant131","variant132":"variant132","variant133":"variant133","variant134":"variant134","variant135":"variant135","variant136":"variant136","variant137":"variant137","variant138":"variant138","variant139":"variant139","variant140":"variant140","variant141":"variant141","variant142":"variant142","variant143":"variant143","variant144":"variant144","variant145":"variant145","variant146":"variant146","variant147":"variant147","variant148":"variant148","variant149":"variant149","variant150":"variant150","variant151":"variant151","variant152":"variant152","variant153":"variant153","variant154":"variant154","variant155":"variant155","variant156":"variant156","variant157":"variant157","variant158":"variant158","variant159":"variant159","variant160":"variant160","variant161":"variant161","variant162":"variant162","variant163":"variant163","variant164":"variant164","variant165":"variant165","variant166":"variant166","variant167":"variant167","variant168":"variant168","variant169":"variant169","variant170":"variant170","variant171":"variant171","variant172":"variant172","variant173":"variant173","variant174":"variant174","variant175":"variant175","variant176":"variant176","variant177":"variant177","variant178":"variant178","variant179":"variant179","variant180":"variant180","variant181":"variant181","variant182":"variant182","variant183":"variant183","variant184":"variant184","variant185":"variant185","variant186":"variant186","variant187":"variant187","variant188":"variant188","variant189":"variant189","variant190":"variant190","variant191":"variant191","variant192":"variant192","variant193":"variant193","variant194":"variant194","variant195":"variant195","variant196":"variant196","variant197":"variant197","variant198":"variant198","variant199":"variant199","variant200":"variant200","variant201":"variant201","variant202":"variant202","variant203":"variant203","variant204":"variant204","variant205":"variant205","variant206":"variant206","variant207":"variant207","variant208":"variant208","variant209":"variant209","variant210":"variant210","variant211":"variant211","variant212":"variant212","variant213":"variant213","variant214":"variant214","variant215":"variant215","variant216":"variant216","variant217":"variant217","variant218":"variant218","variant219":"variant219","variant220":"variant220","variant221":"variant221","variant222":"variant222","variant223":"variant223","variant224":"variant224","variant225":"variant225","variant226":"variant226","variant227":"variant227","variant228":"variant228","variant229":"variant229","variant230":"variant230","variant231":"variant231","variant232":"variant232","variant233":"variant233","variant234":"variant234","variant235":"variant235","variant236":"variant236","variant237":"variant237","variant238":"variant238","variant239":"variant239","variant240":"variant240","variant241":"variant241","variant242":"variant242","variant243":"variant243","variant244":"variant244","variant245":"variant245","variant246":"variant246","variant247":"variant247","variant248":"variant248","variant249":"variant249","variant250":"variant250","variant251":"variant251","variant252":"variant252","variant253":"variant253","variant254":"variant254","variant255":"variant255","variant256":"variant256","variant257":"variant257","variant258":"variant258","variant259":"variant259","variant260":"variant260","variant261":"variant261","variant262":"variant262","variant263":"variant263","variant264":"variant264","variant265":"variant265","variant266":"variant266","variant267":"variant267","variant268":"variant268","variant269":"variant269","variant270":"variant270","variant271":"variant271","variant272":"variant272","variant273":"variant273","variant274":"variant274","variant275":"variant275","variant276":"variant276","variant277":"variant277","variant278":"variant278","variant279":"variant279","variant280":"variant280","variant281":"variant281","variant282":"variant282","variant283":"variant283","variant284":"variant284","variant285":"variant285","variant286":"variant286","variant287":"variant287","variant288":"variant288","variant289":"variant289","variant290":"variant290","variant291":"variant291","variant292":"variant292","variant293":"variant293","variant294":"variant294","variant295":"variant295","variant296":"variant296","variant297":"variant297","variant298":"variant298","variant299":"variant299"}; - -function tToJs(param) { - return param; -} - -function tFromJs(param) { - return _map[param]; -} - -function eq(x, y) { - if (x !== undefined) { - if (y !== undefined) { - return x === y; - } else { - return false; - } - } else { - return y === undefined; - } -} - -if ("variant0" !== "variant0") { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "big_polyvar_test.res", - 314, - 0 - ], - Error: new Error() - }; -} - -if ("variant1" !== "variant1") { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "big_polyvar_test.res", - 315, - 0 - ], - Error: new Error() - }; -} - -if ("variant2" !== "variant2") { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "big_polyvar_test.res", - 316, - 0 - ], - Error: new Error() - }; -} - -if ("variant3" !== "variant3") { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "big_polyvar_test.res", - 317, - 0 - ], - Error: new Error() - }; -} - -if ("variant4" !== "variant4") { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "big_polyvar_test.res", - 318, - 0 - ], - Error: new Error() - }; -} - -if ("variant5" !== "variant5") { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "big_polyvar_test.res", - 319, - 0 - ], - Error: new Error() - }; -} - -if ("variant6" !== "variant6") { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "big_polyvar_test.res", - 320, - 0 - ], - Error: new Error() - }; -} - -if ("variant7" !== "variant7") { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "big_polyvar_test.res", - 321, - 0 - ], - Error: new Error() - }; -} - -if ("variant8" !== "variant8") { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "big_polyvar_test.res", - 322, - 0 - ], - Error: new Error() - }; -} - -if ("variant9" !== "variant9") { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "big_polyvar_test.res", - 323, - 0 - ], - Error: new Error() - }; -} - -if ("variant10" !== "variant10") { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "big_polyvar_test.res", - 324, - 0 - ], - Error: new Error() - }; -} - -if ("variant11" !== "variant11") { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "big_polyvar_test.res", - 325, - 0 - ], - Error: new Error() - }; -} - -if ("variant12" !== "variant12") { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "big_polyvar_test.res", - 326, - 0 - ], - Error: new Error() - }; -} - -if ("variant13" !== "variant13") { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "big_polyvar_test.res", - 327, - 0 - ], - Error: new Error() - }; -} - -if ("variant14" !== "variant14") { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "big_polyvar_test.res", - 328, - 0 - ], - Error: new Error() - }; -} - -if ("variant15" !== "variant15") { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "big_polyvar_test.res", - 329, - 0 - ], - Error: new Error() - }; -} - -if ("variant16" !== "variant16") { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "big_polyvar_test.res", - 330, - 0 - ], - Error: new Error() - }; -} - -if ("variant17" !== "variant17") { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "big_polyvar_test.res", - 331, - 0 - ], - Error: new Error() - }; -} - -if ("variant18" !== "variant18") { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "big_polyvar_test.res", - 332, - 0 - ], - Error: new Error() - }; -} - -if ("variant19" !== "variant19") { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "big_polyvar_test.res", - 333, - 0 - ], - Error: new Error() - }; -} - -if ("variant20" !== "variant20") { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "big_polyvar_test.res", - 334, - 0 - ], - Error: new Error() - }; -} - -if ("variant21" !== "variant21") { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "big_polyvar_test.res", - 335, - 0 - ], - Error: new Error() - }; -} - -if ("variant22" !== "variant22") { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "big_polyvar_test.res", - 336, - 0 - ], - Error: new Error() - }; -} - -if ("variant23" !== "variant23") { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "big_polyvar_test.res", - 337, - 0 - ], - Error: new Error() - }; -} - -if ("variant24" !== "variant24") { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "big_polyvar_test.res", - 338, - 0 - ], - Error: new Error() - }; -} - -if ("variant25" !== "variant25") { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "big_polyvar_test.res", - 339, - 0 - ], - Error: new Error() - }; -} - -if ("variant26" !== "variant26") { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "big_polyvar_test.res", - 340, - 0 - ], - Error: new Error() - }; -} - -if ("variant27" !== "variant27") { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "big_polyvar_test.res", - 341, - 0 - ], - Error: new Error() - }; -} - -if ("variant28" !== "variant28") { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "big_polyvar_test.res", - 342, - 0 - ], - Error: new Error() - }; -} - -if ("variant29" !== "variant29") { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "big_polyvar_test.res", - 343, - 0 - ], - Error: new Error() - }; -} - -if ("variant30" !== "variant30") { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "big_polyvar_test.res", - 344, - 0 - ], - Error: new Error() - }; -} - -if ("variant31" !== "variant31") { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "big_polyvar_test.res", - 345, - 0 - ], - Error: new Error() - }; -} - -if ("variant32" !== "variant32") { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "big_polyvar_test.res", - 346, - 0 - ], - Error: new Error() - }; -} - -if ("variant33" !== "variant33") { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "big_polyvar_test.res", - 347, - 0 - ], - Error: new Error() - }; -} - -if ("variant34" !== "variant34") { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "big_polyvar_test.res", - 348, - 0 - ], - Error: new Error() - }; -} - -if ("variant35" !== "variant35") { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "big_polyvar_test.res", - 349, - 0 - ], - Error: new Error() - }; -} - -if ("variant36" !== "variant36") { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "big_polyvar_test.res", - 350, - 0 - ], - Error: new Error() - }; -} - -if ("variant37" !== "variant37") { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "big_polyvar_test.res", - 351, - 0 - ], - Error: new Error() - }; -} - -if ("variant38" !== "variant38") { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "big_polyvar_test.res", - 352, - 0 - ], - Error: new Error() - }; -} - -if ("variant39" !== "variant39") { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "big_polyvar_test.res", - 353, - 0 - ], - Error: new Error() - }; -} - -if ("variant40" !== "variant40") { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "big_polyvar_test.res", - 354, - 0 - ], - Error: new Error() - }; -} - -if ("variant41" !== "variant41") { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "big_polyvar_test.res", - 355, - 0 - ], - Error: new Error() - }; -} - -if ("variant42" !== "variant42") { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "big_polyvar_test.res", - 356, - 0 - ], - Error: new Error() - }; -} - -if ("variant43" !== "variant43") { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "big_polyvar_test.res", - 357, - 0 - ], - Error: new Error() - }; -} - -if ("variant44" !== "variant44") { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "big_polyvar_test.res", - 358, - 0 - ], - Error: new Error() - }; -} - -if ("variant45" !== "variant45") { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "big_polyvar_test.res", - 359, - 0 - ], - Error: new Error() - }; -} - -if ("variant46" !== "variant46") { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "big_polyvar_test.res", - 360, - 0 - ], - Error: new Error() - }; -} - -if ("variant47" !== "variant47") { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "big_polyvar_test.res", - 361, - 0 - ], - Error: new Error() - }; -} - -if ("variant48" !== "variant48") { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "big_polyvar_test.res", - 362, - 0 - ], - Error: new Error() - }; -} - -if ("variant49" !== "variant49") { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "big_polyvar_test.res", - 363, - 0 - ], - Error: new Error() - }; -} - -if ("variant50" !== "variant50") { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "big_polyvar_test.res", - 364, - 0 - ], - Error: new Error() - }; -} - -if ("variant51" !== "variant51") { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "big_polyvar_test.res", - 365, - 0 - ], - Error: new Error() - }; -} - -if ("variant52" !== "variant52") { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "big_polyvar_test.res", - 366, - 0 - ], - Error: new Error() - }; -} - -if ("variant53" !== "variant53") { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "big_polyvar_test.res", - 367, - 0 - ], - Error: new Error() - }; -} - -if ("variant54" !== "variant54") { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "big_polyvar_test.res", - 368, - 0 - ], - Error: new Error() - }; -} - -if ("variant55" !== "variant55") { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "big_polyvar_test.res", - 369, - 0 - ], - Error: new Error() - }; -} - -if ("variant56" !== "variant56") { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "big_polyvar_test.res", - 370, - 0 - ], - Error: new Error() - }; -} - -if ("variant57" !== "variant57") { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "big_polyvar_test.res", - 371, - 0 - ], - Error: new Error() - }; -} - -if ("variant58" !== "variant58") { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "big_polyvar_test.res", - 372, - 0 - ], - Error: new Error() - }; -} - -if ("variant59" !== "variant59") { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "big_polyvar_test.res", - 373, - 0 - ], - Error: new Error() - }; -} - -if ("variant60" !== "variant60") { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "big_polyvar_test.res", - 374, - 0 - ], - Error: new Error() - }; -} - -if ("variant61" !== "variant61") { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "big_polyvar_test.res", - 375, - 0 - ], - Error: new Error() - }; -} - -if ("variant62" !== "variant62") { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "big_polyvar_test.res", - 376, - 0 - ], - Error: new Error() - }; -} - -if ("variant63" !== "variant63") { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "big_polyvar_test.res", - 377, - 0 - ], - Error: new Error() - }; -} - -if ("variant64" !== "variant64") { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "big_polyvar_test.res", - 378, - 0 - ], - Error: new Error() - }; -} - -if ("variant65" !== "variant65") { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "big_polyvar_test.res", - 379, - 0 - ], - Error: new Error() - }; -} - -if ("variant66" !== "variant66") { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "big_polyvar_test.res", - 380, - 0 - ], - Error: new Error() - }; -} - -if ("variant67" !== "variant67") { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "big_polyvar_test.res", - 381, - 0 - ], - Error: new Error() - }; -} - -if ("variant68" !== "variant68") { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "big_polyvar_test.res", - 382, - 0 - ], - Error: new Error() - }; -} - -if ("variant69" !== "variant69") { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "big_polyvar_test.res", - 383, - 0 - ], - Error: new Error() - }; -} - -if ("variant70" !== "variant70") { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "big_polyvar_test.res", - 384, - 0 - ], - Error: new Error() - }; -} - -if ("variant71" !== "variant71") { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "big_polyvar_test.res", - 385, - 0 - ], - Error: new Error() - }; -} - -if ("variant72" !== "variant72") { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "big_polyvar_test.res", - 386, - 0 - ], - Error: new Error() - }; -} - -if ("variant73" !== "variant73") { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "big_polyvar_test.res", - 387, - 0 - ], - Error: new Error() - }; -} - -if ("variant74" !== "variant74") { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "big_polyvar_test.res", - 388, - 0 - ], - Error: new Error() - }; -} - -if ("variant75" !== "variant75") { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "big_polyvar_test.res", - 389, - 0 - ], - Error: new Error() - }; -} - -if ("variant76" !== "variant76") { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "big_polyvar_test.res", - 390, - 0 - ], - Error: new Error() - }; -} - -if ("variant77" !== "variant77") { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "big_polyvar_test.res", - 391, - 0 - ], - Error: new Error() - }; -} - -if ("variant78" !== "variant78") { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "big_polyvar_test.res", - 392, - 0 - ], - Error: new Error() - }; -} - -if ("variant79" !== "variant79") { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "big_polyvar_test.res", - 393, - 0 - ], - Error: new Error() - }; -} - -if ("variant80" !== "variant80") { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "big_polyvar_test.res", - 394, - 0 - ], - Error: new Error() - }; -} - -if ("variant81" !== "variant81") { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "big_polyvar_test.res", - 395, - 0 - ], - Error: new Error() - }; -} - -if ("variant82" !== "variant82") { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "big_polyvar_test.res", - 396, - 0 - ], - Error: new Error() - }; -} - -if ("variant83" !== "variant83") { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "big_polyvar_test.res", - 397, - 0 - ], - Error: new Error() - }; -} - -if ("variant84" !== "variant84") { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "big_polyvar_test.res", - 398, - 0 - ], - Error: new Error() - }; -} - -if ("variant85" !== "variant85") { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "big_polyvar_test.res", - 399, - 0 - ], - Error: new Error() - }; -} - -if ("variant86" !== "variant86") { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "big_polyvar_test.res", - 400, - 0 - ], - Error: new Error() - }; -} - -if ("variant87" !== "variant87") { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "big_polyvar_test.res", - 401, - 0 - ], - Error: new Error() - }; -} - -if ("variant88" !== "variant88") { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "big_polyvar_test.res", - 402, - 0 - ], - Error: new Error() - }; -} - -if ("variant89" !== "variant89") { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "big_polyvar_test.res", - 403, - 0 - ], - Error: new Error() - }; -} - -if ("variant90" !== "variant90") { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "big_polyvar_test.res", - 404, - 0 - ], - Error: new Error() - }; -} - -if ("variant91" !== "variant91") { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "big_polyvar_test.res", - 405, - 0 - ], - Error: new Error() - }; -} - -if ("variant92" !== "variant92") { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "big_polyvar_test.res", - 406, - 0 - ], - Error: new Error() - }; -} - -if ("variant93" !== "variant93") { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "big_polyvar_test.res", - 407, - 0 - ], - Error: new Error() - }; -} - -if ("variant94" !== "variant94") { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "big_polyvar_test.res", - 408, - 0 - ], - Error: new Error() - }; -} - -if ("variant95" !== "variant95") { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "big_polyvar_test.res", - 409, - 0 - ], - Error: new Error() - }; -} - -if ("variant96" !== "variant96") { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "big_polyvar_test.res", - 410, - 0 - ], - Error: new Error() - }; -} - -if ("variant97" !== "variant97") { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "big_polyvar_test.res", - 411, - 0 - ], - Error: new Error() - }; -} - -if ("variant98" !== "variant98") { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "big_polyvar_test.res", - 412, - 0 - ], - Error: new Error() - }; -} - -if ("variant99" !== "variant99") { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "big_polyvar_test.res", - 413, - 0 - ], - Error: new Error() - }; -} - -if ("variant100" !== "variant100") { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "big_polyvar_test.res", - 414, - 0 - ], - Error: new Error() - }; -} - -if ("variant101" !== "variant101") { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "big_polyvar_test.res", - 415, - 0 - ], - Error: new Error() - }; -} - -if ("variant102" !== "variant102") { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "big_polyvar_test.res", - 416, - 0 - ], - Error: new Error() - }; -} - -if ("variant103" !== "variant103") { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "big_polyvar_test.res", - 417, - 0 - ], - Error: new Error() - }; -} - -if ("variant104" !== "variant104") { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "big_polyvar_test.res", - 418, - 0 - ], - Error: new Error() - }; -} - -if ("variant105" !== "variant105") { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "big_polyvar_test.res", - 419, - 0 - ], - Error: new Error() - }; -} - -if ("variant106" !== "variant106") { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "big_polyvar_test.res", - 420, - 0 - ], - Error: new Error() - }; -} - -if ("variant107" !== "variant107") { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "big_polyvar_test.res", - 421, - 0 - ], - Error: new Error() - }; -} - -if ("variant108" !== "variant108") { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "big_polyvar_test.res", - 422, - 0 - ], - Error: new Error() - }; -} - -if ("variant109" !== "variant109") { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "big_polyvar_test.res", - 423, - 0 - ], - Error: new Error() - }; -} - -if ("variant110" !== "variant110") { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "big_polyvar_test.res", - 424, - 0 - ], - Error: new Error() - }; -} - -if ("variant111" !== "variant111") { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "big_polyvar_test.res", - 425, - 0 - ], - Error: new Error() - }; -} - -if ("variant112" !== "variant112") { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "big_polyvar_test.res", - 426, - 0 - ], - Error: new Error() - }; -} - -if ("variant113" !== "variant113") { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "big_polyvar_test.res", - 427, - 0 - ], - Error: new Error() - }; -} - -if ("variant114" !== "variant114") { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "big_polyvar_test.res", - 428, - 0 - ], - Error: new Error() - }; -} - -if ("variant115" !== "variant115") { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "big_polyvar_test.res", - 429, - 0 - ], - Error: new Error() - }; -} - -if ("variant116" !== "variant116") { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "big_polyvar_test.res", - 430, - 0 - ], - Error: new Error() - }; -} - -if ("variant117" !== "variant117") { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "big_polyvar_test.res", - 431, - 0 - ], - Error: new Error() - }; -} - -if ("variant118" !== "variant118") { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "big_polyvar_test.res", - 432, - 0 - ], - Error: new Error() - }; -} - -if ("variant119" !== "variant119") { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "big_polyvar_test.res", - 433, - 0 - ], - Error: new Error() - }; -} - -if ("variant120" !== "variant120") { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "big_polyvar_test.res", - 434, - 0 - ], - Error: new Error() - }; -} - -if ("variant121" !== "variant121") { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "big_polyvar_test.res", - 435, - 0 - ], - Error: new Error() - }; -} - -if ("variant122" !== "variant122") { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "big_polyvar_test.res", - 436, - 0 - ], - Error: new Error() - }; -} - -if ("variant123" !== "variant123") { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "big_polyvar_test.res", - 437, - 0 - ], - Error: new Error() - }; -} - -if ("variant124" !== "variant124") { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "big_polyvar_test.res", - 438, - 0 - ], - Error: new Error() - }; -} - -if ("variant125" !== "variant125") { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "big_polyvar_test.res", - 439, - 0 - ], - Error: new Error() - }; -} - -if ("variant126" !== "variant126") { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "big_polyvar_test.res", - 440, - 0 - ], - Error: new Error() - }; -} - -if ("variant127" !== "variant127") { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "big_polyvar_test.res", - 441, - 0 - ], - Error: new Error() - }; -} - -if ("variant128" !== "variant128") { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "big_polyvar_test.res", - 442, - 0 - ], - Error: new Error() - }; -} - -if ("variant129" !== "variant129") { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "big_polyvar_test.res", - 443, - 0 - ], - Error: new Error() - }; -} - -if ("variant130" !== "variant130") { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "big_polyvar_test.res", - 444, - 0 - ], - Error: new Error() - }; -} - -if ("variant131" !== "variant131") { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "big_polyvar_test.res", - 445, - 0 - ], - Error: new Error() - }; -} - -if ("variant132" !== "variant132") { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "big_polyvar_test.res", - 446, - 0 - ], - Error: new Error() - }; -} - -if ("variant133" !== "variant133") { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "big_polyvar_test.res", - 447, - 0 - ], - Error: new Error() - }; -} - -if ("variant134" !== "variant134") { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "big_polyvar_test.res", - 448, - 0 - ], - Error: new Error() - }; -} - -if ("variant135" !== "variant135") { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "big_polyvar_test.res", - 449, - 0 - ], - Error: new Error() - }; -} - -if ("variant136" !== "variant136") { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "big_polyvar_test.res", - 450, - 0 - ], - Error: new Error() - }; -} - -if ("variant137" !== "variant137") { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "big_polyvar_test.res", - 451, - 0 - ], - Error: new Error() - }; -} - -if ("variant138" !== "variant138") { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "big_polyvar_test.res", - 452, - 0 - ], - Error: new Error() - }; -} - -if ("variant139" !== "variant139") { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "big_polyvar_test.res", - 453, - 0 - ], - Error: new Error() - }; -} - -if ("variant140" !== "variant140") { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "big_polyvar_test.res", - 454, - 0 - ], - Error: new Error() - }; -} - -if ("variant141" !== "variant141") { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "big_polyvar_test.res", - 455, - 0 - ], - Error: new Error() - }; -} - -if ("variant142" !== "variant142") { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "big_polyvar_test.res", - 456, - 0 - ], - Error: new Error() - }; -} - -if ("variant143" !== "variant143") { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "big_polyvar_test.res", - 457, - 0 - ], - Error: new Error() - }; -} - -if ("variant144" !== "variant144") { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "big_polyvar_test.res", - 458, - 0 - ], - Error: new Error() - }; -} - -if ("variant145" !== "variant145") { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "big_polyvar_test.res", - 459, - 0 - ], - Error: new Error() - }; -} - -if ("variant146" !== "variant146") { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "big_polyvar_test.res", - 460, - 0 - ], - Error: new Error() - }; -} - -if ("variant147" !== "variant147") { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "big_polyvar_test.res", - 461, - 0 - ], - Error: new Error() - }; -} - -if ("variant148" !== "variant148") { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "big_polyvar_test.res", - 462, - 0 - ], - Error: new Error() - }; -} - -if ("variant149" !== "variant149") { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "big_polyvar_test.res", - 463, - 0 - ], - Error: new Error() - }; -} - -if ("variant150" !== "variant150") { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "big_polyvar_test.res", - 464, - 0 - ], - Error: new Error() - }; -} - -if ("variant151" !== "variant151") { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "big_polyvar_test.res", - 465, - 0 - ], - Error: new Error() - }; -} - -if ("variant152" !== "variant152") { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "big_polyvar_test.res", - 466, - 0 - ], - Error: new Error() - }; -} - -if ("variant153" !== "variant153") { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "big_polyvar_test.res", - 467, - 0 - ], - Error: new Error() - }; -} - -if ("variant154" !== "variant154") { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "big_polyvar_test.res", - 468, - 0 - ], - Error: new Error() - }; -} - -if ("variant155" !== "variant155") { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "big_polyvar_test.res", - 469, - 0 - ], - Error: new Error() - }; -} - -if ("variant156" !== "variant156") { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "big_polyvar_test.res", - 470, - 0 - ], - Error: new Error() - }; -} - -if ("variant157" !== "variant157") { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "big_polyvar_test.res", - 471, - 0 - ], - Error: new Error() - }; -} - -if ("variant158" !== "variant158") { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "big_polyvar_test.res", - 472, - 0 - ], - Error: new Error() - }; -} - -if ("variant159" !== "variant159") { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "big_polyvar_test.res", - 473, - 0 - ], - Error: new Error() - }; -} - -if ("variant160" !== "variant160") { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "big_polyvar_test.res", - 474, - 0 - ], - Error: new Error() - }; -} - -if ("variant161" !== "variant161") { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "big_polyvar_test.res", - 475, - 0 - ], - Error: new Error() - }; -} - -if ("variant162" !== "variant162") { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "big_polyvar_test.res", - 476, - 0 - ], - Error: new Error() - }; -} - -if ("variant163" !== "variant163") { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "big_polyvar_test.res", - 477, - 0 - ], - Error: new Error() - }; -} - -if ("variant164" !== "variant164") { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "big_polyvar_test.res", - 478, - 0 - ], - Error: new Error() - }; -} - -if ("variant165" !== "variant165") { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "big_polyvar_test.res", - 479, - 0 - ], - Error: new Error() - }; -} - -if ("variant166" !== "variant166") { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "big_polyvar_test.res", - 480, - 0 - ], - Error: new Error() - }; -} - -if ("variant167" !== "variant167") { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "big_polyvar_test.res", - 481, - 0 - ], - Error: new Error() - }; -} - -if ("variant168" !== "variant168") { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "big_polyvar_test.res", - 482, - 0 - ], - Error: new Error() - }; -} - -if ("variant169" !== "variant169") { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "big_polyvar_test.res", - 483, - 0 - ], - Error: new Error() - }; -} - -if ("variant170" !== "variant170") { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "big_polyvar_test.res", - 484, - 0 - ], - Error: new Error() - }; -} - -if ("variant171" !== "variant171") { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "big_polyvar_test.res", - 485, - 0 - ], - Error: new Error() - }; -} - -if ("variant172" !== "variant172") { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "big_polyvar_test.res", - 486, - 0 - ], - Error: new Error() - }; -} - -if ("variant173" !== "variant173") { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "big_polyvar_test.res", - 487, - 0 - ], - Error: new Error() - }; -} - -if ("variant174" !== "variant174") { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "big_polyvar_test.res", - 488, - 0 - ], - Error: new Error() - }; -} - -if ("variant175" !== "variant175") { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "big_polyvar_test.res", - 489, - 0 - ], - Error: new Error() - }; -} - -if ("variant176" !== "variant176") { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "big_polyvar_test.res", - 490, - 0 - ], - Error: new Error() - }; -} - -if ("variant177" !== "variant177") { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "big_polyvar_test.res", - 491, - 0 - ], - Error: new Error() - }; -} - -if ("variant178" !== "variant178") { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "big_polyvar_test.res", - 492, - 0 - ], - Error: new Error() - }; -} - -if ("variant179" !== "variant179") { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "big_polyvar_test.res", - 493, - 0 - ], - Error: new Error() - }; -} - -if ("variant180" !== "variant180") { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "big_polyvar_test.res", - 494, - 0 - ], - Error: new Error() - }; -} - -if ("variant181" !== "variant181") { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "big_polyvar_test.res", - 495, - 0 - ], - Error: new Error() - }; -} - -if ("variant182" !== "variant182") { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "big_polyvar_test.res", - 496, - 0 - ], - Error: new Error() - }; -} - -if ("variant183" !== "variant183") { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "big_polyvar_test.res", - 497, - 0 - ], - Error: new Error() - }; -} - -if ("variant184" !== "variant184") { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "big_polyvar_test.res", - 498, - 0 - ], - Error: new Error() - }; -} - -if ("variant185" !== "variant185") { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "big_polyvar_test.res", - 499, - 0 - ], - Error: new Error() - }; -} - -if ("variant186" !== "variant186") { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "big_polyvar_test.res", - 500, - 0 - ], - Error: new Error() - }; -} - -if ("variant187" !== "variant187") { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "big_polyvar_test.res", - 501, - 0 - ], - Error: new Error() - }; -} - -if ("variant188" !== "variant188") { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "big_polyvar_test.res", - 502, - 0 - ], - Error: new Error() - }; -} - -if ("variant189" !== "variant189") { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "big_polyvar_test.res", - 503, - 0 - ], - Error: new Error() - }; -} - -if ("variant190" !== "variant190") { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "big_polyvar_test.res", - 504, - 0 - ], - Error: new Error() - }; -} - -if ("variant191" !== "variant191") { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "big_polyvar_test.res", - 505, - 0 - ], - Error: new Error() - }; -} - -if ("variant192" !== "variant192") { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "big_polyvar_test.res", - 506, - 0 - ], - Error: new Error() - }; -} - -if ("variant193" !== "variant193") { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "big_polyvar_test.res", - 507, - 0 - ], - Error: new Error() - }; -} - -if ("variant194" !== "variant194") { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "big_polyvar_test.res", - 508, - 0 - ], - Error: new Error() - }; -} - -if ("variant195" !== "variant195") { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "big_polyvar_test.res", - 509, - 0 - ], - Error: new Error() - }; -} - -if ("variant196" !== "variant196") { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "big_polyvar_test.res", - 510, - 0 - ], - Error: new Error() - }; -} - -if ("variant197" !== "variant197") { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "big_polyvar_test.res", - 511, - 0 - ], - Error: new Error() - }; -} - -if ("variant198" !== "variant198") { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "big_polyvar_test.res", - 512, - 0 - ], - Error: new Error() - }; -} - -if ("variant199" !== "variant199") { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "big_polyvar_test.res", - 513, - 0 - ], - Error: new Error() - }; -} - -if ("variant200" !== "variant200") { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "big_polyvar_test.res", - 514, - 0 - ], - Error: new Error() - }; -} - -if ("variant201" !== "variant201") { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "big_polyvar_test.res", - 515, - 0 - ], - Error: new Error() - }; -} - -if ("variant202" !== "variant202") { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "big_polyvar_test.res", - 516, - 0 - ], - Error: new Error() - }; -} - -if ("variant203" !== "variant203") { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "big_polyvar_test.res", - 517, - 0 - ], - Error: new Error() - }; -} - -if ("variant204" !== "variant204") { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "big_polyvar_test.res", - 518, - 0 - ], - Error: new Error() - }; -} - -if ("variant205" !== "variant205") { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "big_polyvar_test.res", - 519, - 0 - ], - Error: new Error() - }; -} - -if ("variant206" !== "variant206") { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "big_polyvar_test.res", - 520, - 0 - ], - Error: new Error() - }; -} - -if ("variant207" !== "variant207") { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "big_polyvar_test.res", - 521, - 0 - ], - Error: new Error() - }; -} - -if ("variant208" !== "variant208") { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "big_polyvar_test.res", - 522, - 0 - ], - Error: new Error() - }; -} - -if ("variant209" !== "variant209") { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "big_polyvar_test.res", - 523, - 0 - ], - Error: new Error() - }; -} - -if ("variant210" !== "variant210") { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "big_polyvar_test.res", - 524, - 0 - ], - Error: new Error() - }; -} - -if ("variant211" !== "variant211") { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "big_polyvar_test.res", - 525, - 0 - ], - Error: new Error() - }; -} - -if ("variant212" !== "variant212") { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "big_polyvar_test.res", - 526, - 0 - ], - Error: new Error() - }; -} - -if ("variant213" !== "variant213") { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "big_polyvar_test.res", - 527, - 0 - ], - Error: new Error() - }; -} - -if ("variant214" !== "variant214") { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "big_polyvar_test.res", - 528, - 0 - ], - Error: new Error() - }; -} - -if ("variant215" !== "variant215") { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "big_polyvar_test.res", - 529, - 0 - ], - Error: new Error() - }; -} - -if ("variant216" !== "variant216") { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "big_polyvar_test.res", - 530, - 0 - ], - Error: new Error() - }; -} - -if ("variant217" !== "variant217") { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "big_polyvar_test.res", - 531, - 0 - ], - Error: new Error() - }; -} - -if ("variant218" !== "variant218") { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "big_polyvar_test.res", - 532, - 0 - ], - Error: new Error() - }; -} - -if ("variant219" !== "variant219") { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "big_polyvar_test.res", - 533, - 0 - ], - Error: new Error() - }; -} - -if ("variant220" !== "variant220") { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "big_polyvar_test.res", - 534, - 0 - ], - Error: new Error() - }; -} - -if ("variant221" !== "variant221") { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "big_polyvar_test.res", - 535, - 0 - ], - Error: new Error() - }; -} - -if ("variant222" !== "variant222") { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "big_polyvar_test.res", - 536, - 0 - ], - Error: new Error() - }; -} - -if ("variant223" !== "variant223") { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "big_polyvar_test.res", - 537, - 0 - ], - Error: new Error() - }; -} - -if ("variant224" !== "variant224") { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "big_polyvar_test.res", - 538, - 0 - ], - Error: new Error() - }; -} - -if ("variant225" !== "variant225") { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "big_polyvar_test.res", - 539, - 0 - ], - Error: new Error() - }; -} - -if ("variant226" !== "variant226") { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "big_polyvar_test.res", - 540, - 0 - ], - Error: new Error() - }; -} - -if ("variant227" !== "variant227") { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "big_polyvar_test.res", - 541, - 0 - ], - Error: new Error() - }; -} - -if ("variant228" !== "variant228") { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "big_polyvar_test.res", - 542, - 0 - ], - Error: new Error() - }; -} - -if ("variant229" !== "variant229") { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "big_polyvar_test.res", - 543, - 0 - ], - Error: new Error() - }; -} - -if ("variant230" !== "variant230") { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "big_polyvar_test.res", - 544, - 0 - ], - Error: new Error() - }; -} - -if ("variant231" !== "variant231") { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "big_polyvar_test.res", - 545, - 0 - ], - Error: new Error() - }; -} - -if ("variant232" !== "variant232") { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "big_polyvar_test.res", - 546, - 0 - ], - Error: new Error() - }; -} - -if ("variant233" !== "variant233") { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "big_polyvar_test.res", - 547, - 0 - ], - Error: new Error() - }; -} - -if ("variant234" !== "variant234") { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "big_polyvar_test.res", - 548, - 0 - ], - Error: new Error() - }; -} - -if ("variant235" !== "variant235") { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "big_polyvar_test.res", - 549, - 0 - ], - Error: new Error() - }; -} - -if ("variant236" !== "variant236") { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "big_polyvar_test.res", - 550, - 0 - ], - Error: new Error() - }; -} - -if ("variant237" !== "variant237") { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "big_polyvar_test.res", - 551, - 0 - ], - Error: new Error() - }; -} - -if ("variant238" !== "variant238") { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "big_polyvar_test.res", - 552, - 0 - ], - Error: new Error() - }; -} - -if ("variant239" !== "variant239") { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "big_polyvar_test.res", - 553, - 0 - ], - Error: new Error() - }; -} - -if ("variant240" !== "variant240") { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "big_polyvar_test.res", - 554, - 0 - ], - Error: new Error() - }; -} - -if ("variant241" !== "variant241") { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "big_polyvar_test.res", - 555, - 0 - ], - Error: new Error() - }; -} - -if ("variant242" !== "variant242") { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "big_polyvar_test.res", - 556, - 0 - ], - Error: new Error() - }; -} - -if ("variant243" !== "variant243") { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "big_polyvar_test.res", - 557, - 0 - ], - Error: new Error() - }; -} - -if ("variant244" !== "variant244") { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "big_polyvar_test.res", - 558, - 0 - ], - Error: new Error() - }; -} - -if ("variant245" !== "variant245") { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "big_polyvar_test.res", - 559, - 0 - ], - Error: new Error() - }; -} - -if ("variant246" !== "variant246") { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "big_polyvar_test.res", - 560, - 0 - ], - Error: new Error() - }; -} - -if ("variant247" !== "variant247") { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "big_polyvar_test.res", - 561, - 0 - ], - Error: new Error() - }; -} - -if ("variant248" !== "variant248") { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "big_polyvar_test.res", - 562, - 0 - ], - Error: new Error() - }; -} - -if ("variant249" !== "variant249") { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "big_polyvar_test.res", - 563, - 0 - ], - Error: new Error() - }; -} - -if ("variant250" !== "variant250") { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "big_polyvar_test.res", - 564, - 0 - ], - Error: new Error() - }; -} - -if ("variant251" !== "variant251") { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "big_polyvar_test.res", - 565, - 0 - ], - Error: new Error() - }; -} - -if ("variant252" !== "variant252") { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "big_polyvar_test.res", - 566, - 0 - ], - Error: new Error() - }; -} - -if ("variant253" !== "variant253") { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "big_polyvar_test.res", - 567, - 0 - ], - Error: new Error() - }; -} - -if ("variant254" !== "variant254") { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "big_polyvar_test.res", - 568, - 0 - ], - Error: new Error() - }; -} - -if ("variant255" !== "variant255") { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "big_polyvar_test.res", - 569, - 0 - ], - Error: new Error() - }; -} - -if ("variant256" !== "variant256") { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "big_polyvar_test.res", - 570, - 0 - ], - Error: new Error() - }; -} - -if ("variant257" !== "variant257") { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "big_polyvar_test.res", - 571, - 0 - ], - Error: new Error() - }; -} - -if ("variant258" !== "variant258") { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "big_polyvar_test.res", - 572, - 0 - ], - Error: new Error() - }; -} - -if ("variant259" !== "variant259") { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "big_polyvar_test.res", - 573, - 0 - ], - Error: new Error() - }; -} - -if ("variant260" !== "variant260") { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "big_polyvar_test.res", - 574, - 0 - ], - Error: new Error() - }; -} - -if ("variant261" !== "variant261") { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "big_polyvar_test.res", - 575, - 0 - ], - Error: new Error() - }; -} - -if ("variant262" !== "variant262") { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "big_polyvar_test.res", - 576, - 0 - ], - Error: new Error() - }; -} - -if ("variant263" !== "variant263") { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "big_polyvar_test.res", - 577, - 0 - ], - Error: new Error() - }; -} - -if ("variant264" !== "variant264") { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "big_polyvar_test.res", - 578, - 0 - ], - Error: new Error() - }; -} - -if ("variant265" !== "variant265") { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "big_polyvar_test.res", - 579, - 0 - ], - Error: new Error() - }; -} - -if ("variant266" !== "variant266") { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "big_polyvar_test.res", - 580, - 0 - ], - Error: new Error() - }; -} - -if ("variant267" !== "variant267") { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "big_polyvar_test.res", - 581, - 0 - ], - Error: new Error() - }; -} - -if ("variant268" !== "variant268") { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "big_polyvar_test.res", - 582, - 0 - ], - Error: new Error() - }; -} - -if ("variant269" !== "variant269") { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "big_polyvar_test.res", - 583, - 0 - ], - Error: new Error() - }; -} - -if ("variant270" !== "variant270") { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "big_polyvar_test.res", - 584, - 0 - ], - Error: new Error() - }; -} - -if ("variant271" !== "variant271") { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "big_polyvar_test.res", - 585, - 0 - ], - Error: new Error() - }; -} - -if ("variant272" !== "variant272") { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "big_polyvar_test.res", - 586, - 0 - ], - Error: new Error() - }; -} - -if ("variant273" !== "variant273") { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "big_polyvar_test.res", - 587, - 0 - ], - Error: new Error() - }; -} - -if ("variant274" !== "variant274") { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "big_polyvar_test.res", - 588, - 0 - ], - Error: new Error() - }; -} - -if ("variant275" !== "variant275") { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "big_polyvar_test.res", - 589, - 0 - ], - Error: new Error() - }; -} - -if ("variant276" !== "variant276") { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "big_polyvar_test.res", - 590, - 0 - ], - Error: new Error() - }; -} - -if ("variant277" !== "variant277") { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "big_polyvar_test.res", - 591, - 0 - ], - Error: new Error() - }; -} - -if ("variant278" !== "variant278") { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "big_polyvar_test.res", - 592, - 0 - ], - Error: new Error() - }; -} - -if ("variant279" !== "variant279") { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "big_polyvar_test.res", - 593, - 0 - ], - Error: new Error() - }; -} - -if ("variant280" !== "variant280") { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "big_polyvar_test.res", - 594, - 0 - ], - Error: new Error() - }; -} - -if ("variant281" !== "variant281") { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "big_polyvar_test.res", - 595, - 0 - ], - Error: new Error() - }; -} - -if ("variant282" !== "variant282") { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "big_polyvar_test.res", - 596, - 0 - ], - Error: new Error() - }; -} - -if ("variant283" !== "variant283") { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "big_polyvar_test.res", - 597, - 0 - ], - Error: new Error() - }; -} - -if ("variant284" !== "variant284") { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "big_polyvar_test.res", - 598, - 0 - ], - Error: new Error() - }; -} - -if ("variant285" !== "variant285") { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "big_polyvar_test.res", - 599, - 0 - ], - Error: new Error() - }; -} - -if ("variant286" !== "variant286") { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "big_polyvar_test.res", - 600, - 0 - ], - Error: new Error() - }; -} - -if ("variant287" !== "variant287") { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "big_polyvar_test.res", - 601, - 0 - ], - Error: new Error() - }; -} - -if ("variant288" !== "variant288") { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "big_polyvar_test.res", - 602, - 0 - ], - Error: new Error() - }; -} - -if ("variant289" !== "variant289") { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "big_polyvar_test.res", - 603, - 0 - ], - Error: new Error() - }; -} - -if ("variant290" !== "variant290") { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "big_polyvar_test.res", - 604, - 0 - ], - Error: new Error() - }; -} - -if ("variant291" !== "variant291") { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "big_polyvar_test.res", - 605, - 0 - ], - Error: new Error() - }; -} - -if ("variant292" !== "variant292") { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "big_polyvar_test.res", - 606, - 0 - ], - Error: new Error() - }; -} - -if ("variant293" !== "variant293") { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "big_polyvar_test.res", - 607, - 0 - ], - Error: new Error() - }; -} - -if ("variant294" !== "variant294") { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "big_polyvar_test.res", - 608, - 0 - ], - Error: new Error() - }; -} - -if ("variant295" !== "variant295") { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "big_polyvar_test.res", - 609, - 0 - ], - Error: new Error() - }; -} - -if ("variant296" !== "variant296") { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "big_polyvar_test.res", - 610, - 0 - ], - Error: new Error() - }; -} - -if ("variant297" !== "variant297") { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "big_polyvar_test.res", - 611, - 0 - ], - Error: new Error() - }; -} - -if ("variant298" !== "variant298") { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "big_polyvar_test.res", - 612, - 0 - ], - Error: new Error() - }; -} - -if ("variant299" !== "variant299") { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "big_polyvar_test.res", - 613, - 0 - ], - Error: new Error() - }; -} - -if (!eq(tFromJs("variant0"), "variant0")) { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "big_polyvar_test.res", - 614, - 0 - ], - Error: new Error() - }; -} - -if (!eq(tFromJs("variant1"), "variant1")) { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "big_polyvar_test.res", - 615, - 0 - ], - Error: new Error() - }; -} - -if (!eq(tFromJs("variant2"), "variant2")) { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "big_polyvar_test.res", - 616, - 0 - ], - Error: new Error() - }; -} - -if (!eq(tFromJs("variant3"), "variant3")) { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "big_polyvar_test.res", - 617, - 0 - ], - Error: new Error() - }; -} - -if (!eq(tFromJs("variant4"), "variant4")) { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "big_polyvar_test.res", - 618, - 0 - ], - Error: new Error() - }; -} - -if (!eq(tFromJs("variant5"), "variant5")) { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "big_polyvar_test.res", - 619, - 0 - ], - Error: new Error() - }; -} - -if (!eq(tFromJs("variant6"), "variant6")) { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "big_polyvar_test.res", - 620, - 0 - ], - Error: new Error() - }; -} - -if (!eq(tFromJs("variant7"), "variant7")) { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "big_polyvar_test.res", - 621, - 0 - ], - Error: new Error() - }; -} - -if (!eq(tFromJs("variant8"), "variant8")) { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "big_polyvar_test.res", - 622, - 0 - ], - Error: new Error() - }; -} - -if (!eq(tFromJs("variant9"), "variant9")) { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "big_polyvar_test.res", - 623, - 0 - ], - Error: new Error() - }; -} - -if (!eq(tFromJs("variant10"), "variant10")) { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "big_polyvar_test.res", - 624, - 0 - ], - Error: new Error() - }; -} - -if (!eq(tFromJs("variant11"), "variant11")) { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "big_polyvar_test.res", - 625, - 0 - ], - Error: new Error() - }; -} - -if (!eq(tFromJs("variant12"), "variant12")) { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "big_polyvar_test.res", - 626, - 0 - ], - Error: new Error() - }; -} - -if (!eq(tFromJs("variant13"), "variant13")) { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "big_polyvar_test.res", - 627, - 0 - ], - Error: new Error() - }; -} - -if (!eq(tFromJs("variant14"), "variant14")) { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "big_polyvar_test.res", - 628, - 0 - ], - Error: new Error() - }; -} - -if (!eq(tFromJs("variant15"), "variant15")) { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "big_polyvar_test.res", - 629, - 0 - ], - Error: new Error() - }; -} - -if (!eq(tFromJs("variant16"), "variant16")) { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "big_polyvar_test.res", - 630, - 0 - ], - Error: new Error() - }; -} - -if (!eq(tFromJs("variant17"), "variant17")) { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "big_polyvar_test.res", - 631, - 0 - ], - Error: new Error() - }; -} - -if (!eq(tFromJs("variant18"), "variant18")) { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "big_polyvar_test.res", - 632, - 0 - ], - Error: new Error() - }; -} - -if (!eq(tFromJs("variant19"), "variant19")) { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "big_polyvar_test.res", - 633, - 0 - ], - Error: new Error() - }; -} - -if (!eq(tFromJs("variant20"), "variant20")) { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "big_polyvar_test.res", - 634, - 0 - ], - Error: new Error() - }; -} - -if (!eq(tFromJs("variant21"), "variant21")) { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "big_polyvar_test.res", - 635, - 0 - ], - Error: new Error() - }; -} - -if (!eq(tFromJs("variant22"), "variant22")) { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "big_polyvar_test.res", - 636, - 0 - ], - Error: new Error() - }; -} - -if (!eq(tFromJs("variant23"), "variant23")) { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "big_polyvar_test.res", - 637, - 0 - ], - Error: new Error() - }; -} - -if (!eq(tFromJs("variant24"), "variant24")) { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "big_polyvar_test.res", - 638, - 0 - ], - Error: new Error() - }; -} - -if (!eq(tFromJs("variant25"), "variant25")) { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "big_polyvar_test.res", - 639, - 0 - ], - Error: new Error() - }; -} - -if (!eq(tFromJs("variant26"), "variant26")) { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "big_polyvar_test.res", - 640, - 0 - ], - Error: new Error() - }; -} - -if (!eq(tFromJs("variant27"), "variant27")) { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "big_polyvar_test.res", - 641, - 0 - ], - Error: new Error() - }; -} - -if (!eq(tFromJs("variant28"), "variant28")) { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "big_polyvar_test.res", - 642, - 0 - ], - Error: new Error() - }; -} - -if (!eq(tFromJs("variant29"), "variant29")) { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "big_polyvar_test.res", - 643, - 0 - ], - Error: new Error() - }; -} - -if (!eq(tFromJs("variant30"), "variant30")) { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "big_polyvar_test.res", - 644, - 0 - ], - Error: new Error() - }; -} - -if (!eq(tFromJs("variant31"), "variant31")) { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "big_polyvar_test.res", - 645, - 0 - ], - Error: new Error() - }; -} - -if (!eq(tFromJs("variant32"), "variant32")) { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "big_polyvar_test.res", - 646, - 0 - ], - Error: new Error() - }; -} - -if (!eq(tFromJs("variant33"), "variant33")) { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "big_polyvar_test.res", - 647, - 0 - ], - Error: new Error() - }; -} - -if (!eq(tFromJs("variant34"), "variant34")) { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "big_polyvar_test.res", - 648, - 0 - ], - Error: new Error() - }; -} - -if (!eq(tFromJs("variant35"), "variant35")) { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "big_polyvar_test.res", - 649, - 0 - ], - Error: new Error() - }; -} - -if (!eq(tFromJs("variant36"), "variant36")) { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "big_polyvar_test.res", - 650, - 0 - ], - Error: new Error() - }; -} - -if (!eq(tFromJs("variant37"), "variant37")) { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "big_polyvar_test.res", - 651, - 0 - ], - Error: new Error() - }; -} - -if (!eq(tFromJs("variant38"), "variant38")) { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "big_polyvar_test.res", - 652, - 0 - ], - Error: new Error() - }; -} - -if (!eq(tFromJs("variant39"), "variant39")) { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "big_polyvar_test.res", - 653, - 0 - ], - Error: new Error() - }; -} - -if (!eq(tFromJs("variant40"), "variant40")) { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "big_polyvar_test.res", - 654, - 0 - ], - Error: new Error() - }; -} - -if (!eq(tFromJs("variant41"), "variant41")) { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "big_polyvar_test.res", - 655, - 0 - ], - Error: new Error() - }; -} - -if (!eq(tFromJs("variant42"), "variant42")) { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "big_polyvar_test.res", - 656, - 0 - ], - Error: new Error() - }; -} - -if (!eq(tFromJs("variant43"), "variant43")) { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "big_polyvar_test.res", - 657, - 0 - ], - Error: new Error() - }; -} - -if (!eq(tFromJs("variant44"), "variant44")) { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "big_polyvar_test.res", - 658, - 0 - ], - Error: new Error() - }; -} - -if (!eq(tFromJs("variant45"), "variant45")) { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "big_polyvar_test.res", - 659, - 0 - ], - Error: new Error() - }; -} - -if (!eq(tFromJs("variant46"), "variant46")) { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "big_polyvar_test.res", - 660, - 0 - ], - Error: new Error() - }; -} - -if (!eq(tFromJs("variant47"), "variant47")) { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "big_polyvar_test.res", - 661, - 0 - ], - Error: new Error() - }; -} - -if (!eq(tFromJs("variant48"), "variant48")) { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "big_polyvar_test.res", - 662, - 0 - ], - Error: new Error() - }; -} - -if (!eq(tFromJs("variant49"), "variant49")) { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "big_polyvar_test.res", - 663, - 0 - ], - Error: new Error() - }; -} - -if (!eq(tFromJs("variant50"), "variant50")) { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "big_polyvar_test.res", - 664, - 0 - ], - Error: new Error() - }; -} - -if (!eq(tFromJs("variant51"), "variant51")) { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "big_polyvar_test.res", - 665, - 0 - ], - Error: new Error() - }; -} - -if (!eq(tFromJs("variant52"), "variant52")) { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "big_polyvar_test.res", - 666, - 0 - ], - Error: new Error() - }; -} - -if (!eq(tFromJs("variant53"), "variant53")) { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "big_polyvar_test.res", - 667, - 0 - ], - Error: new Error() - }; -} - -if (!eq(tFromJs("variant54"), "variant54")) { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "big_polyvar_test.res", - 668, - 0 - ], - Error: new Error() - }; -} - -if (!eq(tFromJs("variant55"), "variant55")) { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "big_polyvar_test.res", - 669, - 0 - ], - Error: new Error() - }; -} - -if (!eq(tFromJs("variant56"), "variant56")) { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "big_polyvar_test.res", - 670, - 0 - ], - Error: new Error() - }; -} - -if (!eq(tFromJs("variant57"), "variant57")) { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "big_polyvar_test.res", - 671, - 0 - ], - Error: new Error() - }; -} - -if (!eq(tFromJs("variant58"), "variant58")) { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "big_polyvar_test.res", - 672, - 0 - ], - Error: new Error() - }; -} - -if (!eq(tFromJs("variant59"), "variant59")) { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "big_polyvar_test.res", - 673, - 0 - ], - Error: new Error() - }; -} - -if (!eq(tFromJs("variant60"), "variant60")) { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "big_polyvar_test.res", - 674, - 0 - ], - Error: new Error() - }; -} - -if (!eq(tFromJs("variant61"), "variant61")) { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "big_polyvar_test.res", - 675, - 0 - ], - Error: new Error() - }; -} - -if (!eq(tFromJs("variant62"), "variant62")) { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "big_polyvar_test.res", - 676, - 0 - ], - Error: new Error() - }; -} - -if (!eq(tFromJs("variant63"), "variant63")) { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "big_polyvar_test.res", - 677, - 0 - ], - Error: new Error() - }; -} - -if (!eq(tFromJs("variant64"), "variant64")) { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "big_polyvar_test.res", - 678, - 0 - ], - Error: new Error() - }; -} - -if (!eq(tFromJs("variant65"), "variant65")) { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "big_polyvar_test.res", - 679, - 0 - ], - Error: new Error() - }; -} - -if (!eq(tFromJs("variant66"), "variant66")) { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "big_polyvar_test.res", - 680, - 0 - ], - Error: new Error() - }; -} - -if (!eq(tFromJs("variant67"), "variant67")) { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "big_polyvar_test.res", - 681, - 0 - ], - Error: new Error() - }; -} - -if (!eq(tFromJs("variant68"), "variant68")) { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "big_polyvar_test.res", - 682, - 0 - ], - Error: new Error() - }; -} - -if (!eq(tFromJs("variant69"), "variant69")) { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "big_polyvar_test.res", - 683, - 0 - ], - Error: new Error() - }; -} - -if (!eq(tFromJs("variant70"), "variant70")) { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "big_polyvar_test.res", - 684, - 0 - ], - Error: new Error() - }; -} - -if (!eq(tFromJs("variant71"), "variant71")) { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "big_polyvar_test.res", - 685, - 0 - ], - Error: new Error() - }; -} - -if (!eq(tFromJs("variant72"), "variant72")) { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "big_polyvar_test.res", - 686, - 0 - ], - Error: new Error() - }; -} - -if (!eq(tFromJs("variant73"), "variant73")) { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "big_polyvar_test.res", - 687, - 0 - ], - Error: new Error() - }; -} - -if (!eq(tFromJs("variant74"), "variant74")) { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "big_polyvar_test.res", - 688, - 0 - ], - Error: new Error() - }; -} - -if (!eq(tFromJs("variant75"), "variant75")) { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "big_polyvar_test.res", - 689, - 0 - ], - Error: new Error() - }; -} - -if (!eq(tFromJs("variant76"), "variant76")) { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "big_polyvar_test.res", - 690, - 0 - ], - Error: new Error() - }; -} - -if (!eq(tFromJs("variant77"), "variant77")) { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "big_polyvar_test.res", - 691, - 0 - ], - Error: new Error() - }; -} - -if (!eq(tFromJs("variant78"), "variant78")) { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "big_polyvar_test.res", - 692, - 0 - ], - Error: new Error() - }; -} - -if (!eq(tFromJs("variant79"), "variant79")) { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "big_polyvar_test.res", - 693, - 0 - ], - Error: new Error() - }; -} - -if (!eq(tFromJs("variant80"), "variant80")) { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "big_polyvar_test.res", - 694, - 0 - ], - Error: new Error() - }; -} - -if (!eq(tFromJs("variant81"), "variant81")) { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "big_polyvar_test.res", - 695, - 0 - ], - Error: new Error() - }; -} - -if (!eq(tFromJs("variant82"), "variant82")) { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "big_polyvar_test.res", - 696, - 0 - ], - Error: new Error() - }; -} - -if (!eq(tFromJs("variant83"), "variant83")) { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "big_polyvar_test.res", - 697, - 0 - ], - Error: new Error() - }; -} - -if (!eq(tFromJs("variant84"), "variant84")) { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "big_polyvar_test.res", - 698, - 0 - ], - Error: new Error() - }; -} - -if (!eq(tFromJs("variant85"), "variant85")) { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "big_polyvar_test.res", - 699, - 0 - ], - Error: new Error() - }; -} - -if (!eq(tFromJs("variant86"), "variant86")) { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "big_polyvar_test.res", - 700, - 0 - ], - Error: new Error() - }; -} - -if (!eq(tFromJs("variant87"), "variant87")) { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "big_polyvar_test.res", - 701, - 0 - ], - Error: new Error() - }; -} - -if (!eq(tFromJs("variant88"), "variant88")) { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "big_polyvar_test.res", - 702, - 0 - ], - Error: new Error() - }; -} - -if (!eq(tFromJs("variant89"), "variant89")) { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "big_polyvar_test.res", - 703, - 0 - ], - Error: new Error() - }; -} - -if (!eq(tFromJs("variant90"), "variant90")) { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "big_polyvar_test.res", - 704, - 0 - ], - Error: new Error() - }; -} - -if (!eq(tFromJs("variant91"), "variant91")) { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "big_polyvar_test.res", - 705, - 0 - ], - Error: new Error() - }; -} - -if (!eq(tFromJs("variant92"), "variant92")) { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "big_polyvar_test.res", - 706, - 0 - ], - Error: new Error() - }; -} - -if (!eq(tFromJs("variant93"), "variant93")) { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "big_polyvar_test.res", - 707, - 0 - ], - Error: new Error() - }; -} - -if (!eq(tFromJs("variant94"), "variant94")) { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "big_polyvar_test.res", - 708, - 0 - ], - Error: new Error() - }; -} - -if (!eq(tFromJs("variant95"), "variant95")) { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "big_polyvar_test.res", - 709, - 0 - ], - Error: new Error() - }; -} - -if (!eq(tFromJs("variant96"), "variant96")) { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "big_polyvar_test.res", - 710, - 0 - ], - Error: new Error() - }; -} - -if (!eq(tFromJs("variant97"), "variant97")) { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "big_polyvar_test.res", - 711, - 0 - ], - Error: new Error() - }; -} - -if (!eq(tFromJs("variant98"), "variant98")) { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "big_polyvar_test.res", - 712, - 0 - ], - Error: new Error() - }; -} - -if (!eq(tFromJs("variant99"), "variant99")) { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "big_polyvar_test.res", - 713, - 0 - ], - Error: new Error() - }; -} - -if (!eq(tFromJs("variant100"), "variant100")) { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "big_polyvar_test.res", - 714, - 0 - ], - Error: new Error() - }; -} - -if (!eq(tFromJs("variant101"), "variant101")) { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "big_polyvar_test.res", - 715, - 0 - ], - Error: new Error() - }; -} - -if (!eq(tFromJs("variant102"), "variant102")) { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "big_polyvar_test.res", - 716, - 0 - ], - Error: new Error() - }; -} - -if (!eq(tFromJs("variant103"), "variant103")) { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "big_polyvar_test.res", - 717, - 0 - ], - Error: new Error() - }; -} - -if (!eq(tFromJs("variant104"), "variant104")) { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "big_polyvar_test.res", - 718, - 0 - ], - Error: new Error() - }; -} - -if (!eq(tFromJs("variant105"), "variant105")) { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "big_polyvar_test.res", - 719, - 0 - ], - Error: new Error() - }; -} - -if (!eq(tFromJs("variant106"), "variant106")) { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "big_polyvar_test.res", - 720, - 0 - ], - Error: new Error() - }; -} - -if (!eq(tFromJs("variant107"), "variant107")) { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "big_polyvar_test.res", - 721, - 0 - ], - Error: new Error() - }; -} - -if (!eq(tFromJs("variant108"), "variant108")) { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "big_polyvar_test.res", - 722, - 0 - ], - Error: new Error() - }; -} - -if (!eq(tFromJs("variant109"), "variant109")) { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "big_polyvar_test.res", - 723, - 0 - ], - Error: new Error() - }; -} - -if (!eq(tFromJs("variant110"), "variant110")) { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "big_polyvar_test.res", - 724, - 0 - ], - Error: new Error() - }; -} - -if (!eq(tFromJs("variant111"), "variant111")) { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "big_polyvar_test.res", - 725, - 0 - ], - Error: new Error() - }; -} - -if (!eq(tFromJs("variant112"), "variant112")) { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "big_polyvar_test.res", - 726, - 0 - ], - Error: new Error() - }; -} - -if (!eq(tFromJs("variant113"), "variant113")) { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "big_polyvar_test.res", - 727, - 0 - ], - Error: new Error() - }; -} - -if (!eq(tFromJs("variant114"), "variant114")) { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "big_polyvar_test.res", - 728, - 0 - ], - Error: new Error() - }; -} - -if (!eq(tFromJs("variant115"), "variant115")) { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "big_polyvar_test.res", - 729, - 0 - ], - Error: new Error() - }; -} - -if (!eq(tFromJs("variant116"), "variant116")) { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "big_polyvar_test.res", - 730, - 0 - ], - Error: new Error() - }; -} - -if (!eq(tFromJs("variant117"), "variant117")) { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "big_polyvar_test.res", - 731, - 0 - ], - Error: new Error() - }; -} - -if (!eq(tFromJs("variant118"), "variant118")) { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "big_polyvar_test.res", - 732, - 0 - ], - Error: new Error() - }; -} - -if (!eq(tFromJs("variant119"), "variant119")) { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "big_polyvar_test.res", - 733, - 0 - ], - Error: new Error() - }; -} - -if (!eq(tFromJs("variant120"), "variant120")) { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "big_polyvar_test.res", - 734, - 0 - ], - Error: new Error() - }; -} - -if (!eq(tFromJs("variant121"), "variant121")) { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "big_polyvar_test.res", - 735, - 0 - ], - Error: new Error() - }; -} - -if (!eq(tFromJs("variant122"), "variant122")) { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "big_polyvar_test.res", - 736, - 0 - ], - Error: new Error() - }; -} - -if (!eq(tFromJs("variant123"), "variant123")) { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "big_polyvar_test.res", - 737, - 0 - ], - Error: new Error() - }; -} - -if (!eq(tFromJs("variant124"), "variant124")) { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "big_polyvar_test.res", - 738, - 0 - ], - Error: new Error() - }; -} - -if (!eq(tFromJs("variant125"), "variant125")) { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "big_polyvar_test.res", - 739, - 0 - ], - Error: new Error() - }; -} - -if (!eq(tFromJs("variant126"), "variant126")) { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "big_polyvar_test.res", - 740, - 0 - ], - Error: new Error() - }; -} - -if (!eq(tFromJs("variant127"), "variant127")) { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "big_polyvar_test.res", - 741, - 0 - ], - Error: new Error() - }; -} - -if (!eq(tFromJs("variant128"), "variant128")) { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "big_polyvar_test.res", - 742, - 0 - ], - Error: new Error() - }; -} - -if (!eq(tFromJs("variant129"), "variant129")) { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "big_polyvar_test.res", - 743, - 0 - ], - Error: new Error() - }; -} - -if (!eq(tFromJs("variant130"), "variant130")) { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "big_polyvar_test.res", - 744, - 0 - ], - Error: new Error() - }; -} - -if (!eq(tFromJs("variant131"), "variant131")) { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "big_polyvar_test.res", - 745, - 0 - ], - Error: new Error() - }; -} - -if (!eq(tFromJs("variant132"), "variant132")) { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "big_polyvar_test.res", - 746, - 0 - ], - Error: new Error() - }; -} - -if (!eq(tFromJs("variant133"), "variant133")) { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "big_polyvar_test.res", - 747, - 0 - ], - Error: new Error() - }; -} - -if (!eq(tFromJs("variant134"), "variant134")) { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "big_polyvar_test.res", - 748, - 0 - ], - Error: new Error() - }; -} - -if (!eq(tFromJs("variant135"), "variant135")) { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "big_polyvar_test.res", - 749, - 0 - ], - Error: new Error() - }; -} - -if (!eq(tFromJs("variant136"), "variant136")) { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "big_polyvar_test.res", - 750, - 0 - ], - Error: new Error() - }; -} - -if (!eq(tFromJs("variant137"), "variant137")) { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "big_polyvar_test.res", - 751, - 0 - ], - Error: new Error() - }; -} - -if (!eq(tFromJs("variant138"), "variant138")) { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "big_polyvar_test.res", - 752, - 0 - ], - Error: new Error() - }; -} - -if (!eq(tFromJs("variant139"), "variant139")) { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "big_polyvar_test.res", - 753, - 0 - ], - Error: new Error() - }; -} - -if (!eq(tFromJs("variant140"), "variant140")) { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "big_polyvar_test.res", - 754, - 0 - ], - Error: new Error() - }; -} - -if (!eq(tFromJs("variant141"), "variant141")) { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "big_polyvar_test.res", - 755, - 0 - ], - Error: new Error() - }; -} - -if (!eq(tFromJs("variant142"), "variant142")) { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "big_polyvar_test.res", - 756, - 0 - ], - Error: new Error() - }; -} - -if (!eq(tFromJs("variant143"), "variant143")) { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "big_polyvar_test.res", - 757, - 0 - ], - Error: new Error() - }; -} - -if (!eq(tFromJs("variant144"), "variant144")) { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "big_polyvar_test.res", - 758, - 0 - ], - Error: new Error() - }; -} - -if (!eq(tFromJs("variant145"), "variant145")) { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "big_polyvar_test.res", - 759, - 0 - ], - Error: new Error() - }; -} - -if (!eq(tFromJs("variant146"), "variant146")) { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "big_polyvar_test.res", - 760, - 0 - ], - Error: new Error() - }; -} - -if (!eq(tFromJs("variant147"), "variant147")) { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "big_polyvar_test.res", - 761, - 0 - ], - Error: new Error() - }; -} - -if (!eq(tFromJs("variant148"), "variant148")) { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "big_polyvar_test.res", - 762, - 0 - ], - Error: new Error() - }; -} - -if (!eq(tFromJs("variant149"), "variant149")) { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "big_polyvar_test.res", - 763, - 0 - ], - Error: new Error() - }; -} - -if (!eq(tFromJs("variant150"), "variant150")) { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "big_polyvar_test.res", - 764, - 0 - ], - Error: new Error() - }; -} - -if (!eq(tFromJs("variant151"), "variant151")) { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "big_polyvar_test.res", - 765, - 0 - ], - Error: new Error() - }; -} - -if (!eq(tFromJs("variant152"), "variant152")) { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "big_polyvar_test.res", - 766, - 0 - ], - Error: new Error() - }; -} - -if (!eq(tFromJs("variant153"), "variant153")) { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "big_polyvar_test.res", - 767, - 0 - ], - Error: new Error() - }; -} - -if (!eq(tFromJs("variant154"), "variant154")) { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "big_polyvar_test.res", - 768, - 0 - ], - Error: new Error() - }; -} - -if (!eq(tFromJs("variant155"), "variant155")) { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "big_polyvar_test.res", - 769, - 0 - ], - Error: new Error() - }; -} - -if (!eq(tFromJs("variant156"), "variant156")) { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "big_polyvar_test.res", - 770, - 0 - ], - Error: new Error() - }; -} - -if (!eq(tFromJs("variant157"), "variant157")) { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "big_polyvar_test.res", - 771, - 0 - ], - Error: new Error() - }; -} - -if (!eq(tFromJs("variant158"), "variant158")) { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "big_polyvar_test.res", - 772, - 0 - ], - Error: new Error() - }; -} - -if (!eq(tFromJs("variant159"), "variant159")) { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "big_polyvar_test.res", - 773, - 0 - ], - Error: new Error() - }; -} - -if (!eq(tFromJs("variant160"), "variant160")) { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "big_polyvar_test.res", - 774, - 0 - ], - Error: new Error() - }; -} - -if (!eq(tFromJs("variant161"), "variant161")) { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "big_polyvar_test.res", - 775, - 0 - ], - Error: new Error() - }; -} - -if (!eq(tFromJs("variant162"), "variant162")) { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "big_polyvar_test.res", - 776, - 0 - ], - Error: new Error() - }; -} - -if (!eq(tFromJs("variant163"), "variant163")) { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "big_polyvar_test.res", - 777, - 0 - ], - Error: new Error() - }; -} - -if (!eq(tFromJs("variant164"), "variant164")) { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "big_polyvar_test.res", - 778, - 0 - ], - Error: new Error() - }; -} - -if (!eq(tFromJs("variant165"), "variant165")) { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "big_polyvar_test.res", - 779, - 0 - ], - Error: new Error() - }; -} - -if (!eq(tFromJs("variant166"), "variant166")) { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "big_polyvar_test.res", - 780, - 0 - ], - Error: new Error() - }; -} - -if (!eq(tFromJs("variant167"), "variant167")) { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "big_polyvar_test.res", - 781, - 0 - ], - Error: new Error() - }; -} - -if (!eq(tFromJs("variant168"), "variant168")) { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "big_polyvar_test.res", - 782, - 0 - ], - Error: new Error() - }; -} - -if (!eq(tFromJs("variant169"), "variant169")) { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "big_polyvar_test.res", - 783, - 0 - ], - Error: new Error() - }; -} - -if (!eq(tFromJs("variant170"), "variant170")) { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "big_polyvar_test.res", - 784, - 0 - ], - Error: new Error() - }; -} - -if (!eq(tFromJs("variant171"), "variant171")) { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "big_polyvar_test.res", - 785, - 0 - ], - Error: new Error() - }; -} - -if (!eq(tFromJs("variant172"), "variant172")) { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "big_polyvar_test.res", - 786, - 0 - ], - Error: new Error() - }; -} - -if (!eq(tFromJs("variant173"), "variant173")) { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "big_polyvar_test.res", - 787, - 0 - ], - Error: new Error() - }; -} - -if (!eq(tFromJs("variant174"), "variant174")) { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "big_polyvar_test.res", - 788, - 0 - ], - Error: new Error() - }; -} - -if (!eq(tFromJs("variant175"), "variant175")) { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "big_polyvar_test.res", - 789, - 0 - ], - Error: new Error() - }; -} - -if (!eq(tFromJs("variant176"), "variant176")) { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "big_polyvar_test.res", - 790, - 0 - ], - Error: new Error() - }; -} - -if (!eq(tFromJs("variant177"), "variant177")) { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "big_polyvar_test.res", - 791, - 0 - ], - Error: new Error() - }; -} - -if (!eq(tFromJs("variant178"), "variant178")) { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "big_polyvar_test.res", - 792, - 0 - ], - Error: new Error() - }; -} - -if (!eq(tFromJs("variant179"), "variant179")) { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "big_polyvar_test.res", - 793, - 0 - ], - Error: new Error() - }; -} - -if (!eq(tFromJs("variant180"), "variant180")) { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "big_polyvar_test.res", - 794, - 0 - ], - Error: new Error() - }; -} - -if (!eq(tFromJs("variant181"), "variant181")) { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "big_polyvar_test.res", - 795, - 0 - ], - Error: new Error() - }; -} - -if (!eq(tFromJs("variant182"), "variant182")) { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "big_polyvar_test.res", - 796, - 0 - ], - Error: new Error() - }; -} - -if (!eq(tFromJs("variant183"), "variant183")) { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "big_polyvar_test.res", - 797, - 0 - ], - Error: new Error() - }; -} - -if (!eq(tFromJs("variant184"), "variant184")) { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "big_polyvar_test.res", - 798, - 0 - ], - Error: new Error() - }; -} - -if (!eq(tFromJs("variant185"), "variant185")) { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "big_polyvar_test.res", - 799, - 0 - ], - Error: new Error() - }; -} - -if (!eq(tFromJs("variant186"), "variant186")) { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "big_polyvar_test.res", - 800, - 0 - ], - Error: new Error() - }; -} - -if (!eq(tFromJs("variant187"), "variant187")) { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "big_polyvar_test.res", - 801, - 0 - ], - Error: new Error() - }; -} - -if (!eq(tFromJs("variant188"), "variant188")) { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "big_polyvar_test.res", - 802, - 0 - ], - Error: new Error() - }; -} - -if (!eq(tFromJs("variant189"), "variant189")) { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "big_polyvar_test.res", - 803, - 0 - ], - Error: new Error() - }; -} - -if (!eq(tFromJs("variant190"), "variant190")) { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "big_polyvar_test.res", - 804, - 0 - ], - Error: new Error() - }; -} - -if (!eq(tFromJs("variant191"), "variant191")) { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "big_polyvar_test.res", - 805, - 0 - ], - Error: new Error() - }; -} - -if (!eq(tFromJs("variant192"), "variant192")) { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "big_polyvar_test.res", - 806, - 0 - ], - Error: new Error() - }; -} - -if (!eq(tFromJs("variant193"), "variant193")) { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "big_polyvar_test.res", - 807, - 0 - ], - Error: new Error() - }; -} - -if (!eq(tFromJs("variant194"), "variant194")) { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "big_polyvar_test.res", - 808, - 0 - ], - Error: new Error() - }; -} - -if (!eq(tFromJs("variant195"), "variant195")) { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "big_polyvar_test.res", - 809, - 0 - ], - Error: new Error() - }; -} - -if (!eq(tFromJs("variant196"), "variant196")) { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "big_polyvar_test.res", - 810, - 0 - ], - Error: new Error() - }; -} - -if (!eq(tFromJs("variant197"), "variant197")) { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "big_polyvar_test.res", - 811, - 0 - ], - Error: new Error() - }; -} - -if (!eq(tFromJs("variant198"), "variant198")) { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "big_polyvar_test.res", - 812, - 0 - ], - Error: new Error() - }; -} - -if (!eq(tFromJs("variant199"), "variant199")) { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "big_polyvar_test.res", - 813, - 0 - ], - Error: new Error() - }; -} - -if (!eq(tFromJs("variant200"), "variant200")) { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "big_polyvar_test.res", - 814, - 0 - ], - Error: new Error() - }; -} - -if (!eq(tFromJs("variant201"), "variant201")) { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "big_polyvar_test.res", - 815, - 0 - ], - Error: new Error() - }; -} - -if (!eq(tFromJs("variant202"), "variant202")) { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "big_polyvar_test.res", - 816, - 0 - ], - Error: new Error() - }; -} - -if (!eq(tFromJs("variant203"), "variant203")) { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "big_polyvar_test.res", - 817, - 0 - ], - Error: new Error() - }; -} - -if (!eq(tFromJs("variant204"), "variant204")) { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "big_polyvar_test.res", - 818, - 0 - ], - Error: new Error() - }; -} - -if (!eq(tFromJs("variant205"), "variant205")) { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "big_polyvar_test.res", - 819, - 0 - ], - Error: new Error() - }; -} - -if (!eq(tFromJs("variant206"), "variant206")) { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "big_polyvar_test.res", - 820, - 0 - ], - Error: new Error() - }; -} - -if (!eq(tFromJs("variant207"), "variant207")) { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "big_polyvar_test.res", - 821, - 0 - ], - Error: new Error() - }; -} - -if (!eq(tFromJs("variant208"), "variant208")) { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "big_polyvar_test.res", - 822, - 0 - ], - Error: new Error() - }; -} - -if (!eq(tFromJs("variant209"), "variant209")) { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "big_polyvar_test.res", - 823, - 0 - ], - Error: new Error() - }; -} - -if (!eq(tFromJs("variant210"), "variant210")) { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "big_polyvar_test.res", - 824, - 0 - ], - Error: new Error() - }; -} - -if (!eq(tFromJs("variant211"), "variant211")) { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "big_polyvar_test.res", - 825, - 0 - ], - Error: new Error() - }; -} - -if (!eq(tFromJs("variant212"), "variant212")) { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "big_polyvar_test.res", - 826, - 0 - ], - Error: new Error() - }; -} - -if (!eq(tFromJs("variant213"), "variant213")) { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "big_polyvar_test.res", - 827, - 0 - ], - Error: new Error() - }; -} - -if (!eq(tFromJs("variant214"), "variant214")) { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "big_polyvar_test.res", - 828, - 0 - ], - Error: new Error() - }; -} - -if (!eq(tFromJs("variant215"), "variant215")) { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "big_polyvar_test.res", - 829, - 0 - ], - Error: new Error() - }; -} - -if (!eq(tFromJs("variant216"), "variant216")) { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "big_polyvar_test.res", - 830, - 0 - ], - Error: new Error() - }; -} - -if (!eq(tFromJs("variant217"), "variant217")) { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "big_polyvar_test.res", - 831, - 0 - ], - Error: new Error() - }; -} - -if (!eq(tFromJs("variant218"), "variant218")) { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "big_polyvar_test.res", - 832, - 0 - ], - Error: new Error() - }; -} - -if (!eq(tFromJs("variant219"), "variant219")) { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "big_polyvar_test.res", - 833, - 0 - ], - Error: new Error() - }; -} - -if (!eq(tFromJs("variant220"), "variant220")) { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "big_polyvar_test.res", - 834, - 0 - ], - Error: new Error() - }; -} - -if (!eq(tFromJs("variant221"), "variant221")) { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "big_polyvar_test.res", - 835, - 0 - ], - Error: new Error() - }; -} - -if (!eq(tFromJs("variant222"), "variant222")) { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "big_polyvar_test.res", - 836, - 0 - ], - Error: new Error() - }; -} - -if (!eq(tFromJs("variant223"), "variant223")) { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "big_polyvar_test.res", - 837, - 0 - ], - Error: new Error() - }; -} - -if (!eq(tFromJs("variant224"), "variant224")) { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "big_polyvar_test.res", - 838, - 0 - ], - Error: new Error() - }; -} - -if (!eq(tFromJs("variant225"), "variant225")) { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "big_polyvar_test.res", - 839, - 0 - ], - Error: new Error() - }; -} - -if (!eq(tFromJs("variant226"), "variant226")) { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "big_polyvar_test.res", - 840, - 0 - ], - Error: new Error() - }; -} - -if (!eq(tFromJs("variant227"), "variant227")) { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "big_polyvar_test.res", - 841, - 0 - ], - Error: new Error() - }; -} - -if (!eq(tFromJs("variant228"), "variant228")) { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "big_polyvar_test.res", - 842, - 0 - ], - Error: new Error() - }; -} - -if (!eq(tFromJs("variant229"), "variant229")) { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "big_polyvar_test.res", - 843, - 0 - ], - Error: new Error() - }; -} - -if (!eq(tFromJs("variant230"), "variant230")) { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "big_polyvar_test.res", - 844, - 0 - ], - Error: new Error() - }; -} - -if (!eq(tFromJs("variant231"), "variant231")) { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "big_polyvar_test.res", - 845, - 0 - ], - Error: new Error() - }; -} - -if (!eq(tFromJs("variant232"), "variant232")) { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "big_polyvar_test.res", - 846, - 0 - ], - Error: new Error() - }; -} - -if (!eq(tFromJs("variant233"), "variant233")) { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "big_polyvar_test.res", - 847, - 0 - ], - Error: new Error() - }; -} - -if (!eq(tFromJs("variant234"), "variant234")) { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "big_polyvar_test.res", - 848, - 0 - ], - Error: new Error() - }; -} - -if (!eq(tFromJs("variant235"), "variant235")) { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "big_polyvar_test.res", - 849, - 0 - ], - Error: new Error() - }; -} - -if (!eq(tFromJs("variant236"), "variant236")) { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "big_polyvar_test.res", - 850, - 0 - ], - Error: new Error() - }; -} - -if (!eq(tFromJs("variant237"), "variant237")) { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "big_polyvar_test.res", - 851, - 0 - ], - Error: new Error() - }; -} - -if (!eq(tFromJs("variant238"), "variant238")) { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "big_polyvar_test.res", - 852, - 0 - ], - Error: new Error() - }; -} - -if (!eq(tFromJs("variant239"), "variant239")) { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "big_polyvar_test.res", - 853, - 0 - ], - Error: new Error() - }; -} - -if (!eq(tFromJs("variant240"), "variant240")) { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "big_polyvar_test.res", - 854, - 0 - ], - Error: new Error() - }; -} - -if (!eq(tFromJs("variant241"), "variant241")) { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "big_polyvar_test.res", - 855, - 0 - ], - Error: new Error() - }; -} - -if (!eq(tFromJs("variant242"), "variant242")) { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "big_polyvar_test.res", - 856, - 0 - ], - Error: new Error() - }; -} - -if (!eq(tFromJs("variant243"), "variant243")) { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "big_polyvar_test.res", - 857, - 0 - ], - Error: new Error() - }; -} - -if (!eq(tFromJs("variant244"), "variant244")) { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "big_polyvar_test.res", - 858, - 0 - ], - Error: new Error() - }; -} - -if (!eq(tFromJs("variant245"), "variant245")) { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "big_polyvar_test.res", - 859, - 0 - ], - Error: new Error() - }; -} - -if (!eq(tFromJs("variant246"), "variant246")) { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "big_polyvar_test.res", - 860, - 0 - ], - Error: new Error() - }; -} - -if (!eq(tFromJs("variant247"), "variant247")) { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "big_polyvar_test.res", - 861, - 0 - ], - Error: new Error() - }; -} - -if (!eq(tFromJs("variant248"), "variant248")) { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "big_polyvar_test.res", - 862, - 0 - ], - Error: new Error() - }; -} - -if (!eq(tFromJs("variant249"), "variant249")) { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "big_polyvar_test.res", - 863, - 0 - ], - Error: new Error() - }; -} - -if (!eq(tFromJs("variant250"), "variant250")) { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "big_polyvar_test.res", - 864, - 0 - ], - Error: new Error() - }; -} - -if (!eq(tFromJs("variant251"), "variant251")) { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "big_polyvar_test.res", - 865, - 0 - ], - Error: new Error() - }; -} - -if (!eq(tFromJs("variant252"), "variant252")) { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "big_polyvar_test.res", - 866, - 0 - ], - Error: new Error() - }; -} - -if (!eq(tFromJs("variant253"), "variant253")) { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "big_polyvar_test.res", - 867, - 0 - ], - Error: new Error() - }; -} - -if (!eq(tFromJs("variant254"), "variant254")) { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "big_polyvar_test.res", - 868, - 0 - ], - Error: new Error() - }; -} - -if (!eq(tFromJs("variant255"), "variant255")) { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "big_polyvar_test.res", - 869, - 0 - ], - Error: new Error() - }; -} - -if (!eq(tFromJs("variant256"), "variant256")) { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "big_polyvar_test.res", - 870, - 0 - ], - Error: new Error() - }; -} - -if (!eq(tFromJs("variant257"), "variant257")) { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "big_polyvar_test.res", - 871, - 0 - ], - Error: new Error() - }; -} - -if (!eq(tFromJs("variant258"), "variant258")) { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "big_polyvar_test.res", - 872, - 0 - ], - Error: new Error() - }; -} - -if (!eq(tFromJs("variant259"), "variant259")) { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "big_polyvar_test.res", - 873, - 0 - ], - Error: new Error() - }; -} - -if (!eq(tFromJs("variant260"), "variant260")) { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "big_polyvar_test.res", - 874, - 0 - ], - Error: new Error() - }; -} - -if (!eq(tFromJs("variant261"), "variant261")) { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "big_polyvar_test.res", - 875, - 0 - ], - Error: new Error() - }; -} - -if (!eq(tFromJs("variant262"), "variant262")) { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "big_polyvar_test.res", - 876, - 0 - ], - Error: new Error() - }; -} - -if (!eq(tFromJs("variant263"), "variant263")) { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "big_polyvar_test.res", - 877, - 0 - ], - Error: new Error() - }; -} - -if (!eq(tFromJs("variant264"), "variant264")) { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "big_polyvar_test.res", - 878, - 0 - ], - Error: new Error() - }; -} - -if (!eq(tFromJs("variant265"), "variant265")) { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "big_polyvar_test.res", - 879, - 0 - ], - Error: new Error() - }; -} - -if (!eq(tFromJs("variant266"), "variant266")) { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "big_polyvar_test.res", - 880, - 0 - ], - Error: new Error() - }; -} - -if (!eq(tFromJs("variant267"), "variant267")) { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "big_polyvar_test.res", - 881, - 0 - ], - Error: new Error() - }; -} - -if (!eq(tFromJs("variant268"), "variant268")) { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "big_polyvar_test.res", - 882, - 0 - ], - Error: new Error() - }; -} - -if (!eq(tFromJs("variant269"), "variant269")) { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "big_polyvar_test.res", - 883, - 0 - ], - Error: new Error() - }; -} - -if (!eq(tFromJs("variant270"), "variant270")) { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "big_polyvar_test.res", - 884, - 0 - ], - Error: new Error() - }; -} - -if (!eq(tFromJs("variant271"), "variant271")) { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "big_polyvar_test.res", - 885, - 0 - ], - Error: new Error() - }; -} - -if (!eq(tFromJs("variant272"), "variant272")) { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "big_polyvar_test.res", - 886, - 0 - ], - Error: new Error() - }; -} - -if (!eq(tFromJs("variant273"), "variant273")) { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "big_polyvar_test.res", - 887, - 0 - ], - Error: new Error() - }; -} - -if (!eq(tFromJs("variant274"), "variant274")) { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "big_polyvar_test.res", - 888, - 0 - ], - Error: new Error() - }; -} - -if (!eq(tFromJs("variant275"), "variant275")) { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "big_polyvar_test.res", - 889, - 0 - ], - Error: new Error() - }; -} - -if (!eq(tFromJs("variant276"), "variant276")) { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "big_polyvar_test.res", - 890, - 0 - ], - Error: new Error() - }; -} - -if (!eq(tFromJs("variant277"), "variant277")) { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "big_polyvar_test.res", - 891, - 0 - ], - Error: new Error() - }; -} - -if (!eq(tFromJs("variant278"), "variant278")) { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "big_polyvar_test.res", - 892, - 0 - ], - Error: new Error() - }; -} - -if (!eq(tFromJs("variant279"), "variant279")) { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "big_polyvar_test.res", - 893, - 0 - ], - Error: new Error() - }; -} - -if (!eq(tFromJs("variant280"), "variant280")) { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "big_polyvar_test.res", - 894, - 0 - ], - Error: new Error() - }; -} - -if (!eq(tFromJs("variant281"), "variant281")) { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "big_polyvar_test.res", - 895, - 0 - ], - Error: new Error() - }; -} - -if (!eq(tFromJs("variant282"), "variant282")) { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "big_polyvar_test.res", - 896, - 0 - ], - Error: new Error() - }; -} - -if (!eq(tFromJs("variant283"), "variant283")) { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "big_polyvar_test.res", - 897, - 0 - ], - Error: new Error() - }; -} - -if (!eq(tFromJs("variant284"), "variant284")) { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "big_polyvar_test.res", - 898, - 0 - ], - Error: new Error() - }; -} - -if (!eq(tFromJs("variant285"), "variant285")) { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "big_polyvar_test.res", - 899, - 0 - ], - Error: new Error() - }; -} - -if (!eq(tFromJs("variant286"), "variant286")) { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "big_polyvar_test.res", - 900, - 0 - ], - Error: new Error() - }; -} - -if (!eq(tFromJs("variant287"), "variant287")) { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "big_polyvar_test.res", - 901, - 0 - ], - Error: new Error() - }; -} - -if (!eq(tFromJs("variant288"), "variant288")) { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "big_polyvar_test.res", - 902, - 0 - ], - Error: new Error() - }; -} - -if (!eq(tFromJs("variant289"), "variant289")) { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "big_polyvar_test.res", - 903, - 0 - ], - Error: new Error() - }; -} - -if (!eq(tFromJs("variant290"), "variant290")) { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "big_polyvar_test.res", - 904, - 0 - ], - Error: new Error() - }; -} - -if (!eq(tFromJs("variant291"), "variant291")) { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "big_polyvar_test.res", - 905, - 0 - ], - Error: new Error() - }; -} - -if (!eq(tFromJs("variant292"), "variant292")) { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "big_polyvar_test.res", - 906, - 0 - ], - Error: new Error() - }; -} - -if (!eq(tFromJs("variant293"), "variant293")) { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "big_polyvar_test.res", - 907, - 0 - ], - Error: new Error() - }; -} - -if (!eq(tFromJs("variant294"), "variant294")) { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "big_polyvar_test.res", - 908, - 0 - ], - Error: new Error() - }; -} - -if (!eq(tFromJs("variant295"), "variant295")) { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "big_polyvar_test.res", - 909, - 0 - ], - Error: new Error() - }; -} - -if (!eq(tFromJs("variant296"), "variant296")) { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "big_polyvar_test.res", - 910, - 0 - ], - Error: new Error() - }; -} - -if (!eq(tFromJs("variant297"), "variant297")) { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "big_polyvar_test.res", - 911, - 0 - ], - Error: new Error() - }; -} - -if (!eq(tFromJs("variant298"), "variant298")) { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "big_polyvar_test.res", - 912, - 0 - ], - Error: new Error() - }; -} - -if (!eq(tFromJs("variant299"), "variant299")) { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "big_polyvar_test.res", - 913, - 0 - ], - Error: new Error() - }; -} - -if (!eq(tFromJs("xx"), undefined)) { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "big_polyvar_test.res", - 914, - 0 - ], - Error: new Error() - }; -} - -exports.tToJs = tToJs; -exports.tFromJs = tFromJs; -exports.eq = eq; -/* Not a pure module */ diff --git a/tests/tests/src/big_polyvar_test.mjs b/tests/tests/src/big_polyvar_test.mjs new file mode 100644 index 0000000000..7a170c28ed --- /dev/null +++ b/tests/tests/src/big_polyvar_test.mjs @@ -0,0 +1,7243 @@ +// Generated by ReScript, PLEASE EDIT WITH CARE + + +let _map = {"variant0":"variant0","variant1":"variant1","variant2":"variant2","variant3":"variant3","variant4":"variant4","variant5":"variant5","variant6":"variant6","variant7":"variant7","variant8":"variant8","variant9":"variant9","variant10":"variant10","variant11":"variant11","variant12":"variant12","variant13":"variant13","variant14":"variant14","variant15":"variant15","variant16":"variant16","variant17":"variant17","variant18":"variant18","variant19":"variant19","variant20":"variant20","variant21":"variant21","variant22":"variant22","variant23":"variant23","variant24":"variant24","variant25":"variant25","variant26":"variant26","variant27":"variant27","variant28":"variant28","variant29":"variant29","variant30":"variant30","variant31":"variant31","variant32":"variant32","variant33":"variant33","variant34":"variant34","variant35":"variant35","variant36":"variant36","variant37":"variant37","variant38":"variant38","variant39":"variant39","variant40":"variant40","variant41":"variant41","variant42":"variant42","variant43":"variant43","variant44":"variant44","variant45":"variant45","variant46":"variant46","variant47":"variant47","variant48":"variant48","variant49":"variant49","variant50":"variant50","variant51":"variant51","variant52":"variant52","variant53":"variant53","variant54":"variant54","variant55":"variant55","variant56":"variant56","variant57":"variant57","variant58":"variant58","variant59":"variant59","variant60":"variant60","variant61":"variant61","variant62":"variant62","variant63":"variant63","variant64":"variant64","variant65":"variant65","variant66":"variant66","variant67":"variant67","variant68":"variant68","variant69":"variant69","variant70":"variant70","variant71":"variant71","variant72":"variant72","variant73":"variant73","variant74":"variant74","variant75":"variant75","variant76":"variant76","variant77":"variant77","variant78":"variant78","variant79":"variant79","variant80":"variant80","variant81":"variant81","variant82":"variant82","variant83":"variant83","variant84":"variant84","variant85":"variant85","variant86":"variant86","variant87":"variant87","variant88":"variant88","variant89":"variant89","variant90":"variant90","variant91":"variant91","variant92":"variant92","variant93":"variant93","variant94":"variant94","variant95":"variant95","variant96":"variant96","variant97":"variant97","variant98":"variant98","variant99":"variant99","variant100":"variant100","variant101":"variant101","variant102":"variant102","variant103":"variant103","variant104":"variant104","variant105":"variant105","variant106":"variant106","variant107":"variant107","variant108":"variant108","variant109":"variant109","variant110":"variant110","variant111":"variant111","variant112":"variant112","variant113":"variant113","variant114":"variant114","variant115":"variant115","variant116":"variant116","variant117":"variant117","variant118":"variant118","variant119":"variant119","variant120":"variant120","variant121":"variant121","variant122":"variant122","variant123":"variant123","variant124":"variant124","variant125":"variant125","variant126":"variant126","variant127":"variant127","variant128":"variant128","variant129":"variant129","variant130":"variant130","variant131":"variant131","variant132":"variant132","variant133":"variant133","variant134":"variant134","variant135":"variant135","variant136":"variant136","variant137":"variant137","variant138":"variant138","variant139":"variant139","variant140":"variant140","variant141":"variant141","variant142":"variant142","variant143":"variant143","variant144":"variant144","variant145":"variant145","variant146":"variant146","variant147":"variant147","variant148":"variant148","variant149":"variant149","variant150":"variant150","variant151":"variant151","variant152":"variant152","variant153":"variant153","variant154":"variant154","variant155":"variant155","variant156":"variant156","variant157":"variant157","variant158":"variant158","variant159":"variant159","variant160":"variant160","variant161":"variant161","variant162":"variant162","variant163":"variant163","variant164":"variant164","variant165":"variant165","variant166":"variant166","variant167":"variant167","variant168":"variant168","variant169":"variant169","variant170":"variant170","variant171":"variant171","variant172":"variant172","variant173":"variant173","variant174":"variant174","variant175":"variant175","variant176":"variant176","variant177":"variant177","variant178":"variant178","variant179":"variant179","variant180":"variant180","variant181":"variant181","variant182":"variant182","variant183":"variant183","variant184":"variant184","variant185":"variant185","variant186":"variant186","variant187":"variant187","variant188":"variant188","variant189":"variant189","variant190":"variant190","variant191":"variant191","variant192":"variant192","variant193":"variant193","variant194":"variant194","variant195":"variant195","variant196":"variant196","variant197":"variant197","variant198":"variant198","variant199":"variant199","variant200":"variant200","variant201":"variant201","variant202":"variant202","variant203":"variant203","variant204":"variant204","variant205":"variant205","variant206":"variant206","variant207":"variant207","variant208":"variant208","variant209":"variant209","variant210":"variant210","variant211":"variant211","variant212":"variant212","variant213":"variant213","variant214":"variant214","variant215":"variant215","variant216":"variant216","variant217":"variant217","variant218":"variant218","variant219":"variant219","variant220":"variant220","variant221":"variant221","variant222":"variant222","variant223":"variant223","variant224":"variant224","variant225":"variant225","variant226":"variant226","variant227":"variant227","variant228":"variant228","variant229":"variant229","variant230":"variant230","variant231":"variant231","variant232":"variant232","variant233":"variant233","variant234":"variant234","variant235":"variant235","variant236":"variant236","variant237":"variant237","variant238":"variant238","variant239":"variant239","variant240":"variant240","variant241":"variant241","variant242":"variant242","variant243":"variant243","variant244":"variant244","variant245":"variant245","variant246":"variant246","variant247":"variant247","variant248":"variant248","variant249":"variant249","variant250":"variant250","variant251":"variant251","variant252":"variant252","variant253":"variant253","variant254":"variant254","variant255":"variant255","variant256":"variant256","variant257":"variant257","variant258":"variant258","variant259":"variant259","variant260":"variant260","variant261":"variant261","variant262":"variant262","variant263":"variant263","variant264":"variant264","variant265":"variant265","variant266":"variant266","variant267":"variant267","variant268":"variant268","variant269":"variant269","variant270":"variant270","variant271":"variant271","variant272":"variant272","variant273":"variant273","variant274":"variant274","variant275":"variant275","variant276":"variant276","variant277":"variant277","variant278":"variant278","variant279":"variant279","variant280":"variant280","variant281":"variant281","variant282":"variant282","variant283":"variant283","variant284":"variant284","variant285":"variant285","variant286":"variant286","variant287":"variant287","variant288":"variant288","variant289":"variant289","variant290":"variant290","variant291":"variant291","variant292":"variant292","variant293":"variant293","variant294":"variant294","variant295":"variant295","variant296":"variant296","variant297":"variant297","variant298":"variant298","variant299":"variant299"}; + +function tToJs(param) { + return param; +} + +function tFromJs(param) { + return _map[param]; +} + +function eq(x, y) { + if (x !== undefined) { + if (y !== undefined) { + return x === y; + } else { + return false; + } + } else { + return y === undefined; + } +} + +if ("variant0" !== "variant0") { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "big_polyvar_test.res", + 314, + 0 + ], + Error: new Error() + }; +} + +if ("variant1" !== "variant1") { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "big_polyvar_test.res", + 315, + 0 + ], + Error: new Error() + }; +} + +if ("variant2" !== "variant2") { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "big_polyvar_test.res", + 316, + 0 + ], + Error: new Error() + }; +} + +if ("variant3" !== "variant3") { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "big_polyvar_test.res", + 317, + 0 + ], + Error: new Error() + }; +} + +if ("variant4" !== "variant4") { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "big_polyvar_test.res", + 318, + 0 + ], + Error: new Error() + }; +} + +if ("variant5" !== "variant5") { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "big_polyvar_test.res", + 319, + 0 + ], + Error: new Error() + }; +} + +if ("variant6" !== "variant6") { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "big_polyvar_test.res", + 320, + 0 + ], + Error: new Error() + }; +} + +if ("variant7" !== "variant7") { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "big_polyvar_test.res", + 321, + 0 + ], + Error: new Error() + }; +} + +if ("variant8" !== "variant8") { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "big_polyvar_test.res", + 322, + 0 + ], + Error: new Error() + }; +} + +if ("variant9" !== "variant9") { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "big_polyvar_test.res", + 323, + 0 + ], + Error: new Error() + }; +} + +if ("variant10" !== "variant10") { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "big_polyvar_test.res", + 324, + 0 + ], + Error: new Error() + }; +} + +if ("variant11" !== "variant11") { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "big_polyvar_test.res", + 325, + 0 + ], + Error: new Error() + }; +} + +if ("variant12" !== "variant12") { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "big_polyvar_test.res", + 326, + 0 + ], + Error: new Error() + }; +} + +if ("variant13" !== "variant13") { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "big_polyvar_test.res", + 327, + 0 + ], + Error: new Error() + }; +} + +if ("variant14" !== "variant14") { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "big_polyvar_test.res", + 328, + 0 + ], + Error: new Error() + }; +} + +if ("variant15" !== "variant15") { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "big_polyvar_test.res", + 329, + 0 + ], + Error: new Error() + }; +} + +if ("variant16" !== "variant16") { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "big_polyvar_test.res", + 330, + 0 + ], + Error: new Error() + }; +} + +if ("variant17" !== "variant17") { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "big_polyvar_test.res", + 331, + 0 + ], + Error: new Error() + }; +} + +if ("variant18" !== "variant18") { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "big_polyvar_test.res", + 332, + 0 + ], + Error: new Error() + }; +} + +if ("variant19" !== "variant19") { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "big_polyvar_test.res", + 333, + 0 + ], + Error: new Error() + }; +} + +if ("variant20" !== "variant20") { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "big_polyvar_test.res", + 334, + 0 + ], + Error: new Error() + }; +} + +if ("variant21" !== "variant21") { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "big_polyvar_test.res", + 335, + 0 + ], + Error: new Error() + }; +} + +if ("variant22" !== "variant22") { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "big_polyvar_test.res", + 336, + 0 + ], + Error: new Error() + }; +} + +if ("variant23" !== "variant23") { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "big_polyvar_test.res", + 337, + 0 + ], + Error: new Error() + }; +} + +if ("variant24" !== "variant24") { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "big_polyvar_test.res", + 338, + 0 + ], + Error: new Error() + }; +} + +if ("variant25" !== "variant25") { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "big_polyvar_test.res", + 339, + 0 + ], + Error: new Error() + }; +} + +if ("variant26" !== "variant26") { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "big_polyvar_test.res", + 340, + 0 + ], + Error: new Error() + }; +} + +if ("variant27" !== "variant27") { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "big_polyvar_test.res", + 341, + 0 + ], + Error: new Error() + }; +} + +if ("variant28" !== "variant28") { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "big_polyvar_test.res", + 342, + 0 + ], + Error: new Error() + }; +} + +if ("variant29" !== "variant29") { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "big_polyvar_test.res", + 343, + 0 + ], + Error: new Error() + }; +} + +if ("variant30" !== "variant30") { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "big_polyvar_test.res", + 344, + 0 + ], + Error: new Error() + }; +} + +if ("variant31" !== "variant31") { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "big_polyvar_test.res", + 345, + 0 + ], + Error: new Error() + }; +} + +if ("variant32" !== "variant32") { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "big_polyvar_test.res", + 346, + 0 + ], + Error: new Error() + }; +} + +if ("variant33" !== "variant33") { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "big_polyvar_test.res", + 347, + 0 + ], + Error: new Error() + }; +} + +if ("variant34" !== "variant34") { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "big_polyvar_test.res", + 348, + 0 + ], + Error: new Error() + }; +} + +if ("variant35" !== "variant35") { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "big_polyvar_test.res", + 349, + 0 + ], + Error: new Error() + }; +} + +if ("variant36" !== "variant36") { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "big_polyvar_test.res", + 350, + 0 + ], + Error: new Error() + }; +} + +if ("variant37" !== "variant37") { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "big_polyvar_test.res", + 351, + 0 + ], + Error: new Error() + }; +} + +if ("variant38" !== "variant38") { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "big_polyvar_test.res", + 352, + 0 + ], + Error: new Error() + }; +} + +if ("variant39" !== "variant39") { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "big_polyvar_test.res", + 353, + 0 + ], + Error: new Error() + }; +} + +if ("variant40" !== "variant40") { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "big_polyvar_test.res", + 354, + 0 + ], + Error: new Error() + }; +} + +if ("variant41" !== "variant41") { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "big_polyvar_test.res", + 355, + 0 + ], + Error: new Error() + }; +} + +if ("variant42" !== "variant42") { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "big_polyvar_test.res", + 356, + 0 + ], + Error: new Error() + }; +} + +if ("variant43" !== "variant43") { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "big_polyvar_test.res", + 357, + 0 + ], + Error: new Error() + }; +} + +if ("variant44" !== "variant44") { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "big_polyvar_test.res", + 358, + 0 + ], + Error: new Error() + }; +} + +if ("variant45" !== "variant45") { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "big_polyvar_test.res", + 359, + 0 + ], + Error: new Error() + }; +} + +if ("variant46" !== "variant46") { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "big_polyvar_test.res", + 360, + 0 + ], + Error: new Error() + }; +} + +if ("variant47" !== "variant47") { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "big_polyvar_test.res", + 361, + 0 + ], + Error: new Error() + }; +} + +if ("variant48" !== "variant48") { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "big_polyvar_test.res", + 362, + 0 + ], + Error: new Error() + }; +} + +if ("variant49" !== "variant49") { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "big_polyvar_test.res", + 363, + 0 + ], + Error: new Error() + }; +} + +if ("variant50" !== "variant50") { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "big_polyvar_test.res", + 364, + 0 + ], + Error: new Error() + }; +} + +if ("variant51" !== "variant51") { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "big_polyvar_test.res", + 365, + 0 + ], + Error: new Error() + }; +} + +if ("variant52" !== "variant52") { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "big_polyvar_test.res", + 366, + 0 + ], + Error: new Error() + }; +} + +if ("variant53" !== "variant53") { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "big_polyvar_test.res", + 367, + 0 + ], + Error: new Error() + }; +} + +if ("variant54" !== "variant54") { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "big_polyvar_test.res", + 368, + 0 + ], + Error: new Error() + }; +} + +if ("variant55" !== "variant55") { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "big_polyvar_test.res", + 369, + 0 + ], + Error: new Error() + }; +} + +if ("variant56" !== "variant56") { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "big_polyvar_test.res", + 370, + 0 + ], + Error: new Error() + }; +} + +if ("variant57" !== "variant57") { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "big_polyvar_test.res", + 371, + 0 + ], + Error: new Error() + }; +} + +if ("variant58" !== "variant58") { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "big_polyvar_test.res", + 372, + 0 + ], + Error: new Error() + }; +} + +if ("variant59" !== "variant59") { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "big_polyvar_test.res", + 373, + 0 + ], + Error: new Error() + }; +} + +if ("variant60" !== "variant60") { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "big_polyvar_test.res", + 374, + 0 + ], + Error: new Error() + }; +} + +if ("variant61" !== "variant61") { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "big_polyvar_test.res", + 375, + 0 + ], + Error: new Error() + }; +} + +if ("variant62" !== "variant62") { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "big_polyvar_test.res", + 376, + 0 + ], + Error: new Error() + }; +} + +if ("variant63" !== "variant63") { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "big_polyvar_test.res", + 377, + 0 + ], + Error: new Error() + }; +} + +if ("variant64" !== "variant64") { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "big_polyvar_test.res", + 378, + 0 + ], + Error: new Error() + }; +} + +if ("variant65" !== "variant65") { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "big_polyvar_test.res", + 379, + 0 + ], + Error: new Error() + }; +} + +if ("variant66" !== "variant66") { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "big_polyvar_test.res", + 380, + 0 + ], + Error: new Error() + }; +} + +if ("variant67" !== "variant67") { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "big_polyvar_test.res", + 381, + 0 + ], + Error: new Error() + }; +} + +if ("variant68" !== "variant68") { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "big_polyvar_test.res", + 382, + 0 + ], + Error: new Error() + }; +} + +if ("variant69" !== "variant69") { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "big_polyvar_test.res", + 383, + 0 + ], + Error: new Error() + }; +} + +if ("variant70" !== "variant70") { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "big_polyvar_test.res", + 384, + 0 + ], + Error: new Error() + }; +} + +if ("variant71" !== "variant71") { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "big_polyvar_test.res", + 385, + 0 + ], + Error: new Error() + }; +} + +if ("variant72" !== "variant72") { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "big_polyvar_test.res", + 386, + 0 + ], + Error: new Error() + }; +} + +if ("variant73" !== "variant73") { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "big_polyvar_test.res", + 387, + 0 + ], + Error: new Error() + }; +} + +if ("variant74" !== "variant74") { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "big_polyvar_test.res", + 388, + 0 + ], + Error: new Error() + }; +} + +if ("variant75" !== "variant75") { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "big_polyvar_test.res", + 389, + 0 + ], + Error: new Error() + }; +} + +if ("variant76" !== "variant76") { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "big_polyvar_test.res", + 390, + 0 + ], + Error: new Error() + }; +} + +if ("variant77" !== "variant77") { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "big_polyvar_test.res", + 391, + 0 + ], + Error: new Error() + }; +} + +if ("variant78" !== "variant78") { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "big_polyvar_test.res", + 392, + 0 + ], + Error: new Error() + }; +} + +if ("variant79" !== "variant79") { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "big_polyvar_test.res", + 393, + 0 + ], + Error: new Error() + }; +} + +if ("variant80" !== "variant80") { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "big_polyvar_test.res", + 394, + 0 + ], + Error: new Error() + }; +} + +if ("variant81" !== "variant81") { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "big_polyvar_test.res", + 395, + 0 + ], + Error: new Error() + }; +} + +if ("variant82" !== "variant82") { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "big_polyvar_test.res", + 396, + 0 + ], + Error: new Error() + }; +} + +if ("variant83" !== "variant83") { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "big_polyvar_test.res", + 397, + 0 + ], + Error: new Error() + }; +} + +if ("variant84" !== "variant84") { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "big_polyvar_test.res", + 398, + 0 + ], + Error: new Error() + }; +} + +if ("variant85" !== "variant85") { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "big_polyvar_test.res", + 399, + 0 + ], + Error: new Error() + }; +} + +if ("variant86" !== "variant86") { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "big_polyvar_test.res", + 400, + 0 + ], + Error: new Error() + }; +} + +if ("variant87" !== "variant87") { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "big_polyvar_test.res", + 401, + 0 + ], + Error: new Error() + }; +} + +if ("variant88" !== "variant88") { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "big_polyvar_test.res", + 402, + 0 + ], + Error: new Error() + }; +} + +if ("variant89" !== "variant89") { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "big_polyvar_test.res", + 403, + 0 + ], + Error: new Error() + }; +} + +if ("variant90" !== "variant90") { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "big_polyvar_test.res", + 404, + 0 + ], + Error: new Error() + }; +} + +if ("variant91" !== "variant91") { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "big_polyvar_test.res", + 405, + 0 + ], + Error: new Error() + }; +} + +if ("variant92" !== "variant92") { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "big_polyvar_test.res", + 406, + 0 + ], + Error: new Error() + }; +} + +if ("variant93" !== "variant93") { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "big_polyvar_test.res", + 407, + 0 + ], + Error: new Error() + }; +} + +if ("variant94" !== "variant94") { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "big_polyvar_test.res", + 408, + 0 + ], + Error: new Error() + }; +} + +if ("variant95" !== "variant95") { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "big_polyvar_test.res", + 409, + 0 + ], + Error: new Error() + }; +} + +if ("variant96" !== "variant96") { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "big_polyvar_test.res", + 410, + 0 + ], + Error: new Error() + }; +} + +if ("variant97" !== "variant97") { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "big_polyvar_test.res", + 411, + 0 + ], + Error: new Error() + }; +} + +if ("variant98" !== "variant98") { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "big_polyvar_test.res", + 412, + 0 + ], + Error: new Error() + }; +} + +if ("variant99" !== "variant99") { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "big_polyvar_test.res", + 413, + 0 + ], + Error: new Error() + }; +} + +if ("variant100" !== "variant100") { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "big_polyvar_test.res", + 414, + 0 + ], + Error: new Error() + }; +} + +if ("variant101" !== "variant101") { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "big_polyvar_test.res", + 415, + 0 + ], + Error: new Error() + }; +} + +if ("variant102" !== "variant102") { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "big_polyvar_test.res", + 416, + 0 + ], + Error: new Error() + }; +} + +if ("variant103" !== "variant103") { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "big_polyvar_test.res", + 417, + 0 + ], + Error: new Error() + }; +} + +if ("variant104" !== "variant104") { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "big_polyvar_test.res", + 418, + 0 + ], + Error: new Error() + }; +} + +if ("variant105" !== "variant105") { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "big_polyvar_test.res", + 419, + 0 + ], + Error: new Error() + }; +} + +if ("variant106" !== "variant106") { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "big_polyvar_test.res", + 420, + 0 + ], + Error: new Error() + }; +} + +if ("variant107" !== "variant107") { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "big_polyvar_test.res", + 421, + 0 + ], + Error: new Error() + }; +} + +if ("variant108" !== "variant108") { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "big_polyvar_test.res", + 422, + 0 + ], + Error: new Error() + }; +} + +if ("variant109" !== "variant109") { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "big_polyvar_test.res", + 423, + 0 + ], + Error: new Error() + }; +} + +if ("variant110" !== "variant110") { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "big_polyvar_test.res", + 424, + 0 + ], + Error: new Error() + }; +} + +if ("variant111" !== "variant111") { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "big_polyvar_test.res", + 425, + 0 + ], + Error: new Error() + }; +} + +if ("variant112" !== "variant112") { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "big_polyvar_test.res", + 426, + 0 + ], + Error: new Error() + }; +} + +if ("variant113" !== "variant113") { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "big_polyvar_test.res", + 427, + 0 + ], + Error: new Error() + }; +} + +if ("variant114" !== "variant114") { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "big_polyvar_test.res", + 428, + 0 + ], + Error: new Error() + }; +} + +if ("variant115" !== "variant115") { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "big_polyvar_test.res", + 429, + 0 + ], + Error: new Error() + }; +} + +if ("variant116" !== "variant116") { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "big_polyvar_test.res", + 430, + 0 + ], + Error: new Error() + }; +} + +if ("variant117" !== "variant117") { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "big_polyvar_test.res", + 431, + 0 + ], + Error: new Error() + }; +} + +if ("variant118" !== "variant118") { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "big_polyvar_test.res", + 432, + 0 + ], + Error: new Error() + }; +} + +if ("variant119" !== "variant119") { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "big_polyvar_test.res", + 433, + 0 + ], + Error: new Error() + }; +} + +if ("variant120" !== "variant120") { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "big_polyvar_test.res", + 434, + 0 + ], + Error: new Error() + }; +} + +if ("variant121" !== "variant121") { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "big_polyvar_test.res", + 435, + 0 + ], + Error: new Error() + }; +} + +if ("variant122" !== "variant122") { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "big_polyvar_test.res", + 436, + 0 + ], + Error: new Error() + }; +} + +if ("variant123" !== "variant123") { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "big_polyvar_test.res", + 437, + 0 + ], + Error: new Error() + }; +} + +if ("variant124" !== "variant124") { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "big_polyvar_test.res", + 438, + 0 + ], + Error: new Error() + }; +} + +if ("variant125" !== "variant125") { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "big_polyvar_test.res", + 439, + 0 + ], + Error: new Error() + }; +} + +if ("variant126" !== "variant126") { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "big_polyvar_test.res", + 440, + 0 + ], + Error: new Error() + }; +} + +if ("variant127" !== "variant127") { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "big_polyvar_test.res", + 441, + 0 + ], + Error: new Error() + }; +} + +if ("variant128" !== "variant128") { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "big_polyvar_test.res", + 442, + 0 + ], + Error: new Error() + }; +} + +if ("variant129" !== "variant129") { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "big_polyvar_test.res", + 443, + 0 + ], + Error: new Error() + }; +} + +if ("variant130" !== "variant130") { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "big_polyvar_test.res", + 444, + 0 + ], + Error: new Error() + }; +} + +if ("variant131" !== "variant131") { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "big_polyvar_test.res", + 445, + 0 + ], + Error: new Error() + }; +} + +if ("variant132" !== "variant132") { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "big_polyvar_test.res", + 446, + 0 + ], + Error: new Error() + }; +} + +if ("variant133" !== "variant133") { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "big_polyvar_test.res", + 447, + 0 + ], + Error: new Error() + }; +} + +if ("variant134" !== "variant134") { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "big_polyvar_test.res", + 448, + 0 + ], + Error: new Error() + }; +} + +if ("variant135" !== "variant135") { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "big_polyvar_test.res", + 449, + 0 + ], + Error: new Error() + }; +} + +if ("variant136" !== "variant136") { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "big_polyvar_test.res", + 450, + 0 + ], + Error: new Error() + }; +} + +if ("variant137" !== "variant137") { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "big_polyvar_test.res", + 451, + 0 + ], + Error: new Error() + }; +} + +if ("variant138" !== "variant138") { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "big_polyvar_test.res", + 452, + 0 + ], + Error: new Error() + }; +} + +if ("variant139" !== "variant139") { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "big_polyvar_test.res", + 453, + 0 + ], + Error: new Error() + }; +} + +if ("variant140" !== "variant140") { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "big_polyvar_test.res", + 454, + 0 + ], + Error: new Error() + }; +} + +if ("variant141" !== "variant141") { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "big_polyvar_test.res", + 455, + 0 + ], + Error: new Error() + }; +} + +if ("variant142" !== "variant142") { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "big_polyvar_test.res", + 456, + 0 + ], + Error: new Error() + }; +} + +if ("variant143" !== "variant143") { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "big_polyvar_test.res", + 457, + 0 + ], + Error: new Error() + }; +} + +if ("variant144" !== "variant144") { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "big_polyvar_test.res", + 458, + 0 + ], + Error: new Error() + }; +} + +if ("variant145" !== "variant145") { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "big_polyvar_test.res", + 459, + 0 + ], + Error: new Error() + }; +} + +if ("variant146" !== "variant146") { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "big_polyvar_test.res", + 460, + 0 + ], + Error: new Error() + }; +} + +if ("variant147" !== "variant147") { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "big_polyvar_test.res", + 461, + 0 + ], + Error: new Error() + }; +} + +if ("variant148" !== "variant148") { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "big_polyvar_test.res", + 462, + 0 + ], + Error: new Error() + }; +} + +if ("variant149" !== "variant149") { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "big_polyvar_test.res", + 463, + 0 + ], + Error: new Error() + }; +} + +if ("variant150" !== "variant150") { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "big_polyvar_test.res", + 464, + 0 + ], + Error: new Error() + }; +} + +if ("variant151" !== "variant151") { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "big_polyvar_test.res", + 465, + 0 + ], + Error: new Error() + }; +} + +if ("variant152" !== "variant152") { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "big_polyvar_test.res", + 466, + 0 + ], + Error: new Error() + }; +} + +if ("variant153" !== "variant153") { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "big_polyvar_test.res", + 467, + 0 + ], + Error: new Error() + }; +} + +if ("variant154" !== "variant154") { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "big_polyvar_test.res", + 468, + 0 + ], + Error: new Error() + }; +} + +if ("variant155" !== "variant155") { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "big_polyvar_test.res", + 469, + 0 + ], + Error: new Error() + }; +} + +if ("variant156" !== "variant156") { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "big_polyvar_test.res", + 470, + 0 + ], + Error: new Error() + }; +} + +if ("variant157" !== "variant157") { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "big_polyvar_test.res", + 471, + 0 + ], + Error: new Error() + }; +} + +if ("variant158" !== "variant158") { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "big_polyvar_test.res", + 472, + 0 + ], + Error: new Error() + }; +} + +if ("variant159" !== "variant159") { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "big_polyvar_test.res", + 473, + 0 + ], + Error: new Error() + }; +} + +if ("variant160" !== "variant160") { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "big_polyvar_test.res", + 474, + 0 + ], + Error: new Error() + }; +} + +if ("variant161" !== "variant161") { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "big_polyvar_test.res", + 475, + 0 + ], + Error: new Error() + }; +} + +if ("variant162" !== "variant162") { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "big_polyvar_test.res", + 476, + 0 + ], + Error: new Error() + }; +} + +if ("variant163" !== "variant163") { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "big_polyvar_test.res", + 477, + 0 + ], + Error: new Error() + }; +} + +if ("variant164" !== "variant164") { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "big_polyvar_test.res", + 478, + 0 + ], + Error: new Error() + }; +} + +if ("variant165" !== "variant165") { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "big_polyvar_test.res", + 479, + 0 + ], + Error: new Error() + }; +} + +if ("variant166" !== "variant166") { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "big_polyvar_test.res", + 480, + 0 + ], + Error: new Error() + }; +} + +if ("variant167" !== "variant167") { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "big_polyvar_test.res", + 481, + 0 + ], + Error: new Error() + }; +} + +if ("variant168" !== "variant168") { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "big_polyvar_test.res", + 482, + 0 + ], + Error: new Error() + }; +} + +if ("variant169" !== "variant169") { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "big_polyvar_test.res", + 483, + 0 + ], + Error: new Error() + }; +} + +if ("variant170" !== "variant170") { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "big_polyvar_test.res", + 484, + 0 + ], + Error: new Error() + }; +} + +if ("variant171" !== "variant171") { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "big_polyvar_test.res", + 485, + 0 + ], + Error: new Error() + }; +} + +if ("variant172" !== "variant172") { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "big_polyvar_test.res", + 486, + 0 + ], + Error: new Error() + }; +} + +if ("variant173" !== "variant173") { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "big_polyvar_test.res", + 487, + 0 + ], + Error: new Error() + }; +} + +if ("variant174" !== "variant174") { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "big_polyvar_test.res", + 488, + 0 + ], + Error: new Error() + }; +} + +if ("variant175" !== "variant175") { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "big_polyvar_test.res", + 489, + 0 + ], + Error: new Error() + }; +} + +if ("variant176" !== "variant176") { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "big_polyvar_test.res", + 490, + 0 + ], + Error: new Error() + }; +} + +if ("variant177" !== "variant177") { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "big_polyvar_test.res", + 491, + 0 + ], + Error: new Error() + }; +} + +if ("variant178" !== "variant178") { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "big_polyvar_test.res", + 492, + 0 + ], + Error: new Error() + }; +} + +if ("variant179" !== "variant179") { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "big_polyvar_test.res", + 493, + 0 + ], + Error: new Error() + }; +} + +if ("variant180" !== "variant180") { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "big_polyvar_test.res", + 494, + 0 + ], + Error: new Error() + }; +} + +if ("variant181" !== "variant181") { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "big_polyvar_test.res", + 495, + 0 + ], + Error: new Error() + }; +} + +if ("variant182" !== "variant182") { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "big_polyvar_test.res", + 496, + 0 + ], + Error: new Error() + }; +} + +if ("variant183" !== "variant183") { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "big_polyvar_test.res", + 497, + 0 + ], + Error: new Error() + }; +} + +if ("variant184" !== "variant184") { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "big_polyvar_test.res", + 498, + 0 + ], + Error: new Error() + }; +} + +if ("variant185" !== "variant185") { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "big_polyvar_test.res", + 499, + 0 + ], + Error: new Error() + }; +} + +if ("variant186" !== "variant186") { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "big_polyvar_test.res", + 500, + 0 + ], + Error: new Error() + }; +} + +if ("variant187" !== "variant187") { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "big_polyvar_test.res", + 501, + 0 + ], + Error: new Error() + }; +} + +if ("variant188" !== "variant188") { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "big_polyvar_test.res", + 502, + 0 + ], + Error: new Error() + }; +} + +if ("variant189" !== "variant189") { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "big_polyvar_test.res", + 503, + 0 + ], + Error: new Error() + }; +} + +if ("variant190" !== "variant190") { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "big_polyvar_test.res", + 504, + 0 + ], + Error: new Error() + }; +} + +if ("variant191" !== "variant191") { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "big_polyvar_test.res", + 505, + 0 + ], + Error: new Error() + }; +} + +if ("variant192" !== "variant192") { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "big_polyvar_test.res", + 506, + 0 + ], + Error: new Error() + }; +} + +if ("variant193" !== "variant193") { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "big_polyvar_test.res", + 507, + 0 + ], + Error: new Error() + }; +} + +if ("variant194" !== "variant194") { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "big_polyvar_test.res", + 508, + 0 + ], + Error: new Error() + }; +} + +if ("variant195" !== "variant195") { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "big_polyvar_test.res", + 509, + 0 + ], + Error: new Error() + }; +} + +if ("variant196" !== "variant196") { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "big_polyvar_test.res", + 510, + 0 + ], + Error: new Error() + }; +} + +if ("variant197" !== "variant197") { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "big_polyvar_test.res", + 511, + 0 + ], + Error: new Error() + }; +} + +if ("variant198" !== "variant198") { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "big_polyvar_test.res", + 512, + 0 + ], + Error: new Error() + }; +} + +if ("variant199" !== "variant199") { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "big_polyvar_test.res", + 513, + 0 + ], + Error: new Error() + }; +} + +if ("variant200" !== "variant200") { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "big_polyvar_test.res", + 514, + 0 + ], + Error: new Error() + }; +} + +if ("variant201" !== "variant201") { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "big_polyvar_test.res", + 515, + 0 + ], + Error: new Error() + }; +} + +if ("variant202" !== "variant202") { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "big_polyvar_test.res", + 516, + 0 + ], + Error: new Error() + }; +} + +if ("variant203" !== "variant203") { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "big_polyvar_test.res", + 517, + 0 + ], + Error: new Error() + }; +} + +if ("variant204" !== "variant204") { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "big_polyvar_test.res", + 518, + 0 + ], + Error: new Error() + }; +} + +if ("variant205" !== "variant205") { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "big_polyvar_test.res", + 519, + 0 + ], + Error: new Error() + }; +} + +if ("variant206" !== "variant206") { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "big_polyvar_test.res", + 520, + 0 + ], + Error: new Error() + }; +} + +if ("variant207" !== "variant207") { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "big_polyvar_test.res", + 521, + 0 + ], + Error: new Error() + }; +} + +if ("variant208" !== "variant208") { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "big_polyvar_test.res", + 522, + 0 + ], + Error: new Error() + }; +} + +if ("variant209" !== "variant209") { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "big_polyvar_test.res", + 523, + 0 + ], + Error: new Error() + }; +} + +if ("variant210" !== "variant210") { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "big_polyvar_test.res", + 524, + 0 + ], + Error: new Error() + }; +} + +if ("variant211" !== "variant211") { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "big_polyvar_test.res", + 525, + 0 + ], + Error: new Error() + }; +} + +if ("variant212" !== "variant212") { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "big_polyvar_test.res", + 526, + 0 + ], + Error: new Error() + }; +} + +if ("variant213" !== "variant213") { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "big_polyvar_test.res", + 527, + 0 + ], + Error: new Error() + }; +} + +if ("variant214" !== "variant214") { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "big_polyvar_test.res", + 528, + 0 + ], + Error: new Error() + }; +} + +if ("variant215" !== "variant215") { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "big_polyvar_test.res", + 529, + 0 + ], + Error: new Error() + }; +} + +if ("variant216" !== "variant216") { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "big_polyvar_test.res", + 530, + 0 + ], + Error: new Error() + }; +} + +if ("variant217" !== "variant217") { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "big_polyvar_test.res", + 531, + 0 + ], + Error: new Error() + }; +} + +if ("variant218" !== "variant218") { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "big_polyvar_test.res", + 532, + 0 + ], + Error: new Error() + }; +} + +if ("variant219" !== "variant219") { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "big_polyvar_test.res", + 533, + 0 + ], + Error: new Error() + }; +} + +if ("variant220" !== "variant220") { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "big_polyvar_test.res", + 534, + 0 + ], + Error: new Error() + }; +} + +if ("variant221" !== "variant221") { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "big_polyvar_test.res", + 535, + 0 + ], + Error: new Error() + }; +} + +if ("variant222" !== "variant222") { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "big_polyvar_test.res", + 536, + 0 + ], + Error: new Error() + }; +} + +if ("variant223" !== "variant223") { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "big_polyvar_test.res", + 537, + 0 + ], + Error: new Error() + }; +} + +if ("variant224" !== "variant224") { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "big_polyvar_test.res", + 538, + 0 + ], + Error: new Error() + }; +} + +if ("variant225" !== "variant225") { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "big_polyvar_test.res", + 539, + 0 + ], + Error: new Error() + }; +} + +if ("variant226" !== "variant226") { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "big_polyvar_test.res", + 540, + 0 + ], + Error: new Error() + }; +} + +if ("variant227" !== "variant227") { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "big_polyvar_test.res", + 541, + 0 + ], + Error: new Error() + }; +} + +if ("variant228" !== "variant228") { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "big_polyvar_test.res", + 542, + 0 + ], + Error: new Error() + }; +} + +if ("variant229" !== "variant229") { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "big_polyvar_test.res", + 543, + 0 + ], + Error: new Error() + }; +} + +if ("variant230" !== "variant230") { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "big_polyvar_test.res", + 544, + 0 + ], + Error: new Error() + }; +} + +if ("variant231" !== "variant231") { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "big_polyvar_test.res", + 545, + 0 + ], + Error: new Error() + }; +} + +if ("variant232" !== "variant232") { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "big_polyvar_test.res", + 546, + 0 + ], + Error: new Error() + }; +} + +if ("variant233" !== "variant233") { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "big_polyvar_test.res", + 547, + 0 + ], + Error: new Error() + }; +} + +if ("variant234" !== "variant234") { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "big_polyvar_test.res", + 548, + 0 + ], + Error: new Error() + }; +} + +if ("variant235" !== "variant235") { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "big_polyvar_test.res", + 549, + 0 + ], + Error: new Error() + }; +} + +if ("variant236" !== "variant236") { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "big_polyvar_test.res", + 550, + 0 + ], + Error: new Error() + }; +} + +if ("variant237" !== "variant237") { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "big_polyvar_test.res", + 551, + 0 + ], + Error: new Error() + }; +} + +if ("variant238" !== "variant238") { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "big_polyvar_test.res", + 552, + 0 + ], + Error: new Error() + }; +} + +if ("variant239" !== "variant239") { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "big_polyvar_test.res", + 553, + 0 + ], + Error: new Error() + }; +} + +if ("variant240" !== "variant240") { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "big_polyvar_test.res", + 554, + 0 + ], + Error: new Error() + }; +} + +if ("variant241" !== "variant241") { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "big_polyvar_test.res", + 555, + 0 + ], + Error: new Error() + }; +} + +if ("variant242" !== "variant242") { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "big_polyvar_test.res", + 556, + 0 + ], + Error: new Error() + }; +} + +if ("variant243" !== "variant243") { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "big_polyvar_test.res", + 557, + 0 + ], + Error: new Error() + }; +} + +if ("variant244" !== "variant244") { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "big_polyvar_test.res", + 558, + 0 + ], + Error: new Error() + }; +} + +if ("variant245" !== "variant245") { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "big_polyvar_test.res", + 559, + 0 + ], + Error: new Error() + }; +} + +if ("variant246" !== "variant246") { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "big_polyvar_test.res", + 560, + 0 + ], + Error: new Error() + }; +} + +if ("variant247" !== "variant247") { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "big_polyvar_test.res", + 561, + 0 + ], + Error: new Error() + }; +} + +if ("variant248" !== "variant248") { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "big_polyvar_test.res", + 562, + 0 + ], + Error: new Error() + }; +} + +if ("variant249" !== "variant249") { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "big_polyvar_test.res", + 563, + 0 + ], + Error: new Error() + }; +} + +if ("variant250" !== "variant250") { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "big_polyvar_test.res", + 564, + 0 + ], + Error: new Error() + }; +} + +if ("variant251" !== "variant251") { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "big_polyvar_test.res", + 565, + 0 + ], + Error: new Error() + }; +} + +if ("variant252" !== "variant252") { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "big_polyvar_test.res", + 566, + 0 + ], + Error: new Error() + }; +} + +if ("variant253" !== "variant253") { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "big_polyvar_test.res", + 567, + 0 + ], + Error: new Error() + }; +} + +if ("variant254" !== "variant254") { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "big_polyvar_test.res", + 568, + 0 + ], + Error: new Error() + }; +} + +if ("variant255" !== "variant255") { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "big_polyvar_test.res", + 569, + 0 + ], + Error: new Error() + }; +} + +if ("variant256" !== "variant256") { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "big_polyvar_test.res", + 570, + 0 + ], + Error: new Error() + }; +} + +if ("variant257" !== "variant257") { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "big_polyvar_test.res", + 571, + 0 + ], + Error: new Error() + }; +} + +if ("variant258" !== "variant258") { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "big_polyvar_test.res", + 572, + 0 + ], + Error: new Error() + }; +} + +if ("variant259" !== "variant259") { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "big_polyvar_test.res", + 573, + 0 + ], + Error: new Error() + }; +} + +if ("variant260" !== "variant260") { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "big_polyvar_test.res", + 574, + 0 + ], + Error: new Error() + }; +} + +if ("variant261" !== "variant261") { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "big_polyvar_test.res", + 575, + 0 + ], + Error: new Error() + }; +} + +if ("variant262" !== "variant262") { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "big_polyvar_test.res", + 576, + 0 + ], + Error: new Error() + }; +} + +if ("variant263" !== "variant263") { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "big_polyvar_test.res", + 577, + 0 + ], + Error: new Error() + }; +} + +if ("variant264" !== "variant264") { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "big_polyvar_test.res", + 578, + 0 + ], + Error: new Error() + }; +} + +if ("variant265" !== "variant265") { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "big_polyvar_test.res", + 579, + 0 + ], + Error: new Error() + }; +} + +if ("variant266" !== "variant266") { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "big_polyvar_test.res", + 580, + 0 + ], + Error: new Error() + }; +} + +if ("variant267" !== "variant267") { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "big_polyvar_test.res", + 581, + 0 + ], + Error: new Error() + }; +} + +if ("variant268" !== "variant268") { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "big_polyvar_test.res", + 582, + 0 + ], + Error: new Error() + }; +} + +if ("variant269" !== "variant269") { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "big_polyvar_test.res", + 583, + 0 + ], + Error: new Error() + }; +} + +if ("variant270" !== "variant270") { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "big_polyvar_test.res", + 584, + 0 + ], + Error: new Error() + }; +} + +if ("variant271" !== "variant271") { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "big_polyvar_test.res", + 585, + 0 + ], + Error: new Error() + }; +} + +if ("variant272" !== "variant272") { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "big_polyvar_test.res", + 586, + 0 + ], + Error: new Error() + }; +} + +if ("variant273" !== "variant273") { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "big_polyvar_test.res", + 587, + 0 + ], + Error: new Error() + }; +} + +if ("variant274" !== "variant274") { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "big_polyvar_test.res", + 588, + 0 + ], + Error: new Error() + }; +} + +if ("variant275" !== "variant275") { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "big_polyvar_test.res", + 589, + 0 + ], + Error: new Error() + }; +} + +if ("variant276" !== "variant276") { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "big_polyvar_test.res", + 590, + 0 + ], + Error: new Error() + }; +} + +if ("variant277" !== "variant277") { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "big_polyvar_test.res", + 591, + 0 + ], + Error: new Error() + }; +} + +if ("variant278" !== "variant278") { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "big_polyvar_test.res", + 592, + 0 + ], + Error: new Error() + }; +} + +if ("variant279" !== "variant279") { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "big_polyvar_test.res", + 593, + 0 + ], + Error: new Error() + }; +} + +if ("variant280" !== "variant280") { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "big_polyvar_test.res", + 594, + 0 + ], + Error: new Error() + }; +} + +if ("variant281" !== "variant281") { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "big_polyvar_test.res", + 595, + 0 + ], + Error: new Error() + }; +} + +if ("variant282" !== "variant282") { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "big_polyvar_test.res", + 596, + 0 + ], + Error: new Error() + }; +} + +if ("variant283" !== "variant283") { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "big_polyvar_test.res", + 597, + 0 + ], + Error: new Error() + }; +} + +if ("variant284" !== "variant284") { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "big_polyvar_test.res", + 598, + 0 + ], + Error: new Error() + }; +} + +if ("variant285" !== "variant285") { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "big_polyvar_test.res", + 599, + 0 + ], + Error: new Error() + }; +} + +if ("variant286" !== "variant286") { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "big_polyvar_test.res", + 600, + 0 + ], + Error: new Error() + }; +} + +if ("variant287" !== "variant287") { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "big_polyvar_test.res", + 601, + 0 + ], + Error: new Error() + }; +} + +if ("variant288" !== "variant288") { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "big_polyvar_test.res", + 602, + 0 + ], + Error: new Error() + }; +} + +if ("variant289" !== "variant289") { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "big_polyvar_test.res", + 603, + 0 + ], + Error: new Error() + }; +} + +if ("variant290" !== "variant290") { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "big_polyvar_test.res", + 604, + 0 + ], + Error: new Error() + }; +} + +if ("variant291" !== "variant291") { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "big_polyvar_test.res", + 605, + 0 + ], + Error: new Error() + }; +} + +if ("variant292" !== "variant292") { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "big_polyvar_test.res", + 606, + 0 + ], + Error: new Error() + }; +} + +if ("variant293" !== "variant293") { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "big_polyvar_test.res", + 607, + 0 + ], + Error: new Error() + }; +} + +if ("variant294" !== "variant294") { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "big_polyvar_test.res", + 608, + 0 + ], + Error: new Error() + }; +} + +if ("variant295" !== "variant295") { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "big_polyvar_test.res", + 609, + 0 + ], + Error: new Error() + }; +} + +if ("variant296" !== "variant296") { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "big_polyvar_test.res", + 610, + 0 + ], + Error: new Error() + }; +} + +if ("variant297" !== "variant297") { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "big_polyvar_test.res", + 611, + 0 + ], + Error: new Error() + }; +} + +if ("variant298" !== "variant298") { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "big_polyvar_test.res", + 612, + 0 + ], + Error: new Error() + }; +} + +if ("variant299" !== "variant299") { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "big_polyvar_test.res", + 613, + 0 + ], + Error: new Error() + }; +} + +if (!eq(tFromJs("variant0"), "variant0")) { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "big_polyvar_test.res", + 614, + 0 + ], + Error: new Error() + }; +} + +if (!eq(tFromJs("variant1"), "variant1")) { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "big_polyvar_test.res", + 615, + 0 + ], + Error: new Error() + }; +} + +if (!eq(tFromJs("variant2"), "variant2")) { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "big_polyvar_test.res", + 616, + 0 + ], + Error: new Error() + }; +} + +if (!eq(tFromJs("variant3"), "variant3")) { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "big_polyvar_test.res", + 617, + 0 + ], + Error: new Error() + }; +} + +if (!eq(tFromJs("variant4"), "variant4")) { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "big_polyvar_test.res", + 618, + 0 + ], + Error: new Error() + }; +} + +if (!eq(tFromJs("variant5"), "variant5")) { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "big_polyvar_test.res", + 619, + 0 + ], + Error: new Error() + }; +} + +if (!eq(tFromJs("variant6"), "variant6")) { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "big_polyvar_test.res", + 620, + 0 + ], + Error: new Error() + }; +} + +if (!eq(tFromJs("variant7"), "variant7")) { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "big_polyvar_test.res", + 621, + 0 + ], + Error: new Error() + }; +} + +if (!eq(tFromJs("variant8"), "variant8")) { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "big_polyvar_test.res", + 622, + 0 + ], + Error: new Error() + }; +} + +if (!eq(tFromJs("variant9"), "variant9")) { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "big_polyvar_test.res", + 623, + 0 + ], + Error: new Error() + }; +} + +if (!eq(tFromJs("variant10"), "variant10")) { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "big_polyvar_test.res", + 624, + 0 + ], + Error: new Error() + }; +} + +if (!eq(tFromJs("variant11"), "variant11")) { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "big_polyvar_test.res", + 625, + 0 + ], + Error: new Error() + }; +} + +if (!eq(tFromJs("variant12"), "variant12")) { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "big_polyvar_test.res", + 626, + 0 + ], + Error: new Error() + }; +} + +if (!eq(tFromJs("variant13"), "variant13")) { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "big_polyvar_test.res", + 627, + 0 + ], + Error: new Error() + }; +} + +if (!eq(tFromJs("variant14"), "variant14")) { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "big_polyvar_test.res", + 628, + 0 + ], + Error: new Error() + }; +} + +if (!eq(tFromJs("variant15"), "variant15")) { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "big_polyvar_test.res", + 629, + 0 + ], + Error: new Error() + }; +} + +if (!eq(tFromJs("variant16"), "variant16")) { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "big_polyvar_test.res", + 630, + 0 + ], + Error: new Error() + }; +} + +if (!eq(tFromJs("variant17"), "variant17")) { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "big_polyvar_test.res", + 631, + 0 + ], + Error: new Error() + }; +} + +if (!eq(tFromJs("variant18"), "variant18")) { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "big_polyvar_test.res", + 632, + 0 + ], + Error: new Error() + }; +} + +if (!eq(tFromJs("variant19"), "variant19")) { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "big_polyvar_test.res", + 633, + 0 + ], + Error: new Error() + }; +} + +if (!eq(tFromJs("variant20"), "variant20")) { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "big_polyvar_test.res", + 634, + 0 + ], + Error: new Error() + }; +} + +if (!eq(tFromJs("variant21"), "variant21")) { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "big_polyvar_test.res", + 635, + 0 + ], + Error: new Error() + }; +} + +if (!eq(tFromJs("variant22"), "variant22")) { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "big_polyvar_test.res", + 636, + 0 + ], + Error: new Error() + }; +} + +if (!eq(tFromJs("variant23"), "variant23")) { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "big_polyvar_test.res", + 637, + 0 + ], + Error: new Error() + }; +} + +if (!eq(tFromJs("variant24"), "variant24")) { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "big_polyvar_test.res", + 638, + 0 + ], + Error: new Error() + }; +} + +if (!eq(tFromJs("variant25"), "variant25")) { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "big_polyvar_test.res", + 639, + 0 + ], + Error: new Error() + }; +} + +if (!eq(tFromJs("variant26"), "variant26")) { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "big_polyvar_test.res", + 640, + 0 + ], + Error: new Error() + }; +} + +if (!eq(tFromJs("variant27"), "variant27")) { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "big_polyvar_test.res", + 641, + 0 + ], + Error: new Error() + }; +} + +if (!eq(tFromJs("variant28"), "variant28")) { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "big_polyvar_test.res", + 642, + 0 + ], + Error: new Error() + }; +} + +if (!eq(tFromJs("variant29"), "variant29")) { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "big_polyvar_test.res", + 643, + 0 + ], + Error: new Error() + }; +} + +if (!eq(tFromJs("variant30"), "variant30")) { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "big_polyvar_test.res", + 644, + 0 + ], + Error: new Error() + }; +} + +if (!eq(tFromJs("variant31"), "variant31")) { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "big_polyvar_test.res", + 645, + 0 + ], + Error: new Error() + }; +} + +if (!eq(tFromJs("variant32"), "variant32")) { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "big_polyvar_test.res", + 646, + 0 + ], + Error: new Error() + }; +} + +if (!eq(tFromJs("variant33"), "variant33")) { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "big_polyvar_test.res", + 647, + 0 + ], + Error: new Error() + }; +} + +if (!eq(tFromJs("variant34"), "variant34")) { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "big_polyvar_test.res", + 648, + 0 + ], + Error: new Error() + }; +} + +if (!eq(tFromJs("variant35"), "variant35")) { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "big_polyvar_test.res", + 649, + 0 + ], + Error: new Error() + }; +} + +if (!eq(tFromJs("variant36"), "variant36")) { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "big_polyvar_test.res", + 650, + 0 + ], + Error: new Error() + }; +} + +if (!eq(tFromJs("variant37"), "variant37")) { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "big_polyvar_test.res", + 651, + 0 + ], + Error: new Error() + }; +} + +if (!eq(tFromJs("variant38"), "variant38")) { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "big_polyvar_test.res", + 652, + 0 + ], + Error: new Error() + }; +} + +if (!eq(tFromJs("variant39"), "variant39")) { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "big_polyvar_test.res", + 653, + 0 + ], + Error: new Error() + }; +} + +if (!eq(tFromJs("variant40"), "variant40")) { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "big_polyvar_test.res", + 654, + 0 + ], + Error: new Error() + }; +} + +if (!eq(tFromJs("variant41"), "variant41")) { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "big_polyvar_test.res", + 655, + 0 + ], + Error: new Error() + }; +} + +if (!eq(tFromJs("variant42"), "variant42")) { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "big_polyvar_test.res", + 656, + 0 + ], + Error: new Error() + }; +} + +if (!eq(tFromJs("variant43"), "variant43")) { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "big_polyvar_test.res", + 657, + 0 + ], + Error: new Error() + }; +} + +if (!eq(tFromJs("variant44"), "variant44")) { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "big_polyvar_test.res", + 658, + 0 + ], + Error: new Error() + }; +} + +if (!eq(tFromJs("variant45"), "variant45")) { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "big_polyvar_test.res", + 659, + 0 + ], + Error: new Error() + }; +} + +if (!eq(tFromJs("variant46"), "variant46")) { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "big_polyvar_test.res", + 660, + 0 + ], + Error: new Error() + }; +} + +if (!eq(tFromJs("variant47"), "variant47")) { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "big_polyvar_test.res", + 661, + 0 + ], + Error: new Error() + }; +} + +if (!eq(tFromJs("variant48"), "variant48")) { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "big_polyvar_test.res", + 662, + 0 + ], + Error: new Error() + }; +} + +if (!eq(tFromJs("variant49"), "variant49")) { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "big_polyvar_test.res", + 663, + 0 + ], + Error: new Error() + }; +} + +if (!eq(tFromJs("variant50"), "variant50")) { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "big_polyvar_test.res", + 664, + 0 + ], + Error: new Error() + }; +} + +if (!eq(tFromJs("variant51"), "variant51")) { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "big_polyvar_test.res", + 665, + 0 + ], + Error: new Error() + }; +} + +if (!eq(tFromJs("variant52"), "variant52")) { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "big_polyvar_test.res", + 666, + 0 + ], + Error: new Error() + }; +} + +if (!eq(tFromJs("variant53"), "variant53")) { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "big_polyvar_test.res", + 667, + 0 + ], + Error: new Error() + }; +} + +if (!eq(tFromJs("variant54"), "variant54")) { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "big_polyvar_test.res", + 668, + 0 + ], + Error: new Error() + }; +} + +if (!eq(tFromJs("variant55"), "variant55")) { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "big_polyvar_test.res", + 669, + 0 + ], + Error: new Error() + }; +} + +if (!eq(tFromJs("variant56"), "variant56")) { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "big_polyvar_test.res", + 670, + 0 + ], + Error: new Error() + }; +} + +if (!eq(tFromJs("variant57"), "variant57")) { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "big_polyvar_test.res", + 671, + 0 + ], + Error: new Error() + }; +} + +if (!eq(tFromJs("variant58"), "variant58")) { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "big_polyvar_test.res", + 672, + 0 + ], + Error: new Error() + }; +} + +if (!eq(tFromJs("variant59"), "variant59")) { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "big_polyvar_test.res", + 673, + 0 + ], + Error: new Error() + }; +} + +if (!eq(tFromJs("variant60"), "variant60")) { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "big_polyvar_test.res", + 674, + 0 + ], + Error: new Error() + }; +} + +if (!eq(tFromJs("variant61"), "variant61")) { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "big_polyvar_test.res", + 675, + 0 + ], + Error: new Error() + }; +} + +if (!eq(tFromJs("variant62"), "variant62")) { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "big_polyvar_test.res", + 676, + 0 + ], + Error: new Error() + }; +} + +if (!eq(tFromJs("variant63"), "variant63")) { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "big_polyvar_test.res", + 677, + 0 + ], + Error: new Error() + }; +} + +if (!eq(tFromJs("variant64"), "variant64")) { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "big_polyvar_test.res", + 678, + 0 + ], + Error: new Error() + }; +} + +if (!eq(tFromJs("variant65"), "variant65")) { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "big_polyvar_test.res", + 679, + 0 + ], + Error: new Error() + }; +} + +if (!eq(tFromJs("variant66"), "variant66")) { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "big_polyvar_test.res", + 680, + 0 + ], + Error: new Error() + }; +} + +if (!eq(tFromJs("variant67"), "variant67")) { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "big_polyvar_test.res", + 681, + 0 + ], + Error: new Error() + }; +} + +if (!eq(tFromJs("variant68"), "variant68")) { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "big_polyvar_test.res", + 682, + 0 + ], + Error: new Error() + }; +} + +if (!eq(tFromJs("variant69"), "variant69")) { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "big_polyvar_test.res", + 683, + 0 + ], + Error: new Error() + }; +} + +if (!eq(tFromJs("variant70"), "variant70")) { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "big_polyvar_test.res", + 684, + 0 + ], + Error: new Error() + }; +} + +if (!eq(tFromJs("variant71"), "variant71")) { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "big_polyvar_test.res", + 685, + 0 + ], + Error: new Error() + }; +} + +if (!eq(tFromJs("variant72"), "variant72")) { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "big_polyvar_test.res", + 686, + 0 + ], + Error: new Error() + }; +} + +if (!eq(tFromJs("variant73"), "variant73")) { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "big_polyvar_test.res", + 687, + 0 + ], + Error: new Error() + }; +} + +if (!eq(tFromJs("variant74"), "variant74")) { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "big_polyvar_test.res", + 688, + 0 + ], + Error: new Error() + }; +} + +if (!eq(tFromJs("variant75"), "variant75")) { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "big_polyvar_test.res", + 689, + 0 + ], + Error: new Error() + }; +} + +if (!eq(tFromJs("variant76"), "variant76")) { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "big_polyvar_test.res", + 690, + 0 + ], + Error: new Error() + }; +} + +if (!eq(tFromJs("variant77"), "variant77")) { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "big_polyvar_test.res", + 691, + 0 + ], + Error: new Error() + }; +} + +if (!eq(tFromJs("variant78"), "variant78")) { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "big_polyvar_test.res", + 692, + 0 + ], + Error: new Error() + }; +} + +if (!eq(tFromJs("variant79"), "variant79")) { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "big_polyvar_test.res", + 693, + 0 + ], + Error: new Error() + }; +} + +if (!eq(tFromJs("variant80"), "variant80")) { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "big_polyvar_test.res", + 694, + 0 + ], + Error: new Error() + }; +} + +if (!eq(tFromJs("variant81"), "variant81")) { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "big_polyvar_test.res", + 695, + 0 + ], + Error: new Error() + }; +} + +if (!eq(tFromJs("variant82"), "variant82")) { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "big_polyvar_test.res", + 696, + 0 + ], + Error: new Error() + }; +} + +if (!eq(tFromJs("variant83"), "variant83")) { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "big_polyvar_test.res", + 697, + 0 + ], + Error: new Error() + }; +} + +if (!eq(tFromJs("variant84"), "variant84")) { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "big_polyvar_test.res", + 698, + 0 + ], + Error: new Error() + }; +} + +if (!eq(tFromJs("variant85"), "variant85")) { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "big_polyvar_test.res", + 699, + 0 + ], + Error: new Error() + }; +} + +if (!eq(tFromJs("variant86"), "variant86")) { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "big_polyvar_test.res", + 700, + 0 + ], + Error: new Error() + }; +} + +if (!eq(tFromJs("variant87"), "variant87")) { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "big_polyvar_test.res", + 701, + 0 + ], + Error: new Error() + }; +} + +if (!eq(tFromJs("variant88"), "variant88")) { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "big_polyvar_test.res", + 702, + 0 + ], + Error: new Error() + }; +} + +if (!eq(tFromJs("variant89"), "variant89")) { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "big_polyvar_test.res", + 703, + 0 + ], + Error: new Error() + }; +} + +if (!eq(tFromJs("variant90"), "variant90")) { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "big_polyvar_test.res", + 704, + 0 + ], + Error: new Error() + }; +} + +if (!eq(tFromJs("variant91"), "variant91")) { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "big_polyvar_test.res", + 705, + 0 + ], + Error: new Error() + }; +} + +if (!eq(tFromJs("variant92"), "variant92")) { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "big_polyvar_test.res", + 706, + 0 + ], + Error: new Error() + }; +} + +if (!eq(tFromJs("variant93"), "variant93")) { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "big_polyvar_test.res", + 707, + 0 + ], + Error: new Error() + }; +} + +if (!eq(tFromJs("variant94"), "variant94")) { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "big_polyvar_test.res", + 708, + 0 + ], + Error: new Error() + }; +} + +if (!eq(tFromJs("variant95"), "variant95")) { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "big_polyvar_test.res", + 709, + 0 + ], + Error: new Error() + }; +} + +if (!eq(tFromJs("variant96"), "variant96")) { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "big_polyvar_test.res", + 710, + 0 + ], + Error: new Error() + }; +} + +if (!eq(tFromJs("variant97"), "variant97")) { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "big_polyvar_test.res", + 711, + 0 + ], + Error: new Error() + }; +} + +if (!eq(tFromJs("variant98"), "variant98")) { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "big_polyvar_test.res", + 712, + 0 + ], + Error: new Error() + }; +} + +if (!eq(tFromJs("variant99"), "variant99")) { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "big_polyvar_test.res", + 713, + 0 + ], + Error: new Error() + }; +} + +if (!eq(tFromJs("variant100"), "variant100")) { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "big_polyvar_test.res", + 714, + 0 + ], + Error: new Error() + }; +} + +if (!eq(tFromJs("variant101"), "variant101")) { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "big_polyvar_test.res", + 715, + 0 + ], + Error: new Error() + }; +} + +if (!eq(tFromJs("variant102"), "variant102")) { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "big_polyvar_test.res", + 716, + 0 + ], + Error: new Error() + }; +} + +if (!eq(tFromJs("variant103"), "variant103")) { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "big_polyvar_test.res", + 717, + 0 + ], + Error: new Error() + }; +} + +if (!eq(tFromJs("variant104"), "variant104")) { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "big_polyvar_test.res", + 718, + 0 + ], + Error: new Error() + }; +} + +if (!eq(tFromJs("variant105"), "variant105")) { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "big_polyvar_test.res", + 719, + 0 + ], + Error: new Error() + }; +} + +if (!eq(tFromJs("variant106"), "variant106")) { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "big_polyvar_test.res", + 720, + 0 + ], + Error: new Error() + }; +} + +if (!eq(tFromJs("variant107"), "variant107")) { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "big_polyvar_test.res", + 721, + 0 + ], + Error: new Error() + }; +} + +if (!eq(tFromJs("variant108"), "variant108")) { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "big_polyvar_test.res", + 722, + 0 + ], + Error: new Error() + }; +} + +if (!eq(tFromJs("variant109"), "variant109")) { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "big_polyvar_test.res", + 723, + 0 + ], + Error: new Error() + }; +} + +if (!eq(tFromJs("variant110"), "variant110")) { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "big_polyvar_test.res", + 724, + 0 + ], + Error: new Error() + }; +} + +if (!eq(tFromJs("variant111"), "variant111")) { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "big_polyvar_test.res", + 725, + 0 + ], + Error: new Error() + }; +} + +if (!eq(tFromJs("variant112"), "variant112")) { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "big_polyvar_test.res", + 726, + 0 + ], + Error: new Error() + }; +} + +if (!eq(tFromJs("variant113"), "variant113")) { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "big_polyvar_test.res", + 727, + 0 + ], + Error: new Error() + }; +} + +if (!eq(tFromJs("variant114"), "variant114")) { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "big_polyvar_test.res", + 728, + 0 + ], + Error: new Error() + }; +} + +if (!eq(tFromJs("variant115"), "variant115")) { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "big_polyvar_test.res", + 729, + 0 + ], + Error: new Error() + }; +} + +if (!eq(tFromJs("variant116"), "variant116")) { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "big_polyvar_test.res", + 730, + 0 + ], + Error: new Error() + }; +} + +if (!eq(tFromJs("variant117"), "variant117")) { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "big_polyvar_test.res", + 731, + 0 + ], + Error: new Error() + }; +} + +if (!eq(tFromJs("variant118"), "variant118")) { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "big_polyvar_test.res", + 732, + 0 + ], + Error: new Error() + }; +} + +if (!eq(tFromJs("variant119"), "variant119")) { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "big_polyvar_test.res", + 733, + 0 + ], + Error: new Error() + }; +} + +if (!eq(tFromJs("variant120"), "variant120")) { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "big_polyvar_test.res", + 734, + 0 + ], + Error: new Error() + }; +} + +if (!eq(tFromJs("variant121"), "variant121")) { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "big_polyvar_test.res", + 735, + 0 + ], + Error: new Error() + }; +} + +if (!eq(tFromJs("variant122"), "variant122")) { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "big_polyvar_test.res", + 736, + 0 + ], + Error: new Error() + }; +} + +if (!eq(tFromJs("variant123"), "variant123")) { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "big_polyvar_test.res", + 737, + 0 + ], + Error: new Error() + }; +} + +if (!eq(tFromJs("variant124"), "variant124")) { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "big_polyvar_test.res", + 738, + 0 + ], + Error: new Error() + }; +} + +if (!eq(tFromJs("variant125"), "variant125")) { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "big_polyvar_test.res", + 739, + 0 + ], + Error: new Error() + }; +} + +if (!eq(tFromJs("variant126"), "variant126")) { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "big_polyvar_test.res", + 740, + 0 + ], + Error: new Error() + }; +} + +if (!eq(tFromJs("variant127"), "variant127")) { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "big_polyvar_test.res", + 741, + 0 + ], + Error: new Error() + }; +} + +if (!eq(tFromJs("variant128"), "variant128")) { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "big_polyvar_test.res", + 742, + 0 + ], + Error: new Error() + }; +} + +if (!eq(tFromJs("variant129"), "variant129")) { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "big_polyvar_test.res", + 743, + 0 + ], + Error: new Error() + }; +} + +if (!eq(tFromJs("variant130"), "variant130")) { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "big_polyvar_test.res", + 744, + 0 + ], + Error: new Error() + }; +} + +if (!eq(tFromJs("variant131"), "variant131")) { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "big_polyvar_test.res", + 745, + 0 + ], + Error: new Error() + }; +} + +if (!eq(tFromJs("variant132"), "variant132")) { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "big_polyvar_test.res", + 746, + 0 + ], + Error: new Error() + }; +} + +if (!eq(tFromJs("variant133"), "variant133")) { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "big_polyvar_test.res", + 747, + 0 + ], + Error: new Error() + }; +} + +if (!eq(tFromJs("variant134"), "variant134")) { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "big_polyvar_test.res", + 748, + 0 + ], + Error: new Error() + }; +} + +if (!eq(tFromJs("variant135"), "variant135")) { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "big_polyvar_test.res", + 749, + 0 + ], + Error: new Error() + }; +} + +if (!eq(tFromJs("variant136"), "variant136")) { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "big_polyvar_test.res", + 750, + 0 + ], + Error: new Error() + }; +} + +if (!eq(tFromJs("variant137"), "variant137")) { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "big_polyvar_test.res", + 751, + 0 + ], + Error: new Error() + }; +} + +if (!eq(tFromJs("variant138"), "variant138")) { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "big_polyvar_test.res", + 752, + 0 + ], + Error: new Error() + }; +} + +if (!eq(tFromJs("variant139"), "variant139")) { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "big_polyvar_test.res", + 753, + 0 + ], + Error: new Error() + }; +} + +if (!eq(tFromJs("variant140"), "variant140")) { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "big_polyvar_test.res", + 754, + 0 + ], + Error: new Error() + }; +} + +if (!eq(tFromJs("variant141"), "variant141")) { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "big_polyvar_test.res", + 755, + 0 + ], + Error: new Error() + }; +} + +if (!eq(tFromJs("variant142"), "variant142")) { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "big_polyvar_test.res", + 756, + 0 + ], + Error: new Error() + }; +} + +if (!eq(tFromJs("variant143"), "variant143")) { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "big_polyvar_test.res", + 757, + 0 + ], + Error: new Error() + }; +} + +if (!eq(tFromJs("variant144"), "variant144")) { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "big_polyvar_test.res", + 758, + 0 + ], + Error: new Error() + }; +} + +if (!eq(tFromJs("variant145"), "variant145")) { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "big_polyvar_test.res", + 759, + 0 + ], + Error: new Error() + }; +} + +if (!eq(tFromJs("variant146"), "variant146")) { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "big_polyvar_test.res", + 760, + 0 + ], + Error: new Error() + }; +} + +if (!eq(tFromJs("variant147"), "variant147")) { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "big_polyvar_test.res", + 761, + 0 + ], + Error: new Error() + }; +} + +if (!eq(tFromJs("variant148"), "variant148")) { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "big_polyvar_test.res", + 762, + 0 + ], + Error: new Error() + }; +} + +if (!eq(tFromJs("variant149"), "variant149")) { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "big_polyvar_test.res", + 763, + 0 + ], + Error: new Error() + }; +} + +if (!eq(tFromJs("variant150"), "variant150")) { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "big_polyvar_test.res", + 764, + 0 + ], + Error: new Error() + }; +} + +if (!eq(tFromJs("variant151"), "variant151")) { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "big_polyvar_test.res", + 765, + 0 + ], + Error: new Error() + }; +} + +if (!eq(tFromJs("variant152"), "variant152")) { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "big_polyvar_test.res", + 766, + 0 + ], + Error: new Error() + }; +} + +if (!eq(tFromJs("variant153"), "variant153")) { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "big_polyvar_test.res", + 767, + 0 + ], + Error: new Error() + }; +} + +if (!eq(tFromJs("variant154"), "variant154")) { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "big_polyvar_test.res", + 768, + 0 + ], + Error: new Error() + }; +} + +if (!eq(tFromJs("variant155"), "variant155")) { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "big_polyvar_test.res", + 769, + 0 + ], + Error: new Error() + }; +} + +if (!eq(tFromJs("variant156"), "variant156")) { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "big_polyvar_test.res", + 770, + 0 + ], + Error: new Error() + }; +} + +if (!eq(tFromJs("variant157"), "variant157")) { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "big_polyvar_test.res", + 771, + 0 + ], + Error: new Error() + }; +} + +if (!eq(tFromJs("variant158"), "variant158")) { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "big_polyvar_test.res", + 772, + 0 + ], + Error: new Error() + }; +} + +if (!eq(tFromJs("variant159"), "variant159")) { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "big_polyvar_test.res", + 773, + 0 + ], + Error: new Error() + }; +} + +if (!eq(tFromJs("variant160"), "variant160")) { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "big_polyvar_test.res", + 774, + 0 + ], + Error: new Error() + }; +} + +if (!eq(tFromJs("variant161"), "variant161")) { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "big_polyvar_test.res", + 775, + 0 + ], + Error: new Error() + }; +} + +if (!eq(tFromJs("variant162"), "variant162")) { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "big_polyvar_test.res", + 776, + 0 + ], + Error: new Error() + }; +} + +if (!eq(tFromJs("variant163"), "variant163")) { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "big_polyvar_test.res", + 777, + 0 + ], + Error: new Error() + }; +} + +if (!eq(tFromJs("variant164"), "variant164")) { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "big_polyvar_test.res", + 778, + 0 + ], + Error: new Error() + }; +} + +if (!eq(tFromJs("variant165"), "variant165")) { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "big_polyvar_test.res", + 779, + 0 + ], + Error: new Error() + }; +} + +if (!eq(tFromJs("variant166"), "variant166")) { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "big_polyvar_test.res", + 780, + 0 + ], + Error: new Error() + }; +} + +if (!eq(tFromJs("variant167"), "variant167")) { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "big_polyvar_test.res", + 781, + 0 + ], + Error: new Error() + }; +} + +if (!eq(tFromJs("variant168"), "variant168")) { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "big_polyvar_test.res", + 782, + 0 + ], + Error: new Error() + }; +} + +if (!eq(tFromJs("variant169"), "variant169")) { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "big_polyvar_test.res", + 783, + 0 + ], + Error: new Error() + }; +} + +if (!eq(tFromJs("variant170"), "variant170")) { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "big_polyvar_test.res", + 784, + 0 + ], + Error: new Error() + }; +} + +if (!eq(tFromJs("variant171"), "variant171")) { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "big_polyvar_test.res", + 785, + 0 + ], + Error: new Error() + }; +} + +if (!eq(tFromJs("variant172"), "variant172")) { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "big_polyvar_test.res", + 786, + 0 + ], + Error: new Error() + }; +} + +if (!eq(tFromJs("variant173"), "variant173")) { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "big_polyvar_test.res", + 787, + 0 + ], + Error: new Error() + }; +} + +if (!eq(tFromJs("variant174"), "variant174")) { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "big_polyvar_test.res", + 788, + 0 + ], + Error: new Error() + }; +} + +if (!eq(tFromJs("variant175"), "variant175")) { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "big_polyvar_test.res", + 789, + 0 + ], + Error: new Error() + }; +} + +if (!eq(tFromJs("variant176"), "variant176")) { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "big_polyvar_test.res", + 790, + 0 + ], + Error: new Error() + }; +} + +if (!eq(tFromJs("variant177"), "variant177")) { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "big_polyvar_test.res", + 791, + 0 + ], + Error: new Error() + }; +} + +if (!eq(tFromJs("variant178"), "variant178")) { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "big_polyvar_test.res", + 792, + 0 + ], + Error: new Error() + }; +} + +if (!eq(tFromJs("variant179"), "variant179")) { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "big_polyvar_test.res", + 793, + 0 + ], + Error: new Error() + }; +} + +if (!eq(tFromJs("variant180"), "variant180")) { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "big_polyvar_test.res", + 794, + 0 + ], + Error: new Error() + }; +} + +if (!eq(tFromJs("variant181"), "variant181")) { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "big_polyvar_test.res", + 795, + 0 + ], + Error: new Error() + }; +} + +if (!eq(tFromJs("variant182"), "variant182")) { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "big_polyvar_test.res", + 796, + 0 + ], + Error: new Error() + }; +} + +if (!eq(tFromJs("variant183"), "variant183")) { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "big_polyvar_test.res", + 797, + 0 + ], + Error: new Error() + }; +} + +if (!eq(tFromJs("variant184"), "variant184")) { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "big_polyvar_test.res", + 798, + 0 + ], + Error: new Error() + }; +} + +if (!eq(tFromJs("variant185"), "variant185")) { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "big_polyvar_test.res", + 799, + 0 + ], + Error: new Error() + }; +} + +if (!eq(tFromJs("variant186"), "variant186")) { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "big_polyvar_test.res", + 800, + 0 + ], + Error: new Error() + }; +} + +if (!eq(tFromJs("variant187"), "variant187")) { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "big_polyvar_test.res", + 801, + 0 + ], + Error: new Error() + }; +} + +if (!eq(tFromJs("variant188"), "variant188")) { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "big_polyvar_test.res", + 802, + 0 + ], + Error: new Error() + }; +} + +if (!eq(tFromJs("variant189"), "variant189")) { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "big_polyvar_test.res", + 803, + 0 + ], + Error: new Error() + }; +} + +if (!eq(tFromJs("variant190"), "variant190")) { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "big_polyvar_test.res", + 804, + 0 + ], + Error: new Error() + }; +} + +if (!eq(tFromJs("variant191"), "variant191")) { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "big_polyvar_test.res", + 805, + 0 + ], + Error: new Error() + }; +} + +if (!eq(tFromJs("variant192"), "variant192")) { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "big_polyvar_test.res", + 806, + 0 + ], + Error: new Error() + }; +} + +if (!eq(tFromJs("variant193"), "variant193")) { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "big_polyvar_test.res", + 807, + 0 + ], + Error: new Error() + }; +} + +if (!eq(tFromJs("variant194"), "variant194")) { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "big_polyvar_test.res", + 808, + 0 + ], + Error: new Error() + }; +} + +if (!eq(tFromJs("variant195"), "variant195")) { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "big_polyvar_test.res", + 809, + 0 + ], + Error: new Error() + }; +} + +if (!eq(tFromJs("variant196"), "variant196")) { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "big_polyvar_test.res", + 810, + 0 + ], + Error: new Error() + }; +} + +if (!eq(tFromJs("variant197"), "variant197")) { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "big_polyvar_test.res", + 811, + 0 + ], + Error: new Error() + }; +} + +if (!eq(tFromJs("variant198"), "variant198")) { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "big_polyvar_test.res", + 812, + 0 + ], + Error: new Error() + }; +} + +if (!eq(tFromJs("variant199"), "variant199")) { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "big_polyvar_test.res", + 813, + 0 + ], + Error: new Error() + }; +} + +if (!eq(tFromJs("variant200"), "variant200")) { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "big_polyvar_test.res", + 814, + 0 + ], + Error: new Error() + }; +} + +if (!eq(tFromJs("variant201"), "variant201")) { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "big_polyvar_test.res", + 815, + 0 + ], + Error: new Error() + }; +} + +if (!eq(tFromJs("variant202"), "variant202")) { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "big_polyvar_test.res", + 816, + 0 + ], + Error: new Error() + }; +} + +if (!eq(tFromJs("variant203"), "variant203")) { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "big_polyvar_test.res", + 817, + 0 + ], + Error: new Error() + }; +} + +if (!eq(tFromJs("variant204"), "variant204")) { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "big_polyvar_test.res", + 818, + 0 + ], + Error: new Error() + }; +} + +if (!eq(tFromJs("variant205"), "variant205")) { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "big_polyvar_test.res", + 819, + 0 + ], + Error: new Error() + }; +} + +if (!eq(tFromJs("variant206"), "variant206")) { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "big_polyvar_test.res", + 820, + 0 + ], + Error: new Error() + }; +} + +if (!eq(tFromJs("variant207"), "variant207")) { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "big_polyvar_test.res", + 821, + 0 + ], + Error: new Error() + }; +} + +if (!eq(tFromJs("variant208"), "variant208")) { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "big_polyvar_test.res", + 822, + 0 + ], + Error: new Error() + }; +} + +if (!eq(tFromJs("variant209"), "variant209")) { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "big_polyvar_test.res", + 823, + 0 + ], + Error: new Error() + }; +} + +if (!eq(tFromJs("variant210"), "variant210")) { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "big_polyvar_test.res", + 824, + 0 + ], + Error: new Error() + }; +} + +if (!eq(tFromJs("variant211"), "variant211")) { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "big_polyvar_test.res", + 825, + 0 + ], + Error: new Error() + }; +} + +if (!eq(tFromJs("variant212"), "variant212")) { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "big_polyvar_test.res", + 826, + 0 + ], + Error: new Error() + }; +} + +if (!eq(tFromJs("variant213"), "variant213")) { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "big_polyvar_test.res", + 827, + 0 + ], + Error: new Error() + }; +} + +if (!eq(tFromJs("variant214"), "variant214")) { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "big_polyvar_test.res", + 828, + 0 + ], + Error: new Error() + }; +} + +if (!eq(tFromJs("variant215"), "variant215")) { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "big_polyvar_test.res", + 829, + 0 + ], + Error: new Error() + }; +} + +if (!eq(tFromJs("variant216"), "variant216")) { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "big_polyvar_test.res", + 830, + 0 + ], + Error: new Error() + }; +} + +if (!eq(tFromJs("variant217"), "variant217")) { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "big_polyvar_test.res", + 831, + 0 + ], + Error: new Error() + }; +} + +if (!eq(tFromJs("variant218"), "variant218")) { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "big_polyvar_test.res", + 832, + 0 + ], + Error: new Error() + }; +} + +if (!eq(tFromJs("variant219"), "variant219")) { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "big_polyvar_test.res", + 833, + 0 + ], + Error: new Error() + }; +} + +if (!eq(tFromJs("variant220"), "variant220")) { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "big_polyvar_test.res", + 834, + 0 + ], + Error: new Error() + }; +} + +if (!eq(tFromJs("variant221"), "variant221")) { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "big_polyvar_test.res", + 835, + 0 + ], + Error: new Error() + }; +} + +if (!eq(tFromJs("variant222"), "variant222")) { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "big_polyvar_test.res", + 836, + 0 + ], + Error: new Error() + }; +} + +if (!eq(tFromJs("variant223"), "variant223")) { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "big_polyvar_test.res", + 837, + 0 + ], + Error: new Error() + }; +} + +if (!eq(tFromJs("variant224"), "variant224")) { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "big_polyvar_test.res", + 838, + 0 + ], + Error: new Error() + }; +} + +if (!eq(tFromJs("variant225"), "variant225")) { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "big_polyvar_test.res", + 839, + 0 + ], + Error: new Error() + }; +} + +if (!eq(tFromJs("variant226"), "variant226")) { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "big_polyvar_test.res", + 840, + 0 + ], + Error: new Error() + }; +} + +if (!eq(tFromJs("variant227"), "variant227")) { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "big_polyvar_test.res", + 841, + 0 + ], + Error: new Error() + }; +} + +if (!eq(tFromJs("variant228"), "variant228")) { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "big_polyvar_test.res", + 842, + 0 + ], + Error: new Error() + }; +} + +if (!eq(tFromJs("variant229"), "variant229")) { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "big_polyvar_test.res", + 843, + 0 + ], + Error: new Error() + }; +} + +if (!eq(tFromJs("variant230"), "variant230")) { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "big_polyvar_test.res", + 844, + 0 + ], + Error: new Error() + }; +} + +if (!eq(tFromJs("variant231"), "variant231")) { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "big_polyvar_test.res", + 845, + 0 + ], + Error: new Error() + }; +} + +if (!eq(tFromJs("variant232"), "variant232")) { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "big_polyvar_test.res", + 846, + 0 + ], + Error: new Error() + }; +} + +if (!eq(tFromJs("variant233"), "variant233")) { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "big_polyvar_test.res", + 847, + 0 + ], + Error: new Error() + }; +} + +if (!eq(tFromJs("variant234"), "variant234")) { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "big_polyvar_test.res", + 848, + 0 + ], + Error: new Error() + }; +} + +if (!eq(tFromJs("variant235"), "variant235")) { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "big_polyvar_test.res", + 849, + 0 + ], + Error: new Error() + }; +} + +if (!eq(tFromJs("variant236"), "variant236")) { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "big_polyvar_test.res", + 850, + 0 + ], + Error: new Error() + }; +} + +if (!eq(tFromJs("variant237"), "variant237")) { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "big_polyvar_test.res", + 851, + 0 + ], + Error: new Error() + }; +} + +if (!eq(tFromJs("variant238"), "variant238")) { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "big_polyvar_test.res", + 852, + 0 + ], + Error: new Error() + }; +} + +if (!eq(tFromJs("variant239"), "variant239")) { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "big_polyvar_test.res", + 853, + 0 + ], + Error: new Error() + }; +} + +if (!eq(tFromJs("variant240"), "variant240")) { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "big_polyvar_test.res", + 854, + 0 + ], + Error: new Error() + }; +} + +if (!eq(tFromJs("variant241"), "variant241")) { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "big_polyvar_test.res", + 855, + 0 + ], + Error: new Error() + }; +} + +if (!eq(tFromJs("variant242"), "variant242")) { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "big_polyvar_test.res", + 856, + 0 + ], + Error: new Error() + }; +} + +if (!eq(tFromJs("variant243"), "variant243")) { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "big_polyvar_test.res", + 857, + 0 + ], + Error: new Error() + }; +} + +if (!eq(tFromJs("variant244"), "variant244")) { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "big_polyvar_test.res", + 858, + 0 + ], + Error: new Error() + }; +} + +if (!eq(tFromJs("variant245"), "variant245")) { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "big_polyvar_test.res", + 859, + 0 + ], + Error: new Error() + }; +} + +if (!eq(tFromJs("variant246"), "variant246")) { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "big_polyvar_test.res", + 860, + 0 + ], + Error: new Error() + }; +} + +if (!eq(tFromJs("variant247"), "variant247")) { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "big_polyvar_test.res", + 861, + 0 + ], + Error: new Error() + }; +} + +if (!eq(tFromJs("variant248"), "variant248")) { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "big_polyvar_test.res", + 862, + 0 + ], + Error: new Error() + }; +} + +if (!eq(tFromJs("variant249"), "variant249")) { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "big_polyvar_test.res", + 863, + 0 + ], + Error: new Error() + }; +} + +if (!eq(tFromJs("variant250"), "variant250")) { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "big_polyvar_test.res", + 864, + 0 + ], + Error: new Error() + }; +} + +if (!eq(tFromJs("variant251"), "variant251")) { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "big_polyvar_test.res", + 865, + 0 + ], + Error: new Error() + }; +} + +if (!eq(tFromJs("variant252"), "variant252")) { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "big_polyvar_test.res", + 866, + 0 + ], + Error: new Error() + }; +} + +if (!eq(tFromJs("variant253"), "variant253")) { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "big_polyvar_test.res", + 867, + 0 + ], + Error: new Error() + }; +} + +if (!eq(tFromJs("variant254"), "variant254")) { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "big_polyvar_test.res", + 868, + 0 + ], + Error: new Error() + }; +} + +if (!eq(tFromJs("variant255"), "variant255")) { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "big_polyvar_test.res", + 869, + 0 + ], + Error: new Error() + }; +} + +if (!eq(tFromJs("variant256"), "variant256")) { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "big_polyvar_test.res", + 870, + 0 + ], + Error: new Error() + }; +} + +if (!eq(tFromJs("variant257"), "variant257")) { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "big_polyvar_test.res", + 871, + 0 + ], + Error: new Error() + }; +} + +if (!eq(tFromJs("variant258"), "variant258")) { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "big_polyvar_test.res", + 872, + 0 + ], + Error: new Error() + }; +} + +if (!eq(tFromJs("variant259"), "variant259")) { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "big_polyvar_test.res", + 873, + 0 + ], + Error: new Error() + }; +} + +if (!eq(tFromJs("variant260"), "variant260")) { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "big_polyvar_test.res", + 874, + 0 + ], + Error: new Error() + }; +} + +if (!eq(tFromJs("variant261"), "variant261")) { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "big_polyvar_test.res", + 875, + 0 + ], + Error: new Error() + }; +} + +if (!eq(tFromJs("variant262"), "variant262")) { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "big_polyvar_test.res", + 876, + 0 + ], + Error: new Error() + }; +} + +if (!eq(tFromJs("variant263"), "variant263")) { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "big_polyvar_test.res", + 877, + 0 + ], + Error: new Error() + }; +} + +if (!eq(tFromJs("variant264"), "variant264")) { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "big_polyvar_test.res", + 878, + 0 + ], + Error: new Error() + }; +} + +if (!eq(tFromJs("variant265"), "variant265")) { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "big_polyvar_test.res", + 879, + 0 + ], + Error: new Error() + }; +} + +if (!eq(tFromJs("variant266"), "variant266")) { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "big_polyvar_test.res", + 880, + 0 + ], + Error: new Error() + }; +} + +if (!eq(tFromJs("variant267"), "variant267")) { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "big_polyvar_test.res", + 881, + 0 + ], + Error: new Error() + }; +} + +if (!eq(tFromJs("variant268"), "variant268")) { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "big_polyvar_test.res", + 882, + 0 + ], + Error: new Error() + }; +} + +if (!eq(tFromJs("variant269"), "variant269")) { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "big_polyvar_test.res", + 883, + 0 + ], + Error: new Error() + }; +} + +if (!eq(tFromJs("variant270"), "variant270")) { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "big_polyvar_test.res", + 884, + 0 + ], + Error: new Error() + }; +} + +if (!eq(tFromJs("variant271"), "variant271")) { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "big_polyvar_test.res", + 885, + 0 + ], + Error: new Error() + }; +} + +if (!eq(tFromJs("variant272"), "variant272")) { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "big_polyvar_test.res", + 886, + 0 + ], + Error: new Error() + }; +} + +if (!eq(tFromJs("variant273"), "variant273")) { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "big_polyvar_test.res", + 887, + 0 + ], + Error: new Error() + }; +} + +if (!eq(tFromJs("variant274"), "variant274")) { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "big_polyvar_test.res", + 888, + 0 + ], + Error: new Error() + }; +} + +if (!eq(tFromJs("variant275"), "variant275")) { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "big_polyvar_test.res", + 889, + 0 + ], + Error: new Error() + }; +} + +if (!eq(tFromJs("variant276"), "variant276")) { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "big_polyvar_test.res", + 890, + 0 + ], + Error: new Error() + }; +} + +if (!eq(tFromJs("variant277"), "variant277")) { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "big_polyvar_test.res", + 891, + 0 + ], + Error: new Error() + }; +} + +if (!eq(tFromJs("variant278"), "variant278")) { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "big_polyvar_test.res", + 892, + 0 + ], + Error: new Error() + }; +} + +if (!eq(tFromJs("variant279"), "variant279")) { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "big_polyvar_test.res", + 893, + 0 + ], + Error: new Error() + }; +} + +if (!eq(tFromJs("variant280"), "variant280")) { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "big_polyvar_test.res", + 894, + 0 + ], + Error: new Error() + }; +} + +if (!eq(tFromJs("variant281"), "variant281")) { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "big_polyvar_test.res", + 895, + 0 + ], + Error: new Error() + }; +} + +if (!eq(tFromJs("variant282"), "variant282")) { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "big_polyvar_test.res", + 896, + 0 + ], + Error: new Error() + }; +} + +if (!eq(tFromJs("variant283"), "variant283")) { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "big_polyvar_test.res", + 897, + 0 + ], + Error: new Error() + }; +} + +if (!eq(tFromJs("variant284"), "variant284")) { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "big_polyvar_test.res", + 898, + 0 + ], + Error: new Error() + }; +} + +if (!eq(tFromJs("variant285"), "variant285")) { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "big_polyvar_test.res", + 899, + 0 + ], + Error: new Error() + }; +} + +if (!eq(tFromJs("variant286"), "variant286")) { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "big_polyvar_test.res", + 900, + 0 + ], + Error: new Error() + }; +} + +if (!eq(tFromJs("variant287"), "variant287")) { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "big_polyvar_test.res", + 901, + 0 + ], + Error: new Error() + }; +} + +if (!eq(tFromJs("variant288"), "variant288")) { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "big_polyvar_test.res", + 902, + 0 + ], + Error: new Error() + }; +} + +if (!eq(tFromJs("variant289"), "variant289")) { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "big_polyvar_test.res", + 903, + 0 + ], + Error: new Error() + }; +} + +if (!eq(tFromJs("variant290"), "variant290")) { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "big_polyvar_test.res", + 904, + 0 + ], + Error: new Error() + }; +} + +if (!eq(tFromJs("variant291"), "variant291")) { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "big_polyvar_test.res", + 905, + 0 + ], + Error: new Error() + }; +} + +if (!eq(tFromJs("variant292"), "variant292")) { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "big_polyvar_test.res", + 906, + 0 + ], + Error: new Error() + }; +} + +if (!eq(tFromJs("variant293"), "variant293")) { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "big_polyvar_test.res", + 907, + 0 + ], + Error: new Error() + }; +} + +if (!eq(tFromJs("variant294"), "variant294")) { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "big_polyvar_test.res", + 908, + 0 + ], + Error: new Error() + }; +} + +if (!eq(tFromJs("variant295"), "variant295")) { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "big_polyvar_test.res", + 909, + 0 + ], + Error: new Error() + }; +} + +if (!eq(tFromJs("variant296"), "variant296")) { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "big_polyvar_test.res", + 910, + 0 + ], + Error: new Error() + }; +} + +if (!eq(tFromJs("variant297"), "variant297")) { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "big_polyvar_test.res", + 911, + 0 + ], + Error: new Error() + }; +} + +if (!eq(tFromJs("variant298"), "variant298")) { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "big_polyvar_test.res", + 912, + 0 + ], + Error: new Error() + }; +} + +if (!eq(tFromJs("variant299"), "variant299")) { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "big_polyvar_test.res", + 913, + 0 + ], + Error: new Error() + }; +} + +if (!eq(tFromJs("xx"), undefined)) { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "big_polyvar_test.res", + 914, + 0 + ], + Error: new Error() + }; +} + +export { + tToJs, + tFromJs, + eq, +} +/* Not a pure module */ diff --git a/tests/tests/src/bigint_test.js b/tests/tests/src/bigint_test.js deleted file mode 100644 index 119f102f48..0000000000 --- a/tests/tests/src/bigint_test.js +++ /dev/null @@ -1,180 +0,0 @@ -// Generated by ReScript, PLEASE EDIT WITH CARE -'use strict'; - -let Mt = require("./mt.js"); -let Mt_global = require("./mt_global.js"); -let Primitive_bigint = require("rescript/lib/js/Primitive_bigint.js"); -let Primitive_object = require("rescript/lib/js/Primitive_object.js"); - -let test_id = { - contents: 0 -}; - -let suites = { - contents: /* [] */0 -}; - -function eq(loc, x, y) { - Mt_global.collect_eq(test_id, suites, loc, x, y); -} - -function approx(loc, x, y) { - Mt_global.collect_approx(test_id, suites, loc, x, y); -} - -let bigint_compare = Primitive_bigint.compare; - -let generic_compare = Primitive_object.compare; - -function bigint_equal(x, y) { - return x === y; -} - -let generic_equal = Primitive_object.equal; - -function bigint_notequal(x, y) { - return x !== y; -} - -let generic_notequal = Primitive_object.notequal; - -function bigint_lessthan(x, y) { - return x < y; -} - -let generic_lessthan = Primitive_object.lessthan; - -function bigint_greaterthan(x, y) { - return x > y; -} - -let generic_greaterthan = Primitive_object.greaterthan; - -function bigint_lessequal(x, y) { - return x <= y; -} - -let generic_lessequal = Primitive_object.lessequal; - -function bigint_greaterequal(x, y) { - return x >= y; -} - -let generic_greaterequal = Primitive_object.greaterequal; - -function bigint_land(prim0, prim1) { - return prim0 & prim1; -} - -function bigint_lor(prim0, prim1) { - return prim0 | prim1; -} - -function bigint_lxor(prim0, prim1) { - return prim0 ^ prim1; -} - -function bigint_lsl(prim0, prim1) { - return (prim0 << prim1); -} - -function bigint_asr(prim0, prim1) { - return (prim0 >> prim1); -} - -eq("File \"bigint_test.res\", line 26, characters 5-12", Primitive_bigint.compare(1n, 1n), 0); - -eq("File \"bigint_test.res\", line 27, characters 5-12", Primitive_object.compare(1n, 1n), 0); - -eq("File \"bigint_test.res\", line 28, characters 5-12", Primitive_bigint.compare(-0n, -1n), 1); - -eq("File \"bigint_test.res\", line 29, characters 5-12", Primitive_object.compare(-0n, -1n), 1); - -eq("File \"bigint_test.res\", line 30, characters 5-12", Primitive_bigint.compare(0n, -1n), 1); - -eq("File \"bigint_test.res\", line 31, characters 5-12", Primitive_object.compare(0n, -1n), 1); - -eq("File \"bigint_test.res\", line 32, characters 5-12", Primitive_bigint.compare(1n, 2n), -1); - -eq("File \"bigint_test.res\", line 33, characters 5-12", Primitive_object.compare(1n, 2n), -1); - -eq("File \"bigint_test.res\", line 34, characters 5-12", Primitive_bigint.compare(1n, 2n), -1); - -eq("File \"bigint_test.res\", line 35, characters 5-12", Primitive_object.compare(1n, 2n), -1); - -eq("File \"bigint_test.res\", line 36, characters 5-12", Primitive_bigint.compare(1n, 1n), 0); - -eq("File \"bigint_test.res\", line 37, characters 5-12", Primitive_object.compare(1n, 1n), 0); - -eq("File \"bigint_test.res\", line 39, characters 4-11", true, true); - -eq("File \"bigint_test.res\", line 47, characters 4-11", Primitive_object.equal(1000000000000000000000000000000000000000000000000000000000000000000000000000000000000n, 1000000000000000000000000000000000000000000000000000000000000000000000000000000000000n), true); - -eq("File \"bigint_test.res\", line 55, characters 4-11", false, false); - -eq("File \"bigint_test.res\", line 63, characters 4-11", Primitive_object.equal(1000000000000000000000000000000000000000000000000000000000000000000000000000000000000n, 1000000000000000000000000000000000000000000000000000000000000000000000000000000000001n), false); - -eq("File \"bigint_test.res\", line 71, characters 4-11", false, false); - -eq("File \"bigint_test.res\", line 79, characters 4-11", Primitive_object.equal(1000000000000000000000000000000000000000000000000000000000000000000000000000000000000n, -1000000000000000000000000000000000000000000000000000000000000000000000000000000000000n), false); - -eq("File \"bigint_test.res\", line 87, characters 4-11", true, true); - -eq("File \"bigint_test.res\", line 99, characters 4-11", Primitive_object.equal(3n, 3n), true); - -eq("File \"bigint_test.res\", line 111, characters 4-11", true, true); - -eq("File \"bigint_test.res\", line 123, characters 4-11", Primitive_object.equal(3n, 3n), true); - -eq("File \"bigint_test.res\", line 135, characters 4-11", true, true); - -eq("File \"bigint_test.res\", line 147, characters 4-11", Primitive_object.equal(3n, 3n), true); - -eq("File \"bigint_test.res\", line 158, characters 5-12", 9n & 1n, 1n); - -eq("File \"bigint_test.res\", line 159, characters 5-12", 9n | 1n, 9n); - -eq("File \"bigint_test.res\", line 160, characters 5-12", 9n ^ 1n, 8n); - -eq("File \"bigint_test.res\", line 161, characters 5-12", (9n << 1n), 18n); - -eq("File \"bigint_test.res\", line 162, characters 5-12", (9n << -1n), 4n); - -eq("File \"bigint_test.res\", line 163, characters 5-12", (9n >> 1n), 4n); - -eq("File \"bigint_test.res\", line 164, characters 5-12", (9n >> -1n), 18n); - -eq("File \"bigint_test.res\", line 165, characters 5-12", (-9n >> 1n), -5n); - -eq("File \"bigint_test.res\", line 166, characters 5-12", (-9n >> -1n), -18n); - -eq("File \"bigint_test.res\", line 167, characters 5-12", 9n > 1n ? 9n : 1n, 9n); - -eq("File \"bigint_test.res\", line 168, characters 5-12", 9n < 1n ? 9n : 1n, 1n); - -Mt.from_pair_suites("Bigint_test", suites.contents); - -exports.test_id = test_id; -exports.suites = suites; -exports.eq = eq; -exports.approx = approx; -exports.bigint_compare = bigint_compare; -exports.generic_compare = generic_compare; -exports.bigint_equal = bigint_equal; -exports.generic_equal = generic_equal; -exports.bigint_notequal = bigint_notequal; -exports.generic_notequal = generic_notequal; -exports.bigint_lessthan = bigint_lessthan; -exports.generic_lessthan = generic_lessthan; -exports.bigint_greaterthan = bigint_greaterthan; -exports.generic_greaterthan = generic_greaterthan; -exports.bigint_lessequal = bigint_lessequal; -exports.generic_lessequal = generic_lessequal; -exports.bigint_greaterequal = bigint_greaterequal; -exports.generic_greaterequal = generic_greaterequal; -exports.bigint_land = bigint_land; -exports.bigint_lor = bigint_lor; -exports.bigint_lxor = bigint_lxor; -exports.bigint_lsl = bigint_lsl; -exports.bigint_asr = bigint_asr; -/* Not a pure module */ diff --git a/tests/tests/src/bigint_test.mjs b/tests/tests/src/bigint_test.mjs new file mode 100644 index 0000000000..70f398040d --- /dev/null +++ b/tests/tests/src/bigint_test.mjs @@ -0,0 +1,181 @@ +// Generated by ReScript, PLEASE EDIT WITH CARE + +import * as Mt from "./mt.mjs"; +import * as Mt_global from "./mt_global.mjs"; +import * as Primitive_bigint from "rescript/lib/es6/Primitive_bigint.js"; +import * as Primitive_object from "rescript/lib/es6/Primitive_object.js"; + +let test_id = { + contents: 0 +}; + +let suites = { + contents: /* [] */0 +}; + +function eq(loc, x, y) { + Mt_global.collect_eq(test_id, suites, loc, x, y); +} + +function approx(loc, x, y) { + Mt_global.collect_approx(test_id, suites, loc, x, y); +} + +let bigint_compare = Primitive_bigint.compare; + +let generic_compare = Primitive_object.compare; + +function bigint_equal(x, y) { + return x === y; +} + +let generic_equal = Primitive_object.equal; + +function bigint_notequal(x, y) { + return x !== y; +} + +let generic_notequal = Primitive_object.notequal; + +function bigint_lessthan(x, y) { + return x < y; +} + +let generic_lessthan = Primitive_object.lessthan; + +function bigint_greaterthan(x, y) { + return x > y; +} + +let generic_greaterthan = Primitive_object.greaterthan; + +function bigint_lessequal(x, y) { + return x <= y; +} + +let generic_lessequal = Primitive_object.lessequal; + +function bigint_greaterequal(x, y) { + return x >= y; +} + +let generic_greaterequal = Primitive_object.greaterequal; + +function bigint_land(prim0, prim1) { + return prim0 & prim1; +} + +function bigint_lor(prim0, prim1) { + return prim0 | prim1; +} + +function bigint_lxor(prim0, prim1) { + return prim0 ^ prim1; +} + +function bigint_lsl(prim0, prim1) { + return (prim0 << prim1); +} + +function bigint_asr(prim0, prim1) { + return (prim0 >> prim1); +} + +eq("File \"bigint_test.res\", line 26, characters 5-12", Primitive_bigint.compare(1n, 1n), 0); + +eq("File \"bigint_test.res\", line 27, characters 5-12", Primitive_object.compare(1n, 1n), 0); + +eq("File \"bigint_test.res\", line 28, characters 5-12", Primitive_bigint.compare(-0n, -1n), 1); + +eq("File \"bigint_test.res\", line 29, characters 5-12", Primitive_object.compare(-0n, -1n), 1); + +eq("File \"bigint_test.res\", line 30, characters 5-12", Primitive_bigint.compare(0n, -1n), 1); + +eq("File \"bigint_test.res\", line 31, characters 5-12", Primitive_object.compare(0n, -1n), 1); + +eq("File \"bigint_test.res\", line 32, characters 5-12", Primitive_bigint.compare(1n, 2n), -1); + +eq("File \"bigint_test.res\", line 33, characters 5-12", Primitive_object.compare(1n, 2n), -1); + +eq("File \"bigint_test.res\", line 34, characters 5-12", Primitive_bigint.compare(1n, 2n), -1); + +eq("File \"bigint_test.res\", line 35, characters 5-12", Primitive_object.compare(1n, 2n), -1); + +eq("File \"bigint_test.res\", line 36, characters 5-12", Primitive_bigint.compare(1n, 1n), 0); + +eq("File \"bigint_test.res\", line 37, characters 5-12", Primitive_object.compare(1n, 1n), 0); + +eq("File \"bigint_test.res\", line 39, characters 4-11", true, true); + +eq("File \"bigint_test.res\", line 47, characters 4-11", Primitive_object.equal(1000000000000000000000000000000000000000000000000000000000000000000000000000000000000n, 1000000000000000000000000000000000000000000000000000000000000000000000000000000000000n), true); + +eq("File \"bigint_test.res\", line 55, characters 4-11", false, false); + +eq("File \"bigint_test.res\", line 63, characters 4-11", Primitive_object.equal(1000000000000000000000000000000000000000000000000000000000000000000000000000000000000n, 1000000000000000000000000000000000000000000000000000000000000000000000000000000000001n), false); + +eq("File \"bigint_test.res\", line 71, characters 4-11", false, false); + +eq("File \"bigint_test.res\", line 79, characters 4-11", Primitive_object.equal(1000000000000000000000000000000000000000000000000000000000000000000000000000000000000n, -1000000000000000000000000000000000000000000000000000000000000000000000000000000000000n), false); + +eq("File \"bigint_test.res\", line 87, characters 4-11", true, true); + +eq("File \"bigint_test.res\", line 99, characters 4-11", Primitive_object.equal(3n, 3n), true); + +eq("File \"bigint_test.res\", line 111, characters 4-11", true, true); + +eq("File \"bigint_test.res\", line 123, characters 4-11", Primitive_object.equal(3n, 3n), true); + +eq("File \"bigint_test.res\", line 135, characters 4-11", true, true); + +eq("File \"bigint_test.res\", line 147, characters 4-11", Primitive_object.equal(3n, 3n), true); + +eq("File \"bigint_test.res\", line 158, characters 5-12", 9n & 1n, 1n); + +eq("File \"bigint_test.res\", line 159, characters 5-12", 9n | 1n, 9n); + +eq("File \"bigint_test.res\", line 160, characters 5-12", 9n ^ 1n, 8n); + +eq("File \"bigint_test.res\", line 161, characters 5-12", (9n << 1n), 18n); + +eq("File \"bigint_test.res\", line 162, characters 5-12", (9n << -1n), 4n); + +eq("File \"bigint_test.res\", line 163, characters 5-12", (9n >> 1n), 4n); + +eq("File \"bigint_test.res\", line 164, characters 5-12", (9n >> -1n), 18n); + +eq("File \"bigint_test.res\", line 165, characters 5-12", (-9n >> 1n), -5n); + +eq("File \"bigint_test.res\", line 166, characters 5-12", (-9n >> -1n), -18n); + +eq("File \"bigint_test.res\", line 167, characters 5-12", 9n > 1n ? 9n : 1n, 9n); + +eq("File \"bigint_test.res\", line 168, characters 5-12", 9n < 1n ? 9n : 1n, 1n); + +Mt.from_pair_suites("Bigint_test", suites.contents); + +export { + test_id, + suites, + eq, + approx, + bigint_compare, + generic_compare, + bigint_equal, + generic_equal, + bigint_notequal, + generic_notequal, + bigint_lessthan, + generic_lessthan, + bigint_greaterthan, + generic_greaterthan, + bigint_lessequal, + generic_lessequal, + bigint_greaterequal, + generic_greaterequal, + bigint_land, + bigint_lor, + bigint_lxor, + bigint_lsl, + bigint_asr, +} +/* Not a pure module */ diff --git a/tests/tests/src/block_alias_test.js b/tests/tests/src/block_alias_test.js deleted file mode 100644 index 269bf86b1c..0000000000 --- a/tests/tests/src/block_alias_test.js +++ /dev/null @@ -1,86 +0,0 @@ -// Generated by ReScript, PLEASE EDIT WITH CARE -'use strict'; - -let Mt = require("./mt.js"); -let Belt_List = require("rescript/lib/js/Belt_List.js"); -let Primitive_object = require("rescript/lib/js/Primitive_object.js"); - -let suites = { - contents: /* [] */0 -}; - -let test_id = { - contents: 0 -}; - -function eq(loc, x, y) { - Mt.eq_suites(test_id, suites, loc, x, y); -} - -function b(loc, x) { - Mt.bool_suites(test_id, suites, loc, x); -} - -let Block = {}; - -let v0 = { - TAG: "A", - _0: 0, - _1: 1 -}; - -let Block$1 = {}; - -let v1 = { - TAG: "A", - _0: 0, - _1: 1 -}; - -let N = { - Block: Block$1, - v1: v1 -}; - -let Caml_obj = {}; - -let List = {}; - -let V = { - List: List -}; - -let f = Primitive_object.equal; - -eq("File \"block_alias_test.res\", line 27, characters 3-10", Belt_List.length({ - hd: 1, - tl: { - hd: 2, - tl: /* [] */0 - } -}), 2); - -b("File \"block_alias_test.res\", line 28, characters 2-9", Primitive_object.equal(v0, { - TAG: "A", - _0: 0, - _1: 1 -})); - -eq("File \"block_alias_test.res\", line 29, characters 3-10", v0, v1); - -Mt.from_pair_suites("Block_alias_test", suites.contents); - -let h = Belt_List.length; - -exports.suites = suites; -exports.test_id = test_id; -exports.eq = eq; -exports.b = b; -exports.Block = Block; -exports.v0 = v0; -exports.N = N; -exports.Caml_obj = Caml_obj; -exports.V = V; -exports.f = f; -exports.h = h; -/* Not a pure module */ diff --git a/tests/tests/src/block_alias_test.mjs b/tests/tests/src/block_alias_test.mjs new file mode 100644 index 0000000000..082fe3f1a2 --- /dev/null +++ b/tests/tests/src/block_alias_test.mjs @@ -0,0 +1,87 @@ +// Generated by ReScript, PLEASE EDIT WITH CARE + +import * as Mt from "./mt.mjs"; +import * as Belt_List from "rescript/lib/es6/Belt_List.js"; +import * as Primitive_object from "rescript/lib/es6/Primitive_object.js"; + +let suites = { + contents: /* [] */0 +}; + +let test_id = { + contents: 0 +}; + +function eq(loc, x, y) { + Mt.eq_suites(test_id, suites, loc, x, y); +} + +function b(loc, x) { + Mt.bool_suites(test_id, suites, loc, x); +} + +let Block = {}; + +let v0 = { + TAG: "A", + _0: 0, + _1: 1 +}; + +let Block$1 = {}; + +let v1 = { + TAG: "A", + _0: 0, + _1: 1 +}; + +let N = { + Block: Block$1, + v1: v1 +}; + +let Caml_obj = {}; + +let List = {}; + +let V = { + List: List +}; + +let f = Primitive_object.equal; + +eq("File \"block_alias_test.res\", line 27, characters 3-10", Belt_List.length({ + hd: 1, + tl: { + hd: 2, + tl: /* [] */0 + } +}), 2); + +b("File \"block_alias_test.res\", line 28, characters 2-9", Primitive_object.equal(v0, { + TAG: "A", + _0: 0, + _1: 1 +})); + +eq("File \"block_alias_test.res\", line 29, characters 3-10", v0, v1); + +Mt.from_pair_suites("Block_alias_test", suites.contents); + +let h = Belt_List.length; + +export { + suites, + test_id, + eq, + b, + Block, + v0, + N, + Caml_obj, + V, + f, + h, +} +/* Not a pure module */ diff --git a/tests/tests/src/boolean_test.js b/tests/tests/src/boolean_test.js deleted file mode 100644 index ccf8ee22db..0000000000 --- a/tests/tests/src/boolean_test.js +++ /dev/null @@ -1,15 +0,0 @@ -// Generated by ReScript, PLEASE EDIT WITH CARE -'use strict'; - -let Mt = require("./mt.js"); -let Test_bool_equal = require("./test_bool_equal.js"); - -Mt.from_suites("boolean", { - hd: [ - "bool_equal", - Test_bool_equal.assertions - ], - tl: /* [] */0 -}); - -/* Not a pure module */ diff --git a/tests/tests/src/boolean_test.mjs b/tests/tests/src/boolean_test.mjs new file mode 100644 index 0000000000..fe37c3cc45 --- /dev/null +++ b/tests/tests/src/boolean_test.mjs @@ -0,0 +1,14 @@ +// Generated by ReScript, PLEASE EDIT WITH CARE + +import * as Mt from "./mt.mjs"; +import * as Test_bool_equal from "./test_bool_equal.mjs"; + +Mt.from_suites("boolean", { + hd: [ + "bool_equal", + Test_bool_equal.assertions + ], + tl: /* [] */0 +}); + +/* Not a pure module */ diff --git a/tests/tests/src/bs_abstract_test.js b/tests/tests/src/bs_abstract_test.js deleted file mode 100644 index 9ce29796a9..0000000000 --- a/tests/tests/src/bs_abstract_test.js +++ /dev/null @@ -1,58 +0,0 @@ -// Generated by ReScript, PLEASE EDIT WITH CARE -'use strict'; - - -let v = { - hd: 3, - tl: null -}; - -v.tl = v; - -let f = { - k: (x, y) => x === y, - y: "x" -}; - -function uf(u) { - return u.y0(1); -} - -function uf1(u) { - return extra => u.y1(1, extra); -} - -function uf2(u) { - return u.y1(1, 2); -} - -function uff(f) { - return f.yyyy(1); -} - -function uff2(f) { - return f.yyyy1(1, 2); -} - -function uff3(f) { - let x = f.yyyy2; - if (x !== undefined) { - return x(0); - } else { - return 0; - } -} - -function fx(v) { - return v.x; -} - -exports.f = f; -exports.uf = uf; -exports.uf1 = uf1; -exports.uf2 = uf2; -exports.uff = uff; -exports.uff2 = uff2; -exports.uff3 = uff3; -exports.fx = fx; -/* Not a pure module */ diff --git a/tests/tests/src/bs_abstract_test.mjs b/tests/tests/src/bs_abstract_test.mjs new file mode 100644 index 0000000000..e18570117c --- /dev/null +++ b/tests/tests/src/bs_abstract_test.mjs @@ -0,0 +1,59 @@ +// Generated by ReScript, PLEASE EDIT WITH CARE + + +let v = { + hd: 3, + tl: null +}; + +v.tl = v; + +let f = { + k: (x, y) => x === y, + y: "x" +}; + +function uf(u) { + return u.y0(1); +} + +function uf1(u) { + return extra => u.y1(1, extra); +} + +function uf2(u) { + return u.y1(1, 2); +} + +function uff(f) { + return f.yyyy(1); +} + +function uff2(f) { + return f.yyyy1(1, 2); +} + +function uff3(f) { + let x = f.yyyy2; + if (x !== undefined) { + return x(0); + } else { + return 0; + } +} + +function fx(v) { + return v.x; +} + +export { + f, + uf, + uf1, + uf2, + uff, + uff2, + uff3, + fx, +} +/* Not a pure module */ diff --git a/tests/tests/src/bs_array_test.js b/tests/tests/src/bs_array_test.js deleted file mode 100644 index 5b96a4e398..0000000000 --- a/tests/tests/src/bs_array_test.js +++ /dev/null @@ -1,1416 +0,0 @@ -// Generated by ReScript, PLEASE EDIT WITH CARE -'use strict'; - -let Mt = require("./mt.js"); -let Belt_List = require("rescript/lib/js/Belt_List.js"); -let Belt_Array = require("rescript/lib/js/Belt_Array.js"); -let Primitive_int = require("rescript/lib/js/Primitive_int.js"); -let Primitive_object = require("rescript/lib/js/Primitive_object.js"); - -let suites = { - contents: /* [] */0 -}; - -let test_id = { - contents: 0 -}; - -function eq(loc, x, y) { - Mt.eq_suites(test_id, suites, loc, x, y); -} - -function b(loc, x) { - Mt.bool_suites(test_id, suites, loc, x); -} - -function $$throw(loc, x) { - Mt.throw_suites(test_id, suites, loc, x); -} - -function neq(loc, x, y) { - test_id.contents = test_id.contents + 1 | 0; - suites.contents = { - hd: [ - loc + (" id " + test_id.contents.toString()), - () => ({ - TAG: "Neq", - _0: x, - _1: y - }) - ], - tl: suites.contents - }; -} - -function push(prim0, prim1) { - prim0.push(prim1); -} - -console.log([ - 1, - 2, - 3, - 4 -].filter(x => x > 2).map((x, i) => x + i | 0).reduce((x, y) => x + y | 0, 0)); - -let v = [ - 1, - 2 -]; - -eq("File \"bs_array_test.res\", line 31, characters 4-11", [ - Belt_Array.get(v, 0), - Belt_Array.get(v, 1), - Belt_Array.get(v, 2), - Belt_Array.get(v, 3), - Belt_Array.get(v, -1) -], [ - 1, - 2, - undefined, - undefined, - undefined -]); - -$$throw("File \"bs_array_test.res\", line 35, characters 8-15", () => { - Belt_Array.getExn([ - 0, - 1 - ], -1); -}); - -$$throw("File \"bs_array_test.res\", line 36, characters 8-15", () => { - Belt_Array.getExn([ - 0, - 1 - ], 2); -}); - -function f(extra) { - return Belt_Array.getExn([ - 0, - 1 - ], extra); -} - -b("File \"bs_array_test.res\", line 38, characters 4-11", Primitive_object.equal([ - f(0), - f(1) -], [ - 0, - 1 -])); - -$$throw("File \"bs_array_test.res\", line 44, characters 8-15", () => Belt_Array.setExn([ - 0, - 1 -], -1, 0)); - -$$throw("File \"bs_array_test.res\", line 45, characters 8-15", () => Belt_Array.setExn([ - 0, - 1 -], 2, 0)); - -b("File \"bs_array_test.res\", line 46, characters 4-11", !Belt_Array.set([ - 1, - 2 -], 2, 0)); - -let v$1 = [ - 1, - 2 -]; - -if (!Belt_Array.set(v$1, 0, 0)) { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "bs_array_test.res", - 51, - 6 - ], - Error: new Error() - }; -} - -b("File \"bs_array_test.res\", line 48, characters 4-11", Belt_Array.getExn(v$1, 0) === 0); - -let v$2 = [ - 1, - 2 -]; - -if (!Belt_Array.set(v$2, 1, 0)) { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "bs_array_test.res", - 59, - 6 - ], - Error: new Error() - }; -} - -b("File \"bs_array_test.res\", line 56, characters 4-11", Belt_Array.getExn(v$2, 1) === 0); - -let v$3 = [ - 1, - 2 -]; - -b("File \"bs_array_test.res\", line 64, characters 4-11", (Belt_Array.setExn(v$3, 0, 0), Belt_Array.getExn(v$3, 0) === 0)); - -let v$4 = [ - 1, - 2 -]; - -b("File \"bs_array_test.res\", line 72, characters 4-11", (Belt_Array.setExn(v$4, 1, 0), Belt_Array.getExn(v$4, 1) === 0)); - -function add(x, y) { - return x + y | 0; -} - -let v$5 = Belt_Array.makeBy(3000, i => i); - -let u = Belt_Array.shuffle(v$5); - -neq("File \"bs_array_test.res\", line 85, characters 6-13", u, v$5); - -eq("File \"bs_array_test.res\", line 87, characters 5-12", Belt_Array.reduce(u, 0, add), Belt_Array.reduce(v$5, 0, add)); - -b("File \"bs_array_test.res\", line 92, characters 4-11", Primitive_object.equal(Belt_Array.range(0, 3), [ - 0, - 1, - 2, - 3 -])); - -b("File \"bs_array_test.res\", line 93, characters 4-11", Primitive_object.equal(Belt_Array.range(3, 0), [])); - -b("File \"bs_array_test.res\", line 94, characters 4-11", Primitive_object.equal(Belt_Array.range(3, 3), [3])); - -b("File \"bs_array_test.res\", line 96, characters 4-11", Primitive_object.equal(Belt_Array.rangeBy(0, 10, 3), [ - 0, - 3, - 6, - 9 -])); - -b("File \"bs_array_test.res\", line 97, characters 4-11", Primitive_object.equal(Belt_Array.rangeBy(0, 12, 3), [ - 0, - 3, - 6, - 9, - 12 -])); - -b("File \"bs_array_test.res\", line 98, characters 4-11", Primitive_object.equal(Belt_Array.rangeBy(33, 0, 1), [])); - -b("File \"bs_array_test.res\", line 99, characters 4-11", Primitive_object.equal(Belt_Array.rangeBy(33, 0, -1), [])); - -b("File \"bs_array_test.res\", line 100, characters 4-11", Primitive_object.equal(Belt_Array.rangeBy(3, 12, -1), [])); - -b("File \"bs_array_test.res\", line 101, characters 4-11", Primitive_object.equal(Belt_Array.rangeBy(3, 3, 0), [])); - -b("File \"bs_array_test.res\", line 102, characters 4-11", Primitive_object.equal(Belt_Array.rangeBy(3, 3, 1), [3])); - -eq("File \"bs_array_test.res\", line 106, characters 5-12", Belt_Array.reduceReverse([], 100, (prim0, prim1) => prim0 - prim1 | 0), 100); - -eq("File \"bs_array_test.res\", line 107, characters 5-12", Belt_Array.reduceReverse([ - 1, - 2 -], 100, (prim0, prim1) => prim0 - prim1 | 0), 97); - -eq("File \"bs_array_test.res\", line 108, characters 5-12", Belt_Array.reduceReverse([ - 1, - 2, - 3, - 4 -], 100, (prim0, prim1) => prim0 - prim1 | 0), 90); - -eq("File \"bs_array_test.res\", line 109, characters 5-12", Belt_Array.reduceWithIndex([ - 1, - 2, - 3, - 4 -], 0, (acc, x, i) => (acc + x | 0) + i | 0), 16); - -b("File \"bs_array_test.res\", line 110, characters 4-11", Belt_Array.reduceReverse2([ - 1, - 2, - 3 -], [ - 1, - 2 -], 0, (acc, x, y) => (acc + x | 0) + y | 0) === 6); - -function addone(x) { - return x + 1 | 0; -} - -function makeMatrixExn(sx, sy, init) { - if (!(sx >= 0 && sy >= 0)) { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "bs_array_test.res", - 116, - 2 - ], - Error: new Error() - }; - } - let res = new Array(sx); - for (let x = 0; x < sx; ++x) { - let initY = new Array(sy); - for (let y = 0; y < sy; ++y) { - initY[y] = init; - } - res[x] = initY; - } - return res; -} - -eq("File \"bs_array_test.res\", line 129, characters 5-12", Belt_Array.makeBy(0, param => 1), []); - -eq("File \"bs_array_test.res\", line 130, characters 5-12", Belt_Array.makeBy(3, i => i), [ - 0, - 1, - 2 -]); - -eq("File \"bs_array_test.res\", line 131, characters 5-12", makeMatrixExn(3, 4, 1), [ - [ - 1, - 1, - 1, - 1 - ], - [ - 1, - 1, - 1, - 1 - ], - [ - 1, - 1, - 1, - 1 - ] -]); - -eq("File \"bs_array_test.res\", line 132, characters 5-12", makeMatrixExn(3, 0, 0), [ - [], - [], - [] -]); - -eq("File \"bs_array_test.res\", line 133, characters 5-12", makeMatrixExn(0, 3, 1), []); - -eq("File \"bs_array_test.res\", line 134, characters 5-12", makeMatrixExn(1, 1, 1), [[1]]); - -eq("File \"bs_array_test.res\", line 135, characters 5-12", [].slice(0), []); - -eq("File \"bs_array_test.res\", line 136, characters 5-12", Belt_Array.map([], prim => prim + 1 | 0), []); - -eq("File \"bs_array_test.res\", line 137, characters 5-12", Belt_Array.mapWithIndex([], add), []); - -eq("File \"bs_array_test.res\", line 138, characters 5-12", Belt_Array.mapWithIndex([ - 1, - 2, - 3 -], add), [ - 1, - 3, - 5 -]); - -eq("File \"bs_array_test.res\", line 139, characters 5-12", Belt_List.fromArray([]), /* [] */0); - -eq("File \"bs_array_test.res\", line 140, characters 5-12", Belt_List.fromArray([1]), { - hd: 1, - tl: /* [] */0 -}); - -eq("File \"bs_array_test.res\", line 141, characters 5-12", Belt_List.fromArray([ - 1, - 2, - 3 -]), { - hd: 1, - tl: { - hd: 2, - tl: { - hd: 3, - tl: /* [] */0 - } - } -}); - -eq("File \"bs_array_test.res\", line 142, characters 5-12", Belt_Array.map([ - 1, - 2, - 3 -], prim => prim + 1 | 0), [ - 2, - 3, - 4 -]); - -eq("File \"bs_array_test.res\", line 143, characters 5-12", Belt_List.toArray(/* [] */0), []); - -eq("File \"bs_array_test.res\", line 144, characters 5-12", Belt_List.toArray({ - hd: 1, - tl: /* [] */0 -}), [1]); - -eq("File \"bs_array_test.res\", line 145, characters 5-12", Belt_List.toArray({ - hd: 1, - tl: { - hd: 2, - tl: /* [] */0 - } -}), [ - 1, - 2 -]); - -eq("File \"bs_array_test.res\", line 146, characters 5-12", Belt_List.toArray({ - hd: 1, - tl: { - hd: 2, - tl: { - hd: 3, - tl: /* [] */0 - } - } -}), [ - 1, - 2, - 3 -]); - -let v$6 = Belt_Array.makeBy(10, i => i); - -let v0 = Belt_Array.keep(v$6, x => x % 2 === 0); - -let v1 = Belt_Array.keep(v$6, x => x % 3 === 0); - -let v2 = Belt_Array.keepMap(v$6, x => { - if (x % 2 === 0) { - return x + 1 | 0; - } - -}); - -eq("File \"bs_array_test.res\", line 160, characters 5-12", v0, [ - 0, - 2, - 4, - 6, - 8 -]); - -eq("File \"bs_array_test.res\", line 161, characters 5-12", v1, [ - 0, - 3, - 6, - 9 -]); - -eq("File \"bs_array_test.res\", line 162, characters 5-12", v2, [ - 1, - 3, - 5, - 7, - 9 -]); - -let a = [ - 1, - 2, - 3, - 4, - 5 -]; - -let match = Belt_Array.partition(a, x => x % 2 === 0); - -eq("File \"bs_array_test.res\", line 168, characters 5-12", match[0], [ - 2, - 4 -]); - -eq("File \"bs_array_test.res\", line 169, characters 5-12", match[1], [ - 1, - 3, - 5 -]); - -let match$1 = Belt_Array.partition(a, x => x === 2); - -eq("File \"bs_array_test.res\", line 171, characters 5-12", match$1[0], [2]); - -eq("File \"bs_array_test.res\", line 172, characters 5-12", match$1[1], [ - 1, - 3, - 4, - 5 -]); - -let match$2 = Belt_Array.partition([], x => false); - -eq("File \"bs_array_test.res\", line 174, characters 5-12", match$2[0], []); - -eq("File \"bs_array_test.res\", line 175, characters 5-12", match$2[1], []); - -let a$1 = [ - 1, - 2, - 3, - 4, - 5 -]; - -eq("File \"bs_array_test.res\", line 180, characters 5-12", Belt_Array.slice(a$1, 0, 2), [ - 1, - 2 -]); - -eq("File \"bs_array_test.res\", line 181, characters 5-12", Belt_Array.slice(a$1, 0, 5), [ - 1, - 2, - 3, - 4, - 5 -]); - -eq("File \"bs_array_test.res\", line 182, characters 5-12", Belt_Array.slice(a$1, 0, 15), [ - 1, - 2, - 3, - 4, - 5 -]); - -eq("File \"bs_array_test.res\", line 183, characters 5-12", Belt_Array.slice(a$1, 5, 1), []); - -eq("File \"bs_array_test.res\", line 184, characters 5-12", Belt_Array.slice(a$1, 4, 1), [5]); - -eq("File \"bs_array_test.res\", line 185, characters 5-12", Belt_Array.slice(a$1, -1, 1), [5]); - -eq("File \"bs_array_test.res\", line 186, characters 5-12", Belt_Array.slice(a$1, -1, 2), [5]); - -eq("File \"bs_array_test.res\", line 187, characters 5-12", Belt_Array.slice(a$1, -2, 1), [4]); - -eq("File \"bs_array_test.res\", line 188, characters 5-12", Belt_Array.slice(a$1, -2, 2), [ - 4, - 5 -]); - -eq("File \"bs_array_test.res\", line 189, characters 5-12", Belt_Array.slice(a$1, -2, 3), [ - 4, - 5 -]); - -eq("File \"bs_array_test.res\", line 190, characters 5-12", Belt_Array.slice(a$1, -10, 3), [ - 1, - 2, - 3 -]); - -eq("File \"bs_array_test.res\", line 191, characters 5-12", Belt_Array.slice(a$1, -10, 4), [ - 1, - 2, - 3, - 4 -]); - -eq("File \"bs_array_test.res\", line 192, characters 5-12", Belt_Array.slice(a$1, -10, 5), [ - 1, - 2, - 3, - 4, - 5 -]); - -eq("File \"bs_array_test.res\", line 193, characters 5-12", Belt_Array.slice(a$1, -10, 6), [ - 1, - 2, - 3, - 4, - 5 -]); - -eq("File \"bs_array_test.res\", line 194, characters 5-12", Belt_Array.slice(a$1, 0, 0), []); - -eq("File \"bs_array_test.res\", line 195, characters 5-12", Belt_Array.slice(a$1, 0, -1), []); - -let a$2 = [ - 1, - 2, - 3, - 4, - 5 -]; - -eq("File \"bs_array_test.res\", line 200, characters 5-12", Belt_Array.sliceToEnd(a$2, 0), [ - 1, - 2, - 3, - 4, - 5 -]); - -eq("File \"bs_array_test.res\", line 201, characters 5-12", Belt_Array.sliceToEnd(a$2, 5), []); - -eq("File \"bs_array_test.res\", line 202, characters 5-12", Belt_Array.sliceToEnd(a$2, 4), [5]); - -eq("File \"bs_array_test.res\", line 203, characters 5-12", Belt_Array.sliceToEnd(a$2, -1), [5]); - -eq("File \"bs_array_test.res\", line 204, characters 5-12", Belt_Array.sliceToEnd(a$2, -2), [ - 4, - 5 -]); - -eq("File \"bs_array_test.res\", line 205, characters 5-12", Belt_Array.sliceToEnd(a$2, -10), [ - 1, - 2, - 3, - 4, - 5 -]); - -eq("File \"bs_array_test.res\", line 206, characters 5-12", Belt_Array.sliceToEnd(a$2, 6), []); - -let a$3 = Belt_Array.makeBy(10, x => x); - -Belt_Array.fill(a$3, 0, 3, 0); - -eq("File \"bs_array_test.res\", line 211, characters 5-12", a$3.slice(0), [ - 0, - 0, - 0, - 3, - 4, - 5, - 6, - 7, - 8, - 9 -]); - -Belt_Array.fill(a$3, 2, 8, 1); - -eq("File \"bs_array_test.res\", line 213, characters 5-12", a$3.slice(0), [ - 0, - 0, - 1, - 1, - 1, - 1, - 1, - 1, - 1, - 1 -]); - -Belt_Array.fill(a$3, 8, 1, 9); - -eq("File \"bs_array_test.res\", line 215, characters 5-12", a$3.slice(0), [ - 0, - 0, - 1, - 1, - 1, - 1, - 1, - 1, - 9, - 1 -]); - -Belt_Array.fill(a$3, 8, 2, 9); - -eq("File \"bs_array_test.res\", line 217, characters 5-12", a$3.slice(0), [ - 0, - 0, - 1, - 1, - 1, - 1, - 1, - 1, - 9, - 9 -]); - -Belt_Array.fill(a$3, 8, 3, 12); - -eq("File \"bs_array_test.res\", line 219, characters 5-12", a$3.slice(0), [ - 0, - 0, - 1, - 1, - 1, - 1, - 1, - 1, - 12, - 12 -]); - -Belt_Array.fill(a$3, -2, 3, 11); - -eq("File \"bs_array_test.res\", line 221, characters 5-12", a$3.slice(0), [ - 0, - 0, - 1, - 1, - 1, - 1, - 1, - 1, - 11, - 11 -]); - -Belt_Array.fill(a$3, -3, 3, 10); - -eq("File \"bs_array_test.res\", line 223, characters 5-12", a$3.slice(0), [ - 0, - 0, - 1, - 1, - 1, - 1, - 1, - 10, - 10, - 10 -]); - -Belt_Array.fill(a$3, -3, 1, 7); - -eq("File \"bs_array_test.res\", line 225, characters 5-12", a$3.slice(0), [ - 0, - 0, - 1, - 1, - 1, - 1, - 1, - 7, - 10, - 10 -]); - -Belt_Array.fill(a$3, -13, 1, 7); - -eq("File \"bs_array_test.res\", line 227, characters 5-12", a$3.slice(0), [ - 7, - 0, - 1, - 1, - 1, - 1, - 1, - 7, - 10, - 10 -]); - -Belt_Array.fill(a$3, -13, 12, 7); - -eq("File \"bs_array_test.res\", line 229, characters 5-12", a$3.slice(0), Belt_Array.make(10, 7)); - -Belt_Array.fill(a$3, 0, -1, 2); - -eq("File \"bs_array_test.res\", line 231, characters 5-12", a$3.slice(0), Belt_Array.make(10, 7)); - -let b$1 = [ - 1, - 2, - 3 -]; - -Belt_Array.fill(b$1, 0, 0, 0); - -eq("File \"bs_array_test.res\", line 234, characters 5-12", b$1, [ - 1, - 2, - 3 -]); - -Belt_Array.fill(b$1, 4, 1, 0); - -eq("File \"bs_array_test.res\", line 236, characters 5-12", b$1, [ - 1, - 2, - 3 -]); - -let a0 = Belt_Array.makeBy(10, x => x); - -let b0 = Belt_Array.make(10, 3); - -Belt_Array.blit(a0, 1, b0, 2, 5); - -eq("File \"bs_array_test.res\", line 243, characters 5-12", b0.slice(0), [ - 3, - 3, - 1, - 2, - 3, - 4, - 5, - 3, - 3, - 3 -]); - -Belt_Array.blit(a0, -1, b0, 2, 5); - -eq("File \"bs_array_test.res\", line 245, characters 5-12", b0.slice(0), [ - 3, - 3, - 9, - 2, - 3, - 4, - 5, - 3, - 3, - 3 -]); - -Belt_Array.blit(a0, -1, b0, -2, 5); - -eq("File \"bs_array_test.res\", line 247, characters 5-12", b0.slice(0), [ - 3, - 3, - 9, - 2, - 3, - 4, - 5, - 3, - 9, - 3 -]); - -Belt_Array.blit(a0, -2, b0, -2, 2); - -eq("File \"bs_array_test.res\", line 249, characters 5-12", b0.slice(0), [ - 3, - 3, - 9, - 2, - 3, - 4, - 5, - 3, - 8, - 9 -]); - -Belt_Array.blit(a0, -11, b0, -11, 100); - -eq("File \"bs_array_test.res\", line 251, characters 5-12", b0.slice(0), a0); - -Belt_Array.blit(a0, -11, b0, -11, 2); - -eq("File \"bs_array_test.res\", line 253, characters 5-12", b0.slice(0), a0); - -let aa = Belt_Array.makeBy(10, x => x); - -Belt_Array.blit(aa, -1, aa, 1, 2); - -eq("File \"bs_array_test.res\", line 256, characters 5-12", aa.slice(0), [ - 0, - 9, - 2, - 3, - 4, - 5, - 6, - 7, - 8, - 9 -]); - -Belt_Array.blit(aa, -2, aa, 1, 2); - -eq("File \"bs_array_test.res\", line 258, characters 5-12", aa.slice(0), [ - 0, - 8, - 9, - 3, - 4, - 5, - 6, - 7, - 8, - 9 -]); - -Belt_Array.blit(aa, -5, aa, 4, 3); - -eq("File \"bs_array_test.res\", line 260, characters 5-12", aa.slice(0), [ - 0, - 8, - 9, - 3, - 5, - 6, - 7, - 7, - 8, - 9 -]); - -Belt_Array.blit(aa, 4, aa, 5, 3); - -eq("File \"bs_array_test.res\", line 262, characters 5-12", aa.slice(0), [ - 0, - 8, - 9, - 3, - 5, - 5, - 6, - 7, - 8, - 9 -]); - -eq("File \"bs_array_test.res\", line 263, characters 5-12", Belt_Array.make(0, 3), []); - -eq("File \"bs_array_test.res\", line 264, characters 5-12", Belt_Array.make(-1, 3), []); - -let c = [ - 0, - 1, - 2 -]; - -Belt_Array.blit(c, 4, c, 1, 1); - -eq("File \"bs_array_test.res\", line 267, characters 5-12", c, [ - 0, - 1, - 2 -]); - -eq("File \"bs_array_test.res\", line 271, characters 5-12", Belt_Array.zip([ - 1, - 2, - 3 -], [ - 2, - 3, - 4, - 1 -]), [ - [ - 1, - 2 - ], - [ - 2, - 3 - ], - [ - 3, - 4 - ] -]); - -eq("File \"bs_array_test.res\", line 272, characters 5-12", Belt_Array.zip([ - 2, - 3, - 4, - 1 -], [ - 1, - 2, - 3 -]), [ - [ - 2, - 1 - ], - [ - 3, - 2 - ], - [ - 4, - 3 - ] -]); - -eq("File \"bs_array_test.res\", line 273, characters 5-12", Belt_Array.zipBy([ - 2, - 3, - 4, - 1 -], [ - 1, - 2, - 3 -], (prim0, prim1) => prim0 - prim1 | 0), [ - 1, - 1, - 1 -]); - -eq("File \"bs_array_test.res\", line 274, characters 5-12", Belt_Array.zipBy([ - 1, - 2, - 3 -], [ - 2, - 3, - 4, - 1 -], (prim0, prim1) => prim0 - prim1 | 0), Belt_Array.map([ - 1, - 1, - 1 -], x => -x | 0)); - -eq("File \"bs_array_test.res\", line 275, characters 5-12", Belt_Array.unzip([ - [ - 1, - 2 - ], - [ - 2, - 3 - ], - [ - 3, - 4 - ] -]), [ - [ - 1, - 2, - 3 - ], - [ - 2, - 3, - 4 - ] -]); - -function sumUsingForEach(xs) { - let v = { - contents: 0 - }; - Belt_Array.forEach(xs, x => { - v.contents = v.contents + x | 0; - }); - return v.contents; -} - -eq("File \"bs_array_test.res\", line 287, characters 5-12", sumUsingForEach([ - 0, - 1, - 2, - 3, - 4 -]), 10); - -b("File \"bs_array_test.res\", line 288, characters 4-11", !Belt_Array.every([ - 0, - 1, - 2, - 3, - 4 -], x => x > 2)); - -b("File \"bs_array_test.res\", line 289, characters 4-11", Belt_Array.some([ - 1, - 3, - 7, - 8 -], x => x % 2 === 0)); - -b("File \"bs_array_test.res\", line 290, characters 4-11", !Belt_Array.some([ - 1, - 3, - 7 -], x => x % 2 === 0)); - -b("File \"bs_array_test.res\", line 291, characters 4-11", !Belt_Array.eq([ - 0, - 1 -], [1], (prim0, prim1) => prim0 === prim1)); - -let c$1 = { - contents: 0 -}; - -b("File \"bs_array_test.res\", line 293, characters 4-11", (Belt_Array.forEachWithIndex([ - 1, - 1, - 1 -], (i, v) => { - c$1.contents = (c$1.contents + i | 0) + v | 0; -}), c$1.contents === 6)); - -function id(loc, x) { - let u = x.slice(0); - eq("File \"bs_array_test.res\", line 304, characters 4-11", Belt_Array.reverse(x), (Belt_Array.reverseInPlace(u), u)); -} - -id("File \"bs_array_test.res\", line 314, characters 5-12", []); - -id("File \"bs_array_test.res\", line 315, characters 5-12", [1]); - -id("File \"bs_array_test.res\", line 316, characters 5-12", [ - 1, - 2 -]); - -id("File \"bs_array_test.res\", line 317, characters 5-12", [ - 1, - 2, - 3 -]); - -id("File \"bs_array_test.res\", line 318, characters 5-12", [ - 1, - 2, - 3, - 4 -]); - -function every2(xs, ys, x) { - return Belt_Array.every2(Belt_List.toArray(xs), Belt_List.toArray(ys), x); -} - -function some2(xs, ys, x) { - return Belt_Array.some2(Belt_List.toArray(xs), Belt_List.toArray(ys), x); -} - -eq("File \"bs_array_test.res\", line 326, characters 5-12", every2(/* [] */0, { - hd: 1, - tl: /* [] */0 -}, (x, y) => x > y), true); - -eq("File \"bs_array_test.res\", line 327, characters 5-12", every2({ - hd: 2, - tl: { - hd: 3, - tl: /* [] */0 - } -}, { - hd: 1, - tl: /* [] */0 -}, (x, y) => x > y), true); - -eq("File \"bs_array_test.res\", line 328, characters 5-12", every2({ - hd: 2, - tl: /* [] */0 -}, { - hd: 1, - tl: /* [] */0 -}, (x, y) => x > y), true); - -eq("File \"bs_array_test.res\", line 329, characters 5-12", every2({ - hd: 2, - tl: { - hd: 3, - tl: /* [] */0 - } -}, { - hd: 1, - tl: { - hd: 4, - tl: /* [] */0 - } -}, (x, y) => x > y), false); - -eq("File \"bs_array_test.res\", line 330, characters 5-12", every2({ - hd: 2, - tl: { - hd: 3, - tl: /* [] */0 - } -}, { - hd: 1, - tl: { - hd: 0, - tl: /* [] */0 - } -}, (x, y) => x > y), true); - -eq("File \"bs_array_test.res\", line 331, characters 5-12", some2(/* [] */0, { - hd: 1, - tl: /* [] */0 -}, (x, y) => x > y), false); - -eq("File \"bs_array_test.res\", line 332, characters 5-12", some2({ - hd: 2, - tl: { - hd: 3, - tl: /* [] */0 - } -}, { - hd: 1, - tl: /* [] */0 -}, (x, y) => x > y), true); - -eq("File \"bs_array_test.res\", line 333, characters 5-12", some2({ - hd: 2, - tl: { - hd: 3, - tl: /* [] */0 - } -}, { - hd: 1, - tl: { - hd: 4, - tl: /* [] */0 - } -}, (x, y) => x > y), true); - -eq("File \"bs_array_test.res\", line 334, characters 5-12", some2({ - hd: 0, - tl: { - hd: 3, - tl: /* [] */0 - } -}, { - hd: 1, - tl: { - hd: 4, - tl: /* [] */0 - } -}, (x, y) => x > y), false); - -eq("File \"bs_array_test.res\", line 335, characters 5-12", some2({ - hd: 0, - tl: { - hd: 3, - tl: /* [] */0 - } -}, { - hd: 3, - tl: { - hd: 2, - tl: /* [] */0 - } -}, (x, y) => x > y), true); - -eq("File \"bs_array_test.res\", line 339, characters 5-12", Belt_Array.concat([], [ - 1, - 2, - 3 -]), [ - 1, - 2, - 3 -]); - -eq("File \"bs_array_test.res\", line 340, characters 5-12", Belt_Array.concat([], []), []); - -eq("File \"bs_array_test.res\", line 341, characters 5-12", Belt_Array.concat([ - 3, - 2 -], [ - 1, - 2, - 3 -]), [ - 3, - 2, - 1, - 2, - 3 -]); - -eq("File \"bs_array_test.res\", line 342, characters 5-12", Belt_Array.concatMany([ - [ - 3, - 2 - ], - [ - 1, - 2, - 3 - ] -]), [ - 3, - 2, - 1, - 2, - 3 -]); - -eq("File \"bs_array_test.res\", line 343, characters 5-12", Belt_Array.concatMany([ - [ - 3, - 2 - ], - [ - 1, - 2, - 3 - ], - [], - [0] -]), [ - 3, - 2, - 1, - 2, - 3, - 0 -]); - -eq("File \"bs_array_test.res\", line 344, characters 5-12", Belt_Array.concatMany([ - [], - [ - 3, - 2 - ], - [ - 1, - 2, - 3 - ], - [], - [0] -]), [ - 3, - 2, - 1, - 2, - 3, - 0 -]); - -eq("File \"bs_array_test.res\", line 345, characters 5-12", Belt_Array.concatMany([ - [], - [] -]), []); - -b("File \"bs_array_test.res\", line 349, characters 4-11", Belt_Array.cmp([ - 1, - 2, - 3 -], [ - 0, - 1, - 2, - 3 -], Primitive_int.compare) < 0); - -b("File \"bs_array_test.res\", line 350, characters 4-11", Belt_Array.cmp([ - 0, - 1, - 2, - 3 -], [ - 1, - 2, - 3 -], Primitive_int.compare) > 0); - -b("File \"bs_array_test.res\", line 351, characters 4-11", Belt_Array.cmp([ - 1, - 2, - 3 -], [ - 0, - 1, - 2 -], Primitive_int.compare) > 0); - -b("File \"bs_array_test.res\", line 352, characters 4-11", Belt_Array.cmp([ - 1, - 2, - 3 -], [ - 1, - 2, - 3 -], Primitive_int.compare) === 0); - -b("File \"bs_array_test.res\", line 353, characters 4-11", Belt_Array.cmp([ - 1, - 2, - 4 -], [ - 1, - 2, - 3 -], Primitive_int.compare) > 0); - -eq("File \"bs_array_test.res\", line 357, characters 5-12", Belt_Array.getBy([ - 1, - 2, - 3 -], x => x > 1), 2); - -eq("File \"bs_array_test.res\", line 358, characters 5-12", Belt_Array.getBy([ - 1, - 2, - 3 -], x => x > 3), undefined); - -eq("File \"bs_array_test.res\", line 362, characters 5-12", Belt_Array.getIndexBy([ - 1, - 2, - 3 -], x => x > 1), 1); - -eq("File \"bs_array_test.res\", line 363, characters 5-12", Belt_Array.getIndexBy([ - 1, - 2, - 3 -], x => x > 3), undefined); - -let arr = []; - -arr.push(3); - -arr.push(2); - -arr.push(1); - -eq("File \"bs_array_test.res\", line 371, characters 5-12", arr, [ - 3, - 2, - 1 -]); - -Mt.from_pair_suites("File \"bs_array_test.res\", line 374, characters 20-27", suites.contents); - -let A; - -let L; - -exports.suites = suites; -exports.test_id = test_id; -exports.eq = eq; -exports.b = b; -exports.$$throw = $$throw; -exports.neq = neq; -exports.A = A; -exports.L = L; -exports.push = push; -exports.add = add; -exports.addone = addone; -exports.makeMatrixExn = makeMatrixExn; -exports.sumUsingForEach = sumUsingForEach; -exports.id = id; -/* Not a pure module */ diff --git a/tests/tests/src/bs_array_test.mjs b/tests/tests/src/bs_array_test.mjs new file mode 100644 index 0000000000..3aa3a01f3e --- /dev/null +++ b/tests/tests/src/bs_array_test.mjs @@ -0,0 +1,1417 @@ +// Generated by ReScript, PLEASE EDIT WITH CARE + +import * as Mt from "./mt.mjs"; +import * as Belt_List from "rescript/lib/es6/Belt_List.js"; +import * as Belt_Array from "rescript/lib/es6/Belt_Array.js"; +import * as Primitive_int from "rescript/lib/es6/Primitive_int.js"; +import * as Primitive_object from "rescript/lib/es6/Primitive_object.js"; + +let suites = { + contents: /* [] */0 +}; + +let test_id = { + contents: 0 +}; + +function eq(loc, x, y) { + Mt.eq_suites(test_id, suites, loc, x, y); +} + +function b(loc, x) { + Mt.bool_suites(test_id, suites, loc, x); +} + +function $$throw(loc, x) { + Mt.throw_suites(test_id, suites, loc, x); +} + +function neq(loc, x, y) { + test_id.contents = test_id.contents + 1 | 0; + suites.contents = { + hd: [ + loc + (" id " + test_id.contents.toString()), + () => ({ + TAG: "Neq", + _0: x, + _1: y + }) + ], + tl: suites.contents + }; +} + +function push(prim0, prim1) { + prim0.push(prim1); +} + +console.log([ + 1, + 2, + 3, + 4 +].filter(x => x > 2).map((x, i) => x + i | 0).reduce((x, y) => x + y | 0, 0)); + +let v = [ + 1, + 2 +]; + +eq("File \"bs_array_test.res\", line 31, characters 4-11", [ + Belt_Array.get(v, 0), + Belt_Array.get(v, 1), + Belt_Array.get(v, 2), + Belt_Array.get(v, 3), + Belt_Array.get(v, -1) +], [ + 1, + 2, + undefined, + undefined, + undefined +]); + +$$throw("File \"bs_array_test.res\", line 35, characters 8-15", () => { + Belt_Array.getExn([ + 0, + 1 + ], -1); +}); + +$$throw("File \"bs_array_test.res\", line 36, characters 8-15", () => { + Belt_Array.getExn([ + 0, + 1 + ], 2); +}); + +function f(extra) { + return Belt_Array.getExn([ + 0, + 1 + ], extra); +} + +b("File \"bs_array_test.res\", line 38, characters 4-11", Primitive_object.equal([ + f(0), + f(1) +], [ + 0, + 1 +])); + +$$throw("File \"bs_array_test.res\", line 44, characters 8-15", () => Belt_Array.setExn([ + 0, + 1 +], -1, 0)); + +$$throw("File \"bs_array_test.res\", line 45, characters 8-15", () => Belt_Array.setExn([ + 0, + 1 +], 2, 0)); + +b("File \"bs_array_test.res\", line 46, characters 4-11", !Belt_Array.set([ + 1, + 2 +], 2, 0)); + +let v$1 = [ + 1, + 2 +]; + +if (!Belt_Array.set(v$1, 0, 0)) { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "bs_array_test.res", + 51, + 6 + ], + Error: new Error() + }; +} + +b("File \"bs_array_test.res\", line 48, characters 4-11", Belt_Array.getExn(v$1, 0) === 0); + +let v$2 = [ + 1, + 2 +]; + +if (!Belt_Array.set(v$2, 1, 0)) { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "bs_array_test.res", + 59, + 6 + ], + Error: new Error() + }; +} + +b("File \"bs_array_test.res\", line 56, characters 4-11", Belt_Array.getExn(v$2, 1) === 0); + +let v$3 = [ + 1, + 2 +]; + +b("File \"bs_array_test.res\", line 64, characters 4-11", (Belt_Array.setExn(v$3, 0, 0), Belt_Array.getExn(v$3, 0) === 0)); + +let v$4 = [ + 1, + 2 +]; + +b("File \"bs_array_test.res\", line 72, characters 4-11", (Belt_Array.setExn(v$4, 1, 0), Belt_Array.getExn(v$4, 1) === 0)); + +function add(x, y) { + return x + y | 0; +} + +let v$5 = Belt_Array.makeBy(3000, i => i); + +let u = Belt_Array.shuffle(v$5); + +neq("File \"bs_array_test.res\", line 85, characters 6-13", u, v$5); + +eq("File \"bs_array_test.res\", line 87, characters 5-12", Belt_Array.reduce(u, 0, add), Belt_Array.reduce(v$5, 0, add)); + +b("File \"bs_array_test.res\", line 92, characters 4-11", Primitive_object.equal(Belt_Array.range(0, 3), [ + 0, + 1, + 2, + 3 +])); + +b("File \"bs_array_test.res\", line 93, characters 4-11", Primitive_object.equal(Belt_Array.range(3, 0), [])); + +b("File \"bs_array_test.res\", line 94, characters 4-11", Primitive_object.equal(Belt_Array.range(3, 3), [3])); + +b("File \"bs_array_test.res\", line 96, characters 4-11", Primitive_object.equal(Belt_Array.rangeBy(0, 10, 3), [ + 0, + 3, + 6, + 9 +])); + +b("File \"bs_array_test.res\", line 97, characters 4-11", Primitive_object.equal(Belt_Array.rangeBy(0, 12, 3), [ + 0, + 3, + 6, + 9, + 12 +])); + +b("File \"bs_array_test.res\", line 98, characters 4-11", Primitive_object.equal(Belt_Array.rangeBy(33, 0, 1), [])); + +b("File \"bs_array_test.res\", line 99, characters 4-11", Primitive_object.equal(Belt_Array.rangeBy(33, 0, -1), [])); + +b("File \"bs_array_test.res\", line 100, characters 4-11", Primitive_object.equal(Belt_Array.rangeBy(3, 12, -1), [])); + +b("File \"bs_array_test.res\", line 101, characters 4-11", Primitive_object.equal(Belt_Array.rangeBy(3, 3, 0), [])); + +b("File \"bs_array_test.res\", line 102, characters 4-11", Primitive_object.equal(Belt_Array.rangeBy(3, 3, 1), [3])); + +eq("File \"bs_array_test.res\", line 106, characters 5-12", Belt_Array.reduceReverse([], 100, (prim0, prim1) => prim0 - prim1 | 0), 100); + +eq("File \"bs_array_test.res\", line 107, characters 5-12", Belt_Array.reduceReverse([ + 1, + 2 +], 100, (prim0, prim1) => prim0 - prim1 | 0), 97); + +eq("File \"bs_array_test.res\", line 108, characters 5-12", Belt_Array.reduceReverse([ + 1, + 2, + 3, + 4 +], 100, (prim0, prim1) => prim0 - prim1 | 0), 90); + +eq("File \"bs_array_test.res\", line 109, characters 5-12", Belt_Array.reduceWithIndex([ + 1, + 2, + 3, + 4 +], 0, (acc, x, i) => (acc + x | 0) + i | 0), 16); + +b("File \"bs_array_test.res\", line 110, characters 4-11", Belt_Array.reduceReverse2([ + 1, + 2, + 3 +], [ + 1, + 2 +], 0, (acc, x, y) => (acc + x | 0) + y | 0) === 6); + +function addone(x) { + return x + 1 | 0; +} + +function makeMatrixExn(sx, sy, init) { + if (!(sx >= 0 && sy >= 0)) { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "bs_array_test.res", + 116, + 2 + ], + Error: new Error() + }; + } + let res = new Array(sx); + for (let x = 0; x < sx; ++x) { + let initY = new Array(sy); + for (let y = 0; y < sy; ++y) { + initY[y] = init; + } + res[x] = initY; + } + return res; +} + +eq("File \"bs_array_test.res\", line 129, characters 5-12", Belt_Array.makeBy(0, param => 1), []); + +eq("File \"bs_array_test.res\", line 130, characters 5-12", Belt_Array.makeBy(3, i => i), [ + 0, + 1, + 2 +]); + +eq("File \"bs_array_test.res\", line 131, characters 5-12", makeMatrixExn(3, 4, 1), [ + [ + 1, + 1, + 1, + 1 + ], + [ + 1, + 1, + 1, + 1 + ], + [ + 1, + 1, + 1, + 1 + ] +]); + +eq("File \"bs_array_test.res\", line 132, characters 5-12", makeMatrixExn(3, 0, 0), [ + [], + [], + [] +]); + +eq("File \"bs_array_test.res\", line 133, characters 5-12", makeMatrixExn(0, 3, 1), []); + +eq("File \"bs_array_test.res\", line 134, characters 5-12", makeMatrixExn(1, 1, 1), [[1]]); + +eq("File \"bs_array_test.res\", line 135, characters 5-12", [].slice(0), []); + +eq("File \"bs_array_test.res\", line 136, characters 5-12", Belt_Array.map([], prim => prim + 1 | 0), []); + +eq("File \"bs_array_test.res\", line 137, characters 5-12", Belt_Array.mapWithIndex([], add), []); + +eq("File \"bs_array_test.res\", line 138, characters 5-12", Belt_Array.mapWithIndex([ + 1, + 2, + 3 +], add), [ + 1, + 3, + 5 +]); + +eq("File \"bs_array_test.res\", line 139, characters 5-12", Belt_List.fromArray([]), /* [] */0); + +eq("File \"bs_array_test.res\", line 140, characters 5-12", Belt_List.fromArray([1]), { + hd: 1, + tl: /* [] */0 +}); + +eq("File \"bs_array_test.res\", line 141, characters 5-12", Belt_List.fromArray([ + 1, + 2, + 3 +]), { + hd: 1, + tl: { + hd: 2, + tl: { + hd: 3, + tl: /* [] */0 + } + } +}); + +eq("File \"bs_array_test.res\", line 142, characters 5-12", Belt_Array.map([ + 1, + 2, + 3 +], prim => prim + 1 | 0), [ + 2, + 3, + 4 +]); + +eq("File \"bs_array_test.res\", line 143, characters 5-12", Belt_List.toArray(/* [] */0), []); + +eq("File \"bs_array_test.res\", line 144, characters 5-12", Belt_List.toArray({ + hd: 1, + tl: /* [] */0 +}), [1]); + +eq("File \"bs_array_test.res\", line 145, characters 5-12", Belt_List.toArray({ + hd: 1, + tl: { + hd: 2, + tl: /* [] */0 + } +}), [ + 1, + 2 +]); + +eq("File \"bs_array_test.res\", line 146, characters 5-12", Belt_List.toArray({ + hd: 1, + tl: { + hd: 2, + tl: { + hd: 3, + tl: /* [] */0 + } + } +}), [ + 1, + 2, + 3 +]); + +let v$6 = Belt_Array.makeBy(10, i => i); + +let v0 = Belt_Array.keep(v$6, x => x % 2 === 0); + +let v1 = Belt_Array.keep(v$6, x => x % 3 === 0); + +let v2 = Belt_Array.keepMap(v$6, x => { + if (x % 2 === 0) { + return x + 1 | 0; + } + +}); + +eq("File \"bs_array_test.res\", line 160, characters 5-12", v0, [ + 0, + 2, + 4, + 6, + 8 +]); + +eq("File \"bs_array_test.res\", line 161, characters 5-12", v1, [ + 0, + 3, + 6, + 9 +]); + +eq("File \"bs_array_test.res\", line 162, characters 5-12", v2, [ + 1, + 3, + 5, + 7, + 9 +]); + +let a = [ + 1, + 2, + 3, + 4, + 5 +]; + +let match = Belt_Array.partition(a, x => x % 2 === 0); + +eq("File \"bs_array_test.res\", line 168, characters 5-12", match[0], [ + 2, + 4 +]); + +eq("File \"bs_array_test.res\", line 169, characters 5-12", match[1], [ + 1, + 3, + 5 +]); + +let match$1 = Belt_Array.partition(a, x => x === 2); + +eq("File \"bs_array_test.res\", line 171, characters 5-12", match$1[0], [2]); + +eq("File \"bs_array_test.res\", line 172, characters 5-12", match$1[1], [ + 1, + 3, + 4, + 5 +]); + +let match$2 = Belt_Array.partition([], x => false); + +eq("File \"bs_array_test.res\", line 174, characters 5-12", match$2[0], []); + +eq("File \"bs_array_test.res\", line 175, characters 5-12", match$2[1], []); + +let a$1 = [ + 1, + 2, + 3, + 4, + 5 +]; + +eq("File \"bs_array_test.res\", line 180, characters 5-12", Belt_Array.slice(a$1, 0, 2), [ + 1, + 2 +]); + +eq("File \"bs_array_test.res\", line 181, characters 5-12", Belt_Array.slice(a$1, 0, 5), [ + 1, + 2, + 3, + 4, + 5 +]); + +eq("File \"bs_array_test.res\", line 182, characters 5-12", Belt_Array.slice(a$1, 0, 15), [ + 1, + 2, + 3, + 4, + 5 +]); + +eq("File \"bs_array_test.res\", line 183, characters 5-12", Belt_Array.slice(a$1, 5, 1), []); + +eq("File \"bs_array_test.res\", line 184, characters 5-12", Belt_Array.slice(a$1, 4, 1), [5]); + +eq("File \"bs_array_test.res\", line 185, characters 5-12", Belt_Array.slice(a$1, -1, 1), [5]); + +eq("File \"bs_array_test.res\", line 186, characters 5-12", Belt_Array.slice(a$1, -1, 2), [5]); + +eq("File \"bs_array_test.res\", line 187, characters 5-12", Belt_Array.slice(a$1, -2, 1), [4]); + +eq("File \"bs_array_test.res\", line 188, characters 5-12", Belt_Array.slice(a$1, -2, 2), [ + 4, + 5 +]); + +eq("File \"bs_array_test.res\", line 189, characters 5-12", Belt_Array.slice(a$1, -2, 3), [ + 4, + 5 +]); + +eq("File \"bs_array_test.res\", line 190, characters 5-12", Belt_Array.slice(a$1, -10, 3), [ + 1, + 2, + 3 +]); + +eq("File \"bs_array_test.res\", line 191, characters 5-12", Belt_Array.slice(a$1, -10, 4), [ + 1, + 2, + 3, + 4 +]); + +eq("File \"bs_array_test.res\", line 192, characters 5-12", Belt_Array.slice(a$1, -10, 5), [ + 1, + 2, + 3, + 4, + 5 +]); + +eq("File \"bs_array_test.res\", line 193, characters 5-12", Belt_Array.slice(a$1, -10, 6), [ + 1, + 2, + 3, + 4, + 5 +]); + +eq("File \"bs_array_test.res\", line 194, characters 5-12", Belt_Array.slice(a$1, 0, 0), []); + +eq("File \"bs_array_test.res\", line 195, characters 5-12", Belt_Array.slice(a$1, 0, -1), []); + +let a$2 = [ + 1, + 2, + 3, + 4, + 5 +]; + +eq("File \"bs_array_test.res\", line 200, characters 5-12", Belt_Array.sliceToEnd(a$2, 0), [ + 1, + 2, + 3, + 4, + 5 +]); + +eq("File \"bs_array_test.res\", line 201, characters 5-12", Belt_Array.sliceToEnd(a$2, 5), []); + +eq("File \"bs_array_test.res\", line 202, characters 5-12", Belt_Array.sliceToEnd(a$2, 4), [5]); + +eq("File \"bs_array_test.res\", line 203, characters 5-12", Belt_Array.sliceToEnd(a$2, -1), [5]); + +eq("File \"bs_array_test.res\", line 204, characters 5-12", Belt_Array.sliceToEnd(a$2, -2), [ + 4, + 5 +]); + +eq("File \"bs_array_test.res\", line 205, characters 5-12", Belt_Array.sliceToEnd(a$2, -10), [ + 1, + 2, + 3, + 4, + 5 +]); + +eq("File \"bs_array_test.res\", line 206, characters 5-12", Belt_Array.sliceToEnd(a$2, 6), []); + +let a$3 = Belt_Array.makeBy(10, x => x); + +Belt_Array.fill(a$3, 0, 3, 0); + +eq("File \"bs_array_test.res\", line 211, characters 5-12", a$3.slice(0), [ + 0, + 0, + 0, + 3, + 4, + 5, + 6, + 7, + 8, + 9 +]); + +Belt_Array.fill(a$3, 2, 8, 1); + +eq("File \"bs_array_test.res\", line 213, characters 5-12", a$3.slice(0), [ + 0, + 0, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1 +]); + +Belt_Array.fill(a$3, 8, 1, 9); + +eq("File \"bs_array_test.res\", line 215, characters 5-12", a$3.slice(0), [ + 0, + 0, + 1, + 1, + 1, + 1, + 1, + 1, + 9, + 1 +]); + +Belt_Array.fill(a$3, 8, 2, 9); + +eq("File \"bs_array_test.res\", line 217, characters 5-12", a$3.slice(0), [ + 0, + 0, + 1, + 1, + 1, + 1, + 1, + 1, + 9, + 9 +]); + +Belt_Array.fill(a$3, 8, 3, 12); + +eq("File \"bs_array_test.res\", line 219, characters 5-12", a$3.slice(0), [ + 0, + 0, + 1, + 1, + 1, + 1, + 1, + 1, + 12, + 12 +]); + +Belt_Array.fill(a$3, -2, 3, 11); + +eq("File \"bs_array_test.res\", line 221, characters 5-12", a$3.slice(0), [ + 0, + 0, + 1, + 1, + 1, + 1, + 1, + 1, + 11, + 11 +]); + +Belt_Array.fill(a$3, -3, 3, 10); + +eq("File \"bs_array_test.res\", line 223, characters 5-12", a$3.slice(0), [ + 0, + 0, + 1, + 1, + 1, + 1, + 1, + 10, + 10, + 10 +]); + +Belt_Array.fill(a$3, -3, 1, 7); + +eq("File \"bs_array_test.res\", line 225, characters 5-12", a$3.slice(0), [ + 0, + 0, + 1, + 1, + 1, + 1, + 1, + 7, + 10, + 10 +]); + +Belt_Array.fill(a$3, -13, 1, 7); + +eq("File \"bs_array_test.res\", line 227, characters 5-12", a$3.slice(0), [ + 7, + 0, + 1, + 1, + 1, + 1, + 1, + 7, + 10, + 10 +]); + +Belt_Array.fill(a$3, -13, 12, 7); + +eq("File \"bs_array_test.res\", line 229, characters 5-12", a$3.slice(0), Belt_Array.make(10, 7)); + +Belt_Array.fill(a$3, 0, -1, 2); + +eq("File \"bs_array_test.res\", line 231, characters 5-12", a$3.slice(0), Belt_Array.make(10, 7)); + +let b$1 = [ + 1, + 2, + 3 +]; + +Belt_Array.fill(b$1, 0, 0, 0); + +eq("File \"bs_array_test.res\", line 234, characters 5-12", b$1, [ + 1, + 2, + 3 +]); + +Belt_Array.fill(b$1, 4, 1, 0); + +eq("File \"bs_array_test.res\", line 236, characters 5-12", b$1, [ + 1, + 2, + 3 +]); + +let a0 = Belt_Array.makeBy(10, x => x); + +let b0 = Belt_Array.make(10, 3); + +Belt_Array.blit(a0, 1, b0, 2, 5); + +eq("File \"bs_array_test.res\", line 243, characters 5-12", b0.slice(0), [ + 3, + 3, + 1, + 2, + 3, + 4, + 5, + 3, + 3, + 3 +]); + +Belt_Array.blit(a0, -1, b0, 2, 5); + +eq("File \"bs_array_test.res\", line 245, characters 5-12", b0.slice(0), [ + 3, + 3, + 9, + 2, + 3, + 4, + 5, + 3, + 3, + 3 +]); + +Belt_Array.blit(a0, -1, b0, -2, 5); + +eq("File \"bs_array_test.res\", line 247, characters 5-12", b0.slice(0), [ + 3, + 3, + 9, + 2, + 3, + 4, + 5, + 3, + 9, + 3 +]); + +Belt_Array.blit(a0, -2, b0, -2, 2); + +eq("File \"bs_array_test.res\", line 249, characters 5-12", b0.slice(0), [ + 3, + 3, + 9, + 2, + 3, + 4, + 5, + 3, + 8, + 9 +]); + +Belt_Array.blit(a0, -11, b0, -11, 100); + +eq("File \"bs_array_test.res\", line 251, characters 5-12", b0.slice(0), a0); + +Belt_Array.blit(a0, -11, b0, -11, 2); + +eq("File \"bs_array_test.res\", line 253, characters 5-12", b0.slice(0), a0); + +let aa = Belt_Array.makeBy(10, x => x); + +Belt_Array.blit(aa, -1, aa, 1, 2); + +eq("File \"bs_array_test.res\", line 256, characters 5-12", aa.slice(0), [ + 0, + 9, + 2, + 3, + 4, + 5, + 6, + 7, + 8, + 9 +]); + +Belt_Array.blit(aa, -2, aa, 1, 2); + +eq("File \"bs_array_test.res\", line 258, characters 5-12", aa.slice(0), [ + 0, + 8, + 9, + 3, + 4, + 5, + 6, + 7, + 8, + 9 +]); + +Belt_Array.blit(aa, -5, aa, 4, 3); + +eq("File \"bs_array_test.res\", line 260, characters 5-12", aa.slice(0), [ + 0, + 8, + 9, + 3, + 5, + 6, + 7, + 7, + 8, + 9 +]); + +Belt_Array.blit(aa, 4, aa, 5, 3); + +eq("File \"bs_array_test.res\", line 262, characters 5-12", aa.slice(0), [ + 0, + 8, + 9, + 3, + 5, + 5, + 6, + 7, + 8, + 9 +]); + +eq("File \"bs_array_test.res\", line 263, characters 5-12", Belt_Array.make(0, 3), []); + +eq("File \"bs_array_test.res\", line 264, characters 5-12", Belt_Array.make(-1, 3), []); + +let c = [ + 0, + 1, + 2 +]; + +Belt_Array.blit(c, 4, c, 1, 1); + +eq("File \"bs_array_test.res\", line 267, characters 5-12", c, [ + 0, + 1, + 2 +]); + +eq("File \"bs_array_test.res\", line 271, characters 5-12", Belt_Array.zip([ + 1, + 2, + 3 +], [ + 2, + 3, + 4, + 1 +]), [ + [ + 1, + 2 + ], + [ + 2, + 3 + ], + [ + 3, + 4 + ] +]); + +eq("File \"bs_array_test.res\", line 272, characters 5-12", Belt_Array.zip([ + 2, + 3, + 4, + 1 +], [ + 1, + 2, + 3 +]), [ + [ + 2, + 1 + ], + [ + 3, + 2 + ], + [ + 4, + 3 + ] +]); + +eq("File \"bs_array_test.res\", line 273, characters 5-12", Belt_Array.zipBy([ + 2, + 3, + 4, + 1 +], [ + 1, + 2, + 3 +], (prim0, prim1) => prim0 - prim1 | 0), [ + 1, + 1, + 1 +]); + +eq("File \"bs_array_test.res\", line 274, characters 5-12", Belt_Array.zipBy([ + 1, + 2, + 3 +], [ + 2, + 3, + 4, + 1 +], (prim0, prim1) => prim0 - prim1 | 0), Belt_Array.map([ + 1, + 1, + 1 +], x => -x | 0)); + +eq("File \"bs_array_test.res\", line 275, characters 5-12", Belt_Array.unzip([ + [ + 1, + 2 + ], + [ + 2, + 3 + ], + [ + 3, + 4 + ] +]), [ + [ + 1, + 2, + 3 + ], + [ + 2, + 3, + 4 + ] +]); + +function sumUsingForEach(xs) { + let v = { + contents: 0 + }; + Belt_Array.forEach(xs, x => { + v.contents = v.contents + x | 0; + }); + return v.contents; +} + +eq("File \"bs_array_test.res\", line 287, characters 5-12", sumUsingForEach([ + 0, + 1, + 2, + 3, + 4 +]), 10); + +b("File \"bs_array_test.res\", line 288, characters 4-11", !Belt_Array.every([ + 0, + 1, + 2, + 3, + 4 +], x => x > 2)); + +b("File \"bs_array_test.res\", line 289, characters 4-11", Belt_Array.some([ + 1, + 3, + 7, + 8 +], x => x % 2 === 0)); + +b("File \"bs_array_test.res\", line 290, characters 4-11", !Belt_Array.some([ + 1, + 3, + 7 +], x => x % 2 === 0)); + +b("File \"bs_array_test.res\", line 291, characters 4-11", !Belt_Array.eq([ + 0, + 1 +], [1], (prim0, prim1) => prim0 === prim1)); + +let c$1 = { + contents: 0 +}; + +b("File \"bs_array_test.res\", line 293, characters 4-11", (Belt_Array.forEachWithIndex([ + 1, + 1, + 1 +], (i, v) => { + c$1.contents = (c$1.contents + i | 0) + v | 0; +}), c$1.contents === 6)); + +function id(loc, x) { + let u = x.slice(0); + eq("File \"bs_array_test.res\", line 304, characters 4-11", Belt_Array.reverse(x), (Belt_Array.reverseInPlace(u), u)); +} + +id("File \"bs_array_test.res\", line 314, characters 5-12", []); + +id("File \"bs_array_test.res\", line 315, characters 5-12", [1]); + +id("File \"bs_array_test.res\", line 316, characters 5-12", [ + 1, + 2 +]); + +id("File \"bs_array_test.res\", line 317, characters 5-12", [ + 1, + 2, + 3 +]); + +id("File \"bs_array_test.res\", line 318, characters 5-12", [ + 1, + 2, + 3, + 4 +]); + +function every2(xs, ys, x) { + return Belt_Array.every2(Belt_List.toArray(xs), Belt_List.toArray(ys), x); +} + +function some2(xs, ys, x) { + return Belt_Array.some2(Belt_List.toArray(xs), Belt_List.toArray(ys), x); +} + +eq("File \"bs_array_test.res\", line 326, characters 5-12", every2(/* [] */0, { + hd: 1, + tl: /* [] */0 +}, (x, y) => x > y), true); + +eq("File \"bs_array_test.res\", line 327, characters 5-12", every2({ + hd: 2, + tl: { + hd: 3, + tl: /* [] */0 + } +}, { + hd: 1, + tl: /* [] */0 +}, (x, y) => x > y), true); + +eq("File \"bs_array_test.res\", line 328, characters 5-12", every2({ + hd: 2, + tl: /* [] */0 +}, { + hd: 1, + tl: /* [] */0 +}, (x, y) => x > y), true); + +eq("File \"bs_array_test.res\", line 329, characters 5-12", every2({ + hd: 2, + tl: { + hd: 3, + tl: /* [] */0 + } +}, { + hd: 1, + tl: { + hd: 4, + tl: /* [] */0 + } +}, (x, y) => x > y), false); + +eq("File \"bs_array_test.res\", line 330, characters 5-12", every2({ + hd: 2, + tl: { + hd: 3, + tl: /* [] */0 + } +}, { + hd: 1, + tl: { + hd: 0, + tl: /* [] */0 + } +}, (x, y) => x > y), true); + +eq("File \"bs_array_test.res\", line 331, characters 5-12", some2(/* [] */0, { + hd: 1, + tl: /* [] */0 +}, (x, y) => x > y), false); + +eq("File \"bs_array_test.res\", line 332, characters 5-12", some2({ + hd: 2, + tl: { + hd: 3, + tl: /* [] */0 + } +}, { + hd: 1, + tl: /* [] */0 +}, (x, y) => x > y), true); + +eq("File \"bs_array_test.res\", line 333, characters 5-12", some2({ + hd: 2, + tl: { + hd: 3, + tl: /* [] */0 + } +}, { + hd: 1, + tl: { + hd: 4, + tl: /* [] */0 + } +}, (x, y) => x > y), true); + +eq("File \"bs_array_test.res\", line 334, characters 5-12", some2({ + hd: 0, + tl: { + hd: 3, + tl: /* [] */0 + } +}, { + hd: 1, + tl: { + hd: 4, + tl: /* [] */0 + } +}, (x, y) => x > y), false); + +eq("File \"bs_array_test.res\", line 335, characters 5-12", some2({ + hd: 0, + tl: { + hd: 3, + tl: /* [] */0 + } +}, { + hd: 3, + tl: { + hd: 2, + tl: /* [] */0 + } +}, (x, y) => x > y), true); + +eq("File \"bs_array_test.res\", line 339, characters 5-12", Belt_Array.concat([], [ + 1, + 2, + 3 +]), [ + 1, + 2, + 3 +]); + +eq("File \"bs_array_test.res\", line 340, characters 5-12", Belt_Array.concat([], []), []); + +eq("File \"bs_array_test.res\", line 341, characters 5-12", Belt_Array.concat([ + 3, + 2 +], [ + 1, + 2, + 3 +]), [ + 3, + 2, + 1, + 2, + 3 +]); + +eq("File \"bs_array_test.res\", line 342, characters 5-12", Belt_Array.concatMany([ + [ + 3, + 2 + ], + [ + 1, + 2, + 3 + ] +]), [ + 3, + 2, + 1, + 2, + 3 +]); + +eq("File \"bs_array_test.res\", line 343, characters 5-12", Belt_Array.concatMany([ + [ + 3, + 2 + ], + [ + 1, + 2, + 3 + ], + [], + [0] +]), [ + 3, + 2, + 1, + 2, + 3, + 0 +]); + +eq("File \"bs_array_test.res\", line 344, characters 5-12", Belt_Array.concatMany([ + [], + [ + 3, + 2 + ], + [ + 1, + 2, + 3 + ], + [], + [0] +]), [ + 3, + 2, + 1, + 2, + 3, + 0 +]); + +eq("File \"bs_array_test.res\", line 345, characters 5-12", Belt_Array.concatMany([ + [], + [] +]), []); + +b("File \"bs_array_test.res\", line 349, characters 4-11", Belt_Array.cmp([ + 1, + 2, + 3 +], [ + 0, + 1, + 2, + 3 +], Primitive_int.compare) < 0); + +b("File \"bs_array_test.res\", line 350, characters 4-11", Belt_Array.cmp([ + 0, + 1, + 2, + 3 +], [ + 1, + 2, + 3 +], Primitive_int.compare) > 0); + +b("File \"bs_array_test.res\", line 351, characters 4-11", Belt_Array.cmp([ + 1, + 2, + 3 +], [ + 0, + 1, + 2 +], Primitive_int.compare) > 0); + +b("File \"bs_array_test.res\", line 352, characters 4-11", Belt_Array.cmp([ + 1, + 2, + 3 +], [ + 1, + 2, + 3 +], Primitive_int.compare) === 0); + +b("File \"bs_array_test.res\", line 353, characters 4-11", Belt_Array.cmp([ + 1, + 2, + 4 +], [ + 1, + 2, + 3 +], Primitive_int.compare) > 0); + +eq("File \"bs_array_test.res\", line 357, characters 5-12", Belt_Array.getBy([ + 1, + 2, + 3 +], x => x > 1), 2); + +eq("File \"bs_array_test.res\", line 358, characters 5-12", Belt_Array.getBy([ + 1, + 2, + 3 +], x => x > 3), undefined); + +eq("File \"bs_array_test.res\", line 362, characters 5-12", Belt_Array.getIndexBy([ + 1, + 2, + 3 +], x => x > 1), 1); + +eq("File \"bs_array_test.res\", line 363, characters 5-12", Belt_Array.getIndexBy([ + 1, + 2, + 3 +], x => x > 3), undefined); + +let arr = []; + +arr.push(3); + +arr.push(2); + +arr.push(1); + +eq("File \"bs_array_test.res\", line 371, characters 5-12", arr, [ + 3, + 2, + 1 +]); + +Mt.from_pair_suites("File \"bs_array_test.res\", line 374, characters 20-27", suites.contents); + +let A; + +let L; + +export { + suites, + test_id, + eq, + b, + $$throw, + neq, + A, + L, + push, + add, + addone, + makeMatrixExn, + sumUsingForEach, + id, +} +/* Not a pure module */ diff --git a/tests/tests/src/bs_auto_uncurry.js b/tests/tests/src/bs_auto_uncurry.js deleted file mode 100644 index d9601239d7..0000000000 --- a/tests/tests/src/bs_auto_uncurry.js +++ /dev/null @@ -1,138 +0,0 @@ -// Generated by ReScript, PLEASE EDIT WITH CARE -'use strict'; - - -let Curry = {}; - -let Block = {}; - -let xbs = Array.prototype.map.call([ - 1, - 2, - 3, - 5 -], x => x + 1 | 0); - -function f(cb) { - return Array.prototype.map.call([ - 1, - 2, - 3, - 4 - ], cb); -} - -let xs = Array.prototype.map.call([ - [ - 1, - 2 - ], - [ - 1, - 2 - ], - [ - 2, - 1 - ] -], param => (param[1] + param[0] | 0) + 1 | 0); - -function f_0() { - return hi(() => {}); -} - -function f_01() { - return hi(x => { - if (x === undefined) { - console.log("x"); - return; - } - - }); -} - -function f_02(xs) { - return hi(x => { - xs.contents = x; - console.log("x"); - }); -} - -function f_03(xs, u) { - return hi(u); -} - -function h(x, y, z) { - return map2(x, y, z); -} - -function h1(x, y, u, z) { - return map2(x, y, z(u)); -} - -function add3(x) { - return (y, z) => (x + y | 0) + z | 0; -} - -function h2(x) { - return ff(x, (prim0, prim1) => prim0 + prim1 | 0); -} - -function h3(x) { - return ff(x, (y, z) => (1 + y | 0) + z | 0); -} - -function h4(x) { - return ff1(x, 3, (y, z) => (1 + y | 0) + z | 0); -} - -function h5(x) { - return ff2(x, "3", (y, z) => (2 + y | 0) + z | 0); -} - -function add(x, y) { - console.log([ - x, - y - ]); - return x + y | 0; -} - -function h6(x) { - return ff2(x, "3", add); -} - -function unit_magic() { - console.log("noinline"); - console.log("noinline"); - return 3; -} - -let f_unit_magic = unit_magic(); - -function hh(xs, a) { - f_0002(xs, ...a); -} - -exports.Curry = Curry; -exports.Block = Block; -exports.xbs = xbs; -exports.f = f; -exports.xs = xs; -exports.f_0 = f_0; -exports.f_01 = f_01; -exports.f_02 = f_02; -exports.f_03 = f_03; -exports.h = h; -exports.h1 = h1; -exports.add3 = add3; -exports.h2 = h2; -exports.h3 = h3; -exports.h4 = h4; -exports.h5 = h5; -exports.add = add; -exports.h6 = h6; -exports.unit_magic = unit_magic; -exports.f_unit_magic = f_unit_magic; -exports.hh = hh; -/* xbs Not a pure module */ diff --git a/tests/tests/src/bs_auto_uncurry.mjs b/tests/tests/src/bs_auto_uncurry.mjs new file mode 100644 index 0000000000..92dcc6cafb --- /dev/null +++ b/tests/tests/src/bs_auto_uncurry.mjs @@ -0,0 +1,139 @@ +// Generated by ReScript, PLEASE EDIT WITH CARE + + +let Curry = {}; + +let Block = {}; + +let xbs = Array.prototype.map.call([ + 1, + 2, + 3, + 5 +], x => x + 1 | 0); + +function f(cb) { + return Array.prototype.map.call([ + 1, + 2, + 3, + 4 + ], cb); +} + +let xs = Array.prototype.map.call([ + [ + 1, + 2 + ], + [ + 1, + 2 + ], + [ + 2, + 1 + ] +], param => (param[1] + param[0] | 0) + 1 | 0); + +function f_0() { + return hi(() => {}); +} + +function f_01() { + return hi(x => { + if (x === undefined) { + console.log("x"); + return; + } + + }); +} + +function f_02(xs) { + return hi(x => { + xs.contents = x; + console.log("x"); + }); +} + +function f_03(xs, u) { + return hi(u); +} + +function h(x, y, z) { + return map2(x, y, z); +} + +function h1(x, y, u, z) { + return map2(x, y, z(u)); +} + +function add3(x) { + return (y, z) => (x + y | 0) + z | 0; +} + +function h2(x) { + return ff(x, (prim0, prim1) => prim0 + prim1 | 0); +} + +function h3(x) { + return ff(x, (y, z) => (1 + y | 0) + z | 0); +} + +function h4(x) { + return ff1(x, 3, (y, z) => (1 + y | 0) + z | 0); +} + +function h5(x) { + return ff2(x, "3", (y, z) => (2 + y | 0) + z | 0); +} + +function add(x, y) { + console.log([ + x, + y + ]); + return x + y | 0; +} + +function h6(x) { + return ff2(x, "3", add); +} + +function unit_magic() { + console.log("noinline"); + console.log("noinline"); + return 3; +} + +let f_unit_magic = unit_magic(); + +function hh(xs, a) { + f_0002(xs, ...a); +} + +export { + Curry, + Block, + xbs, + f, + xs, + f_0, + f_01, + f_02, + f_03, + h, + h1, + add3, + h2, + h3, + h4, + h5, + add, + h6, + unit_magic, + f_unit_magic, + hh, +} +/* xbs Not a pure module */ diff --git a/tests/tests/src/bs_auto_uncurry_test.js b/tests/tests/src/bs_auto_uncurry_test.js deleted file mode 100644 index 3f46e7548d..0000000000 --- a/tests/tests/src/bs_auto_uncurry_test.js +++ /dev/null @@ -1,110 +0,0 @@ -// Generated by ReScript, PLEASE EDIT WITH CARE -'use strict'; - -let Mt = require("./mt.js"); - -let suites = { - contents: /* [] */0 -}; - -let test_id = { - contents: 0 -}; - -function eq(loc, x, y) { - test_id.contents = test_id.contents + 1 | 0; - suites.contents = { - hd: [ - loc + (" id " + test_id.contents.toString()), - () => ({ - TAG: "Eq", - _0: x, - _1: y - }) - ], - tl: suites.contents - }; -} - -function hi (cb){ - cb (); - return 0; -} -; - -let xs = { - contents: /* [] */0 -}; - -hi(x => { - xs.contents = { - hd: x, - tl: xs.contents - }; -}); - -hi(x => { - xs.contents = { - hd: x, - tl: xs.contents - }; -}); - -eq("File \"bs_auto_uncurry_test.res\", line 27, characters 5-12", xs.contents, { - hd: undefined, - tl: { - hd: undefined, - tl: /* [] */0 - } -}); - -eq("File \"bs_auto_uncurry_test.res\", line 31, characters 5-12", [ - 1, - 2, - 3 -].map(x => x + 1 | 0), [ - 2, - 3, - 4 -]); - -eq("File \"bs_auto_uncurry_test.res\", line 32, characters 5-12", [ - 1, - 2, - 3 -].map(x => x + 1 | 0), [ - 2, - 3, - 4 -]); - -eq("File \"bs_auto_uncurry_test.res\", line 34, characters 5-12", [ - 1, - 2, - 3 -].reduce((prim0, prim1) => prim0 + prim1 | 0, 0), 6); - -eq("File \"bs_auto_uncurry_test.res\", line 36, characters 5-12", [ - 1, - 2, - 3 -].reduce((x, y, i) => (x + y | 0) + i | 0, 0), 9); - -eq("File \"bs_auto_uncurry_test.res\", line 38, characters 5-12", [ - 1, - 2, - 3 -].some(x => x < 1), false); - -eq("File \"bs_auto_uncurry_test.res\", line 40, characters 5-12", [ - 1, - 2, - 3 -].every(x => x > 0), true); - -Mt.from_pair_suites("Bs_auto_uncurry_test", suites.contents); - -exports.suites = suites; -exports.test_id = test_id; -exports.eq = eq; -/* Not a pure module */ diff --git a/tests/tests/src/bs_auto_uncurry_test.mjs b/tests/tests/src/bs_auto_uncurry_test.mjs new file mode 100644 index 0000000000..c38b3e66e4 --- /dev/null +++ b/tests/tests/src/bs_auto_uncurry_test.mjs @@ -0,0 +1,111 @@ +// Generated by ReScript, PLEASE EDIT WITH CARE + +import * as Mt from "./mt.mjs"; + +let suites = { + contents: /* [] */0 +}; + +let test_id = { + contents: 0 +}; + +function eq(loc, x, y) { + test_id.contents = test_id.contents + 1 | 0; + suites.contents = { + hd: [ + loc + (" id " + test_id.contents.toString()), + () => ({ + TAG: "Eq", + _0: x, + _1: y + }) + ], + tl: suites.contents + }; +} + +function hi (cb){ + cb (); + return 0; +} +; + +let xs = { + contents: /* [] */0 +}; + +hi(x => { + xs.contents = { + hd: x, + tl: xs.contents + }; +}); + +hi(x => { + xs.contents = { + hd: x, + tl: xs.contents + }; +}); + +eq("File \"bs_auto_uncurry_test.res\", line 27, characters 5-12", xs.contents, { + hd: undefined, + tl: { + hd: undefined, + tl: /* [] */0 + } +}); + +eq("File \"bs_auto_uncurry_test.res\", line 31, characters 5-12", [ + 1, + 2, + 3 +].map(x => x + 1 | 0), [ + 2, + 3, + 4 +]); + +eq("File \"bs_auto_uncurry_test.res\", line 32, characters 5-12", [ + 1, + 2, + 3 +].map(x => x + 1 | 0), [ + 2, + 3, + 4 +]); + +eq("File \"bs_auto_uncurry_test.res\", line 34, characters 5-12", [ + 1, + 2, + 3 +].reduce((prim0, prim1) => prim0 + prim1 | 0, 0), 6); + +eq("File \"bs_auto_uncurry_test.res\", line 36, characters 5-12", [ + 1, + 2, + 3 +].reduce((x, y, i) => (x + y | 0) + i | 0, 0), 9); + +eq("File \"bs_auto_uncurry_test.res\", line 38, characters 5-12", [ + 1, + 2, + 3 +].some(x => x < 1), false); + +eq("File \"bs_auto_uncurry_test.res\", line 40, characters 5-12", [ + 1, + 2, + 3 +].every(x => x > 0), true); + +Mt.from_pair_suites("Bs_auto_uncurry_test", suites.contents); + +export { + suites, + test_id, + eq, +} +/* Not a pure module */ diff --git a/tests/tests/src/bs_ignore_effect.js b/tests/tests/src/bs_ignore_effect.js deleted file mode 100644 index 49ab49a706..0000000000 --- a/tests/tests/src/bs_ignore_effect.js +++ /dev/null @@ -1,57 +0,0 @@ -// Generated by ReScript, PLEASE EDIT WITH CARE -'use strict'; - -let Mt = require("./mt.js"); - -let suites = { - contents: /* [] */0 -}; - -let test_id = { - contents: 0 -}; - -function eq(loc, x, y) { - test_id.contents = test_id.contents + 1 | 0; - suites.contents = { - hd: [ - loc + (" id " + test_id.contents.toString()), - () => ({ - TAG: "Eq", - _0: x, - _1: y - }) - ], - tl: suites.contents - }; -} - -function add(x,y){ - return x + y -} -; - -let v = { - contents: 0 -}; - -let h = (v.contents = v.contents + 1 | 0, { - hi: 2, - lo: 0 -}); - -let z = (v.contents = v.contents + 1 | 0, "Float", add(3.0, 2.0)); - -eq("File \"bs_ignore_effect.res\", line 37, characters 5-12", v.contents, 2); - -eq("File \"bs_ignore_effect.res\", line 38, characters 5-12", z, 5.0); - -Mt.from_pair_suites("Bs_ignore_effect", suites.contents); - -exports.suites = suites; -exports.test_id = test_id; -exports.eq = eq; -exports.v = v; -exports.h = h; -exports.z = z; -/* Not a pure module */ diff --git a/tests/tests/src/bs_ignore_effect.mjs b/tests/tests/src/bs_ignore_effect.mjs new file mode 100644 index 0000000000..9f7034b1e8 --- /dev/null +++ b/tests/tests/src/bs_ignore_effect.mjs @@ -0,0 +1,58 @@ +// Generated by ReScript, PLEASE EDIT WITH CARE + +import * as Mt from "./mt.mjs"; + +let suites = { + contents: /* [] */0 +}; + +let test_id = { + contents: 0 +}; + +function eq(loc, x, y) { + test_id.contents = test_id.contents + 1 | 0; + suites.contents = { + hd: [ + loc + (" id " + test_id.contents.toString()), + () => ({ + TAG: "Eq", + _0: x, + _1: y + }) + ], + tl: suites.contents + }; +} + +function add(x,y){ + return x + y +} +; + +let v = { + contents: 0 +}; + +let h = (v.contents = v.contents + 1 | 0, { + hi: 2, + lo: 0 +}); + +let z = (v.contents = v.contents + 1 | 0, "Float", add(3.0, 2.0)); + +eq("File \"bs_ignore_effect.res\", line 37, characters 5-12", v.contents, 2); + +eq("File \"bs_ignore_effect.res\", line 38, characters 5-12", z, 5.0); + +Mt.from_pair_suites("Bs_ignore_effect", suites.contents); + +export { + suites, + test_id, + eq, + v, + h, + z, +} +/* Not a pure module */ diff --git a/tests/tests/src/bs_ignore_test.js b/tests/tests/src/bs_ignore_test.js deleted file mode 100644 index 91f0a7b25b..0000000000 --- a/tests/tests/src/bs_ignore_test.js +++ /dev/null @@ -1,40 +0,0 @@ -// Generated by ReScript, PLEASE EDIT WITH CARE -'use strict'; - - -function add(x,y){ - return x + y -} -; - -console.log(add(3.0, 2.0)); - -console.log(add("x", "y")); - -function add_dyn(kind,x,y){ - switch(kind){ - case "string" : return x + y; - case "float" : return x + y; - } -} -; - -function string_of_kind(kind) { - if (kind === "Float") { - return "float"; - } else { - return "string"; - } -} - -function add2(k, x, y) { - return add_dyn(string_of_kind(k), x, y); -} - -console.log(add2("Float", 3.0, 2.0)); - -console.log(add2("String", "x", "y")); - -exports.string_of_kind = string_of_kind; -exports.add2 = add2; -/* Not a pure module */ diff --git a/tests/tests/src/bs_ignore_test.mjs b/tests/tests/src/bs_ignore_test.mjs new file mode 100644 index 0000000000..a9b4f77956 --- /dev/null +++ b/tests/tests/src/bs_ignore_test.mjs @@ -0,0 +1,41 @@ +// Generated by ReScript, PLEASE EDIT WITH CARE + + +function add(x,y){ + return x + y +} +; + +console.log(add(3.0, 2.0)); + +console.log(add("x", "y")); + +function add_dyn(kind,x,y){ + switch(kind){ + case "string" : return x + y; + case "float" : return x + y; + } +} +; + +function string_of_kind(kind) { + if (kind === "Float") { + return "float"; + } else { + return "string"; + } +} + +function add2(k, x, y) { + return add_dyn(string_of_kind(k), x, y); +} + +console.log(add2("Float", 3.0, 2.0)); + +console.log(add2("String", "x", "y")); + +export { + string_of_kind, + add2, +} +/* Not a pure module */ diff --git a/tests/tests/src/bs_map_set_dict_test.js b/tests/tests/src/bs_map_set_dict_test.js deleted file mode 100644 index 7cc84928e0..0000000000 --- a/tests/tests/src/bs_map_set_dict_test.js +++ /dev/null @@ -1,178 +0,0 @@ -// Generated by ReScript, PLEASE EDIT WITH CARE -'use strict'; - -let Mt = require("./mt.js"); -let Belt_Id = require("rescript/lib/js/Belt_Id.js"); -let Belt_Map = require("rescript/lib/js/Belt_Map.js"); -let Belt_Set = require("rescript/lib/js/Belt_Set.js"); -let Belt_List = require("rescript/lib/js/Belt_List.js"); -let Belt_Array = require("rescript/lib/js/Belt_Array.js"); -let Belt_MapDict = require("rescript/lib/js/Belt_MapDict.js"); -let Belt_SetDict = require("rescript/lib/js/Belt_SetDict.js"); -let Primitive_int = require("rescript/lib/js/Primitive_int.js"); -let Array_data_util = require("./array_data_util.js"); - -let suites = { - contents: /* [] */0 -}; - -let test_id = { - contents: 0 -}; - -function eq(loc, x, y) { - Mt.eq_suites(test_id, suites, loc, x, y); -} - -function b(loc, v) { - Mt.bool_suites(test_id, suites, loc, v); -} - -let Icmp = Belt_Id.comparable(Primitive_int.compare); - -let Icmp2 = Belt_Id.comparable(Primitive_int.compare); - -let Ic3 = Belt_Id.comparable(Primitive_int.compare); - -let m0 = Belt_Map.make(Icmp); - -let m00 = Belt_Set.make(Ic3); - -let I2 = Belt_Id.comparable((x, y) => Primitive_int.compare(y, x)); - -let m = Belt_Map.make(Icmp2); - -let m2 = Belt_Map.make(I2); - -let data = Belt_Map.getData(m); - -Belt_Map.getId(m2); - -let m_dict = Belt_Map.getId(m); - -for (let i = 0; i <= 100000; ++i) { - data = Belt_MapDict.set(data, i, i, m_dict.cmp); -} - -let newm = Belt_Map.packIdData(m_dict, data); - -console.log(newm); - -let m11 = Belt_MapDict.set(undefined, 1, 1, Icmp.cmp); - -Belt_Map.make(Icmp); - -console.log(m11); - -let v = Belt_Set.make(Icmp2); - -let m_dict$1 = Belt_Map.getId(m); - -let cmp = m_dict$1.cmp; - -let data$1 = Belt_Set.getData(v); - -for (let i$1 = 0; i$1 <= 100000; ++i$1) { - data$1 = Belt_SetDict.add(data$1, i$1, cmp); -} - -console.log(data$1); - -function f(none) { - return Belt_Map.fromArray(none, Icmp); -} - -function $eq$tilde(a, b) { - return extra => Belt_Map.eq(a, b, extra); -} - -let u0 = Belt_Map.fromArray(Belt_Array.map(Array_data_util.randomRange(0, 39), x => [ - x, - x -]), Icmp); - -let u1 = Belt_Map.set(u0, 39, 120); - -b("File \"bs_map_set_dict_test.res\", line 72, characters 4-11", Belt_Array.every2(Belt_Map.toArray(u0), Belt_Array.map(Array_data_util.range(0, 39), x => [ - x, - x -]), (param, param$1) => { - if (param[0] === param$1[0]) { - return param[1] === param$1[1]; - } else { - return false; - } -})); - -b("File \"bs_map_set_dict_test.res\", line 79, characters 4-11", Belt_List.every2(Belt_Map.toList(u0), Belt_List.fromArray(Belt_Array.map(Array_data_util.range(0, 39), x => [ - x, - x -])), (param, param$1) => { - if (param[0] === param$1[0]) { - return param[1] === param$1[1]; - } else { - return false; - } -})); - -eq("File \"bs_map_set_dict_test.res\", line 84, characters 5-12", Belt_Map.get(u0, 39), 39); - -eq("File \"bs_map_set_dict_test.res\", line 85, characters 5-12", Belt_Map.get(u1, 39), 120); - -let u = Belt_Map.fromArray(Belt_Array.makeByAndShuffle(10000, x => [ - x, - x -]), Icmp); - -eq("File \"bs_map_set_dict_test.res\", line 90, characters 5-12", Belt_Array.makeBy(10000, x => [ - x, - x -]), Belt_Map.toArray(u)); - -Mt.from_pair_suites("Bs_map_set_dict_test", suites.contents); - -let M; - -let MI; - -let I; - -let A; - -let L; - -let vv; - -let vv2; - -let Md0; - -let ISet; - -let S0; - -exports.suites = suites; -exports.test_id = test_id; -exports.eq = eq; -exports.b = b; -exports.Icmp = Icmp; -exports.Icmp2 = Icmp2; -exports.Ic3 = Ic3; -exports.M = M; -exports.MI = MI; -exports.I = I; -exports.A = A; -exports.L = L; -exports.m0 = m0; -exports.m00 = m00; -exports.I2 = I2; -exports.m = m; -exports.m2 = m2; -exports.vv = vv; -exports.vv2 = vv2; -exports.Md0 = Md0; -exports.ISet = ISet; -exports.S0 = S0; -exports.f = f; -exports.$eq$tilde = $eq$tilde; -/* Icmp Not a pure module */ diff --git a/tests/tests/src/bs_map_set_dict_test.mjs b/tests/tests/src/bs_map_set_dict_test.mjs new file mode 100644 index 0000000000..a3dccfe565 --- /dev/null +++ b/tests/tests/src/bs_map_set_dict_test.mjs @@ -0,0 +1,179 @@ +// Generated by ReScript, PLEASE EDIT WITH CARE + +import * as Mt from "./mt.mjs"; +import * as Belt_Id from "rescript/lib/es6/Belt_Id.js"; +import * as Belt_Map from "rescript/lib/es6/Belt_Map.js"; +import * as Belt_Set from "rescript/lib/es6/Belt_Set.js"; +import * as Belt_List from "rescript/lib/es6/Belt_List.js"; +import * as Belt_Array from "rescript/lib/es6/Belt_Array.js"; +import * as Belt_MapDict from "rescript/lib/es6/Belt_MapDict.js"; +import * as Belt_SetDict from "rescript/lib/es6/Belt_SetDict.js"; +import * as Primitive_int from "rescript/lib/es6/Primitive_int.js"; +import * as Array_data_util from "./array_data_util.mjs"; + +let suites = { + contents: /* [] */0 +}; + +let test_id = { + contents: 0 +}; + +function eq(loc, x, y) { + Mt.eq_suites(test_id, suites, loc, x, y); +} + +function b(loc, v) { + Mt.bool_suites(test_id, suites, loc, v); +} + +let Icmp = Belt_Id.comparable(Primitive_int.compare); + +let Icmp2 = Belt_Id.comparable(Primitive_int.compare); + +let Ic3 = Belt_Id.comparable(Primitive_int.compare); + +let m0 = Belt_Map.make(Icmp); + +let m00 = Belt_Set.make(Ic3); + +let I2 = Belt_Id.comparable((x, y) => Primitive_int.compare(y, x)); + +let m = Belt_Map.make(Icmp2); + +let m2 = Belt_Map.make(I2); + +let data = Belt_Map.getData(m); + +Belt_Map.getId(m2); + +let m_dict = Belt_Map.getId(m); + +for (let i = 0; i <= 100000; ++i) { + data = Belt_MapDict.set(data, i, i, m_dict.cmp); +} + +let newm = Belt_Map.packIdData(m_dict, data); + +console.log(newm); + +let m11 = Belt_MapDict.set(undefined, 1, 1, Icmp.cmp); + +Belt_Map.make(Icmp); + +console.log(m11); + +let v = Belt_Set.make(Icmp2); + +let m_dict$1 = Belt_Map.getId(m); + +let cmp = m_dict$1.cmp; + +let data$1 = Belt_Set.getData(v); + +for (let i$1 = 0; i$1 <= 100000; ++i$1) { + data$1 = Belt_SetDict.add(data$1, i$1, cmp); +} + +console.log(data$1); + +function f(none) { + return Belt_Map.fromArray(none, Icmp); +} + +function $eq$tilde(a, b) { + return extra => Belt_Map.eq(a, b, extra); +} + +let u0 = Belt_Map.fromArray(Belt_Array.map(Array_data_util.randomRange(0, 39), x => [ + x, + x +]), Icmp); + +let u1 = Belt_Map.set(u0, 39, 120); + +b("File \"bs_map_set_dict_test.res\", line 72, characters 4-11", Belt_Array.every2(Belt_Map.toArray(u0), Belt_Array.map(Array_data_util.range(0, 39), x => [ + x, + x +]), (param, param$1) => { + if (param[0] === param$1[0]) { + return param[1] === param$1[1]; + } else { + return false; + } +})); + +b("File \"bs_map_set_dict_test.res\", line 79, characters 4-11", Belt_List.every2(Belt_Map.toList(u0), Belt_List.fromArray(Belt_Array.map(Array_data_util.range(0, 39), x => [ + x, + x +])), (param, param$1) => { + if (param[0] === param$1[0]) { + return param[1] === param$1[1]; + } else { + return false; + } +})); + +eq("File \"bs_map_set_dict_test.res\", line 84, characters 5-12", Belt_Map.get(u0, 39), 39); + +eq("File \"bs_map_set_dict_test.res\", line 85, characters 5-12", Belt_Map.get(u1, 39), 120); + +let u = Belt_Map.fromArray(Belt_Array.makeByAndShuffle(10000, x => [ + x, + x +]), Icmp); + +eq("File \"bs_map_set_dict_test.res\", line 90, characters 5-12", Belt_Array.makeBy(10000, x => [ + x, + x +]), Belt_Map.toArray(u)); + +Mt.from_pair_suites("Bs_map_set_dict_test", suites.contents); + +let M; + +let MI; + +let I; + +let A; + +let L; + +let vv; + +let vv2; + +let Md0; + +let ISet; + +let S0; + +export { + suites, + test_id, + eq, + b, + Icmp, + Icmp2, + Ic3, + M, + MI, + I, + A, + L, + m0, + m00, + I2, + m, + m2, + vv, + vv2, + Md0, + ISet, + S0, + f, + $eq$tilde, +} +/* Icmp Not a pure module */ diff --git a/tests/tests/src/bs_map_test.js b/tests/tests/src/bs_map_test.js deleted file mode 100644 index 78862ccd5e..0000000000 --- a/tests/tests/src/bs_map_test.js +++ /dev/null @@ -1,89 +0,0 @@ -// Generated by ReScript, PLEASE EDIT WITH CARE -'use strict'; - -let Mt = require("./mt.js"); -let Belt_Array = require("rescript/lib/js/Belt_Array.js"); -let Belt_MapInt = require("rescript/lib/js/Belt_MapInt.js"); -let Belt_SetInt = require("rescript/lib/js/Belt_SetInt.js"); - -let suites = { - contents: /* [] */0 -}; - -let test_id = { - contents: 0 -}; - -function eq(loc, x, y) { - test_id.contents = test_id.contents + 1 | 0; - suites.contents = { - hd: [ - loc + (" id " + test_id.contents.toString()), - () => ({ - TAG: "Eq", - _0: x, - _1: y - }) - ], - tl: suites.contents - }; -} - -function b(loc, v) { - test_id.contents = test_id.contents + 1 | 0; - suites.contents = { - hd: [ - loc + (" id " + test_id.contents.toString()), - () => ({ - TAG: "Ok", - _0: v - }) - ], - tl: suites.contents - }; -} - -let mapOfArray = Belt_MapInt.fromArray; - -let setOfArray = Belt_SetInt.fromArray; - -function emptyMap() { - -} - -let v = Belt_Array.makeByAndShuffle(1000000, i => [ - i, - i -]); - -let u = Belt_MapInt.fromArray(v); - -Belt_MapInt.checkInvariantInternal(u); - -let firstHalf = Belt_Array.slice(v, 0, 2000); - -let xx = Belt_Array.reduce(firstHalf, u, (acc, param) => Belt_MapInt.remove(acc, param[0])); - -Belt_MapInt.checkInvariantInternal(u); - -Belt_MapInt.checkInvariantInternal(xx); - -Mt.from_pair_suites("Bs_map_test", suites.contents); - -let M; - -let N; - -let A; - -exports.suites = suites; -exports.test_id = test_id; -exports.eq = eq; -exports.b = b; -exports.M = M; -exports.N = N; -exports.A = A; -exports.mapOfArray = mapOfArray; -exports.setOfArray = setOfArray; -exports.emptyMap = emptyMap; -/* v Not a pure module */ diff --git a/tests/tests/src/bs_map_test.mjs b/tests/tests/src/bs_map_test.mjs new file mode 100644 index 0000000000..b00c10c028 --- /dev/null +++ b/tests/tests/src/bs_map_test.mjs @@ -0,0 +1,90 @@ +// Generated by ReScript, PLEASE EDIT WITH CARE + +import * as Mt from "./mt.mjs"; +import * as Belt_Array from "rescript/lib/es6/Belt_Array.js"; +import * as Belt_MapInt from "rescript/lib/es6/Belt_MapInt.js"; +import * as Belt_SetInt from "rescript/lib/es6/Belt_SetInt.js"; + +let suites = { + contents: /* [] */0 +}; + +let test_id = { + contents: 0 +}; + +function eq(loc, x, y) { + test_id.contents = test_id.contents + 1 | 0; + suites.contents = { + hd: [ + loc + (" id " + test_id.contents.toString()), + () => ({ + TAG: "Eq", + _0: x, + _1: y + }) + ], + tl: suites.contents + }; +} + +function b(loc, v) { + test_id.contents = test_id.contents + 1 | 0; + suites.contents = { + hd: [ + loc + (" id " + test_id.contents.toString()), + () => ({ + TAG: "Ok", + _0: v + }) + ], + tl: suites.contents + }; +} + +let mapOfArray = Belt_MapInt.fromArray; + +let setOfArray = Belt_SetInt.fromArray; + +function emptyMap() { + +} + +let v = Belt_Array.makeByAndShuffle(1000000, i => [ + i, + i +]); + +let u = Belt_MapInt.fromArray(v); + +Belt_MapInt.checkInvariantInternal(u); + +let firstHalf = Belt_Array.slice(v, 0, 2000); + +let xx = Belt_Array.reduce(firstHalf, u, (acc, param) => Belt_MapInt.remove(acc, param[0])); + +Belt_MapInt.checkInvariantInternal(u); + +Belt_MapInt.checkInvariantInternal(xx); + +Mt.from_pair_suites("Bs_map_test", suites.contents); + +let M; + +let N; + +let A; + +export { + suites, + test_id, + eq, + b, + M, + N, + A, + mapOfArray, + setOfArray, + emptyMap, +} +/* v Not a pure module */ diff --git a/tests/tests/src/bs_min_max_test.js b/tests/tests/src/bs_min_max_test.js deleted file mode 100644 index 6bfb702b13..0000000000 --- a/tests/tests/src/bs_min_max_test.js +++ /dev/null @@ -1,68 +0,0 @@ -// Generated by ReScript, PLEASE EDIT WITH CARE -'use strict'; - -let Mt = require("./mt.js"); -let Primitive_int = require("rescript/lib/js/Primitive_int.js"); -let Primitive_object = require("rescript/lib/js/Primitive_object.js"); - -let suites = { - contents: /* [] */0 -}; - -let test_id = { - contents: 0 -}; - -function eq(loc, x, y) { - Mt.eq_suites(test_id, suites, loc, x, y); -} - -function b(extra, extra$1) { - return Mt.bool_suites(test_id, suites, extra, extra$1); -} - -function f(x, y) { - return Primitive_int.compare(x + y | 0, y + x | 0); -} - -function f2(x, y) { - return Primitive_int.compare(x + y | 0, y); -} - -let f3 = Primitive_int.compare; - -let f4 = Primitive_int.min; - -let f5_min = Primitive_object.min; - -let f5_max = Primitive_object.max; - -eq("File \"bs_min_max_test.res\", line 19, characters 5-12", Primitive_object.min(undefined, 3), undefined); - -eq("File \"bs_min_max_test.res\", line 20, characters 5-12", Primitive_object.min(3, undefined), undefined); - -eq("File \"bs_min_max_test.res\", line 21, characters 5-12", Primitive_object.max(3, undefined), 3); - -eq("File \"bs_min_max_test.res\", line 22, characters 5-12", Primitive_object.max(undefined, 3), 3); - -b("File \"bs_min_max_test.res\", line 23, characters 4-11", Primitive_object.greaterequal(5, undefined)); - -b("File \"bs_min_max_test.res\", line 24, characters 4-11", Primitive_object.lessequal(undefined, 5)); - -b("File \"bs_min_max_test.res\", line 25, characters 4-11", true); - -b("File \"bs_min_max_test.res\", line 26, characters 4-11", true); - -Mt.from_pair_suites("Bs_min_max_test", suites.contents); - -exports.suites = suites; -exports.test_id = test_id; -exports.eq = eq; -exports.b = b; -exports.f = f; -exports.f2 = f2; -exports.f3 = f3; -exports.f4 = f4; -exports.f5_min = f5_min; -exports.f5_max = f5_max; -/* Not a pure module */ diff --git a/tests/tests/src/bs_min_max_test.mjs b/tests/tests/src/bs_min_max_test.mjs new file mode 100644 index 0000000000..4304874a7a --- /dev/null +++ b/tests/tests/src/bs_min_max_test.mjs @@ -0,0 +1,69 @@ +// Generated by ReScript, PLEASE EDIT WITH CARE + +import * as Mt from "./mt.mjs"; +import * as Primitive_int from "rescript/lib/es6/Primitive_int.js"; +import * as Primitive_object from "rescript/lib/es6/Primitive_object.js"; + +let suites = { + contents: /* [] */0 +}; + +let test_id = { + contents: 0 +}; + +function eq(loc, x, y) { + Mt.eq_suites(test_id, suites, loc, x, y); +} + +function b(extra, extra$1) { + return Mt.bool_suites(test_id, suites, extra, extra$1); +} + +function f(x, y) { + return Primitive_int.compare(x + y | 0, y + x | 0); +} + +function f2(x, y) { + return Primitive_int.compare(x + y | 0, y); +} + +let f3 = Primitive_int.compare; + +let f4 = Primitive_int.min; + +let f5_min = Primitive_object.min; + +let f5_max = Primitive_object.max; + +eq("File \"bs_min_max_test.res\", line 19, characters 5-12", Primitive_object.min(undefined, 3), undefined); + +eq("File \"bs_min_max_test.res\", line 20, characters 5-12", Primitive_object.min(3, undefined), undefined); + +eq("File \"bs_min_max_test.res\", line 21, characters 5-12", Primitive_object.max(3, undefined), 3); + +eq("File \"bs_min_max_test.res\", line 22, characters 5-12", Primitive_object.max(undefined, 3), 3); + +b("File \"bs_min_max_test.res\", line 23, characters 4-11", Primitive_object.greaterequal(5, undefined)); + +b("File \"bs_min_max_test.res\", line 24, characters 4-11", Primitive_object.lessequal(undefined, 5)); + +b("File \"bs_min_max_test.res\", line 25, characters 4-11", true); + +b("File \"bs_min_max_test.res\", line 26, characters 4-11", true); + +Mt.from_pair_suites("Bs_min_max_test", suites.contents); + +export { + suites, + test_id, + eq, + b, + f, + f2, + f3, + f4, + f5_min, + f5_max, +} +/* Not a pure module */ diff --git a/tests/tests/src/bs_mutable_set_test.js b/tests/tests/src/bs_mutable_set_test.js deleted file mode 100644 index 68c62db52d..0000000000 --- a/tests/tests/src/bs_mutable_set_test.js +++ /dev/null @@ -1,565 +0,0 @@ -// Generated by ReScript, PLEASE EDIT WITH CARE -'use strict'; - -let Mt = require("./mt.js"); -let Belt_List = require("rescript/lib/js/Belt_List.js"); -let Belt_Array = require("rescript/lib/js/Belt_Array.js"); -let Belt_Range = require("rescript/lib/js/Belt_Range.js"); -let Array_data_util = require("./array_data_util.js"); -let Primitive_array = require("rescript/lib/js/Primitive_array.js"); -let Belt_MutableSetInt = require("rescript/lib/js/Belt_MutableSetInt.js"); - -let suites = { - contents: /* [] */0 -}; - -let test_id = { - contents: 0 -}; - -function eq(loc, x, y) { - Mt.eq_suites(test_id, suites, loc, x, y); -} - -function b(loc, x) { - Mt.bool_suites(test_id, suites, loc, x); -} - -let u = Belt_MutableSetInt.fromArray(Array_data_util.range(0, 30)); - -b("File \"bs_mutable_set_test.res\", line 22, characters 8-15", Belt_MutableSetInt.removeCheck(u, 0)); - -b("File \"bs_mutable_set_test.res\", line 23, characters 8-15", !Belt_MutableSetInt.removeCheck(u, 0)); - -b("File \"bs_mutable_set_test.res\", line 24, characters 8-15", Belt_MutableSetInt.removeCheck(u, 30)); - -b("File \"bs_mutable_set_test.res\", line 25, characters 8-15", Belt_MutableSetInt.removeCheck(u, 20)); - -eq("File \"bs_mutable_set_test.res\", line 26, characters 9-16", Belt_MutableSetInt.size(u), 28); - -let r = Array_data_util.randomRange(0, 30); - -b("File \"bs_mutable_set_test.res\", line 28, characters 8-15", 29 === Belt_MutableSetInt.maxUndefined(u)); - -b("File \"bs_mutable_set_test.res\", line 29, characters 8-15", 1 === Belt_MutableSetInt.minUndefined(u)); - -Belt_MutableSetInt.add(u, 3); - -for (let i = 0, i_finish = r.length; i < i_finish; ++i) { - Belt_MutableSetInt.remove(u, r[i]); -} - -b("File \"bs_mutable_set_test.res\", line 34, characters 8-15", Belt_MutableSetInt.isEmpty(u)); - -Belt_MutableSetInt.add(u, 0); - -Belt_MutableSetInt.add(u, 1); - -Belt_MutableSetInt.add(u, 2); - -Belt_MutableSetInt.add(u, 0); - -eq("File \"bs_mutable_set_test.res\", line 39, characters 9-16", Belt_MutableSetInt.size(u), 3); - -b("File \"bs_mutable_set_test.res\", line 40, characters 8-15", !Belt_MutableSetInt.isEmpty(u)); - -for (let i$1 = 0; i$1 <= 3; ++i$1) { - Belt_MutableSetInt.remove(u, i$1); -} - -b("File \"bs_mutable_set_test.res\", line 44, characters 8-15", Belt_MutableSetInt.isEmpty(u)); - -Belt_MutableSetInt.mergeMany(u, Array_data_util.randomRange(0, 20000)); - -Belt_MutableSetInt.mergeMany(u, Array_data_util.randomRange(0, 200)); - -eq("File \"bs_mutable_set_test.res\", line 47, characters 9-16", Belt_MutableSetInt.size(u), 20001); - -Belt_MutableSetInt.removeMany(u, Array_data_util.randomRange(0, 200)); - -eq("File \"bs_mutable_set_test.res\", line 49, characters 9-16", Belt_MutableSetInt.size(u), 19800); - -Belt_MutableSetInt.removeMany(u, Array_data_util.randomRange(0, 1000)); - -eq("File \"bs_mutable_set_test.res\", line 51, characters 9-16", Belt_MutableSetInt.size(u), 19000); - -Belt_MutableSetInt.removeMany(u, Array_data_util.randomRange(0, 1000)); - -eq("File \"bs_mutable_set_test.res\", line 53, characters 9-16", Belt_MutableSetInt.size(u), 19000); - -Belt_MutableSetInt.removeMany(u, Array_data_util.randomRange(1000, 10000)); - -eq("File \"bs_mutable_set_test.res\", line 55, characters 9-16", Belt_MutableSetInt.size(u), 10000); - -Belt_MutableSetInt.removeMany(u, Array_data_util.randomRange(10000, 19999)); - -eq("File \"bs_mutable_set_test.res\", line 57, characters 9-16", Belt_MutableSetInt.size(u), 1); - -b("File \"bs_mutable_set_test.res\", line 58, characters 8-15", Belt_MutableSetInt.has(u, 20000)); - -Belt_MutableSetInt.removeMany(u, Array_data_util.randomRange(10000, 30000)); - -b("File \"bs_mutable_set_test.res\", line 60, characters 8-15", Belt_MutableSetInt.isEmpty(u)); - -let v = Belt_MutableSetInt.fromArray(Array_data_util.randomRange(1000, 2000)); - -let bs = Belt_Array.map(Array_data_util.randomRange(500, 1499), x => Belt_MutableSetInt.removeCheck(v, x)); - -let indeedRemoved = Belt_Array.reduce(bs, 0, (acc, x) => { - if (x) { - return acc + 1 | 0; - } else { - return acc; - } -}); - -eq("File \"bs_mutable_set_test.res\", line 73, characters 9-16", indeedRemoved, 500); - -eq("File \"bs_mutable_set_test.res\", line 74, characters 9-16", Belt_MutableSetInt.size(v), 501); - -let cs = Belt_Array.map(Array_data_util.randomRange(500, 2000), x => Belt_MutableSetInt.addCheck(v, x)); - -let indeedAded = Belt_Array.reduce(cs, 0, (acc, x) => { - if (x) { - return acc + 1 | 0; - } else { - return acc; - } -}); - -eq("File \"bs_mutable_set_test.res\", line 83, characters 9-16", indeedAded, 1000); - -eq("File \"bs_mutable_set_test.res\", line 84, characters 9-16", Belt_MutableSetInt.size(v), 1501); - -b("File \"bs_mutable_set_test.res\", line 85, characters 8-15", Belt_MutableSetInt.isEmpty(Belt_MutableSetInt.make())); - -eq("File \"bs_mutable_set_test.res\", line 86, characters 9-16", Belt_MutableSetInt.minimum(v), 500); - -eq("File \"bs_mutable_set_test.res\", line 87, characters 9-16", Belt_MutableSetInt.maximum(v), 2000); - -eq("File \"bs_mutable_set_test.res\", line 88, characters 9-16", Belt_MutableSetInt.minUndefined(v), 500); - -eq("File \"bs_mutable_set_test.res\", line 89, characters 9-16", Belt_MutableSetInt.maxUndefined(v), 2000); - -eq("File \"bs_mutable_set_test.res\", line 90, characters 9-16", Belt_MutableSetInt.reduce(v, 0, (x, y) => x + y | 0), 1876250); - -b("File \"bs_mutable_set_test.res\", line 91, characters 8-15", Belt_List.eq(Belt_MutableSetInt.toList(v), Belt_List.makeBy(1501, i => i + 500 | 0), (x, y) => x === y)); - -eq("File \"bs_mutable_set_test.res\", line 92, characters 9-16", Belt_MutableSetInt.toArray(v), Array_data_util.range(500, 2000)); - -Belt_MutableSetInt.checkInvariantInternal(v); - -eq("File \"bs_mutable_set_test.res\", line 94, characters 9-16", Belt_MutableSetInt.get(v, 3), undefined); - -eq("File \"bs_mutable_set_test.res\", line 95, characters 9-16", Belt_MutableSetInt.get(v, 1200), 1200); - -let match = Belt_MutableSetInt.split(v, 1000); - -let match$1 = match[0]; - -let bb = match$1[1]; - -let aa = match$1[0]; - -b("File \"bs_mutable_set_test.res\", line 97, characters 8-15", match[1]); - -b("File \"bs_mutable_set_test.res\", line 98, characters 8-15", Belt_Array.eq(Belt_MutableSetInt.toArray(aa), Array_data_util.range(500, 999), (x, y) => x === y)); - -b("File \"bs_mutable_set_test.res\", line 99, characters 8-15", Belt_Array.eq(Belt_MutableSetInt.toArray(bb), Array_data_util.range(1001, 2000), (prim0, prim1) => prim0 === prim1)); - -b("File \"bs_mutable_set_test.res\", line 100, characters 8-15", Belt_MutableSetInt.subset(aa, v)); - -b("File \"bs_mutable_set_test.res\", line 101, characters 8-15", Belt_MutableSetInt.subset(bb, v)); - -b("File \"bs_mutable_set_test.res\", line 102, characters 8-15", Belt_MutableSetInt.isEmpty(Belt_MutableSetInt.intersect(aa, bb))); - -let c = Belt_MutableSetInt.removeCheck(v, 1000); - -b("File \"bs_mutable_set_test.res\", line 104, characters 8-15", c); - -let match$2 = Belt_MutableSetInt.split(v, 1000); - -let match$3 = match$2[0]; - -let bb$1 = match$3[1]; - -let aa$1 = match$3[0]; - -b("File \"bs_mutable_set_test.res\", line 106, characters 8-15", !match$2[1]); - -b("File \"bs_mutable_set_test.res\", line 107, characters 8-15", Belt_Array.eq(Belt_MutableSetInt.toArray(aa$1), Array_data_util.range(500, 999), (prim0, prim1) => prim0 === prim1)); - -b("File \"bs_mutable_set_test.res\", line 108, characters 8-15", Belt_Array.eq(Belt_MutableSetInt.toArray(bb$1), Array_data_util.range(1001, 2000), (prim0, prim1) => prim0 === prim1)); - -b("File \"bs_mutable_set_test.res\", line 109, characters 8-15", Belt_MutableSetInt.subset(aa$1, v)); - -b("File \"bs_mutable_set_test.res\", line 110, characters 8-15", Belt_MutableSetInt.subset(bb$1, v)); - -b("File \"bs_mutable_set_test.res\", line 111, characters 8-15", Belt_MutableSetInt.isEmpty(Belt_MutableSetInt.intersect(aa$1, bb$1))); - -let aa$2 = Belt_MutableSetInt.fromArray(Array_data_util.randomRange(0, 100)); - -let bb$2 = Belt_MutableSetInt.fromArray(Array_data_util.randomRange(40, 120)); - -let cc = Belt_MutableSetInt.union(aa$2, bb$2); - -b("File \"bs_mutable_set_test.res\", line 121, characters 8-15", Belt_MutableSetInt.eq(cc, Belt_MutableSetInt.fromArray(Array_data_util.randomRange(0, 120)))); - -b("File \"bs_mutable_set_test.res\", line 124, characters 8-15", Belt_MutableSetInt.eq(Belt_MutableSetInt.union(Belt_MutableSetInt.fromArray(Array_data_util.randomRange(0, 20)), Belt_MutableSetInt.fromArray(Array_data_util.randomRange(21, 40))), Belt_MutableSetInt.fromArray(Array_data_util.randomRange(0, 40)))); - -let dd = Belt_MutableSetInt.intersect(aa$2, bb$2); - -b("File \"bs_mutable_set_test.res\", line 128, characters 8-15", Belt_MutableSetInt.eq(dd, Belt_MutableSetInt.fromArray(Array_data_util.randomRange(40, 100)))); - -b("File \"bs_mutable_set_test.res\", line 130, characters 8-15", Belt_MutableSetInt.eq(Belt_MutableSetInt.intersect(Belt_MutableSetInt.fromArray(Array_data_util.randomRange(0, 20)), Belt_MutableSetInt.fromArray(Array_data_util.randomRange(21, 40))), Belt_MutableSetInt.make())); - -b("File \"bs_mutable_set_test.res\", line 137, characters 8-15", Belt_MutableSetInt.eq(Belt_MutableSetInt.intersect(Belt_MutableSetInt.fromArray(Array_data_util.randomRange(21, 40)), Belt_MutableSetInt.fromArray(Array_data_util.randomRange(0, 20))), Belt_MutableSetInt.make())); - -b("File \"bs_mutable_set_test.res\", line 143, characters 8-15", Belt_MutableSetInt.eq(Belt_MutableSetInt.intersect(Belt_MutableSetInt.fromArray([ - 1, - 3, - 4, - 5, - 7, - 9 -]), Belt_MutableSetInt.fromArray([ - 2, - 4, - 5, - 6, - 8, - 10 -])), Belt_MutableSetInt.fromArray([ - 4, - 5 -]))); - -b("File \"bs_mutable_set_test.res\", line 144, characters 8-15", Belt_MutableSetInt.eq(Belt_MutableSetInt.diff(aa$2, bb$2), Belt_MutableSetInt.fromArray(Array_data_util.randomRange(0, 39)))); - -b("File \"bs_mutable_set_test.res\", line 145, characters 8-15", Belt_MutableSetInt.eq(Belt_MutableSetInt.diff(bb$2, aa$2), Belt_MutableSetInt.fromArray(Array_data_util.randomRange(101, 120)))); - -b("File \"bs_mutable_set_test.res\", line 147, characters 8-15", Belt_MutableSetInt.eq(Belt_MutableSetInt.diff(Belt_MutableSetInt.fromArray(Array_data_util.randomRange(21, 40)), Belt_MutableSetInt.fromArray(Array_data_util.randomRange(0, 20))), Belt_MutableSetInt.fromArray(Array_data_util.randomRange(21, 40)))); - -b("File \"bs_mutable_set_test.res\", line 154, characters 8-15", Belt_MutableSetInt.eq(Belt_MutableSetInt.diff(Belt_MutableSetInt.fromArray(Array_data_util.randomRange(0, 20)), Belt_MutableSetInt.fromArray(Array_data_util.randomRange(21, 40))), Belt_MutableSetInt.fromArray(Array_data_util.randomRange(0, 20)))); - -b("File \"bs_mutable_set_test.res\", line 162, characters 8-15", Belt_MutableSetInt.eq(Belt_MutableSetInt.diff(Belt_MutableSetInt.fromArray(Array_data_util.randomRange(0, 20)), Belt_MutableSetInt.fromArray(Array_data_util.randomRange(0, 40))), Belt_MutableSetInt.fromArray(Array_data_util.randomRange(0, -1)))); - -let a0 = Belt_MutableSetInt.fromArray(Array_data_util.randomRange(0, 1000)); - -let a1 = Belt_MutableSetInt.keep(a0, x => x % 2 === 0); - -let a2 = Belt_MutableSetInt.keep(a0, x => x % 2 !== 0); - -let match$4 = Belt_MutableSetInt.partition(a0, x => x % 2 === 0); - -let a4 = match$4[1]; - -let a3 = match$4[0]; - -b("File \"bs_mutable_set_test.res\", line 174, characters 8-15", Belt_MutableSetInt.eq(a1, a3)); - -b("File \"bs_mutable_set_test.res\", line 175, characters 8-15", Belt_MutableSetInt.eq(a2, a4)); - -Belt_List.forEach({ - hd: a0, - tl: { - hd: a1, - tl: { - hd: a2, - tl: { - hd: a3, - tl: { - hd: a4, - tl: /* [] */0 - } - } - } - } -}, Belt_MutableSetInt.checkInvariantInternal); - -let v$1 = Belt_MutableSetInt.make(); - -for (let i$2 = 0; i$2 <= 100000; ++i$2) { - Belt_MutableSetInt.add(v$1, i$2); -} - -Belt_MutableSetInt.checkInvariantInternal(v$1); - -b("File \"bs_mutable_set_test.res\", line 189, characters 10-17", Belt_Range.every(0, 100000, i => Belt_MutableSetInt.has(v$1, i))); - -eq("File \"bs_mutable_set_test.res\", line 190, characters 5-12", Belt_MutableSetInt.size(v$1), 100001); - -let u$1 = Belt_Array.concat(Array_data_util.randomRange(30, 100), Array_data_util.randomRange(40, 120)); - -let v$2 = Belt_MutableSetInt.make(); - -Belt_MutableSetInt.mergeMany(v$2, u$1); - -eq("File \"bs_mutable_set_test.res\", line 197, characters 5-12", Belt_MutableSetInt.size(v$2), 91); - -eq("File \"bs_mutable_set_test.res\", line 198, characters 5-12", Belt_MutableSetInt.toArray(v$2), Array_data_util.range(30, 120)); - -let u$2 = Belt_Array.concat(Array_data_util.randomRange(0, 100000), Array_data_util.randomRange(0, 100)); - -let v$3 = Belt_MutableSetInt.fromArray(u$2); - -eq("File \"bs_mutable_set_test.res\", line 204, characters 5-12", Belt_MutableSetInt.size(v$3), 100001); - -let u$3 = Array_data_util.randomRange(50000, 80000); - -for (let i$3 = 0, i_finish$1 = u$3.length; i$3 < i_finish$1; ++i$3) { - Belt_MutableSetInt.remove(v$3, i$3); -} - -eq("File \"bs_mutable_set_test.res\", line 211, characters 5-12", Belt_MutableSetInt.size(v$3), 70000); - -let vv = Array_data_util.randomRange(0, 100000); - -for (let i$4 = 0, i_finish$2 = vv.length; i$4 < i_finish$2; ++i$4) { - Belt_MutableSetInt.remove(v$3, Primitive_array.get(vv, i$4)); -} - -eq("File \"bs_mutable_set_test.res\", line 217, characters 5-12", Belt_MutableSetInt.size(v$3), 0); - -b("File \"bs_mutable_set_test.res\", line 218, characters 4-11", Belt_MutableSetInt.isEmpty(v$3)); - -let v$4 = Belt_MutableSetInt.fromArray(Belt_Array.makeBy(30, i => i)); - -Belt_MutableSetInt.remove(v$4, 30); - -Belt_MutableSetInt.remove(v$4, 29); - -b("File \"bs_mutable_set_test.res\", line 225, characters 4-11", 28 === Belt_MutableSetInt.maxUndefined(v$4)); - -Belt_MutableSetInt.remove(v$4, 0); - -b("File \"bs_mutable_set_test.res\", line 227, characters 4-11", 1 === Belt_MutableSetInt.minUndefined(v$4)); - -eq("File \"bs_mutable_set_test.res\", line 228, characters 5-12", Belt_MutableSetInt.size(v$4), 28); - -let vv$1 = Array_data_util.randomRange(1, 28); - -for (let i$5 = 0, i_finish$3 = vv$1.length; i$5 < i_finish$3; ++i$5) { - Belt_MutableSetInt.remove(v$4, Primitive_array.get(vv$1, i$5)); -} - -eq("File \"bs_mutable_set_test.res\", line 233, characters 5-12", Belt_MutableSetInt.size(v$4), 0); - -function id(loc, x) { - let u = Belt_MutableSetInt.fromSortedArrayUnsafe(x); - Belt_MutableSetInt.checkInvariantInternal(u); - b(loc, Belt_Array.every2(Belt_MutableSetInt.toArray(u), x, (prim0, prim1) => prim0 === prim1)); -} - -id("File \"bs_mutable_set_test.res\", line 243, characters 5-12", []); - -id("File \"bs_mutable_set_test.res\", line 244, characters 5-12", [0]); - -id("File \"bs_mutable_set_test.res\", line 245, characters 5-12", [ - 0, - 1 -]); - -id("File \"bs_mutable_set_test.res\", line 246, characters 5-12", [ - 0, - 1, - 2 -]); - -id("File \"bs_mutable_set_test.res\", line 247, characters 5-12", [ - 0, - 1, - 2, - 3 -]); - -id("File \"bs_mutable_set_test.res\", line 248, characters 5-12", [ - 0, - 1, - 2, - 3, - 4 -]); - -id("File \"bs_mutable_set_test.res\", line 249, characters 5-12", [ - 0, - 1, - 2, - 3, - 4, - 5 -]); - -id("File \"bs_mutable_set_test.res\", line 250, characters 5-12", [ - 0, - 1, - 2, - 3, - 4, - 6 -]); - -id("File \"bs_mutable_set_test.res\", line 251, characters 5-12", [ - 0, - 1, - 2, - 3, - 4, - 6, - 7 -]); - -id("File \"bs_mutable_set_test.res\", line 252, characters 5-12", [ - 0, - 1, - 2, - 3, - 4, - 6, - 7, - 8 -]); - -id("File \"bs_mutable_set_test.res\", line 253, characters 5-12", [ - 0, - 1, - 2, - 3, - 4, - 6, - 7, - 8, - 9 -]); - -id("File \"bs_mutable_set_test.res\", line 254, characters 5-12", Array_data_util.range(0, 1000)); - -let v$5 = Belt_MutableSetInt.fromArray(Array_data_util.randomRange(0, 1000)); - -let copyV = Belt_MutableSetInt.keep(v$5, x => x % 8 === 0); - -let match$5 = Belt_MutableSetInt.partition(v$5, x => x % 8 === 0); - -let cc$1 = Belt_MutableSetInt.keep(v$5, x => x % 8 !== 0); - -for (let i$6 = 0; i$6 <= 200; ++i$6) { - Belt_MutableSetInt.remove(v$5, i$6); -} - -eq("File \"bs_mutable_set_test.res\", line 265, characters 5-12", Belt_MutableSetInt.size(copyV), 126); - -eq("File \"bs_mutable_set_test.res\", line 266, characters 5-12", Belt_MutableSetInt.toArray(copyV), Belt_Array.makeBy(126, i => (i << 3))); - -eq("File \"bs_mutable_set_test.res\", line 267, characters 5-12", Belt_MutableSetInt.size(v$5), 800); - -b("File \"bs_mutable_set_test.res\", line 268, characters 4-11", Belt_MutableSetInt.eq(copyV, match$5[0])); - -b("File \"bs_mutable_set_test.res\", line 269, characters 4-11", Belt_MutableSetInt.eq(cc$1, match$5[1])); - -let v$6 = Belt_MutableSetInt.fromArray(Array_data_util.randomRange(0, 1000)); - -let match$6 = Belt_MutableSetInt.split(v$6, 400); - -let match$7 = match$6[0]; - -b("File \"bs_mutable_set_test.res\", line 275, characters 4-11", Belt_MutableSetInt.eq(match$7[0], Belt_MutableSetInt.fromArray(Array_data_util.randomRange(0, 399)))); - -b("File \"bs_mutable_set_test.res\", line 276, characters 4-11", Belt_MutableSetInt.eq(match$7[1], Belt_MutableSetInt.fromArray(Array_data_util.randomRange(401, 1000)))); - -let d = Belt_MutableSetInt.fromArray(Belt_Array.map(Array_data_util.randomRange(0, 1000), x => (x << 1))); - -let match$8 = Belt_MutableSetInt.split(d, 1001); - -let match$9 = match$8[0]; - -b("File \"bs_mutable_set_test.res\", line 279, characters 4-11", Belt_MutableSetInt.eq(match$9[0], Belt_MutableSetInt.fromArray(Belt_Array.makeBy(501, x => (x << 1))))); - -b("File \"bs_mutable_set_test.res\", line 280, characters 4-11", Belt_MutableSetInt.eq(match$9[1], Belt_MutableSetInt.fromArray(Belt_Array.makeBy(500, x => 1002 + (x << 1) | 0)))); - -let aa$3 = Belt_MutableSetInt.fromArray(Array_data_util.randomRange(0, 100)); - -let bb$3 = Belt_MutableSetInt.fromArray(Array_data_util.randomRange(40, 120)); - -let cc$2 = Belt_MutableSetInt.union(aa$3, bb$3); - -b("File \"bs_mutable_set_test.res\", line 290, characters 4-11", Belt_MutableSetInt.eq(cc$2, Belt_MutableSetInt.fromArray(Array_data_util.randomRange(0, 120)))); - -b("File \"bs_mutable_set_test.res\", line 293, characters 4-11", Belt_MutableSetInt.eq(Belt_MutableSetInt.union(Belt_MutableSetInt.fromArray(Array_data_util.randomRange(0, 20)), Belt_MutableSetInt.fromArray(Array_data_util.randomRange(21, 40))), Belt_MutableSetInt.fromArray(Array_data_util.randomRange(0, 40)))); - -let dd$1 = Belt_MutableSetInt.intersect(aa$3, bb$3); - -b("File \"bs_mutable_set_test.res\", line 297, characters 4-11", Belt_MutableSetInt.eq(dd$1, Belt_MutableSetInt.fromArray(Array_data_util.randomRange(40, 100)))); - -b("File \"bs_mutable_set_test.res\", line 299, characters 4-11", Belt_MutableSetInt.eq(Belt_MutableSetInt.intersect(Belt_MutableSetInt.fromArray(Array_data_util.randomRange(0, 20)), Belt_MutableSetInt.fromArray(Array_data_util.randomRange(21, 40))), Belt_MutableSetInt.make())); - -b("File \"bs_mutable_set_test.res\", line 303, characters 4-11", Belt_MutableSetInt.eq(Belt_MutableSetInt.intersect(Belt_MutableSetInt.fromArray(Array_data_util.randomRange(21, 40)), Belt_MutableSetInt.fromArray(Array_data_util.randomRange(0, 20))), Belt_MutableSetInt.make())); - -b("File \"bs_mutable_set_test.res\", line 306, characters 4-11", Belt_MutableSetInt.eq(Belt_MutableSetInt.intersect(Belt_MutableSetInt.fromArray([ - 1, - 3, - 4, - 5, - 7, - 9 -]), Belt_MutableSetInt.fromArray([ - 2, - 4, - 5, - 6, - 8, - 10 -])), Belt_MutableSetInt.fromArray([ - 4, - 5 -]))); - -b("File \"bs_mutable_set_test.res\", line 307, characters 4-11", Belt_MutableSetInt.eq(Belt_MutableSetInt.diff(aa$3, bb$3), Belt_MutableSetInt.fromArray(Array_data_util.randomRange(0, 39)))); - -b("File \"bs_mutable_set_test.res\", line 308, characters 4-11", Belt_MutableSetInt.eq(Belt_MutableSetInt.diff(bb$3, aa$3), Belt_MutableSetInt.fromArray(Array_data_util.randomRange(101, 120)))); - -b("File \"bs_mutable_set_test.res\", line 310, characters 4-11", Belt_MutableSetInt.eq(Belt_MutableSetInt.diff(Belt_MutableSetInt.fromArray(Array_data_util.randomRange(21, 40)), Belt_MutableSetInt.fromArray(Array_data_util.randomRange(0, 20))), Belt_MutableSetInt.fromArray(Array_data_util.randomRange(21, 40)))); - -b("File \"bs_mutable_set_test.res\", line 317, characters 4-11", Belt_MutableSetInt.eq(Belt_MutableSetInt.diff(Belt_MutableSetInt.fromArray(Array_data_util.randomRange(0, 20)), Belt_MutableSetInt.fromArray(Array_data_util.randomRange(21, 40))), Belt_MutableSetInt.fromArray(Array_data_util.randomRange(0, 20)))); - -b("File \"bs_mutable_set_test.res\", line 325, characters 4-11", Belt_MutableSetInt.eq(Belt_MutableSetInt.diff(Belt_MutableSetInt.fromArray(Array_data_util.randomRange(0, 20)), Belt_MutableSetInt.fromArray(Array_data_util.randomRange(0, 40))), Belt_MutableSetInt.fromArray(Array_data_util.randomRange(0, -1)))); - -Mt.from_pair_suites("Bs_mutable_set_test", suites.contents); - -let N; - -let $$Array; - -let I; - -let R; - -let A; - -let L; - -let empty = Belt_MutableSetInt.make; - -let fromArray = Belt_MutableSetInt.fromArray; - -let $plus$plus = Belt_MutableSetInt.union; - -let f = Belt_MutableSetInt.fromArray; - -let $eq$tilde = Belt_MutableSetInt.eq; - -exports.suites = suites; -exports.test_id = test_id; -exports.eq = eq; -exports.b = b; -exports.N = N; -exports.$$Array = $$Array; -exports.I = I; -exports.R = R; -exports.A = A; -exports.L = L; -exports.empty = empty; -exports.fromArray = fromArray; -exports.$plus$plus = $plus$plus; -exports.f = f; -exports.$eq$tilde = $eq$tilde; -/* u Not a pure module */ diff --git a/tests/tests/src/bs_mutable_set_test.mjs b/tests/tests/src/bs_mutable_set_test.mjs new file mode 100644 index 0000000000..60390f5ff3 --- /dev/null +++ b/tests/tests/src/bs_mutable_set_test.mjs @@ -0,0 +1,566 @@ +// Generated by ReScript, PLEASE EDIT WITH CARE + +import * as Mt from "./mt.mjs"; +import * as Belt_List from "rescript/lib/es6/Belt_List.js"; +import * as Belt_Array from "rescript/lib/es6/Belt_Array.js"; +import * as Belt_Range from "rescript/lib/es6/Belt_Range.js"; +import * as Array_data_util from "./array_data_util.mjs"; +import * as Primitive_array from "rescript/lib/es6/Primitive_array.js"; +import * as Belt_MutableSetInt from "rescript/lib/es6/Belt_MutableSetInt.js"; + +let suites = { + contents: /* [] */0 +}; + +let test_id = { + contents: 0 +}; + +function eq(loc, x, y) { + Mt.eq_suites(test_id, suites, loc, x, y); +} + +function b(loc, x) { + Mt.bool_suites(test_id, suites, loc, x); +} + +let u = Belt_MutableSetInt.fromArray(Array_data_util.range(0, 30)); + +b("File \"bs_mutable_set_test.res\", line 22, characters 8-15", Belt_MutableSetInt.removeCheck(u, 0)); + +b("File \"bs_mutable_set_test.res\", line 23, characters 8-15", !Belt_MutableSetInt.removeCheck(u, 0)); + +b("File \"bs_mutable_set_test.res\", line 24, characters 8-15", Belt_MutableSetInt.removeCheck(u, 30)); + +b("File \"bs_mutable_set_test.res\", line 25, characters 8-15", Belt_MutableSetInt.removeCheck(u, 20)); + +eq("File \"bs_mutable_set_test.res\", line 26, characters 9-16", Belt_MutableSetInt.size(u), 28); + +let r = Array_data_util.randomRange(0, 30); + +b("File \"bs_mutable_set_test.res\", line 28, characters 8-15", 29 === Belt_MutableSetInt.maxUndefined(u)); + +b("File \"bs_mutable_set_test.res\", line 29, characters 8-15", 1 === Belt_MutableSetInt.minUndefined(u)); + +Belt_MutableSetInt.add(u, 3); + +for (let i = 0, i_finish = r.length; i < i_finish; ++i) { + Belt_MutableSetInt.remove(u, r[i]); +} + +b("File \"bs_mutable_set_test.res\", line 34, characters 8-15", Belt_MutableSetInt.isEmpty(u)); + +Belt_MutableSetInt.add(u, 0); + +Belt_MutableSetInt.add(u, 1); + +Belt_MutableSetInt.add(u, 2); + +Belt_MutableSetInt.add(u, 0); + +eq("File \"bs_mutable_set_test.res\", line 39, characters 9-16", Belt_MutableSetInt.size(u), 3); + +b("File \"bs_mutable_set_test.res\", line 40, characters 8-15", !Belt_MutableSetInt.isEmpty(u)); + +for (let i$1 = 0; i$1 <= 3; ++i$1) { + Belt_MutableSetInt.remove(u, i$1); +} + +b("File \"bs_mutable_set_test.res\", line 44, characters 8-15", Belt_MutableSetInt.isEmpty(u)); + +Belt_MutableSetInt.mergeMany(u, Array_data_util.randomRange(0, 20000)); + +Belt_MutableSetInt.mergeMany(u, Array_data_util.randomRange(0, 200)); + +eq("File \"bs_mutable_set_test.res\", line 47, characters 9-16", Belt_MutableSetInt.size(u), 20001); + +Belt_MutableSetInt.removeMany(u, Array_data_util.randomRange(0, 200)); + +eq("File \"bs_mutable_set_test.res\", line 49, characters 9-16", Belt_MutableSetInt.size(u), 19800); + +Belt_MutableSetInt.removeMany(u, Array_data_util.randomRange(0, 1000)); + +eq("File \"bs_mutable_set_test.res\", line 51, characters 9-16", Belt_MutableSetInt.size(u), 19000); + +Belt_MutableSetInt.removeMany(u, Array_data_util.randomRange(0, 1000)); + +eq("File \"bs_mutable_set_test.res\", line 53, characters 9-16", Belt_MutableSetInt.size(u), 19000); + +Belt_MutableSetInt.removeMany(u, Array_data_util.randomRange(1000, 10000)); + +eq("File \"bs_mutable_set_test.res\", line 55, characters 9-16", Belt_MutableSetInt.size(u), 10000); + +Belt_MutableSetInt.removeMany(u, Array_data_util.randomRange(10000, 19999)); + +eq("File \"bs_mutable_set_test.res\", line 57, characters 9-16", Belt_MutableSetInt.size(u), 1); + +b("File \"bs_mutable_set_test.res\", line 58, characters 8-15", Belt_MutableSetInt.has(u, 20000)); + +Belt_MutableSetInt.removeMany(u, Array_data_util.randomRange(10000, 30000)); + +b("File \"bs_mutable_set_test.res\", line 60, characters 8-15", Belt_MutableSetInt.isEmpty(u)); + +let v = Belt_MutableSetInt.fromArray(Array_data_util.randomRange(1000, 2000)); + +let bs = Belt_Array.map(Array_data_util.randomRange(500, 1499), x => Belt_MutableSetInt.removeCheck(v, x)); + +let indeedRemoved = Belt_Array.reduce(bs, 0, (acc, x) => { + if (x) { + return acc + 1 | 0; + } else { + return acc; + } +}); + +eq("File \"bs_mutable_set_test.res\", line 73, characters 9-16", indeedRemoved, 500); + +eq("File \"bs_mutable_set_test.res\", line 74, characters 9-16", Belt_MutableSetInt.size(v), 501); + +let cs = Belt_Array.map(Array_data_util.randomRange(500, 2000), x => Belt_MutableSetInt.addCheck(v, x)); + +let indeedAded = Belt_Array.reduce(cs, 0, (acc, x) => { + if (x) { + return acc + 1 | 0; + } else { + return acc; + } +}); + +eq("File \"bs_mutable_set_test.res\", line 83, characters 9-16", indeedAded, 1000); + +eq("File \"bs_mutable_set_test.res\", line 84, characters 9-16", Belt_MutableSetInt.size(v), 1501); + +b("File \"bs_mutable_set_test.res\", line 85, characters 8-15", Belt_MutableSetInt.isEmpty(Belt_MutableSetInt.make())); + +eq("File \"bs_mutable_set_test.res\", line 86, characters 9-16", Belt_MutableSetInt.minimum(v), 500); + +eq("File \"bs_mutable_set_test.res\", line 87, characters 9-16", Belt_MutableSetInt.maximum(v), 2000); + +eq("File \"bs_mutable_set_test.res\", line 88, characters 9-16", Belt_MutableSetInt.minUndefined(v), 500); + +eq("File \"bs_mutable_set_test.res\", line 89, characters 9-16", Belt_MutableSetInt.maxUndefined(v), 2000); + +eq("File \"bs_mutable_set_test.res\", line 90, characters 9-16", Belt_MutableSetInt.reduce(v, 0, (x, y) => x + y | 0), 1876250); + +b("File \"bs_mutable_set_test.res\", line 91, characters 8-15", Belt_List.eq(Belt_MutableSetInt.toList(v), Belt_List.makeBy(1501, i => i + 500 | 0), (x, y) => x === y)); + +eq("File \"bs_mutable_set_test.res\", line 92, characters 9-16", Belt_MutableSetInt.toArray(v), Array_data_util.range(500, 2000)); + +Belt_MutableSetInt.checkInvariantInternal(v); + +eq("File \"bs_mutable_set_test.res\", line 94, characters 9-16", Belt_MutableSetInt.get(v, 3), undefined); + +eq("File \"bs_mutable_set_test.res\", line 95, characters 9-16", Belt_MutableSetInt.get(v, 1200), 1200); + +let match = Belt_MutableSetInt.split(v, 1000); + +let match$1 = match[0]; + +let bb = match$1[1]; + +let aa = match$1[0]; + +b("File \"bs_mutable_set_test.res\", line 97, characters 8-15", match[1]); + +b("File \"bs_mutable_set_test.res\", line 98, characters 8-15", Belt_Array.eq(Belt_MutableSetInt.toArray(aa), Array_data_util.range(500, 999), (x, y) => x === y)); + +b("File \"bs_mutable_set_test.res\", line 99, characters 8-15", Belt_Array.eq(Belt_MutableSetInt.toArray(bb), Array_data_util.range(1001, 2000), (prim0, prim1) => prim0 === prim1)); + +b("File \"bs_mutable_set_test.res\", line 100, characters 8-15", Belt_MutableSetInt.subset(aa, v)); + +b("File \"bs_mutable_set_test.res\", line 101, characters 8-15", Belt_MutableSetInt.subset(bb, v)); + +b("File \"bs_mutable_set_test.res\", line 102, characters 8-15", Belt_MutableSetInt.isEmpty(Belt_MutableSetInt.intersect(aa, bb))); + +let c = Belt_MutableSetInt.removeCheck(v, 1000); + +b("File \"bs_mutable_set_test.res\", line 104, characters 8-15", c); + +let match$2 = Belt_MutableSetInt.split(v, 1000); + +let match$3 = match$2[0]; + +let bb$1 = match$3[1]; + +let aa$1 = match$3[0]; + +b("File \"bs_mutable_set_test.res\", line 106, characters 8-15", !match$2[1]); + +b("File \"bs_mutable_set_test.res\", line 107, characters 8-15", Belt_Array.eq(Belt_MutableSetInt.toArray(aa$1), Array_data_util.range(500, 999), (prim0, prim1) => prim0 === prim1)); + +b("File \"bs_mutable_set_test.res\", line 108, characters 8-15", Belt_Array.eq(Belt_MutableSetInt.toArray(bb$1), Array_data_util.range(1001, 2000), (prim0, prim1) => prim0 === prim1)); + +b("File \"bs_mutable_set_test.res\", line 109, characters 8-15", Belt_MutableSetInt.subset(aa$1, v)); + +b("File \"bs_mutable_set_test.res\", line 110, characters 8-15", Belt_MutableSetInt.subset(bb$1, v)); + +b("File \"bs_mutable_set_test.res\", line 111, characters 8-15", Belt_MutableSetInt.isEmpty(Belt_MutableSetInt.intersect(aa$1, bb$1))); + +let aa$2 = Belt_MutableSetInt.fromArray(Array_data_util.randomRange(0, 100)); + +let bb$2 = Belt_MutableSetInt.fromArray(Array_data_util.randomRange(40, 120)); + +let cc = Belt_MutableSetInt.union(aa$2, bb$2); + +b("File \"bs_mutable_set_test.res\", line 121, characters 8-15", Belt_MutableSetInt.eq(cc, Belt_MutableSetInt.fromArray(Array_data_util.randomRange(0, 120)))); + +b("File \"bs_mutable_set_test.res\", line 124, characters 8-15", Belt_MutableSetInt.eq(Belt_MutableSetInt.union(Belt_MutableSetInt.fromArray(Array_data_util.randomRange(0, 20)), Belt_MutableSetInt.fromArray(Array_data_util.randomRange(21, 40))), Belt_MutableSetInt.fromArray(Array_data_util.randomRange(0, 40)))); + +let dd = Belt_MutableSetInt.intersect(aa$2, bb$2); + +b("File \"bs_mutable_set_test.res\", line 128, characters 8-15", Belt_MutableSetInt.eq(dd, Belt_MutableSetInt.fromArray(Array_data_util.randomRange(40, 100)))); + +b("File \"bs_mutable_set_test.res\", line 130, characters 8-15", Belt_MutableSetInt.eq(Belt_MutableSetInt.intersect(Belt_MutableSetInt.fromArray(Array_data_util.randomRange(0, 20)), Belt_MutableSetInt.fromArray(Array_data_util.randomRange(21, 40))), Belt_MutableSetInt.make())); + +b("File \"bs_mutable_set_test.res\", line 137, characters 8-15", Belt_MutableSetInt.eq(Belt_MutableSetInt.intersect(Belt_MutableSetInt.fromArray(Array_data_util.randomRange(21, 40)), Belt_MutableSetInt.fromArray(Array_data_util.randomRange(0, 20))), Belt_MutableSetInt.make())); + +b("File \"bs_mutable_set_test.res\", line 143, characters 8-15", Belt_MutableSetInt.eq(Belt_MutableSetInt.intersect(Belt_MutableSetInt.fromArray([ + 1, + 3, + 4, + 5, + 7, + 9 +]), Belt_MutableSetInt.fromArray([ + 2, + 4, + 5, + 6, + 8, + 10 +])), Belt_MutableSetInt.fromArray([ + 4, + 5 +]))); + +b("File \"bs_mutable_set_test.res\", line 144, characters 8-15", Belt_MutableSetInt.eq(Belt_MutableSetInt.diff(aa$2, bb$2), Belt_MutableSetInt.fromArray(Array_data_util.randomRange(0, 39)))); + +b("File \"bs_mutable_set_test.res\", line 145, characters 8-15", Belt_MutableSetInt.eq(Belt_MutableSetInt.diff(bb$2, aa$2), Belt_MutableSetInt.fromArray(Array_data_util.randomRange(101, 120)))); + +b("File \"bs_mutable_set_test.res\", line 147, characters 8-15", Belt_MutableSetInt.eq(Belt_MutableSetInt.diff(Belt_MutableSetInt.fromArray(Array_data_util.randomRange(21, 40)), Belt_MutableSetInt.fromArray(Array_data_util.randomRange(0, 20))), Belt_MutableSetInt.fromArray(Array_data_util.randomRange(21, 40)))); + +b("File \"bs_mutable_set_test.res\", line 154, characters 8-15", Belt_MutableSetInt.eq(Belt_MutableSetInt.diff(Belt_MutableSetInt.fromArray(Array_data_util.randomRange(0, 20)), Belt_MutableSetInt.fromArray(Array_data_util.randomRange(21, 40))), Belt_MutableSetInt.fromArray(Array_data_util.randomRange(0, 20)))); + +b("File \"bs_mutable_set_test.res\", line 162, characters 8-15", Belt_MutableSetInt.eq(Belt_MutableSetInt.diff(Belt_MutableSetInt.fromArray(Array_data_util.randomRange(0, 20)), Belt_MutableSetInt.fromArray(Array_data_util.randomRange(0, 40))), Belt_MutableSetInt.fromArray(Array_data_util.randomRange(0, -1)))); + +let a0 = Belt_MutableSetInt.fromArray(Array_data_util.randomRange(0, 1000)); + +let a1 = Belt_MutableSetInt.keep(a0, x => x % 2 === 0); + +let a2 = Belt_MutableSetInt.keep(a0, x => x % 2 !== 0); + +let match$4 = Belt_MutableSetInt.partition(a0, x => x % 2 === 0); + +let a4 = match$4[1]; + +let a3 = match$4[0]; + +b("File \"bs_mutable_set_test.res\", line 174, characters 8-15", Belt_MutableSetInt.eq(a1, a3)); + +b("File \"bs_mutable_set_test.res\", line 175, characters 8-15", Belt_MutableSetInt.eq(a2, a4)); + +Belt_List.forEach({ + hd: a0, + tl: { + hd: a1, + tl: { + hd: a2, + tl: { + hd: a3, + tl: { + hd: a4, + tl: /* [] */0 + } + } + } + } +}, Belt_MutableSetInt.checkInvariantInternal); + +let v$1 = Belt_MutableSetInt.make(); + +for (let i$2 = 0; i$2 <= 100000; ++i$2) { + Belt_MutableSetInt.add(v$1, i$2); +} + +Belt_MutableSetInt.checkInvariantInternal(v$1); + +b("File \"bs_mutable_set_test.res\", line 189, characters 10-17", Belt_Range.every(0, 100000, i => Belt_MutableSetInt.has(v$1, i))); + +eq("File \"bs_mutable_set_test.res\", line 190, characters 5-12", Belt_MutableSetInt.size(v$1), 100001); + +let u$1 = Belt_Array.concat(Array_data_util.randomRange(30, 100), Array_data_util.randomRange(40, 120)); + +let v$2 = Belt_MutableSetInt.make(); + +Belt_MutableSetInt.mergeMany(v$2, u$1); + +eq("File \"bs_mutable_set_test.res\", line 197, characters 5-12", Belt_MutableSetInt.size(v$2), 91); + +eq("File \"bs_mutable_set_test.res\", line 198, characters 5-12", Belt_MutableSetInt.toArray(v$2), Array_data_util.range(30, 120)); + +let u$2 = Belt_Array.concat(Array_data_util.randomRange(0, 100000), Array_data_util.randomRange(0, 100)); + +let v$3 = Belt_MutableSetInt.fromArray(u$2); + +eq("File \"bs_mutable_set_test.res\", line 204, characters 5-12", Belt_MutableSetInt.size(v$3), 100001); + +let u$3 = Array_data_util.randomRange(50000, 80000); + +for (let i$3 = 0, i_finish$1 = u$3.length; i$3 < i_finish$1; ++i$3) { + Belt_MutableSetInt.remove(v$3, i$3); +} + +eq("File \"bs_mutable_set_test.res\", line 211, characters 5-12", Belt_MutableSetInt.size(v$3), 70000); + +let vv = Array_data_util.randomRange(0, 100000); + +for (let i$4 = 0, i_finish$2 = vv.length; i$4 < i_finish$2; ++i$4) { + Belt_MutableSetInt.remove(v$3, Primitive_array.get(vv, i$4)); +} + +eq("File \"bs_mutable_set_test.res\", line 217, characters 5-12", Belt_MutableSetInt.size(v$3), 0); + +b("File \"bs_mutable_set_test.res\", line 218, characters 4-11", Belt_MutableSetInt.isEmpty(v$3)); + +let v$4 = Belt_MutableSetInt.fromArray(Belt_Array.makeBy(30, i => i)); + +Belt_MutableSetInt.remove(v$4, 30); + +Belt_MutableSetInt.remove(v$4, 29); + +b("File \"bs_mutable_set_test.res\", line 225, characters 4-11", 28 === Belt_MutableSetInt.maxUndefined(v$4)); + +Belt_MutableSetInt.remove(v$4, 0); + +b("File \"bs_mutable_set_test.res\", line 227, characters 4-11", 1 === Belt_MutableSetInt.minUndefined(v$4)); + +eq("File \"bs_mutable_set_test.res\", line 228, characters 5-12", Belt_MutableSetInt.size(v$4), 28); + +let vv$1 = Array_data_util.randomRange(1, 28); + +for (let i$5 = 0, i_finish$3 = vv$1.length; i$5 < i_finish$3; ++i$5) { + Belt_MutableSetInt.remove(v$4, Primitive_array.get(vv$1, i$5)); +} + +eq("File \"bs_mutable_set_test.res\", line 233, characters 5-12", Belt_MutableSetInt.size(v$4), 0); + +function id(loc, x) { + let u = Belt_MutableSetInt.fromSortedArrayUnsafe(x); + Belt_MutableSetInt.checkInvariantInternal(u); + b(loc, Belt_Array.every2(Belt_MutableSetInt.toArray(u), x, (prim0, prim1) => prim0 === prim1)); +} + +id("File \"bs_mutable_set_test.res\", line 243, characters 5-12", []); + +id("File \"bs_mutable_set_test.res\", line 244, characters 5-12", [0]); + +id("File \"bs_mutable_set_test.res\", line 245, characters 5-12", [ + 0, + 1 +]); + +id("File \"bs_mutable_set_test.res\", line 246, characters 5-12", [ + 0, + 1, + 2 +]); + +id("File \"bs_mutable_set_test.res\", line 247, characters 5-12", [ + 0, + 1, + 2, + 3 +]); + +id("File \"bs_mutable_set_test.res\", line 248, characters 5-12", [ + 0, + 1, + 2, + 3, + 4 +]); + +id("File \"bs_mutable_set_test.res\", line 249, characters 5-12", [ + 0, + 1, + 2, + 3, + 4, + 5 +]); + +id("File \"bs_mutable_set_test.res\", line 250, characters 5-12", [ + 0, + 1, + 2, + 3, + 4, + 6 +]); + +id("File \"bs_mutable_set_test.res\", line 251, characters 5-12", [ + 0, + 1, + 2, + 3, + 4, + 6, + 7 +]); + +id("File \"bs_mutable_set_test.res\", line 252, characters 5-12", [ + 0, + 1, + 2, + 3, + 4, + 6, + 7, + 8 +]); + +id("File \"bs_mutable_set_test.res\", line 253, characters 5-12", [ + 0, + 1, + 2, + 3, + 4, + 6, + 7, + 8, + 9 +]); + +id("File \"bs_mutable_set_test.res\", line 254, characters 5-12", Array_data_util.range(0, 1000)); + +let v$5 = Belt_MutableSetInt.fromArray(Array_data_util.randomRange(0, 1000)); + +let copyV = Belt_MutableSetInt.keep(v$5, x => x % 8 === 0); + +let match$5 = Belt_MutableSetInt.partition(v$5, x => x % 8 === 0); + +let cc$1 = Belt_MutableSetInt.keep(v$5, x => x % 8 !== 0); + +for (let i$6 = 0; i$6 <= 200; ++i$6) { + Belt_MutableSetInt.remove(v$5, i$6); +} + +eq("File \"bs_mutable_set_test.res\", line 265, characters 5-12", Belt_MutableSetInt.size(copyV), 126); + +eq("File \"bs_mutable_set_test.res\", line 266, characters 5-12", Belt_MutableSetInt.toArray(copyV), Belt_Array.makeBy(126, i => (i << 3))); + +eq("File \"bs_mutable_set_test.res\", line 267, characters 5-12", Belt_MutableSetInt.size(v$5), 800); + +b("File \"bs_mutable_set_test.res\", line 268, characters 4-11", Belt_MutableSetInt.eq(copyV, match$5[0])); + +b("File \"bs_mutable_set_test.res\", line 269, characters 4-11", Belt_MutableSetInt.eq(cc$1, match$5[1])); + +let v$6 = Belt_MutableSetInt.fromArray(Array_data_util.randomRange(0, 1000)); + +let match$6 = Belt_MutableSetInt.split(v$6, 400); + +let match$7 = match$6[0]; + +b("File \"bs_mutable_set_test.res\", line 275, characters 4-11", Belt_MutableSetInt.eq(match$7[0], Belt_MutableSetInt.fromArray(Array_data_util.randomRange(0, 399)))); + +b("File \"bs_mutable_set_test.res\", line 276, characters 4-11", Belt_MutableSetInt.eq(match$7[1], Belt_MutableSetInt.fromArray(Array_data_util.randomRange(401, 1000)))); + +let d = Belt_MutableSetInt.fromArray(Belt_Array.map(Array_data_util.randomRange(0, 1000), x => (x << 1))); + +let match$8 = Belt_MutableSetInt.split(d, 1001); + +let match$9 = match$8[0]; + +b("File \"bs_mutable_set_test.res\", line 279, characters 4-11", Belt_MutableSetInt.eq(match$9[0], Belt_MutableSetInt.fromArray(Belt_Array.makeBy(501, x => (x << 1))))); + +b("File \"bs_mutable_set_test.res\", line 280, characters 4-11", Belt_MutableSetInt.eq(match$9[1], Belt_MutableSetInt.fromArray(Belt_Array.makeBy(500, x => 1002 + (x << 1) | 0)))); + +let aa$3 = Belt_MutableSetInt.fromArray(Array_data_util.randomRange(0, 100)); + +let bb$3 = Belt_MutableSetInt.fromArray(Array_data_util.randomRange(40, 120)); + +let cc$2 = Belt_MutableSetInt.union(aa$3, bb$3); + +b("File \"bs_mutable_set_test.res\", line 290, characters 4-11", Belt_MutableSetInt.eq(cc$2, Belt_MutableSetInt.fromArray(Array_data_util.randomRange(0, 120)))); + +b("File \"bs_mutable_set_test.res\", line 293, characters 4-11", Belt_MutableSetInt.eq(Belt_MutableSetInt.union(Belt_MutableSetInt.fromArray(Array_data_util.randomRange(0, 20)), Belt_MutableSetInt.fromArray(Array_data_util.randomRange(21, 40))), Belt_MutableSetInt.fromArray(Array_data_util.randomRange(0, 40)))); + +let dd$1 = Belt_MutableSetInt.intersect(aa$3, bb$3); + +b("File \"bs_mutable_set_test.res\", line 297, characters 4-11", Belt_MutableSetInt.eq(dd$1, Belt_MutableSetInt.fromArray(Array_data_util.randomRange(40, 100)))); + +b("File \"bs_mutable_set_test.res\", line 299, characters 4-11", Belt_MutableSetInt.eq(Belt_MutableSetInt.intersect(Belt_MutableSetInt.fromArray(Array_data_util.randomRange(0, 20)), Belt_MutableSetInt.fromArray(Array_data_util.randomRange(21, 40))), Belt_MutableSetInt.make())); + +b("File \"bs_mutable_set_test.res\", line 303, characters 4-11", Belt_MutableSetInt.eq(Belt_MutableSetInt.intersect(Belt_MutableSetInt.fromArray(Array_data_util.randomRange(21, 40)), Belt_MutableSetInt.fromArray(Array_data_util.randomRange(0, 20))), Belt_MutableSetInt.make())); + +b("File \"bs_mutable_set_test.res\", line 306, characters 4-11", Belt_MutableSetInt.eq(Belt_MutableSetInt.intersect(Belt_MutableSetInt.fromArray([ + 1, + 3, + 4, + 5, + 7, + 9 +]), Belt_MutableSetInt.fromArray([ + 2, + 4, + 5, + 6, + 8, + 10 +])), Belt_MutableSetInt.fromArray([ + 4, + 5 +]))); + +b("File \"bs_mutable_set_test.res\", line 307, characters 4-11", Belt_MutableSetInt.eq(Belt_MutableSetInt.diff(aa$3, bb$3), Belt_MutableSetInt.fromArray(Array_data_util.randomRange(0, 39)))); + +b("File \"bs_mutable_set_test.res\", line 308, characters 4-11", Belt_MutableSetInt.eq(Belt_MutableSetInt.diff(bb$3, aa$3), Belt_MutableSetInt.fromArray(Array_data_util.randomRange(101, 120)))); + +b("File \"bs_mutable_set_test.res\", line 310, characters 4-11", Belt_MutableSetInt.eq(Belt_MutableSetInt.diff(Belt_MutableSetInt.fromArray(Array_data_util.randomRange(21, 40)), Belt_MutableSetInt.fromArray(Array_data_util.randomRange(0, 20))), Belt_MutableSetInt.fromArray(Array_data_util.randomRange(21, 40)))); + +b("File \"bs_mutable_set_test.res\", line 317, characters 4-11", Belt_MutableSetInt.eq(Belt_MutableSetInt.diff(Belt_MutableSetInt.fromArray(Array_data_util.randomRange(0, 20)), Belt_MutableSetInt.fromArray(Array_data_util.randomRange(21, 40))), Belt_MutableSetInt.fromArray(Array_data_util.randomRange(0, 20)))); + +b("File \"bs_mutable_set_test.res\", line 325, characters 4-11", Belt_MutableSetInt.eq(Belt_MutableSetInt.diff(Belt_MutableSetInt.fromArray(Array_data_util.randomRange(0, 20)), Belt_MutableSetInt.fromArray(Array_data_util.randomRange(0, 40))), Belt_MutableSetInt.fromArray(Array_data_util.randomRange(0, -1)))); + +Mt.from_pair_suites("Bs_mutable_set_test", suites.contents); + +let N; + +let $$Array; + +let I; + +let R; + +let A; + +let L; + +let empty = Belt_MutableSetInt.make; + +let fromArray = Belt_MutableSetInt.fromArray; + +let $plus$plus = Belt_MutableSetInt.union; + +let f = Belt_MutableSetInt.fromArray; + +let $eq$tilde = Belt_MutableSetInt.eq; + +export { + suites, + test_id, + eq, + b, + N, + $$Array, + I, + R, + A, + L, + empty, + fromArray, + $plus$plus, + f, + $eq$tilde, +} +/* u Not a pure module */ diff --git a/tests/tests/src/bs_poly_map_test.js b/tests/tests/src/bs_poly_map_test.js deleted file mode 100644 index 73e4fc45c3..0000000000 --- a/tests/tests/src/bs_poly_map_test.js +++ /dev/null @@ -1,273 +0,0 @@ -// Generated by ReScript, PLEASE EDIT WITH CARE -'use strict'; - -let Mt = require("./mt.js"); -let Belt_Id = require("rescript/lib/js/Belt_Id.js"); -let Belt_Map = require("rescript/lib/js/Belt_Map.js"); -let Belt_Set = require("rescript/lib/js/Belt_Set.js"); -let Belt_Array = require("rescript/lib/js/Belt_Array.js"); -let Primitive_int = require("rescript/lib/js/Primitive_int.js"); -let Array_data_util = require("./array_data_util.js"); -let Primitive_option = require("rescript/lib/js/Primitive_option.js"); - -let suites = { - contents: /* [] */0 -}; - -let test_id = { - contents: 0 -}; - -function eq(loc, x, y) { - Mt.eq_suites(test_id, suites, loc, x, y); -} - -function b(loc, v) { - Mt.bool_suites(test_id, suites, loc, v); -} - -let Icmp = Belt_Id.comparable(Primitive_int.compare); - -function mapOfArray(x) { - return Belt_Map.fromArray(x, Icmp); -} - -function setOfArray(x) { - return Belt_Set.fromArray(x, Icmp); -} - -function emptyMap() { - return Belt_Map.make(Icmp); -} - -function mergeInter(s1, s2) { - return Belt_Set.fromArray(Belt_Map.keysToArray(Belt_Map.merge(s1, s2, (k, v1, v2) => { - if (v1 !== undefined && v2 !== undefined) { - return Primitive_option.some(undefined); - } - - })), Icmp); -} - -function mergeUnion(s1, s2) { - return Belt_Set.fromArray(Belt_Map.keysToArray(Belt_Map.merge(s1, s2, (k, v1, v2) => { - if (v1 !== undefined || v2 !== undefined) { - return Primitive_option.some(undefined); - } - - })), Icmp); -} - -function mergeDiff(s1, s2) { - return Belt_Set.fromArray(Belt_Map.keysToArray(Belt_Map.merge(s1, s2, (k, v1, v2) => { - if (v1 !== undefined && v2 === undefined) { - return Primitive_option.some(undefined); - } - - })), Icmp); -} - -function randomRange(i, j) { - return Belt_Array.map(Array_data_util.randomRange(i, j), x => [ - x, - x - ]); -} - -let u0 = Belt_Map.fromArray(randomRange(0, 100), Icmp); - -let u1 = Belt_Map.fromArray(randomRange(30, 120), Icmp); - -b("File \"bs_poly_map_test.res\", line 64, characters 4-11", Belt_Set.eq(mergeInter(u0, u1), Belt_Set.fromArray(Array_data_util.range(30, 100), Icmp))); - -b("File \"bs_poly_map_test.res\", line 65, characters 4-11", Belt_Set.eq(mergeUnion(u0, u1), Belt_Set.fromArray(Array_data_util.range(0, 120), Icmp))); - -b("File \"bs_poly_map_test.res\", line 66, characters 4-11", Belt_Set.eq(mergeDiff(u0, u1), Belt_Set.fromArray(Array_data_util.range(0, 29), Icmp))); - -b("File \"bs_poly_map_test.res\", line 67, characters 4-11", Belt_Set.eq(mergeDiff(u1, u0), Belt_Set.fromArray(Array_data_util.range(101, 120), Icmp))); - -let a0 = Belt_Map.fromArray(randomRange(0, 10), Icmp); - -let a1 = Belt_Map.set(a0, 3, 33); - -let a2 = Belt_Map.remove(a1, 3); - -let a3 = Belt_Map.update(a2, 3, k => { - if (k !== undefined) { - return k + 1 | 0; - } else { - return 11; - } -}); - -let a4 = Belt_Map.update(a2, 3, k => { - if (k !== undefined) { - return k + 1 | 0; - } - -}); - -let a5 = Belt_Map.remove(a0, 3); - -let a6 = Belt_Map.remove(a5, 3); - -b("File \"bs_poly_map_test.res\", line 88, characters 4-11", a5 === a6); - -b("File \"bs_poly_map_test.res\", line 89, characters 4-11", Belt_Map.has(a0, 3)); - -b("File \"bs_poly_map_test.res\", line 90, characters 4-11", !Belt_Map.has(a5, 3)); - -b("File \"bs_poly_map_test.res\", line 91, characters 4-11", 3 === Belt_Map.getUndefined(a0, 3)); - -b("File \"bs_poly_map_test.res\", line 92, characters 4-11", 33 === Belt_Map.getUndefined(a1, 3)); - -b("File \"bs_poly_map_test.res\", line 93, characters 4-11", Belt_Map.getUndefined(a2, 3) === undefined); - -b("File \"bs_poly_map_test.res\", line 95, characters 4-11", 11 === Belt_Map.getUndefined(a3, 3)); - -b("File \"bs_poly_map_test.res\", line 96, characters 4-11", Belt_Map.getUndefined(a4, 3) === undefined); - -let a7 = Belt_Map.removeMany(a0, [ - 7, - 8, - 0, - 1, - 3, - 2, - 4, - 922, - 4, - 5, - 6 -]); - -eq("File \"bs_poly_map_test.res\", line 99, characters 5-12", Belt_Map.keysToArray(a7), [ - 9, - 10 -]); - -let a8 = Belt_Map.removeMany(a7, Array_data_util.randomRange(0, 100)); - -b("File \"bs_poly_map_test.res\", line 101, characters 4-11", Belt_Map.isEmpty(a8)); - -let u0$1 = Belt_Map.fromArray(randomRange(0, 100), Icmp); - -let u1$1 = Belt_Map.set(u0$1, 3, 32); - -eq("File \"bs_poly_map_test.res\", line 107, characters 5-12", Belt_Map.get(u1$1, 3), 32); - -eq("File \"bs_poly_map_test.res\", line 108, characters 5-12", Belt_Map.get(u0$1, 3), 3); - -function acc(m, is) { - return Belt_Array.reduce(is, m, (a, i) => Belt_Map.update(a, i, n => { - if (n !== undefined) { - return n + 1 | 0; - } else { - return 1; - } - })); -} - -let m = Belt_Map.make(Icmp); - -let m1 = acc(m, Belt_Array.concat(Array_data_util.randomRange(0, 20), Array_data_util.randomRange(10, 30))); - -b("File \"bs_poly_map_test.res\", line 125, characters 4-11", Belt_Map.eq(m1, Belt_Map.fromArray(Belt_Array.makeBy(31, i => [ - i, - i >= 10 && i <= 20 ? 2 : 1 -]), Icmp), (x, y) => x === y)); - -let v0 = Belt_Map.make(Icmp); - -let v1 = Belt_Map.mergeMany(v0, Belt_Array.map(Array_data_util.randomRange(0, 10000), x => [ - x, - x -])); - -let v2 = Belt_Map.fromArray(Belt_Array.map(Array_data_util.randomRange(0, 10000), x => [ - x, - x -]), Icmp); - -b("File \"bs_poly_map_test.res\", line 149, characters 4-11", Belt_Map.eq(v1, v2, (x, y) => x === y)); - -function inc(x) { - if (x !== undefined) { - return x + 1 | 0; - } else { - return 0; - } -} - -let v3 = Belt_Map.update(v1, 10, inc); - -let v4 = Belt_Map.update(v3, -10, inc); - -let match = Belt_Map.split(v3, 5000); - -let pres = match[1]; - -let match$1 = match[0]; - -let match$2 = Belt_Map.get(v3, 10); - -b("File \"bs_poly_map_test.res\", line 160, characters 4-11", match$2 !== undefined ? match$2 === 11 : false); - -let match$3 = Belt_Map.get(v3, -10); - -b("File \"bs_poly_map_test.res\", line 167, characters 4-11", match$3 === undefined); - -let match$4 = Belt_Map.get(v4, -10); - -b("File \"bs_poly_map_test.res\", line 174, characters 4-11", match$4 !== undefined ? match$4 === 0 : false); - -b("File \"bs_poly_map_test.res\", line 180, characters 4-11", Belt_Map.isEmpty(Belt_Map.remove(Belt_Map.make(Icmp), 0))); - -b("File \"bs_poly_map_test.res\", line 181, characters 4-11", Belt_Map.isEmpty(Belt_Map.removeMany(Belt_Map.make(Icmp), [0]))); - -b("File \"bs_poly_map_test.res\", line 183, characters 4-11", pres !== undefined ? pres === 5000 : false); - -b("File \"bs_poly_map_test.res\", line 189, characters 4-11", Belt_Array.eq(Belt_Map.keysToArray(match$1[0]), Belt_Array.makeBy(5000, i => i), (prim0, prim1) => prim0 === prim1)); - -b("File \"bs_poly_map_test.res\", line 190, characters 4-11", Belt_Array.eq(Belt_Map.keysToArray(match$1[1]), Belt_Array.makeBy(5000, i => 5001 + i | 0), (prim0, prim1) => prim0 === prim1)); - -let v7 = Belt_Map.remove(v3, 5000); - -let match$5 = Belt_Map.split(v7, 5000); - -let match$6 = match$5[0]; - -b("File \"bs_poly_map_test.res\", line 195, characters 4-11", match$5[1] === undefined); - -b("File \"bs_poly_map_test.res\", line 201, characters 4-11", Belt_Array.eq(Belt_Map.keysToArray(match$6[0]), Belt_Array.makeBy(5000, i => i), (prim0, prim1) => prim0 === prim1)); - -b("File \"bs_poly_map_test.res\", line 202, characters 4-11", Belt_Array.eq(Belt_Map.keysToArray(match$6[1]), Belt_Array.makeBy(5000, i => 5001 + i | 0), (prim0, prim1) => prim0 === prim1)); - -Mt.from_pair_suites("Bs_poly_map_test", suites.contents); - -let M; - -let N; - -let A; - -let I; - -exports.suites = suites; -exports.test_id = test_id; -exports.eq = eq; -exports.b = b; -exports.Icmp = Icmp; -exports.M = M; -exports.N = N; -exports.A = A; -exports.I = I; -exports.mapOfArray = mapOfArray; -exports.setOfArray = setOfArray; -exports.emptyMap = emptyMap; -exports.mergeInter = mergeInter; -exports.mergeUnion = mergeUnion; -exports.mergeDiff = mergeDiff; -exports.randomRange = randomRange; -exports.acc = acc; -/* Icmp Not a pure module */ diff --git a/tests/tests/src/bs_poly_map_test.mjs b/tests/tests/src/bs_poly_map_test.mjs new file mode 100644 index 0000000000..3497df028e --- /dev/null +++ b/tests/tests/src/bs_poly_map_test.mjs @@ -0,0 +1,274 @@ +// Generated by ReScript, PLEASE EDIT WITH CARE + +import * as Mt from "./mt.mjs"; +import * as Belt_Id from "rescript/lib/es6/Belt_Id.js"; +import * as Belt_Map from "rescript/lib/es6/Belt_Map.js"; +import * as Belt_Set from "rescript/lib/es6/Belt_Set.js"; +import * as Belt_Array from "rescript/lib/es6/Belt_Array.js"; +import * as Primitive_int from "rescript/lib/es6/Primitive_int.js"; +import * as Array_data_util from "./array_data_util.mjs"; +import * as Primitive_option from "rescript/lib/es6/Primitive_option.js"; + +let suites = { + contents: /* [] */0 +}; + +let test_id = { + contents: 0 +}; + +function eq(loc, x, y) { + Mt.eq_suites(test_id, suites, loc, x, y); +} + +function b(loc, v) { + Mt.bool_suites(test_id, suites, loc, v); +} + +let Icmp = Belt_Id.comparable(Primitive_int.compare); + +function mapOfArray(x) { + return Belt_Map.fromArray(x, Icmp); +} + +function setOfArray(x) { + return Belt_Set.fromArray(x, Icmp); +} + +function emptyMap() { + return Belt_Map.make(Icmp); +} + +function mergeInter(s1, s2) { + return Belt_Set.fromArray(Belt_Map.keysToArray(Belt_Map.merge(s1, s2, (k, v1, v2) => { + if (v1 !== undefined && v2 !== undefined) { + return Primitive_option.some(undefined); + } + + })), Icmp); +} + +function mergeUnion(s1, s2) { + return Belt_Set.fromArray(Belt_Map.keysToArray(Belt_Map.merge(s1, s2, (k, v1, v2) => { + if (v1 !== undefined || v2 !== undefined) { + return Primitive_option.some(undefined); + } + + })), Icmp); +} + +function mergeDiff(s1, s2) { + return Belt_Set.fromArray(Belt_Map.keysToArray(Belt_Map.merge(s1, s2, (k, v1, v2) => { + if (v1 !== undefined && v2 === undefined) { + return Primitive_option.some(undefined); + } + + })), Icmp); +} + +function randomRange(i, j) { + return Belt_Array.map(Array_data_util.randomRange(i, j), x => [ + x, + x + ]); +} + +let u0 = Belt_Map.fromArray(randomRange(0, 100), Icmp); + +let u1 = Belt_Map.fromArray(randomRange(30, 120), Icmp); + +b("File \"bs_poly_map_test.res\", line 64, characters 4-11", Belt_Set.eq(mergeInter(u0, u1), Belt_Set.fromArray(Array_data_util.range(30, 100), Icmp))); + +b("File \"bs_poly_map_test.res\", line 65, characters 4-11", Belt_Set.eq(mergeUnion(u0, u1), Belt_Set.fromArray(Array_data_util.range(0, 120), Icmp))); + +b("File \"bs_poly_map_test.res\", line 66, characters 4-11", Belt_Set.eq(mergeDiff(u0, u1), Belt_Set.fromArray(Array_data_util.range(0, 29), Icmp))); + +b("File \"bs_poly_map_test.res\", line 67, characters 4-11", Belt_Set.eq(mergeDiff(u1, u0), Belt_Set.fromArray(Array_data_util.range(101, 120), Icmp))); + +let a0 = Belt_Map.fromArray(randomRange(0, 10), Icmp); + +let a1 = Belt_Map.set(a0, 3, 33); + +let a2 = Belt_Map.remove(a1, 3); + +let a3 = Belt_Map.update(a2, 3, k => { + if (k !== undefined) { + return k + 1 | 0; + } else { + return 11; + } +}); + +let a4 = Belt_Map.update(a2, 3, k => { + if (k !== undefined) { + return k + 1 | 0; + } + +}); + +let a5 = Belt_Map.remove(a0, 3); + +let a6 = Belt_Map.remove(a5, 3); + +b("File \"bs_poly_map_test.res\", line 88, characters 4-11", a5 === a6); + +b("File \"bs_poly_map_test.res\", line 89, characters 4-11", Belt_Map.has(a0, 3)); + +b("File \"bs_poly_map_test.res\", line 90, characters 4-11", !Belt_Map.has(a5, 3)); + +b("File \"bs_poly_map_test.res\", line 91, characters 4-11", 3 === Belt_Map.getUndefined(a0, 3)); + +b("File \"bs_poly_map_test.res\", line 92, characters 4-11", 33 === Belt_Map.getUndefined(a1, 3)); + +b("File \"bs_poly_map_test.res\", line 93, characters 4-11", Belt_Map.getUndefined(a2, 3) === undefined); + +b("File \"bs_poly_map_test.res\", line 95, characters 4-11", 11 === Belt_Map.getUndefined(a3, 3)); + +b("File \"bs_poly_map_test.res\", line 96, characters 4-11", Belt_Map.getUndefined(a4, 3) === undefined); + +let a7 = Belt_Map.removeMany(a0, [ + 7, + 8, + 0, + 1, + 3, + 2, + 4, + 922, + 4, + 5, + 6 +]); + +eq("File \"bs_poly_map_test.res\", line 99, characters 5-12", Belt_Map.keysToArray(a7), [ + 9, + 10 +]); + +let a8 = Belt_Map.removeMany(a7, Array_data_util.randomRange(0, 100)); + +b("File \"bs_poly_map_test.res\", line 101, characters 4-11", Belt_Map.isEmpty(a8)); + +let u0$1 = Belt_Map.fromArray(randomRange(0, 100), Icmp); + +let u1$1 = Belt_Map.set(u0$1, 3, 32); + +eq("File \"bs_poly_map_test.res\", line 107, characters 5-12", Belt_Map.get(u1$1, 3), 32); + +eq("File \"bs_poly_map_test.res\", line 108, characters 5-12", Belt_Map.get(u0$1, 3), 3); + +function acc(m, is) { + return Belt_Array.reduce(is, m, (a, i) => Belt_Map.update(a, i, n => { + if (n !== undefined) { + return n + 1 | 0; + } else { + return 1; + } + })); +} + +let m = Belt_Map.make(Icmp); + +let m1 = acc(m, Belt_Array.concat(Array_data_util.randomRange(0, 20), Array_data_util.randomRange(10, 30))); + +b("File \"bs_poly_map_test.res\", line 125, characters 4-11", Belt_Map.eq(m1, Belt_Map.fromArray(Belt_Array.makeBy(31, i => [ + i, + i >= 10 && i <= 20 ? 2 : 1 +]), Icmp), (x, y) => x === y)); + +let v0 = Belt_Map.make(Icmp); + +let v1 = Belt_Map.mergeMany(v0, Belt_Array.map(Array_data_util.randomRange(0, 10000), x => [ + x, + x +])); + +let v2 = Belt_Map.fromArray(Belt_Array.map(Array_data_util.randomRange(0, 10000), x => [ + x, + x +]), Icmp); + +b("File \"bs_poly_map_test.res\", line 149, characters 4-11", Belt_Map.eq(v1, v2, (x, y) => x === y)); + +function inc(x) { + if (x !== undefined) { + return x + 1 | 0; + } else { + return 0; + } +} + +let v3 = Belt_Map.update(v1, 10, inc); + +let v4 = Belt_Map.update(v3, -10, inc); + +let match = Belt_Map.split(v3, 5000); + +let pres = match[1]; + +let match$1 = match[0]; + +let match$2 = Belt_Map.get(v3, 10); + +b("File \"bs_poly_map_test.res\", line 160, characters 4-11", match$2 !== undefined ? match$2 === 11 : false); + +let match$3 = Belt_Map.get(v3, -10); + +b("File \"bs_poly_map_test.res\", line 167, characters 4-11", match$3 === undefined); + +let match$4 = Belt_Map.get(v4, -10); + +b("File \"bs_poly_map_test.res\", line 174, characters 4-11", match$4 !== undefined ? match$4 === 0 : false); + +b("File \"bs_poly_map_test.res\", line 180, characters 4-11", Belt_Map.isEmpty(Belt_Map.remove(Belt_Map.make(Icmp), 0))); + +b("File \"bs_poly_map_test.res\", line 181, characters 4-11", Belt_Map.isEmpty(Belt_Map.removeMany(Belt_Map.make(Icmp), [0]))); + +b("File \"bs_poly_map_test.res\", line 183, characters 4-11", pres !== undefined ? pres === 5000 : false); + +b("File \"bs_poly_map_test.res\", line 189, characters 4-11", Belt_Array.eq(Belt_Map.keysToArray(match$1[0]), Belt_Array.makeBy(5000, i => i), (prim0, prim1) => prim0 === prim1)); + +b("File \"bs_poly_map_test.res\", line 190, characters 4-11", Belt_Array.eq(Belt_Map.keysToArray(match$1[1]), Belt_Array.makeBy(5000, i => 5001 + i | 0), (prim0, prim1) => prim0 === prim1)); + +let v7 = Belt_Map.remove(v3, 5000); + +let match$5 = Belt_Map.split(v7, 5000); + +let match$6 = match$5[0]; + +b("File \"bs_poly_map_test.res\", line 195, characters 4-11", match$5[1] === undefined); + +b("File \"bs_poly_map_test.res\", line 201, characters 4-11", Belt_Array.eq(Belt_Map.keysToArray(match$6[0]), Belt_Array.makeBy(5000, i => i), (prim0, prim1) => prim0 === prim1)); + +b("File \"bs_poly_map_test.res\", line 202, characters 4-11", Belt_Array.eq(Belt_Map.keysToArray(match$6[1]), Belt_Array.makeBy(5000, i => 5001 + i | 0), (prim0, prim1) => prim0 === prim1)); + +Mt.from_pair_suites("Bs_poly_map_test", suites.contents); + +let M; + +let N; + +let A; + +let I; + +export { + suites, + test_id, + eq, + b, + Icmp, + M, + N, + A, + I, + mapOfArray, + setOfArray, + emptyMap, + mergeInter, + mergeUnion, + mergeDiff, + randomRange, + acc, +} +/* Icmp Not a pure module */ diff --git a/tests/tests/src/bs_poly_mutable_map_test.js b/tests/tests/src/bs_poly_mutable_map_test.js deleted file mode 100644 index 1d716df63a..0000000000 --- a/tests/tests/src/bs_poly_mutable_map_test.js +++ /dev/null @@ -1,119 +0,0 @@ -// Generated by ReScript, PLEASE EDIT WITH CARE -'use strict'; - -let Mt = require("./mt.js"); -let Belt_Id = require("rescript/lib/js/Belt_Id.js"); -let Belt_Set = require("rescript/lib/js/Belt_Set.js"); -let Belt_Array = require("rescript/lib/js/Belt_Array.js"); -let Primitive_int = require("rescript/lib/js/Primitive_int.js"); -let Array_data_util = require("./array_data_util.js"); -let Belt_MutableMap = require("rescript/lib/js/Belt_MutableMap.js"); - -let suites = { - contents: /* [] */0 -}; - -let test_id = { - contents: 0 -}; - -function eq(loc, x, y) { - Mt.eq_suites(test_id, suites, loc, x, y); -} - -function b(loc, v) { - Mt.bool_suites(test_id, suites, loc, v); -} - -let Icmp = Belt_Id.comparable(Primitive_int.compare); - -function f(x) { - return Belt_MutableMap.fromArray(x, Icmp); -} - -function ff(x) { - return Belt_Set.fromArray(x, Icmp); -} - -function randomRange(i, j) { - return Belt_Array.map(Array_data_util.randomRange(i, j), x => [ - x, - x - ]); -} - -let a0 = Belt_MutableMap.fromArray(randomRange(0, 10), Icmp); - -Belt_MutableMap.set(a0, 3, 33); - -eq("File \"bs_poly_mutable_map_test.res\", line 27, characters 5-12", Belt_MutableMap.getExn(a0, 3), 33); - -Belt_MutableMap.removeMany(a0, [ - 7, - 8, - 0, - 1, - 3, - 2, - 4, - 922, - 4, - 5, - 6 -]); - -eq("File \"bs_poly_mutable_map_test.res\", line 29, characters 5-12", Belt_MutableMap.keysToArray(a0), [ - 9, - 10 -]); - -Belt_MutableMap.removeMany(a0, Array_data_util.randomRange(0, 100)); - -b("File \"bs_poly_mutable_map_test.res\", line 31, characters 4-11", Belt_MutableMap.isEmpty(a0)); - -let a0$1 = Belt_MutableMap.fromArray(randomRange(0, 10000), Icmp); - -Belt_MutableMap.set(a0$1, 2000, 33); - -Belt_MutableMap.removeMany(a0$1, Belt_Array.map(randomRange(0, 1998), prim => prim[0])); - -Belt_MutableMap.removeMany(a0$1, Belt_Array.map(randomRange(2002, 11000), prim => prim[0])); - -eq("File \"bs_poly_mutable_map_test.res\", line 39, characters 5-12", Belt_MutableMap.toArray(a0$1), [ - [ - 1999, - 1999 - ], - [ - 2000, - 33 - ], - [ - 2001, - 2001 - ] -]); - -Mt.from_pair_suites("Bs_poly_mutable_map_test", suites.contents); - -let M; - -let N; - -let A; - -let I; - -exports.suites = suites; -exports.test_id = test_id; -exports.eq = eq; -exports.b = b; -exports.Icmp = Icmp; -exports.M = M; -exports.N = N; -exports.A = A; -exports.I = I; -exports.f = f; -exports.ff = ff; -exports.randomRange = randomRange; -/* Icmp Not a pure module */ diff --git a/tests/tests/src/bs_poly_mutable_map_test.mjs b/tests/tests/src/bs_poly_mutable_map_test.mjs new file mode 100644 index 0000000000..0889bd339c --- /dev/null +++ b/tests/tests/src/bs_poly_mutable_map_test.mjs @@ -0,0 +1,120 @@ +// Generated by ReScript, PLEASE EDIT WITH CARE + +import * as Mt from "./mt.mjs"; +import * as Belt_Id from "rescript/lib/es6/Belt_Id.js"; +import * as Belt_Set from "rescript/lib/es6/Belt_Set.js"; +import * as Belt_Array from "rescript/lib/es6/Belt_Array.js"; +import * as Primitive_int from "rescript/lib/es6/Primitive_int.js"; +import * as Array_data_util from "./array_data_util.mjs"; +import * as Belt_MutableMap from "rescript/lib/es6/Belt_MutableMap.js"; + +let suites = { + contents: /* [] */0 +}; + +let test_id = { + contents: 0 +}; + +function eq(loc, x, y) { + Mt.eq_suites(test_id, suites, loc, x, y); +} + +function b(loc, v) { + Mt.bool_suites(test_id, suites, loc, v); +} + +let Icmp = Belt_Id.comparable(Primitive_int.compare); + +function f(x) { + return Belt_MutableMap.fromArray(x, Icmp); +} + +function ff(x) { + return Belt_Set.fromArray(x, Icmp); +} + +function randomRange(i, j) { + return Belt_Array.map(Array_data_util.randomRange(i, j), x => [ + x, + x + ]); +} + +let a0 = Belt_MutableMap.fromArray(randomRange(0, 10), Icmp); + +Belt_MutableMap.set(a0, 3, 33); + +eq("File \"bs_poly_mutable_map_test.res\", line 27, characters 5-12", Belt_MutableMap.getExn(a0, 3), 33); + +Belt_MutableMap.removeMany(a0, [ + 7, + 8, + 0, + 1, + 3, + 2, + 4, + 922, + 4, + 5, + 6 +]); + +eq("File \"bs_poly_mutable_map_test.res\", line 29, characters 5-12", Belt_MutableMap.keysToArray(a0), [ + 9, + 10 +]); + +Belt_MutableMap.removeMany(a0, Array_data_util.randomRange(0, 100)); + +b("File \"bs_poly_mutable_map_test.res\", line 31, characters 4-11", Belt_MutableMap.isEmpty(a0)); + +let a0$1 = Belt_MutableMap.fromArray(randomRange(0, 10000), Icmp); + +Belt_MutableMap.set(a0$1, 2000, 33); + +Belt_MutableMap.removeMany(a0$1, Belt_Array.map(randomRange(0, 1998), prim => prim[0])); + +Belt_MutableMap.removeMany(a0$1, Belt_Array.map(randomRange(2002, 11000), prim => prim[0])); + +eq("File \"bs_poly_mutable_map_test.res\", line 39, characters 5-12", Belt_MutableMap.toArray(a0$1), [ + [ + 1999, + 1999 + ], + [ + 2000, + 33 + ], + [ + 2001, + 2001 + ] +]); + +Mt.from_pair_suites("Bs_poly_mutable_map_test", suites.contents); + +let M; + +let N; + +let A; + +let I; + +export { + suites, + test_id, + eq, + b, + Icmp, + M, + N, + A, + I, + f, + ff, + randomRange, +} +/* Icmp Not a pure module */ diff --git a/tests/tests/src/bs_poly_mutable_set_test.js b/tests/tests/src/bs_poly_mutable_set_test.js deleted file mode 100644 index c227292fac..0000000000 --- a/tests/tests/src/bs_poly_mutable_set_test.js +++ /dev/null @@ -1,320 +0,0 @@ -// Generated by ReScript, PLEASE EDIT WITH CARE -'use strict'; - -let Mt = require("./mt.js"); -let Belt_Id = require("rescript/lib/js/Belt_Id.js"); -let Belt_List = require("rescript/lib/js/Belt_List.js"); -let Belt_Array = require("rescript/lib/js/Belt_Array.js"); -let Primitive_int = require("rescript/lib/js/Primitive_int.js"); -let Array_data_util = require("./array_data_util.js"); -let Belt_MutableSet = require("rescript/lib/js/Belt_MutableSet.js"); - -let suites = { - contents: /* [] */0 -}; - -let test_id = { - contents: 0 -}; - -function eq(loc, x, y) { - Mt.eq_suites(test_id, suites, loc, x, y); -} - -function b(loc, x) { - Mt.bool_suites(test_id, suites, loc, x); -} - -let IntCmp = Belt_Id.comparable(Primitive_int.compare); - -function fromArray(none) { - return Belt_MutableSet.fromArray(none, IntCmp); -} - -function empty() { - return Belt_MutableSet.make(IntCmp); -} - -let u = Belt_MutableSet.fromArray(Array_data_util.range(0, 30), IntCmp); - -b("File \"bs_poly_mutable_set_test.res\", line 16, characters 4-11", Belt_MutableSet.removeCheck(u, 0)); - -b("File \"bs_poly_mutable_set_test.res\", line 17, characters 4-11", !Belt_MutableSet.removeCheck(u, 0)); - -b("File \"bs_poly_mutable_set_test.res\", line 18, characters 4-11", Belt_MutableSet.removeCheck(u, 30)); - -b("File \"bs_poly_mutable_set_test.res\", line 19, characters 4-11", Belt_MutableSet.removeCheck(u, 20)); - -eq("File \"bs_poly_mutable_set_test.res\", line 20, characters 5-12", Belt_MutableSet.size(u), 28); - -let r = Array_data_util.randomRange(0, 30); - -b("File \"bs_poly_mutable_set_test.res\", line 22, characters 4-11", 29 === Belt_MutableSet.maxUndefined(u)); - -b("File \"bs_poly_mutable_set_test.res\", line 23, characters 4-11", 1 === Belt_MutableSet.minUndefined(u)); - -Belt_MutableSet.add(u, 3); - -for (let i = 0, i_finish = r.length; i < i_finish; ++i) { - Belt_MutableSet.remove(u, r[i]); -} - -b("File \"bs_poly_mutable_set_test.res\", line 28, characters 4-11", Belt_MutableSet.isEmpty(u)); - -Belt_MutableSet.add(u, 0); - -Belt_MutableSet.add(u, 1); - -Belt_MutableSet.add(u, 2); - -Belt_MutableSet.add(u, 0); - -eq("File \"bs_poly_mutable_set_test.res\", line 33, characters 5-12", Belt_MutableSet.size(u), 3); - -b("File \"bs_poly_mutable_set_test.res\", line 34, characters 4-11", !Belt_MutableSet.isEmpty(u)); - -for (let i$1 = 0; i$1 <= 3; ++i$1) { - Belt_MutableSet.remove(u, i$1); -} - -b("File \"bs_poly_mutable_set_test.res\", line 38, characters 4-11", Belt_MutableSet.isEmpty(u)); - -Belt_MutableSet.mergeMany(u, Array_data_util.randomRange(0, 20000)); - -Belt_MutableSet.mergeMany(u, Array_data_util.randomRange(0, 200)); - -eq("File \"bs_poly_mutable_set_test.res\", line 41, characters 5-12", Belt_MutableSet.size(u), 20001); - -Belt_MutableSet.removeMany(u, Array_data_util.randomRange(0, 200)); - -eq("File \"bs_poly_mutable_set_test.res\", line 43, characters 5-12", Belt_MutableSet.size(u), 19800); - -Belt_MutableSet.removeMany(u, Array_data_util.randomRange(0, 1000)); - -eq("File \"bs_poly_mutable_set_test.res\", line 45, characters 5-12", Belt_MutableSet.size(u), 19000); - -Belt_MutableSet.removeMany(u, Array_data_util.randomRange(0, 1000)); - -eq("File \"bs_poly_mutable_set_test.res\", line 47, characters 5-12", Belt_MutableSet.size(u), 19000); - -Belt_MutableSet.removeMany(u, Array_data_util.randomRange(1000, 10000)); - -eq("File \"bs_poly_mutable_set_test.res\", line 49, characters 5-12", Belt_MutableSet.size(u), 10000); - -Belt_MutableSet.removeMany(u, Array_data_util.randomRange(10000, 19999)); - -eq("File \"bs_poly_mutable_set_test.res\", line 51, characters 5-12", Belt_MutableSet.size(u), 1); - -b("File \"bs_poly_mutable_set_test.res\", line 52, characters 4-11", Belt_MutableSet.has(u, 20000)); - -Belt_MutableSet.removeMany(u, Array_data_util.randomRange(10000, 30000)); - -b("File \"bs_poly_mutable_set_test.res\", line 54, characters 4-11", Belt_MutableSet.isEmpty(u)); - -let v = Belt_MutableSet.fromArray(Array_data_util.randomRange(1000, 2000), IntCmp); - -let bs = Belt_Array.map(Array_data_util.randomRange(500, 1499), x => Belt_MutableSet.removeCheck(v, x)); - -let indeedRemoved = Belt_Array.reduce(bs, 0, (acc, x) => { - if (x) { - return acc + 1 | 0; - } else { - return acc; - } -}); - -eq("File \"bs_poly_mutable_set_test.res\", line 67, characters 5-12", indeedRemoved, 500); - -eq("File \"bs_poly_mutable_set_test.res\", line 68, characters 5-12", Belt_MutableSet.size(v), 501); - -let cs = Belt_Array.map(Array_data_util.randomRange(500, 2000), x => Belt_MutableSet.addCheck(v, x)); - -let indeedAded = Belt_Array.reduce(cs, 0, (acc, x) => { - if (x) { - return acc + 1 | 0; - } else { - return acc; - } -}); - -eq("File \"bs_poly_mutable_set_test.res\", line 77, characters 5-12", indeedAded, 1000); - -eq("File \"bs_poly_mutable_set_test.res\", line 78, characters 5-12", Belt_MutableSet.size(v), 1501); - -b("File \"bs_poly_mutable_set_test.res\", line 79, characters 4-11", Belt_MutableSet.isEmpty(Belt_MutableSet.make(IntCmp))); - -eq("File \"bs_poly_mutable_set_test.res\", line 80, characters 5-12", Belt_MutableSet.minimum(v), 500); - -eq("File \"bs_poly_mutable_set_test.res\", line 81, characters 5-12", Belt_MutableSet.maximum(v), 2000); - -eq("File \"bs_poly_mutable_set_test.res\", line 82, characters 5-12", Belt_MutableSet.minUndefined(v), 500); - -eq("File \"bs_poly_mutable_set_test.res\", line 83, characters 5-12", Belt_MutableSet.maxUndefined(v), 2000); - -eq("File \"bs_poly_mutable_set_test.res\", line 84, characters 5-12", Belt_MutableSet.reduce(v, 0, (x, y) => x + y | 0), 1876250); - -b("File \"bs_poly_mutable_set_test.res\", line 85, characters 4-11", Belt_List.eq(Belt_MutableSet.toList(v), Belt_List.makeBy(1501, i => i + 500 | 0), (x, y) => x === y)); - -eq("File \"bs_poly_mutable_set_test.res\", line 86, characters 5-12", Belt_MutableSet.toArray(v), Array_data_util.range(500, 2000)); - -Belt_MutableSet.checkInvariantInternal(v); - -eq("File \"bs_poly_mutable_set_test.res\", line 88, characters 5-12", Belt_MutableSet.get(v, 3), undefined); - -eq("File \"bs_poly_mutable_set_test.res\", line 89, characters 5-12", Belt_MutableSet.get(v, 1200), 1200); - -let match = Belt_MutableSet.split(v, 1000); - -let match$1 = match[0]; - -let bb = match$1[1]; - -let aa = match$1[0]; - -b("File \"bs_poly_mutable_set_test.res\", line 91, characters 4-11", match[1]); - -b("File \"bs_poly_mutable_set_test.res\", line 92, characters 4-11", Belt_Array.eq(Belt_MutableSet.toArray(aa), Array_data_util.range(500, 999), (prim0, prim1) => prim0 === prim1)); - -b("File \"bs_poly_mutable_set_test.res\", line 93, characters 4-11", Belt_Array.eq(Belt_MutableSet.toArray(bb), Array_data_util.range(1001, 2000), (prim0, prim1) => prim0 === prim1)); - -b("File \"bs_poly_mutable_set_test.res\", line 94, characters 4-11", Belt_MutableSet.subset(aa, v)); - -b("File \"bs_poly_mutable_set_test.res\", line 95, characters 4-11", Belt_MutableSet.subset(bb, v)); - -b("File \"bs_poly_mutable_set_test.res\", line 96, characters 4-11", Belt_MutableSet.isEmpty(Belt_MutableSet.intersect(aa, bb))); - -let c = Belt_MutableSet.removeCheck(v, 1000); - -b("File \"bs_poly_mutable_set_test.res\", line 98, characters 4-11", c); - -let match$2 = Belt_MutableSet.split(v, 1000); - -let match$3 = match$2[0]; - -let bb$1 = match$3[1]; - -let aa$1 = match$3[0]; - -b("File \"bs_poly_mutable_set_test.res\", line 100, characters 4-11", !match$2[1]); - -b("File \"bs_poly_mutable_set_test.res\", line 101, characters 4-11", Belt_Array.eq(Belt_MutableSet.toArray(aa$1), Array_data_util.range(500, 999), (prim0, prim1) => prim0 === prim1)); - -b("File \"bs_poly_mutable_set_test.res\", line 102, characters 4-11", Belt_Array.eq(Belt_MutableSet.toArray(bb$1), Array_data_util.range(1001, 2000), (prim0, prim1) => prim0 === prim1)); - -b("File \"bs_poly_mutable_set_test.res\", line 103, characters 4-11", Belt_MutableSet.subset(aa$1, v)); - -b("File \"bs_poly_mutable_set_test.res\", line 104, characters 4-11", Belt_MutableSet.subset(bb$1, v)); - -b("File \"bs_poly_mutable_set_test.res\", line 105, characters 4-11", Belt_MutableSet.isEmpty(Belt_MutableSet.intersect(aa$1, bb$1))); - -let aa$2 = Belt_MutableSet.fromArray(Array_data_util.randomRange(0, 100), IntCmp); - -let bb$2 = Belt_MutableSet.fromArray(Array_data_util.randomRange(40, 120), IntCmp); - -let cc = Belt_MutableSet.union(aa$2, bb$2); - -b("File \"bs_poly_mutable_set_test.res\", line 115, characters 4-11", Belt_MutableSet.eq(cc, Belt_MutableSet.fromArray(Array_data_util.randomRange(0, 120), IntCmp))); - -b("File \"bs_poly_mutable_set_test.res\", line 118, characters 4-11", Belt_MutableSet.eq(Belt_MutableSet.union(Belt_MutableSet.fromArray(Array_data_util.randomRange(0, 20), IntCmp), Belt_MutableSet.fromArray(Array_data_util.randomRange(21, 40), IntCmp)), Belt_MutableSet.fromArray(Array_data_util.randomRange(0, 40), IntCmp))); - -let dd = Belt_MutableSet.intersect(aa$2, bb$2); - -b("File \"bs_poly_mutable_set_test.res\", line 122, characters 4-11", Belt_MutableSet.eq(dd, Belt_MutableSet.fromArray(Array_data_util.randomRange(40, 100), IntCmp))); - -b("File \"bs_poly_mutable_set_test.res\", line 124, characters 4-11", Belt_MutableSet.eq(Belt_MutableSet.intersect(Belt_MutableSet.fromArray(Array_data_util.randomRange(0, 20), IntCmp), Belt_MutableSet.fromArray(Array_data_util.randomRange(21, 40), IntCmp)), Belt_MutableSet.make(IntCmp))); - -b("File \"bs_poly_mutable_set_test.res\", line 128, characters 4-11", Belt_MutableSet.eq(Belt_MutableSet.intersect(Belt_MutableSet.fromArray(Array_data_util.randomRange(21, 40), IntCmp), Belt_MutableSet.fromArray(Array_data_util.randomRange(0, 20), IntCmp)), Belt_MutableSet.make(IntCmp))); - -b("File \"bs_poly_mutable_set_test.res\", line 131, characters 4-11", Belt_MutableSet.eq(Belt_MutableSet.intersect(Belt_MutableSet.fromArray([ - 1, - 3, - 4, - 5, - 7, - 9 -], IntCmp), Belt_MutableSet.fromArray([ - 2, - 4, - 5, - 6, - 8, - 10 -], IntCmp)), Belt_MutableSet.fromArray([ - 4, - 5 -], IntCmp))); - -b("File \"bs_poly_mutable_set_test.res\", line 132, characters 4-11", Belt_MutableSet.eq(Belt_MutableSet.diff(aa$2, bb$2), Belt_MutableSet.fromArray(Array_data_util.randomRange(0, 39), IntCmp))); - -b("File \"bs_poly_mutable_set_test.res\", line 133, characters 4-11", Belt_MutableSet.eq(Belt_MutableSet.diff(bb$2, aa$2), Belt_MutableSet.fromArray(Array_data_util.randomRange(101, 120), IntCmp))); - -b("File \"bs_poly_mutable_set_test.res\", line 135, characters 4-11", Belt_MutableSet.eq(Belt_MutableSet.diff(Belt_MutableSet.fromArray(Array_data_util.randomRange(21, 40), IntCmp), Belt_MutableSet.fromArray(Array_data_util.randomRange(0, 20), IntCmp)), Belt_MutableSet.fromArray(Array_data_util.randomRange(21, 40), IntCmp))); - -b("File \"bs_poly_mutable_set_test.res\", line 142, characters 4-11", Belt_MutableSet.eq(Belt_MutableSet.diff(Belt_MutableSet.fromArray(Array_data_util.randomRange(0, 20), IntCmp), Belt_MutableSet.fromArray(Array_data_util.randomRange(21, 40), IntCmp)), Belt_MutableSet.fromArray(Array_data_util.randomRange(0, 20), IntCmp))); - -b("File \"bs_poly_mutable_set_test.res\", line 150, characters 4-11", Belt_MutableSet.eq(Belt_MutableSet.diff(Belt_MutableSet.fromArray(Array_data_util.randomRange(0, 20), IntCmp), Belt_MutableSet.fromArray(Array_data_util.randomRange(0, 40), IntCmp)), Belt_MutableSet.fromArray(Array_data_util.randomRange(0, -1), IntCmp))); - -let a0 = Belt_MutableSet.fromArray(Array_data_util.randomRange(0, 1000), IntCmp); - -let a1 = Belt_MutableSet.keep(a0, x => x % 2 === 0); - -let a2 = Belt_MutableSet.keep(a0, x => x % 2 !== 0); - -let match$4 = Belt_MutableSet.partition(a0, x => x % 2 === 0); - -let a4 = match$4[1]; - -let a3 = match$4[0]; - -b("File \"bs_poly_mutable_set_test.res\", line 162, characters 4-11", Belt_MutableSet.eq(a1, a3)); - -b("File \"bs_poly_mutable_set_test.res\", line 163, characters 4-11", Belt_MutableSet.eq(a2, a4)); - -Belt_List.forEach({ - hd: a0, - tl: { - hd: a1, - tl: { - hd: a2, - tl: { - hd: a3, - tl: { - hd: a4, - tl: /* [] */0 - } - } - } - } -}, Belt_MutableSet.checkInvariantInternal); - -Mt.from_pair_suites("Bs_poly_mutable_set_test", suites.contents); - -let N; - -let I; - -let A; - -let L; - -let $plus$plus = Belt_MutableSet.union; - -let f = fromArray; - -let $eq$tilde = Belt_MutableSet.eq; - -exports.suites = suites; -exports.test_id = test_id; -exports.eq = eq; -exports.b = b; -exports.N = N; -exports.I = I; -exports.A = A; -exports.IntCmp = IntCmp; -exports.L = L; -exports.fromArray = fromArray; -exports.empty = empty; -exports.$plus$plus = $plus$plus; -exports.f = f; -exports.$eq$tilde = $eq$tilde; -/* IntCmp Not a pure module */ diff --git a/tests/tests/src/bs_poly_mutable_set_test.mjs b/tests/tests/src/bs_poly_mutable_set_test.mjs new file mode 100644 index 0000000000..4b5d186f68 --- /dev/null +++ b/tests/tests/src/bs_poly_mutable_set_test.mjs @@ -0,0 +1,321 @@ +// Generated by ReScript, PLEASE EDIT WITH CARE + +import * as Mt from "./mt.mjs"; +import * as Belt_Id from "rescript/lib/es6/Belt_Id.js"; +import * as Belt_List from "rescript/lib/es6/Belt_List.js"; +import * as Belt_Array from "rescript/lib/es6/Belt_Array.js"; +import * as Primitive_int from "rescript/lib/es6/Primitive_int.js"; +import * as Array_data_util from "./array_data_util.mjs"; +import * as Belt_MutableSet from "rescript/lib/es6/Belt_MutableSet.js"; + +let suites = { + contents: /* [] */0 +}; + +let test_id = { + contents: 0 +}; + +function eq(loc, x, y) { + Mt.eq_suites(test_id, suites, loc, x, y); +} + +function b(loc, x) { + Mt.bool_suites(test_id, suites, loc, x); +} + +let IntCmp = Belt_Id.comparable(Primitive_int.compare); + +function fromArray(none) { + return Belt_MutableSet.fromArray(none, IntCmp); +} + +function empty() { + return Belt_MutableSet.make(IntCmp); +} + +let u = Belt_MutableSet.fromArray(Array_data_util.range(0, 30), IntCmp); + +b("File \"bs_poly_mutable_set_test.res\", line 16, characters 4-11", Belt_MutableSet.removeCheck(u, 0)); + +b("File \"bs_poly_mutable_set_test.res\", line 17, characters 4-11", !Belt_MutableSet.removeCheck(u, 0)); + +b("File \"bs_poly_mutable_set_test.res\", line 18, characters 4-11", Belt_MutableSet.removeCheck(u, 30)); + +b("File \"bs_poly_mutable_set_test.res\", line 19, characters 4-11", Belt_MutableSet.removeCheck(u, 20)); + +eq("File \"bs_poly_mutable_set_test.res\", line 20, characters 5-12", Belt_MutableSet.size(u), 28); + +let r = Array_data_util.randomRange(0, 30); + +b("File \"bs_poly_mutable_set_test.res\", line 22, characters 4-11", 29 === Belt_MutableSet.maxUndefined(u)); + +b("File \"bs_poly_mutable_set_test.res\", line 23, characters 4-11", 1 === Belt_MutableSet.minUndefined(u)); + +Belt_MutableSet.add(u, 3); + +for (let i = 0, i_finish = r.length; i < i_finish; ++i) { + Belt_MutableSet.remove(u, r[i]); +} + +b("File \"bs_poly_mutable_set_test.res\", line 28, characters 4-11", Belt_MutableSet.isEmpty(u)); + +Belt_MutableSet.add(u, 0); + +Belt_MutableSet.add(u, 1); + +Belt_MutableSet.add(u, 2); + +Belt_MutableSet.add(u, 0); + +eq("File \"bs_poly_mutable_set_test.res\", line 33, characters 5-12", Belt_MutableSet.size(u), 3); + +b("File \"bs_poly_mutable_set_test.res\", line 34, characters 4-11", !Belt_MutableSet.isEmpty(u)); + +for (let i$1 = 0; i$1 <= 3; ++i$1) { + Belt_MutableSet.remove(u, i$1); +} + +b("File \"bs_poly_mutable_set_test.res\", line 38, characters 4-11", Belt_MutableSet.isEmpty(u)); + +Belt_MutableSet.mergeMany(u, Array_data_util.randomRange(0, 20000)); + +Belt_MutableSet.mergeMany(u, Array_data_util.randomRange(0, 200)); + +eq("File \"bs_poly_mutable_set_test.res\", line 41, characters 5-12", Belt_MutableSet.size(u), 20001); + +Belt_MutableSet.removeMany(u, Array_data_util.randomRange(0, 200)); + +eq("File \"bs_poly_mutable_set_test.res\", line 43, characters 5-12", Belt_MutableSet.size(u), 19800); + +Belt_MutableSet.removeMany(u, Array_data_util.randomRange(0, 1000)); + +eq("File \"bs_poly_mutable_set_test.res\", line 45, characters 5-12", Belt_MutableSet.size(u), 19000); + +Belt_MutableSet.removeMany(u, Array_data_util.randomRange(0, 1000)); + +eq("File \"bs_poly_mutable_set_test.res\", line 47, characters 5-12", Belt_MutableSet.size(u), 19000); + +Belt_MutableSet.removeMany(u, Array_data_util.randomRange(1000, 10000)); + +eq("File \"bs_poly_mutable_set_test.res\", line 49, characters 5-12", Belt_MutableSet.size(u), 10000); + +Belt_MutableSet.removeMany(u, Array_data_util.randomRange(10000, 19999)); + +eq("File \"bs_poly_mutable_set_test.res\", line 51, characters 5-12", Belt_MutableSet.size(u), 1); + +b("File \"bs_poly_mutable_set_test.res\", line 52, characters 4-11", Belt_MutableSet.has(u, 20000)); + +Belt_MutableSet.removeMany(u, Array_data_util.randomRange(10000, 30000)); + +b("File \"bs_poly_mutable_set_test.res\", line 54, characters 4-11", Belt_MutableSet.isEmpty(u)); + +let v = Belt_MutableSet.fromArray(Array_data_util.randomRange(1000, 2000), IntCmp); + +let bs = Belt_Array.map(Array_data_util.randomRange(500, 1499), x => Belt_MutableSet.removeCheck(v, x)); + +let indeedRemoved = Belt_Array.reduce(bs, 0, (acc, x) => { + if (x) { + return acc + 1 | 0; + } else { + return acc; + } +}); + +eq("File \"bs_poly_mutable_set_test.res\", line 67, characters 5-12", indeedRemoved, 500); + +eq("File \"bs_poly_mutable_set_test.res\", line 68, characters 5-12", Belt_MutableSet.size(v), 501); + +let cs = Belt_Array.map(Array_data_util.randomRange(500, 2000), x => Belt_MutableSet.addCheck(v, x)); + +let indeedAded = Belt_Array.reduce(cs, 0, (acc, x) => { + if (x) { + return acc + 1 | 0; + } else { + return acc; + } +}); + +eq("File \"bs_poly_mutable_set_test.res\", line 77, characters 5-12", indeedAded, 1000); + +eq("File \"bs_poly_mutable_set_test.res\", line 78, characters 5-12", Belt_MutableSet.size(v), 1501); + +b("File \"bs_poly_mutable_set_test.res\", line 79, characters 4-11", Belt_MutableSet.isEmpty(Belt_MutableSet.make(IntCmp))); + +eq("File \"bs_poly_mutable_set_test.res\", line 80, characters 5-12", Belt_MutableSet.minimum(v), 500); + +eq("File \"bs_poly_mutable_set_test.res\", line 81, characters 5-12", Belt_MutableSet.maximum(v), 2000); + +eq("File \"bs_poly_mutable_set_test.res\", line 82, characters 5-12", Belt_MutableSet.minUndefined(v), 500); + +eq("File \"bs_poly_mutable_set_test.res\", line 83, characters 5-12", Belt_MutableSet.maxUndefined(v), 2000); + +eq("File \"bs_poly_mutable_set_test.res\", line 84, characters 5-12", Belt_MutableSet.reduce(v, 0, (x, y) => x + y | 0), 1876250); + +b("File \"bs_poly_mutable_set_test.res\", line 85, characters 4-11", Belt_List.eq(Belt_MutableSet.toList(v), Belt_List.makeBy(1501, i => i + 500 | 0), (x, y) => x === y)); + +eq("File \"bs_poly_mutable_set_test.res\", line 86, characters 5-12", Belt_MutableSet.toArray(v), Array_data_util.range(500, 2000)); + +Belt_MutableSet.checkInvariantInternal(v); + +eq("File \"bs_poly_mutable_set_test.res\", line 88, characters 5-12", Belt_MutableSet.get(v, 3), undefined); + +eq("File \"bs_poly_mutable_set_test.res\", line 89, characters 5-12", Belt_MutableSet.get(v, 1200), 1200); + +let match = Belt_MutableSet.split(v, 1000); + +let match$1 = match[0]; + +let bb = match$1[1]; + +let aa = match$1[0]; + +b("File \"bs_poly_mutable_set_test.res\", line 91, characters 4-11", match[1]); + +b("File \"bs_poly_mutable_set_test.res\", line 92, characters 4-11", Belt_Array.eq(Belt_MutableSet.toArray(aa), Array_data_util.range(500, 999), (prim0, prim1) => prim0 === prim1)); + +b("File \"bs_poly_mutable_set_test.res\", line 93, characters 4-11", Belt_Array.eq(Belt_MutableSet.toArray(bb), Array_data_util.range(1001, 2000), (prim0, prim1) => prim0 === prim1)); + +b("File \"bs_poly_mutable_set_test.res\", line 94, characters 4-11", Belt_MutableSet.subset(aa, v)); + +b("File \"bs_poly_mutable_set_test.res\", line 95, characters 4-11", Belt_MutableSet.subset(bb, v)); + +b("File \"bs_poly_mutable_set_test.res\", line 96, characters 4-11", Belt_MutableSet.isEmpty(Belt_MutableSet.intersect(aa, bb))); + +let c = Belt_MutableSet.removeCheck(v, 1000); + +b("File \"bs_poly_mutable_set_test.res\", line 98, characters 4-11", c); + +let match$2 = Belt_MutableSet.split(v, 1000); + +let match$3 = match$2[0]; + +let bb$1 = match$3[1]; + +let aa$1 = match$3[0]; + +b("File \"bs_poly_mutable_set_test.res\", line 100, characters 4-11", !match$2[1]); + +b("File \"bs_poly_mutable_set_test.res\", line 101, characters 4-11", Belt_Array.eq(Belt_MutableSet.toArray(aa$1), Array_data_util.range(500, 999), (prim0, prim1) => prim0 === prim1)); + +b("File \"bs_poly_mutable_set_test.res\", line 102, characters 4-11", Belt_Array.eq(Belt_MutableSet.toArray(bb$1), Array_data_util.range(1001, 2000), (prim0, prim1) => prim0 === prim1)); + +b("File \"bs_poly_mutable_set_test.res\", line 103, characters 4-11", Belt_MutableSet.subset(aa$1, v)); + +b("File \"bs_poly_mutable_set_test.res\", line 104, characters 4-11", Belt_MutableSet.subset(bb$1, v)); + +b("File \"bs_poly_mutable_set_test.res\", line 105, characters 4-11", Belt_MutableSet.isEmpty(Belt_MutableSet.intersect(aa$1, bb$1))); + +let aa$2 = Belt_MutableSet.fromArray(Array_data_util.randomRange(0, 100), IntCmp); + +let bb$2 = Belt_MutableSet.fromArray(Array_data_util.randomRange(40, 120), IntCmp); + +let cc = Belt_MutableSet.union(aa$2, bb$2); + +b("File \"bs_poly_mutable_set_test.res\", line 115, characters 4-11", Belt_MutableSet.eq(cc, Belt_MutableSet.fromArray(Array_data_util.randomRange(0, 120), IntCmp))); + +b("File \"bs_poly_mutable_set_test.res\", line 118, characters 4-11", Belt_MutableSet.eq(Belt_MutableSet.union(Belt_MutableSet.fromArray(Array_data_util.randomRange(0, 20), IntCmp), Belt_MutableSet.fromArray(Array_data_util.randomRange(21, 40), IntCmp)), Belt_MutableSet.fromArray(Array_data_util.randomRange(0, 40), IntCmp))); + +let dd = Belt_MutableSet.intersect(aa$2, bb$2); + +b("File \"bs_poly_mutable_set_test.res\", line 122, characters 4-11", Belt_MutableSet.eq(dd, Belt_MutableSet.fromArray(Array_data_util.randomRange(40, 100), IntCmp))); + +b("File \"bs_poly_mutable_set_test.res\", line 124, characters 4-11", Belt_MutableSet.eq(Belt_MutableSet.intersect(Belt_MutableSet.fromArray(Array_data_util.randomRange(0, 20), IntCmp), Belt_MutableSet.fromArray(Array_data_util.randomRange(21, 40), IntCmp)), Belt_MutableSet.make(IntCmp))); + +b("File \"bs_poly_mutable_set_test.res\", line 128, characters 4-11", Belt_MutableSet.eq(Belt_MutableSet.intersect(Belt_MutableSet.fromArray(Array_data_util.randomRange(21, 40), IntCmp), Belt_MutableSet.fromArray(Array_data_util.randomRange(0, 20), IntCmp)), Belt_MutableSet.make(IntCmp))); + +b("File \"bs_poly_mutable_set_test.res\", line 131, characters 4-11", Belt_MutableSet.eq(Belt_MutableSet.intersect(Belt_MutableSet.fromArray([ + 1, + 3, + 4, + 5, + 7, + 9 +], IntCmp), Belt_MutableSet.fromArray([ + 2, + 4, + 5, + 6, + 8, + 10 +], IntCmp)), Belt_MutableSet.fromArray([ + 4, + 5 +], IntCmp))); + +b("File \"bs_poly_mutable_set_test.res\", line 132, characters 4-11", Belt_MutableSet.eq(Belt_MutableSet.diff(aa$2, bb$2), Belt_MutableSet.fromArray(Array_data_util.randomRange(0, 39), IntCmp))); + +b("File \"bs_poly_mutable_set_test.res\", line 133, characters 4-11", Belt_MutableSet.eq(Belt_MutableSet.diff(bb$2, aa$2), Belt_MutableSet.fromArray(Array_data_util.randomRange(101, 120), IntCmp))); + +b("File \"bs_poly_mutable_set_test.res\", line 135, characters 4-11", Belt_MutableSet.eq(Belt_MutableSet.diff(Belt_MutableSet.fromArray(Array_data_util.randomRange(21, 40), IntCmp), Belt_MutableSet.fromArray(Array_data_util.randomRange(0, 20), IntCmp)), Belt_MutableSet.fromArray(Array_data_util.randomRange(21, 40), IntCmp))); + +b("File \"bs_poly_mutable_set_test.res\", line 142, characters 4-11", Belt_MutableSet.eq(Belt_MutableSet.diff(Belt_MutableSet.fromArray(Array_data_util.randomRange(0, 20), IntCmp), Belt_MutableSet.fromArray(Array_data_util.randomRange(21, 40), IntCmp)), Belt_MutableSet.fromArray(Array_data_util.randomRange(0, 20), IntCmp))); + +b("File \"bs_poly_mutable_set_test.res\", line 150, characters 4-11", Belt_MutableSet.eq(Belt_MutableSet.diff(Belt_MutableSet.fromArray(Array_data_util.randomRange(0, 20), IntCmp), Belt_MutableSet.fromArray(Array_data_util.randomRange(0, 40), IntCmp)), Belt_MutableSet.fromArray(Array_data_util.randomRange(0, -1), IntCmp))); + +let a0 = Belt_MutableSet.fromArray(Array_data_util.randomRange(0, 1000), IntCmp); + +let a1 = Belt_MutableSet.keep(a0, x => x % 2 === 0); + +let a2 = Belt_MutableSet.keep(a0, x => x % 2 !== 0); + +let match$4 = Belt_MutableSet.partition(a0, x => x % 2 === 0); + +let a4 = match$4[1]; + +let a3 = match$4[0]; + +b("File \"bs_poly_mutable_set_test.res\", line 162, characters 4-11", Belt_MutableSet.eq(a1, a3)); + +b("File \"bs_poly_mutable_set_test.res\", line 163, characters 4-11", Belt_MutableSet.eq(a2, a4)); + +Belt_List.forEach({ + hd: a0, + tl: { + hd: a1, + tl: { + hd: a2, + tl: { + hd: a3, + tl: { + hd: a4, + tl: /* [] */0 + } + } + } + } +}, Belt_MutableSet.checkInvariantInternal); + +Mt.from_pair_suites("Bs_poly_mutable_set_test", suites.contents); + +let N; + +let I; + +let A; + +let L; + +let $plus$plus = Belt_MutableSet.union; + +let f = fromArray; + +let $eq$tilde = Belt_MutableSet.eq; + +export { + suites, + test_id, + eq, + b, + N, + I, + A, + IntCmp, + L, + fromArray, + empty, + $plus$plus, + f, + $eq$tilde, +} +/* IntCmp Not a pure module */ diff --git a/tests/tests/src/bs_poly_set_test.js b/tests/tests/src/bs_poly_set_test.js deleted file mode 100644 index aec7fd3860..0000000000 --- a/tests/tests/src/bs_poly_set_test.js +++ /dev/null @@ -1,372 +0,0 @@ -// Generated by ReScript, PLEASE EDIT WITH CARE -'use strict'; - -let Mt = require("./mt.js"); -let Belt_Id = require("rescript/lib/js/Belt_Id.js"); -let Belt_Set = require("rescript/lib/js/Belt_Set.js"); -let Belt_List = require("rescript/lib/js/Belt_List.js"); -let Belt_Array = require("rescript/lib/js/Belt_Array.js"); -let Belt_SetDict = require("rescript/lib/js/Belt_SetDict.js"); -let Primitive_int = require("rescript/lib/js/Primitive_int.js"); -let Belt_SortArray = require("rescript/lib/js/Belt_SortArray.js"); -let Array_data_util = require("./array_data_util.js"); -let Primitive_object = require("rescript/lib/js/Primitive_object.js"); - -let suites = { - contents: /* [] */0 -}; - -let test_id = { - contents: 0 -}; - -function eq(loc, x, y) { - Mt.eq_suites(test_id, suites, loc, x, y); -} - -function b(loc, x) { - Mt.bool_suites(test_id, suites, loc, x); -} - -function t(loc, x) { - Mt.throw_suites(test_id, suites, loc, x); -} - -let IntCmp = Belt_Id.comparable(Primitive_int.compare); - -let u0 = Belt_Set.fromArray(Array_data_util.range(0, 30), IntCmp); - -let u1 = Belt_Set.remove(u0, 0); - -let u2 = Belt_Set.remove(u1, 0); - -let u3 = Belt_Set.remove(u2, 30); - -let u4 = Belt_Set.remove(u3, 20); - -let r = Array_data_util.randomRange(0, 30); - -let u5 = Belt_Set.add(u4, 3); - -let u6 = Belt_Set.removeMany(u5, r); - -let u7 = Belt_Set.mergeMany(u6, [ - 0, - 1, - 2, - 0 -]); - -let u8 = Belt_Set.removeMany(u7, [ - 0, - 1, - 2, - 3 -]); - -let u9 = Belt_Set.mergeMany(u8, Array_data_util.randomRange(0, 20000)); - -let u10 = Belt_Set.mergeMany(u9, Array_data_util.randomRange(0, 200)); - -let u11 = Belt_Set.removeMany(u10, Array_data_util.randomRange(0, 200)); - -let u12 = Belt_Set.removeMany(u11, Array_data_util.randomRange(0, 1000)); - -let u13 = Belt_Set.removeMany(u12, Array_data_util.randomRange(0, 1000)); - -let u14 = Belt_Set.removeMany(u13, Array_data_util.randomRange(1000, 10000)); - -let u15 = Belt_Set.removeMany(u14, Array_data_util.randomRange(10000, 19999)); - -let u16 = Belt_Set.removeMany(u15, Array_data_util.randomRange(20000, 21000)); - -b("File \"bs_poly_set_test.res\", line 34, characters 4-11", u0 !== u1); - -b("File \"bs_poly_set_test.res\", line 35, characters 4-11", u2 === u1); - -eq("File \"bs_poly_set_test.res\", line 36, characters 5-12", Belt_Set.size(u4), 28); - -b("File \"bs_poly_set_test.res\", line 37, characters 4-11", 29 === Belt_Set.maxUndefined(u4)); - -b("File \"bs_poly_set_test.res\", line 38, characters 4-11", 1 === Belt_Set.minUndefined(u4)); - -b("File \"bs_poly_set_test.res\", line 39, characters 4-11", u4 === u5); - -b("File \"bs_poly_set_test.res\", line 40, characters 4-11", Belt_Set.isEmpty(u6)); - -eq("File \"bs_poly_set_test.res\", line 41, characters 5-12", Belt_Set.size(u7), 3); - -b("File \"bs_poly_set_test.res\", line 42, characters 4-11", !Belt_Set.isEmpty(u7)); - -b("File \"bs_poly_set_test.res\", line 43, characters 4-11", Belt_Set.isEmpty(u8)); - -b("File \"bs_poly_set_test.res\", line 46, characters 4-11", Belt_Set.has(u10, 20)); - -b("File \"bs_poly_set_test.res\", line 47, characters 4-11", Belt_Set.has(u10, 21)); - -eq("File \"bs_poly_set_test.res\", line 48, characters 5-12", Belt_Set.size(u10), 20001); - -eq("File \"bs_poly_set_test.res\", line 49, characters 5-12", Belt_Set.size(u11), 19800); - -eq("File \"bs_poly_set_test.res\", line 50, characters 5-12", Belt_Set.size(u12), 19000); - -eq("File \"bs_poly_set_test.res\", line 52, characters 5-12", Belt_Set.size(u13), Belt_Set.size(u12)); - -eq("File \"bs_poly_set_test.res\", line 53, characters 5-12", Belt_Set.size(u14), 10000); - -eq("File \"bs_poly_set_test.res\", line 54, characters 5-12", Belt_Set.size(u15), 1); - -b("File \"bs_poly_set_test.res\", line 55, characters 4-11", Belt_Set.has(u15, 20000)); - -b("File \"bs_poly_set_test.res\", line 56, characters 4-11", !Belt_Set.has(u15, 2000)); - -b("File \"bs_poly_set_test.res\", line 57, characters 4-11", Belt_Set.isEmpty(u16)); - -let u17 = Belt_Set.fromArray(Array_data_util.randomRange(0, 100), IntCmp); - -let u18 = Belt_Set.fromArray(Array_data_util.randomRange(59, 200), IntCmp); - -let u19 = Belt_Set.union(u17, u18); - -let u20 = Belt_Set.fromArray(Array_data_util.randomRange(0, 200), IntCmp); - -let u21 = Belt_Set.intersect(u17, u18); - -let u22 = Belt_Set.diff(u17, u18); - -let u23 = Belt_Set.diff(u18, u17); - -let u24 = Belt_Set.union(u18, u17); - -let u25 = Belt_Set.add(u22, 59); - -let u26 = Belt_Set.add(Belt_Set.make(IntCmp), 3); - -let ss = Belt_Array.makeByAndShuffle(100, i => (i << 1)); - -let u27 = Belt_Set.fromArray(ss, IntCmp); - -let u28 = Belt_Set.union(u27, u26); - -let u29 = Belt_Set.union(u26, u27); - -b("File \"bs_poly_set_test.res\", line 71, characters 4-11", Belt_Set.eq(u28, u29)); - -b("File \"bs_poly_set_test.res\", line 72, characters 4-11", Primitive_object.equal(Belt_Set.toArray(u29), Belt_SortArray.stableSortBy(Belt_Array.concat(ss, [3]), Primitive_int.compare))); - -b("File \"bs_poly_set_test.res\", line 73, characters 4-11", Belt_Set.eq(u19, u20)); - -eq("File \"bs_poly_set_test.res\", line 74, characters 5-12", Belt_Set.toArray(u21), Array_data_util.range(59, 100)); - -eq("File \"bs_poly_set_test.res\", line 75, characters 5-12", Belt_Set.toArray(u22), Array_data_util.range(0, 58)); - -b("File \"bs_poly_set_test.res\", line 76, characters 4-11", Belt_Set.eq(u24, u19)); - -eq("File \"bs_poly_set_test.res\", line 77, characters 5-12", Belt_Set.toArray(u23), Array_data_util.range(101, 200)); - -b("File \"bs_poly_set_test.res\", line 78, characters 4-11", Belt_Set.subset(u23, u18)); - -b("File \"bs_poly_set_test.res\", line 79, characters 4-11", !Belt_Set.subset(u18, u23)); - -b("File \"bs_poly_set_test.res\", line 80, characters 4-11", Belt_Set.subset(u22, u17)); - -b("File \"bs_poly_set_test.res\", line 81, characters 4-11", Belt_Set.subset(u21, u17) && Belt_Set.subset(u21, u18)); - -b("File \"bs_poly_set_test.res\", line 82, characters 4-11", 47 === Belt_Set.getUndefined(u22, 47)); - -b("File \"bs_poly_set_test.res\", line 83, characters 4-11", Primitive_object.equal(47, Belt_Set.get(u22, 47))); - -b("File \"bs_poly_set_test.res\", line 84, characters 4-11", Belt_Set.getUndefined(u22, 59) === undefined); - -b("File \"bs_poly_set_test.res\", line 85, characters 4-11", undefined === Belt_Set.get(u22, 59)); - -eq("File \"bs_poly_set_test.res\", line 87, characters 5-12", Belt_Set.size(u25), 60); - -b("File \"bs_poly_set_test.res\", line 88, characters 4-11", Belt_Set.minimum(Belt_Set.make(IntCmp)) === undefined); - -b("File \"bs_poly_set_test.res\", line 89, characters 4-11", Belt_Set.maximum(Belt_Set.make(IntCmp)) === undefined); - -b("File \"bs_poly_set_test.res\", line 90, characters 4-11", Belt_Set.minUndefined(Belt_Set.make(IntCmp)) === undefined); - -b("File \"bs_poly_set_test.res\", line 91, characters 4-11", Belt_Set.maxUndefined(Belt_Set.make(IntCmp)) === undefined); - -function testIterToList(xs) { - let v = { - contents: /* [] */0 - }; - Belt_Set.forEach(xs, x => { - v.contents = { - hd: x, - tl: v.contents - }; - }); - return Belt_List.reverse(v.contents); -} - -function testIterToList2(xs) { - let v = { - contents: /* [] */0 - }; - Belt_SetDict.forEach(Belt_Set.getData(xs), x => { - v.contents = { - hd: x, - tl: v.contents - }; - }); - return Belt_List.reverse(v.contents); -} - -let u0$1 = Belt_Set.fromArray(Array_data_util.randomRange(0, 20), IntCmp); - -let u1$1 = Belt_Set.remove(u0$1, 17); - -let u2$1 = Belt_Set.add(u1$1, 33); - -b("File \"bs_poly_set_test.res\", line 110, characters 4-11", Belt_List.every2(testIterToList(u0$1), Belt_List.makeBy(21, i => i), (x, y) => x === y)); - -b("File \"bs_poly_set_test.res\", line 111, characters 4-11", Belt_List.every2(testIterToList2(u0$1), Belt_List.makeBy(21, i => i), (x, y) => x === y)); - -b("File \"bs_poly_set_test.res\", line 112, characters 4-11", Belt_List.every2(testIterToList(u0$1), Belt_Set.toList(u0$1), (x, y) => x === y)); - -b("File \"bs_poly_set_test.res\", line 113, characters 4-11", Belt_Set.some(u0$1, x => x === 17)); - -b("File \"bs_poly_set_test.res\", line 114, characters 4-11", !Belt_Set.some(u1$1, x => x === 17)); - -b("File \"bs_poly_set_test.res\", line 115, characters 4-11", Belt_Set.every(u0$1, x => x < 24)); - -b("File \"bs_poly_set_test.res\", line 116, characters 4-11", Belt_SetDict.every(Belt_Set.getData(u0$1), x => x < 24)); - -b("File \"bs_poly_set_test.res\", line 117, characters 4-11", !Belt_Set.every(u2$1, x => x < 24)); - -b("File \"bs_poly_set_test.res\", line 118, characters 4-11", !Belt_Set.every(Belt_Set.fromArray([ - 1, - 2, - 3 -], IntCmp), x => x === 2)); - -b("File \"bs_poly_set_test.res\", line 119, characters 4-11", Belt_Set.cmp(u1$1, u0$1) < 0); - -b("File \"bs_poly_set_test.res\", line 120, characters 4-11", Belt_Set.cmp(u0$1, u1$1) > 0); - -let a0 = Belt_Set.fromArray(Array_data_util.randomRange(0, 1000), IntCmp); - -let a1 = Belt_Set.keep(a0, x => x % 2 === 0); - -let a2 = Belt_Set.keep(a0, x => x % 2 !== 0); - -let match = Belt_Set.partition(a0, x => x % 2 === 0); - -let a4 = match[1]; - -let a3 = match[0]; - -b("File \"bs_poly_set_test.res\", line 127, characters 4-11", Belt_Set.eq(a1, a3)); - -b("File \"bs_poly_set_test.res\", line 128, characters 4-11", Belt_Set.eq(a2, a4)); - -eq("File \"bs_poly_set_test.res\", line 129, characters 5-12", Belt_Set.getExn(a0, 3), 3); - -eq("File \"bs_poly_set_test.res\", line 130, characters 5-12", Belt_Set.getExn(a0, 4), 4); - -t("File \"bs_poly_set_test.res\", line 131, characters 4-11", () => { - Belt_Set.getExn(a0, 1002); -}); - -t("File \"bs_poly_set_test.res\", line 132, characters 4-11", () => { - Belt_Set.getExn(a0, -1); -}); - -eq("File \"bs_poly_set_test.res\", line 133, characters 5-12", Belt_Set.size(a0), 1001); - -b("File \"bs_poly_set_test.res\", line 134, characters 4-11", !Belt_Set.isEmpty(a0)); - -let match$1 = Belt_Set.split(a0, 200); - -let match$2 = match$1[0]; - -b("File \"bs_poly_set_test.res\", line 136, characters 4-11", match$1[1]); - -eq("File \"bs_poly_set_test.res\", line 137, characters 5-12", Belt_Set.toArray(match$2[0]), Belt_Array.makeBy(200, i => i)); - -eq("File \"bs_poly_set_test.res\", line 138, characters 5-12", Belt_Set.toList(match$2[1]), Belt_List.makeBy(800, i => i + 201 | 0)); - -let a7 = Belt_Set.remove(a0, 200); - -let match$3 = Belt_Set.split(a7, 200); - -let match$4 = match$3[0]; - -let a9 = match$4[1]; - -let a8 = match$4[0]; - -b("File \"bs_poly_set_test.res\", line 141, characters 4-11", !match$3[1]); - -eq("File \"bs_poly_set_test.res\", line 142, characters 5-12", Belt_Set.toArray(a8), Belt_Array.makeBy(200, i => i)); - -eq("File \"bs_poly_set_test.res\", line 143, characters 5-12", Belt_Set.toList(a9), Belt_List.makeBy(800, i => i + 201 | 0)); - -eq("File \"bs_poly_set_test.res\", line 144, characters 5-12", Belt_Set.minimum(a8), 0); - -eq("File \"bs_poly_set_test.res\", line 145, characters 5-12", Belt_Set.minimum(a9), 201); - -Belt_List.forEach({ - hd: a0, - tl: { - hd: a1, - tl: { - hd: a2, - tl: { - hd: a3, - tl: { - hd: a4, - tl: /* [] */0 - } - } - } - } -}, Belt_Set.checkInvariantInternal); - -let a = Belt_Set.fromArray([], IntCmp); - -b("File \"bs_poly_set_test.res\", line 151, characters 4-11", Belt_Set.isEmpty(Belt_Set.keep(a, x => x % 2 === 0))); - -let match$5 = Belt_Set.split(Belt_Set.make(IntCmp), 0); - -let match$6 = match$5[0]; - -b("File \"bs_poly_set_test.res\", line 156, characters 4-11", Belt_Set.isEmpty(match$6[0])); - -b("File \"bs_poly_set_test.res\", line 157, characters 4-11", Belt_Set.isEmpty(match$6[1])); - -b("File \"bs_poly_set_test.res\", line 158, characters 4-11", !match$5[1]); - -Mt.from_pair_suites("Bs_poly_set_test", suites.contents); - -let N; - -let D; - -let I; - -let A; - -let S; - -let L; - -exports.suites = suites; -exports.test_id = test_id; -exports.eq = eq; -exports.b = b; -exports.t = t; -exports.N = N; -exports.D = D; -exports.I = I; -exports.A = A; -exports.S = S; -exports.IntCmp = IntCmp; -exports.L = L; -exports.testIterToList = testIterToList; -exports.testIterToList2 = testIterToList2; -/* IntCmp Not a pure module */ diff --git a/tests/tests/src/bs_poly_set_test.mjs b/tests/tests/src/bs_poly_set_test.mjs new file mode 100644 index 0000000000..8812401be4 --- /dev/null +++ b/tests/tests/src/bs_poly_set_test.mjs @@ -0,0 +1,373 @@ +// Generated by ReScript, PLEASE EDIT WITH CARE + +import * as Mt from "./mt.mjs"; +import * as Belt_Id from "rescript/lib/es6/Belt_Id.js"; +import * as Belt_Set from "rescript/lib/es6/Belt_Set.js"; +import * as Belt_List from "rescript/lib/es6/Belt_List.js"; +import * as Belt_Array from "rescript/lib/es6/Belt_Array.js"; +import * as Belt_SetDict from "rescript/lib/es6/Belt_SetDict.js"; +import * as Primitive_int from "rescript/lib/es6/Primitive_int.js"; +import * as Belt_SortArray from "rescript/lib/es6/Belt_SortArray.js"; +import * as Array_data_util from "./array_data_util.mjs"; +import * as Primitive_object from "rescript/lib/es6/Primitive_object.js"; + +let suites = { + contents: /* [] */0 +}; + +let test_id = { + contents: 0 +}; + +function eq(loc, x, y) { + Mt.eq_suites(test_id, suites, loc, x, y); +} + +function b(loc, x) { + Mt.bool_suites(test_id, suites, loc, x); +} + +function t(loc, x) { + Mt.throw_suites(test_id, suites, loc, x); +} + +let IntCmp = Belt_Id.comparable(Primitive_int.compare); + +let u0 = Belt_Set.fromArray(Array_data_util.range(0, 30), IntCmp); + +let u1 = Belt_Set.remove(u0, 0); + +let u2 = Belt_Set.remove(u1, 0); + +let u3 = Belt_Set.remove(u2, 30); + +let u4 = Belt_Set.remove(u3, 20); + +let r = Array_data_util.randomRange(0, 30); + +let u5 = Belt_Set.add(u4, 3); + +let u6 = Belt_Set.removeMany(u5, r); + +let u7 = Belt_Set.mergeMany(u6, [ + 0, + 1, + 2, + 0 +]); + +let u8 = Belt_Set.removeMany(u7, [ + 0, + 1, + 2, + 3 +]); + +let u9 = Belt_Set.mergeMany(u8, Array_data_util.randomRange(0, 20000)); + +let u10 = Belt_Set.mergeMany(u9, Array_data_util.randomRange(0, 200)); + +let u11 = Belt_Set.removeMany(u10, Array_data_util.randomRange(0, 200)); + +let u12 = Belt_Set.removeMany(u11, Array_data_util.randomRange(0, 1000)); + +let u13 = Belt_Set.removeMany(u12, Array_data_util.randomRange(0, 1000)); + +let u14 = Belt_Set.removeMany(u13, Array_data_util.randomRange(1000, 10000)); + +let u15 = Belt_Set.removeMany(u14, Array_data_util.randomRange(10000, 19999)); + +let u16 = Belt_Set.removeMany(u15, Array_data_util.randomRange(20000, 21000)); + +b("File \"bs_poly_set_test.res\", line 34, characters 4-11", u0 !== u1); + +b("File \"bs_poly_set_test.res\", line 35, characters 4-11", u2 === u1); + +eq("File \"bs_poly_set_test.res\", line 36, characters 5-12", Belt_Set.size(u4), 28); + +b("File \"bs_poly_set_test.res\", line 37, characters 4-11", 29 === Belt_Set.maxUndefined(u4)); + +b("File \"bs_poly_set_test.res\", line 38, characters 4-11", 1 === Belt_Set.minUndefined(u4)); + +b("File \"bs_poly_set_test.res\", line 39, characters 4-11", u4 === u5); + +b("File \"bs_poly_set_test.res\", line 40, characters 4-11", Belt_Set.isEmpty(u6)); + +eq("File \"bs_poly_set_test.res\", line 41, characters 5-12", Belt_Set.size(u7), 3); + +b("File \"bs_poly_set_test.res\", line 42, characters 4-11", !Belt_Set.isEmpty(u7)); + +b("File \"bs_poly_set_test.res\", line 43, characters 4-11", Belt_Set.isEmpty(u8)); + +b("File \"bs_poly_set_test.res\", line 46, characters 4-11", Belt_Set.has(u10, 20)); + +b("File \"bs_poly_set_test.res\", line 47, characters 4-11", Belt_Set.has(u10, 21)); + +eq("File \"bs_poly_set_test.res\", line 48, characters 5-12", Belt_Set.size(u10), 20001); + +eq("File \"bs_poly_set_test.res\", line 49, characters 5-12", Belt_Set.size(u11), 19800); + +eq("File \"bs_poly_set_test.res\", line 50, characters 5-12", Belt_Set.size(u12), 19000); + +eq("File \"bs_poly_set_test.res\", line 52, characters 5-12", Belt_Set.size(u13), Belt_Set.size(u12)); + +eq("File \"bs_poly_set_test.res\", line 53, characters 5-12", Belt_Set.size(u14), 10000); + +eq("File \"bs_poly_set_test.res\", line 54, characters 5-12", Belt_Set.size(u15), 1); + +b("File \"bs_poly_set_test.res\", line 55, characters 4-11", Belt_Set.has(u15, 20000)); + +b("File \"bs_poly_set_test.res\", line 56, characters 4-11", !Belt_Set.has(u15, 2000)); + +b("File \"bs_poly_set_test.res\", line 57, characters 4-11", Belt_Set.isEmpty(u16)); + +let u17 = Belt_Set.fromArray(Array_data_util.randomRange(0, 100), IntCmp); + +let u18 = Belt_Set.fromArray(Array_data_util.randomRange(59, 200), IntCmp); + +let u19 = Belt_Set.union(u17, u18); + +let u20 = Belt_Set.fromArray(Array_data_util.randomRange(0, 200), IntCmp); + +let u21 = Belt_Set.intersect(u17, u18); + +let u22 = Belt_Set.diff(u17, u18); + +let u23 = Belt_Set.diff(u18, u17); + +let u24 = Belt_Set.union(u18, u17); + +let u25 = Belt_Set.add(u22, 59); + +let u26 = Belt_Set.add(Belt_Set.make(IntCmp), 3); + +let ss = Belt_Array.makeByAndShuffle(100, i => (i << 1)); + +let u27 = Belt_Set.fromArray(ss, IntCmp); + +let u28 = Belt_Set.union(u27, u26); + +let u29 = Belt_Set.union(u26, u27); + +b("File \"bs_poly_set_test.res\", line 71, characters 4-11", Belt_Set.eq(u28, u29)); + +b("File \"bs_poly_set_test.res\", line 72, characters 4-11", Primitive_object.equal(Belt_Set.toArray(u29), Belt_SortArray.stableSortBy(Belt_Array.concat(ss, [3]), Primitive_int.compare))); + +b("File \"bs_poly_set_test.res\", line 73, characters 4-11", Belt_Set.eq(u19, u20)); + +eq("File \"bs_poly_set_test.res\", line 74, characters 5-12", Belt_Set.toArray(u21), Array_data_util.range(59, 100)); + +eq("File \"bs_poly_set_test.res\", line 75, characters 5-12", Belt_Set.toArray(u22), Array_data_util.range(0, 58)); + +b("File \"bs_poly_set_test.res\", line 76, characters 4-11", Belt_Set.eq(u24, u19)); + +eq("File \"bs_poly_set_test.res\", line 77, characters 5-12", Belt_Set.toArray(u23), Array_data_util.range(101, 200)); + +b("File \"bs_poly_set_test.res\", line 78, characters 4-11", Belt_Set.subset(u23, u18)); + +b("File \"bs_poly_set_test.res\", line 79, characters 4-11", !Belt_Set.subset(u18, u23)); + +b("File \"bs_poly_set_test.res\", line 80, characters 4-11", Belt_Set.subset(u22, u17)); + +b("File \"bs_poly_set_test.res\", line 81, characters 4-11", Belt_Set.subset(u21, u17) && Belt_Set.subset(u21, u18)); + +b("File \"bs_poly_set_test.res\", line 82, characters 4-11", 47 === Belt_Set.getUndefined(u22, 47)); + +b("File \"bs_poly_set_test.res\", line 83, characters 4-11", Primitive_object.equal(47, Belt_Set.get(u22, 47))); + +b("File \"bs_poly_set_test.res\", line 84, characters 4-11", Belt_Set.getUndefined(u22, 59) === undefined); + +b("File \"bs_poly_set_test.res\", line 85, characters 4-11", undefined === Belt_Set.get(u22, 59)); + +eq("File \"bs_poly_set_test.res\", line 87, characters 5-12", Belt_Set.size(u25), 60); + +b("File \"bs_poly_set_test.res\", line 88, characters 4-11", Belt_Set.minimum(Belt_Set.make(IntCmp)) === undefined); + +b("File \"bs_poly_set_test.res\", line 89, characters 4-11", Belt_Set.maximum(Belt_Set.make(IntCmp)) === undefined); + +b("File \"bs_poly_set_test.res\", line 90, characters 4-11", Belt_Set.minUndefined(Belt_Set.make(IntCmp)) === undefined); + +b("File \"bs_poly_set_test.res\", line 91, characters 4-11", Belt_Set.maxUndefined(Belt_Set.make(IntCmp)) === undefined); + +function testIterToList(xs) { + let v = { + contents: /* [] */0 + }; + Belt_Set.forEach(xs, x => { + v.contents = { + hd: x, + tl: v.contents + }; + }); + return Belt_List.reverse(v.contents); +} + +function testIterToList2(xs) { + let v = { + contents: /* [] */0 + }; + Belt_SetDict.forEach(Belt_Set.getData(xs), x => { + v.contents = { + hd: x, + tl: v.contents + }; + }); + return Belt_List.reverse(v.contents); +} + +let u0$1 = Belt_Set.fromArray(Array_data_util.randomRange(0, 20), IntCmp); + +let u1$1 = Belt_Set.remove(u0$1, 17); + +let u2$1 = Belt_Set.add(u1$1, 33); + +b("File \"bs_poly_set_test.res\", line 110, characters 4-11", Belt_List.every2(testIterToList(u0$1), Belt_List.makeBy(21, i => i), (x, y) => x === y)); + +b("File \"bs_poly_set_test.res\", line 111, characters 4-11", Belt_List.every2(testIterToList2(u0$1), Belt_List.makeBy(21, i => i), (x, y) => x === y)); + +b("File \"bs_poly_set_test.res\", line 112, characters 4-11", Belt_List.every2(testIterToList(u0$1), Belt_Set.toList(u0$1), (x, y) => x === y)); + +b("File \"bs_poly_set_test.res\", line 113, characters 4-11", Belt_Set.some(u0$1, x => x === 17)); + +b("File \"bs_poly_set_test.res\", line 114, characters 4-11", !Belt_Set.some(u1$1, x => x === 17)); + +b("File \"bs_poly_set_test.res\", line 115, characters 4-11", Belt_Set.every(u0$1, x => x < 24)); + +b("File \"bs_poly_set_test.res\", line 116, characters 4-11", Belt_SetDict.every(Belt_Set.getData(u0$1), x => x < 24)); + +b("File \"bs_poly_set_test.res\", line 117, characters 4-11", !Belt_Set.every(u2$1, x => x < 24)); + +b("File \"bs_poly_set_test.res\", line 118, characters 4-11", !Belt_Set.every(Belt_Set.fromArray([ + 1, + 2, + 3 +], IntCmp), x => x === 2)); + +b("File \"bs_poly_set_test.res\", line 119, characters 4-11", Belt_Set.cmp(u1$1, u0$1) < 0); + +b("File \"bs_poly_set_test.res\", line 120, characters 4-11", Belt_Set.cmp(u0$1, u1$1) > 0); + +let a0 = Belt_Set.fromArray(Array_data_util.randomRange(0, 1000), IntCmp); + +let a1 = Belt_Set.keep(a0, x => x % 2 === 0); + +let a2 = Belt_Set.keep(a0, x => x % 2 !== 0); + +let match = Belt_Set.partition(a0, x => x % 2 === 0); + +let a4 = match[1]; + +let a3 = match[0]; + +b("File \"bs_poly_set_test.res\", line 127, characters 4-11", Belt_Set.eq(a1, a3)); + +b("File \"bs_poly_set_test.res\", line 128, characters 4-11", Belt_Set.eq(a2, a4)); + +eq("File \"bs_poly_set_test.res\", line 129, characters 5-12", Belt_Set.getExn(a0, 3), 3); + +eq("File \"bs_poly_set_test.res\", line 130, characters 5-12", Belt_Set.getExn(a0, 4), 4); + +t("File \"bs_poly_set_test.res\", line 131, characters 4-11", () => { + Belt_Set.getExn(a0, 1002); +}); + +t("File \"bs_poly_set_test.res\", line 132, characters 4-11", () => { + Belt_Set.getExn(a0, -1); +}); + +eq("File \"bs_poly_set_test.res\", line 133, characters 5-12", Belt_Set.size(a0), 1001); + +b("File \"bs_poly_set_test.res\", line 134, characters 4-11", !Belt_Set.isEmpty(a0)); + +let match$1 = Belt_Set.split(a0, 200); + +let match$2 = match$1[0]; + +b("File \"bs_poly_set_test.res\", line 136, characters 4-11", match$1[1]); + +eq("File \"bs_poly_set_test.res\", line 137, characters 5-12", Belt_Set.toArray(match$2[0]), Belt_Array.makeBy(200, i => i)); + +eq("File \"bs_poly_set_test.res\", line 138, characters 5-12", Belt_Set.toList(match$2[1]), Belt_List.makeBy(800, i => i + 201 | 0)); + +let a7 = Belt_Set.remove(a0, 200); + +let match$3 = Belt_Set.split(a7, 200); + +let match$4 = match$3[0]; + +let a9 = match$4[1]; + +let a8 = match$4[0]; + +b("File \"bs_poly_set_test.res\", line 141, characters 4-11", !match$3[1]); + +eq("File \"bs_poly_set_test.res\", line 142, characters 5-12", Belt_Set.toArray(a8), Belt_Array.makeBy(200, i => i)); + +eq("File \"bs_poly_set_test.res\", line 143, characters 5-12", Belt_Set.toList(a9), Belt_List.makeBy(800, i => i + 201 | 0)); + +eq("File \"bs_poly_set_test.res\", line 144, characters 5-12", Belt_Set.minimum(a8), 0); + +eq("File \"bs_poly_set_test.res\", line 145, characters 5-12", Belt_Set.minimum(a9), 201); + +Belt_List.forEach({ + hd: a0, + tl: { + hd: a1, + tl: { + hd: a2, + tl: { + hd: a3, + tl: { + hd: a4, + tl: /* [] */0 + } + } + } + } +}, Belt_Set.checkInvariantInternal); + +let a = Belt_Set.fromArray([], IntCmp); + +b("File \"bs_poly_set_test.res\", line 151, characters 4-11", Belt_Set.isEmpty(Belt_Set.keep(a, x => x % 2 === 0))); + +let match$5 = Belt_Set.split(Belt_Set.make(IntCmp), 0); + +let match$6 = match$5[0]; + +b("File \"bs_poly_set_test.res\", line 156, characters 4-11", Belt_Set.isEmpty(match$6[0])); + +b("File \"bs_poly_set_test.res\", line 157, characters 4-11", Belt_Set.isEmpty(match$6[1])); + +b("File \"bs_poly_set_test.res\", line 158, characters 4-11", !match$5[1]); + +Mt.from_pair_suites("Bs_poly_set_test", suites.contents); + +let N; + +let D; + +let I; + +let A; + +let S; + +let L; + +export { + suites, + test_id, + eq, + b, + t, + N, + D, + I, + A, + S, + IntCmp, + L, + testIterToList, + testIterToList2, +} +/* IntCmp Not a pure module */ diff --git a/tests/tests/src/bs_qualified.js b/tests/tests/src/bs_qualified.js deleted file mode 100644 index 96ae426c27..0000000000 --- a/tests/tests/src/bs_qualified.js +++ /dev/null @@ -1,53 +0,0 @@ -// Generated by ReScript, PLEASE EDIT WITH CARE -'use strict'; - -let ZZ = require("X"); -let Z = require("z"); -let Vscode = require("vscode"); -let GlMatrix = require("gl-matrix"); - -function f(a, b, c) { - Vscode.commands.executeCommands("hi", a, b, c); - return process.env; -} - -function f2() { - return [ - Z.a0.a1.a2.hi, - a0.a1.a2.ho, - Math.imul(1, 2) - ]; -} - -function f3(x) { - new (global.Buffer)(20); - new (global.a0.a1.a2.Buffer)(20); - new (ZZ.global.a0.a1.a2.Buffer)(100); - new (ZZ.global.a0.a1.a2.makeBuffer3)(20); - console.log(Math.max(1.0, 2.0)); - console.log(x.a0[0]); - console.log(x.a0.a1[0]); - console.log(x.a0.a1.a2[0]); - x.a0[0] = "x"; - x.a0.a1[0] = "x"; - x.a0.a1.a2[0] = "x"; - console.log(x.a0.getX1); - console.log(x.a0.a1.getX2); - console.log(x.a0.a1.a2.getX3); - x.a0.setX1 = 0; - x.a0.a1.setX2 = 0; - x.a0.a1.a2.setX3 = 0; - x["a0-hi"].a1.a2.setXWeird3 = 0; - x.a0.send1(0); - x.a0.a1.send2(0); - x.a0.a1.send3(0); - x.a0.psend1(0); - x.a0.a1.psend2(0); - x.a0.a1.psend3(0); - return GlMatrix.mat4.create(); -} - -exports.f = f; -exports.f2 = f2; -exports.f3 = f3; -/* X Not a pure module */ diff --git a/tests/tests/src/bs_qualified.mjs b/tests/tests/src/bs_qualified.mjs new file mode 100644 index 0000000000..6b4e0bb108 --- /dev/null +++ b/tests/tests/src/bs_qualified.mjs @@ -0,0 +1,54 @@ +// Generated by ReScript, PLEASE EDIT WITH CARE + +import * as ZZ from "X"; +import * as Z from "z"; +import * as Vscode from "vscode"; +import * as GlMatrix from "gl-matrix"; + +function f(a, b, c) { + Vscode.commands.executeCommands("hi", a, b, c); + return process.env; +} + +function f2() { + return [ + Z.a0.a1.a2.hi, + a0.a1.a2.ho, + Math.imul(1, 2) + ]; +} + +function f3(x) { + new (global.Buffer)(20); + new (global.a0.a1.a2.Buffer)(20); + new (ZZ.global.a0.a1.a2.Buffer)(100); + new (ZZ.global.a0.a1.a2.makeBuffer3)(20); + console.log(Math.max(1.0, 2.0)); + console.log(x.a0[0]); + console.log(x.a0.a1[0]); + console.log(x.a0.a1.a2[0]); + x.a0[0] = "x"; + x.a0.a1[0] = "x"; + x.a0.a1.a2[0] = "x"; + console.log(x.a0.getX1); + console.log(x.a0.a1.getX2); + console.log(x.a0.a1.a2.getX3); + x.a0.setX1 = 0; + x.a0.a1.setX2 = 0; + x.a0.a1.a2.setX3 = 0; + x["a0-hi"].a1.a2.setXWeird3 = 0; + x.a0.send1(0); + x.a0.a1.send2(0); + x.a0.a1.send3(0); + x.a0.psend1(0); + x.a0.a1.psend2(0); + x.a0.a1.psend3(0); + return GlMatrix.mat4.create(); +} + +export { + f, + f2, + f3, +} +/* X Not a pure module */ diff --git a/tests/tests/src/bs_queue_test.js b/tests/tests/src/bs_queue_test.js deleted file mode 100644 index 7ba9420106..0000000000 --- a/tests/tests/src/bs_queue_test.js +++ /dev/null @@ -1,1216 +0,0 @@ -// Generated by ReScript, PLEASE EDIT WITH CARE -'use strict'; - -let Mt = require("./mt.js"); -let Belt_Array = require("rescript/lib/js/Belt_Array.js"); -let Primitive_object = require("rescript/lib/js/Primitive_object.js"); -let Belt_MutableQueue = require("rescript/lib/js/Belt_MutableQueue.js"); - -let suites = { - contents: /* [] */0 -}; - -let test_id = { - contents: 0 -}; - -function eq(loc, x, y) { - Mt.eq_suites(test_id, suites, loc, x, y); -} - -function b(loc, x) { - Mt.bool_suites(test_id, suites, loc, x); -} - -function does_raise(f, q) { - try { - f(q); - return false; - } catch (exn) { - return true; - } -} - -function $plus$plus(q, x) { - Belt_MutableQueue.add(q, x); - return q; -} - -let q = Belt_MutableQueue.make(); - -if (!(Primitive_object.equal(Belt_MutableQueue.toArray(q), []) && Belt_MutableQueue.size(q) === 0)) { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "bs_queue_test.res", - 25, - 2 - ], - Error: new Error() - }; -} - -if (!(Primitive_object.equal(Belt_MutableQueue.toArray((Belt_MutableQueue.add(q, 1), q)), [1]) && Belt_MutableQueue.size(q) === 1)) { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "bs_queue_test.res", - 26, - 2 - ], - Error: new Error() - }; -} - -if (!(Primitive_object.equal(Belt_MutableQueue.toArray((Belt_MutableQueue.add(q, 2), q)), [ - 1, - 2 - ]) && Belt_MutableQueue.size(q) === 2)) { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "bs_queue_test.res", - 27, - 2 - ], - Error: new Error() - }; -} - -if (!(Primitive_object.equal(Belt_MutableQueue.toArray((Belt_MutableQueue.add(q, 3), q)), [ - 1, - 2, - 3 - ]) && Belt_MutableQueue.size(q) === 3)) { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "bs_queue_test.res", - 28, - 2 - ], - Error: new Error() - }; -} - -if (!(Primitive_object.equal(Belt_MutableQueue.toArray((Belt_MutableQueue.add(q, 4), q)), [ - 1, - 2, - 3, - 4 - ]) && Belt_MutableQueue.size(q) === 4)) { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "bs_queue_test.res", - 29, - 2 - ], - Error: new Error() - }; -} - -if (Belt_MutableQueue.popExn(q) !== 1) { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "bs_queue_test.res", - 30, - 2 - ], - Error: new Error() - }; -} - -if (!(Primitive_object.equal(Belt_MutableQueue.toArray(q), [ - 2, - 3, - 4 - ]) && Belt_MutableQueue.size(q) === 3)) { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "bs_queue_test.res", - 31, - 2 - ], - Error: new Error() - }; -} - -if (Belt_MutableQueue.popExn(q) !== 2) { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "bs_queue_test.res", - 32, - 2 - ], - Error: new Error() - }; -} - -if (!(Primitive_object.equal(Belt_MutableQueue.toArray(q), [ - 3, - 4 - ]) && Belt_MutableQueue.size(q) === 2)) { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "bs_queue_test.res", - 33, - 2 - ], - Error: new Error() - }; -} - -if (Belt_MutableQueue.popExn(q) !== 3) { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "bs_queue_test.res", - 34, - 2 - ], - Error: new Error() - }; -} - -if (!(Primitive_object.equal(Belt_MutableQueue.toArray(q), [4]) && Belt_MutableQueue.size(q) === 1)) { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "bs_queue_test.res", - 35, - 2 - ], - Error: new Error() - }; -} - -if (Belt_MutableQueue.popExn(q) !== 4) { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "bs_queue_test.res", - 36, - 2 - ], - Error: new Error() - }; -} - -if (!(Primitive_object.equal(Belt_MutableQueue.toArray(q), []) && Belt_MutableQueue.size(q) === 0)) { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "bs_queue_test.res", - 37, - 2 - ], - Error: new Error() - }; -} - -if (!does_raise(Belt_MutableQueue.popExn, q)) { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "bs_queue_test.res", - 38, - 2 - ], - Error: new Error() - }; -} - -let q$1 = Belt_MutableQueue.make(); - -if (Belt_MutableQueue.popExn((Belt_MutableQueue.add(q$1, 1), q$1)) !== 1) { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "bs_queue_test.res", - 43, - 2 - ], - Error: new Error() - }; -} - -if (!does_raise(Belt_MutableQueue.popExn, q$1)) { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "bs_queue_test.res", - 44, - 2 - ], - Error: new Error() - }; -} - -if (Belt_MutableQueue.popExn((Belt_MutableQueue.add(q$1, 2), q$1)) !== 2) { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "bs_queue_test.res", - 45, - 2 - ], - Error: new Error() - }; -} - -if (!does_raise(Belt_MutableQueue.popExn, q$1)) { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "bs_queue_test.res", - 46, - 2 - ], - Error: new Error() - }; -} - -if (Belt_MutableQueue.size(q$1) !== 0) { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "bs_queue_test.res", - 47, - 2 - ], - Error: new Error() - }; -} - -let q$2 = Belt_MutableQueue.make(); - -if (Belt_MutableQueue.peekExn((Belt_MutableQueue.add(q$2, 1), q$2)) !== 1) { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "bs_queue_test.res", - 52, - 2 - ], - Error: new Error() - }; -} - -if (Belt_MutableQueue.peekExn((Belt_MutableQueue.add(q$2, 2), q$2)) !== 1) { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "bs_queue_test.res", - 53, - 2 - ], - Error: new Error() - }; -} - -if (Belt_MutableQueue.peekExn((Belt_MutableQueue.add(q$2, 3), q$2)) !== 1) { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "bs_queue_test.res", - 54, - 2 - ], - Error: new Error() - }; -} - -if (Belt_MutableQueue.peekExn(q$2) !== 1) { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "bs_queue_test.res", - 55, - 2 - ], - Error: new Error() - }; -} - -if (Belt_MutableQueue.popExn(q$2) !== 1) { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "bs_queue_test.res", - 56, - 2 - ], - Error: new Error() - }; -} - -if (Belt_MutableQueue.peekExn(q$2) !== 2) { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "bs_queue_test.res", - 57, - 2 - ], - Error: new Error() - }; -} - -if (Belt_MutableQueue.popExn(q$2) !== 2) { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "bs_queue_test.res", - 58, - 2 - ], - Error: new Error() - }; -} - -if (Belt_MutableQueue.peekExn(q$2) !== 3) { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "bs_queue_test.res", - 59, - 2 - ], - Error: new Error() - }; -} - -if (Belt_MutableQueue.popExn(q$2) !== 3) { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "bs_queue_test.res", - 60, - 2 - ], - Error: new Error() - }; -} - -if (!does_raise(Belt_MutableQueue.peekExn, q$2)) { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "bs_queue_test.res", - 61, - 2 - ], - Error: new Error() - }; -} - -if (!does_raise(Belt_MutableQueue.peekExn, q$2)) { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "bs_queue_test.res", - 62, - 2 - ], - Error: new Error() - }; -} - -let q$3 = Belt_MutableQueue.make(); - -for (let i = 1; i <= 10; ++i) { - Belt_MutableQueue.add(q$3, i); -} - -Belt_MutableQueue.clear(q$3); - -if (Belt_MutableQueue.size(q$3) !== 0) { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "bs_queue_test.res", - 71, - 2 - ], - Error: new Error() - }; -} - -if (!does_raise(Belt_MutableQueue.popExn, q$3)) { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "bs_queue_test.res", - 72, - 2 - ], - Error: new Error() - }; -} - -if (!Primitive_object.equal(q$3, Belt_MutableQueue.make())) { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "bs_queue_test.res", - 73, - 2 - ], - Error: new Error() - }; -} - -Belt_MutableQueue.add(q$3, 42); - -if (Belt_MutableQueue.popExn(q$3) !== 42) { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "bs_queue_test.res", - 75, - 2 - ], - Error: new Error() - }; -} - -let q1 = Belt_MutableQueue.make(); - -for (let i$1 = 1; i$1 <= 10; ++i$1) { - Belt_MutableQueue.add(q1, i$1); -} - -let q2 = Belt_MutableQueue.copy(q1); - -if (!Primitive_object.equal(Belt_MutableQueue.toArray(q1), [ - 1, - 2, - 3, - 4, - 5, - 6, - 7, - 8, - 9, - 10 - ])) { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "bs_queue_test.res", - 84, - 2 - ], - Error: new Error() - }; -} - -if (!Primitive_object.equal(Belt_MutableQueue.toArray(q2), [ - 1, - 2, - 3, - 4, - 5, - 6, - 7, - 8, - 9, - 10 - ])) { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "bs_queue_test.res", - 85, - 2 - ], - Error: new Error() - }; -} - -if (Belt_MutableQueue.size(q1) !== 10) { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "bs_queue_test.res", - 86, - 2 - ], - Error: new Error() - }; -} - -if (Belt_MutableQueue.size(q2) !== 10) { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "bs_queue_test.res", - 87, - 2 - ], - Error: new Error() - }; -} - -for (let i$2 = 1; i$2 <= 10; ++i$2) { - if (Belt_MutableQueue.popExn(q1) !== i$2) { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "bs_queue_test.res", - 89, - 4 - ], - Error: new Error() - }; - } - -} - -for (let i$3 = 1; i$3 <= 10; ++i$3) { - if (Belt_MutableQueue.popExn(q2) !== i$3) { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "bs_queue_test.res", - 92, - 4 - ], - Error: new Error() - }; - } - -} - -let q$4 = Belt_MutableQueue.make(); - -if (!Belt_MutableQueue.isEmpty(q$4)) { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "bs_queue_test.res", - 98, - 2 - ], - Error: new Error() - }; -} - -for (let i$4 = 1; i$4 <= 10; ++i$4) { - Belt_MutableQueue.add(q$4, i$4); - if (Belt_MutableQueue.size(q$4) !== i$4) { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "bs_queue_test.res", - 101, - 4 - ], - Error: new Error() - }; - } - if (Belt_MutableQueue.isEmpty(q$4)) { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "bs_queue_test.res", - 102, - 4 - ], - Error: new Error() - }; - } - -} - -for (let i$5 = 10; i$5 >= 1; --i$5) { - if (Belt_MutableQueue.size(q$4) !== i$5) { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "bs_queue_test.res", - 105, - 4 - ], - Error: new Error() - }; - } - if (Belt_MutableQueue.isEmpty(q$4)) { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "bs_queue_test.res", - 106, - 4 - ], - Error: new Error() - }; - } - Belt_MutableQueue.popExn(q$4); -} - -if (Belt_MutableQueue.size(q$4) !== 0) { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "bs_queue_test.res", - 109, - 2 - ], - Error: new Error() - }; -} - -if (!Belt_MutableQueue.isEmpty(q$4)) { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "bs_queue_test.res", - 110, - 2 - ], - Error: new Error() - }; -} - -let q$5 = Belt_MutableQueue.make(); - -for (let i$6 = 1; i$6 <= 10; ++i$6) { - Belt_MutableQueue.add(q$5, i$6); -} - -let i$7 = { - contents: 1 -}; - -Belt_MutableQueue.forEach(q$5, j => { - if (i$7.contents !== j) { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "bs_queue_test.res", - 120, - 4 - ], - Error: new Error() - }; - } - i$7.contents = i$7.contents + 1 | 0; -}); - -let q1$1 = Belt_MutableQueue.make(); - -let q2$1 = Belt_MutableQueue.make(); - -if (Belt_MutableQueue.size(q1$1) !== 0) { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "bs_queue_test.res", - 127, - 2 - ], - Error: new Error() - }; -} - -if (!Primitive_object.equal(Belt_MutableQueue.toArray(q1$1), [])) { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "bs_queue_test.res", - 128, - 2 - ], - Error: new Error() - }; -} - -if (Belt_MutableQueue.size(q2$1) !== 0) { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "bs_queue_test.res", - 129, - 2 - ], - Error: new Error() - }; -} - -if (!Primitive_object.equal(Belt_MutableQueue.toArray(q2$1), [])) { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "bs_queue_test.res", - 130, - 2 - ], - Error: new Error() - }; -} - -Belt_MutableQueue.transfer(q1$1, q2$1); - -if (Belt_MutableQueue.size(q1$1) !== 0) { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "bs_queue_test.res", - 132, - 2 - ], - Error: new Error() - }; -} - -if (!Primitive_object.equal(Belt_MutableQueue.toArray(q1$1), [])) { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "bs_queue_test.res", - 133, - 2 - ], - Error: new Error() - }; -} - -if (Belt_MutableQueue.size(q2$1) !== 0) { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "bs_queue_test.res", - 134, - 2 - ], - Error: new Error() - }; -} - -if (!Primitive_object.equal(Belt_MutableQueue.toArray(q2$1), [])) { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "bs_queue_test.res", - 135, - 2 - ], - Error: new Error() - }; -} - -let q1$2 = Belt_MutableQueue.make(); - -let q2$2 = Belt_MutableQueue.make(); - -for (let i$8 = 1; i$8 <= 4; ++i$8) { - Belt_MutableQueue.add(q1$2, i$8); -} - -if (Belt_MutableQueue.size(q1$2) !== 4) { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "bs_queue_test.res", - 143, - 2 - ], - Error: new Error() - }; -} - -if (!Primitive_object.equal(Belt_MutableQueue.toArray(q1$2), [ - 1, - 2, - 3, - 4 - ])) { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "bs_queue_test.res", - 144, - 2 - ], - Error: new Error() - }; -} - -if (Belt_MutableQueue.size(q2$2) !== 0) { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "bs_queue_test.res", - 145, - 2 - ], - Error: new Error() - }; -} - -if (!Primitive_object.equal(Belt_MutableQueue.toArray(q2$2), [])) { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "bs_queue_test.res", - 146, - 2 - ], - Error: new Error() - }; -} - -Belt_MutableQueue.transfer(q1$2, q2$2); - -if (Belt_MutableQueue.size(q1$2) !== 0) { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "bs_queue_test.res", - 148, - 2 - ], - Error: new Error() - }; -} - -if (!Primitive_object.equal(Belt_MutableQueue.toArray(q1$2), [])) { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "bs_queue_test.res", - 149, - 2 - ], - Error: new Error() - }; -} - -if (Belt_MutableQueue.size(q2$2) !== 4) { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "bs_queue_test.res", - 150, - 2 - ], - Error: new Error() - }; -} - -if (!Primitive_object.equal(Belt_MutableQueue.toArray(q2$2), [ - 1, - 2, - 3, - 4 - ])) { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "bs_queue_test.res", - 151, - 2 - ], - Error: new Error() - }; -} - -let q1$3 = Belt_MutableQueue.make(); - -let q2$3 = Belt_MutableQueue.make(); - -for (let i$9 = 5; i$9 <= 8; ++i$9) { - Belt_MutableQueue.add(q2$3, i$9); -} - -if (Belt_MutableQueue.size(q1$3) !== 0) { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "bs_queue_test.res", - 159, - 2 - ], - Error: new Error() - }; -} - -if (!Primitive_object.equal(Belt_MutableQueue.toArray(q1$3), [])) { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "bs_queue_test.res", - 160, - 2 - ], - Error: new Error() - }; -} - -if (Belt_MutableQueue.size(q2$3) !== 4) { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "bs_queue_test.res", - 161, - 2 - ], - Error: new Error() - }; -} - -if (!Primitive_object.equal(Belt_MutableQueue.toArray(q2$3), [ - 5, - 6, - 7, - 8 - ])) { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "bs_queue_test.res", - 162, - 2 - ], - Error: new Error() - }; -} - -Belt_MutableQueue.transfer(q1$3, q2$3); - -if (Belt_MutableQueue.size(q1$3) !== 0) { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "bs_queue_test.res", - 164, - 2 - ], - Error: new Error() - }; -} - -if (!Primitive_object.equal(Belt_MutableQueue.toArray(q1$3), [])) { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "bs_queue_test.res", - 165, - 2 - ], - Error: new Error() - }; -} - -if (Belt_MutableQueue.size(q2$3) !== 4) { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "bs_queue_test.res", - 166, - 2 - ], - Error: new Error() - }; -} - -if (!Primitive_object.equal(Belt_MutableQueue.toArray(q2$3), [ - 5, - 6, - 7, - 8 - ])) { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "bs_queue_test.res", - 167, - 2 - ], - Error: new Error() - }; -} - -let q1$4 = Belt_MutableQueue.make(); - -let q2$4 = Belt_MutableQueue.make(); - -for (let i$10 = 1; i$10 <= 4; ++i$10) { - Belt_MutableQueue.add(q1$4, i$10); -} - -for (let i$11 = 5; i$11 <= 8; ++i$11) { - Belt_MutableQueue.add(q2$4, i$11); -} - -if (Belt_MutableQueue.size(q1$4) !== 4) { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "bs_queue_test.res", - 178, - 2 - ], - Error: new Error() - }; -} - -if (!Primitive_object.equal(Belt_MutableQueue.toArray(q1$4), [ - 1, - 2, - 3, - 4 - ])) { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "bs_queue_test.res", - 179, - 2 - ], - Error: new Error() - }; -} - -if (Belt_MutableQueue.size(q2$4) !== 4) { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "bs_queue_test.res", - 180, - 2 - ], - Error: new Error() - }; -} - -if (!Primitive_object.equal(Belt_MutableQueue.toArray(q2$4), [ - 5, - 6, - 7, - 8 - ])) { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "bs_queue_test.res", - 181, - 2 - ], - Error: new Error() - }; -} - -Belt_MutableQueue.transfer(q1$4, q2$4); - -if (Belt_MutableQueue.size(q1$4) !== 0) { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "bs_queue_test.res", - 183, - 2 - ], - Error: new Error() - }; -} - -if (!Primitive_object.equal(Belt_MutableQueue.toArray(q1$4), [])) { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "bs_queue_test.res", - 184, - 2 - ], - Error: new Error() - }; -} - -let v = [ - 5, - 6, - 7, - 8, - 1, - 2, - 3, - 4 -]; - -if (Belt_MutableQueue.size(q2$4) !== 8) { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "bs_queue_test.res", - 186, - 2 - ], - Error: new Error() - }; -} - -if (!Primitive_object.equal(Belt_MutableQueue.toArray(q2$4), v)) { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "bs_queue_test.res", - 187, - 2 - ], - Error: new Error() - }; -} - -if (Belt_MutableQueue.reduce(q2$4, 0, (x, y) => x - y | 0) !== Belt_Array.reduce(v, 0, (x, y) => x - y | 0)) { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "bs_queue_test.res", - 189, - 2 - ], - Error: new Error() - }; -} - -console.log("OK"); - -let q$6 = Belt_MutableQueue.fromArray([ - 1, - 2, - 3, - 4 -]); - -let q1$5 = Belt_MutableQueue.map(q$6, x => x - 1 | 0); - -eq("File \"bs_queue_test.res\", line 197, characters 5-12", Belt_MutableQueue.toArray(q1$5), [ - 0, - 1, - 2, - 3 -]); - -b("File \"bs_queue_test.res\", line 198, characters 4-11", Belt_MutableQueue.isEmpty(Belt_MutableQueue.fromArray([]))); - -b("File \"bs_queue_test.res\", line 199, characters 4-11", Belt_MutableQueue.isEmpty(Belt_MutableQueue.map(Belt_MutableQueue.fromArray([]), x => x + 1 | 0))); - -Mt.from_pair_suites("Bs_queue_test", suites.contents); - -let Q; - -exports.suites = suites; -exports.test_id = test_id; -exports.eq = eq; -exports.b = b; -exports.Q = Q; -exports.does_raise = does_raise; -exports.$plus$plus = $plus$plus; -/* q Not a pure module */ diff --git a/tests/tests/src/bs_queue_test.mjs b/tests/tests/src/bs_queue_test.mjs new file mode 100644 index 0000000000..299089540f --- /dev/null +++ b/tests/tests/src/bs_queue_test.mjs @@ -0,0 +1,1217 @@ +// Generated by ReScript, PLEASE EDIT WITH CARE + +import * as Mt from "./mt.mjs"; +import * as Belt_Array from "rescript/lib/es6/Belt_Array.js"; +import * as Primitive_object from "rescript/lib/es6/Primitive_object.js"; +import * as Belt_MutableQueue from "rescript/lib/es6/Belt_MutableQueue.js"; + +let suites = { + contents: /* [] */0 +}; + +let test_id = { + contents: 0 +}; + +function eq(loc, x, y) { + Mt.eq_suites(test_id, suites, loc, x, y); +} + +function b(loc, x) { + Mt.bool_suites(test_id, suites, loc, x); +} + +function does_raise(f, q) { + try { + f(q); + return false; + } catch (exn) { + return true; + } +} + +function $plus$plus(q, x) { + Belt_MutableQueue.add(q, x); + return q; +} + +let q = Belt_MutableQueue.make(); + +if (!(Primitive_object.equal(Belt_MutableQueue.toArray(q), []) && Belt_MutableQueue.size(q) === 0)) { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "bs_queue_test.res", + 25, + 2 + ], + Error: new Error() + }; +} + +if (!(Primitive_object.equal(Belt_MutableQueue.toArray((Belt_MutableQueue.add(q, 1), q)), [1]) && Belt_MutableQueue.size(q) === 1)) { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "bs_queue_test.res", + 26, + 2 + ], + Error: new Error() + }; +} + +if (!(Primitive_object.equal(Belt_MutableQueue.toArray((Belt_MutableQueue.add(q, 2), q)), [ + 1, + 2 + ]) && Belt_MutableQueue.size(q) === 2)) { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "bs_queue_test.res", + 27, + 2 + ], + Error: new Error() + }; +} + +if (!(Primitive_object.equal(Belt_MutableQueue.toArray((Belt_MutableQueue.add(q, 3), q)), [ + 1, + 2, + 3 + ]) && Belt_MutableQueue.size(q) === 3)) { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "bs_queue_test.res", + 28, + 2 + ], + Error: new Error() + }; +} + +if (!(Primitive_object.equal(Belt_MutableQueue.toArray((Belt_MutableQueue.add(q, 4), q)), [ + 1, + 2, + 3, + 4 + ]) && Belt_MutableQueue.size(q) === 4)) { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "bs_queue_test.res", + 29, + 2 + ], + Error: new Error() + }; +} + +if (Belt_MutableQueue.popExn(q) !== 1) { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "bs_queue_test.res", + 30, + 2 + ], + Error: new Error() + }; +} + +if (!(Primitive_object.equal(Belt_MutableQueue.toArray(q), [ + 2, + 3, + 4 + ]) && Belt_MutableQueue.size(q) === 3)) { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "bs_queue_test.res", + 31, + 2 + ], + Error: new Error() + }; +} + +if (Belt_MutableQueue.popExn(q) !== 2) { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "bs_queue_test.res", + 32, + 2 + ], + Error: new Error() + }; +} + +if (!(Primitive_object.equal(Belt_MutableQueue.toArray(q), [ + 3, + 4 + ]) && Belt_MutableQueue.size(q) === 2)) { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "bs_queue_test.res", + 33, + 2 + ], + Error: new Error() + }; +} + +if (Belt_MutableQueue.popExn(q) !== 3) { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "bs_queue_test.res", + 34, + 2 + ], + Error: new Error() + }; +} + +if (!(Primitive_object.equal(Belt_MutableQueue.toArray(q), [4]) && Belt_MutableQueue.size(q) === 1)) { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "bs_queue_test.res", + 35, + 2 + ], + Error: new Error() + }; +} + +if (Belt_MutableQueue.popExn(q) !== 4) { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "bs_queue_test.res", + 36, + 2 + ], + Error: new Error() + }; +} + +if (!(Primitive_object.equal(Belt_MutableQueue.toArray(q), []) && Belt_MutableQueue.size(q) === 0)) { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "bs_queue_test.res", + 37, + 2 + ], + Error: new Error() + }; +} + +if (!does_raise(Belt_MutableQueue.popExn, q)) { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "bs_queue_test.res", + 38, + 2 + ], + Error: new Error() + }; +} + +let q$1 = Belt_MutableQueue.make(); + +if (Belt_MutableQueue.popExn((Belt_MutableQueue.add(q$1, 1), q$1)) !== 1) { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "bs_queue_test.res", + 43, + 2 + ], + Error: new Error() + }; +} + +if (!does_raise(Belt_MutableQueue.popExn, q$1)) { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "bs_queue_test.res", + 44, + 2 + ], + Error: new Error() + }; +} + +if (Belt_MutableQueue.popExn((Belt_MutableQueue.add(q$1, 2), q$1)) !== 2) { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "bs_queue_test.res", + 45, + 2 + ], + Error: new Error() + }; +} + +if (!does_raise(Belt_MutableQueue.popExn, q$1)) { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "bs_queue_test.res", + 46, + 2 + ], + Error: new Error() + }; +} + +if (Belt_MutableQueue.size(q$1) !== 0) { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "bs_queue_test.res", + 47, + 2 + ], + Error: new Error() + }; +} + +let q$2 = Belt_MutableQueue.make(); + +if (Belt_MutableQueue.peekExn((Belt_MutableQueue.add(q$2, 1), q$2)) !== 1) { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "bs_queue_test.res", + 52, + 2 + ], + Error: new Error() + }; +} + +if (Belt_MutableQueue.peekExn((Belt_MutableQueue.add(q$2, 2), q$2)) !== 1) { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "bs_queue_test.res", + 53, + 2 + ], + Error: new Error() + }; +} + +if (Belt_MutableQueue.peekExn((Belt_MutableQueue.add(q$2, 3), q$2)) !== 1) { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "bs_queue_test.res", + 54, + 2 + ], + Error: new Error() + }; +} + +if (Belt_MutableQueue.peekExn(q$2) !== 1) { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "bs_queue_test.res", + 55, + 2 + ], + Error: new Error() + }; +} + +if (Belt_MutableQueue.popExn(q$2) !== 1) { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "bs_queue_test.res", + 56, + 2 + ], + Error: new Error() + }; +} + +if (Belt_MutableQueue.peekExn(q$2) !== 2) { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "bs_queue_test.res", + 57, + 2 + ], + Error: new Error() + }; +} + +if (Belt_MutableQueue.popExn(q$2) !== 2) { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "bs_queue_test.res", + 58, + 2 + ], + Error: new Error() + }; +} + +if (Belt_MutableQueue.peekExn(q$2) !== 3) { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "bs_queue_test.res", + 59, + 2 + ], + Error: new Error() + }; +} + +if (Belt_MutableQueue.popExn(q$2) !== 3) { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "bs_queue_test.res", + 60, + 2 + ], + Error: new Error() + }; +} + +if (!does_raise(Belt_MutableQueue.peekExn, q$2)) { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "bs_queue_test.res", + 61, + 2 + ], + Error: new Error() + }; +} + +if (!does_raise(Belt_MutableQueue.peekExn, q$2)) { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "bs_queue_test.res", + 62, + 2 + ], + Error: new Error() + }; +} + +let q$3 = Belt_MutableQueue.make(); + +for (let i = 1; i <= 10; ++i) { + Belt_MutableQueue.add(q$3, i); +} + +Belt_MutableQueue.clear(q$3); + +if (Belt_MutableQueue.size(q$3) !== 0) { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "bs_queue_test.res", + 71, + 2 + ], + Error: new Error() + }; +} + +if (!does_raise(Belt_MutableQueue.popExn, q$3)) { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "bs_queue_test.res", + 72, + 2 + ], + Error: new Error() + }; +} + +if (!Primitive_object.equal(q$3, Belt_MutableQueue.make())) { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "bs_queue_test.res", + 73, + 2 + ], + Error: new Error() + }; +} + +Belt_MutableQueue.add(q$3, 42); + +if (Belt_MutableQueue.popExn(q$3) !== 42) { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "bs_queue_test.res", + 75, + 2 + ], + Error: new Error() + }; +} + +let q1 = Belt_MutableQueue.make(); + +for (let i$1 = 1; i$1 <= 10; ++i$1) { + Belt_MutableQueue.add(q1, i$1); +} + +let q2 = Belt_MutableQueue.copy(q1); + +if (!Primitive_object.equal(Belt_MutableQueue.toArray(q1), [ + 1, + 2, + 3, + 4, + 5, + 6, + 7, + 8, + 9, + 10 + ])) { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "bs_queue_test.res", + 84, + 2 + ], + Error: new Error() + }; +} + +if (!Primitive_object.equal(Belt_MutableQueue.toArray(q2), [ + 1, + 2, + 3, + 4, + 5, + 6, + 7, + 8, + 9, + 10 + ])) { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "bs_queue_test.res", + 85, + 2 + ], + Error: new Error() + }; +} + +if (Belt_MutableQueue.size(q1) !== 10) { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "bs_queue_test.res", + 86, + 2 + ], + Error: new Error() + }; +} + +if (Belt_MutableQueue.size(q2) !== 10) { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "bs_queue_test.res", + 87, + 2 + ], + Error: new Error() + }; +} + +for (let i$2 = 1; i$2 <= 10; ++i$2) { + if (Belt_MutableQueue.popExn(q1) !== i$2) { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "bs_queue_test.res", + 89, + 4 + ], + Error: new Error() + }; + } + +} + +for (let i$3 = 1; i$3 <= 10; ++i$3) { + if (Belt_MutableQueue.popExn(q2) !== i$3) { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "bs_queue_test.res", + 92, + 4 + ], + Error: new Error() + }; + } + +} + +let q$4 = Belt_MutableQueue.make(); + +if (!Belt_MutableQueue.isEmpty(q$4)) { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "bs_queue_test.res", + 98, + 2 + ], + Error: new Error() + }; +} + +for (let i$4 = 1; i$4 <= 10; ++i$4) { + Belt_MutableQueue.add(q$4, i$4); + if (Belt_MutableQueue.size(q$4) !== i$4) { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "bs_queue_test.res", + 101, + 4 + ], + Error: new Error() + }; + } + if (Belt_MutableQueue.isEmpty(q$4)) { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "bs_queue_test.res", + 102, + 4 + ], + Error: new Error() + }; + } + +} + +for (let i$5 = 10; i$5 >= 1; --i$5) { + if (Belt_MutableQueue.size(q$4) !== i$5) { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "bs_queue_test.res", + 105, + 4 + ], + Error: new Error() + }; + } + if (Belt_MutableQueue.isEmpty(q$4)) { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "bs_queue_test.res", + 106, + 4 + ], + Error: new Error() + }; + } + Belt_MutableQueue.popExn(q$4); +} + +if (Belt_MutableQueue.size(q$4) !== 0) { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "bs_queue_test.res", + 109, + 2 + ], + Error: new Error() + }; +} + +if (!Belt_MutableQueue.isEmpty(q$4)) { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "bs_queue_test.res", + 110, + 2 + ], + Error: new Error() + }; +} + +let q$5 = Belt_MutableQueue.make(); + +for (let i$6 = 1; i$6 <= 10; ++i$6) { + Belt_MutableQueue.add(q$5, i$6); +} + +let i$7 = { + contents: 1 +}; + +Belt_MutableQueue.forEach(q$5, j => { + if (i$7.contents !== j) { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "bs_queue_test.res", + 120, + 4 + ], + Error: new Error() + }; + } + i$7.contents = i$7.contents + 1 | 0; +}); + +let q1$1 = Belt_MutableQueue.make(); + +let q2$1 = Belt_MutableQueue.make(); + +if (Belt_MutableQueue.size(q1$1) !== 0) { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "bs_queue_test.res", + 127, + 2 + ], + Error: new Error() + }; +} + +if (!Primitive_object.equal(Belt_MutableQueue.toArray(q1$1), [])) { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "bs_queue_test.res", + 128, + 2 + ], + Error: new Error() + }; +} + +if (Belt_MutableQueue.size(q2$1) !== 0) { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "bs_queue_test.res", + 129, + 2 + ], + Error: new Error() + }; +} + +if (!Primitive_object.equal(Belt_MutableQueue.toArray(q2$1), [])) { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "bs_queue_test.res", + 130, + 2 + ], + Error: new Error() + }; +} + +Belt_MutableQueue.transfer(q1$1, q2$1); + +if (Belt_MutableQueue.size(q1$1) !== 0) { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "bs_queue_test.res", + 132, + 2 + ], + Error: new Error() + }; +} + +if (!Primitive_object.equal(Belt_MutableQueue.toArray(q1$1), [])) { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "bs_queue_test.res", + 133, + 2 + ], + Error: new Error() + }; +} + +if (Belt_MutableQueue.size(q2$1) !== 0) { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "bs_queue_test.res", + 134, + 2 + ], + Error: new Error() + }; +} + +if (!Primitive_object.equal(Belt_MutableQueue.toArray(q2$1), [])) { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "bs_queue_test.res", + 135, + 2 + ], + Error: new Error() + }; +} + +let q1$2 = Belt_MutableQueue.make(); + +let q2$2 = Belt_MutableQueue.make(); + +for (let i$8 = 1; i$8 <= 4; ++i$8) { + Belt_MutableQueue.add(q1$2, i$8); +} + +if (Belt_MutableQueue.size(q1$2) !== 4) { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "bs_queue_test.res", + 143, + 2 + ], + Error: new Error() + }; +} + +if (!Primitive_object.equal(Belt_MutableQueue.toArray(q1$2), [ + 1, + 2, + 3, + 4 + ])) { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "bs_queue_test.res", + 144, + 2 + ], + Error: new Error() + }; +} + +if (Belt_MutableQueue.size(q2$2) !== 0) { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "bs_queue_test.res", + 145, + 2 + ], + Error: new Error() + }; +} + +if (!Primitive_object.equal(Belt_MutableQueue.toArray(q2$2), [])) { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "bs_queue_test.res", + 146, + 2 + ], + Error: new Error() + }; +} + +Belt_MutableQueue.transfer(q1$2, q2$2); + +if (Belt_MutableQueue.size(q1$2) !== 0) { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "bs_queue_test.res", + 148, + 2 + ], + Error: new Error() + }; +} + +if (!Primitive_object.equal(Belt_MutableQueue.toArray(q1$2), [])) { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "bs_queue_test.res", + 149, + 2 + ], + Error: new Error() + }; +} + +if (Belt_MutableQueue.size(q2$2) !== 4) { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "bs_queue_test.res", + 150, + 2 + ], + Error: new Error() + }; +} + +if (!Primitive_object.equal(Belt_MutableQueue.toArray(q2$2), [ + 1, + 2, + 3, + 4 + ])) { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "bs_queue_test.res", + 151, + 2 + ], + Error: new Error() + }; +} + +let q1$3 = Belt_MutableQueue.make(); + +let q2$3 = Belt_MutableQueue.make(); + +for (let i$9 = 5; i$9 <= 8; ++i$9) { + Belt_MutableQueue.add(q2$3, i$9); +} + +if (Belt_MutableQueue.size(q1$3) !== 0) { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "bs_queue_test.res", + 159, + 2 + ], + Error: new Error() + }; +} + +if (!Primitive_object.equal(Belt_MutableQueue.toArray(q1$3), [])) { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "bs_queue_test.res", + 160, + 2 + ], + Error: new Error() + }; +} + +if (Belt_MutableQueue.size(q2$3) !== 4) { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "bs_queue_test.res", + 161, + 2 + ], + Error: new Error() + }; +} + +if (!Primitive_object.equal(Belt_MutableQueue.toArray(q2$3), [ + 5, + 6, + 7, + 8 + ])) { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "bs_queue_test.res", + 162, + 2 + ], + Error: new Error() + }; +} + +Belt_MutableQueue.transfer(q1$3, q2$3); + +if (Belt_MutableQueue.size(q1$3) !== 0) { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "bs_queue_test.res", + 164, + 2 + ], + Error: new Error() + }; +} + +if (!Primitive_object.equal(Belt_MutableQueue.toArray(q1$3), [])) { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "bs_queue_test.res", + 165, + 2 + ], + Error: new Error() + }; +} + +if (Belt_MutableQueue.size(q2$3) !== 4) { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "bs_queue_test.res", + 166, + 2 + ], + Error: new Error() + }; +} + +if (!Primitive_object.equal(Belt_MutableQueue.toArray(q2$3), [ + 5, + 6, + 7, + 8 + ])) { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "bs_queue_test.res", + 167, + 2 + ], + Error: new Error() + }; +} + +let q1$4 = Belt_MutableQueue.make(); + +let q2$4 = Belt_MutableQueue.make(); + +for (let i$10 = 1; i$10 <= 4; ++i$10) { + Belt_MutableQueue.add(q1$4, i$10); +} + +for (let i$11 = 5; i$11 <= 8; ++i$11) { + Belt_MutableQueue.add(q2$4, i$11); +} + +if (Belt_MutableQueue.size(q1$4) !== 4) { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "bs_queue_test.res", + 178, + 2 + ], + Error: new Error() + }; +} + +if (!Primitive_object.equal(Belt_MutableQueue.toArray(q1$4), [ + 1, + 2, + 3, + 4 + ])) { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "bs_queue_test.res", + 179, + 2 + ], + Error: new Error() + }; +} + +if (Belt_MutableQueue.size(q2$4) !== 4) { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "bs_queue_test.res", + 180, + 2 + ], + Error: new Error() + }; +} + +if (!Primitive_object.equal(Belt_MutableQueue.toArray(q2$4), [ + 5, + 6, + 7, + 8 + ])) { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "bs_queue_test.res", + 181, + 2 + ], + Error: new Error() + }; +} + +Belt_MutableQueue.transfer(q1$4, q2$4); + +if (Belt_MutableQueue.size(q1$4) !== 0) { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "bs_queue_test.res", + 183, + 2 + ], + Error: new Error() + }; +} + +if (!Primitive_object.equal(Belt_MutableQueue.toArray(q1$4), [])) { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "bs_queue_test.res", + 184, + 2 + ], + Error: new Error() + }; +} + +let v = [ + 5, + 6, + 7, + 8, + 1, + 2, + 3, + 4 +]; + +if (Belt_MutableQueue.size(q2$4) !== 8) { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "bs_queue_test.res", + 186, + 2 + ], + Error: new Error() + }; +} + +if (!Primitive_object.equal(Belt_MutableQueue.toArray(q2$4), v)) { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "bs_queue_test.res", + 187, + 2 + ], + Error: new Error() + }; +} + +if (Belt_MutableQueue.reduce(q2$4, 0, (x, y) => x - y | 0) !== Belt_Array.reduce(v, 0, (x, y) => x - y | 0)) { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "bs_queue_test.res", + 189, + 2 + ], + Error: new Error() + }; +} + +console.log("OK"); + +let q$6 = Belt_MutableQueue.fromArray([ + 1, + 2, + 3, + 4 +]); + +let q1$5 = Belt_MutableQueue.map(q$6, x => x - 1 | 0); + +eq("File \"bs_queue_test.res\", line 197, characters 5-12", Belt_MutableQueue.toArray(q1$5), [ + 0, + 1, + 2, + 3 +]); + +b("File \"bs_queue_test.res\", line 198, characters 4-11", Belt_MutableQueue.isEmpty(Belt_MutableQueue.fromArray([]))); + +b("File \"bs_queue_test.res\", line 199, characters 4-11", Belt_MutableQueue.isEmpty(Belt_MutableQueue.map(Belt_MutableQueue.fromArray([]), x => x + 1 | 0))); + +Mt.from_pair_suites("Bs_queue_test", suites.contents); + +let Q; + +export { + suites, + test_id, + eq, + b, + Q, + does_raise, + $plus$plus, +} +/* q Not a pure module */ diff --git a/tests/tests/src/bs_rest_test.js b/tests/tests/src/bs_rest_test.js deleted file mode 100644 index c982367412..0000000000 --- a/tests/tests/src/bs_rest_test.js +++ /dev/null @@ -1,24 +0,0 @@ -// Generated by ReScript, PLEASE EDIT WITH CARE -'use strict'; - - -function x(v){return [v]} -; - -x("3"); - -let v = x(3); - -function xxx(prim) { - return x(prim); -} - -let u = x(3); - -let xx = x("3"); - -exports.v = v; -exports.xxx = xxx; -exports.u = u; -exports.xx = xx; -/* Not a pure module */ diff --git a/tests/tests/src/bs_rest_test.mjs b/tests/tests/src/bs_rest_test.mjs new file mode 100644 index 0000000000..49a1c83502 --- /dev/null +++ b/tests/tests/src/bs_rest_test.mjs @@ -0,0 +1,25 @@ +// Generated by ReScript, PLEASE EDIT WITH CARE + + +function x(v){return [v]} +; + +x("3"); + +let v = x(3); + +function xxx(prim) { + return x(prim); +} + +let u = x(3); + +let xx = x("3"); + +export { + v, + xxx, + u, + xx, +} +/* Not a pure module */ diff --git a/tests/tests/src/bs_set_int_test.js b/tests/tests/src/bs_set_int_test.js deleted file mode 100644 index 84a499983b..0000000000 --- a/tests/tests/src/bs_set_int_test.js +++ /dev/null @@ -1,385 +0,0 @@ -// Generated by ReScript, PLEASE EDIT WITH CARE -'use strict'; - -let Mt = require("./mt.js"); -let Belt_List = require("rescript/lib/js/Belt_List.js"); -let Belt_Array = require("rescript/lib/js/Belt_Array.js"); -let Belt_SetInt = require("rescript/lib/js/Belt_SetInt.js"); -let Array_data_util = require("./array_data_util.js"); - -let suites = { - contents: /* [] */0 -}; - -let test_id = { - contents: 0 -}; - -function eq(loc, x, y) { - Mt.eq_suites(test_id, suites, loc, x, y); -} - -function b(loc, v) { - Mt.bool_suites(test_id, suites, loc, v); -} - -function $eq$tilde(s, i) { - return Belt_SetInt.eq(Belt_SetInt.fromArray(i), s); -} - -function $eq$star(a, b) { - return Belt_SetInt.eq(Belt_SetInt.fromArray(a), Belt_SetInt.fromArray(b)); -} - -b("File \"bs_set_int_test.res\", line 22, characters 11-18", $eq$star([ - 1, - 2, - 3 -], [ - 3, - 2, - 1 -])); - -let u = Belt_SetInt.intersect(Belt_SetInt.fromArray([ - 1, - 2, - 3 -]), Belt_SetInt.fromArray([ - 3, - 4, - 5 -])); - -b("File \"bs_set_int_test.res\", line 28, characters 11-18", Belt_SetInt.eq(Belt_SetInt.fromArray([3]), u)); - -function range(i, j) { - return Belt_Array.init((j - i | 0) + 1 | 0, k => k + i | 0); -} - -function revRange(i, j) { - return Belt_List.toArray(Belt_List.reverse(Belt_List.fromArray(Belt_Array.init((j - i | 0) + 1 | 0, k => k + i | 0)))); -} - -let v = Belt_SetInt.fromArray(Belt_Array.concat(range(100, 1000), revRange(400, 1500))); - -let i = range(100, 1500); - -b("File \"bs_set_int_test.res\", line 37, characters 4-11", Belt_SetInt.eq(Belt_SetInt.fromArray(i), v)); - -let match = Belt_SetInt.partition(v, x => x % 3 === 0); - -let l; - -let r; - -for (let i$1 = 100; i$1 <= 1500; ++i$1) { - if (i$1 % 3 === 0) { - l = Belt_SetInt.add(l, i$1); - } else { - r = Belt_SetInt.add(r, i$1); - } -} - -let nl = l; - -let nr = r; - -b("File \"bs_set_int_test.res\", line 50, characters 4-11", Belt_SetInt.eq(match[0], nl)); - -b("File \"bs_set_int_test.res\", line 51, characters 4-11", Belt_SetInt.eq(match[1], nr)); - -let i$2 = range(50, 100); - -let s = Belt_SetInt.intersect(Belt_SetInt.fromArray(range(1, 100)), Belt_SetInt.fromArray(range(50, 200))); - -b("File \"bs_set_int_test.res\", line 55, characters 2-9", Belt_SetInt.eq(Belt_SetInt.fromArray(i$2), s)); - -let i$3 = range(1, 200); - -let s$1 = Belt_SetInt.union(Belt_SetInt.fromArray(range(1, 100)), Belt_SetInt.fromArray(range(50, 200))); - -b("File \"bs_set_int_test.res\", line 66, characters 2-9", Belt_SetInt.eq(Belt_SetInt.fromArray(i$3), s$1)); - -let i$4 = range(1, 49); - -let s$2 = Belt_SetInt.diff(Belt_SetInt.fromArray(range(1, 100)), Belt_SetInt.fromArray(range(50, 200))); - -b("File \"bs_set_int_test.res\", line 77, characters 2-9", Belt_SetInt.eq(Belt_SetInt.fromArray(i$4), s$2)); - -let i$5 = revRange(50, 100); - -let s$3 = Belt_SetInt.intersect(Belt_SetInt.fromArray(revRange(1, 100)), Belt_SetInt.fromArray(revRange(50, 200))); - -b("File \"bs_set_int_test.res\", line 88, characters 2-9", Belt_SetInt.eq(Belt_SetInt.fromArray(i$5), s$3)); - -let i$6 = revRange(1, 200); - -let s$4 = Belt_SetInt.union(Belt_SetInt.fromArray(revRange(1, 100)), Belt_SetInt.fromArray(revRange(50, 200))); - -b("File \"bs_set_int_test.res\", line 99, characters 2-9", Belt_SetInt.eq(Belt_SetInt.fromArray(i$6), s$4)); - -let i$7 = revRange(1, 49); - -let s$5 = Belt_SetInt.diff(Belt_SetInt.fromArray(revRange(1, 100)), Belt_SetInt.fromArray(revRange(50, 200))); - -b("File \"bs_set_int_test.res\", line 110, characters 2-9", Belt_SetInt.eq(Belt_SetInt.fromArray(i$7), s$5)); - -let ss = [ - 1, - 222, - 3, - 4, - 2, - 0, - 33, - -1 -]; - -let v$1 = Belt_SetInt.fromArray([ - 1, - 222, - 3, - 4, - 2, - 0, - 33, - -1 -]); - -let minv = Belt_SetInt.minUndefined(v$1); - -let maxv = Belt_SetInt.maxUndefined(v$1); - -function approx(loc, x, y) { - b(loc, x === y); -} - -eq("File \"bs_set_int_test.res\", line 125, characters 5-12", Belt_SetInt.reduce(v$1, 0, (x, y) => x + y | 0), Belt_Array.reduce(ss, 0, (prim0, prim1) => prim0 + prim1 | 0)); - -approx("File \"bs_set_int_test.res\", line 126, characters 9-16", -1, minv); - -approx("File \"bs_set_int_test.res\", line 127, characters 9-16", 222, maxv); - -let v$2 = Belt_SetInt.remove(v$1, 3); - -let minv$1 = Belt_SetInt.minimum(v$2); - -let maxv$1 = Belt_SetInt.maximum(v$2); - -eq("File \"bs_set_int_test.res\", line 130, characters 5-12", minv$1, -1); - -eq("File \"bs_set_int_test.res\", line 131, characters 5-12", maxv$1, 222); - -let v$3 = Belt_SetInt.remove(v$2, 222); - -let minv$2 = Belt_SetInt.minimum(v$3); - -let maxv$2 = Belt_SetInt.maximum(v$3); - -eq("File \"bs_set_int_test.res\", line 134, characters 5-12", minv$2, -1); - -eq("File \"bs_set_int_test.res\", line 135, characters 5-12", maxv$2, 33); - -let v$4 = Belt_SetInt.remove(v$3, -1); - -let minv$3 = Belt_SetInt.minimum(v$4); - -let maxv$3 = Belt_SetInt.maximum(v$4); - -eq("File \"bs_set_int_test.res\", line 138, characters 5-12", minv$3, 0); - -eq("File \"bs_set_int_test.res\", line 139, characters 5-12", maxv$3, 33); - -let v$5 = Belt_SetInt.remove(v$4, 0); - -let v$6 = Belt_SetInt.remove(v$5, 33); - -let v$7 = Belt_SetInt.remove(v$6, 2); - -let v$8 = Belt_SetInt.remove(v$7, 3); - -let v$9 = Belt_SetInt.remove(v$8, 4); - -let v$10 = Belt_SetInt.remove(v$9, 1); - -b("File \"bs_set_int_test.res\", line 146, characters 4-11", Belt_SetInt.isEmpty(v$10)); - -let v$11 = Belt_Array.makeByAndShuffle(1000000, i => i); - -let u$1 = Belt_SetInt.fromArray(v$11); - -Belt_SetInt.checkInvariantInternal(u$1); - -let firstHalf = Belt_Array.slice(v$11, 0, 2000); - -let xx = Belt_Array.reduce(firstHalf, u$1, Belt_SetInt.remove); - -Belt_SetInt.checkInvariantInternal(u$1); - -b("File \"bs_set_int_test.res\", line 158, characters 4-11", Belt_SetInt.eq(Belt_SetInt.union(Belt_SetInt.fromArray(firstHalf), xx), u$1)); - -let aa = Belt_SetInt.fromArray(Array_data_util.randomRange(0, 100)); - -let bb = Belt_SetInt.fromArray(Array_data_util.randomRange(0, 200)); - -let cc = Belt_SetInt.fromArray(Array_data_util.randomRange(120, 200)); - -let dd = Belt_SetInt.union(aa, cc); - -b("File \"bs_set_int_test.res\", line 171, characters 4-11", Belt_SetInt.subset(aa, bb)); - -b("File \"bs_set_int_test.res\", line 172, characters 4-11", Belt_SetInt.subset(dd, bb)); - -b("File \"bs_set_int_test.res\", line 173, characters 4-11", Belt_SetInt.subset(Belt_SetInt.add(dd, 200), bb)); - -b("File \"bs_set_int_test.res\", line 174, characters 4-11", Belt_SetInt.add(dd, 200) === dd); - -b("File \"bs_set_int_test.res\", line 175, characters 4-11", Belt_SetInt.add(dd, 0) === dd); - -b("File \"bs_set_int_test.res\", line 176, characters 4-11", !Belt_SetInt.subset(Belt_SetInt.add(dd, 201), bb)); - -let aa$1 = Belt_SetInt.fromArray(Array_data_util.randomRange(0, 100)); - -let bb$1 = Belt_SetInt.fromArray(Array_data_util.randomRange(0, 100)); - -let cc$1 = Belt_SetInt.add(bb$1, 101); - -let dd$1 = Belt_SetInt.remove(bb$1, 99); - -let ee = Belt_SetInt.add(dd$1, 101); - -b("File \"bs_set_int_test.res\", line 185, characters 4-11", Belt_SetInt.eq(aa$1, bb$1)); - -b("File \"bs_set_int_test.res\", line 186, characters 4-11", !Belt_SetInt.eq(aa$1, cc$1)); - -b("File \"bs_set_int_test.res\", line 187, characters 4-11", !Belt_SetInt.eq(dd$1, cc$1)); - -b("File \"bs_set_int_test.res\", line 188, characters 4-11", !Belt_SetInt.eq(bb$1, ee)); - -let a1 = Belt_SetInt.mergeMany(undefined, Array_data_util.randomRange(0, 100)); - -let a2 = Belt_SetInt.removeMany(a1, Array_data_util.randomRange(40, 100)); - -let a3 = Belt_SetInt.fromArray(Array_data_util.randomRange(0, 39)); - -let match$1 = Belt_SetInt.split(a1, 40); - -let match$2 = match$1[0]; - -let a5 = match$2[1]; - -let a4 = match$2[0]; - -b("File \"bs_set_int_test.res\", line 197, characters 4-11", Belt_SetInt.eq(a1, Belt_SetInt.fromArray(Array_data_util.randomRange(0, 100)))); - -b("File \"bs_set_int_test.res\", line 198, characters 4-11", Belt_SetInt.eq(a2, a3)); - -b("File \"bs_set_int_test.res\", line 199, characters 4-11", match$1[1]); - -b("File \"bs_set_int_test.res\", line 200, characters 4-11", Belt_SetInt.eq(a3, a4)); - -let a6 = Belt_SetInt.remove(Belt_SetInt.removeMany(a1, Array_data_util.randomRange(0, 39)), 40); - -b("File \"bs_set_int_test.res\", line 202, characters 4-11", Belt_SetInt.eq(a5, a6)); - -let a7 = Belt_SetInt.remove(a1, 40); - -let match$3 = Belt_SetInt.split(a7, 40); - -let match$4 = match$3[0]; - -let a9 = match$4[1]; - -b("File \"bs_set_int_test.res\", line 205, characters 4-11", !match$3[1]); - -b("File \"bs_set_int_test.res\", line 206, characters 4-11", Belt_SetInt.eq(a4, match$4[0])); - -b("File \"bs_set_int_test.res\", line 207, characters 4-11", Belt_SetInt.eq(a5, a9)); - -let a10 = Belt_SetInt.removeMany(a9, Array_data_util.randomRange(42, 2000)); - -eq("File \"bs_set_int_test.res\", line 209, characters 5-12", Belt_SetInt.size(a10), 1); - -let a11 = Belt_SetInt.removeMany(a9, Array_data_util.randomRange(0, 2000)); - -b("File \"bs_set_int_test.res\", line 211, characters 4-11", Belt_SetInt.isEmpty(a11)); - -let match$5 = Belt_SetInt.split(undefined, 0); - -let match$6 = match$5[0]; - -b("File \"bs_set_int_test.res\", line 216, characters 4-11", Belt_SetInt.isEmpty(match$6[0])); - -b("File \"bs_set_int_test.res\", line 217, characters 4-11", Belt_SetInt.isEmpty(match$6[1])); - -b("File \"bs_set_int_test.res\", line 218, characters 4-11", !match$5[1]); - -let v$12 = Belt_SetInt.fromArray(Array_data_util.randomRange(0, 2000)); - -let v0 = Belt_SetInt.fromArray(Array_data_util.randomRange(0, 2000)); - -let v1 = Belt_SetInt.fromArray(Array_data_util.randomRange(1, 2001)); - -let v2 = Belt_SetInt.fromArray(Array_data_util.randomRange(3, 2002)); - -let v3 = Belt_SetInt.removeMany(v2, [ - 2002, - 2001 -]); - -let us = Belt_Array.map(Array_data_util.randomRange(1000, 3000), x => Belt_SetInt.has(v$12, x)); - -let counted = Belt_Array.reduce(us, 0, (acc, x) => { - if (x) { - return acc + 1 | 0; - } else { - return acc; - } -}); - -eq("File \"bs_set_int_test.res\", line 235, characters 5-12", counted, 1001); - -b("File \"bs_set_int_test.res\", line 236, characters 4-11", Belt_SetInt.eq(v$12, v0)); - -b("File \"bs_set_int_test.res\", line 237, characters 4-11", Belt_SetInt.cmp(v$12, v0) === 0); - -b("File \"bs_set_int_test.res\", line 238, characters 4-11", Belt_SetInt.cmp(v$12, v1) < 0); - -b("File \"bs_set_int_test.res\", line 239, characters 4-11", Belt_SetInt.cmp(v$12, v2) > 0); - -b("File \"bs_set_int_test.res\", line 240, characters 4-11", Belt_SetInt.subset(v3, v0)); - -b("File \"bs_set_int_test.res\", line 241, characters 4-11", !Belt_SetInt.subset(v1, v0)); - -eq("File \"bs_set_int_test.res\", line 242, characters 5-12", Belt_SetInt.get(v$12, 30), 30); - -eq("File \"bs_set_int_test.res\", line 243, characters 5-12", Belt_SetInt.get(v$12, 3000), undefined); - -Mt.from_pair_suites("Bs_set_int_test", suites.contents); - -let N; - -let I; - -let L; - -let A; - -let ofA = Belt_SetInt.fromArray; - -exports.suites = suites; -exports.test_id = test_id; -exports.eq = eq; -exports.b = b; -exports.N = N; -exports.I = I; -exports.L = L; -exports.A = A; -exports.$eq$tilde = $eq$tilde; -exports.$eq$star = $eq$star; -exports.ofA = ofA; -exports.u = u; -exports.range = range; -exports.revRange = revRange; -/* Not a pure module */ diff --git a/tests/tests/src/bs_set_int_test.mjs b/tests/tests/src/bs_set_int_test.mjs new file mode 100644 index 0000000000..26b26e5458 --- /dev/null +++ b/tests/tests/src/bs_set_int_test.mjs @@ -0,0 +1,386 @@ +// Generated by ReScript, PLEASE EDIT WITH CARE + +import * as Mt from "./mt.mjs"; +import * as Belt_List from "rescript/lib/es6/Belt_List.js"; +import * as Belt_Array from "rescript/lib/es6/Belt_Array.js"; +import * as Belt_SetInt from "rescript/lib/es6/Belt_SetInt.js"; +import * as Array_data_util from "./array_data_util.mjs"; + +let suites = { + contents: /* [] */0 +}; + +let test_id = { + contents: 0 +}; + +function eq(loc, x, y) { + Mt.eq_suites(test_id, suites, loc, x, y); +} + +function b(loc, v) { + Mt.bool_suites(test_id, suites, loc, v); +} + +function $eq$tilde(s, i) { + return Belt_SetInt.eq(Belt_SetInt.fromArray(i), s); +} + +function $eq$star(a, b) { + return Belt_SetInt.eq(Belt_SetInt.fromArray(a), Belt_SetInt.fromArray(b)); +} + +b("File \"bs_set_int_test.res\", line 22, characters 11-18", $eq$star([ + 1, + 2, + 3 +], [ + 3, + 2, + 1 +])); + +let u = Belt_SetInt.intersect(Belt_SetInt.fromArray([ + 1, + 2, + 3 +]), Belt_SetInt.fromArray([ + 3, + 4, + 5 +])); + +b("File \"bs_set_int_test.res\", line 28, characters 11-18", Belt_SetInt.eq(Belt_SetInt.fromArray([3]), u)); + +function range(i, j) { + return Belt_Array.init((j - i | 0) + 1 | 0, k => k + i | 0); +} + +function revRange(i, j) { + return Belt_List.toArray(Belt_List.reverse(Belt_List.fromArray(Belt_Array.init((j - i | 0) + 1 | 0, k => k + i | 0)))); +} + +let v = Belt_SetInt.fromArray(Belt_Array.concat(range(100, 1000), revRange(400, 1500))); + +let i = range(100, 1500); + +b("File \"bs_set_int_test.res\", line 37, characters 4-11", Belt_SetInt.eq(Belt_SetInt.fromArray(i), v)); + +let match = Belt_SetInt.partition(v, x => x % 3 === 0); + +let l; + +let r; + +for (let i$1 = 100; i$1 <= 1500; ++i$1) { + if (i$1 % 3 === 0) { + l = Belt_SetInt.add(l, i$1); + } else { + r = Belt_SetInt.add(r, i$1); + } +} + +let nl = l; + +let nr = r; + +b("File \"bs_set_int_test.res\", line 50, characters 4-11", Belt_SetInt.eq(match[0], nl)); + +b("File \"bs_set_int_test.res\", line 51, characters 4-11", Belt_SetInt.eq(match[1], nr)); + +let i$2 = range(50, 100); + +let s = Belt_SetInt.intersect(Belt_SetInt.fromArray(range(1, 100)), Belt_SetInt.fromArray(range(50, 200))); + +b("File \"bs_set_int_test.res\", line 55, characters 2-9", Belt_SetInt.eq(Belt_SetInt.fromArray(i$2), s)); + +let i$3 = range(1, 200); + +let s$1 = Belt_SetInt.union(Belt_SetInt.fromArray(range(1, 100)), Belt_SetInt.fromArray(range(50, 200))); + +b("File \"bs_set_int_test.res\", line 66, characters 2-9", Belt_SetInt.eq(Belt_SetInt.fromArray(i$3), s$1)); + +let i$4 = range(1, 49); + +let s$2 = Belt_SetInt.diff(Belt_SetInt.fromArray(range(1, 100)), Belt_SetInt.fromArray(range(50, 200))); + +b("File \"bs_set_int_test.res\", line 77, characters 2-9", Belt_SetInt.eq(Belt_SetInt.fromArray(i$4), s$2)); + +let i$5 = revRange(50, 100); + +let s$3 = Belt_SetInt.intersect(Belt_SetInt.fromArray(revRange(1, 100)), Belt_SetInt.fromArray(revRange(50, 200))); + +b("File \"bs_set_int_test.res\", line 88, characters 2-9", Belt_SetInt.eq(Belt_SetInt.fromArray(i$5), s$3)); + +let i$6 = revRange(1, 200); + +let s$4 = Belt_SetInt.union(Belt_SetInt.fromArray(revRange(1, 100)), Belt_SetInt.fromArray(revRange(50, 200))); + +b("File \"bs_set_int_test.res\", line 99, characters 2-9", Belt_SetInt.eq(Belt_SetInt.fromArray(i$6), s$4)); + +let i$7 = revRange(1, 49); + +let s$5 = Belt_SetInt.diff(Belt_SetInt.fromArray(revRange(1, 100)), Belt_SetInt.fromArray(revRange(50, 200))); + +b("File \"bs_set_int_test.res\", line 110, characters 2-9", Belt_SetInt.eq(Belt_SetInt.fromArray(i$7), s$5)); + +let ss = [ + 1, + 222, + 3, + 4, + 2, + 0, + 33, + -1 +]; + +let v$1 = Belt_SetInt.fromArray([ + 1, + 222, + 3, + 4, + 2, + 0, + 33, + -1 +]); + +let minv = Belt_SetInt.minUndefined(v$1); + +let maxv = Belt_SetInt.maxUndefined(v$1); + +function approx(loc, x, y) { + b(loc, x === y); +} + +eq("File \"bs_set_int_test.res\", line 125, characters 5-12", Belt_SetInt.reduce(v$1, 0, (x, y) => x + y | 0), Belt_Array.reduce(ss, 0, (prim0, prim1) => prim0 + prim1 | 0)); + +approx("File \"bs_set_int_test.res\", line 126, characters 9-16", -1, minv); + +approx("File \"bs_set_int_test.res\", line 127, characters 9-16", 222, maxv); + +let v$2 = Belt_SetInt.remove(v$1, 3); + +let minv$1 = Belt_SetInt.minimum(v$2); + +let maxv$1 = Belt_SetInt.maximum(v$2); + +eq("File \"bs_set_int_test.res\", line 130, characters 5-12", minv$1, -1); + +eq("File \"bs_set_int_test.res\", line 131, characters 5-12", maxv$1, 222); + +let v$3 = Belt_SetInt.remove(v$2, 222); + +let minv$2 = Belt_SetInt.minimum(v$3); + +let maxv$2 = Belt_SetInt.maximum(v$3); + +eq("File \"bs_set_int_test.res\", line 134, characters 5-12", minv$2, -1); + +eq("File \"bs_set_int_test.res\", line 135, characters 5-12", maxv$2, 33); + +let v$4 = Belt_SetInt.remove(v$3, -1); + +let minv$3 = Belt_SetInt.minimum(v$4); + +let maxv$3 = Belt_SetInt.maximum(v$4); + +eq("File \"bs_set_int_test.res\", line 138, characters 5-12", minv$3, 0); + +eq("File \"bs_set_int_test.res\", line 139, characters 5-12", maxv$3, 33); + +let v$5 = Belt_SetInt.remove(v$4, 0); + +let v$6 = Belt_SetInt.remove(v$5, 33); + +let v$7 = Belt_SetInt.remove(v$6, 2); + +let v$8 = Belt_SetInt.remove(v$7, 3); + +let v$9 = Belt_SetInt.remove(v$8, 4); + +let v$10 = Belt_SetInt.remove(v$9, 1); + +b("File \"bs_set_int_test.res\", line 146, characters 4-11", Belt_SetInt.isEmpty(v$10)); + +let v$11 = Belt_Array.makeByAndShuffle(1000000, i => i); + +let u$1 = Belt_SetInt.fromArray(v$11); + +Belt_SetInt.checkInvariantInternal(u$1); + +let firstHalf = Belt_Array.slice(v$11, 0, 2000); + +let xx = Belt_Array.reduce(firstHalf, u$1, Belt_SetInt.remove); + +Belt_SetInt.checkInvariantInternal(u$1); + +b("File \"bs_set_int_test.res\", line 158, characters 4-11", Belt_SetInt.eq(Belt_SetInt.union(Belt_SetInt.fromArray(firstHalf), xx), u$1)); + +let aa = Belt_SetInt.fromArray(Array_data_util.randomRange(0, 100)); + +let bb = Belt_SetInt.fromArray(Array_data_util.randomRange(0, 200)); + +let cc = Belt_SetInt.fromArray(Array_data_util.randomRange(120, 200)); + +let dd = Belt_SetInt.union(aa, cc); + +b("File \"bs_set_int_test.res\", line 171, characters 4-11", Belt_SetInt.subset(aa, bb)); + +b("File \"bs_set_int_test.res\", line 172, characters 4-11", Belt_SetInt.subset(dd, bb)); + +b("File \"bs_set_int_test.res\", line 173, characters 4-11", Belt_SetInt.subset(Belt_SetInt.add(dd, 200), bb)); + +b("File \"bs_set_int_test.res\", line 174, characters 4-11", Belt_SetInt.add(dd, 200) === dd); + +b("File \"bs_set_int_test.res\", line 175, characters 4-11", Belt_SetInt.add(dd, 0) === dd); + +b("File \"bs_set_int_test.res\", line 176, characters 4-11", !Belt_SetInt.subset(Belt_SetInt.add(dd, 201), bb)); + +let aa$1 = Belt_SetInt.fromArray(Array_data_util.randomRange(0, 100)); + +let bb$1 = Belt_SetInt.fromArray(Array_data_util.randomRange(0, 100)); + +let cc$1 = Belt_SetInt.add(bb$1, 101); + +let dd$1 = Belt_SetInt.remove(bb$1, 99); + +let ee = Belt_SetInt.add(dd$1, 101); + +b("File \"bs_set_int_test.res\", line 185, characters 4-11", Belt_SetInt.eq(aa$1, bb$1)); + +b("File \"bs_set_int_test.res\", line 186, characters 4-11", !Belt_SetInt.eq(aa$1, cc$1)); + +b("File \"bs_set_int_test.res\", line 187, characters 4-11", !Belt_SetInt.eq(dd$1, cc$1)); + +b("File \"bs_set_int_test.res\", line 188, characters 4-11", !Belt_SetInt.eq(bb$1, ee)); + +let a1 = Belt_SetInt.mergeMany(undefined, Array_data_util.randomRange(0, 100)); + +let a2 = Belt_SetInt.removeMany(a1, Array_data_util.randomRange(40, 100)); + +let a3 = Belt_SetInt.fromArray(Array_data_util.randomRange(0, 39)); + +let match$1 = Belt_SetInt.split(a1, 40); + +let match$2 = match$1[0]; + +let a5 = match$2[1]; + +let a4 = match$2[0]; + +b("File \"bs_set_int_test.res\", line 197, characters 4-11", Belt_SetInt.eq(a1, Belt_SetInt.fromArray(Array_data_util.randomRange(0, 100)))); + +b("File \"bs_set_int_test.res\", line 198, characters 4-11", Belt_SetInt.eq(a2, a3)); + +b("File \"bs_set_int_test.res\", line 199, characters 4-11", match$1[1]); + +b("File \"bs_set_int_test.res\", line 200, characters 4-11", Belt_SetInt.eq(a3, a4)); + +let a6 = Belt_SetInt.remove(Belt_SetInt.removeMany(a1, Array_data_util.randomRange(0, 39)), 40); + +b("File \"bs_set_int_test.res\", line 202, characters 4-11", Belt_SetInt.eq(a5, a6)); + +let a7 = Belt_SetInt.remove(a1, 40); + +let match$3 = Belt_SetInt.split(a7, 40); + +let match$4 = match$3[0]; + +let a9 = match$4[1]; + +b("File \"bs_set_int_test.res\", line 205, characters 4-11", !match$3[1]); + +b("File \"bs_set_int_test.res\", line 206, characters 4-11", Belt_SetInt.eq(a4, match$4[0])); + +b("File \"bs_set_int_test.res\", line 207, characters 4-11", Belt_SetInt.eq(a5, a9)); + +let a10 = Belt_SetInt.removeMany(a9, Array_data_util.randomRange(42, 2000)); + +eq("File \"bs_set_int_test.res\", line 209, characters 5-12", Belt_SetInt.size(a10), 1); + +let a11 = Belt_SetInt.removeMany(a9, Array_data_util.randomRange(0, 2000)); + +b("File \"bs_set_int_test.res\", line 211, characters 4-11", Belt_SetInt.isEmpty(a11)); + +let match$5 = Belt_SetInt.split(undefined, 0); + +let match$6 = match$5[0]; + +b("File \"bs_set_int_test.res\", line 216, characters 4-11", Belt_SetInt.isEmpty(match$6[0])); + +b("File \"bs_set_int_test.res\", line 217, characters 4-11", Belt_SetInt.isEmpty(match$6[1])); + +b("File \"bs_set_int_test.res\", line 218, characters 4-11", !match$5[1]); + +let v$12 = Belt_SetInt.fromArray(Array_data_util.randomRange(0, 2000)); + +let v0 = Belt_SetInt.fromArray(Array_data_util.randomRange(0, 2000)); + +let v1 = Belt_SetInt.fromArray(Array_data_util.randomRange(1, 2001)); + +let v2 = Belt_SetInt.fromArray(Array_data_util.randomRange(3, 2002)); + +let v3 = Belt_SetInt.removeMany(v2, [ + 2002, + 2001 +]); + +let us = Belt_Array.map(Array_data_util.randomRange(1000, 3000), x => Belt_SetInt.has(v$12, x)); + +let counted = Belt_Array.reduce(us, 0, (acc, x) => { + if (x) { + return acc + 1 | 0; + } else { + return acc; + } +}); + +eq("File \"bs_set_int_test.res\", line 235, characters 5-12", counted, 1001); + +b("File \"bs_set_int_test.res\", line 236, characters 4-11", Belt_SetInt.eq(v$12, v0)); + +b("File \"bs_set_int_test.res\", line 237, characters 4-11", Belt_SetInt.cmp(v$12, v0) === 0); + +b("File \"bs_set_int_test.res\", line 238, characters 4-11", Belt_SetInt.cmp(v$12, v1) < 0); + +b("File \"bs_set_int_test.res\", line 239, characters 4-11", Belt_SetInt.cmp(v$12, v2) > 0); + +b("File \"bs_set_int_test.res\", line 240, characters 4-11", Belt_SetInt.subset(v3, v0)); + +b("File \"bs_set_int_test.res\", line 241, characters 4-11", !Belt_SetInt.subset(v1, v0)); + +eq("File \"bs_set_int_test.res\", line 242, characters 5-12", Belt_SetInt.get(v$12, 30), 30); + +eq("File \"bs_set_int_test.res\", line 243, characters 5-12", Belt_SetInt.get(v$12, 3000), undefined); + +Mt.from_pair_suites("Bs_set_int_test", suites.contents); + +let N; + +let I; + +let L; + +let A; + +let ofA = Belt_SetInt.fromArray; + +export { + suites, + test_id, + eq, + b, + N, + I, + L, + A, + $eq$tilde, + $eq$star, + ofA, + u, + range, + revRange, +} +/* Not a pure module */ diff --git a/tests/tests/src/bs_splice_partial.js b/tests/tests/src/bs_splice_partial.js deleted file mode 100644 index aa01df223d..0000000000 --- a/tests/tests/src/bs_splice_partial.js +++ /dev/null @@ -1,48 +0,0 @@ -// Generated by ReScript, PLEASE EDIT WITH CARE -'use strict'; - - -function test(g) { - g.xx(10, 3, "xxx", 1, 2, 3); -} - -function test_hi(x) { - let y = x.hi(1, 2, 3); - if (y !== null) { - console.log(y); - return 2; - } else { - return 1; - } -} - -function test_hi__2(x) { - let match = x.hi__2(); - if (match == null) { - return 1; - } else { - return 2; - } -} - -function test_cb(x) { - x.cb("hI", 1, 2, 3)(3); - x.cb("hI", 1, 2, 3)(3); - return x.cb2("hI", 1, 2, 3)(3); -} - -function f(x) { - v(x); -} - -function testUndefined() { - return say(1, 2, [undefined,undefined]); -} - -exports.test = test; -exports.test_hi = test_hi; -exports.test_hi__2 = test_hi__2; -exports.test_cb = test_cb; -exports.f = f; -exports.testUndefined = testUndefined; -/* No side effect */ diff --git a/tests/tests/src/bs_splice_partial.mjs b/tests/tests/src/bs_splice_partial.mjs new file mode 100644 index 0000000000..8f703e597f --- /dev/null +++ b/tests/tests/src/bs_splice_partial.mjs @@ -0,0 +1,49 @@ +// Generated by ReScript, PLEASE EDIT WITH CARE + + +function test(g) { + g.xx(10, 3, "xxx", 1, 2, 3); +} + +function test_hi(x) { + let y = x.hi(1, 2, 3); + if (y !== null) { + console.log(y); + return 2; + } else { + return 1; + } +} + +function test_hi__2(x) { + let match = x.hi__2(); + if (match == null) { + return 1; + } else { + return 2; + } +} + +function test_cb(x) { + x.cb("hI", 1, 2, 3)(3); + x.cb("hI", 1, 2, 3)(3); + return x.cb2("hI", 1, 2, 3)(3); +} + +function f(x) { + v(x); +} + +function testUndefined() { + return say(1, 2, [undefined,undefined]); +} + +export { + test, + test_hi, + test_hi__2, + test_cb, + f, + testUndefined, +} +/* No side effect */ diff --git a/tests/tests/src/bs_stack_test.js b/tests/tests/src/bs_stack_test.js deleted file mode 100644 index c4b1649d98..0000000000 --- a/tests/tests/src/bs_stack_test.js +++ /dev/null @@ -1,145 +0,0 @@ -// Generated by ReScript, PLEASE EDIT WITH CARE -'use strict'; - -let Mt = require("./mt.js"); -let Js_undefined = require("rescript/lib/js/Js_undefined.js"); -let Primitive_option = require("rescript/lib/js/Primitive_option.js"); -let Belt_MutableQueue = require("rescript/lib/js/Belt_MutableQueue.js"); -let Belt_MutableStack = require("rescript/lib/js/Belt_MutableStack.js"); - -let suites = { - contents: /* [] */0 -}; - -let test_id = { - contents: 0 -}; - -function eq(loc, x, y) { - Mt.eq_suites(test_id, suites, loc, x, y); -} - -function inOrder(v) { - let current = v; - let s = Belt_MutableStack.make(); - let q = Belt_MutableQueue.make(); - while (current !== undefined) { - let v$1 = current; - Belt_MutableStack.push(s, v$1); - current = v$1.left; - }; - while (!Belt_MutableStack.isEmpty(s)) { - current = Belt_MutableStack.popUndefined(s); - let v$2 = current; - Belt_MutableQueue.add(q, v$2.value); - current = v$2.right; - while (current !== undefined) { - let v$3 = current; - Belt_MutableStack.push(s, v$3); - current = v$3.left; - }; - }; - return Belt_MutableQueue.toArray(q); -} - -function inOrder3(v) { - let current = v; - let s = Belt_MutableStack.make(); - let q = Belt_MutableQueue.make(); - while (current !== undefined) { - let v$1 = current; - Belt_MutableStack.push(s, v$1); - current = v$1.left; - }; - Belt_MutableStack.dynamicPopIter(s, popped => { - Belt_MutableQueue.add(q, popped.value); - let current = popped.right; - while (current !== undefined) { - let v = current; - Belt_MutableStack.push(s, v); - current = v.left; - }; - }); - return Belt_MutableQueue.toArray(q); -} - -function inOrder2(v) { - let todo = true; - let cursor = v; - let s = Belt_MutableStack.make(); - let q = Belt_MutableQueue.make(); - while (todo) { - if (cursor !== undefined) { - let v$1 = cursor; - Belt_MutableStack.push(s, v$1); - cursor = v$1.left; - } else if (Belt_MutableStack.isEmpty(s)) { - todo = false; - } else { - cursor = Belt_MutableStack.popUndefined(s); - let current = cursor; - Belt_MutableQueue.add(q, current.value); - cursor = current.right; - } - }; -} - -function n(l, r, a) { - return { - value: a, - left: Js_undefined.fromOption(l), - right: Js_undefined.fromOption(r) - }; -} - -let test1 = n(Primitive_option.some(n(Primitive_option.some(n(undefined, undefined, 4)), Primitive_option.some(n(undefined, undefined, 5)), 2)), Primitive_option.some(n(undefined, undefined, 3)), 1); - -function pushAllLeft(st1, s1) { - let current = st1; - while (current !== undefined) { - let v = current; - Belt_MutableStack.push(s1, v); - current = v.left; - }; -} - -let test2 = n(Primitive_option.some(n(Primitive_option.some(n(Primitive_option.some(n(Primitive_option.some(n(undefined, undefined, 4)), undefined, 2)), undefined, 5)), undefined, 1)), undefined, 3); - -let test3 = n(Primitive_option.some(n(Primitive_option.some(n(Primitive_option.some(n(undefined, undefined, 4)), undefined, 2)), undefined, 5)), Primitive_option.some(n(undefined, undefined, 3)), 1); - -eq("File \"bs_stack_test.res\", line 98, characters 3-10", inOrder(test1), [ - 4, - 2, - 5, - 1, - 3 -]); - -eq("File \"bs_stack_test.res\", line 99, characters 3-10", inOrder3(test1), [ - 4, - 2, - 5, - 1, - 3 -]); - -Mt.from_pair_suites("bs_stack_test.res", suites.contents); - -let S; - -let Q; - -exports.suites = suites; -exports.test_id = test_id; -exports.eq = eq; -exports.S = S; -exports.Q = Q; -exports.inOrder = inOrder; -exports.inOrder3 = inOrder3; -exports.inOrder2 = inOrder2; -exports.n = n; -exports.test1 = test1; -exports.pushAllLeft = pushAllLeft; -exports.test2 = test2; -exports.test3 = test3; -/* test1 Not a pure module */ diff --git a/tests/tests/src/bs_stack_test.mjs b/tests/tests/src/bs_stack_test.mjs new file mode 100644 index 0000000000..5670fd9d43 --- /dev/null +++ b/tests/tests/src/bs_stack_test.mjs @@ -0,0 +1,146 @@ +// Generated by ReScript, PLEASE EDIT WITH CARE + +import * as Mt from "./mt.mjs"; +import * as Js_undefined from "rescript/lib/es6/Js_undefined.js"; +import * as Primitive_option from "rescript/lib/es6/Primitive_option.js"; +import * as Belt_MutableQueue from "rescript/lib/es6/Belt_MutableQueue.js"; +import * as Belt_MutableStack from "rescript/lib/es6/Belt_MutableStack.js"; + +let suites = { + contents: /* [] */0 +}; + +let test_id = { + contents: 0 +}; + +function eq(loc, x, y) { + Mt.eq_suites(test_id, suites, loc, x, y); +} + +function inOrder(v) { + let current = v; + let s = Belt_MutableStack.make(); + let q = Belt_MutableQueue.make(); + while (current !== undefined) { + let v$1 = current; + Belt_MutableStack.push(s, v$1); + current = v$1.left; + }; + while (!Belt_MutableStack.isEmpty(s)) { + current = Belt_MutableStack.popUndefined(s); + let v$2 = current; + Belt_MutableQueue.add(q, v$2.value); + current = v$2.right; + while (current !== undefined) { + let v$3 = current; + Belt_MutableStack.push(s, v$3); + current = v$3.left; + }; + }; + return Belt_MutableQueue.toArray(q); +} + +function inOrder3(v) { + let current = v; + let s = Belt_MutableStack.make(); + let q = Belt_MutableQueue.make(); + while (current !== undefined) { + let v$1 = current; + Belt_MutableStack.push(s, v$1); + current = v$1.left; + }; + Belt_MutableStack.dynamicPopIter(s, popped => { + Belt_MutableQueue.add(q, popped.value); + let current = popped.right; + while (current !== undefined) { + let v = current; + Belt_MutableStack.push(s, v); + current = v.left; + }; + }); + return Belt_MutableQueue.toArray(q); +} + +function inOrder2(v) { + let todo = true; + let cursor = v; + let s = Belt_MutableStack.make(); + let q = Belt_MutableQueue.make(); + while (todo) { + if (cursor !== undefined) { + let v$1 = cursor; + Belt_MutableStack.push(s, v$1); + cursor = v$1.left; + } else if (Belt_MutableStack.isEmpty(s)) { + todo = false; + } else { + cursor = Belt_MutableStack.popUndefined(s); + let current = cursor; + Belt_MutableQueue.add(q, current.value); + cursor = current.right; + } + }; +} + +function n(l, r, a) { + return { + value: a, + left: Js_undefined.fromOption(l), + right: Js_undefined.fromOption(r) + }; +} + +let test1 = n(Primitive_option.some(n(Primitive_option.some(n(undefined, undefined, 4)), Primitive_option.some(n(undefined, undefined, 5)), 2)), Primitive_option.some(n(undefined, undefined, 3)), 1); + +function pushAllLeft(st1, s1) { + let current = st1; + while (current !== undefined) { + let v = current; + Belt_MutableStack.push(s1, v); + current = v.left; + }; +} + +let test2 = n(Primitive_option.some(n(Primitive_option.some(n(Primitive_option.some(n(Primitive_option.some(n(undefined, undefined, 4)), undefined, 2)), undefined, 5)), undefined, 1)), undefined, 3); + +let test3 = n(Primitive_option.some(n(Primitive_option.some(n(Primitive_option.some(n(undefined, undefined, 4)), undefined, 2)), undefined, 5)), Primitive_option.some(n(undefined, undefined, 3)), 1); + +eq("File \"bs_stack_test.res\", line 98, characters 3-10", inOrder(test1), [ + 4, + 2, + 5, + 1, + 3 +]); + +eq("File \"bs_stack_test.res\", line 99, characters 3-10", inOrder3(test1), [ + 4, + 2, + 5, + 1, + 3 +]); + +Mt.from_pair_suites("bs_stack_test.res", suites.contents); + +let S; + +let Q; + +export { + suites, + test_id, + eq, + S, + Q, + inOrder, + inOrder3, + inOrder2, + n, + test1, + pushAllLeft, + test2, + test3, +} +/* test1 Not a pure module */ diff --git a/tests/tests/src/bs_string_test.js b/tests/tests/src/bs_string_test.js deleted file mode 100644 index c7176e11e2..0000000000 --- a/tests/tests/src/bs_string_test.js +++ /dev/null @@ -1,36 +0,0 @@ -// Generated by ReScript, PLEASE EDIT WITH CARE -'use strict'; - -let Mt = require("./mt.js"); - -let suites = { - contents: /* [] */0 -}; - -let test_id = { - contents: 0 -}; - -function eq(loc, x, y) { - test_id.contents = test_id.contents + 1 | 0; - suites.contents = { - hd: [ - loc + (" id " + test_id.contents.toString()), - () => ({ - TAG: "Eq", - _0: x, - _1: y - }) - ], - tl: suites.contents - }; -} - -eq("File \"bs_string_test.res\", line 13, characters 2-9", "ghso ghso g".split(" ").reduce((x, y) => x + ("-" + y), ""), "-ghso-ghso-g"); - -Mt.from_pair_suites("Bs_string_test", suites.contents); - -exports.suites = suites; -exports.test_id = test_id; -exports.eq = eq; -/* Not a pure module */ diff --git a/tests/tests/src/bs_string_test.mjs b/tests/tests/src/bs_string_test.mjs new file mode 100644 index 0000000000..1024e25c3f --- /dev/null +++ b/tests/tests/src/bs_string_test.mjs @@ -0,0 +1,37 @@ +// Generated by ReScript, PLEASE EDIT WITH CARE + +import * as Mt from "./mt.mjs"; + +let suites = { + contents: /* [] */0 +}; + +let test_id = { + contents: 0 +}; + +function eq(loc, x, y) { + test_id.contents = test_id.contents + 1 | 0; + suites.contents = { + hd: [ + loc + (" id " + test_id.contents.toString()), + () => ({ + TAG: "Eq", + _0: x, + _1: y + }) + ], + tl: suites.contents + }; +} + +eq("File \"bs_string_test.res\", line 13, characters 2-9", "ghso ghso g".split(" ").reduce((x, y) => x + ("-" + y), ""), "-ghso-ghso-g"); + +Mt.from_pair_suites("Bs_string_test", suites.contents); + +export { + suites, + test_id, + eq, +} +/* Not a pure module */ diff --git a/tests/tests/src/bs_unwrap_test.js b/tests/tests/src/bs_unwrap_test.js deleted file mode 100644 index 928689aeb0..0000000000 --- a/tests/tests/src/bs_unwrap_test.js +++ /dev/null @@ -1,111 +0,0 @@ -// Generated by ReScript, PLEASE EDIT WITH CARE -'use strict'; - -let Primitive_option = require("rescript/lib/js/Primitive_option.js"); - -console.log([ - "hello world", - 1 -]); - -console.log(1337); - -console.log("hello world"); - -let arg_string = { - NAME: "String", - VAL: "hi runtime" -}; - -console.log(arg_string.VAL); - -let arg_pair = { - NAME: "Pair", - VAL: [ - "hi", - 1 - ] -}; - -console.log(arg_pair.VAL); - -console.log(); - -console.log(1, undefined); - -console.log(2, "hi"); - -console.log(3, "hi"); - -console.log(4, undefined); - -let some_arg = { - NAME: "Bool", - VAL: true -}; - -console.log(5, Primitive_option.unwrapPolyVar(some_arg)); - -console.log(6, undefined); - -console.log(7, Primitive_option.unwrapPolyVar((console.log("trace"), undefined))); - -function dyn_log3(prim0, prim1, prim2) { - console.log(prim0.VAL, Primitive_option.unwrapPolyVar(prim1)); -} - -dyn_log3({ - NAME: "Int", - VAL: 8 -}, { - NAME: "Bool", - VAL: true -}, undefined); - -console.log("foo"); - -console.log({ - foo: 1 -}); - -function dyn_log4(prim) { - console.log(prim.VAL); -} - -console.log({ - foo: 2 -}); - -function f(x) { - console.log(x.VAL); -} - -function ff0(x, p) { - console.log(Primitive_option.unwrapPolyVar(x), p); -} - -function ff1(x, p) { - console.log(Primitive_option.unwrapPolyVar(x()), p); -} - -function test00() { - return { - a: 1, - b: 2, - x: undefined - }; -} - -let none_arg; - -exports.arg_string = arg_string; -exports.arg_pair = arg_pair; -exports.some_arg = some_arg; -exports.none_arg = none_arg; -exports.dyn_log3 = dyn_log3; -exports.dyn_log4 = dyn_log4; -exports.f = f; -exports.ff0 = ff0; -exports.ff1 = ff1; -exports.test00 = test00; -/* Not a pure module */ diff --git a/tests/tests/src/bs_unwrap_test.mjs b/tests/tests/src/bs_unwrap_test.mjs new file mode 100644 index 0000000000..5941ec6fa6 --- /dev/null +++ b/tests/tests/src/bs_unwrap_test.mjs @@ -0,0 +1,112 @@ +// Generated by ReScript, PLEASE EDIT WITH CARE + +import * as Primitive_option from "rescript/lib/es6/Primitive_option.js"; + +console.log([ + "hello world", + 1 +]); + +console.log(1337); + +console.log("hello world"); + +let arg_string = { + NAME: "String", + VAL: "hi runtime" +}; + +console.log(arg_string.VAL); + +let arg_pair = { + NAME: "Pair", + VAL: [ + "hi", + 1 + ] +}; + +console.log(arg_pair.VAL); + +console.log(); + +console.log(1, undefined); + +console.log(2, "hi"); + +console.log(3, "hi"); + +console.log(4, undefined); + +let some_arg = { + NAME: "Bool", + VAL: true +}; + +console.log(5, Primitive_option.unwrapPolyVar(some_arg)); + +console.log(6, undefined); + +console.log(7, Primitive_option.unwrapPolyVar((console.log("trace"), undefined))); + +function dyn_log3(prim0, prim1, prim2) { + console.log(prim0.VAL, Primitive_option.unwrapPolyVar(prim1)); +} + +dyn_log3({ + NAME: "Int", + VAL: 8 +}, { + NAME: "Bool", + VAL: true +}, undefined); + +console.log("foo"); + +console.log({ + foo: 1 +}); + +function dyn_log4(prim) { + console.log(prim.VAL); +} + +console.log({ + foo: 2 +}); + +function f(x) { + console.log(x.VAL); +} + +function ff0(x, p) { + console.log(Primitive_option.unwrapPolyVar(x), p); +} + +function ff1(x, p) { + console.log(Primitive_option.unwrapPolyVar(x()), p); +} + +function test00() { + return { + a: 1, + b: 2, + x: undefined + }; +} + +let none_arg; + +export { + arg_string, + arg_pair, + some_arg, + none_arg, + dyn_log3, + dyn_log4, + f, + ff0, + ff1, + test00, +} +/* Not a pure module */ diff --git a/tests/tests/src/caml_compare_bigint_test.js b/tests/tests/src/caml_compare_bigint_test.js deleted file mode 100644 index fc725fa3b2..0000000000 --- a/tests/tests/src/caml_compare_bigint_test.js +++ /dev/null @@ -1,366 +0,0 @@ -// Generated by ReScript, PLEASE EDIT WITH CARE -'use strict'; - -let Mt = require("./mt.js"); -let Pervasives = require("rescript/lib/js/Pervasives.js"); -let Primitive_object = require("rescript/lib/js/Primitive_object.js"); - -function isLessThan(title, small, big) { - return { - hd: [ - "compare: " + title, - param => ({ - TAG: "Eq", - _0: true, - _1: big > small - }) - ], - tl: { - hd: [ - "compare: " + title, - param => ({ - TAG: "Eq", - _0: true, - _1: small < big - }) - ], - tl: { - hd: [ - "< operator: " + title, - param => ({ - TAG: "Eq", - _0: true, - _1: Primitive_object.lessthan(small, big) - }) - ], - tl: { - hd: [ - "<= operator: " + title, - param => ({ - TAG: "Eq", - _0: true, - _1: Primitive_object.lessequal(small, big) - }) - ], - tl: { - hd: [ - "> operator: " + title, - param => ({ - TAG: "Eq", - _0: true, - _1: Primitive_object.greaterthan(big, small) - }) - ], - tl: { - hd: [ - ">= operator: " + title, - param => ({ - TAG: "Eq", - _0: true, - _1: Primitive_object.greaterequal(big, small) - }) - ], - tl: { - hd: [ - "min: " + title, - param => ({ - TAG: "Eq", - _0: small, - _1: Primitive_object.min(big, small) - }) - ], - tl: { - hd: [ - "min: " + title, - param => ({ - TAG: "Eq", - _0: small, - _1: Primitive_object.min(small, big) - }) - ], - tl: { - hd: [ - "max: " + title, - param => ({ - TAG: "Eq", - _0: big, - _1: Primitive_object.max(big, small) - }) - ], - tl: { - hd: [ - "max: " + title, - param => ({ - TAG: "Eq", - _0: big, - _1: Primitive_object.max(small, big) - }) - ], - tl: { - hd: [ - "!== operator: " + title, - param => ({ - TAG: "Eq", - _0: true, - _1: big !== small - }) - ], - tl: { - hd: [ - "!== operator: " + title, - param => ({ - TAG: "Eq", - _0: true, - _1: small !== big - }) - ], - tl: { - hd: [ - "!= operator: " + title, - param => ({ - TAG: "Eq", - _0: true, - _1: Primitive_object.notequal(big, small) - }) - ], - tl: { - hd: [ - "!= operator: " + title, - param => ({ - TAG: "Eq", - _0: true, - _1: Primitive_object.notequal(small, big) - }) - ], - tl: { - hd: [ - "== operator: " + title, - param => ({ - TAG: "Eq", - _0: false, - _1: Primitive_object.equal(big, small) - }) - ], - tl: { - hd: [ - "== operator: " + title, - param => ({ - TAG: "Eq", - _0: false, - _1: Primitive_object.equal(small, big) - }) - ], - tl: { - hd: [ - "=== operator: " + title, - param => ({ - TAG: "Eq", - _0: false, - _1: big === small - }) - ], - tl: { - hd: [ - "=== operator: " + title, - param => ({ - TAG: "Eq", - _0: false, - _1: small === big - }) - ], - tl: /* [] */0 - } - } - } - } - } - } - } - } - } - } - } - } - } - } - } - } - } - }; -} - -function isEqual(title, num1, num2) { - return { - hd: [ - "< operator: " + title, - param => ({ - TAG: "Eq", - _0: false, - _1: Primitive_object.lessthan(num2, num1) - }) - ], - tl: { - hd: [ - "<= operator: " + title, - param => ({ - TAG: "Eq", - _0: true, - _1: Primitive_object.lessequal(num2, num1) - }) - ], - tl: { - hd: [ - "> operator: " + title, - param => ({ - TAG: "Eq", - _0: false, - _1: Primitive_object.greaterthan(num1, num2) - }) - ], - tl: { - hd: [ - ">= operator: " + title, - param => ({ - TAG: "Eq", - _0: true, - _1: Primitive_object.greaterequal(num1, num2) - }) - ], - tl: { - hd: [ - "min: " + title, - param => ({ - TAG: "Eq", - _0: num1, - _1: Primitive_object.min(num1, num2) - }) - ], - tl: { - hd: [ - "max: " + title, - param => ({ - TAG: "Eq", - _0: num1, - _1: Primitive_object.max(num1, num2) - }) - ], - tl: { - hd: [ - "compare: " + title, - param => ({ - TAG: "Eq", - _0: 0, - _1: Primitive_object.compare(num1, num2) - }) - ], - tl: { - hd: [ - "compare: " + title, - param => ({ - TAG: "Eq", - _0: 0, - _1: Primitive_object.compare(num2, num1) - }) - ], - tl: { - hd: [ - "!= operator: " + title, - param => ({ - TAG: "Eq", - _0: false, - _1: num1 !== num2 - }) - ], - tl: { - hd: [ - "!= operator: " + title, - param => ({ - TAG: "Eq", - _0: false, - _1: num2 !== num1 - }) - ], - tl: { - hd: [ - "!= operator: " + title, - param => ({ - TAG: "Eq", - _0: false, - _1: Primitive_object.notequal(num1, num2) - }) - ], - tl: { - hd: [ - "!= operator: " + title, - param => ({ - TAG: "Eq", - _0: false, - _1: Primitive_object.notequal(num2, num1) - }) - ], - tl: { - hd: [ - "== operator: " + title, - param => ({ - TAG: "Eq", - _0: true, - _1: Primitive_object.equal(num1, num2) - }) - ], - tl: { - hd: [ - "== operator: " + title, - param => ({ - TAG: "Eq", - _0: true, - _1: Primitive_object.equal(num2, num1) - }) - ], - tl: { - hd: [ - "=== operator: " + title, - param => ({ - TAG: "Eq", - _0: true, - _1: num1 === num2 - }) - ], - tl: { - hd: [ - "=== operator: " + title, - param => ({ - TAG: "Eq", - _0: true, - _1: num2 === num1 - }) - ], - tl: /* [] */0 - } - } - } - } - } - } - } - } - } - } - } - } - } - } - } - }; -} - -let five = BigInt("5"); - -let suites = Pervasives.$at(isLessThan("123 and 555555", BigInt("123"), BigInt("555555")), Pervasives.$at(isEqual("98765 and 98765", BigInt("98765"), BigInt("98765")), isEqual("same instance", five, five))); - -Mt.from_pair_suites("caml_compare_bigint_test.res", suites); - -exports.isLessThan = isLessThan; -exports.isEqual = isEqual; -exports.five = five; -exports.suites = suites; -/* five Not a pure module */ diff --git a/tests/tests/src/caml_compare_bigint_test.mjs b/tests/tests/src/caml_compare_bigint_test.mjs new file mode 100644 index 0000000000..f3edb1c6d2 --- /dev/null +++ b/tests/tests/src/caml_compare_bigint_test.mjs @@ -0,0 +1,367 @@ +// Generated by ReScript, PLEASE EDIT WITH CARE + +import * as Mt from "./mt.mjs"; +import * as Pervasives from "rescript/lib/es6/Pervasives.js"; +import * as Primitive_object from "rescript/lib/es6/Primitive_object.js"; + +function isLessThan(title, small, big) { + return { + hd: [ + "compare: " + title, + param => ({ + TAG: "Eq", + _0: true, + _1: big > small + }) + ], + tl: { + hd: [ + "compare: " + title, + param => ({ + TAG: "Eq", + _0: true, + _1: small < big + }) + ], + tl: { + hd: [ + "< operator: " + title, + param => ({ + TAG: "Eq", + _0: true, + _1: Primitive_object.lessthan(small, big) + }) + ], + tl: { + hd: [ + "<= operator: " + title, + param => ({ + TAG: "Eq", + _0: true, + _1: Primitive_object.lessequal(small, big) + }) + ], + tl: { + hd: [ + "> operator: " + title, + param => ({ + TAG: "Eq", + _0: true, + _1: Primitive_object.greaterthan(big, small) + }) + ], + tl: { + hd: [ + ">= operator: " + title, + param => ({ + TAG: "Eq", + _0: true, + _1: Primitive_object.greaterequal(big, small) + }) + ], + tl: { + hd: [ + "min: " + title, + param => ({ + TAG: "Eq", + _0: small, + _1: Primitive_object.min(big, small) + }) + ], + tl: { + hd: [ + "min: " + title, + param => ({ + TAG: "Eq", + _0: small, + _1: Primitive_object.min(small, big) + }) + ], + tl: { + hd: [ + "max: " + title, + param => ({ + TAG: "Eq", + _0: big, + _1: Primitive_object.max(big, small) + }) + ], + tl: { + hd: [ + "max: " + title, + param => ({ + TAG: "Eq", + _0: big, + _1: Primitive_object.max(small, big) + }) + ], + tl: { + hd: [ + "!== operator: " + title, + param => ({ + TAG: "Eq", + _0: true, + _1: big !== small + }) + ], + tl: { + hd: [ + "!== operator: " + title, + param => ({ + TAG: "Eq", + _0: true, + _1: small !== big + }) + ], + tl: { + hd: [ + "!= operator: " + title, + param => ({ + TAG: "Eq", + _0: true, + _1: Primitive_object.notequal(big, small) + }) + ], + tl: { + hd: [ + "!= operator: " + title, + param => ({ + TAG: "Eq", + _0: true, + _1: Primitive_object.notequal(small, big) + }) + ], + tl: { + hd: [ + "== operator: " + title, + param => ({ + TAG: "Eq", + _0: false, + _1: Primitive_object.equal(big, small) + }) + ], + tl: { + hd: [ + "== operator: " + title, + param => ({ + TAG: "Eq", + _0: false, + _1: Primitive_object.equal(small, big) + }) + ], + tl: { + hd: [ + "=== operator: " + title, + param => ({ + TAG: "Eq", + _0: false, + _1: big === small + }) + ], + tl: { + hd: [ + "=== operator: " + title, + param => ({ + TAG: "Eq", + _0: false, + _1: small === big + }) + ], + tl: /* [] */0 + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + }; +} + +function isEqual(title, num1, num2) { + return { + hd: [ + "< operator: " + title, + param => ({ + TAG: "Eq", + _0: false, + _1: Primitive_object.lessthan(num2, num1) + }) + ], + tl: { + hd: [ + "<= operator: " + title, + param => ({ + TAG: "Eq", + _0: true, + _1: Primitive_object.lessequal(num2, num1) + }) + ], + tl: { + hd: [ + "> operator: " + title, + param => ({ + TAG: "Eq", + _0: false, + _1: Primitive_object.greaterthan(num1, num2) + }) + ], + tl: { + hd: [ + ">= operator: " + title, + param => ({ + TAG: "Eq", + _0: true, + _1: Primitive_object.greaterequal(num1, num2) + }) + ], + tl: { + hd: [ + "min: " + title, + param => ({ + TAG: "Eq", + _0: num1, + _1: Primitive_object.min(num1, num2) + }) + ], + tl: { + hd: [ + "max: " + title, + param => ({ + TAG: "Eq", + _0: num1, + _1: Primitive_object.max(num1, num2) + }) + ], + tl: { + hd: [ + "compare: " + title, + param => ({ + TAG: "Eq", + _0: 0, + _1: Primitive_object.compare(num1, num2) + }) + ], + tl: { + hd: [ + "compare: " + title, + param => ({ + TAG: "Eq", + _0: 0, + _1: Primitive_object.compare(num2, num1) + }) + ], + tl: { + hd: [ + "!= operator: " + title, + param => ({ + TAG: "Eq", + _0: false, + _1: num1 !== num2 + }) + ], + tl: { + hd: [ + "!= operator: " + title, + param => ({ + TAG: "Eq", + _0: false, + _1: num2 !== num1 + }) + ], + tl: { + hd: [ + "!= operator: " + title, + param => ({ + TAG: "Eq", + _0: false, + _1: Primitive_object.notequal(num1, num2) + }) + ], + tl: { + hd: [ + "!= operator: " + title, + param => ({ + TAG: "Eq", + _0: false, + _1: Primitive_object.notequal(num2, num1) + }) + ], + tl: { + hd: [ + "== operator: " + title, + param => ({ + TAG: "Eq", + _0: true, + _1: Primitive_object.equal(num1, num2) + }) + ], + tl: { + hd: [ + "== operator: " + title, + param => ({ + TAG: "Eq", + _0: true, + _1: Primitive_object.equal(num2, num1) + }) + ], + tl: { + hd: [ + "=== operator: " + title, + param => ({ + TAG: "Eq", + _0: true, + _1: num1 === num2 + }) + ], + tl: { + hd: [ + "=== operator: " + title, + param => ({ + TAG: "Eq", + _0: true, + _1: num2 === num1 + }) + ], + tl: /* [] */0 + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + }; +} + +let five = BigInt("5"); + +let suites = Pervasives.$at(isLessThan("123 and 555555", BigInt("123"), BigInt("555555")), Pervasives.$at(isEqual("98765 and 98765", BigInt("98765"), BigInt("98765")), isEqual("same instance", five, five))); + +Mt.from_pair_suites("caml_compare_bigint_test.res", suites); + +export { + isLessThan, + isEqual, + five, + suites, +} +/* five Not a pure module */ diff --git a/tests/tests/src/caml_compare_test.js b/tests/tests/src/caml_compare_test.js deleted file mode 100644 index e29dfa0cc4..0000000000 --- a/tests/tests/src/caml_compare_test.js +++ /dev/null @@ -1,1051 +0,0 @@ -// Generated by ReScript, PLEASE EDIT WITH CARE -'use strict'; - -let Mt = require("./mt.js"); -let Primitive_object = require("rescript/lib/js/Primitive_object.js"); -let Primitive_exceptions = require("rescript/lib/js/Primitive_exceptions.js"); - -let function_equal_test; - -try { - function_equal_test = Primitive_object.equal(x => x + 1 | 0, x => x + 2 | 0); -} catch (raw_exn) { - let exn = Primitive_exceptions.internalToException(raw_exn); - function_equal_test = exn.RE_EXN_ID === "Invalid_argument" && exn._1 === "equal: functional value" ? true : false; -} - -let suites = { - contents: { - hd: [ - "File \"caml_compare_test.res\", line 12, characters 5-12", - () => ({ - TAG: "Eq", - _0: true, - _1: Primitive_object.lessthan(undefined, 1) - }) - ], - tl: { - hd: [ - "option2", - () => ({ - TAG: "Eq", - _0: true, - _1: Primitive_object.lessthan(1, 2) - }) - ], - tl: { - hd: [ - "File \"caml_compare_test.res\", line 14, characters 5-12", - () => ({ - TAG: "Eq", - _0: true, - _1: Primitive_object.greaterthan({ - hd: 1, - tl: /* [] */0 - }, /* [] */0) - }) - ], - tl: { - hd: [ - "listeq", - () => ({ - TAG: "Eq", - _0: true, - _1: Primitive_object.equal({ - hd: 1, - tl: { - hd: 2, - tl: { - hd: 3, - tl: /* [] */0 - } - } - }, { - hd: 1, - tl: { - hd: 2, - tl: { - hd: 3, - tl: /* [] */0 - } - } - }) - }) - ], - tl: { - hd: [ - "listneq", - () => ({ - TAG: "Eq", - _0: true, - _1: Primitive_object.greaterthan({ - hd: 1, - tl: { - hd: 2, - tl: { - hd: 3, - tl: /* [] */0 - } - } - }, { - hd: 1, - tl: { - hd: 2, - tl: { - hd: 2, - tl: /* [] */0 - } - } - }) - }) - ], - tl: { - hd: [ - "custom_u", - () => ({ - TAG: "Eq", - _0: true, - _1: Primitive_object.greaterthan([ - { - TAG: "A", - _0: 3 - }, - { - TAG: "B", - _0: 2, - _1: false - }, - { - TAG: "C", - _0: 1 - } - ], [ - { - TAG: "A", - _0: 3 - }, - { - TAG: "B", - _0: 2, - _1: false - }, - { - TAG: "C", - _0: 0 - } - ]) - }) - ], - tl: { - hd: [ - "custom_u2", - () => ({ - TAG: "Eq", - _0: true, - _1: Primitive_object.equal([ - { - TAG: "A", - _0: 3 - }, - { - TAG: "B", - _0: 2, - _1: false - }, - { - TAG: "C", - _0: 1 - } - ], [ - { - TAG: "A", - _0: 3 - }, - { - TAG: "B", - _0: 2, - _1: false - }, - { - TAG: "C", - _0: 1 - } - ]) - }) - ], - tl: { - hd: [ - "function", - () => ({ - TAG: "Eq", - _0: true, - _1: function_equal_test - }) - ], - tl: { - hd: [ - "File \"caml_compare_test.res\", line 20, characters 5-12", - () => ({ - TAG: "Eq", - _0: true, - _1: Primitive_object.lessthan(undefined, 1) - }) - ], - tl: { - hd: [ - "File \"caml_compare_test.res\", line 21, characters 5-12", - () => ({ - TAG: "Eq", - _0: true, - _1: Primitive_object.lessthan(undefined, [ - 1, - 30 - ]) - }) - ], - tl: { - hd: [ - "File \"caml_compare_test.res\", line 22, characters 5-12", - () => ({ - TAG: "Eq", - _0: true, - _1: Primitive_object.greaterthan([ - 1, - 30 - ], undefined) - }) - ], - tl: { - hd: [ - "File \"caml_compare_test.res\", line 24, characters 6-13", - () => ({ - TAG: "Eq", - _0: true, - _1: Primitive_object.lessthan({ - hd: 2, - tl: { - hd: 6, - tl: { - hd: 1, - tl: { - hd: 1, - tl: { - hd: 2, - tl: { - hd: 1, - tl: { - hd: 4, - tl: { - hd: 2, - tl: { - hd: 1, - tl: /* [] */0 - } - } - } - } - } - } - } - } - }, { - hd: 2, - tl: { - hd: 6, - tl: { - hd: 1, - tl: { - hd: 1, - tl: { - hd: 2, - tl: { - hd: 1, - tl: { - hd: 4, - tl: { - hd: 2, - tl: { - hd: 1, - tl: { - hd: 409, - tl: /* [] */0 - } - } - } - } - } - } - } - } - } - }) - }) - ], - tl: { - hd: [ - "File \"caml_compare_test.res\", line 27, characters 5-12", - () => ({ - TAG: "Eq", - _0: true, - _1: Primitive_object.lessthan({ - hd: 1, - tl: /* [] */0 - }, { - hd: 1, - tl: { - hd: 409, - tl: /* [] */0 - } - }) - }) - ], - tl: { - hd: [ - "File \"caml_compare_test.res\", line 28, characters 5-12", - () => ({ - TAG: "Eq", - _0: true, - _1: Primitive_object.lessthan(/* [] */0, { - hd: 409, - tl: /* [] */0 - }) - }) - ], - tl: { - hd: [ - "File \"caml_compare_test.res\", line 30, characters 6-13", - () => ({ - TAG: "Eq", - _0: true, - _1: Primitive_object.greaterthan({ - hd: 2, - tl: { - hd: 6, - tl: { - hd: 1, - tl: { - hd: 1, - tl: { - hd: 2, - tl: { - hd: 1, - tl: { - hd: 4, - tl: { - hd: 2, - tl: { - hd: 1, - tl: { - hd: 409, - tl: /* [] */0 - } - } - } - } - } - } - } - } - } - }, { - hd: 2, - tl: { - hd: 6, - tl: { - hd: 1, - tl: { - hd: 1, - tl: { - hd: 2, - tl: { - hd: 1, - tl: { - hd: 4, - tl: { - hd: 2, - tl: { - hd: 1, - tl: /* [] */0 - } - } - } - } - } - } - } - } - }) - }) - ], - tl: { - hd: [ - "File \"caml_compare_test.res\", line 33, characters 5-12", - () => ({ - TAG: "Eq", - _0: false, - _1: false - }) - ], - tl: { - hd: [ - "File \"caml_compare_test.res\", line 34, characters 5-12", - () => ({ - TAG: "Eq", - _0: false, - _1: false - }) - ], - tl: { - hd: [ - "File \"caml_compare_test.res\", line 36, characters 6-13", - () => ({ - TAG: "Eq", - _0: false, - _1: Primitive_object.equal({ - hd: 2, - tl: { - hd: 6, - tl: { - hd: 1, - tl: { - hd: 1, - tl: { - hd: 2, - tl: { - hd: 1, - tl: { - hd: 4, - tl: { - hd: 2, - tl: { - hd: 1, - tl: /* [] */0 - } - } - } - } - } - } - } - } - }, { - hd: 2, - tl: { - hd: 6, - tl: { - hd: 1, - tl: { - hd: 1, - tl: { - hd: 2, - tl: { - hd: 1, - tl: { - hd: 4, - tl: { - hd: 2, - tl: { - hd: 1, - tl: { - hd: 409, - tl: /* [] */0 - } - } - } - } - } - } - } - } - } - }) - }) - ], - tl: { - hd: [ - "File \"caml_compare_test.res\", line 40, characters 6-13", - () => ({ - TAG: "Eq", - _0: false, - _1: Primitive_object.equal({ - hd: 2, - tl: { - hd: 6, - tl: { - hd: 1, - tl: { - hd: 1, - tl: { - hd: 2, - tl: { - hd: 1, - tl: { - hd: 4, - tl: { - hd: 2, - tl: { - hd: 1, - tl: { - hd: 409, - tl: /* [] */0 - } - } - } - } - } - } - } - } - } - }, { - hd: 2, - tl: { - hd: 6, - tl: { - hd: 1, - tl: { - hd: 1, - tl: { - hd: 2, - tl: { - hd: 1, - tl: { - hd: 4, - tl: { - hd: 2, - tl: { - hd: 1, - tl: /* [] */0 - } - } - } - } - } - } - } - } - }) - }) - ], - tl: { - hd: [ - "cmp_id", - () => ({ - TAG: "Eq", - _0: Primitive_object.compare({ - x: 1, - y: 2 - }, { - x: 1, - y: 2 - }), - _1: 0 - }) - ], - tl: { - hd: [ - "cmp_val", - () => ({ - TAG: "Eq", - _0: Primitive_object.compare({ - x: 1 - }, { - x: 2 - }), - _1: -1 - }) - ], - tl: { - hd: [ - "cmp_val2", - () => ({ - TAG: "Eq", - _0: Primitive_object.compare({ - x: 2 - }, { - x: 1 - }), - _1: 1 - }) - ], - tl: { - hd: [ - "cmp_empty", - () => ({ - TAG: "Eq", - _0: Primitive_object.compare({}, {}), - _1: 0 - }) - ], - tl: { - hd: [ - "cmp_empty2", - () => ({ - TAG: "Eq", - _0: Primitive_object.compare({}, {x:1}), - _1: -1 - }) - ], - tl: { - hd: [ - "cmp_swap", - () => ({ - TAG: "Eq", - _0: Primitive_object.compare({ - x: 1, - y: 2 - }, { - y: 2, - x: 1 - }), - _1: 0 - }) - ], - tl: { - hd: [ - "cmp_size", - () => ({ - TAG: "Eq", - _0: Primitive_object.compare({x:1}, {x:1, y:2}), - _1: -1 - }) - ], - tl: { - hd: [ - "cmp_size2", - () => ({ - TAG: "Eq", - _0: Primitive_object.compare({x:1, y:2}, {x:1}), - _1: 1 - }) - ], - tl: { - hd: [ - "cmp_order", - () => ({ - TAG: "Eq", - _0: Primitive_object.compare({ - x: 0, - y: 1 - }, { - x: 1, - y: 0 - }), - _1: -1 - }) - ], - tl: { - hd: [ - "cmp_order2", - () => ({ - TAG: "Eq", - _0: Primitive_object.compare({ - x: 1, - y: 0 - }, { - x: 0, - y: 1 - }), - _1: 1 - }) - ], - tl: { - hd: [ - "cmp_in_list", - () => ({ - TAG: "Eq", - _0: Primitive_object.compare({ - hd: { - x: 1 - }, - tl: /* [] */0 - }, { - hd: { - x: 2 - }, - tl: /* [] */0 - }), - _1: -1 - }) - ], - tl: { - hd: [ - "cmp_in_list2", - () => ({ - TAG: "Eq", - _0: Primitive_object.compare({ - hd: { - x: 2 - }, - tl: /* [] */0 - }, { - hd: { - x: 1 - }, - tl: /* [] */0 - }), - _1: 1 - }) - ], - tl: { - hd: [ - "cmp_with_list", - () => ({ - TAG: "Eq", - _0: Primitive_object.compare({ - x: { - hd: 0, - tl: /* [] */0 - } - }, { - x: { - hd: 1, - tl: /* [] */0 - } - }), - _1: -1 - }) - ], - tl: { - hd: [ - "cmp_with_list2", - () => ({ - TAG: "Eq", - _0: Primitive_object.compare({ - x: { - hd: 1, - tl: /* [] */0 - } - }, { - x: { - hd: 0, - tl: /* [] */0 - } - }), - _1: 1 - }) - ], - tl: { - hd: [ - "eq_id", - () => ({ - TAG: "Ok", - _0: Primitive_object.equal({ - x: 1, - y: 2 - }, { - x: 1, - y: 2 - }) - }) - ], - tl: { - hd: [ - "eq_val", - () => ({ - TAG: "Eq", - _0: Primitive_object.equal({ - x: 1 - }, { - x: 2 - }), - _1: false - }) - ], - tl: { - hd: [ - "eq_val2", - () => ({ - TAG: "Eq", - _0: Primitive_object.equal({ - x: 2 - }, { - x: 1 - }), - _1: false - }) - ], - tl: { - hd: [ - "eq_empty", - () => ({ - TAG: "Eq", - _0: Primitive_object.equal({}, {}), - _1: true - }) - ], - tl: { - hd: [ - "eq_empty2", - () => ({ - TAG: "Eq", - _0: Primitive_object.equal({}, {x:1}), - _1: false - }) - ], - tl: { - hd: [ - "eq_swap", - () => ({ - TAG: "Ok", - _0: Primitive_object.equal({ - x: 1, - y: 2 - }, { - y: 2, - x: 1 - }) - }) - ], - tl: { - hd: [ - "eq_size", - () => ({ - TAG: "Eq", - _0: Primitive_object.equal({x:1}, {x:1, y:2}), - _1: false - }) - ], - tl: { - hd: [ - "eq_size2", - () => ({ - TAG: "Eq", - _0: Primitive_object.equal({x:1, y:2}, {x:1}), - _1: false - }) - ], - tl: { - hd: [ - "eq_in_list", - () => ({ - TAG: "Eq", - _0: Primitive_object.equal({ - hd: { - x: 1 - }, - tl: /* [] */0 - }, { - hd: { - x: 2 - }, - tl: /* [] */0 - }), - _1: false - }) - ], - tl: { - hd: [ - "eq_in_list2", - () => ({ - TAG: "Eq", - _0: Primitive_object.equal({ - hd: { - x: 2 - }, - tl: /* [] */0 - }, { - hd: { - x: 2 - }, - tl: /* [] */0 - }), - _1: true - }) - ], - tl: { - hd: [ - "eq_with_list", - () => ({ - TAG: "Eq", - _0: Primitive_object.equal({ - x: { - hd: 0, - tl: /* [] */0 - } - }, { - x: { - hd: 0, - tl: /* [] */0 - } - }), - _1: true - }) - ], - tl: { - hd: [ - "eq_with_list2", - () => ({ - TAG: "Eq", - _0: Primitive_object.equal({ - x: { - hd: 0, - tl: /* [] */0 - } - }, { - x: { - hd: 1, - tl: /* [] */0 - } - }), - _1: false - }) - ], - tl: { - hd: [ - "eq_no_prototype", - () => ({ - TAG: "Eq", - _0: Primitive_object.equal({x:1}, ((function(){let o = Object.create(null);o.x = 1;return o;})())), - _1: true - }) - ], - tl: { - hd: [ - "File \"caml_compare_test.res\", line 76, characters 5-12", - () => ({ - TAG: "Eq", - _0: Primitive_object.compare(null, { - hd: 3, - tl: /* [] */0 - }), - _1: -1 - }) - ], - tl: { - hd: [ - "File \"caml_compare_test.res\", line 77, characters 5-12", - () => ({ - TAG: "Eq", - _0: Primitive_object.compare({ - hd: 3, - tl: /* [] */0 - }, null), - _1: 1 - }) - ], - tl: { - hd: [ - "File \"caml_compare_test.res\", line 78, characters 5-12", - () => ({ - TAG: "Eq", - _0: Primitive_object.compare(null, 0), - _1: -1 - }) - ], - tl: { - hd: [ - "File \"caml_compare_test.res\", line 79, characters 5-12", - () => ({ - TAG: "Eq", - _0: Primitive_object.compare(0, null), - _1: 1 - }) - ], - tl: { - hd: [ - "File \"caml_compare_test.res\", line 80, characters 5-12", - () => ({ - TAG: "Eq", - _0: Primitive_object.compare(undefined, 0), - _1: -1 - }) - ], - tl: { - hd: [ - "File \"caml_compare_test.res\", line 81, characters 5-12", - () => ({ - TAG: "Eq", - _0: Primitive_object.compare(0, undefined), - _1: 1 - }) - ], - tl: /* [] */0 - } - } - } - } - } - } - } - } - } - } - } - } - } - } - } - } - } - } - } - } - } - } - } - } - } - } - } - } - } - } - } - } - } - } - } - } - } - } - } - } - } - } - } - } - } - } - } - } - } - } - } - } -}; - -let test_id = { - contents: 0 -}; - -function eq(loc, x, y) { - Mt.eq_suites(test_id, suites, loc, x, y); -} - -eq("File \"caml_compare_test.res\", line 88, characters 3-10", true, Primitive_object.greaterthan(1, undefined)); - -eq("File \"caml_compare_test.res\", line 89, characters 3-10", true, Primitive_object.lessthan(/* [] */0, { - hd: 1, - tl: /* [] */0 -})); - -eq("File \"caml_compare_test.res\", line 90, characters 3-10", false, Primitive_object.greaterthan(undefined, 1)); - -eq("File \"caml_compare_test.res\", line 91, characters 3-10", false, Primitive_object.greaterthan(undefined, [ - 1, - 30 -])); - -eq("File \"caml_compare_test.res\", line 92, characters 3-10", false, Primitive_object.lessthan([ - 1, - 30 -], undefined)); - -Mt.from_pair_suites("Caml_compare_test", suites.contents); - -exports.function_equal_test = function_equal_test; -exports.suites = suites; -exports.test_id = test_id; -exports.eq = eq; -/* function_equal_test Not a pure module */ diff --git a/tests/tests/src/caml_compare_test.mjs b/tests/tests/src/caml_compare_test.mjs new file mode 100644 index 0000000000..073733b27f --- /dev/null +++ b/tests/tests/src/caml_compare_test.mjs @@ -0,0 +1,1052 @@ +// Generated by ReScript, PLEASE EDIT WITH CARE + +import * as Mt from "./mt.mjs"; +import * as Primitive_object from "rescript/lib/es6/Primitive_object.js"; +import * as Primitive_exceptions from "rescript/lib/es6/Primitive_exceptions.js"; + +let function_equal_test; + +try { + function_equal_test = Primitive_object.equal(x => x + 1 | 0, x => x + 2 | 0); +} catch (raw_exn) { + let exn = Primitive_exceptions.internalToException(raw_exn); + function_equal_test = exn.RE_EXN_ID === "Invalid_argument" && exn._1 === "equal: functional value" ? true : false; +} + +let suites = { + contents: { + hd: [ + "File \"caml_compare_test.res\", line 12, characters 5-12", + () => ({ + TAG: "Eq", + _0: true, + _1: Primitive_object.lessthan(undefined, 1) + }) + ], + tl: { + hd: [ + "option2", + () => ({ + TAG: "Eq", + _0: true, + _1: Primitive_object.lessthan(1, 2) + }) + ], + tl: { + hd: [ + "File \"caml_compare_test.res\", line 14, characters 5-12", + () => ({ + TAG: "Eq", + _0: true, + _1: Primitive_object.greaterthan({ + hd: 1, + tl: /* [] */0 + }, /* [] */0) + }) + ], + tl: { + hd: [ + "listeq", + () => ({ + TAG: "Eq", + _0: true, + _1: Primitive_object.equal({ + hd: 1, + tl: { + hd: 2, + tl: { + hd: 3, + tl: /* [] */0 + } + } + }, { + hd: 1, + tl: { + hd: 2, + tl: { + hd: 3, + tl: /* [] */0 + } + } + }) + }) + ], + tl: { + hd: [ + "listneq", + () => ({ + TAG: "Eq", + _0: true, + _1: Primitive_object.greaterthan({ + hd: 1, + tl: { + hd: 2, + tl: { + hd: 3, + tl: /* [] */0 + } + } + }, { + hd: 1, + tl: { + hd: 2, + tl: { + hd: 2, + tl: /* [] */0 + } + } + }) + }) + ], + tl: { + hd: [ + "custom_u", + () => ({ + TAG: "Eq", + _0: true, + _1: Primitive_object.greaterthan([ + { + TAG: "A", + _0: 3 + }, + { + TAG: "B", + _0: 2, + _1: false + }, + { + TAG: "C", + _0: 1 + } + ], [ + { + TAG: "A", + _0: 3 + }, + { + TAG: "B", + _0: 2, + _1: false + }, + { + TAG: "C", + _0: 0 + } + ]) + }) + ], + tl: { + hd: [ + "custom_u2", + () => ({ + TAG: "Eq", + _0: true, + _1: Primitive_object.equal([ + { + TAG: "A", + _0: 3 + }, + { + TAG: "B", + _0: 2, + _1: false + }, + { + TAG: "C", + _0: 1 + } + ], [ + { + TAG: "A", + _0: 3 + }, + { + TAG: "B", + _0: 2, + _1: false + }, + { + TAG: "C", + _0: 1 + } + ]) + }) + ], + tl: { + hd: [ + "function", + () => ({ + TAG: "Eq", + _0: true, + _1: function_equal_test + }) + ], + tl: { + hd: [ + "File \"caml_compare_test.res\", line 20, characters 5-12", + () => ({ + TAG: "Eq", + _0: true, + _1: Primitive_object.lessthan(undefined, 1) + }) + ], + tl: { + hd: [ + "File \"caml_compare_test.res\", line 21, characters 5-12", + () => ({ + TAG: "Eq", + _0: true, + _1: Primitive_object.lessthan(undefined, [ + 1, + 30 + ]) + }) + ], + tl: { + hd: [ + "File \"caml_compare_test.res\", line 22, characters 5-12", + () => ({ + TAG: "Eq", + _0: true, + _1: Primitive_object.greaterthan([ + 1, + 30 + ], undefined) + }) + ], + tl: { + hd: [ + "File \"caml_compare_test.res\", line 24, characters 6-13", + () => ({ + TAG: "Eq", + _0: true, + _1: Primitive_object.lessthan({ + hd: 2, + tl: { + hd: 6, + tl: { + hd: 1, + tl: { + hd: 1, + tl: { + hd: 2, + tl: { + hd: 1, + tl: { + hd: 4, + tl: { + hd: 2, + tl: { + hd: 1, + tl: /* [] */0 + } + } + } + } + } + } + } + } + }, { + hd: 2, + tl: { + hd: 6, + tl: { + hd: 1, + tl: { + hd: 1, + tl: { + hd: 2, + tl: { + hd: 1, + tl: { + hd: 4, + tl: { + hd: 2, + tl: { + hd: 1, + tl: { + hd: 409, + tl: /* [] */0 + } + } + } + } + } + } + } + } + } + }) + }) + ], + tl: { + hd: [ + "File \"caml_compare_test.res\", line 27, characters 5-12", + () => ({ + TAG: "Eq", + _0: true, + _1: Primitive_object.lessthan({ + hd: 1, + tl: /* [] */0 + }, { + hd: 1, + tl: { + hd: 409, + tl: /* [] */0 + } + }) + }) + ], + tl: { + hd: [ + "File \"caml_compare_test.res\", line 28, characters 5-12", + () => ({ + TAG: "Eq", + _0: true, + _1: Primitive_object.lessthan(/* [] */0, { + hd: 409, + tl: /* [] */0 + }) + }) + ], + tl: { + hd: [ + "File \"caml_compare_test.res\", line 30, characters 6-13", + () => ({ + TAG: "Eq", + _0: true, + _1: Primitive_object.greaterthan({ + hd: 2, + tl: { + hd: 6, + tl: { + hd: 1, + tl: { + hd: 1, + tl: { + hd: 2, + tl: { + hd: 1, + tl: { + hd: 4, + tl: { + hd: 2, + tl: { + hd: 1, + tl: { + hd: 409, + tl: /* [] */0 + } + } + } + } + } + } + } + } + } + }, { + hd: 2, + tl: { + hd: 6, + tl: { + hd: 1, + tl: { + hd: 1, + tl: { + hd: 2, + tl: { + hd: 1, + tl: { + hd: 4, + tl: { + hd: 2, + tl: { + hd: 1, + tl: /* [] */0 + } + } + } + } + } + } + } + } + }) + }) + ], + tl: { + hd: [ + "File \"caml_compare_test.res\", line 33, characters 5-12", + () => ({ + TAG: "Eq", + _0: false, + _1: false + }) + ], + tl: { + hd: [ + "File \"caml_compare_test.res\", line 34, characters 5-12", + () => ({ + TAG: "Eq", + _0: false, + _1: false + }) + ], + tl: { + hd: [ + "File \"caml_compare_test.res\", line 36, characters 6-13", + () => ({ + TAG: "Eq", + _0: false, + _1: Primitive_object.equal({ + hd: 2, + tl: { + hd: 6, + tl: { + hd: 1, + tl: { + hd: 1, + tl: { + hd: 2, + tl: { + hd: 1, + tl: { + hd: 4, + tl: { + hd: 2, + tl: { + hd: 1, + tl: /* [] */0 + } + } + } + } + } + } + } + } + }, { + hd: 2, + tl: { + hd: 6, + tl: { + hd: 1, + tl: { + hd: 1, + tl: { + hd: 2, + tl: { + hd: 1, + tl: { + hd: 4, + tl: { + hd: 2, + tl: { + hd: 1, + tl: { + hd: 409, + tl: /* [] */0 + } + } + } + } + } + } + } + } + } + }) + }) + ], + tl: { + hd: [ + "File \"caml_compare_test.res\", line 40, characters 6-13", + () => ({ + TAG: "Eq", + _0: false, + _1: Primitive_object.equal({ + hd: 2, + tl: { + hd: 6, + tl: { + hd: 1, + tl: { + hd: 1, + tl: { + hd: 2, + tl: { + hd: 1, + tl: { + hd: 4, + tl: { + hd: 2, + tl: { + hd: 1, + tl: { + hd: 409, + tl: /* [] */0 + } + } + } + } + } + } + } + } + } + }, { + hd: 2, + tl: { + hd: 6, + tl: { + hd: 1, + tl: { + hd: 1, + tl: { + hd: 2, + tl: { + hd: 1, + tl: { + hd: 4, + tl: { + hd: 2, + tl: { + hd: 1, + tl: /* [] */0 + } + } + } + } + } + } + } + } + }) + }) + ], + tl: { + hd: [ + "cmp_id", + () => ({ + TAG: "Eq", + _0: Primitive_object.compare({ + x: 1, + y: 2 + }, { + x: 1, + y: 2 + }), + _1: 0 + }) + ], + tl: { + hd: [ + "cmp_val", + () => ({ + TAG: "Eq", + _0: Primitive_object.compare({ + x: 1 + }, { + x: 2 + }), + _1: -1 + }) + ], + tl: { + hd: [ + "cmp_val2", + () => ({ + TAG: "Eq", + _0: Primitive_object.compare({ + x: 2 + }, { + x: 1 + }), + _1: 1 + }) + ], + tl: { + hd: [ + "cmp_empty", + () => ({ + TAG: "Eq", + _0: Primitive_object.compare({}, {}), + _1: 0 + }) + ], + tl: { + hd: [ + "cmp_empty2", + () => ({ + TAG: "Eq", + _0: Primitive_object.compare({}, {x:1}), + _1: -1 + }) + ], + tl: { + hd: [ + "cmp_swap", + () => ({ + TAG: "Eq", + _0: Primitive_object.compare({ + x: 1, + y: 2 + }, { + y: 2, + x: 1 + }), + _1: 0 + }) + ], + tl: { + hd: [ + "cmp_size", + () => ({ + TAG: "Eq", + _0: Primitive_object.compare({x:1}, {x:1, y:2}), + _1: -1 + }) + ], + tl: { + hd: [ + "cmp_size2", + () => ({ + TAG: "Eq", + _0: Primitive_object.compare({x:1, y:2}, {x:1}), + _1: 1 + }) + ], + tl: { + hd: [ + "cmp_order", + () => ({ + TAG: "Eq", + _0: Primitive_object.compare({ + x: 0, + y: 1 + }, { + x: 1, + y: 0 + }), + _1: -1 + }) + ], + tl: { + hd: [ + "cmp_order2", + () => ({ + TAG: "Eq", + _0: Primitive_object.compare({ + x: 1, + y: 0 + }, { + x: 0, + y: 1 + }), + _1: 1 + }) + ], + tl: { + hd: [ + "cmp_in_list", + () => ({ + TAG: "Eq", + _0: Primitive_object.compare({ + hd: { + x: 1 + }, + tl: /* [] */0 + }, { + hd: { + x: 2 + }, + tl: /* [] */0 + }), + _1: -1 + }) + ], + tl: { + hd: [ + "cmp_in_list2", + () => ({ + TAG: "Eq", + _0: Primitive_object.compare({ + hd: { + x: 2 + }, + tl: /* [] */0 + }, { + hd: { + x: 1 + }, + tl: /* [] */0 + }), + _1: 1 + }) + ], + tl: { + hd: [ + "cmp_with_list", + () => ({ + TAG: "Eq", + _0: Primitive_object.compare({ + x: { + hd: 0, + tl: /* [] */0 + } + }, { + x: { + hd: 1, + tl: /* [] */0 + } + }), + _1: -1 + }) + ], + tl: { + hd: [ + "cmp_with_list2", + () => ({ + TAG: "Eq", + _0: Primitive_object.compare({ + x: { + hd: 1, + tl: /* [] */0 + } + }, { + x: { + hd: 0, + tl: /* [] */0 + } + }), + _1: 1 + }) + ], + tl: { + hd: [ + "eq_id", + () => ({ + TAG: "Ok", + _0: Primitive_object.equal({ + x: 1, + y: 2 + }, { + x: 1, + y: 2 + }) + }) + ], + tl: { + hd: [ + "eq_val", + () => ({ + TAG: "Eq", + _0: Primitive_object.equal({ + x: 1 + }, { + x: 2 + }), + _1: false + }) + ], + tl: { + hd: [ + "eq_val2", + () => ({ + TAG: "Eq", + _0: Primitive_object.equal({ + x: 2 + }, { + x: 1 + }), + _1: false + }) + ], + tl: { + hd: [ + "eq_empty", + () => ({ + TAG: "Eq", + _0: Primitive_object.equal({}, {}), + _1: true + }) + ], + tl: { + hd: [ + "eq_empty2", + () => ({ + TAG: "Eq", + _0: Primitive_object.equal({}, {x:1}), + _1: false + }) + ], + tl: { + hd: [ + "eq_swap", + () => ({ + TAG: "Ok", + _0: Primitive_object.equal({ + x: 1, + y: 2 + }, { + y: 2, + x: 1 + }) + }) + ], + tl: { + hd: [ + "eq_size", + () => ({ + TAG: "Eq", + _0: Primitive_object.equal({x:1}, {x:1, y:2}), + _1: false + }) + ], + tl: { + hd: [ + "eq_size2", + () => ({ + TAG: "Eq", + _0: Primitive_object.equal({x:1, y:2}, {x:1}), + _1: false + }) + ], + tl: { + hd: [ + "eq_in_list", + () => ({ + TAG: "Eq", + _0: Primitive_object.equal({ + hd: { + x: 1 + }, + tl: /* [] */0 + }, { + hd: { + x: 2 + }, + tl: /* [] */0 + }), + _1: false + }) + ], + tl: { + hd: [ + "eq_in_list2", + () => ({ + TAG: "Eq", + _0: Primitive_object.equal({ + hd: { + x: 2 + }, + tl: /* [] */0 + }, { + hd: { + x: 2 + }, + tl: /* [] */0 + }), + _1: true + }) + ], + tl: { + hd: [ + "eq_with_list", + () => ({ + TAG: "Eq", + _0: Primitive_object.equal({ + x: { + hd: 0, + tl: /* [] */0 + } + }, { + x: { + hd: 0, + tl: /* [] */0 + } + }), + _1: true + }) + ], + tl: { + hd: [ + "eq_with_list2", + () => ({ + TAG: "Eq", + _0: Primitive_object.equal({ + x: { + hd: 0, + tl: /* [] */0 + } + }, { + x: { + hd: 1, + tl: /* [] */0 + } + }), + _1: false + }) + ], + tl: { + hd: [ + "eq_no_prototype", + () => ({ + TAG: "Eq", + _0: Primitive_object.equal({x:1}, ((function(){let o = Object.create(null);o.x = 1;return o;})())), + _1: true + }) + ], + tl: { + hd: [ + "File \"caml_compare_test.res\", line 76, characters 5-12", + () => ({ + TAG: "Eq", + _0: Primitive_object.compare(null, { + hd: 3, + tl: /* [] */0 + }), + _1: -1 + }) + ], + tl: { + hd: [ + "File \"caml_compare_test.res\", line 77, characters 5-12", + () => ({ + TAG: "Eq", + _0: Primitive_object.compare({ + hd: 3, + tl: /* [] */0 + }, null), + _1: 1 + }) + ], + tl: { + hd: [ + "File \"caml_compare_test.res\", line 78, characters 5-12", + () => ({ + TAG: "Eq", + _0: Primitive_object.compare(null, 0), + _1: -1 + }) + ], + tl: { + hd: [ + "File \"caml_compare_test.res\", line 79, characters 5-12", + () => ({ + TAG: "Eq", + _0: Primitive_object.compare(0, null), + _1: 1 + }) + ], + tl: { + hd: [ + "File \"caml_compare_test.res\", line 80, characters 5-12", + () => ({ + TAG: "Eq", + _0: Primitive_object.compare(undefined, 0), + _1: -1 + }) + ], + tl: { + hd: [ + "File \"caml_compare_test.res\", line 81, characters 5-12", + () => ({ + TAG: "Eq", + _0: Primitive_object.compare(0, undefined), + _1: 1 + }) + ], + tl: /* [] */0 + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } +}; + +let test_id = { + contents: 0 +}; + +function eq(loc, x, y) { + Mt.eq_suites(test_id, suites, loc, x, y); +} + +eq("File \"caml_compare_test.res\", line 88, characters 3-10", true, Primitive_object.greaterthan(1, undefined)); + +eq("File \"caml_compare_test.res\", line 89, characters 3-10", true, Primitive_object.lessthan(/* [] */0, { + hd: 1, + tl: /* [] */0 +})); + +eq("File \"caml_compare_test.res\", line 90, characters 3-10", false, Primitive_object.greaterthan(undefined, 1)); + +eq("File \"caml_compare_test.res\", line 91, characters 3-10", false, Primitive_object.greaterthan(undefined, [ + 1, + 30 +])); + +eq("File \"caml_compare_test.res\", line 92, characters 3-10", false, Primitive_object.lessthan([ + 1, + 30 +], undefined)); + +Mt.from_pair_suites("Caml_compare_test", suites.contents); + +export { + function_equal_test, + suites, + test_id, + eq, +} +/* function_equal_test Not a pure module */ diff --git a/tests/tests/src/chain_code_test.js b/tests/tests/src/chain_code_test.js deleted file mode 100644 index b00658505f..0000000000 --- a/tests/tests/src/chain_code_test.js +++ /dev/null @@ -1,69 +0,0 @@ -// Generated by ReScript, PLEASE EDIT WITH CARE -'use strict'; - -let Mt = require("./mt.js"); - -let suites = { - contents: /* [] */0 -}; - -let test_id = { - contents: 0 -}; - -function eq(loc, x, y) { - test_id.contents = test_id.contents + 1 | 0; - suites.contents = { - hd: [ - loc + (" id " + test_id.contents.toString()), - () => ({ - TAG: "Eq", - _0: x, - _1: y - }) - ], - tl: suites.contents - }; -} - -function f(h) { - return h.x.y.z; -} - -function f2(h) { - return h.x.y.z; -} - -function f3(h, x, y) { - return h.paint(x, y).draw(x, y); -} - -function f4(h, x, y) { - h.paint = [ - x, - y - ]; - h.paint.draw = [ - x, - y - ]; -} - -eq("File \"chain_code_test.res\", line 27, characters 12-19", 32, ({ - x: { - y: { - z: 32 - } - } -}).x.y.z); - -Mt.from_pair_suites("Chain_code_test", suites.contents); - -exports.suites = suites; -exports.test_id = test_id; -exports.eq = eq; -exports.f = f; -exports.f2 = f2; -exports.f3 = f3; -exports.f4 = f4; -/* Not a pure module */ diff --git a/tests/tests/src/chain_code_test.mjs b/tests/tests/src/chain_code_test.mjs new file mode 100644 index 0000000000..8b817cb815 --- /dev/null +++ b/tests/tests/src/chain_code_test.mjs @@ -0,0 +1,70 @@ +// Generated by ReScript, PLEASE EDIT WITH CARE + +import * as Mt from "./mt.mjs"; + +let suites = { + contents: /* [] */0 +}; + +let test_id = { + contents: 0 +}; + +function eq(loc, x, y) { + test_id.contents = test_id.contents + 1 | 0; + suites.contents = { + hd: [ + loc + (" id " + test_id.contents.toString()), + () => ({ + TAG: "Eq", + _0: x, + _1: y + }) + ], + tl: suites.contents + }; +} + +function f(h) { + return h.x.y.z; +} + +function f2(h) { + return h.x.y.z; +} + +function f3(h, x, y) { + return h.paint(x, y).draw(x, y); +} + +function f4(h, x, y) { + h.paint = [ + x, + y + ]; + h.paint.draw = [ + x, + y + ]; +} + +eq("File \"chain_code_test.res\", line 27, characters 12-19", 32, ({ + x: { + y: { + z: 32 + } + } +}).x.y.z); + +Mt.from_pair_suites("Chain_code_test", suites.contents); + +export { + suites, + test_id, + eq, + f, + f2, + f3, + f4, +} +/* Not a pure module */ diff --git a/tests/tests/src/chn_test.js b/tests/tests/src/chn_test.js deleted file mode 100644 index 97e5f6699e..0000000000 --- a/tests/tests/src/chn_test.js +++ /dev/null @@ -1,276 +0,0 @@ -// Generated by ReScript, PLEASE EDIT WITH CARE -'use strict'; - -let Mt = require("./mt.js"); -let Belt_List = require("rescript/lib/js/Belt_List.js"); - -let suites = { - contents: /* [] */0 -}; - -let test_id = { - contents: 0 -}; - -function eq(loc, x, y) { - test_id.contents = test_id.contents + 1 | 0; - suites.contents = { - hd: [ - loc + (" id " + test_id.contents.toString()), - () => ({ - TAG: "Eq", - _0: x, - _1: y - }) - ], - tl: suites.contents - }; -} - -console.log("你好,\n世界"); - -console.log("\x3f\u003f\b\t\n\v\f\r\0\"'"); - -function convert(s) { - return Belt_List.fromArray(Array.from(s, x => { - let x$1 = x.codePointAt(0); - if (x$1 !== undefined) { - return x$1; - } - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "chn_test.res", - 24, - 16 - ], - Error: new Error() - }; - })); -} - -eq("File \"chn_test.res\", line 32, characters 4-11", "你好,\n世界", "你好,\n世界"); - -eq("File \"chn_test.res\", line 38, characters 4-11", convert("汉字是世界上最美丽的character"), { - hd: 27721, - tl: { - hd: 23383, - tl: { - hd: 26159, - tl: { - hd: 19990, - tl: { - hd: 30028, - tl: { - hd: 19978, - tl: { - hd: 26368, - tl: { - hd: 32654, - tl: { - hd: 20029, - tl: { - hd: 30340, - tl: { - hd: 99, - tl: { - hd: 104, - tl: { - hd: 97, - tl: { - hd: 114, - tl: { - hd: 97, - tl: { - hd: 99, - tl: { - hd: 116, - tl: { - hd: 101, - tl: { - hd: 114, - tl: /* [] */0 - } - } - } - } - } - } - } - } - } - } - } - } - } - } - } - } - } - } -}); - -eq("File \"chn_test.res\", line 62, characters 5-12", convert("\x3f\x3fa"), { - hd: 63, - tl: { - hd: 63, - tl: { - hd: 97, - tl: /* [] */0 - } - } -}); - -eq("File \"chn_test.res\", line 63, characters 5-12", convert("??a"), { - hd: 63, - tl: { - hd: 63, - tl: { - hd: 97, - tl: /* [] */0 - } - } -}); - -eq("File \"chn_test.res\", line 64, characters 5-12", convert("\u003f\x3fa"), { - hd: 63, - tl: { - hd: 63, - tl: { - hd: 97, - tl: /* [] */0 - } - } -}); - -eq("File \"chn_test.res\", line 65, characters 5-12", convert("🚀🚀a"), { - hd: 128640, - tl: { - hd: 128640, - tl: { - hd: 97, - tl: /* [] */0 - } - } -}); - -eq("File \"chn_test.res\", line 66, characters 5-12", convert("\uD83D\uDE80a"), { - hd: 128640, - tl: { - hd: 97, - tl: /* [] */0 - } -}); - -eq("File \"chn_test.res\", line 67, characters 5-12", convert("\uD83D\uDE80\x3f"), { - hd: 128640, - tl: { - hd: 63, - tl: /* [] */0 - } -}); - -eq("File \"chn_test.res\", line 71, characters 5-12", convert("\uD83D\uDE80\uD83D\uDE80a"), { - hd: 128640, - tl: { - hd: 128640, - tl: { - hd: 97, - tl: /* [] */0 - } - } -}); - -eq("No inline string length", "\uD83D\uDE80\0".length, 3); - -eq("File \"chn_test.res\", line 78, characters 4-11", "\uD83D\uDE80\0".codePointAt(0), 128640); - -eq("File \"chn_test.res\", line 83, characters 5-12", "🚀".codePointAt(0), 128640); - -eq("File \"chn_test.res\", line 88, characters 5-12", convert("\uD83D\uDE80"), { - hd: 128640, - tl: /* [] */0 -}); - -eq("File \"chn_test.res\", line 89, characters 5-12", convert("\uD83D\uDE80\uD83D\uDE80"), { - hd: 128640, - tl: { - hd: 128640, - tl: /* [] */0 - } -}); - -eq("File \"chn_test.res\", line 90, characters 5-12", convert(" \b\t\n\v\f\ra"), { - hd: 32, - tl: { - hd: 8, - tl: { - hd: 9, - tl: { - hd: 10, - tl: { - hd: 11, - tl: { - hd: 12, - tl: { - hd: 13, - tl: { - hd: 97, - tl: /* [] */0 - } - } - } - } - } - } - } -}); - -eq("File \"chn_test.res\", line 96, characters 5-12", convert(" \b\t\n\v\f\r\"'\\\0a"), { - hd: 32, - tl: { - hd: 8, - tl: { - hd: 9, - tl: { - hd: 10, - tl: { - hd: 11, - tl: { - hd: 12, - tl: { - hd: 13, - tl: { - hd: 34, - tl: { - hd: 39, - tl: { - hd: 92, - tl: { - hd: 0, - tl: { - hd: 97, - tl: /* [] */0 - } - } - } - } - } - } - } - } - } - } - } -}); - -Mt.from_pair_suites("Chn_test", suites.contents); - -let $$String; - -exports.$$String = $$String; -exports.suites = suites; -exports.test_id = test_id; -exports.eq = eq; -exports.convert = convert; -/* Not a pure module */ diff --git a/tests/tests/src/chn_test.mjs b/tests/tests/src/chn_test.mjs new file mode 100644 index 0000000000..5a56ac3cb6 --- /dev/null +++ b/tests/tests/src/chn_test.mjs @@ -0,0 +1,277 @@ +// Generated by ReScript, PLEASE EDIT WITH CARE + +import * as Mt from "./mt.mjs"; +import * as Belt_List from "rescript/lib/es6/Belt_List.js"; + +let suites = { + contents: /* [] */0 +}; + +let test_id = { + contents: 0 +}; + +function eq(loc, x, y) { + test_id.contents = test_id.contents + 1 | 0; + suites.contents = { + hd: [ + loc + (" id " + test_id.contents.toString()), + () => ({ + TAG: "Eq", + _0: x, + _1: y + }) + ], + tl: suites.contents + }; +} + +console.log("你好,\n世界"); + +console.log("\x3f\u003f\b\t\n\v\f\r\0\"'"); + +function convert(s) { + return Belt_List.fromArray(Array.from(s, x => { + let x$1 = x.codePointAt(0); + if (x$1 !== undefined) { + return x$1; + } + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "chn_test.res", + 24, + 16 + ], + Error: new Error() + }; + })); +} + +eq("File \"chn_test.res\", line 32, characters 4-11", "你好,\n世界", "你好,\n世界"); + +eq("File \"chn_test.res\", line 38, characters 4-11", convert("汉字是世界上最美丽的character"), { + hd: 27721, + tl: { + hd: 23383, + tl: { + hd: 26159, + tl: { + hd: 19990, + tl: { + hd: 30028, + tl: { + hd: 19978, + tl: { + hd: 26368, + tl: { + hd: 32654, + tl: { + hd: 20029, + tl: { + hd: 30340, + tl: { + hd: 99, + tl: { + hd: 104, + tl: { + hd: 97, + tl: { + hd: 114, + tl: { + hd: 97, + tl: { + hd: 99, + tl: { + hd: 116, + tl: { + hd: 101, + tl: { + hd: 114, + tl: /* [] */0 + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } +}); + +eq("File \"chn_test.res\", line 62, characters 5-12", convert("\x3f\x3fa"), { + hd: 63, + tl: { + hd: 63, + tl: { + hd: 97, + tl: /* [] */0 + } + } +}); + +eq("File \"chn_test.res\", line 63, characters 5-12", convert("??a"), { + hd: 63, + tl: { + hd: 63, + tl: { + hd: 97, + tl: /* [] */0 + } + } +}); + +eq("File \"chn_test.res\", line 64, characters 5-12", convert("\u003f\x3fa"), { + hd: 63, + tl: { + hd: 63, + tl: { + hd: 97, + tl: /* [] */0 + } + } +}); + +eq("File \"chn_test.res\", line 65, characters 5-12", convert("🚀🚀a"), { + hd: 128640, + tl: { + hd: 128640, + tl: { + hd: 97, + tl: /* [] */0 + } + } +}); + +eq("File \"chn_test.res\", line 66, characters 5-12", convert("\uD83D\uDE80a"), { + hd: 128640, + tl: { + hd: 97, + tl: /* [] */0 + } +}); + +eq("File \"chn_test.res\", line 67, characters 5-12", convert("\uD83D\uDE80\x3f"), { + hd: 128640, + tl: { + hd: 63, + tl: /* [] */0 + } +}); + +eq("File \"chn_test.res\", line 71, characters 5-12", convert("\uD83D\uDE80\uD83D\uDE80a"), { + hd: 128640, + tl: { + hd: 128640, + tl: { + hd: 97, + tl: /* [] */0 + } + } +}); + +eq("No inline string length", "\uD83D\uDE80\0".length, 3); + +eq("File \"chn_test.res\", line 78, characters 4-11", "\uD83D\uDE80\0".codePointAt(0), 128640); + +eq("File \"chn_test.res\", line 83, characters 5-12", "🚀".codePointAt(0), 128640); + +eq("File \"chn_test.res\", line 88, characters 5-12", convert("\uD83D\uDE80"), { + hd: 128640, + tl: /* [] */0 +}); + +eq("File \"chn_test.res\", line 89, characters 5-12", convert("\uD83D\uDE80\uD83D\uDE80"), { + hd: 128640, + tl: { + hd: 128640, + tl: /* [] */0 + } +}); + +eq("File \"chn_test.res\", line 90, characters 5-12", convert(" \b\t\n\v\f\ra"), { + hd: 32, + tl: { + hd: 8, + tl: { + hd: 9, + tl: { + hd: 10, + tl: { + hd: 11, + tl: { + hd: 12, + tl: { + hd: 13, + tl: { + hd: 97, + tl: /* [] */0 + } + } + } + } + } + } + } +}); + +eq("File \"chn_test.res\", line 96, characters 5-12", convert(" \b\t\n\v\f\r\"'\\\0a"), { + hd: 32, + tl: { + hd: 8, + tl: { + hd: 9, + tl: { + hd: 10, + tl: { + hd: 11, + tl: { + hd: 12, + tl: { + hd: 13, + tl: { + hd: 34, + tl: { + hd: 39, + tl: { + hd: 92, + tl: { + hd: 0, + tl: { + hd: 97, + tl: /* [] */0 + } + } + } + } + } + } + } + } + } + } + } +}); + +Mt.from_pair_suites("Chn_test", suites.contents); + +let $$String; + +export { + $$String, + suites, + test_id, + eq, + convert, +} +/* Not a pure module */ diff --git a/tests/tests/src/class_type_ffi_test.js b/tests/tests/src/class_type_ffi_test.js deleted file mode 100644 index ad02e32fbc..0000000000 --- a/tests/tests/src/class_type_ffi_test.js +++ /dev/null @@ -1,30 +0,0 @@ -// Generated by ReScript, PLEASE EDIT WITH CARE -'use strict'; - - -function test_set(x) { - x.length__aux = 3; -} - -function ff(fn, a0, a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11) { - return fn(a0, a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11); -} - -function ff2(fn, a0, a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12) { - return fn(a0, a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12); -} - -function off2(o, a0, a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12) { - return o.huge_method(a0, a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12); -} - -function mk_f() { - return (a0, a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12) => a0(a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12); -} - -exports.test_set = test_set; -exports.ff = ff; -exports.ff2 = ff2; -exports.off2 = off2; -exports.mk_f = mk_f; -/* No side effect */ diff --git a/tests/tests/src/class_type_ffi_test.mjs b/tests/tests/src/class_type_ffi_test.mjs new file mode 100644 index 0000000000..90ec60a23b --- /dev/null +++ b/tests/tests/src/class_type_ffi_test.mjs @@ -0,0 +1,31 @@ +// Generated by ReScript, PLEASE EDIT WITH CARE + + +function test_set(x) { + x.length__aux = 3; +} + +function ff(fn, a0, a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11) { + return fn(a0, a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11); +} + +function ff2(fn, a0, a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12) { + return fn(a0, a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12); +} + +function off2(o, a0, a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12) { + return o.huge_method(a0, a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12); +} + +function mk_f() { + return (a0, a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12) => a0(a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12); +} + +export { + test_set, + ff, + ff2, + off2, + mk_f, +} +/* No side effect */ diff --git a/tests/tests/src/coercion_module_alias_test.js b/tests/tests/src/coercion_module_alias_test.js deleted file mode 100644 index c64cadd3d1..0000000000 --- a/tests/tests/src/coercion_module_alias_test.js +++ /dev/null @@ -1,210 +0,0 @@ -// Generated by ReScript, PLEASE EDIT WITH CARE -'use strict'; - -let Char = require("rescript/lib/js/Char.js"); -let Belt_List = require("rescript/lib/js/Belt_List.js"); - -function l(prim) { - console.log(prim); -} - -let C$p = Char; - -console.log(66); - -console.log(66); - -let C3 = Char; - -console.log(66); - -let f = Belt_List.length; - -function g(x) { - return Belt_List.length(Belt_List.map(x, prim => prim + 1 | 0)); -} - -function F(X) { - return Char; -} - -let C4 = Char; - -console.log(66); - -function G(X) { - return X; -} - -let M = {}; - -let N = { - x: 1 -}; - -let N$p; - -let M$p = { - N: N, - N$p: N$p -}; - -console.log(1); - -let M$p$p = { - N$p: N -}; - -console.log(M$p$p.N$p.x); - -let M2 = { - N: N, - N$p: N$p -}; - -let M3 = { - N$p: N -}; - -console.log(1); - -let M3$p = { - N$p: N -}; - -console.log(M3$p.N$p.x); - -let N$1 = { - x: 1 -}; - -let M4 = { - N$p: N$1 -}; - -console.log(1); - -function F0(X) { - let N = { - x: 1 - }; - return { - N: N, - N$p: undefined - }; -} - -let N$2 = { - x: 1 -}; - -let M5 = { - N$p: N$2 -}; - -console.log(M5.N$p.x); - -let D = { - y: 3 -}; - -let N$3 = { - x: 1 -}; - -let N$p$1; - -let M6 = { - D: D, - N: N$3, - N$p: N$p$1 -}; - -console.log(1); - -let M7 = { - N$p: N$3 -}; - -console.log(M7.N$p.x); - -console.log(1); - -let C$p$1; - -let M8 = { - C: undefined, - C$p: C$p$1 -}; - -let M9_C = { - chr: prim => prim -}; - -let M9 = { - C: M9_C, - C$p: C$p$1 -}; - -let prim = M9_C.chr(66); - -console.log(prim); - -let M10 = { - C$p: { - chr: prim => prim - } -}; - -let prim$1 = M10.C$p.chr(66); - -console.log(prim$1); - -let C; - -let C$p$p$p = C$p; - -let C$p$p = Char; - -function G0(funarg) { - let N = { - x: 1 - }; - return { - N$p: N - }; -} - -let M1 = { - N: N$3, - N$p: N$p$1 -}; - -exports.l = l; -exports.C = C; -exports.C$p = C$p; -exports.C$p$p$p = C$p$p$p; -exports.C$p$p = C$p$p; -exports.C3 = C3; -exports.f = f; -exports.g = g; -exports.F = F; -exports.C4 = C4; -exports.G = G; -exports.M = M; -exports.M$p = M$p; -exports.M$p$p = M$p$p; -exports.M2 = M2; -exports.M3 = M3; -exports.M3$p = M3$p; -exports.M4 = M4; -exports.F0 = F0; -exports.G0 = G0; -exports.M5 = M5; -exports.M6 = M6; -exports.M1 = M1; -exports.M7 = M7; -exports.M8 = M8; -exports.M9 = M9; -exports.M10 = M10; -/* Not a pure module */ diff --git a/tests/tests/src/coercion_module_alias_test.mjs b/tests/tests/src/coercion_module_alias_test.mjs new file mode 100644 index 0000000000..d8615b6cdd --- /dev/null +++ b/tests/tests/src/coercion_module_alias_test.mjs @@ -0,0 +1,211 @@ +// Generated by ReScript, PLEASE EDIT WITH CARE + +import * as Char from "rescript/lib/es6/Char.js"; +import * as Belt_List from "rescript/lib/es6/Belt_List.js"; + +function l(prim) { + console.log(prim); +} + +let C$p = Char; + +console.log(66); + +console.log(66); + +let C3 = Char; + +console.log(66); + +let f = Belt_List.length; + +function g(x) { + return Belt_List.length(Belt_List.map(x, prim => prim + 1 | 0)); +} + +function F(X) { + return Char; +} + +let C4 = Char; + +console.log(66); + +function G(X) { + return X; +} + +let M = {}; + +let N = { + x: 1 +}; + +let N$p; + +let M$p = { + N: N, + N$p: N$p +}; + +console.log(1); + +let M$p$p = { + N$p: N +}; + +console.log(M$p$p.N$p.x); + +let M2 = { + N: N, + N$p: N$p +}; + +let M3 = { + N$p: N +}; + +console.log(1); + +let M3$p = { + N$p: N +}; + +console.log(M3$p.N$p.x); + +let N$1 = { + x: 1 +}; + +let M4 = { + N$p: N$1 +}; + +console.log(1); + +function F0(X) { + let N = { + x: 1 + }; + return { + N: N, + N$p: undefined + }; +} + +let N$2 = { + x: 1 +}; + +let M5 = { + N$p: N$2 +}; + +console.log(M5.N$p.x); + +let D = { + y: 3 +}; + +let N$3 = { + x: 1 +}; + +let N$p$1; + +let M6 = { + D: D, + N: N$3, + N$p: N$p$1 +}; + +console.log(1); + +let M7 = { + N$p: N$3 +}; + +console.log(M7.N$p.x); + +console.log(1); + +let C$p$1; + +let M8 = { + C: undefined, + C$p: C$p$1 +}; + +let M9_C = { + chr: prim => prim +}; + +let M9 = { + C: M9_C, + C$p: C$p$1 +}; + +let prim = M9_C.chr(66); + +console.log(prim); + +let M10 = { + C$p: { + chr: prim => prim + } +}; + +let prim$1 = M10.C$p.chr(66); + +console.log(prim$1); + +let C; + +let C$p$p$p = C$p; + +let C$p$p = Char; + +function G0(funarg) { + let N = { + x: 1 + }; + return { + N$p: N + }; +} + +let M1 = { + N: N$3, + N$p: N$p$1 +}; + +export { + l, + C, + C$p, + C$p$p$p, + C$p$p, + C3, + f, + g, + F, + C4, + G, + M, + M$p, + M$p$p, + M2, + M3, + M3$p, + M4, + F0, + G0, + M5, + M6, + M1, + M7, + M8, + M9, + M10, +} +/* Not a pure module */ diff --git a/tests/tests/src/compare_test.js b/tests/tests/src/compare_test.js deleted file mode 100644 index 4b4c6e86ea..0000000000 --- a/tests/tests/src/compare_test.js +++ /dev/null @@ -1,52 +0,0 @@ -// Generated by ReScript, PLEASE EDIT WITH CARE -'use strict'; - - -function compare(x, y) { - switch (x) { - case "A" : - return y === "A"; - case "B" : - return y === "B"; - case "C" : - return y === "C"; - } -} - -function compare2(x, y) { - switch (x) { - case "A" : - switch (y) { - case "A" : - return true; - case "B" : - case "C" : - return false; - } - case "B" : - switch (y) { - case "B" : - return true; - case "A" : - case "C" : - return false; - } - case "C" : - switch (y) { - case "A" : - case "B" : - return false; - case "C" : - return true; - } - } -} - -function compare3(x, y) { - return x === y; -} - -exports.compare = compare; -exports.compare2 = compare2; -exports.compare3 = compare3; -/* No side effect */ diff --git a/tests/tests/src/compare_test.mjs b/tests/tests/src/compare_test.mjs new file mode 100644 index 0000000000..4ce42f1021 --- /dev/null +++ b/tests/tests/src/compare_test.mjs @@ -0,0 +1,53 @@ +// Generated by ReScript, PLEASE EDIT WITH CARE + + +function compare(x, y) { + switch (x) { + case "A" : + return y === "A"; + case "B" : + return y === "B"; + case "C" : + return y === "C"; + } +} + +function compare2(x, y) { + switch (x) { + case "A" : + switch (y) { + case "A" : + return true; + case "B" : + case "C" : + return false; + } + case "B" : + switch (y) { + case "B" : + return true; + case "A" : + case "C" : + return false; + } + case "C" : + switch (y) { + case "A" : + case "B" : + return false; + case "C" : + return true; + } + } +} + +function compare3(x, y) { + return x === y; +} + +export { + compare, + compare2, + compare3, +} +/* No side effect */ diff --git a/tests/tests/src/complete_parmatch_test.js b/tests/tests/src/complete_parmatch_test.js deleted file mode 100644 index 6abcb4081f..0000000000 --- a/tests/tests/src/complete_parmatch_test.js +++ /dev/null @@ -1,19 +0,0 @@ -// Generated by ReScript, PLEASE EDIT WITH CARE -'use strict'; - - -function f(x) { - switch (x) { - case 1 : - return /* 'a' */97; - case 2 : - return /* 'b' */98; - case 3 : - return /* 'c' */99; - default: - return /* 'x' */120; - } -} - -exports.f = f; -/* No side effect */ diff --git a/tests/tests/src/complete_parmatch_test.mjs b/tests/tests/src/complete_parmatch_test.mjs new file mode 100644 index 0000000000..89cada93e2 --- /dev/null +++ b/tests/tests/src/complete_parmatch_test.mjs @@ -0,0 +1,20 @@ +// Generated by ReScript, PLEASE EDIT WITH CARE + + +function f(x) { + switch (x) { + case 1 : + return /* 'a' */97; + case 2 : + return /* 'b' */98; + case 3 : + return /* 'c' */99; + default: + return /* 'x' */120; + } +} + +export { + f, +} +/* No side effect */ diff --git a/tests/tests/src/complex_while_loop.js b/tests/tests/src/complex_while_loop.js deleted file mode 100644 index cd4fa0c7eb..0000000000 --- a/tests/tests/src/complex_while_loop.js +++ /dev/null @@ -1,33 +0,0 @@ -// Generated by ReScript, PLEASE EDIT WITH CARE -'use strict'; - - -function f() { - let n = 0; - while ((() => { - let fib = x => { - if (x === 0 || x === 1) { - return 1; - } else { - return fib(x - 1 | 0) + fib(x - 2 | 0) | 0; - } - }; - return fib(n) > 10; - })()) { - console.log(n.toString()); - n = n + 1 | 0; - }; -} - -function ff() { - while ((() => { - let b = 9; - return (3 + b | 0) > 10; - })()) { - - }; -} - -exports.f = f; -exports.ff = ff; -/* No side effect */ diff --git a/tests/tests/src/complex_while_loop.mjs b/tests/tests/src/complex_while_loop.mjs new file mode 100644 index 0000000000..5fd9b2aa27 --- /dev/null +++ b/tests/tests/src/complex_while_loop.mjs @@ -0,0 +1,34 @@ +// Generated by ReScript, PLEASE EDIT WITH CARE + + +function f() { + let n = 0; + while ((() => { + let fib = x => { + if (x === 0 || x === 1) { + return 1; + } else { + return fib(x - 1 | 0) + fib(x - 2 | 0) | 0; + } + }; + return fib(n) > 10; + })()) { + console.log(n.toString()); + n = n + 1 | 0; + }; +} + +function ff() { + while ((() => { + let b = 9; + return (3 + b | 0) > 10; + })()) { + + }; +} + +export { + f, + ff, +} +/* No side effect */ diff --git a/tests/tests/src/condition_compilation_test.js b/tests/tests/src/condition_compilation_test.js deleted file mode 100644 index 5bca8c3fab..0000000000 --- a/tests/tests/src/condition_compilation_test.js +++ /dev/null @@ -1,66 +0,0 @@ -// Generated by ReScript, PLEASE EDIT WITH CARE -'use strict'; - -let Mt = require("./mt.js"); - -let v = { - contents: 1 -}; - -v.contents = v.contents + 1 | 0; - -let a = v.contents; - -let suites = { - contents: /* [] */0 -}; - -let test_id = { - contents: 0 -}; - -function eq(loc, x, y) { - test_id.contents = test_id.contents + 1 | 0; - suites.contents = { - hd: [ - loc + (" id " + test_id.contents.toString()), - () => ({ - TAG: "Eq", - _0: x, - _1: y - }) - ], - tl: suites.contents - }; -} - -eq("File \"condition_compilation_test.res\", line 63, characters 5-12", 3, 3); - -eq("File \"condition_compilation_test.res\", line 64, characters 5-12", v.contents, 2); - -Mt.from_pair_suites("Condition_compilation_test", suites.contents); - -let b = "u"; - -let buffer_size = 1; - -let vv = 3; - -let version_gt_3 = true; - -let version = -1; - -let ocaml_veriosn = "unknown"; - -exports.b = b; -exports.buffer_size = buffer_size; -exports.vv = vv; -exports.v = v; -exports.a = a; -exports.version_gt_3 = version_gt_3; -exports.version = version; -exports.ocaml_veriosn = ocaml_veriosn; -exports.suites = suites; -exports.test_id = test_id; -exports.eq = eq; -/* Not a pure module */ diff --git a/tests/tests/src/condition_compilation_test.mjs b/tests/tests/src/condition_compilation_test.mjs new file mode 100644 index 0000000000..533679e9e7 --- /dev/null +++ b/tests/tests/src/condition_compilation_test.mjs @@ -0,0 +1,67 @@ +// Generated by ReScript, PLEASE EDIT WITH CARE + +import * as Mt from "./mt.mjs"; + +let v = { + contents: 1 +}; + +v.contents = v.contents + 1 | 0; + +let a = v.contents; + +let suites = { + contents: /* [] */0 +}; + +let test_id = { + contents: 0 +}; + +function eq(loc, x, y) { + test_id.contents = test_id.contents + 1 | 0; + suites.contents = { + hd: [ + loc + (" id " + test_id.contents.toString()), + () => ({ + TAG: "Eq", + _0: x, + _1: y + }) + ], + tl: suites.contents + }; +} + +eq("File \"condition_compilation_test.res\", line 63, characters 5-12", 3, 3); + +eq("File \"condition_compilation_test.res\", line 64, characters 5-12", v.contents, 2); + +Mt.from_pair_suites("Condition_compilation_test", suites.contents); + +let b = "u"; + +let buffer_size = 1; + +let vv = 3; + +let version_gt_3 = true; + +let version = -1; + +let ocaml_veriosn = "unknown"; + +export { + b, + buffer_size, + vv, + v, + a, + version_gt_3, + version, + ocaml_veriosn, + suites, + test_id, + eq, +} +/* Not a pure module */ diff --git a/tests/tests/src/conditional/cond_a.js b/tests/tests/src/conditional/cond_a.js deleted file mode 100644 index 654be840bb..0000000000 --- a/tests/tests/src/conditional/cond_a.js +++ /dev/null @@ -1,16 +0,0 @@ -// Generated by ReScript, PLEASE EDIT WITH CARE -'use strict'; - - -throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "cond_a.res", - 1, - 8 - ], - Error: new Error() -}; - -exports.u = u; -/* u Not a pure module */ diff --git a/tests/tests/src/conditional/cond_a.mjs b/tests/tests/src/conditional/cond_a.mjs new file mode 100644 index 0000000000..7eea77289a --- /dev/null +++ b/tests/tests/src/conditional/cond_a.mjs @@ -0,0 +1,17 @@ +// Generated by ReScript, PLEASE EDIT WITH CARE + + +throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "cond_a.res", + 1, + 8 + ], + Error: new Error() +}; + +export { + u, +} +/* u Not a pure module */ diff --git a/tests/tests/src/conditional/cond_a_B.js b/tests/tests/src/conditional/cond_a_B.js deleted file mode 100644 index c5a52052e0..0000000000 --- a/tests/tests/src/conditional/cond_a_B.js +++ /dev/null @@ -1,15 +0,0 @@ -// Generated by ReScript, PLEASE EDIT WITH CARE -'use strict'; - - -let B = { - value: 3 -}; - -let A = { - u: 3 -}; - -exports.B = B; -exports.A = A; -/* No side effect */ diff --git a/tests/tests/src/conditional/cond_a_B.mjs b/tests/tests/src/conditional/cond_a_B.mjs new file mode 100644 index 0000000000..85ab1e8e9b --- /dev/null +++ b/tests/tests/src/conditional/cond_a_B.mjs @@ -0,0 +1,16 @@ +// Generated by ReScript, PLEASE EDIT WITH CARE + + +let B = { + value: 3 +}; + +let A = { + u: 3 +}; + +export { + B, + A, +} +/* No side effect */ diff --git a/tests/tests/src/conditional/cond_a_C.js b/tests/tests/src/conditional/cond_a_C.js deleted file mode 100644 index 41056e1139..0000000000 --- a/tests/tests/src/conditional/cond_a_C.js +++ /dev/null @@ -1,15 +0,0 @@ -// Generated by ReScript, PLEASE EDIT WITH CARE -'use strict'; - - -let C = { - value: 3 -}; - -let A = { - u: 3 -}; - -exports.C = C; -exports.A = A; -/* No side effect */ diff --git a/tests/tests/src/conditional/cond_a_C.mjs b/tests/tests/src/conditional/cond_a_C.mjs new file mode 100644 index 0000000000..50cff7a715 --- /dev/null +++ b/tests/tests/src/conditional/cond_a_C.mjs @@ -0,0 +1,16 @@ +// Generated by ReScript, PLEASE EDIT WITH CARE + + +let C = { + value: 3 +}; + +let A = { + u: 3 +}; + +export { + C, + A, +} +/* No side effect */ diff --git a/tests/tests/src/conditional/cond_a_none.js b/tests/tests/src/conditional/cond_a_none.js deleted file mode 100644 index 90d2901291..0000000000 --- a/tests/tests/src/conditional/cond_a_none.js +++ /dev/null @@ -1,16 +0,0 @@ -// Generated by ReScript, PLEASE EDIT WITH CARE -'use strict'; - - -throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "cond_a_none.res", - 2, - 10 - ], - Error: new Error() -}; - -exports.A = A; -/* u Not a pure module */ diff --git a/tests/tests/src/conditional/cond_a_none.mjs b/tests/tests/src/conditional/cond_a_none.mjs new file mode 100644 index 0000000000..765ecc86fd --- /dev/null +++ b/tests/tests/src/conditional/cond_a_none.mjs @@ -0,0 +1,17 @@ +// Generated by ReScript, PLEASE EDIT WITH CARE + + +throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "cond_a_none.res", + 2, + 10 + ], + Error: new Error() +}; + +export { + A, +} +/* u Not a pure module */ diff --git a/tests/tests/src/conditional/cond_b.js b/tests/tests/src/conditional/cond_b.js deleted file mode 100644 index aaf55c9a90..0000000000 --- a/tests/tests/src/conditional/cond_b.js +++ /dev/null @@ -1,8 +0,0 @@ -// Generated by ReScript, PLEASE EDIT WITH CARE -'use strict'; - - -let value = 3; - -exports.value = value; -/* No side effect */ diff --git a/tests/tests/src/conditional/cond_b.mjs b/tests/tests/src/conditional/cond_b.mjs new file mode 100644 index 0000000000..522d8f9212 --- /dev/null +++ b/tests/tests/src/conditional/cond_b.mjs @@ -0,0 +1,9 @@ +// Generated by ReScript, PLEASE EDIT WITH CARE + + +let value = 3; + +export { + value, +} +/* No side effect */ diff --git a/tests/tests/src/conditional/cond_c.js b/tests/tests/src/conditional/cond_c.js deleted file mode 100644 index aaf55c9a90..0000000000 --- a/tests/tests/src/conditional/cond_c.js +++ /dev/null @@ -1,8 +0,0 @@ -// Generated by ReScript, PLEASE EDIT WITH CARE -'use strict'; - - -let value = 3; - -exports.value = value; -/* No side effect */ diff --git a/tests/tests/src/conditional/cond_c.mjs b/tests/tests/src/conditional/cond_c.mjs new file mode 100644 index 0000000000..522d8f9212 --- /dev/null +++ b/tests/tests/src/conditional/cond_c.mjs @@ -0,0 +1,9 @@ +// Generated by ReScript, PLEASE EDIT WITH CARE + + +let value = 3; + +export { + value, +} +/* No side effect */ diff --git a/tests/tests/src/config1_test.js b/tests/tests/src/config1_test.mjs similarity index 100% rename from tests/tests/src/config1_test.js rename to tests/tests/src/config1_test.mjs diff --git a/tests/tests/src/console_log_test.js b/tests/tests/src/console_log_test.js deleted file mode 100644 index 7ca7f50b95..0000000000 --- a/tests/tests/src/console_log_test.js +++ /dev/null @@ -1,19 +0,0 @@ -// Generated by ReScript, PLEASE EDIT WITH CARE -'use strict'; - -let Primitive_object = require("rescript/lib/js/Primitive_object.js"); - -function min_int(prim0, prim1) { - return Math.min(prim0, prim1); -} - -function say(prim0, prim1) { - return prim0.say(prim1); -} - -let v = Primitive_object.compare; - -exports.min_int = min_int; -exports.say = say; -exports.v = v; -/* No side effect */ diff --git a/tests/tests/src/console_log_test.mjs b/tests/tests/src/console_log_test.mjs new file mode 100644 index 0000000000..0ca31922c5 --- /dev/null +++ b/tests/tests/src/console_log_test.mjs @@ -0,0 +1,20 @@ +// Generated by ReScript, PLEASE EDIT WITH CARE + +import * as Primitive_object from "rescript/lib/es6/Primitive_object.js"; + +function min_int(prim0, prim1) { + return Math.min(prim0, prim1); +} + +function say(prim0, prim1) { + return prim0.say(prim1); +} + +let v = Primitive_object.compare; + +export { + min_int, + say, + v, +} +/* No side effect */ diff --git a/tests/tests/src/const_block_test.js b/tests/tests/src/const_block_test.js deleted file mode 100644 index 479e3ad51f..0000000000 --- a/tests/tests/src/const_block_test.js +++ /dev/null @@ -1,102 +0,0 @@ -// Generated by ReScript, PLEASE EDIT WITH CARE -'use strict'; - -let Mt = require("./mt.js"); -let Primitive_array = require("rescript/lib/js/Primitive_array.js"); - -let a = [ - 0, - 1, - 2 -]; - -let b = [ - 0, - 1, - 2 -]; - -let c = [ - 0, - 1, - 2, - 3, - 4, - 5 -]; - -function f() { - Primitive_array.set(a, 0, 3.0); - Primitive_array.set(b, 0, 3); -} - -function h() { - return c; -} - -function g() { - f(); - return { - TAG: "Eq", - _0: [ - Primitive_array.get(a, 0), - Primitive_array.get(b, 0) - ], - _1: [ - 3.0, - 3 - ] - }; -} - -let suites_0 = [ - "const_block_test", - g -]; - -let suites_1 = { - hd: [ - "avoid_mutable_inline_test", - () => { - Primitive_array.set(c, 0, 3); - Primitive_array.set(c, 1, 4); - return { - TAG: "Eq", - _0: [ - 3, - 4, - 2, - 3, - 4, - 5 - ], - _1: c - }; - } - ], - tl: /* [] */0 -}; - -let suites = { - hd: suites_0, - tl: suites_1 -}; - -Mt.from_pair_suites("Const_block_test", suites); - -let v = [ - 0, - 1, - 2, - 3, - 4, - 5 -]; - -exports.a = a; -exports.b = b; -exports.c = c; -exports.v = v; -exports.f = f; -exports.h = h; -/* Not a pure module */ diff --git a/tests/tests/src/const_block_test.mjs b/tests/tests/src/const_block_test.mjs new file mode 100644 index 0000000000..fecc847176 --- /dev/null +++ b/tests/tests/src/const_block_test.mjs @@ -0,0 +1,103 @@ +// Generated by ReScript, PLEASE EDIT WITH CARE + +import * as Mt from "./mt.mjs"; +import * as Primitive_array from "rescript/lib/es6/Primitive_array.js"; + +let a = [ + 0, + 1, + 2 +]; + +let b = [ + 0, + 1, + 2 +]; + +let c = [ + 0, + 1, + 2, + 3, + 4, + 5 +]; + +function f() { + Primitive_array.set(a, 0, 3.0); + Primitive_array.set(b, 0, 3); +} + +function h() { + return c; +} + +function g() { + f(); + return { + TAG: "Eq", + _0: [ + Primitive_array.get(a, 0), + Primitive_array.get(b, 0) + ], + _1: [ + 3.0, + 3 + ] + }; +} + +let suites_0 = [ + "const_block_test", + g +]; + +let suites_1 = { + hd: [ + "avoid_mutable_inline_test", + () => { + Primitive_array.set(c, 0, 3); + Primitive_array.set(c, 1, 4); + return { + TAG: "Eq", + _0: [ + 3, + 4, + 2, + 3, + 4, + 5 + ], + _1: c + }; + } + ], + tl: /* [] */0 +}; + +let suites = { + hd: suites_0, + tl: suites_1 +}; + +Mt.from_pair_suites("Const_block_test", suites); + +let v = [ + 0, + 1, + 2, + 3, + 4, + 5 +]; + +export { + a, + b, + c, + v, + f, + h, +} +/* Not a pure module */ diff --git a/tests/tests/src/const_defs.js b/tests/tests/src/const_defs.js deleted file mode 100644 index 4e308ce038..0000000000 --- a/tests/tests/src/const_defs.js +++ /dev/null @@ -1,8 +0,0 @@ -// Generated by ReScript, PLEASE EDIT WITH CARE -'use strict'; - - -let v = true; - -exports.v = v; -/* No side effect */ diff --git a/tests/tests/src/const_defs.mjs b/tests/tests/src/const_defs.mjs new file mode 100644 index 0000000000..929ed489c4 --- /dev/null +++ b/tests/tests/src/const_defs.mjs @@ -0,0 +1,9 @@ +// Generated by ReScript, PLEASE EDIT WITH CARE + + +let v = true; + +export { + v, +} +/* No side effect */ diff --git a/tests/tests/src/const_defs_test.js b/tests/tests/src/const_defs_test.js deleted file mode 100644 index 0d7788f675..0000000000 --- a/tests/tests/src/const_defs_test.js +++ /dev/null @@ -1,14 +0,0 @@ -// Generated by ReScript, PLEASE EDIT WITH CARE -'use strict'; - -let Pervasives = require("rescript/lib/js/Pervasives.js"); - -let u = 3; - -function f() { - return Pervasives.invalid_arg("hi"); -} - -exports.u = u; -exports.f = f; -/* No side effect */ diff --git a/tests/tests/src/const_defs_test.mjs b/tests/tests/src/const_defs_test.mjs new file mode 100644 index 0000000000..538e6c636c --- /dev/null +++ b/tests/tests/src/const_defs_test.mjs @@ -0,0 +1,15 @@ +// Generated by ReScript, PLEASE EDIT WITH CARE + +import * as Pervasives from "rescript/lib/es6/Pervasives.js"; + +let u = 3; + +function f() { + return Pervasives.invalid_arg("hi"); +} + +export { + u, + f, +} +/* No side effect */ diff --git a/tests/tests/src/const_test.js b/tests/tests/src/const_test.js deleted file mode 100644 index e36d5b3ad9..0000000000 --- a/tests/tests/src/const_test.js +++ /dev/null @@ -1,50 +0,0 @@ -// Generated by ReScript, PLEASE EDIT WITH CARE -'use strict'; - - -function f(x) { - return x; -} - -function ff(x) { - return x; -} - -function fff(x) { - let x$1 = { - TAG: "A", - _0: x - }; - switch (x$1.TAG) { - case "A" : - return x; - case "B" : - return 1; - case "C" : - return 2; - } -} - -function h(x) { - if (x === "B") { - return 1; - } else if (x === "C") { - return 2; - } else { - return 0; - } -} - -function hh() { - return 3; -} - -let g = h("A"); - -exports.f = f; -exports.ff = ff; -exports.fff = fff; -exports.h = h; -exports.hh = hh; -exports.g = g; -/* g Not a pure module */ diff --git a/tests/tests/src/const_test.mjs b/tests/tests/src/const_test.mjs new file mode 100644 index 0000000000..3a7d0323ea --- /dev/null +++ b/tests/tests/src/const_test.mjs @@ -0,0 +1,51 @@ +// Generated by ReScript, PLEASE EDIT WITH CARE + + +function f(x) { + return x; +} + +function ff(x) { + return x; +} + +function fff(x) { + let x$1 = { + TAG: "A", + _0: x + }; + switch (x$1.TAG) { + case "A" : + return x; + case "B" : + return 1; + case "C" : + return 2; + } +} + +function h(x) { + if (x === "B") { + return 1; + } else if (x === "C") { + return 2; + } else { + return 0; + } +} + +function hh() { + return 3; +} + +let g = h("A"); + +export { + f, + ff, + fff, + h, + hh, + g, +} +/* g Not a pure module */ diff --git a/tests/tests/src/cont_int_fold_test.js b/tests/tests/src/cont_int_fold_test.js deleted file mode 100644 index 3fa0671aaa..0000000000 --- a/tests/tests/src/cont_int_fold_test.js +++ /dev/null @@ -1,15 +0,0 @@ -// Generated by ReScript, PLEASE EDIT WITH CARE -'use strict'; - - -function a(a0, a1, a2, a3, a4) { - return (((((1 + a0 | 0) + a1 | 0) + a2 | 0) + a3 | 0) + a4 | 0) + 2 | 0; -} - -function b(a0, a1, a2, a3, a4) { - return (((((1 + a0 | 0) + a1 | 0) + a2 | 0) + a3 | 0) + a4 | 0) + (((((1 + a0 | 0) + a1 | 0) + a2 | 0) + a3 | 0) + a4 | 0) | 0; -} - -exports.a = a; -exports.b = b; -/* No side effect */ diff --git a/tests/tests/src/cont_int_fold_test.mjs b/tests/tests/src/cont_int_fold_test.mjs new file mode 100644 index 0000000000..708c375572 --- /dev/null +++ b/tests/tests/src/cont_int_fold_test.mjs @@ -0,0 +1,16 @@ +// Generated by ReScript, PLEASE EDIT WITH CARE + + +function a(a0, a1, a2, a3, a4) { + return (((((1 + a0 | 0) + a1 | 0) + a2 | 0) + a3 | 0) + a4 | 0) + 2 | 0; +} + +function b(a0, a1, a2, a3, a4) { + return (((((1 + a0 | 0) + a1 | 0) + a2 | 0) + a3 | 0) + a4 | 0) + (((((1 + a0 | 0) + a1 | 0) + a2 | 0) + a3 | 0) + a4 | 0) | 0; +} + +export { + a, + b, +} +/* No side effect */ diff --git a/tests/tests/src/cps_test.js b/tests/tests/src/cps_test.js deleted file mode 100644 index 6136c08066..0000000000 --- a/tests/tests/src/cps_test.js +++ /dev/null @@ -1,94 +0,0 @@ -// Generated by ReScript, PLEASE EDIT WITH CARE -'use strict'; - -let Mt = require("./mt.js"); -let Belt_Array = require("rescript/lib/js/Belt_Array.js"); - -function test() { - let v = { - contents: 0 - }; - let f = (_n, _acc) => { - while (true) { - let acc = _acc; - let n = _n; - if (n === 0) { - return acc(); - } - _acc = () => { - v.contents = v.contents + n | 0; - return acc(); - }; - _n = n - 1 | 0; - continue; - }; - }; - f(10, () => {}); - return v.contents; -} - -function test_closure() { - let v = { - contents: 0 - }; - let arr = Belt_Array.make(6, x => x); - for (let i = 0; i <= 5; ++i) { - arr[i] = param => i; - } - Belt_Array.forEach(arr, i => { - v.contents = v.contents + i(0) | 0; - }); - return v.contents; -} - -function test_closure2() { - let v = { - contents: 0 - }; - let arr = Belt_Array.make(6, x => x); - for (let i = 0; i <= 5; ++i) { - let j = i + i | 0; - arr[i] = param => j; - } - Belt_Array.forEach(arr, i => { - v.contents = v.contents + i(0) | 0; - }); - return v.contents; -} - -Mt.from_pair_suites("Cps_test", { - hd: [ - "cps_test_sum", - () => ({ - TAG: "Eq", - _0: 55, - _1: test() - }) - ], - tl: { - hd: [ - "cps_test_closure", - () => ({ - TAG: "Eq", - _0: 15, - _1: test_closure() - }) - ], - tl: { - hd: [ - "cps_test_closure2", - () => ({ - TAG: "Eq", - _0: 30, - _1: test_closure2() - }) - ], - tl: /* [] */0 - } - } -}); - -exports.test = test; -exports.test_closure = test_closure; -exports.test_closure2 = test_closure2; -/* Not a pure module */ diff --git a/tests/tests/src/cps_test.mjs b/tests/tests/src/cps_test.mjs new file mode 100644 index 0000000000..1e1c1c6d8f --- /dev/null +++ b/tests/tests/src/cps_test.mjs @@ -0,0 +1,95 @@ +// Generated by ReScript, PLEASE EDIT WITH CARE + +import * as Mt from "./mt.mjs"; +import * as Belt_Array from "rescript/lib/es6/Belt_Array.js"; + +function test() { + let v = { + contents: 0 + }; + let f = (_n, _acc) => { + while (true) { + let acc = _acc; + let n = _n; + if (n === 0) { + return acc(); + } + _acc = () => { + v.contents = v.contents + n | 0; + return acc(); + }; + _n = n - 1 | 0; + continue; + }; + }; + f(10, () => {}); + return v.contents; +} + +function test_closure() { + let v = { + contents: 0 + }; + let arr = Belt_Array.make(6, x => x); + for (let i = 0; i <= 5; ++i) { + arr[i] = param => i; + } + Belt_Array.forEach(arr, i => { + v.contents = v.contents + i(0) | 0; + }); + return v.contents; +} + +function test_closure2() { + let v = { + contents: 0 + }; + let arr = Belt_Array.make(6, x => x); + for (let i = 0; i <= 5; ++i) { + let j = i + i | 0; + arr[i] = param => j; + } + Belt_Array.forEach(arr, i => { + v.contents = v.contents + i(0) | 0; + }); + return v.contents; +} + +Mt.from_pair_suites("Cps_test", { + hd: [ + "cps_test_sum", + () => ({ + TAG: "Eq", + _0: 55, + _1: test() + }) + ], + tl: { + hd: [ + "cps_test_closure", + () => ({ + TAG: "Eq", + _0: 15, + _1: test_closure() + }) + ], + tl: { + hd: [ + "cps_test_closure2", + () => ({ + TAG: "Eq", + _0: 30, + _1: test_closure2() + }) + ], + tl: /* [] */0 + } + } +}); + +export { + test, + test_closure, + test_closure2, +} +/* Not a pure module */ diff --git a/tests/tests/src/cross_module_inline_test.js b/tests/tests/src/cross_module_inline_test.js deleted file mode 100644 index eb32c53f16..0000000000 --- a/tests/tests/src/cross_module_inline_test.js +++ /dev/null @@ -1,9 +0,0 @@ -// Generated by ReScript, PLEASE EDIT WITH CARE -'use strict'; - -let Test_char = require("./test_char.js"); - -let v = Test_char.caml_is_printable(/* 'a' */97); - -exports.v = v; -/* v Not a pure module */ diff --git a/tests/tests/src/cross_module_inline_test.mjs b/tests/tests/src/cross_module_inline_test.mjs new file mode 100644 index 0000000000..715b9c6e1d --- /dev/null +++ b/tests/tests/src/cross_module_inline_test.mjs @@ -0,0 +1,10 @@ +// Generated by ReScript, PLEASE EDIT WITH CARE + +import * as Test_char from "./test_char.mjs"; + +let v = Test_char.caml_is_printable(/* 'a' */97); + +export { + v, +} +/* v Not a pure module */ diff --git a/tests/tests/src/custom_error_test.js b/tests/tests/src/custom_error_test.js deleted file mode 100644 index 12e8246a47..0000000000 --- a/tests/tests/src/custom_error_test.js +++ /dev/null @@ -1,66 +0,0 @@ -// Generated by ReScript, PLEASE EDIT WITH CARE -'use strict'; - -let Exn = require("rescript/lib/js/Exn.js"); -let Primitive_exceptions = require("rescript/lib/js/Primitive_exceptions.js"); - -function test_js_error() { - let e; - try { - e = JSON.parse(" {\"x\" : }"); - } catch (raw_err) { - let err = Primitive_exceptions.internalToException(raw_err); - if (err.RE_EXN_ID === Exn.$$Error) { - console.log(err._1.stack); - return; - } - throw err; - } - return e; -} - -function test_js_error2() { - try { - return JSON.parse(" {\"x\" : }"); - } catch (raw_e) { - let e = Primitive_exceptions.internalToException(raw_e); - if (e.RE_EXN_ID === Exn.$$Error) { - console.log(e._1.stack); - throw e; - } - throw e; - } -} - -function example1() { - let v; - try { - v = JSON.parse(" {\"x\" }"); - } catch (raw_err) { - let err = Primitive_exceptions.internalToException(raw_err); - if (err.RE_EXN_ID === Exn.$$Error) { - console.log(err._1.stack); - return; - } - throw err; - } - return v; -} - -function example2() { - try { - return JSON.parse(" {\"x\"}"); - } catch (raw_exn) { - let exn = Primitive_exceptions.internalToException(raw_exn); - if (exn.RE_EXN_ID === Exn.$$Error) { - return; - } - throw exn; - } -} - -exports.test_js_error = test_js_error; -exports.test_js_error2 = test_js_error2; -exports.example1 = example1; -exports.example2 = example2; -/* No side effect */ diff --git a/tests/tests/src/custom_error_test.mjs b/tests/tests/src/custom_error_test.mjs new file mode 100644 index 0000000000..8954226c64 --- /dev/null +++ b/tests/tests/src/custom_error_test.mjs @@ -0,0 +1,67 @@ +// Generated by ReScript, PLEASE EDIT WITH CARE + +import * as Exn from "rescript/lib/es6/Exn.js"; +import * as Primitive_exceptions from "rescript/lib/es6/Primitive_exceptions.js"; + +function test_js_error() { + let e; + try { + e = JSON.parse(" {\"x\" : }"); + } catch (raw_err) { + let err = Primitive_exceptions.internalToException(raw_err); + if (err.RE_EXN_ID === Exn.$$Error) { + console.log(err._1.stack); + return; + } + throw err; + } + return e; +} + +function test_js_error2() { + try { + return JSON.parse(" {\"x\" : }"); + } catch (raw_e) { + let e = Primitive_exceptions.internalToException(raw_e); + if (e.RE_EXN_ID === Exn.$$Error) { + console.log(e._1.stack); + throw e; + } + throw e; + } +} + +function example1() { + let v; + try { + v = JSON.parse(" {\"x\" }"); + } catch (raw_err) { + let err = Primitive_exceptions.internalToException(raw_err); + if (err.RE_EXN_ID === Exn.$$Error) { + console.log(err._1.stack); + return; + } + throw err; + } + return v; +} + +function example2() { + try { + return JSON.parse(" {\"x\"}"); + } catch (raw_exn) { + let exn = Primitive_exceptions.internalToException(raw_exn); + if (exn.RE_EXN_ID === Exn.$$Error) { + return; + } + throw exn; + } +} + +export { + test_js_error, + test_js_error2, + example1, + example2, +} +/* No side effect */ diff --git a/tests/tests/src/debug_keep_test.js b/tests/tests/src/debug_keep_test.js deleted file mode 100644 index 6b2d610da8..0000000000 --- a/tests/tests/src/debug_keep_test.js +++ /dev/null @@ -1,7 +0,0 @@ -// Generated by ReScript, PLEASE EDIT WITH CARE -'use strict'; - - -debugger; - -/* Not a pure module */ diff --git a/tests/tests/src/debug_keep_test.mjs b/tests/tests/src/debug_keep_test.mjs new file mode 100644 index 0000000000..93b325414a --- /dev/null +++ b/tests/tests/src/debug_keep_test.mjs @@ -0,0 +1,6 @@ +// Generated by ReScript, PLEASE EDIT WITH CARE + + +debugger; + +/* Not a pure module */ diff --git a/tests/tests/src/debug_mode_value.js b/tests/tests/src/debug_mode_value.js deleted file mode 100644 index 2e14ec1623..0000000000 --- a/tests/tests/src/debug_mode_value.js +++ /dev/null @@ -1,19 +0,0 @@ -// Generated by ReScript, PLEASE EDIT WITH CARE -'use strict'; - - -let u = { - TAG: "A", - _0: 1, - _1: 2, - [Symbol.for("name")]: "A" -}; - -let h = { - hd: 1, - tl: /* [] */0 -}; - -exports.u = u; -exports.h = h; -/* No side effect */ diff --git a/tests/tests/src/debug_mode_value.mjs b/tests/tests/src/debug_mode_value.mjs new file mode 100644 index 0000000000..5312ef0edf --- /dev/null +++ b/tests/tests/src/debug_mode_value.mjs @@ -0,0 +1,20 @@ +// Generated by ReScript, PLEASE EDIT WITH CARE + + +let u = { + TAG: "A", + _0: 1, + _1: 2, + [Symbol.for("name")]: "A" +}; + +let h = { + hd: 1, + tl: /* [] */0 +}; + +export { + u, + h, +} +/* No side effect */ diff --git a/tests/tests/src/debug_tmp.js b/tests/tests/src/debug_tmp.mjs similarity index 100% rename from tests/tests/src/debug_tmp.js rename to tests/tests/src/debug_tmp.mjs diff --git a/tests/tests/src/debugger_test.js b/tests/tests/src/debugger_test.js deleted file mode 100644 index 37d33813f9..0000000000 --- a/tests/tests/src/debugger_test.js +++ /dev/null @@ -1,34 +0,0 @@ -// Generated by ReScript, PLEASE EDIT WITH CARE -'use strict'; - - -function f(x, y) { - console.log([ - x, - y - ]); - return x + y | 0; -} - -function g() { - f(1, 2); - debugger; - f(1, 2); - debugger; - return 3; -} - -function exterme_g() { - f(1, 2); - debugger; - let v; - console.log(v); - f(1, 2); - debugger; - return 3; -} - -exports.f = f; -exports.g = g; -exports.exterme_g = exterme_g; -/* No side effect */ diff --git a/tests/tests/src/debugger_test.mjs b/tests/tests/src/debugger_test.mjs new file mode 100644 index 0000000000..0ff39dd1b0 --- /dev/null +++ b/tests/tests/src/debugger_test.mjs @@ -0,0 +1,35 @@ +// Generated by ReScript, PLEASE EDIT WITH CARE + + +function f(x, y) { + console.log([ + x, + y + ]); + return x + y | 0; +} + +function g() { + f(1, 2); + debugger; + f(1, 2); + debugger; + return 3; +} + +function exterme_g() { + f(1, 2); + debugger; + let v; + console.log(v); + f(1, 2); + debugger; + return 3; +} + +export { + f, + g, + exterme_g, +} +/* No side effect */ diff --git a/tests/tests/src/default_export_test.js b/tests/tests/src/default_export_test.js deleted file mode 100644 index 86a2657e3a..0000000000 --- a/tests/tests/src/default_export_test.js +++ /dev/null @@ -1,9 +0,0 @@ -// Generated by ReScript, PLEASE EDIT WITH CARE -'use strict'; - - -let $$default = "xx"; - -exports.default = $$default; -exports.__esModule = true; -/* No side effect */ diff --git a/tests/tests/src/default_export_test.mjs b/tests/tests/src/default_export_test.mjs new file mode 100644 index 0000000000..4c67f05d73 --- /dev/null +++ b/tests/tests/src/default_export_test.mjs @@ -0,0 +1,9 @@ +// Generated by ReScript, PLEASE EDIT WITH CARE + + +let $$default = "xx"; + +export { + $$default as default, +} +/* No side effect */ diff --git a/tests/tests/src/defunctor_make_test.js b/tests/tests/src/defunctor_make_test.js deleted file mode 100644 index 3e5afd3d23..0000000000 --- a/tests/tests/src/defunctor_make_test.js +++ /dev/null @@ -1,172 +0,0 @@ -// Generated by ReScript, PLEASE EDIT WITH CARE -'use strict'; - -let Pervasives = require("rescript/lib/js/Pervasives.js"); -let Primitive_int = require("rescript/lib/js/Primitive_int.js"); - -function getcompare(x) { - return x; -} - -function Make(M) { - return M; -} - -let Comparable = { - getcompare: getcompare, - Make: Make -}; - -function height(x) { - if (typeof x !== "object") { - return 0; - } else { - return x._4; - } -} - -function create(l, x, d, r) { - let hl = height(l); - let hr = height(r); - return { - TAG: "Node", - _0: l, - _1: x, - _2: d, - _3: r, - _4: hl >= hr ? hl + 1 | 0 : hr + 1 | 0 - }; -} - -function bal(l, x, d, r) { - let hl; - hl = typeof l !== "object" ? 0 : l._4; - let hr; - hr = typeof r !== "object" ? 0 : r._4; - if (hl > (hr + 2 | 0)) { - if (typeof l !== "object") { - return Pervasives.invalid_arg("Map.bal"); - } - let lr = l._3; - let ld = l._2; - let lv = l._1; - let ll = l._0; - if (height(ll) >= height(lr)) { - return create(ll, lv, ld, create(lr, x, d, r)); - } else if (typeof lr !== "object") { - return Pervasives.invalid_arg("Map.bal"); - } else { - return create(create(ll, lv, ld, lr._0), lr._1, lr._2, create(lr._3, x, d, r)); - } - } - if (hr <= (hl + 2 | 0)) { - return { - TAG: "Node", - _0: l, - _1: x, - _2: d, - _3: r, - _4: hl >= hr ? hl + 1 | 0 : hr + 1 | 0 - }; - } - if (typeof r !== "object") { - return Pervasives.invalid_arg("Map.bal"); - } - let rr = r._3; - let rd = r._2; - let rv = r._1; - let rl = r._0; - if (height(rr) >= height(rl)) { - return create(create(l, x, d, rl), rv, rd, rr); - } else if (typeof rl !== "object") { - return Pervasives.invalid_arg("Map.bal"); - } else { - return create(create(l, x, d, rl._0), rl._1, rl._2, create(rl._3, rv, rd, rr)); - } -} - -function add(x, data, compare, x_) { - if (typeof x_ !== "object") { - return { - TAG: "Node", - _0: "Empty", - _1: x, - _2: data, - _3: "Empty", - _4: 1 - }; - } - let r = x_._3; - let d = x_._2; - let v = x_._1; - let l = x_._0; - let c = compare(x, v); - if (c === 0) { - return { - TAG: "Node", - _0: l, - _1: x, - _2: data, - _3: r, - _4: x_._4 - }; - } else if (c < 0) { - return bal(add(x, data, compare, l), v, d, r); - } else { - return bal(l, v, d, add(x, data, compare, r)); - } -} - -function add$1(x, data, v) { - let X = v.compare; - return { - compare: v.compare, - data: add(x, data, X.compare, v.data) - }; -} - -function empty(v) { - return { - compare: v, - data: "Empty" - }; -} - -let compare = Primitive_int.compare; - -let V0 = { - compare: compare -}; - -let compare$1 = Primitive_int.compare; - -let V1 = { - compare: compare$1 -}; - -let v0 = { - compare: V0, - data: "Empty" -}; - -let v1 = { - compare: V1, - data: "Empty" -}; - -let v3 = add$1(3, "a", v0); - -console.log(v3); - -exports.Comparable = Comparable; -exports.height = height; -exports.create = create; -exports.bal = bal; -exports.add = add$1; -exports.empty = empty; -exports.V0 = V0; -exports.V1 = V1; -exports.v0 = v0; -exports.v1 = v1; -exports.v3 = v3; -/* v3 Not a pure module */ diff --git a/tests/tests/src/defunctor_make_test.mjs b/tests/tests/src/defunctor_make_test.mjs new file mode 100644 index 0000000000..e0ddcadaec --- /dev/null +++ b/tests/tests/src/defunctor_make_test.mjs @@ -0,0 +1,173 @@ +// Generated by ReScript, PLEASE EDIT WITH CARE + +import * as Pervasives from "rescript/lib/es6/Pervasives.js"; +import * as Primitive_int from "rescript/lib/es6/Primitive_int.js"; + +function getcompare(x) { + return x; +} + +function Make(M) { + return M; +} + +let Comparable = { + getcompare: getcompare, + Make: Make +}; + +function height(x) { + if (typeof x !== "object") { + return 0; + } else { + return x._4; + } +} + +function create(l, x, d, r) { + let hl = height(l); + let hr = height(r); + return { + TAG: "Node", + _0: l, + _1: x, + _2: d, + _3: r, + _4: hl >= hr ? hl + 1 | 0 : hr + 1 | 0 + }; +} + +function bal(l, x, d, r) { + let hl; + hl = typeof l !== "object" ? 0 : l._4; + let hr; + hr = typeof r !== "object" ? 0 : r._4; + if (hl > (hr + 2 | 0)) { + if (typeof l !== "object") { + return Pervasives.invalid_arg("Map.bal"); + } + let lr = l._3; + let ld = l._2; + let lv = l._1; + let ll = l._0; + if (height(ll) >= height(lr)) { + return create(ll, lv, ld, create(lr, x, d, r)); + } else if (typeof lr !== "object") { + return Pervasives.invalid_arg("Map.bal"); + } else { + return create(create(ll, lv, ld, lr._0), lr._1, lr._2, create(lr._3, x, d, r)); + } + } + if (hr <= (hl + 2 | 0)) { + return { + TAG: "Node", + _0: l, + _1: x, + _2: d, + _3: r, + _4: hl >= hr ? hl + 1 | 0 : hr + 1 | 0 + }; + } + if (typeof r !== "object") { + return Pervasives.invalid_arg("Map.bal"); + } + let rr = r._3; + let rd = r._2; + let rv = r._1; + let rl = r._0; + if (height(rr) >= height(rl)) { + return create(create(l, x, d, rl), rv, rd, rr); + } else if (typeof rl !== "object") { + return Pervasives.invalid_arg("Map.bal"); + } else { + return create(create(l, x, d, rl._0), rl._1, rl._2, create(rl._3, rv, rd, rr)); + } +} + +function add(x, data, compare, x_) { + if (typeof x_ !== "object") { + return { + TAG: "Node", + _0: "Empty", + _1: x, + _2: data, + _3: "Empty", + _4: 1 + }; + } + let r = x_._3; + let d = x_._2; + let v = x_._1; + let l = x_._0; + let c = compare(x, v); + if (c === 0) { + return { + TAG: "Node", + _0: l, + _1: x, + _2: data, + _3: r, + _4: x_._4 + }; + } else if (c < 0) { + return bal(add(x, data, compare, l), v, d, r); + } else { + return bal(l, v, d, add(x, data, compare, r)); + } +} + +function add$1(x, data, v) { + let X = v.compare; + return { + compare: v.compare, + data: add(x, data, X.compare, v.data) + }; +} + +function empty(v) { + return { + compare: v, + data: "Empty" + }; +} + +let compare = Primitive_int.compare; + +let V0 = { + compare: compare +}; + +let compare$1 = Primitive_int.compare; + +let V1 = { + compare: compare$1 +}; + +let v0 = { + compare: V0, + data: "Empty" +}; + +let v1 = { + compare: V1, + data: "Empty" +}; + +let v3 = add$1(3, "a", v0); + +console.log(v3); + +export { + Comparable, + height, + create, + bal, + add$1 as add, + empty, + V0, + V1, + v0, + v1, + v3, +} +/* v3 Not a pure module */ diff --git a/tests/tests/src/demo_int_map.js b/tests/tests/src/demo_int_map.js deleted file mode 100644 index d8531713c0..0000000000 --- a/tests/tests/src/demo_int_map.js +++ /dev/null @@ -1,18 +0,0 @@ -// Generated by ReScript, PLEASE EDIT WITH CARE -'use strict'; - -let Belt_MapInt = require("rescript/lib/js/Belt_MapInt.js"); - -function test() { - let m; - for (let i = 0; i <= 1000000; ++i) { - m = Belt_MapInt.set(m, i, i); - } - for (let i$1 = 0; i$1 <= 1000000; ++i$1) { - Belt_MapInt.get(m, i$1); - } -} - -test(); - -/* Not a pure module */ diff --git a/tests/tests/src/demo_int_map.mjs b/tests/tests/src/demo_int_map.mjs new file mode 100644 index 0000000000..21aadffef3 --- /dev/null +++ b/tests/tests/src/demo_int_map.mjs @@ -0,0 +1,17 @@ +// Generated by ReScript, PLEASE EDIT WITH CARE + +import * as Belt_MapInt from "rescript/lib/es6/Belt_MapInt.js"; + +function test() { + let m; + for (let i = 0; i <= 1000000; ++i) { + m = Belt_MapInt.set(m, i, i); + } + for (let i$1 = 0; i$1 <= 1000000; ++i$1) { + Belt_MapInt.get(m, i$1); + } +} + +test(); + +/* Not a pure module */ diff --git a/tests/tests/src/demo_page.js b/tests/tests/src/demo_page.js deleted file mode 100644 index f506133343..0000000000 --- a/tests/tests/src/demo_page.js +++ /dev/null @@ -1,54 +0,0 @@ -// Generated by ReScript, PLEASE EDIT WITH CARE -'use strict'; - -let React = require("react"); -let ReactDom = require("react-dom"); - -function fib(x) { - if (x === 2 || x === 1) { - return 1; - } else { - return fib(x - 1 | 0) + fib(x - 2 | 0) | 0; - } -} - -function sum(n) { - let v = 0; - for (let i = 0; i <= n; ++i) { - v = v + i | 0; - } - return v; -} - -function map(f, x) { - if (typeof x !== "object") { - return "Nil"; - } else { - return { - TAG: "Cons", - _0: f(x._0), - _1: map(f, x._1) - }; - } -} - -function test_curry(x, y) { - return x + y | 0; -} - -function f(extra) { - return 32 + extra | 0; -} - -ReactDom.render(React.createClass({ - render: () => React.DOM.div({ - alt: "pic" - }, React.DOM.h1(undefined, "hello react"), React.DOM.h2(undefined, "type safe!")) -}), document.getElementById("hi")); - -exports.fib = fib; -exports.sum = sum; -exports.map = map; -exports.test_curry = test_curry; -exports.f = f; -/* Not a pure module */ diff --git a/tests/tests/src/demo_page.mjs b/tests/tests/src/demo_page.mjs new file mode 100644 index 0000000000..ee3b1665a5 --- /dev/null +++ b/tests/tests/src/demo_page.mjs @@ -0,0 +1,55 @@ +// Generated by ReScript, PLEASE EDIT WITH CARE + +import * as React from "react"; +import * as ReactDom from "react-dom"; + +function fib(x) { + if (x === 2 || x === 1) { + return 1; + } else { + return fib(x - 1 | 0) + fib(x - 2 | 0) | 0; + } +} + +function sum(n) { + let v = 0; + for (let i = 0; i <= n; ++i) { + v = v + i | 0; + } + return v; +} + +function map(f, x) { + if (typeof x !== "object") { + return "Nil"; + } else { + return { + TAG: "Cons", + _0: f(x._0), + _1: map(f, x._1) + }; + } +} + +function test_curry(x, y) { + return x + y | 0; +} + +function f(extra) { + return 32 + extra | 0; +} + +ReactDom.render(React.createClass({ + render: () => React.DOM.div({ + alt: "pic" + }, React.DOM.h1(undefined, "hello react"), React.DOM.h2(undefined, "type safe!")) +}), document.getElementById("hi")); + +export { + fib, + sum, + map, + test_curry, + f, +} +/* Not a pure module */ diff --git a/tests/tests/src/demo_pipe.js b/tests/tests/src/demo_pipe.js deleted file mode 100644 index ade4eaf5be..0000000000 --- a/tests/tests/src/demo_pipe.js +++ /dev/null @@ -1,14 +0,0 @@ -// Generated by ReScript, PLEASE EDIT WITH CARE -'use strict'; - - -function register(rl) { - return rl.on("line", x => { - console.log(x); - }).on("close", () => { - console.log("finished"); - }); -} - -exports.register = register; -/* No side effect */ diff --git a/tests/tests/src/demo_pipe.mjs b/tests/tests/src/demo_pipe.mjs new file mode 100644 index 0000000000..2e061cce11 --- /dev/null +++ b/tests/tests/src/demo_pipe.mjs @@ -0,0 +1,15 @@ +// Generated by ReScript, PLEASE EDIT WITH CARE + + +function register(rl) { + return rl.on("line", x => { + console.log(x); + }).on("close", () => { + console.log("finished"); + }); +} + +export { + register, +} +/* No side effect */ diff --git a/tests/tests/src/derive_projector_test.js b/tests/tests/src/derive_projector_test.js deleted file mode 100644 index 6ed61163a3..0000000000 --- a/tests/tests/src/derive_projector_test.js +++ /dev/null @@ -1,127 +0,0 @@ -// Generated by ReScript, PLEASE EDIT WITH CARE -'use strict'; - - -function u_x(param) { - return param.u_x; -} - -function b_x(param) { - return param.b_x; -} - -function c_x(param) { - return param.c_x; -} - -function d_int(param_0) { - return { - TAG: "D_int", - _0: param_0 - }; -} - -function d_tuple(param_0, param_1) { - return { - TAG: "D_tuple", - _0: param_0, - _1: param_1 - }; -} - -function newContent(param_0) { - return { - TAG: "NewContent", - _0: param_0 - }; -} - -function d_tweak(param_0) { - return { - TAG: "D_tweak", - _0: param_0 - }; -} - -function u_X(param) { - return param.u_X; -} - -function d(param) { - return param.d; -} - -let v = { - TAG: "D_int", - _0: 3 -}; - -let h_1 = { - hd: { - TAG: "D_int", - _0: 3 - }, - tl: { - hd: { - TAG: "D_tuple", - _0: 3, - _1: "hgo" - }, - tl: { - hd: { - TAG: "D_tweak", - _0: [ - 3, - "hgo" - ] - }, - tl: { - hd: { - TAG: "NewContent", - _0: "3" - }, - tl: /* [] */0 - } - } - } -}; - -let h = { - hd: "D_empty", - tl: h_1 -}; - -function xx(param_0) { - return { - TAG: "Xx", - _0: param_0 - }; -} - -function a(param_0) { - return { - TAG: "A", - _0: param_0 - }; -} - -let d_empty = "D_empty"; - -let hei = "Hei"; - -exports.u_x = u_x; -exports.b_x = b_x; -exports.c_x = c_x; -exports.d_empty = d_empty; -exports.d_int = d_int; -exports.d_tuple = d_tuple; -exports.newContent = newContent; -exports.d_tweak = d_tweak; -exports.hei = hei; -exports.u_X = u_X; -exports.d = d; -exports.v = v; -exports.h = h; -exports.xx = xx; -exports.a = a; -/* No side effect */ diff --git a/tests/tests/src/derive_projector_test.mjs b/tests/tests/src/derive_projector_test.mjs new file mode 100644 index 0000000000..c732e0e0f8 --- /dev/null +++ b/tests/tests/src/derive_projector_test.mjs @@ -0,0 +1,128 @@ +// Generated by ReScript, PLEASE EDIT WITH CARE + + +function u_x(param) { + return param.u_x; +} + +function b_x(param) { + return param.b_x; +} + +function c_x(param) { + return param.c_x; +} + +function d_int(param_0) { + return { + TAG: "D_int", + _0: param_0 + }; +} + +function d_tuple(param_0, param_1) { + return { + TAG: "D_tuple", + _0: param_0, + _1: param_1 + }; +} + +function newContent(param_0) { + return { + TAG: "NewContent", + _0: param_0 + }; +} + +function d_tweak(param_0) { + return { + TAG: "D_tweak", + _0: param_0 + }; +} + +function u_X(param) { + return param.u_X; +} + +function d(param) { + return param.d; +} + +let v = { + TAG: "D_int", + _0: 3 +}; + +let h_1 = { + hd: { + TAG: "D_int", + _0: 3 + }, + tl: { + hd: { + TAG: "D_tuple", + _0: 3, + _1: "hgo" + }, + tl: { + hd: { + TAG: "D_tweak", + _0: [ + 3, + "hgo" + ] + }, + tl: { + hd: { + TAG: "NewContent", + _0: "3" + }, + tl: /* [] */0 + } + } + } +}; + +let h = { + hd: "D_empty", + tl: h_1 +}; + +function xx(param_0) { + return { + TAG: "Xx", + _0: param_0 + }; +} + +function a(param_0) { + return { + TAG: "A", + _0: param_0 + }; +} + +let d_empty = "D_empty"; + +let hei = "Hei"; + +export { + u_x, + b_x, + c_x, + d_empty, + d_int, + d_tuple, + newContent, + d_tweak, + hei, + u_X, + d, + v, + h, + xx, + a, +} +/* No side effect */ diff --git a/tests/tests/src/directives.js b/tests/tests/src/directives.js deleted file mode 100644 index 4272ed41a3..0000000000 --- a/tests/tests/src/directives.js +++ /dev/null @@ -1,11 +0,0 @@ -first directive; -second directive; -// Generated by ReScript, PLEASE EDIT WITH CARE -'use strict'; - -let Belt_Array = require("rescript/lib/js/Belt_Array.js"); - -let a = Belt_Array.forEach; - -exports.a = a; -/* No side effect */ diff --git a/tests/tests/src/directives.mjs b/tests/tests/src/directives.mjs new file mode 100644 index 0000000000..ef14b48f85 --- /dev/null +++ b/tests/tests/src/directives.mjs @@ -0,0 +1,12 @@ +first directive; +second directive; +// Generated by ReScript, PLEASE EDIT WITH CARE + +import * as Belt_Array from "rescript/lib/es6/Belt_Array.js"; + +let a = Belt_Array.forEach; + +export { + a, +} +/* No side effect */ diff --git a/tests/tests/src/div_by_zero_test.js b/tests/tests/src/div_by_zero_test.js deleted file mode 100644 index 002cf63458..0000000000 --- a/tests/tests/src/div_by_zero_test.js +++ /dev/null @@ -1,68 +0,0 @@ -// Generated by ReScript, PLEASE EDIT WITH CARE -'use strict'; - -let Mt = require("./mt.js"); -let Primitive_int = require("rescript/lib/js/Primitive_int.js"); - -let suites = { - contents: /* [] */0 -}; - -let test_id = { - contents: 0 -}; - -function eq(loc, x, y) { - test_id.contents = test_id.contents + 1 | 0; - suites.contents = { - hd: [ - loc + (" id " + test_id.contents.toString()), - () => ({ - TAG: "Eq", - _0: x, - _1: y - }) - ], - tl: suites.contents - }; -} - -function add(suite) { - suites.contents = { - hd: suite, - tl: suites.contents - }; -} - -add([ - "File \"div_by_zero_test.res\", line 14, characters 7-14", - () => ({ - TAG: "ThrowAny", - _0: () => { - Primitive_int.div(3, 0); - } - }) -]); - -add([ - "File \"div_by_zero_test.res\", line 15, characters 7-14", - () => ({ - TAG: "ThrowAny", - _0: () => { - Primitive_int.mod_(3, 0); - } - }) -]); - -function div(x, y) { - return Primitive_int.div(x, y) + 3 | 0; -} - -Mt.from_pair_suites("Div_by_zero_test", suites.contents); - -exports.suites = suites; -exports.test_id = test_id; -exports.eq = eq; -exports.add = add; -exports.div = div; -/* Not a pure module */ diff --git a/tests/tests/src/div_by_zero_test.mjs b/tests/tests/src/div_by_zero_test.mjs new file mode 100644 index 0000000000..03d9d73e33 --- /dev/null +++ b/tests/tests/src/div_by_zero_test.mjs @@ -0,0 +1,69 @@ +// Generated by ReScript, PLEASE EDIT WITH CARE + +import * as Mt from "./mt.mjs"; +import * as Primitive_int from "rescript/lib/es6/Primitive_int.js"; + +let suites = { + contents: /* [] */0 +}; + +let test_id = { + contents: 0 +}; + +function eq(loc, x, y) { + test_id.contents = test_id.contents + 1 | 0; + suites.contents = { + hd: [ + loc + (" id " + test_id.contents.toString()), + () => ({ + TAG: "Eq", + _0: x, + _1: y + }) + ], + tl: suites.contents + }; +} + +function add(suite) { + suites.contents = { + hd: suite, + tl: suites.contents + }; +} + +add([ + "File \"div_by_zero_test.res\", line 14, characters 7-14", + () => ({ + TAG: "ThrowAny", + _0: () => { + Primitive_int.div(3, 0); + } + }) +]); + +add([ + "File \"div_by_zero_test.res\", line 15, characters 7-14", + () => ({ + TAG: "ThrowAny", + _0: () => { + Primitive_int.mod_(3, 0); + } + }) +]); + +function div(x, y) { + return Primitive_int.div(x, y) + 3 | 0; +} + +Mt.from_pair_suites("Div_by_zero_test", suites.contents); + +export { + suites, + test_id, + eq, + add, + div, +} +/* Not a pure module */ diff --git a/tests/tests/src/dollar_escape_test.js b/tests/tests/src/dollar_escape_test.js deleted file mode 100644 index 1c547e8f66..0000000000 --- a/tests/tests/src/dollar_escape_test.js +++ /dev/null @@ -1,54 +0,0 @@ -// Generated by ReScript, PLEASE EDIT WITH CARE -'use strict'; - -let Mt = require("./mt.js"); - -let suites = { - contents: /* [] */0 -}; - -let test_id = { - contents: 0 -}; - -function eq(loc, x, y) { - test_id.contents = test_id.contents + 1 | 0; - suites.contents = { - hd: [ - loc + (" id " + test_id.contents.toString()), - () => ({ - TAG: "Eq", - _0: x, - _1: y - }) - ], - tl: suites.contents - }; -} - -function $$(x, y) { - return x + y | 0; -} - -let v = 3; - -function $$$plus(x, y) { - return Math.imul(x, y); -} - -let u = 3; - -eq("File \"dollar_escape_test.res\", line 20, characters 3-10", v, 3); - -eq("File \"dollar_escape_test.res\", line 21, characters 3-10", u, 3); - -Mt.from_pair_suites("Dollar_escape_test", suites.contents); - -exports.suites = suites; -exports.test_id = test_id; -exports.eq = eq; -exports.$$ = $$; -exports.v = v; -exports.$$$plus = $$$plus; -exports.u = u; -/* Not a pure module */ diff --git a/tests/tests/src/dollar_escape_test.mjs b/tests/tests/src/dollar_escape_test.mjs new file mode 100644 index 0000000000..8257d45abb --- /dev/null +++ b/tests/tests/src/dollar_escape_test.mjs @@ -0,0 +1,55 @@ +// Generated by ReScript, PLEASE EDIT WITH CARE + +import * as Mt from "./mt.mjs"; + +let suites = { + contents: /* [] */0 +}; + +let test_id = { + contents: 0 +}; + +function eq(loc, x, y) { + test_id.contents = test_id.contents + 1 | 0; + suites.contents = { + hd: [ + loc + (" id " + test_id.contents.toString()), + () => ({ + TAG: "Eq", + _0: x, + _1: y + }) + ], + tl: suites.contents + }; +} + +function $$(x, y) { + return x + y | 0; +} + +let v = 3; + +function $$$plus(x, y) { + return Math.imul(x, y); +} + +let u = 3; + +eq("File \"dollar_escape_test.res\", line 20, characters 3-10", v, 3); + +eq("File \"dollar_escape_test.res\", line 21, characters 3-10", u, 3); + +Mt.from_pair_suites("Dollar_escape_test", suites.contents); + +export { + suites, + test_id, + eq, + $$, + v, + $$$plus, + u, +} +/* Not a pure module */ diff --git a/tests/tests/src/earger_curry_test.js b/tests/tests/src/earger_curry_test.js deleted file mode 100644 index 111b088b10..0000000000 --- a/tests/tests/src/earger_curry_test.js +++ /dev/null @@ -1,167 +0,0 @@ -// Generated by ReScript, PLEASE EDIT WITH CARE -'use strict'; - -let Mt = require("./mt.js"); -let Belt_Array = require("rescript/lib/js/Belt_Array.js"); -let Pervasives = require("rescript/lib/js/Pervasives.js"); - -function map(f, a) { - let f$1 = x => f(x); - let l = a.length; - if (l === 0) { - return []; - } - let r = Belt_Array.make(l, f$1(a[0])); - for (let i = 1; i < l; ++i) { - r[i] = f$1(a[i]); - } - return r; -} - -function init(l, f) { - let f$1 = x => f(x); - if (l === 0) { - return []; - } - if (l < 0) { - return Pervasives.invalid_arg("Array.init"); - } - let res = Belt_Array.make(l, f$1(0)); - for (let i = 1; i < l; ++i) { - res[i] = f$1(i); - } - return res; -} - -function fold_left(f, x, a) { - let f$1 = (x, y) => f(x, y); - let r = x; - for (let i = 0, i_finish = a.length; i < i_finish; ++i) { - r = f$1(r, a[i]); - } - return r; -} - -function f2() { - let arr = Belt_Array.init(30000000, i => i); - let b = Belt_Array.map(arr, i => i + i - 1); - let v = Belt_Array.reduceReverse(b, 0, (prim0, prim1) => prim0 + prim1); - console.log(v.toString()); -} - -f2(); - -let suites = { - contents: /* [] */0 -}; - -let test_id = { - contents: 0 -}; - -function eq(loc, x, y) { - test_id.contents = test_id.contents + 1 | 0; - suites.contents = { - hd: [ - loc + (" id " + test_id.contents.toString()), - () => ({ - TAG: "Eq", - _0: x, - _1: y - }) - ], - tl: suites.contents - }; -} - -let v = { - contents: 0 -}; - -let all_v = { - contents: /* [] */0 -}; - -function add5(a0, a1, a2, a3, a4) { - console.log([ - a0, - a1, - a2, - a3, - a4 - ]); - all_v.contents = { - hd: v.contents, - tl: all_v.contents - }; - return (((a0 + a1 | 0) + a2 | 0) + a3 | 0) + a4 | 0; -} - -function f(x) { - return (extra, extra$1) => add5(x, (v.contents = v.contents + 1 | 0, 1), (v.contents = v.contents + 1 | 0, 2), extra, extra$1); -} - -function g(x) { - let u = (a, b) => add5(x, (v.contents = v.contents + 1 | 0, 1), (v.contents = v.contents + 1 | 0, 2), a, b); - all_v.contents = { - hd: v.contents, - tl: all_v.contents - }; - return u; -} - -let a = f(0)(3, 4); - -let b = f(0)(3, 5); - -let c = g(0)(3, 4); - -let d = g(0)(3, 5); - -eq("File \"earger_curry_test.res\", line 148, characters 5-12", a, 10); - -eq("File \"earger_curry_test.res\", line 149, characters 5-12", b, 11); - -eq("File \"earger_curry_test.res\", line 150, characters 5-12", c, 10); - -eq("File \"earger_curry_test.res\", line 151, characters 5-12", d, 11); - -eq("File \"earger_curry_test.res\", line 152, characters 5-12", all_v.contents, { - hd: 8, - tl: { - hd: 6, - tl: { - hd: 6, - tl: { - hd: 4, - tl: { - hd: 4, - tl: { - hd: 2, - tl: /* [] */0 - } - } - } - } - } -}); - -Mt.from_pair_suites("Earger_curry_test", suites.contents); - -exports.map = map; -exports.init = init; -exports.fold_left = fold_left; -exports.f2 = f2; -exports.suites = suites; -exports.test_id = test_id; -exports.eq = eq; -exports.v = v; -exports.all_v = all_v; -exports.add5 = add5; -exports.f = f; -exports.g = g; -exports.a = a; -exports.b = b; -exports.c = c; -exports.d = d; -/* Not a pure module */ diff --git a/tests/tests/src/earger_curry_test.mjs b/tests/tests/src/earger_curry_test.mjs new file mode 100644 index 0000000000..97e7a61672 --- /dev/null +++ b/tests/tests/src/earger_curry_test.mjs @@ -0,0 +1,168 @@ +// Generated by ReScript, PLEASE EDIT WITH CARE + +import * as Mt from "./mt.mjs"; +import * as Belt_Array from "rescript/lib/es6/Belt_Array.js"; +import * as Pervasives from "rescript/lib/es6/Pervasives.js"; + +function map(f, a) { + let f$1 = x => f(x); + let l = a.length; + if (l === 0) { + return []; + } + let r = Belt_Array.make(l, f$1(a[0])); + for (let i = 1; i < l; ++i) { + r[i] = f$1(a[i]); + } + return r; +} + +function init(l, f) { + let f$1 = x => f(x); + if (l === 0) { + return []; + } + if (l < 0) { + return Pervasives.invalid_arg("Array.init"); + } + let res = Belt_Array.make(l, f$1(0)); + for (let i = 1; i < l; ++i) { + res[i] = f$1(i); + } + return res; +} + +function fold_left(f, x, a) { + let f$1 = (x, y) => f(x, y); + let r = x; + for (let i = 0, i_finish = a.length; i < i_finish; ++i) { + r = f$1(r, a[i]); + } + return r; +} + +function f2() { + let arr = Belt_Array.init(30000000, i => i); + let b = Belt_Array.map(arr, i => i + i - 1); + let v = Belt_Array.reduceReverse(b, 0, (prim0, prim1) => prim0 + prim1); + console.log(v.toString()); +} + +f2(); + +let suites = { + contents: /* [] */0 +}; + +let test_id = { + contents: 0 +}; + +function eq(loc, x, y) { + test_id.contents = test_id.contents + 1 | 0; + suites.contents = { + hd: [ + loc + (" id " + test_id.contents.toString()), + () => ({ + TAG: "Eq", + _0: x, + _1: y + }) + ], + tl: suites.contents + }; +} + +let v = { + contents: 0 +}; + +let all_v = { + contents: /* [] */0 +}; + +function add5(a0, a1, a2, a3, a4) { + console.log([ + a0, + a1, + a2, + a3, + a4 + ]); + all_v.contents = { + hd: v.contents, + tl: all_v.contents + }; + return (((a0 + a1 | 0) + a2 | 0) + a3 | 0) + a4 | 0; +} + +function f(x) { + return (extra, extra$1) => add5(x, (v.contents = v.contents + 1 | 0, 1), (v.contents = v.contents + 1 | 0, 2), extra, extra$1); +} + +function g(x) { + let u = (a, b) => add5(x, (v.contents = v.contents + 1 | 0, 1), (v.contents = v.contents + 1 | 0, 2), a, b); + all_v.contents = { + hd: v.contents, + tl: all_v.contents + }; + return u; +} + +let a = f(0)(3, 4); + +let b = f(0)(3, 5); + +let c = g(0)(3, 4); + +let d = g(0)(3, 5); + +eq("File \"earger_curry_test.res\", line 148, characters 5-12", a, 10); + +eq("File \"earger_curry_test.res\", line 149, characters 5-12", b, 11); + +eq("File \"earger_curry_test.res\", line 150, characters 5-12", c, 10); + +eq("File \"earger_curry_test.res\", line 151, characters 5-12", d, 11); + +eq("File \"earger_curry_test.res\", line 152, characters 5-12", all_v.contents, { + hd: 8, + tl: { + hd: 6, + tl: { + hd: 6, + tl: { + hd: 4, + tl: { + hd: 4, + tl: { + hd: 2, + tl: /* [] */0 + } + } + } + } + } +}); + +Mt.from_pair_suites("Earger_curry_test", suites.contents); + +export { + map, + init, + fold_left, + f2, + suites, + test_id, + eq, + v, + all_v, + add5, + f, + g, + a, + b, + c, + d, +} +/* Not a pure module */ diff --git a/tests/tests/src/effect.js b/tests/tests/src/effect.js deleted file mode 100644 index 9b2a8742c7..0000000000 --- a/tests/tests/src/effect.js +++ /dev/null @@ -1,18 +0,0 @@ -// Generated by ReScript, PLEASE EDIT WITH CARE -'use strict'; - - -console.log("hello"); - -console.log("hey"); - -let a = 3; - -let b = 4; - -let c = 3; - -exports.a = a; -exports.b = b; -exports.c = c; -/* Not a pure module */ diff --git a/tests/tests/src/effect.mjs b/tests/tests/src/effect.mjs new file mode 100644 index 0000000000..81df1be1eb --- /dev/null +++ b/tests/tests/src/effect.mjs @@ -0,0 +1,19 @@ +// Generated by ReScript, PLEASE EDIT WITH CARE + + +console.log("hello"); + +console.log("hey"); + +let a = 3; + +let b = 4; + +let c = 3; + +export { + a, + b, + c, +} +/* Not a pure module */ diff --git a/tests/tests/src/epsilon_test.js b/tests/tests/src/epsilon_test.js deleted file mode 100644 index abcb43cc1c..0000000000 --- a/tests/tests/src/epsilon_test.js +++ /dev/null @@ -1,39 +0,0 @@ -// Generated by ReScript, PLEASE EDIT WITH CARE -'use strict'; - -let Mt = require("./mt.js"); -let Pervasives = require("rescript/lib/js/Pervasives.js"); - -let v = (Number.EPSILON?Number.EPSILON:2.220446049250313e-16); - -let suites_0 = [ - "epsilon", - param => ({ - TAG: "Eq", - _0: Pervasives.epsilon_float, - _1: v - }) -]; - -let suites_1 = { - hd: [ - "raw_epsilon", - param => ({ - TAG: "Eq", - _0: 2.220446049250313e-16, - _1: v - }) - ], - tl: /* [] */0 -}; - -let suites = { - hd: suites_0, - tl: suites_1 -}; - -Mt.from_pair_suites("Epsilon_test", suites); - -exports.v = v; -exports.suites = suites; -/* v Not a pure module */ diff --git a/tests/tests/src/epsilon_test.mjs b/tests/tests/src/epsilon_test.mjs new file mode 100644 index 0000000000..f5207c3f63 --- /dev/null +++ b/tests/tests/src/epsilon_test.mjs @@ -0,0 +1,40 @@ +// Generated by ReScript, PLEASE EDIT WITH CARE + +import * as Mt from "./mt.mjs"; +import * as Pervasives from "rescript/lib/es6/Pervasives.js"; + +let v = (Number.EPSILON?Number.EPSILON:2.220446049250313e-16); + +let suites_0 = [ + "epsilon", + param => ({ + TAG: "Eq", + _0: Pervasives.epsilon_float, + _1: v + }) +]; + +let suites_1 = { + hd: [ + "raw_epsilon", + param => ({ + TAG: "Eq", + _0: 2.220446049250313e-16, + _1: v + }) + ], + tl: /* [] */0 +}; + +let suites = { + hd: suites_0, + tl: suites_1 +}; + +Mt.from_pair_suites("Epsilon_test", suites); + +export { + v, + suites, +} +/* v Not a pure module */ diff --git a/tests/tests/src/equal_box_test.js b/tests/tests/src/equal_box_test.js deleted file mode 100644 index 43d1ccdc88..0000000000 --- a/tests/tests/src/equal_box_test.js +++ /dev/null @@ -1,116 +0,0 @@ -// Generated by ReScript, PLEASE EDIT WITH CARE -'use strict'; - -let Mt = require("./mt.js"); -let Primitive_object = require("rescript/lib/js/Primitive_object.js"); - -let aa = Primitive_object.equal; - -let bb = Primitive_object.equal; - -let cc = Primitive_object.equal; - -let suites = { - contents: /* [] */0 -}; - -let test_id = { - contents: 0 -}; - -function eq(loc, x, y) { - Mt.eq_suites(test_id, suites, loc, x, y); -} - -function b(loc, x) { - Mt.bool_suites(test_id, suites, loc, x); -} - -function f() { - -} - -function shouldBeNull() { - return null; -} - -b("File \"equal_box_test.res\", line 14, characters 4-11", 3 !== null); - -b("File \"equal_box_test.res\", line 15, characters 4-11", true); - -b("File \"equal_box_test.res\", line 16, characters 4-11", "3" !== null); - -b("File \"equal_box_test.res\", line 17, characters 4-11", /* '3' */51 !== null); - -b("File \"equal_box_test.res\", line 18, characters 4-11", 0 !== null); - -b("File \"equal_box_test.res\", line 19, characters 4-11", 0 !== null); - -b("File \"equal_box_test.res\", line 20, characters 4-11", true); - -b("File \"equal_box_test.res\", line 21, characters 4-11", true); - -b("File \"equal_box_test.res\", line 22, characters 4-11", true); - -b("File \"equal_box_test.res\", line 23, characters 4-11", true); - -b("File \"equal_box_test.res\", line 24, characters 4-11", 3 !== undefined); - -let v = null; - -b("File \"equal_box_test.res\", line 29, characters 4-11", 3 !== v); - -b("File \"equal_box_test.res\", line 30, characters 4-11", undefined !== v); - -b("File \"equal_box_test.res\", line 31, characters 4-11", "3" !== v); - -b("File \"equal_box_test.res\", line 32, characters 4-11", /* '3' */51 !== v); - -b("File \"equal_box_test.res\", line 33, characters 4-11", 0 !== v); - -b("File \"equal_box_test.res\", line 34, characters 4-11", 0 !== v); - -b("File \"equal_box_test.res\", line 35, characters 4-11", undefined !== v); - -b("File \"equal_box_test.res\", line 36, characters 4-11", null === v); - -b("File \"equal_box_test.res\", line 37, characters 4-11", true); - -b("File \"equal_box_test.res\", line 38, characters 4-11", true); - -b("File \"equal_box_test.res\", line 39, characters 4-11", 3 !== undefined); - -b("File \"equal_box_test.res\", line 45, characters 4-11", 3 !== undefined); - -b("File \"equal_box_test.res\", line 46, characters 4-11", true); - -b("File \"equal_box_test.res\", line 47, characters 4-11", "3" !== undefined); - -b("File \"equal_box_test.res\", line 48, characters 4-11", /* '3' */51 !== undefined); - -b("File \"equal_box_test.res\", line 49, characters 4-11", 0 !== undefined); - -b("File \"equal_box_test.res\", line 50, characters 4-11", 0 !== undefined); - -b("File \"equal_box_test.res\", line 51, characters 4-11", true); - -b("File \"equal_box_test.res\", line 55, characters 4-11", true); - -b("File \"equal_box_test.res\", line 56, characters 4-11", true); - -b("File \"equal_box_test.res\", line 57, characters 4-11", true); - -b("File \"equal_box_test.res\", line 58, characters 4-11", 3 !== undefined); - -Mt.from_pair_suites("File \"equal_box_test.res\", line 61, characters 20-27", suites.contents); - -exports.aa = aa; -exports.bb = bb; -exports.cc = cc; -exports.suites = suites; -exports.test_id = test_id; -exports.eq = eq; -exports.b = b; -exports.f = f; -exports.shouldBeNull = shouldBeNull; -/* Not a pure module */ diff --git a/tests/tests/src/equal_box_test.mjs b/tests/tests/src/equal_box_test.mjs new file mode 100644 index 0000000000..a840b951f3 --- /dev/null +++ b/tests/tests/src/equal_box_test.mjs @@ -0,0 +1,117 @@ +// Generated by ReScript, PLEASE EDIT WITH CARE + +import * as Mt from "./mt.mjs"; +import * as Primitive_object from "rescript/lib/es6/Primitive_object.js"; + +let aa = Primitive_object.equal; + +let bb = Primitive_object.equal; + +let cc = Primitive_object.equal; + +let suites = { + contents: /* [] */0 +}; + +let test_id = { + contents: 0 +}; + +function eq(loc, x, y) { + Mt.eq_suites(test_id, suites, loc, x, y); +} + +function b(loc, x) { + Mt.bool_suites(test_id, suites, loc, x); +} + +function f() { + +} + +function shouldBeNull() { + return null; +} + +b("File \"equal_box_test.res\", line 14, characters 4-11", 3 !== null); + +b("File \"equal_box_test.res\", line 15, characters 4-11", true); + +b("File \"equal_box_test.res\", line 16, characters 4-11", "3" !== null); + +b("File \"equal_box_test.res\", line 17, characters 4-11", /* '3' */51 !== null); + +b("File \"equal_box_test.res\", line 18, characters 4-11", 0 !== null); + +b("File \"equal_box_test.res\", line 19, characters 4-11", 0 !== null); + +b("File \"equal_box_test.res\", line 20, characters 4-11", true); + +b("File \"equal_box_test.res\", line 21, characters 4-11", true); + +b("File \"equal_box_test.res\", line 22, characters 4-11", true); + +b("File \"equal_box_test.res\", line 23, characters 4-11", true); + +b("File \"equal_box_test.res\", line 24, characters 4-11", 3 !== undefined); + +let v = null; + +b("File \"equal_box_test.res\", line 29, characters 4-11", 3 !== v); + +b("File \"equal_box_test.res\", line 30, characters 4-11", undefined !== v); + +b("File \"equal_box_test.res\", line 31, characters 4-11", "3" !== v); + +b("File \"equal_box_test.res\", line 32, characters 4-11", /* '3' */51 !== v); + +b("File \"equal_box_test.res\", line 33, characters 4-11", 0 !== v); + +b("File \"equal_box_test.res\", line 34, characters 4-11", 0 !== v); + +b("File \"equal_box_test.res\", line 35, characters 4-11", undefined !== v); + +b("File \"equal_box_test.res\", line 36, characters 4-11", null === v); + +b("File \"equal_box_test.res\", line 37, characters 4-11", true); + +b("File \"equal_box_test.res\", line 38, characters 4-11", true); + +b("File \"equal_box_test.res\", line 39, characters 4-11", 3 !== undefined); + +b("File \"equal_box_test.res\", line 45, characters 4-11", 3 !== undefined); + +b("File \"equal_box_test.res\", line 46, characters 4-11", true); + +b("File \"equal_box_test.res\", line 47, characters 4-11", "3" !== undefined); + +b("File \"equal_box_test.res\", line 48, characters 4-11", /* '3' */51 !== undefined); + +b("File \"equal_box_test.res\", line 49, characters 4-11", 0 !== undefined); + +b("File \"equal_box_test.res\", line 50, characters 4-11", 0 !== undefined); + +b("File \"equal_box_test.res\", line 51, characters 4-11", true); + +b("File \"equal_box_test.res\", line 55, characters 4-11", true); + +b("File \"equal_box_test.res\", line 56, characters 4-11", true); + +b("File \"equal_box_test.res\", line 57, characters 4-11", true); + +b("File \"equal_box_test.res\", line 58, characters 4-11", 3 !== undefined); + +Mt.from_pair_suites("File \"equal_box_test.res\", line 61, characters 20-27", suites.contents); + +export { + aa, + bb, + cc, + suites, + test_id, + eq, + b, + f, + shouldBeNull, +} +/* Not a pure module */ diff --git a/tests/tests/src/equal_exception_test.js b/tests/tests/src/equal_exception_test.js deleted file mode 100644 index 4179bf287a..0000000000 --- a/tests/tests/src/equal_exception_test.js +++ /dev/null @@ -1,152 +0,0 @@ -// Generated by ReScript, PLEASE EDIT WITH CARE -'use strict'; - -let Mt = require("./mt.js"); -let Primitive_object = require("rescript/lib/js/Primitive_object.js"); -let Primitive_exceptions = require("rescript/lib/js/Primitive_exceptions.js"); - -let v = "gso"; - -function is_equal() { - if (v.codePointAt(0) === /* 'g' */103) { - return; - } - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "equal_exception_test.res", - 6, - 2 - ], - Error: new Error() - }; -} - -function is_exception() { - try { - throw { - RE_EXN_ID: "Not_found", - Error: new Error() - }; - } catch (raw_exn) { - let exn = Primitive_exceptions.internalToException(raw_exn); - if (exn.RE_EXN_ID === "Not_found") { - return; - } - throw exn; - } -} - -function is_normal_exception(_x) { - let A = /* @__PURE__ */Primitive_exceptions.create("A"); - let v = { - RE_EXN_ID: A, - _1: 3 - }; - try { - throw v; - } catch (raw_exn) { - let exn = Primitive_exceptions.internalToException(raw_exn); - if (exn.RE_EXN_ID === A) { - if (exn._1 === 3) { - return; - } - throw exn; - } - throw exn; - } -} - -function is_arbitrary_exception() { - let A = /* @__PURE__ */Primitive_exceptions.create("A"); - try { - throw { - RE_EXN_ID: A, - Error: new Error() - }; - } catch (exn) { - return; - } -} - -let suites_0 = [ - "is_equal", - is_equal -]; - -let suites_1 = { - hd: [ - "is_exception", - is_exception - ], - tl: { - hd: [ - "is_normal_exception", - is_normal_exception - ], - tl: { - hd: [ - "is_arbitrary_exception", - is_arbitrary_exception - ], - tl: /* [] */0 - } - } -}; - -let suites = { - hd: suites_0, - tl: suites_1 -}; - -let e = { - RE_EXN_ID: "Not_found" -}; - -function eq(x) { - return x.RE_EXN_ID === "Not_found"; -} - -let Not_found = /* @__PURE__ */Primitive_exceptions.create("Equal_exception_test.Not_found"); - -if (Primitive_object.equal(e, { - RE_EXN_ID: Not_found - }) !== false) { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "equal_exception_test.res", - 47, - 0 - ], - Error: new Error() - }; -} - -if (Not_found === "Not_found" !== false) { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "equal_exception_test.res", - 48, - 0 - ], - Error: new Error() - }; -} - -Mt.from_suites("exception", suites); - -let $$String; - -exports.$$String = $$String; -exports.v = v; -exports.is_equal = is_equal; -exports.is_exception = is_exception; -exports.is_normal_exception = is_normal_exception; -exports.is_arbitrary_exception = is_arbitrary_exception; -exports.suites = suites; -exports.e = e; -exports.eq = eq; -exports.Not_found = Not_found; -/* Not a pure module */ diff --git a/tests/tests/src/equal_exception_test.mjs b/tests/tests/src/equal_exception_test.mjs new file mode 100644 index 0000000000..fc7990ef36 --- /dev/null +++ b/tests/tests/src/equal_exception_test.mjs @@ -0,0 +1,153 @@ +// Generated by ReScript, PLEASE EDIT WITH CARE + +import * as Mt from "./mt.mjs"; +import * as Primitive_object from "rescript/lib/es6/Primitive_object.js"; +import * as Primitive_exceptions from "rescript/lib/es6/Primitive_exceptions.js"; + +let v = "gso"; + +function is_equal() { + if (v.codePointAt(0) === /* 'g' */103) { + return; + } + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "equal_exception_test.res", + 6, + 2 + ], + Error: new Error() + }; +} + +function is_exception() { + try { + throw { + RE_EXN_ID: "Not_found", + Error: new Error() + }; + } catch (raw_exn) { + let exn = Primitive_exceptions.internalToException(raw_exn); + if (exn.RE_EXN_ID === "Not_found") { + return; + } + throw exn; + } +} + +function is_normal_exception(_x) { + let A = /* @__PURE__ */Primitive_exceptions.create("A"); + let v = { + RE_EXN_ID: A, + _1: 3 + }; + try { + throw v; + } catch (raw_exn) { + let exn = Primitive_exceptions.internalToException(raw_exn); + if (exn.RE_EXN_ID === A) { + if (exn._1 === 3) { + return; + } + throw exn; + } + throw exn; + } +} + +function is_arbitrary_exception() { + let A = /* @__PURE__ */Primitive_exceptions.create("A"); + try { + throw { + RE_EXN_ID: A, + Error: new Error() + }; + } catch (exn) { + return; + } +} + +let suites_0 = [ + "is_equal", + is_equal +]; + +let suites_1 = { + hd: [ + "is_exception", + is_exception + ], + tl: { + hd: [ + "is_normal_exception", + is_normal_exception + ], + tl: { + hd: [ + "is_arbitrary_exception", + is_arbitrary_exception + ], + tl: /* [] */0 + } + } +}; + +let suites = { + hd: suites_0, + tl: suites_1 +}; + +let e = { + RE_EXN_ID: "Not_found" +}; + +function eq(x) { + return x.RE_EXN_ID === "Not_found"; +} + +let Not_found = /* @__PURE__ */Primitive_exceptions.create("Equal_exception_test.Not_found"); + +if (Primitive_object.equal(e, { + RE_EXN_ID: Not_found + }) !== false) { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "equal_exception_test.res", + 47, + 0 + ], + Error: new Error() + }; +} + +if (Not_found === "Not_found" !== false) { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "equal_exception_test.res", + 48, + 0 + ], + Error: new Error() + }; +} + +Mt.from_suites("exception", suites); + +let $$String; + +export { + $$String, + v, + is_equal, + is_exception, + is_normal_exception, + is_arbitrary_exception, + suites, + e, + eq, + Not_found, +} +/* Not a pure module */ diff --git a/tests/tests/src/equal_test.js b/tests/tests/src/equal_test.js deleted file mode 100644 index a4cfefc608..0000000000 --- a/tests/tests/src/equal_test.js +++ /dev/null @@ -1,26 +0,0 @@ -// Generated by ReScript, PLEASE EDIT WITH CARE -'use strict'; - - -function str_equal(x, y) { - return x === y; -} - -let str_b = true; - -function int_equal(x, y) { - return x === y; -} - -function float_equal(x, y) { - return x === y; -} - -let v = false; - -exports.str_equal = str_equal; -exports.str_b = str_b; -exports.int_equal = int_equal; -exports.v = v; -exports.float_equal = float_equal; -/* No side effect */ diff --git a/tests/tests/src/equal_test.mjs b/tests/tests/src/equal_test.mjs new file mode 100644 index 0000000000..722a9031db --- /dev/null +++ b/tests/tests/src/equal_test.mjs @@ -0,0 +1,27 @@ +// Generated by ReScript, PLEASE EDIT WITH CARE + + +function str_equal(x, y) { + return x === y; +} + +let str_b = true; + +function int_equal(x, y) { + return x === y; +} + +function float_equal(x, y) { + return x === y; +} + +let v = false; + +export { + str_equal, + str_b, + int_equal, + v, + float_equal, +} +/* No side effect */ diff --git a/tests/tests_esmodule/src/es6_export.mjs b/tests/tests/src/es6_export.mjs similarity index 100% rename from tests/tests_esmodule/src/es6_export.mjs rename to tests/tests/src/es6_export.mjs diff --git a/tests/tests_esmodule/src/es6_export.res b/tests/tests/src/es6_export.res similarity index 100% rename from tests/tests_esmodule/src/es6_export.res rename to tests/tests/src/es6_export.res diff --git a/tests/tests_esmodule/src/es6_import.mjs b/tests/tests/src/es6_import.mjs similarity index 100% rename from tests/tests_esmodule/src/es6_import.mjs rename to tests/tests/src/es6_import.mjs diff --git a/tests/tests_esmodule/src/es6_import.res b/tests/tests/src/es6_import.res similarity index 100% rename from tests/tests_esmodule/src/es6_import.res rename to tests/tests/src/es6_import.res diff --git a/tests/tests/src/escape_esmodule.js b/tests/tests/src/escape_esmodule.js deleted file mode 100644 index 4a0d036ebc..0000000000 --- a/tests/tests/src/escape_esmodule.js +++ /dev/null @@ -1,12 +0,0 @@ -// Generated by ReScript, PLEASE EDIT WITH CARE -'use strict'; - - -let __esModule = false; - -let $$default = 4; - -exports.__esModule = __esModule; -exports.default = $$default; -exports.__esModule = true; -/* No side effect */ diff --git a/tests/tests/src/escape_esmodule.mjs b/tests/tests/src/escape_esmodule.mjs new file mode 100644 index 0000000000..5583ddd1cc --- /dev/null +++ b/tests/tests/src/escape_esmodule.mjs @@ -0,0 +1,12 @@ +// Generated by ReScript, PLEASE EDIT WITH CARE + + +let __esModule = false; + +let $$default = 4; + +export { + __esModule, + $$default as default, +} +/* No side effect */ diff --git a/tests/tests/src/esmodule_ref.js b/tests/tests/src/esmodule_ref.js deleted file mode 100644 index 2afa67236b..0000000000 --- a/tests/tests/src/esmodule_ref.js +++ /dev/null @@ -1,7 +0,0 @@ -// Generated by ReScript, PLEASE EDIT WITH CARE -'use strict'; - - -console.log(false); - -/* Not a pure module */ diff --git a/tests/tests/src/esmodule_ref.mjs b/tests/tests/src/esmodule_ref.mjs new file mode 100644 index 0000000000..959043b041 --- /dev/null +++ b/tests/tests/src/esmodule_ref.mjs @@ -0,0 +1,6 @@ +// Generated by ReScript, PLEASE EDIT WITH CARE + + +console.log(false); + +/* Not a pure module */ diff --git a/tests/tests/src/event_ffi.js b/tests/tests/src/event_ffi.js deleted file mode 100644 index 21992a969d..0000000000 --- a/tests/tests/src/event_ffi.js +++ /dev/null @@ -1,76 +0,0 @@ -// Generated by ReScript, PLEASE EDIT WITH CARE -'use strict'; - -let Belt_List = require("rescript/lib/js/Belt_List.js"); - -function h0(x) { - return x(); -} - -function h00(x) { - return x(); -} - -function h1(x, y) { - return x(y); -} - -function h10(x) { - return x(3); -} - -function h30(x) { - return a => x(3, 3, a); -} - -function h33(x) { - return x(1, 2, 3); -} - -function h34(x) { - return x(1, 2, 3)(4); -} - -function ocaml_run(b, c) { - return (1 + b | 0) + c | 0; -} - -function a0() { - console.log("hi"); -} - -function a1() { - return x => x; -} - -function a2(x, y) { - return x + y | 0; -} - -function a3(x, y, z) { - return (x + y | 0) + z | 0; -} - -function xx() { - return param => { - console.log(3); - }; -} - -let test_as = Belt_List.map; - -exports.h0 = h0; -exports.h00 = h00; -exports.h1 = h1; -exports.h10 = h10; -exports.h30 = h30; -exports.h33 = h33; -exports.h34 = h34; -exports.ocaml_run = ocaml_run; -exports.a0 = a0; -exports.a1 = a1; -exports.a2 = a2; -exports.a3 = a3; -exports.test_as = test_as; -exports.xx = xx; -/* No side effect */ diff --git a/tests/tests/src/event_ffi.mjs b/tests/tests/src/event_ffi.mjs new file mode 100644 index 0000000000..ec47eeae4c --- /dev/null +++ b/tests/tests/src/event_ffi.mjs @@ -0,0 +1,77 @@ +// Generated by ReScript, PLEASE EDIT WITH CARE + +import * as Belt_List from "rescript/lib/es6/Belt_List.js"; + +function h0(x) { + return x(); +} + +function h00(x) { + return x(); +} + +function h1(x, y) { + return x(y); +} + +function h10(x) { + return x(3); +} + +function h30(x) { + return a => x(3, 3, a); +} + +function h33(x) { + return x(1, 2, 3); +} + +function h34(x) { + return x(1, 2, 3)(4); +} + +function ocaml_run(b, c) { + return (1 + b | 0) + c | 0; +} + +function a0() { + console.log("hi"); +} + +function a1() { + return x => x; +} + +function a2(x, y) { + return x + y | 0; +} + +function a3(x, y, z) { + return (x + y | 0) + z | 0; +} + +function xx() { + return param => { + console.log(3); + }; +} + +let test_as = Belt_List.map; + +export { + h0, + h00, + h1, + h10, + h30, + h33, + h34, + ocaml_run, + a0, + a1, + a2, + a3, + test_as, + xx, +} +/* No side effect */ diff --git a/tests/tests/src/exception_alias.js b/tests/tests/src/exception_alias.js deleted file mode 100644 index 5c4bc893e7..0000000000 --- a/tests/tests/src/exception_alias.js +++ /dev/null @@ -1,127 +0,0 @@ -// Generated by ReScript, PLEASE EDIT WITH CARE -'use strict'; - -let Belt_List = require("rescript/lib/js/Belt_List.js"); - -let a0 = { - RE_EXN_ID: "Not_found" -}; - -let b = Belt_List.length({ - hd: 1, - tl: { - hd: 2, - tl: /* [] */0 - } -}); - -let List = { - size: Belt_List.size, - head: Belt_List.head, - headExn: Belt_List.headExn, - tail: Belt_List.tail, - tailExn: Belt_List.tailExn, - add: Belt_List.add, - get: Belt_List.get, - getExn: Belt_List.getExn, - make: Belt_List.make, - makeByU: Belt_List.makeByU, - makeBy: Belt_List.makeBy, - shuffle: Belt_List.shuffle, - drop: Belt_List.drop, - take: Belt_List.take, - splitAt: Belt_List.splitAt, - concat: Belt_List.concat, - concatMany: Belt_List.concatMany, - reverseConcat: Belt_List.reverseConcat, - flatten: Belt_List.flatten, - mapU: Belt_List.mapU, - map: Belt_List.map, - zip: Belt_List.zip, - zipByU: Belt_List.zipByU, - zipBy: Belt_List.zipBy, - mapWithIndexU: Belt_List.mapWithIndexU, - mapWithIndex: Belt_List.mapWithIndex, - fromArray: Belt_List.fromArray, - toArray: Belt_List.toArray, - reverse: Belt_List.reverse, - mapReverseU: Belt_List.mapReverseU, - mapReverse: Belt_List.mapReverse, - forEachU: Belt_List.forEachU, - forEach: Belt_List.forEach, - forEachWithIndexU: Belt_List.forEachWithIndexU, - forEachWithIndex: Belt_List.forEachWithIndex, - reduceU: Belt_List.reduceU, - reduce: Belt_List.reduce, - reduceWithIndexU: Belt_List.reduceWithIndexU, - reduceWithIndex: Belt_List.reduceWithIndex, - reduceReverseU: Belt_List.reduceReverseU, - reduceReverse: Belt_List.reduceReverse, - mapReverse2U: Belt_List.mapReverse2U, - mapReverse2: Belt_List.mapReverse2, - forEach2U: Belt_List.forEach2U, - forEach2: Belt_List.forEach2, - reduce2U: Belt_List.reduce2U, - reduce2: Belt_List.reduce2, - reduceReverse2U: Belt_List.reduceReverse2U, - reduceReverse2: Belt_List.reduceReverse2, - everyU: Belt_List.everyU, - every: Belt_List.every, - someU: Belt_List.someU, - some: Belt_List.some, - every2U: Belt_List.every2U, - every2: Belt_List.every2, - some2U: Belt_List.some2U, - some2: Belt_List.some2, - cmpByLength: Belt_List.cmpByLength, - cmpU: Belt_List.cmpU, - cmp: Belt_List.cmp, - eqU: Belt_List.eqU, - eq: Belt_List.eq, - hasU: Belt_List.hasU, - has: Belt_List.has, - getByU: Belt_List.getByU, - getBy: Belt_List.getBy, - keepU: Belt_List.keepU, - keep: Belt_List.keep, - filter: Belt_List.filter, - keepWithIndexU: Belt_List.keepWithIndexU, - keepWithIndex: Belt_List.keepWithIndex, - filterWithIndex: Belt_List.filterWithIndex, - keepMapU: Belt_List.keepMapU, - keepMap: Belt_List.keepMap, - partitionU: Belt_List.partitionU, - partition: Belt_List.partition, - unzip: Belt_List.unzip, - getAssocU: Belt_List.getAssocU, - getAssoc: Belt_List.getAssoc, - hasAssocU: Belt_List.hasAssocU, - hasAssoc: Belt_List.hasAssoc, - removeAssocU: Belt_List.removeAssocU, - removeAssoc: Belt_List.removeAssoc, - setAssocU: Belt_List.setAssocU, - setAssoc: Belt_List.setAssoc, - sortU: Belt_List.sortU, - sort: Belt_List.sort, - b: b, - length: 3 -}; - -let a1 = a0; - -let a2 = a0; - -let a3 = a0; - -let a4 = a0; - -let a5 = a0; - -exports.a0 = a0; -exports.a1 = a1; -exports.a2 = a2; -exports.a3 = a3; -exports.a4 = a4; -exports.a5 = a5; -exports.List = List; -/* b Not a pure module */ diff --git a/tests/tests/src/exception_alias.mjs b/tests/tests/src/exception_alias.mjs new file mode 100644 index 0000000000..2b2cac959e --- /dev/null +++ b/tests/tests/src/exception_alias.mjs @@ -0,0 +1,128 @@ +// Generated by ReScript, PLEASE EDIT WITH CARE + +import * as Belt_List from "rescript/lib/es6/Belt_List.js"; + +let a0 = { + RE_EXN_ID: "Not_found" +}; + +let b = Belt_List.length({ + hd: 1, + tl: { + hd: 2, + tl: /* [] */0 + } +}); + +let List = { + size: Belt_List.size, + head: Belt_List.head, + headExn: Belt_List.headExn, + tail: Belt_List.tail, + tailExn: Belt_List.tailExn, + add: Belt_List.add, + get: Belt_List.get, + getExn: Belt_List.getExn, + make: Belt_List.make, + makeByU: Belt_List.makeByU, + makeBy: Belt_List.makeBy, + shuffle: Belt_List.shuffle, + drop: Belt_List.drop, + take: Belt_List.take, + splitAt: Belt_List.splitAt, + concat: Belt_List.concat, + concatMany: Belt_List.concatMany, + reverseConcat: Belt_List.reverseConcat, + flatten: Belt_List.flatten, + mapU: Belt_List.mapU, + map: Belt_List.map, + zip: Belt_List.zip, + zipByU: Belt_List.zipByU, + zipBy: Belt_List.zipBy, + mapWithIndexU: Belt_List.mapWithIndexU, + mapWithIndex: Belt_List.mapWithIndex, + fromArray: Belt_List.fromArray, + toArray: Belt_List.toArray, + reverse: Belt_List.reverse, + mapReverseU: Belt_List.mapReverseU, + mapReverse: Belt_List.mapReverse, + forEachU: Belt_List.forEachU, + forEach: Belt_List.forEach, + forEachWithIndexU: Belt_List.forEachWithIndexU, + forEachWithIndex: Belt_List.forEachWithIndex, + reduceU: Belt_List.reduceU, + reduce: Belt_List.reduce, + reduceWithIndexU: Belt_List.reduceWithIndexU, + reduceWithIndex: Belt_List.reduceWithIndex, + reduceReverseU: Belt_List.reduceReverseU, + reduceReverse: Belt_List.reduceReverse, + mapReverse2U: Belt_List.mapReverse2U, + mapReverse2: Belt_List.mapReverse2, + forEach2U: Belt_List.forEach2U, + forEach2: Belt_List.forEach2, + reduce2U: Belt_List.reduce2U, + reduce2: Belt_List.reduce2, + reduceReverse2U: Belt_List.reduceReverse2U, + reduceReverse2: Belt_List.reduceReverse2, + everyU: Belt_List.everyU, + every: Belt_List.every, + someU: Belt_List.someU, + some: Belt_List.some, + every2U: Belt_List.every2U, + every2: Belt_List.every2, + some2U: Belt_List.some2U, + some2: Belt_List.some2, + cmpByLength: Belt_List.cmpByLength, + cmpU: Belt_List.cmpU, + cmp: Belt_List.cmp, + eqU: Belt_List.eqU, + eq: Belt_List.eq, + hasU: Belt_List.hasU, + has: Belt_List.has, + getByU: Belt_List.getByU, + getBy: Belt_List.getBy, + keepU: Belt_List.keepU, + keep: Belt_List.keep, + filter: Belt_List.filter, + keepWithIndexU: Belt_List.keepWithIndexU, + keepWithIndex: Belt_List.keepWithIndex, + filterWithIndex: Belt_List.filterWithIndex, + keepMapU: Belt_List.keepMapU, + keepMap: Belt_List.keepMap, + partitionU: Belt_List.partitionU, + partition: Belt_List.partition, + unzip: Belt_List.unzip, + getAssocU: Belt_List.getAssocU, + getAssoc: Belt_List.getAssoc, + hasAssocU: Belt_List.hasAssocU, + hasAssoc: Belt_List.hasAssoc, + removeAssocU: Belt_List.removeAssocU, + removeAssoc: Belt_List.removeAssoc, + setAssocU: Belt_List.setAssocU, + setAssoc: Belt_List.setAssoc, + sortU: Belt_List.sortU, + sort: Belt_List.sort, + b: b, + length: 3 +}; + +let a1 = a0; + +let a2 = a0; + +let a3 = a0; + +let a4 = a0; + +let a5 = a0; + +export { + a0, + a1, + a2, + a3, + a4, + a5, + List, +} +/* b Not a pure module */ diff --git a/tests/tests/src/exception_raise_test.js b/tests/tests/src/exception_raise_test.js deleted file mode 100644 index 4b7f7b2fba..0000000000 --- a/tests/tests/src/exception_raise_test.js +++ /dev/null @@ -1,244 +0,0 @@ -// Generated by ReScript, PLEASE EDIT WITH CARE -'use strict'; - -let Mt = require("./mt.js"); -let Exn = require("rescript/lib/js/Exn.js"); -let Belt_List = require("rescript/lib/js/Belt_List.js"); -let Primitive_exceptions = require("rescript/lib/js/Primitive_exceptions.js"); - -let Local = /* @__PURE__ */Primitive_exceptions.create("Exception_raise_test.Local"); - -let B = /* @__PURE__ */Primitive_exceptions.create("Exception_raise_test.B"); - -let C = /* @__PURE__ */Primitive_exceptions.create("Exception_raise_test.C"); - -let D = /* @__PURE__ */Primitive_exceptions.create("Exception_raise_test.D"); - -function appf(g, x) { - let A = /* @__PURE__ */Primitive_exceptions.create("A"); - try { - return g(x); - } catch (raw_exn) { - let exn = Primitive_exceptions.internalToException(raw_exn); - if (exn.RE_EXN_ID === Local) { - return 3; - } - if (exn.RE_EXN_ID === "Not_found") { - return 2; - } - if (exn.RE_EXN_ID === A) { - return 3; - } - if (exn.RE_EXN_ID !== B) { - if (exn.RE_EXN_ID === C) { - return exn._1; - } else if (exn.RE_EXN_ID === D) { - return exn._1[0]; - } else { - return 4; - } - } - let match = exn._1; - if (!match) { - return 4; - } - let match$1 = match.tl; - if (!match$1) { - return 4; - } - let match$2 = match$1.tl; - if (match$2) { - return match$2.hd; - } else { - return 4; - } - } -} - -let A = /* @__PURE__ */Primitive_exceptions.create("Exception_raise_test.A"); - -let f; - -try { - f = (function () {throw (new Error ("x"))} ()); -} catch (raw_x) { - let x = Primitive_exceptions.internalToException(raw_x); - f = x.RE_EXN_ID === A ? x._1 : 2; -} - -let ff; - -try { - ff = (function () {throw 3} ()); -} catch (raw_x$1) { - let x$1 = Primitive_exceptions.internalToException(raw_x$1); - ff = x$1.RE_EXN_ID === A ? x$1._1 : 2; -} - -let fff; - -try { - fff = (function () {throw 2} ()); -} catch (raw_x$2) { - let x$2 = Primitive_exceptions.internalToException(raw_x$2); - fff = x$2.RE_EXN_ID === A ? x$2._1 : 2; -} - -let a0; - -try { - a0 = (function (){throw 2} ()); -} catch (raw_x$3) { - let x$3 = Primitive_exceptions.internalToException(raw_x$3); - if (x$3.RE_EXN_ID === A || x$3.RE_EXN_ID === Exn.$$Error) { - a0 = x$3._1; - } else { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "exception_raise_test.res", - 104, - 7 - ], - Error: new Error() - }; - } -} - -let a1; - -try { - a1 = (function (){throw 2} ()); -} catch (raw_e) { - a1 = Primitive_exceptions.internalToException(raw_e); -} - -let a2; - -try { - a2 = (function (){throw (new Error("x"))} ()); -} catch (raw_e$1) { - a2 = Primitive_exceptions.internalToException(raw_e$1); -} - -let suites = { - contents: { - hd: [ - "File \"exception_raise_test.res\", line 120, characters 5-12", - () => ({ - TAG: "Eq", - _0: [ - f, - ff, - fff, - a0 - ], - _1: [ - 2, - 2, - 2, - 2 - ] - }) - ], - tl: { - hd: [ - "File \"exception_raise_test.res\", line 123, characters 6-13", - () => { - if (a1.RE_EXN_ID === Exn.$$Error) { - return { - TAG: "Eq", - _0: a1._1, - _1: 2 - }; - } - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "exception_raise_test.res", - 127, - 15 - ], - Error: new Error() - }; - } - ], - tl: /* [] */0 - } - } -}; - -let test_id = { - contents: 0 -}; - -function eq(loc, x, y) { - Mt.eq_suites(test_id, suites, loc, x, y); -} - -try { - ((()=>{throw 2})()); -} catch (raw_e$2) { - let e = Primitive_exceptions.internalToException(raw_e$2); - eq("File \"exception_raise_test.res\", line 137, characters 10-17", Exn.asJsExn(e) !== undefined, true); -} - -try { - throw { - RE_EXN_ID: "Not_found", - Error: new Error() - }; -} catch (raw_e$3) { - let e$1 = Primitive_exceptions.internalToException(raw_e$3); - eq("File \"exception_raise_test.res\", line 141, characters 10-17", Exn.asJsExn(e$1) !== undefined, false); -} - -function fff0(x, g) { - let val; - try { - val = x(); - } catch (exn) { - return 1; - } - return g(); -} - -function input_lines(ic, _acc) { - while (true) { - let acc = _acc; - let line; - try { - line = input_line(ic); - } catch (exn) { - return Belt_List.reverse(acc); - } - _acc = { - hd: line, - tl: acc - }; - continue; - }; -} - -eq("File \"exception_raise_test.res\", line 157, characters 12-19", ((a,b,c,_) => a + b + c)(1, 2, 3, 4), 6); - -Mt.from_pair_suites("Exception_raise_test", suites.contents); - -exports.Local = Local; -exports.B = B; -exports.C = C; -exports.D = D; -exports.appf = appf; -exports.A = A; -exports.f = f; -exports.ff = ff; -exports.fff = fff; -exports.a0 = a0; -exports.a1 = a1; -exports.a2 = a2; -exports.suites = suites; -exports.test_id = test_id; -exports.eq = eq; -exports.fff0 = fff0; -exports.input_lines = input_lines; -/* f Not a pure module */ diff --git a/tests/tests/src/exception_raise_test.mjs b/tests/tests/src/exception_raise_test.mjs new file mode 100644 index 0000000000..571bbff0e5 --- /dev/null +++ b/tests/tests/src/exception_raise_test.mjs @@ -0,0 +1,245 @@ +// Generated by ReScript, PLEASE EDIT WITH CARE + +import * as Mt from "./mt.mjs"; +import * as Exn from "rescript/lib/es6/Exn.js"; +import * as Belt_List from "rescript/lib/es6/Belt_List.js"; +import * as Primitive_exceptions from "rescript/lib/es6/Primitive_exceptions.js"; + +let Local = /* @__PURE__ */Primitive_exceptions.create("Exception_raise_test.Local"); + +let B = /* @__PURE__ */Primitive_exceptions.create("Exception_raise_test.B"); + +let C = /* @__PURE__ */Primitive_exceptions.create("Exception_raise_test.C"); + +let D = /* @__PURE__ */Primitive_exceptions.create("Exception_raise_test.D"); + +function appf(g, x) { + let A = /* @__PURE__ */Primitive_exceptions.create("A"); + try { + return g(x); + } catch (raw_exn) { + let exn = Primitive_exceptions.internalToException(raw_exn); + if (exn.RE_EXN_ID === Local) { + return 3; + } + if (exn.RE_EXN_ID === "Not_found") { + return 2; + } + if (exn.RE_EXN_ID === A) { + return 3; + } + if (exn.RE_EXN_ID !== B) { + if (exn.RE_EXN_ID === C) { + return exn._1; + } else if (exn.RE_EXN_ID === D) { + return exn._1[0]; + } else { + return 4; + } + } + let match = exn._1; + if (!match) { + return 4; + } + let match$1 = match.tl; + if (!match$1) { + return 4; + } + let match$2 = match$1.tl; + if (match$2) { + return match$2.hd; + } else { + return 4; + } + } +} + +let A = /* @__PURE__ */Primitive_exceptions.create("Exception_raise_test.A"); + +let f; + +try { + f = (function () {throw (new Error ("x"))} ()); +} catch (raw_x) { + let x = Primitive_exceptions.internalToException(raw_x); + f = x.RE_EXN_ID === A ? x._1 : 2; +} + +let ff; + +try { + ff = (function () {throw 3} ()); +} catch (raw_x$1) { + let x$1 = Primitive_exceptions.internalToException(raw_x$1); + ff = x$1.RE_EXN_ID === A ? x$1._1 : 2; +} + +let fff; + +try { + fff = (function () {throw 2} ()); +} catch (raw_x$2) { + let x$2 = Primitive_exceptions.internalToException(raw_x$2); + fff = x$2.RE_EXN_ID === A ? x$2._1 : 2; +} + +let a0; + +try { + a0 = (function (){throw 2} ()); +} catch (raw_x$3) { + let x$3 = Primitive_exceptions.internalToException(raw_x$3); + if (x$3.RE_EXN_ID === A || x$3.RE_EXN_ID === Exn.$$Error) { + a0 = x$3._1; + } else { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "exception_raise_test.res", + 104, + 7 + ], + Error: new Error() + }; + } +} + +let a1; + +try { + a1 = (function (){throw 2} ()); +} catch (raw_e) { + a1 = Primitive_exceptions.internalToException(raw_e); +} + +let a2; + +try { + a2 = (function (){throw (new Error("x"))} ()); +} catch (raw_e$1) { + a2 = Primitive_exceptions.internalToException(raw_e$1); +} + +let suites = { + contents: { + hd: [ + "File \"exception_raise_test.res\", line 120, characters 5-12", + () => ({ + TAG: "Eq", + _0: [ + f, + ff, + fff, + a0 + ], + _1: [ + 2, + 2, + 2, + 2 + ] + }) + ], + tl: { + hd: [ + "File \"exception_raise_test.res\", line 123, characters 6-13", + () => { + if (a1.RE_EXN_ID === Exn.$$Error) { + return { + TAG: "Eq", + _0: a1._1, + _1: 2 + }; + } + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "exception_raise_test.res", + 127, + 15 + ], + Error: new Error() + }; + } + ], + tl: /* [] */0 + } + } +}; + +let test_id = { + contents: 0 +}; + +function eq(loc, x, y) { + Mt.eq_suites(test_id, suites, loc, x, y); +} + +try { + ((()=>{throw 2})()); +} catch (raw_e$2) { + let e = Primitive_exceptions.internalToException(raw_e$2); + eq("File \"exception_raise_test.res\", line 137, characters 10-17", Exn.asJsExn(e) !== undefined, true); +} + +try { + throw { + RE_EXN_ID: "Not_found", + Error: new Error() + }; +} catch (raw_e$3) { + let e$1 = Primitive_exceptions.internalToException(raw_e$3); + eq("File \"exception_raise_test.res\", line 141, characters 10-17", Exn.asJsExn(e$1) !== undefined, false); +} + +function fff0(x, g) { + let val; + try { + val = x(); + } catch (exn) { + return 1; + } + return g(); +} + +function input_lines(ic, _acc) { + while (true) { + let acc = _acc; + let line; + try { + line = input_line(ic); + } catch (exn) { + return Belt_List.reverse(acc); + } + _acc = { + hd: line, + tl: acc + }; + continue; + }; +} + +eq("File \"exception_raise_test.res\", line 157, characters 12-19", ((a,b,c,_) => a + b + c)(1, 2, 3, 4), 6); + +Mt.from_pair_suites("Exception_raise_test", suites.contents); + +export { + Local, + B, + C, + D, + appf, + A, + f, + ff, + fff, + a0, + a1, + a2, + suites, + test_id, + eq, + fff0, + input_lines, +} +/* f Not a pure module */ diff --git a/tests/tests/src/exception_rebound_err_test.js b/tests/tests/src/exception_rebound_err_test.js deleted file mode 100644 index 4852b7d73d..0000000000 --- a/tests/tests/src/exception_rebound_err_test.js +++ /dev/null @@ -1,88 +0,0 @@ -// Generated by ReScript, PLEASE EDIT WITH CARE -'use strict'; - -let Mt = require("./mt.js"); -let Primitive_exceptions = require("rescript/lib/js/Primitive_exceptions.js"); - -let suites = { - contents: /* [] */0 -}; - -let test_id = { - contents: 0 -}; - -function eq(loc, x, y) { - test_id.contents = test_id.contents + 1 | 0; - suites.contents = { - hd: [ - loc + (" id " + test_id.contents.toString()), - () => ({ - TAG: "Eq", - _0: x, - _1: y - }) - ], - tl: suites.contents - }; -} - -let A = /* @__PURE__ */Primitive_exceptions.create("Exception_rebound_err_test.A"); - -let B = /* @__PURE__ */Primitive_exceptions.create("Exception_rebound_err_test.B"); - -let C = /* @__PURE__ */Primitive_exceptions.create("Exception_rebound_err_test.C"); - -function test_js_error4() { - try { - JSON.parse(" {\"x\"}"); - return 1; - } catch (raw_e) { - let e = Primitive_exceptions.internalToException(raw_e); - if (e.RE_EXN_ID === "Not_found") { - return 2; - } - if (e.RE_EXN_ID === "Invalid_argument" && e._1 === "x") { - return 3; - } - if (e.RE_EXN_ID === A) { - if (e._1 !== 2) { - return 7; - } else { - return 4; - } - } else if (e.RE_EXN_ID === B) { - return 5; - } else if (e.RE_EXN_ID === C && !(e._1 !== 1 || e._2 !== 2)) { - return 6; - } else { - return 7; - } - } -} - -function f(g) { - try { - return g(); - } catch (raw_exn) { - let exn = Primitive_exceptions.internalToException(raw_exn); - if (exn.RE_EXN_ID === "Not_found") { - return 1; - } - throw exn; - } -} - -eq("File \"exception_rebound_err_test.res\", line 34, characters 3-10", test_js_error4(), 7); - -Mt.from_pair_suites("Exception_rebound_err_test", suites.contents); - -exports.suites = suites; -exports.test_id = test_id; -exports.eq = eq; -exports.A = A; -exports.B = B; -exports.C = C; -exports.test_js_error4 = test_js_error4; -exports.f = f; -/* Not a pure module */ diff --git a/tests/tests/src/exception_rebound_err_test.mjs b/tests/tests/src/exception_rebound_err_test.mjs new file mode 100644 index 0000000000..a43cea2ec0 --- /dev/null +++ b/tests/tests/src/exception_rebound_err_test.mjs @@ -0,0 +1,89 @@ +// Generated by ReScript, PLEASE EDIT WITH CARE + +import * as Mt from "./mt.mjs"; +import * as Primitive_exceptions from "rescript/lib/es6/Primitive_exceptions.js"; + +let suites = { + contents: /* [] */0 +}; + +let test_id = { + contents: 0 +}; + +function eq(loc, x, y) { + test_id.contents = test_id.contents + 1 | 0; + suites.contents = { + hd: [ + loc + (" id " + test_id.contents.toString()), + () => ({ + TAG: "Eq", + _0: x, + _1: y + }) + ], + tl: suites.contents + }; +} + +let A = /* @__PURE__ */Primitive_exceptions.create("Exception_rebound_err_test.A"); + +let B = /* @__PURE__ */Primitive_exceptions.create("Exception_rebound_err_test.B"); + +let C = /* @__PURE__ */Primitive_exceptions.create("Exception_rebound_err_test.C"); + +function test_js_error4() { + try { + JSON.parse(" {\"x\"}"); + return 1; + } catch (raw_e) { + let e = Primitive_exceptions.internalToException(raw_e); + if (e.RE_EXN_ID === "Not_found") { + return 2; + } + if (e.RE_EXN_ID === "Invalid_argument" && e._1 === "x") { + return 3; + } + if (e.RE_EXN_ID === A) { + if (e._1 !== 2) { + return 7; + } else { + return 4; + } + } else if (e.RE_EXN_ID === B) { + return 5; + } else if (e.RE_EXN_ID === C && !(e._1 !== 1 || e._2 !== 2)) { + return 6; + } else { + return 7; + } + } +} + +function f(g) { + try { + return g(); + } catch (raw_exn) { + let exn = Primitive_exceptions.internalToException(raw_exn); + if (exn.RE_EXN_ID === "Not_found") { + return 1; + } + throw exn; + } +} + +eq("File \"exception_rebound_err_test.res\", line 34, characters 3-10", test_js_error4(), 7); + +Mt.from_pair_suites("Exception_rebound_err_test", suites.contents); + +export { + suites, + test_id, + eq, + A, + B, + C, + test_js_error4, + f, +} +/* Not a pure module */ diff --git a/tests/tests/src/exception_value_test.js b/tests/tests/src/exception_value_test.js deleted file mode 100644 index dccedce368..0000000000 --- a/tests/tests/src/exception_value_test.js +++ /dev/null @@ -1,91 +0,0 @@ -// Generated by ReScript, PLEASE EDIT WITH CARE -'use strict'; - -let Exn = require("rescript/lib/js/Exn.js"); -let Primitive_exceptions = require("rescript/lib/js/Primitive_exceptions.js"); - -function f() { - throw { - RE_EXN_ID: "Not_found", - Error: new Error() - }; -} - -function assert_f(x) { - if (x <= 3) { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "exception_value_test.res", - 4, - 11 - ], - Error: new Error() - }; - } - return 3; -} - -function hh() { - throw { - RE_EXN_ID: "Not_found", - Error: new Error() - }; -} - -let A = /* @__PURE__ */Primitive_exceptions.create("Exception_value_test.A"); - -let B = /* @__PURE__ */Primitive_exceptions.create("Exception_value_test.B"); - -let C = /* @__PURE__ */Primitive_exceptions.create("Exception_value_test.C"); - -let u = { - RE_EXN_ID: A, - _1: 3 -}; - -function test_not_found(f, param) { - try { - return f(); - } catch (raw_exn) { - let exn = Primitive_exceptions.internalToException(raw_exn); - if (exn.RE_EXN_ID === "Not_found") { - return 2; - } - throw exn; - } -} - -function test_js_error2() { - try { - return JSON.parse(" {\"x\" : }"); - } catch (raw_e) { - let e = Primitive_exceptions.internalToException(raw_e); - if (e.RE_EXN_ID === Exn.$$Error) { - console.log(e._1.stack); - throw e; - } - throw e; - } -} - -function test_js_error3() { - try { - JSON.parse(" {\"x\"}"); - return 1; - } catch (e) { - return 0; - } -} - -exports.f = f; -exports.assert_f = assert_f; -exports.hh = hh; -exports.A = A; -exports.B = B; -exports.C = C; -exports.u = u; -exports.test_not_found = test_not_found; -exports.test_js_error2 = test_js_error2; -exports.test_js_error3 = test_js_error3; -/* No side effect */ diff --git a/tests/tests/src/exception_value_test.mjs b/tests/tests/src/exception_value_test.mjs new file mode 100644 index 0000000000..4b84d820d4 --- /dev/null +++ b/tests/tests/src/exception_value_test.mjs @@ -0,0 +1,92 @@ +// Generated by ReScript, PLEASE EDIT WITH CARE + +import * as Exn from "rescript/lib/es6/Exn.js"; +import * as Primitive_exceptions from "rescript/lib/es6/Primitive_exceptions.js"; + +function f() { + throw { + RE_EXN_ID: "Not_found", + Error: new Error() + }; +} + +function assert_f(x) { + if (x <= 3) { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "exception_value_test.res", + 4, + 11 + ], + Error: new Error() + }; + } + return 3; +} + +function hh() { + throw { + RE_EXN_ID: "Not_found", + Error: new Error() + }; +} + +let A = /* @__PURE__ */Primitive_exceptions.create("Exception_value_test.A"); + +let B = /* @__PURE__ */Primitive_exceptions.create("Exception_value_test.B"); + +let C = /* @__PURE__ */Primitive_exceptions.create("Exception_value_test.C"); + +let u = { + RE_EXN_ID: A, + _1: 3 +}; + +function test_not_found(f, param) { + try { + return f(); + } catch (raw_exn) { + let exn = Primitive_exceptions.internalToException(raw_exn); + if (exn.RE_EXN_ID === "Not_found") { + return 2; + } + throw exn; + } +} + +function test_js_error2() { + try { + return JSON.parse(" {\"x\" : }"); + } catch (raw_e) { + let e = Primitive_exceptions.internalToException(raw_e); + if (e.RE_EXN_ID === Exn.$$Error) { + console.log(e._1.stack); + throw e; + } + throw e; + } +} + +function test_js_error3() { + try { + JSON.parse(" {\"x\"}"); + return 1; + } catch (e) { + return 0; + } +} + +export { + f, + assert_f, + hh, + A, + B, + C, + u, + test_not_found, + test_js_error2, + test_js_error3, +} +/* No side effect */ diff --git a/tests/tests/src/exotic_labels_test.js b/tests/tests/src/exotic_labels_test.js deleted file mode 100644 index f2287e6b87..0000000000 --- a/tests/tests/src/exotic_labels_test.js +++ /dev/null @@ -1,16 +0,0 @@ -// Generated by ReScript, PLEASE EDIT WITH CARE -'use strict'; - - -function fn1(v) { - return v.field; -} - -let dict = { - key: 1, - KEY: 1 -}; - -exports.fn1 = fn1; -exports.dict = dict; -/* No side effect */ diff --git a/tests/tests/src/exotic_labels_test.mjs b/tests/tests/src/exotic_labels_test.mjs new file mode 100644 index 0000000000..6aceb11261 --- /dev/null +++ b/tests/tests/src/exotic_labels_test.mjs @@ -0,0 +1,17 @@ +// Generated by ReScript, PLEASE EDIT WITH CARE + + +function fn1(v) { + return v.field; +} + +let dict = { + key: 1, + KEY: 1 +}; + +export { + fn1, + dict, +} +/* No side effect */ diff --git a/tests/tests/src/exponentiation_precedence_test.js b/tests/tests/src/exponentiation_precedence_test.js deleted file mode 100644 index 9b5fbe7102..0000000000 --- a/tests/tests/src/exponentiation_precedence_test.js +++ /dev/null @@ -1,17 +0,0 @@ -// Generated by ReScript, PLEASE EDIT WITH CARE -'use strict'; - - -let a = Math.pow(2, Math.pow(3, 2)); - -let b = Math.pow(2, Math.pow(-3, 2)); - -let c = Math.pow(Math.pow(2, 3), 2); - -let d = Math.pow(-2, 2); - -exports.a = a; -exports.b = b; -exports.c = c; -exports.d = d; -/* a Not a pure module */ diff --git a/tests/tests/src/exponentiation_precedence_test.mjs b/tests/tests/src/exponentiation_precedence_test.mjs new file mode 100644 index 0000000000..1f84a4ec3c --- /dev/null +++ b/tests/tests/src/exponentiation_precedence_test.mjs @@ -0,0 +1,18 @@ +// Generated by ReScript, PLEASE EDIT WITH CARE + + +let a = Math.pow(2, Math.pow(3, 2)); + +let b = Math.pow(2, Math.pow(-3, 2)); + +let c = Math.pow(Math.pow(2, 3), 2); + +let d = Math.pow(-2, 2); + +export { + a, + b, + c, + d, +} +/* a Not a pure module */ diff --git a/tests/tests/src/export_keyword.js b/tests/tests/src/export_keyword.js deleted file mode 100644 index 7d53aca900..0000000000 --- a/tests/tests/src/export_keyword.js +++ /dev/null @@ -1,14 +0,0 @@ -// Generated by ReScript, PLEASE EDIT WITH CARE -'use strict'; - - -let $$case = 3; - -let window = 2; - -let $$switch = 3; - -exports.$$case = $$case; -exports.window = window; -exports.$$switch = $$switch; -/* No side effect */ diff --git a/tests/tests/src/export_keyword.mjs b/tests/tests/src/export_keyword.mjs new file mode 100644 index 0000000000..43fcd33f8c --- /dev/null +++ b/tests/tests/src/export_keyword.mjs @@ -0,0 +1,15 @@ +// Generated by ReScript, PLEASE EDIT WITH CARE + + +let $$case = 3; + +let window = 2; + +let $$switch = 3; + +export { + $$case, + window, + $$switch, +} +/* No side effect */ diff --git a/tests/tests/src/ext_array_test.js b/tests/tests/src/ext_array_test.js deleted file mode 100644 index d506904b7f..0000000000 --- a/tests/tests/src/ext_array_test.js +++ /dev/null @@ -1,298 +0,0 @@ -// Generated by ReScript, PLEASE EDIT WITH CARE -'use strict'; - -let Belt_List = require("rescript/lib/js/Belt_List.js"); -let Belt_Array = require("rescript/lib/js/Belt_Array.js"); -let Pervasives = require("rescript/lib/js/Pervasives.js"); -let Primitive_option = require("rescript/lib/js/Primitive_option.js"); - -function reverse_range(a, i, len) { - if (len === 0) { - return; - } - for (let k = 0, k_finish = (len - 1 | 0) / 2 | 0; k <= k_finish; ++k) { - let t = a[i + k | 0]; - a[i + k | 0] = a[((i + len | 0) - 1 | 0) - k | 0]; - a[((i + len | 0) - 1 | 0) - k | 0] = t; - } -} - -function reverse_in_place(a) { - reverse_range(a, 0, a.length); -} - -function reverse(a) { - let b_len = a.length; - if (b_len === 0) { - return []; - } - let b = a.slice(0); - for (let i = 0; i < b_len; ++i) { - b[i] = a[(b_len - 1 | 0) - i | 0]; - } - return b; -} - -function reverse_of_list(x) { - if (!x) { - return []; - } - let len = Belt_List.length(x); - let a = Belt_Array.make(len, x.hd); - let _i = 0; - let _x = x.tl; - while (true) { - let x$1 = _x; - let i = _i; - if (!x$1) { - return a; - } - a[(len - i | 0) - 2 | 0] = x$1.hd; - _x = x$1.tl; - _i = i + 1 | 0; - continue; - }; -} - -function filter(f, a) { - let arr_len = a.length; - let _acc = /* [] */0; - let _i = 0; - while (true) { - let i = _i; - let acc = _acc; - if (i === arr_len) { - return reverse_of_list(acc); - } - let v = a[i]; - if (f(v)) { - _i = i + 1 | 0; - _acc = { - hd: v, - tl: acc - }; - continue; - } - _i = i + 1 | 0; - continue; - }; -} - -function filter_map(f, a) { - let arr_len = a.length; - let _acc = /* [] */0; - let _i = 0; - while (true) { - let i = _i; - let acc = _acc; - if (i === arr_len) { - return reverse_of_list(acc); - } - let v = a[i]; - let v$1 = f(v); - if (v$1 !== undefined) { - _i = i + 1 | 0; - _acc = { - hd: Primitive_option.valFromOption(v$1), - tl: acc - }; - continue; - } - _i = i + 1 | 0; - continue; - }; -} - -function range(from, to_) { - if (from > to_) { - return Pervasives.invalid_arg("Ext_array_test.range"); - } else { - return Belt_Array.init((to_ - from | 0) + 1 | 0, i => i + from | 0); - } -} - -function map2i(f, a, b) { - let len = a.length; - if (len !== b.length) { - return Pervasives.invalid_arg("Ext_array_test.map2i"); - } else { - return Belt_Array.mapWithIndex(a, (i, a) => f(i, a, b[i])); - } -} - -function tolist_aux(a, f, _i, _res) { - while (true) { - let res = _res; - let i = _i; - if (i < 0) { - return res; - } - let v = a[i]; - let v$1 = f(v); - _res = v$1 !== undefined ? ({ - hd: Primitive_option.valFromOption(v$1), - tl: res - }) : res; - _i = i - 1 | 0; - continue; - }; -} - -function to_list_map(f, a) { - return tolist_aux(a, f, a.length - 1 | 0, /* [] */0); -} - -function to_list_map_acc(f, a, acc) { - return tolist_aux(a, f, a.length - 1 | 0, acc); -} - -function of_list_map(f, a) { - if (!a) { - return []; - } - let tl = a.tl; - let hd = f(a.hd); - let len = Belt_List.length(tl) + 1 | 0; - let arr = Belt_Array.make(len, hd); - let _i = 1; - let _x = tl; - while (true) { - let x = _x; - let i = _i; - if (!x) { - return arr; - } - arr[i] = f(x.hd); - _x = x.tl; - _i = i + 1 | 0; - continue; - }; -} - -function rfind_with_index(arr, cmp, v) { - let len = arr.length; - let _i = len - 1 | 0; - while (true) { - let i = _i; - if (i < 0) { - return i; - } - if (cmp(arr[i], v)) { - return i; - } - _i = i - 1 | 0; - continue; - }; -} - -function rfind_and_split(arr, cmp, v) { - let i = rfind_with_index(arr, cmp, v); - if (i < 0) { - return "No_split"; - } else { - return { - NAME: "Split", - VAL: [ - Belt_Array.slice(arr, 0, i), - Belt_Array.slice(arr, i + 1 | 0, (arr.length - i | 0) - 1 | 0) - ] - }; - } -} - -function find_with_index(arr, cmp, v) { - let len = arr.length; - let _i = 0; - while (true) { - let i = _i; - if (i >= len) { - return -1; - } - if (cmp(arr[i], v)) { - return i; - } - _i = i + 1 | 0; - continue; - }; -} - -function find_and_split(arr, cmp, v) { - let i = find_with_index(arr, cmp, v); - if (i < 0) { - return "No_split"; - } else { - return { - NAME: "Split", - VAL: [ - Belt_Array.slice(arr, 0, i), - Belt_Array.slice(arr, i + 1 | 0, (arr.length - i | 0) - 1 | 0) - ] - }; - } -} - -function exists(p, a) { - let n = a.length; - let _i = 0; - while (true) { - let i = _i; - if (i === n) { - return false; - } - if (p(a[i])) { - return true; - } - _i = i + 1 | 0; - continue; - }; -} - -function is_empty(arr) { - return arr.length === 0; -} - -function unsafe_loop(_index, len, p, xs, ys) { - while (true) { - let index = _index; - if (index >= len) { - return true; - } - if (!p(xs[index], ys[index])) { - return false; - } - _index = index + 1 | 0; - continue; - }; -} - -function for_all2_no_exn(p, xs, ys) { - let len_xs = xs.length; - let len_ys = ys.length; - if (len_xs === len_ys) { - return unsafe_loop(0, len_xs, p, xs, ys); - } else { - return false; - } -} - -exports.reverse_range = reverse_range; -exports.reverse_in_place = reverse_in_place; -exports.reverse = reverse; -exports.reverse_of_list = reverse_of_list; -exports.filter = filter; -exports.filter_map = filter_map; -exports.range = range; -exports.map2i = map2i; -exports.tolist_aux = tolist_aux; -exports.to_list_map = to_list_map; -exports.to_list_map_acc = to_list_map_acc; -exports.of_list_map = of_list_map; -exports.rfind_with_index = rfind_with_index; -exports.rfind_and_split = rfind_and_split; -exports.find_with_index = find_with_index; -exports.find_and_split = find_and_split; -exports.exists = exists; -exports.is_empty = is_empty; -exports.unsafe_loop = unsafe_loop; -exports.for_all2_no_exn = for_all2_no_exn; -/* No side effect */ diff --git a/tests/tests/src/ext_array_test.mjs b/tests/tests/src/ext_array_test.mjs new file mode 100644 index 0000000000..0ca8a94fe9 --- /dev/null +++ b/tests/tests/src/ext_array_test.mjs @@ -0,0 +1,299 @@ +// Generated by ReScript, PLEASE EDIT WITH CARE + +import * as Belt_List from "rescript/lib/es6/Belt_List.js"; +import * as Belt_Array from "rescript/lib/es6/Belt_Array.js"; +import * as Pervasives from "rescript/lib/es6/Pervasives.js"; +import * as Primitive_option from "rescript/lib/es6/Primitive_option.js"; + +function reverse_range(a, i, len) { + if (len === 0) { + return; + } + for (let k = 0, k_finish = (len - 1 | 0) / 2 | 0; k <= k_finish; ++k) { + let t = a[i + k | 0]; + a[i + k | 0] = a[((i + len | 0) - 1 | 0) - k | 0]; + a[((i + len | 0) - 1 | 0) - k | 0] = t; + } +} + +function reverse_in_place(a) { + reverse_range(a, 0, a.length); +} + +function reverse(a) { + let b_len = a.length; + if (b_len === 0) { + return []; + } + let b = a.slice(0); + for (let i = 0; i < b_len; ++i) { + b[i] = a[(b_len - 1 | 0) - i | 0]; + } + return b; +} + +function reverse_of_list(x) { + if (!x) { + return []; + } + let len = Belt_List.length(x); + let a = Belt_Array.make(len, x.hd); + let _i = 0; + let _x = x.tl; + while (true) { + let x$1 = _x; + let i = _i; + if (!x$1) { + return a; + } + a[(len - i | 0) - 2 | 0] = x$1.hd; + _x = x$1.tl; + _i = i + 1 | 0; + continue; + }; +} + +function filter(f, a) { + let arr_len = a.length; + let _acc = /* [] */0; + let _i = 0; + while (true) { + let i = _i; + let acc = _acc; + if (i === arr_len) { + return reverse_of_list(acc); + } + let v = a[i]; + if (f(v)) { + _i = i + 1 | 0; + _acc = { + hd: v, + tl: acc + }; + continue; + } + _i = i + 1 | 0; + continue; + }; +} + +function filter_map(f, a) { + let arr_len = a.length; + let _acc = /* [] */0; + let _i = 0; + while (true) { + let i = _i; + let acc = _acc; + if (i === arr_len) { + return reverse_of_list(acc); + } + let v = a[i]; + let v$1 = f(v); + if (v$1 !== undefined) { + _i = i + 1 | 0; + _acc = { + hd: Primitive_option.valFromOption(v$1), + tl: acc + }; + continue; + } + _i = i + 1 | 0; + continue; + }; +} + +function range(from, to_) { + if (from > to_) { + return Pervasives.invalid_arg("Ext_array_test.range"); + } else { + return Belt_Array.init((to_ - from | 0) + 1 | 0, i => i + from | 0); + } +} + +function map2i(f, a, b) { + let len = a.length; + if (len !== b.length) { + return Pervasives.invalid_arg("Ext_array_test.map2i"); + } else { + return Belt_Array.mapWithIndex(a, (i, a) => f(i, a, b[i])); + } +} + +function tolist_aux(a, f, _i, _res) { + while (true) { + let res = _res; + let i = _i; + if (i < 0) { + return res; + } + let v = a[i]; + let v$1 = f(v); + _res = v$1 !== undefined ? ({ + hd: Primitive_option.valFromOption(v$1), + tl: res + }) : res; + _i = i - 1 | 0; + continue; + }; +} + +function to_list_map(f, a) { + return tolist_aux(a, f, a.length - 1 | 0, /* [] */0); +} + +function to_list_map_acc(f, a, acc) { + return tolist_aux(a, f, a.length - 1 | 0, acc); +} + +function of_list_map(f, a) { + if (!a) { + return []; + } + let tl = a.tl; + let hd = f(a.hd); + let len = Belt_List.length(tl) + 1 | 0; + let arr = Belt_Array.make(len, hd); + let _i = 1; + let _x = tl; + while (true) { + let x = _x; + let i = _i; + if (!x) { + return arr; + } + arr[i] = f(x.hd); + _x = x.tl; + _i = i + 1 | 0; + continue; + }; +} + +function rfind_with_index(arr, cmp, v) { + let len = arr.length; + let _i = len - 1 | 0; + while (true) { + let i = _i; + if (i < 0) { + return i; + } + if (cmp(arr[i], v)) { + return i; + } + _i = i - 1 | 0; + continue; + }; +} + +function rfind_and_split(arr, cmp, v) { + let i = rfind_with_index(arr, cmp, v); + if (i < 0) { + return "No_split"; + } else { + return { + NAME: "Split", + VAL: [ + Belt_Array.slice(arr, 0, i), + Belt_Array.slice(arr, i + 1 | 0, (arr.length - i | 0) - 1 | 0) + ] + }; + } +} + +function find_with_index(arr, cmp, v) { + let len = arr.length; + let _i = 0; + while (true) { + let i = _i; + if (i >= len) { + return -1; + } + if (cmp(arr[i], v)) { + return i; + } + _i = i + 1 | 0; + continue; + }; +} + +function find_and_split(arr, cmp, v) { + let i = find_with_index(arr, cmp, v); + if (i < 0) { + return "No_split"; + } else { + return { + NAME: "Split", + VAL: [ + Belt_Array.slice(arr, 0, i), + Belt_Array.slice(arr, i + 1 | 0, (arr.length - i | 0) - 1 | 0) + ] + }; + } +} + +function exists(p, a) { + let n = a.length; + let _i = 0; + while (true) { + let i = _i; + if (i === n) { + return false; + } + if (p(a[i])) { + return true; + } + _i = i + 1 | 0; + continue; + }; +} + +function is_empty(arr) { + return arr.length === 0; +} + +function unsafe_loop(_index, len, p, xs, ys) { + while (true) { + let index = _index; + if (index >= len) { + return true; + } + if (!p(xs[index], ys[index])) { + return false; + } + _index = index + 1 | 0; + continue; + }; +} + +function for_all2_no_exn(p, xs, ys) { + let len_xs = xs.length; + let len_ys = ys.length; + if (len_xs === len_ys) { + return unsafe_loop(0, len_xs, p, xs, ys); + } else { + return false; + } +} + +export { + reverse_range, + reverse_in_place, + reverse, + reverse_of_list, + filter, + filter_map, + range, + map2i, + tolist_aux, + to_list_map, + to_list_map_acc, + of_list_map, + rfind_with_index, + rfind_and_split, + find_with_index, + find_and_split, + exists, + is_empty, + unsafe_loop, + for_all2_no_exn, +} +/* No side effect */ diff --git a/tests/tests/src/ext_pervasives_test.js b/tests/tests/src/ext_pervasives_test.js deleted file mode 100644 index abdc710db7..0000000000 --- a/tests/tests/src/ext_pervasives_test.js +++ /dev/null @@ -1,37 +0,0 @@ -// Generated by ReScript, PLEASE EDIT WITH CARE -'use strict'; - - -function $$finally(v, action, f) { - let e; - try { - e = f(v); - } catch (e$1) { - action(v); - throw e$1; - } - action(v); - return e; -} - -function hash_variant(s) { - let accu = 0; - for (let i = 0, i_finish = s.length; i < i_finish; ++i) { - accu = Math.imul(223, accu) + s.codePointAt(i) | 0; - } - accu = accu & 2147483647; - if (accu > 1073741823) { - return accu - -2147483648 | 0; - } else { - return accu; - } -} - -let LargeFile = { - u: 3 -}; - -exports.$$finally = $$finally; -exports.hash_variant = hash_variant; -exports.LargeFile = LargeFile; -/* No side effect */ diff --git a/tests/tests/src/ext_pervasives_test.mjs b/tests/tests/src/ext_pervasives_test.mjs new file mode 100644 index 0000000000..f15c564ef2 --- /dev/null +++ b/tests/tests/src/ext_pervasives_test.mjs @@ -0,0 +1,38 @@ +// Generated by ReScript, PLEASE EDIT WITH CARE + + +function $$finally(v, action, f) { + let e; + try { + e = f(v); + } catch (e$1) { + action(v); + throw e$1; + } + action(v); + return e; +} + +function hash_variant(s) { + let accu = 0; + for (let i = 0, i_finish = s.length; i < i_finish; ++i) { + accu = Math.imul(223, accu) + s.codePointAt(i) | 0; + } + accu = accu & 2147483647; + if (accu > 1073741823) { + return accu - -2147483648 | 0; + } else { + return accu; + } +} + +let LargeFile = { + u: 3 +}; + +export { + $$finally, + hash_variant, + LargeFile, +} +/* No side effect */ diff --git a/tests/tests/src/extensible_variant_test.js b/tests/tests/src/extensible_variant_test.js deleted file mode 100644 index 99285b1ab9..0000000000 --- a/tests/tests/src/extensible_variant_test.js +++ /dev/null @@ -1,92 +0,0 @@ -// Generated by ReScript, PLEASE EDIT WITH CARE -'use strict'; - -let Mt = require("./mt.js"); -let Primitive_exceptions = require("rescript/lib/js/Primitive_exceptions.js"); - -let Str = /* @__PURE__ */Primitive_exceptions.create("Extensible_variant_test.Str"); - -let Int = /* @__PURE__ */Primitive_exceptions.create("Extensible_variant_test.N.Int"); - -let N = { - Int: Int -}; - -let Int$1 = /* @__PURE__ */Primitive_exceptions.create("Extensible_variant_test.Int"); - -function to_int(x) { - if (x.RE_EXN_ID === Str) { - return -1; - } - if (x.RE_EXN_ID === Int) { - return x._1; - } - if (x.RE_EXN_ID === Int$1) { - return x._2; - } - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "extensible_variant_test.res", - 16, - 9 - ], - Error: new Error() - }; -} - -let suites_0 = [ - "test_int", - param => ({ - TAG: "Eq", - _0: 3, - _1: to_int({ - RE_EXN_ID: Int, - _1: 3, - _2: 0 - }) - }) -]; - -let suites_1 = { - hd: [ - "test_int2", - param => ({ - TAG: "Eq", - _0: 0, - _1: to_int({ - RE_EXN_ID: Int$1, - _1: 3, - _2: 0 - }) - }) - ], - tl: { - hd: [ - "test_string", - param => ({ - TAG: "Eq", - _0: -1, - _1: to_int({ - RE_EXN_ID: Str, - _1: "x" - }) - }) - ], - tl: /* [] */0 - } -}; - -let suites = { - hd: suites_0, - tl: suites_1 -}; - -Mt.from_pair_suites("Extensible_variant_test", suites); - -exports.Str = Str; -exports.N = N; -exports.Int = Int$1; -exports.to_int = to_int; -exports.suites = suites; -/* Not a pure module */ diff --git a/tests/tests/src/extensible_variant_test.mjs b/tests/tests/src/extensible_variant_test.mjs new file mode 100644 index 0000000000..b6d8da5bbc --- /dev/null +++ b/tests/tests/src/extensible_variant_test.mjs @@ -0,0 +1,93 @@ +// Generated by ReScript, PLEASE EDIT WITH CARE + +import * as Mt from "./mt.mjs"; +import * as Primitive_exceptions from "rescript/lib/es6/Primitive_exceptions.js"; + +let Str = /* @__PURE__ */Primitive_exceptions.create("Extensible_variant_test.Str"); + +let Int = /* @__PURE__ */Primitive_exceptions.create("Extensible_variant_test.N.Int"); + +let N = { + Int: Int +}; + +let Int$1 = /* @__PURE__ */Primitive_exceptions.create("Extensible_variant_test.Int"); + +function to_int(x) { + if (x.RE_EXN_ID === Str) { + return -1; + } + if (x.RE_EXN_ID === Int) { + return x._1; + } + if (x.RE_EXN_ID === Int$1) { + return x._2; + } + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "extensible_variant_test.res", + 16, + 9 + ], + Error: new Error() + }; +} + +let suites_0 = [ + "test_int", + param => ({ + TAG: "Eq", + _0: 3, + _1: to_int({ + RE_EXN_ID: Int, + _1: 3, + _2: 0 + }) + }) +]; + +let suites_1 = { + hd: [ + "test_int2", + param => ({ + TAG: "Eq", + _0: 0, + _1: to_int({ + RE_EXN_ID: Int$1, + _1: 3, + _2: 0 + }) + }) + ], + tl: { + hd: [ + "test_string", + param => ({ + TAG: "Eq", + _0: -1, + _1: to_int({ + RE_EXN_ID: Str, + _1: "x" + }) + }) + ], + tl: /* [] */0 + } +}; + +let suites = { + hd: suites_0, + tl: suites_1 +}; + +Mt.from_pair_suites("Extensible_variant_test", suites); + +export { + Str, + N, + Int$1 as Int, + to_int, + suites, +} +/* Not a pure module */ diff --git a/tests/tests/src/external_ppx.js b/tests/tests/src/external_ppx.js deleted file mode 100644 index c5dd25dc0e..0000000000 --- a/tests/tests/src/external_ppx.js +++ /dev/null @@ -1,26 +0,0 @@ -// Generated by ReScript, PLEASE EDIT WITH CARE -'use strict'; - -let External_ppxGen = require("./external_ppx.gen"); - -let renamed = { - type: "123", - normal: 12 -}; - -let u = { - hi: 2, - lo: 3, - lo2: {hi:-3 }, - lo3: -1, - lo4: -3 -}; - -function f(prim) { - return External_ppxGen.f(prim); -} - -exports.renamed = renamed; -exports.u = u; -exports.f = f; -/* ./external_ppx.gen Not a pure module */ diff --git a/tests/tests/src/external_ppx.mjs b/tests/tests/src/external_ppx.mjs new file mode 100644 index 0000000000..41d0d27f60 --- /dev/null +++ b/tests/tests/src/external_ppx.mjs @@ -0,0 +1,27 @@ +// Generated by ReScript, PLEASE EDIT WITH CARE + +import * as External_ppxGen from "./external_ppx.gen"; + +let renamed = { + type: "123", + normal: 12 +}; + +let u = { + hi: 2, + lo: 3, + lo2: {hi:-3 }, + lo3: -1, + lo4: -3 +}; + +function f(prim) { + return External_ppxGen.f(prim); +} + +export { + renamed, + u, + f, +} +/* ./external_ppx.gen Not a pure module */ diff --git a/tests/tests/src/external_ppx2.js b/tests/tests/src/external_ppx2.js deleted file mode 100644 index f4c9318e9d..0000000000 --- a/tests/tests/src/external_ppx2.js +++ /dev/null @@ -1,13 +0,0 @@ -// Generated by ReScript, PLEASE EDIT WITH CARE -'use strict'; - - -f("\h\e\l\lo", 42); - -let x = "\h\e\l\lo"; - -let y; - -exports.x = x; -exports.y = y; -/* Not a pure module */ diff --git a/tests/tests/src/external_ppx2.mjs b/tests/tests/src/external_ppx2.mjs new file mode 100644 index 0000000000..ab97a23df5 --- /dev/null +++ b/tests/tests/src/external_ppx2.mjs @@ -0,0 +1,14 @@ +// Generated by ReScript, PLEASE EDIT WITH CARE + + +f("\h\e\l\lo", 42); + +let x = "\h\e\l\lo"; + +let y; + +export { + x, + y, +} +/* Not a pure module */ diff --git a/tests/tests/src/ffi_arity_test.js b/tests/tests/src/ffi_arity_test.js deleted file mode 100644 index ad382cb1b0..0000000000 --- a/tests/tests/src/ffi_arity_test.js +++ /dev/null @@ -1,121 +0,0 @@ -// Generated by ReScript, PLEASE EDIT WITH CARE -'use strict'; - -let Mt = require("./mt.js"); - -function f(v) { - if (v % 2 === 0) { - return v => Math.imul(v, v); - } else { - return v => v + v | 0; - } -} - -let v = [ - 1, - 2, - 3 -].map((a, b) => f(a)(b)); - -let vv = [ - 1, - 2, - 3 -].map((a, b) => a + b | 0); - -let hh = [ - "1", - "2", - "3" -].map(x => parseInt(x)); - -function u() { - return 3; -} - -let vvv = { - contents: 0 -}; - -function fff() { - console.log("x"); - console.log("x"); - vvv.contents = vvv.contents + 1 | 0; -} - -function g() { - fff(); -} - -function abc(x, y, z) { - console.log("xx"); - console.log("yy"); - return (x + y | 0) + z | 0; -} - -let abc_u = abc; - -fff(); - -Mt.from_pair_suites("Ffi_arity_test", { - hd: [ - "File \"ffi_arity_test.res\", line 51, characters 7-14", - () => ({ - TAG: "Eq", - _0: v, - _1: [ - 0, - 1, - 4 - ] - }) - ], - tl: { - hd: [ - "File \"ffi_arity_test.res\", line 52, characters 7-14", - () => ({ - TAG: "Eq", - _0: vv, - _1: [ - 1, - 3, - 5 - ] - }) - ], - tl: { - hd: [ - "File \"ffi_arity_test.res\", line 53, characters 7-14", - () => ({ - TAG: "Eq", - _0: hh, - _1: [ - 1, - 2, - 3 - ] - }) - ], - tl: /* [] */0 - } - } -}); - -function bar(fn) { - return fn(); -} - -((function(){console.log("forgiving arity")})()); - -exports.f = f; -exports.v = v; -exports.vv = vv; -exports.hh = hh; -exports.u = u; -exports.vvv = vvv; -exports.fff = fff; -exports.g = g; -exports.abc = abc; -exports.abc_u = abc_u; -exports.bar = bar; -/* v Not a pure module */ diff --git a/tests/tests/src/ffi_arity_test.mjs b/tests/tests/src/ffi_arity_test.mjs new file mode 100644 index 0000000000..155e3928f7 --- /dev/null +++ b/tests/tests/src/ffi_arity_test.mjs @@ -0,0 +1,122 @@ +// Generated by ReScript, PLEASE EDIT WITH CARE + +import * as Mt from "./mt.mjs"; + +function f(v) { + if (v % 2 === 0) { + return v => Math.imul(v, v); + } else { + return v => v + v | 0; + } +} + +let v = [ + 1, + 2, + 3 +].map((a, b) => f(a)(b)); + +let vv = [ + 1, + 2, + 3 +].map((a, b) => a + b | 0); + +let hh = [ + "1", + "2", + "3" +].map(x => parseInt(x)); + +function u() { + return 3; +} + +let vvv = { + contents: 0 +}; + +function fff() { + console.log("x"); + console.log("x"); + vvv.contents = vvv.contents + 1 | 0; +} + +function g() { + fff(); +} + +function abc(x, y, z) { + console.log("xx"); + console.log("yy"); + return (x + y | 0) + z | 0; +} + +let abc_u = abc; + +fff(); + +Mt.from_pair_suites("Ffi_arity_test", { + hd: [ + "File \"ffi_arity_test.res\", line 51, characters 7-14", + () => ({ + TAG: "Eq", + _0: v, + _1: [ + 0, + 1, + 4 + ] + }) + ], + tl: { + hd: [ + "File \"ffi_arity_test.res\", line 52, characters 7-14", + () => ({ + TAG: "Eq", + _0: vv, + _1: [ + 1, + 3, + 5 + ] + }) + ], + tl: { + hd: [ + "File \"ffi_arity_test.res\", line 53, characters 7-14", + () => ({ + TAG: "Eq", + _0: hh, + _1: [ + 1, + 2, + 3 + ] + }) + ], + tl: /* [] */0 + } + } +}); + +function bar(fn) { + return fn(); +} + +((function(){console.log("forgiving arity")})()); + +export { + f, + v, + vv, + hh, + u, + vvv, + fff, + g, + abc, + abc_u, + bar, +} +/* v Not a pure module */ diff --git a/tests/tests/src/ffi_array_test.js b/tests/tests/src/ffi_array_test.js deleted file mode 100644 index 1249fd62cd..0000000000 --- a/tests/tests/src/ffi_array_test.js +++ /dev/null @@ -1,46 +0,0 @@ -// Generated by ReScript, PLEASE EDIT WITH CARE -'use strict'; - -let Mt = require("./mt.js"); - -let suites = { - contents: /* [] */0 -}; - -let test_id = { - contents: 0 -}; - -function eq(loc, x, y) { - test_id.contents = test_id.contents + 1 | 0; - suites.contents = { - hd: [ - loc + (" id " + test_id.contents.toString()), - () => ({ - TAG: "Eq", - _0: x, - _1: y - }) - ], - tl: suites.contents - }; -} - -eq("File \"ffi_array_test.res\", line 14, characters 12-19", [ - 1, - 2, - 3, - 4 -].map(x => x + 1 | 0), [ - 2, - 3, - 4, - 5 -]); - -Mt.from_pair_suites("Ffi_array_test", suites.contents); - -exports.suites = suites; -exports.test_id = test_id; -exports.eq = eq; -/* Not a pure module */ diff --git a/tests/tests/src/ffi_array_test.mjs b/tests/tests/src/ffi_array_test.mjs new file mode 100644 index 0000000000..7945bf9ef9 --- /dev/null +++ b/tests/tests/src/ffi_array_test.mjs @@ -0,0 +1,47 @@ +// Generated by ReScript, PLEASE EDIT WITH CARE + +import * as Mt from "./mt.mjs"; + +let suites = { + contents: /* [] */0 +}; + +let test_id = { + contents: 0 +}; + +function eq(loc, x, y) { + test_id.contents = test_id.contents + 1 | 0; + suites.contents = { + hd: [ + loc + (" id " + test_id.contents.toString()), + () => ({ + TAG: "Eq", + _0: x, + _1: y + }) + ], + tl: suites.contents + }; +} + +eq("File \"ffi_array_test.res\", line 14, characters 12-19", [ + 1, + 2, + 3, + 4 +].map(x => x + 1 | 0), [ + 2, + 3, + 4, + 5 +]); + +Mt.from_pair_suites("Ffi_array_test", suites.contents); + +export { + suites, + test_id, + eq, +} +/* Not a pure module */ diff --git a/tests/tests/src/ffi_js_test.js b/tests/tests/src/ffi_js_test.js deleted file mode 100644 index bc0b64e95d..0000000000 --- a/tests/tests/src/ffi_js_test.js +++ /dev/null @@ -1,177 +0,0 @@ -// Generated by ReScript, PLEASE EDIT WITH CARE -'use strict'; - -let Mt = require("./mt.js"); - -let keys = (function (x){return Object.keys(x)}); - -function $$higher_order(x){ - return function(y,z){ - return x + y + z - } - } -; - -let suites = { - contents: /* [] */0 -}; - -let test_id = { - contents: 0 -}; - -function eq(loc, param) { - let y = param[1]; - let x = param[0]; - test_id.contents = test_id.contents + 1 | 0; - suites.contents = { - hd: [ - loc + (" id " + test_id.contents.toString()), - () => ({ - TAG: "Eq", - _0: x, - _1: y - }) - ], - tl: suites.contents - }; -} - -let int_config = { - hi: 3, - low: 32 -}; - -let string_config = { - hi: 3, - low: "32" -}; - -eq("File \"ffi_js_test.res\", line 33, characters 12-19", [ - 6, - $$higher_order(1)(2, 3) -]); - -let same_type_0 = { - hd: int_config, - tl: { - hd: { - hi: 3, - low: 32 - }, - tl: /* [] */0 - } -}; - -let same_type_1 = { - hd: string_config, - tl: { - hd: { - hi: 3, - low: "32" - }, - tl: /* [] */0 - } -}; - -let same_type = [ - same_type_0, - same_type_1 -]; - -eq("File \"ffi_js_test.res\", line 41, characters 5-12", [ - Object.keys(int_config).length, - 2 -]); - -eq("File \"ffi_js_test.res\", line 42, characters 5-12", [ - Object.keys(string_config).length, - 2 -]); - -let u = { - contents: 3 -}; - -let side_effect_config = (u.contents = u.contents + 1 | 0, "Int", { - hi: 3, - low: 32 -}); - -eq("File \"ffi_js_test.res\", line 56, characters 12-19", [ - u.contents, - 4 -]); - -function vv(z) { - return z.hh(); -} - -function v(z) { - return z.ff(); -} - -function vvv(z) { - return z.ff_pipe(); -} - -function vvvv(z) { - return z.ff_pipe2(); -} - -function create_prim() { - return { - "x'": 3, - "x''": 3, - "x''''": 2 - }; -} - -function ffff(x) { - x.setGADT = 3; - x.setGADT2 = [ - 3, - "3" - ]; - x.setGADT2 = [ - "3", - 3 - ]; - let match = x[3]; - console.log([ - match[0], - match[1] - ]); - console.log(x.getGADT); - let match$1 = x.getGADT2; - console.log(match$1[0], match$1[1]); - let match$2 = x[0]; - console.log(match$2[0], match$2[1]); - x[0] = [ - 1, - "x" - ]; - x[3] = [ - 3, - "x" - ]; -} - -Mt.from_pair_suites("Ffi_js_test", suites.contents); - -exports.keys = keys; -exports.suites = suites; -exports.test_id = test_id; -exports.eq = eq; -exports.int_config = int_config; -exports.string_config = string_config; -exports.same_type = same_type; -exports.u = u; -exports.side_effect_config = side_effect_config; -exports.vv = vv; -exports.v = v; -exports.vvv = vvv; -exports.vvvv = vvvv; -exports.create_prim = create_prim; -exports.ffff = ffff; -/* Not a pure module */ diff --git a/tests/tests/src/ffi_js_test.mjs b/tests/tests/src/ffi_js_test.mjs new file mode 100644 index 0000000000..038c5489b1 --- /dev/null +++ b/tests/tests/src/ffi_js_test.mjs @@ -0,0 +1,178 @@ +// Generated by ReScript, PLEASE EDIT WITH CARE + +import * as Mt from "./mt.mjs"; + +let keys = (function (x){return Object.keys(x)}); + +function $$higher_order(x){ + return function(y,z){ + return x + y + z + } + } +; + +let suites = { + contents: /* [] */0 +}; + +let test_id = { + contents: 0 +}; + +function eq(loc, param) { + let y = param[1]; + let x = param[0]; + test_id.contents = test_id.contents + 1 | 0; + suites.contents = { + hd: [ + loc + (" id " + test_id.contents.toString()), + () => ({ + TAG: "Eq", + _0: x, + _1: y + }) + ], + tl: suites.contents + }; +} + +let int_config = { + hi: 3, + low: 32 +}; + +let string_config = { + hi: 3, + low: "32" +}; + +eq("File \"ffi_js_test.res\", line 33, characters 12-19", [ + 6, + $$higher_order(1)(2, 3) +]); + +let same_type_0 = { + hd: int_config, + tl: { + hd: { + hi: 3, + low: 32 + }, + tl: /* [] */0 + } +}; + +let same_type_1 = { + hd: string_config, + tl: { + hd: { + hi: 3, + low: "32" + }, + tl: /* [] */0 + } +}; + +let same_type = [ + same_type_0, + same_type_1 +]; + +eq("File \"ffi_js_test.res\", line 41, characters 5-12", [ + Object.keys(int_config).length, + 2 +]); + +eq("File \"ffi_js_test.res\", line 42, characters 5-12", [ + Object.keys(string_config).length, + 2 +]); + +let u = { + contents: 3 +}; + +let side_effect_config = (u.contents = u.contents + 1 | 0, "Int", { + hi: 3, + low: 32 +}); + +eq("File \"ffi_js_test.res\", line 56, characters 12-19", [ + u.contents, + 4 +]); + +function vv(z) { + return z.hh(); +} + +function v(z) { + return z.ff(); +} + +function vvv(z) { + return z.ff_pipe(); +} + +function vvvv(z) { + return z.ff_pipe2(); +} + +function create_prim() { + return { + "x'": 3, + "x''": 3, + "x''''": 2 + }; +} + +function ffff(x) { + x.setGADT = 3; + x.setGADT2 = [ + 3, + "3" + ]; + x.setGADT2 = [ + "3", + 3 + ]; + let match = x[3]; + console.log([ + match[0], + match[1] + ]); + console.log(x.getGADT); + let match$1 = x.getGADT2; + console.log(match$1[0], match$1[1]); + let match$2 = x[0]; + console.log(match$2[0], match$2[1]); + x[0] = [ + 1, + "x" + ]; + x[3] = [ + 3, + "x" + ]; +} + +Mt.from_pair_suites("Ffi_js_test", suites.contents); + +export { + keys, + suites, + test_id, + eq, + int_config, + string_config, + same_type, + u, + side_effect_config, + vv, + v, + vvv, + vvvv, + create_prim, + ffff, +} +/* Not a pure module */ diff --git a/tests/tests/src/ffi_splice_test.js b/tests/tests/src/ffi_splice_test.js deleted file mode 100644 index afed162b54..0000000000 --- a/tests/tests/src/ffi_splice_test.js +++ /dev/null @@ -1,67 +0,0 @@ -// Generated by ReScript, PLEASE EDIT WITH CARE -'use strict'; - -let Mt = require("./mt.js"); - -let suites = { - contents: /* [] */0 -}; - -let test_id = { - contents: 0 -}; - -function eq(loc, x, y) { - test_id.contents = test_id.contents + 1 | 0; - suites.contents = { - hd: [ - loc + (" id " + test_id.contents.toString()), - () => ({ - TAG: "Eq", - _0: x, - _1: y - }) - ], - tl: suites.contents - }; -} - -function Make (){ - this.data = [] - for(var i = 0; i < arguments.length; ++i){ - this.data[i] = arguments[i] -} -} - -Make.prototype.sum = function(){ - var result = 0; - for(var k = 0; k < this.data.length; ++k){ - result = result + this.data[k] - }; - return result -} - -Make.prototype.add = function(){ - -} -; - -function f(x) { - return x.test("a", "b").test("a", "b"); -} - -let v = new Make(1, 2, 3, 4); - -let u = v.sum(); - -eq("File \"ffi_splice_test.res\", line 54, characters 12-19", u, 10); - -Mt.from_pair_suites("Ffi_splice_test", suites.contents); - -exports.suites = suites; -exports.test_id = test_id; -exports.eq = eq; -exports.f = f; -exports.v = v; -exports.u = u; -/* Not a pure module */ diff --git a/tests/tests/src/ffi_splice_test.mjs b/tests/tests/src/ffi_splice_test.mjs new file mode 100644 index 0000000000..23ff2a8691 --- /dev/null +++ b/tests/tests/src/ffi_splice_test.mjs @@ -0,0 +1,68 @@ +// Generated by ReScript, PLEASE EDIT WITH CARE + +import * as Mt from "./mt.mjs"; + +let suites = { + contents: /* [] */0 +}; + +let test_id = { + contents: 0 +}; + +function eq(loc, x, y) { + test_id.contents = test_id.contents + 1 | 0; + suites.contents = { + hd: [ + loc + (" id " + test_id.contents.toString()), + () => ({ + TAG: "Eq", + _0: x, + _1: y + }) + ], + tl: suites.contents + }; +} + +function Make (){ + this.data = [] + for(var i = 0; i < arguments.length; ++i){ + this.data[i] = arguments[i] +} +} + +Make.prototype.sum = function(){ + var result = 0; + for(var k = 0; k < this.data.length; ++k){ + result = result + this.data[k] + }; + return result +} + +Make.prototype.add = function(){ + +} +; + +function f(x) { + return x.test("a", "b").test("a", "b"); +} + +let v = new Make(1, 2, 3, 4); + +let u = v.sum(); + +eq("File \"ffi_splice_test.res\", line 54, characters 12-19", u, 10); + +Mt.from_pair_suites("Ffi_splice_test", suites.contents); + +export { + suites, + test_id, + eq, + f, + v, + u, +} +/* Not a pure module */ diff --git a/tests/tests/src/ffi_test.js b/tests/tests/src/ffi_test.js deleted file mode 100644 index e677b1fbff..0000000000 --- a/tests/tests/src/ffi_test.js +++ /dev/null @@ -1,42 +0,0 @@ -// Generated by ReScript, PLEASE EDIT WITH CARE -'use strict'; - - -function u() { - return xx(3); -} - -let Textarea = {}; - -let $$Int32Array = {}; - -function v() { - let u = new TextArea(); - u.minHeight = 3; - return u.minHeight; -} - -function f() { - let v = new Int32Array(32); - v[0] = 3; - return v[0]; -} - -let a = true; - -let b = false; - -let c = null; - -let d; - -exports.u = u; -exports.a = a; -exports.b = b; -exports.c = c; -exports.d = d; -exports.Textarea = Textarea; -exports.$$Int32Array = $$Int32Array; -exports.v = v; -exports.f = f; -/* No side effect */ diff --git a/tests/tests/src/ffi_test.mjs b/tests/tests/src/ffi_test.mjs new file mode 100644 index 0000000000..a2b2abaf23 --- /dev/null +++ b/tests/tests/src/ffi_test.mjs @@ -0,0 +1,43 @@ +// Generated by ReScript, PLEASE EDIT WITH CARE + + +function u() { + return xx(3); +} + +let Textarea = {}; + +let $$Int32Array = {}; + +function v() { + let u = new TextArea(); + u.minHeight = 3; + return u.minHeight; +} + +function f() { + let v = new Int32Array(32); + v[0] = 3; + return v[0]; +} + +let a = true; + +let b = false; + +let c = null; + +let d; + +export { + u, + a, + b, + c, + d, + Textarea, + $$Int32Array, + v, + f, +} +/* No side effect */ diff --git a/tests/tests/src/fib.js b/tests/tests/src/fib.js deleted file mode 100644 index 40074bd13e..0000000000 --- a/tests/tests/src/fib.js +++ /dev/null @@ -1,45 +0,0 @@ -// Generated by ReScript, PLEASE EDIT WITH CARE -'use strict'; - - -function fib(x) { - if (x === 0 || x === 1) { - return 1; - } else { - return fib(x - 1 | 0) + fib(x - 2 | 0) | 0; - } -} - -function fib2(n) { - let _a = 1; - let _b = 1; - let _i = 0; - while (true) { - let i = _i; - let b = _b; - let a = _a; - if (n === i) { - return a; - } - _i = i + 1 | 0; - _b = a + b | 0; - _a = b; - continue; - }; -} - -function fib3(n) { - let a = 1; - let b = 1; - for (let i = 1; i <= n; ++i) { - let tmp = a; - a = b; - b = b + tmp | 0; - } - return a; -} - -exports.fib = fib; -exports.fib2 = fib2; -exports.fib3 = fib3; -/* No side effect */ diff --git a/tests/tests/src/fib.mjs b/tests/tests/src/fib.mjs new file mode 100644 index 0000000000..40a3b661f3 --- /dev/null +++ b/tests/tests/src/fib.mjs @@ -0,0 +1,46 @@ +// Generated by ReScript, PLEASE EDIT WITH CARE + + +function fib(x) { + if (x === 0 || x === 1) { + return 1; + } else { + return fib(x - 1 | 0) + fib(x - 2 | 0) | 0; + } +} + +function fib2(n) { + let _a = 1; + let _b = 1; + let _i = 0; + while (true) { + let i = _i; + let b = _b; + let a = _a; + if (n === i) { + return a; + } + _i = i + 1 | 0; + _b = a + b | 0; + _a = b; + continue; + }; +} + +function fib3(n) { + let a = 1; + let b = 1; + for (let i = 1; i <= n; ++i) { + let tmp = a; + a = b; + b = b + tmp | 0; + } + return a; +} + +export { + fib, + fib2, + fib3, +} +/* No side effect */ diff --git a/tests/tests/src/flattern_order_test.js b/tests/tests/src/flattern_order_test.js deleted file mode 100644 index f89f8bd401..0000000000 --- a/tests/tests/src/flattern_order_test.js +++ /dev/null @@ -1,50 +0,0 @@ -// Generated by ReScript, PLEASE EDIT WITH CARE -'use strict'; - - -function even(_n) { - while (true) { - let n = _n; - if (n === 0) { - return true; - } - _n = n - 1 | 0; - continue; - }; -} - -function even2(n) { - if (n === 0) { - return true; - } else { - let n$1 = n - 1 | 0; - if (n$1 === 1) { - return true; - } else { - return even2(n$1 - 1 | 0); - } - } -} - -let v = { - contents: 0 -}; - -function obj_get() { - return v.contents; -} - -function obj_set(i) { - v.contents = i; -} - -let obj = { - get: obj_get, - set: obj_set -}; - -exports.even = even; -exports.even2 = even2; -exports.v = v; -exports.obj = obj; -/* No side effect */ diff --git a/tests/tests/src/flattern_order_test.mjs b/tests/tests/src/flattern_order_test.mjs new file mode 100644 index 0000000000..bb4d043d55 --- /dev/null +++ b/tests/tests/src/flattern_order_test.mjs @@ -0,0 +1,51 @@ +// Generated by ReScript, PLEASE EDIT WITH CARE + + +function even(_n) { + while (true) { + let n = _n; + if (n === 0) { + return true; + } + _n = n - 1 | 0; + continue; + }; +} + +function even2(n) { + if (n === 0) { + return true; + } else { + let n$1 = n - 1 | 0; + if (n$1 === 1) { + return true; + } else { + return even2(n$1 - 1 | 0); + } + } +} + +let v = { + contents: 0 +}; + +function obj_get() { + return v.contents; +} + +function obj_set(i) { + v.contents = i; +} + +let obj = { + get: obj_get, + set: obj_set +}; + +export { + even, + even2, + v, + obj, +} +/* No side effect */ diff --git a/tests/tests/src/flexible_array_test.js b/tests/tests/src/flexible_array_test.js deleted file mode 100644 index 34b52f9366..0000000000 --- a/tests/tests/src/flexible_array_test.js +++ /dev/null @@ -1,327 +0,0 @@ -// Generated by ReScript, PLEASE EDIT WITH CARE -'use strict'; - -let Belt_Array = require("rescript/lib/js/Belt_Array.js"); -let Pervasives = require("rescript/lib/js/Pervasives.js"); -let Primitive_array = require("rescript/lib/js/Primitive_array.js"); -let Primitive_object = require("rescript/lib/js/Primitive_object.js"); - -function sub(_tr, _k) { - while (true) { - let k = _k; - let tr = _tr; - if (typeof tr !== "object") { - throw { - RE_EXN_ID: "Not_found", - Error: new Error() - }; - } - if (k === 1) { - return tr._0; - } - if (k % 2 === 0) { - _k = k / 2 | 0; - _tr = tr._1; - continue; - } - _k = k / 2 | 0; - _tr = tr._2; - continue; - }; -} - -function update(tr, k, w) { - if (typeof tr !== "object") { - if (k === 1) { - return { - TAG: "Br", - _0: w, - _1: "Lf", - _2: "Lf" - }; - } - throw { - RE_EXN_ID: "Not_found", - Error: new Error() - }; - } - let r = tr._2; - let l = tr._1; - if (k === 1) { - return { - TAG: "Br", - _0: w, - _1: l, - _2: r - }; - } - let v = tr._0; - if (k % 2 === 0) { - return { - TAG: "Br", - _0: v, - _1: update(l, k / 2 | 0, w), - _2: r - }; - } else { - return { - TAG: "Br", - _0: v, - _1: l, - _2: update(r, k / 2 | 0, w) - }; - } -} - -function $$delete(tr, n) { - if (typeof tr !== "object") { - throw { - RE_EXN_ID: "Not_found", - Error: new Error() - }; - } - if (n === 1) { - return "Lf"; - } - let r = tr._2; - let l = tr._1; - let v = tr._0; - if (n % 2 === 0) { - return { - TAG: "Br", - _0: v, - _1: $$delete(l, n / 2 | 0), - _2: r - }; - } else { - return { - TAG: "Br", - _0: v, - _1: l, - _2: $$delete(r, n / 2 | 0) - }; - } -} - -function loext(tr, w) { - if (typeof tr !== "object") { - return { - TAG: "Br", - _0: w, - _1: "Lf", - _2: "Lf" - }; - } else { - return { - TAG: "Br", - _0: w, - _1: loext(tr._2, tr._0), - _2: tr._1 - }; - } -} - -function lorem(tr) { - if (typeof tr !== "object") { - throw { - RE_EXN_ID: "Not_found", - Error: new Error() - }; - } - let l = tr._1; - if (typeof l === "object") { - return { - TAG: "Br", - _0: l._0, - _1: tr._2, - _2: lorem(l) - }; - } - let tmp = tr._2; - if (typeof tmp !== "object") { - return "Lf"; - } - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "flexible_array_test.res", - 82, - 9 - ], - Error: new Error() - }; -} - -let empty = [ - "Lf", - 0 -]; - -function length(param) { - return param[1]; -} - -function get(param, i) { - if (i >= 0 && i < param[1]) { - return sub(param[0], i + 1 | 0); - } else { - return Pervasives.invalid_arg("Array.get"); - } -} - -function set(param, i, v) { - let k = param[1]; - if (i >= 0 && i < k) { - return [ - update(param[0], i + 1 | 0, v), - k - ]; - } else { - return Pervasives.invalid_arg("Array.set"); - } -} - -function push_front(param, v) { - return [ - loext(param[0], v), - param[1] + 1 | 0 - ]; -} - -function pop_front(param) { - let k = param[1]; - if (k > 0) { - return [ - lorem(param[0]), - k - 1 | 0 - ]; - } else { - return Pervasives.invalid_arg("Array.pop_front"); - } -} - -function push_back(param, v) { - let k = param[1]; - return [ - update(param[0], k + 1 | 0, v), - k + 1 | 0 - ]; -} - -function pop_back(param) { - let k = param[1]; - if (k > 0) { - return [ - $$delete(param[0], k), - k - 1 | 0 - ]; - } else { - return Pervasives.invalid_arg("Array.pop_back"); - } -} - -function filter_from(i, p, s) { - let u = empty; - for (let i$1 = i, i_finish = length(s); i$1 < i_finish; ++i$1) { - let ele = get(s, i$1); - if (p(ele)) { - u = push_back(u, ele); - } - - } - return u; -} - -function append(a, b) { - let empty$1 = empty; - for (let i = 0, i_finish = length(a); i < i_finish; ++i) { - empty$1 = push_back(empty$1, get(a, i)); - } - for (let i$1 = 0, i_finish$1 = length(b); i$1 < i_finish$1; ++i$1) { - empty$1 = push_back(empty$1, get(b, i$1)); - } - return empty$1; -} - -function sort(s) { - let size = length(s); - if (size <= 1) { - return s; - } - let head = get(s, 0); - let larger = sort(filter_from(1, x => Primitive_object.greaterthan(x, head), s)); - let smaller = sort(filter_from(1, x => Primitive_object.lessequal(x, head), s)); - return append(smaller, push_front(larger, head)); -} - -function of_array(arr) { - let v = empty; - for (let i = 0, i_finish = arr.length; i < i_finish; ++i) { - v = push_back(v, Primitive_array.get(arr, i)); - } - return v; -} - -let equal = Primitive_object.equal; - -let Int_array = { - empty: empty, - get: get, - set: set, - push_front: push_front, - pop_front: pop_front, - push_back: push_back, - pop_back: pop_back, - append: append, - sort: sort, - of_array: of_array, - equal: equal -}; - -function $eq$tilde(x, y) { - return Primitive_object.equal(x, of_array(y)); -} - -let u = of_array([ - 1, - 2, - 2, - 5, - 3, - 6 -]); - -if (!$eq$tilde(sort(u), [ - 1, - 2, - 2, - 3, - 5, - 6 - ])) { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "flexible_array_test.res", - 186, - 2 - ], - Error: new Error() - }; -} - -let v = Belt_Array.init(500, i => 500 - i | 0); - -$eq$tilde(sort(of_array(v)), Belt_Array.init(500, i => i + 1 | 0)); - -let $$Array; - -exports.$$Array = $$Array; -exports.sub = sub; -exports.update = update; -exports.$$delete = $$delete; -exports.loext = loext; -exports.lorem = lorem; -exports.Int_array = Int_array; -exports.$eq$tilde = $eq$tilde; -/* u Not a pure module */ diff --git a/tests/tests/src/flexible_array_test.mjs b/tests/tests/src/flexible_array_test.mjs new file mode 100644 index 0000000000..3859e57047 --- /dev/null +++ b/tests/tests/src/flexible_array_test.mjs @@ -0,0 +1,328 @@ +// Generated by ReScript, PLEASE EDIT WITH CARE + +import * as Belt_Array from "rescript/lib/es6/Belt_Array.js"; +import * as Pervasives from "rescript/lib/es6/Pervasives.js"; +import * as Primitive_array from "rescript/lib/es6/Primitive_array.js"; +import * as Primitive_object from "rescript/lib/es6/Primitive_object.js"; + +function sub(_tr, _k) { + while (true) { + let k = _k; + let tr = _tr; + if (typeof tr !== "object") { + throw { + RE_EXN_ID: "Not_found", + Error: new Error() + }; + } + if (k === 1) { + return tr._0; + } + if (k % 2 === 0) { + _k = k / 2 | 0; + _tr = tr._1; + continue; + } + _k = k / 2 | 0; + _tr = tr._2; + continue; + }; +} + +function update(tr, k, w) { + if (typeof tr !== "object") { + if (k === 1) { + return { + TAG: "Br", + _0: w, + _1: "Lf", + _2: "Lf" + }; + } + throw { + RE_EXN_ID: "Not_found", + Error: new Error() + }; + } + let r = tr._2; + let l = tr._1; + if (k === 1) { + return { + TAG: "Br", + _0: w, + _1: l, + _2: r + }; + } + let v = tr._0; + if (k % 2 === 0) { + return { + TAG: "Br", + _0: v, + _1: update(l, k / 2 | 0, w), + _2: r + }; + } else { + return { + TAG: "Br", + _0: v, + _1: l, + _2: update(r, k / 2 | 0, w) + }; + } +} + +function $$delete(tr, n) { + if (typeof tr !== "object") { + throw { + RE_EXN_ID: "Not_found", + Error: new Error() + }; + } + if (n === 1) { + return "Lf"; + } + let r = tr._2; + let l = tr._1; + let v = tr._0; + if (n % 2 === 0) { + return { + TAG: "Br", + _0: v, + _1: $$delete(l, n / 2 | 0), + _2: r + }; + } else { + return { + TAG: "Br", + _0: v, + _1: l, + _2: $$delete(r, n / 2 | 0) + }; + } +} + +function loext(tr, w) { + if (typeof tr !== "object") { + return { + TAG: "Br", + _0: w, + _1: "Lf", + _2: "Lf" + }; + } else { + return { + TAG: "Br", + _0: w, + _1: loext(tr._2, tr._0), + _2: tr._1 + }; + } +} + +function lorem(tr) { + if (typeof tr !== "object") { + throw { + RE_EXN_ID: "Not_found", + Error: new Error() + }; + } + let l = tr._1; + if (typeof l === "object") { + return { + TAG: "Br", + _0: l._0, + _1: tr._2, + _2: lorem(l) + }; + } + let tmp = tr._2; + if (typeof tmp !== "object") { + return "Lf"; + } + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "flexible_array_test.res", + 82, + 9 + ], + Error: new Error() + }; +} + +let empty = [ + "Lf", + 0 +]; + +function length(param) { + return param[1]; +} + +function get(param, i) { + if (i >= 0 && i < param[1]) { + return sub(param[0], i + 1 | 0); + } else { + return Pervasives.invalid_arg("Array.get"); + } +} + +function set(param, i, v) { + let k = param[1]; + if (i >= 0 && i < k) { + return [ + update(param[0], i + 1 | 0, v), + k + ]; + } else { + return Pervasives.invalid_arg("Array.set"); + } +} + +function push_front(param, v) { + return [ + loext(param[0], v), + param[1] + 1 | 0 + ]; +} + +function pop_front(param) { + let k = param[1]; + if (k > 0) { + return [ + lorem(param[0]), + k - 1 | 0 + ]; + } else { + return Pervasives.invalid_arg("Array.pop_front"); + } +} + +function push_back(param, v) { + let k = param[1]; + return [ + update(param[0], k + 1 | 0, v), + k + 1 | 0 + ]; +} + +function pop_back(param) { + let k = param[1]; + if (k > 0) { + return [ + $$delete(param[0], k), + k - 1 | 0 + ]; + } else { + return Pervasives.invalid_arg("Array.pop_back"); + } +} + +function filter_from(i, p, s) { + let u = empty; + for (let i$1 = i, i_finish = length(s); i$1 < i_finish; ++i$1) { + let ele = get(s, i$1); + if (p(ele)) { + u = push_back(u, ele); + } + + } + return u; +} + +function append(a, b) { + let empty$1 = empty; + for (let i = 0, i_finish = length(a); i < i_finish; ++i) { + empty$1 = push_back(empty$1, get(a, i)); + } + for (let i$1 = 0, i_finish$1 = length(b); i$1 < i_finish$1; ++i$1) { + empty$1 = push_back(empty$1, get(b, i$1)); + } + return empty$1; +} + +function sort(s) { + let size = length(s); + if (size <= 1) { + return s; + } + let head = get(s, 0); + let larger = sort(filter_from(1, x => Primitive_object.greaterthan(x, head), s)); + let smaller = sort(filter_from(1, x => Primitive_object.lessequal(x, head), s)); + return append(smaller, push_front(larger, head)); +} + +function of_array(arr) { + let v = empty; + for (let i = 0, i_finish = arr.length; i < i_finish; ++i) { + v = push_back(v, Primitive_array.get(arr, i)); + } + return v; +} + +let equal = Primitive_object.equal; + +let Int_array = { + empty: empty, + get: get, + set: set, + push_front: push_front, + pop_front: pop_front, + push_back: push_back, + pop_back: pop_back, + append: append, + sort: sort, + of_array: of_array, + equal: equal +}; + +function $eq$tilde(x, y) { + return Primitive_object.equal(x, of_array(y)); +} + +let u = of_array([ + 1, + 2, + 2, + 5, + 3, + 6 +]); + +if (!$eq$tilde(sort(u), [ + 1, + 2, + 2, + 3, + 5, + 6 + ])) { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "flexible_array_test.res", + 186, + 2 + ], + Error: new Error() + }; +} + +let v = Belt_Array.init(500, i => 500 - i | 0); + +$eq$tilde(sort(of_array(v)), Belt_Array.init(500, i => i + 1 | 0)); + +let $$Array; + +export { + $$Array, + sub, + update, + $$delete, + loext, + lorem, + Int_array, + $eq$tilde, +} +/* u Not a pure module */ diff --git a/tests/tests/src/float_array.js b/tests/tests/src/float_array.js deleted file mode 100644 index 148cd53002..0000000000 --- a/tests/tests/src/float_array.js +++ /dev/null @@ -1,66 +0,0 @@ -// Generated by ReScript, PLEASE EDIT WITH CARE -'use strict'; - - -function small_float_array(x) { - return [ - [ - 1, - 2, - 3 - ], - x - ]; -} - -function longer_float_array(x) { - return [ - [ - 1, - 2, - 3, - 4, - 5, - 6, - 7, - 8, - 9, - 0, - 1, - 2, - 3, - 4, - 5, - 6, - 7, - 8, - 9, - 0, - 1, - 2, - 3, - 4, - 5, - 6, - 7, - 8, - 9, - 0, - 1, - 2, - 3, - 4, - 5, - 6, - 7, - 8, - 9, - 0 - ], - x - ]; -} - -exports.small_float_array = small_float_array; -exports.longer_float_array = longer_float_array; -/* No side effect */ diff --git a/tests/tests/src/float_array.mjs b/tests/tests/src/float_array.mjs new file mode 100644 index 0000000000..48f469b64b --- /dev/null +++ b/tests/tests/src/float_array.mjs @@ -0,0 +1,67 @@ +// Generated by ReScript, PLEASE EDIT WITH CARE + + +function small_float_array(x) { + return [ + [ + 1, + 2, + 3 + ], + x + ]; +} + +function longer_float_array(x) { + return [ + [ + 1, + 2, + 3, + 4, + 5, + 6, + 7, + 8, + 9, + 0, + 1, + 2, + 3, + 4, + 5, + 6, + 7, + 8, + 9, + 0, + 1, + 2, + 3, + 4, + 5, + 6, + 7, + 8, + 9, + 0, + 1, + 2, + 3, + 4, + 5, + 6, + 7, + 8, + 9, + 0 + ], + x + ]; +} + +export { + small_float_array, + longer_float_array, +} +/* No side effect */ diff --git a/tests/tests/src/float_record.js b/tests/tests/src/float_record.js deleted file mode 100644 index 32f9d95d0f..0000000000 --- a/tests/tests/src/float_record.js +++ /dev/null @@ -1,15 +0,0 @@ -// Generated by ReScript, PLEASE EDIT WITH CARE -'use strict'; - - -function make(f) { - return f; -} - -function from(t) { - return t; -} - -exports.make = make; -exports.from = from; -/* No side effect */ diff --git a/tests/tests/src/float_record.mjs b/tests/tests/src/float_record.mjs new file mode 100644 index 0000000000..e67289b6e5 --- /dev/null +++ b/tests/tests/src/float_record.mjs @@ -0,0 +1,16 @@ +// Generated by ReScript, PLEASE EDIT WITH CARE + + +function make(f) { + return f; +} + +function from(t) { + return t; +} + +export { + make, + from, +} +/* No side effect */ diff --git a/tests/tests/src/float_test.js b/tests/tests/src/float_test.js deleted file mode 100644 index ae51edf98f..0000000000 --- a/tests/tests/src/float_test.js +++ /dev/null @@ -1,218 +0,0 @@ -// Generated by ReScript, PLEASE EDIT WITH CARE -'use strict'; - -let Belt_List = require("rescript/lib/js/Belt_List.js"); -let Mt_global = require("./mt_global.js"); -let Belt_Array = require("rescript/lib/js/Belt_Array.js"); -let Pervasives = require("rescript/lib/js/Pervasives.js"); -let Primitive_float = require("rescript/lib/js/Primitive_float.js"); -let Primitive_object = require("rescript/lib/js/Primitive_object.js"); - -let test_id = { - contents: 0 -}; - -let suites = { - contents: /* [] */0 -}; - -function eq(loc, x, y) { - Mt_global.collect_eq(test_id, suites, loc, x, y); -} - -function approx(loc, x, y) { - Mt_global.collect_approx(test_id, suites, loc, x, y); -} - -function from_pairs(ps) { - return Belt_List.fromArray(Belt_Array.mapWithIndex(ps, (i, param) => { - let b = param[1]; - let a = param[0]; - return [ - "pair " + i, - param => ({ - TAG: "Approx", - _0: a, - _1: b - }) - ]; - })); -} - -let float_compare = Primitive_float.compare; - -let generic_compare = Primitive_object.compare; - -function float_equal(x, y) { - return x === y; -} - -let generic_equal = Primitive_object.equal; - -function float_notequal(x, y) { - return x !== y; -} - -let generic_notequal = Primitive_object.notequal; - -function float_lessthan(x, y) { - return x < y; -} - -let generic_lessthan = Primitive_object.lessthan; - -function float_greaterthan(x, y) { - return x > y; -} - -let generic_greaterthan = Primitive_object.greaterthan; - -function float_lessequal(x, y) { - return x <= y; -} - -let generic_lessequal = Primitive_object.lessequal; - -function float_greaterequal(x, y) { - return x >= y; -} - -let generic_greaterequal = Primitive_object.greaterequal; - -eq("File \"float_test.res\", line 28, characters 5-12", Pervasives.classify_float(3), "FP_normal"); - -eq("File \"float_test.res\", line 30, characters 4-11", [ - -1, - 1, - 1 -], Belt_Array.map(Belt_Array.map([ - [ - 1, - 3 - ], - [ - 2, - 1 - ], - [ - 3, - 2 - ] -], param => Primitive_float.compare(param[0], param[1])), x => { - if (x > 0) { - return 1; - } else if (x < 0) { - return -1; - } else { - return 0; - } -})); - -eq("File \"float_test.res\", line 44, characters 5-12", Math.log10(10), 1); - -eq("File \"float_test.res\", line 45, characters 5-12", Number("3.0"), 3.0); - -eq("File \"float_test.res\", line 46, characters 5-12", Primitive_float.compare(NaN, NaN), 0); - -eq("File \"float_test.res\", line 47, characters 5-12", Primitive_object.compare(NaN, NaN), 0); - -eq("File \"float_test.res\", line 48, characters 5-12", Primitive_float.compare(NaN, Pervasives.neg_infinity), -1); - -eq("File \"float_test.res\", line 49, characters 5-12", Primitive_object.compare(NaN, Pervasives.neg_infinity), -1); - -eq("File \"float_test.res\", line 50, characters 5-12", Primitive_float.compare(Pervasives.neg_infinity, NaN), 1); - -eq("File \"float_test.res\", line 51, characters 5-12", Primitive_object.compare(Pervasives.neg_infinity, NaN), 1); - -eq("File \"float_test.res\", line 52, characters 5-12", NaN === NaN, false); - -eq("File \"float_test.res\", line 53, characters 5-12", Primitive_object.equal(NaN, NaN), false); - -eq("File \"float_test.res\", line 54, characters 5-12", 4.2 === NaN, false); - -eq("File \"float_test.res\", line 55, characters 5-12", Primitive_object.equal(4.2, NaN), false); - -eq("File \"float_test.res\", line 56, characters 5-12", NaN === 4.2, false); - -eq("File \"float_test.res\", line 57, characters 5-12", Primitive_object.equal(NaN, 4.2), false); - -eq("File \"float_test.res\", line 58, characters 5-12", NaN !== NaN, true); - -eq("File \"float_test.res\", line 59, characters 5-12", Primitive_object.notequal(NaN, NaN), true); - -eq("File \"float_test.res\", line 60, characters 5-12", 4.2 !== NaN, true); - -eq("File \"float_test.res\", line 61, characters 5-12", Primitive_object.notequal(4.2, NaN), true); - -eq("File \"float_test.res\", line 62, characters 5-12", NaN !== 4.2, true); - -eq("File \"float_test.res\", line 63, characters 5-12", Primitive_object.notequal(NaN, 4.2), true); - -eq("File \"float_test.res\", line 64, characters 5-12", NaN < NaN, false); - -eq("File \"float_test.res\", line 65, characters 5-12", Primitive_object.lessthan(NaN, NaN), false); - -eq("File \"float_test.res\", line 66, characters 5-12", 4.2 < NaN, false); - -eq("File \"float_test.res\", line 67, characters 5-12", Primitive_object.lessthan(4.2, NaN), false); - -eq("File \"float_test.res\", line 68, characters 5-12", NaN < 4.2, false); - -eq("File \"float_test.res\", line 69, characters 5-12", Primitive_object.lessthan(NaN, 4.2), false); - -eq("File \"float_test.res\", line 70, characters 5-12", NaN > NaN, false); - -eq("File \"float_test.res\", line 71, characters 5-12", Primitive_object.greaterthan(NaN, NaN), false); - -eq("File \"float_test.res\", line 72, characters 5-12", 4.2 > NaN, false); - -eq("File \"float_test.res\", line 73, characters 5-12", Primitive_object.greaterthan(4.2, NaN), false); - -eq("File \"float_test.res\", line 74, characters 5-12", NaN > 4.2, false); - -eq("File \"float_test.res\", line 75, characters 5-12", Primitive_object.greaterthan(NaN, 4.2), false); - -eq("File \"float_test.res\", line 76, characters 5-12", NaN <= NaN, false); - -eq("File \"float_test.res\", line 77, characters 5-12", Primitive_object.lessequal(NaN, NaN), false); - -eq("File \"float_test.res\", line 78, characters 5-12", 4.2 <= NaN, false); - -eq("File \"float_test.res\", line 79, characters 5-12", Primitive_object.lessequal(4.2, NaN), false); - -eq("File \"float_test.res\", line 80, characters 5-12", NaN <= 4.2, false); - -eq("File \"float_test.res\", line 81, characters 5-12", Primitive_object.lessequal(NaN, 4.2), false); - -eq("File \"float_test.res\", line 82, characters 5-12", NaN >= NaN, false); - -eq("File \"float_test.res\", line 83, characters 5-12", Primitive_object.greaterequal(NaN, NaN), false); - -eq("File \"float_test.res\", line 84, characters 5-12", 4.2 >= NaN, false); - -eq("File \"float_test.res\", line 85, characters 5-12", Primitive_object.greaterequal(4.2, NaN), false); - -eq("File \"float_test.res\", line 86, characters 5-12", NaN >= 4.2, false); - -eq("File \"float_test.res\", line 87, characters 5-12", Primitive_object.greaterequal(NaN, 4.2), false); - -exports.test_id = test_id; -exports.suites = suites; -exports.eq = eq; -exports.approx = approx; -exports.from_pairs = from_pairs; -exports.float_compare = float_compare; -exports.generic_compare = generic_compare; -exports.float_equal = float_equal; -exports.generic_equal = generic_equal; -exports.float_notequal = float_notequal; -exports.generic_notequal = generic_notequal; -exports.float_lessthan = float_lessthan; -exports.generic_lessthan = generic_lessthan; -exports.float_greaterthan = float_greaterthan; -exports.generic_greaterthan = generic_greaterthan; -exports.float_lessequal = float_lessequal; -exports.generic_lessequal = generic_lessequal; -exports.float_greaterequal = float_greaterequal; -exports.generic_greaterequal = generic_greaterequal; -/* Not a pure module */ diff --git a/tests/tests/src/float_test.mjs b/tests/tests/src/float_test.mjs new file mode 100644 index 0000000000..59943ba5d5 --- /dev/null +++ b/tests/tests/src/float_test.mjs @@ -0,0 +1,219 @@ +// Generated by ReScript, PLEASE EDIT WITH CARE + +import * as Belt_List from "rescript/lib/es6/Belt_List.js"; +import * as Mt_global from "./mt_global.mjs"; +import * as Belt_Array from "rescript/lib/es6/Belt_Array.js"; +import * as Pervasives from "rescript/lib/es6/Pervasives.js"; +import * as Primitive_float from "rescript/lib/es6/Primitive_float.js"; +import * as Primitive_object from "rescript/lib/es6/Primitive_object.js"; + +let test_id = { + contents: 0 +}; + +let suites = { + contents: /* [] */0 +}; + +function eq(loc, x, y) { + Mt_global.collect_eq(test_id, suites, loc, x, y); +} + +function approx(loc, x, y) { + Mt_global.collect_approx(test_id, suites, loc, x, y); +} + +function from_pairs(ps) { + return Belt_List.fromArray(Belt_Array.mapWithIndex(ps, (i, param) => { + let b = param[1]; + let a = param[0]; + return [ + "pair " + i, + param => ({ + TAG: "Approx", + _0: a, + _1: b + }) + ]; + })); +} + +let float_compare = Primitive_float.compare; + +let generic_compare = Primitive_object.compare; + +function float_equal(x, y) { + return x === y; +} + +let generic_equal = Primitive_object.equal; + +function float_notequal(x, y) { + return x !== y; +} + +let generic_notequal = Primitive_object.notequal; + +function float_lessthan(x, y) { + return x < y; +} + +let generic_lessthan = Primitive_object.lessthan; + +function float_greaterthan(x, y) { + return x > y; +} + +let generic_greaterthan = Primitive_object.greaterthan; + +function float_lessequal(x, y) { + return x <= y; +} + +let generic_lessequal = Primitive_object.lessequal; + +function float_greaterequal(x, y) { + return x >= y; +} + +let generic_greaterequal = Primitive_object.greaterequal; + +eq("File \"float_test.res\", line 28, characters 5-12", Pervasives.classify_float(3), "FP_normal"); + +eq("File \"float_test.res\", line 30, characters 4-11", [ + -1, + 1, + 1 +], Belt_Array.map(Belt_Array.map([ + [ + 1, + 3 + ], + [ + 2, + 1 + ], + [ + 3, + 2 + ] +], param => Primitive_float.compare(param[0], param[1])), x => { + if (x > 0) { + return 1; + } else if (x < 0) { + return -1; + } else { + return 0; + } +})); + +eq("File \"float_test.res\", line 44, characters 5-12", Math.log10(10), 1); + +eq("File \"float_test.res\", line 45, characters 5-12", Number("3.0"), 3.0); + +eq("File \"float_test.res\", line 46, characters 5-12", Primitive_float.compare(NaN, NaN), 0); + +eq("File \"float_test.res\", line 47, characters 5-12", Primitive_object.compare(NaN, NaN), 0); + +eq("File \"float_test.res\", line 48, characters 5-12", Primitive_float.compare(NaN, Pervasives.neg_infinity), -1); + +eq("File \"float_test.res\", line 49, characters 5-12", Primitive_object.compare(NaN, Pervasives.neg_infinity), -1); + +eq("File \"float_test.res\", line 50, characters 5-12", Primitive_float.compare(Pervasives.neg_infinity, NaN), 1); + +eq("File \"float_test.res\", line 51, characters 5-12", Primitive_object.compare(Pervasives.neg_infinity, NaN), 1); + +eq("File \"float_test.res\", line 52, characters 5-12", NaN === NaN, false); + +eq("File \"float_test.res\", line 53, characters 5-12", Primitive_object.equal(NaN, NaN), false); + +eq("File \"float_test.res\", line 54, characters 5-12", 4.2 === NaN, false); + +eq("File \"float_test.res\", line 55, characters 5-12", Primitive_object.equal(4.2, NaN), false); + +eq("File \"float_test.res\", line 56, characters 5-12", NaN === 4.2, false); + +eq("File \"float_test.res\", line 57, characters 5-12", Primitive_object.equal(NaN, 4.2), false); + +eq("File \"float_test.res\", line 58, characters 5-12", NaN !== NaN, true); + +eq("File \"float_test.res\", line 59, characters 5-12", Primitive_object.notequal(NaN, NaN), true); + +eq("File \"float_test.res\", line 60, characters 5-12", 4.2 !== NaN, true); + +eq("File \"float_test.res\", line 61, characters 5-12", Primitive_object.notequal(4.2, NaN), true); + +eq("File \"float_test.res\", line 62, characters 5-12", NaN !== 4.2, true); + +eq("File \"float_test.res\", line 63, characters 5-12", Primitive_object.notequal(NaN, 4.2), true); + +eq("File \"float_test.res\", line 64, characters 5-12", NaN < NaN, false); + +eq("File \"float_test.res\", line 65, characters 5-12", Primitive_object.lessthan(NaN, NaN), false); + +eq("File \"float_test.res\", line 66, characters 5-12", 4.2 < NaN, false); + +eq("File \"float_test.res\", line 67, characters 5-12", Primitive_object.lessthan(4.2, NaN), false); + +eq("File \"float_test.res\", line 68, characters 5-12", NaN < 4.2, false); + +eq("File \"float_test.res\", line 69, characters 5-12", Primitive_object.lessthan(NaN, 4.2), false); + +eq("File \"float_test.res\", line 70, characters 5-12", NaN > NaN, false); + +eq("File \"float_test.res\", line 71, characters 5-12", Primitive_object.greaterthan(NaN, NaN), false); + +eq("File \"float_test.res\", line 72, characters 5-12", 4.2 > NaN, false); + +eq("File \"float_test.res\", line 73, characters 5-12", Primitive_object.greaterthan(4.2, NaN), false); + +eq("File \"float_test.res\", line 74, characters 5-12", NaN > 4.2, false); + +eq("File \"float_test.res\", line 75, characters 5-12", Primitive_object.greaterthan(NaN, 4.2), false); + +eq("File \"float_test.res\", line 76, characters 5-12", NaN <= NaN, false); + +eq("File \"float_test.res\", line 77, characters 5-12", Primitive_object.lessequal(NaN, NaN), false); + +eq("File \"float_test.res\", line 78, characters 5-12", 4.2 <= NaN, false); + +eq("File \"float_test.res\", line 79, characters 5-12", Primitive_object.lessequal(4.2, NaN), false); + +eq("File \"float_test.res\", line 80, characters 5-12", NaN <= 4.2, false); + +eq("File \"float_test.res\", line 81, characters 5-12", Primitive_object.lessequal(NaN, 4.2), false); + +eq("File \"float_test.res\", line 82, characters 5-12", NaN >= NaN, false); + +eq("File \"float_test.res\", line 83, characters 5-12", Primitive_object.greaterequal(NaN, NaN), false); + +eq("File \"float_test.res\", line 84, characters 5-12", 4.2 >= NaN, false); + +eq("File \"float_test.res\", line 85, characters 5-12", Primitive_object.greaterequal(4.2, NaN), false); + +eq("File \"float_test.res\", line 86, characters 5-12", NaN >= 4.2, false); + +eq("File \"float_test.res\", line 87, characters 5-12", Primitive_object.greaterequal(NaN, 4.2), false); + +export { + test_id, + suites, + eq, + approx, + from_pairs, + float_compare, + generic_compare, + float_equal, + generic_equal, + float_notequal, + generic_notequal, + float_lessthan, + generic_lessthan, + float_greaterthan, + generic_greaterthan, + float_lessequal, + generic_lessequal, + float_greaterequal, + generic_greaterequal, +} +/* Not a pure module */ diff --git a/tests/tests/src/for_loop_test.js b/tests/tests/src/for_loop_test.js deleted file mode 100644 index 4dfe8ec842..0000000000 --- a/tests/tests/src/for_loop_test.js +++ /dev/null @@ -1,265 +0,0 @@ -// Generated by ReScript, PLEASE EDIT WITH CARE -'use strict'; - -let Belt_List = require("rescript/lib/js/Belt_List.js"); -let Belt_Array = require("rescript/lib/js/Belt_Array.js"); - -function for_3(x) { - let v = { - contents: 0 - }; - let arr = Belt_Array.map(x, param => (() => {})); - for (let i = 0, i_finish = x.length; i < i_finish; ++i) { - let j = (i << 1); - arr[i] = () => { - v.contents = v.contents + j | 0; - }; - } - Belt_Array.forEach(arr, x => x()); - return v.contents; -} - -function for_4(x) { - let v = { - contents: 0 - }; - let arr = Belt_Array.map(x, param => (() => {})); - for (let i = 0, i_finish = x.length; i < i_finish; ++i) { - let j = (i << 1); - let k = (j << 1); - arr[i] = () => { - v.contents = v.contents + k | 0; - }; - } - Belt_Array.forEach(arr, x => x()); - return v.contents; -} - -function for_5(x, u) { - let v = { - contents: 0 - }; - let arr = Belt_Array.map(x, param => (() => {})); - for (let i = 0, i_finish = x.length; i < i_finish; ++i) { - let k = Math.imul((u << 1), u); - arr[i] = () => { - v.contents = v.contents + k | 0; - }; - } - Belt_Array.forEach(arr, x => x()); - return v.contents; -} - -function for_6(x, u) { - let v = { - contents: 0 - }; - let arr = Belt_Array.map(x, param => (() => {})); - let v4 = { - contents: 0 - }; - let v5 = { - contents: 0 - }; - let inspect_3 = -1; - v4.contents = v4.contents + 1 | 0; - for (let j = 0; j <= 1; ++j) { - v5.contents = v5.contents + 1 | 0; - let v2 = { - contents: 0 - }; - for (let i = 0, i_finish = x.length; i < i_finish; ++i) { - let k = Math.imul((u << 1), u); - let h = (v5.contents << 1); - v2.contents = v2.contents + 1 | 0; - arr[i] = () => { - v.contents = (((((v.contents + k | 0) + v2.contents | 0) + v4.contents | 0) + v5.contents | 0) + h | 0) + u | 0; - }; - } - inspect_3 = v2.contents; - } - Belt_Array.forEach(arr, x => x()); - return [ - v.contents, - v4.contents, - v5.contents, - inspect_3 - ]; -} - -function for_7() { - let v = { - contents: 0 - }; - let arr = Belt_Array.make(21, () => {}); - for (let i = 0; i <= 6; ++i) { - for (let j = 0; j <= 2; ++j) { - arr[Math.imul(i, 3) + j | 0] = () => { - v.contents = (v.contents + i | 0) + j | 0; - }; - } - } - Belt_Array.forEach(arr, f => f()); - return v.contents; -} - -function for_8() { - let v = { - contents: 0 - }; - let arr = Belt_Array.make(21, () => {}); - for (let i = 0; i <= 6; ++i) { - let k = (i << 1); - for (let j = 0; j <= 2; ++j) { - let h = i + j | 0; - arr[Math.imul(i, 3) + j | 0] = () => { - v.contents = (((v.contents + i | 0) + j | 0) + h | 0) + k | 0; - }; - } - } - Belt_Array.forEach(arr, f => f()); - return v.contents; -} - -function for_9() { - let v = { - contents: /* [] */0 - }; - let collect = x => { - v.contents = { - hd: x, - tl: v.contents - }; - }; - let vv = { - contents: 0 - }; - let vv2 = { - contents: 0 - }; - let arr = Belt_Array.make(4, () => {}); - let arr2 = Belt_Array.make(2, () => {}); - for (let i = 0; i <= 1; ++i) { - let v$1 = { - contents: 0 - }; - v$1.contents = v$1.contents + i | 0; - for (let j = 0; j <= 1; ++j) { - v$1.contents = v$1.contents + 1 | 0; - collect(v$1.contents); - arr[(i << 1) + j | 0] = () => { - vv.contents = vv.contents + v$1.contents | 0; - }; - } - arr2[i] = () => { - vv2.contents = vv2.contents + v$1.contents | 0; - }; - } - Belt_Array.forEach(arr, f => f()); - Belt_Array.forEach(arr2, f => f()); - return [[ - vv.contents, - Belt_List.toArray(Belt_List.reverse(v.contents)), - vv2.contents - ]]; -} - -let suites_0 = [ - "for_loop_test_3", - param => ({ - TAG: "Eq", - _0: 90, - _1: for_3(Belt_Array.make(10, 2)) - }) -]; - -let suites_1 = { - hd: [ - "for_loop_test_4", - param => ({ - TAG: "Eq", - _0: 180, - _1: for_4(Belt_Array.make(10, 2)) - }) - ], - tl: { - hd: [ - "for_loop_test_5", - param => ({ - TAG: "Eq", - _0: 2420, - _1: for_5(Belt_Array.make(10, 2), 11) - }) - ], - tl: { - hd: [ - "for_loop_test_6", - param => ({ - TAG: "Eq", - _0: [ - 30, - 1, - 2, - 3 - ], - _1: for_6(Belt_Array.make(3, 0), 0) - }) - ], - tl: { - hd: [ - "for_loop_test_7", - param => ({ - TAG: "Eq", - _0: 84, - _1: for_7() - }) - ], - tl: { - hd: [ - "for_loop_test_8", - param => ({ - TAG: "Eq", - _0: 294, - _1: for_8() - }) - ], - tl: { - hd: [ - "for_loop_test_9", - param => ({ - TAG: "Eq", - _0: [[ - 10, - [ - 1, - 2, - 2, - 3 - ], - 5 - ]], - _1: for_9() - }) - ], - tl: /* [] */0 - } - } - } - } - } -}; - -let suites = { - hd: suites_0, - tl: suites_1 -}; - -exports.for_3 = for_3; -exports.for_4 = for_4; -exports.for_5 = for_5; -exports.for_6 = for_6; -exports.for_7 = for_7; -exports.for_8 = for_8; -exports.for_9 = for_9; -exports.suites = suites; -/* No side effect */ diff --git a/tests/tests/src/for_loop_test.mjs b/tests/tests/src/for_loop_test.mjs new file mode 100644 index 0000000000..773daf9f45 --- /dev/null +++ b/tests/tests/src/for_loop_test.mjs @@ -0,0 +1,266 @@ +// Generated by ReScript, PLEASE EDIT WITH CARE + +import * as Belt_List from "rescript/lib/es6/Belt_List.js"; +import * as Belt_Array from "rescript/lib/es6/Belt_Array.js"; + +function for_3(x) { + let v = { + contents: 0 + }; + let arr = Belt_Array.map(x, param => (() => {})); + for (let i = 0, i_finish = x.length; i < i_finish; ++i) { + let j = (i << 1); + arr[i] = () => { + v.contents = v.contents + j | 0; + }; + } + Belt_Array.forEach(arr, x => x()); + return v.contents; +} + +function for_4(x) { + let v = { + contents: 0 + }; + let arr = Belt_Array.map(x, param => (() => {})); + for (let i = 0, i_finish = x.length; i < i_finish; ++i) { + let j = (i << 1); + let k = (j << 1); + arr[i] = () => { + v.contents = v.contents + k | 0; + }; + } + Belt_Array.forEach(arr, x => x()); + return v.contents; +} + +function for_5(x, u) { + let v = { + contents: 0 + }; + let arr = Belt_Array.map(x, param => (() => {})); + for (let i = 0, i_finish = x.length; i < i_finish; ++i) { + let k = Math.imul((u << 1), u); + arr[i] = () => { + v.contents = v.contents + k | 0; + }; + } + Belt_Array.forEach(arr, x => x()); + return v.contents; +} + +function for_6(x, u) { + let v = { + contents: 0 + }; + let arr = Belt_Array.map(x, param => (() => {})); + let v4 = { + contents: 0 + }; + let v5 = { + contents: 0 + }; + let inspect_3 = -1; + v4.contents = v4.contents + 1 | 0; + for (let j = 0; j <= 1; ++j) { + v5.contents = v5.contents + 1 | 0; + let v2 = { + contents: 0 + }; + for (let i = 0, i_finish = x.length; i < i_finish; ++i) { + let k = Math.imul((u << 1), u); + let h = (v5.contents << 1); + v2.contents = v2.contents + 1 | 0; + arr[i] = () => { + v.contents = (((((v.contents + k | 0) + v2.contents | 0) + v4.contents | 0) + v5.contents | 0) + h | 0) + u | 0; + }; + } + inspect_3 = v2.contents; + } + Belt_Array.forEach(arr, x => x()); + return [ + v.contents, + v4.contents, + v5.contents, + inspect_3 + ]; +} + +function for_7() { + let v = { + contents: 0 + }; + let arr = Belt_Array.make(21, () => {}); + for (let i = 0; i <= 6; ++i) { + for (let j = 0; j <= 2; ++j) { + arr[Math.imul(i, 3) + j | 0] = () => { + v.contents = (v.contents + i | 0) + j | 0; + }; + } + } + Belt_Array.forEach(arr, f => f()); + return v.contents; +} + +function for_8() { + let v = { + contents: 0 + }; + let arr = Belt_Array.make(21, () => {}); + for (let i = 0; i <= 6; ++i) { + let k = (i << 1); + for (let j = 0; j <= 2; ++j) { + let h = i + j | 0; + arr[Math.imul(i, 3) + j | 0] = () => { + v.contents = (((v.contents + i | 0) + j | 0) + h | 0) + k | 0; + }; + } + } + Belt_Array.forEach(arr, f => f()); + return v.contents; +} + +function for_9() { + let v = { + contents: /* [] */0 + }; + let collect = x => { + v.contents = { + hd: x, + tl: v.contents + }; + }; + let vv = { + contents: 0 + }; + let vv2 = { + contents: 0 + }; + let arr = Belt_Array.make(4, () => {}); + let arr2 = Belt_Array.make(2, () => {}); + for (let i = 0; i <= 1; ++i) { + let v$1 = { + contents: 0 + }; + v$1.contents = v$1.contents + i | 0; + for (let j = 0; j <= 1; ++j) { + v$1.contents = v$1.contents + 1 | 0; + collect(v$1.contents); + arr[(i << 1) + j | 0] = () => { + vv.contents = vv.contents + v$1.contents | 0; + }; + } + arr2[i] = () => { + vv2.contents = vv2.contents + v$1.contents | 0; + }; + } + Belt_Array.forEach(arr, f => f()); + Belt_Array.forEach(arr2, f => f()); + return [[ + vv.contents, + Belt_List.toArray(Belt_List.reverse(v.contents)), + vv2.contents + ]]; +} + +let suites_0 = [ + "for_loop_test_3", + param => ({ + TAG: "Eq", + _0: 90, + _1: for_3(Belt_Array.make(10, 2)) + }) +]; + +let suites_1 = { + hd: [ + "for_loop_test_4", + param => ({ + TAG: "Eq", + _0: 180, + _1: for_4(Belt_Array.make(10, 2)) + }) + ], + tl: { + hd: [ + "for_loop_test_5", + param => ({ + TAG: "Eq", + _0: 2420, + _1: for_5(Belt_Array.make(10, 2), 11) + }) + ], + tl: { + hd: [ + "for_loop_test_6", + param => ({ + TAG: "Eq", + _0: [ + 30, + 1, + 2, + 3 + ], + _1: for_6(Belt_Array.make(3, 0), 0) + }) + ], + tl: { + hd: [ + "for_loop_test_7", + param => ({ + TAG: "Eq", + _0: 84, + _1: for_7() + }) + ], + tl: { + hd: [ + "for_loop_test_8", + param => ({ + TAG: "Eq", + _0: 294, + _1: for_8() + }) + ], + tl: { + hd: [ + "for_loop_test_9", + param => ({ + TAG: "Eq", + _0: [[ + 10, + [ + 1, + 2, + 2, + 3 + ], + 5 + ]], + _1: for_9() + }) + ], + tl: /* [] */0 + } + } + } + } + } +}; + +let suites = { + hd: suites_0, + tl: suites_1 +}; + +export { + for_3, + for_4, + for_5, + for_6, + for_7, + for_8, + for_9, + suites, +} +/* No side effect */ diff --git a/tests/tests/src/for_side_effect_test.js b/tests/tests/src/for_side_effect_test.js deleted file mode 100644 index 5ad59cf45d..0000000000 --- a/tests/tests/src/for_side_effect_test.js +++ /dev/null @@ -1,41 +0,0 @@ -// Generated by ReScript, PLEASE EDIT WITH CARE -'use strict'; - -let Mt = require("./mt.js"); - -function tst() { - for (let i = (console.log("hi"), 0), i_finish = (console.log("hello"), 3); i <= i_finish; ++i) { - - } -} - -function test2() { - let v = 0; - v = 3; - v = 10; - for (let i = 0; i <= 1; ++i) { - - } - return v; -} - -let suites_0 = [ - "for_order", - param => ({ - TAG: "Eq", - _0: 10, - _1: test2() - }) -]; - -let suites = { - hd: suites_0, - tl: /* [] */0 -}; - -Mt.from_pair_suites("For_side_effect_test", suites); - -exports.tst = tst; -exports.test2 = test2; -exports.suites = suites; -/* Not a pure module */ diff --git a/tests/tests/src/for_side_effect_test.mjs b/tests/tests/src/for_side_effect_test.mjs new file mode 100644 index 0000000000..b6cd3db629 --- /dev/null +++ b/tests/tests/src/for_side_effect_test.mjs @@ -0,0 +1,42 @@ +// Generated by ReScript, PLEASE EDIT WITH CARE + +import * as Mt from "./mt.mjs"; + +function tst() { + for (let i = (console.log("hi"), 0), i_finish = (console.log("hello"), 3); i <= i_finish; ++i) { + + } +} + +function test2() { + let v = 0; + v = 3; + v = 10; + for (let i = 0; i <= 1; ++i) { + + } + return v; +} + +let suites_0 = [ + "for_order", + param => ({ + TAG: "Eq", + _0: 10, + _1: test2() + }) +]; + +let suites = { + hd: suites_0, + tl: /* [] */0 +}; + +Mt.from_pair_suites("For_side_effect_test", suites); + +export { + tst, + test2, + suites, +} +/* Not a pure module */ diff --git a/tests/tests/src/format_regression.js b/tests/tests/src/format_regression.js deleted file mode 100644 index 4f2a36aadf..0000000000 --- a/tests/tests/src/format_regression.js +++ /dev/null @@ -1,76 +0,0 @@ -// Generated by ReScript, PLEASE EDIT WITH CARE -'use strict'; - - -function peek_queue(param) { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "format_regression.res", - 10, - 22 - ], - Error: new Error() - }; -} - -function int_of_size(param) { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "format_regression.res", - 11, - 23 - ], - Error: new Error() - }; -} - -function take_queue(param) { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "format_regression.res", - 12, - 22 - ], - Error: new Error() - }; -} - -function format_pp_token(param, param$1, param$2) { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "format_regression.res", - 13, - 35 - ], - Error: new Error() - }; -} - -function advance_loop(state) { - while (true) { - let match = peek_queue(state.pp_queue); - let size = match.elem_size; - let size$1 = int_of_size(size); - if (size$1 < 0 && (state.pp_right_total - state.pp_left_total | 0) < state.pp_space_left) { - return; - } - take_queue(state.pp_queue); - format_pp_token(state, size$1 < 0 ? 1000000010 : size$1, match.token); - state.pp_left_total = match.length + state.pp_left_total | 0; - continue; - }; -} - -let pp_infinity = 1000000010; - -exports.peek_queue = peek_queue; -exports.int_of_size = int_of_size; -exports.take_queue = take_queue; -exports.format_pp_token = format_pp_token; -exports.pp_infinity = pp_infinity; -exports.advance_loop = advance_loop; -/* No side effect */ diff --git a/tests/tests/src/format_regression.mjs b/tests/tests/src/format_regression.mjs new file mode 100644 index 0000000000..f06f105f26 --- /dev/null +++ b/tests/tests/src/format_regression.mjs @@ -0,0 +1,77 @@ +// Generated by ReScript, PLEASE EDIT WITH CARE + + +function peek_queue(param) { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "format_regression.res", + 10, + 22 + ], + Error: new Error() + }; +} + +function int_of_size(param) { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "format_regression.res", + 11, + 23 + ], + Error: new Error() + }; +} + +function take_queue(param) { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "format_regression.res", + 12, + 22 + ], + Error: new Error() + }; +} + +function format_pp_token(param, param$1, param$2) { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "format_regression.res", + 13, + 35 + ], + Error: new Error() + }; +} + +function advance_loop(state) { + while (true) { + let match = peek_queue(state.pp_queue); + let size = match.elem_size; + let size$1 = int_of_size(size); + if (size$1 < 0 && (state.pp_right_total - state.pp_left_total | 0) < state.pp_space_left) { + return; + } + take_queue(state.pp_queue); + format_pp_token(state, size$1 < 0 ? 1000000010 : size$1, match.token); + state.pp_left_total = match.length + state.pp_left_total | 0; + continue; + }; +} + +let pp_infinity = 1000000010; + +export { + peek_queue, + int_of_size, + take_queue, + format_pp_token, + pp_infinity, + advance_loop, +} +/* No side effect */ diff --git a/tests/tests/src/fun_pattern_match.js b/tests/tests/src/fun_pattern_match.js deleted file mode 100644 index 1759104a45..0000000000 --- a/tests/tests/src/fun_pattern_match.js +++ /dev/null @@ -1,96 +0,0 @@ -// Generated by ReScript, PLEASE EDIT WITH CARE -'use strict'; - -let Primitive_int = require("rescript/lib/js/Primitive_int.js"); - -function f(param, v) { - return ((((param.x0 + param.x1 | 0) + param.x2 | 0) + param.x3 | 0) + param.x4 | 0) + v | 0; -} - -function f2(param, param$1) { - return (((((param.x0 + param.x1 | 0) + param.x2 | 0) + param.x3 | 0) + param.x4 | 0) + param$1.a | 0) + param$1.b | 0; -} - -function f3(param, param$1) { - let lhs = param.rank; - let rhs = param$1.rank; - if (typeof lhs !== "object") { - lhs === "Uninitialized"; - } else { - if (typeof rhs === "object") { - return Primitive_int.compare(lhs._0, rhs._0); - } - rhs === "Uninitialized"; - } - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "fun_pattern_match.res", - 33, - 9 - ], - Error: new Error() - }; -} - -function f4(param, param$1) { - let lhs = param.rank; - let rhs = param$1.rank; - if (typeof lhs !== "object") { - lhs === "Uninitialized"; - } else { - if (typeof rhs === "object") { - return Primitive_int.compare(lhs._0, rhs._0); - } - rhs === "Uninitialized"; - } - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "fun_pattern_match.res", - 39, - 9 - ], - Error: new Error() - }; -} - -let x = { - NAME: "A", - VAL: r -}; - -function r() { - return x; -} - -let match = r(); - -let v = match.VAL(); - -console.log(v); - -function handle_tuple(x, y) { - if (x !== 0) { - if (x === 1 && y === 2) { - return 3; - } - - } else if (y === 1) { - return 2; - } - console.log([ - x, - y - ]); - return x + y | 0; -} - -exports.f = f; -exports.f2 = f2; -exports.f3 = f3; -exports.f4 = f4; -exports.r = r; -exports.v = v; -exports.handle_tuple = handle_tuple; -/* match Not a pure module */ diff --git a/tests/tests/src/fun_pattern_match.mjs b/tests/tests/src/fun_pattern_match.mjs new file mode 100644 index 0000000000..1a175d381d --- /dev/null +++ b/tests/tests/src/fun_pattern_match.mjs @@ -0,0 +1,97 @@ +// Generated by ReScript, PLEASE EDIT WITH CARE + +import * as Primitive_int from "rescript/lib/es6/Primitive_int.js"; + +function f(param, v) { + return ((((param.x0 + param.x1 | 0) + param.x2 | 0) + param.x3 | 0) + param.x4 | 0) + v | 0; +} + +function f2(param, param$1) { + return (((((param.x0 + param.x1 | 0) + param.x2 | 0) + param.x3 | 0) + param.x4 | 0) + param$1.a | 0) + param$1.b | 0; +} + +function f3(param, param$1) { + let lhs = param.rank; + let rhs = param$1.rank; + if (typeof lhs !== "object") { + lhs === "Uninitialized"; + } else { + if (typeof rhs === "object") { + return Primitive_int.compare(lhs._0, rhs._0); + } + rhs === "Uninitialized"; + } + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "fun_pattern_match.res", + 33, + 9 + ], + Error: new Error() + }; +} + +function f4(param, param$1) { + let lhs = param.rank; + let rhs = param$1.rank; + if (typeof lhs !== "object") { + lhs === "Uninitialized"; + } else { + if (typeof rhs === "object") { + return Primitive_int.compare(lhs._0, rhs._0); + } + rhs === "Uninitialized"; + } + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "fun_pattern_match.res", + 39, + 9 + ], + Error: new Error() + }; +} + +let x = { + NAME: "A", + VAL: r +}; + +function r() { + return x; +} + +let match = r(); + +let v = match.VAL(); + +console.log(v); + +function handle_tuple(x, y) { + if (x !== 0) { + if (x === 1 && y === 2) { + return 3; + } + + } else if (y === 1) { + return 2; + } + console.log([ + x, + y + ]); + return x + y | 0; +} + +export { + f, + f2, + f3, + f4, + r, + v, + handle_tuple, +} +/* match Not a pure module */ diff --git a/tests/tests/src/function_directives.js b/tests/tests/src/function_directives.js deleted file mode 100644 index 0899e32f5f..0000000000 --- a/tests/tests/src/function_directives.js +++ /dev/null @@ -1,11 +0,0 @@ -// Generated by ReScript, PLEASE EDIT WITH CARE -'use strict'; - - -function testFnWithDirective(name) { - 'use memo'; - return "Hello " + name; -} - -exports.testFnWithDirective = testFnWithDirective; -/* No side effect */ diff --git a/tests/tests/src/function_directives.mjs b/tests/tests/src/function_directives.mjs new file mode 100644 index 0000000000..c52fde9713 --- /dev/null +++ b/tests/tests/src/function_directives.mjs @@ -0,0 +1,12 @@ +// Generated by ReScript, PLEASE EDIT WITH CARE + + +function testFnWithDirective(name) { + 'use memo'; + return "Hello " + name; +} + +export { + testFnWithDirective, +} +/* No side effect */ diff --git a/tests/tests/src/function_directives_no_inline.js b/tests/tests/src/function_directives_no_inline.js deleted file mode 100644 index 722bb4ca81..0000000000 --- a/tests/tests/src/function_directives_no_inline.js +++ /dev/null @@ -1,14 +0,0 @@ -// Generated by ReScript, PLEASE EDIT WITH CARE -'use strict'; - - -function testFnWithDirective(name) { - 'use server'; - return "Hello " + name; -} - -let x = testFnWithDirective("test"); - -exports.testFnWithDirective = testFnWithDirective; -exports.x = x; -/* x Not a pure module */ diff --git a/tests/tests/src/function_directives_no_inline.mjs b/tests/tests/src/function_directives_no_inline.mjs new file mode 100644 index 0000000000..b75084c2a8 --- /dev/null +++ b/tests/tests/src/function_directives_no_inline.mjs @@ -0,0 +1,15 @@ +// Generated by ReScript, PLEASE EDIT WITH CARE + + +function testFnWithDirective(name) { + 'use server'; + return "Hello " + name; +} + +let x = testFnWithDirective("test"); + +export { + testFnWithDirective, + x, +} +/* x Not a pure module */ diff --git a/tests/tests/src/functor_app_test.js b/tests/tests/src/functor_app_test.js deleted file mode 100644 index f989957a63..0000000000 --- a/tests/tests/src/functor_app_test.js +++ /dev/null @@ -1,51 +0,0 @@ -// Generated by ReScript, PLEASE EDIT WITH CARE -'use strict'; - -let Mt = require("./mt.js"); -let Functor_def = require("./functor_def.js"); -let Functor_inst = require("./functor_inst.js"); - -let suites = { - contents: /* [] */0 -}; - -let test_id = { - contents: 0 -}; - -function eq(loc, x, y) { - test_id.contents = test_id.contents + 1 | 0; - suites.contents = { - hd: [ - loc + (" id " + test_id.contents.toString()), - () => ({ - TAG: "Eq", - _0: x, - _1: y - }) - ], - tl: suites.contents - }; -} - -let Y0 = Functor_def.Make(Functor_inst); - -let Y1 = Functor_def.Make(Functor_inst); - -eq("File \"functor_app_test.res\", line 18, characters 3-10", Y0.h(1, 2), 4); - -eq("File \"functor_app_test.res\", line 19, characters 3-10", Y1.h(2, 3), 6); - -let v = Functor_def.$$return(); - -eq("File \"functor_app_test.res\", line 23, characters 3-10", v, 2); - -Mt.from_pair_suites("Functor_app_test", suites.contents); - -exports.suites = suites; -exports.test_id = test_id; -exports.eq = eq; -exports.Y0 = Y0; -exports.Y1 = Y1; -exports.v = v; -/* Y0 Not a pure module */ diff --git a/tests/tests/src/functor_app_test.mjs b/tests/tests/src/functor_app_test.mjs new file mode 100644 index 0000000000..affd2cd6d4 --- /dev/null +++ b/tests/tests/src/functor_app_test.mjs @@ -0,0 +1,52 @@ +// Generated by ReScript, PLEASE EDIT WITH CARE + +import * as Mt from "./mt.mjs"; +import * as Functor_def from "./functor_def.mjs"; +import * as Functor_inst from "./functor_inst.mjs"; + +let suites = { + contents: /* [] */0 +}; + +let test_id = { + contents: 0 +}; + +function eq(loc, x, y) { + test_id.contents = test_id.contents + 1 | 0; + suites.contents = { + hd: [ + loc + (" id " + test_id.contents.toString()), + () => ({ + TAG: "Eq", + _0: x, + _1: y + }) + ], + tl: suites.contents + }; +} + +let Y0 = Functor_def.Make(Functor_inst); + +let Y1 = Functor_def.Make(Functor_inst); + +eq("File \"functor_app_test.res\", line 18, characters 3-10", Y0.h(1, 2), 4); + +eq("File \"functor_app_test.res\", line 19, characters 3-10", Y1.h(2, 3), 6); + +let v = Functor_def.$$return(); + +eq("File \"functor_app_test.res\", line 23, characters 3-10", v, 2); + +Mt.from_pair_suites("Functor_app_test", suites.contents); + +export { + suites, + test_id, + eq, + Y0, + Y1, + v, +} +/* Y0 Not a pure module */ diff --git a/tests/tests/src/functor_def.js b/tests/tests/src/functor_def.js deleted file mode 100644 index 756262d85a..0000000000 --- a/tests/tests/src/functor_def.js +++ /dev/null @@ -1,32 +0,0 @@ -// Generated by ReScript, PLEASE EDIT WITH CARE -'use strict'; - - -let v = { - contents: 0 -}; - -function f(x, x$1) { - v.contents = v.contents + 1 | 0; - return x$1 + x$1 | 0; -} - -function $$return() { - return v.contents; -} - -function Make(U) { - let h = (x, x$1) => { - console.log(f(x$1, x$1)); - return U.say(x$1, x$1); - }; - return { - h: h - }; -} - -exports.v = v; -exports.f = f; -exports.$$return = $$return; -exports.Make = Make; -/* No side effect */ diff --git a/tests/tests/src/functor_def.mjs b/tests/tests/src/functor_def.mjs new file mode 100644 index 0000000000..87baf8c358 --- /dev/null +++ b/tests/tests/src/functor_def.mjs @@ -0,0 +1,33 @@ +// Generated by ReScript, PLEASE EDIT WITH CARE + + +let v = { + contents: 0 +}; + +function f(x, x$1) { + v.contents = v.contents + 1 | 0; + return x$1 + x$1 | 0; +} + +function $$return() { + return v.contents; +} + +function Make(U) { + let h = (x, x$1) => { + console.log(f(x$1, x$1)); + return U.say(x$1, x$1); + }; + return { + h: h + }; +} + +export { + v, + f, + $$return, + Make, +} +/* No side effect */ diff --git a/tests/tests/src/functor_ffi.js b/tests/tests/src/functor_ffi.js deleted file mode 100644 index 077b43ce90..0000000000 --- a/tests/tests/src/functor_ffi.js +++ /dev/null @@ -1,31 +0,0 @@ -// Generated by ReScript, PLEASE EDIT WITH CARE -'use strict'; - -let Primitive_option = require("rescript/lib/js/Primitive_option.js"); - -function Make(S) { - let opt_get = (f, i) => Primitive_option.fromUndefined(f[i]); - return { - opt_get: opt_get - }; -} - -function opt_get(f, i) { - return Primitive_option.fromUndefined(f[i]); -} - -let Int_arr = { - opt_get: opt_get -}; - -function f(v) { - return [ - v[0], - Primitive_option.fromUndefined(v[1]) - ]; -} - -exports.Make = Make; -exports.Int_arr = Int_arr; -exports.f = f; -/* No side effect */ diff --git a/tests/tests/src/functor_ffi.mjs b/tests/tests/src/functor_ffi.mjs new file mode 100644 index 0000000000..8ea2c8aafe --- /dev/null +++ b/tests/tests/src/functor_ffi.mjs @@ -0,0 +1,32 @@ +// Generated by ReScript, PLEASE EDIT WITH CARE + +import * as Primitive_option from "rescript/lib/es6/Primitive_option.js"; + +function Make(S) { + let opt_get = (f, i) => Primitive_option.fromUndefined(f[i]); + return { + opt_get: opt_get + }; +} + +function opt_get(f, i) { + return Primitive_option.fromUndefined(f[i]); +} + +let Int_arr = { + opt_get: opt_get +}; + +function f(v) { + return [ + v[0], + Primitive_option.fromUndefined(v[1]) + ]; +} + +export { + Make, + Int_arr, + f, +} +/* No side effect */ diff --git a/tests/tests/src/functor_inst.js b/tests/tests/src/functor_inst.js deleted file mode 100644 index 9dcca2304c..0000000000 --- a/tests/tests/src/functor_inst.js +++ /dev/null @@ -1,10 +0,0 @@ -// Generated by ReScript, PLEASE EDIT WITH CARE -'use strict'; - - -function say(x, y) { - return x + y | 0; -} - -exports.say = say; -/* No side effect */ diff --git a/tests/tests/src/functor_inst.mjs b/tests/tests/src/functor_inst.mjs new file mode 100644 index 0000000000..9f6fa2406f --- /dev/null +++ b/tests/tests/src/functor_inst.mjs @@ -0,0 +1,11 @@ +// Generated by ReScript, PLEASE EDIT WITH CARE + + +function say(x, y) { + return x + y | 0; +} + +export { + say, +} +/* No side effect */ diff --git a/tests/tests/src/functors.js b/tests/tests/src/functors.js deleted file mode 100644 index 44b8b1ef0a..0000000000 --- a/tests/tests/src/functors.js +++ /dev/null @@ -1,51 +0,0 @@ -// Generated by ReScript, PLEASE EDIT WITH CARE -'use strict'; - - -function O(X) { - let cow = x => X.foo(x); - let sheep = x => 1 + X.foo(x) | 0; - return { - cow: cow, - sheep: sheep - }; -} - -function F(X, Y) { - let cow = x => Y.foo(X.foo(x)); - let sheep = x => 1 + Y.foo(X.foo(x)) | 0; - return { - cow: cow, - sheep: sheep - }; -} - -function F1(X, Y) { - let sheep = x => 1 + Y.foo(X.foo(x)) | 0; - return { - sheep: sheep - }; -} - -function F2(X, Y) { - let sheep = x => 1 + Y.foo(X.foo(x)) | 0; - return { - sheep: sheep - }; -} - -let M = { - F: (funarg, funarg$1) => { - let sheep = x => 1 + funarg$1.foo(funarg.foo(x)) | 0; - return { - sheep: sheep - }; - } -}; - -exports.O = O; -exports.F = F; -exports.F1 = F1; -exports.F2 = F2; -exports.M = M; -/* No side effect */ diff --git a/tests/tests/src/functors.mjs b/tests/tests/src/functors.mjs new file mode 100644 index 0000000000..3552471b2e --- /dev/null +++ b/tests/tests/src/functors.mjs @@ -0,0 +1,52 @@ +// Generated by ReScript, PLEASE EDIT WITH CARE + + +function O(X) { + let cow = x => X.foo(x); + let sheep = x => 1 + X.foo(x) | 0; + return { + cow: cow, + sheep: sheep + }; +} + +function F(X, Y) { + let cow = x => Y.foo(X.foo(x)); + let sheep = x => 1 + Y.foo(X.foo(x)) | 0; + return { + cow: cow, + sheep: sheep + }; +} + +function F1(X, Y) { + let sheep = x => 1 + Y.foo(X.foo(x)) | 0; + return { + sheep: sheep + }; +} + +function F2(X, Y) { + let sheep = x => 1 + Y.foo(X.foo(x)) | 0; + return { + sheep: sheep + }; +} + +let M = { + F: (funarg, funarg$1) => { + let sheep = x => 1 + funarg$1.foo(funarg.foo(x)) | 0; + return { + sheep: sheep + }; + } +}; + +export { + O, + F, + F1, + F2, + M, +} +/* No side effect */ diff --git a/tests/tests/src/gbk.js b/tests/tests/src/gbk.js deleted file mode 100644 index 431b05718e..0000000000 --- a/tests/tests/src/gbk.js +++ /dev/null @@ -1,15 +0,0 @@ -// Generated by ReScript, PLEASE EDIT WITH CARE -'use strict'; - - -console.log("你好"); - -console.log("你好"); - -console.log("你好"); - -console.log("你好你好"); - -console.log("\\u4f60\\u597d"); - -/* Not a pure module */ diff --git a/tests/tests/src/gbk.mjs b/tests/tests/src/gbk.mjs new file mode 100644 index 0000000000..4713069ee1 --- /dev/null +++ b/tests/tests/src/gbk.mjs @@ -0,0 +1,14 @@ +// Generated by ReScript, PLEASE EDIT WITH CARE + + +console.log("你好"); + +console.log("你好"); + +console.log("你好"); + +console.log("你好你好"); + +console.log("\\u4f60\\u597d"); + +/* Not a pure module */ diff --git a/tests/tests/src/gentTypeReTest.js b/tests/tests/src/gentTypeReTest.js deleted file mode 100644 index 7f7b74c9d4..0000000000 --- a/tests/tests/src/gentTypeReTest.js +++ /dev/null @@ -1,11 +0,0 @@ -// Generated by ReScript, PLEASE EDIT WITH CARE -'use strict'; - -let GentTypeReTestGen = require("./gentTypeReTest.gen"); - -function f(prim) { - return GentTypeReTestGen.f(prim); -} - -exports.f = f; -/* ./gentTypeReTest.gen Not a pure module */ diff --git a/tests/tests/src/gentTypeReTest.mjs b/tests/tests/src/gentTypeReTest.mjs new file mode 100644 index 0000000000..6238d3ae03 --- /dev/null +++ b/tests/tests/src/gentTypeReTest.mjs @@ -0,0 +1,12 @@ +// Generated by ReScript, PLEASE EDIT WITH CARE + +import * as GentTypeReTestGen from "./gentTypeReTest.gen"; + +function f(prim) { + return GentTypeReTestGen.f(prim); +} + +export { + f, +} +/* ./gentTypeReTest.gen Not a pure module */ diff --git a/tests/tests/src/glob_test_add.js b/tests/tests/src/glob_test_add.js deleted file mode 100644 index 236426944d..0000000000 --- a/tests/tests/src/glob_test_add.js +++ /dev/null @@ -1,10 +0,0 @@ -// Generated by ReScript, PLEASE EDIT WITH CARE -'use strict'; - - -function add(x, y) { - return x + y | 0; -} - -exports.add = add; -/* No side effect */ diff --git a/tests/tests/src/glob_test_add.mjs b/tests/tests/src/glob_test_add.mjs new file mode 100644 index 0000000000..6411d2fe35 --- /dev/null +++ b/tests/tests/src/glob_test_add.mjs @@ -0,0 +1,11 @@ +// Generated by ReScript, PLEASE EDIT WITH CARE + + +function add(x, y) { + return x + y | 0; +} + +export { + add, +} +/* No side effect */ diff --git a/tests/tests/src/glob_test_u.js b/tests/tests/src/glob_test_u.js deleted file mode 100644 index 7fe7ff01f9..0000000000 --- a/tests/tests/src/glob_test_u.js +++ /dev/null @@ -1,9 +0,0 @@ -// Generated by ReScript, PLEASE EDIT WITH CARE -'use strict'; - -let Glob_u = require("./glob_u.js"); - -let v = Glob_u.v; - -exports.v = v; -/* No side effect */ diff --git a/tests/tests/src/glob_test_u.mjs b/tests/tests/src/glob_test_u.mjs new file mode 100644 index 0000000000..d10ba715a1 --- /dev/null +++ b/tests/tests/src/glob_test_u.mjs @@ -0,0 +1,10 @@ +// Generated by ReScript, PLEASE EDIT WITH CARE + +import * as Glob_u from "./glob_u.mjs"; + +let v = Glob_u.v; + +export { + v, +} +/* No side effect */ diff --git a/tests/tests/src/glob_u.js b/tests/tests/src/glob_u.js deleted file mode 100644 index e49a9a2be3..0000000000 --- a/tests/tests/src/glob_u.js +++ /dev/null @@ -1,8 +0,0 @@ -// Generated by ReScript, PLEASE EDIT WITH CARE -'use strict'; - - -let v = 3; - -exports.v = v; -/* No side effect */ diff --git a/tests/tests/src/glob_u.mjs b/tests/tests/src/glob_u.mjs new file mode 100644 index 0000000000..cf0b79fe71 --- /dev/null +++ b/tests/tests/src/glob_u.mjs @@ -0,0 +1,9 @@ +// Generated by ReScript, PLEASE EDIT WITH CARE + + +let v = 3; + +export { + v, +} +/* No side effect */ diff --git a/tests/tests/src/glob_x.js b/tests/tests/src/glob_x.js deleted file mode 100644 index 8e4cf0d74c..0000000000 --- a/tests/tests/src/glob_x.js +++ /dev/null @@ -1,8 +0,0 @@ -// Generated by ReScript, PLEASE EDIT WITH CARE -'use strict'; - - -let v = 32; - -exports.v = v; -/* No side effect */ diff --git a/tests/tests/src/glob_x.mjs b/tests/tests/src/glob_x.mjs new file mode 100644 index 0000000000..6bf5005a51 --- /dev/null +++ b/tests/tests/src/glob_x.mjs @@ -0,0 +1,9 @@ +// Generated by ReScript, PLEASE EDIT WITH CARE + + +let v = 32; + +export { + v, +} +/* No side effect */ diff --git a/tests/tests/src/global_exception_regression_test.js b/tests/tests/src/global_exception_regression_test.js deleted file mode 100644 index a659c2d3fb..0000000000 --- a/tests/tests/src/global_exception_regression_test.js +++ /dev/null @@ -1,50 +0,0 @@ -// Generated by ReScript, PLEASE EDIT WITH CARE -'use strict'; - -let Mt = require("./mt.js"); - -let v = { - RE_EXN_ID: "Not_found" -}; - -let u = { - RE_EXN_ID: "Not_found" -}; - -let s = { - RE_EXN_ID: "End_of_file" -}; - -let suites_0 = [ - "not_found_equal", - param => ({ - TAG: "Eq", - _0: u, - _1: v - }) -]; - -let suites_1 = { - hd: [ - "not_found_not_equal_end_of_file", - param => ({ - TAG: "Neq", - _0: u, - _1: s - }) - ], - tl: /* [] */0 -}; - -let suites = { - hd: suites_0, - tl: suites_1 -}; - -Mt.from_pair_suites("Global_exception_regression_test", suites); - -exports.v = v; -exports.u = u; -exports.s = s; -exports.suites = suites; -/* Not a pure module */ diff --git a/tests/tests/src/global_exception_regression_test.mjs b/tests/tests/src/global_exception_regression_test.mjs new file mode 100644 index 0000000000..13326c86f5 --- /dev/null +++ b/tests/tests/src/global_exception_regression_test.mjs @@ -0,0 +1,51 @@ +// Generated by ReScript, PLEASE EDIT WITH CARE + +import * as Mt from "./mt.mjs"; + +let v = { + RE_EXN_ID: "Not_found" +}; + +let u = { + RE_EXN_ID: "Not_found" +}; + +let s = { + RE_EXN_ID: "End_of_file" +}; + +let suites_0 = [ + "not_found_equal", + param => ({ + TAG: "Eq", + _0: u, + _1: v + }) +]; + +let suites_1 = { + hd: [ + "not_found_not_equal_end_of_file", + param => ({ + TAG: "Neq", + _0: u, + _1: s + }) + ], + tl: /* [] */0 +}; + +let suites = { + hd: suites_0, + tl: suites_1 +}; + +Mt.from_pair_suites("Global_exception_regression_test", suites); + +export { + v, + u, + s, + suites, +} +/* Not a pure module */ diff --git a/tests/tests/src/global_mangles.js b/tests/tests/src/global_mangles.js deleted file mode 100644 index 134806694a..0000000000 --- a/tests/tests/src/global_mangles.js +++ /dev/null @@ -1,17 +0,0 @@ -// Generated by ReScript, PLEASE EDIT WITH CARE -'use strict'; - - -let $$__dirname = 1; - -let $$__filename = 2; - -let $$exports = 3; - -let $$require = 4; - -exports.$$__dirname = $$__dirname; -exports.$$__filename = $$__filename; -exports.$$exports = $$exports; -exports.$$require = $$require; -/* No side effect */ diff --git a/tests/tests/src/global_mangles.mjs b/tests/tests/src/global_mangles.mjs new file mode 100644 index 0000000000..e507b65f58 --- /dev/null +++ b/tests/tests/src/global_mangles.mjs @@ -0,0 +1,18 @@ +// Generated by ReScript, PLEASE EDIT WITH CARE + + +let $$__dirname = 1; + +let $$__filename = 2; + +let $$exports = 3; + +let $$require = 4; + +export { + $$__dirname, + $$__filename, + $$exports, + $$require, +} +/* No side effect */ diff --git a/tests/tests/src/global_module_alias_test.js b/tests/tests/src/global_module_alias_test.js deleted file mode 100644 index 59ea350887..0000000000 --- a/tests/tests/src/global_module_alias_test.js +++ /dev/null @@ -1,168 +0,0 @@ -// Generated by ReScript, PLEASE EDIT WITH CARE -'use strict'; - -let Mt = require("./mt.js"); -let Belt_List = require("rescript/lib/js/Belt_List.js"); - -let suites = { - contents: /* [] */0 -}; - -let test_id = { - contents: 0 -}; - -function eq(loc, x, y) { - test_id.contents = test_id.contents + 1 | 0; - suites.contents = { - hd: [ - loc + (" id " + test_id.contents.toString()), - () => ({ - TAG: "Eq", - _0: x, - _1: y - }) - ], - tl: suites.contents - }; -} - -let v = { - contents: 0 -}; - -function Make(U) { - v.contents = v.contents + 1 | 0; - v.contents = v.contents + 1 | 0; - v.contents = v.contents + 1 | 0; - return U; -} - -function f() { - v.contents = v.contents + 1 | 0; - v.contents = v.contents + 1 | 0; - v.contents = v.contents + 1 | 0; - v.contents = v.contents + 1 | 0; - v.contents = v.contents + 1 | 0; - v.contents = v.contents + 1 | 0; - return Belt_List; -} - -eq("File \"global_module_alias_test.res\", line 53, characters 12-19", Belt_List.length({ - hd: 1, - tl: { - hd: 2, - tl: /* [] */0 - } -}), 2); - -v.contents = v.contents + 1 | 0; - -v.contents = v.contents + 1 | 0; - -v.contents = v.contents + 1 | 0; - -v.contents = v.contents + 1 | 0; - -v.contents = v.contents + 1 | 0; - -v.contents = v.contents + 1 | 0; - -v.contents = v.contents + 1 | 0; - -v.contents = v.contents + 1 | 0; - -v.contents = v.contents + 1 | 0; - -v.contents = v.contents + 1 | 0; - -v.contents = v.contents + 1 | 0; - -v.contents = v.contents + 1 | 0; - -let H = Belt_List; - -eq("File \"global_module_alias_test.res\", line 57, characters 12-19", v.contents, 12); - -function g() { - return Belt_List.length({ - hd: 1, - tl: { - hd: 2, - tl: { - hd: 3, - tl: { - hd: 4, - tl: /* [] */0 - } - } - } - }); -} - -function xx() { - v.contents = v.contents + 1 | 0; - v.contents = v.contents + 1 | 0; - v.contents = v.contents + 1 | 0; - return Belt_List; -} - -eq("File \"global_module_alias_test.res\", line 85, characters 12-19", g(), 4); - -let V = xx(); - -eq("File \"global_module_alias_test.res\", line 89, characters 5-12", V.length({ - hd: 1, - tl: { - hd: 2, - tl: { - hd: 3, - tl: /* [] */0 - } - } -}), 3); - -eq("File \"global_module_alias_test.res\", line 90, characters 5-12", v.contents, 15); - -let H$1 = f(); - -eq("File \"global_module_alias_test.res\", line 92, characters 5-12", H$1.length({ - hd: 1, - tl: { - hd: 2, - tl: /* [] */0 - } -}), 2); - -eq("File \"global_module_alias_test.res\", line 93, characters 5-12", v.contents, 21); - -Mt.from_pair_suites("Global_module_alias_test", suites.contents); - -let A; - -let B; - -let C; - -let D; - -let E; - -let F; - -exports.suites = suites; -exports.test_id = test_id; -exports.eq = eq; -exports.A = A; -exports.B = B; -exports.C = C; -exports.D = D; -exports.E = E; -exports.F = F; -exports.v = v; -exports.Make = Make; -exports.f = f; -exports.H = H; -exports.g = g; -exports.xx = xx; -/* Not a pure module */ diff --git a/tests/tests/src/global_module_alias_test.mjs b/tests/tests/src/global_module_alias_test.mjs new file mode 100644 index 0000000000..8e04b8914c --- /dev/null +++ b/tests/tests/src/global_module_alias_test.mjs @@ -0,0 +1,169 @@ +// Generated by ReScript, PLEASE EDIT WITH CARE + +import * as Mt from "./mt.mjs"; +import * as Belt_List from "rescript/lib/es6/Belt_List.js"; + +let suites = { + contents: /* [] */0 +}; + +let test_id = { + contents: 0 +}; + +function eq(loc, x, y) { + test_id.contents = test_id.contents + 1 | 0; + suites.contents = { + hd: [ + loc + (" id " + test_id.contents.toString()), + () => ({ + TAG: "Eq", + _0: x, + _1: y + }) + ], + tl: suites.contents + }; +} + +let v = { + contents: 0 +}; + +function Make(U) { + v.contents = v.contents + 1 | 0; + v.contents = v.contents + 1 | 0; + v.contents = v.contents + 1 | 0; + return U; +} + +function f() { + v.contents = v.contents + 1 | 0; + v.contents = v.contents + 1 | 0; + v.contents = v.contents + 1 | 0; + v.contents = v.contents + 1 | 0; + v.contents = v.contents + 1 | 0; + v.contents = v.contents + 1 | 0; + return Belt_List; +} + +eq("File \"global_module_alias_test.res\", line 53, characters 12-19", Belt_List.length({ + hd: 1, + tl: { + hd: 2, + tl: /* [] */0 + } +}), 2); + +v.contents = v.contents + 1 | 0; + +v.contents = v.contents + 1 | 0; + +v.contents = v.contents + 1 | 0; + +v.contents = v.contents + 1 | 0; + +v.contents = v.contents + 1 | 0; + +v.contents = v.contents + 1 | 0; + +v.contents = v.contents + 1 | 0; + +v.contents = v.contents + 1 | 0; + +v.contents = v.contents + 1 | 0; + +v.contents = v.contents + 1 | 0; + +v.contents = v.contents + 1 | 0; + +v.contents = v.contents + 1 | 0; + +let H = Belt_List; + +eq("File \"global_module_alias_test.res\", line 57, characters 12-19", v.contents, 12); + +function g() { + return Belt_List.length({ + hd: 1, + tl: { + hd: 2, + tl: { + hd: 3, + tl: { + hd: 4, + tl: /* [] */0 + } + } + } + }); +} + +function xx() { + v.contents = v.contents + 1 | 0; + v.contents = v.contents + 1 | 0; + v.contents = v.contents + 1 | 0; + return Belt_List; +} + +eq("File \"global_module_alias_test.res\", line 85, characters 12-19", g(), 4); + +let V = xx(); + +eq("File \"global_module_alias_test.res\", line 89, characters 5-12", V.length({ + hd: 1, + tl: { + hd: 2, + tl: { + hd: 3, + tl: /* [] */0 + } + } +}), 3); + +eq("File \"global_module_alias_test.res\", line 90, characters 5-12", v.contents, 15); + +let H$1 = f(); + +eq("File \"global_module_alias_test.res\", line 92, characters 5-12", H$1.length({ + hd: 1, + tl: { + hd: 2, + tl: /* [] */0 + } +}), 2); + +eq("File \"global_module_alias_test.res\", line 93, characters 5-12", v.contents, 21); + +Mt.from_pair_suites("Global_module_alias_test", suites.contents); + +let A; + +let B; + +let C; + +let D; + +let E; + +let F; + +export { + suites, + test_id, + eq, + A, + B, + C, + D, + E, + F, + v, + Make, + f, + H, + g, + xx, +} +/* Not a pure module */ diff --git a/tests/tests/src/google_closure_test.js b/tests/tests/src/google_closure_test.js deleted file mode 100644 index 2e9cbe212d..0000000000 --- a/tests/tests/src/google_closure_test.js +++ /dev/null @@ -1,30 +0,0 @@ -// Generated by ReScript, PLEASE EDIT WITH CARE -'use strict'; - -let Mt = require("./mt.js"); -let Test_google_closure = require("./test_google_closure.js"); - -Mt.from_pair_suites("Closure", { - hd: [ - "partial", - () => ({ - TAG: "Eq", - _0: [ - Test_google_closure.a, - Test_google_closure.b, - Test_google_closure.c - ], - _1: [ - "3", - 101, - [ - 1, - 2 - ] - ] - }) - ], - tl: /* [] */0 -}); - -/* Not a pure module */ diff --git a/tests/tests/src/google_closure_test.mjs b/tests/tests/src/google_closure_test.mjs new file mode 100644 index 0000000000..0b7b69a2f5 --- /dev/null +++ b/tests/tests/src/google_closure_test.mjs @@ -0,0 +1,29 @@ +// Generated by ReScript, PLEASE EDIT WITH CARE + +import * as Mt from "./mt.mjs"; +import * as Test_google_closure from "./test_google_closure.mjs"; + +Mt.from_pair_suites("Closure", { + hd: [ + "partial", + () => ({ + TAG: "Eq", + _0: [ + Test_google_closure.a, + Test_google_closure.b, + Test_google_closure.c + ], + _1: [ + "3", + 101, + [ + 1, + 2 + ] + ] + }) + ], + tl: /* [] */0 +}); + +/* Not a pure module */ diff --git a/tests/tests/src/gpr496_test.js b/tests/tests/src/gpr496_test.js deleted file mode 100644 index ad6cc10094..0000000000 --- a/tests/tests/src/gpr496_test.js +++ /dev/null @@ -1,82 +0,0 @@ -// Generated by ReScript, PLEASE EDIT WITH CARE -'use strict'; - -let Mt = require("./mt.js"); -let Primitive_bool = require("rescript/lib/js/Primitive_bool.js"); - -let suites = { - contents: /* [] */0 -}; - -let test_id = { - contents: 0 -}; - -function eq(loc, x, y) { - test_id.contents = test_id.contents + 1 | 0; - suites.contents = { - hd: [ - loc + (" id " + test_id.contents.toString()), - () => ({ - TAG: "Eq", - _0: x, - _1: y - }) - ], - tl: suites.contents - }; -} - -let expected = [ - false, - false, - true, - true, - -1, - 1, - 0, - 0 -]; - -let expected2 = [ - false, - false, - true, - true, - -1, - 1, - 0, - 0 -]; - -let u = [ - false, - false, - true, - true, - -1, - 1, - 0, - 0 -]; - -eq("File \"gpr496_test.res\", line 35, characters 12-19", expected, u); - -eq("File \"gpr496_test.res\", line 37, characters 12-19", expected, expected2); - -function ff(x, y) { - return Primitive_bool.min(x, y()); -} - -eq("File \"gpr496_test.res\", line 40, characters 12-19", true < false ? true : false, false); - -Mt.from_pair_suites("Gpr496_test", suites.contents); - -exports.suites = suites; -exports.test_id = test_id; -exports.eq = eq; -exports.expected = expected; -exports.expected2 = expected2; -exports.u = u; -exports.ff = ff; -/* Not a pure module */ diff --git a/tests/tests/src/gpr496_test.mjs b/tests/tests/src/gpr496_test.mjs new file mode 100644 index 0000000000..99190d9362 --- /dev/null +++ b/tests/tests/src/gpr496_test.mjs @@ -0,0 +1,83 @@ +// Generated by ReScript, PLEASE EDIT WITH CARE + +import * as Mt from "./mt.mjs"; +import * as Primitive_bool from "rescript/lib/es6/Primitive_bool.js"; + +let suites = { + contents: /* [] */0 +}; + +let test_id = { + contents: 0 +}; + +function eq(loc, x, y) { + test_id.contents = test_id.contents + 1 | 0; + suites.contents = { + hd: [ + loc + (" id " + test_id.contents.toString()), + () => ({ + TAG: "Eq", + _0: x, + _1: y + }) + ], + tl: suites.contents + }; +} + +let expected = [ + false, + false, + true, + true, + -1, + 1, + 0, + 0 +]; + +let expected2 = [ + false, + false, + true, + true, + -1, + 1, + 0, + 0 +]; + +let u = [ + false, + false, + true, + true, + -1, + 1, + 0, + 0 +]; + +eq("File \"gpr496_test.res\", line 35, characters 12-19", expected, u); + +eq("File \"gpr496_test.res\", line 37, characters 12-19", expected, expected2); + +function ff(x, y) { + return Primitive_bool.min(x, y()); +} + +eq("File \"gpr496_test.res\", line 40, characters 12-19", true < false ? true : false, false); + +Mt.from_pair_suites("Gpr496_test", suites.contents); + +export { + suites, + test_id, + eq, + expected, + expected2, + u, + ff, +} +/* Not a pure module */ diff --git a/tests/tests/src/gpr_1072.js b/tests/tests/src/gpr_1072.js deleted file mode 100644 index 5331e079e6..0000000000 --- a/tests/tests/src/gpr_1072.js +++ /dev/null @@ -1,192 +0,0 @@ -// Generated by ReScript, PLEASE EDIT WITH CARE -'use strict'; - - -let u = { - y: 3 -}; - -let v_ice_cream3_0 = { - flavor: "vanilla", - num: 3 -}; - -let v_ice_cream3_1 = { - hd: { - flavor: "x", - num: 3 - }, - tl: { - hd: { - flavor: "vanilla", - num: 3 - }, - tl: /* [] */0 - } -}; - -let v_ice_cream3 = { - hd: v_ice_cream3_0, - tl: v_ice_cream3_1 -}; - -let v_ice_cream4_0 = { - flavor: "vanilla", - num: 3 -}; - -let v_ice_cream4_1 = { - hd: { - flavor: "x", - num: 3 - }, - tl: /* [] */0 -}; - -let v_ice_cream4 = { - hd: v_ice_cream4_0, - tl: v_ice_cream4_1 -}; - -let vv = { - x__ignore: 3 -}; - -let int_expect = { - x__ignore: 0 -}; - -let int_expect2 = { - x__ignore: 0 -}; - -let int_expects_0 = {}; - -let int_expects_1 = { - hd: { - x__ignore: 2 - }, - tl: { - hd: { - x__ignore: 3 - }, - tl: /* [] */0 - } -}; - -let int_expects = { - hd: int_expects_0, - tl: int_expects_1 -}; - -let mk_ice = { - flavour: "vanilla", - num: 3 -}; - -let my_ice2 = { - flavour: "vanilla", - num: 1 -}; - -let my_ice3 = { - num: 2 -}; - -let v_mk4 = { - y: 3 -}; - -let v_mk5 = { - x: undefined, - y: 3 -}; - -let v_mk6 = { - y: 3 -}; - -let v_mk6_1 = { - x: undefined, - y: 3 -}; - -let mk_u = { - x__ignore: 0 -}; - -let v_mk7_0 = { - y: 3 -}; - -let v_mk7_1 = { - hd: { - y: 2 - }, - tl: { - hd: { - y: 2 - }, - tl: /* [] */0 - } -}; - -let v_mk7 = { - hd: v_mk7_0, - tl: v_mk7_1 -}; - -again("a", 3); - -again(undefined, 3); - -again(undefined, 3); - -again(undefined, 3); - -again2("a", 3); - -again3(3); - -again3(2); - -let side_effect = { - contents: 0 -}; - -again4(undefined, undefined, 141); - -again4(undefined, undefined, 142); - -again4(undefined, undefined, 143); - -again4(undefined, undefined, 144); - -again4(undefined, undefined, 145); - -again4((side_effect.contents = side_effect.contents + 1 | 0, undefined), undefined, 152); - -again4((side_effect.contents = side_effect.contents + 1 | 0, undefined), (side_effect.contents = side_effect.contents - 1 | 0, undefined), 164); - -again4(undefined, (side_effect.contents = side_effect.contents - 1 | 0, undefined), 172); - -again4((side_effect.contents = side_effect.contents + 1 | 0, undefined), undefined, 175); - -exports.u = u; -exports.v_ice_cream3 = v_ice_cream3; -exports.v_ice_cream4 = v_ice_cream4; -exports.vv = vv; -exports.int_expect = int_expect; -exports.int_expect2 = int_expect2; -exports.int_expects = int_expects; -exports.mk_ice = mk_ice; -exports.my_ice2 = my_ice2; -exports.my_ice3 = my_ice3; -exports.v_mk4 = v_mk4; -exports.v_mk5 = v_mk5; -exports.v_mk6 = v_mk6; -exports.v_mk6_1 = v_mk6_1; -exports.mk_u = mk_u; -exports.v_mk7 = v_mk7; -exports.side_effect = side_effect; -/* Not a pure module */ diff --git a/tests/tests/src/gpr_1072.mjs b/tests/tests/src/gpr_1072.mjs new file mode 100644 index 0000000000..eb64957172 --- /dev/null +++ b/tests/tests/src/gpr_1072.mjs @@ -0,0 +1,193 @@ +// Generated by ReScript, PLEASE EDIT WITH CARE + + +let u = { + y: 3 +}; + +let v_ice_cream3_0 = { + flavor: "vanilla", + num: 3 +}; + +let v_ice_cream3_1 = { + hd: { + flavor: "x", + num: 3 + }, + tl: { + hd: { + flavor: "vanilla", + num: 3 + }, + tl: /* [] */0 + } +}; + +let v_ice_cream3 = { + hd: v_ice_cream3_0, + tl: v_ice_cream3_1 +}; + +let v_ice_cream4_0 = { + flavor: "vanilla", + num: 3 +}; + +let v_ice_cream4_1 = { + hd: { + flavor: "x", + num: 3 + }, + tl: /* [] */0 +}; + +let v_ice_cream4 = { + hd: v_ice_cream4_0, + tl: v_ice_cream4_1 +}; + +let vv = { + x__ignore: 3 +}; + +let int_expect = { + x__ignore: 0 +}; + +let int_expect2 = { + x__ignore: 0 +}; + +let int_expects_0 = {}; + +let int_expects_1 = { + hd: { + x__ignore: 2 + }, + tl: { + hd: { + x__ignore: 3 + }, + tl: /* [] */0 + } +}; + +let int_expects = { + hd: int_expects_0, + tl: int_expects_1 +}; + +let mk_ice = { + flavour: "vanilla", + num: 3 +}; + +let my_ice2 = { + flavour: "vanilla", + num: 1 +}; + +let my_ice3 = { + num: 2 +}; + +let v_mk4 = { + y: 3 +}; + +let v_mk5 = { + x: undefined, + y: 3 +}; + +let v_mk6 = { + y: 3 +}; + +let v_mk6_1 = { + x: undefined, + y: 3 +}; + +let mk_u = { + x__ignore: 0 +}; + +let v_mk7_0 = { + y: 3 +}; + +let v_mk7_1 = { + hd: { + y: 2 + }, + tl: { + hd: { + y: 2 + }, + tl: /* [] */0 + } +}; + +let v_mk7 = { + hd: v_mk7_0, + tl: v_mk7_1 +}; + +again("a", 3); + +again(undefined, 3); + +again(undefined, 3); + +again(undefined, 3); + +again2("a", 3); + +again3(3); + +again3(2); + +let side_effect = { + contents: 0 +}; + +again4(undefined, undefined, 141); + +again4(undefined, undefined, 142); + +again4(undefined, undefined, 143); + +again4(undefined, undefined, 144); + +again4(undefined, undefined, 145); + +again4((side_effect.contents = side_effect.contents + 1 | 0, undefined), undefined, 152); + +again4((side_effect.contents = side_effect.contents + 1 | 0, undefined), (side_effect.contents = side_effect.contents - 1 | 0, undefined), 164); + +again4(undefined, (side_effect.contents = side_effect.contents - 1 | 0, undefined), 172); + +again4((side_effect.contents = side_effect.contents + 1 | 0, undefined), undefined, 175); + +export { + u, + v_ice_cream3, + v_ice_cream4, + vv, + int_expect, + int_expect2, + int_expects, + mk_ice, + my_ice2, + my_ice3, + v_mk4, + v_mk5, + v_mk6, + v_mk6_1, + mk_u, + v_mk7, + side_effect, +} +/* Not a pure module */ diff --git a/tests/tests/src/gpr_1072_reg.js b/tests/tests/src/gpr_1072_reg.js deleted file mode 100644 index 282186115c..0000000000 --- a/tests/tests/src/gpr_1072_reg.js +++ /dev/null @@ -1,13 +0,0 @@ -// Generated by ReScript, PLEASE EDIT WITH CARE -'use strict'; - - -let v1 = { - localeMatcher: "best fit", - formatMatcher: "basic", - day: "2-digit", - timeZoneName: "short" -}; - -exports.v1 = v1; -/* No side effect */ diff --git a/tests/tests/src/gpr_1072_reg.mjs b/tests/tests/src/gpr_1072_reg.mjs new file mode 100644 index 0000000000..693b7b72fe --- /dev/null +++ b/tests/tests/src/gpr_1072_reg.mjs @@ -0,0 +1,14 @@ +// Generated by ReScript, PLEASE EDIT WITH CARE + + +let v1 = { + localeMatcher: "best fit", + formatMatcher: "basic", + day: "2-digit", + timeZoneName: "short" +}; + +export { + v1, +} +/* No side effect */ diff --git a/tests/tests/src/gpr_1150.js b/tests/tests/src/gpr_1150.js deleted file mode 100644 index b5cc9c15ab..0000000000 --- a/tests/tests/src/gpr_1150.js +++ /dev/null @@ -1,249 +0,0 @@ -// Generated by ReScript, PLEASE EDIT WITH CARE -'use strict'; - - -function f(children) { - if (!children) { - return []; - } - let children$1 = children.tl; - let a0 = children.hd; - if (!children$1) { - return [a0]; - } - let children$2 = children$1.tl; - let a1 = children$1.hd; - if (!children$2) { - return [ - a0, - a1 - ]; - } - let children$3 = children$2.tl; - let a2 = children$2.hd; - if (!children$3) { - return [ - a0, - a1, - a2 - ]; - } - let children$4 = children$3.tl; - let a3 = children$3.hd; - if (!children$4) { - return [ - a0, - a1, - a2, - a3 - ]; - } - let children$5 = children$4.tl; - let a4 = children$4.hd; - if (!children$5) { - return [ - a0, - a1, - a2, - a3, - a4 - ]; - } - let children$6 = children$5.tl; - let a5 = children$5.hd; - if (!children$6) { - return [ - a0, - a1, - a2, - a3, - a4, - a5 - ]; - } - let children$7 = children$6.tl; - let a6 = children$6.hd; - if (!children$7) { - return [ - a0, - a1, - a2, - a3, - a4, - a5, - a6 - ]; - } - let children$8 = children$7.tl; - let a7 = children$7.hd; - if (!children$8) { - return [ - a0, - a1, - a2, - a3, - a4, - a5, - a6, - a7 - ]; - } - let children$9 = children$8.tl; - let a8 = children$8.hd; - if (!children$9) { - return [ - a0, - a1, - a2, - a3, - a4, - a5, - a6, - a7, - a8 - ]; - } - let children$10 = children$9.tl; - let a9 = children$9.hd; - if (!children$10) { - return [ - a0, - a1, - a2, - a3, - a4, - a5, - a6, - a7, - a8, - a9 - ]; - } - let children$11 = children$10.tl; - let a10 = children$10.hd; - if (!children$11) { - return [ - a0, - a1, - a2, - a3, - a4, - a5, - a6, - a7, - a8, - a9, - a10 - ]; - } - let children$12 = children$11.tl; - let a11 = children$11.hd; - if (!children$12) { - return [ - a0, - a1, - a2, - a3, - a4, - a5, - a6, - a7, - a8, - a9, - a10, - a11 - ]; - } - let children$13 = children$12.tl; - let a12 = children$12.hd; - if (!children$13) { - return [ - a0, - a1, - a2, - a3, - a4, - a5, - a6, - a7, - a8, - a9, - a10, - a11, - a12 - ]; - } - let children$14 = children$13.tl; - let a13 = children$13.hd; - if (!children$14) { - return [ - a0, - a1, - a2, - a3, - a4, - a5, - a6, - a7, - a8, - a9, - a10, - a11, - a12, - a13 - ]; - } - let children$15 = children$14.tl; - let a14 = children$14.hd; - if (!children$15) { - return [ - a0, - a1, - a2, - a3, - a4, - a5, - a6, - a7, - a8, - a9, - a10, - a11, - a12, - a13, - a14 - ]; - } - if (children$15.tl) { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "gpr_1150.res", - 100, - 62 - ], - Error: new Error() - }; - } - return [ - a0, - a1, - a2, - a3, - a4, - a5, - a6, - a7, - a8, - a9, - a10, - a11, - a12, - a13, - a14, - children$15.hd - ]; -} - -exports.f = f; -/* No side effect */ diff --git a/tests/tests/src/gpr_1150.mjs b/tests/tests/src/gpr_1150.mjs new file mode 100644 index 0000000000..6485e77f1c --- /dev/null +++ b/tests/tests/src/gpr_1150.mjs @@ -0,0 +1,250 @@ +// Generated by ReScript, PLEASE EDIT WITH CARE + + +function f(children) { + if (!children) { + return []; + } + let children$1 = children.tl; + let a0 = children.hd; + if (!children$1) { + return [a0]; + } + let children$2 = children$1.tl; + let a1 = children$1.hd; + if (!children$2) { + return [ + a0, + a1 + ]; + } + let children$3 = children$2.tl; + let a2 = children$2.hd; + if (!children$3) { + return [ + a0, + a1, + a2 + ]; + } + let children$4 = children$3.tl; + let a3 = children$3.hd; + if (!children$4) { + return [ + a0, + a1, + a2, + a3 + ]; + } + let children$5 = children$4.tl; + let a4 = children$4.hd; + if (!children$5) { + return [ + a0, + a1, + a2, + a3, + a4 + ]; + } + let children$6 = children$5.tl; + let a5 = children$5.hd; + if (!children$6) { + return [ + a0, + a1, + a2, + a3, + a4, + a5 + ]; + } + let children$7 = children$6.tl; + let a6 = children$6.hd; + if (!children$7) { + return [ + a0, + a1, + a2, + a3, + a4, + a5, + a6 + ]; + } + let children$8 = children$7.tl; + let a7 = children$7.hd; + if (!children$8) { + return [ + a0, + a1, + a2, + a3, + a4, + a5, + a6, + a7 + ]; + } + let children$9 = children$8.tl; + let a8 = children$8.hd; + if (!children$9) { + return [ + a0, + a1, + a2, + a3, + a4, + a5, + a6, + a7, + a8 + ]; + } + let children$10 = children$9.tl; + let a9 = children$9.hd; + if (!children$10) { + return [ + a0, + a1, + a2, + a3, + a4, + a5, + a6, + a7, + a8, + a9 + ]; + } + let children$11 = children$10.tl; + let a10 = children$10.hd; + if (!children$11) { + return [ + a0, + a1, + a2, + a3, + a4, + a5, + a6, + a7, + a8, + a9, + a10 + ]; + } + let children$12 = children$11.tl; + let a11 = children$11.hd; + if (!children$12) { + return [ + a0, + a1, + a2, + a3, + a4, + a5, + a6, + a7, + a8, + a9, + a10, + a11 + ]; + } + let children$13 = children$12.tl; + let a12 = children$12.hd; + if (!children$13) { + return [ + a0, + a1, + a2, + a3, + a4, + a5, + a6, + a7, + a8, + a9, + a10, + a11, + a12 + ]; + } + let children$14 = children$13.tl; + let a13 = children$13.hd; + if (!children$14) { + return [ + a0, + a1, + a2, + a3, + a4, + a5, + a6, + a7, + a8, + a9, + a10, + a11, + a12, + a13 + ]; + } + let children$15 = children$14.tl; + let a14 = children$14.hd; + if (!children$15) { + return [ + a0, + a1, + a2, + a3, + a4, + a5, + a6, + a7, + a8, + a9, + a10, + a11, + a12, + a13, + a14 + ]; + } + if (children$15.tl) { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "gpr_1150.res", + 100, + 62 + ], + Error: new Error() + }; + } + return [ + a0, + a1, + a2, + a3, + a4, + a5, + a6, + a7, + a8, + a9, + a10, + a11, + a12, + a13, + a14, + children$15.hd + ]; +} + +export { + f, +} +/* No side effect */ diff --git a/tests/tests/src/gpr_1170.js b/tests/tests/src/gpr_1170.js deleted file mode 100644 index 17d775348e..0000000000 --- a/tests/tests/src/gpr_1170.js +++ /dev/null @@ -1,11 +0,0 @@ -// Generated by ReScript, PLEASE EDIT WITH CARE -'use strict'; - - -function f(resp) { - resp.statusCode = 200; - resp.hi = "hi"; -} - -exports.f = f; -/* No side effect */ diff --git a/tests/tests/src/gpr_1170.mjs b/tests/tests/src/gpr_1170.mjs new file mode 100644 index 0000000000..29c0e9438c --- /dev/null +++ b/tests/tests/src/gpr_1170.mjs @@ -0,0 +1,12 @@ +// Generated by ReScript, PLEASE EDIT WITH CARE + + +function f(resp) { + resp.statusCode = 200; + resp.hi = "hi"; +} + +export { + f, +} +/* No side effect */ diff --git a/tests/tests/src/gpr_1240_missing_unbox.js b/tests/tests/src/gpr_1240_missing_unbox.js deleted file mode 100644 index abd18ac83d..0000000000 --- a/tests/tests/src/gpr_1240_missing_unbox.js +++ /dev/null @@ -1,15 +0,0 @@ -// Generated by ReScript, PLEASE EDIT WITH CARE -'use strict'; - - -function f(x, y) { - let x$1 = x; - let y$1 = y; - return [ - x$1, - y$1 - ]; -} - -exports.f = f; -/* No side effect */ diff --git a/tests/tests/src/gpr_1240_missing_unbox.mjs b/tests/tests/src/gpr_1240_missing_unbox.mjs new file mode 100644 index 0000000000..2719a6e2a6 --- /dev/null +++ b/tests/tests/src/gpr_1240_missing_unbox.mjs @@ -0,0 +1,16 @@ +// Generated by ReScript, PLEASE EDIT WITH CARE + + +function f(x, y) { + let x$1 = x; + let y$1 = y; + return [ + x$1, + y$1 + ]; +} + +export { + f, +} +/* No side effect */ diff --git a/tests/tests/src/gpr_1245_test.js b/tests/tests/src/gpr_1245_test.js deleted file mode 100644 index b711c99090..0000000000 --- a/tests/tests/src/gpr_1245_test.js +++ /dev/null @@ -1,64 +0,0 @@ -// Generated by ReScript, PLEASE EDIT WITH CARE -'use strict'; - -let Primitive_exceptions = require("rescript/lib/js/Primitive_exceptions.js"); - -let x = { - contents: 1 -}; - -let y = { - contents: 2 -}; - -function f(param) { - let a = { - contents: param[0] - }; - let b = { - contents: param[1] - }; - console.log(a, b); -} - -function g() { - return 3; -} - -function a0(f) { - let u = f(); - if (u !== null) { - console.log(u); - console.log(u); - return 1; - } else { - return 0; - } -} - -function a1(f) { - let E = /* @__PURE__ */Primitive_exceptions.create("E"); - try { - return f(); - } catch (raw_exn) { - let exn = Primitive_exceptions.internalToException(raw_exn); - if (exn.RE_EXN_ID === E) { - return 1; - } - throw exn; - } -} - -let a = 1; - -let b = 2; - -exports.a = a; -exports.b = b; -exports.x = x; -exports.y = y; -exports.f = f; -exports.g = g; -exports.a0 = a0; -exports.a1 = a1; -/* No side effect */ diff --git a/tests/tests/src/gpr_1245_test.mjs b/tests/tests/src/gpr_1245_test.mjs new file mode 100644 index 0000000000..ac31796aa0 --- /dev/null +++ b/tests/tests/src/gpr_1245_test.mjs @@ -0,0 +1,65 @@ +// Generated by ReScript, PLEASE EDIT WITH CARE + +import * as Primitive_exceptions from "rescript/lib/es6/Primitive_exceptions.js"; + +let x = { + contents: 1 +}; + +let y = { + contents: 2 +}; + +function f(param) { + let a = { + contents: param[0] + }; + let b = { + contents: param[1] + }; + console.log(a, b); +} + +function g() { + return 3; +} + +function a0(f) { + let u = f(); + if (u !== null) { + console.log(u); + console.log(u); + return 1; + } else { + return 0; + } +} + +function a1(f) { + let E = /* @__PURE__ */Primitive_exceptions.create("E"); + try { + return f(); + } catch (raw_exn) { + let exn = Primitive_exceptions.internalToException(raw_exn); + if (exn.RE_EXN_ID === E) { + return 1; + } + throw exn; + } +} + +let a = 1; + +let b = 2; + +export { + a, + b, + x, + y, + f, + g, + a0, + a1, +} +/* No side effect */ diff --git a/tests/tests/src/gpr_1268.js b/tests/tests/src/gpr_1268.js deleted file mode 100644 index ffc1dafced..0000000000 --- a/tests/tests/src/gpr_1268.js +++ /dev/null @@ -1,35 +0,0 @@ -// Generated by ReScript, PLEASE EDIT WITH CARE -'use strict'; - - -function f_add2(a, b, x, y) { - return add(b(y), a(x)); -} - -function f(a, b, x, y) { - return a(x) + b(y) | 0; -} - -function f1(a, b, x, y) { - return add(a(x), b(y)); -} - -function f2(x) { - console.log(x); -} - -function f3(x) { - console.log(x); -} - -function f4(x, y) { - return add(y, x); -} - -exports.f_add2 = f_add2; -exports.f = f; -exports.f1 = f1; -exports.f2 = f2; -exports.f3 = f3; -exports.f4 = f4; -/* No side effect */ diff --git a/tests/tests/src/gpr_1268.mjs b/tests/tests/src/gpr_1268.mjs new file mode 100644 index 0000000000..e4148a134a --- /dev/null +++ b/tests/tests/src/gpr_1268.mjs @@ -0,0 +1,36 @@ +// Generated by ReScript, PLEASE EDIT WITH CARE + + +function f_add2(a, b, x, y) { + return add(b(y), a(x)); +} + +function f(a, b, x, y) { + return a(x) + b(y) | 0; +} + +function f1(a, b, x, y) { + return add(a(x), b(y)); +} + +function f2(x) { + console.log(x); +} + +function f3(x) { + console.log(x); +} + +function f4(x, y) { + return add(y, x); +} + +export { + f_add2, + f, + f1, + f2, + f3, + f4, +} +/* No side effect */ diff --git a/tests/tests/src/gpr_1409_test.js b/tests/tests/src/gpr_1409_test.js deleted file mode 100644 index dd1dd10a8e..0000000000 --- a/tests/tests/src/gpr_1409_test.js +++ /dev/null @@ -1,175 +0,0 @@ -// Generated by ReScript, PLEASE EDIT WITH CARE -'use strict'; - -let Mt = require("./mt.js"); -let Belt_List = require("rescript/lib/js/Belt_List.js"); -let String_set = require("./string_set.js"); -let Primitive_option = require("rescript/lib/js/Primitive_option.js"); - -let suites = { - contents: /* [] */0 -}; - -let test_id = { - contents: 0 -}; - -function eq(loc, x, y) { - test_id.contents = test_id.contents + 1 | 0; - suites.contents = { - hd: [ - loc + (" id " + test_id.contents.toString()), - () => ({ - TAG: "Eq", - _0: x, - _1: y - }) - ], - tl: suites.contents - }; -} - -let a = {}; - -let b = { - foo: "42" -}; - -function map(f, x) { - if (x !== undefined) { - return Primitive_option.some(f(Primitive_option.valFromOption(x))); - } - -} - -function make(foo, param) { - let tmp = {}; - let tmp$1 = map(prim => prim.toString(), foo); - if (tmp$1 !== undefined) { - tmp.foo = tmp$1; - } - return tmp; -} - -let a_ = make(undefined, undefined); - -let b_ = make(42, undefined); - -eq("File \"gpr_1409_test.res\", line 31, characters 3-10", b_.foo, "42"); - -console.log(Object.keys(a_)); - -console.log(a, b, a_, b_); - -eq("File \"gpr_1409_test.res\", line 36, characters 3-10", Object.keys(a_).length, 0); - -let test2 = { - hi: 2 -}; - -function test3(_open, xx__hi) { - let tmp = { - hi: 2 - }; - if (_open !== undefined) { - tmp._open = _open; - } - if (xx__hi !== undefined) { - tmp.xx__hi = xx__hi; - } - return tmp; -} - -function test4(_open, xx__hi) { - console.log("no inlin"); - let tmp = { - _open: _open, - hi: 2 - }; - if (xx__hi !== undefined) { - tmp.xx__hi = xx__hi; - } - return tmp; -} - -function test5(f, x) { - console.log("no inline"); - let tmp = { - hi: 2 - }; - let tmp$1 = f(x); - if (tmp$1 !== undefined) { - tmp._open = tmp$1; - } - let tmp$2 = f(x); - if (tmp$2 !== undefined) { - tmp.xx__hi = tmp$2; - } - return tmp; -} - -function test6(f, x) { - console.log("no inline"); - let x$1 = { - contents: 3 - }; - let tmp = { - hi: 2 - }; - let tmp$1 = (x$1.contents = x$1.contents + 1 | 0, x$1.contents); - if (tmp$1 !== undefined) { - tmp._open = tmp$1; - } - let tmp$2 = f(x$1); - if (tmp$2 !== undefined) { - tmp.xx__hi = tmp$2; - } - return tmp; -} - -function keys(xs, ys) { - return String_set.equal(String_set.of_list(xs), String_set.of_list(Belt_List.fromArray(ys))); -} - -eq("File \"gpr_1409_test.res\", line 74, characters 3-10", keys({ - hd: "hi", - tl: /* [] */0 -}, Object.keys(test3(undefined, undefined))), true); - -eq("File \"gpr_1409_test.res\", line 76, characters 3-10", keys({ - hd: "hi", - tl: { - hd: "_open", - tl: /* [] */0 - } -}, Object.keys(test3(2, undefined))), true); - -eq("File \"gpr_1409_test.res\", line 78, characters 3-10", keys({ - hd: "hi", - tl: { - hd: "_open", - tl: { - hd: "xx__hi", - tl: /* [] */0 - } - } -}, Object.keys(test3(2, 2))), true); - -Mt.from_pair_suites("Gpr_1409_test", suites.contents); - -exports.suites = suites; -exports.test_id = test_id; -exports.eq = eq; -exports.a = a; -exports.b = b; -exports.map = map; -exports.make = make; -exports.a_ = a_; -exports.b_ = b_; -exports.test2 = test2; -exports.test3 = test3; -exports.test4 = test4; -exports.test5 = test5; -exports.test6 = test6; -exports.keys = keys; -/* a_ Not a pure module */ diff --git a/tests/tests/src/gpr_1409_test.mjs b/tests/tests/src/gpr_1409_test.mjs new file mode 100644 index 0000000000..e98e5287ef --- /dev/null +++ b/tests/tests/src/gpr_1409_test.mjs @@ -0,0 +1,176 @@ +// Generated by ReScript, PLEASE EDIT WITH CARE + +import * as Mt from "./mt.mjs"; +import * as Belt_List from "rescript/lib/es6/Belt_List.js"; +import * as String_set from "./string_set.mjs"; +import * as Primitive_option from "rescript/lib/es6/Primitive_option.js"; + +let suites = { + contents: /* [] */0 +}; + +let test_id = { + contents: 0 +}; + +function eq(loc, x, y) { + test_id.contents = test_id.contents + 1 | 0; + suites.contents = { + hd: [ + loc + (" id " + test_id.contents.toString()), + () => ({ + TAG: "Eq", + _0: x, + _1: y + }) + ], + tl: suites.contents + }; +} + +let a = {}; + +let b = { + foo: "42" +}; + +function map(f, x) { + if (x !== undefined) { + return Primitive_option.some(f(Primitive_option.valFromOption(x))); + } + +} + +function make(foo, param) { + let tmp = {}; + let tmp$1 = map(prim => prim.toString(), foo); + if (tmp$1 !== undefined) { + tmp.foo = tmp$1; + } + return tmp; +} + +let a_ = make(undefined, undefined); + +let b_ = make(42, undefined); + +eq("File \"gpr_1409_test.res\", line 31, characters 3-10", b_.foo, "42"); + +console.log(Object.keys(a_)); + +console.log(a, b, a_, b_); + +eq("File \"gpr_1409_test.res\", line 36, characters 3-10", Object.keys(a_).length, 0); + +let test2 = { + hi: 2 +}; + +function test3(_open, xx__hi) { + let tmp = { + hi: 2 + }; + if (_open !== undefined) { + tmp._open = _open; + } + if (xx__hi !== undefined) { + tmp.xx__hi = xx__hi; + } + return tmp; +} + +function test4(_open, xx__hi) { + console.log("no inlin"); + let tmp = { + _open: _open, + hi: 2 + }; + if (xx__hi !== undefined) { + tmp.xx__hi = xx__hi; + } + return tmp; +} + +function test5(f, x) { + console.log("no inline"); + let tmp = { + hi: 2 + }; + let tmp$1 = f(x); + if (tmp$1 !== undefined) { + tmp._open = tmp$1; + } + let tmp$2 = f(x); + if (tmp$2 !== undefined) { + tmp.xx__hi = tmp$2; + } + return tmp; +} + +function test6(f, x) { + console.log("no inline"); + let x$1 = { + contents: 3 + }; + let tmp = { + hi: 2 + }; + let tmp$1 = (x$1.contents = x$1.contents + 1 | 0, x$1.contents); + if (tmp$1 !== undefined) { + tmp._open = tmp$1; + } + let tmp$2 = f(x$1); + if (tmp$2 !== undefined) { + tmp.xx__hi = tmp$2; + } + return tmp; +} + +function keys(xs, ys) { + return String_set.equal(String_set.of_list(xs), String_set.of_list(Belt_List.fromArray(ys))); +} + +eq("File \"gpr_1409_test.res\", line 74, characters 3-10", keys({ + hd: "hi", + tl: /* [] */0 +}, Object.keys(test3(undefined, undefined))), true); + +eq("File \"gpr_1409_test.res\", line 76, characters 3-10", keys({ + hd: "hi", + tl: { + hd: "_open", + tl: /* [] */0 + } +}, Object.keys(test3(2, undefined))), true); + +eq("File \"gpr_1409_test.res\", line 78, characters 3-10", keys({ + hd: "hi", + tl: { + hd: "_open", + tl: { + hd: "xx__hi", + tl: /* [] */0 + } + } +}, Object.keys(test3(2, 2))), true); + +Mt.from_pair_suites("Gpr_1409_test", suites.contents); + +export { + suites, + test_id, + eq, + a, + b, + map, + make, + a_, + b_, + test2, + test3, + test4, + test5, + test6, + keys, +} +/* a_ Not a pure module */ diff --git a/tests/tests/src/gpr_1423_app_test.js b/tests/tests/src/gpr_1423_app_test.js deleted file mode 100644 index ab493e1656..0000000000 --- a/tests/tests/src/gpr_1423_app_test.js +++ /dev/null @@ -1,49 +0,0 @@ -// Generated by ReScript, PLEASE EDIT WITH CARE -'use strict'; - -let Mt = require("./mt.js"); -let Gpr_1423_nav = require("./gpr_1423_nav.js"); - -let suites = { - contents: /* [] */0 -}; - -let test_id = { - contents: 0 -}; - -function eq(loc, x, y) { - test_id.contents = test_id.contents + 1 | 0; - suites.contents = { - hd: [ - loc + (" id " + test_id.contents.toString()), - () => ({ - TAG: "Eq", - _0: x, - _1: y - }) - ], - tl: suites.contents - }; -} - -function foo(f) { - console.log(f("a1", undefined)); -} - -foo((none, extra) => Gpr_1423_nav.busted(none, "a2", extra)); - -function foo2(f) { - return f("a1", undefined); -} - -eq("File \"gpr_1423_app_test.res\", line 18, characters 12-19", Gpr_1423_nav.busted("a1", "a2", undefined), "a1a2"); - -Mt.from_pair_suites("Gpr_1423_app_test", suites.contents); - -exports.suites = suites; -exports.test_id = test_id; -exports.eq = eq; -exports.foo = foo; -exports.foo2 = foo2; -/* Not a pure module */ diff --git a/tests/tests/src/gpr_1423_app_test.mjs b/tests/tests/src/gpr_1423_app_test.mjs new file mode 100644 index 0000000000..6974c66297 --- /dev/null +++ b/tests/tests/src/gpr_1423_app_test.mjs @@ -0,0 +1,50 @@ +// Generated by ReScript, PLEASE EDIT WITH CARE + +import * as Mt from "./mt.mjs"; +import * as Gpr_1423_nav from "./gpr_1423_nav.mjs"; + +let suites = { + contents: /* [] */0 +}; + +let test_id = { + contents: 0 +}; + +function eq(loc, x, y) { + test_id.contents = test_id.contents + 1 | 0; + suites.contents = { + hd: [ + loc + (" id " + test_id.contents.toString()), + () => ({ + TAG: "Eq", + _0: x, + _1: y + }) + ], + tl: suites.contents + }; +} + +function foo(f) { + console.log(f("a1", undefined)); +} + +foo((none, extra) => Gpr_1423_nav.busted(none, "a2", extra)); + +function foo2(f) { + return f("a1", undefined); +} + +eq("File \"gpr_1423_app_test.res\", line 18, characters 12-19", Gpr_1423_nav.busted("a1", "a2", undefined), "a1a2"); + +Mt.from_pair_suites("Gpr_1423_app_test", suites.contents); + +export { + suites, + test_id, + eq, + foo, + foo2, +} +/* Not a pure module */ diff --git a/tests/tests/src/gpr_1423_nav.js b/tests/tests/src/gpr_1423_nav.js deleted file mode 100644 index 0116b45024..0000000000 --- a/tests/tests/src/gpr_1423_nav.js +++ /dev/null @@ -1,10 +0,0 @@ -// Generated by ReScript, PLEASE EDIT WITH CARE -'use strict'; - - -function busted(a1, a2, param) { - return a1 + a2; -} - -exports.busted = busted; -/* No side effect */ diff --git a/tests/tests/src/gpr_1423_nav.mjs b/tests/tests/src/gpr_1423_nav.mjs new file mode 100644 index 0000000000..69c9a7968b --- /dev/null +++ b/tests/tests/src/gpr_1423_nav.mjs @@ -0,0 +1,11 @@ +// Generated by ReScript, PLEASE EDIT WITH CARE + + +function busted(a1, a2, param) { + return a1 + a2; +} + +export { + busted, +} +/* No side effect */ diff --git a/tests/tests/src/gpr_1438.js b/tests/tests/src/gpr_1438.js deleted file mode 100644 index 8f89b09dfb..0000000000 --- a/tests/tests/src/gpr_1438.js +++ /dev/null @@ -1,23 +0,0 @@ -// Generated by ReScript, PLEASE EDIT WITH CARE -'use strict'; - - -function actionKey(key, a, b, c, d, e) { - switch (key) { - case 98 : - return c; - case 106 : - return d; - case 107 : - return e; - case 116 : - return b; - case 99 : - case 118 : - return a; - } - return param => {}; -} - -exports.actionKey = actionKey; -/* No side effect */ diff --git a/tests/tests/src/gpr_1438.mjs b/tests/tests/src/gpr_1438.mjs new file mode 100644 index 0000000000..854af721e5 --- /dev/null +++ b/tests/tests/src/gpr_1438.mjs @@ -0,0 +1,24 @@ +// Generated by ReScript, PLEASE EDIT WITH CARE + + +function actionKey(key, a, b, c, d, e) { + switch (key) { + case 98 : + return c; + case 106 : + return d; + case 107 : + return e; + case 116 : + return b; + case 99 : + case 118 : + return a; + } + return param => {}; +} + +export { + actionKey, +} +/* No side effect */ diff --git a/tests/tests/src/gpr_1481.js b/tests/tests/src/gpr_1481.js deleted file mode 100644 index 71d2813dd7..0000000000 --- a/tests/tests/src/gpr_1481.js +++ /dev/null @@ -1,11 +0,0 @@ -// Generated by ReScript, PLEASE EDIT WITH CARE -'use strict'; - -let Moduleid = require("#moduleid"); - -function f() { - return Moduleid.name; -} - -exports.f = f; -/* #moduleid Not a pure module */ diff --git a/tests/tests/src/gpr_1481.mjs b/tests/tests/src/gpr_1481.mjs new file mode 100644 index 0000000000..efd39acc3e --- /dev/null +++ b/tests/tests/src/gpr_1481.mjs @@ -0,0 +1,12 @@ +// Generated by ReScript, PLEASE EDIT WITH CARE + +import * as Moduleid from "#moduleid"; + +function f() { + return Moduleid.name; +} + +export { + f, +} +/* #moduleid Not a pure module */ diff --git a/tests/tests/src/gpr_1484.js b/tests/tests/src/gpr_1484.js deleted file mode 100644 index 5e8a8743ba..0000000000 --- a/tests/tests/src/gpr_1484.js +++ /dev/null @@ -1,10 +0,0 @@ -// Generated by ReScript, PLEASE EDIT WITH CARE -'use strict'; - - -function test(x) { - x.nodeValue = null; -} - -exports.test = test; -/* No side effect */ diff --git a/tests/tests/src/gpr_1484.mjs b/tests/tests/src/gpr_1484.mjs new file mode 100644 index 0000000000..f2dda9b552 --- /dev/null +++ b/tests/tests/src/gpr_1484.mjs @@ -0,0 +1,11 @@ +// Generated by ReScript, PLEASE EDIT WITH CARE + + +function test(x) { + x.nodeValue = null; +} + +export { + test, +} +/* No side effect */ diff --git a/tests/tests/src/gpr_1539_test.js b/tests/tests/src/gpr_1539_test.js deleted file mode 100644 index df9b081966..0000000000 --- a/tests/tests/src/gpr_1539_test.js +++ /dev/null @@ -1,35 +0,0 @@ -// Generated by ReScript, PLEASE EDIT WITH CARE -'use strict'; - -let Primitive_module = require("rescript/lib/js/Primitive_module.js"); - -let Point = Primitive_module.init([ - "gpr_1539_test.res", - 11, - 4 -], { - TAG: "Module", - _0: [[ - "Function", - "add" - ]] -}); - -Primitive_module.update({ - TAG: "Module", - _0: [[ - "Function", - "add" - ]] -}, Point, { - add: (prim0, prim1) => prim0.add(prim1) -}); - -let CRS; - -let Layer; - -exports.CRS = CRS; -exports.Layer = Layer; -exports.Point = Point; -/* Point Not a pure module */ diff --git a/tests/tests/src/gpr_1539_test.mjs b/tests/tests/src/gpr_1539_test.mjs new file mode 100644 index 0000000000..10564256b7 --- /dev/null +++ b/tests/tests/src/gpr_1539_test.mjs @@ -0,0 +1,36 @@ +// Generated by ReScript, PLEASE EDIT WITH CARE + +import * as Primitive_module from "rescript/lib/es6/Primitive_module.js"; + +let Point = Primitive_module.init([ + "gpr_1539_test.res", + 11, + 4 +], { + TAG: "Module", + _0: [[ + "Function", + "add" + ]] +}); + +Primitive_module.update({ + TAG: "Module", + _0: [[ + "Function", + "add" + ]] +}, Point, { + add: (prim0, prim1) => prim0.add(prim1) +}); + +let CRS; + +let Layer; + +export { + CRS, + Layer, + Point, +} +/* Point Not a pure module */ diff --git a/tests/tests/src/gpr_1658_test.js b/tests/tests/src/gpr_1658_test.js deleted file mode 100644 index bee607284c..0000000000 --- a/tests/tests/src/gpr_1658_test.js +++ /dev/null @@ -1,47 +0,0 @@ -// Generated by ReScript, PLEASE EDIT WITH CARE -'use strict'; - -let Mt = require("./mt.js"); -let Js_types = require("rescript/lib/js/Js_types.js"); - -let suites = { - contents: /* [] */0 -}; - -let test_id = { - contents: 0 -}; - -function eq(loc, x, y) { - test_id.contents = test_id.contents + 1 | 0; - suites.contents = { - hd: [ - loc + (" id " + test_id.contents.toString()), - () => ({ - TAG: "Eq", - _0: x, - _1: y - }) - ], - tl: suites.contents - }; -} - -eq("File \"gpr_1658_test.res\", line 13, characters 5-12", null, null); - -let match = Js_types.classify(null); - -if (typeof match !== "object" && match === "JSNull") { - eq("File \"gpr_1658_test.res\", line 15, characters 17-24", true, true); -} else { - eq("File \"gpr_1658_test.res\", line 16, characters 12-19", true, false); -} - -eq("File \"gpr_1658_test.res\", line 18, characters 5-12", true, Js_types.test(null, "Null")); - -Mt.from_pair_suites("File \"gpr_1658_test.res\", line 21, characters 20-27", suites.contents); - -exports.suites = suites; -exports.test_id = test_id; -exports.eq = eq; -/* Not a pure module */ diff --git a/tests/tests/src/gpr_1658_test.mjs b/tests/tests/src/gpr_1658_test.mjs new file mode 100644 index 0000000000..78a878d8f0 --- /dev/null +++ b/tests/tests/src/gpr_1658_test.mjs @@ -0,0 +1,48 @@ +// Generated by ReScript, PLEASE EDIT WITH CARE + +import * as Mt from "./mt.mjs"; +import * as Js_types from "rescript/lib/es6/Js_types.js"; + +let suites = { + contents: /* [] */0 +}; + +let test_id = { + contents: 0 +}; + +function eq(loc, x, y) { + test_id.contents = test_id.contents + 1 | 0; + suites.contents = { + hd: [ + loc + (" id " + test_id.contents.toString()), + () => ({ + TAG: "Eq", + _0: x, + _1: y + }) + ], + tl: suites.contents + }; +} + +eq("File \"gpr_1658_test.res\", line 13, characters 5-12", null, null); + +let match = Js_types.classify(null); + +if (typeof match !== "object" && match === "JSNull") { + eq("File \"gpr_1658_test.res\", line 15, characters 17-24", true, true); +} else { + eq("File \"gpr_1658_test.res\", line 16, characters 12-19", true, false); +} + +eq("File \"gpr_1658_test.res\", line 18, characters 5-12", true, Js_types.test(null, "Null")); + +Mt.from_pair_suites("File \"gpr_1658_test.res\", line 21, characters 20-27", suites.contents); + +export { + suites, + test_id, + eq, +} +/* Not a pure module */ diff --git a/tests/tests/src/gpr_1667_test.js b/tests/tests/src/gpr_1667_test.js deleted file mode 100644 index 71234de8d6..0000000000 --- a/tests/tests/src/gpr_1667_test.js +++ /dev/null @@ -1,36 +0,0 @@ -// Generated by ReScript, PLEASE EDIT WITH CARE -'use strict'; - -let Mt = require("./mt.js"); - -let suites = { - contents: /* [] */0 -}; - -let test_id = { - contents: 0 -}; - -function eq(loc, x, y) { - test_id.contents = test_id.contents + 1 | 0; - suites.contents = { - hd: [ - loc + (" id " + test_id.contents.toString()), - () => ({ - TAG: "Eq", - _0: x, - _1: y - }) - ], - tl: suites.contents - }; -} - -eq("File \"gpr_1667_test.res\", line 28, characters 5-12", 0, 0); - -Mt.from_pair_suites("Gpr_1667_test", suites.contents); - -exports.suites = suites; -exports.test_id = test_id; -exports.eq = eq; -/* Not a pure module */ diff --git a/tests/tests/src/gpr_1667_test.mjs b/tests/tests/src/gpr_1667_test.mjs new file mode 100644 index 0000000000..fdc82775d0 --- /dev/null +++ b/tests/tests/src/gpr_1667_test.mjs @@ -0,0 +1,37 @@ +// Generated by ReScript, PLEASE EDIT WITH CARE + +import * as Mt from "./mt.mjs"; + +let suites = { + contents: /* [] */0 +}; + +let test_id = { + contents: 0 +}; + +function eq(loc, x, y) { + test_id.contents = test_id.contents + 1 | 0; + suites.contents = { + hd: [ + loc + (" id " + test_id.contents.toString()), + () => ({ + TAG: "Eq", + _0: x, + _1: y + }) + ], + tl: suites.contents + }; +} + +eq("File \"gpr_1667_test.res\", line 28, characters 5-12", 0, 0); + +Mt.from_pair_suites("Gpr_1667_test", suites.contents); + +export { + suites, + test_id, + eq, +} +/* Not a pure module */ diff --git a/tests/tests/src/gpr_1692_test.js b/tests/tests/src/gpr_1692_test.js deleted file mode 100644 index 7c0694ed44..0000000000 --- a/tests/tests/src/gpr_1692_test.js +++ /dev/null @@ -1,7 +0,0 @@ -// Generated by ReScript, PLEASE EDIT WITH CARE -'use strict'; - - -(f => 0)(""); - -/* Not a pure module */ diff --git a/tests/tests/src/gpr_1692_test.mjs b/tests/tests/src/gpr_1692_test.mjs new file mode 100644 index 0000000000..3863ef51b9 --- /dev/null +++ b/tests/tests/src/gpr_1692_test.mjs @@ -0,0 +1,6 @@ +// Generated by ReScript, PLEASE EDIT WITH CARE + + +(f => 0)(""); + +/* Not a pure module */ diff --git a/tests/tests/src/gpr_1698_test.js b/tests/tests/src/gpr_1698_test.js deleted file mode 100644 index a85cfeee77..0000000000 --- a/tests/tests/src/gpr_1698_test.js +++ /dev/null @@ -1,216 +0,0 @@ -// Generated by ReScript, PLEASE EDIT WITH CARE -'use strict'; - - -function is_number(_expr) { - while (true) { - let expr = _expr; - switch (expr.TAG) { - case "Val" : - if (expr._0.TAG === "Natural") { - return true; - } else { - return false; - } - case "Neg" : - _expr = expr._0; - continue; - case "Sum" : - case "Pow" : - case "Frac" : - case "Gcd" : - return false; - } - }; -} - -function compare(context, state, _a, _b) { - while (true) { - let b = _b; - let a = _a; - let exit = 0; - let na; - let da; - let nb; - let db; - let exit$1 = 0; - let exit$2 = 0; - let exit$3 = 0; - switch (a.TAG) { - case "Val" : - switch (b.TAG) { - case "Val" : - return 111; - case "Neg" : - exit$3 = 5; - break; - case "Sum" : - exit$2 = 4; - break; - case "Frac" : - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "gpr_1698_test.res", - 41, - 9 - ], - Error: new Error() - }; - case "Pow" : - case "Gcd" : - exit = 1; - break; - } - break; - case "Neg" : - _a = a._0; - continue; - case "Sum" : - case "Pow" : - exit$3 = 5; - break; - case "Frac" : - switch (b.TAG) { - case "Val" : - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "gpr_1698_test.res", - 41, - 9 - ], - Error: new Error() - }; - case "Neg" : - exit$3 = 5; - break; - case "Sum" : - exit$2 = 4; - break; - case "Frac" : - na = a._0; - da = a._1; - nb = b._0; - db = b._1; - exit = 2; - break; - case "Pow" : - case "Gcd" : - exit = 1; - break; - } - break; - case "Gcd" : - switch (b.TAG) { - case "Neg" : - exit$3 = 5; - break; - case "Sum" : - exit$2 = 4; - break; - case "Gcd" : - na = a._0; - da = a._1; - nb = b._0; - db = b._1; - exit = 2; - break; - default: - exit$1 = 3; - } - break; - } - if (exit$3 === 5) { - if (b.TAG === "Neg") { - _b = b._0; - continue; - } - if (a.TAG === "Sum") { - if (is_number(b)) { - return 1; - } - exit$2 = 4; - } else { - exit$2 = 4; - } - } - if (exit$2 === 4) { - if (b.TAG === "Sum") { - if (is_number(a)) { - return -1; - } - exit$1 = 3; - } else { - exit$1 = 3; - } - } - if (exit$1 === 3) { - switch (a.TAG) { - case "Sum" : - exit = 1; - break; - case "Pow" : - return -1; - case "Val" : - case "Frac" : - case "Gcd" : - return 1; - } - } - switch (exit) { - case 1 : - switch (b.TAG) { - case "Pow" : - return 1; - default: - return -1; - } - case 2 : - let denom = compare(context, state, da, db); - if (denom !== 0) { - return denom; - } - _b = nb; - _a = na; - continue; - } - }; -} - -let a = { - TAG: "Sum", - _0: { - hd: { - TAG: "Val", - _0: { - TAG: "Symbol", - _0: "a" - } - }, - tl: { - hd: { - TAG: "Val", - _0: { - TAG: "Natural", - _0: 2 - } - }, - tl: /* [] */0 - } - } -}; - -let b = { - TAG: "Val", - _0: { - TAG: "Symbol", - _0: "x" - } -}; - -console.log(compare("InSum", { - complex: true -}, a, b)); - -/* Not a pure module */ diff --git a/tests/tests/src/gpr_1698_test.mjs b/tests/tests/src/gpr_1698_test.mjs new file mode 100644 index 0000000000..947fa0a4f2 --- /dev/null +++ b/tests/tests/src/gpr_1698_test.mjs @@ -0,0 +1,215 @@ +// Generated by ReScript, PLEASE EDIT WITH CARE + + +function is_number(_expr) { + while (true) { + let expr = _expr; + switch (expr.TAG) { + case "Val" : + if (expr._0.TAG === "Natural") { + return true; + } else { + return false; + } + case "Neg" : + _expr = expr._0; + continue; + case "Sum" : + case "Pow" : + case "Frac" : + case "Gcd" : + return false; + } + }; +} + +function compare(context, state, _a, _b) { + while (true) { + let b = _b; + let a = _a; + let exit = 0; + let na; + let da; + let nb; + let db; + let exit$1 = 0; + let exit$2 = 0; + let exit$3 = 0; + switch (a.TAG) { + case "Val" : + switch (b.TAG) { + case "Val" : + return 111; + case "Neg" : + exit$3 = 5; + break; + case "Sum" : + exit$2 = 4; + break; + case "Frac" : + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "gpr_1698_test.res", + 41, + 9 + ], + Error: new Error() + }; + case "Pow" : + case "Gcd" : + exit = 1; + break; + } + break; + case "Neg" : + _a = a._0; + continue; + case "Sum" : + case "Pow" : + exit$3 = 5; + break; + case "Frac" : + switch (b.TAG) { + case "Val" : + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "gpr_1698_test.res", + 41, + 9 + ], + Error: new Error() + }; + case "Neg" : + exit$3 = 5; + break; + case "Sum" : + exit$2 = 4; + break; + case "Frac" : + na = a._0; + da = a._1; + nb = b._0; + db = b._1; + exit = 2; + break; + case "Pow" : + case "Gcd" : + exit = 1; + break; + } + break; + case "Gcd" : + switch (b.TAG) { + case "Neg" : + exit$3 = 5; + break; + case "Sum" : + exit$2 = 4; + break; + case "Gcd" : + na = a._0; + da = a._1; + nb = b._0; + db = b._1; + exit = 2; + break; + default: + exit$1 = 3; + } + break; + } + if (exit$3 === 5) { + if (b.TAG === "Neg") { + _b = b._0; + continue; + } + if (a.TAG === "Sum") { + if (is_number(b)) { + return 1; + } + exit$2 = 4; + } else { + exit$2 = 4; + } + } + if (exit$2 === 4) { + if (b.TAG === "Sum") { + if (is_number(a)) { + return -1; + } + exit$1 = 3; + } else { + exit$1 = 3; + } + } + if (exit$1 === 3) { + switch (a.TAG) { + case "Sum" : + exit = 1; + break; + case "Pow" : + return -1; + case "Val" : + case "Frac" : + case "Gcd" : + return 1; + } + } + switch (exit) { + case 1 : + switch (b.TAG) { + case "Pow" : + return 1; + default: + return -1; + } + case 2 : + let denom = compare(context, state, da, db); + if (denom !== 0) { + return denom; + } + _b = nb; + _a = na; + continue; + } + }; +} + +let a = { + TAG: "Sum", + _0: { + hd: { + TAG: "Val", + _0: { + TAG: "Symbol", + _0: "a" + } + }, + tl: { + hd: { + TAG: "Val", + _0: { + TAG: "Natural", + _0: 2 + } + }, + tl: /* [] */0 + } + } +}; + +let b = { + TAG: "Val", + _0: { + TAG: "Symbol", + _0: "x" + } +}; + +console.log(compare("InSum", { + complex: true +}, a, b)); + +/* Not a pure module */ diff --git a/tests/tests/src/gpr_1701_test.js b/tests/tests/src/gpr_1701_test.js deleted file mode 100644 index 57622db869..0000000000 --- a/tests/tests/src/gpr_1701_test.js +++ /dev/null @@ -1,110 +0,0 @@ -// Generated by ReScript, PLEASE EDIT WITH CARE -'use strict'; - -let Belt_List = require("rescript/lib/js/Belt_List.js"); -let Primitive_exceptions = require("rescript/lib/js/Primitive_exceptions.js"); - -let Foo = /* @__PURE__ */Primitive_exceptions.create("Gpr_1701_test.Foo"); - -function test(n) { - if (n === 0) { - throw { - RE_EXN_ID: Foo, - Error: new Error() - }; - } - try { - return test(n - 1 | 0); - } catch (raw_exn) { - let exn = Primitive_exceptions.internalToException(raw_exn); - if (exn.RE_EXN_ID === Foo) { - return; - } - throw exn; - } -} - -test(100); - -function read_lines(inc) { - let _acc = /* [] */0; - while (true) { - let acc = _acc; - let l; - try { - l = input_line(inc); - } catch (raw_exn) { - let exn = Primitive_exceptions.internalToException(raw_exn); - if (exn.RE_EXN_ID === "End_of_file") { - l = undefined; - } else { - throw exn; - } - } - if (l === undefined) { - return Belt_List.reverse(acc); - } - _acc = { - hd: l, - tl: acc - }; - continue; - }; -} - -function read_lines2(inc) { - let _acc = /* [] */0; - while (true) { - let acc = _acc; - let l; - try { - l = input_line(inc); - } catch (raw_exn) { - let exn = Primitive_exceptions.internalToException(raw_exn); - if (exn.RE_EXN_ID === "End_of_file") { - return Belt_List.reverse(acc); - } - throw exn; - } - _acc = { - hd: l, - tl: acc - }; - continue; - }; -} - -function read_lines3(inc) { - let loop = acc => { - try { - let l = input_line(inc); - return loop({ - hd: l, - tl: acc - }); - } catch (raw_exn) { - let exn = Primitive_exceptions.internalToException(raw_exn); - if (exn.RE_EXN_ID === "End_of_file") { - return Belt_List.reverse(acc); - } - throw exn; - } - }; - return loop(/* [] */0); -} - -function fff(f, x) { - try { - return fff(f, x); - } catch (exn) { - return x + 1 | 0; - } -} - -exports.Foo = Foo; -exports.test = test; -exports.read_lines = read_lines; -exports.read_lines2 = read_lines2; -exports.read_lines3 = read_lines3; -exports.fff = fff; -/* Not a pure module */ diff --git a/tests/tests/src/gpr_1701_test.mjs b/tests/tests/src/gpr_1701_test.mjs new file mode 100644 index 0000000000..8a0f18cd3a --- /dev/null +++ b/tests/tests/src/gpr_1701_test.mjs @@ -0,0 +1,111 @@ +// Generated by ReScript, PLEASE EDIT WITH CARE + +import * as Belt_List from "rescript/lib/es6/Belt_List.js"; +import * as Primitive_exceptions from "rescript/lib/es6/Primitive_exceptions.js"; + +let Foo = /* @__PURE__ */Primitive_exceptions.create("Gpr_1701_test.Foo"); + +function test(n) { + if (n === 0) { + throw { + RE_EXN_ID: Foo, + Error: new Error() + }; + } + try { + return test(n - 1 | 0); + } catch (raw_exn) { + let exn = Primitive_exceptions.internalToException(raw_exn); + if (exn.RE_EXN_ID === Foo) { + return; + } + throw exn; + } +} + +test(100); + +function read_lines(inc) { + let _acc = /* [] */0; + while (true) { + let acc = _acc; + let l; + try { + l = input_line(inc); + } catch (raw_exn) { + let exn = Primitive_exceptions.internalToException(raw_exn); + if (exn.RE_EXN_ID === "End_of_file") { + l = undefined; + } else { + throw exn; + } + } + if (l === undefined) { + return Belt_List.reverse(acc); + } + _acc = { + hd: l, + tl: acc + }; + continue; + }; +} + +function read_lines2(inc) { + let _acc = /* [] */0; + while (true) { + let acc = _acc; + let l; + try { + l = input_line(inc); + } catch (raw_exn) { + let exn = Primitive_exceptions.internalToException(raw_exn); + if (exn.RE_EXN_ID === "End_of_file") { + return Belt_List.reverse(acc); + } + throw exn; + } + _acc = { + hd: l, + tl: acc + }; + continue; + }; +} + +function read_lines3(inc) { + let loop = acc => { + try { + let l = input_line(inc); + return loop({ + hd: l, + tl: acc + }); + } catch (raw_exn) { + let exn = Primitive_exceptions.internalToException(raw_exn); + if (exn.RE_EXN_ID === "End_of_file") { + return Belt_List.reverse(acc); + } + throw exn; + } + }; + return loop(/* [] */0); +} + +function fff(f, x) { + try { + return fff(f, x); + } catch (exn) { + return x + 1 | 0; + } +} + +export { + Foo, + test, + read_lines, + read_lines2, + read_lines3, + fff, +} +/* Not a pure module */ diff --git a/tests/tests/src/gpr_1716_test.js b/tests/tests/src/gpr_1716_test.js deleted file mode 100644 index 76b85865c4..0000000000 --- a/tests/tests/src/gpr_1716_test.js +++ /dev/null @@ -1,56 +0,0 @@ -// Generated by ReScript, PLEASE EDIT WITH CARE -'use strict'; - -let Mt = require("./mt.js"); -let Primitive_object = require("rescript/lib/js/Primitive_object.js"); - -let suites = { - contents: /* [] */0 -}; - -let test_id = { - contents: 0 -}; - -function eq(loc, x, y) { - test_id.contents = test_id.contents + 1 | 0; - suites.contents = { - hd: [ - loc + (" id " + test_id.contents.toString()), - () => ({ - TAG: "Eq", - _0: x, - _1: y - }) - ], - tl: suites.contents - }; -} - -let a = {}; - -let b = {}; - -Primitive_object.updateDummy(a, { - b: b -}); - -Primitive_object.updateDummy(b, { - a: a -}); - -function is_inifite(x) { - return x.b.a === x; -} - -eq("File \"gpr_1716_test.res\", line 19, characters 3-10", true, is_inifite(a)); - -Mt.from_pair_suites("Gpr_1716_test", suites.contents); - -exports.suites = suites; -exports.test_id = test_id; -exports.eq = eq; -exports.a = a; -exports.b = b; -exports.is_inifite = is_inifite; -/* Not a pure module */ diff --git a/tests/tests/src/gpr_1716_test.mjs b/tests/tests/src/gpr_1716_test.mjs new file mode 100644 index 0000000000..736d033164 --- /dev/null +++ b/tests/tests/src/gpr_1716_test.mjs @@ -0,0 +1,57 @@ +// Generated by ReScript, PLEASE EDIT WITH CARE + +import * as Mt from "./mt.mjs"; +import * as Primitive_object from "rescript/lib/es6/Primitive_object.js"; + +let suites = { + contents: /* [] */0 +}; + +let test_id = { + contents: 0 +}; + +function eq(loc, x, y) { + test_id.contents = test_id.contents + 1 | 0; + suites.contents = { + hd: [ + loc + (" id " + test_id.contents.toString()), + () => ({ + TAG: "Eq", + _0: x, + _1: y + }) + ], + tl: suites.contents + }; +} + +let a = {}; + +let b = {}; + +Primitive_object.updateDummy(a, { + b: b +}); + +Primitive_object.updateDummy(b, { + a: a +}); + +function is_inifite(x) { + return x.b.a === x; +} + +eq("File \"gpr_1716_test.res\", line 19, characters 3-10", true, is_inifite(a)); + +Mt.from_pair_suites("Gpr_1716_test", suites.contents); + +export { + suites, + test_id, + eq, + a, + b, + is_inifite, +} +/* Not a pure module */ diff --git a/tests/tests/src/gpr_1717_test.js b/tests/tests/src/gpr_1717_test.js deleted file mode 100644 index f1543fa85f..0000000000 --- a/tests/tests/src/gpr_1717_test.js +++ /dev/null @@ -1,14 +0,0 @@ -// Generated by ReScript, PLEASE EDIT WITH CARE -'use strict'; - - -let A = {}; - -let A0 = {}; - -let A1 = {}; - -exports.A = A; -exports.A0 = A0; -exports.A1 = A1; -/* No side effect */ diff --git a/tests/tests/src/gpr_1717_test.mjs b/tests/tests/src/gpr_1717_test.mjs new file mode 100644 index 0000000000..a3c3f5cab5 --- /dev/null +++ b/tests/tests/src/gpr_1717_test.mjs @@ -0,0 +1,15 @@ +// Generated by ReScript, PLEASE EDIT WITH CARE + + +let A = {}; + +let A0 = {}; + +let A1 = {}; + +export { + A, + A0, + A1, +} +/* No side effect */ diff --git a/tests/tests/src/gpr_1728_test.js b/tests/tests/src/gpr_1728_test.js deleted file mode 100644 index 629b951788..0000000000 --- a/tests/tests/src/gpr_1728_test.js +++ /dev/null @@ -1,61 +0,0 @@ -// Generated by ReScript, PLEASE EDIT WITH CARE -'use strict'; - -let Mt = require("./mt.js"); - -let suites = { - contents: /* [] */0 -}; - -let test_id = { - contents: 0 -}; - -function eq(loc, x, y) { - test_id.contents = test_id.contents + 1 | 0; - suites.contents = { - hd: [ - loc + (" id " + test_id.contents.toString()), - () => ({ - TAG: "Eq", - _0: x, - _1: y - }) - ], - tl: suites.contents - }; -} - -function foo(x) { - return Number.parseInt(x) !== 3; -} - -function badInlining(obj) { - let x = obj.field; - Number.parseInt(x) !== 3; -} - -eq("File \"gpr_1728_test.res\", line 21, characters 3-10", badInlining({ - field: "3" -}), undefined); - -eq("File \"gpr_1728_test.res\", line 23, characters 3-10", Number.parseInt("-13"), -13); - -eq("File \"gpr_1728_test.res\", line 24, characters 3-10", Number.parseInt("+13"), 13); - -eq("File \"gpr_1728_test.res\", line 25, characters 3-10", Number.parseInt("13"), 13); - -eq("File \"gpr_1728_test.res\", line 26, characters 3-10", Number.parseInt("+0x32"), 50); - -eq("File \"gpr_1728_test.res\", line 27, characters 3-10", Number.parseInt("-0x32"), -50); - -eq("File \"gpr_1728_test.res\", line 28, characters 3-10", Number.parseInt("0x32"), 50); - -Mt.from_pair_suites("Gpr_1728_test", suites.contents); - -exports.suites = suites; -exports.test_id = test_id; -exports.eq = eq; -exports.foo = foo; -exports.badInlining = badInlining; -/* Not a pure module */ diff --git a/tests/tests/src/gpr_1728_test.mjs b/tests/tests/src/gpr_1728_test.mjs new file mode 100644 index 0000000000..d06df97cef --- /dev/null +++ b/tests/tests/src/gpr_1728_test.mjs @@ -0,0 +1,62 @@ +// Generated by ReScript, PLEASE EDIT WITH CARE + +import * as Mt from "./mt.mjs"; + +let suites = { + contents: /* [] */0 +}; + +let test_id = { + contents: 0 +}; + +function eq(loc, x, y) { + test_id.contents = test_id.contents + 1 | 0; + suites.contents = { + hd: [ + loc + (" id " + test_id.contents.toString()), + () => ({ + TAG: "Eq", + _0: x, + _1: y + }) + ], + tl: suites.contents + }; +} + +function foo(x) { + return Number.parseInt(x) !== 3; +} + +function badInlining(obj) { + let x = obj.field; + Number.parseInt(x) !== 3; +} + +eq("File \"gpr_1728_test.res\", line 21, characters 3-10", badInlining({ + field: "3" +}), undefined); + +eq("File \"gpr_1728_test.res\", line 23, characters 3-10", Number.parseInt("-13"), -13); + +eq("File \"gpr_1728_test.res\", line 24, characters 3-10", Number.parseInt("+13"), 13); + +eq("File \"gpr_1728_test.res\", line 25, characters 3-10", Number.parseInt("13"), 13); + +eq("File \"gpr_1728_test.res\", line 26, characters 3-10", Number.parseInt("+0x32"), 50); + +eq("File \"gpr_1728_test.res\", line 27, characters 3-10", Number.parseInt("-0x32"), -50); + +eq("File \"gpr_1728_test.res\", line 28, characters 3-10", Number.parseInt("0x32"), 50); + +Mt.from_pair_suites("Gpr_1728_test", suites.contents); + +export { + suites, + test_id, + eq, + foo, + badInlining, +} +/* Not a pure module */ diff --git a/tests/tests/src/gpr_1749_test.js b/tests/tests/src/gpr_1749_test.js deleted file mode 100644 index 72fc1b73ba..0000000000 --- a/tests/tests/src/gpr_1749_test.js +++ /dev/null @@ -1,39 +0,0 @@ -// Generated by ReScript, PLEASE EDIT WITH CARE -'use strict'; - -let Mt = require("./mt.js"); - -let suites = { - contents: /* [] */0 -}; - -let test_id = { - contents: 0 -}; - -function eq(loc, x, y) { - test_id.contents = test_id.contents + 1 | 0; - suites.contents = { - hd: [ - loc + (" id " + test_id.contents.toString()), - () => ({ - TAG: "Eq", - _0: x, - _1: y - }) - ], - tl: suites.contents - }; -} - -eq("File \"gpr_1749_test.res\", line 18, characters 3-10", 0, 0); - -Mt.from_pair_suites("Gpr_1749_test", suites.contents); - -let a = 0; - -exports.suites = suites; -exports.test_id = test_id; -exports.eq = eq; -exports.a = a; -/* Not a pure module */ diff --git a/tests/tests/src/gpr_1749_test.mjs b/tests/tests/src/gpr_1749_test.mjs new file mode 100644 index 0000000000..84539b9ad7 --- /dev/null +++ b/tests/tests/src/gpr_1749_test.mjs @@ -0,0 +1,40 @@ +// Generated by ReScript, PLEASE EDIT WITH CARE + +import * as Mt from "./mt.mjs"; + +let suites = { + contents: /* [] */0 +}; + +let test_id = { + contents: 0 +}; + +function eq(loc, x, y) { + test_id.contents = test_id.contents + 1 | 0; + suites.contents = { + hd: [ + loc + (" id " + test_id.contents.toString()), + () => ({ + TAG: "Eq", + _0: x, + _1: y + }) + ], + tl: suites.contents + }; +} + +eq("File \"gpr_1749_test.res\", line 18, characters 3-10", 0, 0); + +Mt.from_pair_suites("Gpr_1749_test", suites.contents); + +let a = 0; + +export { + suites, + test_id, + eq, + a, +} +/* Not a pure module */ diff --git a/tests/tests/src/gpr_1759_test.js b/tests/tests/src/gpr_1759_test.mjs similarity index 100% rename from tests/tests/src/gpr_1759_test.js rename to tests/tests/src/gpr_1759_test.mjs diff --git a/tests/tests/src/gpr_1760_test.js b/tests/tests/src/gpr_1760_test.js deleted file mode 100644 index 7338f82e64..0000000000 --- a/tests/tests/src/gpr_1760_test.js +++ /dev/null @@ -1,63 +0,0 @@ -// Generated by ReScript, PLEASE EDIT WITH CARE -'use strict'; - -let Mt = require("./mt.js"); -let Primitive_int = require("rescript/lib/js/Primitive_int.js"); - -let suites = { - contents: /* [] */0 -}; - -let test_id = { - contents: 0 -}; - -function eq(loc, x, y) { - test_id.contents = test_id.contents + 1 | 0; - suites.contents = { - hd: [ - loc + (" id " + test_id.contents.toString()), - () => ({ - TAG: "Eq", - _0: x, - _1: y - }) - ], - tl: suites.contents - }; -} - -let a0; - -try { - Primitive_int.div(0, 0); - a0 = 0; -} catch (exn) { - a0 = 1; -} - -let a1; - -try { - Primitive_int.mod_(0, 0); - a1 = 0; -} catch (exn$1) { - a1 = 1; -} - -eq("File \"gpr_1760_test.res\", line 26, characters 3-10", [ - a0, - a1 -], [ - 1, - 1 -]); - -Mt.from_pair_suites("Gpr_1760_test", suites.contents); - -exports.suites = suites; -exports.test_id = test_id; -exports.eq = eq; -exports.a0 = a0; -exports.a1 = a1; -/* a0 Not a pure module */ diff --git a/tests/tests/src/gpr_1760_test.mjs b/tests/tests/src/gpr_1760_test.mjs new file mode 100644 index 0000000000..37d83370f7 --- /dev/null +++ b/tests/tests/src/gpr_1760_test.mjs @@ -0,0 +1,64 @@ +// Generated by ReScript, PLEASE EDIT WITH CARE + +import * as Mt from "./mt.mjs"; +import * as Primitive_int from "rescript/lib/es6/Primitive_int.js"; + +let suites = { + contents: /* [] */0 +}; + +let test_id = { + contents: 0 +}; + +function eq(loc, x, y) { + test_id.contents = test_id.contents + 1 | 0; + suites.contents = { + hd: [ + loc + (" id " + test_id.contents.toString()), + () => ({ + TAG: "Eq", + _0: x, + _1: y + }) + ], + tl: suites.contents + }; +} + +let a0; + +try { + Primitive_int.div(0, 0); + a0 = 0; +} catch (exn) { + a0 = 1; +} + +let a1; + +try { + Primitive_int.mod_(0, 0); + a1 = 0; +} catch (exn$1) { + a1 = 1; +} + +eq("File \"gpr_1760_test.res\", line 26, characters 3-10", [ + a0, + a1 +], [ + 1, + 1 +]); + +Mt.from_pair_suites("Gpr_1760_test", suites.contents); + +export { + suites, + test_id, + eq, + a0, + a1, +} +/* a0 Not a pure module */ diff --git a/tests/tests/src/gpr_1762_test.js b/tests/tests/src/gpr_1762_test.js deleted file mode 100644 index b17bbc3718..0000000000 --- a/tests/tests/src/gpr_1762_test.js +++ /dev/null @@ -1,49 +0,0 @@ -// Generated by ReScript, PLEASE EDIT WITH CARE -'use strict'; - -let Mt = require("./mt.js"); - -let suites = { - contents: /* [] */0 -}; - -let test_id = { - contents: 0 -}; - -function eq(loc, x, y) { - test_id.contents = test_id.contents + 1 | 0; - suites.contents = { - hd: [ - loc + (" id " + test_id.contents.toString()), - () => ({ - TAG: "Eq", - _0: x, - _1: y - }) - ], - tl: suites.contents - }; -} - -let v = { - contents: 3 -}; - -function update() { - v.contents = v.contents + 1 | 0; - return true; -} - -v.contents = v.contents + 1 | 0; - -eq("File \"gpr_1762_test.res\", line 27, characters 3-10", v.contents, 4); - -Mt.from_pair_suites("Gpr_1762_test", suites.contents); - -exports.suites = suites; -exports.test_id = test_id; -exports.eq = eq; -exports.v = v; -exports.update = update; -/* Not a pure module */ diff --git a/tests/tests/src/gpr_1762_test.mjs b/tests/tests/src/gpr_1762_test.mjs new file mode 100644 index 0000000000..23ea3ade99 --- /dev/null +++ b/tests/tests/src/gpr_1762_test.mjs @@ -0,0 +1,50 @@ +// Generated by ReScript, PLEASE EDIT WITH CARE + +import * as Mt from "./mt.mjs"; + +let suites = { + contents: /* [] */0 +}; + +let test_id = { + contents: 0 +}; + +function eq(loc, x, y) { + test_id.contents = test_id.contents + 1 | 0; + suites.contents = { + hd: [ + loc + (" id " + test_id.contents.toString()), + () => ({ + TAG: "Eq", + _0: x, + _1: y + }) + ], + tl: suites.contents + }; +} + +let v = { + contents: 3 +}; + +function update() { + v.contents = v.contents + 1 | 0; + return true; +} + +v.contents = v.contents + 1 | 0; + +eq("File \"gpr_1762_test.res\", line 27, characters 3-10", v.contents, 4); + +Mt.from_pair_suites("Gpr_1762_test", suites.contents); + +export { + suites, + test_id, + eq, + v, + update, +} +/* Not a pure module */ diff --git a/tests/tests/src/gpr_1817_test.js b/tests/tests/src/gpr_1817_test.js deleted file mode 100644 index 44fc6903c2..0000000000 --- a/tests/tests/src/gpr_1817_test.js +++ /dev/null @@ -1,61 +0,0 @@ -// Generated by ReScript, PLEASE EDIT WITH CARE -'use strict'; - -let Mt = require("./mt.js"); -let Primitive_object = require("rescript/lib/js/Primitive_object.js"); - -let suites = { - contents: /* [] */0 -}; - -let test_id = { - contents: 0 -}; - -function eq(loc, x, y) { - test_id.contents = test_id.contents + 1 | 0; - suites.contents = { - hd: [ - loc + (" id " + test_id.contents.toString()), - () => ({ - TAG: "Eq", - _0: x, - _1: y - }) - ], - tl: suites.contents - }; -} - -function f() { - let x = new Date(); - let y = new Date(); - return [ - Primitive_object.greaterthan(y, x), - Primitive_object.lessthan(y, x), - true - ]; -} - -let match = f(); - -let a2 = match[2]; - -let a1 = match[1]; - -let a0 = match[0]; - -console.log(a0, a1); - -eq("File \"gpr_1817_test.res\", line 23, characters 3-10", a2, true); - -Mt.from_pair_suites("Gpr_1817_test", suites.contents); - -exports.suites = suites; -exports.test_id = test_id; -exports.eq = eq; -exports.f = f; -exports.a0 = a0; -exports.a1 = a1; -exports.a2 = a2; -/* match Not a pure module */ diff --git a/tests/tests/src/gpr_1817_test.mjs b/tests/tests/src/gpr_1817_test.mjs new file mode 100644 index 0000000000..44b33b3797 --- /dev/null +++ b/tests/tests/src/gpr_1817_test.mjs @@ -0,0 +1,62 @@ +// Generated by ReScript, PLEASE EDIT WITH CARE + +import * as Mt from "./mt.mjs"; +import * as Primitive_object from "rescript/lib/es6/Primitive_object.js"; + +let suites = { + contents: /* [] */0 +}; + +let test_id = { + contents: 0 +}; + +function eq(loc, x, y) { + test_id.contents = test_id.contents + 1 | 0; + suites.contents = { + hd: [ + loc + (" id " + test_id.contents.toString()), + () => ({ + TAG: "Eq", + _0: x, + _1: y + }) + ], + tl: suites.contents + }; +} + +function f() { + let x = new Date(); + let y = new Date(); + return [ + Primitive_object.greaterthan(y, x), + Primitive_object.lessthan(y, x), + true + ]; +} + +let match = f(); + +let a2 = match[2]; + +let a1 = match[1]; + +let a0 = match[0]; + +console.log(a0, a1); + +eq("File \"gpr_1817_test.res\", line 23, characters 3-10", a2, true); + +Mt.from_pair_suites("Gpr_1817_test", suites.contents); + +export { + suites, + test_id, + eq, + f, + a0, + a1, + a2, +} +/* match Not a pure module */ diff --git a/tests/tests/src/gpr_1822_test.js b/tests/tests/src/gpr_1822_test.js deleted file mode 100644 index 71b86d9e3f..0000000000 --- a/tests/tests/src/gpr_1822_test.js +++ /dev/null @@ -1,47 +0,0 @@ -// Generated by ReScript, PLEASE EDIT WITH CARE -'use strict'; - -let Mt = require("./mt.js"); - -let suites = { - contents: /* [] */0 -}; - -let test_id = { - contents: 0 -}; - -function eq(loc, x, y) { - test_id.contents = test_id.contents + 1 | 0; - suites.contents = { - hd: [ - loc + (" id " + test_id.contents.toString()), - () => ({ - TAG: "Eq", - _0: x, - _1: y - }) - ], - tl: suites.contents - }; -} - -let myShape = { - TAG: "Circle", - _0: 10 -}; - -let area; - -area = myShape.TAG === "Circle" ? 100 * 3.14 : Math.imul(10, myShape._1); - -eq("File \"gpr_1822_test.res\", line 23, characters 3-10", area, 314); - -Mt.from_pair_suites("Gpr_1822_test", suites.contents); - -exports.suites = suites; -exports.test_id = test_id; -exports.eq = eq; -exports.myShape = myShape; -exports.area = area; -/* area Not a pure module */ diff --git a/tests/tests/src/gpr_1822_test.mjs b/tests/tests/src/gpr_1822_test.mjs new file mode 100644 index 0000000000..9706a4d490 --- /dev/null +++ b/tests/tests/src/gpr_1822_test.mjs @@ -0,0 +1,48 @@ +// Generated by ReScript, PLEASE EDIT WITH CARE + +import * as Mt from "./mt.mjs"; + +let suites = { + contents: /* [] */0 +}; + +let test_id = { + contents: 0 +}; + +function eq(loc, x, y) { + test_id.contents = test_id.contents + 1 | 0; + suites.contents = { + hd: [ + loc + (" id " + test_id.contents.toString()), + () => ({ + TAG: "Eq", + _0: x, + _1: y + }) + ], + tl: suites.contents + }; +} + +let myShape = { + TAG: "Circle", + _0: 10 +}; + +let area; + +area = myShape.TAG === "Circle" ? 100 * 3.14 : Math.imul(10, myShape._1); + +eq("File \"gpr_1822_test.res\", line 23, characters 3-10", area, 314); + +Mt.from_pair_suites("Gpr_1822_test", suites.contents); + +export { + suites, + test_id, + eq, + myShape, + area, +} +/* area Not a pure module */ diff --git a/tests/tests/src/gpr_1891_test.js b/tests/tests/src/gpr_1891_test.js deleted file mode 100644 index 0be949d234..0000000000 --- a/tests/tests/src/gpr_1891_test.js +++ /dev/null @@ -1,49 +0,0 @@ -// Generated by ReScript, PLEASE EDIT WITH CARE -'use strict'; - - -function foo(x) { - if (typeof x === "object" && x.NAME === "Foo" && x.VAL === 3) { - console.log("1"); - } else { - console.log("2"); - } -} - -function foo2(x) { - if (typeof x === "object" && x.NAME === "Foo" && x.VAL === 3) { - return "xxxx"; - } else { - return "xxx"; - } -} - -function foo3(x) { - if (typeof x === "object" && x.NAME === "Foo" && x.VAL === 3) { - return 1; - } else { - return 2; - } -} - -function foo4(x, h) { - if (typeof x === "object" && x.NAME === "Foo" && x.VAL === 3) { - return h(); - } - -} - -function foo5(x) { - if (typeof x === "object" && x.NAME === "Foo" && x.VAL === 3) { - console.log("hi"); - } else { - console.log("x"); - } -} - -exports.foo = foo; -exports.foo2 = foo2; -exports.foo3 = foo3; -exports.foo4 = foo4; -exports.foo5 = foo5; -/* No side effect */ diff --git a/tests/tests/src/gpr_1891_test.mjs b/tests/tests/src/gpr_1891_test.mjs new file mode 100644 index 0000000000..7896f4d914 --- /dev/null +++ b/tests/tests/src/gpr_1891_test.mjs @@ -0,0 +1,50 @@ +// Generated by ReScript, PLEASE EDIT WITH CARE + + +function foo(x) { + if (typeof x === "object" && x.NAME === "Foo" && x.VAL === 3) { + console.log("1"); + } else { + console.log("2"); + } +} + +function foo2(x) { + if (typeof x === "object" && x.NAME === "Foo" && x.VAL === 3) { + return "xxxx"; + } else { + return "xxx"; + } +} + +function foo3(x) { + if (typeof x === "object" && x.NAME === "Foo" && x.VAL === 3) { + return 1; + } else { + return 2; + } +} + +function foo4(x, h) { + if (typeof x === "object" && x.NAME === "Foo" && x.VAL === 3) { + return h(); + } + +} + +function foo5(x) { + if (typeof x === "object" && x.NAME === "Foo" && x.VAL === 3) { + console.log("hi"); + } else { + console.log("x"); + } +} + +export { + foo, + foo2, + foo3, + foo4, + foo5, +} +/* No side effect */ diff --git a/tests/tests/src/gpr_1943_test.js b/tests/tests/src/gpr_1943_test.js deleted file mode 100644 index a49712564e..0000000000 --- a/tests/tests/src/gpr_1943_test.js +++ /dev/null @@ -1,68 +0,0 @@ -// Generated by ReScript, PLEASE EDIT WITH CARE -'use strict'; - -let Mt = require("./mt.js"); - -let suites = { - contents: /* [] */0 -}; - -let test_id = { - contents: 0 -}; - -function eq(loc, x, y) { - test_id.contents = test_id.contents + 1 | 0; - suites.contents = { - hd: [ - loc + (" id " + test_id.contents.toString()), - () => ({ - TAG: "Eq", - _0: x, - _1: y - }) - ], - tl: suites.contents - }; -} - -function f(x) { - return [ - x._003, - x._50, - x._50x, - x.__50, - x.__50x, - x["_50x'"], - x["x'"] - ]; -} - -let v = f({ - _003: 0, - _50: 1, - _50x: 2, - __50: 3, - __50x: 4, - "_50x'": 5, - "x'": 6 -}); - -eq("File \"gpr_1943_test.res\", line 26, characters 3-10", [ - 0, - 1, - 2, - 3, - 4, - 5, - 6 -], v); - -Mt.from_pair_suites("Gpr_1943_test", suites.contents); - -exports.suites = suites; -exports.test_id = test_id; -exports.eq = eq; -exports.f = f; -exports.v = v; -/* v Not a pure module */ diff --git a/tests/tests/src/gpr_1943_test.mjs b/tests/tests/src/gpr_1943_test.mjs new file mode 100644 index 0000000000..2b4d0fbaf7 --- /dev/null +++ b/tests/tests/src/gpr_1943_test.mjs @@ -0,0 +1,69 @@ +// Generated by ReScript, PLEASE EDIT WITH CARE + +import * as Mt from "./mt.mjs"; + +let suites = { + contents: /* [] */0 +}; + +let test_id = { + contents: 0 +}; + +function eq(loc, x, y) { + test_id.contents = test_id.contents + 1 | 0; + suites.contents = { + hd: [ + loc + (" id " + test_id.contents.toString()), + () => ({ + TAG: "Eq", + _0: x, + _1: y + }) + ], + tl: suites.contents + }; +} + +function f(x) { + return [ + x._003, + x._50, + x._50x, + x.__50, + x.__50x, + x["_50x'"], + x["x'"] + ]; +} + +let v = f({ + _003: 0, + _50: 1, + _50x: 2, + __50: 3, + __50x: 4, + "_50x'": 5, + "x'": 6 +}); + +eq("File \"gpr_1943_test.res\", line 26, characters 3-10", [ + 0, + 1, + 2, + 3, + 4, + 5, + 6 +], v); + +Mt.from_pair_suites("Gpr_1943_test", suites.contents); + +export { + suites, + test_id, + eq, + f, + v, +} +/* v Not a pure module */ diff --git a/tests/tests/src/gpr_1946_test.js b/tests/tests/src/gpr_1946_test.js deleted file mode 100644 index f57d17a937..0000000000 --- a/tests/tests/src/gpr_1946_test.js +++ /dev/null @@ -1,64 +0,0 @@ -// Generated by ReScript, PLEASE EDIT WITH CARE -'use strict'; - -let Mt = require("./mt.js"); - -let suites = { - contents: /* [] */0 -}; - -let test_id = { - contents: 0 -}; - -function eq(loc, x, y) { - Mt.eq_suites(test_id, suites, loc, x, y); -} - -let x = ({ - x: 3, - y: 4 -}).x; - -let zz = ({ - _5: 3 -})._5; - -let h = { - "0123": 2, - "123_456": 3 -}; - -function f(id) { - while (false) { - - }; - return id; -} - -eq("File \"gpr_1946_test.res\", line 24, characters 3-10", ({ - _5: 3 -})._5, 3); - -eq("File \"gpr_1946_test.res\", line 25, characters 3-10", [ - 2, - 3 -], [ - f(h)["0123"], - f(h)["123_456"] -]); - -console.log(({ - _5: 3 - }).TAG); - -Mt.from_pair_suites("File \"gpr_1946_test.res\", line 28, characters 20-27", suites.contents); - -exports.suites = suites; -exports.test_id = test_id; -exports.eq = eq; -exports.x = x; -exports.zz = zz; -exports.h = h; -exports.f = f; -/* x Not a pure module */ diff --git a/tests/tests/src/gpr_1946_test.mjs b/tests/tests/src/gpr_1946_test.mjs new file mode 100644 index 0000000000..22c9c267a8 --- /dev/null +++ b/tests/tests/src/gpr_1946_test.mjs @@ -0,0 +1,65 @@ +// Generated by ReScript, PLEASE EDIT WITH CARE + +import * as Mt from "./mt.mjs"; + +let suites = { + contents: /* [] */0 +}; + +let test_id = { + contents: 0 +}; + +function eq(loc, x, y) { + Mt.eq_suites(test_id, suites, loc, x, y); +} + +let x = ({ + x: 3, + y: 4 +}).x; + +let zz = ({ + _5: 3 +})._5; + +let h = { + "0123": 2, + "123_456": 3 +}; + +function f(id) { + while (false) { + + }; + return id; +} + +eq("File \"gpr_1946_test.res\", line 24, characters 3-10", ({ + _5: 3 +})._5, 3); + +eq("File \"gpr_1946_test.res\", line 25, characters 3-10", [ + 2, + 3 +], [ + f(h)["0123"], + f(h)["123_456"] +]); + +console.log(({ + _5: 3 + }).TAG); + +Mt.from_pair_suites("File \"gpr_1946_test.res\", line 28, characters 20-27", suites.contents); + +export { + suites, + test_id, + eq, + x, + zz, + h, + f, +} +/* x Not a pure module */ diff --git a/tests/tests/src/gpr_2316_test.js b/tests/tests/src/gpr_2316_test.js deleted file mode 100644 index a0bc150bb7..0000000000 --- a/tests/tests/src/gpr_2316_test.js +++ /dev/null @@ -1,79 +0,0 @@ -// Generated by ReScript, PLEASE EDIT WITH CARE -'use strict'; - -let Mt = require("./mt.js"); -let Pervasives = require("rescript/lib/js/Pervasives.js"); -let Primitive_exceptions = require("rescript/lib/js/Primitive_exceptions.js"); - -let suites = { - contents: /* [] */0 -}; - -let test_id = { - contents: 0 -}; - -function eq(loc, x, y) { - test_id.contents = test_id.contents + 1 | 0; - suites.contents = { - hd: [ - loc + (" id " + test_id.contents.toString()), - () => ({ - TAG: "Eq", - _0: x, - _1: y - }) - ], - tl: suites.contents - }; -} - -let y; - -try { - Pervasives.failwith("boo"); - y = undefined; -} catch (raw_msg) { - let msg = Primitive_exceptions.internalToException(raw_msg); - if (msg.RE_EXN_ID === "Failure") { - y = msg._1; - } else { - throw msg; - } -} - -let x; - -let exit = 0; - -let e; - -try { - e = Pervasives.failwith("boo"); - exit = 1; -} catch (raw_msg$1) { - let msg$1 = Primitive_exceptions.internalToException(raw_msg$1); - if (msg$1.RE_EXN_ID === "Failure") { - x = msg$1._1; - } else { - throw msg$1; - } -} - -if (exit === 1) { - console.log("ok"); - x = undefined; -} - -eq("File \"gpr_2316_test.res\", line 25, characters 5-12", y, "boo"); - -eq("File \"gpr_2316_test.res\", line 26, characters 5-12", x, "boo"); - -Mt.from_pair_suites("Gpr_2316_test", suites.contents); - -exports.suites = suites; -exports.test_id = test_id; -exports.eq = eq; -exports.y = y; -exports.x = x; -/* y Not a pure module */ diff --git a/tests/tests/src/gpr_2316_test.mjs b/tests/tests/src/gpr_2316_test.mjs new file mode 100644 index 0000000000..6041bebb16 --- /dev/null +++ b/tests/tests/src/gpr_2316_test.mjs @@ -0,0 +1,80 @@ +// Generated by ReScript, PLEASE EDIT WITH CARE + +import * as Mt from "./mt.mjs"; +import * as Pervasives from "rescript/lib/es6/Pervasives.js"; +import * as Primitive_exceptions from "rescript/lib/es6/Primitive_exceptions.js"; + +let suites = { + contents: /* [] */0 +}; + +let test_id = { + contents: 0 +}; + +function eq(loc, x, y) { + test_id.contents = test_id.contents + 1 | 0; + suites.contents = { + hd: [ + loc + (" id " + test_id.contents.toString()), + () => ({ + TAG: "Eq", + _0: x, + _1: y + }) + ], + tl: suites.contents + }; +} + +let y; + +try { + Pervasives.failwith("boo"); + y = undefined; +} catch (raw_msg) { + let msg = Primitive_exceptions.internalToException(raw_msg); + if (msg.RE_EXN_ID === "Failure") { + y = msg._1; + } else { + throw msg; + } +} + +let x; + +let exit = 0; + +let e; + +try { + e = Pervasives.failwith("boo"); + exit = 1; +} catch (raw_msg$1) { + let msg$1 = Primitive_exceptions.internalToException(raw_msg$1); + if (msg$1.RE_EXN_ID === "Failure") { + x = msg$1._1; + } else { + throw msg$1; + } +} + +if (exit === 1) { + console.log("ok"); + x = undefined; +} + +eq("File \"gpr_2316_test.res\", line 25, characters 5-12", y, "boo"); + +eq("File \"gpr_2316_test.res\", line 26, characters 5-12", x, "boo"); + +Mt.from_pair_suites("Gpr_2316_test", suites.contents); + +export { + suites, + test_id, + eq, + y, + x, +} +/* y Not a pure module */ diff --git a/tests/tests/src/gpr_2352_test.js b/tests/tests/src/gpr_2352_test.js deleted file mode 100644 index 887a6902cf..0000000000 --- a/tests/tests/src/gpr_2352_test.js +++ /dev/null @@ -1,10 +0,0 @@ -// Generated by ReScript, PLEASE EDIT WITH CARE -'use strict'; - - -function f(x) { - x.hey = 22; -} - -exports.f = f; -/* No side effect */ diff --git a/tests/tests/src/gpr_2352_test.mjs b/tests/tests/src/gpr_2352_test.mjs new file mode 100644 index 0000000000..ec07255ef3 --- /dev/null +++ b/tests/tests/src/gpr_2352_test.mjs @@ -0,0 +1,11 @@ +// Generated by ReScript, PLEASE EDIT WITH CARE + + +function f(x) { + x.hey = 22; +} + +export { + f, +} +/* No side effect */ diff --git a/tests/tests/src/gpr_2413_test.js b/tests/tests/src/gpr_2413_test.js deleted file mode 100644 index 02d6c20738..0000000000 --- a/tests/tests/src/gpr_2413_test.js +++ /dev/null @@ -1,35 +0,0 @@ -// Generated by ReScript, PLEASE EDIT WITH CARE -'use strict'; - - -function f(x) { - switch (x.TAG) { - case "A" : - let a = x._0; - if (a.TAG === "P") { - let a$1 = a._0; - return a$1 + a$1 | 0; - } - let a$2 = a._0; - return a$2 - a$2 | 0; - case "B" : - case "C" : - break; - } - let a$3 = x._0._0; - return Math.imul(a$3, a$3); -} - -function ff(c) { - c.contents = c.contents + 1 | 0; - let match = (1 + c.contents | 0) + 1 | 0; - if (match > 3 || match < 0) { - return 0; - } else { - return match + 1 | 0; - } -} - -exports.f = f; -exports.ff = ff; -/* No side effect */ diff --git a/tests/tests/src/gpr_2413_test.mjs b/tests/tests/src/gpr_2413_test.mjs new file mode 100644 index 0000000000..1bfc18d21a --- /dev/null +++ b/tests/tests/src/gpr_2413_test.mjs @@ -0,0 +1,36 @@ +// Generated by ReScript, PLEASE EDIT WITH CARE + + +function f(x) { + switch (x.TAG) { + case "A" : + let a = x._0; + if (a.TAG === "P") { + let a$1 = a._0; + return a$1 + a$1 | 0; + } + let a$2 = a._0; + return a$2 - a$2 | 0; + case "B" : + case "C" : + break; + } + let a$3 = x._0._0; + return Math.imul(a$3, a$3); +} + +function ff(c) { + c.contents = c.contents + 1 | 0; + let match = (1 + c.contents | 0) + 1 | 0; + if (match > 3 || match < 0) { + return 0; + } else { + return match + 1 | 0; + } +} + +export { + f, + ff, +} +/* No side effect */ diff --git a/tests/tests/src/gpr_2474.js b/tests/tests/src/gpr_2474.js deleted file mode 100644 index 891bfb92bb..0000000000 --- a/tests/tests/src/gpr_2474.js +++ /dev/null @@ -1,8 +0,0 @@ -// Generated by ReScript, PLEASE EDIT WITH CARE -'use strict'; - - -let coordinates = 1; - -exports.coordinates = coordinates; -/* No side effect */ diff --git a/tests/tests/src/gpr_2474.mjs b/tests/tests/src/gpr_2474.mjs new file mode 100644 index 0000000000..a8c4e71e85 --- /dev/null +++ b/tests/tests/src/gpr_2474.mjs @@ -0,0 +1,9 @@ +// Generated by ReScript, PLEASE EDIT WITH CARE + + +let coordinates = 1; + +export { + coordinates, +} +/* No side effect */ diff --git a/tests/tests/src/gpr_2487.js b/tests/tests/src/gpr_2487.js deleted file mode 100644 index 97d0d0262d..0000000000 --- a/tests/tests/src/gpr_2487.js +++ /dev/null @@ -1,20 +0,0 @@ -// Generated by ReScript, PLEASE EDIT WITH CARE -'use strict'; - -let Belt_Array = require("rescript/lib/js/Belt_Array.js"); - -let b = Belt_Array.eq([ - 1, - 2, - 3 -], [ - 1, - 2, - 3 -], (prim0, prim1) => prim0 === prim1); - -let A; - -exports.A = A; -exports.b = b; -/* b Not a pure module */ diff --git a/tests/tests/src/gpr_2487.mjs b/tests/tests/src/gpr_2487.mjs new file mode 100644 index 0000000000..4a526a73c6 --- /dev/null +++ b/tests/tests/src/gpr_2487.mjs @@ -0,0 +1,21 @@ +// Generated by ReScript, PLEASE EDIT WITH CARE + +import * as Belt_Array from "rescript/lib/es6/Belt_Array.js"; + +let b = Belt_Array.eq([ + 1, + 2, + 3 +], [ + 1, + 2, + 3 +], (prim0, prim1) => prim0 === prim1); + +let A; + +export { + A, + b, +} +/* b Not a pure module */ diff --git a/tests/tests/src/gpr_2503_test.js b/tests/tests/src/gpr_2503_test.js deleted file mode 100644 index 3d77208865..0000000000 --- a/tests/tests/src/gpr_2503_test.js +++ /dev/null @@ -1,80 +0,0 @@ -// Generated by ReScript, PLEASE EDIT WITH CARE -'use strict'; - -let Mt = require("./mt.js"); -let Primitive_option = require("rescript/lib/js/Primitive_option.js"); - -let suites = { - contents: /* [] */0 -}; - -let test_id = { - contents: 0 -}; - -function eq(loc, x, y) { - Mt.eq_suites(test_id, suites, loc, x, y); -} - -function b(loc, b$1) { - Mt.bool_suites(test_id, suites, loc, b$1); -} - -function makeWrapper(foo, param) { - let tmp = {}; - if (foo !== undefined) { - tmp.foo = Primitive_option.valFromOption(foo); - } - console.log(tmp); -} - -function makeWrapper2(foo, param) { - console.log({ - foo: foo - }); -} - -makeWrapper2("a", undefined); - -function makeWrapper3(foo, param) { - console.log(2); - let tmp = {}; - if (foo !== undefined) { - tmp.foo = Primitive_option.valFromOption(foo); - } - return tmp; -} - -function makeWrapper4(foo, param) { - console.log(2); - let tmp = {}; - let tmp$1 = foo > 100 ? undefined : ( - foo > 10 ? "b" : "a" - ); - if (tmp$1 !== undefined) { - tmp.foo = Primitive_option.valFromOption(tmp$1); - } - return tmp; -} - -b("File \"gpr_2503_test.res\", line 39, characters 2-9", "a" === makeWrapper3("a", undefined).foo); - -b("File \"gpr_2503_test.res\", line 41, characters 2-9", undefined === makeWrapper3(undefined, undefined).foo); - -b("File \"gpr_2503_test.res\", line 43, characters 2-9", "a" === makeWrapper4(1, undefined).foo); - -b("File \"gpr_2503_test.res\", line 45, characters 2-9", "b" === makeWrapper4(11, undefined).foo); - -b("File \"gpr_2503_test.res\", line 47, characters 2-9", undefined === makeWrapper4(111, undefined).foo); - -Mt.from_pair_suites("Gpr_2503_test", suites.contents); - -exports.suites = suites; -exports.test_id = test_id; -exports.eq = eq; -exports.b = b; -exports.makeWrapper = makeWrapper; -exports.makeWrapper2 = makeWrapper2; -exports.makeWrapper3 = makeWrapper3; -exports.makeWrapper4 = makeWrapper4; -/* Not a pure module */ diff --git a/tests/tests/src/gpr_2503_test.mjs b/tests/tests/src/gpr_2503_test.mjs new file mode 100644 index 0000000000..5c814a0086 --- /dev/null +++ b/tests/tests/src/gpr_2503_test.mjs @@ -0,0 +1,81 @@ +// Generated by ReScript, PLEASE EDIT WITH CARE + +import * as Mt from "./mt.mjs"; +import * as Primitive_option from "rescript/lib/es6/Primitive_option.js"; + +let suites = { + contents: /* [] */0 +}; + +let test_id = { + contents: 0 +}; + +function eq(loc, x, y) { + Mt.eq_suites(test_id, suites, loc, x, y); +} + +function b(loc, b$1) { + Mt.bool_suites(test_id, suites, loc, b$1); +} + +function makeWrapper(foo, param) { + let tmp = {}; + if (foo !== undefined) { + tmp.foo = Primitive_option.valFromOption(foo); + } + console.log(tmp); +} + +function makeWrapper2(foo, param) { + console.log({ + foo: foo + }); +} + +makeWrapper2("a", undefined); + +function makeWrapper3(foo, param) { + console.log(2); + let tmp = {}; + if (foo !== undefined) { + tmp.foo = Primitive_option.valFromOption(foo); + } + return tmp; +} + +function makeWrapper4(foo, param) { + console.log(2); + let tmp = {}; + let tmp$1 = foo > 100 ? undefined : ( + foo > 10 ? "b" : "a" + ); + if (tmp$1 !== undefined) { + tmp.foo = Primitive_option.valFromOption(tmp$1); + } + return tmp; +} + +b("File \"gpr_2503_test.res\", line 39, characters 2-9", "a" === makeWrapper3("a", undefined).foo); + +b("File \"gpr_2503_test.res\", line 41, characters 2-9", undefined === makeWrapper3(undefined, undefined).foo); + +b("File \"gpr_2503_test.res\", line 43, characters 2-9", "a" === makeWrapper4(1, undefined).foo); + +b("File \"gpr_2503_test.res\", line 45, characters 2-9", "b" === makeWrapper4(11, undefined).foo); + +b("File \"gpr_2503_test.res\", line 47, characters 2-9", undefined === makeWrapper4(111, undefined).foo); + +Mt.from_pair_suites("Gpr_2503_test", suites.contents); + +export { + suites, + test_id, + eq, + b, + makeWrapper, + makeWrapper2, + makeWrapper3, + makeWrapper4, +} +/* Not a pure module */ diff --git a/tests/tests/src/gpr_2608_test.js b/tests/tests/src/gpr_2608_test.js deleted file mode 100644 index d98dae52f4..0000000000 --- a/tests/tests/src/gpr_2608_test.js +++ /dev/null @@ -1,53 +0,0 @@ -// Generated by ReScript, PLEASE EDIT WITH CARE -'use strict'; - -let Mt = require("./mt.js"); -let Belt_List = require("rescript/lib/js/Belt_List.js"); - -let suites = { - contents: /* [] */0 -}; - -let test_id = { - contents: 0 -}; - -function eq(loc, x, y) { - Mt.eq_suites(test_id, suites, loc, x, y); -} - -let oppHeroes = { - hd: 0, - tl: /* [] */0 -}; - -let huntGrootCondition = false; - -if (Belt_List.length(/* [] */0) > 0) { - let x = Belt_List.filter(oppHeroes, h => Belt_List.headExn(/* [] */0) <= 1000); - huntGrootCondition = Belt_List.length(x) === 0; -} - -let huntGrootCondition2 = true; - -if (Belt_List.length(/* [] */0) < 0) { - let x$1 = Belt_List.filter(oppHeroes, h => Belt_List.headExn(/* [] */0) <= 1000); - huntGrootCondition2 = Belt_List.length(x$1) === 0; -} - -eq("File \"gpr_2608_test.res\", line 23, characters 5-12", huntGrootCondition, false); - -eq("File \"gpr_2608_test.res\", line 24, characters 5-12", huntGrootCondition2, true); - -Mt.from_pair_suites("Gpr_2608_test", suites.contents); - -let nearestGroots = /* [] */0; - -exports.suites = suites; -exports.test_id = test_id; -exports.eq = eq; -exports.nearestGroots = nearestGroots; -exports.oppHeroes = oppHeroes; -exports.huntGrootCondition = huntGrootCondition; -exports.huntGrootCondition2 = huntGrootCondition2; -/* huntGrootCondition Not a pure module */ diff --git a/tests/tests/src/gpr_2608_test.mjs b/tests/tests/src/gpr_2608_test.mjs new file mode 100644 index 0000000000..c21ae62eaf --- /dev/null +++ b/tests/tests/src/gpr_2608_test.mjs @@ -0,0 +1,54 @@ +// Generated by ReScript, PLEASE EDIT WITH CARE + +import * as Mt from "./mt.mjs"; +import * as Belt_List from "rescript/lib/es6/Belt_List.js"; + +let suites = { + contents: /* [] */0 +}; + +let test_id = { + contents: 0 +}; + +function eq(loc, x, y) { + Mt.eq_suites(test_id, suites, loc, x, y); +} + +let oppHeroes = { + hd: 0, + tl: /* [] */0 +}; + +let huntGrootCondition = false; + +if (Belt_List.length(/* [] */0) > 0) { + let x = Belt_List.filter(oppHeroes, h => Belt_List.headExn(/* [] */0) <= 1000); + huntGrootCondition = Belt_List.length(x) === 0; +} + +let huntGrootCondition2 = true; + +if (Belt_List.length(/* [] */0) < 0) { + let x$1 = Belt_List.filter(oppHeroes, h => Belt_List.headExn(/* [] */0) <= 1000); + huntGrootCondition2 = Belt_List.length(x$1) === 0; +} + +eq("File \"gpr_2608_test.res\", line 23, characters 5-12", huntGrootCondition, false); + +eq("File \"gpr_2608_test.res\", line 24, characters 5-12", huntGrootCondition2, true); + +Mt.from_pair_suites("Gpr_2608_test", suites.contents); + +let nearestGroots = /* [] */0; + +export { + suites, + test_id, + eq, + nearestGroots, + oppHeroes, + huntGrootCondition, + huntGrootCondition2, +} +/* huntGrootCondition Not a pure module */ diff --git a/tests/tests/src/gpr_2614_test.js b/tests/tests/src/gpr_2614_test.js deleted file mode 100644 index 73298c140b..0000000000 --- a/tests/tests/src/gpr_2614_test.js +++ /dev/null @@ -1,74 +0,0 @@ -// Generated by ReScript, PLEASE EDIT WITH CARE -'use strict'; - -let Primitive_option = require("rescript/lib/js/Primitive_option.js"); - -let v = { - "Content-Type": 3, - l: 2, - open: 2 -}; - -let b = v.l; - -let c = v.open; - -function ff() { - v["Content-Type"] = 3; - v.l = 2; -} - -let partial_arg = "x"; - -function h0(param) { - let tmp = { - hi: 2 - }; - if (partial_arg !== undefined) { - tmp["lo-x"] = Primitive_option.valFromOption(partial_arg); - } - return tmp; -} - -let h1 = { - "lo-x": "x", - hi: 2 -}; - -let h2 = { - hi: 2 -}; - -function hh(x) { - x["lo-x"] = "3"; - return Primitive_option.fromUndefined(x["lo-x"]); -} - -function hh2(x) { - let match = x["lo-x"]; - if (match !== undefined) { - return 1; - } else { - return 0; - } -} - -let u = { - "xx-yy": 3 -}; - -let x = u["xx-yy"]; - -let v$1 = x !== undefined ? x : 0; - -exports.b = b; -exports.c = c; -exports.ff = ff; -exports.h0 = h0; -exports.h1 = h1; -exports.h2 = h2; -exports.hh = hh; -exports.hh2 = hh2; -exports.u = u; -exports.v = v$1; -/* Not a pure module */ diff --git a/tests/tests/src/gpr_2614_test.mjs b/tests/tests/src/gpr_2614_test.mjs new file mode 100644 index 0000000000..29ee32cd3d --- /dev/null +++ b/tests/tests/src/gpr_2614_test.mjs @@ -0,0 +1,75 @@ +// Generated by ReScript, PLEASE EDIT WITH CARE + +import * as Primitive_option from "rescript/lib/es6/Primitive_option.js"; + +let v = { + "Content-Type": 3, + l: 2, + open: 2 +}; + +let b = v.l; + +let c = v.open; + +function ff() { + v["Content-Type"] = 3; + v.l = 2; +} + +let partial_arg = "x"; + +function h0(param) { + let tmp = { + hi: 2 + }; + if (partial_arg !== undefined) { + tmp["lo-x"] = Primitive_option.valFromOption(partial_arg); + } + return tmp; +} + +let h1 = { + "lo-x": "x", + hi: 2 +}; + +let h2 = { + hi: 2 +}; + +function hh(x) { + x["lo-x"] = "3"; + return Primitive_option.fromUndefined(x["lo-x"]); +} + +function hh2(x) { + let match = x["lo-x"]; + if (match !== undefined) { + return 1; + } else { + return 0; + } +} + +let u = { + "xx-yy": 3 +}; + +let x = u["xx-yy"]; + +let v$1 = x !== undefined ? x : 0; + +export { + b, + c, + ff, + h0, + h1, + h2, + hh, + hh2, + u, + v$1 as v, +} +/* Not a pure module */ diff --git a/tests/tests/src/gpr_2633_test.js b/tests/tests/src/gpr_2633_test.js deleted file mode 100644 index 43ff22b9d0..0000000000 --- a/tests/tests/src/gpr_2633_test.js +++ /dev/null @@ -1,15 +0,0 @@ -// Generated by ReScript, PLEASE EDIT WITH CARE -'use strict'; - - -function on1(foo, event) { - foo.on(event.NAME, event.VAL); -} - -function on2(foo, h, event) { - foo.on(h(event).NAME, h(event).VAL); -} - -exports.on1 = on1; -exports.on2 = on2; -/* No side effect */ diff --git a/tests/tests/src/gpr_2633_test.mjs b/tests/tests/src/gpr_2633_test.mjs new file mode 100644 index 0000000000..8d22cca865 --- /dev/null +++ b/tests/tests/src/gpr_2633_test.mjs @@ -0,0 +1,16 @@ +// Generated by ReScript, PLEASE EDIT WITH CARE + + +function on1(foo, event) { + foo.on(event.NAME, event.VAL); +} + +function on2(foo, h, event) { + foo.on(h(event).NAME, h(event).VAL); +} + +export { + on1, + on2, +} +/* No side effect */ diff --git a/tests/tests/src/gpr_2642_test.js b/tests/tests/src/gpr_2642_test.js deleted file mode 100644 index 1d5d3b9b66..0000000000 --- a/tests/tests/src/gpr_2642_test.js +++ /dev/null @@ -1,25 +0,0 @@ -// Generated by ReScript, PLEASE EDIT WITH CARE -'use strict'; - - -function isfree(id, _x) { - while (true) { - let x = _x; - switch (x.TAG) { - case "Pident" : - return id === x._0; - case "Pdot" : - _x = x._0; - continue; - case "Papply" : - if (isfree(id, x._0)) { - return true; - } - _x = x._1; - continue; - } - }; -} - -exports.isfree = isfree; -/* No side effect */ diff --git a/tests/tests/src/gpr_2642_test.mjs b/tests/tests/src/gpr_2642_test.mjs new file mode 100644 index 0000000000..3edb40c387 --- /dev/null +++ b/tests/tests/src/gpr_2642_test.mjs @@ -0,0 +1,26 @@ +// Generated by ReScript, PLEASE EDIT WITH CARE + + +function isfree(id, _x) { + while (true) { + let x = _x; + switch (x.TAG) { + case "Pident" : + return id === x._0; + case "Pdot" : + _x = x._0; + continue; + case "Papply" : + if (isfree(id, x._0)) { + return true; + } + _x = x._1; + continue; + } + }; +} + +export { + isfree, +} +/* No side effect */ diff --git a/tests/tests/src/gpr_2682_test.js b/tests/tests/src/gpr_2682_test.js deleted file mode 100644 index 1c07be7aca..0000000000 --- a/tests/tests/src/gpr_2682_test.js +++ /dev/null @@ -1,69 +0,0 @@ -// Generated by ReScript, PLEASE EDIT WITH CARE -'use strict'; - - -let sum = ((a,b) => a + b); - -let v = sum(1, 2); - -function f(a) { - return a + 3 | 0; -} - -let b = f(1); - -let c = f(2); - -let forIn = ((o,foo)=> { - for (var i in o){ - foo(o) - } - }); - -function log(x) { - console.log(x); -} - -let N = { - log2: log -}; - -forIn({ - x: 3 -}, x => { - console.log(x); -}); - -forIn({ - x: 3, - y: 3 -}, x => { - console.log(x); -}); - -let f3 = (()=>true); - -let bbbb = f3(); - -if (!bbbb) { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "gpr_2682_test.res", - 52, - 0 - ], - Error: new Error() - }; -} - -exports.sum = sum; -exports.v = v; -exports.f = f; -exports.b = b; -exports.c = c; -exports.forIn = forIn; -exports.N = N; -exports.f3 = f3; -exports.bbbb = bbbb; -/* v Not a pure module */ diff --git a/tests/tests/src/gpr_2682_test.mjs b/tests/tests/src/gpr_2682_test.mjs new file mode 100644 index 0000000000..bcdb050231 --- /dev/null +++ b/tests/tests/src/gpr_2682_test.mjs @@ -0,0 +1,70 @@ +// Generated by ReScript, PLEASE EDIT WITH CARE + + +let sum = ((a,b) => a + b); + +let v = sum(1, 2); + +function f(a) { + return a + 3 | 0; +} + +let b = f(1); + +let c = f(2); + +let forIn = ((o,foo)=> { + for (var i in o){ + foo(o) + } + }); + +function log(x) { + console.log(x); +} + +let N = { + log2: log +}; + +forIn({ + x: 3 +}, x => { + console.log(x); +}); + +forIn({ + x: 3, + y: 3 +}, x => { + console.log(x); +}); + +let f3 = (()=>true); + +let bbbb = f3(); + +if (!bbbb) { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "gpr_2682_test.res", + 52, + 0 + ], + Error: new Error() + }; +} + +export { + sum, + v, + f, + b, + c, + forIn, + N, + f3, + bbbb, +} +/* v Not a pure module */ diff --git a/tests/tests/src/gpr_2700_test.js b/tests/tests/src/gpr_2700_test.js deleted file mode 100644 index d30a948391..0000000000 --- a/tests/tests/src/gpr_2700_test.js +++ /dev/null @@ -1,14 +0,0 @@ -// Generated by ReScript, PLEASE EDIT WITH CARE -'use strict'; - - -function f(x) { - if (x === 3) { - return true; - } else { - return x === 4; - } -} - -exports.f = f; -/* No side effect */ diff --git a/tests/tests/src/gpr_2700_test.mjs b/tests/tests/src/gpr_2700_test.mjs new file mode 100644 index 0000000000..9eeae57bfa --- /dev/null +++ b/tests/tests/src/gpr_2700_test.mjs @@ -0,0 +1,15 @@ +// Generated by ReScript, PLEASE EDIT WITH CARE + + +function f(x) { + if (x === 3) { + return true; + } else { + return x === 4; + } +} + +export { + f, +} +/* No side effect */ diff --git a/tests/tests/src/gpr_2731_test.js b/tests/tests/src/gpr_2731_test.js deleted file mode 100644 index dc4a63ff60..0000000000 --- a/tests/tests/src/gpr_2731_test.js +++ /dev/null @@ -1,27 +0,0 @@ -// Generated by ReScript, PLEASE EDIT WITH CARE -'use strict'; - - -function f(x) { - return x + 1 | 0; -} - -let a = f(1); - -let b = f(2); - -function g() { - return 1; -} - -let c = g(); - -let d = g(); - -exports.f = f; -exports.a = a; -exports.b = b; -exports.g = g; -exports.c = c; -exports.d = d; -/* a Not a pure module */ diff --git a/tests/tests/src/gpr_2731_test.mjs b/tests/tests/src/gpr_2731_test.mjs new file mode 100644 index 0000000000..3bf300bc49 --- /dev/null +++ b/tests/tests/src/gpr_2731_test.mjs @@ -0,0 +1,28 @@ +// Generated by ReScript, PLEASE EDIT WITH CARE + + +function f(x) { + return x + 1 | 0; +} + +let a = f(1); + +let b = f(2); + +function g() { + return 1; +} + +let c = g(); + +let d = g(); + +export { + f, + a, + b, + g, + c, + d, +} +/* a Not a pure module */ diff --git a/tests/tests/src/gpr_2789_test.js b/tests/tests/src/gpr_2789_test.js deleted file mode 100644 index ee5bceb7ef..0000000000 --- a/tests/tests/src/gpr_2789_test.js +++ /dev/null @@ -1,23 +0,0 @@ -// Generated by ReScript, PLEASE EDIT WITH CARE -'use strict'; - -let Mt = require("./mt.js"); - -let suites = { - contents: /* [] */0 -}; - -let test_id = { - contents: 0 -}; - -function eq(loc, x, y) { - Mt.eq_suites(test_id, suites, loc, x, y); -} - -Mt.from_pair_suites("Gpr_2789_test", suites.contents); - -exports.suites = suites; -exports.test_id = test_id; -exports.eq = eq; -/* Not a pure module */ diff --git a/tests/tests/src/gpr_2789_test.mjs b/tests/tests/src/gpr_2789_test.mjs new file mode 100644 index 0000000000..ab55b96595 --- /dev/null +++ b/tests/tests/src/gpr_2789_test.mjs @@ -0,0 +1,24 @@ +// Generated by ReScript, PLEASE EDIT WITH CARE + +import * as Mt from "./mt.mjs"; + +let suites = { + contents: /* [] */0 +}; + +let test_id = { + contents: 0 +}; + +function eq(loc, x, y) { + Mt.eq_suites(test_id, suites, loc, x, y); +} + +Mt.from_pair_suites("Gpr_2789_test", suites.contents); + +export { + suites, + test_id, + eq, +} +/* Not a pure module */ diff --git a/tests/tests/src/gpr_2931_test.js b/tests/tests/src/gpr_2931_test.js deleted file mode 100644 index a5746e30eb..0000000000 --- a/tests/tests/src/gpr_2931_test.js +++ /dev/null @@ -1,47 +0,0 @@ -// Generated by ReScript, PLEASE EDIT WITH CARE -'use strict'; - -let Mt = require("./mt.js"); - -let suites = { - contents: /* [] */0 -}; - -let test_id = { - contents: 0 -}; - -function eq(loc, x, y) { - Mt.eq_suites(test_id, suites, loc, x, y); -} - -function fake_c2(a_type, b_type) { - switch (a_type) { - case "number" : - if (b_type === "number") { - return 33; - } - break; - case "string" : - return 1; - case "undefined" : - return -1; - } - if (b_type === "undefined") { - return 1; - } else if (a_type === "number") { - return 3; - } else { - return 0; - } -} - -eq("File \"gpr_2931_test.res\", line 15, characters 3-10", 3, fake_c2("number", "xx")); - -Mt.from_pair_suites("Gpr_2931_test", suites.contents); - -exports.suites = suites; -exports.test_id = test_id; -exports.eq = eq; -exports.fake_c2 = fake_c2; -/* Not a pure module */ diff --git a/tests/tests/src/gpr_2931_test.mjs b/tests/tests/src/gpr_2931_test.mjs new file mode 100644 index 0000000000..b6ef19d386 --- /dev/null +++ b/tests/tests/src/gpr_2931_test.mjs @@ -0,0 +1,48 @@ +// Generated by ReScript, PLEASE EDIT WITH CARE + +import * as Mt from "./mt.mjs"; + +let suites = { + contents: /* [] */0 +}; + +let test_id = { + contents: 0 +}; + +function eq(loc, x, y) { + Mt.eq_suites(test_id, suites, loc, x, y); +} + +function fake_c2(a_type, b_type) { + switch (a_type) { + case "number" : + if (b_type === "number") { + return 33; + } + break; + case "string" : + return 1; + case "undefined" : + return -1; + } + if (b_type === "undefined") { + return 1; + } else if (a_type === "number") { + return 3; + } else { + return 0; + } +} + +eq("File \"gpr_2931_test.res\", line 15, characters 3-10", 3, fake_c2("number", "xx")); + +Mt.from_pair_suites("Gpr_2931_test", suites.contents); + +export { + suites, + test_id, + eq, + fake_c2, +} +/* Not a pure module */ diff --git a/tests/tests/src/gpr_3142_test.js b/tests/tests/src/gpr_3142_test.js deleted file mode 100644 index fc15d1979d..0000000000 --- a/tests/tests/src/gpr_3142_test.js +++ /dev/null @@ -1,61 +0,0 @@ -// Generated by ReScript, PLEASE EDIT WITH CARE -'use strict'; - -let Mt = require("./mt.js"); - -let suites = { - contents: /* [] */0 -}; - -let test_id = { - contents: 0 -}; - -function eq(loc, x, y) { - Mt.eq_suites(test_id, suites, loc, x, y); -} - -let _map = {"a":"x","u":"hi","b":"你","c":"我"}; - -let _revMap = {"x":"a","hi":"u","你":"b","我":"c"}; - -function tToJs(param) { - return _map[param]; -} - -function tFromJs(param) { - return _revMap[param]; -} - -eq("File \"gpr_3142_test.res\", line 17, characters 3-10", tToJs("a"), "x"); - -eq("File \"gpr_3142_test.res\", line 18, characters 3-10", tToJs("u"), "hi"); - -eq("File \"gpr_3142_test.res\", line 19, characters 3-10", tToJs("b"), "你"); - -eq("File \"gpr_3142_test.res\", line 20, characters 3-10", tToJs("c"), "我"); - -eq("File \"gpr_3142_test.res\", line 22, characters 3-10", tFromJs("x"), "a"); - -eq("File \"gpr_3142_test.res\", line 23, characters 3-10", tFromJs("hi"), "u"); - -eq("File \"gpr_3142_test.res\", line 24, characters 3-10", tFromJs("你"), "b"); - -eq("File \"gpr_3142_test.res\", line 25, characters 3-10", tFromJs("我"), "c"); - -eq("File \"gpr_3142_test.res\", line 26, characters 3-10", tFromJs("xx"), undefined); - -Mt.from_pair_suites("Gpr_3142_test", suites.contents); - -let v = tToJs; - -let u = tFromJs; - -exports.suites = suites; -exports.test_id = test_id; -exports.eq = eq; -exports.tToJs = tToJs; -exports.tFromJs = tFromJs; -exports.v = v; -exports.u = u; -/* Not a pure module */ diff --git a/tests/tests/src/gpr_3142_test.mjs b/tests/tests/src/gpr_3142_test.mjs new file mode 100644 index 0000000000..60628522d2 --- /dev/null +++ b/tests/tests/src/gpr_3142_test.mjs @@ -0,0 +1,62 @@ +// Generated by ReScript, PLEASE EDIT WITH CARE + +import * as Mt from "./mt.mjs"; + +let suites = { + contents: /* [] */0 +}; + +let test_id = { + contents: 0 +}; + +function eq(loc, x, y) { + Mt.eq_suites(test_id, suites, loc, x, y); +} + +let _map = {"a":"x","u":"hi","b":"你","c":"我"}; + +let _revMap = {"x":"a","hi":"u","你":"b","我":"c"}; + +function tToJs(param) { + return _map[param]; +} + +function tFromJs(param) { + return _revMap[param]; +} + +eq("File \"gpr_3142_test.res\", line 17, characters 3-10", tToJs("a"), "x"); + +eq("File \"gpr_3142_test.res\", line 18, characters 3-10", tToJs("u"), "hi"); + +eq("File \"gpr_3142_test.res\", line 19, characters 3-10", tToJs("b"), "你"); + +eq("File \"gpr_3142_test.res\", line 20, characters 3-10", tToJs("c"), "我"); + +eq("File \"gpr_3142_test.res\", line 22, characters 3-10", tFromJs("x"), "a"); + +eq("File \"gpr_3142_test.res\", line 23, characters 3-10", tFromJs("hi"), "u"); + +eq("File \"gpr_3142_test.res\", line 24, characters 3-10", tFromJs("你"), "b"); + +eq("File \"gpr_3142_test.res\", line 25, characters 3-10", tFromJs("我"), "c"); + +eq("File \"gpr_3142_test.res\", line 26, characters 3-10", tFromJs("xx"), undefined); + +Mt.from_pair_suites("Gpr_3142_test", suites.contents); + +let v = tToJs; + +let u = tFromJs; + +export { + suites, + test_id, + eq, + tToJs, + tFromJs, + v, + u, +} +/* Not a pure module */ diff --git a/tests/tests/src/gpr_3154_test.js b/tests/tests/src/gpr_3154_test.js deleted file mode 100644 index da6e5f6f87..0000000000 --- a/tests/tests/src/gpr_3154_test.js +++ /dev/null @@ -1,51 +0,0 @@ -// Generated by ReScript, PLEASE EDIT WITH CARE -'use strict'; - -let Mt = require("./mt.js"); -let Js_dict = require("rescript/lib/js/Js_dict.js"); -let Primitive_option = require("rescript/lib/js/Primitive_option.js"); - -let suites = { - contents: /* [] */0 -}; - -let test_id = { - contents: 0 -}; - -function eq(loc, x, y) { - Mt.eq_suites(test_id, suites, loc, x, y); -} - -function b(loc, x) { - Mt.bool_suites(test_id, suites, loc, x); -} - -let d = {}; - -d["foo"] = undefined; - -let match = Js_dict.get(d, "foo"); - -if (match !== undefined && Primitive_option.valFromOption(match) === undefined) { - b("File \"gpr_3154_test.res\", line 12, characters 20-27", true); -} else { - b("File \"gpr_3154_test.res\", line 13, characters 11-18", false); -} - -let d0 = {}; - -d0["foo"] = undefined; - -eq("File \"gpr_3154_test.res\", line 20, characters 5-12", Js_dict.get(d0, "foo"), Primitive_option.some(undefined)); - -Mt.from_pair_suites("Gpr_3154_test", suites.contents); - -let J; - -exports.suites = suites; -exports.test_id = test_id; -exports.eq = eq; -exports.b = b; -exports.J = J; -/* Not a pure module */ diff --git a/tests/tests/src/gpr_3154_test.mjs b/tests/tests/src/gpr_3154_test.mjs new file mode 100644 index 0000000000..718fff37ff --- /dev/null +++ b/tests/tests/src/gpr_3154_test.mjs @@ -0,0 +1,52 @@ +// Generated by ReScript, PLEASE EDIT WITH CARE + +import * as Mt from "./mt.mjs"; +import * as Js_dict from "rescript/lib/es6/Js_dict.js"; +import * as Primitive_option from "rescript/lib/es6/Primitive_option.js"; + +let suites = { + contents: /* [] */0 +}; + +let test_id = { + contents: 0 +}; + +function eq(loc, x, y) { + Mt.eq_suites(test_id, suites, loc, x, y); +} + +function b(loc, x) { + Mt.bool_suites(test_id, suites, loc, x); +} + +let d = {}; + +d["foo"] = undefined; + +let match = Js_dict.get(d, "foo"); + +if (match !== undefined && Primitive_option.valFromOption(match) === undefined) { + b("File \"gpr_3154_test.res\", line 12, characters 20-27", true); +} else { + b("File \"gpr_3154_test.res\", line 13, characters 11-18", false); +} + +let d0 = {}; + +d0["foo"] = undefined; + +eq("File \"gpr_3154_test.res\", line 20, characters 5-12", Js_dict.get(d0, "foo"), Primitive_option.some(undefined)); + +Mt.from_pair_suites("Gpr_3154_test", suites.contents); + +let J; + +export { + suites, + test_id, + eq, + b, + J, +} +/* Not a pure module */ diff --git a/tests/tests/src/gpr_3209_test.js b/tests/tests/src/gpr_3209_test.js deleted file mode 100644 index 8351c2e193..0000000000 --- a/tests/tests/src/gpr_3209_test.js +++ /dev/null @@ -1,27 +0,0 @@ -// Generated by ReScript, PLEASE EDIT WITH CARE -'use strict'; - - -function f9(x) { - if (typeof x !== "object") { - switch (x) { - case "T60" : - case "T61" : - case "T62" : - return 1; - default: - return 3; - } - } else { - switch (x.TAG) { - case "T64" : - case "T65" : - return 2; - default: - return 3; - } - } -} - -exports.f9 = f9; -/* No side effect */ diff --git a/tests/tests/src/gpr_3209_test.mjs b/tests/tests/src/gpr_3209_test.mjs new file mode 100644 index 0000000000..ebca49945c --- /dev/null +++ b/tests/tests/src/gpr_3209_test.mjs @@ -0,0 +1,28 @@ +// Generated by ReScript, PLEASE EDIT WITH CARE + + +function f9(x) { + if (typeof x !== "object") { + switch (x) { + case "T60" : + case "T61" : + case "T62" : + return 1; + default: + return 3; + } + } else { + switch (x.TAG) { + case "T64" : + case "T65" : + return 2; + default: + return 3; + } + } +} + +export { + f9, +} +/* No side effect */ diff --git a/tests/tests/src/gpr_3492_test.js b/tests/tests/src/gpr_3492_test.js deleted file mode 100644 index 2778593e60..0000000000 --- a/tests/tests/src/gpr_3492_test.js +++ /dev/null @@ -1,34 +0,0 @@ -// Generated by ReScript, PLEASE EDIT WITH CARE -'use strict'; - -let Mt = require("./mt.js"); - -let suites = { - contents: /* [] */0 -}; - -let test_id = { - contents: 0 -}; - -function eq(loc, x, y) { - Mt.eq_suites(test_id, suites, loc, x, y); -} - -function foo(a){return a()} -; - -function fn() { - console.log("hi"); - return 1; -} - -eq("File \"gpr_3492_test.res\", line 13, characters 12-19", foo(fn), 1); - -Mt.from_pair_suites("gpr_3492_test.res", suites.contents); - -exports.suites = suites; -exports.test_id = test_id; -exports.eq = eq; -exports.fn = fn; -/* Not a pure module */ diff --git a/tests/tests/src/gpr_3492_test.mjs b/tests/tests/src/gpr_3492_test.mjs new file mode 100644 index 0000000000..5a6f7c65c1 --- /dev/null +++ b/tests/tests/src/gpr_3492_test.mjs @@ -0,0 +1,35 @@ +// Generated by ReScript, PLEASE EDIT WITH CARE + +import * as Mt from "./mt.mjs"; + +let suites = { + contents: /* [] */0 +}; + +let test_id = { + contents: 0 +}; + +function eq(loc, x, y) { + Mt.eq_suites(test_id, suites, loc, x, y); +} + +function foo(a){return a()} +; + +function fn() { + console.log("hi"); + return 1; +} + +eq("File \"gpr_3492_test.res\", line 13, characters 12-19", foo(fn), 1); + +Mt.from_pair_suites("gpr_3492_test.res", suites.contents); + +export { + suites, + test_id, + eq, + fn, +} +/* Not a pure module */ diff --git a/tests/tests/src/gpr_3519_jsx_test.js b/tests/tests/src/gpr_3519_jsx_test.js deleted file mode 100644 index 50cf7d45a2..0000000000 --- a/tests/tests/src/gpr_3519_jsx_test.js +++ /dev/null @@ -1,19 +0,0 @@ -// Generated by ReScript, PLEASE EDIT WITH CARE -'use strict'; - - -let React = { - $$null: undefined -}; - -function make(param, param$1) { - -} - -let Foo = { - make: make -}; - -exports.React = React; -exports.Foo = Foo; -/* No side effect */ diff --git a/tests/tests/src/gpr_3519_jsx_test.mjs b/tests/tests/src/gpr_3519_jsx_test.mjs new file mode 100644 index 0000000000..d640430095 --- /dev/null +++ b/tests/tests/src/gpr_3519_jsx_test.mjs @@ -0,0 +1,20 @@ +// Generated by ReScript, PLEASE EDIT WITH CARE + + +let React = { + $$null: undefined +}; + +function make(param, param$1) { + +} + +let Foo = { + make: make +}; + +export { + React, + Foo, +} +/* No side effect */ diff --git a/tests/tests/src/gpr_3519_test.js b/tests/tests/src/gpr_3519_test.mjs similarity index 100% rename from tests/tests/src/gpr_3519_test.js rename to tests/tests/src/gpr_3519_test.mjs diff --git a/tests/tests/src/gpr_3536_test.js b/tests/tests/src/gpr_3536_test.js deleted file mode 100644 index 4f40fea997..0000000000 --- a/tests/tests/src/gpr_3536_test.js +++ /dev/null @@ -1,44 +0,0 @@ -// Generated by ReScript, PLEASE EDIT WITH CARE -'use strict'; - -let Mt = require("./mt.js"); - -let suites = { - contents: /* [] */0 -}; - -let test_id = { - contents: 0 -}; - -function eq(loc, x, y) { - Mt.eq_suites(test_id, suites, loc, x, y); -} - -let X = {}; - -function xx(obj, a0, a1, a2, a3, a4, a5) { - return (a4(a2(a0(obj, a1), a3), a5) - 1 | 0) - 3 | 0; -} - -eq("File \"gpr_3536_test.res\", line 18, characters 12-19", 5, 5); - -eq("File \"gpr_3536_test.res\", line 20, characters 12-19", xx(3, (prim0, prim1) => prim0 - prim1 | 0, 2, (prim0, prim1) => prim0 + prim1 | 0, 4, (prim0, prim1) => Math.imul(prim0, prim1), 3), 11); - -Mt.from_pair_suites("Gpr_3536_test", suites.contents); - -let v = 5; - -let u = { - TAG: "Some", - _0: 3 -}; - -exports.suites = suites; -exports.test_id = test_id; -exports.eq = eq; -exports.v = v; -exports.X = X; -exports.u = u; -exports.xx = xx; -/* Not a pure module */ diff --git a/tests/tests/src/gpr_3536_test.mjs b/tests/tests/src/gpr_3536_test.mjs new file mode 100644 index 0000000000..052dc887ae --- /dev/null +++ b/tests/tests/src/gpr_3536_test.mjs @@ -0,0 +1,45 @@ +// Generated by ReScript, PLEASE EDIT WITH CARE + +import * as Mt from "./mt.mjs"; + +let suites = { + contents: /* [] */0 +}; + +let test_id = { + contents: 0 +}; + +function eq(loc, x, y) { + Mt.eq_suites(test_id, suites, loc, x, y); +} + +let X = {}; + +function xx(obj, a0, a1, a2, a3, a4, a5) { + return (a4(a2(a0(obj, a1), a3), a5) - 1 | 0) - 3 | 0; +} + +eq("File \"gpr_3536_test.res\", line 18, characters 12-19", 5, 5); + +eq("File \"gpr_3536_test.res\", line 20, characters 12-19", xx(3, (prim0, prim1) => prim0 - prim1 | 0, 2, (prim0, prim1) => prim0 + prim1 | 0, 4, (prim0, prim1) => Math.imul(prim0, prim1), 3), 11); + +Mt.from_pair_suites("Gpr_3536_test", suites.contents); + +let v = 5; + +let u = { + TAG: "Some", + _0: 3 +}; + +export { + suites, + test_id, + eq, + v, + X, + u, + xx, +} +/* Not a pure module */ diff --git a/tests/tests/src/gpr_3546_test.js b/tests/tests/src/gpr_3546_test.js deleted file mode 100644 index eded96c5c3..0000000000 --- a/tests/tests/src/gpr_3546_test.js +++ /dev/null @@ -1,19 +0,0 @@ -// Generated by ReScript, PLEASE EDIT WITH CARE -'use strict'; - - -function t_error3(param_0) { - return { - TAG: "T_error3", - _0: param_0 - }; -} - -let t_error = "T_error"; - -let t_error2 = "T_error2"; - -exports.t_error = t_error; -exports.t_error2 = t_error2; -exports.t_error3 = t_error3; -/* No side effect */ diff --git a/tests/tests/src/gpr_3546_test.mjs b/tests/tests/src/gpr_3546_test.mjs new file mode 100644 index 0000000000..3a98e1a84e --- /dev/null +++ b/tests/tests/src/gpr_3546_test.mjs @@ -0,0 +1,20 @@ +// Generated by ReScript, PLEASE EDIT WITH CARE + + +function t_error3(param_0) { + return { + TAG: "T_error3", + _0: param_0 + }; +} + +let t_error = "T_error"; + +let t_error2 = "T_error2"; + +export { + t_error, + t_error2, + t_error3, +} +/* No side effect */ diff --git a/tests/tests/src/gpr_3548_test.js b/tests/tests/src/gpr_3548_test.js deleted file mode 100644 index d8d45b39b1..0000000000 --- a/tests/tests/src/gpr_3548_test.js +++ /dev/null @@ -1,21 +0,0 @@ -// Generated by ReScript, PLEASE EDIT WITH CARE -'use strict'; - - -let _map = {"Horizontal":"horizontal","Vertical":"vertical"}; - -let _revMap = {"horizontal":"Horizontal","vertical":"Vertical"}; - -function orientationToJs(param) { - return _map[param]; -} - -function orientationFromJs(param) { - return _revMap[param]; -} - -console.log(orientationToJs("Horizontal")); - -exports.orientationToJs = orientationToJs; -exports.orientationFromJs = orientationFromJs; -/* Not a pure module */ diff --git a/tests/tests/src/gpr_3548_test.mjs b/tests/tests/src/gpr_3548_test.mjs new file mode 100644 index 0000000000..b7f5f8f81a --- /dev/null +++ b/tests/tests/src/gpr_3548_test.mjs @@ -0,0 +1,22 @@ +// Generated by ReScript, PLEASE EDIT WITH CARE + + +let _map = {"Horizontal":"horizontal","Vertical":"vertical"}; + +let _revMap = {"horizontal":"Horizontal","vertical":"Vertical"}; + +function orientationToJs(param) { + return _map[param]; +} + +function orientationFromJs(param) { + return _revMap[param]; +} + +console.log(orientationToJs("Horizontal")); + +export { + orientationToJs, + orientationFromJs, +} +/* Not a pure module */ diff --git a/tests/tests/src/gpr_3549_test.js b/tests/tests/src/gpr_3549_test.js deleted file mode 100644 index 709541175c..0000000000 --- a/tests/tests/src/gpr_3549_test.js +++ /dev/null @@ -1,60 +0,0 @@ -// Generated by ReScript, PLEASE EDIT WITH CARE -'use strict'; - -let Mt = require("./mt.js"); - -let suites = { - contents: /* [] */0 -}; - -let test_id = { - contents: 0 -}; - -function eq(loc, x, y) { - Mt.eq_suites(test_id, suites, loc, x, y); -} - -let others = [ - 0, - 0, - 1, - 1, - 2e3 -]; - -eq("File \"gpr_3549_test.res\", line 13, characters 5-12", 7.0, 7); - -eq("File \"gpr_3549_test.res\", line 14, characters 5-12", 2e3, 2000); - -eq("File \"gpr_3549_test.res\", line 15, characters 5-12", 0.2, 0.2); - -eq("File \"gpr_3549_test.res\", line 16, characters 5-12", 32, 32); - -eq("File \"gpr_3549_test.res\", line 17, characters 5-12", others, [ - 0.0, - 0.0, - 1.0, - 1.0, - 2e3 -]); - -Mt.from_pair_suites("Gpr_3549_test", suites.contents); - -let u = 32; - -let x = 7.0; - -let y = 2e3; - -let z = 0.2; - -exports.suites = suites; -exports.test_id = test_id; -exports.eq = eq; -exports.u = u; -exports.x = x; -exports.y = y; -exports.z = z; -exports.others = others; -/* Not a pure module */ diff --git a/tests/tests/src/gpr_3549_test.mjs b/tests/tests/src/gpr_3549_test.mjs new file mode 100644 index 0000000000..c77aa3ac5c --- /dev/null +++ b/tests/tests/src/gpr_3549_test.mjs @@ -0,0 +1,61 @@ +// Generated by ReScript, PLEASE EDIT WITH CARE + +import * as Mt from "./mt.mjs"; + +let suites = { + contents: /* [] */0 +}; + +let test_id = { + contents: 0 +}; + +function eq(loc, x, y) { + Mt.eq_suites(test_id, suites, loc, x, y); +} + +let others = [ + 0, + 0, + 1, + 1, + 2e3 +]; + +eq("File \"gpr_3549_test.res\", line 13, characters 5-12", 7.0, 7); + +eq("File \"gpr_3549_test.res\", line 14, characters 5-12", 2e3, 2000); + +eq("File \"gpr_3549_test.res\", line 15, characters 5-12", 0.2, 0.2); + +eq("File \"gpr_3549_test.res\", line 16, characters 5-12", 32, 32); + +eq("File \"gpr_3549_test.res\", line 17, characters 5-12", others, [ + 0.0, + 0.0, + 1.0, + 1.0, + 2e3 +]); + +Mt.from_pair_suites("Gpr_3549_test", suites.contents); + +let u = 32; + +let x = 7.0; + +let y = 2e3; + +let z = 0.2; + +export { + suites, + test_id, + eq, + u, + x, + y, + z, + others, +} +/* Not a pure module */ diff --git a/tests/tests/src/gpr_3566_drive_test.js b/tests/tests/src/gpr_3566_drive_test.js deleted file mode 100644 index 03e11b1192..0000000000 --- a/tests/tests/src/gpr_3566_drive_test.js +++ /dev/null @@ -1,38 +0,0 @@ -// Generated by ReScript, PLEASE EDIT WITH CARE -'use strict'; - -let Mt = require("./mt.js"); -let Gpr_3566_test = require("./gpr_3566_test.js"); -let Primitive_option = require("rescript/lib/js/Primitive_option.js"); - -let suites = { - contents: /* [] */0 -}; - -let test_id = { - contents: 0 -}; - -function eq(loc, x, y) { - Mt.eq_suites(test_id, suites, loc, x, y); -} - -let H = Gpr_3566_test.Test({}); - -eq("File \"gpr_3566_drive_test.res\", line 7, characters 12-19", H.b, true); - -let Caml_option = {}; - -function f(x) { - return Primitive_option.some(x); -} - -Mt.from_pair_suites("gpr_3566_drive_test.res", suites.contents); - -exports.suites = suites; -exports.test_id = test_id; -exports.eq = eq; -exports.H = H; -exports.Caml_option = Caml_option; -exports.f = f; -/* H Not a pure module */ diff --git a/tests/tests/src/gpr_3566_drive_test.mjs b/tests/tests/src/gpr_3566_drive_test.mjs new file mode 100644 index 0000000000..a19b4080d7 --- /dev/null +++ b/tests/tests/src/gpr_3566_drive_test.mjs @@ -0,0 +1,39 @@ +// Generated by ReScript, PLEASE EDIT WITH CARE + +import * as Mt from "./mt.mjs"; +import * as Gpr_3566_test from "./gpr_3566_test.mjs"; +import * as Primitive_option from "rescript/lib/es6/Primitive_option.js"; + +let suites = { + contents: /* [] */0 +}; + +let test_id = { + contents: 0 +}; + +function eq(loc, x, y) { + Mt.eq_suites(test_id, suites, loc, x, y); +} + +let H = Gpr_3566_test.Test({}); + +eq("File \"gpr_3566_drive_test.res\", line 7, characters 12-19", H.b, true); + +let Caml_option = {}; + +function f(x) { + return Primitive_option.some(x); +} + +Mt.from_pair_suites("gpr_3566_drive_test.res", suites.contents); + +export { + suites, + test_id, + eq, + H, + Caml_option, + f, +} +/* H Not a pure module */ diff --git a/tests/tests/src/gpr_3566_test.js b/tests/tests/src/gpr_3566_test.js deleted file mode 100644 index 2059d1e0ed..0000000000 --- a/tests/tests/src/gpr_3566_test.js +++ /dev/null @@ -1,142 +0,0 @@ -// Generated by ReScript, PLEASE EDIT WITH CARE -'use strict'; - -let Primitive_object = require("rescript/lib/js/Primitive_object.js"); -let Primitive_option = require("rescript/lib/js/Primitive_option.js"); - -function eq_A(x, y) { - if (x.TAG === "A" && y.TAG === "A") { - return x._0 === y._0; - } else { - return false; - } -} - -function Test($star) { - console.log("no inline"); - let u = { - TAG: "A", - _0: 3 - }; - let Block = {}; - let b = eq_A({ - TAG: "A", - _0: 3 - }, u); - return { - u: u, - Block: Block, - y: 32, - b: b - }; -} - -function Test2($star) { - console.log("no inline"); - let Block = {}; - let b = eq_A({ - TAG: "A", - _0: 3 - }, { - TAG: "A", - _0: 3 - }); - return { - Block: Block, - y: 32, - b: b - }; -} - -function f(i, y) { - let x = { - TAG: "A", - _0: i - }; - return eq_A(x, y); -} - -function Test3($star) { - let f = Primitive_object.equal; - let Caml_obj = {}; - return { - f: f, - Caml_obj: Caml_obj - }; -} - -function Test4($star) { - let Caml_obj = {}; - let f = Primitive_object.equal; - return { - Caml_obj: Caml_obj, - f: f - }; -} - -function Test5($star) { - let f = x => Primitive_option.some(x); - let Caml_option = {}; - return { - f: f, - Caml_option: Caml_option - }; -} - -function Test6($star) { - let Caml_option = {}; - let f = x => Primitive_option.some(x); - return { - Caml_option: Caml_option, - f: f - }; -} - -function Test7($star) { - let Caml_option = {}; - return { - Caml_option: Caml_option - }; -} - -function Test8($star) { - let Curry = {}; - let f = x => x(1); - return { - Curry: Curry, - f: f - }; -} - -function Test9($star) { - let f = x => x(1); - let Curry = {}; - return { - f: f, - Curry: Curry - }; -} - -function Test10($star) { - let Curry = {}; - return { - Curry: Curry - }; -} - -let x = 3; - -exports.eq_A = eq_A; -exports.Test = Test; -exports.Test2 = Test2; -exports.x = x; -exports.f = f; -exports.Test3 = Test3; -exports.Test4 = Test4; -exports.Test5 = Test5; -exports.Test6 = Test6; -exports.Test7 = Test7; -exports.Test8 = Test8; -exports.Test9 = Test9; -exports.Test10 = Test10; -/* No side effect */ diff --git a/tests/tests/src/gpr_3566_test.mjs b/tests/tests/src/gpr_3566_test.mjs new file mode 100644 index 0000000000..dd716ecbdd --- /dev/null +++ b/tests/tests/src/gpr_3566_test.mjs @@ -0,0 +1,143 @@ +// Generated by ReScript, PLEASE EDIT WITH CARE + +import * as Primitive_object from "rescript/lib/es6/Primitive_object.js"; +import * as Primitive_option from "rescript/lib/es6/Primitive_option.js"; + +function eq_A(x, y) { + if (x.TAG === "A" && y.TAG === "A") { + return x._0 === y._0; + } else { + return false; + } +} + +function Test($star) { + console.log("no inline"); + let u = { + TAG: "A", + _0: 3 + }; + let Block = {}; + let b = eq_A({ + TAG: "A", + _0: 3 + }, u); + return { + u: u, + Block: Block, + y: 32, + b: b + }; +} + +function Test2($star) { + console.log("no inline"); + let Block = {}; + let b = eq_A({ + TAG: "A", + _0: 3 + }, { + TAG: "A", + _0: 3 + }); + return { + Block: Block, + y: 32, + b: b + }; +} + +function f(i, y) { + let x = { + TAG: "A", + _0: i + }; + return eq_A(x, y); +} + +function Test3($star) { + let f = Primitive_object.equal; + let Caml_obj = {}; + return { + f: f, + Caml_obj: Caml_obj + }; +} + +function Test4($star) { + let Caml_obj = {}; + let f = Primitive_object.equal; + return { + Caml_obj: Caml_obj, + f: f + }; +} + +function Test5($star) { + let f = x => Primitive_option.some(x); + let Caml_option = {}; + return { + f: f, + Caml_option: Caml_option + }; +} + +function Test6($star) { + let Caml_option = {}; + let f = x => Primitive_option.some(x); + return { + Caml_option: Caml_option, + f: f + }; +} + +function Test7($star) { + let Caml_option = {}; + return { + Caml_option: Caml_option + }; +} + +function Test8($star) { + let Curry = {}; + let f = x => x(1); + return { + Curry: Curry, + f: f + }; +} + +function Test9($star) { + let f = x => x(1); + let Curry = {}; + return { + f: f, + Curry: Curry + }; +} + +function Test10($star) { + let Curry = {}; + return { + Curry: Curry + }; +} + +let x = 3; + +export { + eq_A, + Test, + Test2, + x, + f, + Test3, + Test4, + Test5, + Test6, + Test7, + Test8, + Test9, + Test10, +} +/* No side effect */ diff --git a/tests/tests/src/gpr_3595_test.js b/tests/tests/src/gpr_3595_test.js deleted file mode 100644 index 9606c9b577..0000000000 --- a/tests/tests/src/gpr_3595_test.js +++ /dev/null @@ -1,24 +0,0 @@ -// Generated by ReScript, PLEASE EDIT WITH CARE -'use strict'; - -let Mt = require("./mt.js"); - -let suites = { - contents: /* [] */0 -}; - -let test_id = { - contents: 0 -}; - -function eq(loc, x, y) { - Mt.eq_suites(test_id, suites, loc, x, y); -} - -let x = 1; - -exports.suites = suites; -exports.test_id = test_id; -exports.eq = eq; -exports.x = x; -/* Mt Not a pure module */ diff --git a/tests/tests/src/gpr_3595_test.mjs b/tests/tests/src/gpr_3595_test.mjs new file mode 100644 index 0000000000..e039ff0cdc --- /dev/null +++ b/tests/tests/src/gpr_3595_test.mjs @@ -0,0 +1,25 @@ +// Generated by ReScript, PLEASE EDIT WITH CARE + +import * as Mt from "./mt.mjs"; + +let suites = { + contents: /* [] */0 +}; + +let test_id = { + contents: 0 +}; + +function eq(loc, x, y) { + Mt.eq_suites(test_id, suites, loc, x, y); +} + +let x = 1; + +export { + suites, + test_id, + eq, + x, +} +/* Mt Not a pure module */ diff --git a/tests/tests/src/gpr_3609_test.js b/tests/tests/src/gpr_3609_test.js deleted file mode 100644 index b500d4101c..0000000000 --- a/tests/tests/src/gpr_3609_test.js +++ /dev/null @@ -1,14 +0,0 @@ -// Generated by ReScript, PLEASE EDIT WITH CARE -'use strict'; - - -function func(state) { - if (typeof state !== "object") { - return 0; - } else { - return 0 + state._0 | 0; - } -} - -exports.func = func; -/* No side effect */ diff --git a/tests/tests/src/gpr_3609_test.mjs b/tests/tests/src/gpr_3609_test.mjs new file mode 100644 index 0000000000..3aea07bc90 --- /dev/null +++ b/tests/tests/src/gpr_3609_test.mjs @@ -0,0 +1,15 @@ +// Generated by ReScript, PLEASE EDIT WITH CARE + + +function func(state) { + if (typeof state !== "object") { + return 0; + } else { + return 0 + state._0 | 0; + } +} + +export { + func, +} +/* No side effect */ diff --git a/tests/tests/src/gpr_3697_test.js b/tests/tests/src/gpr_3697_test.js deleted file mode 100644 index fb51e9d217..0000000000 --- a/tests/tests/src/gpr_3697_test.js +++ /dev/null @@ -1,31 +0,0 @@ -// Generated by ReScript, PLEASE EDIT WITH CARE -'use strict'; - -let Lazy = require("rescript/lib/js/Lazy.js"); - -function fix() { - return { - TAG: "Fix", - _0: Lazy.from_fun(fix) - }; -} - -function unfixLeak(_f) { - while (true) { - let f = _f; - _f = Lazy.force(f._0); - continue; - }; -} - -function unfix(p) { - while (true) { - let h = p.contents; - p.contents = Lazy.force(h._0); - }; -} - -exports.fix = fix; -exports.unfixLeak = unfixLeak; -exports.unfix = unfix; -/* No side effect */ diff --git a/tests/tests/src/gpr_3697_test.mjs b/tests/tests/src/gpr_3697_test.mjs new file mode 100644 index 0000000000..c17da8ed66 --- /dev/null +++ b/tests/tests/src/gpr_3697_test.mjs @@ -0,0 +1,32 @@ +// Generated by ReScript, PLEASE EDIT WITH CARE + +import * as Lazy from "rescript/lib/es6/Lazy.js"; + +function fix() { + return { + TAG: "Fix", + _0: Lazy.from_fun(fix) + }; +} + +function unfixLeak(_f) { + while (true) { + let f = _f; + _f = Lazy.force(f._0); + continue; + }; +} + +function unfix(p) { + while (true) { + let h = p.contents; + p.contents = Lazy.force(h._0); + }; +} + +export { + fix, + unfixLeak, + unfix, +} +/* No side effect */ diff --git a/tests/tests/src/gpr_373_test.js b/tests/tests/src/gpr_373_test.js deleted file mode 100644 index 500f2af235..0000000000 --- a/tests/tests/src/gpr_373_test.js +++ /dev/null @@ -1,17 +0,0 @@ -// Generated by ReScript, PLEASE EDIT WITH CARE -'use strict'; - - -let overflow_dec_i32_number = 272872590; - -let overflow_dec_i32_number_2 = 0; - -let not_overflow_dec_i32_number_3 = -1; - -let overflow_hex_i32_number = -1; - -exports.overflow_dec_i32_number = overflow_dec_i32_number; -exports.overflow_dec_i32_number_2 = overflow_dec_i32_number_2; -exports.not_overflow_dec_i32_number_3 = not_overflow_dec_i32_number_3; -exports.overflow_hex_i32_number = overflow_hex_i32_number; -/* No side effect */ diff --git a/tests/tests/src/gpr_373_test.mjs b/tests/tests/src/gpr_373_test.mjs new file mode 100644 index 0000000000..9244c1983e --- /dev/null +++ b/tests/tests/src/gpr_373_test.mjs @@ -0,0 +1,18 @@ +// Generated by ReScript, PLEASE EDIT WITH CARE + + +let overflow_dec_i32_number = 272872590; + +let overflow_dec_i32_number_2 = 0; + +let not_overflow_dec_i32_number_3 = -1; + +let overflow_hex_i32_number = -1; + +export { + overflow_dec_i32_number, + overflow_dec_i32_number_2, + not_overflow_dec_i32_number_3, + overflow_hex_i32_number, +} +/* No side effect */ diff --git a/tests/tests/src/gpr_3770_test.js b/tests/tests/src/gpr_3770_test.js deleted file mode 100644 index 57b77c7a3d..0000000000 --- a/tests/tests/src/gpr_3770_test.js +++ /dev/null @@ -1,14 +0,0 @@ -// Generated by ReScript, PLEASE EDIT WITH CARE -'use strict'; - - -function show(x) { - let a = x._0; - if (a === 0 && x._1 === 0 && x._2 === 0) { - return "zeroes"; - } - return a.toString() + x._1.toString(); -} - -exports.show = show; -/* No side effect */ diff --git a/tests/tests/src/gpr_3770_test.mjs b/tests/tests/src/gpr_3770_test.mjs new file mode 100644 index 0000000000..b483394ac4 --- /dev/null +++ b/tests/tests/src/gpr_3770_test.mjs @@ -0,0 +1,15 @@ +// Generated by ReScript, PLEASE EDIT WITH CARE + + +function show(x) { + let a = x._0; + if (a === 0 && x._1 === 0 && x._2 === 0) { + return "zeroes"; + } + return a.toString() + x._1.toString(); +} + +export { + show, +} +/* No side effect */ diff --git a/tests/tests/src/gpr_3852_alias.js b/tests/tests/src/gpr_3852_alias.js deleted file mode 100644 index 37c7ce97db..0000000000 --- a/tests/tests/src/gpr_3852_alias.js +++ /dev/null @@ -1,8 +0,0 @@ -// Generated by ReScript, PLEASE EDIT WITH CARE -'use strict'; - - -let A; - -exports.A = A; -/* No side effect */ diff --git a/tests/tests/src/gpr_3852_alias.mjs b/tests/tests/src/gpr_3852_alias.mjs new file mode 100644 index 0000000000..f19fa334d7 --- /dev/null +++ b/tests/tests/src/gpr_3852_alias.mjs @@ -0,0 +1,9 @@ +// Generated by ReScript, PLEASE EDIT WITH CARE + + +let A; + +export { + A, +} +/* No side effect */ diff --git a/tests/tests/src/gpr_3852_alias_reify.js b/tests/tests/src/gpr_3852_alias_reify.js deleted file mode 100644 index cd1305a2c7..0000000000 --- a/tests/tests/src/gpr_3852_alias_reify.js +++ /dev/null @@ -1,9 +0,0 @@ -// Generated by ReScript, PLEASE EDIT WITH CARE -'use strict'; - -let Gpr_3852_effect = require("./gpr_3852_effect.js"); - -let A = Gpr_3852_effect; - -exports.A = A; -/* Gpr_3852_effect Not a pure module */ diff --git a/tests/tests/src/gpr_3852_alias_reify.mjs b/tests/tests/src/gpr_3852_alias_reify.mjs new file mode 100644 index 0000000000..8a4c7ecb10 --- /dev/null +++ b/tests/tests/src/gpr_3852_alias_reify.mjs @@ -0,0 +1,10 @@ +// Generated by ReScript, PLEASE EDIT WITH CARE + +import * as Gpr_3852_effect from "./gpr_3852_effect.mjs"; + +let A = Gpr_3852_effect; + +export { + A, +} +/* Gpr_3852_effect Not a pure module */ diff --git a/tests/tests/src/gpr_3852_effect.js b/tests/tests/src/gpr_3852_effect.js deleted file mode 100644 index 5ff5e0c92e..0000000000 --- a/tests/tests/src/gpr_3852_effect.js +++ /dev/null @@ -1,10 +0,0 @@ -// Generated by ReScript, PLEASE EDIT WITH CARE -'use strict'; - - -console.log("hello"); - -let v = 0; - -exports.v = v; -/* Not a pure module */ diff --git a/tests/tests/src/gpr_3852_effect.mjs b/tests/tests/src/gpr_3852_effect.mjs new file mode 100644 index 0000000000..a21f2cec83 --- /dev/null +++ b/tests/tests/src/gpr_3852_effect.mjs @@ -0,0 +1,11 @@ +// Generated by ReScript, PLEASE EDIT WITH CARE + + +console.log("hello"); + +let v = 0; + +export { + v, +} +/* Not a pure module */ diff --git a/tests/tests/src/gpr_3865.js b/tests/tests/src/gpr_3865.js deleted file mode 100644 index 332dd4de57..0000000000 --- a/tests/tests/src/gpr_3865.js +++ /dev/null @@ -1,17 +0,0 @@ -// Generated by ReScript, PLEASE EDIT WITH CARE -'use strict'; - -let Gpr_3865_bar = require("./gpr_3865_bar.js"); -let Gpr_3865_foo = require("./gpr_3865_foo.js"); - -let B = Gpr_3865_bar.Make(Gpr_3865_foo); - -console.log(Gpr_3865_foo.$$return); - -console.log(B.$$return); - -let F; - -exports.F = F; -exports.B = B; -/* B Not a pure module */ diff --git a/tests/tests/src/gpr_3865.mjs b/tests/tests/src/gpr_3865.mjs new file mode 100644 index 0000000000..3c3bb62dad --- /dev/null +++ b/tests/tests/src/gpr_3865.mjs @@ -0,0 +1,18 @@ +// Generated by ReScript, PLEASE EDIT WITH CARE + +import * as Gpr_3865_bar from "./gpr_3865_bar.mjs"; +import * as Gpr_3865_foo from "./gpr_3865_foo.mjs"; + +let B = Gpr_3865_bar.Make(Gpr_3865_foo); + +console.log(Gpr_3865_foo.$$return); + +console.log(B.$$return); + +let F; + +export { + F, + B, +} +/* B Not a pure module */ diff --git a/tests/tests/src/gpr_3865_bar.js b/tests/tests/src/gpr_3865_bar.js deleted file mode 100644 index c36cc825e9..0000000000 --- a/tests/tests/src/gpr_3865_bar.js +++ /dev/null @@ -1,10 +0,0 @@ -// Generated by ReScript, PLEASE EDIT WITH CARE -'use strict'; - - -function Make(M) { - return M; -} - -exports.Make = Make; -/* No side effect */ diff --git a/tests/tests/src/gpr_3865_bar.mjs b/tests/tests/src/gpr_3865_bar.mjs new file mode 100644 index 0000000000..68a2c4d8ef --- /dev/null +++ b/tests/tests/src/gpr_3865_bar.mjs @@ -0,0 +1,11 @@ +// Generated by ReScript, PLEASE EDIT WITH CARE + + +function Make(M) { + return M; +} + +export { + Make, +} +/* No side effect */ diff --git a/tests/tests/src/gpr_3865_foo.js b/tests/tests/src/gpr_3865_foo.js deleted file mode 100644 index 4871e7aa37..0000000000 --- a/tests/tests/src/gpr_3865_foo.js +++ /dev/null @@ -1,8 +0,0 @@ -// Generated by ReScript, PLEASE EDIT WITH CARE -'use strict'; - - -let $$return = 5; - -exports.$$return = $$return; -/* No side effect */ diff --git a/tests/tests/src/gpr_3865_foo.mjs b/tests/tests/src/gpr_3865_foo.mjs new file mode 100644 index 0000000000..760820a7d5 --- /dev/null +++ b/tests/tests/src/gpr_3865_foo.mjs @@ -0,0 +1,9 @@ +// Generated by ReScript, PLEASE EDIT WITH CARE + + +let $$return = 5; + +export { + $$return, +} +/* No side effect */ diff --git a/tests/tests/src/gpr_3875_test.js b/tests/tests/src/gpr_3875_test.js deleted file mode 100644 index 6dcd01cc61..0000000000 --- a/tests/tests/src/gpr_3875_test.js +++ /dev/null @@ -1,73 +0,0 @@ -// Generated by ReScript, PLEASE EDIT WITH CARE -'use strict'; - -let Mt = require("./mt.js"); - -let result = { - contents: "" -}; - -function log(x) { - result.contents = x; -} - -let Xx = { - log: log -}; - -function compilerBug(a, b, c, f) { - let exit = 0; - if (a !== "x") { - exit = 2; - } - if (exit === 2) { - if (b === undefined) { - if (c) { - result.contents = "No x, c is true"; - } else { - result.contents = "No x, c is false"; - } - return; - } - if (b !== "x") { - if (c) { - result.contents = "No x, c is true"; - } else { - result.contents = "No x, c is false"; - } - return; - } - - } - if (f()) { - result.contents = "Some x, f returns true"; - } else { - result.contents = "Some x, f returns false"; - } -} - -let suites = { - contents: /* [] */0 -}; - -let test_id = { - contents: 0 -}; - -function eq(loc, x, y) { - Mt.eq_suites(test_id, suites, loc, x, y); -} - -compilerBug("x", undefined, true, () => true); - -eq("File \"gpr_3875_test.res\", line 35, characters 5-12", result.contents, "Some x, f returns true"); - -Mt.from_pair_suites("gpr_3875_test.res", suites.contents); - -exports.result = result; -exports.Xx = Xx; -exports.compilerBug = compilerBug; -exports.suites = suites; -exports.test_id = test_id; -exports.eq = eq; -/* Not a pure module */ diff --git a/tests/tests/src/gpr_3875_test.mjs b/tests/tests/src/gpr_3875_test.mjs new file mode 100644 index 0000000000..f0f0f434aa --- /dev/null +++ b/tests/tests/src/gpr_3875_test.mjs @@ -0,0 +1,74 @@ +// Generated by ReScript, PLEASE EDIT WITH CARE + +import * as Mt from "./mt.mjs"; + +let result = { + contents: "" +}; + +function log(x) { + result.contents = x; +} + +let Xx = { + log: log +}; + +function compilerBug(a, b, c, f) { + let exit = 0; + if (a !== "x") { + exit = 2; + } + if (exit === 2) { + if (b === undefined) { + if (c) { + result.contents = "No x, c is true"; + } else { + result.contents = "No x, c is false"; + } + return; + } + if (b !== "x") { + if (c) { + result.contents = "No x, c is true"; + } else { + result.contents = "No x, c is false"; + } + return; + } + + } + if (f()) { + result.contents = "Some x, f returns true"; + } else { + result.contents = "Some x, f returns false"; + } +} + +let suites = { + contents: /* [] */0 +}; + +let test_id = { + contents: 0 +}; + +function eq(loc, x, y) { + Mt.eq_suites(test_id, suites, loc, x, y); +} + +compilerBug("x", undefined, true, () => true); + +eq("File \"gpr_3875_test.res\", line 35, characters 5-12", result.contents, "Some x, f returns true"); + +Mt.from_pair_suites("gpr_3875_test.res", suites.contents); + +export { + result, + Xx, + compilerBug, + suites, + test_id, + eq, +} +/* Not a pure module */ diff --git a/tests/tests/src/gpr_3877_test.js b/tests/tests/src/gpr_3877_test.js deleted file mode 100644 index 27c66d7aef..0000000000 --- a/tests/tests/src/gpr_3877_test.js +++ /dev/null @@ -1,50 +0,0 @@ -// Generated by ReScript, PLEASE EDIT WITH CARE -'use strict'; - - -function test(code) { - if (code > 599 || code < 500) { - if (code === 201 || code === 200) { - return "good response"; - } else { - return "the catch all"; - } - } else if (code > 597 || code < 512) { - return "bad response"; - } else { - return "the catch all"; - } -} - -let a = "good response"; - -let b = "bad response"; - -if (a !== "good response") { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "gpr_3877_test.res", - 26, - 0 - ], - Error: new Error() - }; -} - -if (b !== "bad response") { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "gpr_3877_test.res", - 27, - 0 - ], - Error: new Error() - }; -} - -exports.test = test; -exports.a = a; -exports.b = b; -/* Not a pure module */ diff --git a/tests/tests/src/gpr_3877_test.mjs b/tests/tests/src/gpr_3877_test.mjs new file mode 100644 index 0000000000..66f0c8d4ff --- /dev/null +++ b/tests/tests/src/gpr_3877_test.mjs @@ -0,0 +1,51 @@ +// Generated by ReScript, PLEASE EDIT WITH CARE + + +function test(code) { + if (code > 599 || code < 500) { + if (code === 201 || code === 200) { + return "good response"; + } else { + return "the catch all"; + } + } else if (code > 597 || code < 512) { + return "bad response"; + } else { + return "the catch all"; + } +} + +let a = "good response"; + +let b = "bad response"; + +if (a !== "good response") { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "gpr_3877_test.res", + 26, + 0 + ], + Error: new Error() + }; +} + +if (b !== "bad response") { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "gpr_3877_test.res", + 27, + 0 + ], + Error: new Error() + }; +} + +export { + test, + a, + b, +} +/* Not a pure module */ diff --git a/tests/tests/src/gpr_3895_test.js b/tests/tests/src/gpr_3895_test.js deleted file mode 100644 index 6e01e4091e..0000000000 --- a/tests/tests/src/gpr_3895_test.js +++ /dev/null @@ -1,11 +0,0 @@ -// Generated by ReScript, PLEASE EDIT WITH CARE -'use strict'; - - -function f(re) { - re.exec("banana"); - return 3; -} - -exports.f = f; -/* No side effect */ diff --git a/tests/tests/src/gpr_3895_test.mjs b/tests/tests/src/gpr_3895_test.mjs new file mode 100644 index 0000000000..002e342b1c --- /dev/null +++ b/tests/tests/src/gpr_3895_test.mjs @@ -0,0 +1,12 @@ +// Generated by ReScript, PLEASE EDIT WITH CARE + + +function f(re) { + re.exec("banana"); + return 3; +} + +export { + f, +} +/* No side effect */ diff --git a/tests/tests/src/gpr_3897_test.js b/tests/tests/src/gpr_3897_test.js deleted file mode 100644 index d5f7e2fcca..0000000000 --- a/tests/tests/src/gpr_3897_test.js +++ /dev/null @@ -1,10 +0,0 @@ -// Generated by ReScript, PLEASE EDIT WITH CARE -'use strict'; - - -function Make(U) { - return U; -} - -exports.Make = Make; -/* No side effect */ diff --git a/tests/tests/src/gpr_3897_test.mjs b/tests/tests/src/gpr_3897_test.mjs new file mode 100644 index 0000000000..b64b18e493 --- /dev/null +++ b/tests/tests/src/gpr_3897_test.mjs @@ -0,0 +1,11 @@ +// Generated by ReScript, PLEASE EDIT WITH CARE + + +function Make(U) { + return U; +} + +export { + Make, +} +/* No side effect */ diff --git a/tests/tests/src/gpr_3931_test.js b/tests/tests/src/gpr_3931_test.js deleted file mode 100644 index 9abd2ec825..0000000000 --- a/tests/tests/src/gpr_3931_test.js +++ /dev/null @@ -1,66 +0,0 @@ -// Generated by ReScript, PLEASE EDIT WITH CARE -'use strict'; - -let Belt_Array = require("rescript/lib/js/Belt_Array.js"); -let Primitive_module = require("rescript/lib/js/Primitive_module.js"); - -let PA = Primitive_module.init([ - "gpr_3931_test.res", - 3, - 4 -], { - TAG: "Module", - _0: [[ - "Function", - "print" - ]] -}); - -let P = Primitive_module.init([ - "gpr_3931_test.res", - 12, - 4 -], { - TAG: "Module", - _0: [[ - "Function", - "print" - ]] -}); - -function print(a) { - Belt_Array.forEach(a, P.print); -} - -Primitive_module.update({ - TAG: "Module", - _0: [[ - "Function", - "print" - ]] -}, PA, { - print: print -}); - -function print$1(i) { - console.log("%d", i); -} - -Primitive_module.update({ - TAG: "Module", - _0: [[ - "Function", - "print" - ]] -}, P, { - print: print$1 -}); - -PA.print([ - 1, - 2 -]); - -exports.PA = PA; -exports.P = P; -/* PA Not a pure module */ diff --git a/tests/tests/src/gpr_3931_test.mjs b/tests/tests/src/gpr_3931_test.mjs new file mode 100644 index 0000000000..551d06a19a --- /dev/null +++ b/tests/tests/src/gpr_3931_test.mjs @@ -0,0 +1,67 @@ +// Generated by ReScript, PLEASE EDIT WITH CARE + +import * as Belt_Array from "rescript/lib/es6/Belt_Array.js"; +import * as Primitive_module from "rescript/lib/es6/Primitive_module.js"; + +let PA = Primitive_module.init([ + "gpr_3931_test.res", + 3, + 4 +], { + TAG: "Module", + _0: [[ + "Function", + "print" + ]] +}); + +let P = Primitive_module.init([ + "gpr_3931_test.res", + 12, + 4 +], { + TAG: "Module", + _0: [[ + "Function", + "print" + ]] +}); + +function print(a) { + Belt_Array.forEach(a, P.print); +} + +Primitive_module.update({ + TAG: "Module", + _0: [[ + "Function", + "print" + ]] +}, PA, { + print: print +}); + +function print$1(i) { + console.log("%d", i); +} + +Primitive_module.update({ + TAG: "Module", + _0: [[ + "Function", + "print" + ]] +}, P, { + print: print$1 +}); + +PA.print([ + 1, + 2 +]); + +export { + PA, + P, +} +/* PA Not a pure module */ diff --git a/tests/tests/src/gpr_3980_test.js b/tests/tests/src/gpr_3980_test.js deleted file mode 100644 index 9e092fc64f..0000000000 --- a/tests/tests/src/gpr_3980_test.js +++ /dev/null @@ -1,48 +0,0 @@ -// Generated by ReScript, PLEASE EDIT WITH CARE -'use strict'; - -let Js_math = require("rescript/lib/js/Js_math.js"); - -let match = 1; - -if (match !== undefined) { - if (match !== 1) { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "gpr_3980_test.res", - 15, - 7 - ], - Error: new Error() - }; - } - let match$1 = 1; - if (match$1 !== 1) { - if (match$1 !== 2) { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "gpr_3980_test.res", - 13, - 9 - ], - Error: new Error() - }; - } - Js_math.floor(1); - } - -} else { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "gpr_3980_test.res", - 15, - 7 - ], - Error: new Error() - }; -} - -/* Not a pure module */ diff --git a/tests/tests/src/gpr_3980_test.mjs b/tests/tests/src/gpr_3980_test.mjs new file mode 100644 index 0000000000..6dacc59289 --- /dev/null +++ b/tests/tests/src/gpr_3980_test.mjs @@ -0,0 +1,47 @@ +// Generated by ReScript, PLEASE EDIT WITH CARE + +import * as Js_math from "rescript/lib/es6/Js_math.js"; + +let match = 1; + +if (match !== undefined) { + if (match !== 1) { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "gpr_3980_test.res", + 15, + 7 + ], + Error: new Error() + }; + } + let match$1 = 1; + if (match$1 !== 1) { + if (match$1 !== 2) { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "gpr_3980_test.res", + 13, + 9 + ], + Error: new Error() + }; + } + Js_math.floor(1); + } + +} else { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "gpr_3980_test.res", + 15, + 7 + ], + Error: new Error() + }; +} + +/* Not a pure module */ diff --git a/tests/tests/src/gpr_4025_test.js b/tests/tests/src/gpr_4025_test.js deleted file mode 100644 index 009ab3fd39..0000000000 --- a/tests/tests/src/gpr_4025_test.js +++ /dev/null @@ -1,16 +0,0 @@ -// Generated by ReScript, PLEASE EDIT WITH CARE -'use strict'; - - -({})["hi"] = "hello"; - -console.log("hi"); - -function f(x) { - ({ - x: (console.log("hi"), x) - }).x = x + 1 | 0; -} - -exports.f = f; -/* Not a pure module */ diff --git a/tests/tests/src/gpr_4025_test.mjs b/tests/tests/src/gpr_4025_test.mjs new file mode 100644 index 0000000000..5da59c6157 --- /dev/null +++ b/tests/tests/src/gpr_4025_test.mjs @@ -0,0 +1,17 @@ +// Generated by ReScript, PLEASE EDIT WITH CARE + + +({})["hi"] = "hello"; + +console.log("hi"); + +function f(x) { + ({ + x: (console.log("hi"), x) + }).x = x + 1 | 0; +} + +export { + f, +} +/* Not a pure module */ diff --git a/tests/tests/src/gpr_4069_test.js b/tests/tests/src/gpr_4069_test.js deleted file mode 100644 index 2bfd0e23e8..0000000000 --- a/tests/tests/src/gpr_4069_test.js +++ /dev/null @@ -1,47 +0,0 @@ -// Generated by ReScript, PLEASE EDIT WITH CARE -'use strict'; - - -function f(value) { - if (value == null) { - return; - } else { - return value; - } -} - -function fxx(v) { - let match = v(); - switch (match) { - case 1 : - return /* 'a' */97; - case 2 : - return /* 'b' */98; - case 3 : - return /* 'c' */99; - default: - return /* 'd' */100; - } -} - -function fxxx2(v) { - if (v()) { - return 2; - } else { - return 1; - } -} - -function fxxx3(v) { - if (v()) { - return 2; - } else { - return 1; - } -} - -exports.f = f; -exports.fxx = fxx; -exports.fxxx2 = fxxx2; -exports.fxxx3 = fxxx3; -/* No side effect */ diff --git a/tests/tests/src/gpr_4069_test.mjs b/tests/tests/src/gpr_4069_test.mjs new file mode 100644 index 0000000000..5f3ccfae9c --- /dev/null +++ b/tests/tests/src/gpr_4069_test.mjs @@ -0,0 +1,48 @@ +// Generated by ReScript, PLEASE EDIT WITH CARE + + +function f(value) { + if (value == null) { + return; + } else { + return value; + } +} + +function fxx(v) { + let match = v(); + switch (match) { + case 1 : + return /* 'a' */97; + case 2 : + return /* 'b' */98; + case 3 : + return /* 'c' */99; + default: + return /* 'd' */100; + } +} + +function fxxx2(v) { + if (v()) { + return 2; + } else { + return 1; + } +} + +function fxxx3(v) { + if (v()) { + return 2; + } else { + return 1; + } +} + +export { + f, + fxx, + fxxx2, + fxxx3, +} +/* No side effect */ diff --git a/tests/tests/src/gpr_4265_test.js b/tests/tests/src/gpr_4265_test.js deleted file mode 100644 index faba26bf99..0000000000 --- a/tests/tests/src/gpr_4265_test.js +++ /dev/null @@ -1,52 +0,0 @@ -// Generated by ReScript, PLEASE EDIT WITH CARE -'use strict'; - -let Mt = require("./mt.js"); -let Belt_MutableMapInt = require("rescript/lib/js/Belt_MutableMapInt.js"); - -let suites = { - contents: /* [] */0 -}; - -let test_id = { - contents: 0 -}; - -function eq(loc, x, y) { - Mt.eq_suites(test_id, suites, loc, x, y); -} - -let mockMap = Belt_MutableMapInt.make(); - -function add(id) { - Belt_MutableMapInt.set(mockMap, id, id); - return id; -} - -function remove(id) { - Belt_MutableMapInt.remove(mockMap, id); -} - -add(1726); - -let n = add(6667); - -add(486); - -Belt_MutableMapInt.remove(mockMap, 1726); - -let n1 = Belt_MutableMapInt.getExn(mockMap, 6667); - -eq("File \"gpr_4265_test.res\", line 18, characters 3-10", n, n1); - -Mt.from_pair_suites("gpr_4265_test.res", suites.contents); - -exports.suites = suites; -exports.test_id = test_id; -exports.eq = eq; -exports.mockMap = mockMap; -exports.add = add; -exports.remove = remove; -exports.n = n; -exports.n1 = n1; -/* mockMap Not a pure module */ diff --git a/tests/tests/src/gpr_4265_test.mjs b/tests/tests/src/gpr_4265_test.mjs new file mode 100644 index 0000000000..2383420185 --- /dev/null +++ b/tests/tests/src/gpr_4265_test.mjs @@ -0,0 +1,53 @@ +// Generated by ReScript, PLEASE EDIT WITH CARE + +import * as Mt from "./mt.mjs"; +import * as Belt_MutableMapInt from "rescript/lib/es6/Belt_MutableMapInt.js"; + +let suites = { + contents: /* [] */0 +}; + +let test_id = { + contents: 0 +}; + +function eq(loc, x, y) { + Mt.eq_suites(test_id, suites, loc, x, y); +} + +let mockMap = Belt_MutableMapInt.make(); + +function add(id) { + Belt_MutableMapInt.set(mockMap, id, id); + return id; +} + +function remove(id) { + Belt_MutableMapInt.remove(mockMap, id); +} + +add(1726); + +let n = add(6667); + +add(486); + +Belt_MutableMapInt.remove(mockMap, 1726); + +let n1 = Belt_MutableMapInt.getExn(mockMap, 6667); + +eq("File \"gpr_4265_test.res\", line 18, characters 3-10", n, n1); + +Mt.from_pair_suites("gpr_4265_test.res", suites.contents); + +export { + suites, + test_id, + eq, + mockMap, + add, + remove, + n, + n1, +} +/* mockMap Not a pure module */ diff --git a/tests/tests/src/gpr_4274_test.js b/tests/tests/src/gpr_4274_test.js deleted file mode 100644 index f42ebb2d5c..0000000000 --- a/tests/tests/src/gpr_4274_test.js +++ /dev/null @@ -1,38 +0,0 @@ -// Generated by ReScript, PLEASE EDIT WITH CARE -'use strict'; - -let Belt_List = require("rescript/lib/js/Belt_List.js"); -let Belt_Array = require("rescript/lib/js/Belt_Array.js"); - -let N = {}; - -function f(X, xs) { - X.forEach(xs, { - i: x => { - console.log(x.x); - } - }); -} - -Belt_List.forEach({ - hd: { - x: 3 - }, - tl: /* [] */0 -}, x => { - console.log(x.x); -}); - -let Foo = {}; - -let bar = [{ - foo: "bar" - }]; - -Belt_Array.map(bar, b => b.foo); - -exports.N = N; -exports.f = f; -exports.Foo = Foo; -exports.bar = bar; -/* Not a pure module */ diff --git a/tests/tests/src/gpr_4274_test.mjs b/tests/tests/src/gpr_4274_test.mjs new file mode 100644 index 0000000000..9f7a387279 --- /dev/null +++ b/tests/tests/src/gpr_4274_test.mjs @@ -0,0 +1,39 @@ +// Generated by ReScript, PLEASE EDIT WITH CARE + +import * as Belt_List from "rescript/lib/es6/Belt_List.js"; +import * as Belt_Array from "rescript/lib/es6/Belt_Array.js"; + +let N = {}; + +function f(X, xs) { + X.forEach(xs, { + i: x => { + console.log(x.x); + } + }); +} + +Belt_List.forEach({ + hd: { + x: 3 + }, + tl: /* [] */0 +}, x => { + console.log(x.x); +}); + +let Foo = {}; + +let bar = [{ + foo: "bar" + }]; + +Belt_Array.map(bar, b => b.foo); + +export { + N, + f, + Foo, + bar, +} +/* Not a pure module */ diff --git a/tests/tests/src/gpr_4280_test.js b/tests/tests/src/gpr_4280_test.js deleted file mode 100644 index ace40e3643..0000000000 --- a/tests/tests/src/gpr_4280_test.js +++ /dev/null @@ -1,112 +0,0 @@ -// Generated by ReScript, PLEASE EDIT WITH CARE -'use strict'; - -let Mt = require("./mt.js"); - -let suites = { - contents: /* [] */0 -}; - -let test_id = { - contents: 0 -}; - -function eq(loc, x, y) { - Mt.eq_suites(test_id, suites, loc, x, y); -} - -let u = { - contents: 0 -}; - -function div(children, param) { - for (let i = 0; i <= 1; ++i) { - u.contents = 300; - console.log("nonline"); - } -} - -function string(s) { - for (let i = 0; i <= 1; ++i) { - u.contents = 200; - console.log("no"); - } -} - -function fn(authState, route) { - let onboardingRoute; - if (typeof authState === "object") { - let exit = 0; - if (typeof route === "object" && route.NAME === "Onboarding") { - onboardingRoute = route.VAL; - } else { - exit = 2; - } - if (exit === 2) { - console.log(authState.VAL); - div({ - hd: string("VerifyEmail"), - tl: /* [] */0 - }, undefined); - return 2; - } - - } else { - let exit$1 = 0; - if (typeof route === "object") { - if (route.NAME === "Onboarding") { - onboardingRoute = route.VAL; - } else { - exit$1 = 2; - } - } else { - if (route === "SignUp" || route === "SignIn" || route === "Invite" || route === "PasswordReset") { - div({ - hd: string("LoggedOut"), - tl: /* [] */0 - }, undefined); - return 1; - } - exit$1 = 2; - } - if (exit$1 === 2) { - div({ - hd: string("Redirect"), - tl: /* [] */0 - }, undefined); - return 3; - } - - } - console.log(onboardingRoute); - div({ - hd: string("Onboarding"), - tl: /* [] */0 - }, undefined); - return 0; -} - -eq("File \"gpr_4280_test.res\", line 42, characters 3-10", fn("Unauthenticated", "Invite"), 1); - -eq("File \"gpr_4280_test.res\", line 43, characters 3-10", fn("Unauthenticated", { - NAME: "Onboarding", - VAL: 0 -}), 0); - -eq("File \"gpr_4280_test.res\", line 44, characters 3-10", fn({ - NAME: "Unverified", - VAL: 0 -}, "Invite"), 2); - -eq("File \"gpr_4280_test.res\", line 45, characters 3-10", fn("Unauthenticated", "xx"), 3); - -Mt.from_pair_suites("gpr_4280_test.res", suites.contents); - -exports.suites = suites; -exports.test_id = test_id; -exports.eq = eq; -exports.u = u; -exports.div = div; -exports.string = string; -exports.fn = fn; -/* Not a pure module */ diff --git a/tests/tests/src/gpr_4280_test.mjs b/tests/tests/src/gpr_4280_test.mjs new file mode 100644 index 0000000000..1ee814af0c --- /dev/null +++ b/tests/tests/src/gpr_4280_test.mjs @@ -0,0 +1,113 @@ +// Generated by ReScript, PLEASE EDIT WITH CARE + +import * as Mt from "./mt.mjs"; + +let suites = { + contents: /* [] */0 +}; + +let test_id = { + contents: 0 +}; + +function eq(loc, x, y) { + Mt.eq_suites(test_id, suites, loc, x, y); +} + +let u = { + contents: 0 +}; + +function div(children, param) { + for (let i = 0; i <= 1; ++i) { + u.contents = 300; + console.log("nonline"); + } +} + +function string(s) { + for (let i = 0; i <= 1; ++i) { + u.contents = 200; + console.log("no"); + } +} + +function fn(authState, route) { + let onboardingRoute; + if (typeof authState === "object") { + let exit = 0; + if (typeof route === "object" && route.NAME === "Onboarding") { + onboardingRoute = route.VAL; + } else { + exit = 2; + } + if (exit === 2) { + console.log(authState.VAL); + div({ + hd: string("VerifyEmail"), + tl: /* [] */0 + }, undefined); + return 2; + } + + } else { + let exit$1 = 0; + if (typeof route === "object") { + if (route.NAME === "Onboarding") { + onboardingRoute = route.VAL; + } else { + exit$1 = 2; + } + } else { + if (route === "SignUp" || route === "SignIn" || route === "Invite" || route === "PasswordReset") { + div({ + hd: string("LoggedOut"), + tl: /* [] */0 + }, undefined); + return 1; + } + exit$1 = 2; + } + if (exit$1 === 2) { + div({ + hd: string("Redirect"), + tl: /* [] */0 + }, undefined); + return 3; + } + + } + console.log(onboardingRoute); + div({ + hd: string("Onboarding"), + tl: /* [] */0 + }, undefined); + return 0; +} + +eq("File \"gpr_4280_test.res\", line 42, characters 3-10", fn("Unauthenticated", "Invite"), 1); + +eq("File \"gpr_4280_test.res\", line 43, characters 3-10", fn("Unauthenticated", { + NAME: "Onboarding", + VAL: 0 +}), 0); + +eq("File \"gpr_4280_test.res\", line 44, characters 3-10", fn({ + NAME: "Unverified", + VAL: 0 +}, "Invite"), 2); + +eq("File \"gpr_4280_test.res\", line 45, characters 3-10", fn("Unauthenticated", "xx"), 3); + +Mt.from_pair_suites("gpr_4280_test.res", suites.contents); + +export { + suites, + test_id, + eq, + u, + div, + string, + fn, +} +/* Not a pure module */ diff --git a/tests/tests/src/gpr_4407_test.js b/tests/tests/src/gpr_4407_test.js deleted file mode 100644 index f2acc97937..0000000000 --- a/tests/tests/src/gpr_4407_test.js +++ /dev/null @@ -1,33 +0,0 @@ -// Generated by ReScript, PLEASE EDIT WITH CARE -'use strict'; - -let Mt = require("./mt.js"); -let Debug_mode_value = require("./debug_mode_value.js"); - -let suites = { - contents: /* [] */0 -}; - -let test_id = { - contents: 0 -}; - -function eq(loc, x, y) { - Mt.eq_suites(test_id, suites, loc, x, y); -} - -let non_debug_u = { - TAG: "A", - _0: 1, - _1: 2 -}; - -eq("File \"gpr_4407_test.res\", line 7, characters 3-10", Debug_mode_value.u, non_debug_u); - -Mt.from_pair_suites("File \"gpr_4407_test.res\", line 8, characters 20-27", suites.contents); - -exports.suites = suites; -exports.test_id = test_id; -exports.eq = eq; -exports.non_debug_u = non_debug_u; -/* Not a pure module */ diff --git a/tests/tests/src/gpr_4407_test.mjs b/tests/tests/src/gpr_4407_test.mjs new file mode 100644 index 0000000000..9769092d6c --- /dev/null +++ b/tests/tests/src/gpr_4407_test.mjs @@ -0,0 +1,34 @@ +// Generated by ReScript, PLEASE EDIT WITH CARE + +import * as Mt from "./mt.mjs"; +import * as Debug_mode_value from "./debug_mode_value.mjs"; + +let suites = { + contents: /* [] */0 +}; + +let test_id = { + contents: 0 +}; + +function eq(loc, x, y) { + Mt.eq_suites(test_id, suites, loc, x, y); +} + +let non_debug_u = { + TAG: "A", + _0: 1, + _1: 2 +}; + +eq("File \"gpr_4407_test.res\", line 7, characters 3-10", Debug_mode_value.u, non_debug_u); + +Mt.from_pair_suites("File \"gpr_4407_test.res\", line 8, characters 20-27", suites.contents); + +export { + suites, + test_id, + eq, + non_debug_u, +} +/* Not a pure module */ diff --git a/tests/tests/src/gpr_441.js b/tests/tests/src/gpr_441.mjs similarity index 100% rename from tests/tests/src/gpr_441.js rename to tests/tests/src/gpr_441.mjs diff --git a/tests/tests/src/gpr_4442_test.js b/tests/tests/src/gpr_4442_test.js deleted file mode 100644 index 3aed6757a0..0000000000 --- a/tests/tests/src/gpr_4442_test.js +++ /dev/null @@ -1,35 +0,0 @@ -// Generated by ReScript, PLEASE EDIT WITH CARE -'use strict'; - -let Mt = require("./mt.js"); - -let suites = { - contents: /* [] */0 -}; - -let test_id = { - contents: 0 -}; - -function eq(loc, x, y) { - Mt.eq_suites(test_id, suites, loc, x, y); -} - -let u = (function fib(n){ - if(n===0||n==1){ - return 1 - } - return fib(n-1) + fib(n-2) -}); - -eq("File \"gpr_4442_test.res\", line 12, characters 3-10", u(2), 2); - -eq("File \"gpr_4442_test.res\", line 13, characters 3-10", u(3), 3); - -Mt.from_pair_suites("gpr_4442_test.res", suites.contents); - -exports.suites = suites; -exports.test_id = test_id; -exports.eq = eq; -exports.u = u; -/* Not a pure module */ diff --git a/tests/tests/src/gpr_4442_test.mjs b/tests/tests/src/gpr_4442_test.mjs new file mode 100644 index 0000000000..a8e879ee62 --- /dev/null +++ b/tests/tests/src/gpr_4442_test.mjs @@ -0,0 +1,36 @@ +// Generated by ReScript, PLEASE EDIT WITH CARE + +import * as Mt from "./mt.mjs"; + +let suites = { + contents: /* [] */0 +}; + +let test_id = { + contents: 0 +}; + +function eq(loc, x, y) { + Mt.eq_suites(test_id, suites, loc, x, y); +} + +let u = (function fib(n){ + if(n===0||n==1){ + return 1 + } + return fib(n-1) + fib(n-2) +}); + +eq("File \"gpr_4442_test.res\", line 12, characters 3-10", u(2), 2); + +eq("File \"gpr_4442_test.res\", line 13, characters 3-10", u(3), 3); + +Mt.from_pair_suites("gpr_4442_test.res", suites.contents); + +export { + suites, + test_id, + eq, + u, +} +/* Not a pure module */ diff --git a/tests/tests/src/gpr_4491_test.js b/tests/tests/src/gpr_4491_test.js deleted file mode 100644 index c36e8b60fd..0000000000 --- a/tests/tests/src/gpr_4491_test.js +++ /dev/null @@ -1,16 +0,0 @@ -// Generated by ReScript, PLEASE EDIT WITH CARE -'use strict'; - - -function f(xs) { - if (xs !== undefined) { - console.log("side effect"); - - } else { - - } - console.log("nothing to see here", xs); -} - -exports.f = f; -/* No side effect */ diff --git a/tests/tests/src/gpr_4491_test.mjs b/tests/tests/src/gpr_4491_test.mjs new file mode 100644 index 0000000000..44a26abb85 --- /dev/null +++ b/tests/tests/src/gpr_4491_test.mjs @@ -0,0 +1,17 @@ +// Generated by ReScript, PLEASE EDIT WITH CARE + + +function f(xs) { + if (xs !== undefined) { + console.log("side effect"); + + } else { + + } + console.log("nothing to see here", xs); +} + +export { + f, +} +/* No side effect */ diff --git a/tests/tests/src/gpr_4494_test.js b/tests/tests/src/gpr_4494_test.mjs similarity index 100% rename from tests/tests/src/gpr_4494_test.js rename to tests/tests/src/gpr_4494_test.mjs diff --git a/tests/tests/src/gpr_4519_test.js b/tests/tests/src/gpr_4519_test.js deleted file mode 100644 index 108f0cc1ed..0000000000 --- a/tests/tests/src/gpr_4519_test.js +++ /dev/null @@ -1,38 +0,0 @@ -// Generated by ReScript, PLEASE EDIT WITH CARE -'use strict'; - -let Mt = require("./mt.js"); - -let suites = { - contents: /* [] */0 -}; - -let test_id = { - contents: 0 -}; - -function eq(loc, x, y) { - Mt.eq_suites(test_id, suites, loc, x, y); -} - -function nextFor(x) { - if (x !== undefined) { - if (x === "Required") { - return "Optional"; - } else { - return; - } - } else { - return "Required"; - } -} - -eq("File \"gpr_4519_test.res\", line 16, characters 3-10", nextFor("Required"), "Optional"); - -Mt.from_pair_suites("Gpr_4519_test", suites.contents); - -exports.suites = suites; -exports.test_id = test_id; -exports.eq = eq; -exports.nextFor = nextFor; -/* Not a pure module */ diff --git a/tests/tests/src/gpr_4519_test.mjs b/tests/tests/src/gpr_4519_test.mjs new file mode 100644 index 0000000000..0ae150ce6b --- /dev/null +++ b/tests/tests/src/gpr_4519_test.mjs @@ -0,0 +1,39 @@ +// Generated by ReScript, PLEASE EDIT WITH CARE + +import * as Mt from "./mt.mjs"; + +let suites = { + contents: /* [] */0 +}; + +let test_id = { + contents: 0 +}; + +function eq(loc, x, y) { + Mt.eq_suites(test_id, suites, loc, x, y); +} + +function nextFor(x) { + if (x !== undefined) { + if (x === "Required") { + return "Optional"; + } else { + return; + } + } else { + return "Required"; + } +} + +eq("File \"gpr_4519_test.res\", line 16, characters 3-10", nextFor("Required"), "Optional"); + +Mt.from_pair_suites("Gpr_4519_test", suites.contents); + +export { + suites, + test_id, + eq, + nextFor, +} +/* Not a pure module */ diff --git a/tests/tests/src/gpr_459_test.js b/tests/tests/src/gpr_459_test.js deleted file mode 100644 index 26b66b39e2..0000000000 --- a/tests/tests/src/gpr_459_test.js +++ /dev/null @@ -1,55 +0,0 @@ -// Generated by ReScript, PLEASE EDIT WITH CARE -'use strict'; - -let Mt = require("./mt.js"); - -let suites = { - contents: /* [] */0 -}; - -let test_id = { - contents: 0 -}; - -function eq(loc, x, y) { - test_id.contents = test_id.contents + 1 | 0; - suites.contents = { - hd: [ - loc + (" id " + test_id.contents.toString()), - () => ({ - TAG: "Eq", - _0: x, - _1: y - }) - ], - tl: suites.contents - }; -} - -let uu = { - "_'x": 3 -}; - -let uu2 = { - _then: 1, - catch: 2, - "_'x": 3 -}; - -let hh = uu["_'x"]; - -eq("File \"gpr_459_test.res\", line 26, characters 12-19", hh, 3); - -eq("File \"gpr_459_test.res\", line 28, characters 12-19", [ - 1, - 2, - 3 -], [ - uu2._then, - uu2.catch, - uu2["_'x"] -]); - -Mt.from_pair_suites("Gpr_459_test", suites.contents); - -/* hh Not a pure module */ diff --git a/tests/tests/src/gpr_459_test.mjs b/tests/tests/src/gpr_459_test.mjs new file mode 100644 index 0000000000..561368ea42 --- /dev/null +++ b/tests/tests/src/gpr_459_test.mjs @@ -0,0 +1,54 @@ +// Generated by ReScript, PLEASE EDIT WITH CARE + +import * as Mt from "./mt.mjs"; + +let suites = { + contents: /* [] */0 +}; + +let test_id = { + contents: 0 +}; + +function eq(loc, x, y) { + test_id.contents = test_id.contents + 1 | 0; + suites.contents = { + hd: [ + loc + (" id " + test_id.contents.toString()), + () => ({ + TAG: "Eq", + _0: x, + _1: y + }) + ], + tl: suites.contents + }; +} + +let uu = { + "_'x": 3 +}; + +let uu2 = { + _then: 1, + catch: 2, + "_'x": 3 +}; + +let hh = uu["_'x"]; + +eq("File \"gpr_459_test.res\", line 26, characters 12-19", hh, 3); + +eq("File \"gpr_459_test.res\", line 28, characters 12-19", [ + 1, + 2, + 3 +], [ + uu2._then, + uu2.catch, + uu2["_'x"] +]); + +Mt.from_pair_suites("Gpr_459_test", suites.contents); + +/* hh Not a pure module */ diff --git a/tests/tests/src/gpr_4632.js b/tests/tests/src/gpr_4632.js deleted file mode 100644 index fa3f84ae3c..0000000000 --- a/tests/tests/src/gpr_4632.js +++ /dev/null @@ -1,36 +0,0 @@ -// Generated by ReScript, PLEASE EDIT WITH CARE -'use strict'; - - -let T0_myList = { - hd: 1, - tl: { - hd: 2, - tl: /* [] */0 - } -}; - -let T0_tail = { - hd: 2, - tl: /* [] */0 -}; - -let T0 = { - myList: T0_myList, - head: 1, - tail: T0_tail -}; - -throw { - RE_EXN_ID: "Match_failure", - _1: [ - "gpr_4632.res", - 12, - 6 - ], - Error: new Error() -}; - -exports.T0 = T0; -exports.T1 = T1; -/* T1 Not a pure module */ diff --git a/tests/tests/src/gpr_4632.mjs b/tests/tests/src/gpr_4632.mjs new file mode 100644 index 0000000000..66dfe24aac --- /dev/null +++ b/tests/tests/src/gpr_4632.mjs @@ -0,0 +1,37 @@ +// Generated by ReScript, PLEASE EDIT WITH CARE + + +let T0_myList = { + hd: 1, + tl: { + hd: 2, + tl: /* [] */0 + } +}; + +let T0_tail = { + hd: 2, + tl: /* [] */0 +}; + +let T0 = { + myList: T0_myList, + head: 1, + tail: T0_tail +}; + +throw { + RE_EXN_ID: "Match_failure", + _1: [ + "gpr_4632.res", + 12, + 6 + ], + Error: new Error() +}; + +export { + T0, + T1, +} +/* T1 Not a pure module */ diff --git a/tests/tests/src/gpr_4639_test.js b/tests/tests/src/gpr_4639_test.js deleted file mode 100644 index 881fe37bf2..0000000000 --- a/tests/tests/src/gpr_4639_test.js +++ /dev/null @@ -1,24 +0,0 @@ -// Generated by ReScript, PLEASE EDIT WITH CARE -'use strict'; - - -function x(url) { - if (!url) { - return "start"; - } - switch (url.hd) { - case "login" : - if (url.tl) { - return "start"; - } else { - return "login"; - } - case "start" : - return "start"; - default: - return "start"; - } -} - -exports.x = x; -/* No side effect */ diff --git a/tests/tests/src/gpr_4639_test.mjs b/tests/tests/src/gpr_4639_test.mjs new file mode 100644 index 0000000000..6e281fb365 --- /dev/null +++ b/tests/tests/src/gpr_4639_test.mjs @@ -0,0 +1,25 @@ +// Generated by ReScript, PLEASE EDIT WITH CARE + + +function x(url) { + if (!url) { + return "start"; + } + switch (url.hd) { + case "login" : + if (url.tl) { + return "start"; + } else { + return "login"; + } + case "start" : + return "start"; + default: + return "start"; + } +} + +export { + x, +} +/* No side effect */ diff --git a/tests/tests/src/gpr_4900_test.js b/tests/tests/src/gpr_4900_test.js deleted file mode 100644 index 35fd666726..0000000000 --- a/tests/tests/src/gpr_4900_test.js +++ /dev/null @@ -1,39 +0,0 @@ -// Generated by ReScript, PLEASE EDIT WITH CARE -'use strict'; - -let Mt = require("./mt.js"); - -let suites = { - contents: /* [] */0 -}; - -let test_id = { - contents: 0 -}; - -function showToJs(x) { - if (typeof x !== "object" && x === "No") { - return false; - } else { - return true; - } -} - -Mt.eq_suites(test_id, suites, "File \"gpr_4900_test.res\", line 13, characters 29-36", true, true); - -Mt.eq_suites(test_id, suites, "File \"gpr_4900_test.res\", line 14, characters 29-36", false, false); - -Mt.eq_suites(test_id, suites, "File \"gpr_4900_test.res\", line 15, characters 29-36", true, true); - -Mt.from_pair_suites("File \"gpr_4900_test.res\", line 17, characters 17-24", suites.contents); - -let from_pair_suites = Mt.from_pair_suites; - -let eq_suites = Mt.eq_suites; - -exports.from_pair_suites = from_pair_suites; -exports.eq_suites = eq_suites; -exports.suites = suites; -exports.test_id = test_id; -exports.showToJs = showToJs; -/* Not a pure module */ diff --git a/tests/tests/src/gpr_4900_test.mjs b/tests/tests/src/gpr_4900_test.mjs new file mode 100644 index 0000000000..5d3ef07f54 --- /dev/null +++ b/tests/tests/src/gpr_4900_test.mjs @@ -0,0 +1,40 @@ +// Generated by ReScript, PLEASE EDIT WITH CARE + +import * as Mt from "./mt.mjs"; + +let suites = { + contents: /* [] */0 +}; + +let test_id = { + contents: 0 +}; + +function showToJs(x) { + if (typeof x !== "object" && x === "No") { + return false; + } else { + return true; + } +} + +Mt.eq_suites(test_id, suites, "File \"gpr_4900_test.res\", line 13, characters 29-36", true, true); + +Mt.eq_suites(test_id, suites, "File \"gpr_4900_test.res\", line 14, characters 29-36", false, false); + +Mt.eq_suites(test_id, suites, "File \"gpr_4900_test.res\", line 15, characters 29-36", true, true); + +Mt.from_pair_suites("File \"gpr_4900_test.res\", line 17, characters 17-24", suites.contents); + +let from_pair_suites = Mt.from_pair_suites; + +let eq_suites = Mt.eq_suites; + +export { + from_pair_suites, + eq_suites, + suites, + test_id, + showToJs, +} +/* Not a pure module */ diff --git a/tests/tests/src/gpr_4924_test.js b/tests/tests/src/gpr_4924_test.js deleted file mode 100644 index ddb8218754..0000000000 --- a/tests/tests/src/gpr_4924_test.js +++ /dev/null @@ -1,93 +0,0 @@ -// Generated by ReScript, PLEASE EDIT WITH CARE -'use strict'; - -let Mt = require("./mt.js"); - -let suites = { - contents: /* [] */0 -}; - -let test_id = { - contents: 0 -}; - -function u(b) { - if (typeof b !== "object" && b === "A") { - return 0; - } else { - return 1; - } -} - -function u1(b) { - if (typeof b !== "object" && b === "A") { - return true; - } else { - return false; - } -} - -function u2(b) { - if (typeof b !== "object" && b === "A") { - return false; - } else { - return true; - } -} - -Mt.eq_suites(test_id, suites, "File \"gpr_4924_test.res\", line 27, characters 29-36", false, false); - -Mt.eq_suites(test_id, suites, "File \"gpr_4924_test.res\", line 28, characters 29-36", true, true); - -Mt.eq_suites(test_id, suites, "File \"gpr_4924_test.res\", line 29, characters 29-36", true, true); - -function u3(b) { - if (typeof b !== "object" && b === "A") { - return 3; - } else { - return 4; - } -} - -function u4(b) { - if (typeof b !== "object" && b === "A") { - return 3; - } else { - return 4; - } -} - -function u5(b) { - if (typeof b !== "object" && b === "A") { - return false; - } else { - return true; - } -} - -function u6(b) { - if (typeof b !== "object" && b === "A") { - return true; - } else { - return false; - } -} - -Mt.from_pair_suites("File \"gpr_4924_test.res\", line 54, characters 17-24", suites.contents); - -let from_pair_suites = Mt.from_pair_suites; - -let eq_suites = Mt.eq_suites; - -exports.from_pair_suites = from_pair_suites; -exports.eq_suites = eq_suites; -exports.suites = suites; -exports.test_id = test_id; -exports.u = u; -exports.u1 = u1; -exports.u2 = u2; -exports.u3 = u3; -exports.u4 = u4; -exports.u5 = u5; -exports.u6 = u6; -/* Not a pure module */ diff --git a/tests/tests/src/gpr_4924_test.mjs b/tests/tests/src/gpr_4924_test.mjs new file mode 100644 index 0000000000..26cbb2f36e --- /dev/null +++ b/tests/tests/src/gpr_4924_test.mjs @@ -0,0 +1,94 @@ +// Generated by ReScript, PLEASE EDIT WITH CARE + +import * as Mt from "./mt.mjs"; + +let suites = { + contents: /* [] */0 +}; + +let test_id = { + contents: 0 +}; + +function u(b) { + if (typeof b !== "object" && b === "A") { + return 0; + } else { + return 1; + } +} + +function u1(b) { + if (typeof b !== "object" && b === "A") { + return true; + } else { + return false; + } +} + +function u2(b) { + if (typeof b !== "object" && b === "A") { + return false; + } else { + return true; + } +} + +Mt.eq_suites(test_id, suites, "File \"gpr_4924_test.res\", line 27, characters 29-36", false, false); + +Mt.eq_suites(test_id, suites, "File \"gpr_4924_test.res\", line 28, characters 29-36", true, true); + +Mt.eq_suites(test_id, suites, "File \"gpr_4924_test.res\", line 29, characters 29-36", true, true); + +function u3(b) { + if (typeof b !== "object" && b === "A") { + return 3; + } else { + return 4; + } +} + +function u4(b) { + if (typeof b !== "object" && b === "A") { + return 3; + } else { + return 4; + } +} + +function u5(b) { + if (typeof b !== "object" && b === "A") { + return false; + } else { + return true; + } +} + +function u6(b) { + if (typeof b !== "object" && b === "A") { + return true; + } else { + return false; + } +} + +Mt.from_pair_suites("File \"gpr_4924_test.res\", line 54, characters 17-24", suites.contents); + +let from_pair_suites = Mt.from_pair_suites; + +let eq_suites = Mt.eq_suites; + +export { + from_pair_suites, + eq_suites, + suites, + test_id, + u, + u1, + u2, + u3, + u4, + u5, + u6, +} +/* Not a pure module */ diff --git a/tests/tests/src/gpr_4931.js b/tests/tests/src/gpr_4931.js deleted file mode 100644 index 3a4a16ec2b..0000000000 --- a/tests/tests/src/gpr_4931.js +++ /dev/null @@ -1,10 +0,0 @@ -// Generated by ReScript, PLEASE EDIT WITH CARE -'use strict'; - - -if (import.meta.hot){ - console.log('es6') -} -; - -/* Not a pure module */ diff --git a/tests/tests/src/gpr_4931.mjs b/tests/tests/src/gpr_4931.mjs new file mode 100644 index 0000000000..eaf96fb94e --- /dev/null +++ b/tests/tests/src/gpr_4931.mjs @@ -0,0 +1,9 @@ +// Generated by ReScript, PLEASE EDIT WITH CARE + + +if (import.meta.hot){ + console.log('es6') +} +; + +/* Not a pure module */ diff --git a/tests/tests_esmodule/src/gpr_4931_allow.mjs b/tests/tests/src/gpr_4931_allow.mjs similarity index 100% rename from tests/tests_esmodule/src/gpr_4931_allow.mjs rename to tests/tests/src/gpr_4931_allow.mjs diff --git a/tests/tests_esmodule/src/gpr_4931_allow.res b/tests/tests/src/gpr_4931_allow.res similarity index 100% rename from tests/tests_esmodule/src/gpr_4931_allow.res rename to tests/tests/src/gpr_4931_allow.res diff --git a/tests/tests/src/gpr_5071_test.js b/tests/tests/src/gpr_5071_test.js deleted file mode 100644 index b0236606ef..0000000000 --- a/tests/tests/src/gpr_5071_test.js +++ /dev/null @@ -1,18 +0,0 @@ -// Generated by ReScript, PLEASE EDIT WITH CARE -'use strict'; - - -function make(s) { - if (s !== undefined) { - return s; - } else { - return null; - } -} - -let H = { - make: make -}; - -exports.H = H; -/* No side effect */ diff --git a/tests/tests/src/gpr_5071_test.mjs b/tests/tests/src/gpr_5071_test.mjs new file mode 100644 index 0000000000..5e390c146c --- /dev/null +++ b/tests/tests/src/gpr_5071_test.mjs @@ -0,0 +1,19 @@ +// Generated by ReScript, PLEASE EDIT WITH CARE + + +function make(s) { + if (s !== undefined) { + return s; + } else { + return null; + } +} + +let H = { + make: make +}; + +export { + H, +} +/* No side effect */ diff --git a/tests/tests/src/gpr_5169_test.js b/tests/tests/src/gpr_5169_test.js deleted file mode 100644 index 68e20efdaf..0000000000 --- a/tests/tests/src/gpr_5169_test.js +++ /dev/null @@ -1,56 +0,0 @@ -// Generated by ReScript, PLEASE EDIT WITH CARE -'use strict'; - - -let NotOption = {}; - -let TotallyNotOption = {}; - -let NotOption2 = {}; - -let a; - -let b = 1; - -let c; - -let d = 1; - -let e; - -let f = 1; - -let g; - -let h = 1; - -let i = "None"; - -let j = { - TAG: "Some", - _0: 1 -}; - -let k = "None"; - -let l = { - TAG: "Some", - _0: 1 -}; - -exports.NotOption = NotOption; -exports.a = a; -exports.b = b; -exports.c = c; -exports.d = d; -exports.TotallyNotOption = TotallyNotOption; -exports.e = e; -exports.f = f; -exports.g = g; -exports.h = h; -exports.NotOption2 = NotOption2; -exports.i = i; -exports.j = j; -exports.k = k; -exports.l = l; -/* No side effect */ diff --git a/tests/tests/src/gpr_5169_test.mjs b/tests/tests/src/gpr_5169_test.mjs new file mode 100644 index 0000000000..a6a1e3c8ac --- /dev/null +++ b/tests/tests/src/gpr_5169_test.mjs @@ -0,0 +1,57 @@ +// Generated by ReScript, PLEASE EDIT WITH CARE + + +let NotOption = {}; + +let TotallyNotOption = {}; + +let NotOption2 = {}; + +let a; + +let b = 1; + +let c; + +let d = 1; + +let e; + +let f = 1; + +let g; + +let h = 1; + +let i = "None"; + +let j = { + TAG: "Some", + _0: 1 +}; + +let k = "None"; + +let l = { + TAG: "Some", + _0: 1 +}; + +export { + NotOption, + a, + b, + c, + d, + TotallyNotOption, + e, + f, + g, + h, + NotOption2, + i, + j, + k, + l, +} +/* No side effect */ diff --git a/tests/tests/src/gpr_5218_test.js b/tests/tests/src/gpr_5218_test.js deleted file mode 100644 index 98cb8e6eb6..0000000000 --- a/tests/tests/src/gpr_5218_test.js +++ /dev/null @@ -1,52 +0,0 @@ -// Generated by ReScript, PLEASE EDIT WITH CARE -'use strict'; - -let Mt = require("./mt.js"); - -let test_id = { - contents: 0 -}; - -let suites = { - contents: /* [] */0 -}; - -function test(x) { - if (x.NAME === 2) { - return { - NAME: 2, - VAL: x.VAL - }; - } else { - return { - NAME: 1, - VAL: x.VAL - }; - } -} - -Mt.eq_suites(test_id, suites, "File \"gpr_5218_test.res\", line 11, characters 29-36", test({ - NAME: 1, - VAL: 3 -}), { - NAME: 1, - VAL: 3 -}); - -Mt.eq_suites(test_id, suites, "File \"gpr_5218_test.res\", line 13, characters 29-36", test({ - NAME: 2, - VAL: 3 -}), { - NAME: 2, - VAL: 3 -}); - -Mt.from_pair_suites("gpr_5218_test.res", suites.contents); - -let eq_suites = Mt.eq_suites; - -exports.eq_suites = eq_suites; -exports.test_id = test_id; -exports.suites = suites; -exports.test = test; -/* Not a pure module */ diff --git a/tests/tests/src/gpr_5218_test.mjs b/tests/tests/src/gpr_5218_test.mjs new file mode 100644 index 0000000000..a8ab04cbc6 --- /dev/null +++ b/tests/tests/src/gpr_5218_test.mjs @@ -0,0 +1,53 @@ +// Generated by ReScript, PLEASE EDIT WITH CARE + +import * as Mt from "./mt.mjs"; + +let test_id = { + contents: 0 +}; + +let suites = { + contents: /* [] */0 +}; + +function test(x) { + if (x.NAME === 2) { + return { + NAME: 2, + VAL: x.VAL + }; + } else { + return { + NAME: 1, + VAL: x.VAL + }; + } +} + +Mt.eq_suites(test_id, suites, "File \"gpr_5218_test.res\", line 11, characters 29-36", test({ + NAME: 1, + VAL: 3 +}), { + NAME: 1, + VAL: 3 +}); + +Mt.eq_suites(test_id, suites, "File \"gpr_5218_test.res\", line 13, characters 29-36", test({ + NAME: 2, + VAL: 3 +}), { + NAME: 2, + VAL: 3 +}); + +Mt.from_pair_suites("gpr_5218_test.res", suites.contents); + +let eq_suites = Mt.eq_suites; + +export { + eq_suites, + test_id, + suites, + test, +} +/* Not a pure module */ diff --git a/tests/tests/src/gpr_5280_optimize_test.js b/tests/tests/src/gpr_5280_optimize_test.js deleted file mode 100644 index 47f58f76b4..0000000000 --- a/tests/tests/src/gpr_5280_optimize_test.js +++ /dev/null @@ -1,16 +0,0 @@ -// Generated by ReScript, PLEASE EDIT WITH CARE -'use strict'; - - -let a = { - TAG: "Color", - _0: "#ffff" -}; - -let c; - -c = typeof a !== "object" ? "orange" : "white"; - -exports.a = a; -exports.c = c; -/* c Not a pure module */ diff --git a/tests/tests/src/gpr_5280_optimize_test.mjs b/tests/tests/src/gpr_5280_optimize_test.mjs new file mode 100644 index 0000000000..d9b2adb7ef --- /dev/null +++ b/tests/tests/src/gpr_5280_optimize_test.mjs @@ -0,0 +1,17 @@ +// Generated by ReScript, PLEASE EDIT WITH CARE + + +let a = { + TAG: "Color", + _0: "#ffff" +}; + +let c; + +c = typeof a !== "object" ? "orange" : "white"; + +export { + a, + c, +} +/* c Not a pure module */ diff --git a/tests/tests/src/gpr_5557.js b/tests/tests/src/gpr_5557.js deleted file mode 100644 index 54715699d9..0000000000 --- a/tests/tests/src/gpr_5557.js +++ /dev/null @@ -1,24 +0,0 @@ -// Generated by ReScript, PLEASE EDIT WITH CARE -'use strict'; - - -function isA(c) { - if (c === 97) { - return true; - } - throw { - RE_EXN_ID: "Match_failure", - _1: [ - "gpr_5557.res", - 5, - 2 - ], - Error: new Error() - }; -} - -let h = /* 'a' */97; - -exports.isA = isA; -exports.h = h; -/* No side effect */ diff --git a/tests/tests/src/gpr_5557.mjs b/tests/tests/src/gpr_5557.mjs new file mode 100644 index 0000000000..9f2a08e9b2 --- /dev/null +++ b/tests/tests/src/gpr_5557.mjs @@ -0,0 +1,25 @@ +// Generated by ReScript, PLEASE EDIT WITH CARE + + +function isA(c) { + if (c === 97) { + return true; + } + throw { + RE_EXN_ID: "Match_failure", + _1: [ + "gpr_5557.res", + 5, + 2 + ], + Error: new Error() + }; +} + +let h = /* 'a' */97; + +export { + isA, + h, +} +/* No side effect */ diff --git a/tests/tests/src/gpr_5753.js b/tests/tests/src/gpr_5753.js deleted file mode 100644 index 1c02f17ab4..0000000000 --- a/tests/tests/src/gpr_5753.js +++ /dev/null @@ -1,7 +0,0 @@ -// Generated by ReScript, PLEASE EDIT WITH CARE -'use strict'; - - -console.log(/* '文' */25991); - -/* Not a pure module */ diff --git a/tests/tests/src/gpr_5753.mjs b/tests/tests/src/gpr_5753.mjs new file mode 100644 index 0000000000..fb7f666a90 --- /dev/null +++ b/tests/tests/src/gpr_5753.mjs @@ -0,0 +1,6 @@ +// Generated by ReScript, PLEASE EDIT WITH CARE + + +console.log(/* '文' */25991); + +/* Not a pure module */ diff --git a/tests/tests/src/gpr_658.js b/tests/tests/src/gpr_658.mjs similarity index 100% rename from tests/tests/src/gpr_658.js rename to tests/tests/src/gpr_658.mjs diff --git a/tests/tests/src/gpr_7012_test.js b/tests/tests/src/gpr_7012_test.js deleted file mode 100644 index e3e17b7d56..0000000000 --- a/tests/tests/src/gpr_7012_test.js +++ /dev/null @@ -1,21 +0,0 @@ -// Generated by ReScript, PLEASE EDIT WITH CARE -'use strict'; - - -function f1() { - return () => ({ - a: 1, - b: 2 - }); -} - -function f2() { - return { - a: 1, - b: 2 - }; -} - -exports.f1 = f1; -exports.f2 = f2; -/* No side effect */ diff --git a/tests/tests/src/gpr_7012_test.mjs b/tests/tests/src/gpr_7012_test.mjs new file mode 100644 index 0000000000..b907f7ca40 --- /dev/null +++ b/tests/tests/src/gpr_7012_test.mjs @@ -0,0 +1,22 @@ +// Generated by ReScript, PLEASE EDIT WITH CARE + + +function f1() { + return () => ({ + a: 1, + b: 2 + }); +} + +function f2() { + return { + a: 1, + b: 2 + }; +} + +export { + f1, + f2, +} +/* No side effect */ diff --git a/tests/tests/src/gpr_858_test.js b/tests/tests/src/gpr_858_test.js deleted file mode 100644 index 6d77cc2118..0000000000 --- a/tests/tests/src/gpr_858_test.js +++ /dev/null @@ -1,15 +0,0 @@ -// Generated by ReScript, PLEASE EDIT WITH CARE -'use strict'; - - -let direct = { - contents: /* [] */0 -}; - -let indirect = { - contents: /* [] */0 -}; - -exports.direct = direct; -exports.indirect = indirect; -/* No side effect */ diff --git a/tests/tests/src/gpr_858_test.mjs b/tests/tests/src/gpr_858_test.mjs new file mode 100644 index 0000000000..fb109c0ddb --- /dev/null +++ b/tests/tests/src/gpr_858_test.mjs @@ -0,0 +1,16 @@ +// Generated by ReScript, PLEASE EDIT WITH CARE + + +let direct = { + contents: /* [] */0 +}; + +let indirect = { + contents: /* [] */0 +}; + +export { + direct, + indirect, +} +/* No side effect */ diff --git a/tests/tests/src/gpr_858_unit2_test.js b/tests/tests/src/gpr_858_unit2_test.js deleted file mode 100644 index 4ca3b4244e..0000000000 --- a/tests/tests/src/gpr_858_unit2_test.js +++ /dev/null @@ -1,37 +0,0 @@ -// Generated by ReScript, PLEASE EDIT WITH CARE -'use strict'; - - -let delayed = { - contents: () => {} -}; - -for (let i = 1; i <= 2; ++i) { - let f = (n, x) => { - if (x !== 0) { - let prev = delayed.contents; - delayed.contents = () => { - prev(); - f(((n + 1 | 0) + i | 0) - i | 0, x - 1 | 0); - }; - return; - } - if (i === n) { - return; - } - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "gpr_858_unit2_test.res", - 6, - 13 - ], - Error: new Error() - }; - }; - f(0, i); -} - -delayed.contents(); - -/* Not a pure module */ diff --git a/tests/tests/src/gpr_858_unit2_test.mjs b/tests/tests/src/gpr_858_unit2_test.mjs new file mode 100644 index 0000000000..dddf174039 --- /dev/null +++ b/tests/tests/src/gpr_858_unit2_test.mjs @@ -0,0 +1,36 @@ +// Generated by ReScript, PLEASE EDIT WITH CARE + + +let delayed = { + contents: () => {} +}; + +for (let i = 1; i <= 2; ++i) { + let f = (n, x) => { + if (x !== 0) { + let prev = delayed.contents; + delayed.contents = () => { + prev(); + f(((n + 1 | 0) + i | 0) - i | 0, x - 1 | 0); + }; + return; + } + if (i === n) { + return; + } + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "gpr_858_unit2_test.res", + 6, + 13 + ], + Error: new Error() + }; + }; + f(0, i); +} + +delayed.contents(); + +/* Not a pure module */ diff --git a/tests/tests/src/gpr_904_test.js b/tests/tests/src/gpr_904_test.js deleted file mode 100644 index fab6f9fcb6..0000000000 --- a/tests/tests/src/gpr_904_test.js +++ /dev/null @@ -1,68 +0,0 @@ -// Generated by ReScript, PLEASE EDIT WITH CARE -'use strict'; - -let Mt = require("./mt.js"); - -let suites = { - contents: /* [] */0 -}; - -let test_id = { - contents: 0 -}; - -function eq(loc, x, y) { - test_id.contents = test_id.contents + 1 | 0; - suites.contents = { - hd: [ - loc + (" id " + test_id.contents.toString()), - () => ({ - TAG: "Eq", - _0: x, - _1: y - }) - ], - tl: suites.contents - }; -} - -function check_healty(check) { - if (!check.a && !check.b) { - return !check.c; - } else { - return false; - } -} - -function basic_not(x) { - return !x; -} - -function f(check) { - if (check.x) { - return check.y; - } else { - return false; - } -} - -eq("File \"gpr_904_test.res\", line 19, characters 12-19", f({ - x: true, - y: false -}), false); - -eq("File \"gpr_904_test.res\", line 21, characters 12-19", check_healty({ - a: false, - b: false, - c: true -}), false); - -Mt.from_pair_suites("Gpr_904_test", suites.contents); - -exports.suites = suites; -exports.test_id = test_id; -exports.eq = eq; -exports.check_healty = check_healty; -exports.basic_not = basic_not; -exports.f = f; -/* Not a pure module */ diff --git a/tests/tests/src/gpr_904_test.mjs b/tests/tests/src/gpr_904_test.mjs new file mode 100644 index 0000000000..56e3de6096 --- /dev/null +++ b/tests/tests/src/gpr_904_test.mjs @@ -0,0 +1,69 @@ +// Generated by ReScript, PLEASE EDIT WITH CARE + +import * as Mt from "./mt.mjs"; + +let suites = { + contents: /* [] */0 +}; + +let test_id = { + contents: 0 +}; + +function eq(loc, x, y) { + test_id.contents = test_id.contents + 1 | 0; + suites.contents = { + hd: [ + loc + (" id " + test_id.contents.toString()), + () => ({ + TAG: "Eq", + _0: x, + _1: y + }) + ], + tl: suites.contents + }; +} + +function check_healty(check) { + if (!check.a && !check.b) { + return !check.c; + } else { + return false; + } +} + +function basic_not(x) { + return !x; +} + +function f(check) { + if (check.x) { + return check.y; + } else { + return false; + } +} + +eq("File \"gpr_904_test.res\", line 19, characters 12-19", f({ + x: true, + y: false +}), false); + +eq("File \"gpr_904_test.res\", line 21, characters 12-19", check_healty({ + a: false, + b: false, + c: true +}), false); + +Mt.from_pair_suites("Gpr_904_test", suites.contents); + +export { + suites, + test_id, + eq, + check_healty, + basic_not, + f, +} +/* Not a pure module */ diff --git a/tests/tests/src/gpr_974_test.js b/tests/tests/src/gpr_974_test.js deleted file mode 100644 index 50246afe80..0000000000 --- a/tests/tests/src/gpr_974_test.js +++ /dev/null @@ -1,43 +0,0 @@ -// Generated by ReScript, PLEASE EDIT WITH CARE -'use strict'; - -let Primitive_object = require("rescript/lib/js/Primitive_object.js"); -let Primitive_option = require("rescript/lib/js/Primitive_option.js"); - -if (!Primitive_object.equal(Primitive_option.fromNullable(""), "")) { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "gpr_974_test.res", - 2, - 2 - ], - Error: new Error() - }; -} - -if (!Primitive_object.equal(Primitive_option.fromUndefined(""), "")) { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "gpr_974_test.res", - 3, - 2 - ], - Error: new Error() - }; -} - -if (!Primitive_object.equal(Primitive_option.fromNull(""), "")) { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "gpr_974_test.res", - 4, - 2 - ], - Error: new Error() - }; -} - -/* Not a pure module */ diff --git a/tests/tests/src/gpr_974_test.mjs b/tests/tests/src/gpr_974_test.mjs new file mode 100644 index 0000000000..b3db25c414 --- /dev/null +++ b/tests/tests/src/gpr_974_test.mjs @@ -0,0 +1,42 @@ +// Generated by ReScript, PLEASE EDIT WITH CARE + +import * as Primitive_object from "rescript/lib/es6/Primitive_object.js"; +import * as Primitive_option from "rescript/lib/es6/Primitive_option.js"; + +if (!Primitive_object.equal(Primitive_option.fromNullable(""), "")) { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "gpr_974_test.res", + 2, + 2 + ], + Error: new Error() + }; +} + +if (!Primitive_object.equal(Primitive_option.fromUndefined(""), "")) { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "gpr_974_test.res", + 3, + 2 + ], + Error: new Error() + }; +} + +if (!Primitive_object.equal(Primitive_option.fromNull(""), "")) { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "gpr_974_test.res", + 4, + 2 + ], + Error: new Error() + }; +} + +/* Not a pure module */ diff --git a/tests/tests/src/gpr_977_test.js b/tests/tests/src/gpr_977_test.js deleted file mode 100644 index dfbbb13700..0000000000 --- a/tests/tests/src/gpr_977_test.js +++ /dev/null @@ -1,50 +0,0 @@ -// Generated by ReScript, PLEASE EDIT WITH CARE -'use strict'; - -let Mt = require("./mt.js"); - -let suites = { - contents: /* [] */0 -}; - -let test_id = { - contents: 0 -}; - -function eq(loc, x, y) { - test_id.contents = test_id.contents + 1 | 0; - suites.contents = { - hd: [ - loc + (" id " + test_id.contents.toString()), - () => ({ - TAG: "Eq", - _0: x, - _1: y - }) - ], - tl: suites.contents - }; -} - -function f(x) { - for (let i = 0; i <= 100; ++i) { - console.log("."); - } - return -x | 0; -} - -let u = f(-2147483648); - -eq("File \"gpr_977_test.res\", line 23, characters 5-12", -2147483648, u); - -Mt.from_pair_suites("Gpr_977_test", suites.contents); - -let min_32_int = -2147483648; - -exports.suites = suites; -exports.test_id = test_id; -exports.eq = eq; -exports.f = f; -exports.min_32_int = min_32_int; -exports.u = u; -/* u Not a pure module */ diff --git a/tests/tests/src/gpr_977_test.mjs b/tests/tests/src/gpr_977_test.mjs new file mode 100644 index 0000000000..dcc92c8134 --- /dev/null +++ b/tests/tests/src/gpr_977_test.mjs @@ -0,0 +1,51 @@ +// Generated by ReScript, PLEASE EDIT WITH CARE + +import * as Mt from "./mt.mjs"; + +let suites = { + contents: /* [] */0 +}; + +let test_id = { + contents: 0 +}; + +function eq(loc, x, y) { + test_id.contents = test_id.contents + 1 | 0; + suites.contents = { + hd: [ + loc + (" id " + test_id.contents.toString()), + () => ({ + TAG: "Eq", + _0: x, + _1: y + }) + ], + tl: suites.contents + }; +} + +function f(x) { + for (let i = 0; i <= 100; ++i) { + console.log("."); + } + return -x | 0; +} + +let u = f(-2147483648); + +eq("File \"gpr_977_test.res\", line 23, characters 5-12", -2147483648, u); + +Mt.from_pair_suites("Gpr_977_test", suites.contents); + +let min_32_int = -2147483648; + +export { + suites, + test_id, + eq, + f, + min_32_int, + u, +} +/* u Not a pure module */ diff --git a/tests/tests/src/gpr_return_type_unused_attribute.js b/tests/tests/src/gpr_return_type_unused_attribute.js deleted file mode 100644 index 389cfde1b9..0000000000 --- a/tests/tests/src/gpr_return_type_unused_attribute.js +++ /dev/null @@ -1,8 +0,0 @@ -// Generated by ReScript, PLEASE EDIT WITH CARE -'use strict'; - - -let v = mk(2); - -exports.v = v; -/* v Not a pure module */ diff --git a/tests/tests/src/gpr_return_type_unused_attribute.mjs b/tests/tests/src/gpr_return_type_unused_attribute.mjs new file mode 100644 index 0000000000..b4933befa4 --- /dev/null +++ b/tests/tests/src/gpr_return_type_unused_attribute.mjs @@ -0,0 +1,9 @@ +// Generated by ReScript, PLEASE EDIT WITH CARE + + +let v = mk(2); + +export { + v, +} +/* v Not a pure module */ diff --git a/tests/tests/src/gray_code_test.js b/tests/tests/src/gray_code_test.js deleted file mode 100644 index a07c7bb844..0000000000 --- a/tests/tests/src/gray_code_test.js +++ /dev/null @@ -1,37 +0,0 @@ -// Generated by ReScript, PLEASE EDIT WITH CARE -'use strict'; - - -function gray_encode(b) { - return b ^ (b >>> 1); -} - -function gray_decode(n) { - let _p = n; - let _n = (n >>> 1); - while (true) { - let n$1 = _n; - let p = _p; - if (n$1 === 0) { - return p; - } - _n = (n$1 >>> 1); - _p = p ^ n$1; - continue; - }; -} - -function next_power(v) { - let v$1 = v - 1 | 0; - let v$2 = (v$1 >>> 1) | v$1; - let v$3 = (v$2 >>> 2) | v$2; - let v$4 = (v$3 >>> 4) | v$3; - let v$5 = (v$4 >>> 8) | v$4; - let v$6 = (v$5 >>> 16) | v$5; - return v$6 + 1 | 0; -} - -exports.gray_encode = gray_encode; -exports.gray_decode = gray_decode; -exports.next_power = next_power; -/* No side effect */ diff --git a/tests/tests/src/gray_code_test.mjs b/tests/tests/src/gray_code_test.mjs new file mode 100644 index 0000000000..209409e41f --- /dev/null +++ b/tests/tests/src/gray_code_test.mjs @@ -0,0 +1,38 @@ +// Generated by ReScript, PLEASE EDIT WITH CARE + + +function gray_encode(b) { + return b ^ (b >>> 1); +} + +function gray_decode(n) { + let _p = n; + let _n = (n >>> 1); + while (true) { + let n$1 = _n; + let p = _p; + if (n$1 === 0) { + return p; + } + _n = (n$1 >>> 1); + _p = p ^ n$1; + continue; + }; +} + +function next_power(v) { + let v$1 = v - 1 | 0; + let v$2 = (v$1 >>> 1) | v$1; + let v$3 = (v$2 >>> 2) | v$2; + let v$4 = (v$3 >>> 4) | v$3; + let v$5 = (v$4 >>> 8) | v$4; + let v$6 = (v$5 >>> 16) | v$5; + return v$6 + 1 | 0; +} + +export { + gray_encode, + gray_decode, + next_power, +} +/* No side effect */ diff --git a/tests/tests/src/guide_for_ext.js b/tests/tests/src/guide_for_ext.js deleted file mode 100644 index 54cb1abb17..0000000000 --- a/tests/tests/src/guide_for_ext.js +++ /dev/null @@ -1,13 +0,0 @@ -// Generated by ReScript, PLEASE EDIT WITH CARE -'use strict'; - - -function mk() { - return { - text: 32, - label: "hel" - }; -} - -exports.mk = mk; -/* No side effect */ diff --git a/tests/tests/src/guide_for_ext.mjs b/tests/tests/src/guide_for_ext.mjs new file mode 100644 index 0000000000..9ed99e2913 --- /dev/null +++ b/tests/tests/src/guide_for_ext.mjs @@ -0,0 +1,14 @@ +// Generated by ReScript, PLEASE EDIT WITH CARE + + +function mk() { + return { + text: 32, + label: "hel" + }; +} + +export { + mk, +} +/* No side effect */ diff --git a/tests/tests/src/hash_collision_test.js b/tests/tests/src/hash_collision_test.js deleted file mode 100644 index 4636497da7..0000000000 --- a/tests/tests/src/hash_collision_test.js +++ /dev/null @@ -1,61 +0,0 @@ -// Generated by ReScript, PLEASE EDIT WITH CARE -'use strict'; - -let Mt = require("./mt.js"); - -let suites = { - contents: /* [] */0 -}; - -let test_id = { - contents: 0 -}; - -function eq(loc, x, y) { - Mt.eq_suites(test_id, suites, loc, x, y); -} - -function f0(x) { - if (x === "azdwbie") { - return 1; - } else { - return 0; - } -} - -function f1(x) { - if (x.NAME === "azdwbie") { - return x.VAL + 2 | 0; - } else { - return x.VAL + 1 | 0; - } -} - -let hi = [ - "Eric_Cooper", - "azdwbie" -]; - -eq("File \"hash_collision_test.res\", line 20, characters 3-10", 0, 0); - -eq("File \"hash_collision_test.res\", line 21, characters 3-10", 1, 1); - -eq("File \"hash_collision_test.res\", line 23, characters 3-10", f1({ - NAME: "Eric_Cooper", - VAL: -1 -}), 0); - -eq("File \"hash_collision_test.res\", line 25, characters 3-10", f1({ - NAME: "azdwbie", - VAL: -2 -}), 0); - -Mt.from_pair_suites("hash_collision_test.res", suites.contents); - -exports.suites = suites; -exports.test_id = test_id; -exports.eq = eq; -exports.f0 = f0; -exports.f1 = f1; -exports.hi = hi; -/* Not a pure module */ diff --git a/tests/tests/src/hash_collision_test.mjs b/tests/tests/src/hash_collision_test.mjs new file mode 100644 index 0000000000..2927bab38b --- /dev/null +++ b/tests/tests/src/hash_collision_test.mjs @@ -0,0 +1,62 @@ +// Generated by ReScript, PLEASE EDIT WITH CARE + +import * as Mt from "./mt.mjs"; + +let suites = { + contents: /* [] */0 +}; + +let test_id = { + contents: 0 +}; + +function eq(loc, x, y) { + Mt.eq_suites(test_id, suites, loc, x, y); +} + +function f0(x) { + if (x === "azdwbie") { + return 1; + } else { + return 0; + } +} + +function f1(x) { + if (x.NAME === "azdwbie") { + return x.VAL + 2 | 0; + } else { + return x.VAL + 1 | 0; + } +} + +let hi = [ + "Eric_Cooper", + "azdwbie" +]; + +eq("File \"hash_collision_test.res\", line 20, characters 3-10", 0, 0); + +eq("File \"hash_collision_test.res\", line 21, characters 3-10", 1, 1); + +eq("File \"hash_collision_test.res\", line 23, characters 3-10", f1({ + NAME: "Eric_Cooper", + VAL: -1 +}), 0); + +eq("File \"hash_collision_test.res\", line 25, characters 3-10", f1({ + NAME: "azdwbie", + VAL: -2 +}), 0); + +Mt.from_pair_suites("hash_collision_test.res", suites.contents); + +export { + suites, + test_id, + eq, + f0, + f1, + hi, +} +/* Not a pure module */ diff --git a/tests/tests/src/hash_sugar_desugar.js b/tests/tests/src/hash_sugar_desugar.js deleted file mode 100644 index 32667634e3..0000000000 --- a/tests/tests/src/hash_sugar_desugar.js +++ /dev/null @@ -1,47 +0,0 @@ -// Generated by ReScript, PLEASE EDIT WITH CARE -'use strict'; - - -function h1(u) { - return u.p; -} - -function h3(u) { - let f = u.hi; - return f(1, 2); -} - -function g5(u) { - u.hi = 3; -} - -function h5(u) { - u.hi = 3; -} - -function h6(u) { - return u.p; -} - -function h7(u) { - return u.m(1, 2); -} - -function h8(u) { - let f = u.hi; - return f(1, 2); -} - -function chain_g(h) { - return h.x.y.z; -} - -exports.h1 = h1; -exports.h3 = h3; -exports.g5 = g5; -exports.h5 = h5; -exports.h6 = h6; -exports.h7 = h7; -exports.h8 = h8; -exports.chain_g = chain_g; -/* No side effect */ diff --git a/tests/tests/src/hash_sugar_desugar.mjs b/tests/tests/src/hash_sugar_desugar.mjs new file mode 100644 index 0000000000..0dc563de05 --- /dev/null +++ b/tests/tests/src/hash_sugar_desugar.mjs @@ -0,0 +1,48 @@ +// Generated by ReScript, PLEASE EDIT WITH CARE + + +function h1(u) { + return u.p; +} + +function h3(u) { + let f = u.hi; + return f(1, 2); +} + +function g5(u) { + u.hi = 3; +} + +function h5(u) { + u.hi = 3; +} + +function h6(u) { + return u.p; +} + +function h7(u) { + return u.m(1, 2); +} + +function h8(u) { + let f = u.hi; + return f(1, 2); +} + +function chain_g(h) { + return h.x.y.z; +} + +export { + h1, + h3, + g5, + h5, + h6, + h7, + h8, + chain_g, +} +/* No side effect */ diff --git a/tests/tests/src/hash_test.js b/tests/tests/src/hash_test.js deleted file mode 100644 index d0573d3860..0000000000 --- a/tests/tests/src/hash_test.js +++ /dev/null @@ -1,86 +0,0 @@ -// Generated by ReScript, PLEASE EDIT WITH CARE -'use strict'; - -let Mt = require("./mt.js"); -let Mt_global = require("./mt_global.js"); -let Belt_Array = require("rescript/lib/js/Belt_Array.js"); -let Ocaml_Hashtbl = require("./ocaml_compat/Ocaml_Hashtbl.js"); - -let suites = { - contents: /* [] */0 -}; - -let test_id = { - contents: 0 -}; - -function eq(f, x, y) { - Mt_global.collect_eq(test_id, suites, f, x, y); -} - -let test_strings = Belt_Array.init(32, i => String.fromCodePoint(i).repeat(i)); - -let test_strings_hash_results = [ - 0, - 904391063, - 889600889, - 929588010, - 596566298, - 365199070, - 448044845, - 311625091, - 681445541, - 634941451, - 82108334, - 17482990, - 491949228, - 696194769, - 711728152, - 594966620, - 820561748, - 958901713, - 102794744, - 378848504, - 349314368, - 114167579, - 71240932, - 110067399, - 280623927, - 323523937, - 310683234, - 178511779, - 585018975, - 544388424, - 1043872806, - 831138595 -]; - -function normalize(x) { - return x & 1073741823; -} - -function caml_hash(x) { - return Ocaml_Hashtbl.hash(x) & 1073741823; -} - -eq("File \"hash_test.res\", line 48, characters 12-19", Belt_Array.map(test_strings, caml_hash), test_strings_hash_results); - -eq("File \"hash_test.res\", line 50, characters 12-19", Ocaml_Hashtbl.hash(0) & 1073741823, 129913994); - -eq("File \"hash_test.res\", line 52, characters 12-19", Ocaml_Hashtbl.hash("x") & 1073741823, 780510073); - -eq("File \"hash_test.res\", line 54, characters 12-19", Ocaml_Hashtbl.hash("xy") & 1073741823, 194127723); - -Mt.from_pair_suites("Hash_test", suites.contents); - -let Hashtbl; - -exports.Hashtbl = Hashtbl; -exports.suites = suites; -exports.test_id = test_id; -exports.eq = eq; -exports.test_strings = test_strings; -exports.test_strings_hash_results = test_strings_hash_results; -exports.normalize = normalize; -exports.caml_hash = caml_hash; -/* test_strings Not a pure module */ diff --git a/tests/tests/src/hash_test.mjs b/tests/tests/src/hash_test.mjs new file mode 100644 index 0000000000..444e03b020 --- /dev/null +++ b/tests/tests/src/hash_test.mjs @@ -0,0 +1,87 @@ +// Generated by ReScript, PLEASE EDIT WITH CARE + +import * as Mt from "./mt.mjs"; +import * as Mt_global from "./mt_global.mjs"; +import * as Belt_Array from "rescript/lib/es6/Belt_Array.js"; +import * as Ocaml_Hashtbl from "./ocaml_compat/Ocaml_Hashtbl.mjs"; + +let suites = { + contents: /* [] */0 +}; + +let test_id = { + contents: 0 +}; + +function eq(f, x, y) { + Mt_global.collect_eq(test_id, suites, f, x, y); +} + +let test_strings = Belt_Array.init(32, i => String.fromCodePoint(i).repeat(i)); + +let test_strings_hash_results = [ + 0, + 904391063, + 889600889, + 929588010, + 596566298, + 365199070, + 448044845, + 311625091, + 681445541, + 634941451, + 82108334, + 17482990, + 491949228, + 696194769, + 711728152, + 594966620, + 820561748, + 958901713, + 102794744, + 378848504, + 349314368, + 114167579, + 71240932, + 110067399, + 280623927, + 323523937, + 310683234, + 178511779, + 585018975, + 544388424, + 1043872806, + 831138595 +]; + +function normalize(x) { + return x & 1073741823; +} + +function caml_hash(x) { + return Ocaml_Hashtbl.hash(x) & 1073741823; +} + +eq("File \"hash_test.res\", line 48, characters 12-19", Belt_Array.map(test_strings, caml_hash), test_strings_hash_results); + +eq("File \"hash_test.res\", line 50, characters 12-19", Ocaml_Hashtbl.hash(0) & 1073741823, 129913994); + +eq("File \"hash_test.res\", line 52, characters 12-19", Ocaml_Hashtbl.hash("x") & 1073741823, 780510073); + +eq("File \"hash_test.res\", line 54, characters 12-19", Ocaml_Hashtbl.hash("xy") & 1073741823, 194127723); + +Mt.from_pair_suites("Hash_test", suites.contents); + +let Hashtbl; + +export { + Hashtbl, + suites, + test_id, + eq, + test_strings, + test_strings_hash_results, + normalize, + caml_hash, +} +/* test_strings Not a pure module */ diff --git a/tests/tests/src/hello.foo.js b/tests/tests/src/hello.foo.js deleted file mode 100644 index a9caeea8a9..0000000000 --- a/tests/tests/src/hello.foo.js +++ /dev/null @@ -1,7 +0,0 @@ -// Generated by ReScript, PLEASE EDIT WITH CARE -'use strict'; - - -console.log("Hello"); - -/* Not a pure module */ diff --git a/tests/tests/src/hello.foo.mjs b/tests/tests/src/hello.foo.mjs new file mode 100644 index 0000000000..51c799ff51 --- /dev/null +++ b/tests/tests/src/hello.foo.mjs @@ -0,0 +1,6 @@ +// Generated by ReScript, PLEASE EDIT WITH CARE + + +console.log("Hello"); + +/* Not a pure module */ diff --git a/tests/tests/src/hello_res.js b/tests/tests/src/hello_res.js deleted file mode 100644 index 616a1593cb..0000000000 --- a/tests/tests/src/hello_res.js +++ /dev/null @@ -1,46 +0,0 @@ -// Generated by ReScript, PLEASE EDIT WITH CARE -'use strict'; - -let Belt_List = require("rescript/lib/js/Belt_List.js"); - -let b = Belt_List.length({ - hd: 1, - tl: { - hd: 2, - tl: { - hd: 3, - tl: /* [] */0 - } - } -}); - -let a = b - 1 | 0; - -console.log("hello, res"); - -Belt_List.add(/* [] */0, Belt_List.length({ - hd: 1, - tl: { - hd: 2, - tl: { - hd: 3, - tl: /* [] */0 - } - } -})); - -console.log(3); - -console.log([ - 3, - 1 -]); - -let to = 3; - -let downto = 1; - -exports.a = a; -exports.to = to; -exports.downto = downto; -/* b Not a pure module */ diff --git a/tests/tests/src/hello_res.mjs b/tests/tests/src/hello_res.mjs new file mode 100644 index 0000000000..a06084d525 --- /dev/null +++ b/tests/tests/src/hello_res.mjs @@ -0,0 +1,47 @@ +// Generated by ReScript, PLEASE EDIT WITH CARE + +import * as Belt_List from "rescript/lib/es6/Belt_List.js"; + +let b = Belt_List.length({ + hd: 1, + tl: { + hd: 2, + tl: { + hd: 3, + tl: /* [] */0 + } + } +}); + +let a = b - 1 | 0; + +console.log("hello, res"); + +Belt_List.add(/* [] */0, Belt_List.length({ + hd: 1, + tl: { + hd: 2, + tl: { + hd: 3, + tl: /* [] */0 + } + } +})); + +console.log(3); + +console.log([ + 3, + 1 +]); + +let to = 3; + +let downto = 1; + +export { + a, + to, + downto, +} +/* b Not a pure module */ diff --git a/tests/tests/src/ignore_test.js b/tests/tests/src/ignore_test.js deleted file mode 100644 index 26b2a6a3d9..0000000000 --- a/tests/tests/src/ignore_test.js +++ /dev/null @@ -1,46 +0,0 @@ -// Generated by ReScript, PLEASE EDIT WITH CARE -'use strict'; - -let Mt = require("./mt.js"); - -let suites = { - contents: /* [] */0 -}; - -let test_id = { - contents: 0 -}; - -function eq(loc, x, y) { - test_id.contents = test_id.contents + 1 | 0; - suites.contents = { - hd: [ - loc + (" id " + test_id.contents.toString()), - () => ({ - TAG: "Eq", - _0: x, - _1: y - }) - ], - tl: suites.contents - }; -} - -function f(x) { - -} - -function ff(x) { - console.log(x); -} - -eq("File \"ignore_test.res\", line 16, characters 12-19", undefined, undefined); - -Mt.from_pair_suites("Ignore_test", suites.contents); - -exports.suites = suites; -exports.test_id = test_id; -exports.eq = eq; -exports.f = f; -exports.ff = ff; -/* Not a pure module */ diff --git a/tests/tests/src/ignore_test.mjs b/tests/tests/src/ignore_test.mjs new file mode 100644 index 0000000000..af644d5d38 --- /dev/null +++ b/tests/tests/src/ignore_test.mjs @@ -0,0 +1,47 @@ +// Generated by ReScript, PLEASE EDIT WITH CARE + +import * as Mt from "./mt.mjs"; + +let suites = { + contents: /* [] */0 +}; + +let test_id = { + contents: 0 +}; + +function eq(loc, x, y) { + test_id.contents = test_id.contents + 1 | 0; + suites.contents = { + hd: [ + loc + (" id " + test_id.contents.toString()), + () => ({ + TAG: "Eq", + _0: x, + _1: y + }) + ], + tl: suites.contents + }; +} + +function f(x) { + +} + +function ff(x) { + console.log(x); +} + +eq("File \"ignore_test.res\", line 16, characters 12-19", undefined, undefined); + +Mt.from_pair_suites("Ignore_test", suites.contents); + +export { + suites, + test_id, + eq, + f, + ff, +} +/* Not a pure module */ diff --git a/tests/tests/src/ignore_uncurry_attribute.js b/tests/tests/src/ignore_uncurry_attribute.js deleted file mode 100644 index 6ca125db40..0000000000 --- a/tests/tests/src/ignore_uncurry_attribute.js +++ /dev/null @@ -1,15 +0,0 @@ -// Generated by ReScript, PLEASE EDIT WITH CARE -'use strict'; - - -function map1(prim0, prim1) { - return map(prim0, prim1); -} - -function map2(prim0, prim1) { - return map(prim0, prim1); -} - -exports.map1 = map1; -exports.map2 = map2; -/* No side effect */ diff --git a/tests/tests/src/ignore_uncurry_attribute.mjs b/tests/tests/src/ignore_uncurry_attribute.mjs new file mode 100644 index 0000000000..2aeae25082 --- /dev/null +++ b/tests/tests/src/ignore_uncurry_attribute.mjs @@ -0,0 +1,16 @@ +// Generated by ReScript, PLEASE EDIT WITH CARE + + +function map1(prim0, prim1) { + return map(prim0, prim1); +} + +function map2(prim0, prim1) { + return map(prim0, prim1); +} + +export { + map1, + map2, +} +/* No side effect */ diff --git a/tests/tests/src/import2.js b/tests/tests/src/import2.js deleted file mode 100644 index 3f5a1f3bb1..0000000000 --- a/tests/tests/src/import2.js +++ /dev/null @@ -1,12 +0,0 @@ -// Generated by ReScript, PLEASE EDIT WITH CARE -'use strict'; - -let A = require("a").default; - -let a = import("a").then(m => m.default); - -let b = A; - -exports.a = a; -exports.b = b; -/* a Not a pure module */ diff --git a/tests/tests/src/import2.mjs b/tests/tests/src/import2.mjs new file mode 100644 index 0000000000..6979d3dd4d --- /dev/null +++ b/tests/tests/src/import2.mjs @@ -0,0 +1,13 @@ +// Generated by ReScript, PLEASE EDIT WITH CARE + +import A from "a"; + +let a = import("a").then(m => m.default); + +let b = A; + +export { + a, + b, +} +/* a Not a pure module */ diff --git a/tests/tests/src/import_external.js b/tests/tests/src/import_external.js deleted file mode 100644 index 177183ade1..0000000000 --- a/tests/tests/src/import_external.js +++ /dev/null @@ -1,11 +0,0 @@ -// Generated by ReScript, PLEASE EDIT WITH CARE -'use strict'; - - -let f8 = import("a").then(m => m.default); - -let f9 = import("b").then(m => m.default); - -exports.f8 = f8; -exports.f9 = f9; -/* f8 Not a pure module */ diff --git a/tests/tests/src/import_external.mjs b/tests/tests/src/import_external.mjs new file mode 100644 index 0000000000..21c60fd678 --- /dev/null +++ b/tests/tests/src/import_external.mjs @@ -0,0 +1,12 @@ +// Generated by ReScript, PLEASE EDIT WITH CARE + + +let f8 = import("a").then(m => m.default); + +let f9 = import("b").then(m => m.default); + +export { + f8, + f9, +} +/* f8 Not a pure module */ diff --git a/tests/tests/src/import_side_effect.js b/tests/tests/src/import_side_effect.js deleted file mode 100644 index afbe3337f7..0000000000 --- a/tests/tests/src/import_side_effect.js +++ /dev/null @@ -1,11 +0,0 @@ -// Generated by ReScript, PLEASE EDIT WITH CARE -'use strict'; - - -let a = import("./side_effect2.js").then(m => m.a); - -let M = await import("./side_effect.js"); - -exports.a = a; -exports.M = M; -/* M Not a pure module */ diff --git a/tests/tests/src/import_side_effect.mjs b/tests/tests/src/import_side_effect.mjs new file mode 100644 index 0000000000..64e2bbd213 --- /dev/null +++ b/tests/tests/src/import_side_effect.mjs @@ -0,0 +1,12 @@ +// Generated by ReScript, PLEASE EDIT WITH CARE + + +let a = import("./side_effect2.mjs").then(m => m.a); + +let M = await import("./side_effect.mjs"); + +export { + a, + M, +} +/* M Not a pure module */ diff --git a/tests/tests/src/import_side_effect_free.js b/tests/tests/src/import_side_effect_free.js deleted file mode 100644 index 4df30a1a43..0000000000 --- a/tests/tests/src/import_side_effect_free.js +++ /dev/null @@ -1,8 +0,0 @@ -// Generated by ReScript, PLEASE EDIT WITH CARE -'use strict'; - - -let a = await import("./side_effect_free.js").then(m => m.a); - -exports.a = a; -/* a Not a pure module */ diff --git a/tests/tests/src/import_side_effect_free.mjs b/tests/tests/src/import_side_effect_free.mjs new file mode 100644 index 0000000000..ebaa5983e8 --- /dev/null +++ b/tests/tests/src/import_side_effect_free.mjs @@ -0,0 +1,9 @@ +// Generated by ReScript, PLEASE EDIT WITH CARE + + +let a = await import("./side_effect_free.mjs").then(m => m.a); + +export { + a, +} +/* a Not a pure module */ diff --git a/tests/tests/src/include_side_effect.js b/tests/tests/src/include_side_effect.js deleted file mode 100644 index 63aed7ac46..0000000000 --- a/tests/tests/src/include_side_effect.js +++ /dev/null @@ -1,7 +0,0 @@ -// Generated by ReScript, PLEASE EDIT WITH CARE -'use strict'; - -let Side_effect = require("./side_effect.js"); - - -/* Side_effect Not a pure module */ diff --git a/tests/tests/src/include_side_effect.mjs b/tests/tests/src/include_side_effect.mjs new file mode 100644 index 0000000000..8dba94d007 --- /dev/null +++ b/tests/tests/src/include_side_effect.mjs @@ -0,0 +1,6 @@ +// Generated by ReScript, PLEASE EDIT WITH CARE + +import * as Side_effect from "./side_effect.mjs"; + + +/* Side_effect Not a pure module */ diff --git a/tests/tests/src/include_side_effect_free.js b/tests/tests/src/include_side_effect_free.mjs similarity index 100% rename from tests/tests/src/include_side_effect_free.js rename to tests/tests/src/include_side_effect_free.mjs diff --git a/tests/tests/src/incomplete_toplevel_test.js b/tests/tests/src/incomplete_toplevel_test.js deleted file mode 100644 index 0d65fa6c4d..0000000000 --- a/tests/tests/src/incomplete_toplevel_test.js +++ /dev/null @@ -1,26 +0,0 @@ -// Generated by ReScript, PLEASE EDIT WITH CARE -'use strict'; - - -function f() { - console.log("no inline"); - return [ - 1, - 2, - 3 - ]; -} - -let match = f(); - -let a = match[0]; - -let b = match[1]; - -let c = match[2]; - -exports.f = f; -exports.a = a; -exports.b = b; -exports.c = c; -/* match Not a pure module */ diff --git a/tests/tests/src/incomplete_toplevel_test.mjs b/tests/tests/src/incomplete_toplevel_test.mjs new file mode 100644 index 0000000000..50846e68e4 --- /dev/null +++ b/tests/tests/src/incomplete_toplevel_test.mjs @@ -0,0 +1,27 @@ +// Generated by ReScript, PLEASE EDIT WITH CARE + + +function f() { + console.log("no inline"); + return [ + 1, + 2, + 3 + ]; +} + +let match = f(); + +let a = match[0]; + +let b = match[1]; + +let c = match[2]; + +export { + f, + a, + b, + c, +} +/* match Not a pure module */ diff --git a/tests/tests/src/infer_type_test.js b/tests/tests/src/infer_type_test.js deleted file mode 100644 index 45b8ea9433..0000000000 --- a/tests/tests/src/infer_type_test.js +++ /dev/null @@ -1,30 +0,0 @@ -// Generated by ReScript, PLEASE EDIT WITH CARE -'use strict'; - - -let hh = { - hi: 30, - lo: 20 -}; - -let v = { - hi: 32, - lo: 3 -}; - -let vv = { - hi: 3, - lo: 3, - width: 3 -}; - -let u = v.hi; - -let uu = v.width; - -exports.hh = hh; -exports.v = v; -exports.vv = vv; -exports.u = u; -exports.uu = uu; -/* Not a pure module */ diff --git a/tests/tests/src/infer_type_test.mjs b/tests/tests/src/infer_type_test.mjs new file mode 100644 index 0000000000..e69d1d8079 --- /dev/null +++ b/tests/tests/src/infer_type_test.mjs @@ -0,0 +1,31 @@ +// Generated by ReScript, PLEASE EDIT WITH CARE + + +let hh = { + hi: 30, + lo: 20 +}; + +let v = { + hi: 32, + lo: 3 +}; + +let vv = { + hi: 3, + lo: 3, + width: 3 +}; + +let u = v.hi; + +let uu = v.width; + +export { + hh, + v, + vv, + u, + uu, +} +/* Not a pure module */ diff --git a/tests/tests/src/inline_condition_with_pattern_matching.js b/tests/tests/src/inline_condition_with_pattern_matching.js deleted file mode 100644 index 71d45b5669..0000000000 --- a/tests/tests/src/inline_condition_with_pattern_matching.js +++ /dev/null @@ -1,61 +0,0 @@ -// Generated by ReScript, PLEASE EDIT WITH CARE -'use strict'; - - -let person1 = { - TAG: "Teacher", - age: 12345 -}; - -let message; - -if (person1.TAG === "Teacher") { - message = "b"; -} else { - let tmp = 12345; - message = typeof tmp !== "object" || tmp.TAG === "Vacations" ? "a" : "b"; -} - -let Test1 = { - person1: person1, - message: message -}; - -let person2 = { - TAG: "Teacher", - name: "Jane", - age: 12345 -}; - -let message$1; - -if (person2.TAG === "Teacher") { - message$1 = "Hello Jane."; -} else { - let name = "Jane"; - let match = person2.reportCard; - if (match.passing) { - message$1 = "Congrats " + name + ", nice GPA of " + match.gpa.toString() + " you got there!"; - } else { - let exit = 0; - let tmp$1 = 12345; - if (typeof tmp$1 !== "object") { - message$1 = tmp$1 === "Sick" ? "How are you feeling?" : "Good luck next semester " + name + "!"; - } else { - exit = 1; - } - if (exit === 1) { - message$1 = person2.reportCard.gpa !== 0.0 ? "Good luck next semester " + name + "!" : "Come back in " + (12345)._0.toString() + " days!"; - } - - } -} - -let Test2 = { - person2: person2, - message: message$1 -}; - -exports.Test1 = Test1; -exports.Test2 = Test2; -/* message Not a pure module */ diff --git a/tests/tests/src/inline_condition_with_pattern_matching.mjs b/tests/tests/src/inline_condition_with_pattern_matching.mjs new file mode 100644 index 0000000000..d2fd37d192 --- /dev/null +++ b/tests/tests/src/inline_condition_with_pattern_matching.mjs @@ -0,0 +1,62 @@ +// Generated by ReScript, PLEASE EDIT WITH CARE + + +let person1 = { + TAG: "Teacher", + age: 12345 +}; + +let message; + +if (person1.TAG === "Teacher") { + message = "b"; +} else { + let tmp = 12345; + message = typeof tmp !== "object" || tmp.TAG === "Vacations" ? "a" : "b"; +} + +let Test1 = { + person1: person1, + message: message +}; + +let person2 = { + TAG: "Teacher", + name: "Jane", + age: 12345 +}; + +let message$1; + +if (person2.TAG === "Teacher") { + message$1 = "Hello Jane."; +} else { + let name = "Jane"; + let match = person2.reportCard; + if (match.passing) { + message$1 = "Congrats " + name + ", nice GPA of " + match.gpa.toString() + " you got there!"; + } else { + let exit = 0; + let tmp$1 = 12345; + if (typeof tmp$1 !== "object") { + message$1 = tmp$1 === "Sick" ? "How are you feeling?" : "Good luck next semester " + name + "!"; + } else { + exit = 1; + } + if (exit === 1) { + message$1 = person2.reportCard.gpa !== 0.0 ? "Good luck next semester " + name + "!" : "Come back in " + (12345)._0.toString() + " days!"; + } + + } +} + +let Test2 = { + person2: person2, + message: message$1 +}; + +export { + Test1, + Test2, +} +/* message Not a pure module */ diff --git a/tests/tests/src/inline_const.js b/tests/tests/src/inline_const.js deleted file mode 100644 index d5cd71d47f..0000000000 --- a/tests/tests/src/inline_const.js +++ /dev/null @@ -1,27 +0,0 @@ -// Generated by ReScript, PLEASE EDIT WITH CARE -'use strict'; - - -let N = {}; - -let hh = "hellohello"; - -console.log([ - 3e-6, - 3e-6 -]); - -let x = true; - -function N1(funarg) { - return {}; -} - -let h = "hello"; - -exports.x = x; -exports.N = N; -exports.N1 = N1; -exports.h = h; -exports.hh = hh; -/* Not a pure module */ diff --git a/tests/tests/src/inline_const.mjs b/tests/tests/src/inline_const.mjs new file mode 100644 index 0000000000..af9a3b3253 --- /dev/null +++ b/tests/tests/src/inline_const.mjs @@ -0,0 +1,28 @@ +// Generated by ReScript, PLEASE EDIT WITH CARE + + +let N = {}; + +let hh = "hellohello"; + +console.log([ + 3e-6, + 3e-6 +]); + +let x = true; + +function N1(funarg) { + return {}; +} + +let h = "hello"; + +export { + x, + N, + N1, + h, + hh, +} +/* Not a pure module */ diff --git a/tests/tests/src/inline_const_test.js b/tests/tests/src/inline_const_test.js deleted file mode 100644 index a04ff5fd8d..0000000000 --- a/tests/tests/src/inline_const_test.js +++ /dev/null @@ -1,67 +0,0 @@ -// Generated by ReScript, PLEASE EDIT WITH CARE -'use strict'; - -let Mt = require("./mt.js"); -let Inline_const = require("./inline_const.js"); - -let suites = { - contents: /* [] */0 -}; - -let test_id = { - contents: 0 -}; - -function eq(loc, x, y) { - Mt.eq_suites(test_id, suites, loc, x, y); -} - -let H = Inline_const.N1({}); - -let f = "hello"; - -let f1 = "a"; - -let f2 = "中文"; - -let f3 = "中文"; - -let f4 = "中文"; - -eq("File \"inline_const_test.res\", line 13, characters 5-12", f, "hello"); - -eq("File \"inline_const_test.res\", line 14, characters 5-12", f1, "a"); - -eq("File \"inline_const_test.res\", line 15, characters 5-12", f2, "中文"); - -eq("File \"inline_const_test.res\", line 16, characters 5-12", f3, "中文"); - -eq("File \"inline_const_test.res\", line 17, characters 5-12", f4, "中文"); - -eq("File \"inline_const_test.res\", line 18, characters 5-12", true, true); - -eq("File \"inline_const_test.res\", line 19, characters 5-12", 1, 1); - -eq("File \"inline_const_test.res\", line 20, characters 5-12", 3e-6, 0.000003); - -Mt.from_pair_suites("File \"inline_const_test.res\", line 23, characters 29-36", suites.contents); - -let f5 = true; - -let f6 = 1; - -let f7 = 3e-6; - -exports.suites = suites; -exports.test_id = test_id; -exports.eq = eq; -exports.H = H; -exports.f = f; -exports.f1 = f1; -exports.f2 = f2; -exports.f3 = f3; -exports.f4 = f4; -exports.f5 = f5; -exports.f6 = f6; -exports.f7 = f7; -/* H Not a pure module */ diff --git a/tests/tests/src/inline_const_test.mjs b/tests/tests/src/inline_const_test.mjs new file mode 100644 index 0000000000..e5b3e28417 --- /dev/null +++ b/tests/tests/src/inline_const_test.mjs @@ -0,0 +1,68 @@ +// Generated by ReScript, PLEASE EDIT WITH CARE + +import * as Mt from "./mt.mjs"; +import * as Inline_const from "./inline_const.mjs"; + +let suites = { + contents: /* [] */0 +}; + +let test_id = { + contents: 0 +}; + +function eq(loc, x, y) { + Mt.eq_suites(test_id, suites, loc, x, y); +} + +let H = Inline_const.N1({}); + +let f = "hello"; + +let f1 = "a"; + +let f2 = "中文"; + +let f3 = "中文"; + +let f4 = "中文"; + +eq("File \"inline_const_test.res\", line 13, characters 5-12", f, "hello"); + +eq("File \"inline_const_test.res\", line 14, characters 5-12", f1, "a"); + +eq("File \"inline_const_test.res\", line 15, characters 5-12", f2, "中文"); + +eq("File \"inline_const_test.res\", line 16, characters 5-12", f3, "中文"); + +eq("File \"inline_const_test.res\", line 17, characters 5-12", f4, "中文"); + +eq("File \"inline_const_test.res\", line 18, characters 5-12", true, true); + +eq("File \"inline_const_test.res\", line 19, characters 5-12", 1, 1); + +eq("File \"inline_const_test.res\", line 20, characters 5-12", 3e-6, 0.000003); + +Mt.from_pair_suites("File \"inline_const_test.res\", line 23, characters 29-36", suites.contents); + +let f5 = true; + +let f6 = 1; + +let f7 = 3e-6; + +export { + suites, + test_id, + eq, + H, + f, + f1, + f2, + f3, + f4, + f5, + f6, + f7, +} +/* H Not a pure module */ diff --git a/tests/tests/src/inline_edge_cases.js b/tests/tests/src/inline_edge_cases.js deleted file mode 100644 index 8631edf009..0000000000 --- a/tests/tests/src/inline_edge_cases.js +++ /dev/null @@ -1,51 +0,0 @@ -// Generated by ReScript, PLEASE EDIT WITH CARE -'use strict'; - - -function test3(_n) { - while (true) { - let n = _n; - if (n === 0) { - return (n + 5 | 0) + 4 | 0; - } - _n = n - 1 | 0; - continue; - }; -} - -function test2(_n) { - while (true) { - let n = _n; - if (n === 0) { - return test3(n) + 3 | 0; - } - _n = n - 1 | 0; - continue; - }; -} - -function test0(_n) { - while (true) { - let n = _n; - if (n === 0) { - let _n$1 = n; - while (true) { - let n$1 = _n$1; - if (n$1 === 0) { - return test2(n$1) + 2 | 0; - } - _n$1 = n$1 - 1 | 0; - continue; - }; - } - _n = n - 1 | 0; - continue; - }; -} - -let v = test0(10); - -test0(10) + 2 | 0; - -exports.v = v; -/* v Not a pure module */ diff --git a/tests/tests/src/inline_edge_cases.mjs b/tests/tests/src/inline_edge_cases.mjs new file mode 100644 index 0000000000..90fa047806 --- /dev/null +++ b/tests/tests/src/inline_edge_cases.mjs @@ -0,0 +1,52 @@ +// Generated by ReScript, PLEASE EDIT WITH CARE + + +function test3(_n) { + while (true) { + let n = _n; + if (n === 0) { + return (n + 5 | 0) + 4 | 0; + } + _n = n - 1 | 0; + continue; + }; +} + +function test2(_n) { + while (true) { + let n = _n; + if (n === 0) { + return test3(n) + 3 | 0; + } + _n = n - 1 | 0; + continue; + }; +} + +function test0(_n) { + while (true) { + let n = _n; + if (n === 0) { + let _n$1 = n; + while (true) { + let n$1 = _n$1; + if (n$1 === 0) { + return test2(n$1) + 2 | 0; + } + _n$1 = n$1 - 1 | 0; + continue; + }; + } + _n = n - 1 | 0; + continue; + }; +} + +let v = test0(10); + +test0(10) + 2 | 0; + +export { + v, +} +/* v Not a pure module */ diff --git a/tests/tests/src/inline_map2_test.js b/tests/tests/src/inline_map2_test.js deleted file mode 100644 index 3865139140..0000000000 --- a/tests/tests/src/inline_map2_test.js +++ /dev/null @@ -1,1966 +0,0 @@ -// Generated by ReScript, PLEASE EDIT WITH CARE -'use strict'; - -let Mt = require("./mt.js"); -let Belt_List = require("rescript/lib/js/Belt_List.js"); -let Pervasives = require("rescript/lib/js/Pervasives.js"); -let Primitive_int = require("rescript/lib/js/Primitive_int.js"); -let Primitive_option = require("rescript/lib/js/Primitive_option.js"); -let Primitive_string = require("rescript/lib/js/Primitive_string.js"); - -function Make(Ord) { - let height = x => { - if (typeof x !== "object") { - return 0; - } else { - return x._4; - } - }; - let create = (l, x, d, r) => { - let hl = height(l); - let hr = height(r); - return { - TAG: "Node", - _0: l, - _1: x, - _2: d, - _3: r, - _4: hl >= hr ? hl + 1 | 0 : hr + 1 | 0 - }; - }; - let singleton = (x, d) => ({ - TAG: "Node", - _0: "Empty", - _1: x, - _2: d, - _3: "Empty", - _4: 1 - }); - let bal = (l, x, d, r) => { - let hl; - hl = typeof l !== "object" ? 0 : l._4; - let hr; - hr = typeof r !== "object" ? 0 : r._4; - if (hl > (hr + 2 | 0)) { - if (typeof l !== "object") { - return Pervasives.invalid_arg("Map.bal"); - } - let lr = l._3; - let ld = l._2; - let lv = l._1; - let ll = l._0; - if (height(ll) >= height(lr)) { - return create(ll, lv, ld, create(lr, x, d, r)); - } else if (typeof lr !== "object") { - return Pervasives.invalid_arg("Map.bal"); - } else { - return create(create(ll, lv, ld, lr._0), lr._1, lr._2, create(lr._3, x, d, r)); - } - } - if (hr <= (hl + 2 | 0)) { - return { - TAG: "Node", - _0: l, - _1: x, - _2: d, - _3: r, - _4: hl >= hr ? hl + 1 | 0 : hr + 1 | 0 - }; - } - if (typeof r !== "object") { - return Pervasives.invalid_arg("Map.bal"); - } - let rr = r._3; - let rd = r._2; - let rv = r._1; - let rl = r._0; - if (height(rr) >= height(rl)) { - return create(create(l, x, d, rl), rv, rd, rr); - } else if (typeof rl !== "object") { - return Pervasives.invalid_arg("Map.bal"); - } else { - return create(create(l, x, d, rl._0), rl._1, rl._2, create(rl._3, rv, rd, rr)); - } - }; - let is_empty = x => { - if (typeof x !== "object") { - return true; - } else { - return false; - } - }; - let add = (x, data, x_) => { - if (typeof x_ !== "object") { - return { - TAG: "Node", - _0: "Empty", - _1: x, - _2: data, - _3: "Empty", - _4: 1 - }; - } - let r = x_._3; - let d = x_._2; - let v = x_._1; - let l = x_._0; - let c = Ord.compare(x, v); - if (c === 0) { - return { - TAG: "Node", - _0: l, - _1: x, - _2: data, - _3: r, - _4: x_._4 - }; - } else if (c < 0) { - return bal(add(x, data, l), v, d, r); - } else { - return bal(l, v, d, add(x, data, r)); - } - }; - let find = (x, _x_) => { - while (true) { - let x_ = _x_; - if (typeof x_ !== "object") { - throw { - RE_EXN_ID: "Not_found", - Error: new Error() - }; - } - let c = Ord.compare(x, x_._1); - if (c === 0) { - return x_._2; - } - _x_ = c < 0 ? x_._0 : x_._3; - continue; - }; - }; - let mem = (x, _x_) => { - while (true) { - let x_ = _x_; - if (typeof x_ !== "object") { - return false; - } - let c = Ord.compare(x, x_._1); - if (c === 0) { - return true; - } - _x_ = c < 0 ? x_._0 : x_._3; - continue; - }; - }; - let min_binding = _x => { - while (true) { - let x = _x; - if (typeof x !== "object") { - throw { - RE_EXN_ID: "Not_found", - Error: new Error() - }; - } - let l = x._0; - if (typeof l !== "object") { - return [ - x._1, - x._2 - ]; - } - _x = l; - continue; - }; - }; - let max_binding = _x => { - while (true) { - let x = _x; - if (typeof x !== "object") { - throw { - RE_EXN_ID: "Not_found", - Error: new Error() - }; - } - let r = x._3; - if (typeof r !== "object") { - return [ - x._1, - x._2 - ]; - } - _x = r; - continue; - }; - }; - let remove_min_binding = x => { - if (typeof x !== "object") { - return Pervasives.invalid_arg("Map.remove_min_elt"); - } - let l = x._0; - if (typeof l !== "object") { - return x._3; - } else { - return bal(remove_min_binding(l), x._1, x._2, x._3); - } - }; - let remove = (x, x_) => { - if (typeof x_ !== "object") { - return "Empty"; - } - let r = x_._3; - let d = x_._2; - let v = x_._1; - let l = x_._0; - let c = Ord.compare(x, v); - if (c === 0) { - if (typeof l !== "object") { - return r; - } - if (typeof r !== "object") { - return l; - } - let match = min_binding(r); - return bal(l, match[0], match[1], remove_min_binding(r)); - } else if (c < 0) { - return bal(remove(x, l), v, d, r); - } else { - return bal(l, v, d, remove(x, r)); - } - }; - let iter = (f, _x) => { - while (true) { - let x = _x; - if (typeof x !== "object") { - return; - } - iter(f, x._0); - f(x._1, x._2); - _x = x._3; - continue; - }; - }; - let map = (f, x) => { - if (typeof x !== "object") { - return "Empty"; - } - let l$p = map(f, x._0); - let d$p = f(x._2); - let r$p = map(f, x._3); - return { - TAG: "Node", - _0: l$p, - _1: x._1, - _2: d$p, - _3: r$p, - _4: x._4 - }; - }; - let mapi = (f, x) => { - if (typeof x !== "object") { - return "Empty"; - } - let v = x._1; - let l$p = mapi(f, x._0); - let d$p = f(v, x._2); - let r$p = mapi(f, x._3); - return { - TAG: "Node", - _0: l$p, - _1: v, - _2: d$p, - _3: r$p, - _4: x._4 - }; - }; - let fold = (f, _m, _accu) => { - while (true) { - let accu = _accu; - let m = _m; - if (typeof m !== "object") { - return accu; - } - _accu = f(m._1, m._2, fold(f, m._0, accu)); - _m = m._3; - continue; - }; - }; - let for_all = (p, _x) => { - while (true) { - let x = _x; - if (typeof x !== "object") { - return true; - } - if (!p(x._1, x._2)) { - return false; - } - if (!for_all(p, x._0)) { - return false; - } - _x = x._3; - continue; - }; - }; - let exists = (p, _x) => { - while (true) { - let x = _x; - if (typeof x !== "object") { - return false; - } - if (p(x._1, x._2)) { - return true; - } - if (exists(p, x._0)) { - return true; - } - _x = x._3; - continue; - }; - }; - let add_min_binding = (k, v, x) => { - if (typeof x !== "object") { - return singleton(k, v); - } else { - return bal(add_min_binding(k, v, x._0), x._1, x._2, x._3); - } - }; - let add_max_binding = (k, v, x) => { - if (typeof x !== "object") { - return singleton(k, v); - } else { - return bal(x._0, x._1, x._2, add_max_binding(k, v, x._3)); - } - }; - let join = (l, v, d, r) => { - if (typeof l !== "object") { - return add_min_binding(v, d, r); - } - let lh = l._4; - if (typeof r !== "object") { - return add_max_binding(v, d, l); - } - let rh = r._4; - if (lh > (rh + 2 | 0)) { - return bal(l._0, l._1, l._2, join(l._3, v, d, r)); - } else if (rh > (lh + 2 | 0)) { - return bal(join(l, v, d, r._0), r._1, r._2, r._3); - } else { - return create(l, v, d, r); - } - }; - let concat = (t1, t2) => { - if (typeof t1 !== "object") { - return t2; - } - if (typeof t2 !== "object") { - return t1; - } - let match = min_binding(t2); - return join(t1, match[0], match[1], remove_min_binding(t2)); - }; - let concat_or_join = (t1, v, d, t2) => { - if (d !== undefined) { - return join(t1, v, Primitive_option.valFromOption(d), t2); - } else { - return concat(t1, t2); - } - }; - let split = (x, x_) => { - if (typeof x_ !== "object") { - return [ - "Empty", - undefined, - "Empty" - ]; - } - let r = x_._3; - let d = x_._2; - let v = x_._1; - let l = x_._0; - let c = Ord.compare(x, v); - if (c === 0) { - return [ - l, - Primitive_option.some(d), - r - ]; - } - if (c < 0) { - let match = split(x, l); - return [ - match[0], - match[1], - join(match[2], v, d, r) - ]; - } - let match$1 = split(x, r); - return [ - join(l, v, d, match$1[0]), - match$1[1], - match$1[2] - ]; - }; - let merge = (f, s1, s2) => { - if (typeof s1 !== "object") { - if (typeof s2 !== "object") { - return "Empty"; - } - - } else { - let v1 = s1._1; - if (s1._4 >= height(s2)) { - let match = split(v1, s2); - return concat_or_join(merge(f, s1._0, match[0]), v1, f(v1, Primitive_option.some(s1._2), match[1]), merge(f, s1._3, match[2])); - } - - } - if (typeof s2 !== "object") { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "inline_map2_test.res", - 359, - 11 - ], - Error: new Error() - }; - } - let v2 = s2._1; - let match$1 = split(v2, s1); - return concat_or_join(merge(f, match$1[0], s2._0), v2, f(v2, match$1[1], Primitive_option.some(s2._2)), merge(f, match$1[2], s2._3)); - }; - let filter = (p, x) => { - if (typeof x !== "object") { - return "Empty"; - } - let d = x._2; - let v = x._1; - let l$p = filter(p, x._0); - let pvd = p(v, d); - let r$p = filter(p, x._3); - if (pvd) { - return join(l$p, v, d, r$p); - } else { - return concat(l$p, r$p); - } - }; - let partition = (p, x) => { - if (typeof x !== "object") { - return [ - "Empty", - "Empty" - ]; - } - let d = x._2; - let v = x._1; - let match = partition(p, x._0); - let lf = match[1]; - let lt = match[0]; - let pvd = p(v, d); - let match$1 = partition(p, x._3); - let rf = match$1[1]; - let rt = match$1[0]; - if (pvd) { - return [ - join(lt, v, d, rt), - concat(lf, rf) - ]; - } else { - return [ - concat(lt, rt), - join(lf, v, d, rf) - ]; - } - }; - let cons_enum = (_m, _e) => { - while (true) { - let e = _e; - let m = _m; - if (typeof m !== "object") { - return e; - } - _e = { - TAG: "More", - _0: m._1, - _1: m._2, - _2: m._3, - _3: e - }; - _m = m._0; - continue; - }; - }; - let compare = (cmp, m1, m2) => { - let _e1 = cons_enum(m1, "End"); - let _e2 = cons_enum(m2, "End"); - while (true) { - let e2 = _e2; - let e1 = _e1; - if (typeof e1 !== "object") { - if (typeof e2 !== "object") { - return 0; - } else { - return -1; - } - } - if (typeof e2 !== "object") { - return 1; - } - let c = Ord.compare(e1._0, e2._0); - if (c !== 0) { - return c; - } - let c$1 = cmp(e1._1, e2._1); - if (c$1 !== 0) { - return c$1; - } - _e2 = cons_enum(e2._2, e2._3); - _e1 = cons_enum(e1._2, e1._3); - continue; - }; - }; - let equal = (cmp, m1, m2) => { - let _e1 = cons_enum(m1, "End"); - let _e2 = cons_enum(m2, "End"); - while (true) { - let e2 = _e2; - let e1 = _e1; - if (typeof e1 !== "object") { - if (typeof e2 !== "object") { - return true; - } else { - return false; - } - } - if (typeof e2 !== "object") { - return false; - } - if (Ord.compare(e1._0, e2._0) !== 0) { - return false; - } - if (!cmp(e1._1, e2._1)) { - return false; - } - _e2 = cons_enum(e2._2, e2._3); - _e1 = cons_enum(e1._2, e1._3); - continue; - }; - }; - let cardinal = x => { - if (typeof x !== "object") { - return 0; - } else { - return (cardinal(x._0) + 1 | 0) + cardinal(x._3) | 0; - } - }; - let bindings_aux = (_accu, _x) => { - while (true) { - let x = _x; - let accu = _accu; - if (typeof x !== "object") { - return accu; - } - _x = x._0; - _accu = { - hd: [ - x._1, - x._2 - ], - tl: bindings_aux(accu, x._3) - }; - continue; - }; - }; - let bindings = s => bindings_aux(/* [] */0, s); - return { - height: height, - create: create, - singleton: singleton, - bal: bal, - empty: "Empty", - is_empty: is_empty, - add: add, - find: find, - mem: mem, - min_binding: min_binding, - max_binding: max_binding, - remove_min_binding: remove_min_binding, - remove: remove, - iter: iter, - map: map, - mapi: mapi, - fold: fold, - for_all: for_all, - exists: exists, - add_min_binding: add_min_binding, - add_max_binding: add_max_binding, - join: join, - concat: concat, - concat_or_join: concat_or_join, - split: split, - merge: merge, - filter: filter, - partition: partition, - cons_enum: cons_enum, - compare: compare, - equal: equal, - cardinal: cardinal, - bindings_aux: bindings_aux, - bindings: bindings, - choose: min_binding - }; -} - -function height(x) { - if (typeof x !== "object") { - return 0; - } else { - return x._4; - } -} - -function create(l, x, d, r) { - let hl = height(l); - let hr = height(r); - return { - TAG: "Node", - _0: l, - _1: x, - _2: d, - _3: r, - _4: hl >= hr ? hl + 1 | 0 : hr + 1 | 0 - }; -} - -function singleton(x, d) { - return { - TAG: "Node", - _0: "Empty", - _1: x, - _2: d, - _3: "Empty", - _4: 1 - }; -} - -function bal(l, x, d, r) { - let hl; - hl = typeof l !== "object" ? 0 : l._4; - let hr; - hr = typeof r !== "object" ? 0 : r._4; - if (hl > (hr + 2 | 0)) { - if (typeof l !== "object") { - return Pervasives.invalid_arg("Map.bal"); - } - let lr = l._3; - let ld = l._2; - let lv = l._1; - let ll = l._0; - if (height(ll) >= height(lr)) { - return create(ll, lv, ld, create(lr, x, d, r)); - } else if (typeof lr !== "object") { - return Pervasives.invalid_arg("Map.bal"); - } else { - return create(create(ll, lv, ld, lr._0), lr._1, lr._2, create(lr._3, x, d, r)); - } - } - if (hr <= (hl + 2 | 0)) { - return { - TAG: "Node", - _0: l, - _1: x, - _2: d, - _3: r, - _4: hl >= hr ? hl + 1 | 0 : hr + 1 | 0 - }; - } - if (typeof r !== "object") { - return Pervasives.invalid_arg("Map.bal"); - } - let rr = r._3; - let rd = r._2; - let rv = r._1; - let rl = r._0; - if (height(rr) >= height(rl)) { - return create(create(l, x, d, rl), rv, rd, rr); - } else if (typeof rl !== "object") { - return Pervasives.invalid_arg("Map.bal"); - } else { - return create(create(l, x, d, rl._0), rl._1, rl._2, create(rl._3, rv, rd, rr)); - } -} - -function is_empty(x) { - if (typeof x !== "object") { - return true; - } else { - return false; - } -} - -function add(x, data, x_) { - if (typeof x_ !== "object") { - return { - TAG: "Node", - _0: "Empty", - _1: x, - _2: data, - _3: "Empty", - _4: 1 - }; - } - let r = x_._3; - let d = x_._2; - let v = x_._1; - let l = x_._0; - let c = Primitive_int.compare(x, v); - if (c === 0) { - return { - TAG: "Node", - _0: l, - _1: x, - _2: data, - _3: r, - _4: x_._4 - }; - } else if (c < 0) { - return bal(add(x, data, l), v, d, r); - } else { - return bal(l, v, d, add(x, data, r)); - } -} - -function find(x, _x_) { - while (true) { - let x_ = _x_; - if (typeof x_ !== "object") { - throw { - RE_EXN_ID: "Not_found", - Error: new Error() - }; - } - let c = Primitive_int.compare(x, x_._1); - if (c === 0) { - return x_._2; - } - _x_ = c < 0 ? x_._0 : x_._3; - continue; - }; -} - -function mem(x, _x_) { - while (true) { - let x_ = _x_; - if (typeof x_ !== "object") { - return false; - } - let c = Primitive_int.compare(x, x_._1); - if (c === 0) { - return true; - } - _x_ = c < 0 ? x_._0 : x_._3; - continue; - }; -} - -function min_binding(_x) { - while (true) { - let x = _x; - if (typeof x !== "object") { - throw { - RE_EXN_ID: "Not_found", - Error: new Error() - }; - } - let l = x._0; - if (typeof l !== "object") { - return [ - x._1, - x._2 - ]; - } - _x = l; - continue; - }; -} - -function max_binding(_x) { - while (true) { - let x = _x; - if (typeof x !== "object") { - throw { - RE_EXN_ID: "Not_found", - Error: new Error() - }; - } - let r = x._3; - if (typeof r !== "object") { - return [ - x._1, - x._2 - ]; - } - _x = r; - continue; - }; -} - -function remove_min_binding(x) { - if (typeof x !== "object") { - return Pervasives.invalid_arg("Map.remove_min_elt"); - } - let l = x._0; - if (typeof l !== "object") { - return x._3; - } else { - return bal(remove_min_binding(l), x._1, x._2, x._3); - } -} - -function remove(x, x_) { - if (typeof x_ !== "object") { - return "Empty"; - } - let r = x_._3; - let d = x_._2; - let v = x_._1; - let l = x_._0; - let c = Primitive_int.compare(x, v); - if (c === 0) { - if (typeof l !== "object") { - return r; - } - if (typeof r !== "object") { - return l; - } - let match = min_binding(r); - return bal(l, match[0], match[1], remove_min_binding(r)); - } else if (c < 0) { - return bal(remove(x, l), v, d, r); - } else { - return bal(l, v, d, remove(x, r)); - } -} - -function iter(f, _x) { - while (true) { - let x = _x; - if (typeof x !== "object") { - return; - } - iter(f, x._0); - f(x._1, x._2); - _x = x._3; - continue; - }; -} - -function map(f, x) { - if (typeof x !== "object") { - return "Empty"; - } - let l$p = map(f, x._0); - let d$p = f(x._2); - let r$p = map(f, x._3); - return { - TAG: "Node", - _0: l$p, - _1: x._1, - _2: d$p, - _3: r$p, - _4: x._4 - }; -} - -function mapi(f, x) { - if (typeof x !== "object") { - return "Empty"; - } - let v = x._1; - let l$p = mapi(f, x._0); - let d$p = f(v, x._2); - let r$p = mapi(f, x._3); - return { - TAG: "Node", - _0: l$p, - _1: v, - _2: d$p, - _3: r$p, - _4: x._4 - }; -} - -function fold(f, _m, _accu) { - while (true) { - let accu = _accu; - let m = _m; - if (typeof m !== "object") { - return accu; - } - _accu = f(m._1, m._2, fold(f, m._0, accu)); - _m = m._3; - continue; - }; -} - -function for_all(p, _x) { - while (true) { - let x = _x; - if (typeof x !== "object") { - return true; - } - if (!p(x._1, x._2)) { - return false; - } - if (!for_all(p, x._0)) { - return false; - } - _x = x._3; - continue; - }; -} - -function exists(p, _x) { - while (true) { - let x = _x; - if (typeof x !== "object") { - return false; - } - if (p(x._1, x._2)) { - return true; - } - if (exists(p, x._0)) { - return true; - } - _x = x._3; - continue; - }; -} - -function add_min_binding(k, v, x) { - if (typeof x !== "object") { - return singleton(k, v); - } else { - return bal(add_min_binding(k, v, x._0), x._1, x._2, x._3); - } -} - -function add_max_binding(k, v, x) { - if (typeof x !== "object") { - return singleton(k, v); - } else { - return bal(x._0, x._1, x._2, add_max_binding(k, v, x._3)); - } -} - -function join(l, v, d, r) { - if (typeof l !== "object") { - return add_min_binding(v, d, r); - } - let lh = l._4; - if (typeof r !== "object") { - return add_max_binding(v, d, l); - } - let rh = r._4; - if (lh > (rh + 2 | 0)) { - return bal(l._0, l._1, l._2, join(l._3, v, d, r)); - } else if (rh > (lh + 2 | 0)) { - return bal(join(l, v, d, r._0), r._1, r._2, r._3); - } else { - return create(l, v, d, r); - } -} - -function concat(t1, t2) { - if (typeof t1 !== "object") { - return t2; - } - if (typeof t2 !== "object") { - return t1; - } - let match = min_binding(t2); - return join(t1, match[0], match[1], remove_min_binding(t2)); -} - -function concat_or_join(t1, v, d, t2) { - if (d !== undefined) { - return join(t1, v, Primitive_option.valFromOption(d), t2); - } else { - return concat(t1, t2); - } -} - -function split(x, x_) { - if (typeof x_ !== "object") { - return [ - "Empty", - undefined, - "Empty" - ]; - } - let r = x_._3; - let d = x_._2; - let v = x_._1; - let l = x_._0; - let c = Primitive_int.compare(x, v); - if (c === 0) { - return [ - l, - Primitive_option.some(d), - r - ]; - } - if (c < 0) { - let match = split(x, l); - return [ - match[0], - match[1], - join(match[2], v, d, r) - ]; - } - let match$1 = split(x, r); - return [ - join(l, v, d, match$1[0]), - match$1[1], - match$1[2] - ]; -} - -function merge(f, s1, s2) { - if (typeof s1 !== "object") { - if (typeof s2 !== "object") { - return "Empty"; - } - - } else { - let v1 = s1._1; - if (s1._4 >= height(s2)) { - let match = split(v1, s2); - return concat_or_join(merge(f, s1._0, match[0]), v1, f(v1, Primitive_option.some(s1._2), match[1]), merge(f, s1._3, match[2])); - } - - } - if (typeof s2 !== "object") { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "inline_map2_test.res", - 359, - 11 - ], - Error: new Error() - }; - } - let v2 = s2._1; - let match$1 = split(v2, s1); - return concat_or_join(merge(f, match$1[0], s2._0), v2, f(v2, match$1[1], Primitive_option.some(s2._2)), merge(f, match$1[2], s2._3)); -} - -function filter(p, x) { - if (typeof x !== "object") { - return "Empty"; - } - let d = x._2; - let v = x._1; - let l$p = filter(p, x._0); - let pvd = p(v, d); - let r$p = filter(p, x._3); - if (pvd) { - return join(l$p, v, d, r$p); - } else { - return concat(l$p, r$p); - } -} - -function partition(p, x) { - if (typeof x !== "object") { - return [ - "Empty", - "Empty" - ]; - } - let d = x._2; - let v = x._1; - let match = partition(p, x._0); - let lf = match[1]; - let lt = match[0]; - let pvd = p(v, d); - let match$1 = partition(p, x._3); - let rf = match$1[1]; - let rt = match$1[0]; - if (pvd) { - return [ - join(lt, v, d, rt), - concat(lf, rf) - ]; - } else { - return [ - concat(lt, rt), - join(lf, v, d, rf) - ]; - } -} - -function cons_enum(_m, _e) { - while (true) { - let e = _e; - let m = _m; - if (typeof m !== "object") { - return e; - } - _e = { - TAG: "More", - _0: m._1, - _1: m._2, - _2: m._3, - _3: e - }; - _m = m._0; - continue; - }; -} - -function compare(cmp, m1, m2) { - let _e1 = cons_enum(m1, "End"); - let _e2 = cons_enum(m2, "End"); - while (true) { - let e2 = _e2; - let e1 = _e1; - if (typeof e1 !== "object") { - if (typeof e2 !== "object") { - return 0; - } else { - return -1; - } - } - if (typeof e2 !== "object") { - return 1; - } - let c = Primitive_int.compare(e1._0, e2._0); - if (c !== 0) { - return c; - } - let c$1 = cmp(e1._1, e2._1); - if (c$1 !== 0) { - return c$1; - } - _e2 = cons_enum(e2._2, e2._3); - _e1 = cons_enum(e1._2, e1._3); - continue; - }; -} - -function equal(cmp, m1, m2) { - let _e1 = cons_enum(m1, "End"); - let _e2 = cons_enum(m2, "End"); - while (true) { - let e2 = _e2; - let e1 = _e1; - if (typeof e1 !== "object") { - if (typeof e2 !== "object") { - return true; - } else { - return false; - } - } - if (typeof e2 !== "object") { - return false; - } - if (e1._0 !== e2._0) { - return false; - } - if (!cmp(e1._1, e2._1)) { - return false; - } - _e2 = cons_enum(e2._2, e2._3); - _e1 = cons_enum(e1._2, e1._3); - continue; - }; -} - -function cardinal(x) { - if (typeof x !== "object") { - return 0; - } else { - return (cardinal(x._0) + 1 | 0) + cardinal(x._3) | 0; - } -} - -function bindings_aux(_accu, _x) { - while (true) { - let x = _x; - let accu = _accu; - if (typeof x !== "object") { - return accu; - } - _x = x._0; - _accu = { - hd: [ - x._1, - x._2 - ], - tl: bindings_aux(accu, x._3) - }; - continue; - }; -} - -function bindings(s) { - return bindings_aux(/* [] */0, s); -} - -let IntMap = { - height: height, - create: create, - singleton: singleton, - bal: bal, - empty: "Empty", - is_empty: is_empty, - add: add, - find: find, - mem: mem, - min_binding: min_binding, - max_binding: max_binding, - remove_min_binding: remove_min_binding, - remove: remove, - iter: iter, - map: map, - mapi: mapi, - fold: fold, - for_all: for_all, - exists: exists, - add_min_binding: add_min_binding, - add_max_binding: add_max_binding, - join: join, - concat: concat, - concat_or_join: concat_or_join, - split: split, - merge: merge, - filter: filter, - partition: partition, - cons_enum: cons_enum, - compare: compare, - equal: equal, - cardinal: cardinal, - bindings_aux: bindings_aux, - bindings: bindings, - choose: min_binding -}; - -let m = Belt_List.reduceReverse({ - hd: [ - 10, - /* 'a' */97 - ], - tl: { - hd: [ - 3, - /* 'b' */98 - ], - tl: { - hd: [ - 7, - /* 'c' */99 - ], - tl: { - hd: [ - 20, - /* 'd' */100 - ], - tl: /* [] */0 - } - } - } -}, "Empty", (acc, param) => add(param[0], param[1], acc)); - -function height$1(x) { - if (typeof x !== "object") { - return 0; - } else { - return x._4; - } -} - -function create$1(l, x, d, r) { - let hl = height$1(l); - let hr = height$1(r); - return { - TAG: "Node", - _0: l, - _1: x, - _2: d, - _3: r, - _4: hl >= hr ? hl + 1 | 0 : hr + 1 | 0 - }; -} - -function singleton$1(x, d) { - return { - TAG: "Node", - _0: "Empty", - _1: x, - _2: d, - _3: "Empty", - _4: 1 - }; -} - -function bal$1(l, x, d, r) { - let hl; - hl = typeof l !== "object" ? 0 : l._4; - let hr; - hr = typeof r !== "object" ? 0 : r._4; - if (hl > (hr + 2 | 0)) { - if (typeof l !== "object") { - return Pervasives.invalid_arg("Map.bal"); - } - let lr = l._3; - let ld = l._2; - let lv = l._1; - let ll = l._0; - if (height$1(ll) >= height$1(lr)) { - return create$1(ll, lv, ld, create$1(lr, x, d, r)); - } else if (typeof lr !== "object") { - return Pervasives.invalid_arg("Map.bal"); - } else { - return create$1(create$1(ll, lv, ld, lr._0), lr._1, lr._2, create$1(lr._3, x, d, r)); - } - } - if (hr <= (hl + 2 | 0)) { - return { - TAG: "Node", - _0: l, - _1: x, - _2: d, - _3: r, - _4: hl >= hr ? hl + 1 | 0 : hr + 1 | 0 - }; - } - if (typeof r !== "object") { - return Pervasives.invalid_arg("Map.bal"); - } - let rr = r._3; - let rd = r._2; - let rv = r._1; - let rl = r._0; - if (height$1(rr) >= height$1(rl)) { - return create$1(create$1(l, x, d, rl), rv, rd, rr); - } else if (typeof rl !== "object") { - return Pervasives.invalid_arg("Map.bal"); - } else { - return create$1(create$1(l, x, d, rl._0), rl._1, rl._2, create$1(rl._3, rv, rd, rr)); - } -} - -function is_empty$1(x) { - if (typeof x !== "object") { - return true; - } else { - return false; - } -} - -function add$1(x, data, x_) { - if (typeof x_ !== "object") { - return { - TAG: "Node", - _0: "Empty", - _1: x, - _2: data, - _3: "Empty", - _4: 1 - }; - } - let r = x_._3; - let d = x_._2; - let v = x_._1; - let l = x_._0; - let c = Primitive_string.compare(x, v); - if (c === 0) { - return { - TAG: "Node", - _0: l, - _1: x, - _2: data, - _3: r, - _4: x_._4 - }; - } else if (c < 0) { - return bal$1(add$1(x, data, l), v, d, r); - } else { - return bal$1(l, v, d, add$1(x, data, r)); - } -} - -function find$1(x, _x_) { - while (true) { - let x_ = _x_; - if (typeof x_ !== "object") { - throw { - RE_EXN_ID: "Not_found", - Error: new Error() - }; - } - let c = Primitive_string.compare(x, x_._1); - if (c === 0) { - return x_._2; - } - _x_ = c < 0 ? x_._0 : x_._3; - continue; - }; -} - -function mem$1(x, _x_) { - while (true) { - let x_ = _x_; - if (typeof x_ !== "object") { - return false; - } - let c = Primitive_string.compare(x, x_._1); - if (c === 0) { - return true; - } - _x_ = c < 0 ? x_._0 : x_._3; - continue; - }; -} - -function min_binding$1(_x) { - while (true) { - let x = _x; - if (typeof x !== "object") { - throw { - RE_EXN_ID: "Not_found", - Error: new Error() - }; - } - let l = x._0; - if (typeof l !== "object") { - return [ - x._1, - x._2 - ]; - } - _x = l; - continue; - }; -} - -function max_binding$1(_x) { - while (true) { - let x = _x; - if (typeof x !== "object") { - throw { - RE_EXN_ID: "Not_found", - Error: new Error() - }; - } - let r = x._3; - if (typeof r !== "object") { - return [ - x._1, - x._2 - ]; - } - _x = r; - continue; - }; -} - -function remove_min_binding$1(x) { - if (typeof x !== "object") { - return Pervasives.invalid_arg("Map.remove_min_elt"); - } - let l = x._0; - if (typeof l !== "object") { - return x._3; - } else { - return bal$1(remove_min_binding$1(l), x._1, x._2, x._3); - } -} - -function remove$1(x, x_) { - if (typeof x_ !== "object") { - return "Empty"; - } - let r = x_._3; - let d = x_._2; - let v = x_._1; - let l = x_._0; - let c = Primitive_string.compare(x, v); - if (c === 0) { - if (typeof l !== "object") { - return r; - } - if (typeof r !== "object") { - return l; - } - let match = min_binding$1(r); - return bal$1(l, match[0], match[1], remove_min_binding$1(r)); - } else if (c < 0) { - return bal$1(remove$1(x, l), v, d, r); - } else { - return bal$1(l, v, d, remove$1(x, r)); - } -} - -function iter$1(f, _x) { - while (true) { - let x = _x; - if (typeof x !== "object") { - return; - } - iter$1(f, x._0); - f(x._1, x._2); - _x = x._3; - continue; - }; -} - -function map$1(f, x) { - if (typeof x !== "object") { - return "Empty"; - } - let l$p = map$1(f, x._0); - let d$p = f(x._2); - let r$p = map$1(f, x._3); - return { - TAG: "Node", - _0: l$p, - _1: x._1, - _2: d$p, - _3: r$p, - _4: x._4 - }; -} - -function mapi$1(f, x) { - if (typeof x !== "object") { - return "Empty"; - } - let v = x._1; - let l$p = mapi$1(f, x._0); - let d$p = f(v, x._2); - let r$p = mapi$1(f, x._3); - return { - TAG: "Node", - _0: l$p, - _1: v, - _2: d$p, - _3: r$p, - _4: x._4 - }; -} - -function fold$1(f, _m, _accu) { - while (true) { - let accu = _accu; - let m = _m; - if (typeof m !== "object") { - return accu; - } - _accu = f(m._1, m._2, fold$1(f, m._0, accu)); - _m = m._3; - continue; - }; -} - -function for_all$1(p, _x) { - while (true) { - let x = _x; - if (typeof x !== "object") { - return true; - } - if (!p(x._1, x._2)) { - return false; - } - if (!for_all$1(p, x._0)) { - return false; - } - _x = x._3; - continue; - }; -} - -function exists$1(p, _x) { - while (true) { - let x = _x; - if (typeof x !== "object") { - return false; - } - if (p(x._1, x._2)) { - return true; - } - if (exists$1(p, x._0)) { - return true; - } - _x = x._3; - continue; - }; -} - -function add_min_binding$1(k, v, x) { - if (typeof x !== "object") { - return singleton$1(k, v); - } else { - return bal$1(add_min_binding$1(k, v, x._0), x._1, x._2, x._3); - } -} - -function add_max_binding$1(k, v, x) { - if (typeof x !== "object") { - return singleton$1(k, v); - } else { - return bal$1(x._0, x._1, x._2, add_max_binding$1(k, v, x._3)); - } -} - -function join$1(l, v, d, r) { - if (typeof l !== "object") { - return add_min_binding$1(v, d, r); - } - let lh = l._4; - if (typeof r !== "object") { - return add_max_binding$1(v, d, l); - } - let rh = r._4; - if (lh > (rh + 2 | 0)) { - return bal$1(l._0, l._1, l._2, join$1(l._3, v, d, r)); - } else if (rh > (lh + 2 | 0)) { - return bal$1(join$1(l, v, d, r._0), r._1, r._2, r._3); - } else { - return create$1(l, v, d, r); - } -} - -function concat$1(t1, t2) { - if (typeof t1 !== "object") { - return t2; - } - if (typeof t2 !== "object") { - return t1; - } - let match = min_binding$1(t2); - return join$1(t1, match[0], match[1], remove_min_binding$1(t2)); -} - -function concat_or_join$1(t1, v, d, t2) { - if (d !== undefined) { - return join$1(t1, v, Primitive_option.valFromOption(d), t2); - } else { - return concat$1(t1, t2); - } -} - -function split$1(x, x_) { - if (typeof x_ !== "object") { - return [ - "Empty", - undefined, - "Empty" - ]; - } - let r = x_._3; - let d = x_._2; - let v = x_._1; - let l = x_._0; - let c = Primitive_string.compare(x, v); - if (c === 0) { - return [ - l, - Primitive_option.some(d), - r - ]; - } - if (c < 0) { - let match = split$1(x, l); - return [ - match[0], - match[1], - join$1(match[2], v, d, r) - ]; - } - let match$1 = split$1(x, r); - return [ - join$1(l, v, d, match$1[0]), - match$1[1], - match$1[2] - ]; -} - -function merge$1(f, s1, s2) { - if (typeof s1 !== "object") { - if (typeof s2 !== "object") { - return "Empty"; - } - - } else { - let v1 = s1._1; - if (s1._4 >= height$1(s2)) { - let match = split$1(v1, s2); - return concat_or_join$1(merge$1(f, s1._0, match[0]), v1, f(v1, Primitive_option.some(s1._2), match[1]), merge$1(f, s1._3, match[2])); - } - - } - if (typeof s2 !== "object") { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "inline_map2_test.res", - 359, - 11 - ], - Error: new Error() - }; - } - let v2 = s2._1; - let match$1 = split$1(v2, s1); - return concat_or_join$1(merge$1(f, match$1[0], s2._0), v2, f(v2, match$1[1], Primitive_option.some(s2._2)), merge$1(f, match$1[2], s2._3)); -} - -function filter$1(p, x) { - if (typeof x !== "object") { - return "Empty"; - } - let d = x._2; - let v = x._1; - let l$p = filter$1(p, x._0); - let pvd = p(v, d); - let r$p = filter$1(p, x._3); - if (pvd) { - return join$1(l$p, v, d, r$p); - } else { - return concat$1(l$p, r$p); - } -} - -function partition$1(p, x) { - if (typeof x !== "object") { - return [ - "Empty", - "Empty" - ]; - } - let d = x._2; - let v = x._1; - let match = partition$1(p, x._0); - let lf = match[1]; - let lt = match[0]; - let pvd = p(v, d); - let match$1 = partition$1(p, x._3); - let rf = match$1[1]; - let rt = match$1[0]; - if (pvd) { - return [ - join$1(lt, v, d, rt), - concat$1(lf, rf) - ]; - } else { - return [ - concat$1(lt, rt), - join$1(lf, v, d, rf) - ]; - } -} - -function cons_enum$1(_m, _e) { - while (true) { - let e = _e; - let m = _m; - if (typeof m !== "object") { - return e; - } - _e = { - TAG: "More", - _0: m._1, - _1: m._2, - _2: m._3, - _3: e - }; - _m = m._0; - continue; - }; -} - -function compare$1(cmp, m1, m2) { - let _e1 = cons_enum$1(m1, "End"); - let _e2 = cons_enum$1(m2, "End"); - while (true) { - let e2 = _e2; - let e1 = _e1; - if (typeof e1 !== "object") { - if (typeof e2 !== "object") { - return 0; - } else { - return -1; - } - } - if (typeof e2 !== "object") { - return 1; - } - let c = Primitive_string.compare(e1._0, e2._0); - if (c !== 0) { - return c; - } - let c$1 = cmp(e1._1, e2._1); - if (c$1 !== 0) { - return c$1; - } - _e2 = cons_enum$1(e2._2, e2._3); - _e1 = cons_enum$1(e1._2, e1._3); - continue; - }; -} - -function equal$1(cmp, m1, m2) { - let _e1 = cons_enum$1(m1, "End"); - let _e2 = cons_enum$1(m2, "End"); - while (true) { - let e2 = _e2; - let e1 = _e1; - if (typeof e1 !== "object") { - if (typeof e2 !== "object") { - return true; - } else { - return false; - } - } - if (typeof e2 !== "object") { - return false; - } - if (e1._0 !== e2._0) { - return false; - } - if (!cmp(e1._1, e2._1)) { - return false; - } - _e2 = cons_enum$1(e2._2, e2._3); - _e1 = cons_enum$1(e1._2, e1._3); - continue; - }; -} - -function cardinal$1(x) { - if (typeof x !== "object") { - return 0; - } else { - return (cardinal$1(x._0) + 1 | 0) + cardinal$1(x._3) | 0; - } -} - -function bindings_aux$1(_accu, _x) { - while (true) { - let x = _x; - let accu = _accu; - if (typeof x !== "object") { - return accu; - } - _x = x._0; - _accu = { - hd: [ - x._1, - x._2 - ], - tl: bindings_aux$1(accu, x._3) - }; - continue; - }; -} - -function bindings$1(s) { - return bindings_aux$1(/* [] */0, s); -} - -let SMap = { - height: height$1, - create: create$1, - singleton: singleton$1, - bal: bal$1, - empty: "Empty", - is_empty: is_empty$1, - add: add$1, - find: find$1, - mem: mem$1, - min_binding: min_binding$1, - max_binding: max_binding$1, - remove_min_binding: remove_min_binding$1, - remove: remove$1, - iter: iter$1, - map: map$1, - mapi: mapi$1, - fold: fold$1, - for_all: for_all$1, - exists: exists$1, - add_min_binding: add_min_binding$1, - add_max_binding: add_max_binding$1, - join: join$1, - concat: concat$1, - concat_or_join: concat_or_join$1, - split: split$1, - merge: merge$1, - filter: filter$1, - partition: partition$1, - cons_enum: cons_enum$1, - compare: compare$1, - equal: equal$1, - cardinal: cardinal$1, - bindings_aux: bindings_aux$1, - bindings: bindings$1, - choose: min_binding$1 -}; - -let s = Belt_List.reduceReverse({ - hd: [ - "10", - /* 'a' */97 - ], - tl: { - hd: [ - "3", - /* 'b' */98 - ], - tl: { - hd: [ - "7", - /* 'c' */99 - ], - tl: { - hd: [ - "20", - /* 'd' */100 - ], - tl: /* [] */0 - } - } - } -}, "Empty", (acc, param) => add$1(param[0], param[1], acc)); - -Mt.from_pair_suites("Inline_map2_test", { - hd: [ - "assertion1", - () => ({ - TAG: "Eq", - _0: find(10, m), - _1: /* 'a' */97 - }) - ], - tl: { - hd: [ - "assertion2", - () => ({ - TAG: "Eq", - _0: find$1("10", s), - _1: /* 'a' */97 - }) - ], - tl: /* [] */0 - } -}); - -let empty = "Empty"; - -exports.Make = Make; -exports.IntMap = IntMap; -exports.empty = empty; -exports.m = m; -exports.SMap = SMap; -exports.s = s; -/* m Not a pure module */ diff --git a/tests/tests/src/inline_map2_test.mjs b/tests/tests/src/inline_map2_test.mjs new file mode 100644 index 0000000000..a31d35a05b --- /dev/null +++ b/tests/tests/src/inline_map2_test.mjs @@ -0,0 +1,1967 @@ +// Generated by ReScript, PLEASE EDIT WITH CARE + +import * as Mt from "./mt.mjs"; +import * as Belt_List from "rescript/lib/es6/Belt_List.js"; +import * as Pervasives from "rescript/lib/es6/Pervasives.js"; +import * as Primitive_int from "rescript/lib/es6/Primitive_int.js"; +import * as Primitive_option from "rescript/lib/es6/Primitive_option.js"; +import * as Primitive_string from "rescript/lib/es6/Primitive_string.js"; + +function Make(Ord) { + let height = x => { + if (typeof x !== "object") { + return 0; + } else { + return x._4; + } + }; + let create = (l, x, d, r) => { + let hl = height(l); + let hr = height(r); + return { + TAG: "Node", + _0: l, + _1: x, + _2: d, + _3: r, + _4: hl >= hr ? hl + 1 | 0 : hr + 1 | 0 + }; + }; + let singleton = (x, d) => ({ + TAG: "Node", + _0: "Empty", + _1: x, + _2: d, + _3: "Empty", + _4: 1 + }); + let bal = (l, x, d, r) => { + let hl; + hl = typeof l !== "object" ? 0 : l._4; + let hr; + hr = typeof r !== "object" ? 0 : r._4; + if (hl > (hr + 2 | 0)) { + if (typeof l !== "object") { + return Pervasives.invalid_arg("Map.bal"); + } + let lr = l._3; + let ld = l._2; + let lv = l._1; + let ll = l._0; + if (height(ll) >= height(lr)) { + return create(ll, lv, ld, create(lr, x, d, r)); + } else if (typeof lr !== "object") { + return Pervasives.invalid_arg("Map.bal"); + } else { + return create(create(ll, lv, ld, lr._0), lr._1, lr._2, create(lr._3, x, d, r)); + } + } + if (hr <= (hl + 2 | 0)) { + return { + TAG: "Node", + _0: l, + _1: x, + _2: d, + _3: r, + _4: hl >= hr ? hl + 1 | 0 : hr + 1 | 0 + }; + } + if (typeof r !== "object") { + return Pervasives.invalid_arg("Map.bal"); + } + let rr = r._3; + let rd = r._2; + let rv = r._1; + let rl = r._0; + if (height(rr) >= height(rl)) { + return create(create(l, x, d, rl), rv, rd, rr); + } else if (typeof rl !== "object") { + return Pervasives.invalid_arg("Map.bal"); + } else { + return create(create(l, x, d, rl._0), rl._1, rl._2, create(rl._3, rv, rd, rr)); + } + }; + let is_empty = x => { + if (typeof x !== "object") { + return true; + } else { + return false; + } + }; + let add = (x, data, x_) => { + if (typeof x_ !== "object") { + return { + TAG: "Node", + _0: "Empty", + _1: x, + _2: data, + _3: "Empty", + _4: 1 + }; + } + let r = x_._3; + let d = x_._2; + let v = x_._1; + let l = x_._0; + let c = Ord.compare(x, v); + if (c === 0) { + return { + TAG: "Node", + _0: l, + _1: x, + _2: data, + _3: r, + _4: x_._4 + }; + } else if (c < 0) { + return bal(add(x, data, l), v, d, r); + } else { + return bal(l, v, d, add(x, data, r)); + } + }; + let find = (x, _x_) => { + while (true) { + let x_ = _x_; + if (typeof x_ !== "object") { + throw { + RE_EXN_ID: "Not_found", + Error: new Error() + }; + } + let c = Ord.compare(x, x_._1); + if (c === 0) { + return x_._2; + } + _x_ = c < 0 ? x_._0 : x_._3; + continue; + }; + }; + let mem = (x, _x_) => { + while (true) { + let x_ = _x_; + if (typeof x_ !== "object") { + return false; + } + let c = Ord.compare(x, x_._1); + if (c === 0) { + return true; + } + _x_ = c < 0 ? x_._0 : x_._3; + continue; + }; + }; + let min_binding = _x => { + while (true) { + let x = _x; + if (typeof x !== "object") { + throw { + RE_EXN_ID: "Not_found", + Error: new Error() + }; + } + let l = x._0; + if (typeof l !== "object") { + return [ + x._1, + x._2 + ]; + } + _x = l; + continue; + }; + }; + let max_binding = _x => { + while (true) { + let x = _x; + if (typeof x !== "object") { + throw { + RE_EXN_ID: "Not_found", + Error: new Error() + }; + } + let r = x._3; + if (typeof r !== "object") { + return [ + x._1, + x._2 + ]; + } + _x = r; + continue; + }; + }; + let remove_min_binding = x => { + if (typeof x !== "object") { + return Pervasives.invalid_arg("Map.remove_min_elt"); + } + let l = x._0; + if (typeof l !== "object") { + return x._3; + } else { + return bal(remove_min_binding(l), x._1, x._2, x._3); + } + }; + let remove = (x, x_) => { + if (typeof x_ !== "object") { + return "Empty"; + } + let r = x_._3; + let d = x_._2; + let v = x_._1; + let l = x_._0; + let c = Ord.compare(x, v); + if (c === 0) { + if (typeof l !== "object") { + return r; + } + if (typeof r !== "object") { + return l; + } + let match = min_binding(r); + return bal(l, match[0], match[1], remove_min_binding(r)); + } else if (c < 0) { + return bal(remove(x, l), v, d, r); + } else { + return bal(l, v, d, remove(x, r)); + } + }; + let iter = (f, _x) => { + while (true) { + let x = _x; + if (typeof x !== "object") { + return; + } + iter(f, x._0); + f(x._1, x._2); + _x = x._3; + continue; + }; + }; + let map = (f, x) => { + if (typeof x !== "object") { + return "Empty"; + } + let l$p = map(f, x._0); + let d$p = f(x._2); + let r$p = map(f, x._3); + return { + TAG: "Node", + _0: l$p, + _1: x._1, + _2: d$p, + _3: r$p, + _4: x._4 + }; + }; + let mapi = (f, x) => { + if (typeof x !== "object") { + return "Empty"; + } + let v = x._1; + let l$p = mapi(f, x._0); + let d$p = f(v, x._2); + let r$p = mapi(f, x._3); + return { + TAG: "Node", + _0: l$p, + _1: v, + _2: d$p, + _3: r$p, + _4: x._4 + }; + }; + let fold = (f, _m, _accu) => { + while (true) { + let accu = _accu; + let m = _m; + if (typeof m !== "object") { + return accu; + } + _accu = f(m._1, m._2, fold(f, m._0, accu)); + _m = m._3; + continue; + }; + }; + let for_all = (p, _x) => { + while (true) { + let x = _x; + if (typeof x !== "object") { + return true; + } + if (!p(x._1, x._2)) { + return false; + } + if (!for_all(p, x._0)) { + return false; + } + _x = x._3; + continue; + }; + }; + let exists = (p, _x) => { + while (true) { + let x = _x; + if (typeof x !== "object") { + return false; + } + if (p(x._1, x._2)) { + return true; + } + if (exists(p, x._0)) { + return true; + } + _x = x._3; + continue; + }; + }; + let add_min_binding = (k, v, x) => { + if (typeof x !== "object") { + return singleton(k, v); + } else { + return bal(add_min_binding(k, v, x._0), x._1, x._2, x._3); + } + }; + let add_max_binding = (k, v, x) => { + if (typeof x !== "object") { + return singleton(k, v); + } else { + return bal(x._0, x._1, x._2, add_max_binding(k, v, x._3)); + } + }; + let join = (l, v, d, r) => { + if (typeof l !== "object") { + return add_min_binding(v, d, r); + } + let lh = l._4; + if (typeof r !== "object") { + return add_max_binding(v, d, l); + } + let rh = r._4; + if (lh > (rh + 2 | 0)) { + return bal(l._0, l._1, l._2, join(l._3, v, d, r)); + } else if (rh > (lh + 2 | 0)) { + return bal(join(l, v, d, r._0), r._1, r._2, r._3); + } else { + return create(l, v, d, r); + } + }; + let concat = (t1, t2) => { + if (typeof t1 !== "object") { + return t2; + } + if (typeof t2 !== "object") { + return t1; + } + let match = min_binding(t2); + return join(t1, match[0], match[1], remove_min_binding(t2)); + }; + let concat_or_join = (t1, v, d, t2) => { + if (d !== undefined) { + return join(t1, v, Primitive_option.valFromOption(d), t2); + } else { + return concat(t1, t2); + } + }; + let split = (x, x_) => { + if (typeof x_ !== "object") { + return [ + "Empty", + undefined, + "Empty" + ]; + } + let r = x_._3; + let d = x_._2; + let v = x_._1; + let l = x_._0; + let c = Ord.compare(x, v); + if (c === 0) { + return [ + l, + Primitive_option.some(d), + r + ]; + } + if (c < 0) { + let match = split(x, l); + return [ + match[0], + match[1], + join(match[2], v, d, r) + ]; + } + let match$1 = split(x, r); + return [ + join(l, v, d, match$1[0]), + match$1[1], + match$1[2] + ]; + }; + let merge = (f, s1, s2) => { + if (typeof s1 !== "object") { + if (typeof s2 !== "object") { + return "Empty"; + } + + } else { + let v1 = s1._1; + if (s1._4 >= height(s2)) { + let match = split(v1, s2); + return concat_or_join(merge(f, s1._0, match[0]), v1, f(v1, Primitive_option.some(s1._2), match[1]), merge(f, s1._3, match[2])); + } + + } + if (typeof s2 !== "object") { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "inline_map2_test.res", + 359, + 11 + ], + Error: new Error() + }; + } + let v2 = s2._1; + let match$1 = split(v2, s1); + return concat_or_join(merge(f, match$1[0], s2._0), v2, f(v2, match$1[1], Primitive_option.some(s2._2)), merge(f, match$1[2], s2._3)); + }; + let filter = (p, x) => { + if (typeof x !== "object") { + return "Empty"; + } + let d = x._2; + let v = x._1; + let l$p = filter(p, x._0); + let pvd = p(v, d); + let r$p = filter(p, x._3); + if (pvd) { + return join(l$p, v, d, r$p); + } else { + return concat(l$p, r$p); + } + }; + let partition = (p, x) => { + if (typeof x !== "object") { + return [ + "Empty", + "Empty" + ]; + } + let d = x._2; + let v = x._1; + let match = partition(p, x._0); + let lf = match[1]; + let lt = match[0]; + let pvd = p(v, d); + let match$1 = partition(p, x._3); + let rf = match$1[1]; + let rt = match$1[0]; + if (pvd) { + return [ + join(lt, v, d, rt), + concat(lf, rf) + ]; + } else { + return [ + concat(lt, rt), + join(lf, v, d, rf) + ]; + } + }; + let cons_enum = (_m, _e) => { + while (true) { + let e = _e; + let m = _m; + if (typeof m !== "object") { + return e; + } + _e = { + TAG: "More", + _0: m._1, + _1: m._2, + _2: m._3, + _3: e + }; + _m = m._0; + continue; + }; + }; + let compare = (cmp, m1, m2) => { + let _e1 = cons_enum(m1, "End"); + let _e2 = cons_enum(m2, "End"); + while (true) { + let e2 = _e2; + let e1 = _e1; + if (typeof e1 !== "object") { + if (typeof e2 !== "object") { + return 0; + } else { + return -1; + } + } + if (typeof e2 !== "object") { + return 1; + } + let c = Ord.compare(e1._0, e2._0); + if (c !== 0) { + return c; + } + let c$1 = cmp(e1._1, e2._1); + if (c$1 !== 0) { + return c$1; + } + _e2 = cons_enum(e2._2, e2._3); + _e1 = cons_enum(e1._2, e1._3); + continue; + }; + }; + let equal = (cmp, m1, m2) => { + let _e1 = cons_enum(m1, "End"); + let _e2 = cons_enum(m2, "End"); + while (true) { + let e2 = _e2; + let e1 = _e1; + if (typeof e1 !== "object") { + if (typeof e2 !== "object") { + return true; + } else { + return false; + } + } + if (typeof e2 !== "object") { + return false; + } + if (Ord.compare(e1._0, e2._0) !== 0) { + return false; + } + if (!cmp(e1._1, e2._1)) { + return false; + } + _e2 = cons_enum(e2._2, e2._3); + _e1 = cons_enum(e1._2, e1._3); + continue; + }; + }; + let cardinal = x => { + if (typeof x !== "object") { + return 0; + } else { + return (cardinal(x._0) + 1 | 0) + cardinal(x._3) | 0; + } + }; + let bindings_aux = (_accu, _x) => { + while (true) { + let x = _x; + let accu = _accu; + if (typeof x !== "object") { + return accu; + } + _x = x._0; + _accu = { + hd: [ + x._1, + x._2 + ], + tl: bindings_aux(accu, x._3) + }; + continue; + }; + }; + let bindings = s => bindings_aux(/* [] */0, s); + return { + height: height, + create: create, + singleton: singleton, + bal: bal, + empty: "Empty", + is_empty: is_empty, + add: add, + find: find, + mem: mem, + min_binding: min_binding, + max_binding: max_binding, + remove_min_binding: remove_min_binding, + remove: remove, + iter: iter, + map: map, + mapi: mapi, + fold: fold, + for_all: for_all, + exists: exists, + add_min_binding: add_min_binding, + add_max_binding: add_max_binding, + join: join, + concat: concat, + concat_or_join: concat_or_join, + split: split, + merge: merge, + filter: filter, + partition: partition, + cons_enum: cons_enum, + compare: compare, + equal: equal, + cardinal: cardinal, + bindings_aux: bindings_aux, + bindings: bindings, + choose: min_binding + }; +} + +function height(x) { + if (typeof x !== "object") { + return 0; + } else { + return x._4; + } +} + +function create(l, x, d, r) { + let hl = height(l); + let hr = height(r); + return { + TAG: "Node", + _0: l, + _1: x, + _2: d, + _3: r, + _4: hl >= hr ? hl + 1 | 0 : hr + 1 | 0 + }; +} + +function singleton(x, d) { + return { + TAG: "Node", + _0: "Empty", + _1: x, + _2: d, + _3: "Empty", + _4: 1 + }; +} + +function bal(l, x, d, r) { + let hl; + hl = typeof l !== "object" ? 0 : l._4; + let hr; + hr = typeof r !== "object" ? 0 : r._4; + if (hl > (hr + 2 | 0)) { + if (typeof l !== "object") { + return Pervasives.invalid_arg("Map.bal"); + } + let lr = l._3; + let ld = l._2; + let lv = l._1; + let ll = l._0; + if (height(ll) >= height(lr)) { + return create(ll, lv, ld, create(lr, x, d, r)); + } else if (typeof lr !== "object") { + return Pervasives.invalid_arg("Map.bal"); + } else { + return create(create(ll, lv, ld, lr._0), lr._1, lr._2, create(lr._3, x, d, r)); + } + } + if (hr <= (hl + 2 | 0)) { + return { + TAG: "Node", + _0: l, + _1: x, + _2: d, + _3: r, + _4: hl >= hr ? hl + 1 | 0 : hr + 1 | 0 + }; + } + if (typeof r !== "object") { + return Pervasives.invalid_arg("Map.bal"); + } + let rr = r._3; + let rd = r._2; + let rv = r._1; + let rl = r._0; + if (height(rr) >= height(rl)) { + return create(create(l, x, d, rl), rv, rd, rr); + } else if (typeof rl !== "object") { + return Pervasives.invalid_arg("Map.bal"); + } else { + return create(create(l, x, d, rl._0), rl._1, rl._2, create(rl._3, rv, rd, rr)); + } +} + +function is_empty(x) { + if (typeof x !== "object") { + return true; + } else { + return false; + } +} + +function add(x, data, x_) { + if (typeof x_ !== "object") { + return { + TAG: "Node", + _0: "Empty", + _1: x, + _2: data, + _3: "Empty", + _4: 1 + }; + } + let r = x_._3; + let d = x_._2; + let v = x_._1; + let l = x_._0; + let c = Primitive_int.compare(x, v); + if (c === 0) { + return { + TAG: "Node", + _0: l, + _1: x, + _2: data, + _3: r, + _4: x_._4 + }; + } else if (c < 0) { + return bal(add(x, data, l), v, d, r); + } else { + return bal(l, v, d, add(x, data, r)); + } +} + +function find(x, _x_) { + while (true) { + let x_ = _x_; + if (typeof x_ !== "object") { + throw { + RE_EXN_ID: "Not_found", + Error: new Error() + }; + } + let c = Primitive_int.compare(x, x_._1); + if (c === 0) { + return x_._2; + } + _x_ = c < 0 ? x_._0 : x_._3; + continue; + }; +} + +function mem(x, _x_) { + while (true) { + let x_ = _x_; + if (typeof x_ !== "object") { + return false; + } + let c = Primitive_int.compare(x, x_._1); + if (c === 0) { + return true; + } + _x_ = c < 0 ? x_._0 : x_._3; + continue; + }; +} + +function min_binding(_x) { + while (true) { + let x = _x; + if (typeof x !== "object") { + throw { + RE_EXN_ID: "Not_found", + Error: new Error() + }; + } + let l = x._0; + if (typeof l !== "object") { + return [ + x._1, + x._2 + ]; + } + _x = l; + continue; + }; +} + +function max_binding(_x) { + while (true) { + let x = _x; + if (typeof x !== "object") { + throw { + RE_EXN_ID: "Not_found", + Error: new Error() + }; + } + let r = x._3; + if (typeof r !== "object") { + return [ + x._1, + x._2 + ]; + } + _x = r; + continue; + }; +} + +function remove_min_binding(x) { + if (typeof x !== "object") { + return Pervasives.invalid_arg("Map.remove_min_elt"); + } + let l = x._0; + if (typeof l !== "object") { + return x._3; + } else { + return bal(remove_min_binding(l), x._1, x._2, x._3); + } +} + +function remove(x, x_) { + if (typeof x_ !== "object") { + return "Empty"; + } + let r = x_._3; + let d = x_._2; + let v = x_._1; + let l = x_._0; + let c = Primitive_int.compare(x, v); + if (c === 0) { + if (typeof l !== "object") { + return r; + } + if (typeof r !== "object") { + return l; + } + let match = min_binding(r); + return bal(l, match[0], match[1], remove_min_binding(r)); + } else if (c < 0) { + return bal(remove(x, l), v, d, r); + } else { + return bal(l, v, d, remove(x, r)); + } +} + +function iter(f, _x) { + while (true) { + let x = _x; + if (typeof x !== "object") { + return; + } + iter(f, x._0); + f(x._1, x._2); + _x = x._3; + continue; + }; +} + +function map(f, x) { + if (typeof x !== "object") { + return "Empty"; + } + let l$p = map(f, x._0); + let d$p = f(x._2); + let r$p = map(f, x._3); + return { + TAG: "Node", + _0: l$p, + _1: x._1, + _2: d$p, + _3: r$p, + _4: x._4 + }; +} + +function mapi(f, x) { + if (typeof x !== "object") { + return "Empty"; + } + let v = x._1; + let l$p = mapi(f, x._0); + let d$p = f(v, x._2); + let r$p = mapi(f, x._3); + return { + TAG: "Node", + _0: l$p, + _1: v, + _2: d$p, + _3: r$p, + _4: x._4 + }; +} + +function fold(f, _m, _accu) { + while (true) { + let accu = _accu; + let m = _m; + if (typeof m !== "object") { + return accu; + } + _accu = f(m._1, m._2, fold(f, m._0, accu)); + _m = m._3; + continue; + }; +} + +function for_all(p, _x) { + while (true) { + let x = _x; + if (typeof x !== "object") { + return true; + } + if (!p(x._1, x._2)) { + return false; + } + if (!for_all(p, x._0)) { + return false; + } + _x = x._3; + continue; + }; +} + +function exists(p, _x) { + while (true) { + let x = _x; + if (typeof x !== "object") { + return false; + } + if (p(x._1, x._2)) { + return true; + } + if (exists(p, x._0)) { + return true; + } + _x = x._3; + continue; + }; +} + +function add_min_binding(k, v, x) { + if (typeof x !== "object") { + return singleton(k, v); + } else { + return bal(add_min_binding(k, v, x._0), x._1, x._2, x._3); + } +} + +function add_max_binding(k, v, x) { + if (typeof x !== "object") { + return singleton(k, v); + } else { + return bal(x._0, x._1, x._2, add_max_binding(k, v, x._3)); + } +} + +function join(l, v, d, r) { + if (typeof l !== "object") { + return add_min_binding(v, d, r); + } + let lh = l._4; + if (typeof r !== "object") { + return add_max_binding(v, d, l); + } + let rh = r._4; + if (lh > (rh + 2 | 0)) { + return bal(l._0, l._1, l._2, join(l._3, v, d, r)); + } else if (rh > (lh + 2 | 0)) { + return bal(join(l, v, d, r._0), r._1, r._2, r._3); + } else { + return create(l, v, d, r); + } +} + +function concat(t1, t2) { + if (typeof t1 !== "object") { + return t2; + } + if (typeof t2 !== "object") { + return t1; + } + let match = min_binding(t2); + return join(t1, match[0], match[1], remove_min_binding(t2)); +} + +function concat_or_join(t1, v, d, t2) { + if (d !== undefined) { + return join(t1, v, Primitive_option.valFromOption(d), t2); + } else { + return concat(t1, t2); + } +} + +function split(x, x_) { + if (typeof x_ !== "object") { + return [ + "Empty", + undefined, + "Empty" + ]; + } + let r = x_._3; + let d = x_._2; + let v = x_._1; + let l = x_._0; + let c = Primitive_int.compare(x, v); + if (c === 0) { + return [ + l, + Primitive_option.some(d), + r + ]; + } + if (c < 0) { + let match = split(x, l); + return [ + match[0], + match[1], + join(match[2], v, d, r) + ]; + } + let match$1 = split(x, r); + return [ + join(l, v, d, match$1[0]), + match$1[1], + match$1[2] + ]; +} + +function merge(f, s1, s2) { + if (typeof s1 !== "object") { + if (typeof s2 !== "object") { + return "Empty"; + } + + } else { + let v1 = s1._1; + if (s1._4 >= height(s2)) { + let match = split(v1, s2); + return concat_or_join(merge(f, s1._0, match[0]), v1, f(v1, Primitive_option.some(s1._2), match[1]), merge(f, s1._3, match[2])); + } + + } + if (typeof s2 !== "object") { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "inline_map2_test.res", + 359, + 11 + ], + Error: new Error() + }; + } + let v2 = s2._1; + let match$1 = split(v2, s1); + return concat_or_join(merge(f, match$1[0], s2._0), v2, f(v2, match$1[1], Primitive_option.some(s2._2)), merge(f, match$1[2], s2._3)); +} + +function filter(p, x) { + if (typeof x !== "object") { + return "Empty"; + } + let d = x._2; + let v = x._1; + let l$p = filter(p, x._0); + let pvd = p(v, d); + let r$p = filter(p, x._3); + if (pvd) { + return join(l$p, v, d, r$p); + } else { + return concat(l$p, r$p); + } +} + +function partition(p, x) { + if (typeof x !== "object") { + return [ + "Empty", + "Empty" + ]; + } + let d = x._2; + let v = x._1; + let match = partition(p, x._0); + let lf = match[1]; + let lt = match[0]; + let pvd = p(v, d); + let match$1 = partition(p, x._3); + let rf = match$1[1]; + let rt = match$1[0]; + if (pvd) { + return [ + join(lt, v, d, rt), + concat(lf, rf) + ]; + } else { + return [ + concat(lt, rt), + join(lf, v, d, rf) + ]; + } +} + +function cons_enum(_m, _e) { + while (true) { + let e = _e; + let m = _m; + if (typeof m !== "object") { + return e; + } + _e = { + TAG: "More", + _0: m._1, + _1: m._2, + _2: m._3, + _3: e + }; + _m = m._0; + continue; + }; +} + +function compare(cmp, m1, m2) { + let _e1 = cons_enum(m1, "End"); + let _e2 = cons_enum(m2, "End"); + while (true) { + let e2 = _e2; + let e1 = _e1; + if (typeof e1 !== "object") { + if (typeof e2 !== "object") { + return 0; + } else { + return -1; + } + } + if (typeof e2 !== "object") { + return 1; + } + let c = Primitive_int.compare(e1._0, e2._0); + if (c !== 0) { + return c; + } + let c$1 = cmp(e1._1, e2._1); + if (c$1 !== 0) { + return c$1; + } + _e2 = cons_enum(e2._2, e2._3); + _e1 = cons_enum(e1._2, e1._3); + continue; + }; +} + +function equal(cmp, m1, m2) { + let _e1 = cons_enum(m1, "End"); + let _e2 = cons_enum(m2, "End"); + while (true) { + let e2 = _e2; + let e1 = _e1; + if (typeof e1 !== "object") { + if (typeof e2 !== "object") { + return true; + } else { + return false; + } + } + if (typeof e2 !== "object") { + return false; + } + if (e1._0 !== e2._0) { + return false; + } + if (!cmp(e1._1, e2._1)) { + return false; + } + _e2 = cons_enum(e2._2, e2._3); + _e1 = cons_enum(e1._2, e1._3); + continue; + }; +} + +function cardinal(x) { + if (typeof x !== "object") { + return 0; + } else { + return (cardinal(x._0) + 1 | 0) + cardinal(x._3) | 0; + } +} + +function bindings_aux(_accu, _x) { + while (true) { + let x = _x; + let accu = _accu; + if (typeof x !== "object") { + return accu; + } + _x = x._0; + _accu = { + hd: [ + x._1, + x._2 + ], + tl: bindings_aux(accu, x._3) + }; + continue; + }; +} + +function bindings(s) { + return bindings_aux(/* [] */0, s); +} + +let IntMap = { + height: height, + create: create, + singleton: singleton, + bal: bal, + empty: "Empty", + is_empty: is_empty, + add: add, + find: find, + mem: mem, + min_binding: min_binding, + max_binding: max_binding, + remove_min_binding: remove_min_binding, + remove: remove, + iter: iter, + map: map, + mapi: mapi, + fold: fold, + for_all: for_all, + exists: exists, + add_min_binding: add_min_binding, + add_max_binding: add_max_binding, + join: join, + concat: concat, + concat_or_join: concat_or_join, + split: split, + merge: merge, + filter: filter, + partition: partition, + cons_enum: cons_enum, + compare: compare, + equal: equal, + cardinal: cardinal, + bindings_aux: bindings_aux, + bindings: bindings, + choose: min_binding +}; + +let m = Belt_List.reduceReverse({ + hd: [ + 10, + /* 'a' */97 + ], + tl: { + hd: [ + 3, + /* 'b' */98 + ], + tl: { + hd: [ + 7, + /* 'c' */99 + ], + tl: { + hd: [ + 20, + /* 'd' */100 + ], + tl: /* [] */0 + } + } + } +}, "Empty", (acc, param) => add(param[0], param[1], acc)); + +function height$1(x) { + if (typeof x !== "object") { + return 0; + } else { + return x._4; + } +} + +function create$1(l, x, d, r) { + let hl = height$1(l); + let hr = height$1(r); + return { + TAG: "Node", + _0: l, + _1: x, + _2: d, + _3: r, + _4: hl >= hr ? hl + 1 | 0 : hr + 1 | 0 + }; +} + +function singleton$1(x, d) { + return { + TAG: "Node", + _0: "Empty", + _1: x, + _2: d, + _3: "Empty", + _4: 1 + }; +} + +function bal$1(l, x, d, r) { + let hl; + hl = typeof l !== "object" ? 0 : l._4; + let hr; + hr = typeof r !== "object" ? 0 : r._4; + if (hl > (hr + 2 | 0)) { + if (typeof l !== "object") { + return Pervasives.invalid_arg("Map.bal"); + } + let lr = l._3; + let ld = l._2; + let lv = l._1; + let ll = l._0; + if (height$1(ll) >= height$1(lr)) { + return create$1(ll, lv, ld, create$1(lr, x, d, r)); + } else if (typeof lr !== "object") { + return Pervasives.invalid_arg("Map.bal"); + } else { + return create$1(create$1(ll, lv, ld, lr._0), lr._1, lr._2, create$1(lr._3, x, d, r)); + } + } + if (hr <= (hl + 2 | 0)) { + return { + TAG: "Node", + _0: l, + _1: x, + _2: d, + _3: r, + _4: hl >= hr ? hl + 1 | 0 : hr + 1 | 0 + }; + } + if (typeof r !== "object") { + return Pervasives.invalid_arg("Map.bal"); + } + let rr = r._3; + let rd = r._2; + let rv = r._1; + let rl = r._0; + if (height$1(rr) >= height$1(rl)) { + return create$1(create$1(l, x, d, rl), rv, rd, rr); + } else if (typeof rl !== "object") { + return Pervasives.invalid_arg("Map.bal"); + } else { + return create$1(create$1(l, x, d, rl._0), rl._1, rl._2, create$1(rl._3, rv, rd, rr)); + } +} + +function is_empty$1(x) { + if (typeof x !== "object") { + return true; + } else { + return false; + } +} + +function add$1(x, data, x_) { + if (typeof x_ !== "object") { + return { + TAG: "Node", + _0: "Empty", + _1: x, + _2: data, + _3: "Empty", + _4: 1 + }; + } + let r = x_._3; + let d = x_._2; + let v = x_._1; + let l = x_._0; + let c = Primitive_string.compare(x, v); + if (c === 0) { + return { + TAG: "Node", + _0: l, + _1: x, + _2: data, + _3: r, + _4: x_._4 + }; + } else if (c < 0) { + return bal$1(add$1(x, data, l), v, d, r); + } else { + return bal$1(l, v, d, add$1(x, data, r)); + } +} + +function find$1(x, _x_) { + while (true) { + let x_ = _x_; + if (typeof x_ !== "object") { + throw { + RE_EXN_ID: "Not_found", + Error: new Error() + }; + } + let c = Primitive_string.compare(x, x_._1); + if (c === 0) { + return x_._2; + } + _x_ = c < 0 ? x_._0 : x_._3; + continue; + }; +} + +function mem$1(x, _x_) { + while (true) { + let x_ = _x_; + if (typeof x_ !== "object") { + return false; + } + let c = Primitive_string.compare(x, x_._1); + if (c === 0) { + return true; + } + _x_ = c < 0 ? x_._0 : x_._3; + continue; + }; +} + +function min_binding$1(_x) { + while (true) { + let x = _x; + if (typeof x !== "object") { + throw { + RE_EXN_ID: "Not_found", + Error: new Error() + }; + } + let l = x._0; + if (typeof l !== "object") { + return [ + x._1, + x._2 + ]; + } + _x = l; + continue; + }; +} + +function max_binding$1(_x) { + while (true) { + let x = _x; + if (typeof x !== "object") { + throw { + RE_EXN_ID: "Not_found", + Error: new Error() + }; + } + let r = x._3; + if (typeof r !== "object") { + return [ + x._1, + x._2 + ]; + } + _x = r; + continue; + }; +} + +function remove_min_binding$1(x) { + if (typeof x !== "object") { + return Pervasives.invalid_arg("Map.remove_min_elt"); + } + let l = x._0; + if (typeof l !== "object") { + return x._3; + } else { + return bal$1(remove_min_binding$1(l), x._1, x._2, x._3); + } +} + +function remove$1(x, x_) { + if (typeof x_ !== "object") { + return "Empty"; + } + let r = x_._3; + let d = x_._2; + let v = x_._1; + let l = x_._0; + let c = Primitive_string.compare(x, v); + if (c === 0) { + if (typeof l !== "object") { + return r; + } + if (typeof r !== "object") { + return l; + } + let match = min_binding$1(r); + return bal$1(l, match[0], match[1], remove_min_binding$1(r)); + } else if (c < 0) { + return bal$1(remove$1(x, l), v, d, r); + } else { + return bal$1(l, v, d, remove$1(x, r)); + } +} + +function iter$1(f, _x) { + while (true) { + let x = _x; + if (typeof x !== "object") { + return; + } + iter$1(f, x._0); + f(x._1, x._2); + _x = x._3; + continue; + }; +} + +function map$1(f, x) { + if (typeof x !== "object") { + return "Empty"; + } + let l$p = map$1(f, x._0); + let d$p = f(x._2); + let r$p = map$1(f, x._3); + return { + TAG: "Node", + _0: l$p, + _1: x._1, + _2: d$p, + _3: r$p, + _4: x._4 + }; +} + +function mapi$1(f, x) { + if (typeof x !== "object") { + return "Empty"; + } + let v = x._1; + let l$p = mapi$1(f, x._0); + let d$p = f(v, x._2); + let r$p = mapi$1(f, x._3); + return { + TAG: "Node", + _0: l$p, + _1: v, + _2: d$p, + _3: r$p, + _4: x._4 + }; +} + +function fold$1(f, _m, _accu) { + while (true) { + let accu = _accu; + let m = _m; + if (typeof m !== "object") { + return accu; + } + _accu = f(m._1, m._2, fold$1(f, m._0, accu)); + _m = m._3; + continue; + }; +} + +function for_all$1(p, _x) { + while (true) { + let x = _x; + if (typeof x !== "object") { + return true; + } + if (!p(x._1, x._2)) { + return false; + } + if (!for_all$1(p, x._0)) { + return false; + } + _x = x._3; + continue; + }; +} + +function exists$1(p, _x) { + while (true) { + let x = _x; + if (typeof x !== "object") { + return false; + } + if (p(x._1, x._2)) { + return true; + } + if (exists$1(p, x._0)) { + return true; + } + _x = x._3; + continue; + }; +} + +function add_min_binding$1(k, v, x) { + if (typeof x !== "object") { + return singleton$1(k, v); + } else { + return bal$1(add_min_binding$1(k, v, x._0), x._1, x._2, x._3); + } +} + +function add_max_binding$1(k, v, x) { + if (typeof x !== "object") { + return singleton$1(k, v); + } else { + return bal$1(x._0, x._1, x._2, add_max_binding$1(k, v, x._3)); + } +} + +function join$1(l, v, d, r) { + if (typeof l !== "object") { + return add_min_binding$1(v, d, r); + } + let lh = l._4; + if (typeof r !== "object") { + return add_max_binding$1(v, d, l); + } + let rh = r._4; + if (lh > (rh + 2 | 0)) { + return bal$1(l._0, l._1, l._2, join$1(l._3, v, d, r)); + } else if (rh > (lh + 2 | 0)) { + return bal$1(join$1(l, v, d, r._0), r._1, r._2, r._3); + } else { + return create$1(l, v, d, r); + } +} + +function concat$1(t1, t2) { + if (typeof t1 !== "object") { + return t2; + } + if (typeof t2 !== "object") { + return t1; + } + let match = min_binding$1(t2); + return join$1(t1, match[0], match[1], remove_min_binding$1(t2)); +} + +function concat_or_join$1(t1, v, d, t2) { + if (d !== undefined) { + return join$1(t1, v, Primitive_option.valFromOption(d), t2); + } else { + return concat$1(t1, t2); + } +} + +function split$1(x, x_) { + if (typeof x_ !== "object") { + return [ + "Empty", + undefined, + "Empty" + ]; + } + let r = x_._3; + let d = x_._2; + let v = x_._1; + let l = x_._0; + let c = Primitive_string.compare(x, v); + if (c === 0) { + return [ + l, + Primitive_option.some(d), + r + ]; + } + if (c < 0) { + let match = split$1(x, l); + return [ + match[0], + match[1], + join$1(match[2], v, d, r) + ]; + } + let match$1 = split$1(x, r); + return [ + join$1(l, v, d, match$1[0]), + match$1[1], + match$1[2] + ]; +} + +function merge$1(f, s1, s2) { + if (typeof s1 !== "object") { + if (typeof s2 !== "object") { + return "Empty"; + } + + } else { + let v1 = s1._1; + if (s1._4 >= height$1(s2)) { + let match = split$1(v1, s2); + return concat_or_join$1(merge$1(f, s1._0, match[0]), v1, f(v1, Primitive_option.some(s1._2), match[1]), merge$1(f, s1._3, match[2])); + } + + } + if (typeof s2 !== "object") { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "inline_map2_test.res", + 359, + 11 + ], + Error: new Error() + }; + } + let v2 = s2._1; + let match$1 = split$1(v2, s1); + return concat_or_join$1(merge$1(f, match$1[0], s2._0), v2, f(v2, match$1[1], Primitive_option.some(s2._2)), merge$1(f, match$1[2], s2._3)); +} + +function filter$1(p, x) { + if (typeof x !== "object") { + return "Empty"; + } + let d = x._2; + let v = x._1; + let l$p = filter$1(p, x._0); + let pvd = p(v, d); + let r$p = filter$1(p, x._3); + if (pvd) { + return join$1(l$p, v, d, r$p); + } else { + return concat$1(l$p, r$p); + } +} + +function partition$1(p, x) { + if (typeof x !== "object") { + return [ + "Empty", + "Empty" + ]; + } + let d = x._2; + let v = x._1; + let match = partition$1(p, x._0); + let lf = match[1]; + let lt = match[0]; + let pvd = p(v, d); + let match$1 = partition$1(p, x._3); + let rf = match$1[1]; + let rt = match$1[0]; + if (pvd) { + return [ + join$1(lt, v, d, rt), + concat$1(lf, rf) + ]; + } else { + return [ + concat$1(lt, rt), + join$1(lf, v, d, rf) + ]; + } +} + +function cons_enum$1(_m, _e) { + while (true) { + let e = _e; + let m = _m; + if (typeof m !== "object") { + return e; + } + _e = { + TAG: "More", + _0: m._1, + _1: m._2, + _2: m._3, + _3: e + }; + _m = m._0; + continue; + }; +} + +function compare$1(cmp, m1, m2) { + let _e1 = cons_enum$1(m1, "End"); + let _e2 = cons_enum$1(m2, "End"); + while (true) { + let e2 = _e2; + let e1 = _e1; + if (typeof e1 !== "object") { + if (typeof e2 !== "object") { + return 0; + } else { + return -1; + } + } + if (typeof e2 !== "object") { + return 1; + } + let c = Primitive_string.compare(e1._0, e2._0); + if (c !== 0) { + return c; + } + let c$1 = cmp(e1._1, e2._1); + if (c$1 !== 0) { + return c$1; + } + _e2 = cons_enum$1(e2._2, e2._3); + _e1 = cons_enum$1(e1._2, e1._3); + continue; + }; +} + +function equal$1(cmp, m1, m2) { + let _e1 = cons_enum$1(m1, "End"); + let _e2 = cons_enum$1(m2, "End"); + while (true) { + let e2 = _e2; + let e1 = _e1; + if (typeof e1 !== "object") { + if (typeof e2 !== "object") { + return true; + } else { + return false; + } + } + if (typeof e2 !== "object") { + return false; + } + if (e1._0 !== e2._0) { + return false; + } + if (!cmp(e1._1, e2._1)) { + return false; + } + _e2 = cons_enum$1(e2._2, e2._3); + _e1 = cons_enum$1(e1._2, e1._3); + continue; + }; +} + +function cardinal$1(x) { + if (typeof x !== "object") { + return 0; + } else { + return (cardinal$1(x._0) + 1 | 0) + cardinal$1(x._3) | 0; + } +} + +function bindings_aux$1(_accu, _x) { + while (true) { + let x = _x; + let accu = _accu; + if (typeof x !== "object") { + return accu; + } + _x = x._0; + _accu = { + hd: [ + x._1, + x._2 + ], + tl: bindings_aux$1(accu, x._3) + }; + continue; + }; +} + +function bindings$1(s) { + return bindings_aux$1(/* [] */0, s); +} + +let SMap = { + height: height$1, + create: create$1, + singleton: singleton$1, + bal: bal$1, + empty: "Empty", + is_empty: is_empty$1, + add: add$1, + find: find$1, + mem: mem$1, + min_binding: min_binding$1, + max_binding: max_binding$1, + remove_min_binding: remove_min_binding$1, + remove: remove$1, + iter: iter$1, + map: map$1, + mapi: mapi$1, + fold: fold$1, + for_all: for_all$1, + exists: exists$1, + add_min_binding: add_min_binding$1, + add_max_binding: add_max_binding$1, + join: join$1, + concat: concat$1, + concat_or_join: concat_or_join$1, + split: split$1, + merge: merge$1, + filter: filter$1, + partition: partition$1, + cons_enum: cons_enum$1, + compare: compare$1, + equal: equal$1, + cardinal: cardinal$1, + bindings_aux: bindings_aux$1, + bindings: bindings$1, + choose: min_binding$1 +}; + +let s = Belt_List.reduceReverse({ + hd: [ + "10", + /* 'a' */97 + ], + tl: { + hd: [ + "3", + /* 'b' */98 + ], + tl: { + hd: [ + "7", + /* 'c' */99 + ], + tl: { + hd: [ + "20", + /* 'd' */100 + ], + tl: /* [] */0 + } + } + } +}, "Empty", (acc, param) => add$1(param[0], param[1], acc)); + +Mt.from_pair_suites("Inline_map2_test", { + hd: [ + "assertion1", + () => ({ + TAG: "Eq", + _0: find(10, m), + _1: /* 'a' */97 + }) + ], + tl: { + hd: [ + "assertion2", + () => ({ + TAG: "Eq", + _0: find$1("10", s), + _1: /* 'a' */97 + }) + ], + tl: /* [] */0 + } +}); + +let empty = "Empty"; + +export { + Make, + IntMap, + empty, + m, + SMap, + s, +} +/* m Not a pure module */ diff --git a/tests/tests/src/inline_map_demo.js b/tests/tests/src/inline_map_demo.js deleted file mode 100644 index 396fd23487..0000000000 --- a/tests/tests/src/inline_map_demo.js +++ /dev/null @@ -1,196 +0,0 @@ -// Generated by ReScript, PLEASE EDIT WITH CARE -'use strict'; - -let Mt = require("./mt.js"); -let Belt_List = require("rescript/lib/js/Belt_List.js"); -let Primitive_int = require("rescript/lib/js/Primitive_int.js"); - -function height(x) { - if (typeof x !== "object") { - return 0; - } else { - return x._4; - } -} - -function create(l, x, d, r) { - let hl = height(l); - let hr = height(r); - return { - TAG: "Node", - _0: l, - _1: x, - _2: d, - _3: r, - _4: hl >= hr ? hl + 1 | 0 : hr + 1 | 0 - }; -} - -function bal(l, x, d, r) { - let hl; - hl = typeof l !== "object" ? 0 : l._4; - let hr; - hr = typeof r !== "object" ? 0 : r._4; - if (hl > (hr + 2 | 0)) { - if (typeof l !== "object") { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "inline_map_demo.res", - 41, - 15 - ], - Error: new Error() - }; - } - let lr = l._3; - let ld = l._2; - let lv = l._1; - let ll = l._0; - if (height(ll) >= height(lr)) { - return create(ll, lv, ld, create(lr, x, d, r)); - } - if (typeof lr === "object") { - return create(create(ll, lv, ld, lr._0), lr._1, lr._2, create(lr._3, x, d, r)); - } - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "inline_map_demo.res", - 47, - 19 - ], - Error: new Error() - }; - } - if (hr <= (hl + 2 | 0)) { - return { - TAG: "Node", - _0: l, - _1: x, - _2: d, - _3: r, - _4: hl >= hr ? hl + 1 | 0 : hr + 1 | 0 - }; - } - if (typeof r !== "object") { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "inline_map_demo.res", - 55, - 15 - ], - Error: new Error() - }; - } - let rr = r._3; - let rd = r._2; - let rv = r._1; - let rl = r._0; - if (height(rr) >= height(rl)) { - return create(create(l, x, d, rl), rv, rd, rr); - } - if (typeof rl === "object") { - return create(create(l, x, d, rl._0), rl._1, rl._2, create(rl._3, rv, rd, rr)); - } - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "inline_map_demo.res", - 61, - 19 - ], - Error: new Error() - }; -} - -function add(x, data, tree) { - if (typeof tree !== "object") { - return { - TAG: "Node", - _0: "Empty", - _1: x, - _2: data, - _3: "Empty", - _4: 1 - }; - } - let r = tree._3; - let d = tree._2; - let v = tree._1; - let l = tree._0; - let c = Primitive_int.compare(x, v); - if (c === 0) { - return { - TAG: "Node", - _0: l, - _1: x, - _2: data, - _3: r, - _4: tree._4 - }; - } else if (c < 0) { - return bal(add(x, data, l), v, d, r); - } else { - return bal(l, v, d, add(x, data, r)); - } -} - -let m = Belt_List.reduceReverse({ - hd: [ - 10, - /* 'a' */97 - ], - tl: { - hd: [ - 3, - /* 'b' */98 - ], - tl: { - hd: [ - 7, - /* 'c' */99 - ], - tl: { - hd: [ - 20, - /* 'd' */100 - ], - tl: /* [] */0 - } - } - } -}, "Empty", (acc, param) => add(param[0], param[1], acc)); - -function find(px, _x) { - while (true) { - let x = _x; - if (typeof x !== "object") { - throw { - RE_EXN_ID: "Not_found", - Error: new Error() - }; - } - let c = Primitive_int.compare(px, x._1); - if (c === 0) { - return x._2; - } - _x = c < 0 ? x._0 : x._3; - continue; - }; -} - -Mt.from_pair_suites("Inline_map_demo", { - hd: [ - "find", - () => ({ - TAG: "Eq", - _0: find(10, m), - _1: /* 'a' */97 - }) - ], - tl: /* [] */0 -}); - -/* m Not a pure module */ diff --git a/tests/tests/src/inline_map_demo.mjs b/tests/tests/src/inline_map_demo.mjs new file mode 100644 index 0000000000..092e289277 --- /dev/null +++ b/tests/tests/src/inline_map_demo.mjs @@ -0,0 +1,195 @@ +// Generated by ReScript, PLEASE EDIT WITH CARE + +import * as Mt from "./mt.mjs"; +import * as Belt_List from "rescript/lib/es6/Belt_List.js"; +import * as Primitive_int from "rescript/lib/es6/Primitive_int.js"; + +function height(x) { + if (typeof x !== "object") { + return 0; + } else { + return x._4; + } +} + +function create(l, x, d, r) { + let hl = height(l); + let hr = height(r); + return { + TAG: "Node", + _0: l, + _1: x, + _2: d, + _3: r, + _4: hl >= hr ? hl + 1 | 0 : hr + 1 | 0 + }; +} + +function bal(l, x, d, r) { + let hl; + hl = typeof l !== "object" ? 0 : l._4; + let hr; + hr = typeof r !== "object" ? 0 : r._4; + if (hl > (hr + 2 | 0)) { + if (typeof l !== "object") { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "inline_map_demo.res", + 41, + 15 + ], + Error: new Error() + }; + } + let lr = l._3; + let ld = l._2; + let lv = l._1; + let ll = l._0; + if (height(ll) >= height(lr)) { + return create(ll, lv, ld, create(lr, x, d, r)); + } + if (typeof lr === "object") { + return create(create(ll, lv, ld, lr._0), lr._1, lr._2, create(lr._3, x, d, r)); + } + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "inline_map_demo.res", + 47, + 19 + ], + Error: new Error() + }; + } + if (hr <= (hl + 2 | 0)) { + return { + TAG: "Node", + _0: l, + _1: x, + _2: d, + _3: r, + _4: hl >= hr ? hl + 1 | 0 : hr + 1 | 0 + }; + } + if (typeof r !== "object") { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "inline_map_demo.res", + 55, + 15 + ], + Error: new Error() + }; + } + let rr = r._3; + let rd = r._2; + let rv = r._1; + let rl = r._0; + if (height(rr) >= height(rl)) { + return create(create(l, x, d, rl), rv, rd, rr); + } + if (typeof rl === "object") { + return create(create(l, x, d, rl._0), rl._1, rl._2, create(rl._3, rv, rd, rr)); + } + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "inline_map_demo.res", + 61, + 19 + ], + Error: new Error() + }; +} + +function add(x, data, tree) { + if (typeof tree !== "object") { + return { + TAG: "Node", + _0: "Empty", + _1: x, + _2: data, + _3: "Empty", + _4: 1 + }; + } + let r = tree._3; + let d = tree._2; + let v = tree._1; + let l = tree._0; + let c = Primitive_int.compare(x, v); + if (c === 0) { + return { + TAG: "Node", + _0: l, + _1: x, + _2: data, + _3: r, + _4: tree._4 + }; + } else if (c < 0) { + return bal(add(x, data, l), v, d, r); + } else { + return bal(l, v, d, add(x, data, r)); + } +} + +let m = Belt_List.reduceReverse({ + hd: [ + 10, + /* 'a' */97 + ], + tl: { + hd: [ + 3, + /* 'b' */98 + ], + tl: { + hd: [ + 7, + /* 'c' */99 + ], + tl: { + hd: [ + 20, + /* 'd' */100 + ], + tl: /* [] */0 + } + } + } +}, "Empty", (acc, param) => add(param[0], param[1], acc)); + +function find(px, _x) { + while (true) { + let x = _x; + if (typeof x !== "object") { + throw { + RE_EXN_ID: "Not_found", + Error: new Error() + }; + } + let c = Primitive_int.compare(px, x._1); + if (c === 0) { + return x._2; + } + _x = c < 0 ? x._0 : x._3; + continue; + }; +} + +Mt.from_pair_suites("Inline_map_demo", { + hd: [ + "find", + () => ({ + TAG: "Eq", + _0: find(10, m), + _1: /* 'a' */97 + }) + ], + tl: /* [] */0 +}); + +/* m Not a pure module */ diff --git a/tests/tests/src/inline_map_test.js b/tests/tests/src/inline_map_test.js deleted file mode 100644 index d7d1420850..0000000000 --- a/tests/tests/src/inline_map_test.js +++ /dev/null @@ -1,165 +0,0 @@ -// Generated by ReScript, PLEASE EDIT WITH CARE -'use strict'; - -let Mt = require("./mt.js"); -let Belt_List = require("rescript/lib/js/Belt_List.js"); -let Pervasives = require("rescript/lib/js/Pervasives.js"); -let Primitive_int = require("rescript/lib/js/Primitive_int.js"); - -function height(x) { - if (typeof x !== "object") { - return 0; - } else { - return x._4; - } -} - -function create(l, x, d, r) { - let hl = height(l); - let hr = height(r); - return { - TAG: "Node", - _0: l, - _1: x, - _2: d, - _3: r, - _4: hl >= hr ? hl + 1 | 0 : hr + 1 | 0 - }; -} - -function bal(l, x, d, r) { - let hl; - hl = typeof l !== "object" ? 0 : l._4; - let hr; - hr = typeof r !== "object" ? 0 : r._4; - if (hl > (hr + 2 | 0)) { - if (typeof l !== "object") { - return Pervasives.invalid_arg("Map.bal"); - } - let lr = l._3; - let ld = l._2; - let lv = l._1; - let ll = l._0; - if (height(ll) >= height(lr)) { - return create(ll, lv, ld, create(lr, x, d, r)); - } else if (typeof lr !== "object") { - return Pervasives.invalid_arg("Map.bal"); - } else { - return create(create(ll, lv, ld, lr._0), lr._1, lr._2, create(lr._3, x, d, r)); - } - } - if (hr <= (hl + 2 | 0)) { - return { - TAG: "Node", - _0: l, - _1: x, - _2: d, - _3: r, - _4: hl >= hr ? hl + 1 | 0 : hr + 1 | 0 - }; - } - if (typeof r !== "object") { - return Pervasives.invalid_arg("Map.bal"); - } - let rr = r._3; - let rd = r._2; - let rv = r._1; - let rl = r._0; - if (height(rr) >= height(rl)) { - return create(create(l, x, d, rl), rv, rd, rr); - } else if (typeof rl !== "object") { - return Pervasives.invalid_arg("Map.bal"); - } else { - return create(create(l, x, d, rl._0), rl._1, rl._2, create(rl._3, rv, rd, rr)); - } -} - -function add(x, data, x_) { - if (typeof x_ !== "object") { - return { - TAG: "Node", - _0: "Empty", - _1: x, - _2: data, - _3: "Empty", - _4: 1 - }; - } - let r = x_._3; - let d = x_._2; - let v = x_._1; - let l = x_._0; - let c = Primitive_int.compare(x, v); - if (c === 0) { - return { - TAG: "Node", - _0: l, - _1: x, - _2: data, - _3: r, - _4: x_._4 - }; - } else if (c < 0) { - return bal(add(x, data, l), v, d, r); - } else { - return bal(l, v, d, add(x, data, r)); - } -} - -function find(x, _x_) { - while (true) { - let x_ = _x_; - if (typeof x_ !== "object") { - throw { - RE_EXN_ID: "Not_found", - Error: new Error() - }; - } - let c = Primitive_int.compare(x, x_._1); - if (c === 0) { - return x_._2; - } - _x_ = c < 0 ? x_._0 : x_._3; - continue; - }; -} - -let m = Belt_List.reduceReverse({ - hd: [ - 10, - /* 'a' */97 - ], - tl: { - hd: [ - 3, - /* 'b' */98 - ], - tl: { - hd: [ - 7, - /* 'c' */99 - ], - tl: { - hd: [ - 20, - /* 'd' */100 - ], - tl: /* [] */0 - } - } - } -}, "Empty", (acc, param) => add(param[0], param[1], acc)); - -Mt.from_pair_suites("Inline_map_test", { - hd: [ - "find", - () => ({ - TAG: "Eq", - _0: find(10, m), - _1: /* 'a' */97 - }) - ], - tl: /* [] */0 -}); - -/* m Not a pure module */ diff --git a/tests/tests/src/inline_map_test.mjs b/tests/tests/src/inline_map_test.mjs new file mode 100644 index 0000000000..e1f33bdd99 --- /dev/null +++ b/tests/tests/src/inline_map_test.mjs @@ -0,0 +1,164 @@ +// Generated by ReScript, PLEASE EDIT WITH CARE + +import * as Mt from "./mt.mjs"; +import * as Belt_List from "rescript/lib/es6/Belt_List.js"; +import * as Pervasives from "rescript/lib/es6/Pervasives.js"; +import * as Primitive_int from "rescript/lib/es6/Primitive_int.js"; + +function height(x) { + if (typeof x !== "object") { + return 0; + } else { + return x._4; + } +} + +function create(l, x, d, r) { + let hl = height(l); + let hr = height(r); + return { + TAG: "Node", + _0: l, + _1: x, + _2: d, + _3: r, + _4: hl >= hr ? hl + 1 | 0 : hr + 1 | 0 + }; +} + +function bal(l, x, d, r) { + let hl; + hl = typeof l !== "object" ? 0 : l._4; + let hr; + hr = typeof r !== "object" ? 0 : r._4; + if (hl > (hr + 2 | 0)) { + if (typeof l !== "object") { + return Pervasives.invalid_arg("Map.bal"); + } + let lr = l._3; + let ld = l._2; + let lv = l._1; + let ll = l._0; + if (height(ll) >= height(lr)) { + return create(ll, lv, ld, create(lr, x, d, r)); + } else if (typeof lr !== "object") { + return Pervasives.invalid_arg("Map.bal"); + } else { + return create(create(ll, lv, ld, lr._0), lr._1, lr._2, create(lr._3, x, d, r)); + } + } + if (hr <= (hl + 2 | 0)) { + return { + TAG: "Node", + _0: l, + _1: x, + _2: d, + _3: r, + _4: hl >= hr ? hl + 1 | 0 : hr + 1 | 0 + }; + } + if (typeof r !== "object") { + return Pervasives.invalid_arg("Map.bal"); + } + let rr = r._3; + let rd = r._2; + let rv = r._1; + let rl = r._0; + if (height(rr) >= height(rl)) { + return create(create(l, x, d, rl), rv, rd, rr); + } else if (typeof rl !== "object") { + return Pervasives.invalid_arg("Map.bal"); + } else { + return create(create(l, x, d, rl._0), rl._1, rl._2, create(rl._3, rv, rd, rr)); + } +} + +function add(x, data, x_) { + if (typeof x_ !== "object") { + return { + TAG: "Node", + _0: "Empty", + _1: x, + _2: data, + _3: "Empty", + _4: 1 + }; + } + let r = x_._3; + let d = x_._2; + let v = x_._1; + let l = x_._0; + let c = Primitive_int.compare(x, v); + if (c === 0) { + return { + TAG: "Node", + _0: l, + _1: x, + _2: data, + _3: r, + _4: x_._4 + }; + } else if (c < 0) { + return bal(add(x, data, l), v, d, r); + } else { + return bal(l, v, d, add(x, data, r)); + } +} + +function find(x, _x_) { + while (true) { + let x_ = _x_; + if (typeof x_ !== "object") { + throw { + RE_EXN_ID: "Not_found", + Error: new Error() + }; + } + let c = Primitive_int.compare(x, x_._1); + if (c === 0) { + return x_._2; + } + _x_ = c < 0 ? x_._0 : x_._3; + continue; + }; +} + +let m = Belt_List.reduceReverse({ + hd: [ + 10, + /* 'a' */97 + ], + tl: { + hd: [ + 3, + /* 'b' */98 + ], + tl: { + hd: [ + 7, + /* 'c' */99 + ], + tl: { + hd: [ + 20, + /* 'd' */100 + ], + tl: /* [] */0 + } + } + } +}, "Empty", (acc, param) => add(param[0], param[1], acc)); + +Mt.from_pair_suites("Inline_map_test", { + hd: [ + "find", + () => ({ + TAG: "Eq", + _0: find(10, m), + _1: /* 'a' */97 + }) + ], + tl: /* [] */0 +}); + +/* m Not a pure module */ diff --git a/tests/tests/src/inline_record_test.js b/tests/tests/src/inline_record_test.js deleted file mode 100644 index ec33568fcb..0000000000 --- a/tests/tests/src/inline_record_test.js +++ /dev/null @@ -1,241 +0,0 @@ -// Generated by ReScript, PLEASE EDIT WITH CARE -'use strict'; - -let Mt = require("./mt.js"); -let Belt_List = require("rescript/lib/js/Belt_List.js"); -let Primitive_exceptions = require("rescript/lib/js/Primitive_exceptions.js"); - -let suites = { - contents: /* [] */0 -}; - -let test_id = { - contents: 0 -}; - -function eq(loc, x, y) { - Mt.eq_suites(test_id, suites, loc, x, y); -} - -let v = { - TAG: "A0", - lbl: 3, - more: /* [] */0 -}; - -let v1 = { - TAG: "A1", - more: { - hd: 1, - tl: { - hd: 2, - tl: /* [] */0 - } - } -}; - -function f(x) { - if (x.TAG === "A0") { - return Belt_List.reduceReverse(x.more, x.lbl, (prim0, prim1) => prim0 + prim1 | 0); - } else { - return Belt_List.reduceReverse(x.more, 0, (prim0, prim1) => prim0 + prim1 | 0); - } -} - -eq("File \"inline_record_test.res\", line 19, characters 3-10", f(v), 3); - -eq("File \"inline_record_test.res\", line 20, characters 3-10", f(v1), 3); - -console.log(f(v)); - -console.log(f(v1)); - -let A0 = /* @__PURE__ */Primitive_exceptions.create("Inline_record_test.A0"); - -let v3 = { - RE_EXN_ID: A0, - lbl: 3, - more: /* [] */0 -}; - -let tmp; - -if (A0 === A0) { - tmp = 3; -} else { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "inline_record_test.res", - 47, - 9 - ], - Error: new Error() - }; -} - -eq("File \"inline_record_test.res\", line 44, characters 2-9", tmp, 3); - -function ff(x) { - if (x.TAG === "A0") { - x.x = x.x + 1 | 0; - } else { - x.z = x.z + 2 | 0; - } -} - -let v4 = { - TAG: "A0", - x: 0, - y: 0, - z: 0 -}; - -let v5 = { - TAG: "A1", - z: 0 -}; - -for (let i = 0; i <= 10; ++i) { - ff(v4); - ff(v5); -} - -let tmp$1; - -if (v4.TAG === "A0") { - tmp$1 = v4.x; -} else { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "inline_record_test.res", - 74, - 9 - ], - Error: new Error() - }; -} - -eq("File \"inline_record_test.res\", line 71, characters 2-9", tmp$1, 11); - -let tmp$2; - -if (v5.TAG === "A0") { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "inline_record_test.res", - 83, - 9 - ], - Error: new Error() - }; -} - -tmp$2 = v5.z; - -eq("File \"inline_record_test.res\", line 80, characters 2-9", tmp$2, 22); - -let A4 = /* @__PURE__ */Primitive_exceptions.create("Inline_record_test.A4"); - -let v6 = { - RE_EXN_ID: A4, - x: 0, - y: 0, - z: 0 -}; - -function ff0(x) { - if (x.RE_EXN_ID === A4) { - x.x = x.x + 1 | 0; - x.z = x.z + 1 | 0; - return; - } - -} - -for (let i$1 = 0; i$1 <= 10; ++i$1) { - ff0(v6); -} - -let tmp$3; - -if (v6.RE_EXN_ID === A4) { - tmp$3 = v6.x; -} else { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "inline_record_test.res", - 108, - 9 - ], - Error: new Error() - }; -} - -eq("File \"inline_record_test.res\", line 105, characters 2-9", tmp$3, 11); - -function ff1(x) { - if (typeof x !== "object") { - return "A1"; - } else { - return { - TAG: "A0", - lbl: x.lbl + 1 | 0, - more: x.more - }; - } -} - -Mt.from_pair_suites("Inline_record_test", suites.contents); - -let b = { - TAG: "B" -}; - -if (typeof b !== "object") { - console.log("A!"); -} else { - console.log("B"); -} - -console.log("10!"); - -let v2 = { - TAG: "A0", - lbl: 3, - more: /* [] */0 -}; - -let vvv = { - TAG: "A0", - lbl: 3, - more: /* [] */0 -}; - -let r = { - y: 10 -}; - -exports.suites = suites; -exports.test_id = test_id; -exports.eq = eq; -exports.v = v; -exports.v1 = v1; -exports.f = f; -exports.v2 = v2; -exports.A0 = A0; -exports.v3 = v3; -exports.vvv = vvv; -exports.ff = ff; -exports.v4 = v4; -exports.v5 = v5; -exports.A4 = A4; -exports.v6 = v6; -exports.ff0 = ff0; -exports.ff1 = ff1; -exports.b = b; -exports.r = r; -/* Not a pure module */ diff --git a/tests/tests/src/inline_record_test.mjs b/tests/tests/src/inline_record_test.mjs new file mode 100644 index 0000000000..a09d054b4f --- /dev/null +++ b/tests/tests/src/inline_record_test.mjs @@ -0,0 +1,242 @@ +// Generated by ReScript, PLEASE EDIT WITH CARE + +import * as Mt from "./mt.mjs"; +import * as Belt_List from "rescript/lib/es6/Belt_List.js"; +import * as Primitive_exceptions from "rescript/lib/es6/Primitive_exceptions.js"; + +let suites = { + contents: /* [] */0 +}; + +let test_id = { + contents: 0 +}; + +function eq(loc, x, y) { + Mt.eq_suites(test_id, suites, loc, x, y); +} + +let v = { + TAG: "A0", + lbl: 3, + more: /* [] */0 +}; + +let v1 = { + TAG: "A1", + more: { + hd: 1, + tl: { + hd: 2, + tl: /* [] */0 + } + } +}; + +function f(x) { + if (x.TAG === "A0") { + return Belt_List.reduceReverse(x.more, x.lbl, (prim0, prim1) => prim0 + prim1 | 0); + } else { + return Belt_List.reduceReverse(x.more, 0, (prim0, prim1) => prim0 + prim1 | 0); + } +} + +eq("File \"inline_record_test.res\", line 19, characters 3-10", f(v), 3); + +eq("File \"inline_record_test.res\", line 20, characters 3-10", f(v1), 3); + +console.log(f(v)); + +console.log(f(v1)); + +let A0 = /* @__PURE__ */Primitive_exceptions.create("Inline_record_test.A0"); + +let v3 = { + RE_EXN_ID: A0, + lbl: 3, + more: /* [] */0 +}; + +let tmp; + +if (A0 === A0) { + tmp = 3; +} else { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "inline_record_test.res", + 47, + 9 + ], + Error: new Error() + }; +} + +eq("File \"inline_record_test.res\", line 44, characters 2-9", tmp, 3); + +function ff(x) { + if (x.TAG === "A0") { + x.x = x.x + 1 | 0; + } else { + x.z = x.z + 2 | 0; + } +} + +let v4 = { + TAG: "A0", + x: 0, + y: 0, + z: 0 +}; + +let v5 = { + TAG: "A1", + z: 0 +}; + +for (let i = 0; i <= 10; ++i) { + ff(v4); + ff(v5); +} + +let tmp$1; + +if (v4.TAG === "A0") { + tmp$1 = v4.x; +} else { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "inline_record_test.res", + 74, + 9 + ], + Error: new Error() + }; +} + +eq("File \"inline_record_test.res\", line 71, characters 2-9", tmp$1, 11); + +let tmp$2; + +if (v5.TAG === "A0") { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "inline_record_test.res", + 83, + 9 + ], + Error: new Error() + }; +} + +tmp$2 = v5.z; + +eq("File \"inline_record_test.res\", line 80, characters 2-9", tmp$2, 22); + +let A4 = /* @__PURE__ */Primitive_exceptions.create("Inline_record_test.A4"); + +let v6 = { + RE_EXN_ID: A4, + x: 0, + y: 0, + z: 0 +}; + +function ff0(x) { + if (x.RE_EXN_ID === A4) { + x.x = x.x + 1 | 0; + x.z = x.z + 1 | 0; + return; + } + +} + +for (let i$1 = 0; i$1 <= 10; ++i$1) { + ff0(v6); +} + +let tmp$3; + +if (v6.RE_EXN_ID === A4) { + tmp$3 = v6.x; +} else { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "inline_record_test.res", + 108, + 9 + ], + Error: new Error() + }; +} + +eq("File \"inline_record_test.res\", line 105, characters 2-9", tmp$3, 11); + +function ff1(x) { + if (typeof x !== "object") { + return "A1"; + } else { + return { + TAG: "A0", + lbl: x.lbl + 1 | 0, + more: x.more + }; + } +} + +Mt.from_pair_suites("Inline_record_test", suites.contents); + +let b = { + TAG: "B" +}; + +if (typeof b !== "object") { + console.log("A!"); +} else { + console.log("B"); +} + +console.log("10!"); + +let v2 = { + TAG: "A0", + lbl: 3, + more: /* [] */0 +}; + +let vvv = { + TAG: "A0", + lbl: 3, + more: /* [] */0 +}; + +let r = { + y: 10 +}; + +export { + suites, + test_id, + eq, + v, + v1, + f, + v2, + A0, + v3, + vvv, + ff, + v4, + v5, + A4, + v6, + ff0, + ff1, + b, + r, +} +/* Not a pure module */ diff --git a/tests/tests/src/inline_regression_test.js b/tests/tests/src/inline_regression_test.js deleted file mode 100644 index ca32d92e24..0000000000 --- a/tests/tests/src/inline_regression_test.js +++ /dev/null @@ -1,63 +0,0 @@ -// Generated by ReScript, PLEASE EDIT WITH CARE -'use strict'; - -let Mt = require("./mt.js"); - -function generic_basename(is_dir_sep, current_dir_name, name) { - if (name === "") { - return current_dir_name; - } else { - let _n = name.length - 1 | 0; - while (true) { - let n = _n; - if (n < 0) { - return name.substr(0, 1); - } - if (!is_dir_sep(name, n)) { - let _n$1 = n; - let p = n + 1 | 0; - while (true) { - let n$1 = _n$1; - if (n$1 < 0) { - return name.substr(0, p); - } - if (is_dir_sep(name, n$1)) { - return name.substr(n$1 + 1 | 0, (p - n$1 | 0) - 1 | 0); - } - _n$1 = n$1 - 1 | 0; - continue; - }; - } - _n = n - 1 | 0; - continue; - }; - } -} - -function basename(extra) { - return generic_basename((s, i) => s.codePointAt(i) === /* '/' */47, "", extra); -} - -let suites_0 = [ - "basename", - param => ({ - TAG: "Eq", - _0: basename("b/c/a.b"), - _1: "a.b" - }) -]; - -let suites = { - hd: suites_0, - tl: /* [] */0 -}; - -Mt.from_pair_suites("Inline_regression_test", suites); - -let $$String; - -exports.$$String = $$String; -exports.generic_basename = generic_basename; -exports.basename = basename; -exports.suites = suites; -/* Not a pure module */ diff --git a/tests/tests/src/inline_regression_test.mjs b/tests/tests/src/inline_regression_test.mjs new file mode 100644 index 0000000000..334eccca8b --- /dev/null +++ b/tests/tests/src/inline_regression_test.mjs @@ -0,0 +1,64 @@ +// Generated by ReScript, PLEASE EDIT WITH CARE + +import * as Mt from "./mt.mjs"; + +function generic_basename(is_dir_sep, current_dir_name, name) { + if (name === "") { + return current_dir_name; + } else { + let _n = name.length - 1 | 0; + while (true) { + let n = _n; + if (n < 0) { + return name.substr(0, 1); + } + if (!is_dir_sep(name, n)) { + let _n$1 = n; + let p = n + 1 | 0; + while (true) { + let n$1 = _n$1; + if (n$1 < 0) { + return name.substr(0, p); + } + if (is_dir_sep(name, n$1)) { + return name.substr(n$1 + 1 | 0, (p - n$1 | 0) - 1 | 0); + } + _n$1 = n$1 - 1 | 0; + continue; + }; + } + _n = n - 1 | 0; + continue; + }; + } +} + +function basename(extra) { + return generic_basename((s, i) => s.codePointAt(i) === /* '/' */47, "", extra); +} + +let suites_0 = [ + "basename", + param => ({ + TAG: "Eq", + _0: basename("b/c/a.b"), + _1: "a.b" + }) +]; + +let suites = { + hd: suites_0, + tl: /* [] */0 +}; + +Mt.from_pair_suites("Inline_regression_test", suites); + +let $$String; + +export { + $$String, + generic_basename, + basename, + suites, +} +/* Not a pure module */ diff --git a/tests/tests/src/inline_string_test.js b/tests/tests/src/inline_string_test.js deleted file mode 100644 index c81d1e60ac..0000000000 --- a/tests/tests/src/inline_string_test.js +++ /dev/null @@ -1,28 +0,0 @@ -// Generated by ReScript, PLEASE EDIT WITH CARE -'use strict'; - - -console.log("list"); - -console.log("list"); - -function f(x) { - if (x !== undefined) { - return "Some"; - } else { - return "None"; - } -} - -console.log([ - f(3), - "None", - "Some" -]); - -console.log([ - "A", - "A" -]); - -/* Not a pure module */ diff --git a/tests/tests/src/inline_string_test.mjs b/tests/tests/src/inline_string_test.mjs new file mode 100644 index 0000000000..c36fe82076 --- /dev/null +++ b/tests/tests/src/inline_string_test.mjs @@ -0,0 +1,27 @@ +// Generated by ReScript, PLEASE EDIT WITH CARE + + +console.log("list"); + +console.log("list"); + +function f(x) { + if (x !== undefined) { + return "Some"; + } else { + return "None"; + } +} + +console.log([ + f(3), + "None", + "Some" +]); + +console.log([ + "A", + "A" +]); + +/* Not a pure module */ diff --git a/tests/tests/src/inner_call.js b/tests/tests/src/inner_call.js deleted file mode 100644 index 0c024ff4b5..0000000000 --- a/tests/tests/src/inner_call.js +++ /dev/null @@ -1,18 +0,0 @@ -// Generated by ReScript, PLEASE EDIT WITH CARE -'use strict'; - -let Inner_define = require("./inner_define.js"); - -console.log(Inner_define.N.add(1, 2)); - -function f(x) { - return [ - Inner_define.N0.f1(x), - Inner_define.N0.f2(x, x), - Inner_define.N0.f3(x, x, x), - Inner_define.N1.f2(x, x) - ]; -} - -exports.f = f; -/* Not a pure module */ diff --git a/tests/tests/src/inner_call.mjs b/tests/tests/src/inner_call.mjs new file mode 100644 index 0000000000..97d10f4a59 --- /dev/null +++ b/tests/tests/src/inner_call.mjs @@ -0,0 +1,19 @@ +// Generated by ReScript, PLEASE EDIT WITH CARE + +import * as Inner_define from "./inner_define.mjs"; + +console.log(Inner_define.N.add(1, 2)); + +function f(x) { + return [ + Inner_define.N0.f1(x), + Inner_define.N0.f2(x, x), + Inner_define.N0.f3(x, x, x), + Inner_define.N1.f2(x, x) + ]; +} + +export { + f, +} +/* Not a pure module */ diff --git a/tests/tests/src/inner_define.js b/tests/tests/src/inner_define.js deleted file mode 100644 index adf0620cb6..0000000000 --- a/tests/tests/src/inner_define.js +++ /dev/null @@ -1,47 +0,0 @@ -// Generated by ReScript, PLEASE EDIT WITH CARE -'use strict'; - - -function add(x, y) { - return x + y | 0; -} - -let N = { - add: add -}; - -function f1(param) { - -} - -function f2(param, param$1) { - -} - -function f3(param, param$1, param$2) { - -} - -let N0 = { - f1: f1, - f2: f2, - f3: f3 -}; - -function f2$1(param, param$1) { - -} - -function f3$1(param, param$1, param$2) { - -} - -let N1 = { - f2: f2$1, - f3: f3$1 -}; - -exports.N = N; -exports.N0 = N0; -exports.N1 = N1; -/* No side effect */ diff --git a/tests/tests/src/inner_define.mjs b/tests/tests/src/inner_define.mjs new file mode 100644 index 0000000000..91367037f0 --- /dev/null +++ b/tests/tests/src/inner_define.mjs @@ -0,0 +1,48 @@ +// Generated by ReScript, PLEASE EDIT WITH CARE + + +function add(x, y) { + return x + y | 0; +} + +let N = { + add: add +}; + +function f1(param) { + +} + +function f2(param, param$1) { + +} + +function f3(param, param$1, param$2) { + +} + +let N0 = { + f1: f1, + f2: f2, + f3: f3 +}; + +function f2$1(param, param$1) { + +} + +function f3$1(param, param$1, param$2) { + +} + +let N1 = { + f2: f2$1, + f3: f3$1 +}; + +export { + N, + N0, + N1, +} +/* No side effect */ diff --git a/tests/tests/src/inner_unused.js b/tests/tests/src/inner_unused.js deleted file mode 100644 index b938658dc5..0000000000 --- a/tests/tests/src/inner_unused.js +++ /dev/null @@ -1,23 +0,0 @@ -// Generated by ReScript, PLEASE EDIT WITH CARE -'use strict'; - - -function f(x) { - return x + 3 | 0; -} - -function M(Id) { - let f = x => x; - return { - f: f - }; -} - -function fff(param, param$1) { - return 3; -} - -exports.f = f; -exports.M = M; -exports.fff = fff; -/* No side effect */ diff --git a/tests/tests/src/inner_unused.mjs b/tests/tests/src/inner_unused.mjs new file mode 100644 index 0000000000..ec09ffe4eb --- /dev/null +++ b/tests/tests/src/inner_unused.mjs @@ -0,0 +1,24 @@ +// Generated by ReScript, PLEASE EDIT WITH CARE + + +function f(x) { + return x + 3 | 0; +} + +function M(Id) { + let f = x => x; + return { + f: f + }; +} + +function fff(param, param$1) { + return 3; +} + +export { + f, + M, + fff, +} +/* No side effect */ diff --git a/tests/tests/src/installation_test.js b/tests/tests/src/installation_test.js deleted file mode 100644 index 17e63f6ae5..0000000000 --- a/tests/tests/src/installation_test.js +++ /dev/null @@ -1,34 +0,0 @@ -// Generated by ReScript, PLEASE EDIT WITH CARE -'use strict'; - -let Mt = require("./mt.js"); - -let suites = { - contents: /* [] */0 -}; - -let test_id = { - contents: 0 -}; - -function eq(loc, x, y) { - test_id.contents = test_id.contents + 1 | 0; - suites.contents = { - hd: [ - loc + (" id " + test_id.contents.toString()), - () => ({ - TAG: "Eq", - _0: x, - _1: y - }) - ], - tl: suites.contents - }; -} - -Mt.from_pair_suites("Installation_test", suites.contents); - -exports.suites = suites; -exports.test_id = test_id; -exports.eq = eq; -/* Not a pure module */ diff --git a/tests/tests/src/installation_test.mjs b/tests/tests/src/installation_test.mjs new file mode 100644 index 0000000000..b6ea863332 --- /dev/null +++ b/tests/tests/src/installation_test.mjs @@ -0,0 +1,35 @@ +// Generated by ReScript, PLEASE EDIT WITH CARE + +import * as Mt from "./mt.mjs"; + +let suites = { + contents: /* [] */0 +}; + +let test_id = { + contents: 0 +}; + +function eq(loc, x, y) { + test_id.contents = test_id.contents + 1 | 0; + suites.contents = { + hd: [ + loc + (" id " + test_id.contents.toString()), + () => ({ + TAG: "Eq", + _0: x, + _1: y + }) + ], + tl: suites.contents + }; +} + +Mt.from_pair_suites("Installation_test", suites.contents); + +export { + suites, + test_id, + eq, +} +/* Not a pure module */ diff --git a/tests/tests/src/int_map.js b/tests/tests/src/int_map.js deleted file mode 100644 index f83e958ae5..0000000000 --- a/tests/tests/src/int_map.js +++ /dev/null @@ -1,20 +0,0 @@ -// Generated by ReScript, PLEASE EDIT WITH CARE -'use strict'; - -let Belt_Id = require("rescript/lib/js/Belt_Id.js"); -let Belt_Map = require("rescript/lib/js/Belt_Map.js"); -let Primitive_object = require("rescript/lib/js/Primitive_object.js"); - -let cmp = Primitive_object.compare; - -let IntCmp = Belt_Id.MakeComparable({ - cmp: cmp -}); - -let m = Belt_Map.make(IntCmp); - -let m$1 = Belt_Map.set(m, 0, "test"); - -exports.IntCmp = IntCmp; -exports.m = m$1; -/* IntCmp Not a pure module */ diff --git a/tests/tests/src/int_map.mjs b/tests/tests/src/int_map.mjs new file mode 100644 index 0000000000..3a25527bc5 --- /dev/null +++ b/tests/tests/src/int_map.mjs @@ -0,0 +1,21 @@ +// Generated by ReScript, PLEASE EDIT WITH CARE + +import * as Belt_Id from "rescript/lib/es6/Belt_Id.js"; +import * as Belt_Map from "rescript/lib/es6/Belt_Map.js"; +import * as Primitive_object from "rescript/lib/es6/Primitive_object.js"; + +let cmp = Primitive_object.compare; + +let IntCmp = Belt_Id.MakeComparable({ + cmp: cmp +}); + +let m = Belt_Map.make(IntCmp); + +let m$1 = Belt_Map.set(m, 0, "test"); + +export { + IntCmp, + m$1 as m, +} +/* IntCmp Not a pure module */ diff --git a/tests/tests/src/int_overflow_test.js b/tests/tests/src/int_overflow_test.js deleted file mode 100644 index b484e987bd..0000000000 --- a/tests/tests/src/int_overflow_test.js +++ /dev/null @@ -1,173 +0,0 @@ -// Generated by ReScript, PLEASE EDIT WITH CARE -'use strict'; - -let Mt = require("./mt.js"); - -function hash_variant(s) { - let accu = 0; - for (let i = 0, i_finish = s.length; i < i_finish; ++i) { - accu = Math.imul(223, accu) + s.codePointAt(i) & 2147483647; - } - if (accu > 1073741823) { - return accu - -2147483648 | 0; - } else { - return accu; - } -} - -function hash_variant2(s) { - let accu = 0; - for (let i = 0, i_finish = s.length; i < i_finish; ++i) { - accu = Math.imul(223, accu) + s.codePointAt(i) | 0; - } - accu = accu & 2147483647; - if (accu > 1073741823) { - return accu - -2147483648 | 0; - } else { - return accu; - } -} - -function fib(x) { - if (x === 0 || x === 1) { - return 1; - } else { - return fib(x - 1 | 0) + fib(x - 2 | 0) | 0; - } -} - -Mt.from_pair_suites("Int_overflow_test", { - hd: [ - "plus_overflow", - () => ({ - TAG: "Eq", - _0: true, - _1: true - }) - ], - tl: { - hd: [ - "minus_overflow", - () => ({ - TAG: "Eq", - _0: true, - _1: true - }) - ], - tl: { - hd: [ - "flow_again", - () => ({ - TAG: "Eq", - _0: 2147483646, - _1: 2147483646 - }) - ], - tl: { - hd: [ - "flow_again", - () => ({ - TAG: "Eq", - _0: -2, - _1: -2 - }) - ], - tl: { - hd: [ - "hash_test", - () => ({ - TAG: "Eq", - _0: hash_variant("xxyyzzuuxxzzyy00112233"), - _1: 544087776 - }) - ], - tl: { - hd: [ - "hash_test2", - () => ({ - TAG: "Eq", - _0: hash_variant("xxyyzxzzyy"), - _1: -449896130 - }) - ], - tl: { - hd: [ - "File \"int_overflow_test.res\", line 74, characters 5-12", - () => ({ - TAG: "Eq", - _0: hash_variant2("xxyyzzuuxxzzyy00112233"), - _1: 544087776 - }) - ], - tl: { - hd: [ - "File \"int_overflow_test.res\", line 75, characters 5-12", - () => ({ - TAG: "Eq", - _0: hash_variant2("xxyyzxzzyy"), - _1: -449896130 - }) - ], - tl: { - hd: [ - "int_literal_flow", - () => ({ - TAG: "Eq", - _0: -1, - _1: -1 - }) - ], - tl: { - hd: [ - "int_literal_flow2", - () => ({ - TAG: "Eq", - _0: -1, - _1: -1 - }) - ], - tl: { - hd: [ - "File \"int_overflow_test.res\", line 78, characters 5-12", - () => ({ - TAG: "Eq", - _0: Number("3") | 0, - _1: 3 - }) - ], - tl: { - hd: [ - "File \"int_overflow_test.res\", line 80, characters 5-12", - () => ({ - TAG: "Eq", - _0: Number("3.2") | 0, - _1: 3 - }) - ], - tl: /* [] */0 - } - } - } - } - } - } - } - } - } - } - } -}); - -let $$String; - -let max_int = 2147483647; - -let min_int = -2147483648; - -exports.$$String = $$String; -exports.max_int = max_int; -exports.min_int = min_int; -exports.hash_variant = hash_variant; -exports.hash_variant2 = hash_variant2; -exports.fib = fib; -/* Not a pure module */ diff --git a/tests/tests/src/int_overflow_test.mjs b/tests/tests/src/int_overflow_test.mjs new file mode 100644 index 0000000000..8f44d3aae1 --- /dev/null +++ b/tests/tests/src/int_overflow_test.mjs @@ -0,0 +1,174 @@ +// Generated by ReScript, PLEASE EDIT WITH CARE + +import * as Mt from "./mt.mjs"; + +function hash_variant(s) { + let accu = 0; + for (let i = 0, i_finish = s.length; i < i_finish; ++i) { + accu = Math.imul(223, accu) + s.codePointAt(i) & 2147483647; + } + if (accu > 1073741823) { + return accu - -2147483648 | 0; + } else { + return accu; + } +} + +function hash_variant2(s) { + let accu = 0; + for (let i = 0, i_finish = s.length; i < i_finish; ++i) { + accu = Math.imul(223, accu) + s.codePointAt(i) | 0; + } + accu = accu & 2147483647; + if (accu > 1073741823) { + return accu - -2147483648 | 0; + } else { + return accu; + } +} + +function fib(x) { + if (x === 0 || x === 1) { + return 1; + } else { + return fib(x - 1 | 0) + fib(x - 2 | 0) | 0; + } +} + +Mt.from_pair_suites("Int_overflow_test", { + hd: [ + "plus_overflow", + () => ({ + TAG: "Eq", + _0: true, + _1: true + }) + ], + tl: { + hd: [ + "minus_overflow", + () => ({ + TAG: "Eq", + _0: true, + _1: true + }) + ], + tl: { + hd: [ + "flow_again", + () => ({ + TAG: "Eq", + _0: 2147483646, + _1: 2147483646 + }) + ], + tl: { + hd: [ + "flow_again", + () => ({ + TAG: "Eq", + _0: -2, + _1: -2 + }) + ], + tl: { + hd: [ + "hash_test", + () => ({ + TAG: "Eq", + _0: hash_variant("xxyyzzuuxxzzyy00112233"), + _1: 544087776 + }) + ], + tl: { + hd: [ + "hash_test2", + () => ({ + TAG: "Eq", + _0: hash_variant("xxyyzxzzyy"), + _1: -449896130 + }) + ], + tl: { + hd: [ + "File \"int_overflow_test.res\", line 74, characters 5-12", + () => ({ + TAG: "Eq", + _0: hash_variant2("xxyyzzuuxxzzyy00112233"), + _1: 544087776 + }) + ], + tl: { + hd: [ + "File \"int_overflow_test.res\", line 75, characters 5-12", + () => ({ + TAG: "Eq", + _0: hash_variant2("xxyyzxzzyy"), + _1: -449896130 + }) + ], + tl: { + hd: [ + "int_literal_flow", + () => ({ + TAG: "Eq", + _0: -1, + _1: -1 + }) + ], + tl: { + hd: [ + "int_literal_flow2", + () => ({ + TAG: "Eq", + _0: -1, + _1: -1 + }) + ], + tl: { + hd: [ + "File \"int_overflow_test.res\", line 78, characters 5-12", + () => ({ + TAG: "Eq", + _0: Number("3") | 0, + _1: 3 + }) + ], + tl: { + hd: [ + "File \"int_overflow_test.res\", line 80, characters 5-12", + () => ({ + TAG: "Eq", + _0: Number("3.2") | 0, + _1: 3 + }) + ], + tl: /* [] */0 + } + } + } + } + } + } + } + } + } + } + } +}); + +let $$String; + +let max_int = 2147483647; + +let min_int = -2147483648; + +export { + $$String, + max_int, + min_int, + hash_variant, + hash_variant2, + fib, +} +/* Not a pure module */ diff --git a/tests/tests/src/int_poly_var.js b/tests/tests/src/int_poly_var.js deleted file mode 100644 index 2b8b98f150..0000000000 --- a/tests/tests/src/int_poly_var.js +++ /dev/null @@ -1,199 +0,0 @@ -// Generated by ReScript, PLEASE EDIT WITH CARE -'use strict'; - -let Mt = require("./mt.js"); - -let test_id = { - contents: 0 -}; - -let suites = { - contents: /* [] */0 -}; - -function nest(x) { - if (x.TAG === "A") { - let match = x._0; - if (match === 0) { - return 0; - } else if (match === 1) { - return 1; - } else { - return 2; - } - } - let match$1 = x._0; - if (x._1 !== 0) { - if (match$1 === 1) { - return 4; - } else if (match$1 === 2) { - return 5; - } else { - return 6; - } - } else { - return 3; - } -} - -function f2(x, b) { - if (x === 1) { - return b; - } else if (x === 2) { - return 0; - } else if (x === "c") { - return 33; - } else { - return 3; - } -} - -function f3(x, b) { - if (typeof x !== "object") { - return 3; - } - let variant = x.NAME; - if (variant === 32) { - return x.VAL[0]; - } else if (variant === 333) { - return x.VAL[1]; - } else { - return x.VAL; - } -} - -function h(x) { - return x === 0; -} - -let g = /* 'b' */98; - -let hihi = f3(3, 0); - -let hh10 = "3" === 3; - -let tuple_0 = nest({ - TAG: "A", - _0: 0 -}); - -let tuple_1 = nest({ - TAG: "A", - _0: 1 -}); - -let tuple_2 = nest({ - TAG: "A", - _0: 2 -}); - -let tuple_3 = nest({ - TAG: "B", - _0: 1, - _1: 0 -}); - -let tuple_4 = nest({ - TAG: "B", - _0: 1, - _1: 1 -}); - -let tuple_5 = nest({ - TAG: "B", - _0: 2, - _1: 1 -}); - -let tuple_6 = nest({ - TAG: "B", - _0: 2, - _1: 2 -}); - -let tuple_7 = nest({ - TAG: "B", - _0: 0, - _1: 0 -}); - -let tuple_8 = nest({ - TAG: "B", - _0: 0, - _1: 1 -}); - -let tuple = [ - tuple_0, - tuple_1, - tuple_2, - tuple_3, - tuple_4, - tuple_5, - tuple_6, - tuple_7, - tuple_8, - true, - hh10 -]; - -Mt.eq_suites(test_id, suites, "File \"int_poly_var.res\", line 79, characters 29-36", hihi, 3); - -Mt.eq_suites(test_id, suites, "File \"int_poly_var.res\", line 80, characters 29-36", tuple, [ - 0, - 1, - 2, - 3, - 4, - 5, - 5, - 3, - 6, - true, - false -]); - -function hh0(x) { - return x; -} - -function hh1(x) { - return x; -} - -function f(x) { - if (x.NAME === 1) { - return x.VAL; - } else { - return x.VAL.toString(); - } -} - -Mt.from_pair_suites("int_poly_var.res", suites.contents); - -let eq_suites = Mt.eq_suites; - -let u = 1; - -let hh9 = true; - -let begin = 3; - -exports.eq_suites = eq_suites; -exports.test_id = test_id; -exports.suites = suites; -exports.u = u; -exports.nest = nest; -exports.f2 = f2; -exports.f3 = f3; -exports.h = h; -exports.g = g; -exports.hihi = hihi; -exports.hh9 = hh9; -exports.hh10 = hh10; -exports.tuple = tuple; -exports.begin = begin; -exports.hh0 = hh0; -exports.hh1 = hh1; -exports.f = f; -/* hihi Not a pure module */ diff --git a/tests/tests/src/int_poly_var.mjs b/tests/tests/src/int_poly_var.mjs new file mode 100644 index 0000000000..0311dd926c --- /dev/null +++ b/tests/tests/src/int_poly_var.mjs @@ -0,0 +1,200 @@ +// Generated by ReScript, PLEASE EDIT WITH CARE + +import * as Mt from "./mt.mjs"; + +let test_id = { + contents: 0 +}; + +let suites = { + contents: /* [] */0 +}; + +function nest(x) { + if (x.TAG === "A") { + let match = x._0; + if (match === 0) { + return 0; + } else if (match === 1) { + return 1; + } else { + return 2; + } + } + let match$1 = x._0; + if (x._1 !== 0) { + if (match$1 === 1) { + return 4; + } else if (match$1 === 2) { + return 5; + } else { + return 6; + } + } else { + return 3; + } +} + +function f2(x, b) { + if (x === 1) { + return b; + } else if (x === 2) { + return 0; + } else if (x === "c") { + return 33; + } else { + return 3; + } +} + +function f3(x, b) { + if (typeof x !== "object") { + return 3; + } + let variant = x.NAME; + if (variant === 32) { + return x.VAL[0]; + } else if (variant === 333) { + return x.VAL[1]; + } else { + return x.VAL; + } +} + +function h(x) { + return x === 0; +} + +let g = /* 'b' */98; + +let hihi = f3(3, 0); + +let hh10 = "3" === 3; + +let tuple_0 = nest({ + TAG: "A", + _0: 0 +}); + +let tuple_1 = nest({ + TAG: "A", + _0: 1 +}); + +let tuple_2 = nest({ + TAG: "A", + _0: 2 +}); + +let tuple_3 = nest({ + TAG: "B", + _0: 1, + _1: 0 +}); + +let tuple_4 = nest({ + TAG: "B", + _0: 1, + _1: 1 +}); + +let tuple_5 = nest({ + TAG: "B", + _0: 2, + _1: 1 +}); + +let tuple_6 = nest({ + TAG: "B", + _0: 2, + _1: 2 +}); + +let tuple_7 = nest({ + TAG: "B", + _0: 0, + _1: 0 +}); + +let tuple_8 = nest({ + TAG: "B", + _0: 0, + _1: 1 +}); + +let tuple = [ + tuple_0, + tuple_1, + tuple_2, + tuple_3, + tuple_4, + tuple_5, + tuple_6, + tuple_7, + tuple_8, + true, + hh10 +]; + +Mt.eq_suites(test_id, suites, "File \"int_poly_var.res\", line 79, characters 29-36", hihi, 3); + +Mt.eq_suites(test_id, suites, "File \"int_poly_var.res\", line 80, characters 29-36", tuple, [ + 0, + 1, + 2, + 3, + 4, + 5, + 5, + 3, + 6, + true, + false +]); + +function hh0(x) { + return x; +} + +function hh1(x) { + return x; +} + +function f(x) { + if (x.NAME === 1) { + return x.VAL; + } else { + return x.VAL.toString(); + } +} + +Mt.from_pair_suites("int_poly_var.res", suites.contents); + +let eq_suites = Mt.eq_suites; + +let u = 1; + +let hh9 = true; + +let begin = 3; + +export { + eq_suites, + test_id, + suites, + u, + nest, + f2, + f3, + h, + g, + hihi, + hh9, + hh10, + tuple, + begin, + hh0, + hh1, + f, +} +/* hihi Not a pure module */ diff --git a/tests/tests/src/int_switch_test.js b/tests/tests/src/int_switch_test.js deleted file mode 100644 index 54e513b7bf..0000000000 --- a/tests/tests/src/int_switch_test.js +++ /dev/null @@ -1,83 +0,0 @@ -// Generated by ReScript, PLEASE EDIT WITH CARE -'use strict'; - -let Mt = require("./mt.js"); - -let suites = { - contents: /* [] */0 -}; - -let test_id = { - contents: 0 -}; - -function eq(loc, x, y) { - Mt.eq_suites(test_id, suites, loc, x, y); -} - -function b(loc, x) { - Mt.bool_suites(test_id, suites, loc, x); -} - -function f(x) { - let match = x(); - switch (match) { - case 1 : - return /* 'a' */97; - case 2 : - return /* 'b' */98; - case 3 : - return /* 'c' */99; - default: - return /* 'x' */120; - } -} - -function f22(x) { - let match = x(); - switch (match) { - case 1 : - return /* 'a' */97; - case 2 : - return /* 'b' */98; - case 3 : - return /* 'c' */99; - default: - return /* 'x' */120; - } -} - -function f33(x) { - let match = x(); - switch (match) { - case "A" : - return /* 'a' */97; - case "B" : - return /* 'b' */98; - case "C" : - return /* 'c' */99; - case "D" : - return /* 'x' */120; - } -} - -eq("File \"int_switch_test.res\", line 32, characters 3-10", f(() => 1), /* 'a' */97); - -eq("File \"int_switch_test.res\", line 33, characters 3-10", f(() => 2), /* 'b' */98); - -eq("File \"int_switch_test.res\", line 34, characters 3-10", f(() => 3), /* 'c' */99); - -eq("File \"int_switch_test.res\", line 35, characters 3-10", f(() => 0), /* 'x' */120); - -eq("File \"int_switch_test.res\", line 36, characters 3-10", f(() => -1), /* 'x' */120); - -Mt.from_pair_suites("Int_switch_test", suites.contents); - -exports.suites = suites; -exports.test_id = test_id; -exports.eq = eq; -exports.b = b; -exports.f = f; -exports.f22 = f22; -exports.f33 = f33; -/* Not a pure module */ diff --git a/tests/tests/src/int_switch_test.mjs b/tests/tests/src/int_switch_test.mjs new file mode 100644 index 0000000000..73a1f8a314 --- /dev/null +++ b/tests/tests/src/int_switch_test.mjs @@ -0,0 +1,84 @@ +// Generated by ReScript, PLEASE EDIT WITH CARE + +import * as Mt from "./mt.mjs"; + +let suites = { + contents: /* [] */0 +}; + +let test_id = { + contents: 0 +}; + +function eq(loc, x, y) { + Mt.eq_suites(test_id, suites, loc, x, y); +} + +function b(loc, x) { + Mt.bool_suites(test_id, suites, loc, x); +} + +function f(x) { + let match = x(); + switch (match) { + case 1 : + return /* 'a' */97; + case 2 : + return /* 'b' */98; + case 3 : + return /* 'c' */99; + default: + return /* 'x' */120; + } +} + +function f22(x) { + let match = x(); + switch (match) { + case 1 : + return /* 'a' */97; + case 2 : + return /* 'b' */98; + case 3 : + return /* 'c' */99; + default: + return /* 'x' */120; + } +} + +function f33(x) { + let match = x(); + switch (match) { + case "A" : + return /* 'a' */97; + case "B" : + return /* 'b' */98; + case "C" : + return /* 'c' */99; + case "D" : + return /* 'x' */120; + } +} + +eq("File \"int_switch_test.res\", line 32, characters 3-10", f(() => 1), /* 'a' */97); + +eq("File \"int_switch_test.res\", line 33, characters 3-10", f(() => 2), /* 'b' */98); + +eq("File \"int_switch_test.res\", line 34, characters 3-10", f(() => 3), /* 'c' */99); + +eq("File \"int_switch_test.res\", line 35, characters 3-10", f(() => 0), /* 'x' */120); + +eq("File \"int_switch_test.res\", line 36, characters 3-10", f(() => -1), /* 'x' */120); + +Mt.from_pair_suites("Int_switch_test", suites.contents); + +export { + suites, + test_id, + eq, + b, + f, + f22, + f33, +} +/* Not a pure module */ diff --git a/tests/tests/src/internal_unused_test.js b/tests/tests/src/internal_unused_test.js deleted file mode 100644 index f5779acf9b..0000000000 --- a/tests/tests/src/internal_unused_test.js +++ /dev/null @@ -1,48 +0,0 @@ -// Generated by ReScript, PLEASE EDIT WITH CARE -'use strict'; - -let Primitive_exceptions = require("rescript/lib/js/Primitive_exceptions.js"); - -console.log(3); - -let A = /* @__PURE__ */Primitive_exceptions.create("Internal_unused_test.P1.A"); - -function f() { - throw { - RE_EXN_ID: A, - Error: new Error() - }; -} - -let c = 5; - -let h1 = 2; - -let h2 = h1 + 1 | 0; - -let h4 = 2; - -let h5 = h4 + 1 | 0; - -let b = 5; - -let N = { - b: b -}; - -console.log(h5); - -console.log(h2); - -console.log(c); - -console.log(3); - -function H($star) { - return {}; -} - -exports.f = f; -exports.N = N; -exports.H = H; -/* Not a pure module */ diff --git a/tests/tests/src/internal_unused_test.mjs b/tests/tests/src/internal_unused_test.mjs new file mode 100644 index 0000000000..e671df9174 --- /dev/null +++ b/tests/tests/src/internal_unused_test.mjs @@ -0,0 +1,49 @@ +// Generated by ReScript, PLEASE EDIT WITH CARE + +import * as Primitive_exceptions from "rescript/lib/es6/Primitive_exceptions.js"; + +console.log(3); + +let A = /* @__PURE__ */Primitive_exceptions.create("Internal_unused_test.P1.A"); + +function f() { + throw { + RE_EXN_ID: A, + Error: new Error() + }; +} + +let c = 5; + +let h1 = 2; + +let h2 = h1 + 1 | 0; + +let h4 = 2; + +let h5 = h4 + 1 | 0; + +let b = 5; + +let N = { + b: b +}; + +console.log(h5); + +console.log(h2); + +console.log(c); + +console.log(3); + +function H($star) { + return {}; +} + +export { + f, + N, + H, +} +/* Not a pure module */ diff --git a/tests/tests/src/joinClasses.js b/tests/tests/src/joinClasses.js deleted file mode 100644 index d8309c66e9..0000000000 --- a/tests/tests/src/joinClasses.js +++ /dev/null @@ -1,8 +0,0 @@ -module.exports = function(){ - var sum = 0 ; - var i = 0; - for(; i < arguments.length ; ++ i){ - sum += arguments[i] - } - return sum -} \ No newline at end of file diff --git a/tests/tests/src/joinClasses.mjs b/tests/tests/src/joinClasses.mjs new file mode 100644 index 0000000000..1429898013 --- /dev/null +++ b/tests/tests/src/joinClasses.mjs @@ -0,0 +1,8 @@ +export default function(){ + var sum = 0 ; + var i = 0; + for(; i < arguments.length ; ++ i){ + sum += arguments[i] + } + return sum +} \ No newline at end of file diff --git a/tests/tests/src/js_array_test.js b/tests/tests/src/js_array_test.js deleted file mode 100644 index 47a28e403d..0000000000 --- a/tests/tests/src/js_array_test.js +++ /dev/null @@ -1,1006 +0,0 @@ -// Generated by ReScript, PLEASE EDIT WITH CARE -'use strict'; - -let Mt = require("./mt.js"); -let Primitive_option = require("rescript/lib/js/Primitive_option.js"); - -let suites_0 = [ - "isArray_array", - param => ({ - TAG: "Eq", - _0: true, - _1: Array.isArray([]) - }) -]; - -let suites_1 = { - hd: [ - "isArray_int", - param => ({ - TAG: "Eq", - _0: false, - _1: Array.isArray(34) - }) - ], - tl: { - hd: [ - "length", - param => ({ - TAG: "Eq", - _0: 3, - _1: [ - 1, - 2, - 3 - ].length - }) - ], - tl: { - hd: [ - "copyWithin", - param => ({ - TAG: "Eq", - _0: [ - 1, - 2, - 3, - 1, - 2 - ], - _1: [ - 1, - 2, - 3, - 4, - 5 - ].copyWithin(-2) - }) - ], - tl: { - hd: [ - "copyWithinFrom", - param => ({ - TAG: "Eq", - _0: [ - 4, - 5, - 3, - 4, - 5 - ], - _1: [ - 1, - 2, - 3, - 4, - 5 - ].copyWithin(0, 3) - }) - ], - tl: { - hd: [ - "copyWithinFromRange", - param => ({ - TAG: "Eq", - _0: [ - 4, - 2, - 3, - 4, - 5 - ], - _1: [ - 1, - 2, - 3, - 4, - 5 - ].copyWithin(0, 3, 4) - }) - ], - tl: { - hd: [ - "fillInPlace", - param => ({ - TAG: "Eq", - _0: [ - 4, - 4, - 4 - ], - _1: [ - 1, - 2, - 3 - ].fill(4) - }) - ], - tl: { - hd: [ - "fillFromInPlace", - param => ({ - TAG: "Eq", - _0: [ - 1, - 4, - 4 - ], - _1: [ - 1, - 2, - 3 - ].fill(4, 1) - }) - ], - tl: { - hd: [ - "fillRangeInPlace", - param => ({ - TAG: "Eq", - _0: [ - 1, - 4, - 3 - ], - _1: [ - 1, - 2, - 3 - ].fill(4, 1, 2) - }) - ], - tl: { - hd: [ - "pop", - param => ({ - TAG: "Eq", - _0: 3, - _1: Primitive_option.fromUndefined([ - 1, - 2, - 3 - ].pop()) - }) - ], - tl: { - hd: [ - "pop - empty array", - param => ({ - TAG: "Eq", - _0: undefined, - _1: Primitive_option.fromUndefined([].pop()) - }) - ], - tl: { - hd: [ - "push", - param => ({ - TAG: "Eq", - _0: 4, - _1: [ - 1, - 2, - 3 - ].push(4) - }) - ], - tl: { - hd: [ - "pushMany", - param => ({ - TAG: "Eq", - _0: 5, - _1: [ - 1, - 2, - 3 - ].push(4, 5) - }) - ], - tl: { - hd: [ - "reverseInPlace", - param => ({ - TAG: "Eq", - _0: [ - 3, - 2, - 1 - ], - _1: [ - 1, - 2, - 3 - ].reverse() - }) - ], - tl: { - hd: [ - "shift", - param => ({ - TAG: "Eq", - _0: 1, - _1: Primitive_option.fromUndefined([ - 1, - 2, - 3 - ].shift()) - }) - ], - tl: { - hd: [ - "shift - empty array", - param => ({ - TAG: "Eq", - _0: undefined, - _1: Primitive_option.fromUndefined([].shift()) - }) - ], - tl: { - hd: [ - "sortInPlace", - param => ({ - TAG: "Eq", - _0: [ - 1, - 2, - 3 - ], - _1: [ - 3, - 1, - 2 - ].sort() - }) - ], - tl: { - hd: [ - "sortInPlaceWith", - param => ({ - TAG: "Eq", - _0: [ - 3, - 2, - 1 - ], - _1: [ - 3, - 1, - 2 - ].sort((a, b) => b - a | 0) - }) - ], - tl: { - hd: [ - "spliceInPlace", - param => { - let arr = [ - 1, - 2, - 3, - 4 - ]; - let removed = arr.splice(2, 0, 5); - return { - TAG: "Eq", - _0: [ - [ - 1, - 2, - 5, - 3, - 4 - ], - [] - ], - _1: [ - arr, - removed - ] - }; - } - ], - tl: { - hd: [ - "removeFromInPlace", - param => { - let arr = [ - 1, - 2, - 3, - 4 - ]; - let removed = arr.splice(2); - return { - TAG: "Eq", - _0: [ - [ - 1, - 2 - ], - [ - 3, - 4 - ] - ], - _1: [ - arr, - removed - ] - }; - } - ], - tl: { - hd: [ - "removeCountInPlace", - param => { - let arr = [ - 1, - 2, - 3, - 4 - ]; - let removed = arr.splice(2, 1); - return { - TAG: "Eq", - _0: [ - [ - 1, - 2, - 4 - ], - [3] - ], - _1: [ - arr, - removed - ] - }; - } - ], - tl: { - hd: [ - "unshift", - param => ({ - TAG: "Eq", - _0: 4, - _1: [ - 1, - 2, - 3 - ].unshift(4) - }) - ], - tl: { - hd: [ - "unshiftMany", - param => ({ - TAG: "Eq", - _0: 5, - _1: [ - 1, - 2, - 3 - ].unshift(4, 5) - }) - ], - tl: { - hd: [ - "append", - param => ({ - TAG: "Eq", - _0: [ - 1, - 2, - 3, - 4 - ], - _1: [ - 1, - 2, - 3 - ].concat([4]) - }) - ], - tl: { - hd: [ - "concat", - param => ({ - TAG: "Eq", - _0: [ - 1, - 2, - 3, - 4, - 5 - ], - _1: [ - 1, - 2, - 3 - ].concat([ - 4, - 5 - ]) - }) - ], - tl: { - hd: [ - "concatMany", - param => ({ - TAG: "Eq", - _0: [ - 1, - 2, - 3, - 4, - 5, - 6, - 7 - ], - _1: [ - 1, - 2, - 3 - ].concat([ - 4, - 5 - ], [ - 6, - 7 - ]) - }) - ], - tl: { - hd: [ - "includes", - param => ({ - TAG: "Eq", - _0: true, - _1: [ - 1, - 2, - 3 - ].includes(3) - }) - ], - tl: { - hd: [ - "indexOf", - param => ({ - TAG: "Eq", - _0: 1, - _1: [ - 1, - 2, - 3 - ].indexOf(2) - }) - ], - tl: { - hd: [ - "indexOfFrom", - param => ({ - TAG: "Eq", - _0: 3, - _1: [ - 1, - 2, - 3, - 2 - ].indexOf(2, 2) - }) - ], - tl: { - hd: [ - "join", - param => ({ - TAG: "Eq", - _0: "1,2,3", - _1: [ - 1, - 2, - 3 - ].join() - }) - ], - tl: { - hd: [ - "joinWith", - param => ({ - TAG: "Eq", - _0: "1;2;3", - _1: [ - 1, - 2, - 3 - ].join(";") - }) - ], - tl: { - hd: [ - "lastIndexOf", - param => ({ - TAG: "Eq", - _0: 1, - _1: [ - 1, - 2, - 3 - ].lastIndexOf(2) - }) - ], - tl: { - hd: [ - "lastIndexOfFrom", - param => ({ - TAG: "Eq", - _0: 1, - _1: [ - 1, - 2, - 3, - 2 - ].lastIndexOf(2, 2) - }) - ], - tl: { - hd: [ - "slice", - param => ({ - TAG: "Eq", - _0: [ - 2, - 3 - ], - _1: [ - 1, - 2, - 3, - 4, - 5 - ].slice(1, 3) - }) - ], - tl: { - hd: [ - "copy", - param => ({ - TAG: "Eq", - _0: [ - 1, - 2, - 3, - 4, - 5 - ], - _1: [ - 1, - 2, - 3, - 4, - 5 - ].slice() - }) - ], - tl: { - hd: [ - "sliceFrom", - param => ({ - TAG: "Eq", - _0: [ - 3, - 4, - 5 - ], - _1: [ - 1, - 2, - 3, - 4, - 5 - ].slice(2) - }) - ], - tl: { - hd: [ - "toString", - param => ({ - TAG: "Eq", - _0: "1,2,3", - _1: [ - 1, - 2, - 3 - ].toString() - }) - ], - tl: { - hd: [ - "toLocaleString", - param => ({ - TAG: "Eq", - _0: "1,2,3", - _1: [ - 1, - 2, - 3 - ].toLocaleString() - }) - ], - tl: { - hd: [ - "every", - param => ({ - TAG: "Eq", - _0: true, - _1: [ - 1, - 2, - 3 - ].every(n => n > 0) - }) - ], - tl: { - hd: [ - "everyi", - param => ({ - TAG: "Eq", - _0: false, - _1: [ - 1, - 2, - 3 - ].every((param, i) => i > 0) - }) - ], - tl: { - hd: [ - "filter", - param => ({ - TAG: "Eq", - _0: [ - 2, - 4 - ], - _1: [ - 1, - 2, - 3, - 4 - ].filter(n => n % 2 === 0) - }) - ], - tl: { - hd: [ - "filteri", - param => ({ - TAG: "Eq", - _0: [ - 1, - 3 - ], - _1: [ - 1, - 2, - 3, - 4 - ].filter((param, i) => i % 2 === 0) - }) - ], - tl: { - hd: [ - "find", - param => ({ - TAG: "Eq", - _0: 2, - _1: Primitive_option.fromUndefined([ - 1, - 2, - 3, - 4 - ].find(n => n % 2 === 0)) - }) - ], - tl: { - hd: [ - "find - no match", - param => ({ - TAG: "Eq", - _0: undefined, - _1: Primitive_option.fromUndefined([ - 1, - 2, - 3, - 4 - ].find(n => n % 2 === 5)) - }) - ], - tl: { - hd: [ - "findi", - param => ({ - TAG: "Eq", - _0: 1, - _1: Primitive_option.fromUndefined([ - 1, - 2, - 3, - 4 - ].find((param, i) => i % 2 === 0)) - }) - ], - tl: { - hd: [ - "findi - no match", - param => ({ - TAG: "Eq", - _0: undefined, - _1: Primitive_option.fromUndefined([ - 1, - 2, - 3, - 4 - ].find((param, i) => i % 2 === 5)) - }) - ], - tl: { - hd: [ - "findIndex", - param => ({ - TAG: "Eq", - _0: 1, - _1: [ - 1, - 2, - 3, - 4 - ].findIndex(n => n % 2 === 0) - }) - ], - tl: { - hd: [ - "findIndexi", - param => ({ - TAG: "Eq", - _0: 0, - _1: [ - 1, - 2, - 3, - 4 - ].findIndex((param, i) => i % 2 === 0) - }) - ], - tl: { - hd: [ - "forEach", - param => { - let sum = { - contents: 0 - }; - [ - 1, - 2, - 3 - ].forEach(n => { - sum.contents = sum.contents + n | 0; - }); - return { - TAG: "Eq", - _0: 6, - _1: sum.contents - }; - } - ], - tl: { - hd: [ - "forEachi", - param => { - let sum = { - contents: 0 - }; - [ - 1, - 2, - 3 - ].forEach((param, i) => { - sum.contents = sum.contents + i | 0; - }); - return { - TAG: "Eq", - _0: 3, - _1: sum.contents - }; - } - ], - tl: { - hd: [ - "map", - param => ({ - TAG: "Eq", - _0: [ - 2, - 4, - 6, - 8 - ], - _1: [ - 1, - 2, - 3, - 4 - ].map(n => (n << 1)) - }) - ], - tl: { - hd: [ - "map", - param => ({ - TAG: "Eq", - _0: [ - 0, - 2, - 4, - 6 - ], - _1: [ - 1, - 2, - 3, - 4 - ].map((param, i) => (i << 1)) - }) - ], - tl: { - hd: [ - "reduce", - param => ({ - TAG: "Eq", - _0: -10, - _1: [ - 1, - 2, - 3, - 4 - ].reduce((acc, n) => acc - n | 0, 0) - }) - ], - tl: { - hd: [ - "reducei", - param => ({ - TAG: "Eq", - _0: -6, - _1: [ - 1, - 2, - 3, - 4 - ].reduce((acc, param, i) => acc - i | 0, 0) - }) - ], - tl: { - hd: [ - "reduceRight", - param => ({ - TAG: "Eq", - _0: -10, - _1: [ - 1, - 2, - 3, - 4 - ].reduceRight((acc, n) => acc - n | 0, 0) - }) - ], - tl: { - hd: [ - "reduceRighti", - param => ({ - TAG: "Eq", - _0: -6, - _1: [ - 1, - 2, - 3, - 4 - ].reduceRight((acc, param, i) => acc - i | 0, 0) - }) - ], - tl: { - hd: [ - "some", - param => ({ - TAG: "Eq", - _0: false, - _1: [ - 1, - 2, - 3, - 4 - ].some(n => n <= 0) - }) - ], - tl: { - hd: [ - "somei", - param => ({ - TAG: "Eq", - _0: true, - _1: [ - 1, - 2, - 3, - 4 - ].some((param, i) => i <= 0) - }) - ], - tl: /* [] */0 - } - } - } - } - } - } - } - } - } - } - } - } - } - } - } - } - } - } - } - } - } - } - } - } - } - } - } - } - } - } - } - } - } - } - } - } - } - } - } - } - } - } - } - } - } - } - } - } - } - } - } - } - } - } - } - } -}; - -let suites = { - hd: suites_0, - tl: suites_1 -}; - -Mt.from_pair_suites("Js_array_test", suites); - -exports.suites = suites; -/* Not a pure module */ diff --git a/tests/tests/src/js_array_test.mjs b/tests/tests/src/js_array_test.mjs new file mode 100644 index 0000000000..9b14eaf969 --- /dev/null +++ b/tests/tests/src/js_array_test.mjs @@ -0,0 +1,1007 @@ +// Generated by ReScript, PLEASE EDIT WITH CARE + +import * as Mt from "./mt.mjs"; +import * as Primitive_option from "rescript/lib/es6/Primitive_option.js"; + +let suites_0 = [ + "isArray_array", + param => ({ + TAG: "Eq", + _0: true, + _1: Array.isArray([]) + }) +]; + +let suites_1 = { + hd: [ + "isArray_int", + param => ({ + TAG: "Eq", + _0: false, + _1: Array.isArray(34) + }) + ], + tl: { + hd: [ + "length", + param => ({ + TAG: "Eq", + _0: 3, + _1: [ + 1, + 2, + 3 + ].length + }) + ], + tl: { + hd: [ + "copyWithin", + param => ({ + TAG: "Eq", + _0: [ + 1, + 2, + 3, + 1, + 2 + ], + _1: [ + 1, + 2, + 3, + 4, + 5 + ].copyWithin(-2) + }) + ], + tl: { + hd: [ + "copyWithinFrom", + param => ({ + TAG: "Eq", + _0: [ + 4, + 5, + 3, + 4, + 5 + ], + _1: [ + 1, + 2, + 3, + 4, + 5 + ].copyWithin(0, 3) + }) + ], + tl: { + hd: [ + "copyWithinFromRange", + param => ({ + TAG: "Eq", + _0: [ + 4, + 2, + 3, + 4, + 5 + ], + _1: [ + 1, + 2, + 3, + 4, + 5 + ].copyWithin(0, 3, 4) + }) + ], + tl: { + hd: [ + "fillInPlace", + param => ({ + TAG: "Eq", + _0: [ + 4, + 4, + 4 + ], + _1: [ + 1, + 2, + 3 + ].fill(4) + }) + ], + tl: { + hd: [ + "fillFromInPlace", + param => ({ + TAG: "Eq", + _0: [ + 1, + 4, + 4 + ], + _1: [ + 1, + 2, + 3 + ].fill(4, 1) + }) + ], + tl: { + hd: [ + "fillRangeInPlace", + param => ({ + TAG: "Eq", + _0: [ + 1, + 4, + 3 + ], + _1: [ + 1, + 2, + 3 + ].fill(4, 1, 2) + }) + ], + tl: { + hd: [ + "pop", + param => ({ + TAG: "Eq", + _0: 3, + _1: Primitive_option.fromUndefined([ + 1, + 2, + 3 + ].pop()) + }) + ], + tl: { + hd: [ + "pop - empty array", + param => ({ + TAG: "Eq", + _0: undefined, + _1: Primitive_option.fromUndefined([].pop()) + }) + ], + tl: { + hd: [ + "push", + param => ({ + TAG: "Eq", + _0: 4, + _1: [ + 1, + 2, + 3 + ].push(4) + }) + ], + tl: { + hd: [ + "pushMany", + param => ({ + TAG: "Eq", + _0: 5, + _1: [ + 1, + 2, + 3 + ].push(4, 5) + }) + ], + tl: { + hd: [ + "reverseInPlace", + param => ({ + TAG: "Eq", + _0: [ + 3, + 2, + 1 + ], + _1: [ + 1, + 2, + 3 + ].reverse() + }) + ], + tl: { + hd: [ + "shift", + param => ({ + TAG: "Eq", + _0: 1, + _1: Primitive_option.fromUndefined([ + 1, + 2, + 3 + ].shift()) + }) + ], + tl: { + hd: [ + "shift - empty array", + param => ({ + TAG: "Eq", + _0: undefined, + _1: Primitive_option.fromUndefined([].shift()) + }) + ], + tl: { + hd: [ + "sortInPlace", + param => ({ + TAG: "Eq", + _0: [ + 1, + 2, + 3 + ], + _1: [ + 3, + 1, + 2 + ].sort() + }) + ], + tl: { + hd: [ + "sortInPlaceWith", + param => ({ + TAG: "Eq", + _0: [ + 3, + 2, + 1 + ], + _1: [ + 3, + 1, + 2 + ].sort((a, b) => b - a | 0) + }) + ], + tl: { + hd: [ + "spliceInPlace", + param => { + let arr = [ + 1, + 2, + 3, + 4 + ]; + let removed = arr.splice(2, 0, 5); + return { + TAG: "Eq", + _0: [ + [ + 1, + 2, + 5, + 3, + 4 + ], + [] + ], + _1: [ + arr, + removed + ] + }; + } + ], + tl: { + hd: [ + "removeFromInPlace", + param => { + let arr = [ + 1, + 2, + 3, + 4 + ]; + let removed = arr.splice(2); + return { + TAG: "Eq", + _0: [ + [ + 1, + 2 + ], + [ + 3, + 4 + ] + ], + _1: [ + arr, + removed + ] + }; + } + ], + tl: { + hd: [ + "removeCountInPlace", + param => { + let arr = [ + 1, + 2, + 3, + 4 + ]; + let removed = arr.splice(2, 1); + return { + TAG: "Eq", + _0: [ + [ + 1, + 2, + 4 + ], + [3] + ], + _1: [ + arr, + removed + ] + }; + } + ], + tl: { + hd: [ + "unshift", + param => ({ + TAG: "Eq", + _0: 4, + _1: [ + 1, + 2, + 3 + ].unshift(4) + }) + ], + tl: { + hd: [ + "unshiftMany", + param => ({ + TAG: "Eq", + _0: 5, + _1: [ + 1, + 2, + 3 + ].unshift(4, 5) + }) + ], + tl: { + hd: [ + "append", + param => ({ + TAG: "Eq", + _0: [ + 1, + 2, + 3, + 4 + ], + _1: [ + 1, + 2, + 3 + ].concat([4]) + }) + ], + tl: { + hd: [ + "concat", + param => ({ + TAG: "Eq", + _0: [ + 1, + 2, + 3, + 4, + 5 + ], + _1: [ + 1, + 2, + 3 + ].concat([ + 4, + 5 + ]) + }) + ], + tl: { + hd: [ + "concatMany", + param => ({ + TAG: "Eq", + _0: [ + 1, + 2, + 3, + 4, + 5, + 6, + 7 + ], + _1: [ + 1, + 2, + 3 + ].concat([ + 4, + 5 + ], [ + 6, + 7 + ]) + }) + ], + tl: { + hd: [ + "includes", + param => ({ + TAG: "Eq", + _0: true, + _1: [ + 1, + 2, + 3 + ].includes(3) + }) + ], + tl: { + hd: [ + "indexOf", + param => ({ + TAG: "Eq", + _0: 1, + _1: [ + 1, + 2, + 3 + ].indexOf(2) + }) + ], + tl: { + hd: [ + "indexOfFrom", + param => ({ + TAG: "Eq", + _0: 3, + _1: [ + 1, + 2, + 3, + 2 + ].indexOf(2, 2) + }) + ], + tl: { + hd: [ + "join", + param => ({ + TAG: "Eq", + _0: "1,2,3", + _1: [ + 1, + 2, + 3 + ].join() + }) + ], + tl: { + hd: [ + "joinWith", + param => ({ + TAG: "Eq", + _0: "1;2;3", + _1: [ + 1, + 2, + 3 + ].join(";") + }) + ], + tl: { + hd: [ + "lastIndexOf", + param => ({ + TAG: "Eq", + _0: 1, + _1: [ + 1, + 2, + 3 + ].lastIndexOf(2) + }) + ], + tl: { + hd: [ + "lastIndexOfFrom", + param => ({ + TAG: "Eq", + _0: 1, + _1: [ + 1, + 2, + 3, + 2 + ].lastIndexOf(2, 2) + }) + ], + tl: { + hd: [ + "slice", + param => ({ + TAG: "Eq", + _0: [ + 2, + 3 + ], + _1: [ + 1, + 2, + 3, + 4, + 5 + ].slice(1, 3) + }) + ], + tl: { + hd: [ + "copy", + param => ({ + TAG: "Eq", + _0: [ + 1, + 2, + 3, + 4, + 5 + ], + _1: [ + 1, + 2, + 3, + 4, + 5 + ].slice() + }) + ], + tl: { + hd: [ + "sliceFrom", + param => ({ + TAG: "Eq", + _0: [ + 3, + 4, + 5 + ], + _1: [ + 1, + 2, + 3, + 4, + 5 + ].slice(2) + }) + ], + tl: { + hd: [ + "toString", + param => ({ + TAG: "Eq", + _0: "1,2,3", + _1: [ + 1, + 2, + 3 + ].toString() + }) + ], + tl: { + hd: [ + "toLocaleString", + param => ({ + TAG: "Eq", + _0: "1,2,3", + _1: [ + 1, + 2, + 3 + ].toLocaleString() + }) + ], + tl: { + hd: [ + "every", + param => ({ + TAG: "Eq", + _0: true, + _1: [ + 1, + 2, + 3 + ].every(n => n > 0) + }) + ], + tl: { + hd: [ + "everyi", + param => ({ + TAG: "Eq", + _0: false, + _1: [ + 1, + 2, + 3 + ].every((param, i) => i > 0) + }) + ], + tl: { + hd: [ + "filter", + param => ({ + TAG: "Eq", + _0: [ + 2, + 4 + ], + _1: [ + 1, + 2, + 3, + 4 + ].filter(n => n % 2 === 0) + }) + ], + tl: { + hd: [ + "filteri", + param => ({ + TAG: "Eq", + _0: [ + 1, + 3 + ], + _1: [ + 1, + 2, + 3, + 4 + ].filter((param, i) => i % 2 === 0) + }) + ], + tl: { + hd: [ + "find", + param => ({ + TAG: "Eq", + _0: 2, + _1: Primitive_option.fromUndefined([ + 1, + 2, + 3, + 4 + ].find(n => n % 2 === 0)) + }) + ], + tl: { + hd: [ + "find - no match", + param => ({ + TAG: "Eq", + _0: undefined, + _1: Primitive_option.fromUndefined([ + 1, + 2, + 3, + 4 + ].find(n => n % 2 === 5)) + }) + ], + tl: { + hd: [ + "findi", + param => ({ + TAG: "Eq", + _0: 1, + _1: Primitive_option.fromUndefined([ + 1, + 2, + 3, + 4 + ].find((param, i) => i % 2 === 0)) + }) + ], + tl: { + hd: [ + "findi - no match", + param => ({ + TAG: "Eq", + _0: undefined, + _1: Primitive_option.fromUndefined([ + 1, + 2, + 3, + 4 + ].find((param, i) => i % 2 === 5)) + }) + ], + tl: { + hd: [ + "findIndex", + param => ({ + TAG: "Eq", + _0: 1, + _1: [ + 1, + 2, + 3, + 4 + ].findIndex(n => n % 2 === 0) + }) + ], + tl: { + hd: [ + "findIndexi", + param => ({ + TAG: "Eq", + _0: 0, + _1: [ + 1, + 2, + 3, + 4 + ].findIndex((param, i) => i % 2 === 0) + }) + ], + tl: { + hd: [ + "forEach", + param => { + let sum = { + contents: 0 + }; + [ + 1, + 2, + 3 + ].forEach(n => { + sum.contents = sum.contents + n | 0; + }); + return { + TAG: "Eq", + _0: 6, + _1: sum.contents + }; + } + ], + tl: { + hd: [ + "forEachi", + param => { + let sum = { + contents: 0 + }; + [ + 1, + 2, + 3 + ].forEach((param, i) => { + sum.contents = sum.contents + i | 0; + }); + return { + TAG: "Eq", + _0: 3, + _1: sum.contents + }; + } + ], + tl: { + hd: [ + "map", + param => ({ + TAG: "Eq", + _0: [ + 2, + 4, + 6, + 8 + ], + _1: [ + 1, + 2, + 3, + 4 + ].map(n => (n << 1)) + }) + ], + tl: { + hd: [ + "map", + param => ({ + TAG: "Eq", + _0: [ + 0, + 2, + 4, + 6 + ], + _1: [ + 1, + 2, + 3, + 4 + ].map((param, i) => (i << 1)) + }) + ], + tl: { + hd: [ + "reduce", + param => ({ + TAG: "Eq", + _0: -10, + _1: [ + 1, + 2, + 3, + 4 + ].reduce((acc, n) => acc - n | 0, 0) + }) + ], + tl: { + hd: [ + "reducei", + param => ({ + TAG: "Eq", + _0: -6, + _1: [ + 1, + 2, + 3, + 4 + ].reduce((acc, param, i) => acc - i | 0, 0) + }) + ], + tl: { + hd: [ + "reduceRight", + param => ({ + TAG: "Eq", + _0: -10, + _1: [ + 1, + 2, + 3, + 4 + ].reduceRight((acc, n) => acc - n | 0, 0) + }) + ], + tl: { + hd: [ + "reduceRighti", + param => ({ + TAG: "Eq", + _0: -6, + _1: [ + 1, + 2, + 3, + 4 + ].reduceRight((acc, param, i) => acc - i | 0, 0) + }) + ], + tl: { + hd: [ + "some", + param => ({ + TAG: "Eq", + _0: false, + _1: [ + 1, + 2, + 3, + 4 + ].some(n => n <= 0) + }) + ], + tl: { + hd: [ + "somei", + param => ({ + TAG: "Eq", + _0: true, + _1: [ + 1, + 2, + 3, + 4 + ].some((param, i) => i <= 0) + }) + ], + tl: /* [] */0 + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } +}; + +let suites = { + hd: suites_0, + tl: suites_1 +}; + +Mt.from_pair_suites("Js_array_test", suites); + +export { + suites, +} +/* Not a pure module */ diff --git a/tests/tests/src/js_bool_test.js b/tests/tests/src/js_bool_test.js deleted file mode 100644 index 50bd8edab0..0000000000 --- a/tests/tests/src/js_bool_test.js +++ /dev/null @@ -1,147 +0,0 @@ -// Generated by ReScript, PLEASE EDIT WITH CARE -'use strict'; - -let Mt = require("./mt.js"); - -function f(x) { - if (x) { - return true; - } else { - return false; - } -} - -function f2(x) { - if (x) { - return true; - } else { - return false; - } -} - -function f4(x) { - if (x) { - return true; - } else { - return false; - } -} - -let u = 1; - -let v = true; - -let suites_0 = [ - "?bool_eq_caml_bool", - param => ({ - TAG: "Eq", - _0: u, - _1: true - }) -]; - -let suites_1 = { - hd: [ - "js_bool_eq_js_bool", - param => ({ - TAG: "Eq", - _0: v, - _1: true - }) - ], - tl: { - hd: [ - "js_bool_neq_acml_bool", - param => ({ - TAG: "Eq", - _0: true, - _1: true === true - }) - ], - tl: /* [] */0 - } -}; - -let suites = { - hd: suites_0, - tl: suites_1 -}; - -function ff(u) { - if (u === true) { - return 1; - } else { - return 2; - } -} - -function fi(x, y) { - return x === y; -} - -function fb(x, y) { - return x === y; -} - -function fadd(x, y) { - return x + y | 0; -} - -function ffadd(x, y) { - return x + y; -} - -function ss(x) { - return "xx" > x; -} - -function bb(x) { - return [ - true > x, - false, - true, - true <= x, - false, - false < x, - false >= x, - true - ]; -} - -let consts = [ - false, - false, - true, - false, - true, - false, - true, - true -]; - -let bool_array = [ - true, - false -]; - -Mt.from_pair_suites("Js_bool_test", suites); - -let f3 = true; - -exports.f = f; -exports.f2 = f2; -exports.f4 = f4; -exports.f3 = f3; -exports.u = u; -exports.v = v; -exports.suites = suites; -exports.ff = ff; -exports.fi = fi; -exports.fb = fb; -exports.fadd = fadd; -exports.ffadd = ffadd; -exports.ss = ss; -exports.bb = bb; -exports.consts = consts; -exports.bool_array = bool_array; -/* Not a pure module */ diff --git a/tests/tests/src/js_bool_test.mjs b/tests/tests/src/js_bool_test.mjs new file mode 100644 index 0000000000..bb87a4f7f0 --- /dev/null +++ b/tests/tests/src/js_bool_test.mjs @@ -0,0 +1,148 @@ +// Generated by ReScript, PLEASE EDIT WITH CARE + +import * as Mt from "./mt.mjs"; + +function f(x) { + if (x) { + return true; + } else { + return false; + } +} + +function f2(x) { + if (x) { + return true; + } else { + return false; + } +} + +function f4(x) { + if (x) { + return true; + } else { + return false; + } +} + +let u = 1; + +let v = true; + +let suites_0 = [ + "?bool_eq_caml_bool", + param => ({ + TAG: "Eq", + _0: u, + _1: true + }) +]; + +let suites_1 = { + hd: [ + "js_bool_eq_js_bool", + param => ({ + TAG: "Eq", + _0: v, + _1: true + }) + ], + tl: { + hd: [ + "js_bool_neq_acml_bool", + param => ({ + TAG: "Eq", + _0: true, + _1: true === true + }) + ], + tl: /* [] */0 + } +}; + +let suites = { + hd: suites_0, + tl: suites_1 +}; + +function ff(u) { + if (u === true) { + return 1; + } else { + return 2; + } +} + +function fi(x, y) { + return x === y; +} + +function fb(x, y) { + return x === y; +} + +function fadd(x, y) { + return x + y | 0; +} + +function ffadd(x, y) { + return x + y; +} + +function ss(x) { + return "xx" > x; +} + +function bb(x) { + return [ + true > x, + false, + true, + true <= x, + false, + false < x, + false >= x, + true + ]; +} + +let consts = [ + false, + false, + true, + false, + true, + false, + true, + true +]; + +let bool_array = [ + true, + false +]; + +Mt.from_pair_suites("Js_bool_test", suites); + +let f3 = true; + +export { + f, + f2, + f4, + f3, + u, + v, + suites, + ff, + fi, + fb, + fadd, + ffadd, + ss, + bb, + consts, + bool_array, +} +/* Not a pure module */ diff --git a/tests/tests/src/js_date_test.js b/tests/tests/src/js_date_test.js deleted file mode 100644 index 0cdf7f80be..0000000000 --- a/tests/tests/src/js_date_test.js +++ /dev/null @@ -1,1058 +0,0 @@ -// Generated by ReScript, PLEASE EDIT WITH CARE -'use strict'; - -let Mt = require("./mt.js"); -let Primitive_object = require("rescript/lib/js/Primitive_object.js"); - -function date() { - return new Date("1976-03-08T12:34:56.789+01:23"); -} - -let suites_0 = [ - "valueOf", - param => ({ - TAG: "Eq", - _0: 195131516789, - _1: new Date("1976-03-08T12:34:56.789+01:23").valueOf() - }) -]; - -let suites_1 = { - hd: [ - "make", - param => ({ - TAG: "Ok", - _0: new Date().getTime() > 1487223505382 - }) - ], - tl: { - hd: [ - "parseAsFloat", - param => ({ - TAG: "Eq", - _0: Date.parse("1976-03-08T12:34:56.789+01:23"), - _1: 195131516789 - }) - ], - tl: { - hd: [ - "parseAsFloat_invalid", - param => ({ - TAG: "Ok", - _0: Number.isNaN(Date.parse("gibberish")) - }) - ], - tl: { - hd: [ - "fromFloat", - param => ({ - TAG: "Eq", - _0: "1976-03-08T11:11:56.789Z", - _1: new Date(195131516789).toISOString() - }) - ], - tl: { - hd: [ - "fromString_valid", - param => ({ - TAG: "Eq", - _0: 195131516789, - _1: new Date("1976-03-08T12:34:56.789+01:23").getTime() - }) - ], - tl: { - hd: [ - "fromString_invalid", - param => ({ - TAG: "Ok", - _0: Number.isNaN(new Date("gibberish").getTime()) - }) - ], - tl: { - hd: [ - "makeWithYM", - param => { - let d = new Date(1984, 4); - return { - TAG: "Eq", - _0: [ - 1984, - 4 - ], - _1: [ - d.getFullYear(), - d.getMonth() - ] - }; - } - ], - tl: { - hd: [ - "makeWithYMD", - param => { - let d = new Date(1984, 4, 6); - return { - TAG: "Eq", - _0: [ - 1984, - 4, - 6 - ], - _1: [ - d.getFullYear(), - d.getMonth(), - d.getDate() - ] - }; - } - ], - tl: { - hd: [ - "makeWithYMDH", - param => { - let d = new Date(1984, 4, 6, 3); - return { - TAG: "Eq", - _0: [ - 1984, - 4, - 6, - 3 - ], - _1: [ - d.getFullYear(), - d.getMonth(), - d.getDate(), - d.getHours() - ] - }; - } - ], - tl: { - hd: [ - "makeWithYMDHM", - param => { - let d = new Date(1984, 4, 6, 3, 59); - return { - TAG: "Eq", - _0: [ - 1984, - 4, - 6, - 3, - 59 - ], - _1: [ - d.getFullYear(), - d.getMonth(), - d.getDate(), - d.getHours(), - d.getMinutes() - ] - }; - } - ], - tl: { - hd: [ - "makeWithYMDHMS", - param => { - let d = new Date(1984, 4, 6, 3, 59, 27); - return { - TAG: "Eq", - _0: [ - 1984, - 4, - 6, - 3, - 59, - 27 - ], - _1: [ - d.getFullYear(), - d.getMonth(), - d.getDate(), - d.getHours(), - d.getMinutes(), - d.getSeconds() - ] - }; - } - ], - tl: { - hd: [ - "utcWithYM", - param => { - let d = Date.UTC(1984, 4); - let d$1 = new Date(d); - return { - TAG: "Eq", - _0: [ - 1984, - 4 - ], - _1: [ - d$1.getUTCFullYear(), - d$1.getUTCMonth() - ] - }; - } - ], - tl: { - hd: [ - "utcWithYMD", - param => { - let d = Date.UTC(1984, 4, 6); - let d$1 = new Date(d); - return { - TAG: "Eq", - _0: [ - 1984, - 4, - 6 - ], - _1: [ - d$1.getUTCFullYear(), - d$1.getUTCMonth(), - d$1.getUTCDate() - ] - }; - } - ], - tl: { - hd: [ - "utcWithYMDH", - param => { - let d = Date.UTC(1984, 4, 6, 3); - let d$1 = new Date(d); - return { - TAG: "Eq", - _0: [ - 1984, - 4, - 6, - 3 - ], - _1: [ - d$1.getUTCFullYear(), - d$1.getUTCMonth(), - d$1.getUTCDate(), - d$1.getUTCHours() - ] - }; - } - ], - tl: { - hd: [ - "utcWithYMDHM", - param => { - let d = Date.UTC(1984, 4, 6, 3, 59); - let d$1 = new Date(d); - return { - TAG: "Eq", - _0: [ - 1984, - 4, - 6, - 3, - 59 - ], - _1: [ - d$1.getUTCFullYear(), - d$1.getUTCMonth(), - d$1.getUTCDate(), - d$1.getUTCHours(), - d$1.getUTCMinutes() - ] - }; - } - ], - tl: { - hd: [ - "utcWithYMDHMS", - param => { - let d = Date.UTC(1984, 4, 6, 3, 59, 27); - let d$1 = new Date(d); - return { - TAG: "Eq", - _0: [ - 1984, - 4, - 6, - 3, - 59, - 27 - ], - _1: [ - d$1.getUTCFullYear(), - d$1.getUTCMonth(), - d$1.getUTCDate(), - d$1.getUTCHours(), - d$1.getUTCMinutes(), - d$1.getUTCSeconds() - ] - }; - } - ], - tl: { - hd: [ - "getFullYear", - param => ({ - TAG: "Eq", - _0: 1976, - _1: new Date("1976-03-08T12:34:56.789+01:23").getFullYear() - }) - ], - tl: { - hd: [ - "getMilliseconds", - param => ({ - TAG: "Eq", - _0: 789, - _1: new Date("1976-03-08T12:34:56.789+01:23").getMilliseconds() - }) - ], - tl: { - hd: [ - "getSeconds", - param => ({ - TAG: "Eq", - _0: 56, - _1: new Date("1976-03-08T12:34:56.789+01:23").getSeconds() - }) - ], - tl: { - hd: [ - "getTime", - param => ({ - TAG: "Eq", - _0: 195131516789, - _1: new Date("1976-03-08T12:34:56.789+01:23").getTime() - }) - ], - tl: { - hd: [ - "getUTCDate", - param => ({ - TAG: "Eq", - _0: 8, - _1: new Date("1976-03-08T12:34:56.789+01:23").getUTCDate() - }) - ], - tl: { - hd: [ - "getUTCDay", - param => ({ - TAG: "Eq", - _0: 1, - _1: new Date("1976-03-08T12:34:56.789+01:23").getUTCDay() - }) - ], - tl: { - hd: [ - "getUTCFUllYear", - param => ({ - TAG: "Eq", - _0: 1976, - _1: new Date("1976-03-08T12:34:56.789+01:23").getUTCFullYear() - }) - ], - tl: { - hd: [ - "getUTCHours", - param => ({ - TAG: "Eq", - _0: 11, - _1: new Date("1976-03-08T12:34:56.789+01:23").getUTCHours() - }) - ], - tl: { - hd: [ - "getUTCMilliseconds", - param => ({ - TAG: "Eq", - _0: 789, - _1: new Date("1976-03-08T12:34:56.789+01:23").getUTCMilliseconds() - }) - ], - tl: { - hd: [ - "getUTCMinutes", - param => ({ - TAG: "Eq", - _0: 11, - _1: new Date("1976-03-08T12:34:56.789+01:23").getUTCMinutes() - }) - ], - tl: { - hd: [ - "getUTCMonth", - param => ({ - TAG: "Eq", - _0: 2, - _1: new Date("1976-03-08T12:34:56.789+01:23").getUTCMonth() - }) - ], - tl: { - hd: [ - "getUTCSeconds", - param => ({ - TAG: "Eq", - _0: 56, - _1: new Date("1976-03-08T12:34:56.789+01:23").getUTCSeconds() - }) - ], - tl: { - hd: [ - "getYear", - param => ({ - TAG: "Eq", - _0: 1976, - _1: new Date("1976-03-08T12:34:56.789+01:23").getFullYear() - }) - ], - tl: { - hd: [ - "setDate", - param => { - let d = new Date("1976-03-08T12:34:56.789+01:23"); - d.setDate(12); - return { - TAG: "Eq", - _0: 12, - _1: d.getDate() - }; - } - ], - tl: { - hd: [ - "setFullYear", - param => { - let d = new Date("1976-03-08T12:34:56.789+01:23"); - d.setFullYear(1986); - return { - TAG: "Eq", - _0: 1986, - _1: d.getFullYear() - }; - } - ], - tl: { - hd: [ - "setFullYearM", - param => { - let d = new Date("1976-03-08T12:34:56.789+01:23"); - d.setFullYear(1986, 7); - return { - TAG: "Eq", - _0: [ - 1986, - 7 - ], - _1: [ - d.getFullYear(), - d.getMonth() - ] - }; - } - ], - tl: { - hd: [ - "setFullYearMD", - param => { - let d = new Date("1976-03-08T12:34:56.789+01:23"); - d.setFullYear(1986, 7, 23); - return { - TAG: "Eq", - _0: [ - 1986, - 7, - 23 - ], - _1: [ - d.getFullYear(), - d.getMonth(), - d.getDate() - ] - }; - } - ], - tl: { - hd: [ - "setHours", - param => { - let d = new Date("1976-03-08T12:34:56.789+01:23"); - d.setHours(22); - return { - TAG: "Eq", - _0: 22, - _1: d.getHours() - }; - } - ], - tl: { - hd: [ - "setHoursM", - param => { - let d = new Date("1976-03-08T12:34:56.789+01:23"); - d.setHours(22, 48); - return { - TAG: "Eq", - _0: [ - 22, - 48 - ], - _1: [ - d.getHours(), - d.getMinutes() - ] - }; - } - ], - tl: { - hd: [ - "setHoursMS", - param => { - let d = new Date("1976-03-08T12:34:56.789+01:23"); - d.setHours(22, 48, 54); - return { - TAG: "Eq", - _0: [ - 22, - 48, - 54 - ], - _1: [ - d.getHours(), - d.getMinutes(), - d.getSeconds() - ] - }; - } - ], - tl: { - hd: [ - "setMilliseconds", - param => { - let d = new Date("1976-03-08T12:34:56.789+01:23"); - d.setMilliseconds(543); - return { - TAG: "Eq", - _0: 543, - _1: d.getMilliseconds() - }; - } - ], - tl: { - hd: [ - "setMinutes", - param => { - let d = new Date("1976-03-08T12:34:56.789+01:23"); - d.setMinutes(18); - return { - TAG: "Eq", - _0: 18, - _1: d.getMinutes() - }; - } - ], - tl: { - hd: [ - "setMinutesS", - param => { - let d = new Date("1976-03-08T12:34:56.789+01:23"); - d.setMinutes(18, 42); - return { - TAG: "Eq", - _0: [ - 18, - 42 - ], - _1: [ - d.getMinutes(), - d.getSeconds() - ] - }; - } - ], - tl: { - hd: [ - "setMinutesSMs", - param => { - let d = new Date("1976-03-08T12:34:56.789+01:23"); - d.setMinutes(18, 42, 311); - return { - TAG: "Eq", - _0: [ - 18, - 42, - 311 - ], - _1: [ - d.getMinutes(), - d.getSeconds(), - d.getMilliseconds() - ] - }; - } - ], - tl: { - hd: [ - "setMonth", - param => { - let d = new Date("1976-03-08T12:34:56.789+01:23"); - d.setMonth(10); - return { - TAG: "Eq", - _0: 10, - _1: d.getMonth() - }; - } - ], - tl: { - hd: [ - "setMonthD", - param => { - let d = new Date("1976-03-08T12:34:56.789+01:23"); - d.setMonth(10, 14); - return { - TAG: "Eq", - _0: [ - 10, - 14 - ], - _1: [ - d.getMonth(), - d.getDate() - ] - }; - } - ], - tl: { - hd: [ - "setSeconds", - param => { - let d = new Date("1976-03-08T12:34:56.789+01:23"); - d.setSeconds(36); - return { - TAG: "Eq", - _0: 36, - _1: d.getSeconds() - }; - } - ], - tl: { - hd: [ - "setSecondsMs", - param => { - let d = new Date("1976-03-08T12:34:56.789+01:23"); - d.setSeconds(36, 420); - return { - TAG: "Eq", - _0: [ - 36, - 420 - ], - _1: [ - d.getSeconds(), - d.getMilliseconds() - ] - }; - } - ], - tl: { - hd: [ - "setUTCDate", - param => { - let d = new Date("1976-03-08T12:34:56.789+01:23"); - d.setUTCDate(12); - return { - TAG: "Eq", - _0: 12, - _1: d.getUTCDate() - }; - } - ], - tl: { - hd: [ - "setUTCFullYear", - param => { - let d = new Date("1976-03-08T12:34:56.789+01:23"); - d.setUTCFullYear(1986); - return { - TAG: "Eq", - _0: 1986, - _1: d.getUTCFullYear() - }; - } - ], - tl: { - hd: [ - "setUTCFullYearM", - param => { - let d = new Date("1976-03-08T12:34:56.789+01:23"); - d.setUTCFullYear(1986, 7); - return { - TAG: "Eq", - _0: [ - 1986, - 7 - ], - _1: [ - d.getUTCFullYear(), - d.getUTCMonth() - ] - }; - } - ], - tl: { - hd: [ - "setUTCFullYearMD", - param => { - let d = new Date("1976-03-08T12:34:56.789+01:23"); - d.setUTCFullYear(1986, 7, 23); - return { - TAG: "Eq", - _0: [ - 1986, - 7, - 23 - ], - _1: [ - d.getUTCFullYear(), - d.getUTCMonth(), - d.getUTCDate() - ] - }; - } - ], - tl: { - hd: [ - "setUTCHours", - param => { - let d = new Date("1976-03-08T12:34:56.789+01:23"); - d.setUTCHours(22); - return { - TAG: "Eq", - _0: 22, - _1: d.getUTCHours() - }; - } - ], - tl: { - hd: [ - "setUTCHoursM", - param => { - let d = new Date("1976-03-08T12:34:56.789+01:23"); - d.setUTCHours(22, 48); - return { - TAG: "Eq", - _0: [ - 22, - 48 - ], - _1: [ - d.getUTCHours(), - d.getUTCMinutes() - ] - }; - } - ], - tl: { - hd: [ - "setUTCHoursMS", - param => { - let d = new Date("1976-03-08T12:34:56.789+01:23"); - d.setUTCHours(22, 48, 54); - return { - TAG: "Eq", - _0: [ - 22, - 48, - 54 - ], - _1: [ - d.getUTCHours(), - d.getUTCMinutes(), - d.getUTCSeconds() - ] - }; - } - ], - tl: { - hd: [ - "setUTCMilliseconds", - param => { - let d = new Date("1976-03-08T12:34:56.789+01:23"); - d.setUTCMilliseconds(543); - return { - TAG: "Eq", - _0: 543, - _1: d.getUTCMilliseconds() - }; - } - ], - tl: { - hd: [ - "setUTCMinutes", - param => { - let d = new Date("1976-03-08T12:34:56.789+01:23"); - d.setUTCMinutes(18); - return { - TAG: "Eq", - _0: 18, - _1: d.getUTCMinutes() - }; - } - ], - tl: { - hd: [ - "setUTCMinutesS", - param => { - let d = new Date("1976-03-08T12:34:56.789+01:23"); - d.setUTCMinutes(18, 42); - return { - TAG: "Eq", - _0: [ - 18, - 42 - ], - _1: [ - d.getUTCMinutes(), - d.getUTCSeconds() - ] - }; - } - ], - tl: { - hd: [ - "setUTCMinutesSMs", - param => { - let d = new Date("1976-03-08T12:34:56.789+01:23"); - d.setUTCMinutes(18, 42, 311); - return { - TAG: "Eq", - _0: [ - 18, - 42, - 311 - ], - _1: [ - d.getUTCMinutes(), - d.getUTCSeconds(), - d.getUTCMilliseconds() - ] - }; - } - ], - tl: { - hd: [ - "setUTCMonth", - param => { - let d = new Date("1976-03-08T12:34:56.789+01:23"); - d.setUTCMonth(10); - return { - TAG: "Eq", - _0: 10, - _1: d.getUTCMonth() - }; - } - ], - tl: { - hd: [ - "setUTCMonthD", - param => { - let d = new Date("1976-03-08T12:34:56.789+01:23"); - d.setUTCMonth(10, 14); - return { - TAG: "Eq", - _0: [ - 10, - 14 - ], - _1: [ - d.getUTCMonth(), - d.getUTCDate() - ] - }; - } - ], - tl: { - hd: [ - "setUTCSeconds", - param => { - let d = new Date("1976-03-08T12:34:56.789+01:23"); - d.setUTCSeconds(36); - return { - TAG: "Eq", - _0: 36, - _1: d.getUTCSeconds() - }; - } - ], - tl: { - hd: [ - "setUTCSecondsMs", - param => { - let d = new Date("1976-03-08T12:34:56.789+01:23"); - d.setUTCSeconds(36, 420); - return { - TAG: "Eq", - _0: [ - 36, - 420 - ], - _1: [ - d.getUTCSeconds(), - d.getUTCMilliseconds() - ] - }; - } - ], - tl: { - hd: [ - "toDateString", - param => ({ - TAG: "Eq", - _0: "Mon Mar 08 1976", - _1: new Date("1976-03-08T12:34:56.789+01:23").toDateString() - }) - ], - tl: { - hd: [ - "toGMTString", - param => ({ - TAG: "Eq", - _0: "Mon, 08 Mar 1976 11:11:56 GMT", - _1: new Date("1976-03-08T12:34:56.789+01:23").toUTCString() - }) - ], - tl: { - hd: [ - "toISOString", - param => ({ - TAG: "Eq", - _0: "1976-03-08T11:11:56.789Z", - _1: new Date("1976-03-08T12:34:56.789+01:23").toISOString() - }) - ], - tl: { - hd: [ - "toJSON", - param => ({ - TAG: "Eq", - _0: "1976-03-08T11:11:56.789Z", - _1: new Date("1976-03-08T12:34:56.789+01:23").toJSON() - }) - ], - tl: { - hd: [ - "toJSONUnsafe", - param => ({ - TAG: "Eq", - _0: "1976-03-08T11:11:56.789Z", - _1: new Date("1976-03-08T12:34:56.789+01:23").toJSON() - }) - ], - tl: { - hd: [ - "toUTCString", - param => ({ - TAG: "Eq", - _0: "Mon, 08 Mar 1976 11:11:56 GMT", - _1: new Date("1976-03-08T12:34:56.789+01:23").toUTCString() - }) - ], - tl: { - hd: [ - "eq", - param => { - let a = new Date("2013-03-01T01:10:00"); - let b = new Date("2013-03-01T01:10:00"); - let c = new Date("2013-03-01T01:10:01"); - return { - TAG: "Ok", - _0: Primitive_object.equal(a, b) && Primitive_object.notequal(b, c) && Primitive_object.greaterthan(c, b) - }; - } - ], - tl: /* [] */0 - } - } - } - } - } - } - } - } - } - } - } - } - } - } - } - } - } - } - } - } - } - } - } - } - } - } - } - } - } - } - } - } - } - } - } - } - } - } - } - } - } - } - } - } - } - } - } - } - } - } - } - } - } - } - } - } - } - } - } - } - } - } - } - } - } -}; - -let suites = { - hd: suites_0, - tl: suites_1 -}; - -Mt.from_pair_suites("Js_date_test", suites); - -let N; - -exports.N = N; -exports.date = date; -exports.suites = suites; -/* Not a pure module */ diff --git a/tests/tests/src/js_date_test.mjs b/tests/tests/src/js_date_test.mjs new file mode 100644 index 0000000000..6970ed1c59 --- /dev/null +++ b/tests/tests/src/js_date_test.mjs @@ -0,0 +1,1059 @@ +// Generated by ReScript, PLEASE EDIT WITH CARE + +import * as Mt from "./mt.mjs"; +import * as Primitive_object from "rescript/lib/es6/Primitive_object.js"; + +function date() { + return new Date("1976-03-08T12:34:56.789+01:23"); +} + +let suites_0 = [ + "valueOf", + param => ({ + TAG: "Eq", + _0: 195131516789, + _1: new Date("1976-03-08T12:34:56.789+01:23").valueOf() + }) +]; + +let suites_1 = { + hd: [ + "make", + param => ({ + TAG: "Ok", + _0: new Date().getTime() > 1487223505382 + }) + ], + tl: { + hd: [ + "parseAsFloat", + param => ({ + TAG: "Eq", + _0: Date.parse("1976-03-08T12:34:56.789+01:23"), + _1: 195131516789 + }) + ], + tl: { + hd: [ + "parseAsFloat_invalid", + param => ({ + TAG: "Ok", + _0: Number.isNaN(Date.parse("gibberish")) + }) + ], + tl: { + hd: [ + "fromFloat", + param => ({ + TAG: "Eq", + _0: "1976-03-08T11:11:56.789Z", + _1: new Date(195131516789).toISOString() + }) + ], + tl: { + hd: [ + "fromString_valid", + param => ({ + TAG: "Eq", + _0: 195131516789, + _1: new Date("1976-03-08T12:34:56.789+01:23").getTime() + }) + ], + tl: { + hd: [ + "fromString_invalid", + param => ({ + TAG: "Ok", + _0: Number.isNaN(new Date("gibberish").getTime()) + }) + ], + tl: { + hd: [ + "makeWithYM", + param => { + let d = new Date(1984, 4); + return { + TAG: "Eq", + _0: [ + 1984, + 4 + ], + _1: [ + d.getFullYear(), + d.getMonth() + ] + }; + } + ], + tl: { + hd: [ + "makeWithYMD", + param => { + let d = new Date(1984, 4, 6); + return { + TAG: "Eq", + _0: [ + 1984, + 4, + 6 + ], + _1: [ + d.getFullYear(), + d.getMonth(), + d.getDate() + ] + }; + } + ], + tl: { + hd: [ + "makeWithYMDH", + param => { + let d = new Date(1984, 4, 6, 3); + return { + TAG: "Eq", + _0: [ + 1984, + 4, + 6, + 3 + ], + _1: [ + d.getFullYear(), + d.getMonth(), + d.getDate(), + d.getHours() + ] + }; + } + ], + tl: { + hd: [ + "makeWithYMDHM", + param => { + let d = new Date(1984, 4, 6, 3, 59); + return { + TAG: "Eq", + _0: [ + 1984, + 4, + 6, + 3, + 59 + ], + _1: [ + d.getFullYear(), + d.getMonth(), + d.getDate(), + d.getHours(), + d.getMinutes() + ] + }; + } + ], + tl: { + hd: [ + "makeWithYMDHMS", + param => { + let d = new Date(1984, 4, 6, 3, 59, 27); + return { + TAG: "Eq", + _0: [ + 1984, + 4, + 6, + 3, + 59, + 27 + ], + _1: [ + d.getFullYear(), + d.getMonth(), + d.getDate(), + d.getHours(), + d.getMinutes(), + d.getSeconds() + ] + }; + } + ], + tl: { + hd: [ + "utcWithYM", + param => { + let d = Date.UTC(1984, 4); + let d$1 = new Date(d); + return { + TAG: "Eq", + _0: [ + 1984, + 4 + ], + _1: [ + d$1.getUTCFullYear(), + d$1.getUTCMonth() + ] + }; + } + ], + tl: { + hd: [ + "utcWithYMD", + param => { + let d = Date.UTC(1984, 4, 6); + let d$1 = new Date(d); + return { + TAG: "Eq", + _0: [ + 1984, + 4, + 6 + ], + _1: [ + d$1.getUTCFullYear(), + d$1.getUTCMonth(), + d$1.getUTCDate() + ] + }; + } + ], + tl: { + hd: [ + "utcWithYMDH", + param => { + let d = Date.UTC(1984, 4, 6, 3); + let d$1 = new Date(d); + return { + TAG: "Eq", + _0: [ + 1984, + 4, + 6, + 3 + ], + _1: [ + d$1.getUTCFullYear(), + d$1.getUTCMonth(), + d$1.getUTCDate(), + d$1.getUTCHours() + ] + }; + } + ], + tl: { + hd: [ + "utcWithYMDHM", + param => { + let d = Date.UTC(1984, 4, 6, 3, 59); + let d$1 = new Date(d); + return { + TAG: "Eq", + _0: [ + 1984, + 4, + 6, + 3, + 59 + ], + _1: [ + d$1.getUTCFullYear(), + d$1.getUTCMonth(), + d$1.getUTCDate(), + d$1.getUTCHours(), + d$1.getUTCMinutes() + ] + }; + } + ], + tl: { + hd: [ + "utcWithYMDHMS", + param => { + let d = Date.UTC(1984, 4, 6, 3, 59, 27); + let d$1 = new Date(d); + return { + TAG: "Eq", + _0: [ + 1984, + 4, + 6, + 3, + 59, + 27 + ], + _1: [ + d$1.getUTCFullYear(), + d$1.getUTCMonth(), + d$1.getUTCDate(), + d$1.getUTCHours(), + d$1.getUTCMinutes(), + d$1.getUTCSeconds() + ] + }; + } + ], + tl: { + hd: [ + "getFullYear", + param => ({ + TAG: "Eq", + _0: 1976, + _1: new Date("1976-03-08T12:34:56.789+01:23").getFullYear() + }) + ], + tl: { + hd: [ + "getMilliseconds", + param => ({ + TAG: "Eq", + _0: 789, + _1: new Date("1976-03-08T12:34:56.789+01:23").getMilliseconds() + }) + ], + tl: { + hd: [ + "getSeconds", + param => ({ + TAG: "Eq", + _0: 56, + _1: new Date("1976-03-08T12:34:56.789+01:23").getSeconds() + }) + ], + tl: { + hd: [ + "getTime", + param => ({ + TAG: "Eq", + _0: 195131516789, + _1: new Date("1976-03-08T12:34:56.789+01:23").getTime() + }) + ], + tl: { + hd: [ + "getUTCDate", + param => ({ + TAG: "Eq", + _0: 8, + _1: new Date("1976-03-08T12:34:56.789+01:23").getUTCDate() + }) + ], + tl: { + hd: [ + "getUTCDay", + param => ({ + TAG: "Eq", + _0: 1, + _1: new Date("1976-03-08T12:34:56.789+01:23").getUTCDay() + }) + ], + tl: { + hd: [ + "getUTCFUllYear", + param => ({ + TAG: "Eq", + _0: 1976, + _1: new Date("1976-03-08T12:34:56.789+01:23").getUTCFullYear() + }) + ], + tl: { + hd: [ + "getUTCHours", + param => ({ + TAG: "Eq", + _0: 11, + _1: new Date("1976-03-08T12:34:56.789+01:23").getUTCHours() + }) + ], + tl: { + hd: [ + "getUTCMilliseconds", + param => ({ + TAG: "Eq", + _0: 789, + _1: new Date("1976-03-08T12:34:56.789+01:23").getUTCMilliseconds() + }) + ], + tl: { + hd: [ + "getUTCMinutes", + param => ({ + TAG: "Eq", + _0: 11, + _1: new Date("1976-03-08T12:34:56.789+01:23").getUTCMinutes() + }) + ], + tl: { + hd: [ + "getUTCMonth", + param => ({ + TAG: "Eq", + _0: 2, + _1: new Date("1976-03-08T12:34:56.789+01:23").getUTCMonth() + }) + ], + tl: { + hd: [ + "getUTCSeconds", + param => ({ + TAG: "Eq", + _0: 56, + _1: new Date("1976-03-08T12:34:56.789+01:23").getUTCSeconds() + }) + ], + tl: { + hd: [ + "getYear", + param => ({ + TAG: "Eq", + _0: 1976, + _1: new Date("1976-03-08T12:34:56.789+01:23").getFullYear() + }) + ], + tl: { + hd: [ + "setDate", + param => { + let d = new Date("1976-03-08T12:34:56.789+01:23"); + d.setDate(12); + return { + TAG: "Eq", + _0: 12, + _1: d.getDate() + }; + } + ], + tl: { + hd: [ + "setFullYear", + param => { + let d = new Date("1976-03-08T12:34:56.789+01:23"); + d.setFullYear(1986); + return { + TAG: "Eq", + _0: 1986, + _1: d.getFullYear() + }; + } + ], + tl: { + hd: [ + "setFullYearM", + param => { + let d = new Date("1976-03-08T12:34:56.789+01:23"); + d.setFullYear(1986, 7); + return { + TAG: "Eq", + _0: [ + 1986, + 7 + ], + _1: [ + d.getFullYear(), + d.getMonth() + ] + }; + } + ], + tl: { + hd: [ + "setFullYearMD", + param => { + let d = new Date("1976-03-08T12:34:56.789+01:23"); + d.setFullYear(1986, 7, 23); + return { + TAG: "Eq", + _0: [ + 1986, + 7, + 23 + ], + _1: [ + d.getFullYear(), + d.getMonth(), + d.getDate() + ] + }; + } + ], + tl: { + hd: [ + "setHours", + param => { + let d = new Date("1976-03-08T12:34:56.789+01:23"); + d.setHours(22); + return { + TAG: "Eq", + _0: 22, + _1: d.getHours() + }; + } + ], + tl: { + hd: [ + "setHoursM", + param => { + let d = new Date("1976-03-08T12:34:56.789+01:23"); + d.setHours(22, 48); + return { + TAG: "Eq", + _0: [ + 22, + 48 + ], + _1: [ + d.getHours(), + d.getMinutes() + ] + }; + } + ], + tl: { + hd: [ + "setHoursMS", + param => { + let d = new Date("1976-03-08T12:34:56.789+01:23"); + d.setHours(22, 48, 54); + return { + TAG: "Eq", + _0: [ + 22, + 48, + 54 + ], + _1: [ + d.getHours(), + d.getMinutes(), + d.getSeconds() + ] + }; + } + ], + tl: { + hd: [ + "setMilliseconds", + param => { + let d = new Date("1976-03-08T12:34:56.789+01:23"); + d.setMilliseconds(543); + return { + TAG: "Eq", + _0: 543, + _1: d.getMilliseconds() + }; + } + ], + tl: { + hd: [ + "setMinutes", + param => { + let d = new Date("1976-03-08T12:34:56.789+01:23"); + d.setMinutes(18); + return { + TAG: "Eq", + _0: 18, + _1: d.getMinutes() + }; + } + ], + tl: { + hd: [ + "setMinutesS", + param => { + let d = new Date("1976-03-08T12:34:56.789+01:23"); + d.setMinutes(18, 42); + return { + TAG: "Eq", + _0: [ + 18, + 42 + ], + _1: [ + d.getMinutes(), + d.getSeconds() + ] + }; + } + ], + tl: { + hd: [ + "setMinutesSMs", + param => { + let d = new Date("1976-03-08T12:34:56.789+01:23"); + d.setMinutes(18, 42, 311); + return { + TAG: "Eq", + _0: [ + 18, + 42, + 311 + ], + _1: [ + d.getMinutes(), + d.getSeconds(), + d.getMilliseconds() + ] + }; + } + ], + tl: { + hd: [ + "setMonth", + param => { + let d = new Date("1976-03-08T12:34:56.789+01:23"); + d.setMonth(10); + return { + TAG: "Eq", + _0: 10, + _1: d.getMonth() + }; + } + ], + tl: { + hd: [ + "setMonthD", + param => { + let d = new Date("1976-03-08T12:34:56.789+01:23"); + d.setMonth(10, 14); + return { + TAG: "Eq", + _0: [ + 10, + 14 + ], + _1: [ + d.getMonth(), + d.getDate() + ] + }; + } + ], + tl: { + hd: [ + "setSeconds", + param => { + let d = new Date("1976-03-08T12:34:56.789+01:23"); + d.setSeconds(36); + return { + TAG: "Eq", + _0: 36, + _1: d.getSeconds() + }; + } + ], + tl: { + hd: [ + "setSecondsMs", + param => { + let d = new Date("1976-03-08T12:34:56.789+01:23"); + d.setSeconds(36, 420); + return { + TAG: "Eq", + _0: [ + 36, + 420 + ], + _1: [ + d.getSeconds(), + d.getMilliseconds() + ] + }; + } + ], + tl: { + hd: [ + "setUTCDate", + param => { + let d = new Date("1976-03-08T12:34:56.789+01:23"); + d.setUTCDate(12); + return { + TAG: "Eq", + _0: 12, + _1: d.getUTCDate() + }; + } + ], + tl: { + hd: [ + "setUTCFullYear", + param => { + let d = new Date("1976-03-08T12:34:56.789+01:23"); + d.setUTCFullYear(1986); + return { + TAG: "Eq", + _0: 1986, + _1: d.getUTCFullYear() + }; + } + ], + tl: { + hd: [ + "setUTCFullYearM", + param => { + let d = new Date("1976-03-08T12:34:56.789+01:23"); + d.setUTCFullYear(1986, 7); + return { + TAG: "Eq", + _0: [ + 1986, + 7 + ], + _1: [ + d.getUTCFullYear(), + d.getUTCMonth() + ] + }; + } + ], + tl: { + hd: [ + "setUTCFullYearMD", + param => { + let d = new Date("1976-03-08T12:34:56.789+01:23"); + d.setUTCFullYear(1986, 7, 23); + return { + TAG: "Eq", + _0: [ + 1986, + 7, + 23 + ], + _1: [ + d.getUTCFullYear(), + d.getUTCMonth(), + d.getUTCDate() + ] + }; + } + ], + tl: { + hd: [ + "setUTCHours", + param => { + let d = new Date("1976-03-08T12:34:56.789+01:23"); + d.setUTCHours(22); + return { + TAG: "Eq", + _0: 22, + _1: d.getUTCHours() + }; + } + ], + tl: { + hd: [ + "setUTCHoursM", + param => { + let d = new Date("1976-03-08T12:34:56.789+01:23"); + d.setUTCHours(22, 48); + return { + TAG: "Eq", + _0: [ + 22, + 48 + ], + _1: [ + d.getUTCHours(), + d.getUTCMinutes() + ] + }; + } + ], + tl: { + hd: [ + "setUTCHoursMS", + param => { + let d = new Date("1976-03-08T12:34:56.789+01:23"); + d.setUTCHours(22, 48, 54); + return { + TAG: "Eq", + _0: [ + 22, + 48, + 54 + ], + _1: [ + d.getUTCHours(), + d.getUTCMinutes(), + d.getUTCSeconds() + ] + }; + } + ], + tl: { + hd: [ + "setUTCMilliseconds", + param => { + let d = new Date("1976-03-08T12:34:56.789+01:23"); + d.setUTCMilliseconds(543); + return { + TAG: "Eq", + _0: 543, + _1: d.getUTCMilliseconds() + }; + } + ], + tl: { + hd: [ + "setUTCMinutes", + param => { + let d = new Date("1976-03-08T12:34:56.789+01:23"); + d.setUTCMinutes(18); + return { + TAG: "Eq", + _0: 18, + _1: d.getUTCMinutes() + }; + } + ], + tl: { + hd: [ + "setUTCMinutesS", + param => { + let d = new Date("1976-03-08T12:34:56.789+01:23"); + d.setUTCMinutes(18, 42); + return { + TAG: "Eq", + _0: [ + 18, + 42 + ], + _1: [ + d.getUTCMinutes(), + d.getUTCSeconds() + ] + }; + } + ], + tl: { + hd: [ + "setUTCMinutesSMs", + param => { + let d = new Date("1976-03-08T12:34:56.789+01:23"); + d.setUTCMinutes(18, 42, 311); + return { + TAG: "Eq", + _0: [ + 18, + 42, + 311 + ], + _1: [ + d.getUTCMinutes(), + d.getUTCSeconds(), + d.getUTCMilliseconds() + ] + }; + } + ], + tl: { + hd: [ + "setUTCMonth", + param => { + let d = new Date("1976-03-08T12:34:56.789+01:23"); + d.setUTCMonth(10); + return { + TAG: "Eq", + _0: 10, + _1: d.getUTCMonth() + }; + } + ], + tl: { + hd: [ + "setUTCMonthD", + param => { + let d = new Date("1976-03-08T12:34:56.789+01:23"); + d.setUTCMonth(10, 14); + return { + TAG: "Eq", + _0: [ + 10, + 14 + ], + _1: [ + d.getUTCMonth(), + d.getUTCDate() + ] + }; + } + ], + tl: { + hd: [ + "setUTCSeconds", + param => { + let d = new Date("1976-03-08T12:34:56.789+01:23"); + d.setUTCSeconds(36); + return { + TAG: "Eq", + _0: 36, + _1: d.getUTCSeconds() + }; + } + ], + tl: { + hd: [ + "setUTCSecondsMs", + param => { + let d = new Date("1976-03-08T12:34:56.789+01:23"); + d.setUTCSeconds(36, 420); + return { + TAG: "Eq", + _0: [ + 36, + 420 + ], + _1: [ + d.getUTCSeconds(), + d.getUTCMilliseconds() + ] + }; + } + ], + tl: { + hd: [ + "toDateString", + param => ({ + TAG: "Eq", + _0: "Mon Mar 08 1976", + _1: new Date("1976-03-08T12:34:56.789+01:23").toDateString() + }) + ], + tl: { + hd: [ + "toGMTString", + param => ({ + TAG: "Eq", + _0: "Mon, 08 Mar 1976 11:11:56 GMT", + _1: new Date("1976-03-08T12:34:56.789+01:23").toUTCString() + }) + ], + tl: { + hd: [ + "toISOString", + param => ({ + TAG: "Eq", + _0: "1976-03-08T11:11:56.789Z", + _1: new Date("1976-03-08T12:34:56.789+01:23").toISOString() + }) + ], + tl: { + hd: [ + "toJSON", + param => ({ + TAG: "Eq", + _0: "1976-03-08T11:11:56.789Z", + _1: new Date("1976-03-08T12:34:56.789+01:23").toJSON() + }) + ], + tl: { + hd: [ + "toJSONUnsafe", + param => ({ + TAG: "Eq", + _0: "1976-03-08T11:11:56.789Z", + _1: new Date("1976-03-08T12:34:56.789+01:23").toJSON() + }) + ], + tl: { + hd: [ + "toUTCString", + param => ({ + TAG: "Eq", + _0: "Mon, 08 Mar 1976 11:11:56 GMT", + _1: new Date("1976-03-08T12:34:56.789+01:23").toUTCString() + }) + ], + tl: { + hd: [ + "eq", + param => { + let a = new Date("2013-03-01T01:10:00"); + let b = new Date("2013-03-01T01:10:00"); + let c = new Date("2013-03-01T01:10:01"); + return { + TAG: "Ok", + _0: Primitive_object.equal(a, b) && Primitive_object.notequal(b, c) && Primitive_object.greaterthan(c, b) + }; + } + ], + tl: /* [] */0 + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } +}; + +let suites = { + hd: suites_0, + tl: suites_1 +}; + +Mt.from_pair_suites("Js_date_test", suites); + +let N; + +export { + N, + date, + suites, +} +/* Not a pure module */ diff --git a/tests/tests/src/js_dict_test.js b/tests/tests/src/js_dict_test.js deleted file mode 100644 index 911cabffba..0000000000 --- a/tests/tests/src/js_dict_test.js +++ /dev/null @@ -1,239 +0,0 @@ -// Generated by ReScript, PLEASE EDIT WITH CARE -'use strict'; - -let Mt = require("./mt.js"); -let Js_dict = require("rescript/lib/js/Js_dict.js"); - -function obj() { - return { - foo: 43, - bar: 86 - }; -} - -let suites_0 = [ - "empty", - param => ({ - TAG: "Eq", - _0: [], - _1: Object.keys({}) - }) -]; - -let suites_1 = { - hd: [ - "get", - param => ({ - TAG: "Eq", - _0: 43, - _1: Js_dict.get({ - foo: 43, - bar: 86 - }, "foo") - }) - ], - tl: { - hd: [ - "get - property not in object", - param => ({ - TAG: "Eq", - _0: undefined, - _1: Js_dict.get({ - foo: 43, - bar: 86 - }, "baz") - }) - ], - tl: { - hd: [ - "unsafe_get", - param => ({ - TAG: "Eq", - _0: 43, - _1: ({ - foo: 43, - bar: 86 - })["foo"] - }) - ], - tl: { - hd: [ - "set", - param => { - let o = { - foo: 43, - bar: 86 - }; - o["foo"] = 36; - return { - TAG: "Eq", - _0: 36, - _1: Js_dict.get(o, "foo") - }; - } - ], - tl: { - hd: [ - "keys", - param => ({ - TAG: "Eq", - _0: [ - "foo", - "bar" - ], - _1: Object.keys({ - foo: 43, - bar: 86 - }) - }) - ], - tl: { - hd: [ - "entries", - param => ({ - TAG: "Eq", - _0: [ - [ - "foo", - 43 - ], - [ - "bar", - 86 - ] - ], - _1: Js_dict.entries({ - foo: 43, - bar: 86 - }) - }) - ], - tl: { - hd: [ - "values", - param => ({ - TAG: "Eq", - _0: [ - 43, - 86 - ], - _1: Js_dict.values({ - foo: 43, - bar: 86 - }) - }) - ], - tl: { - hd: [ - "fromList - []", - param => ({ - TAG: "Eq", - _0: {}, - _1: Js_dict.fromList(/* [] */0) - }) - ], - tl: { - hd: [ - "fromList", - param => ({ - TAG: "Eq", - _0: [ - [ - "x", - 23 - ], - [ - "y", - 46 - ] - ], - _1: Js_dict.entries(Js_dict.fromList({ - hd: [ - "x", - 23 - ], - tl: { - hd: [ - "y", - 46 - ], - tl: /* [] */0 - } - })) - }) - ], - tl: { - hd: [ - "fromArray - []", - param => ({ - TAG: "Eq", - _0: {}, - _1: Js_dict.fromArray([]) - }) - ], - tl: { - hd: [ - "fromArray", - param => ({ - TAG: "Eq", - _0: [ - [ - "x", - 23 - ], - [ - "y", - 46 - ] - ], - _1: Js_dict.entries(Js_dict.fromArray([ - [ - "x", - 23 - ], - [ - "y", - 46 - ] - ])) - }) - ], - tl: { - hd: [ - "map", - param => ({ - TAG: "Eq", - _0: { - foo: "43", - bar: "86" - }, - _1: Js_dict.map(i => i.toString(), { - foo: 43, - bar: 86 - }) - }) - ], - tl: /* [] */0 - } - } - } - } - } - } - } - } - } - } - } -}; - -let suites = { - hd: suites_0, - tl: suites_1 -}; - -Mt.from_pair_suites("Js_dict_test", suites); - -exports.obj = obj; -exports.suites = suites; -/* Not a pure module */ diff --git a/tests/tests/src/js_dict_test.mjs b/tests/tests/src/js_dict_test.mjs new file mode 100644 index 0000000000..762b69f8de --- /dev/null +++ b/tests/tests/src/js_dict_test.mjs @@ -0,0 +1,240 @@ +// Generated by ReScript, PLEASE EDIT WITH CARE + +import * as Mt from "./mt.mjs"; +import * as Js_dict from "rescript/lib/es6/Js_dict.js"; + +function obj() { + return { + foo: 43, + bar: 86 + }; +} + +let suites_0 = [ + "empty", + param => ({ + TAG: "Eq", + _0: [], + _1: Object.keys({}) + }) +]; + +let suites_1 = { + hd: [ + "get", + param => ({ + TAG: "Eq", + _0: 43, + _1: Js_dict.get({ + foo: 43, + bar: 86 + }, "foo") + }) + ], + tl: { + hd: [ + "get - property not in object", + param => ({ + TAG: "Eq", + _0: undefined, + _1: Js_dict.get({ + foo: 43, + bar: 86 + }, "baz") + }) + ], + tl: { + hd: [ + "unsafe_get", + param => ({ + TAG: "Eq", + _0: 43, + _1: ({ + foo: 43, + bar: 86 + })["foo"] + }) + ], + tl: { + hd: [ + "set", + param => { + let o = { + foo: 43, + bar: 86 + }; + o["foo"] = 36; + return { + TAG: "Eq", + _0: 36, + _1: Js_dict.get(o, "foo") + }; + } + ], + tl: { + hd: [ + "keys", + param => ({ + TAG: "Eq", + _0: [ + "foo", + "bar" + ], + _1: Object.keys({ + foo: 43, + bar: 86 + }) + }) + ], + tl: { + hd: [ + "entries", + param => ({ + TAG: "Eq", + _0: [ + [ + "foo", + 43 + ], + [ + "bar", + 86 + ] + ], + _1: Js_dict.entries({ + foo: 43, + bar: 86 + }) + }) + ], + tl: { + hd: [ + "values", + param => ({ + TAG: "Eq", + _0: [ + 43, + 86 + ], + _1: Js_dict.values({ + foo: 43, + bar: 86 + }) + }) + ], + tl: { + hd: [ + "fromList - []", + param => ({ + TAG: "Eq", + _0: {}, + _1: Js_dict.fromList(/* [] */0) + }) + ], + tl: { + hd: [ + "fromList", + param => ({ + TAG: "Eq", + _0: [ + [ + "x", + 23 + ], + [ + "y", + 46 + ] + ], + _1: Js_dict.entries(Js_dict.fromList({ + hd: [ + "x", + 23 + ], + tl: { + hd: [ + "y", + 46 + ], + tl: /* [] */0 + } + })) + }) + ], + tl: { + hd: [ + "fromArray - []", + param => ({ + TAG: "Eq", + _0: {}, + _1: Js_dict.fromArray([]) + }) + ], + tl: { + hd: [ + "fromArray", + param => ({ + TAG: "Eq", + _0: [ + [ + "x", + 23 + ], + [ + "y", + 46 + ] + ], + _1: Js_dict.entries(Js_dict.fromArray([ + [ + "x", + 23 + ], + [ + "y", + 46 + ] + ])) + }) + ], + tl: { + hd: [ + "map", + param => ({ + TAG: "Eq", + _0: { + foo: "43", + bar: "86" + }, + _1: Js_dict.map(i => i.toString(), { + foo: 43, + bar: 86 + }) + }) + ], + tl: /* [] */0 + } + } + } + } + } + } + } + } + } + } + } +}; + +let suites = { + hd: suites_0, + tl: suites_1 +}; + +Mt.from_pair_suites("Js_dict_test", suites); + +export { + obj, + suites, +} +/* Not a pure module */ diff --git a/tests/tests/src/js_exception_catch_test.js b/tests/tests/src/js_exception_catch_test.js deleted file mode 100644 index 60a773a8a0..0000000000 --- a/tests/tests/src/js_exception_catch_test.js +++ /dev/null @@ -1,188 +0,0 @@ -// Generated by ReScript, PLEASE EDIT WITH CARE -'use strict'; - -let Mt = require("./mt.js"); -let Exn = require("rescript/lib/js/Exn.js"); -let Pervasives = require("rescript/lib/js/Pervasives.js"); -let Primitive_exceptions = require("rescript/lib/js/Primitive_exceptions.js"); - -let suites = { - contents: /* [] */0 -}; - -let counter = { - contents: 0 -}; - -function add_test(loc, test) { - counter.contents = counter.contents + 1 | 0; - let id = loc + (" id " + counter.contents.toString()); - suites.contents = { - hd: [ - id, - test - ], - tl: suites.contents - }; -} - -function eq(loc, x, y) { - add_test(loc, () => ({ - TAG: "Eq", - _0: x, - _1: y - })); -} - -function false_(loc) { - add_test(loc, () => ({ - TAG: "Ok", - _0: false - })); -} - -function true_(loc) { - add_test(loc, () => ({ - TAG: "Ok", - _0: true - })); -} - -let exit = 0; - -let e; - -try { - e = JSON.parse(" {\"x\"}"); - exit = 1; -} catch (raw_x) { - let x = Primitive_exceptions.internalToException(raw_x); - if (x.RE_EXN_ID === Exn.$$Error) { - add_test("File \"js_exception_catch_test.res\", line 18, characters 37-44", () => ({ - TAG: "Ok", - _0: true - })); - } else { - throw x; - } -} - -if (exit === 1) { - add_test("File \"js_exception_catch_test.res\", line 19, characters 14-21", () => ({ - TAG: "Ok", - _0: false - })); -} - -let A = /* @__PURE__ */Primitive_exceptions.create("Js_exception_catch_test.A"); - -let B = /* @__PURE__ */Primitive_exceptions.create("Js_exception_catch_test.B"); - -let C = /* @__PURE__ */Primitive_exceptions.create("Js_exception_catch_test.C"); - -function test(f) { - try { - f(); - return "No_error"; - } catch (raw_e) { - let e = Primitive_exceptions.internalToException(raw_e); - if (e.RE_EXN_ID === "Not_found") { - return "Not_found"; - } else if (e.RE_EXN_ID === "Invalid_argument") { - if (e._1 === "x") { - return "Invalid_argument"; - } else { - return "Invalid_any"; - } - } else if (e.RE_EXN_ID === A) { - if (e._1 !== 2) { - return "A_any"; - } else { - return "A2"; - } - } else if (e.RE_EXN_ID === B) { - return "B"; - } else if (e.RE_EXN_ID === C) { - if (e._1 !== 1 || e._2 !== 2) { - return "C_any"; - } else { - return "C"; - } - } else if (e.RE_EXN_ID === Exn.$$Error) { - return "Js_error"; - } else { - return "Any"; - } - } -} - -eq("File \"js_exception_catch_test.res\", line 44, characters 5-12", test(() => {}), "No_error"); - -eq("File \"js_exception_catch_test.res\", line 45, characters 5-12", test(() => { - throw { - RE_EXN_ID: "Not_found", - Error: new Error() - }; -}), "Not_found"); - -eq("File \"js_exception_catch_test.res\", line 46, characters 5-12", test(() => Pervasives.invalid_arg("x")), "Invalid_argument"); - -eq("File \"js_exception_catch_test.res\", line 47, characters 5-12", test(() => Pervasives.invalid_arg("")), "Invalid_any"); - -eq("File \"js_exception_catch_test.res\", line 48, characters 5-12", test(() => { - throw { - RE_EXN_ID: A, - _1: 2, - Error: new Error() - }; -}), "A2"); - -eq("File \"js_exception_catch_test.res\", line 49, characters 5-12", test(() => { - throw { - RE_EXN_ID: A, - _1: 3, - Error: new Error() - }; -}), "A_any"); - -eq("File \"js_exception_catch_test.res\", line 50, characters 5-12", test(() => { - throw { - RE_EXN_ID: B, - Error: new Error() - }; -}), "B"); - -eq("File \"js_exception_catch_test.res\", line 51, characters 5-12", test(() => { - throw { - RE_EXN_ID: C, - _1: 1, - _2: 2, - Error: new Error() - }; -}), "C"); - -eq("File \"js_exception_catch_test.res\", line 52, characters 5-12", test(() => { - throw { - RE_EXN_ID: C, - _1: 0, - _2: 2, - Error: new Error() - }; -}), "C_any"); - -eq("File \"js_exception_catch_test.res\", line 53, characters 5-12", test(() => Exn.raiseError("x")), "Js_error"); - -eq("File \"js_exception_catch_test.res\", line 54, characters 5-12", test(() => Pervasives.failwith("x")), "Any"); - -Mt.from_pair_suites("Js_exception_catch_test", suites.contents); - -exports.suites = suites; -exports.add_test = add_test; -exports.eq = eq; -exports.false_ = false_; -exports.true_ = true_; -exports.A = A; -exports.B = B; -exports.C = C; -exports.test = test; -/* Not a pure module */ diff --git a/tests/tests/src/js_exception_catch_test.mjs b/tests/tests/src/js_exception_catch_test.mjs new file mode 100644 index 0000000000..040fd2c6ca --- /dev/null +++ b/tests/tests/src/js_exception_catch_test.mjs @@ -0,0 +1,189 @@ +// Generated by ReScript, PLEASE EDIT WITH CARE + +import * as Mt from "./mt.mjs"; +import * as Exn from "rescript/lib/es6/Exn.js"; +import * as Pervasives from "rescript/lib/es6/Pervasives.js"; +import * as Primitive_exceptions from "rescript/lib/es6/Primitive_exceptions.js"; + +let suites = { + contents: /* [] */0 +}; + +let counter = { + contents: 0 +}; + +function add_test(loc, test) { + counter.contents = counter.contents + 1 | 0; + let id = loc + (" id " + counter.contents.toString()); + suites.contents = { + hd: [ + id, + test + ], + tl: suites.contents + }; +} + +function eq(loc, x, y) { + add_test(loc, () => ({ + TAG: "Eq", + _0: x, + _1: y + })); +} + +function false_(loc) { + add_test(loc, () => ({ + TAG: "Ok", + _0: false + })); +} + +function true_(loc) { + add_test(loc, () => ({ + TAG: "Ok", + _0: true + })); +} + +let exit = 0; + +let e; + +try { + e = JSON.parse(" {\"x\"}"); + exit = 1; +} catch (raw_x) { + let x = Primitive_exceptions.internalToException(raw_x); + if (x.RE_EXN_ID === Exn.$$Error) { + add_test("File \"js_exception_catch_test.res\", line 18, characters 37-44", () => ({ + TAG: "Ok", + _0: true + })); + } else { + throw x; + } +} + +if (exit === 1) { + add_test("File \"js_exception_catch_test.res\", line 19, characters 14-21", () => ({ + TAG: "Ok", + _0: false + })); +} + +let A = /* @__PURE__ */Primitive_exceptions.create("Js_exception_catch_test.A"); + +let B = /* @__PURE__ */Primitive_exceptions.create("Js_exception_catch_test.B"); + +let C = /* @__PURE__ */Primitive_exceptions.create("Js_exception_catch_test.C"); + +function test(f) { + try { + f(); + return "No_error"; + } catch (raw_e) { + let e = Primitive_exceptions.internalToException(raw_e); + if (e.RE_EXN_ID === "Not_found") { + return "Not_found"; + } else if (e.RE_EXN_ID === "Invalid_argument") { + if (e._1 === "x") { + return "Invalid_argument"; + } else { + return "Invalid_any"; + } + } else if (e.RE_EXN_ID === A) { + if (e._1 !== 2) { + return "A_any"; + } else { + return "A2"; + } + } else if (e.RE_EXN_ID === B) { + return "B"; + } else if (e.RE_EXN_ID === C) { + if (e._1 !== 1 || e._2 !== 2) { + return "C_any"; + } else { + return "C"; + } + } else if (e.RE_EXN_ID === Exn.$$Error) { + return "Js_error"; + } else { + return "Any"; + } + } +} + +eq("File \"js_exception_catch_test.res\", line 44, characters 5-12", test(() => {}), "No_error"); + +eq("File \"js_exception_catch_test.res\", line 45, characters 5-12", test(() => { + throw { + RE_EXN_ID: "Not_found", + Error: new Error() + }; +}), "Not_found"); + +eq("File \"js_exception_catch_test.res\", line 46, characters 5-12", test(() => Pervasives.invalid_arg("x")), "Invalid_argument"); + +eq("File \"js_exception_catch_test.res\", line 47, characters 5-12", test(() => Pervasives.invalid_arg("")), "Invalid_any"); + +eq("File \"js_exception_catch_test.res\", line 48, characters 5-12", test(() => { + throw { + RE_EXN_ID: A, + _1: 2, + Error: new Error() + }; +}), "A2"); + +eq("File \"js_exception_catch_test.res\", line 49, characters 5-12", test(() => { + throw { + RE_EXN_ID: A, + _1: 3, + Error: new Error() + }; +}), "A_any"); + +eq("File \"js_exception_catch_test.res\", line 50, characters 5-12", test(() => { + throw { + RE_EXN_ID: B, + Error: new Error() + }; +}), "B"); + +eq("File \"js_exception_catch_test.res\", line 51, characters 5-12", test(() => { + throw { + RE_EXN_ID: C, + _1: 1, + _2: 2, + Error: new Error() + }; +}), "C"); + +eq("File \"js_exception_catch_test.res\", line 52, characters 5-12", test(() => { + throw { + RE_EXN_ID: C, + _1: 0, + _2: 2, + Error: new Error() + }; +}), "C_any"); + +eq("File \"js_exception_catch_test.res\", line 53, characters 5-12", test(() => Exn.raiseError("x")), "Js_error"); + +eq("File \"js_exception_catch_test.res\", line 54, characters 5-12", test(() => Pervasives.failwith("x")), "Any"); + +Mt.from_pair_suites("Js_exception_catch_test", suites.contents); + +export { + suites, + add_test, + eq, + false_, + true_, + A, + B, + C, + test, +} +/* Not a pure module */ diff --git a/tests/tests/src/js_float_test.js b/tests/tests/src/js_float_test.js deleted file mode 100644 index 3569b1f3d7..0000000000 --- a/tests/tests/src/js_float_test.js +++ /dev/null @@ -1,455 +0,0 @@ -// Generated by ReScript, PLEASE EDIT WITH CARE -'use strict'; - -let Mt = require("./mt.js"); -let Pervasives = require("rescript/lib/js/Pervasives.js"); - -let suites_0 = [ - "_NaN <> _NaN", - param => ({ - TAG: "Eq", - _0: false, - _1: NaN === NaN - }) -]; - -let suites_1 = { - hd: [ - "isNaN - _NaN", - param => ({ - TAG: "Eq", - _0: true, - _1: Number.isNaN(NaN) - }) - ], - tl: { - hd: [ - "isNaN - 0.", - param => ({ - TAG: "Eq", - _0: false, - _1: Number.isNaN(0) - }) - ], - tl: { - hd: [ - "isFinite - infinity", - param => ({ - TAG: "Eq", - _0: false, - _1: Number.isFinite(Pervasives.infinity) - }) - ], - tl: { - hd: [ - "isFinite - neg_infinity", - param => ({ - TAG: "Eq", - _0: false, - _1: Number.isFinite(Pervasives.neg_infinity) - }) - ], - tl: { - hd: [ - "isFinite - _NaN", - param => ({ - TAG: "Eq", - _0: false, - _1: Number.isFinite(NaN) - }) - ], - tl: { - hd: [ - "isFinite - 0.", - param => ({ - TAG: "Eq", - _0: true, - _1: Number.isFinite(0) - }) - ], - tl: { - hd: [ - "toExponential", - param => ({ - TAG: "Eq", - _0: "1.23456e+2", - _1: (123.456).toExponential() - }) - ], - tl: { - hd: [ - "toExponential - large number", - param => ({ - TAG: "Eq", - _0: "1.2e+21", - _1: (1.2e21).toExponential() - }) - ], - tl: { - hd: [ - "toExponentialWithPrecision - digits:2", - param => ({ - TAG: "Eq", - _0: "1.23e+2", - _1: (123.456).toExponential(2) - }) - ], - tl: { - hd: [ - "toExponentialWithPrecision - digits:4", - param => ({ - TAG: "Eq", - _0: "1.2346e+2", - _1: (123.456).toExponential(4) - }) - ], - tl: { - hd: [ - "toExponentialWithPrecision - digits:20", - param => ({ - TAG: "Eq", - _0: "0.00000000000000000000e+0", - _1: (0).toExponential(20) - }) - ], - tl: { - hd: [ - "File \"js_float_test.res\", line 27, characters 5-12", - param => ({ - TAG: "ThrowAny", - _0: () => { - (0).toExponential(101); - } - }) - ], - tl: { - hd: [ - "toExponentialWithPrecision - digits:-1", - param => ({ - TAG: "ThrowAny", - _0: () => { - (0).toExponential(-1); - } - }) - ], - tl: { - hd: [ - "toFixed", - param => ({ - TAG: "Eq", - _0: "123", - _1: (123.456).toFixed() - }) - ], - tl: { - hd: [ - "toFixed - large number", - param => ({ - TAG: "Eq", - _0: "1.2e+21", - _1: (1.2e21).toFixed() - }) - ], - tl: { - hd: [ - "toFixedWithPrecision - digits:2", - param => ({ - TAG: "Eq", - _0: "123.46", - _1: (123.456).toFixed(2) - }) - ], - tl: { - hd: [ - "toFixedWithPrecision - digits:4", - param => ({ - TAG: "Eq", - _0: "123.4560", - _1: (123.456).toFixed(4) - }) - ], - tl: { - hd: [ - "toFixedWithPrecision - digits:20", - param => ({ - TAG: "Eq", - _0: "0.00000000000000000000", - _1: (0).toFixed(20) - }) - ], - tl: { - hd: [ - "toFixedWithPrecision - digits:101", - param => ({ - TAG: "ThrowAny", - _0: () => { - (0).toFixed(101); - } - }) - ], - tl: { - hd: [ - "toFixedWithPrecision - digits:-1", - param => ({ - TAG: "ThrowAny", - _0: () => { - (0).toFixed(-1); - } - }) - ], - tl: { - hd: [ - "toPrecision", - param => ({ - TAG: "Eq", - _0: "123.456", - _1: (123.456).toPrecision() - }) - ], - tl: { - hd: [ - "toPrecision - large number", - param => ({ - TAG: "Eq", - _0: "1.2e+21", - _1: (1.2e21).toPrecision() - }) - ], - tl: { - hd: [ - "toPrecisionWithPrecision - digits:2", - param => ({ - TAG: "Eq", - _0: "1.2e+2", - _1: (123.456).toPrecision(2) - }) - ], - tl: { - hd: [ - "toPrecisionWithPrecision - digits:4", - param => ({ - TAG: "Eq", - _0: "123.5", - _1: (123.456).toPrecision(4) - }) - ], - tl: { - hd: [ - "toPrecisionWithPrecision - digits:20", - param => ({ - TAG: "Eq", - _0: "0.0000000000000000000", - _1: (0).toPrecision(20) - }) - ], - tl: { - hd: [ - "File \"js_float_test.res\", line 68, characters 5-12", - param => ({ - TAG: "ThrowAny", - _0: () => { - (0).toPrecision(101); - } - }) - ], - tl: { - hd: [ - "toPrecisionWithPrecision - digits:-1", - param => ({ - TAG: "ThrowAny", - _0: () => { - (0).toPrecision(-1); - } - }) - ], - tl: { - hd: [ - "toString", - param => ({ - TAG: "Eq", - _0: "1.23", - _1: (1.23).toString() - }) - ], - tl: { - hd: [ - "toString - large number", - param => ({ - TAG: "Eq", - _0: "1.2e+21", - _1: (1.2e21).toString() - }) - ], - tl: { - hd: [ - "toStringWithRadix - radix:2", - param => ({ - TAG: "Eq", - _0: "1111011.0111010010111100011010100111111011111001110111", - _1: (123.456).toString(2) - }) - ], - tl: { - hd: [ - "toStringWithRadix - radix:16", - param => ({ - TAG: "Eq", - _0: "7b.74bc6a7ef9dc", - _1: (123.456).toString(16) - }) - ], - tl: { - hd: [ - "toStringWithRadix - radix:36", - param => ({ - TAG: "Eq", - _0: "3f", - _1: (123).toString(36) - }) - ], - tl: { - hd: [ - "toStringWithRadix - radix:37", - param => ({ - TAG: "ThrowAny", - _0: () => { - (0).toString(37); - } - }) - ], - tl: { - hd: [ - "toStringWithRadix - radix:1", - param => ({ - TAG: "ThrowAny", - _0: () => { - (0).toString(1); - } - }) - ], - tl: { - hd: [ - "toStringWithRadix - radix:-1", - param => ({ - TAG: "ThrowAny", - _0: () => { - (0).toString(-1); - } - }) - ], - tl: { - hd: [ - "fromString - 123", - param => ({ - TAG: "Eq", - _0: 123, - _1: Number("123") - }) - ], - tl: { - hd: [ - "fromString - 12.3", - param => ({ - TAG: "Eq", - _0: 12.3, - _1: Number("12.3") - }) - ], - tl: { - hd: [ - "fromString - empty string", - param => ({ - TAG: "Eq", - _0: 0, - _1: Number("") - }) - ], - tl: { - hd: [ - "fromString - 0x11", - param => ({ - TAG: "Eq", - _0: 17, - _1: Number("0x11") - }) - ], - tl: { - hd: [ - "fromString - 0b11", - param => ({ - TAG: "Eq", - _0: 3, - _1: Number("0b11") - }) - ], - tl: { - hd: [ - "fromString - 0o11", - param => ({ - TAG: "Eq", - _0: 9, - _1: Number("0o11") - }) - ], - tl: { - hd: [ - "fromString - invalid string", - param => ({ - TAG: "Eq", - _0: true, - _1: Number.isNaN(Number("foo")) - }) - ], - tl: /* [] */0 - } - } - } - } - } - } - } - } - } - } - } - } - } - } - } - } - } - } - } - } - } - } - } - } - } - } - } - } - } - } - } - } - } - } - } - } - } - } - } - } - } -}; - -let suites = { - hd: suites_0, - tl: suites_1 -}; - -Mt.from_pair_suites("Js_float_test", suites); - -exports.suites = suites; -/* Not a pure module */ diff --git a/tests/tests/src/js_float_test.mjs b/tests/tests/src/js_float_test.mjs new file mode 100644 index 0000000000..509c5b5531 --- /dev/null +++ b/tests/tests/src/js_float_test.mjs @@ -0,0 +1,456 @@ +// Generated by ReScript, PLEASE EDIT WITH CARE + +import * as Mt from "./mt.mjs"; +import * as Pervasives from "rescript/lib/es6/Pervasives.js"; + +let suites_0 = [ + "_NaN <> _NaN", + param => ({ + TAG: "Eq", + _0: false, + _1: NaN === NaN + }) +]; + +let suites_1 = { + hd: [ + "isNaN - _NaN", + param => ({ + TAG: "Eq", + _0: true, + _1: Number.isNaN(NaN) + }) + ], + tl: { + hd: [ + "isNaN - 0.", + param => ({ + TAG: "Eq", + _0: false, + _1: Number.isNaN(0) + }) + ], + tl: { + hd: [ + "isFinite - infinity", + param => ({ + TAG: "Eq", + _0: false, + _1: Number.isFinite(Pervasives.infinity) + }) + ], + tl: { + hd: [ + "isFinite - neg_infinity", + param => ({ + TAG: "Eq", + _0: false, + _1: Number.isFinite(Pervasives.neg_infinity) + }) + ], + tl: { + hd: [ + "isFinite - _NaN", + param => ({ + TAG: "Eq", + _0: false, + _1: Number.isFinite(NaN) + }) + ], + tl: { + hd: [ + "isFinite - 0.", + param => ({ + TAG: "Eq", + _0: true, + _1: Number.isFinite(0) + }) + ], + tl: { + hd: [ + "toExponential", + param => ({ + TAG: "Eq", + _0: "1.23456e+2", + _1: (123.456).toExponential() + }) + ], + tl: { + hd: [ + "toExponential - large number", + param => ({ + TAG: "Eq", + _0: "1.2e+21", + _1: (1.2e21).toExponential() + }) + ], + tl: { + hd: [ + "toExponentialWithPrecision - digits:2", + param => ({ + TAG: "Eq", + _0: "1.23e+2", + _1: (123.456).toExponential(2) + }) + ], + tl: { + hd: [ + "toExponentialWithPrecision - digits:4", + param => ({ + TAG: "Eq", + _0: "1.2346e+2", + _1: (123.456).toExponential(4) + }) + ], + tl: { + hd: [ + "toExponentialWithPrecision - digits:20", + param => ({ + TAG: "Eq", + _0: "0.00000000000000000000e+0", + _1: (0).toExponential(20) + }) + ], + tl: { + hd: [ + "File \"js_float_test.res\", line 27, characters 5-12", + param => ({ + TAG: "ThrowAny", + _0: () => { + (0).toExponential(101); + } + }) + ], + tl: { + hd: [ + "toExponentialWithPrecision - digits:-1", + param => ({ + TAG: "ThrowAny", + _0: () => { + (0).toExponential(-1); + } + }) + ], + tl: { + hd: [ + "toFixed", + param => ({ + TAG: "Eq", + _0: "123", + _1: (123.456).toFixed() + }) + ], + tl: { + hd: [ + "toFixed - large number", + param => ({ + TAG: "Eq", + _0: "1.2e+21", + _1: (1.2e21).toFixed() + }) + ], + tl: { + hd: [ + "toFixedWithPrecision - digits:2", + param => ({ + TAG: "Eq", + _0: "123.46", + _1: (123.456).toFixed(2) + }) + ], + tl: { + hd: [ + "toFixedWithPrecision - digits:4", + param => ({ + TAG: "Eq", + _0: "123.4560", + _1: (123.456).toFixed(4) + }) + ], + tl: { + hd: [ + "toFixedWithPrecision - digits:20", + param => ({ + TAG: "Eq", + _0: "0.00000000000000000000", + _1: (0).toFixed(20) + }) + ], + tl: { + hd: [ + "toFixedWithPrecision - digits:101", + param => ({ + TAG: "ThrowAny", + _0: () => { + (0).toFixed(101); + } + }) + ], + tl: { + hd: [ + "toFixedWithPrecision - digits:-1", + param => ({ + TAG: "ThrowAny", + _0: () => { + (0).toFixed(-1); + } + }) + ], + tl: { + hd: [ + "toPrecision", + param => ({ + TAG: "Eq", + _0: "123.456", + _1: (123.456).toPrecision() + }) + ], + tl: { + hd: [ + "toPrecision - large number", + param => ({ + TAG: "Eq", + _0: "1.2e+21", + _1: (1.2e21).toPrecision() + }) + ], + tl: { + hd: [ + "toPrecisionWithPrecision - digits:2", + param => ({ + TAG: "Eq", + _0: "1.2e+2", + _1: (123.456).toPrecision(2) + }) + ], + tl: { + hd: [ + "toPrecisionWithPrecision - digits:4", + param => ({ + TAG: "Eq", + _0: "123.5", + _1: (123.456).toPrecision(4) + }) + ], + tl: { + hd: [ + "toPrecisionWithPrecision - digits:20", + param => ({ + TAG: "Eq", + _0: "0.0000000000000000000", + _1: (0).toPrecision(20) + }) + ], + tl: { + hd: [ + "File \"js_float_test.res\", line 68, characters 5-12", + param => ({ + TAG: "ThrowAny", + _0: () => { + (0).toPrecision(101); + } + }) + ], + tl: { + hd: [ + "toPrecisionWithPrecision - digits:-1", + param => ({ + TAG: "ThrowAny", + _0: () => { + (0).toPrecision(-1); + } + }) + ], + tl: { + hd: [ + "toString", + param => ({ + TAG: "Eq", + _0: "1.23", + _1: (1.23).toString() + }) + ], + tl: { + hd: [ + "toString - large number", + param => ({ + TAG: "Eq", + _0: "1.2e+21", + _1: (1.2e21).toString() + }) + ], + tl: { + hd: [ + "toStringWithRadix - radix:2", + param => ({ + TAG: "Eq", + _0: "1111011.0111010010111100011010100111111011111001110111", + _1: (123.456).toString(2) + }) + ], + tl: { + hd: [ + "toStringWithRadix - radix:16", + param => ({ + TAG: "Eq", + _0: "7b.74bc6a7ef9dc", + _1: (123.456).toString(16) + }) + ], + tl: { + hd: [ + "toStringWithRadix - radix:36", + param => ({ + TAG: "Eq", + _0: "3f", + _1: (123).toString(36) + }) + ], + tl: { + hd: [ + "toStringWithRadix - radix:37", + param => ({ + TAG: "ThrowAny", + _0: () => { + (0).toString(37); + } + }) + ], + tl: { + hd: [ + "toStringWithRadix - radix:1", + param => ({ + TAG: "ThrowAny", + _0: () => { + (0).toString(1); + } + }) + ], + tl: { + hd: [ + "toStringWithRadix - radix:-1", + param => ({ + TAG: "ThrowAny", + _0: () => { + (0).toString(-1); + } + }) + ], + tl: { + hd: [ + "fromString - 123", + param => ({ + TAG: "Eq", + _0: 123, + _1: Number("123") + }) + ], + tl: { + hd: [ + "fromString - 12.3", + param => ({ + TAG: "Eq", + _0: 12.3, + _1: Number("12.3") + }) + ], + tl: { + hd: [ + "fromString - empty string", + param => ({ + TAG: "Eq", + _0: 0, + _1: Number("") + }) + ], + tl: { + hd: [ + "fromString - 0x11", + param => ({ + TAG: "Eq", + _0: 17, + _1: Number("0x11") + }) + ], + tl: { + hd: [ + "fromString - 0b11", + param => ({ + TAG: "Eq", + _0: 3, + _1: Number("0b11") + }) + ], + tl: { + hd: [ + "fromString - 0o11", + param => ({ + TAG: "Eq", + _0: 9, + _1: Number("0o11") + }) + ], + tl: { + hd: [ + "fromString - invalid string", + param => ({ + TAG: "Eq", + _0: true, + _1: Number.isNaN(Number("foo")) + }) + ], + tl: /* [] */0 + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } +}; + +let suites = { + hd: suites_0, + tl: suites_1 +}; + +Mt.from_pair_suites("Js_float_test", suites); + +export { + suites, +} +/* Not a pure module */ diff --git a/tests/tests/src/js_global_test.js b/tests/tests/src/js_global_test.js deleted file mode 100644 index 8a77b3aef1..0000000000 --- a/tests/tests/src/js_global_test.js +++ /dev/null @@ -1,81 +0,0 @@ -// Generated by ReScript, PLEASE EDIT WITH CARE -'use strict'; - -let Mt = require("./mt.js"); - -let suites_0 = [ - "setTimeout/clearTimeout sanity check", - param => { - let handle = setTimeout(() => {}, 0); - clearTimeout(handle); - return { - TAG: "Ok", - _0: true - }; - } -]; - -let suites_1 = { - hd: [ - "setInerval/clearInterval sanity check", - param => { - let handle = setInterval(() => {}, 0); - clearInterval(handle); - return { - TAG: "Ok", - _0: true - }; - } - ], - tl: { - hd: [ - "encodeURI", - param => ({ - TAG: "Eq", - _0: encodeURI("[-=-]"), - _1: "%5B-=-%5D" - }) - ], - tl: { - hd: [ - "decodeURI", - param => ({ - TAG: "Eq", - _0: decodeURI("%5B-=-%5D"), - _1: "[-=-]" - }) - ], - tl: { - hd: [ - "encodeURIComponent", - param => ({ - TAG: "Eq", - _0: encodeURIComponent("[-=-]"), - _1: "%5B-%3D-%5D" - }) - ], - tl: { - hd: [ - "decodeURIComponent", - param => ({ - TAG: "Eq", - _0: decodeURIComponent("%5B-%3D-%5D"), - _1: "[-=-]" - }) - ], - tl: /* [] */0 - } - } - } - } -}; - -let suites = { - hd: suites_0, - tl: suites_1 -}; - -Mt.from_pair_suites("Js_global_test", suites); - -exports.suites = suites; -/* Not a pure module */ diff --git a/tests/tests/src/js_global_test.mjs b/tests/tests/src/js_global_test.mjs new file mode 100644 index 0000000000..9d27ba39db --- /dev/null +++ b/tests/tests/src/js_global_test.mjs @@ -0,0 +1,82 @@ +// Generated by ReScript, PLEASE EDIT WITH CARE + +import * as Mt from "./mt.mjs"; + +let suites_0 = [ + "setTimeout/clearTimeout sanity check", + param => { + let handle = setTimeout(() => {}, 0); + clearTimeout(handle); + return { + TAG: "Ok", + _0: true + }; + } +]; + +let suites_1 = { + hd: [ + "setInerval/clearInterval sanity check", + param => { + let handle = setInterval(() => {}, 0); + clearInterval(handle); + return { + TAG: "Ok", + _0: true + }; + } + ], + tl: { + hd: [ + "encodeURI", + param => ({ + TAG: "Eq", + _0: encodeURI("[-=-]"), + _1: "%5B-=-%5D" + }) + ], + tl: { + hd: [ + "decodeURI", + param => ({ + TAG: "Eq", + _0: decodeURI("%5B-=-%5D"), + _1: "[-=-]" + }) + ], + tl: { + hd: [ + "encodeURIComponent", + param => ({ + TAG: "Eq", + _0: encodeURIComponent("[-=-]"), + _1: "%5B-%3D-%5D" + }) + ], + tl: { + hd: [ + "decodeURIComponent", + param => ({ + TAG: "Eq", + _0: decodeURIComponent("%5B-%3D-%5D"), + _1: "[-=-]" + }) + ], + tl: /* [] */0 + } + } + } + } +}; + +let suites = { + hd: suites_0, + tl: suites_1 +}; + +Mt.from_pair_suites("Js_global_test", suites); + +export { + suites, +} +/* Not a pure module */ diff --git a/tests/tests/src/js_int_test.js b/tests/tests/src/js_int_test.js deleted file mode 100644 index e7a41d3a1f..0000000000 --- a/tests/tests/src/js_int_test.js +++ /dev/null @@ -1,212 +0,0 @@ -// Generated by ReScript, PLEASE EDIT WITH CARE -'use strict'; - -let Mt = require("./mt.js"); - -let suites_0 = [ - "toExponential", - param => ({ - TAG: "Eq", - _0: "1.23456e+5", - _1: (123456).toExponential() - }) -]; - -let suites_1 = { - hd: [ - "toExponentialWithPrecision - digits:2", - param => ({ - TAG: "Eq", - _0: "1.23e+5", - _1: (123456).toExponential(2) - }) - ], - tl: { - hd: [ - "toExponentialWithPrecision - digits:4", - param => ({ - TAG: "Eq", - _0: "1.2346e+5", - _1: (123456).toExponential(4) - }) - ], - tl: { - hd: [ - "toExponentialWithPrecision - digits:20", - param => ({ - TAG: "Eq", - _0: "0.00000000000000000000e+0", - _1: (0).toExponential(20) - }) - ], - tl: { - hd: [ - "File \"js_int_test.res\", line 19, characters 5-12", - param => ({ - TAG: "ThrowAny", - _0: () => { - (0).toExponential(101); - } - }) - ], - tl: { - hd: [ - "toExponentialWithPrecision - digits:-1", - param => ({ - TAG: "ThrowAny", - _0: () => { - (0).toExponential(-1); - } - }) - ], - tl: { - hd: [ - "toPrecision", - param => ({ - TAG: "Eq", - _0: "123456", - _1: (123456).toPrecision() - }) - ], - tl: { - hd: [ - "toPrecisionWithPrecision - digits:2", - param => ({ - TAG: "Eq", - _0: "1.2e+5", - _1: (123456).toPrecision(2) - }) - ], - tl: { - hd: [ - "toPrecisionWithPrecision - digits:4", - param => ({ - TAG: "Eq", - _0: "1.235e+5", - _1: (123456).toPrecision(4) - }) - ], - tl: { - hd: [ - "toPrecisionWithPrecision - digits:20", - param => ({ - TAG: "Eq", - _0: "0.0000000000000000000", - _1: (0).toPrecision(20) - }) - ], - tl: { - hd: [ - "File \"js_int_test.res\", line 37, characters 5-12", - param => ({ - TAG: "ThrowAny", - _0: () => { - (0).toPrecision(101); - } - }) - ], - tl: { - hd: [ - "toPrecisionWithPrecision - digits:-1", - param => ({ - TAG: "ThrowAny", - _0: () => { - (0).toPrecision(-1); - } - }) - ], - tl: { - hd: [ - "toString", - param => ({ - TAG: "Eq", - _0: "123", - _1: (123).toString() - }) - ], - tl: { - hd: [ - "toStringWithRadix - radix:2", - param => ({ - TAG: "Eq", - _0: "11110001001000000", - _1: (123456).toString(2) - }) - ], - tl: { - hd: [ - "toStringWithRadix - radix:16", - param => ({ - TAG: "Eq", - _0: "1e240", - _1: (123456).toString(16) - }) - ], - tl: { - hd: [ - "toStringWithRadix - radix:36", - param => ({ - TAG: "Eq", - _0: "2n9c", - _1: (123456).toString(36) - }) - ], - tl: { - hd: [ - "toStringWithRadix - radix:37", - param => ({ - TAG: "ThrowAny", - _0: () => { - (0).toString(37); - } - }) - ], - tl: { - hd: [ - "toStringWithRadix - radix:1", - param => ({ - TAG: "ThrowAny", - _0: () => { - (0).toString(1); - } - }) - ], - tl: { - hd: [ - "toStringWithRadix - radix:-1", - param => ({ - TAG: "ThrowAny", - _0: () => { - (0).toString(-1); - } - }) - ], - tl: /* [] */0 - } - } - } - } - } - } - } - } - } - } - } - } - } - } - } - } - } -}; - -let suites = { - hd: suites_0, - tl: suites_1 -}; - -Mt.from_pair_suites("Js_int_test", suites); - -exports.suites = suites; -/* Not a pure module */ diff --git a/tests/tests/src/js_int_test.mjs b/tests/tests/src/js_int_test.mjs new file mode 100644 index 0000000000..7a975543dc --- /dev/null +++ b/tests/tests/src/js_int_test.mjs @@ -0,0 +1,213 @@ +// Generated by ReScript, PLEASE EDIT WITH CARE + +import * as Mt from "./mt.mjs"; + +let suites_0 = [ + "toExponential", + param => ({ + TAG: "Eq", + _0: "1.23456e+5", + _1: (123456).toExponential() + }) +]; + +let suites_1 = { + hd: [ + "toExponentialWithPrecision - digits:2", + param => ({ + TAG: "Eq", + _0: "1.23e+5", + _1: (123456).toExponential(2) + }) + ], + tl: { + hd: [ + "toExponentialWithPrecision - digits:4", + param => ({ + TAG: "Eq", + _0: "1.2346e+5", + _1: (123456).toExponential(4) + }) + ], + tl: { + hd: [ + "toExponentialWithPrecision - digits:20", + param => ({ + TAG: "Eq", + _0: "0.00000000000000000000e+0", + _1: (0).toExponential(20) + }) + ], + tl: { + hd: [ + "File \"js_int_test.res\", line 19, characters 5-12", + param => ({ + TAG: "ThrowAny", + _0: () => { + (0).toExponential(101); + } + }) + ], + tl: { + hd: [ + "toExponentialWithPrecision - digits:-1", + param => ({ + TAG: "ThrowAny", + _0: () => { + (0).toExponential(-1); + } + }) + ], + tl: { + hd: [ + "toPrecision", + param => ({ + TAG: "Eq", + _0: "123456", + _1: (123456).toPrecision() + }) + ], + tl: { + hd: [ + "toPrecisionWithPrecision - digits:2", + param => ({ + TAG: "Eq", + _0: "1.2e+5", + _1: (123456).toPrecision(2) + }) + ], + tl: { + hd: [ + "toPrecisionWithPrecision - digits:4", + param => ({ + TAG: "Eq", + _0: "1.235e+5", + _1: (123456).toPrecision(4) + }) + ], + tl: { + hd: [ + "toPrecisionWithPrecision - digits:20", + param => ({ + TAG: "Eq", + _0: "0.0000000000000000000", + _1: (0).toPrecision(20) + }) + ], + tl: { + hd: [ + "File \"js_int_test.res\", line 37, characters 5-12", + param => ({ + TAG: "ThrowAny", + _0: () => { + (0).toPrecision(101); + } + }) + ], + tl: { + hd: [ + "toPrecisionWithPrecision - digits:-1", + param => ({ + TAG: "ThrowAny", + _0: () => { + (0).toPrecision(-1); + } + }) + ], + tl: { + hd: [ + "toString", + param => ({ + TAG: "Eq", + _0: "123", + _1: (123).toString() + }) + ], + tl: { + hd: [ + "toStringWithRadix - radix:2", + param => ({ + TAG: "Eq", + _0: "11110001001000000", + _1: (123456).toString(2) + }) + ], + tl: { + hd: [ + "toStringWithRadix - radix:16", + param => ({ + TAG: "Eq", + _0: "1e240", + _1: (123456).toString(16) + }) + ], + tl: { + hd: [ + "toStringWithRadix - radix:36", + param => ({ + TAG: "Eq", + _0: "2n9c", + _1: (123456).toString(36) + }) + ], + tl: { + hd: [ + "toStringWithRadix - radix:37", + param => ({ + TAG: "ThrowAny", + _0: () => { + (0).toString(37); + } + }) + ], + tl: { + hd: [ + "toStringWithRadix - radix:1", + param => ({ + TAG: "ThrowAny", + _0: () => { + (0).toString(1); + } + }) + ], + tl: { + hd: [ + "toStringWithRadix - radix:-1", + param => ({ + TAG: "ThrowAny", + _0: () => { + (0).toString(-1); + } + }) + ], + tl: /* [] */0 + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } +}; + +let suites = { + hd: suites_0, + tl: suites_1 +}; + +Mt.from_pair_suites("Js_int_test", suites); + +export { + suites, +} +/* Not a pure module */ diff --git a/tests/tests/src/js_json_test.js b/tests/tests/src/js_json_test.js deleted file mode 100644 index c4ca3be08c..0000000000 --- a/tests/tests/src/js_json_test.js +++ /dev/null @@ -1,698 +0,0 @@ -// Generated by ReScript, PLEASE EDIT WITH CARE -'use strict'; - -let Mt = require("./mt.js"); -let Js_dict = require("rescript/lib/js/Js_dict.js"); -let Js_json = require("rescript/lib/js/Js_json.js"); -let Belt_List = require("rescript/lib/js/Belt_List.js"); -let Belt_Array = require("rescript/lib/js/Belt_Array.js"); -let Primitive_array = require("rescript/lib/js/Primitive_array.js"); -let Primitive_option = require("rescript/lib/js/Primitive_option.js"); - -let suites = { - contents: /* [] */0 -}; - -let counter = { - contents: 0 -}; - -function add_test(loc, test) { - counter.contents = counter.contents + 1 | 0; - let id = loc + (" id " + counter.contents.toString()); - suites.contents = { - hd: [ - id, - test - ], - tl: suites.contents - }; -} - -function eq(loc, x, y) { - add_test(loc, () => ({ - TAG: "Eq", - _0: x, - _1: y - })); -} - -function false_(loc) { - add_test(loc, () => ({ - TAG: "Ok", - _0: false - })); -} - -function true_(loc) { - add_test(loc, () => ({ - TAG: "Ok", - _0: true - })); -} - -let v = JSON.parse(" { \"x\" : [1, 2, 3 ] } "); - -add_test("File \"js_json_test.res\", line 23, characters 11-18", () => { - let ty = Js_json.classify(v); - if (typeof ty !== "object") { - return { - TAG: "Ok", - _0: false - }; - } - if (ty.TAG !== "JSONObject") { - return { - TAG: "Ok", - _0: false - }; - } - let v$1 = Js_dict.get(ty._0, "x"); - if (v$1 === undefined) { - return { - TAG: "Ok", - _0: false - }; - } - let ty2 = Js_json.classify(v$1); - if (typeof ty2 !== "object") { - return { - TAG: "Ok", - _0: false - }; - } - if (ty2.TAG !== "JSONArray") { - return { - TAG: "Ok", - _0: false - }; - } - ty2._0.forEach(x => { - let ty3 = Js_json.classify(x); - if (typeof ty3 !== "object") { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "js_json_test.res", - 39, - 21 - ], - Error: new Error() - }; - } - if (ty3.TAG === "JSONNumber") { - return; - } - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "js_json_test.res", - 39, - 21 - ], - Error: new Error() - }; - }); - return { - TAG: "Ok", - _0: true - }; -}); - -eq("File \"js_json_test.res\", line 51, characters 5-12", Js_json.test(v, "Object"), true); - -let json = JSON.parse(JSON.stringify(null)); - -let ty = Js_json.classify(json); - -if (typeof ty !== "object") { - if (ty === "JSONNull") { - add_test("File \"js_json_test.res\", line 58, characters 24-31", () => ({ - TAG: "Ok", - _0: true - })); - } else { - console.log(ty); - add_test("File \"js_json_test.res\", line 61, characters 11-18", () => ({ - TAG: "Ok", - _0: false - })); - } -} else { - console.log(ty); - add_test("File \"js_json_test.res\", line 61, characters 11-18", () => ({ - TAG: "Ok", - _0: false - })); -} - -let json$1 = JSON.parse(JSON.stringify("test string")); - -let ty$1 = Js_json.classify(json$1); - -if (typeof ty$1 !== "object") { - add_test("File \"js_json_test.res\", line 71, characters 16-23", () => ({ - TAG: "Ok", - _0: false - })); -} else if (ty$1.TAG === "JSONString") { - eq("File \"js_json_test.res\", line 70, characters 26-33", ty$1._0, "test string"); -} else { - add_test("File \"js_json_test.res\", line 71, characters 16-23", () => ({ - TAG: "Ok", - _0: false - })); -} - -let json$2 = JSON.parse(JSON.stringify(1.23456789)); - -let ty$2 = Js_json.classify(json$2); - -let exit = 0; - -if (typeof ty$2 !== "object" || ty$2.TAG !== "JSONNumber") { - exit = 1; -} else { - eq("File \"js_json_test.res\", line 80, characters 26-33", ty$2._0, 1.23456789); -} - -if (exit === 1) { - add_test("File \"js_json_test.res\", line 81, characters 18-25", () => ({ - TAG: "Ok", - _0: false - })); -} - -let json$3 = JSON.parse(JSON.stringify(-1347440721)); - -let ty$3 = Js_json.classify(json$3); - -let exit$1 = 0; - -if (typeof ty$3 !== "object" || ty$3.TAG !== "JSONNumber") { - exit$1 = 1; -} else { - eq("File \"js_json_test.res\", line 90, characters 26-33", ty$3._0 | 0, -1347440721); -} - -if (exit$1 === 1) { - add_test("File \"js_json_test.res\", line 91, characters 18-25", () => ({ - TAG: "Ok", - _0: false - })); -} - -function test(v) { - let json = JSON.parse(JSON.stringify(v)); - let ty = Js_json.classify(json); - if (typeof ty === "object") { - return add_test("File \"js_json_test.res\", line 103, characters 18-25", () => ({ - TAG: "Ok", - _0: false - })); - } - switch (ty) { - case "JSONFalse" : - return eq("File \"js_json_test.res\", line 102, characters 24-31", false, v); - case "JSONTrue" : - return eq("File \"js_json_test.res\", line 101, characters 23-30", true, v); - default: - return add_test("File \"js_json_test.res\", line 103, characters 18-25", () => ({ - TAG: "Ok", - _0: false - })); - } -} - -test(true); - -test(false); - -function option_get(x) { - if (x !== undefined) { - return Primitive_option.valFromOption(x); - } - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "js_json_test.res", - 114, - 12 - ], - Error: new Error() - }; -} - -let dict = {}; - -dict["a"] = "test string"; - -dict["b"] = 123.0; - -let json$4 = JSON.parse(JSON.stringify(dict)); - -let ty$4 = Js_json.classify(json$4); - -if (typeof ty$4 !== "object") { - add_test("File \"js_json_test.res\", line 145, characters 16-23", () => ({ - TAG: "Ok", - _0: false - })); -} else if (ty$4.TAG === "JSONObject") { - let x = ty$4._0; - let ta = Js_json.classify(option_get(Js_dict.get(x, "a"))); - if (typeof ta !== "object") { - add_test("File \"js_json_test.res\", line 143, characters 18-25", () => ({ - TAG: "Ok", - _0: false - })); - } else if (ta.TAG === "JSONString") { - if (ta._0 !== "test string") { - add_test("File \"js_json_test.res\", line 134, characters 15-22", () => ({ - TAG: "Ok", - _0: false - })); - } else { - let ty$5 = Js_json.classify(option_get(Js_dict.get(x, "b"))); - if (typeof ty$5 !== "object") { - add_test("File \"js_json_test.res\", line 140, characters 22-29", () => ({ - TAG: "Ok", - _0: false - })); - } else if (ty$5.TAG === "JSONNumber") { - let b = ty$5._0; - add_test("File \"js_json_test.res\", line 139, characters 38-45", () => ({ - TAG: "Approx", - _0: 123.0, - _1: b - })); - } else { - add_test("File \"js_json_test.res\", line 140, characters 22-29", () => ({ - TAG: "Ok", - _0: false - })); - } - } - } else { - add_test("File \"js_json_test.res\", line 143, characters 18-25", () => ({ - TAG: "Ok", - _0: false - })); - } -} else { - add_test("File \"js_json_test.res\", line 145, characters 16-23", () => ({ - TAG: "Ok", - _0: false - })); -} - -function eq_at_i(loc, json, i, kind, expected) { - let ty = Js_json.classify(json); - if (typeof ty !== "object") { - return add_test(loc, () => ({ - TAG: "Ok", - _0: false - })); - } - if (ty.TAG !== "JSONArray") { - return add_test(loc, () => ({ - TAG: "Ok", - _0: false - })); - } - let ty$1 = Js_json.classify(Primitive_array.get(ty._0, i)); - switch (kind) { - case "String" : - if (typeof ty$1 !== "object") { - return add_test(loc, () => ({ - TAG: "Ok", - _0: false - })); - } else if (ty$1.TAG === "JSONString") { - return eq(loc, ty$1._0, expected); - } else { - return add_test(loc, () => ({ - TAG: "Ok", - _0: false - })); - } - case "Number" : - if (typeof ty$1 !== "object") { - return add_test(loc, () => ({ - TAG: "Ok", - _0: false - })); - } else if (ty$1.TAG === "JSONNumber") { - return eq(loc, ty$1._0, expected); - } else { - return add_test(loc, () => ({ - TAG: "Ok", - _0: false - })); - } - case "Object" : - if (typeof ty$1 !== "object") { - return add_test(loc, () => ({ - TAG: "Ok", - _0: false - })); - } else if (ty$1.TAG === "JSONObject") { - return eq(loc, ty$1._0, expected); - } else { - return add_test(loc, () => ({ - TAG: "Ok", - _0: false - })); - } - case "Array" : - if (typeof ty$1 !== "object") { - return add_test(loc, () => ({ - TAG: "Ok", - _0: false - })); - } else if (ty$1.TAG === "JSONArray") { - return eq(loc, ty$1._0, expected); - } else { - return add_test(loc, () => ({ - TAG: "Ok", - _0: false - })); - } - case "Boolean" : - if (typeof ty$1 === "object") { - return add_test(loc, () => ({ - TAG: "Ok", - _0: false - })); - } - switch (ty$1) { - case "JSONFalse" : - return eq(loc, false, expected); - case "JSONTrue" : - return eq(loc, true, expected); - default: - return add_test(loc, () => ({ - TAG: "Ok", - _0: false - })); - } - case "Null" : - if (typeof ty$1 !== "object") { - if (ty$1 === "JSONNull") { - return add_test(loc, () => ({ - TAG: "Ok", - _0: true - })); - } else { - return add_test(loc, () => ({ - TAG: "Ok", - _0: false - })); - } - } else { - return add_test(loc, () => ({ - TAG: "Ok", - _0: false - })); - } - } -} - -let json$5 = JSON.parse(JSON.stringify(Belt_Array.map([ - "string 0", - "string 1", - "string 2" -], prim => prim))); - -eq_at_i("File \"js_json_test.res\", line 199, characters 10-17", json$5, 0, "String", "string 0"); - -eq_at_i("File \"js_json_test.res\", line 200, characters 10-17", json$5, 1, "String", "string 1"); - -eq_at_i("File \"js_json_test.res\", line 201, characters 10-17", json$5, 2, "String", "string 2"); - -let json$6 = JSON.parse(JSON.stringify([ - "string 0", - "string 1", - "string 2" -])); - -eq_at_i("File \"js_json_test.res\", line 208, characters 10-17", json$6, 0, "String", "string 0"); - -eq_at_i("File \"js_json_test.res\", line 209, characters 10-17", json$6, 1, "String", "string 1"); - -eq_at_i("File \"js_json_test.res\", line 210, characters 10-17", json$6, 2, "String", "string 2"); - -let a = [ - 1.0000001, - 10000000000.1, - 123.0 -]; - -let json$7 = JSON.parse(JSON.stringify(a)); - -eq_at_i("File \"js_json_test.res\", line 219, characters 10-17", json$7, 0, "Number", Primitive_array.get(a, 0)); - -eq_at_i("File \"js_json_test.res\", line 220, characters 10-17", json$7, 1, "Number", Primitive_array.get(a, 1)); - -eq_at_i("File \"js_json_test.res\", line 221, characters 10-17", json$7, 2, "Number", Primitive_array.get(a, 2)); - -let a$1 = [ - 0, - -1347440721, - -268391749 -]; - -let json$8 = JSON.parse(JSON.stringify(Belt_Array.map(a$1, prim => prim))); - -eq_at_i("File \"js_json_test.res\", line 230, characters 10-17", json$8, 0, "Number", Primitive_array.get(a$1, 0)); - -eq_at_i("File \"js_json_test.res\", line 231, characters 10-17", json$8, 1, "Number", Primitive_array.get(a$1, 1)); - -eq_at_i("File \"js_json_test.res\", line 232, characters 10-17", json$8, 2, "Number", Primitive_array.get(a$1, 2)); - -let a$2 = [ - true, - false, - true -]; - -let json$9 = JSON.parse(JSON.stringify(a$2)); - -eq_at_i("File \"js_json_test.res\", line 241, characters 10-17", json$9, 0, "Boolean", Primitive_array.get(a$2, 0)); - -eq_at_i("File \"js_json_test.res\", line 242, characters 10-17", json$9, 1, "Boolean", Primitive_array.get(a$2, 1)); - -eq_at_i("File \"js_json_test.res\", line 243, characters 10-17", json$9, 2, "Boolean", Primitive_array.get(a$2, 2)); - -function make_d(s, i) { - let d = {}; - d["a"] = s; - d["b"] = i; - return d; -} - -let a$3 = [ - make_d("aaa", 123), - make_d("bbb", 456) -]; - -let json$10 = JSON.parse(JSON.stringify(a$3)); - -let ty$6 = Js_json.classify(json$10); - -if (typeof ty$6 !== "object") { - add_test("File \"js_json_test.res\", line 271, characters 16-23", () => ({ - TAG: "Ok", - _0: false - })); -} else if (ty$6.TAG === "JSONArray") { - let ty$7 = Js_json.classify(Primitive_array.get(ty$6._0, 1)); - if (typeof ty$7 !== "object") { - add_test("File \"js_json_test.res\", line 269, characters 18-25", () => ({ - TAG: "Ok", - _0: false - })); - } else if (ty$7.TAG === "JSONObject") { - let ty$8 = Js_json.classify(option_get(Js_dict.get(ty$7._0, "a"))); - if (typeof ty$8 !== "object") { - add_test("File \"js_json_test.res\", line 267, characters 20-27", () => ({ - TAG: "Ok", - _0: false - })); - } else if (ty$8.TAG === "JSONString") { - eq("File \"js_json_test.res\", line 266, characters 35-42", ty$8._0, "bbb"); - } else { - add_test("File \"js_json_test.res\", line 267, characters 20-27", () => ({ - TAG: "Ok", - _0: false - })); - } - } else { - add_test("File \"js_json_test.res\", line 269, characters 18-25", () => ({ - TAG: "Ok", - _0: false - })); - } -} else { - add_test("File \"js_json_test.res\", line 271, characters 16-23", () => ({ - TAG: "Ok", - _0: false - })); -} - -try { - JSON.parse("{{ A}"); - add_test("File \"js_json_test.res\", line 279, characters 11-18", () => ({ - TAG: "Ok", - _0: false - })); -} catch (exn) { - add_test("File \"js_json_test.res\", line 281, characters 17-24", () => ({ - TAG: "Ok", - _0: true - })); -} - -eq("File \"js_json_test.res\", line 287, characters 12-19", JSON.stringify([ - 1, - 2, - 3 -]), "[1,2,3]"); - -eq("File \"js_json_test.res\", line 290, characters 2-9", JSON.stringify({ - foo: 1, - bar: "hello", - baz: { - baaz: 10 - } -}), "{\"foo\":1,\"bar\":\"hello\",\"baz\":{\"baaz\":10}}"); - -eq("File \"js_json_test.res\", line 295, characters 12-19", JSON.stringify(null), "null"); - -eq("File \"js_json_test.res\", line 297, characters 12-19", JSON.stringify(undefined), undefined); - -eq("File \"js_json_test.res\", line 300, characters 5-12", Js_json.decodeString("test"), "test"); - -eq("File \"js_json_test.res\", line 301, characters 5-12", Js_json.decodeString(true), undefined); - -eq("File \"js_json_test.res\", line 302, characters 5-12", Js_json.decodeString([]), undefined); - -eq("File \"js_json_test.res\", line 303, characters 5-12", Js_json.decodeString(null), undefined); - -eq("File \"js_json_test.res\", line 304, characters 5-12", Js_json.decodeString({}), undefined); - -eq("File \"js_json_test.res\", line 305, characters 5-12", Js_json.decodeString(1.23), undefined); - -eq("File \"js_json_test.res\", line 309, characters 5-12", Js_json.decodeNumber("test"), undefined); - -eq("File \"js_json_test.res\", line 310, characters 5-12", Js_json.decodeNumber(true), undefined); - -eq("File \"js_json_test.res\", line 311, characters 5-12", Js_json.decodeNumber([]), undefined); - -eq("File \"js_json_test.res\", line 312, characters 5-12", Js_json.decodeNumber(null), undefined); - -eq("File \"js_json_test.res\", line 313, characters 5-12", Js_json.decodeNumber({}), undefined); - -eq("File \"js_json_test.res\", line 314, characters 5-12", Js_json.decodeNumber(1.23), 1.23); - -eq("File \"js_json_test.res\", line 318, characters 5-12", Js_json.decodeObject("test"), undefined); - -eq("File \"js_json_test.res\", line 319, characters 5-12", Js_json.decodeObject(true), undefined); - -eq("File \"js_json_test.res\", line 320, characters 5-12", Js_json.decodeObject([]), undefined); - -eq("File \"js_json_test.res\", line 321, characters 5-12", Js_json.decodeObject(null), undefined); - -eq("File \"js_json_test.res\", line 322, characters 5-12", Js_json.decodeObject({}), {}); - -eq("File \"js_json_test.res\", line 323, characters 5-12", Js_json.decodeObject(1.23), undefined); - -eq("File \"js_json_test.res\", line 327, characters 5-12", Js_json.decodeArray("test"), undefined); - -eq("File \"js_json_test.res\", line 328, characters 5-12", Js_json.decodeArray(true), undefined); - -eq("File \"js_json_test.res\", line 329, characters 5-12", Js_json.decodeArray([]), []); - -eq("File \"js_json_test.res\", line 330, characters 5-12", Js_json.decodeArray(null), undefined); - -eq("File \"js_json_test.res\", line 331, characters 5-12", Js_json.decodeArray({}), undefined); - -eq("File \"js_json_test.res\", line 332, characters 5-12", Js_json.decodeArray(1.23), undefined); - -eq("File \"js_json_test.res\", line 336, characters 5-12", Js_json.decodeBoolean("test"), undefined); - -eq("File \"js_json_test.res\", line 337, characters 5-12", Js_json.decodeBoolean(true), true); - -eq("File \"js_json_test.res\", line 338, characters 5-12", Js_json.decodeBoolean([]), undefined); - -eq("File \"js_json_test.res\", line 339, characters 5-12", Js_json.decodeBoolean(null), undefined); - -eq("File \"js_json_test.res\", line 340, characters 5-12", Js_json.decodeBoolean({}), undefined); - -eq("File \"js_json_test.res\", line 341, characters 5-12", Js_json.decodeBoolean(1.23), undefined); - -eq("File \"js_json_test.res\", line 345, characters 5-12", Js_json.decodeNull("test"), undefined); - -eq("File \"js_json_test.res\", line 346, characters 5-12", Js_json.decodeNull(true), undefined); - -eq("File \"js_json_test.res\", line 347, characters 5-12", Js_json.decodeNull([]), undefined); - -eq("File \"js_json_test.res\", line 348, characters 5-12", Js_json.decodeNull(null), null); - -eq("File \"js_json_test.res\", line 349, characters 5-12", Js_json.decodeNull({}), undefined); - -eq("File \"js_json_test.res\", line 350, characters 5-12", Js_json.decodeNull(1.23), undefined); - -function id(obj) { - return Js_json.deserializeUnsafe(Js_json.serializeExn(obj)); -} - -function idtest(obj) { - eq("File \"js_json_test.res\", line 355, characters 23-30", obj, Js_json.deserializeUnsafe(Js_json.serializeExn(obj))); -} - -idtest(undefined); - -idtest({ - hd: [ - undefined, - undefined, - undefined - ], - tl: /* [] */0 -}); - -idtest(Belt_List.makeBy(500, i => { - if (i % 2 === 0) { - return; - } else { - return 1; - } -})); - -idtest(Belt_Array.makeBy(500, i => { - if (i % 2 === 0) { - return; - } else { - return 1; - } -})); - -Mt.from_pair_suites("Js_json_test", suites.contents); - -let J; - -let $$Array; - -exports.suites = suites; -exports.J = J; -exports.$$Array = $$Array; -exports.add_test = add_test; -exports.eq = eq; -exports.false_ = false_; -exports.true_ = true_; -exports.option_get = option_get; -exports.eq_at_i = eq_at_i; -exports.id = id; -exports.idtest = idtest; -/* v Not a pure module */ diff --git a/tests/tests/src/js_json_test.mjs b/tests/tests/src/js_json_test.mjs new file mode 100644 index 0000000000..89f0f5aa81 --- /dev/null +++ b/tests/tests/src/js_json_test.mjs @@ -0,0 +1,699 @@ +// Generated by ReScript, PLEASE EDIT WITH CARE + +import * as Mt from "./mt.mjs"; +import * as Js_dict from "rescript/lib/es6/Js_dict.js"; +import * as Js_json from "rescript/lib/es6/Js_json.js"; +import * as Belt_List from "rescript/lib/es6/Belt_List.js"; +import * as Belt_Array from "rescript/lib/es6/Belt_Array.js"; +import * as Primitive_array from "rescript/lib/es6/Primitive_array.js"; +import * as Primitive_option from "rescript/lib/es6/Primitive_option.js"; + +let suites = { + contents: /* [] */0 +}; + +let counter = { + contents: 0 +}; + +function add_test(loc, test) { + counter.contents = counter.contents + 1 | 0; + let id = loc + (" id " + counter.contents.toString()); + suites.contents = { + hd: [ + id, + test + ], + tl: suites.contents + }; +} + +function eq(loc, x, y) { + add_test(loc, () => ({ + TAG: "Eq", + _0: x, + _1: y + })); +} + +function false_(loc) { + add_test(loc, () => ({ + TAG: "Ok", + _0: false + })); +} + +function true_(loc) { + add_test(loc, () => ({ + TAG: "Ok", + _0: true + })); +} + +let v = JSON.parse(" { \"x\" : [1, 2, 3 ] } "); + +add_test("File \"js_json_test.res\", line 23, characters 11-18", () => { + let ty = Js_json.classify(v); + if (typeof ty !== "object") { + return { + TAG: "Ok", + _0: false + }; + } + if (ty.TAG !== "JSONObject") { + return { + TAG: "Ok", + _0: false + }; + } + let v$1 = Js_dict.get(ty._0, "x"); + if (v$1 === undefined) { + return { + TAG: "Ok", + _0: false + }; + } + let ty2 = Js_json.classify(v$1); + if (typeof ty2 !== "object") { + return { + TAG: "Ok", + _0: false + }; + } + if (ty2.TAG !== "JSONArray") { + return { + TAG: "Ok", + _0: false + }; + } + ty2._0.forEach(x => { + let ty3 = Js_json.classify(x); + if (typeof ty3 !== "object") { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "js_json_test.res", + 39, + 21 + ], + Error: new Error() + }; + } + if (ty3.TAG === "JSONNumber") { + return; + } + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "js_json_test.res", + 39, + 21 + ], + Error: new Error() + }; + }); + return { + TAG: "Ok", + _0: true + }; +}); + +eq("File \"js_json_test.res\", line 51, characters 5-12", Js_json.test(v, "Object"), true); + +let json = JSON.parse(JSON.stringify(null)); + +let ty = Js_json.classify(json); + +if (typeof ty !== "object") { + if (ty === "JSONNull") { + add_test("File \"js_json_test.res\", line 58, characters 24-31", () => ({ + TAG: "Ok", + _0: true + })); + } else { + console.log(ty); + add_test("File \"js_json_test.res\", line 61, characters 11-18", () => ({ + TAG: "Ok", + _0: false + })); + } +} else { + console.log(ty); + add_test("File \"js_json_test.res\", line 61, characters 11-18", () => ({ + TAG: "Ok", + _0: false + })); +} + +let json$1 = JSON.parse(JSON.stringify("test string")); + +let ty$1 = Js_json.classify(json$1); + +if (typeof ty$1 !== "object") { + add_test("File \"js_json_test.res\", line 71, characters 16-23", () => ({ + TAG: "Ok", + _0: false + })); +} else if (ty$1.TAG === "JSONString") { + eq("File \"js_json_test.res\", line 70, characters 26-33", ty$1._0, "test string"); +} else { + add_test("File \"js_json_test.res\", line 71, characters 16-23", () => ({ + TAG: "Ok", + _0: false + })); +} + +let json$2 = JSON.parse(JSON.stringify(1.23456789)); + +let ty$2 = Js_json.classify(json$2); + +let exit = 0; + +if (typeof ty$2 !== "object" || ty$2.TAG !== "JSONNumber") { + exit = 1; +} else { + eq("File \"js_json_test.res\", line 80, characters 26-33", ty$2._0, 1.23456789); +} + +if (exit === 1) { + add_test("File \"js_json_test.res\", line 81, characters 18-25", () => ({ + TAG: "Ok", + _0: false + })); +} + +let json$3 = JSON.parse(JSON.stringify(-1347440721)); + +let ty$3 = Js_json.classify(json$3); + +let exit$1 = 0; + +if (typeof ty$3 !== "object" || ty$3.TAG !== "JSONNumber") { + exit$1 = 1; +} else { + eq("File \"js_json_test.res\", line 90, characters 26-33", ty$3._0 | 0, -1347440721); +} + +if (exit$1 === 1) { + add_test("File \"js_json_test.res\", line 91, characters 18-25", () => ({ + TAG: "Ok", + _0: false + })); +} + +function test(v) { + let json = JSON.parse(JSON.stringify(v)); + let ty = Js_json.classify(json); + if (typeof ty === "object") { + return add_test("File \"js_json_test.res\", line 103, characters 18-25", () => ({ + TAG: "Ok", + _0: false + })); + } + switch (ty) { + case "JSONFalse" : + return eq("File \"js_json_test.res\", line 102, characters 24-31", false, v); + case "JSONTrue" : + return eq("File \"js_json_test.res\", line 101, characters 23-30", true, v); + default: + return add_test("File \"js_json_test.res\", line 103, characters 18-25", () => ({ + TAG: "Ok", + _0: false + })); + } +} + +test(true); + +test(false); + +function option_get(x) { + if (x !== undefined) { + return Primitive_option.valFromOption(x); + } + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "js_json_test.res", + 114, + 12 + ], + Error: new Error() + }; +} + +let dict = {}; + +dict["a"] = "test string"; + +dict["b"] = 123.0; + +let json$4 = JSON.parse(JSON.stringify(dict)); + +let ty$4 = Js_json.classify(json$4); + +if (typeof ty$4 !== "object") { + add_test("File \"js_json_test.res\", line 145, characters 16-23", () => ({ + TAG: "Ok", + _0: false + })); +} else if (ty$4.TAG === "JSONObject") { + let x = ty$4._0; + let ta = Js_json.classify(option_get(Js_dict.get(x, "a"))); + if (typeof ta !== "object") { + add_test("File \"js_json_test.res\", line 143, characters 18-25", () => ({ + TAG: "Ok", + _0: false + })); + } else if (ta.TAG === "JSONString") { + if (ta._0 !== "test string") { + add_test("File \"js_json_test.res\", line 134, characters 15-22", () => ({ + TAG: "Ok", + _0: false + })); + } else { + let ty$5 = Js_json.classify(option_get(Js_dict.get(x, "b"))); + if (typeof ty$5 !== "object") { + add_test("File \"js_json_test.res\", line 140, characters 22-29", () => ({ + TAG: "Ok", + _0: false + })); + } else if (ty$5.TAG === "JSONNumber") { + let b = ty$5._0; + add_test("File \"js_json_test.res\", line 139, characters 38-45", () => ({ + TAG: "Approx", + _0: 123.0, + _1: b + })); + } else { + add_test("File \"js_json_test.res\", line 140, characters 22-29", () => ({ + TAG: "Ok", + _0: false + })); + } + } + } else { + add_test("File \"js_json_test.res\", line 143, characters 18-25", () => ({ + TAG: "Ok", + _0: false + })); + } +} else { + add_test("File \"js_json_test.res\", line 145, characters 16-23", () => ({ + TAG: "Ok", + _0: false + })); +} + +function eq_at_i(loc, json, i, kind, expected) { + let ty = Js_json.classify(json); + if (typeof ty !== "object") { + return add_test(loc, () => ({ + TAG: "Ok", + _0: false + })); + } + if (ty.TAG !== "JSONArray") { + return add_test(loc, () => ({ + TAG: "Ok", + _0: false + })); + } + let ty$1 = Js_json.classify(Primitive_array.get(ty._0, i)); + switch (kind) { + case "String" : + if (typeof ty$1 !== "object") { + return add_test(loc, () => ({ + TAG: "Ok", + _0: false + })); + } else if (ty$1.TAG === "JSONString") { + return eq(loc, ty$1._0, expected); + } else { + return add_test(loc, () => ({ + TAG: "Ok", + _0: false + })); + } + case "Number" : + if (typeof ty$1 !== "object") { + return add_test(loc, () => ({ + TAG: "Ok", + _0: false + })); + } else if (ty$1.TAG === "JSONNumber") { + return eq(loc, ty$1._0, expected); + } else { + return add_test(loc, () => ({ + TAG: "Ok", + _0: false + })); + } + case "Object" : + if (typeof ty$1 !== "object") { + return add_test(loc, () => ({ + TAG: "Ok", + _0: false + })); + } else if (ty$1.TAG === "JSONObject") { + return eq(loc, ty$1._0, expected); + } else { + return add_test(loc, () => ({ + TAG: "Ok", + _0: false + })); + } + case "Array" : + if (typeof ty$1 !== "object") { + return add_test(loc, () => ({ + TAG: "Ok", + _0: false + })); + } else if (ty$1.TAG === "JSONArray") { + return eq(loc, ty$1._0, expected); + } else { + return add_test(loc, () => ({ + TAG: "Ok", + _0: false + })); + } + case "Boolean" : + if (typeof ty$1 === "object") { + return add_test(loc, () => ({ + TAG: "Ok", + _0: false + })); + } + switch (ty$1) { + case "JSONFalse" : + return eq(loc, false, expected); + case "JSONTrue" : + return eq(loc, true, expected); + default: + return add_test(loc, () => ({ + TAG: "Ok", + _0: false + })); + } + case "Null" : + if (typeof ty$1 !== "object") { + if (ty$1 === "JSONNull") { + return add_test(loc, () => ({ + TAG: "Ok", + _0: true + })); + } else { + return add_test(loc, () => ({ + TAG: "Ok", + _0: false + })); + } + } else { + return add_test(loc, () => ({ + TAG: "Ok", + _0: false + })); + } + } +} + +let json$5 = JSON.parse(JSON.stringify(Belt_Array.map([ + "string 0", + "string 1", + "string 2" +], prim => prim))); + +eq_at_i("File \"js_json_test.res\", line 199, characters 10-17", json$5, 0, "String", "string 0"); + +eq_at_i("File \"js_json_test.res\", line 200, characters 10-17", json$5, 1, "String", "string 1"); + +eq_at_i("File \"js_json_test.res\", line 201, characters 10-17", json$5, 2, "String", "string 2"); + +let json$6 = JSON.parse(JSON.stringify([ + "string 0", + "string 1", + "string 2" +])); + +eq_at_i("File \"js_json_test.res\", line 208, characters 10-17", json$6, 0, "String", "string 0"); + +eq_at_i("File \"js_json_test.res\", line 209, characters 10-17", json$6, 1, "String", "string 1"); + +eq_at_i("File \"js_json_test.res\", line 210, characters 10-17", json$6, 2, "String", "string 2"); + +let a = [ + 1.0000001, + 10000000000.1, + 123.0 +]; + +let json$7 = JSON.parse(JSON.stringify(a)); + +eq_at_i("File \"js_json_test.res\", line 219, characters 10-17", json$7, 0, "Number", Primitive_array.get(a, 0)); + +eq_at_i("File \"js_json_test.res\", line 220, characters 10-17", json$7, 1, "Number", Primitive_array.get(a, 1)); + +eq_at_i("File \"js_json_test.res\", line 221, characters 10-17", json$7, 2, "Number", Primitive_array.get(a, 2)); + +let a$1 = [ + 0, + -1347440721, + -268391749 +]; + +let json$8 = JSON.parse(JSON.stringify(Belt_Array.map(a$1, prim => prim))); + +eq_at_i("File \"js_json_test.res\", line 230, characters 10-17", json$8, 0, "Number", Primitive_array.get(a$1, 0)); + +eq_at_i("File \"js_json_test.res\", line 231, characters 10-17", json$8, 1, "Number", Primitive_array.get(a$1, 1)); + +eq_at_i("File \"js_json_test.res\", line 232, characters 10-17", json$8, 2, "Number", Primitive_array.get(a$1, 2)); + +let a$2 = [ + true, + false, + true +]; + +let json$9 = JSON.parse(JSON.stringify(a$2)); + +eq_at_i("File \"js_json_test.res\", line 241, characters 10-17", json$9, 0, "Boolean", Primitive_array.get(a$2, 0)); + +eq_at_i("File \"js_json_test.res\", line 242, characters 10-17", json$9, 1, "Boolean", Primitive_array.get(a$2, 1)); + +eq_at_i("File \"js_json_test.res\", line 243, characters 10-17", json$9, 2, "Boolean", Primitive_array.get(a$2, 2)); + +function make_d(s, i) { + let d = {}; + d["a"] = s; + d["b"] = i; + return d; +} + +let a$3 = [ + make_d("aaa", 123), + make_d("bbb", 456) +]; + +let json$10 = JSON.parse(JSON.stringify(a$3)); + +let ty$6 = Js_json.classify(json$10); + +if (typeof ty$6 !== "object") { + add_test("File \"js_json_test.res\", line 271, characters 16-23", () => ({ + TAG: "Ok", + _0: false + })); +} else if (ty$6.TAG === "JSONArray") { + let ty$7 = Js_json.classify(Primitive_array.get(ty$6._0, 1)); + if (typeof ty$7 !== "object") { + add_test("File \"js_json_test.res\", line 269, characters 18-25", () => ({ + TAG: "Ok", + _0: false + })); + } else if (ty$7.TAG === "JSONObject") { + let ty$8 = Js_json.classify(option_get(Js_dict.get(ty$7._0, "a"))); + if (typeof ty$8 !== "object") { + add_test("File \"js_json_test.res\", line 267, characters 20-27", () => ({ + TAG: "Ok", + _0: false + })); + } else if (ty$8.TAG === "JSONString") { + eq("File \"js_json_test.res\", line 266, characters 35-42", ty$8._0, "bbb"); + } else { + add_test("File \"js_json_test.res\", line 267, characters 20-27", () => ({ + TAG: "Ok", + _0: false + })); + } + } else { + add_test("File \"js_json_test.res\", line 269, characters 18-25", () => ({ + TAG: "Ok", + _0: false + })); + } +} else { + add_test("File \"js_json_test.res\", line 271, characters 16-23", () => ({ + TAG: "Ok", + _0: false + })); +} + +try { + JSON.parse("{{ A}"); + add_test("File \"js_json_test.res\", line 279, characters 11-18", () => ({ + TAG: "Ok", + _0: false + })); +} catch (exn) { + add_test("File \"js_json_test.res\", line 281, characters 17-24", () => ({ + TAG: "Ok", + _0: true + })); +} + +eq("File \"js_json_test.res\", line 287, characters 12-19", JSON.stringify([ + 1, + 2, + 3 +]), "[1,2,3]"); + +eq("File \"js_json_test.res\", line 290, characters 2-9", JSON.stringify({ + foo: 1, + bar: "hello", + baz: { + baaz: 10 + } +}), "{\"foo\":1,\"bar\":\"hello\",\"baz\":{\"baaz\":10}}"); + +eq("File \"js_json_test.res\", line 295, characters 12-19", JSON.stringify(null), "null"); + +eq("File \"js_json_test.res\", line 297, characters 12-19", JSON.stringify(undefined), undefined); + +eq("File \"js_json_test.res\", line 300, characters 5-12", Js_json.decodeString("test"), "test"); + +eq("File \"js_json_test.res\", line 301, characters 5-12", Js_json.decodeString(true), undefined); + +eq("File \"js_json_test.res\", line 302, characters 5-12", Js_json.decodeString([]), undefined); + +eq("File \"js_json_test.res\", line 303, characters 5-12", Js_json.decodeString(null), undefined); + +eq("File \"js_json_test.res\", line 304, characters 5-12", Js_json.decodeString({}), undefined); + +eq("File \"js_json_test.res\", line 305, characters 5-12", Js_json.decodeString(1.23), undefined); + +eq("File \"js_json_test.res\", line 309, characters 5-12", Js_json.decodeNumber("test"), undefined); + +eq("File \"js_json_test.res\", line 310, characters 5-12", Js_json.decodeNumber(true), undefined); + +eq("File \"js_json_test.res\", line 311, characters 5-12", Js_json.decodeNumber([]), undefined); + +eq("File \"js_json_test.res\", line 312, characters 5-12", Js_json.decodeNumber(null), undefined); + +eq("File \"js_json_test.res\", line 313, characters 5-12", Js_json.decodeNumber({}), undefined); + +eq("File \"js_json_test.res\", line 314, characters 5-12", Js_json.decodeNumber(1.23), 1.23); + +eq("File \"js_json_test.res\", line 318, characters 5-12", Js_json.decodeObject("test"), undefined); + +eq("File \"js_json_test.res\", line 319, characters 5-12", Js_json.decodeObject(true), undefined); + +eq("File \"js_json_test.res\", line 320, characters 5-12", Js_json.decodeObject([]), undefined); + +eq("File \"js_json_test.res\", line 321, characters 5-12", Js_json.decodeObject(null), undefined); + +eq("File \"js_json_test.res\", line 322, characters 5-12", Js_json.decodeObject({}), {}); + +eq("File \"js_json_test.res\", line 323, characters 5-12", Js_json.decodeObject(1.23), undefined); + +eq("File \"js_json_test.res\", line 327, characters 5-12", Js_json.decodeArray("test"), undefined); + +eq("File \"js_json_test.res\", line 328, characters 5-12", Js_json.decodeArray(true), undefined); + +eq("File \"js_json_test.res\", line 329, characters 5-12", Js_json.decodeArray([]), []); + +eq("File \"js_json_test.res\", line 330, characters 5-12", Js_json.decodeArray(null), undefined); + +eq("File \"js_json_test.res\", line 331, characters 5-12", Js_json.decodeArray({}), undefined); + +eq("File \"js_json_test.res\", line 332, characters 5-12", Js_json.decodeArray(1.23), undefined); + +eq("File \"js_json_test.res\", line 336, characters 5-12", Js_json.decodeBoolean("test"), undefined); + +eq("File \"js_json_test.res\", line 337, characters 5-12", Js_json.decodeBoolean(true), true); + +eq("File \"js_json_test.res\", line 338, characters 5-12", Js_json.decodeBoolean([]), undefined); + +eq("File \"js_json_test.res\", line 339, characters 5-12", Js_json.decodeBoolean(null), undefined); + +eq("File \"js_json_test.res\", line 340, characters 5-12", Js_json.decodeBoolean({}), undefined); + +eq("File \"js_json_test.res\", line 341, characters 5-12", Js_json.decodeBoolean(1.23), undefined); + +eq("File \"js_json_test.res\", line 345, characters 5-12", Js_json.decodeNull("test"), undefined); + +eq("File \"js_json_test.res\", line 346, characters 5-12", Js_json.decodeNull(true), undefined); + +eq("File \"js_json_test.res\", line 347, characters 5-12", Js_json.decodeNull([]), undefined); + +eq("File \"js_json_test.res\", line 348, characters 5-12", Js_json.decodeNull(null), null); + +eq("File \"js_json_test.res\", line 349, characters 5-12", Js_json.decodeNull({}), undefined); + +eq("File \"js_json_test.res\", line 350, characters 5-12", Js_json.decodeNull(1.23), undefined); + +function id(obj) { + return Js_json.deserializeUnsafe(Js_json.serializeExn(obj)); +} + +function idtest(obj) { + eq("File \"js_json_test.res\", line 355, characters 23-30", obj, Js_json.deserializeUnsafe(Js_json.serializeExn(obj))); +} + +idtest(undefined); + +idtest({ + hd: [ + undefined, + undefined, + undefined + ], + tl: /* [] */0 +}); + +idtest(Belt_List.makeBy(500, i => { + if (i % 2 === 0) { + return; + } else { + return 1; + } +})); + +idtest(Belt_Array.makeBy(500, i => { + if (i % 2 === 0) { + return; + } else { + return 1; + } +})); + +Mt.from_pair_suites("Js_json_test", suites.contents); + +let J; + +let $$Array; + +export { + suites, + J, + $$Array, + add_test, + eq, + false_, + true_, + option_get, + eq_at_i, + id, + idtest, +} +/* v Not a pure module */ diff --git a/tests/tests/src/js_math_test.js b/tests/tests/src/js_math_test.js deleted file mode 100644 index e7ff1dd711..0000000000 --- a/tests/tests/src/js_math_test.js +++ /dev/null @@ -1,630 +0,0 @@ -// Generated by ReScript, PLEASE EDIT WITH CARE -'use strict'; - -let Mt = require("./mt.js"); -let Js_math = require("rescript/lib/js/Js_math.js"); - -let suites_0 = [ - "_E", - param => ({ - TAG: "ApproxThreshold", - _0: 0.001, - _1: 2.718, - _2: Math.E - }) -]; - -let suites_1 = { - hd: [ - "_LN2", - param => ({ - TAG: "ApproxThreshold", - _0: 0.001, - _1: 0.693, - _2: Math.LN2 - }) - ], - tl: { - hd: [ - "_LN10", - param => ({ - TAG: "ApproxThreshold", - _0: 0.001, - _1: 2.303, - _2: Math.LN10 - }) - ], - tl: { - hd: [ - "_LOG2E", - param => ({ - TAG: "ApproxThreshold", - _0: 0.001, - _1: 1.443, - _2: Math.LOG2E - }) - ], - tl: { - hd: [ - "_LOG10E", - param => ({ - TAG: "ApproxThreshold", - _0: 0.001, - _1: 0.434, - _2: Math.LOG10E - }) - ], - tl: { - hd: [ - "_PI", - param => ({ - TAG: "ApproxThreshold", - _0: 0.00001, - _1: 3.14159, - _2: Math.PI - }) - ], - tl: { - hd: [ - "_SQRT1_2", - param => ({ - TAG: "ApproxThreshold", - _0: 0.001, - _1: 0.707, - _2: Math.SQRT1_2 - }) - ], - tl: { - hd: [ - "_SQRT2", - param => ({ - TAG: "ApproxThreshold", - _0: 0.001, - _1: 1.414, - _2: Math.SQRT2 - }) - ], - tl: { - hd: [ - "abs_int", - param => ({ - TAG: "Eq", - _0: 4, - _1: Math.abs(-4) - }) - ], - tl: { - hd: [ - "abs_float", - param => ({ - TAG: "Eq", - _0: 1.2, - _1: Math.abs(-1.2) - }) - ], - tl: { - hd: [ - "acos", - param => ({ - TAG: "ApproxThreshold", - _0: 0.001, - _1: 1.159, - _2: Math.acos(0.4) - }) - ], - tl: { - hd: [ - "acosh", - param => ({ - TAG: "ApproxThreshold", - _0: 0.001, - _1: 0.622, - _2: Math.acosh(1.2) - }) - ], - tl: { - hd: [ - "asin", - param => ({ - TAG: "ApproxThreshold", - _0: 0.001, - _1: 0.411, - _2: Math.asin(0.4) - }) - ], - tl: { - hd: [ - "asinh", - param => ({ - TAG: "ApproxThreshold", - _0: 0.001, - _1: 0.390, - _2: Math.asinh(0.4) - }) - ], - tl: { - hd: [ - "atan", - param => ({ - TAG: "ApproxThreshold", - _0: 0.001, - _1: 0.380, - _2: Math.atan(0.4) - }) - ], - tl: { - hd: [ - "atanh", - param => ({ - TAG: "ApproxThreshold", - _0: 0.001, - _1: 0.423, - _2: Math.atanh(0.4) - }) - ], - tl: { - hd: [ - "atan2", - param => ({ - TAG: "ApproxThreshold", - _0: 0.001, - _1: 0.588, - _2: Math.atan2(0.4, 0.6) - }) - ], - tl: { - hd: [ - "cbrt", - param => ({ - TAG: "Eq", - _0: 2, - _1: Math.cbrt(8) - }) - ], - tl: { - hd: [ - "unsafe_ceil_int", - param => ({ - TAG: "Eq", - _0: 4, - _1: Math.ceil(3.2) - }) - ], - tl: { - hd: [ - "ceil_int", - param => ({ - TAG: "Eq", - _0: 4, - _1: Js_math.ceil_int(3.2) - }) - ], - tl: { - hd: [ - "ceil_float", - param => ({ - TAG: "Eq", - _0: 4, - _1: Math.ceil(3.2) - }) - ], - tl: { - hd: [ - "cos", - param => ({ - TAG: "ApproxThreshold", - _0: 0.001, - _1: 0.921, - _2: Math.cos(0.4) - }) - ], - tl: { - hd: [ - "cosh", - param => ({ - TAG: "ApproxThreshold", - _0: 0.001, - _1: 1.081, - _2: Math.cosh(0.4) - }) - ], - tl: { - hd: [ - "exp", - param => ({ - TAG: "ApproxThreshold", - _0: 0.001, - _1: 1.491, - _2: Math.exp(0.4) - }) - ], - tl: { - hd: [ - "expm1", - param => ({ - TAG: "ApproxThreshold", - _0: 0.001, - _1: 0.491, - _2: Math.expm1(0.4) - }) - ], - tl: { - hd: [ - "unsafe_floor_int", - param => ({ - TAG: "Eq", - _0: 3, - _1: Math.floor(3.2) - }) - ], - tl: { - hd: [ - "floor_int", - param => ({ - TAG: "Eq", - _0: 3, - _1: Js_math.floor_int(3.2) - }) - ], - tl: { - hd: [ - "floor_float", - param => ({ - TAG: "Eq", - _0: 3, - _1: Math.floor(3.2) - }) - ], - tl: { - hd: [ - "fround", - param => ({ - TAG: "Approx", - _0: 3.2, - _1: Math.fround(3.2) - }) - ], - tl: { - hd: [ - "hypot", - param => ({ - TAG: "ApproxThreshold", - _0: 0.001, - _1: 0.721, - _2: Math.hypot(0.4, 0.6) - }) - ], - tl: { - hd: [ - "hypotMany", - param => ({ - TAG: "ApproxThreshold", - _0: 0.001, - _1: 1.077, - _2: Math.hypot(0.4, 0.6, 0.8) - }) - ], - tl: { - hd: [ - "imul", - param => ({ - TAG: "Eq", - _0: 8, - _1: Math.imul(4, 2) - }) - ], - tl: { - hd: [ - "log", - param => ({ - TAG: "ApproxThreshold", - _0: 0.001, - _1: -0.916, - _2: Math.log(0.4) - }) - ], - tl: { - hd: [ - "log1p", - param => ({ - TAG: "ApproxThreshold", - _0: 0.001, - _1: 0.336, - _2: Math.log1p(0.4) - }) - ], - tl: { - hd: [ - "log10", - param => ({ - TAG: "ApproxThreshold", - _0: 0.001, - _1: -0.397, - _2: Math.log10(0.4) - }) - ], - tl: { - hd: [ - "log2", - param => ({ - TAG: "ApproxThreshold", - _0: 0.001, - _1: -1.321, - _2: Math.log2(0.4) - }) - ], - tl: { - hd: [ - "max_int", - param => ({ - TAG: "Eq", - _0: 4, - _1: Math.max(2, 4) - }) - ], - tl: { - hd: [ - "maxMany_int", - param => ({ - TAG: "Eq", - _0: 4, - _1: Math.max(2, 4, 3) - }) - ], - tl: { - hd: [ - "max_float", - param => ({ - TAG: "Eq", - _0: 4.2, - _1: Math.max(2.7, 4.2) - }) - ], - tl: { - hd: [ - "maxMany_float", - param => ({ - TAG: "Eq", - _0: 4.2, - _1: Math.max(2.7, 4.2, 3.9) - }) - ], - tl: { - hd: [ - "min_int", - param => ({ - TAG: "Eq", - _0: 2, - _1: Math.min(2, 4) - }) - ], - tl: { - hd: [ - "minMany_int", - param => ({ - TAG: "Eq", - _0: 2, - _1: Math.min(2, 4, 3) - }) - ], - tl: { - hd: [ - "min_float", - param => ({ - TAG: "Eq", - _0: 2.7, - _1: Math.min(2.7, 4.2) - }) - ], - tl: { - hd: [ - "minMany_float", - param => ({ - TAG: "Eq", - _0: 2.7, - _1: Math.min(2.7, 4.2, 3.9) - }) - ], - tl: { - hd: [ - "random", - param => { - let a = Math.random(); - return { - TAG: "Ok", - _0: a >= 0 && a < 1 - }; - } - ], - tl: { - hd: [ - "random_int", - param => { - let a = Js_math.random_int(1, 3); - return { - TAG: "Ok", - _0: a >= 1 && a < 3 - }; - } - ], - tl: { - hd: [ - "unsafe_round", - param => ({ - TAG: "Eq", - _0: 3, - _1: Math.round(3.2) - }) - ], - tl: { - hd: [ - "round", - param => ({ - TAG: "Eq", - _0: 3, - _1: Math.round(3.2) - }) - ], - tl: { - hd: [ - "sign_int", - param => ({ - TAG: "Eq", - _0: -1, - _1: Math.sign(-4) - }) - ], - tl: { - hd: [ - "sign_float", - param => ({ - TAG: "Eq", - _0: -1, - _1: Math.sign(-4.2) - }) - ], - tl: { - hd: [ - "sign_float -0", - param => ({ - TAG: "Eq", - _0: -0, - _1: Math.sign(-0) - }) - ], - tl: { - hd: [ - "sin", - param => ({ - TAG: "ApproxThreshold", - _0: 0.001, - _1: 0.389, - _2: Math.sin(0.4) - }) - ], - tl: { - hd: [ - "sinh", - param => ({ - TAG: "ApproxThreshold", - _0: 0.001, - _1: 0.410, - _2: Math.sinh(0.4) - }) - ], - tl: { - hd: [ - "sqrt", - param => ({ - TAG: "ApproxThreshold", - _0: 0.001, - _1: 0.632, - _2: Math.sqrt(0.4) - }) - ], - tl: { - hd: [ - "tan", - param => ({ - TAG: "ApproxThreshold", - _0: 0.001, - _1: 0.422, - _2: Math.tan(0.4) - }) - ], - tl: { - hd: [ - "tanh", - param => ({ - TAG: "ApproxThreshold", - _0: 0.001, - _1: 0.379, - _2: Math.tanh(0.4) - }) - ], - tl: { - hd: [ - "unsafe_trunc", - param => ({ - TAG: "Eq", - _0: 4, - _1: Math.trunc(4.2156) - }) - ], - tl: { - hd: [ - "trunc", - param => ({ - TAG: "Eq", - _0: 4, - _1: Math.trunc(4.2156) - }) - ], - tl: /* [] */0 - } - } - } - } - } - } - } - } - } - } - } - } - } - } - } - } - } - } - } - } - } - } - } - } - } - } - } - } - } - } - } - } - } - } - } - } - } - } - } - } - } - } - } - } - } - } - } - } - } - } - } - } - } - } - } - } -}; - -let suites = { - hd: suites_0, - tl: suites_1 -}; - -Mt.from_pair_suites("Js_math_test", suites); - -exports.suites = suites; -/* Not a pure module */ diff --git a/tests/tests/src/js_math_test.mjs b/tests/tests/src/js_math_test.mjs new file mode 100644 index 0000000000..4fd0796e70 --- /dev/null +++ b/tests/tests/src/js_math_test.mjs @@ -0,0 +1,631 @@ +// Generated by ReScript, PLEASE EDIT WITH CARE + +import * as Mt from "./mt.mjs"; +import * as Js_math from "rescript/lib/es6/Js_math.js"; + +let suites_0 = [ + "_E", + param => ({ + TAG: "ApproxThreshold", + _0: 0.001, + _1: 2.718, + _2: Math.E + }) +]; + +let suites_1 = { + hd: [ + "_LN2", + param => ({ + TAG: "ApproxThreshold", + _0: 0.001, + _1: 0.693, + _2: Math.LN2 + }) + ], + tl: { + hd: [ + "_LN10", + param => ({ + TAG: "ApproxThreshold", + _0: 0.001, + _1: 2.303, + _2: Math.LN10 + }) + ], + tl: { + hd: [ + "_LOG2E", + param => ({ + TAG: "ApproxThreshold", + _0: 0.001, + _1: 1.443, + _2: Math.LOG2E + }) + ], + tl: { + hd: [ + "_LOG10E", + param => ({ + TAG: "ApproxThreshold", + _0: 0.001, + _1: 0.434, + _2: Math.LOG10E + }) + ], + tl: { + hd: [ + "_PI", + param => ({ + TAG: "ApproxThreshold", + _0: 0.00001, + _1: 3.14159, + _2: Math.PI + }) + ], + tl: { + hd: [ + "_SQRT1_2", + param => ({ + TAG: "ApproxThreshold", + _0: 0.001, + _1: 0.707, + _2: Math.SQRT1_2 + }) + ], + tl: { + hd: [ + "_SQRT2", + param => ({ + TAG: "ApproxThreshold", + _0: 0.001, + _1: 1.414, + _2: Math.SQRT2 + }) + ], + tl: { + hd: [ + "abs_int", + param => ({ + TAG: "Eq", + _0: 4, + _1: Math.abs(-4) + }) + ], + tl: { + hd: [ + "abs_float", + param => ({ + TAG: "Eq", + _0: 1.2, + _1: Math.abs(-1.2) + }) + ], + tl: { + hd: [ + "acos", + param => ({ + TAG: "ApproxThreshold", + _0: 0.001, + _1: 1.159, + _2: Math.acos(0.4) + }) + ], + tl: { + hd: [ + "acosh", + param => ({ + TAG: "ApproxThreshold", + _0: 0.001, + _1: 0.622, + _2: Math.acosh(1.2) + }) + ], + tl: { + hd: [ + "asin", + param => ({ + TAG: "ApproxThreshold", + _0: 0.001, + _1: 0.411, + _2: Math.asin(0.4) + }) + ], + tl: { + hd: [ + "asinh", + param => ({ + TAG: "ApproxThreshold", + _0: 0.001, + _1: 0.390, + _2: Math.asinh(0.4) + }) + ], + tl: { + hd: [ + "atan", + param => ({ + TAG: "ApproxThreshold", + _0: 0.001, + _1: 0.380, + _2: Math.atan(0.4) + }) + ], + tl: { + hd: [ + "atanh", + param => ({ + TAG: "ApproxThreshold", + _0: 0.001, + _1: 0.423, + _2: Math.atanh(0.4) + }) + ], + tl: { + hd: [ + "atan2", + param => ({ + TAG: "ApproxThreshold", + _0: 0.001, + _1: 0.588, + _2: Math.atan2(0.4, 0.6) + }) + ], + tl: { + hd: [ + "cbrt", + param => ({ + TAG: "Eq", + _0: 2, + _1: Math.cbrt(8) + }) + ], + tl: { + hd: [ + "unsafe_ceil_int", + param => ({ + TAG: "Eq", + _0: 4, + _1: Math.ceil(3.2) + }) + ], + tl: { + hd: [ + "ceil_int", + param => ({ + TAG: "Eq", + _0: 4, + _1: Js_math.ceil_int(3.2) + }) + ], + tl: { + hd: [ + "ceil_float", + param => ({ + TAG: "Eq", + _0: 4, + _1: Math.ceil(3.2) + }) + ], + tl: { + hd: [ + "cos", + param => ({ + TAG: "ApproxThreshold", + _0: 0.001, + _1: 0.921, + _2: Math.cos(0.4) + }) + ], + tl: { + hd: [ + "cosh", + param => ({ + TAG: "ApproxThreshold", + _0: 0.001, + _1: 1.081, + _2: Math.cosh(0.4) + }) + ], + tl: { + hd: [ + "exp", + param => ({ + TAG: "ApproxThreshold", + _0: 0.001, + _1: 1.491, + _2: Math.exp(0.4) + }) + ], + tl: { + hd: [ + "expm1", + param => ({ + TAG: "ApproxThreshold", + _0: 0.001, + _1: 0.491, + _2: Math.expm1(0.4) + }) + ], + tl: { + hd: [ + "unsafe_floor_int", + param => ({ + TAG: "Eq", + _0: 3, + _1: Math.floor(3.2) + }) + ], + tl: { + hd: [ + "floor_int", + param => ({ + TAG: "Eq", + _0: 3, + _1: Js_math.floor_int(3.2) + }) + ], + tl: { + hd: [ + "floor_float", + param => ({ + TAG: "Eq", + _0: 3, + _1: Math.floor(3.2) + }) + ], + tl: { + hd: [ + "fround", + param => ({ + TAG: "Approx", + _0: 3.2, + _1: Math.fround(3.2) + }) + ], + tl: { + hd: [ + "hypot", + param => ({ + TAG: "ApproxThreshold", + _0: 0.001, + _1: 0.721, + _2: Math.hypot(0.4, 0.6) + }) + ], + tl: { + hd: [ + "hypotMany", + param => ({ + TAG: "ApproxThreshold", + _0: 0.001, + _1: 1.077, + _2: Math.hypot(0.4, 0.6, 0.8) + }) + ], + tl: { + hd: [ + "imul", + param => ({ + TAG: "Eq", + _0: 8, + _1: Math.imul(4, 2) + }) + ], + tl: { + hd: [ + "log", + param => ({ + TAG: "ApproxThreshold", + _0: 0.001, + _1: -0.916, + _2: Math.log(0.4) + }) + ], + tl: { + hd: [ + "log1p", + param => ({ + TAG: "ApproxThreshold", + _0: 0.001, + _1: 0.336, + _2: Math.log1p(0.4) + }) + ], + tl: { + hd: [ + "log10", + param => ({ + TAG: "ApproxThreshold", + _0: 0.001, + _1: -0.397, + _2: Math.log10(0.4) + }) + ], + tl: { + hd: [ + "log2", + param => ({ + TAG: "ApproxThreshold", + _0: 0.001, + _1: -1.321, + _2: Math.log2(0.4) + }) + ], + tl: { + hd: [ + "max_int", + param => ({ + TAG: "Eq", + _0: 4, + _1: Math.max(2, 4) + }) + ], + tl: { + hd: [ + "maxMany_int", + param => ({ + TAG: "Eq", + _0: 4, + _1: Math.max(2, 4, 3) + }) + ], + tl: { + hd: [ + "max_float", + param => ({ + TAG: "Eq", + _0: 4.2, + _1: Math.max(2.7, 4.2) + }) + ], + tl: { + hd: [ + "maxMany_float", + param => ({ + TAG: "Eq", + _0: 4.2, + _1: Math.max(2.7, 4.2, 3.9) + }) + ], + tl: { + hd: [ + "min_int", + param => ({ + TAG: "Eq", + _0: 2, + _1: Math.min(2, 4) + }) + ], + tl: { + hd: [ + "minMany_int", + param => ({ + TAG: "Eq", + _0: 2, + _1: Math.min(2, 4, 3) + }) + ], + tl: { + hd: [ + "min_float", + param => ({ + TAG: "Eq", + _0: 2.7, + _1: Math.min(2.7, 4.2) + }) + ], + tl: { + hd: [ + "minMany_float", + param => ({ + TAG: "Eq", + _0: 2.7, + _1: Math.min(2.7, 4.2, 3.9) + }) + ], + tl: { + hd: [ + "random", + param => { + let a = Math.random(); + return { + TAG: "Ok", + _0: a >= 0 && a < 1 + }; + } + ], + tl: { + hd: [ + "random_int", + param => { + let a = Js_math.random_int(1, 3); + return { + TAG: "Ok", + _0: a >= 1 && a < 3 + }; + } + ], + tl: { + hd: [ + "unsafe_round", + param => ({ + TAG: "Eq", + _0: 3, + _1: Math.round(3.2) + }) + ], + tl: { + hd: [ + "round", + param => ({ + TAG: "Eq", + _0: 3, + _1: Math.round(3.2) + }) + ], + tl: { + hd: [ + "sign_int", + param => ({ + TAG: "Eq", + _0: -1, + _1: Math.sign(-4) + }) + ], + tl: { + hd: [ + "sign_float", + param => ({ + TAG: "Eq", + _0: -1, + _1: Math.sign(-4.2) + }) + ], + tl: { + hd: [ + "sign_float -0", + param => ({ + TAG: "Eq", + _0: -0, + _1: Math.sign(-0) + }) + ], + tl: { + hd: [ + "sin", + param => ({ + TAG: "ApproxThreshold", + _0: 0.001, + _1: 0.389, + _2: Math.sin(0.4) + }) + ], + tl: { + hd: [ + "sinh", + param => ({ + TAG: "ApproxThreshold", + _0: 0.001, + _1: 0.410, + _2: Math.sinh(0.4) + }) + ], + tl: { + hd: [ + "sqrt", + param => ({ + TAG: "ApproxThreshold", + _0: 0.001, + _1: 0.632, + _2: Math.sqrt(0.4) + }) + ], + tl: { + hd: [ + "tan", + param => ({ + TAG: "ApproxThreshold", + _0: 0.001, + _1: 0.422, + _2: Math.tan(0.4) + }) + ], + tl: { + hd: [ + "tanh", + param => ({ + TAG: "ApproxThreshold", + _0: 0.001, + _1: 0.379, + _2: Math.tanh(0.4) + }) + ], + tl: { + hd: [ + "unsafe_trunc", + param => ({ + TAG: "Eq", + _0: 4, + _1: Math.trunc(4.2156) + }) + ], + tl: { + hd: [ + "trunc", + param => ({ + TAG: "Eq", + _0: 4, + _1: Math.trunc(4.2156) + }) + ], + tl: /* [] */0 + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } +}; + +let suites = { + hd: suites_0, + tl: suites_1 +}; + +Mt.from_pair_suites("Js_math_test", suites); + +export { + suites, +} +/* Not a pure module */ diff --git a/tests/tests/src/js_null_test.js b/tests/tests/src/js_null_test.js deleted file mode 100644 index 5602d061e0..0000000000 --- a/tests/tests/src/js_null_test.js +++ /dev/null @@ -1,143 +0,0 @@ -// Generated by ReScript, PLEASE EDIT WITH CARE -'use strict'; - -let Mt = require("./mt.js"); -let Js_null = require("rescript/lib/js/Js_null.js"); -let Primitive_option = require("rescript/lib/js/Primitive_option.js"); - -let suites_0 = [ - "toOption - empty", - param => ({ - TAG: "Eq", - _0: undefined, - _1: undefined - }) -]; - -let suites_1 = { - hd: [ - "toOption - 'a", - param => ({ - TAG: "Eq", - _0: Primitive_option.some(undefined), - _1: Primitive_option.some() - }) - ], - tl: { - hd: [ - "return", - param => ({ - TAG: "Eq", - _0: "something", - _1: Primitive_option.fromNull("something") - }) - ], - tl: { - hd: [ - "test - empty", - param => ({ - TAG: "Eq", - _0: true, - _1: true - }) - ], - tl: { - hd: [ - "test - 'a", - param => ({ - TAG: "Eq", - _0: false, - _1: false - }) - ], - tl: { - hd: [ - "bind - empty", - param => ({ - TAG: "StrictEq", - _0: null, - _1: Js_null.bind(null, v => v) - }) - ], - tl: { - hd: [ - "bind - 'a", - param => ({ - TAG: "StrictEq", - _0: 4, - _1: Js_null.bind(2, n => (n << 1)) - }) - ], - tl: { - hd: [ - "iter - empty", - param => { - let hit = { - contents: false - }; - Js_null.iter(null, param => { - hit.contents = true; - }); - return { - TAG: "Eq", - _0: false, - _1: hit.contents - }; - } - ], - tl: { - hd: [ - "iter - 'a", - param => { - let hit = { - contents: 0 - }; - Js_null.iter(2, v => { - hit.contents = v; - }); - return { - TAG: "Eq", - _0: 2, - _1: hit.contents - }; - } - ], - tl: { - hd: [ - "fromOption - None", - param => ({ - TAG: "Eq", - _0: null, - _1: Js_null.fromOption(undefined) - }) - ], - tl: { - hd: [ - "fromOption - Some", - param => ({ - TAG: "Eq", - _0: 2, - _1: Js_null.fromOption(2) - }) - ], - tl: /* [] */0 - } - } - } - } - } - } - } - } - } -}; - -let suites = { - hd: suites_0, - tl: suites_1 -}; - -Mt.from_pair_suites("Js_null_test", suites); - -exports.suites = suites; -/* Not a pure module */ diff --git a/tests/tests/src/js_null_test.mjs b/tests/tests/src/js_null_test.mjs new file mode 100644 index 0000000000..72e46d20a1 --- /dev/null +++ b/tests/tests/src/js_null_test.mjs @@ -0,0 +1,144 @@ +// Generated by ReScript, PLEASE EDIT WITH CARE + +import * as Mt from "./mt.mjs"; +import * as Js_null from "rescript/lib/es6/Js_null.js"; +import * as Primitive_option from "rescript/lib/es6/Primitive_option.js"; + +let suites_0 = [ + "toOption - empty", + param => ({ + TAG: "Eq", + _0: undefined, + _1: undefined + }) +]; + +let suites_1 = { + hd: [ + "toOption - 'a", + param => ({ + TAG: "Eq", + _0: Primitive_option.some(undefined), + _1: Primitive_option.some() + }) + ], + tl: { + hd: [ + "return", + param => ({ + TAG: "Eq", + _0: "something", + _1: Primitive_option.fromNull("something") + }) + ], + tl: { + hd: [ + "test - empty", + param => ({ + TAG: "Eq", + _0: true, + _1: true + }) + ], + tl: { + hd: [ + "test - 'a", + param => ({ + TAG: "Eq", + _0: false, + _1: false + }) + ], + tl: { + hd: [ + "bind - empty", + param => ({ + TAG: "StrictEq", + _0: null, + _1: Js_null.bind(null, v => v) + }) + ], + tl: { + hd: [ + "bind - 'a", + param => ({ + TAG: "StrictEq", + _0: 4, + _1: Js_null.bind(2, n => (n << 1)) + }) + ], + tl: { + hd: [ + "iter - empty", + param => { + let hit = { + contents: false + }; + Js_null.iter(null, param => { + hit.contents = true; + }); + return { + TAG: "Eq", + _0: false, + _1: hit.contents + }; + } + ], + tl: { + hd: [ + "iter - 'a", + param => { + let hit = { + contents: 0 + }; + Js_null.iter(2, v => { + hit.contents = v; + }); + return { + TAG: "Eq", + _0: 2, + _1: hit.contents + }; + } + ], + tl: { + hd: [ + "fromOption - None", + param => ({ + TAG: "Eq", + _0: null, + _1: Js_null.fromOption(undefined) + }) + ], + tl: { + hd: [ + "fromOption - Some", + param => ({ + TAG: "Eq", + _0: 2, + _1: Js_null.fromOption(2) + }) + ], + tl: /* [] */0 + } + } + } + } + } + } + } + } + } +}; + +let suites = { + hd: suites_0, + tl: suites_1 +}; + +Mt.from_pair_suites("Js_null_test", suites); + +export { + suites, +} +/* Not a pure module */ diff --git a/tests/tests/src/js_null_undefined_test.js b/tests/tests/src/js_null_undefined_test.js deleted file mode 100644 index 0be76007f1..0000000000 --- a/tests/tests/src/js_null_undefined_test.js +++ /dev/null @@ -1,275 +0,0 @@ -// Generated by ReScript, PLEASE EDIT WITH CARE -'use strict'; - -let Mt = require("./mt.js"); -let Primitive_option = require("rescript/lib/js/Primitive_option.js"); -let Js_null_undefined = require("rescript/lib/js/Js_null_undefined.js"); - -let suites_0 = [ - "toOption - null", - param => ({ - TAG: "Eq", - _0: undefined, - _1: undefined - }) -]; - -let suites_1 = { - hd: [ - "toOption - undefined", - param => ({ - TAG: "Eq", - _0: undefined, - _1: undefined - }) - ], - tl: { - hd: [ - "toOption - empty", - param => ({ - TAG: "Eq", - _0: undefined, - _1: undefined - }) - ], - tl: { - hd: [ - "File \"js_null_undefined_test.res\", line 9, characters 5-12", - param => ({ - TAG: "Eq", - _0: "foo", - _1: Primitive_option.fromNullable("foo") - }) - ], - tl: { - hd: [ - "return", - param => ({ - TAG: "Eq", - _0: "something", - _1: Primitive_option.fromNullable("something") - }) - ], - tl: { - hd: [ - "test - null", - param => ({ - TAG: "Eq", - _0: true, - _1: true - }) - ], - tl: { - hd: [ - "test - undefined", - param => ({ - TAG: "Eq", - _0: true, - _1: true - }) - ], - tl: { - hd: [ - "test - empty", - param => ({ - TAG: "Eq", - _0: true, - _1: true - }) - ], - tl: { - hd: [ - "File \"js_null_undefined_test.res\", line 14, characters 5-12", - param => ({ - TAG: "Eq", - _0: true, - _1: true - }) - ], - tl: { - hd: [ - "bind - null", - param => ({ - TAG: "StrictEq", - _0: null, - _1: Js_null_undefined.bind(null, v => v) - }) - ], - tl: { - hd: [ - "bind - undefined", - param => ({ - TAG: "StrictEq", - _0: undefined, - _1: Js_null_undefined.bind(undefined, v => v) - }) - ], - tl: { - hd: [ - "bind - empty", - param => ({ - TAG: "StrictEq", - _0: undefined, - _1: Js_null_undefined.bind(undefined, v => v) - }) - ], - tl: { - hd: [ - "bind - 'a", - param => ({ - TAG: "Eq", - _0: 4, - _1: Js_null_undefined.bind(2, n => (n << 1)) - }) - ], - tl: { - hd: [ - "iter - null", - param => { - let hit = { - contents: false - }; - Js_null_undefined.iter(null, param => { - hit.contents = true; - }); - return { - TAG: "Eq", - _0: false, - _1: hit.contents - }; - } - ], - tl: { - hd: [ - "iter - undefined", - param => { - let hit = { - contents: false - }; - Js_null_undefined.iter(undefined, param => { - hit.contents = true; - }); - return { - TAG: "Eq", - _0: false, - _1: hit.contents - }; - } - ], - tl: { - hd: [ - "iter - empty", - param => { - let hit = { - contents: false - }; - Js_null_undefined.iter(undefined, param => { - hit.contents = true; - }); - return { - TAG: "Eq", - _0: false, - _1: hit.contents - }; - } - ], - tl: { - hd: [ - "iter - 'a", - param => { - let hit = { - contents: 0 - }; - Js_null_undefined.iter(2, v => { - hit.contents = v; - }); - return { - TAG: "Eq", - _0: 2, - _1: hit.contents - }; - } - ], - tl: { - hd: [ - "fromOption - None", - param => ({ - TAG: "Eq", - _0: undefined, - _1: Js_null_undefined.fromOption(undefined) - }) - ], - tl: { - hd: [ - "fromOption - Some", - param => ({ - TAG: "Eq", - _0: 2, - _1: Js_null_undefined.fromOption(2) - }) - ], - tl: { - hd: [ - "null <> undefined", - param => ({ - TAG: "Ok", - _0: true - }) - ], - tl: { - hd: [ - "null <> empty", - param => ({ - TAG: "Ok", - _0: true - }) - ], - tl: { - hd: [ - "undefined = empty", - param => ({ - TAG: "Ok", - _0: true - }) - ], - tl: { - hd: [ - "File \"js_null_undefined_test.res\", line 57, characters 6-13", - param => ({ - TAG: "Ok", - _0: true - }) - ], - tl: /* [] */0 - } - } - } - } - } - } - } - } - } - } - } - } - } - } - } - } - } - } - } - } - } -}; - -let suites = { - hd: suites_0, - tl: suites_1 -}; - -Mt.from_pair_suites("Js_null_undefined_test", suites); - -exports.suites = suites; -/* Not a pure module */ diff --git a/tests/tests/src/js_null_undefined_test.mjs b/tests/tests/src/js_null_undefined_test.mjs new file mode 100644 index 0000000000..a6970c1b5b --- /dev/null +++ b/tests/tests/src/js_null_undefined_test.mjs @@ -0,0 +1,276 @@ +// Generated by ReScript, PLEASE EDIT WITH CARE + +import * as Mt from "./mt.mjs"; +import * as Primitive_option from "rescript/lib/es6/Primitive_option.js"; +import * as Js_null_undefined from "rescript/lib/es6/Js_null_undefined.js"; + +let suites_0 = [ + "toOption - null", + param => ({ + TAG: "Eq", + _0: undefined, + _1: undefined + }) +]; + +let suites_1 = { + hd: [ + "toOption - undefined", + param => ({ + TAG: "Eq", + _0: undefined, + _1: undefined + }) + ], + tl: { + hd: [ + "toOption - empty", + param => ({ + TAG: "Eq", + _0: undefined, + _1: undefined + }) + ], + tl: { + hd: [ + "File \"js_null_undefined_test.res\", line 9, characters 5-12", + param => ({ + TAG: "Eq", + _0: "foo", + _1: Primitive_option.fromNullable("foo") + }) + ], + tl: { + hd: [ + "return", + param => ({ + TAG: "Eq", + _0: "something", + _1: Primitive_option.fromNullable("something") + }) + ], + tl: { + hd: [ + "test - null", + param => ({ + TAG: "Eq", + _0: true, + _1: true + }) + ], + tl: { + hd: [ + "test - undefined", + param => ({ + TAG: "Eq", + _0: true, + _1: true + }) + ], + tl: { + hd: [ + "test - empty", + param => ({ + TAG: "Eq", + _0: true, + _1: true + }) + ], + tl: { + hd: [ + "File \"js_null_undefined_test.res\", line 14, characters 5-12", + param => ({ + TAG: "Eq", + _0: true, + _1: true + }) + ], + tl: { + hd: [ + "bind - null", + param => ({ + TAG: "StrictEq", + _0: null, + _1: Js_null_undefined.bind(null, v => v) + }) + ], + tl: { + hd: [ + "bind - undefined", + param => ({ + TAG: "StrictEq", + _0: undefined, + _1: Js_null_undefined.bind(undefined, v => v) + }) + ], + tl: { + hd: [ + "bind - empty", + param => ({ + TAG: "StrictEq", + _0: undefined, + _1: Js_null_undefined.bind(undefined, v => v) + }) + ], + tl: { + hd: [ + "bind - 'a", + param => ({ + TAG: "Eq", + _0: 4, + _1: Js_null_undefined.bind(2, n => (n << 1)) + }) + ], + tl: { + hd: [ + "iter - null", + param => { + let hit = { + contents: false + }; + Js_null_undefined.iter(null, param => { + hit.contents = true; + }); + return { + TAG: "Eq", + _0: false, + _1: hit.contents + }; + } + ], + tl: { + hd: [ + "iter - undefined", + param => { + let hit = { + contents: false + }; + Js_null_undefined.iter(undefined, param => { + hit.contents = true; + }); + return { + TAG: "Eq", + _0: false, + _1: hit.contents + }; + } + ], + tl: { + hd: [ + "iter - empty", + param => { + let hit = { + contents: false + }; + Js_null_undefined.iter(undefined, param => { + hit.contents = true; + }); + return { + TAG: "Eq", + _0: false, + _1: hit.contents + }; + } + ], + tl: { + hd: [ + "iter - 'a", + param => { + let hit = { + contents: 0 + }; + Js_null_undefined.iter(2, v => { + hit.contents = v; + }); + return { + TAG: "Eq", + _0: 2, + _1: hit.contents + }; + } + ], + tl: { + hd: [ + "fromOption - None", + param => ({ + TAG: "Eq", + _0: undefined, + _1: Js_null_undefined.fromOption(undefined) + }) + ], + tl: { + hd: [ + "fromOption - Some", + param => ({ + TAG: "Eq", + _0: 2, + _1: Js_null_undefined.fromOption(2) + }) + ], + tl: { + hd: [ + "null <> undefined", + param => ({ + TAG: "Ok", + _0: true + }) + ], + tl: { + hd: [ + "null <> empty", + param => ({ + TAG: "Ok", + _0: true + }) + ], + tl: { + hd: [ + "undefined = empty", + param => ({ + TAG: "Ok", + _0: true + }) + ], + tl: { + hd: [ + "File \"js_null_undefined_test.res\", line 57, characters 6-13", + param => ({ + TAG: "Ok", + _0: true + }) + ], + tl: /* [] */0 + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } +}; + +let suites = { + hd: suites_0, + tl: suites_1 +}; + +Mt.from_pair_suites("Js_null_undefined_test", suites); + +export { + suites, +} +/* Not a pure module */ diff --git a/tests/tests/src/js_nullable_test.js b/tests/tests/src/js_nullable_test.js deleted file mode 100644 index 1fe258c0b8..0000000000 --- a/tests/tests/src/js_nullable_test.js +++ /dev/null @@ -1,59 +0,0 @@ -// Generated by ReScript, PLEASE EDIT WITH CARE -'use strict'; - -let Mt = require("./mt.js"); - -let suites = { - contents: /* [] */0 -}; - -let test_id = { - contents: 0 -}; - -function eq(loc, x, y) { - test_id.contents = test_id.contents + 1 | 0; - suites.contents = { - hd: [ - loc + (" id " + test_id.contents.toString()), - () => ({ - TAG: "Eq", - _0: x, - _1: y - }) - ], - tl: suites.contents - }; -} - -function test(dom) { - let elem = dom.getElementById("haha"); - if (elem == null) { - return 1; - } else { - console.log(elem); - return 2; - } -} - -function f(x, y) { - console.log("no inline"); - return x + y | 0; -} - -eq("File \"js_nullable_test.res\", line 31, characters 3-10", false, false); - -eq("File \"js_nullable_test.res\", line 33, characters 3-10", (f(1, 2) == null), false); - -eq("File \"js_nullable_test.res\", line 35, characters 3-10", (null == null), true); - -eq("File \"js_nullable_test.res\", line 40, characters 5-12", false, false); - -Mt.from_pair_suites("Js_nullable_test", suites.contents); - -exports.suites = suites; -exports.test_id = test_id; -exports.eq = eq; -exports.test = test; -exports.f = f; -/* Not a pure module */ diff --git a/tests/tests/src/js_nullable_test.mjs b/tests/tests/src/js_nullable_test.mjs new file mode 100644 index 0000000000..858584d04a --- /dev/null +++ b/tests/tests/src/js_nullable_test.mjs @@ -0,0 +1,60 @@ +// Generated by ReScript, PLEASE EDIT WITH CARE + +import * as Mt from "./mt.mjs"; + +let suites = { + contents: /* [] */0 +}; + +let test_id = { + contents: 0 +}; + +function eq(loc, x, y) { + test_id.contents = test_id.contents + 1 | 0; + suites.contents = { + hd: [ + loc + (" id " + test_id.contents.toString()), + () => ({ + TAG: "Eq", + _0: x, + _1: y + }) + ], + tl: suites.contents + }; +} + +function test(dom) { + let elem = dom.getElementById("haha"); + if (elem == null) { + return 1; + } else { + console.log(elem); + return 2; + } +} + +function f(x, y) { + console.log("no inline"); + return x + y | 0; +} + +eq("File \"js_nullable_test.res\", line 31, characters 3-10", false, false); + +eq("File \"js_nullable_test.res\", line 33, characters 3-10", (f(1, 2) == null), false); + +eq("File \"js_nullable_test.res\", line 35, characters 3-10", (null == null), true); + +eq("File \"js_nullable_test.res\", line 40, characters 5-12", false, false); + +Mt.from_pair_suites("Js_nullable_test", suites.contents); + +export { + suites, + test_id, + eq, + test, + f, +} +/* Not a pure module */ diff --git a/tests/tests/src/js_obj_test.js b/tests/tests/src/js_obj_test.js deleted file mode 100644 index b39bb04e02..0000000000 --- a/tests/tests/src/js_obj_test.js +++ /dev/null @@ -1,39 +0,0 @@ -// Generated by ReScript, PLEASE EDIT WITH CARE -'use strict'; - -let Mt = require("./mt.js"); - -let suites_0 = [ - "empty", - param => ({ - TAG: "Eq", - _0: 0, - _1: Object.keys({}).length - }) -]; - -let suites_1 = { - hd: [ - "assign", - param => ({ - TAG: "Eq", - _0: { - a: 1 - }, - _1: Object.assign({}, { - a: 1 - }) - }) - ], - tl: /* [] */0 -}; - -let suites = { - hd: suites_0, - tl: suites_1 -}; - -Mt.from_pair_suites("Js_obj_test", suites); - -exports.suites = suites; -/* Not a pure module */ diff --git a/tests/tests/src/js_obj_test.mjs b/tests/tests/src/js_obj_test.mjs new file mode 100644 index 0000000000..0a013ea480 --- /dev/null +++ b/tests/tests/src/js_obj_test.mjs @@ -0,0 +1,40 @@ +// Generated by ReScript, PLEASE EDIT WITH CARE + +import * as Mt from "./mt.mjs"; + +let suites_0 = [ + "empty", + param => ({ + TAG: "Eq", + _0: 0, + _1: Object.keys({}).length + }) +]; + +let suites_1 = { + hd: [ + "assign", + param => ({ + TAG: "Eq", + _0: { + a: 1 + }, + _1: Object.assign({}, { + a: 1 + }) + }) + ], + tl: /* [] */0 +}; + +let suites = { + hd: suites_0, + tl: suites_1 +}; + +Mt.from_pair_suites("Js_obj_test", suites); + +export { + suites, +} +/* Not a pure module */ diff --git a/tests/tests/src/js_option_test.js b/tests/tests/src/js_option_test.js deleted file mode 100644 index 36a0a365e0..0000000000 --- a/tests/tests/src/js_option_test.js +++ /dev/null @@ -1,251 +0,0 @@ -// Generated by ReScript, PLEASE EDIT WITH CARE -'use strict'; - -let Mt = require("./mt.js"); -let Js_option = require("rescript/lib/js/Js_option.js"); - -function simpleEq(a, b) { - return a === b; -} - -let option_suites_0 = [ - "option_isSome_Some", - param => ({ - TAG: "Eq", - _0: true, - _1: Js_option.isSome(1) - }) -]; - -let option_suites_1 = { - hd: [ - "option_isSome_None", - param => ({ - TAG: "Eq", - _0: false, - _1: Js_option.isSome(undefined) - }) - ], - tl: { - hd: [ - "option_isNone_Some", - param => ({ - TAG: "Eq", - _0: false, - _1: Js_option.isNone(1) - }) - ], - tl: { - hd: [ - "option_isNone_None", - param => ({ - TAG: "Eq", - _0: true, - _1: Js_option.isNone(undefined) - }) - ], - tl: { - hd: [ - "option_isSomeValue_Eq", - param => ({ - TAG: "Eq", - _0: true, - _1: Js_option.isSomeValue(simpleEq, 2, 2) - }) - ], - tl: { - hd: [ - "option_isSomeValue_Diff", - param => ({ - TAG: "Eq", - _0: false, - _1: Js_option.isSomeValue(simpleEq, 1, 2) - }) - ], - tl: { - hd: [ - "option_isSomeValue_DiffNone", - param => ({ - TAG: "Eq", - _0: false, - _1: Js_option.isSomeValue(simpleEq, 1, undefined) - }) - ], - tl: { - hd: [ - "option_getExn_Some", - param => ({ - TAG: "Eq", - _0: 2, - _1: Js_option.getExn(2) - }) - ], - tl: { - hd: [ - "option_equal_Eq", - param => ({ - TAG: "Eq", - _0: true, - _1: Js_option.equal(simpleEq, 2, 2) - }) - ], - tl: { - hd: [ - "option_equal_Diff", - param => ({ - TAG: "Eq", - _0: false, - _1: Js_option.equal(simpleEq, 1, 2) - }) - ], - tl: { - hd: [ - "option_equal_DiffNone", - param => ({ - TAG: "Eq", - _0: false, - _1: Js_option.equal(simpleEq, 1, undefined) - }) - ], - tl: { - hd: [ - "option_andThen_SomeSome", - param => ({ - TAG: "Eq", - _0: true, - _1: Js_option.isSomeValue(simpleEq, 3, Js_option.andThen(a => a + 1 | 0, 2)) - }) - ], - tl: { - hd: [ - "option_andThen_SomeNone", - param => ({ - TAG: "Eq", - _0: false, - _1: Js_option.isSomeValue(simpleEq, 3, Js_option.andThen(param => {}, 2)) - }) - ], - tl: { - hd: [ - "option_map_Some", - param => ({ - TAG: "Eq", - _0: true, - _1: Js_option.isSomeValue(simpleEq, 3, Js_option.map(a => a + 1 | 0, 2)) - }) - ], - tl: { - hd: [ - "option_map_None", - param => ({ - TAG: "Eq", - _0: undefined, - _1: Js_option.map(a => a + 1 | 0, undefined) - }) - ], - tl: { - hd: [ - "option_default_Some", - param => ({ - TAG: "Eq", - _0: 2, - _1: Js_option.getWithDefault(3, 2) - }) - ], - tl: { - hd: [ - "option_default_None", - param => ({ - TAG: "Eq", - _0: 3, - _1: Js_option.getWithDefault(3, undefined) - }) - ], - tl: { - hd: [ - "option_filter_Pass", - param => ({ - TAG: "Eq", - _0: true, - _1: Js_option.isSomeValue(simpleEq, 2, Js_option.filter(a => a % 2 === 0, 2)) - }) - ], - tl: { - hd: [ - "option_filter_Reject", - param => ({ - TAG: "Eq", - _0: undefined, - _1: Js_option.filter(a => a % 3 === 0, 2) - }) - ], - tl: { - hd: [ - "option_filter_None", - param => ({ - TAG: "Eq", - _0: undefined, - _1: Js_option.filter(a => a % 3 === 0, undefined) - }) - ], - tl: { - hd: [ - "option_firstSome_First", - param => ({ - TAG: "Eq", - _0: true, - _1: Js_option.isSomeValue(simpleEq, 3, Js_option.firstSome(3, 2)) - }) - ], - tl: { - hd: [ - "option_firstSome_First", - param => ({ - TAG: "Eq", - _0: true, - _1: Js_option.isSomeValue(simpleEq, 2, Js_option.firstSome(undefined, 2)) - }) - ], - tl: { - hd: [ - "option_firstSome_None", - param => ({ - TAG: "Eq", - _0: undefined, - _1: Js_option.firstSome(undefined, undefined) - }) - ], - tl: /* [] */0 - } - } - } - } - } - } - } - } - } - } - } - } - } - } - } - } - } - } - } - } - } -}; - -let option_suites = { - hd: option_suites_0, - tl: option_suites_1 -}; - -Mt.from_pair_suites("Js_option_test", option_suites); - -exports.simpleEq = simpleEq; -exports.option_suites = option_suites; -/* Not a pure module */ diff --git a/tests/tests/src/js_option_test.mjs b/tests/tests/src/js_option_test.mjs new file mode 100644 index 0000000000..3c4ab8a792 --- /dev/null +++ b/tests/tests/src/js_option_test.mjs @@ -0,0 +1,252 @@ +// Generated by ReScript, PLEASE EDIT WITH CARE + +import * as Mt from "./mt.mjs"; +import * as Js_option from "rescript/lib/es6/Js_option.js"; + +function simpleEq(a, b) { + return a === b; +} + +let option_suites_0 = [ + "option_isSome_Some", + param => ({ + TAG: "Eq", + _0: true, + _1: Js_option.isSome(1) + }) +]; + +let option_suites_1 = { + hd: [ + "option_isSome_None", + param => ({ + TAG: "Eq", + _0: false, + _1: Js_option.isSome(undefined) + }) + ], + tl: { + hd: [ + "option_isNone_Some", + param => ({ + TAG: "Eq", + _0: false, + _1: Js_option.isNone(1) + }) + ], + tl: { + hd: [ + "option_isNone_None", + param => ({ + TAG: "Eq", + _0: true, + _1: Js_option.isNone(undefined) + }) + ], + tl: { + hd: [ + "option_isSomeValue_Eq", + param => ({ + TAG: "Eq", + _0: true, + _1: Js_option.isSomeValue(simpleEq, 2, 2) + }) + ], + tl: { + hd: [ + "option_isSomeValue_Diff", + param => ({ + TAG: "Eq", + _0: false, + _1: Js_option.isSomeValue(simpleEq, 1, 2) + }) + ], + tl: { + hd: [ + "option_isSomeValue_DiffNone", + param => ({ + TAG: "Eq", + _0: false, + _1: Js_option.isSomeValue(simpleEq, 1, undefined) + }) + ], + tl: { + hd: [ + "option_getExn_Some", + param => ({ + TAG: "Eq", + _0: 2, + _1: Js_option.getExn(2) + }) + ], + tl: { + hd: [ + "option_equal_Eq", + param => ({ + TAG: "Eq", + _0: true, + _1: Js_option.equal(simpleEq, 2, 2) + }) + ], + tl: { + hd: [ + "option_equal_Diff", + param => ({ + TAG: "Eq", + _0: false, + _1: Js_option.equal(simpleEq, 1, 2) + }) + ], + tl: { + hd: [ + "option_equal_DiffNone", + param => ({ + TAG: "Eq", + _0: false, + _1: Js_option.equal(simpleEq, 1, undefined) + }) + ], + tl: { + hd: [ + "option_andThen_SomeSome", + param => ({ + TAG: "Eq", + _0: true, + _1: Js_option.isSomeValue(simpleEq, 3, Js_option.andThen(a => a + 1 | 0, 2)) + }) + ], + tl: { + hd: [ + "option_andThen_SomeNone", + param => ({ + TAG: "Eq", + _0: false, + _1: Js_option.isSomeValue(simpleEq, 3, Js_option.andThen(param => {}, 2)) + }) + ], + tl: { + hd: [ + "option_map_Some", + param => ({ + TAG: "Eq", + _0: true, + _1: Js_option.isSomeValue(simpleEq, 3, Js_option.map(a => a + 1 | 0, 2)) + }) + ], + tl: { + hd: [ + "option_map_None", + param => ({ + TAG: "Eq", + _0: undefined, + _1: Js_option.map(a => a + 1 | 0, undefined) + }) + ], + tl: { + hd: [ + "option_default_Some", + param => ({ + TAG: "Eq", + _0: 2, + _1: Js_option.getWithDefault(3, 2) + }) + ], + tl: { + hd: [ + "option_default_None", + param => ({ + TAG: "Eq", + _0: 3, + _1: Js_option.getWithDefault(3, undefined) + }) + ], + tl: { + hd: [ + "option_filter_Pass", + param => ({ + TAG: "Eq", + _0: true, + _1: Js_option.isSomeValue(simpleEq, 2, Js_option.filter(a => a % 2 === 0, 2)) + }) + ], + tl: { + hd: [ + "option_filter_Reject", + param => ({ + TAG: "Eq", + _0: undefined, + _1: Js_option.filter(a => a % 3 === 0, 2) + }) + ], + tl: { + hd: [ + "option_filter_None", + param => ({ + TAG: "Eq", + _0: undefined, + _1: Js_option.filter(a => a % 3 === 0, undefined) + }) + ], + tl: { + hd: [ + "option_firstSome_First", + param => ({ + TAG: "Eq", + _0: true, + _1: Js_option.isSomeValue(simpleEq, 3, Js_option.firstSome(3, 2)) + }) + ], + tl: { + hd: [ + "option_firstSome_First", + param => ({ + TAG: "Eq", + _0: true, + _1: Js_option.isSomeValue(simpleEq, 2, Js_option.firstSome(undefined, 2)) + }) + ], + tl: { + hd: [ + "option_firstSome_None", + param => ({ + TAG: "Eq", + _0: undefined, + _1: Js_option.firstSome(undefined, undefined) + }) + ], + tl: /* [] */0 + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } +}; + +let option_suites = { + hd: option_suites_0, + tl: option_suites_1 +}; + +Mt.from_pair_suites("Js_option_test", option_suites); + +export { + simpleEq, + option_suites, +} +/* Not a pure module */ diff --git a/tests/tests/src/js_re_test.js b/tests/tests/src/js_re_test.js deleted file mode 100644 index c202252c06..0000000000 --- a/tests/tests/src/js_re_test.js +++ /dev/null @@ -1,279 +0,0 @@ -// Generated by ReScript, PLEASE EDIT WITH CARE -'use strict'; - -let Mt = require("./mt.js"); -let Primitive_array = require("rescript/lib/js/Primitive_array.js"); -let Primitive_option = require("rescript/lib/js/Primitive_option.js"); - -let suites_0 = [ - "captures", - param => { - let re = /(\d+)-(?:(\d+))?/g; - let result = re.exec("3-"); - if (result === null) { - return { - TAG: "Fail", - _0: undefined - }; - } - let defined = Primitive_array.get(result, 1); - let $$undefined = Primitive_array.get(result, 2); - return { - TAG: "Eq", - _0: [ - "3", - null - ], - _1: [ - defined, - $$undefined - ] - }; - } -]; - -let suites_1 = { - hd: [ - "fromString", - param => { - let contentOf = (tag, xmlString) => { - let x = Primitive_option.fromNull(new RegExp("<" + (tag + (">(.*?)<\\/" + (tag + ">")))).exec(xmlString)); - if (x !== undefined) { - return Primitive_option.fromNullable(Primitive_array.get(Primitive_option.valFromOption(x), 1)); - } - - }; - return { - TAG: "Eq", - _0: contentOf("div", "
Hi
"), - _1: "Hi" - }; - } - ], - tl: { - hd: [ - "exec_literal", - param => { - let res = /[^.]+/.exec("http://xxx.domain.com"); - if (res !== null) { - return { - TAG: "Eq", - _0: "http://xxx", - _1: Primitive_array.get(res, 0) - }; - } else { - return { - TAG: "FailWith", - _0: "regex should match" - }; - } - } - ], - tl: { - hd: [ - "exec_no_match", - param => { - let match = /https:\/\/(.*)/.exec("http://xxx.domain.com"); - if (match !== null) { - return { - TAG: "FailWith", - _0: "regex should not match" - }; - } else { - return { - TAG: "Ok", - _0: true - }; - } - } - ], - tl: { - hd: [ - "test_str", - param => { - let res = new RegExp("foo").test("#foo#"); - return { - TAG: "Eq", - _0: true, - _1: res - }; - } - ], - tl: { - hd: [ - "fromStringWithFlags", - param => { - let res = new RegExp("foo", "g"); - return { - TAG: "Eq", - _0: true, - _1: res.global - }; - } - ], - tl: { - hd: [ - "result_index", - param => { - let res = new RegExp("zbar").exec("foobarbazbar"); - if (res !== null) { - return { - TAG: "Eq", - _0: 8, - _1: res.index - }; - } else { - return { - TAG: "Fail", - _0: undefined - }; - } - } - ], - tl: { - hd: [ - "result_input", - param => { - let input = "foobar"; - let res = /foo/g.exec(input); - if (res !== null) { - return { - TAG: "Eq", - _0: input, - _1: res.input - }; - } else { - return { - TAG: "Fail", - _0: undefined - }; - } - } - ], - tl: { - hd: [ - "t_flags", - param => ({ - TAG: "Eq", - _0: "gi", - _1: /./ig.flags - }) - ], - tl: { - hd: [ - "t_global", - param => ({ - TAG: "Eq", - _0: true, - _1: /./ig.global - }) - ], - tl: { - hd: [ - "t_ignoreCase", - param => ({ - TAG: "Eq", - _0: true, - _1: /./ig.ignoreCase - }) - ], - tl: { - hd: [ - "t_lastIndex", - param => { - let re = /na/g; - re.exec("banana"); - return { - TAG: "Eq", - _0: 4, - _1: re.lastIndex - }; - } - ], - tl: { - hd: [ - "t_setLastIndex", - param => { - let re = /na/g; - let before = re.lastIndex; - re.lastIndex = 42; - let after = re.lastIndex; - return { - TAG: "Eq", - _0: [ - 0, - 42 - ], - _1: [ - before, - after - ] - }; - } - ], - tl: { - hd: [ - "t_multiline", - param => ({ - TAG: "Eq", - _0: false, - _1: /./ig.multiline - }) - ], - tl: { - hd: [ - "t_source", - param => ({ - TAG: "Eq", - _0: "f.+o", - _1: /f.+o/ig.source - }) - ], - tl: { - hd: [ - "t_sticky", - param => ({ - TAG: "Eq", - _0: true, - _1: /./yg.sticky - }) - ], - tl: { - hd: [ - "t_unicode", - param => ({ - TAG: "Eq", - _0: false, - _1: /./yg.unicode - }) - ], - tl: /* [] */0 - } - } - } - } - } - } - } - } - } - } - } - } - } - } - } -}; - -let suites = { - hd: suites_0, - tl: suites_1 -}; - -Mt.from_pair_suites("Js_re_test", suites); - -let $$Array; - -exports.$$Array = $$Array; -exports.suites = suites; -/* Not a pure module */ diff --git a/tests/tests/src/js_re_test.mjs b/tests/tests/src/js_re_test.mjs new file mode 100644 index 0000000000..6f199ed231 --- /dev/null +++ b/tests/tests/src/js_re_test.mjs @@ -0,0 +1,280 @@ +// Generated by ReScript, PLEASE EDIT WITH CARE + +import * as Mt from "./mt.mjs"; +import * as Primitive_array from "rescript/lib/es6/Primitive_array.js"; +import * as Primitive_option from "rescript/lib/es6/Primitive_option.js"; + +let suites_0 = [ + "captures", + param => { + let re = /(\d+)-(?:(\d+))?/g; + let result = re.exec("3-"); + if (result === null) { + return { + TAG: "Fail", + _0: undefined + }; + } + let defined = Primitive_array.get(result, 1); + let $$undefined = Primitive_array.get(result, 2); + return { + TAG: "Eq", + _0: [ + "3", + null + ], + _1: [ + defined, + $$undefined + ] + }; + } +]; + +let suites_1 = { + hd: [ + "fromString", + param => { + let contentOf = (tag, xmlString) => { + let x = Primitive_option.fromNull(new RegExp("<" + (tag + (">(.*?)<\\/" + (tag + ">")))).exec(xmlString)); + if (x !== undefined) { + return Primitive_option.fromNullable(Primitive_array.get(Primitive_option.valFromOption(x), 1)); + } + + }; + return { + TAG: "Eq", + _0: contentOf("div", "
Hi
"), + _1: "Hi" + }; + } + ], + tl: { + hd: [ + "exec_literal", + param => { + let res = /[^.]+/.exec("http://xxx.domain.com"); + if (res !== null) { + return { + TAG: "Eq", + _0: "http://xxx", + _1: Primitive_array.get(res, 0) + }; + } else { + return { + TAG: "FailWith", + _0: "regex should match" + }; + } + } + ], + tl: { + hd: [ + "exec_no_match", + param => { + let match = /https:\/\/(.*)/.exec("http://xxx.domain.com"); + if (match !== null) { + return { + TAG: "FailWith", + _0: "regex should not match" + }; + } else { + return { + TAG: "Ok", + _0: true + }; + } + } + ], + tl: { + hd: [ + "test_str", + param => { + let res = new RegExp("foo").test("#foo#"); + return { + TAG: "Eq", + _0: true, + _1: res + }; + } + ], + tl: { + hd: [ + "fromStringWithFlags", + param => { + let res = new RegExp("foo", "g"); + return { + TAG: "Eq", + _0: true, + _1: res.global + }; + } + ], + tl: { + hd: [ + "result_index", + param => { + let res = new RegExp("zbar").exec("foobarbazbar"); + if (res !== null) { + return { + TAG: "Eq", + _0: 8, + _1: res.index + }; + } else { + return { + TAG: "Fail", + _0: undefined + }; + } + } + ], + tl: { + hd: [ + "result_input", + param => { + let input = "foobar"; + let res = /foo/g.exec(input); + if (res !== null) { + return { + TAG: "Eq", + _0: input, + _1: res.input + }; + } else { + return { + TAG: "Fail", + _0: undefined + }; + } + } + ], + tl: { + hd: [ + "t_flags", + param => ({ + TAG: "Eq", + _0: "gi", + _1: /./ig.flags + }) + ], + tl: { + hd: [ + "t_global", + param => ({ + TAG: "Eq", + _0: true, + _1: /./ig.global + }) + ], + tl: { + hd: [ + "t_ignoreCase", + param => ({ + TAG: "Eq", + _0: true, + _1: /./ig.ignoreCase + }) + ], + tl: { + hd: [ + "t_lastIndex", + param => { + let re = /na/g; + re.exec("banana"); + return { + TAG: "Eq", + _0: 4, + _1: re.lastIndex + }; + } + ], + tl: { + hd: [ + "t_setLastIndex", + param => { + let re = /na/g; + let before = re.lastIndex; + re.lastIndex = 42; + let after = re.lastIndex; + return { + TAG: "Eq", + _0: [ + 0, + 42 + ], + _1: [ + before, + after + ] + }; + } + ], + tl: { + hd: [ + "t_multiline", + param => ({ + TAG: "Eq", + _0: false, + _1: /./ig.multiline + }) + ], + tl: { + hd: [ + "t_source", + param => ({ + TAG: "Eq", + _0: "f.+o", + _1: /f.+o/ig.source + }) + ], + tl: { + hd: [ + "t_sticky", + param => ({ + TAG: "Eq", + _0: true, + _1: /./yg.sticky + }) + ], + tl: { + hd: [ + "t_unicode", + param => ({ + TAG: "Eq", + _0: false, + _1: /./yg.unicode + }) + ], + tl: /* [] */0 + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } +}; + +let suites = { + hd: suites_0, + tl: suites_1 +}; + +Mt.from_pair_suites("Js_re_test", suites); + +let $$Array; + +export { + $$Array, + suites, +} +/* Not a pure module */ diff --git a/tests/tests/src/js_string_test.js b/tests/tests/src/js_string_test.js deleted file mode 100644 index 376f0a8d9c..0000000000 --- a/tests/tests/src/js_string_test.js +++ /dev/null @@ -1,628 +0,0 @@ -// Generated by ReScript, PLEASE EDIT WITH CARE -'use strict'; - -let Mt = require("./mt.js"); -let Js_string = require("rescript/lib/js/Js_string.js"); -let Belt_Option = require("rescript/lib/js/Belt_Option.js"); -let Primitive_option = require("rescript/lib/js/Primitive_option.js"); - -let suites_0 = [ - "make", - param => ({ - TAG: "Eq", - _0: "null", - _1: String(null).concat("") - }) -]; - -let suites_1 = { - hd: [ - "fromCharCode", - param => ({ - TAG: "Eq", - _0: "a", - _1: String.fromCharCode(97) - }) - ], - tl: { - hd: [ - "fromCharCodeMany", - param => ({ - TAG: "Eq", - _0: "az", - _1: String.fromCharCode(97, 122) - }) - ], - tl: { - hd: [ - "fromCodePoint", - param => ({ - TAG: "Eq", - _0: "a", - _1: String.fromCodePoint(97) - }) - ], - tl: { - hd: [ - "fromCodePointMany", - param => ({ - TAG: "Eq", - _0: "az", - _1: String.fromCodePoint(97, 122) - }) - ], - tl: { - hd: [ - "length", - param => ({ - TAG: "Eq", - _0: 3, - _1: "foo".length - }) - ], - tl: { - hd: [ - "get", - param => ({ - TAG: "Eq", - _0: "a", - _1: "foobar"[4] - }) - ], - tl: { - hd: [ - "charAt", - param => ({ - TAG: "Eq", - _0: "a", - _1: "foobar".charAt(4) - }) - ], - tl: { - hd: [ - "charCodeAt", - param => ({ - TAG: "Eq", - _0: 97, - _1: "foobar".charCodeAt(4) - }) - ], - tl: { - hd: [ - "codePointAt", - param => ({ - TAG: "Eq", - _0: 97, - _1: "foobar".codePointAt(4) - }) - ], - tl: { - hd: [ - "codePointAt - out of bounds", - param => ({ - TAG: "Eq", - _0: undefined, - _1: "foobar".codePointAt(98) - }) - ], - tl: { - hd: [ - "concat", - param => ({ - TAG: "Eq", - _0: "foobar", - _1: "foo".concat("bar") - }) - ], - tl: { - hd: [ - "concatMany", - param => ({ - TAG: "Eq", - _0: "foobarbaz", - _1: "foo".concat("bar", "baz") - }) - ], - tl: { - hd: [ - "endsWith", - param => ({ - TAG: "Eq", - _0: true, - _1: "foobar".endsWith("bar") - }) - ], - tl: { - hd: [ - "endsWithFrom", - param => ({ - TAG: "Eq", - _0: false, - _1: "foobar".endsWith("bar", 1) - }) - ], - tl: { - hd: [ - "includes", - param => ({ - TAG: "Eq", - _0: true, - _1: "foobarbaz".includes("bar") - }) - ], - tl: { - hd: [ - "includesFrom", - param => ({ - TAG: "Eq", - _0: false, - _1: "foobarbaz".includes("bar", 4) - }) - ], - tl: { - hd: [ - "indexOf", - param => ({ - TAG: "Eq", - _0: 3, - _1: "foobarbaz".indexOf("bar") - }) - ], - tl: { - hd: [ - "indexOfFrom", - param => ({ - TAG: "Eq", - _0: -1, - _1: "foobarbaz".indexOf("bar", 4) - }) - ], - tl: { - hd: [ - "lastIndexOf", - param => ({ - TAG: "Eq", - _0: 3, - _1: "foobarbaz".lastIndexOf("bar") - }) - ], - tl: { - hd: [ - "lastIndexOfFrom", - param => ({ - TAG: "Eq", - _0: 3, - _1: "foobarbaz".lastIndexOf("bar", 4) - }) - ], - tl: { - hd: [ - "localeCompare", - param => ({ - TAG: "Eq", - _0: 0, - _1: "foo".localeCompare("foo") - }) - ], - tl: { - hd: [ - "match", - param => ({ - TAG: "Eq", - _0: [ - "na", - "na" - ], - _1: Primitive_option.fromNull("banana".match(/na+/g)) - }) - ], - tl: { - hd: [ - "match - no match", - param => ({ - TAG: "Eq", - _0: undefined, - _1: Primitive_option.fromNull("banana".match(/nanana+/g)) - }) - ], - tl: { - hd: [ - "match - not found capture groups", - param => ({ - TAG: "Eq", - _0: [ - "hello ", - undefined - ], - _1: Belt_Option.map(Primitive_option.fromNull("hello word".match(/hello (world)?/)), prim => prim.slice()) - }) - ], - tl: { - hd: [ - "normalize", - param => ({ - TAG: "Eq", - _0: "foo", - _1: "foo".normalize() - }) - ], - tl: { - hd: [ - "normalizeByForm", - param => ({ - TAG: "Eq", - _0: "foo", - _1: "foo".normalize("NFKD") - }) - ], - tl: { - hd: [ - "repeat", - param => ({ - TAG: "Eq", - _0: "foofoofoo", - _1: "foo".repeat(3) - }) - ], - tl: { - hd: [ - "replace", - param => ({ - TAG: "Eq", - _0: "fooBORKbaz", - _1: "foobarbaz".replace("bar", "BORK") - }) - ], - tl: { - hd: [ - "replaceByRe", - param => ({ - TAG: "Eq", - _0: "fooBORKBORK", - _1: "foobarbaz".replace(/ba./g, "BORK") - }) - ], - tl: { - hd: [ - "unsafeReplaceBy0", - param => { - let replace = (whole, offset, s) => { - if (whole === "bar") { - return "BORK"; - } else { - return "DORK"; - } - }; - return { - TAG: "Eq", - _0: "fooBORKDORK", - _1: "foobarbaz".replace(/ba./g, replace) - }; - } - ], - tl: { - hd: [ - "unsafeReplaceBy1", - param => { - let replace = (whole, p1, offset, s) => { - if (whole === "bar") { - return "BORK"; - } else { - return "DORK"; - } - }; - return { - TAG: "Eq", - _0: "fooBORKDORK", - _1: "foobarbaz".replace(/ba./g, replace) - }; - } - ], - tl: { - hd: [ - "unsafeReplaceBy2", - param => { - let replace = (whole, p1, p2, offset, s) => { - if (whole === "bar") { - return "BORK"; - } else { - return "DORK"; - } - }; - return { - TAG: "Eq", - _0: "fooBORKDORK", - _1: "foobarbaz".replace(/ba./g, replace) - }; - } - ], - tl: { - hd: [ - "unsafeReplaceBy3", - param => { - let replace = (whole, p1, p2, p3, offset, s) => { - if (whole === "bar") { - return "BORK"; - } else { - return "DORK"; - } - }; - return { - TAG: "Eq", - _0: "fooBORKDORK", - _1: "foobarbaz".replace(/ba./g, replace) - }; - } - ], - tl: { - hd: [ - "search", - param => ({ - TAG: "Eq", - _0: 3, - _1: "foobarbaz".search(/ba./g) - }) - ], - tl: { - hd: [ - "slice", - param => ({ - TAG: "Eq", - _0: "bar", - _1: "foobarbaz".slice(3, 6) - }) - ], - tl: { - hd: [ - "sliceToEnd", - param => ({ - TAG: "Eq", - _0: "barbaz", - _1: "foobarbaz".slice(3) - }) - ], - tl: { - hd: [ - "split", - param => ({ - TAG: "Eq", - _0: [ - "foo", - "bar", - "baz" - ], - _1: "foo bar baz".split(" ") - }) - ], - tl: { - hd: [ - "splitAtMost", - param => ({ - TAG: "Eq", - _0: [ - "foo", - "bar" - ], - _1: "foo bar baz".split(" ", 2) - }) - ], - tl: { - hd: [ - "splitByRe", - param => ({ - TAG: "Eq", - _0: [ - "a", - "#", - undefined, - "b", - "#", - ":", - "c" - ], - _1: Js_string.splitByRe(/(#)(:)?/, "a#b#:c") - }) - ], - tl: { - hd: [ - "splitByReAtMost", - param => ({ - TAG: "Eq", - _0: [ - "a", - "#", - undefined - ], - _1: Js_string.splitByReAtMost(/(#)(:)?/, 3, "a#b#:c") - }) - ], - tl: { - hd: [ - "startsWith", - param => ({ - TAG: "Eq", - _0: true, - _1: "foobarbaz".startsWith("foo") - }) - ], - tl: { - hd: [ - "startsWithFrom", - param => ({ - TAG: "Eq", - _0: false, - _1: "foobarbaz".startsWith("foo", 1) - }) - ], - tl: { - hd: [ - "substr", - param => ({ - TAG: "Eq", - _0: "barbaz", - _1: "foobarbaz".substr(3) - }) - ], - tl: { - hd: [ - "substrAtMost", - param => ({ - TAG: "Eq", - _0: "bar", - _1: "foobarbaz".substr(3, 3) - }) - ], - tl: { - hd: [ - "substring", - param => ({ - TAG: "Eq", - _0: "bar", - _1: "foobarbaz".substring(3, 6) - }) - ], - tl: { - hd: [ - "substringToEnd", - param => ({ - TAG: "Eq", - _0: "barbaz", - _1: "foobarbaz".substring(3) - }) - ], - tl: { - hd: [ - "toLowerCase", - param => ({ - TAG: "Eq", - _0: "bork", - _1: "BORK".toLowerCase() - }) - ], - tl: { - hd: [ - "toLocaleLowerCase", - param => ({ - TAG: "Eq", - _0: "bork", - _1: "BORK".toLocaleLowerCase() - }) - ], - tl: { - hd: [ - "toUpperCase", - param => ({ - TAG: "Eq", - _0: "FUBAR", - _1: "fubar".toUpperCase() - }) - ], - tl: { - hd: [ - "toLocaleUpperCase", - param => ({ - TAG: "Eq", - _0: "FUBAR", - _1: "fubar".toLocaleUpperCase() - }) - ], - tl: { - hd: [ - "trim", - param => ({ - TAG: "Eq", - _0: "foo", - _1: " foo ".trim() - }) - ], - tl: { - hd: [ - "anchor", - param => ({ - TAG: "Eq", - _0: "foo", - _1: "foo".anchor("bar") - }) - ], - tl: { - hd: [ - "link", - param => ({ - TAG: "Eq", - _0: "foo", - _1: "foo".link("https://reason.ml") - }) - ], - tl: { - hd: [ - "File \"js_string_test.res\", line 135, characters 5-12", - param => ({ - TAG: "Ok", - _0: "ab".includes("a") - }) - ], - tl: /* [] */0 - } - } - } - } - } - } - } - } - } - } - } - } - } - } - } - } - } - } - } - } - } - } - } - } - } - } - } - } - } - } - } - } - } - } - } - } - } - } - } - } - } - } - } - } - } - } - } - } - } - } - } - } - } -}; - -let suites = { - hd: suites_0, - tl: suites_1 -}; - -Mt.from_pair_suites("Js_string_test", suites); - -exports.suites = suites; -/* Not a pure module */ diff --git a/tests/tests/src/js_string_test.mjs b/tests/tests/src/js_string_test.mjs new file mode 100644 index 0000000000..13432d0358 --- /dev/null +++ b/tests/tests/src/js_string_test.mjs @@ -0,0 +1,629 @@ +// Generated by ReScript, PLEASE EDIT WITH CARE + +import * as Mt from "./mt.mjs"; +import * as Js_string from "rescript/lib/es6/Js_string.js"; +import * as Belt_Option from "rescript/lib/es6/Belt_Option.js"; +import * as Primitive_option from "rescript/lib/es6/Primitive_option.js"; + +let suites_0 = [ + "make", + param => ({ + TAG: "Eq", + _0: "null", + _1: String(null).concat("") + }) +]; + +let suites_1 = { + hd: [ + "fromCharCode", + param => ({ + TAG: "Eq", + _0: "a", + _1: String.fromCharCode(97) + }) + ], + tl: { + hd: [ + "fromCharCodeMany", + param => ({ + TAG: "Eq", + _0: "az", + _1: String.fromCharCode(97, 122) + }) + ], + tl: { + hd: [ + "fromCodePoint", + param => ({ + TAG: "Eq", + _0: "a", + _1: String.fromCodePoint(97) + }) + ], + tl: { + hd: [ + "fromCodePointMany", + param => ({ + TAG: "Eq", + _0: "az", + _1: String.fromCodePoint(97, 122) + }) + ], + tl: { + hd: [ + "length", + param => ({ + TAG: "Eq", + _0: 3, + _1: "foo".length + }) + ], + tl: { + hd: [ + "get", + param => ({ + TAG: "Eq", + _0: "a", + _1: "foobar"[4] + }) + ], + tl: { + hd: [ + "charAt", + param => ({ + TAG: "Eq", + _0: "a", + _1: "foobar".charAt(4) + }) + ], + tl: { + hd: [ + "charCodeAt", + param => ({ + TAG: "Eq", + _0: 97, + _1: "foobar".charCodeAt(4) + }) + ], + tl: { + hd: [ + "codePointAt", + param => ({ + TAG: "Eq", + _0: 97, + _1: "foobar".codePointAt(4) + }) + ], + tl: { + hd: [ + "codePointAt - out of bounds", + param => ({ + TAG: "Eq", + _0: undefined, + _1: "foobar".codePointAt(98) + }) + ], + tl: { + hd: [ + "concat", + param => ({ + TAG: "Eq", + _0: "foobar", + _1: "foo".concat("bar") + }) + ], + tl: { + hd: [ + "concatMany", + param => ({ + TAG: "Eq", + _0: "foobarbaz", + _1: "foo".concat("bar", "baz") + }) + ], + tl: { + hd: [ + "endsWith", + param => ({ + TAG: "Eq", + _0: true, + _1: "foobar".endsWith("bar") + }) + ], + tl: { + hd: [ + "endsWithFrom", + param => ({ + TAG: "Eq", + _0: false, + _1: "foobar".endsWith("bar", 1) + }) + ], + tl: { + hd: [ + "includes", + param => ({ + TAG: "Eq", + _0: true, + _1: "foobarbaz".includes("bar") + }) + ], + tl: { + hd: [ + "includesFrom", + param => ({ + TAG: "Eq", + _0: false, + _1: "foobarbaz".includes("bar", 4) + }) + ], + tl: { + hd: [ + "indexOf", + param => ({ + TAG: "Eq", + _0: 3, + _1: "foobarbaz".indexOf("bar") + }) + ], + tl: { + hd: [ + "indexOfFrom", + param => ({ + TAG: "Eq", + _0: -1, + _1: "foobarbaz".indexOf("bar", 4) + }) + ], + tl: { + hd: [ + "lastIndexOf", + param => ({ + TAG: "Eq", + _0: 3, + _1: "foobarbaz".lastIndexOf("bar") + }) + ], + tl: { + hd: [ + "lastIndexOfFrom", + param => ({ + TAG: "Eq", + _0: 3, + _1: "foobarbaz".lastIndexOf("bar", 4) + }) + ], + tl: { + hd: [ + "localeCompare", + param => ({ + TAG: "Eq", + _0: 0, + _1: "foo".localeCompare("foo") + }) + ], + tl: { + hd: [ + "match", + param => ({ + TAG: "Eq", + _0: [ + "na", + "na" + ], + _1: Primitive_option.fromNull("banana".match(/na+/g)) + }) + ], + tl: { + hd: [ + "match - no match", + param => ({ + TAG: "Eq", + _0: undefined, + _1: Primitive_option.fromNull("banana".match(/nanana+/g)) + }) + ], + tl: { + hd: [ + "match - not found capture groups", + param => ({ + TAG: "Eq", + _0: [ + "hello ", + undefined + ], + _1: Belt_Option.map(Primitive_option.fromNull("hello word".match(/hello (world)?/)), prim => prim.slice()) + }) + ], + tl: { + hd: [ + "normalize", + param => ({ + TAG: "Eq", + _0: "foo", + _1: "foo".normalize() + }) + ], + tl: { + hd: [ + "normalizeByForm", + param => ({ + TAG: "Eq", + _0: "foo", + _1: "foo".normalize("NFKD") + }) + ], + tl: { + hd: [ + "repeat", + param => ({ + TAG: "Eq", + _0: "foofoofoo", + _1: "foo".repeat(3) + }) + ], + tl: { + hd: [ + "replace", + param => ({ + TAG: "Eq", + _0: "fooBORKbaz", + _1: "foobarbaz".replace("bar", "BORK") + }) + ], + tl: { + hd: [ + "replaceByRe", + param => ({ + TAG: "Eq", + _0: "fooBORKBORK", + _1: "foobarbaz".replace(/ba./g, "BORK") + }) + ], + tl: { + hd: [ + "unsafeReplaceBy0", + param => { + let replace = (whole, offset, s) => { + if (whole === "bar") { + return "BORK"; + } else { + return "DORK"; + } + }; + return { + TAG: "Eq", + _0: "fooBORKDORK", + _1: "foobarbaz".replace(/ba./g, replace) + }; + } + ], + tl: { + hd: [ + "unsafeReplaceBy1", + param => { + let replace = (whole, p1, offset, s) => { + if (whole === "bar") { + return "BORK"; + } else { + return "DORK"; + } + }; + return { + TAG: "Eq", + _0: "fooBORKDORK", + _1: "foobarbaz".replace(/ba./g, replace) + }; + } + ], + tl: { + hd: [ + "unsafeReplaceBy2", + param => { + let replace = (whole, p1, p2, offset, s) => { + if (whole === "bar") { + return "BORK"; + } else { + return "DORK"; + } + }; + return { + TAG: "Eq", + _0: "fooBORKDORK", + _1: "foobarbaz".replace(/ba./g, replace) + }; + } + ], + tl: { + hd: [ + "unsafeReplaceBy3", + param => { + let replace = (whole, p1, p2, p3, offset, s) => { + if (whole === "bar") { + return "BORK"; + } else { + return "DORK"; + } + }; + return { + TAG: "Eq", + _0: "fooBORKDORK", + _1: "foobarbaz".replace(/ba./g, replace) + }; + } + ], + tl: { + hd: [ + "search", + param => ({ + TAG: "Eq", + _0: 3, + _1: "foobarbaz".search(/ba./g) + }) + ], + tl: { + hd: [ + "slice", + param => ({ + TAG: "Eq", + _0: "bar", + _1: "foobarbaz".slice(3, 6) + }) + ], + tl: { + hd: [ + "sliceToEnd", + param => ({ + TAG: "Eq", + _0: "barbaz", + _1: "foobarbaz".slice(3) + }) + ], + tl: { + hd: [ + "split", + param => ({ + TAG: "Eq", + _0: [ + "foo", + "bar", + "baz" + ], + _1: "foo bar baz".split(" ") + }) + ], + tl: { + hd: [ + "splitAtMost", + param => ({ + TAG: "Eq", + _0: [ + "foo", + "bar" + ], + _1: "foo bar baz".split(" ", 2) + }) + ], + tl: { + hd: [ + "splitByRe", + param => ({ + TAG: "Eq", + _0: [ + "a", + "#", + undefined, + "b", + "#", + ":", + "c" + ], + _1: Js_string.splitByRe(/(#)(:)?/, "a#b#:c") + }) + ], + tl: { + hd: [ + "splitByReAtMost", + param => ({ + TAG: "Eq", + _0: [ + "a", + "#", + undefined + ], + _1: Js_string.splitByReAtMost(/(#)(:)?/, 3, "a#b#:c") + }) + ], + tl: { + hd: [ + "startsWith", + param => ({ + TAG: "Eq", + _0: true, + _1: "foobarbaz".startsWith("foo") + }) + ], + tl: { + hd: [ + "startsWithFrom", + param => ({ + TAG: "Eq", + _0: false, + _1: "foobarbaz".startsWith("foo", 1) + }) + ], + tl: { + hd: [ + "substr", + param => ({ + TAG: "Eq", + _0: "barbaz", + _1: "foobarbaz".substr(3) + }) + ], + tl: { + hd: [ + "substrAtMost", + param => ({ + TAG: "Eq", + _0: "bar", + _1: "foobarbaz".substr(3, 3) + }) + ], + tl: { + hd: [ + "substring", + param => ({ + TAG: "Eq", + _0: "bar", + _1: "foobarbaz".substring(3, 6) + }) + ], + tl: { + hd: [ + "substringToEnd", + param => ({ + TAG: "Eq", + _0: "barbaz", + _1: "foobarbaz".substring(3) + }) + ], + tl: { + hd: [ + "toLowerCase", + param => ({ + TAG: "Eq", + _0: "bork", + _1: "BORK".toLowerCase() + }) + ], + tl: { + hd: [ + "toLocaleLowerCase", + param => ({ + TAG: "Eq", + _0: "bork", + _1: "BORK".toLocaleLowerCase() + }) + ], + tl: { + hd: [ + "toUpperCase", + param => ({ + TAG: "Eq", + _0: "FUBAR", + _1: "fubar".toUpperCase() + }) + ], + tl: { + hd: [ + "toLocaleUpperCase", + param => ({ + TAG: "Eq", + _0: "FUBAR", + _1: "fubar".toLocaleUpperCase() + }) + ], + tl: { + hd: [ + "trim", + param => ({ + TAG: "Eq", + _0: "foo", + _1: " foo ".trim() + }) + ], + tl: { + hd: [ + "anchor", + param => ({ + TAG: "Eq", + _0: "foo", + _1: "foo".anchor("bar") + }) + ], + tl: { + hd: [ + "link", + param => ({ + TAG: "Eq", + _0: "foo", + _1: "foo".link("https://reason.ml") + }) + ], + tl: { + hd: [ + "File \"js_string_test.res\", line 135, characters 5-12", + param => ({ + TAG: "Ok", + _0: "ab".includes("a") + }) + ], + tl: /* [] */0 + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } +}; + +let suites = { + hd: suites_0, + tl: suites_1 +}; + +Mt.from_pair_suites("Js_string_test", suites); + +export { + suites, +} +/* Not a pure module */ diff --git a/tests/tests/src/js_undefined_test.js b/tests/tests/src/js_undefined_test.js deleted file mode 100644 index f8bf54b3a8..0000000000 --- a/tests/tests/src/js_undefined_test.js +++ /dev/null @@ -1,143 +0,0 @@ -// Generated by ReScript, PLEASE EDIT WITH CARE -'use strict'; - -let Mt = require("./mt.js"); -let Js_undefined = require("rescript/lib/js/Js_undefined.js"); -let Primitive_option = require("rescript/lib/js/Primitive_option.js"); - -let suites_0 = [ - "toOption - empty", - param => ({ - TAG: "Eq", - _0: undefined, - _1: undefined - }) -]; - -let suites_1 = { - hd: [ - "File \"js_undefined_test.res\", line 7, characters 5-12", - param => ({ - TAG: "Eq", - _0: undefined, - _1: undefined - }) - ], - tl: { - hd: [ - "return", - param => ({ - TAG: "Eq", - _0: "something", - _1: Primitive_option.fromUndefined("something") - }) - ], - tl: { - hd: [ - "test - empty", - param => ({ - TAG: "Eq", - _0: true, - _1: true - }) - ], - tl: { - hd: [ - "File \"js_undefined_test.res\", line 10, characters 5-12", - param => ({ - TAG: "Eq", - _0: true, - _1: true - }) - ], - tl: { - hd: [ - "bind - empty", - param => ({ - TAG: "Eq", - _0: undefined, - _1: Js_undefined.bind(undefined, v => v) - }) - ], - tl: { - hd: [ - "bind - 'a", - param => ({ - TAG: "Eq", - _0: 4, - _1: Js_undefined.bind(2, n => (n << 1)) - }) - ], - tl: { - hd: [ - "iter - empty", - param => { - let hit = { - contents: false - }; - Js_undefined.iter(undefined, param => { - hit.contents = true; - }); - return { - TAG: "Eq", - _0: false, - _1: hit.contents - }; - } - ], - tl: { - hd: [ - "iter - 'a", - param => { - let hit = { - contents: 0 - }; - Js_undefined.iter(2, v => { - hit.contents = v; - }); - return { - TAG: "Eq", - _0: 2, - _1: hit.contents - }; - } - ], - tl: { - hd: [ - "fromOption - None", - param => ({ - TAG: "Eq", - _0: undefined, - _1: Js_undefined.fromOption(undefined) - }) - ], - tl: { - hd: [ - "fromOption - Some", - param => ({ - TAG: "Eq", - _0: 2, - _1: Js_undefined.fromOption(2) - }) - ], - tl: /* [] */0 - } - } - } - } - } - } - } - } - } -}; - -let suites = { - hd: suites_0, - tl: suites_1 -}; - -Mt.from_pair_suites("Js_undefined_test", suites); - -exports.suites = suites; -/* Not a pure module */ diff --git a/tests/tests/src/js_undefined_test.mjs b/tests/tests/src/js_undefined_test.mjs new file mode 100644 index 0000000000..37f280b9c5 --- /dev/null +++ b/tests/tests/src/js_undefined_test.mjs @@ -0,0 +1,144 @@ +// Generated by ReScript, PLEASE EDIT WITH CARE + +import * as Mt from "./mt.mjs"; +import * as Js_undefined from "rescript/lib/es6/Js_undefined.js"; +import * as Primitive_option from "rescript/lib/es6/Primitive_option.js"; + +let suites_0 = [ + "toOption - empty", + param => ({ + TAG: "Eq", + _0: undefined, + _1: undefined + }) +]; + +let suites_1 = { + hd: [ + "File \"js_undefined_test.res\", line 7, characters 5-12", + param => ({ + TAG: "Eq", + _0: undefined, + _1: undefined + }) + ], + tl: { + hd: [ + "return", + param => ({ + TAG: "Eq", + _0: "something", + _1: Primitive_option.fromUndefined("something") + }) + ], + tl: { + hd: [ + "test - empty", + param => ({ + TAG: "Eq", + _0: true, + _1: true + }) + ], + tl: { + hd: [ + "File \"js_undefined_test.res\", line 10, characters 5-12", + param => ({ + TAG: "Eq", + _0: true, + _1: true + }) + ], + tl: { + hd: [ + "bind - empty", + param => ({ + TAG: "Eq", + _0: undefined, + _1: Js_undefined.bind(undefined, v => v) + }) + ], + tl: { + hd: [ + "bind - 'a", + param => ({ + TAG: "Eq", + _0: 4, + _1: Js_undefined.bind(2, n => (n << 1)) + }) + ], + tl: { + hd: [ + "iter - empty", + param => { + let hit = { + contents: false + }; + Js_undefined.iter(undefined, param => { + hit.contents = true; + }); + return { + TAG: "Eq", + _0: false, + _1: hit.contents + }; + } + ], + tl: { + hd: [ + "iter - 'a", + param => { + let hit = { + contents: 0 + }; + Js_undefined.iter(2, v => { + hit.contents = v; + }); + return { + TAG: "Eq", + _0: 2, + _1: hit.contents + }; + } + ], + tl: { + hd: [ + "fromOption - None", + param => ({ + TAG: "Eq", + _0: undefined, + _1: Js_undefined.fromOption(undefined) + }) + ], + tl: { + hd: [ + "fromOption - Some", + param => ({ + TAG: "Eq", + _0: 2, + _1: Js_undefined.fromOption(2) + }) + ], + tl: /* [] */0 + } + } + } + } + } + } + } + } + } +}; + +let suites = { + hd: suites_0, + tl: suites_1 +}; + +Mt.from_pair_suites("Js_undefined_test", suites); + +export { + suites, +} +/* Not a pure module */ diff --git a/tests/tests/src/js_val.js b/tests/tests/src/js_val.js deleted file mode 100644 index 8f90618909..0000000000 --- a/tests/tests/src/js_val.js +++ /dev/null @@ -1,18 +0,0 @@ -// Generated by ReScript, PLEASE EDIT WITH CARE -'use strict'; - -let X = require("x"); - -let h = u; - -let hh = X.vv; - -let hhh = X.vv; - -let hhhh = X.vvvv; - -exports.h = h; -exports.hh = hh; -exports.hhh = hhh; -exports.hhhh = hhhh; -/* h Not a pure module */ diff --git a/tests/tests/src/js_val.mjs b/tests/tests/src/js_val.mjs new file mode 100644 index 0000000000..9e179b40f5 --- /dev/null +++ b/tests/tests/src/js_val.mjs @@ -0,0 +1,19 @@ +// Generated by ReScript, PLEASE EDIT WITH CARE + +import * as X from "x"; + +let h = u; + +let hh = X.vv; + +let hhh = X.vv; + +let hhhh = X.vvvv; + +export { + h, + hh, + hhh, + hhhh, +} +/* h Not a pure module */ diff --git a/tests/tests/src/jsoo_400_test.js b/tests/tests/src/jsoo_400_test.js deleted file mode 100644 index 1fc00f0acf..0000000000 --- a/tests/tests/src/jsoo_400_test.js +++ /dev/null @@ -1,31 +0,0 @@ -// Generated by ReScript, PLEASE EDIT WITH CARE -'use strict'; - -let Mt = require("./mt.js"); -let Primitive_int = require("rescript/lib/js/Primitive_int.js"); - -function u() { - let n; - try { - n = "123".length; - } catch (exn) { - return 42; - } - return Primitive_int.div(3, 0); -} - -Mt.from_pair_suites("Jsoo_400_test", { - hd: [ - "File \"jsoo_400_test.res\", line 7, characters 38-45", - () => ({ - TAG: "ThrowAny", - _0: () => { - u(); - } - }) - ], - tl: /* [] */0 -}); - -exports.u = u; -/* Not a pure module */ diff --git a/tests/tests/src/jsoo_400_test.mjs b/tests/tests/src/jsoo_400_test.mjs new file mode 100644 index 0000000000..03ac7bf8a0 --- /dev/null +++ b/tests/tests/src/jsoo_400_test.mjs @@ -0,0 +1,32 @@ +// Generated by ReScript, PLEASE EDIT WITH CARE + +import * as Mt from "./mt.mjs"; +import * as Primitive_int from "rescript/lib/es6/Primitive_int.js"; + +function u() { + let n; + try { + n = "123".length; + } catch (exn) { + return 42; + } + return Primitive_int.div(3, 0); +} + +Mt.from_pair_suites("Jsoo_400_test", { + hd: [ + "File \"jsoo_400_test.res\", line 7, characters 38-45", + () => ({ + TAG: "ThrowAny", + _0: () => { + u(); + } + }) + ], + tl: /* [] */0 +}); + +export { + u, +} +/* Not a pure module */ diff --git a/tests/tests/src/jsoo_485_test.js b/tests/tests/src/jsoo_485_test.js deleted file mode 100644 index 2d3d8fcb08..0000000000 --- a/tests/tests/src/jsoo_485_test.js +++ /dev/null @@ -1,10 +0,0 @@ -// Generated by ReScript, PLEASE EDIT WITH CARE -'use strict'; - - -function f() { - 3; -} - -exports.f = f; -/* Not a pure module */ diff --git a/tests/tests/src/jsoo_485_test.mjs b/tests/tests/src/jsoo_485_test.mjs new file mode 100644 index 0000000000..9d8e343508 --- /dev/null +++ b/tests/tests/src/jsoo_485_test.mjs @@ -0,0 +1,11 @@ +// Generated by ReScript, PLEASE EDIT WITH CARE + + +function f() { + 3; +} + +export { + f, +} +/* Not a pure module */ diff --git a/tests/tests/src/jsxv4_newtype.js b/tests/tests/src/jsxv4_newtype.js deleted file mode 100644 index 89350fee88..0000000000 --- a/tests/tests/src/jsxv4_newtype.js +++ /dev/null @@ -1,41 +0,0 @@ -// Generated by ReScript, PLEASE EDIT WITH CARE -'use strict'; - - -function Jsxv4_newtype$V4A(props) { - return null; -} - -let V4A = { - make: Jsxv4_newtype$V4A -}; - -function Jsxv4_newtype$V4A1(props) { - return null; -} - -let V4A1 = { - make: Jsxv4_newtype$V4A1 -}; - -function Jsxv4_newtype$V4A2(props) { - return null; -} - -let V4A2 = { - make: Jsxv4_newtype$V4A2 -}; - -function Jsxv4_newtype$V4A3(props) { - return props.foo; -} - -let V4A3 = { - make: Jsxv4_newtype$V4A3 -}; - -exports.V4A = V4A; -exports.V4A1 = V4A1; -exports.V4A2 = V4A2; -exports.V4A3 = V4A3; -/* No side effect */ diff --git a/tests/tests/src/jsxv4_newtype.mjs b/tests/tests/src/jsxv4_newtype.mjs new file mode 100644 index 0000000000..6e12bf12b9 --- /dev/null +++ b/tests/tests/src/jsxv4_newtype.mjs @@ -0,0 +1,42 @@ +// Generated by ReScript, PLEASE EDIT WITH CARE + + +function Jsxv4_newtype$V4A(props) { + return null; +} + +let V4A = { + make: Jsxv4_newtype$V4A +}; + +function Jsxv4_newtype$V4A1(props) { + return null; +} + +let V4A1 = { + make: Jsxv4_newtype$V4A1 +}; + +function Jsxv4_newtype$V4A2(props) { + return null; +} + +let V4A2 = { + make: Jsxv4_newtype$V4A2 +}; + +function Jsxv4_newtype$V4A3(props) { + return props.foo; +} + +let V4A3 = { + make: Jsxv4_newtype$V4A3 +}; + +export { + V4A, + V4A1, + V4A2, + V4A3, +} +/* No side effect */ diff --git a/tests/tests/src/keep_uncurry_attribute.js b/tests/tests/src/keep_uncurry_attribute.js deleted file mode 100644 index 6ca125db40..0000000000 --- a/tests/tests/src/keep_uncurry_attribute.js +++ /dev/null @@ -1,15 +0,0 @@ -// Generated by ReScript, PLEASE EDIT WITH CARE -'use strict'; - - -function map1(prim0, prim1) { - return map(prim0, prim1); -} - -function map2(prim0, prim1) { - return map(prim0, prim1); -} - -exports.map1 = map1; -exports.map2 = map2; -/* No side effect */ diff --git a/tests/tests/src/keep_uncurry_attribute.mjs b/tests/tests/src/keep_uncurry_attribute.mjs new file mode 100644 index 0000000000..2aeae25082 --- /dev/null +++ b/tests/tests/src/keep_uncurry_attribute.mjs @@ -0,0 +1,16 @@ +// Generated by ReScript, PLEASE EDIT WITH CARE + + +function map1(prim0, prim1) { + return map(prim0, prim1); +} + +function map2(prim0, prim1) { + return map(prim0, prim1); +} + +export { + map1, + map2, +} +/* No side effect */ diff --git a/tests/tests/src/key_word_property.js b/tests/tests/src/key_word_property.js deleted file mode 100644 index f3c8178555..0000000000 --- a/tests/tests/src/key_word_property.js +++ /dev/null @@ -1,67 +0,0 @@ -// Generated by ReScript, PLEASE EDIT WITH CARE -'use strict'; - -let Vscode = require("vscode"); -let SomeEs6Module = require("some-es6-module"); -let SomeEs6Module$1 = require("some-es6-module").default; -let OmeEs6Module = require("./ome-es6-module").default; -let OmeEs6Module$1 = require("./ome-es6-module"); - -let $$default = SomeEs6Module$1; - -let default2 = SomeEs6Module.default2; - -let oefault = OmeEs6Module; - -let oefault2 = OmeEs6Module$1.default2; - -let window = Vscode.window; - -function mk(window, $$default) { - return { - window: window, - default: $$default - }; -} - -function mk2(window, $$default) { - return { - hd: { - window: window, - default: $$default - }, - tl: /* [] */0 - }; -} - -function des(v) { - return { - window: v.window, - default: v.default - }; -} - -let test = { - case: 3, - window: 3 -}; - -function u() { - return window.switch(); -} - -let $$case = 3; - -exports.default = $$default; -exports.__esModule = true; -exports.default2 = default2; -exports.oefault = oefault; -exports.oefault2 = oefault2; -exports.window = window; -exports.mk = mk; -exports.mk2 = mk2; -exports.des = des; -exports.$$case = $$case; -exports.test = test; -exports.u = u; -/* default Not a pure module */ diff --git a/tests/tests/src/key_word_property.mjs b/tests/tests/src/key_word_property.mjs new file mode 100644 index 0000000000..26e224057d --- /dev/null +++ b/tests/tests/src/key_word_property.mjs @@ -0,0 +1,67 @@ +// Generated by ReScript, PLEASE EDIT WITH CARE + +import * as Vscode from "vscode"; +import * as SomeEs6Module from "some-es6-module"; +import SomeEs6Module$1 from "some-es6-module"; +import OmeEs6Module from "./ome-es6-module"; +import * as OmeEs6Module$1 from "./ome-es6-module"; + +let $$default = SomeEs6Module$1; + +let default2 = SomeEs6Module.default2; + +let oefault = OmeEs6Module; + +let oefault2 = OmeEs6Module$1.default2; + +let window = Vscode.window; + +function mk(window, $$default) { + return { + window: window, + default: $$default + }; +} + +function mk2(window, $$default) { + return { + hd: { + window: window, + default: $$default + }, + tl: /* [] */0 + }; +} + +function des(v) { + return { + window: v.window, + default: v.default + }; +} + +let test = { + case: 3, + window: 3 +}; + +function u() { + return window.switch(); +} + +let $$case = 3; + +export { + $$default as default, + default2, + oefault, + oefault2, + window, + mk, + mk2, + des, + $$case, + test, + u, +} +/* default Not a pure module */ diff --git a/tests/tests/src/key_word_property2.js b/tests/tests/src/key_word_property2.js deleted file mode 100644 index b576e13b98..0000000000 --- a/tests/tests/src/key_word_property2.js +++ /dev/null @@ -1,31 +0,0 @@ -// Generated by ReScript, PLEASE EDIT WITH CARE -'use strict'; - -let Export_keyword = require("./export_keyword.js"); - -function test2(v) { - return { - _open: v._open, - window: v.window - }; -} - -function test(p) { - return [ - p.catch, - p._then - ]; -} - -let $$case = Export_keyword.$$case; - -let window = Export_keyword.window; - -let $$switch = Export_keyword.$$switch; - -exports.test2 = test2; -exports.test = test; -exports.$$case = $$case; -exports.window = window; -exports.$$switch = $$switch; -/* No side effect */ diff --git a/tests/tests/src/key_word_property2.mjs b/tests/tests/src/key_word_property2.mjs new file mode 100644 index 0000000000..5db581f8f0 --- /dev/null +++ b/tests/tests/src/key_word_property2.mjs @@ -0,0 +1,32 @@ +// Generated by ReScript, PLEASE EDIT WITH CARE + +import * as Export_keyword from "./export_keyword.mjs"; + +function test2(v) { + return { + _open: v._open, + window: v.window + }; +} + +function test(p) { + return [ + p.catch, + p._then + ]; +} + +let $$case = Export_keyword.$$case; + +let window = Export_keyword.window; + +let $$switch = Export_keyword.$$switch; + +export { + test2, + test, + $$case, + window, + $$switch, +} +/* No side effect */ diff --git a/tests/tests/src/key_word_property_plus_test.js b/tests/tests/src/key_word_property_plus_test.js deleted file mode 100644 index 24d7c9e106..0000000000 --- a/tests/tests/src/key_word_property_plus_test.js +++ /dev/null @@ -1,42 +0,0 @@ -// Generated by ReScript, PLEASE EDIT WITH CARE -'use strict'; - -let Mt = require("./mt.js"); -let Global_mangles = require("./global_mangles.js"); - -let suites = { - contents: /* [] */0 -}; - -let test_id = { - contents: 0 -}; - -function eq(loc, x, y) { - test_id.contents = test_id.contents + 1 | 0; - suites.contents = { - hd: [ - loc + (" id " + test_id.contents.toString()), - () => ({ - TAG: "Eq", - _0: x, - _1: y - }) - ], - tl: suites.contents - }; -} - -eq("File \"key_word_property_plus_test.res\", line 13, characters 2-9", [ - 1, - 2, - 3, - 4 -].reduce((prim0, prim1) => prim0 + prim1 | 0, 0), ((Global_mangles.$$__dirname + Global_mangles.$$__filename | 0) + Global_mangles.$$exports | 0) + Global_mangles.$$require | 0); - -Mt.from_pair_suites("Key_word_property_plus_test", suites.contents); - -exports.suites = suites; -exports.test_id = test_id; -exports.eq = eq; -/* Not a pure module */ diff --git a/tests/tests/src/key_word_property_plus_test.mjs b/tests/tests/src/key_word_property_plus_test.mjs new file mode 100644 index 0000000000..1a7bc49b29 --- /dev/null +++ b/tests/tests/src/key_word_property_plus_test.mjs @@ -0,0 +1,43 @@ +// Generated by ReScript, PLEASE EDIT WITH CARE + +import * as Mt from "./mt.mjs"; +import * as Global_mangles from "./global_mangles.mjs"; + +let suites = { + contents: /* [] */0 +}; + +let test_id = { + contents: 0 +}; + +function eq(loc, x, y) { + test_id.contents = test_id.contents + 1 | 0; + suites.contents = { + hd: [ + loc + (" id " + test_id.contents.toString()), + () => ({ + TAG: "Eq", + _0: x, + _1: y + }) + ], + tl: suites.contents + }; +} + +eq("File \"key_word_property_plus_test.res\", line 13, characters 2-9", [ + 1, + 2, + 3, + 4 +].reduce((prim0, prim1) => prim0 + prim1 | 0, 0), ((Global_mangles.$$__dirname + Global_mangles.$$__filename | 0) + Global_mangles.$$exports | 0) + Global_mangles.$$require | 0); + +Mt.from_pair_suites("Key_word_property_plus_test", suites.contents); + +export { + suites, + test_id, + eq, +} +/* Not a pure module */ diff --git a/tests/tests/src/label_uncurry.js b/tests/tests/src/label_uncurry.js deleted file mode 100644 index eccdd19de1..0000000000 --- a/tests/tests/src/label_uncurry.js +++ /dev/null @@ -1,34 +0,0 @@ -// Generated by ReScript, PLEASE EDIT WITH CARE -'use strict'; - -let Belt_Int = require("rescript/lib/js/Belt_Int.js"); - -function f(x) { - return x; -} - -function u(x, y) { - let y$1 = Belt_Int.fromString(y); - if (y$1 !== undefined) { - return x + y$1 | 0; - } - -} - -function u1(f) { - console.log(f(2, "x")); - console.log(f(2, "x")); -} - -function h(x) { - return 3; -} - -let a = u1(u); - -exports.f = f; -exports.u = u; -exports.u1 = u1; -exports.h = h; -exports.a = a; -/* a Not a pure module */ diff --git a/tests/tests/src/label_uncurry.mjs b/tests/tests/src/label_uncurry.mjs new file mode 100644 index 0000000000..1ec78962fe --- /dev/null +++ b/tests/tests/src/label_uncurry.mjs @@ -0,0 +1,35 @@ +// Generated by ReScript, PLEASE EDIT WITH CARE + +import * as Belt_Int from "rescript/lib/es6/Belt_Int.js"; + +function f(x) { + return x; +} + +function u(x, y) { + let y$1 = Belt_Int.fromString(y); + if (y$1 !== undefined) { + return x + y$1 | 0; + } + +} + +function u1(f) { + console.log(f(2, "x")); + console.log(f(2, "x")); +} + +function h(x) { + return 3; +} + +let a = u1(u); + +export { + f, + u, + u1, + h, + a, +} +/* a Not a pure module */ diff --git a/tests/tests/src/large_integer_pat.js b/tests/tests/src/large_integer_pat.js deleted file mode 100644 index 7e03d302c4..0000000000 --- a/tests/tests/src/large_integer_pat.js +++ /dev/null @@ -1,14 +0,0 @@ -// Generated by ReScript, PLEASE EDIT WITH CARE -'use strict'; - - -function ff(x) { - if (x >= 123 || x < 0) { - return 2; - } else { - return 1; - } -} - -exports.ff = ff; -/* No side effect */ diff --git a/tests/tests/src/large_integer_pat.mjs b/tests/tests/src/large_integer_pat.mjs new file mode 100644 index 0000000000..0439386152 --- /dev/null +++ b/tests/tests/src/large_integer_pat.mjs @@ -0,0 +1,15 @@ +// Generated by ReScript, PLEASE EDIT WITH CARE + + +function ff(x) { + if (x >= 123 || x < 0) { + return 2; + } else { + return 1; + } +} + +export { + ff, +} +/* No side effect */ diff --git a/tests/tests/src/large_record_duplication_test.js b/tests/tests/src/large_record_duplication_test.js deleted file mode 100644 index 2745be9fa7..0000000000 --- a/tests/tests/src/large_record_duplication_test.js +++ /dev/null @@ -1,248 +0,0 @@ -// Generated by ReScript, PLEASE EDIT WITH CARE -'use strict'; - -let Mt = require("./mt.js"); -let Primitive_object = require("rescript/lib/js/Primitive_object.js"); -let Primitive_exceptions = require("rescript/lib/js/Primitive_exceptions.js"); - -let suites = { - contents: /* [] */0 -}; - -let test_id = { - contents: 0 -}; - -function eq(loc, x, y) { - Mt.eq_suites(test_id, suites, loc, x, y); -} - -function f0(x) { - let newrecord = {...x}; - newrecord.x0 = 1; - return newrecord; -} - -let Small = /* @__PURE__ */Primitive_exceptions.create("Large_record_duplication_test.Small"); - -function f_small(x) { - if (x.RE_EXN_ID === Small) { - return { - RE_EXN_ID: Small, - x: 2, - y: x.y - }; - } else { - return { - RE_EXN_ID: "Not_found" - }; - } -} - -let h = { - RE_EXN_ID: Small, - x: 1, - y: "" -}; - -eq("File \"large_record_duplication_test.res\", line 70, characters 3-10", f_small(h), { - RE_EXN_ID: Small, - x: 2, - y: "" -}); - -eq("File \"large_record_duplication_test.res\", line 72, characters 3-10", Primitive_object.equal(h, { - RE_EXN_ID: Small, - x: 2, - y: "" -}), false); - -let v1 = { - TAG: "A0", - x0: 9, - x1: 9, - x2: 9, - x3: 9, - x4: 9, - x5: 9, - x6: 9, - x7: 9, - x8: 9, - x9: 9, - x10: 9, - x11: 9, - x12: 9, - x13: 9, - x14: 9, - x15: 9, - x16: 9, - x17: 9, - x18: 9, - x19: 9, - x20: 9, - x21: 9, - x22: 9 -}; - -function get_x0(x) { - if (typeof x !== "object") { - return; - } else { - return x.x0; - } -} - -function f1(x) { - if (typeof x !== "object") { - return "A1"; - } - let newrecord = {...x}; - newrecord.x0 = 1; - return newrecord; -} - -eq("File \"large_record_duplication_test.res\", line 140, characters 3-10", get_x0(f1(v1)), 1); - -let v2 = { - TAG: "A0", - x0: 9, - x1: 9, - x2: 9, - x3: 9, - x4: 9, - x5: 9, - x6: 9, - x7: 9, - x8: 9, - x9: 9, - x10: 9, - x11: 9, - x12: 9, - x13: 9, - x14: 9, - x15: 9, - x16: 9, - x17: 9, - x18: 9, - x19: 9, - x20: 9, - x21: 9, - x22: 9 -}; - -function get_x0$1(x) { - if (x.TAG === "A0") { - return x.x0; - } - -} - -function f2(x) { - if (x.TAG !== "A0") { - return x; - } - let newrecord = {...x}; - newrecord.x0 = 1; - return newrecord; -} - -eq("File \"large_record_duplication_test.res\", line 208, characters 3-10", get_x0$1(f2(v2)), 1); - -let A0 = /* @__PURE__ */Primitive_exceptions.create("Large_record_duplication_test.A0"); - -function f3(x) { - if (x.RE_EXN_ID !== A0) { - return x; - } - let newrecord = {...x}; - newrecord.x0 = 1; - return newrecord; -} - -function get_x0$2(x) { - if (x.RE_EXN_ID === A0) { - return x.x0; - } - -} - -let v3 = { - RE_EXN_ID: A0, - x0: 9, - x1: 9, - x2: 9, - x3: 9, - x4: 9, - x5: 9, - x6: 9, - x7: 9, - x8: 9, - x9: 9, - x10: 9, - x11: 9, - x12: 9, - x13: 9, - x14: 9, - x15: 9, - x16: 9, - x17: 9, - x18: 9, - x19: 9, - x20: 9, - x21: 9, - x22: 9 -}; - -eq("File \"large_record_duplication_test.res\", line 275, characters 3-10", get_x0$2(f3(v3)), 1); - -eq("File \"large_record_duplication_test.res\", line 276, characters 3-10", get_x0$2(v3), 9); - -eq("File \"large_record_duplication_test.res\", line 277, characters 3-10", get_x0$2({ - RE_EXN_ID: "Not_found" -}), undefined); - -Mt.from_pair_suites("Large_record_duplication_test", suites.contents); - -let v0 = { - x0: 9, - x1: 9, - x2: 9, - x3: 9, - x4: 9, - x5: 9, - x6: 9, - x7: 9, - x8: 9, - x9: 9, - x10: 9, - x11: 9, - x12: 9, - x13: 9, - x14: 9, - x15: 9, - x16: 9, - x17: 9, - x18: 9, - x19: 9, - x20: 9, - x21: 9, - x22: 9 -}; - -exports.suites = suites; -exports.test_id = test_id; -exports.eq = eq; -exports.v0 = v0; -exports.f0 = f0; -exports.Small = Small; -exports.f_small = f_small; -exports.h = h; -exports.v1 = v1; -exports.f1 = f1; -exports.v2 = v2; -exports.f2 = f2; -exports.A0 = A0; -exports.f3 = f3; -exports.get_x0 = get_x0$2; -exports.v3 = v3; -/* Not a pure module */ diff --git a/tests/tests/src/large_record_duplication_test.mjs b/tests/tests/src/large_record_duplication_test.mjs new file mode 100644 index 0000000000..1bf6c5d1fe --- /dev/null +++ b/tests/tests/src/large_record_duplication_test.mjs @@ -0,0 +1,249 @@ +// Generated by ReScript, PLEASE EDIT WITH CARE + +import * as Mt from "./mt.mjs"; +import * as Primitive_object from "rescript/lib/es6/Primitive_object.js"; +import * as Primitive_exceptions from "rescript/lib/es6/Primitive_exceptions.js"; + +let suites = { + contents: /* [] */0 +}; + +let test_id = { + contents: 0 +}; + +function eq(loc, x, y) { + Mt.eq_suites(test_id, suites, loc, x, y); +} + +function f0(x) { + let newrecord = {...x}; + newrecord.x0 = 1; + return newrecord; +} + +let Small = /* @__PURE__ */Primitive_exceptions.create("Large_record_duplication_test.Small"); + +function f_small(x) { + if (x.RE_EXN_ID === Small) { + return { + RE_EXN_ID: Small, + x: 2, + y: x.y + }; + } else { + return { + RE_EXN_ID: "Not_found" + }; + } +} + +let h = { + RE_EXN_ID: Small, + x: 1, + y: "" +}; + +eq("File \"large_record_duplication_test.res\", line 70, characters 3-10", f_small(h), { + RE_EXN_ID: Small, + x: 2, + y: "" +}); + +eq("File \"large_record_duplication_test.res\", line 72, characters 3-10", Primitive_object.equal(h, { + RE_EXN_ID: Small, + x: 2, + y: "" +}), false); + +let v1 = { + TAG: "A0", + x0: 9, + x1: 9, + x2: 9, + x3: 9, + x4: 9, + x5: 9, + x6: 9, + x7: 9, + x8: 9, + x9: 9, + x10: 9, + x11: 9, + x12: 9, + x13: 9, + x14: 9, + x15: 9, + x16: 9, + x17: 9, + x18: 9, + x19: 9, + x20: 9, + x21: 9, + x22: 9 +}; + +function get_x0(x) { + if (typeof x !== "object") { + return; + } else { + return x.x0; + } +} + +function f1(x) { + if (typeof x !== "object") { + return "A1"; + } + let newrecord = {...x}; + newrecord.x0 = 1; + return newrecord; +} + +eq("File \"large_record_duplication_test.res\", line 140, characters 3-10", get_x0(f1(v1)), 1); + +let v2 = { + TAG: "A0", + x0: 9, + x1: 9, + x2: 9, + x3: 9, + x4: 9, + x5: 9, + x6: 9, + x7: 9, + x8: 9, + x9: 9, + x10: 9, + x11: 9, + x12: 9, + x13: 9, + x14: 9, + x15: 9, + x16: 9, + x17: 9, + x18: 9, + x19: 9, + x20: 9, + x21: 9, + x22: 9 +}; + +function get_x0$1(x) { + if (x.TAG === "A0") { + return x.x0; + } + +} + +function f2(x) { + if (x.TAG !== "A0") { + return x; + } + let newrecord = {...x}; + newrecord.x0 = 1; + return newrecord; +} + +eq("File \"large_record_duplication_test.res\", line 208, characters 3-10", get_x0$1(f2(v2)), 1); + +let A0 = /* @__PURE__ */Primitive_exceptions.create("Large_record_duplication_test.A0"); + +function f3(x) { + if (x.RE_EXN_ID !== A0) { + return x; + } + let newrecord = {...x}; + newrecord.x0 = 1; + return newrecord; +} + +function get_x0$2(x) { + if (x.RE_EXN_ID === A0) { + return x.x0; + } + +} + +let v3 = { + RE_EXN_ID: A0, + x0: 9, + x1: 9, + x2: 9, + x3: 9, + x4: 9, + x5: 9, + x6: 9, + x7: 9, + x8: 9, + x9: 9, + x10: 9, + x11: 9, + x12: 9, + x13: 9, + x14: 9, + x15: 9, + x16: 9, + x17: 9, + x18: 9, + x19: 9, + x20: 9, + x21: 9, + x22: 9 +}; + +eq("File \"large_record_duplication_test.res\", line 275, characters 3-10", get_x0$2(f3(v3)), 1); + +eq("File \"large_record_duplication_test.res\", line 276, characters 3-10", get_x0$2(v3), 9); + +eq("File \"large_record_duplication_test.res\", line 277, characters 3-10", get_x0$2({ + RE_EXN_ID: "Not_found" +}), undefined); + +Mt.from_pair_suites("Large_record_duplication_test", suites.contents); + +let v0 = { + x0: 9, + x1: 9, + x2: 9, + x3: 9, + x4: 9, + x5: 9, + x6: 9, + x7: 9, + x8: 9, + x9: 9, + x10: 9, + x11: 9, + x12: 9, + x13: 9, + x14: 9, + x15: 9, + x16: 9, + x17: 9, + x18: 9, + x19: 9, + x20: 9, + x21: 9, + x22: 9 +}; + +export { + suites, + test_id, + eq, + v0, + f0, + Small, + f_small, + h, + v1, + f1, + v2, + f2, + A0, + f3, + get_x0$2 as get_x0, + v3, +} +/* Not a pure module */ diff --git a/tests/tests/src/largest_int_flow.js b/tests/tests/src/largest_int_flow.js deleted file mode 100644 index 983d4c7db5..0000000000 --- a/tests/tests/src/largest_int_flow.js +++ /dev/null @@ -1,8 +0,0 @@ -// Generated by ReScript, PLEASE EDIT WITH CARE -'use strict'; - - -let x = 272872590; - -exports.x = x; -/* No side effect */ diff --git a/tests/tests/src/largest_int_flow.mjs b/tests/tests/src/largest_int_flow.mjs new file mode 100644 index 0000000000..9e03876624 --- /dev/null +++ b/tests/tests/src/largest_int_flow.mjs @@ -0,0 +1,9 @@ +// Generated by ReScript, PLEASE EDIT WITH CARE + + +let x = 272872590; + +export { + x, +} +/* No side effect */ diff --git a/tests/tests/src/lazy_demo.js b/tests/tests/src/lazy_demo.js deleted file mode 100644 index 30ea117a52..0000000000 --- a/tests/tests/src/lazy_demo.js +++ /dev/null @@ -1,25 +0,0 @@ -// Generated by ReScript, PLEASE EDIT WITH CARE -'use strict'; - -let Lazy = require("rescript/lib/js/Lazy.js"); - -let lazy1 = Lazy.from_fun(() => { - console.log("Hello, lazy"); - return 1; -}); - -let lazy2 = Lazy.from_fun(() => 3); - -console.log(lazy1, lazy2); - -let la = Lazy.force(lazy1); - -let lb = Lazy.force(lazy2); - -console.log(la, lb); - -exports.lazy1 = lazy1; -exports.lazy2 = lazy2; -exports.la = la; -exports.lb = lb; -/* Not a pure module */ diff --git a/tests/tests/src/lazy_demo.mjs b/tests/tests/src/lazy_demo.mjs new file mode 100644 index 0000000000..494d3f3056 --- /dev/null +++ b/tests/tests/src/lazy_demo.mjs @@ -0,0 +1,26 @@ +// Generated by ReScript, PLEASE EDIT WITH CARE + +import * as Lazy from "rescript/lib/es6/Lazy.js"; + +let lazy1 = Lazy.from_fun(() => { + console.log("Hello, lazy"); + return 1; +}); + +let lazy2 = Lazy.from_fun(() => 3); + +console.log(lazy1, lazy2); + +let la = Lazy.force(lazy1); + +let lb = Lazy.force(lazy2); + +console.log(la, lb); + +export { + lazy1, + lazy2, + la, + lb, +} +/* Not a pure module */ diff --git a/tests/tests/src/lazy_test.js b/tests/tests/src/lazy_test.js deleted file mode 100644 index 7cc8a8f763..0000000000 --- a/tests/tests/src/lazy_test.js +++ /dev/null @@ -1,217 +0,0 @@ -// Generated by ReScript, PLEASE EDIT WITH CARE -'use strict'; - -let Mt = require("./mt.js"); -let Lazy = require("rescript/lib/js/Lazy.js"); - -let u = { - contents: 3 -}; - -let v = Lazy.from_fun(() => { - u.contents = 32; -}); - -function lazy_test() { - let h = u.contents; - Lazy.force(v); - let g = u.contents; - return [ - h, - g - ]; -} - -let u_v = { - contents: 0 -}; - -let u$1 = Lazy.from_fun(() => { - u_v.contents = 2; -}); - -Lazy.force(u$1); - -let exotic = Lazy.force; - -let l_from_fun = Lazy.from_fun(() => 3); - -let forward_test = Lazy.from_fun(() => { - let u = 3; - u = u + 1 | 0; - return u; -}); - -let f005 = Lazy.from_fun(() => 6); - -let f006 = Lazy.from_fun(() => (() => 3)); - -let f007 = Lazy.from_fun(() => { - throw { - RE_EXN_ID: "Not_found", - Error: new Error() - }; -}); - -let f008 = Lazy.from_fun(() => { - console.log("hi"); - throw { - RE_EXN_ID: "Not_found", - Error: new Error() - }; -}); - -let a2 = Lazy.from_val; - -let a3 = Lazy.from_val(3); - -let a4 = Lazy.from_val(3); - -let a5 = Lazy.from_val(undefined); - -let a6 = Lazy.from_val(); - -let a7 = Lazy.force(a5); - -let a8 = Lazy.force(a6); - -Mt.from_pair_suites("Lazy_test", { - hd: [ - "simple", - () => ({ - TAG: "Eq", - _0: lazy_test(), - _1: [ - 3, - 32 - ] - }) - ], - tl: { - hd: [ - "lazy_force", - () => ({ - TAG: "Eq", - _0: u_v.contents, - _1: 2 - }) - ], - tl: { - hd: [ - "lazy_from_fun", - () => ({ - TAG: "Eq", - _0: Lazy.force(l_from_fun), - _1: 3 - }) - ], - tl: { - hd: [ - "lazy_from_val", - () => ({ - TAG: "Eq", - _0: Lazy.force(Lazy.from_val(3)), - _1: 3 - }) - ], - tl: { - hd: [ - "lazy_from_val2", - () => ({ - TAG: "Eq", - _0: Lazy.force(Lazy.force(Lazy.from_val(Lazy.from_fun(() => 3)))), - _1: 3 - }) - ], - tl: { - hd: [ - "lazy_from_val3", - () => { - debugger; - return { - TAG: "Eq", - _0: Lazy.force(Lazy.force(Lazy.from_val(forward_test))), - _1: 4 - }; - } - ], - tl: { - hd: [ - "lazy_test.res", - () => ({ - TAG: "Eq", - _0: a3, - _1: a4 - }) - ], - tl: { - hd: [ - "lazy_test.res", - () => ({ - TAG: "Eq", - _0: a7, - _1: undefined - }) - ], - tl: { - hd: [ - "lazy_test.res", - () => ({ - TAG: "Eq", - _0: a8, - _1: undefined - }) - ], - tl: { - hd: [ - "File \"lazy_test.res\", line 98, characters 7-14", - () => ({ - TAG: "Ok", - _0: Lazy.is_val(Lazy.from_val(3)) - }) - ], - tl: { - hd: [ - "File \"lazy_test.res\", line 99, characters 7-14", - () => ({ - TAG: "Ok", - _0: !Lazy.is_val(Lazy.from_fun(() => { - throw { - RE_EXN_ID: "Not_found", - Error: new Error() - }; - })) - }) - ], - tl: /* [] */0 - } - } - } - } - } - } - } - } - } - } -}); - -exports.v = v; -exports.lazy_test = lazy_test; -exports.u_v = u_v; -exports.u = u$1; -exports.exotic = exotic; -exports.l_from_fun = l_from_fun; -exports.forward_test = forward_test; -exports.f005 = f005; -exports.f006 = f006; -exports.f007 = f007; -exports.f008 = f008; -exports.a2 = a2; -exports.a3 = a3; -exports.a4 = a4; -exports.a5 = a5; -exports.a6 = a6; -exports.a7 = a7; -exports.a8 = a8; -/* Not a pure module */ diff --git a/tests/tests/src/lazy_test.mjs b/tests/tests/src/lazy_test.mjs new file mode 100644 index 0000000000..81b84408b5 --- /dev/null +++ b/tests/tests/src/lazy_test.mjs @@ -0,0 +1,218 @@ +// Generated by ReScript, PLEASE EDIT WITH CARE + +import * as Mt from "./mt.mjs"; +import * as Lazy from "rescript/lib/es6/Lazy.js"; + +let u = { + contents: 3 +}; + +let v = Lazy.from_fun(() => { + u.contents = 32; +}); + +function lazy_test() { + let h = u.contents; + Lazy.force(v); + let g = u.contents; + return [ + h, + g + ]; +} + +let u_v = { + contents: 0 +}; + +let u$1 = Lazy.from_fun(() => { + u_v.contents = 2; +}); + +Lazy.force(u$1); + +let exotic = Lazy.force; + +let l_from_fun = Lazy.from_fun(() => 3); + +let forward_test = Lazy.from_fun(() => { + let u = 3; + u = u + 1 | 0; + return u; +}); + +let f005 = Lazy.from_fun(() => 6); + +let f006 = Lazy.from_fun(() => (() => 3)); + +let f007 = Lazy.from_fun(() => { + throw { + RE_EXN_ID: "Not_found", + Error: new Error() + }; +}); + +let f008 = Lazy.from_fun(() => { + console.log("hi"); + throw { + RE_EXN_ID: "Not_found", + Error: new Error() + }; +}); + +let a2 = Lazy.from_val; + +let a3 = Lazy.from_val(3); + +let a4 = Lazy.from_val(3); + +let a5 = Lazy.from_val(undefined); + +let a6 = Lazy.from_val(); + +let a7 = Lazy.force(a5); + +let a8 = Lazy.force(a6); + +Mt.from_pair_suites("Lazy_test", { + hd: [ + "simple", + () => ({ + TAG: "Eq", + _0: lazy_test(), + _1: [ + 3, + 32 + ] + }) + ], + tl: { + hd: [ + "lazy_force", + () => ({ + TAG: "Eq", + _0: u_v.contents, + _1: 2 + }) + ], + tl: { + hd: [ + "lazy_from_fun", + () => ({ + TAG: "Eq", + _0: Lazy.force(l_from_fun), + _1: 3 + }) + ], + tl: { + hd: [ + "lazy_from_val", + () => ({ + TAG: "Eq", + _0: Lazy.force(Lazy.from_val(3)), + _1: 3 + }) + ], + tl: { + hd: [ + "lazy_from_val2", + () => ({ + TAG: "Eq", + _0: Lazy.force(Lazy.force(Lazy.from_val(Lazy.from_fun(() => 3)))), + _1: 3 + }) + ], + tl: { + hd: [ + "lazy_from_val3", + () => { + debugger; + return { + TAG: "Eq", + _0: Lazy.force(Lazy.force(Lazy.from_val(forward_test))), + _1: 4 + }; + } + ], + tl: { + hd: [ + "lazy_test.res", + () => ({ + TAG: "Eq", + _0: a3, + _1: a4 + }) + ], + tl: { + hd: [ + "lazy_test.res", + () => ({ + TAG: "Eq", + _0: a7, + _1: undefined + }) + ], + tl: { + hd: [ + "lazy_test.res", + () => ({ + TAG: "Eq", + _0: a8, + _1: undefined + }) + ], + tl: { + hd: [ + "File \"lazy_test.res\", line 98, characters 7-14", + () => ({ + TAG: "Ok", + _0: Lazy.is_val(Lazy.from_val(3)) + }) + ], + tl: { + hd: [ + "File \"lazy_test.res\", line 99, characters 7-14", + () => ({ + TAG: "Ok", + _0: !Lazy.is_val(Lazy.from_fun(() => { + throw { + RE_EXN_ID: "Not_found", + Error: new Error() + }; + })) + }) + ], + tl: /* [] */0 + } + } + } + } + } + } + } + } + } + } +}); + +export { + v, + lazy_test, + u_v, + u$1 as u, + exotic, + l_from_fun, + forward_test, + f005, + f006, + f007, + f008, + a2, + a3, + a4, + a5, + a6, + a7, + a8, +} +/* Not a pure module */ diff --git a/tests/tests/src/lib_js_test.js b/tests/tests/src/lib_js_test.js deleted file mode 100644 index 58a10c1f40..0000000000 --- a/tests/tests/src/lib_js_test.js +++ /dev/null @@ -1,36 +0,0 @@ -// Generated by ReScript, PLEASE EDIT WITH CARE -'use strict'; - -let Mt = require("./mt.js"); - -console.log(JSON.stringify({ - hd: 1, - tl: { - hd: 2, - tl: { - hd: 3, - tl: /* [] */0 - } - } -})); - -console.log("hey"); - -let suites_0 = [ - "anything_to_string", - param => ({ - TAG: "Eq", - _0: "3", - _1: String(3) - }) -]; - -let suites = { - hd: suites_0, - tl: /* [] */0 -}; - -Mt.from_pair_suites("Lib_js_test", suites); - -exports.suites = suites; -/* Not a pure module */ diff --git a/tests/tests/src/lib_js_test.mjs b/tests/tests/src/lib_js_test.mjs new file mode 100644 index 0000000000..3f9a96b3db --- /dev/null +++ b/tests/tests/src/lib_js_test.mjs @@ -0,0 +1,37 @@ +// Generated by ReScript, PLEASE EDIT WITH CARE + +import * as Mt from "./mt.mjs"; + +console.log(JSON.stringify({ + hd: 1, + tl: { + hd: 2, + tl: { + hd: 3, + tl: /* [] */0 + } + } +})); + +console.log("hey"); + +let suites_0 = [ + "anything_to_string", + param => ({ + TAG: "Eq", + _0: "3", + _1: String(3) + }) +]; + +let suites = { + hd: suites_0, + tl: /* [] */0 +}; + +Mt.from_pair_suites("Lib_js_test", suites); + +export { + suites, +} +/* Not a pure module */ diff --git a/tests/tests/src/limits_test.js b/tests/tests/src/limits_test.js deleted file mode 100644 index 859defe438..0000000000 --- a/tests/tests/src/limits_test.js +++ /dev/null @@ -1,39 +0,0 @@ -// Generated by ReScript, PLEASE EDIT WITH CARE -'use strict'; - -let Mt = require("./mt.js"); -let Pervasives = require("rescript/lib/js/Pervasives.js"); - -let suites = { - contents: /* [] */0 -}; - -let test_id = { - contents: 0 -}; - -function eq(loc, x, y) { - test_id.contents = test_id.contents + 1 | 0; - suites.contents = { - hd: [ - loc + (" id " + test_id.contents.toString()), - () => ({ - TAG: "Eq", - _0: x, - _1: y - }) - ], - tl: suites.contents - }; -} - -eq("File \"limits_test.res\", line 13, characters 5-12", Pervasives.max_int, 2147483647); - -eq("File \"limits_test.res\", line 14, characters 5-12", Pervasives.min_int, -2147483648); - -Mt.from_pair_suites("Limits_test", suites.contents); - -exports.suites = suites; -exports.test_id = test_id; -exports.eq = eq; -/* Not a pure module */ diff --git a/tests/tests/src/limits_test.mjs b/tests/tests/src/limits_test.mjs new file mode 100644 index 0000000000..bb3d6ee16a --- /dev/null +++ b/tests/tests/src/limits_test.mjs @@ -0,0 +1,40 @@ +// Generated by ReScript, PLEASE EDIT WITH CARE + +import * as Mt from "./mt.mjs"; +import * as Pervasives from "rescript/lib/es6/Pervasives.js"; + +let suites = { + contents: /* [] */0 +}; + +let test_id = { + contents: 0 +}; + +function eq(loc, x, y) { + test_id.contents = test_id.contents + 1 | 0; + suites.contents = { + hd: [ + loc + (" id " + test_id.contents.toString()), + () => ({ + TAG: "Eq", + _0: x, + _1: y + }) + ], + tl: suites.contents + }; +} + +eq("File \"limits_test.res\", line 13, characters 5-12", Pervasives.max_int, 2147483647); + +eq("File \"limits_test.res\", line 14, characters 5-12", Pervasives.min_int, -2147483648); + +Mt.from_pair_suites("Limits_test", suites.contents); + +export { + suites, + test_id, + eq, +} +/* Not a pure module */ diff --git a/tests/tests/src/list_test.js b/tests/tests/src/list_test.js deleted file mode 100644 index 5f412f534f..0000000000 --- a/tests/tests/src/list_test.js +++ /dev/null @@ -1,169 +0,0 @@ -// Generated by ReScript, PLEASE EDIT WITH CARE -'use strict'; - -let Mt = require("./mt.js"); -let Belt_List = require("rescript/lib/js/Belt_List.js"); -let Belt_Array = require("rescript/lib/js/Belt_Array.js"); -let Primitive_int = require("rescript/lib/js/Primitive_int.js"); -let Primitive_object = require("rescript/lib/js/Primitive_object.js"); - -let eq = Primitive_object.equal; - -let list_suites_0 = [ - "length", - param => ({ - TAG: "Eq", - _0: 1, - _1: Belt_List.length({ - hd: [ - 0, - 1, - 2, - 3, - 4 - ], - tl: /* [] */0 - }) - }) -]; - -let list_suites_1 = { - hd: [ - "length2", - param => ({ - TAG: "Eq", - _0: 5, - _1: Belt_List.length({ - hd: 0, - tl: { - hd: 1, - tl: { - hd: 2, - tl: { - hd: 3, - tl: { - hd: 4, - tl: /* [] */0 - } - } - } - } - }) - }) - ], - tl: { - hd: [ - "long_length", - param => ({ - TAG: "Eq", - _0: 30000, - _1: Belt_List.length(Belt_List.fromArray(Belt_Array.init(30000, param => 0))) - }) - ], - tl: { - hd: [ - "sort", - param => ({ - TAG: "Eq", - _0: Belt_List.sort({ - hd: 4, - tl: { - hd: 1, - tl: { - hd: 2, - tl: { - hd: 3, - tl: /* [] */0 - } - } - } - }, Primitive_int.compare), - _1: { - hd: 1, - tl: { - hd: 2, - tl: { - hd: 3, - tl: { - hd: 4, - tl: /* [] */0 - } - } - } - } - }) - ], - tl: { - hd: [ - "File \"list_test.res\", line 23, characters 5-12", - param => ({ - TAG: "Eq", - _0: true, - _1: Belt_List.has({ - hd: 1, - tl: { - hd: 2, - tl: { - hd: 3, - tl: /* [] */0 - } - } - }, 3, eq) - }) - ], - tl: { - hd: [ - "File \"list_test.res\", line 24, characters 5-12", - param => ({ - TAG: "Eq", - _0: false, - _1: Belt_List.has({ - hd: 1, - tl: { - hd: 2, - tl: { - hd: 3, - tl: /* [] */0 - } - } - }, 4, eq) - }) - ], - tl: { - hd: [ - "File \"list_test.res\", line 25, characters 5-12", - param => ({ - TAG: "Eq", - _0: 9, - _1: Belt_List.getAssoc({ - hd: [ - 1, - 2 - ], - tl: { - hd: [ - 4, - 9 - ], - tl: /* [] */0 - } - }, 4, eq) - }) - ], - tl: /* [] */0 - } - } - } - } - } -}; - -let list_suites = { - hd: list_suites_0, - tl: list_suites_1 -}; - -Mt.from_pair_suites("List_test", list_suites); - -exports.list_suites = list_suites; -/* Not a pure module */ diff --git a/tests/tests/src/list_test.mjs b/tests/tests/src/list_test.mjs new file mode 100644 index 0000000000..a96e58ef11 --- /dev/null +++ b/tests/tests/src/list_test.mjs @@ -0,0 +1,170 @@ +// Generated by ReScript, PLEASE EDIT WITH CARE + +import * as Mt from "./mt.mjs"; +import * as Belt_List from "rescript/lib/es6/Belt_List.js"; +import * as Belt_Array from "rescript/lib/es6/Belt_Array.js"; +import * as Primitive_int from "rescript/lib/es6/Primitive_int.js"; +import * as Primitive_object from "rescript/lib/es6/Primitive_object.js"; + +let eq = Primitive_object.equal; + +let list_suites_0 = [ + "length", + param => ({ + TAG: "Eq", + _0: 1, + _1: Belt_List.length({ + hd: [ + 0, + 1, + 2, + 3, + 4 + ], + tl: /* [] */0 + }) + }) +]; + +let list_suites_1 = { + hd: [ + "length2", + param => ({ + TAG: "Eq", + _0: 5, + _1: Belt_List.length({ + hd: 0, + tl: { + hd: 1, + tl: { + hd: 2, + tl: { + hd: 3, + tl: { + hd: 4, + tl: /* [] */0 + } + } + } + } + }) + }) + ], + tl: { + hd: [ + "long_length", + param => ({ + TAG: "Eq", + _0: 30000, + _1: Belt_List.length(Belt_List.fromArray(Belt_Array.init(30000, param => 0))) + }) + ], + tl: { + hd: [ + "sort", + param => ({ + TAG: "Eq", + _0: Belt_List.sort({ + hd: 4, + tl: { + hd: 1, + tl: { + hd: 2, + tl: { + hd: 3, + tl: /* [] */0 + } + } + } + }, Primitive_int.compare), + _1: { + hd: 1, + tl: { + hd: 2, + tl: { + hd: 3, + tl: { + hd: 4, + tl: /* [] */0 + } + } + } + } + }) + ], + tl: { + hd: [ + "File \"list_test.res\", line 23, characters 5-12", + param => ({ + TAG: "Eq", + _0: true, + _1: Belt_List.has({ + hd: 1, + tl: { + hd: 2, + tl: { + hd: 3, + tl: /* [] */0 + } + } + }, 3, eq) + }) + ], + tl: { + hd: [ + "File \"list_test.res\", line 24, characters 5-12", + param => ({ + TAG: "Eq", + _0: false, + _1: Belt_List.has({ + hd: 1, + tl: { + hd: 2, + tl: { + hd: 3, + tl: /* [] */0 + } + } + }, 4, eq) + }) + ], + tl: { + hd: [ + "File \"list_test.res\", line 25, characters 5-12", + param => ({ + TAG: "Eq", + _0: 9, + _1: Belt_List.getAssoc({ + hd: [ + 1, + 2 + ], + tl: { + hd: [ + 4, + 9 + ], + tl: /* [] */0 + } + }, 4, eq) + }) + ], + tl: /* [] */0 + } + } + } + } + } +}; + +let list_suites = { + hd: list_suites_0, + tl: list_suites_1 +}; + +Mt.from_pair_suites("List_test", list_suites); + +export { + list_suites, +} +/* Not a pure module */ diff --git a/tests/tests/src/local_exception_test.js b/tests/tests/src/local_exception_test.js deleted file mode 100644 index 6fcd566e9d..0000000000 --- a/tests/tests/src/local_exception_test.js +++ /dev/null @@ -1,33 +0,0 @@ -// Generated by ReScript, PLEASE EDIT WITH CARE -'use strict'; - -let Primitive_exceptions = require("rescript/lib/js/Primitive_exceptions.js"); - -let A = /* @__PURE__ */Primitive_exceptions.create("Local_exception_test.A"); - -let v = { - RE_EXN_ID: A, - _1: 3, - _2: true -}; - -let B = /* @__PURE__ */Primitive_exceptions.create("Local_exception_test.B"); - -let u = { - RE_EXN_ID: B -}; - -let D = /* @__PURE__ */Primitive_exceptions.create("Local_exception_test.D"); - -let d = { - RE_EXN_ID: D, - _1: 3 -}; - -exports.A = A; -exports.v = v; -exports.B = B; -exports.u = u; -exports.D = D; -exports.d = d; -/* No side effect */ diff --git a/tests/tests/src/local_exception_test.mjs b/tests/tests/src/local_exception_test.mjs new file mode 100644 index 0000000000..09b738eb6b --- /dev/null +++ b/tests/tests/src/local_exception_test.mjs @@ -0,0 +1,34 @@ +// Generated by ReScript, PLEASE EDIT WITH CARE + +import * as Primitive_exceptions from "rescript/lib/es6/Primitive_exceptions.js"; + +let A = /* @__PURE__ */Primitive_exceptions.create("Local_exception_test.A"); + +let v = { + RE_EXN_ID: A, + _1: 3, + _2: true +}; + +let B = /* @__PURE__ */Primitive_exceptions.create("Local_exception_test.B"); + +let u = { + RE_EXN_ID: B +}; + +let D = /* @__PURE__ */Primitive_exceptions.create("Local_exception_test.D"); + +let d = { + RE_EXN_ID: D, + _1: 3 +}; + +export { + A, + v, + B, + u, + D, + d, +} +/* No side effect */ diff --git a/tests/tests/src/loop_regression_test.js b/tests/tests/src/loop_regression_test.js deleted file mode 100644 index af40ea6875..0000000000 --- a/tests/tests/src/loop_regression_test.js +++ /dev/null @@ -1,42 +0,0 @@ -// Generated by ReScript, PLEASE EDIT WITH CARE -'use strict'; - -let Mt = require("./mt.js"); - -function f() { - let v = { - contents: 0 - }; - let acc = { - contents: 0 - }; - let n = 10; - while (true) { - if (v.contents > n) { - return acc.contents; - } - acc.contents = acc.contents + v.contents | 0; - v.contents = v.contents + 1 | 0; - continue; - }; -} - -let suites_0 = [ - "sum", - param => ({ - TAG: "Eq", - _0: 55, - _1: f() - }) -]; - -let suites = { - hd: suites_0, - tl: /* [] */0 -}; - -Mt.from_pair_suites("Loop_regression_test", suites); - -exports.f = f; -exports.suites = suites; -/* Not a pure module */ diff --git a/tests/tests/src/loop_regression_test.mjs b/tests/tests/src/loop_regression_test.mjs new file mode 100644 index 0000000000..6883ee9b20 --- /dev/null +++ b/tests/tests/src/loop_regression_test.mjs @@ -0,0 +1,43 @@ +// Generated by ReScript, PLEASE EDIT WITH CARE + +import * as Mt from "./mt.mjs"; + +function f() { + let v = { + contents: 0 + }; + let acc = { + contents: 0 + }; + let n = 10; + while (true) { + if (v.contents > n) { + return acc.contents; + } + acc.contents = acc.contents + v.contents | 0; + v.contents = v.contents + 1 | 0; + continue; + }; +} + +let suites_0 = [ + "sum", + param => ({ + TAG: "Eq", + _0: 55, + _1: f() + }) +]; + +let suites = { + hd: suites_0, + tl: /* [] */0 +}; + +Mt.from_pair_suites("Loop_regression_test", suites); + +export { + f, + suites, +} +/* Not a pure module */ diff --git a/tests/tests/src/map_find_test.js b/tests/tests/src/map_find_test.js deleted file mode 100644 index a1ea4592a9..0000000000 --- a/tests/tests/src/map_find_test.js +++ /dev/null @@ -1,83 +0,0 @@ -// Generated by ReScript, PLEASE EDIT WITH CARE -'use strict'; - -let Mt = require("./mt.js"); -let Belt_List = require("rescript/lib/js/Belt_List.js"); -let Belt_MapInt = require("rescript/lib/js/Belt_MapInt.js"); -let Belt_MapString = require("rescript/lib/js/Belt_MapString.js"); - -let m = Belt_List.reduceReverse({ - hd: [ - 10, - /* 'a' */97 - ], - tl: { - hd: [ - 3, - /* 'b' */98 - ], - tl: { - hd: [ - 7, - /* 'c' */99 - ], - tl: { - hd: [ - 20, - /* 'd' */100 - ], - tl: /* [] */0 - } - } - } -}, undefined, (acc, param) => Belt_MapInt.set(acc, param[0], param[1])); - -let s = Belt_List.reduceReverse({ - hd: [ - "10", - /* 'a' */97 - ], - tl: { - hd: [ - "3", - /* 'b' */98 - ], - tl: { - hd: [ - "7", - /* 'c' */99 - ], - tl: { - hd: [ - "20", - /* 'd' */100 - ], - tl: /* [] */0 - } - } - } -}, undefined, (acc, param) => Belt_MapString.set(acc, param[0], param[1])); - -Mt.from_pair_suites("Map_find_test", { - hd: [ - "int", - () => ({ - TAG: "Eq", - _0: Belt_MapInt.get(m, 10), - _1: /* 'a' */97 - }) - ], - tl: { - hd: [ - "string", - () => ({ - TAG: "Eq", - _0: Belt_MapString.get(s, "10"), - _1: /* 'a' */97 - }) - ], - tl: /* [] */0 - } -}); - -/* m Not a pure module */ diff --git a/tests/tests/src/map_find_test.mjs b/tests/tests/src/map_find_test.mjs new file mode 100644 index 0000000000..e737597b13 --- /dev/null +++ b/tests/tests/src/map_find_test.mjs @@ -0,0 +1,82 @@ +// Generated by ReScript, PLEASE EDIT WITH CARE + +import * as Mt from "./mt.mjs"; +import * as Belt_List from "rescript/lib/es6/Belt_List.js"; +import * as Belt_MapInt from "rescript/lib/es6/Belt_MapInt.js"; +import * as Belt_MapString from "rescript/lib/es6/Belt_MapString.js"; + +let m = Belt_List.reduceReverse({ + hd: [ + 10, + /* 'a' */97 + ], + tl: { + hd: [ + 3, + /* 'b' */98 + ], + tl: { + hd: [ + 7, + /* 'c' */99 + ], + tl: { + hd: [ + 20, + /* 'd' */100 + ], + tl: /* [] */0 + } + } + } +}, undefined, (acc, param) => Belt_MapInt.set(acc, param[0], param[1])); + +let s = Belt_List.reduceReverse({ + hd: [ + "10", + /* 'a' */97 + ], + tl: { + hd: [ + "3", + /* 'b' */98 + ], + tl: { + hd: [ + "7", + /* 'c' */99 + ], + tl: { + hd: [ + "20", + /* 'd' */100 + ], + tl: /* [] */0 + } + } + } +}, undefined, (acc, param) => Belt_MapString.set(acc, param[0], param[1])); + +Mt.from_pair_suites("Map_find_test", { + hd: [ + "int", + () => ({ + TAG: "Eq", + _0: Belt_MapInt.get(m, 10), + _1: /* 'a' */97 + }) + ], + tl: { + hd: [ + "string", + () => ({ + TAG: "Eq", + _0: Belt_MapString.get(s, "10"), + _1: /* 'a' */97 + }) + ], + tl: /* [] */0 + } +}); + +/* m Not a pure module */ diff --git a/tests/tests/src/mario_game.js b/tests/tests/src/mario_game.js deleted file mode 100644 index b4da8a7816..0000000000 --- a/tests/tests/src/mario_game.js +++ /dev/null @@ -1,3335 +0,0 @@ -// Generated by ReScript, PLEASE EDIT WITH CARE -'use strict'; - -let Belt_List = require("rescript/lib/js/Belt_List.js"); -let Pervasives = require("rescript/lib/js/Pervasives.js"); -let Primitive_int = require("rescript/lib/js/Primitive_int.js"); -let Primitive_bool = require("rescript/lib/js/Primitive_bool.js"); -let Primitive_float = require("rescript/lib/js/Primitive_float.js"); -let Primitive_object = require("rescript/lib/js/Primitive_object.js"); -let Primitive_option = require("rescript/lib/js/Primitive_option.js"); - -function self_init() { - -} - -let int = ((max) => { - return ((Math.random() * 100) | 0) % max; - }); - -let Random = { - self_init: self_init, - int: int -}; - -let Actors = {}; - -let Dom_html = {}; - -function setup_sprite(loopOpt, bbox_offsetOpt, bbox_sizeOpt, img_src, max_frames, max_ticks, frame_size, src_offset) { - let loop = loopOpt !== undefined ? loopOpt : true; - let bbox_offset = bbox_offsetOpt !== undefined ? bbox_offsetOpt : [ - 0, - 0 - ]; - let bbox_size = bbox_sizeOpt !== undefined ? bbox_sizeOpt : [ - 0, - 0 - ]; - let bbox_size$1 = Primitive_object.equal(bbox_size, [ - 0, - 0 - ]) ? frame_size : bbox_size; - let img_src$1 = "./sprites/" + img_src; - return { - max_frames: max_frames, - max_ticks: max_ticks, - img_src: img_src$1, - frame_size: frame_size, - src_offset: src_offset, - bbox_offset: bbox_offset, - bbox_size: bbox_size$1, - loop: loop - }; -} - -function make_enemy(param) { - let dir = param[1]; - switch (param[0]) { - case "Goomba" : - return setup_sprite(undefined, [ - 1, - 1 - ], [ - 14, - 14 - ], "enemies.png", 2, 10, [ - 16, - 16 - ], [ - 0, - 128 - ]); - case "GKoopa" : - if (dir === "Left") { - return setup_sprite(undefined, [ - 4, - 10 - ], [ - 11, - 16 - ], "enemies.png", 2, 10, [ - 16, - 27 - ], [ - 0, - 69 - ]); - } else { - return setup_sprite(undefined, [ - 1, - 10 - ], [ - 11, - 16 - ], "enemies.png", 2, 10, [ - 16, - 27 - ], [ - 32, - 69 - ]); - } - case "RKoopa" : - if (dir === "Left") { - return setup_sprite(undefined, [ - 4, - 10 - ], [ - 11, - 16 - ], "enemies.png", 2, 10, [ - 16, - 27 - ], [ - 0, - 5 - ]); - } else { - return setup_sprite(undefined, [ - 1, - 10 - ], [ - 11, - 16 - ], "enemies.png", 2, 10, [ - 16, - 27 - ], [ - 32, - 5 - ]); - } - case "GKoopaShell" : - return setup_sprite(undefined, [ - 2, - 2 - ], [ - 12, - 13 - ], "enemies.png", 4, 10, [ - 16, - 16 - ], [ - 0, - 96 - ]); - case "RKoopaShell" : - return setup_sprite(undefined, [ - 2, - 2 - ], [ - 12, - 13 - ], "enemies.png", 4, 10, [ - 16, - 16 - ], [ - 0, - 32 - ]); - } -} - -function make_particle(x) { - switch (x) { - case "GoombaSquish" : - return setup_sprite(undefined, undefined, undefined, "enemies.png", 1, 0, [ - 16, - 16 - ], [ - 0, - 144 - ]); - case "BrickChunkL" : - return setup_sprite(undefined, undefined, undefined, "chunks.png", 1, 0, [ - 8, - 8 - ], [ - 0, - 0 - ]); - case "BrickChunkR" : - return setup_sprite(undefined, undefined, undefined, "chunks.png", 1, 0, [ - 8, - 8 - ], [ - 8, - 0 - ]); - case "Score100" : - return setup_sprite(undefined, undefined, undefined, "score.png", 1, 0, [ - 12, - 8 - ], [ - 0, - 0 - ]); - case "Score200" : - return setup_sprite(undefined, undefined, undefined, "score.png", 1, 0, [ - 12, - 9 - ], [ - 0, - 9 - ]); - case "Score400" : - return setup_sprite(undefined, undefined, undefined, "score.png", 1, 0, [ - 12, - 9 - ], [ - 0, - 18 - ]); - case "Score800" : - return setup_sprite(undefined, undefined, undefined, "score.png", 1, 0, [ - 12, - 9 - ], [ - 0, - 27 - ]); - case "Score1000" : - return setup_sprite(undefined, undefined, undefined, "score.png", 1, 0, [ - 14, - 9 - ], [ - 13, - 0 - ]); - case "Score2000" : - return setup_sprite(undefined, undefined, undefined, "score.png", 1, 0, [ - 14, - 9 - ], [ - 13, - 9 - ]); - case "Score4000" : - return setup_sprite(undefined, undefined, undefined, "score.png", 1, 0, [ - 14, - 9 - ], [ - 13, - 18 - ]); - case "Score8000" : - return setup_sprite(undefined, undefined, undefined, "score.png", 1, 0, [ - 14, - 9 - ], [ - 13, - 27 - ]); - } -} - -function make_type(typ, dir) { - switch (typ.TAG) { - case "SPlayer" : - let pt = typ._0; - let spr_type = [ - typ._1, - dir - ]; - if (pt === "BigM") { - let typ$1 = spr_type[0]; - if (spr_type[1] === "Left") { - switch (typ$1) { - case "Standing" : - return setup_sprite(undefined, [ - 2, - 1 - ], [ - 13, - 25 - ], "mario-big.png", 1, 0, [ - 16, - 27 - ], [ - 16, - 5 - ]); - case "Jumping" : - return setup_sprite(undefined, [ - 2, - 1 - ], [ - 12, - 25 - ], "mario-big.png", 1, 0, [ - 16, - 26 - ], [ - 48, - 6 - ]); - case "Running" : - return setup_sprite(undefined, [ - 2, - 1 - ], [ - 13, - 25 - ], "mario-big.png", 4, 10, [ - 16, - 27 - ], [ - 0, - 37 - ]); - case "Crouching" : - return setup_sprite(undefined, [ - 2, - 10 - ], [ - 13, - 17 - ], "mario-big.png", 1, 0, [ - 16, - 27 - ], [ - 32, - 5 - ]); - } - } else { - switch (typ$1) { - case "Standing" : - return setup_sprite(undefined, [ - 1, - 1 - ], [ - 13, - 25 - ], "mario-big.png", 1, 0, [ - 16, - 26 - ], [ - 16, - 69 - ]); - case "Jumping" : - return setup_sprite(undefined, [ - 2, - 1 - ], [ - 12, - 25 - ], "mario-big.png", 1, 0, [ - 16, - 26 - ], [ - 48, - 70 - ]); - case "Running" : - return setup_sprite(undefined, [ - 2, - 1 - ], [ - 13, - 25 - ], "mario-big.png", 4, 10, [ - 16, - 27 - ], [ - 0, - 101 - ]); - case "Crouching" : - return setup_sprite(undefined, [ - 2, - 10 - ], [ - 13, - 17 - ], "mario-big.png", 1, 0, [ - 16, - 27 - ], [ - 32, - 69 - ]); - } - } - } else { - let typ$2 = spr_type[0]; - if (spr_type[1] === "Left") { - switch (typ$2) { - case "Standing" : - return setup_sprite(undefined, [ - 3, - 1 - ], [ - 11, - 15 - ], "mario-small.png", 1, 0, [ - 16, - 16 - ], [ - 0, - 0 - ]); - case "Jumping" : - return setup_sprite(undefined, [ - 2, - 1 - ], [ - 13, - 15 - ], "mario-small.png", 2, 10, [ - 16, - 16 - ], [ - 16, - 16 - ]); - case "Running" : - return setup_sprite(undefined, [ - 2, - 1 - ], [ - 12, - 15 - ], "mario-small.png", 3, 5, [ - 16, - 16 - ], [ - 16, - 0 - ]); - case "Crouching" : - return setup_sprite(undefined, [ - 1, - 5 - ], [ - 14, - 10 - ], "mario-small.png", 1, 0, [ - 16, - 16 - ], [ - 0, - 64 - ]); - } - } else { - switch (typ$2) { - case "Standing" : - return setup_sprite(undefined, [ - 1, - 1 - ], [ - 11, - 15 - ], "mario-small.png", 1, 0, [ - 16, - 16 - ], [ - 0, - 32 - ]); - case "Jumping" : - return setup_sprite(undefined, [ - 2, - 1 - ], [ - 13, - 15 - ], "mario-small.png", 2, 10, [ - 16, - 16 - ], [ - 16, - 48 - ]); - case "Running" : - return setup_sprite(undefined, [ - 2, - 1 - ], [ - 12, - 15 - ], "mario-small.png", 3, 5, [ - 16, - 16 - ], [ - 16, - 32 - ]); - case "Crouching" : - return setup_sprite(undefined, [ - 1, - 5 - ], [ - 14, - 10 - ], "mario-small.png", 1, 0, [ - 16, - 16 - ], [ - 0, - 64 - ]); - } - } - } - case "SEnemy" : - return make_enemy([ - typ._0, - dir - ]); - case "SItem" : - let x = typ._0; - switch (x) { - case "Mushroom" : - return setup_sprite(undefined, [ - 2, - 0 - ], [ - 12, - 16 - ], "items.png", 1, 0, [ - 16, - 16 - ], [ - 0, - 0 - ]); - case "FireFlower" : - return setup_sprite(undefined, undefined, undefined, "items.png", 1, 0, [ - 16, - 16 - ], [ - 0, - 188 - ]); - case "Star" : - return setup_sprite(undefined, undefined, undefined, "items.png", 1, 0, [ - 16, - 16 - ], [ - 16, - 48 - ]); - case "Coin" : - return setup_sprite(undefined, [ - 3, - 0 - ], [ - 12, - 16 - ], "items.png", 3, 15, [ - 16, - 16 - ], [ - 0, - 80 - ]); - } - case "SBlock" : - let x$1 = typ._0; - if (typeof x$1 === "object") { - return setup_sprite(undefined, undefined, undefined, "blocks.png", 4, 15, [ - 16, - 16 - ], [ - 0, - 16 - ]); - } - switch (x$1) { - case "QBlockUsed" : - return setup_sprite(undefined, undefined, undefined, "blocks.png", 1, 0, [ - 16, - 16 - ], [ - 0, - 32 - ]); - case "Brick" : - return setup_sprite(undefined, undefined, undefined, "blocks.png", 5, 10, [ - 16, - 16 - ], [ - 0, - 0 - ]); - case "UnBBlock" : - return setup_sprite(undefined, undefined, undefined, "blocks.png", 1, 0, [ - 16, - 16 - ], [ - 0, - 48 - ]); - case "Cloud" : - return setup_sprite(undefined, undefined, undefined, "blocks.png", 1, 0, [ - 16, - 16 - ], [ - 0, - 64 - ]); - case "Panel" : - return setup_sprite(undefined, undefined, undefined, "panel.png", 3, 15, [ - 26, - 26 - ], [ - 0, - 0 - ]); - case "Ground" : - return setup_sprite(undefined, undefined, undefined, "ground.png", 1, 0, [ - 16, - 16 - ], [ - 0, - 32 - ]); - } - } -} - -function make_from_params(params, context) { - let img = document.createElement("img"); - img.src = params.img_src; - return { - params: params, - context: context, - frame: { - contents: 0 - }, - ticks: { - contents: 0 - }, - img: img - }; -} - -function make(spawn, dir, context) { - let params = make_type(spawn, dir); - return make_from_params(params, context); -} - -function make_bgd(context) { - let params = setup_sprite(undefined, undefined, undefined, "bgd-1.png", 1, 0, [ - 512, - 256 - ], [ - 0, - 0 - ]); - return make_from_params(params, context); -} - -function make_particle$1(ptyp, context) { - let params = make_particle(ptyp); - return make_from_params(params, context); -} - -function transform_enemy(enemy_typ, spr, dir) { - let params = make_enemy([ - enemy_typ, - dir - ]); - let img = document.createElement("img"); - img.src = params.img_src; - spr.params = params; - spr.img = img; -} - -function update_animation(spr) { - let curr_ticks = spr.ticks.contents; - if (curr_ticks >= spr.params.max_ticks) { - spr.ticks.contents = 0; - if (spr.params.loop) { - spr.frame.contents = Primitive_int.mod_(spr.frame.contents + 1 | 0, spr.params.max_frames); - return; - } else { - return; - } - } else { - spr.ticks.contents = curr_ticks + 1 | 0; - return; - } -} - -let Sprite = { - setup_sprite: setup_sprite, - make: make, - make_bgd: make_bgd, - make_particle: make_particle$1, - transform_enemy: transform_enemy, - update_animation: update_animation -}; - -function pair_to_xy(pair) { - return { - x: pair[0], - y: pair[1] - }; -} - -function make_type$1(typ, ctx) { - switch (typ) { - case "BrickChunkL" : - case "BrickChunkR" : - return { - sprite: make_particle$1(typ, ctx), - rot: 0, - lifetime: 300 - }; - default: - return { - sprite: make_particle$1(typ, ctx), - rot: 0, - lifetime: 30 - }; - } -} - -function make$1(velOpt, accOpt, part_type, pos, ctx) { - let vel = velOpt !== undefined ? velOpt : [ - 0, - 0 - ]; - let acc = accOpt !== undefined ? accOpt : [ - 0, - 0 - ]; - let params = make_type$1(part_type, ctx); - let pos$1 = pair_to_xy(pos); - let vel$1 = pair_to_xy(vel); - let acc$1 = pair_to_xy(acc); - return { - params: params, - part_type: part_type, - pos: pos$1, - vel: vel$1, - acc: acc$1, - kill: false, - life: params.lifetime - }; -} - -function make_score(score, pos, ctx) { - let t = score >= 801 ? ( - score >= 2001 ? ( - score !== 4000 ? ( - score !== 8000 ? "Score100" : "Score8000" - ) : "Score4000" - ) : ( - score !== 1000 ? ( - score >= 2000 ? "Score2000" : "Score100" - ) : "Score1000" - ) - ) : ( - score >= 201 ? ( - score !== 400 ? ( - score >= 800 ? "Score800" : "Score100" - ) : "Score400" - ) : ( - score !== 100 && score >= 200 ? "Score200" : "Score100" - ) - ); - return make$1([ - 0.5, - -0.7 - ], undefined, t, pos, ctx); -} - -function update_vel(part) { - part.vel.x = part.vel.x + part.acc.x; - part.vel.y = part.vel.y + part.acc.y; -} - -function process(part) { - part.life = part.life - 1 | 0; - if (part.life === 0) { - part.kill = true; - } - update_vel(part); - part.pos.x = part.vel.x + part.pos.x; - part.pos.y = part.vel.y + part.pos.y; -} - -let Particle = { - make: make$1, - make_score: make_score, - process: process -}; - -let id_counter = { - contents: Pervasives.min_int -}; - -function setup_obj(has_gravityOpt, speedOpt, param) { - let has_gravity = has_gravityOpt !== undefined ? has_gravityOpt : true; - let speed = speedOpt !== undefined ? speedOpt : 1; - return { - has_gravity: has_gravity, - speed: speed - }; -} - -function set_vel_to_speed(obj) { - let speed = obj.params.speed; - let match = obj.dir; - if (match === "Left") { - obj.vel.x = - speed; - } else { - obj.vel.x = speed; - } -} - -function make_player() { - return setup_obj(undefined, 2.8, undefined); -} - -function make_type$2(x) { - switch (x.TAG) { - case "SPlayer" : - return make_player(); - case "SEnemy" : - let x$1 = x._0; - switch (x$1) { - case "GKoopaShell" : - case "RKoopaShell" : - return setup_obj(undefined, 3, undefined); - default: - return setup_obj(undefined, undefined, undefined); - } - case "SItem" : - let x$2 = x._0; - if (x$2 === "Coin") { - return setup_obj(false, undefined, undefined); - } else { - return setup_obj(undefined, undefined, undefined); - } - case "SBlock" : - return setup_obj(false, undefined, undefined); - } -} - -function new_id() { - id_counter.contents = id_counter.contents + 1 | 0; - return id_counter.contents; -} - -function make$2($staropt$star, $staropt$star$1, spawnable, context, param) { - let id = $staropt$star !== undefined ? Primitive_option.valFromOption($staropt$star) : undefined; - let dir = $staropt$star$1 !== undefined ? $staropt$star$1 : "Left"; - let spr = make(spawnable, dir, context); - let params = make_type$2(spawnable); - let id$1 = id !== undefined ? id : new_id(); - let obj = { - params: params, - pos: { - x: param[0], - y: param[1] - }, - vel: { - x: 0.0, - y: 0.0 - }, - id: id$1, - jumping: false, - grounded: false, - dir: dir, - invuln: 0, - kill: false, - health: 1, - crouch: false, - score: 0 - }; - return [ - spr, - obj - ]; -} - -function spawn(spawnable, context, param) { - let match = make$2(undefined, undefined, spawnable, context, [ - param[0], - param[1] - ]); - let obj = match[1]; - let spr = match[0]; - switch (spawnable.TAG) { - case "SPlayer" : - return { - TAG: "Player", - _0: spawnable._0, - _1: spr, - _2: obj - }; - case "SEnemy" : - set_vel_to_speed(obj); - return { - TAG: "Enemy", - _0: spawnable._0, - _1: spr, - _2: obj - }; - case "SItem" : - return { - TAG: "Item", - _0: spawnable._0, - _1: spr, - _2: obj - }; - case "SBlock" : - return { - TAG: "Block", - _0: spawnable._0, - _1: spr, - _2: obj - }; - } -} - -function get_sprite(x) { - return x._1; -} - -function get_obj(x) { - return x._2; -} - -function is_player(x) { - if (x.TAG === "Player") { - return true; - } else { - return false; - } -} - -function is_enemy(x) { - if (x.TAG === "Enemy") { - return true; - } else { - return false; - } -} - -function equals(col1, col2) { - return col1._2.id === col2._2.id; -} - -function normalize_pos(pos, p1, p2) { - let match = p1.bbox_offset; - let match$1 = p2.bbox_offset; - let match$2 = p1.bbox_size; - let match$3 = p2.bbox_size; - pos.x = pos.x - (match$3[0] + match$1[0]) + (match$2[0] + match[0]); - pos.y = pos.y - (match$3[1] + match$1[1]) + (match$2[1] + match[1]); -} - -function update_player(player, keys, context) { - let prev_jumping = player.jumping; - let prev_dir = player.dir; - let prev_vx = Math.abs(player.vel.x); - Belt_List.forEach(keys, extra => { - let lr_acc = player.vel.x * 0.2; - switch (extra) { - case "CLeft" : - if (!player.crouch) { - if (player.vel.x > - player.params.speed) { - player.vel.x = player.vel.x - (0.4 - lr_acc); - } - player.dir = "Left"; - return; - } else { - return; - } - case "CRight" : - if (!player.crouch) { - if (player.vel.x < player.params.speed) { - player.vel.x = player.vel.x + (0.4 + lr_acc); - } - player.dir = "Right"; - return; - } else { - return; - } - case "CUp" : - if (!player.jumping && player.grounded) { - player.jumping = true; - player.grounded = false; - player.vel.y = Primitive_bool.max(player.vel.y - (5.7 + Math.abs(player.vel.x) * 0.25), -6); - return; - } else { - return; - } - case "CDown" : - if (!player.jumping && player.grounded) { - player.crouch = true; - return; - } else { - return; - } - } - }); - let v = player.vel.x * 0.9; - let vel_damped = Math.abs(v) < 0.1 ? 0 : v; - player.vel.x = vel_damped; - let pl_typ = player.health <= 1 ? "SmallM" : "BigM"; - if (!prev_jumping && player.jumping) { - return [ - pl_typ, - make({ - TAG: "SPlayer", - _0: pl_typ, - _1: "Jumping" - }, player.dir, context) - ]; - } else if (prev_dir !== player.dir || prev_vx === 0 && Math.abs(player.vel.x) > 0 && !player.jumping) { - return [ - pl_typ, - make({ - TAG: "SPlayer", - _0: pl_typ, - _1: "Running" - }, player.dir, context) - ]; - } else if (prev_dir !== player.dir && player.jumping && prev_jumping) { - return [ - pl_typ, - make({ - TAG: "SPlayer", - _0: pl_typ, - _1: "Jumping" - }, player.dir, context) - ]; - } else if (player.vel.y === 0 && player.crouch) { - return [ - pl_typ, - make({ - TAG: "SPlayer", - _0: pl_typ, - _1: "Crouching" - }, player.dir, context) - ]; - } else if (player.vel.y === 0 && player.vel.x === 0) { - return [ - pl_typ, - make({ - TAG: "SPlayer", - _0: pl_typ, - _1: "Standing" - }, player.dir, context) - ]; - } else { - return; - } -} - -function update_vel$1(obj) { - if (obj.grounded) { - obj.vel.y = 0; - return; - } else if (obj.params.has_gravity) { - obj.vel.y = Primitive_float.min(obj.vel.y + 0.2 + Math.abs(obj.vel.y) * 0.01, 4.5); - return; - } else { - return; - } -} - -function update_pos(obj) { - obj.pos.x = obj.vel.x + obj.pos.x; - if (obj.params.has_gravity) { - obj.pos.y = obj.vel.y + obj.pos.y; - return; - } - -} - -function process_obj(obj, mapy) { - update_vel$1(obj); - update_pos(obj); - if (obj.pos.y > mapy) { - obj.kill = true; - return; - } - -} - -function normalize_origin(pos, spr) { - let p = spr.params; - let match = p.bbox_offset; - let match$1 = p.bbox_size; - pos.x = pos.x - match[0]; - pos.y = pos.y - (match[1] + match$1[1]); -} - -function collide_block(check_xOpt, dir, obj) { - let check_x = check_xOpt !== undefined ? check_xOpt : true; - switch (dir) { - case "North" : - obj.vel.y = -0.001; - return; - case "South" : - obj.vel.y = 0; - obj.grounded = true; - obj.jumping = false; - return; - case "East" : - case "West" : - break; - } - if (check_x) { - obj.vel.x = 0; - return; - } - -} - -function opposite_dir(dir) { - if (dir === "Left") { - return "Right"; - } else { - return "Left"; - } -} - -function reverse_left_right(obj) { - obj.vel.x = - obj.vel.x; - obj.dir = opposite_dir(obj.dir); -} - -function evolve_enemy(player_dir, typ, spr, obj, context) { - switch (typ) { - case "Goomba" : - obj.kill = true; - return; - case "GKoopa" : - let match = make$2(undefined, obj.dir, { - TAG: "SEnemy", - _0: "GKoopaShell" - }, context, [ - obj.pos.x, - obj.pos.y - ]); - let new_obj = match[1]; - let new_spr = match[0]; - normalize_pos(new_obj.pos, spr.params, new_spr.params); - return { - TAG: "Enemy", - _0: "GKoopaShell", - _1: new_spr, - _2: new_obj - }; - case "RKoopa" : - let match$1 = make$2(undefined, obj.dir, { - TAG: "SEnemy", - _0: "RKoopaShell" - }, context, [ - obj.pos.x, - obj.pos.y - ]); - let new_obj$1 = match$1[1]; - let new_spr$1 = match$1[0]; - normalize_pos(new_obj$1.pos, spr.params, new_spr$1.params); - return { - TAG: "Enemy", - _0: "RKoopaShell", - _1: new_spr$1, - _2: new_obj$1 - }; - case "GKoopaShell" : - case "RKoopaShell" : - break; - } - obj.dir = player_dir; - if (obj.vel.x !== 0) { - obj.vel.x = 0; - } else { - set_vel_to_speed(obj); - } -} - -function rev_dir(o, t, s) { - reverse_left_right(o); - let old_params = s.params; - transform_enemy(t, s, o.dir); - normalize_pos(o.pos, old_params, s.params); -} - -function dec_health(obj) { - let health = obj.health - 1 | 0; - if (health === 0) { - obj.kill = true; - return; - } else if (obj.invuln === 0) { - obj.health = health; - return; - } else { - return; - } -} - -function evolve_block(obj, context) { - dec_health(obj); - let match = make$2(undefined, undefined, { - TAG: "SBlock", - _0: "QBlockUsed" - }, context, [ - obj.pos.x, - obj.pos.y - ]); - return { - TAG: "Block", - _0: "QBlockUsed", - _1: match[0], - _2: match[1] - }; -} - -function spawn_above(player_dir, obj, typ, context) { - let item = spawn({ - TAG: "SItem", - _0: typ - }, context, [ - obj.pos.x, - obj.pos.y - ]); - let item_obj = item._2; - item_obj.pos.y = item_obj.pos.y - item._1.params.frame_size[1]; - item_obj.dir = opposite_dir(player_dir); - set_vel_to_speed(item_obj); - return item; -} - -function get_aabb(obj) { - let spr = obj._1.params; - let obj$1 = obj._2; - let match = spr.bbox_offset; - let box = obj$1.pos.x + match[0]; - let boy = obj$1.pos.y + match[1]; - let match$1 = spr.bbox_size; - let sy = match$1[1]; - let sx = match$1[0]; - return { - center: { - x: box + sx / 2, - y: boy + sy / 2 - }, - half: { - x: sx / 2, - y: sy / 2 - } - }; -} - -function col_bypass(c1, c2) { - let o1 = c1._2; - let o2 = c2._2; - let ctypes; - switch (c1.TAG) { - case "Player" : - ctypes = c2.TAG === "Enemy" ? c1._2.invuln > 0 : false; - break; - case "Enemy" : - ctypes = c2.TAG === "Item" ? true : false; - break; - case "Item" : - switch (c2.TAG) { - case "Enemy" : - case "Item" : - ctypes = true; - break; - case "Player" : - case "Block" : - ctypes = false; - break; - } - break; - case "Block" : - ctypes = false; - break; - } - if (o1.kill || o2.kill) { - return true; - } else { - return ctypes; - } -} - -function check_collision(c1, c2) { - let b1 = get_aabb(c1); - let b2 = get_aabb(c2); - let o1 = c1._2; - if (col_bypass(c1, c2)) { - return; - } - let vx = b1.center.x - b2.center.x; - let vy = b1.center.y - b2.center.y; - let hwidths = b1.half.x + b2.half.x; - let hheights = b1.half.y + b2.half.y; - if (!(Math.abs(vx) < hwidths && Math.abs(vy) < hheights)) { - return; - } - let ox = hwidths - Math.abs(vx); - let oy = hheights - Math.abs(vy); - if (ox >= oy) { - if (vy > 0) { - o1.pos.y = o1.pos.y + oy; - return "North"; - } else { - o1.pos.y = o1.pos.y - oy; - return "South"; - } - } else if (vx > 0) { - o1.pos.x = o1.pos.x + ox; - return "West"; - } else { - o1.pos.x = o1.pos.x - ox; - return "East"; - } -} - -function kill(collid, ctx) { - switch (collid.TAG) { - case "Player" : - return /* [] */0; - case "Enemy" : - let o = collid._2; - let pos_0 = o.pos.x; - let pos_1 = o.pos.y; - let pos = [ - pos_0, - pos_1 - ]; - let score = o.score > 0 ? ({ - hd: make_score(o.score, pos, ctx), - tl: /* [] */0 - }) : /* [] */0; - let remains; - remains = collid._0 === "Goomba" ? ({ - hd: make$1(undefined, undefined, "GoombaSquish", pos, ctx), - tl: /* [] */0 - }) : /* [] */0; - return Pervasives.$at(score, remains); - case "Item" : - let o$1 = collid._2; - if (collid._0 === "Mushroom") { - return { - hd: make_score(o$1.score, [ - o$1.pos.x, - o$1.pos.y - ], ctx), - tl: /* [] */0 - }; - } else { - return /* [] */0; - } - case "Block" : - let o$2 = collid._2; - let tmp = collid._0; - if (typeof tmp === "object") { - return /* [] */0; - } - if (tmp !== "Brick") { - return /* [] */0; - } - let pos_0$1 = o$2.pos.x; - let pos_1$1 = o$2.pos.y; - let pos$1 = [ - pos_0$1, - pos_1$1 - ]; - let p1 = make$1([ - -5, - -5 - ], [ - 0, - 0.2 - ], "BrickChunkL", pos$1, ctx); - let p2 = make$1([ - -3, - -4 - ], [ - 0, - 0.2 - ], "BrickChunkL", pos$1, ctx); - let p3 = make$1([ - 3, - -4 - ], [ - 0, - 0.2 - ], "BrickChunkR", pos$1, ctx); - let p4 = make$1([ - 5, - -5 - ], [ - 0, - 0.2 - ], "BrickChunkR", pos$1, ctx); - return { - hd: p1, - tl: { - hd: p2, - tl: { - hd: p3, - tl: { - hd: p4, - tl: /* [] */0 - } - } - } - }; - } -} - -let $$Object = { - invuln: 60, - dampen_jump: 4, - get_sprite: get_sprite, - get_obj: get_obj, - spawn: spawn, - equals: equals, - is_player: is_player, - is_enemy: is_enemy, - normalize_origin: normalize_origin, - normalize_pos: normalize_pos, - kill: kill, - process_obj: process_obj, - update_player: update_player, - check_collision: check_collision, - evolve_enemy: evolve_enemy, - evolve_block: evolve_block, - dec_health: dec_health, - rev_dir: rev_dir, - reverse_left_right: reverse_left_right, - collide_block: collide_block, - spawn_above: spawn_above -}; - -function render_bbox(sprite, param) { - let context = sprite.context; - let match = sprite.params.bbox_offset; - let match$1 = sprite.params.bbox_size; - context.strokeStyle = "#FF0000"; - return context.strokeRect(param[0] + match[0], param[1] + match[1], match$1[0], match$1[1]); -} - -function render(sprite, param) { - let context = sprite.context; - let match = sprite.params.src_offset; - let match$1 = sprite.params.frame_size; - let sw = match$1[0]; - let match$2 = sprite.params.frame_size; - let sx = match[0] + sprite.frame.contents * sw; - return context.drawImage(sprite.img, sx, match[1], sw, match$1[1], param[0], param[1], match$2[0], match$2[1]); -} - -function draw_bgd(bgd, off_x) { - render(bgd, [ - - off_x, - 0 - ]); - return render(bgd, [ - bgd.params.frame_size[0] - off_x, - 0 - ]); -} - -function clear_canvas(canvas) { - let context = canvas.getContext("2d"); - let cwidth = canvas.width; - let cheight = canvas.height; - context.clearRect(0, 0, cwidth, cheight); -} - -function hud(canvas, score, coins) { - let score_string = score.toString(); - let coin_string = coins.toString(); - let context = canvas.getContext("2d"); - context.font = "10px 'Press Start 2P'"; - context.fillText("Score: " + score_string, canvas.width - 140, 18); - context.fillText("Coins: " + coin_string, 120, 18); -} - -function fps(canvas, fps_val) { - let fps_str = fps_val.toFixed(); - let context = canvas.getContext("2d"); - context.fillText(fps_str, 10, 18); -} - -function game_win(ctx) { - ctx.rect(0, 0, 512, 512); - ctx.fillStyle = "black"; - ctx.fill(); - ctx.fillStyle = "white"; - ctx.font = "20px 'Press Start 2P'"; - ctx.fillText("You win!", 180, 128); - return Pervasives.failwith("Game over."); -} - -function game_loss(ctx) { - ctx.rect(0, 0, 512, 512); - ctx.fillStyle = "black"; - ctx.fill(); - ctx.fillStyle = "white"; - ctx.font = "20px 'Press Start 2P'"; - ctx.fillText("GAME OVER. You lose!", 60, 128); - return Pervasives.failwith("Game over."); -} - -let Draw = { - render: render, - clear_canvas: clear_canvas, - draw_bgd: draw_bgd, - render_bbox: render_bbox, - fps: fps, - hud: hud, - game_win: game_win, - game_loss: game_loss -}; - -function make$3(param, param$1) { - return { - pos: { - x: 0, - y: 0 - }, - v_dim: { - x: param[0], - y: param[1] - }, - m_dim: { - x: param$1[0], - y: param$1[1] - } - }; -} - -function calc_viewport_point(cc, vc, mc) { - let vc_half = vc / 2; - return Primitive_float.min(Primitive_bool.max(cc - vc_half, 0), Primitive_float.min(mc - vc, Math.abs(cc - vc_half))); -} - -function in_viewport(v, pos) { - let v_min_x = v.pos.x - 32; - let v_max_x = v.pos.x + v.v_dim.x; - let v_min_y = v.pos.y - 32; - let v_max_y = v.pos.y + v.v_dim.y; - let x = pos.x; - let y = pos.y; - if (x >= v_min_x && x <= v_max_x && y >= v_min_y) { - return y <= v_max_y; - } else { - return false; - } -} - -function out_of_viewport_below(v, y) { - let v_max_y = v.pos.y + v.v_dim.y; - return y >= v_max_y; -} - -function coord_to_viewport(viewport, coord) { - return { - x: coord.x - viewport.pos.x, - y: coord.y - viewport.pos.y - }; -} - -function update(vpt, ctr) { - let new_x = calc_viewport_point(ctr.x, vpt.v_dim.x, vpt.m_dim.x); - let new_y = calc_viewport_point(ctr.y, vpt.v_dim.y, vpt.m_dim.y); - let pos = { - x: new_x, - y: new_y - }; - return { - pos: pos, - v_dim: vpt.v_dim, - m_dim: vpt.m_dim - }; -} - -let Viewport = { - make: make$3, - calc_viewport_point: calc_viewport_point, - in_viewport: in_viewport, - out_of_viewport_below: out_of_viewport_below, - coord_to_viewport: coord_to_viewport, - update: update -}; - -let pressed_keys = { - left: false, - right: false, - up: false, - down: false, - bbox: 0 -}; - -let collid_objs = { - contents: /* [] */0 -}; - -let particles = { - contents: /* [] */0 -}; - -let last_time = { - contents: 0 -}; - -function calc_fps(t0, t1) { - let delta = (t1 - t0) / 1000; - return 1 / delta; -} - -function update_score(state, i) { - state.score = state.score + i | 0; -} - -function process_collision(dir, c1, c2, state) { - let context = state.ctx; - let exit = 0; - let s1; - let o1; - let typ; - let s2; - let o2; - let s1$1; - let o1$1; - let t2; - let s2$1; - let o2$1; - let o1$2; - let t2$1; - let o2$2; - switch (c1.TAG) { - case "Player" : - let o1$3 = c1._2; - let s1$2 = c1._1; - switch (c2.TAG) { - case "Player" : - return [ - undefined, - undefined - ]; - case "Enemy" : - let o2$3 = c2._2; - let s2$2 = c2._1; - let typ$1 = c2._0; - if (dir === "South") { - s1 = s1$2; - o1 = o1$3; - typ = typ$1; - s2 = s2$2; - o2 = o2$3; - exit = 1; - } else { - s1$1 = s1$2; - o1$1 = o1$3; - t2 = typ$1; - s2$1 = s2$2; - o2$1 = o2$3; - exit = 2; - } - break; - case "Item" : - o1$2 = o1$3; - t2$1 = c2._0; - o2$2 = c2._2; - exit = 3; - break; - case "Block" : - let o2$4 = c2._2; - let t = c2._0; - if (dir === "North") { - if (typeof t !== "object") { - switch (t) { - case "Brick" : - if (c1._0 === "BigM") { - collide_block(undefined, dir, o1$3); - dec_health(o2$4); - return [ - undefined, - undefined - ]; - } else { - collide_block(undefined, dir, o1$3); - return [ - undefined, - undefined - ]; - } - case "Panel" : - game_win(state.ctx); - return [ - undefined, - undefined - ]; - default: - collide_block(undefined, dir, o1$3); - return [ - undefined, - undefined - ]; - } - } else { - let updated_block = evolve_block(o2$4, context); - let spawned_item = spawn_above(o1$3.dir, o2$4, t._0, context); - collide_block(undefined, dir, o1$3); - return [ - spawned_item, - updated_block - ]; - } - } else { - let exit$1 = 0; - if (typeof t !== "object") { - if (t === "Panel") { - game_win(state.ctx); - return [ - undefined, - undefined - ]; - } - exit$1 = 4; - } else { - exit$1 = 4; - } - if (exit$1 === 4) { - if (dir === "South") { - state.multiplier = 1; - collide_block(undefined, dir, o1$3); - return [ - undefined, - undefined - ]; - } - collide_block(undefined, dir, o1$3); - return [ - undefined, - undefined - ]; - } - - } - break; - } - break; - case "Enemy" : - let o1$4 = c1._2; - let s1$3 = c1._1; - let t1 = c1._0; - switch (c2.TAG) { - case "Player" : - let o1$5 = c2._2; - let s1$4 = c2._1; - if (dir === "North") { - s1 = s1$4; - o1 = o1$5; - typ = t1; - s2 = s1$3; - o2 = o1$4; - exit = 1; - } else { - s1$1 = s1$4; - o1$1 = o1$5; - t2 = t1; - s2$1 = s1$3; - o2$1 = o1$4; - exit = 2; - } - break; - case "Enemy" : - let t2$2 = c2._0; - let s2$3 = c2._1; - let o2$5 = c2._2; - let exit$2 = 0; - switch (t1) { - case "GKoopaShell" : - switch (t2$2) { - case "GKoopaShell" : - case "RKoopaShell" : - exit$2 = 1; - break; - default: - exit$2 = 2; - } - break; - case "RKoopaShell" : - switch (t2$2) { - case "GKoopaShell" : - case "RKoopaShell" : - exit$2 = 1; - break; - default: - exit$2 = 2; - } - break; - default: - switch (t2$2) { - case "GKoopaShell" : - case "RKoopaShell" : - exit$2 = 3; - break; - default: - let exit$3 = 0; - switch (dir) { - case "North" : - case "South" : - return [ - undefined, - undefined - ]; - case "East" : - case "West" : - exit$3 = 4; - break; - } - if (exit$3 === 4) { - rev_dir(o1$4, t1, s1$3); - rev_dir(o2$5, t2$2, s2$3); - return [ - undefined, - undefined - ]; - } - - } - } - switch (exit$2) { - case 1 : - dec_health(o1$4); - dec_health(o2$5); - return [ - undefined, - undefined - ]; - case 2 : - if (o1$4.vel.x === 0) { - rev_dir(o2$5, t2$2, s2$3); - return [ - undefined, - undefined - ]; - } else { - dec_health(o2$5); - return [ - undefined, - undefined - ]; - } - case 3 : - if (o2$5.vel.x === 0) { - rev_dir(o1$4, t1, s1$3); - return [ - undefined, - undefined - ]; - } else { - dec_health(o1$4); - return [ - undefined, - undefined - ]; - } - } - case "Item" : - return [ - undefined, - undefined - ]; - case "Block" : - let o2$6 = c2._2; - let t2$3 = c2._0; - let exit$4 = 0; - switch (dir) { - case "North" : - case "South" : - collide_block(undefined, dir, o1$4); - return [ - undefined, - undefined - ]; - case "East" : - case "West" : - exit$4 = 4; - break; - } - if (exit$4 === 4) { - let exit$5 = 0; - let typ$2; - switch (t1) { - case "GKoopaShell" : - if (typeof t2$3 !== "object") { - if (t2$3 === "Brick") { - dec_health(o2$6); - reverse_left_right(o1$4); - return [ - undefined, - undefined - ]; - } - exit$5 = 5; - } else { - typ$2 = t2$3._0; - exit$5 = 6; - } - break; - case "RKoopaShell" : - if (typeof t2$3 !== "object") { - if (t2$3 === "Brick") { - dec_health(o2$6); - reverse_left_right(o1$4); - return [ - undefined, - undefined - ]; - } - exit$5 = 5; - } else { - typ$2 = t2$3._0; - exit$5 = 6; - } - break; - default: - exit$5 = 5; - } - switch (exit$5) { - case 5 : - rev_dir(o1$4, t1, s1$3); - return [ - undefined, - undefined - ]; - case 6 : - let updated_block$1 = evolve_block(o2$6, context); - let spawned_item$1 = spawn_above(o1$4.dir, o2$6, typ$2, context); - rev_dir(o1$4, t1, s1$3); - return [ - updated_block$1, - spawned_item$1 - ]; - } - } - break; - } - break; - case "Item" : - let o2$7 = c1._2; - switch (c2.TAG) { - case "Player" : - o1$2 = c2._2; - t2$1 = c1._0; - o2$2 = o2$7; - exit = 3; - break; - case "Enemy" : - case "Item" : - return [ - undefined, - undefined - ]; - case "Block" : - switch (dir) { - case "North" : - case "South" : - collide_block(undefined, dir, o2$7); - return [ - undefined, - undefined - ]; - case "East" : - case "West" : - reverse_left_right(o2$7); - return [ - undefined, - undefined - ]; - } - } - break; - case "Block" : - return [ - undefined, - undefined - ]; - } - switch (exit) { - case 1 : - o1.invuln = 10; - o1.jumping = false; - o1.grounded = true; - switch (typ) { - case "GKoopaShell" : - case "RKoopaShell" : - break; - default: - dec_health(o2); - o1.vel.y = - 4; - if (state.multiplier === 8) { - update_score(state, 800); - o2.score = 800; - return [ - undefined, - evolve_enemy(o1.dir, typ, s2, o2, context) - ]; - } - let score = Math.imul(100, state.multiplier); - update_score(state, score); - o2.score = score; - state.multiplier = (state.multiplier << 1); - return [ - undefined, - evolve_enemy(o1.dir, typ, s2, o2, context) - ]; - } - let r2 = evolve_enemy(o1.dir, typ, s2, o2, context); - o1.vel.y = - 4; - o1.pos.y = o1.pos.y - 5; - return [ - undefined, - r2 - ]; - case 2 : - switch (t2) { - case "GKoopaShell" : - case "RKoopaShell" : - break; - default: - dec_health(o1$1); - o1$1.invuln = 60; - return [ - undefined, - undefined - ]; - } - let r2$1 = o2$1.vel.x === 0 ? evolve_enemy(o1$1.dir, t2, s2$1, o2$1, context) : (dec_health(o1$1), o1$1.invuln = 60, undefined); - return [ - undefined, - r2$1 - ]; - case 3 : - let exit$6 = 0; - switch (t2$1) { - case "Mushroom" : - dec_health(o2$2); - if (o1$2.health === 2) { - - } else { - o1$2.health = o1$2.health + 1 | 0; - } - o1$2.vel.x = 0; - o1$2.vel.y = 0; - update_score(state, 1000); - o2$2.score = 1000; - return [ - undefined, - undefined - ]; - case "FireFlower" : - case "Star" : - exit$6 = 4; - break; - case "Coin" : - state.coins = state.coins + 1 | 0; - dec_health(o2$2); - update_score(state, 100); - return [ - undefined, - undefined - ]; - } - if (exit$6 === 4) { - dec_health(o2$2); - update_score(state, 1000); - return [ - undefined, - undefined - ]; - } - break; - } -} - -function broad_phase(collid, all_collids, state) { - let obj = collid._2; - return Belt_List.filter(all_collids, c => { - if (in_viewport(state.vpt, obj.pos) || is_player(collid)) { - return true; - } else { - return out_of_viewport_below(state.vpt, obj.pos.y); - } - }); -} - -function check_collisions(collid, all_collids, state) { - if (collid.TAG === "Block") { - return /* [] */0; - } - let broad = broad_phase(collid, all_collids, state); - let _cs = broad; - let _acc = /* [] */0; - while (true) { - let acc = _acc; - let cs = _cs; - if (!cs) { - return acc; - } - let h = cs.hd; - let c_obj = collid._2; - let new_objs; - if (equals(collid, h)) { - new_objs = [ - undefined, - undefined - ]; - } else { - let dir = check_collision(collid, h); - new_objs = dir !== undefined && h._2.id !== c_obj.id ? process_collision(dir, collid, h, state) : [ - undefined, - undefined - ]; - } - let o = new_objs[0]; - let acc$1; - if (o !== undefined) { - let o2 = new_objs[1]; - acc$1 = o2 !== undefined ? ({ - hd: o, - tl: { - hd: o2, - tl: acc - } - }) : ({ - hd: o, - tl: acc - }); - } else { - let o$1 = new_objs[1]; - acc$1 = o$1 !== undefined ? ({ - hd: o$1, - tl: acc - }) : acc; - } - _acc = acc$1; - _cs = cs.tl; - continue; - }; -} - -function update_collidable(state, collid, all_collids) { - let obj = collid._2; - let spr = collid._1; - obj.invuln = obj.invuln > 0 ? obj.invuln - 1 | 0 : 0; - let viewport_filter = in_viewport(state.vpt, obj.pos) || is_player(collid) || out_of_viewport_below(state.vpt, obj.pos.y); - if (!(!obj.kill && viewport_filter)) { - return /* [] */0; - } - obj.grounded = false; - process_obj(obj, state.map); - let evolved = check_collisions(collid, all_collids, state); - let vpt_adj_xy = coord_to_viewport(state.vpt, obj.pos); - render(spr, [ - vpt_adj_xy.x, - vpt_adj_xy.y - ]); - if (pressed_keys.bbox === 1) { - render_bbox(spr, [ - vpt_adj_xy.x, - vpt_adj_xy.y - ]); - } - if (obj.vel.x !== 0 || !is_enemy(collid)) { - update_animation(spr); - } - return evolved; -} - -function translate_keys() { - let ctrls_0 = [ - pressed_keys.left, - "CLeft" - ]; - let ctrls_1 = { - hd: [ - pressed_keys.right, - "CRight" - ], - tl: { - hd: [ - pressed_keys.up, - "CUp" - ], - tl: { - hd: [ - pressed_keys.down, - "CDown" - ], - tl: /* [] */0 - } - } - }; - let ctrls = { - hd: ctrls_0, - tl: ctrls_1 - }; - return Belt_List.reduceReverse(ctrls, /* [] */0, (a, x) => { - if (x[0]) { - return { - hd: x[1], - tl: a - }; - } else { - return a; - } - }); -} - -function run_update_collid(state, collid, all_collids) { - if (collid.TAG === "Player") { - let o = collid._2; - let keys = translate_keys(); - o.crouch = false; - let match = update_player(o, keys, state.ctx); - let player; - if (match !== undefined) { - let new_spr = match[1]; - normalize_pos(o.pos, collid._1.params, new_spr.params); - player = { - TAG: "Player", - _0: match[0], - _1: new_spr, - _2: o - }; - } else { - player = collid; - } - let evolved = update_collidable(state, player, all_collids); - collid_objs.contents = Pervasives.$at(collid_objs.contents, evolved); - return player; - } - let obj = collid._2; - let evolved$1 = update_collidable(state, collid, all_collids); - if (!obj.kill) { - collid_objs.contents = { - hd: collid, - tl: Pervasives.$at(collid_objs.contents, evolved$1) - }; - } - let new_parts = obj.kill ? kill(collid, state.ctx) : /* [] */0; - particles.contents = Pervasives.$at(particles.contents, new_parts); - return collid; -} - -function update_loop(canvas, param, map_dim) { - let player = param[0]; - let ctx = canvas.getContext("2d"); - let cwidth = canvas.width / 1; - let cheight = canvas.height / 1; - let viewport = make$3([ - cwidth, - cheight - ], map_dim); - let state = { - bgd: make_bgd(ctx), - ctx: ctx, - vpt: update(viewport, player._2.pos), - map: map_dim[1], - score: 0, - coins: 0, - multiplier: 1, - game_over: false - }; - state.ctx.scale(1, 1); - let update_helper = (time, state, player, objs, parts) => { - if (state.game_over === true) { - return game_win(state.ctx); - } - collid_objs.contents = /* [] */0; - particles.contents = /* [] */0; - let fps$1 = calc_fps(last_time.contents, time); - last_time.contents = time; - clear_canvas(canvas); - let vpos_x_int = state.vpt.pos.x / 5 | 0; - let bgd_width = state.bgd.params.frame_size[0] | 0; - draw_bgd(state.bgd, Primitive_int.mod_(vpos_x_int, bgd_width)); - let player$1 = run_update_collid(state, player, objs); - if (player$1._2.kill === true) { - return game_loss(state.ctx); - } - let state$1 = { - bgd: state.bgd, - ctx: state.ctx, - vpt: update(state.vpt, player$1._2.pos), - map: state.map, - score: state.score, - coins: state.coins, - multiplier: state.multiplier, - game_over: state.game_over - }; - Belt_List.forEach(objs, obj => { - run_update_collid(state$1, obj, objs); - }); - Belt_List.forEach(parts, part => { - process(part); - let x = part.pos.x - state$1.vpt.pos.x; - let y = part.pos.y - state$1.vpt.pos.y; - render(part.params.sprite, [ - x, - y - ]); - if (!part.kill) { - particles.contents = { - hd: part, - tl: particles.contents - }; - return; - } - - }); - fps(canvas, fps$1); - hud(canvas, state$1.score, state$1.coins); - requestAnimationFrame(t => update_helper(t, state$1, player$1, collid_objs.contents, particles.contents)); - }; - update_helper(0, state, player, param[1], /* [] */0); -} - -function keydown(evt) { - let match = evt.keyCode; - if (match >= 41) { - switch (match) { - case 65 : - pressed_keys.left = true; - break; - case 66 : - pressed_keys.bbox = (pressed_keys.bbox + 1 | 0) % 2; - break; - case 68 : - pressed_keys.right = true; - break; - case 83 : - pressed_keys.down = true; - break; - case 87 : - pressed_keys.up = true; - break; - } - } else if (match >= 32) { - switch (match) { - case 33 : - case 34 : - case 35 : - case 36 : - break; - case 37 : - pressed_keys.left = true; - break; - case 32 : - case 38 : - pressed_keys.up = true; - break; - case 39 : - pressed_keys.right = true; - break; - case 40 : - pressed_keys.down = true; - break; - } - } - return true; -} - -function keyup(evt) { - let match = evt.keyCode; - if (match >= 68) { - if (match !== 83) { - if (match !== 87) { - if (match >= 69) { - - } else { - pressed_keys.right = false; - } - } else { - pressed_keys.up = false; - } - } else { - pressed_keys.down = false; - } - } else if (match >= 41) { - if (match !== 65) { - - } else { - pressed_keys.left = false; - } - } else if (match >= 32) { - switch (match) { - case 33 : - case 34 : - case 35 : - case 36 : - break; - case 37 : - pressed_keys.left = false; - break; - case 32 : - case 38 : - pressed_keys.up = false; - break; - case 39 : - pressed_keys.right = false; - break; - case 40 : - pressed_keys.down = false; - break; - } - } - return true; -} - -let Director = { - update_loop: update_loop, - keydown: keydown, - keyup: keyup -}; - -function mem_loc(checkloc, _loclist) { - while (true) { - let loclist = _loclist; - if (!loclist) { - return false; - } - if (Primitive_object.equal(checkloc, loclist.hd[1])) { - return true; - } - _loclist = loclist.tl; - continue; - }; -} - -function convert_list(lst) { - if (!lst) { - return /* [] */0; - } - let h = lst.hd; - return Pervasives.$at({ - hd: [ - h[0], - [ - h[1][0] * 16, - h[1][1] * 16 - ] - ], - tl: /* [] */0 - }, convert_list(lst.tl)); -} - -function choose_enemy_typ(typ) { - switch (typ) { - case 0 : - return "RKoopa"; - case 1 : - return "GKoopa"; - case 2 : - return "Goomba"; - default: - return Pervasives.failwith("Shouldn't reach here"); - } -} - -function choose_sblock_typ(typ) { - switch (typ) { - case 0 : - return "Brick"; - case 1 : - return "UnBBlock"; - case 2 : - return "Cloud"; - case 3 : - return { - TAG: "QBlock", - _0: "Mushroom" - }; - case 4 : - return "Ground"; - default: - return Pervasives.failwith("Shouldn't reach here"); - } -} - -function avoid_overlap(_lst, currentLst) { - while (true) { - let lst = _lst; - if (!lst) { - return /* [] */0; - } - let t = lst.tl; - let h = lst.hd; - if (!mem_loc(h[1], currentLst)) { - return Pervasives.$at({ - hd: h, - tl: /* [] */0 - }, avoid_overlap(t, currentLst)); - } - _lst = t; - continue; - }; -} - -function trim_edges(_lst, blockw, blockh) { - while (true) { - let lst = _lst; - if (!lst) { - return /* [] */0; - } - let t = lst.tl; - let h = lst.hd; - let cx = h[1][0]; - let cy = h[1][1]; - let pixx = blockw * 16; - let pixy = blockh * 16; - if (!(cx < 128 || pixx - cx < 528 || cy === 0 || pixy - cy < 48)) { - return Pervasives.$at({ - hd: h, - tl: /* [] */0 - }, trim_edges(t, blockw, blockh)); - } - _lst = t; - continue; - }; -} - -function generate_clouds(cbx, cby, typ, num) { - if (num === 0) { - return /* [] */0; - } else { - return Pervasives.$at({ - hd: [ - typ, - [ - cbx, - cby - ] - ], - tl: /* [] */0 - }, generate_clouds(cbx + 1, cby, typ, num - 1 | 0)); - } -} - -function generate_coins(_block_coord) { - while (true) { - let block_coord = _block_coord; - let place_coin = int(2); - if (!block_coord) { - return /* [] */0; - } - let t = block_coord.tl; - let h = block_coord.hd; - if (place_coin === 0) { - let xc = h[1][0]; - let yc = h[1][1]; - return Pervasives.$at({ - hd: [ - 0, - [ - xc, - yc - 16 - ] - ], - tl: /* [] */0 - }, generate_coins(t)); - } - _block_coord = t; - continue; - }; -} - -function choose_block_pattern(blockw, blockh, cbx, cby, prob) { - if (cbx > blockw || cby > blockh) { - return /* [] */0; - } - let block_typ = int(4); - let stair_typ = int(2); - let life_block_chance = int(5); - let middle_block = life_block_chance === 0 ? 3 : stair_typ; - switch (prob) { - case 0 : - if (blockw - cbx > 2) { - return { - hd: [ - stair_typ, - [ - cbx, - cby - ] - ], - tl: { - hd: [ - middle_block, - [ - cbx + 1, - cby - ] - ], - tl: { - hd: [ - stair_typ, - [ - cbx + 2, - cby - ] - ], - tl: /* [] */0 - } - } - }; - } else if (blockw - cbx > 1) { - return { - hd: [ - block_typ, - [ - cbx, - cby - ] - ], - tl: { - hd: [ - block_typ, - [ - cbx + 1, - cby - ] - ], - tl: /* [] */0 - } - }; - } else { - return { - hd: [ - block_typ, - [ - cbx, - cby - ] - ], - tl: /* [] */0 - }; - } - case 1 : - let num_clouds = int(5) + 5 | 0; - if (cby < 5) { - return generate_clouds(cbx, cby, 2, num_clouds); - } else { - return /* [] */0; - } - case 2 : - if (blockh - cby === 1) { - let four_0 = [ - stair_typ, - [ - cbx, - cby - ] - ]; - let four_1 = { - hd: [ - stair_typ, - [ - cbx + 1, - cby - ] - ], - tl: { - hd: [ - stair_typ, - [ - cbx + 2, - cby - ] - ], - tl: { - hd: [ - stair_typ, - [ - cbx + 3, - cby - ] - ], - tl: /* [] */0 - } - } - }; - let four = { - hd: four_0, - tl: four_1 - }; - let three_0 = [ - stair_typ, - [ - cbx + 1, - cby - 1 - ] - ]; - let three_1 = { - hd: [ - stair_typ, - [ - cbx + 2, - cby - 1 - ] - ], - tl: { - hd: [ - stair_typ, - [ - cbx + 3, - cby - 1 - ] - ], - tl: /* [] */0 - } - }; - let three = { - hd: three_0, - tl: three_1 - }; - let two_0 = [ - stair_typ, - [ - cbx + 2, - cby - 2 - ] - ]; - let two_1 = { - hd: [ - stair_typ, - [ - cbx + 3, - cby - 2 - ] - ], - tl: /* [] */0 - }; - let two = { - hd: two_0, - tl: two_1 - }; - let one_0 = [ - stair_typ, - [ - cbx + 3, - cby - 3 - ] - ]; - let one = { - hd: one_0, - tl: /* [] */0 - }; - return Pervasives.$at(four, Pervasives.$at(three, Pervasives.$at(two, one))); - } else { - return /* [] */0; - } - case 3 : - if (stair_typ === 0 && blockh - cby > 3) { - let three_0$1 = [ - stair_typ, - [ - cbx, - cby - ] - ]; - let three_1$1 = { - hd: [ - stair_typ, - [ - cbx + 1, - cby - ] - ], - tl: { - hd: [ - stair_typ, - [ - cbx + 2, - cby - ] - ], - tl: /* [] */0 - } - }; - let three$1 = { - hd: three_0$1, - tl: three_1$1 - }; - let two_0$1 = [ - stair_typ, - [ - cbx + 2, - cby + 1 - ] - ]; - let two_1$1 = { - hd: [ - stair_typ, - [ - cbx + 3, - cby + 1 - ] - ], - tl: /* [] */0 - }; - let two$1 = { - hd: two_0$1, - tl: two_1$1 - }; - let one_0$1 = [ - stair_typ, - [ - cbx + 5, - cby + 2 - ] - ]; - let one_1 = { - hd: [ - stair_typ, - [ - cbx + 6, - cby + 2 - ] - ], - tl: /* [] */0 - }; - let one$1 = { - hd: one_0$1, - tl: one_1 - }; - return Pervasives.$at(three$1, Pervasives.$at(two$1, one$1)); - } else if (blockh - cby > 2) { - let one_0$2 = [ - stair_typ, - [ - cbx, - cby - ] - ]; - let one_1$1 = { - hd: [ - stair_typ, - [ - cbx + 1, - cby - ] - ], - tl: /* [] */0 - }; - let one$2 = { - hd: one_0$2, - tl: one_1$1 - }; - let two_0$2 = [ - stair_typ, - [ - cbx + 3, - cby - 1 - ] - ]; - let two_1$2 = { - hd: [ - stair_typ, - [ - cbx + 4, - cby - 1 - ] - ], - tl: /* [] */0 - }; - let two$2 = { - hd: two_0$2, - tl: two_1$2 - }; - let three_0$2 = [ - stair_typ, - [ - cbx + 4, - cby - 2 - ] - ]; - let three_1$2 = { - hd: [ - stair_typ, - [ - cbx + 5, - cby - 2 - ] - ], - tl: { - hd: [ - stair_typ, - [ - cbx + 6, - cby - 2 - ] - ], - tl: /* [] */0 - } - }; - let three$2 = { - hd: three_0$2, - tl: three_1$2 - }; - return Pervasives.$at(one$2, Pervasives.$at(two$2, three$2)); - } else { - return { - hd: [ - stair_typ, - [ - cbx, - cby - ] - ], - tl: /* [] */0 - }; - } - case 4 : - if (cby + 3 - blockh === 2) { - return { - hd: [ - stair_typ, - [ - cbx, - cby - ] - ], - tl: /* [] */0 - }; - } else if (cby + 3 - blockh === 1) { - return { - hd: [ - stair_typ, - [ - cbx, - cby - ] - ], - tl: { - hd: [ - stair_typ, - [ - cbx, - cby + 1 - ] - ], - tl: /* [] */0 - } - }; - } else { - return { - hd: [ - stair_typ, - [ - cbx, - cby - ] - ], - tl: { - hd: [ - stair_typ, - [ - cbx, - cby + 1 - ] - ], - tl: { - hd: [ - stair_typ, - [ - cbx, - cby + 2 - ] - ], - tl: /* [] */0 - } - } - }; - } - case 5 : - return { - hd: [ - 3, - [ - cbx, - cby - ] - ], - tl: /* [] */0 - }; - default: - return Pervasives.failwith("Shouldn't reach here"); - } -} - -function generate_enemies(blockw, blockh, _cbx, _cby, acc) { - while (true) { - let cby = _cby; - let cbx = _cbx; - if (cbx > blockw - 32) { - return /* [] */0; - } - if (cby > blockh - 1 || cbx < 15) { - _cby = 0; - _cbx = cbx + 1; - continue; - } - if (mem_loc([ - cbx, - cby - ], acc) || cby === 0) { - _cby = cby + 1; - continue; - } - let prob = int(30); - if (prob < 3 && blockh - 1 === cby) { - let enemy_0 = [ - prob, - [ - cbx * 16, - cby * 16 - ] - ]; - let enemy = { - hd: enemy_0, - tl: /* [] */0 - }; - return Pervasives.$at(enemy, generate_enemies(blockw, blockh, cbx, cby + 1, acc)); - } - _cby = cby + 1; - continue; - }; -} - -function generate_block_enemies(_block_coord) { - while (true) { - let block_coord = _block_coord; - let place_enemy = int(20); - let enemy_typ = int(3); - if (!block_coord) { - return /* [] */0; - } - let t = block_coord.tl; - let h = block_coord.hd; - if (place_enemy === 0) { - let xc = h[1][0]; - let yc = h[1][1]; - return Pervasives.$at({ - hd: [ - enemy_typ, - [ - xc, - yc - 16 - ] - ], - tl: /* [] */0 - }, generate_block_enemies(t)); - } - _block_coord = t; - continue; - }; -} - -function generate_block_locs(blockw, blockh, _cbx, _cby, _acc) { - while (true) { - let acc = _acc; - let cby = _cby; - let cbx = _cbx; - if (blockw - cbx < 33) { - return acc; - } - if (cby > blockh - 1) { - _cby = 0; - _cbx = cbx + 1; - continue; - } - if (mem_loc([ - cbx, - cby - ], acc) || cby === 0) { - _cby = cby + 1; - continue; - } - let prob = int(100); - if (prob < 5) { - let newacc = choose_block_pattern(blockw, blockh, cbx, cby, prob); - let undup_lst = avoid_overlap(newacc, acc); - let called_acc = Pervasives.$at(acc, undup_lst); - _acc = called_acc; - _cby = cby + 1; - continue; - } - _cby = cby + 1; - continue; - }; -} - -function generate_panel(context, blockw, blockh) { - return spawn({ - TAG: "SBlock", - _0: "Panel" - }, context, [ - blockw * 16 - 256, - blockh * 16 * 2 / 3 - ]); -} - -function generate_ground(blockw, blockh, _inc, _acc) { - while (true) { - let acc = _acc; - let inc = _inc; - if (inc > blockw) { - return acc; - } - if (inc > 10) { - let skip = int(10); - let newacc = Pervasives.$at(acc, { - hd: [ - 4, - [ - inc * 16, - blockh * 16 - ] - ], - tl: /* [] */0 - }); - if (skip === 7 && blockw - inc > 32) { - _inc = inc + 1; - continue; - } - _acc = newacc; - _inc = inc + 1; - continue; - } - let newacc$1 = Pervasives.$at(acc, { - hd: [ - 4, - [ - inc * 16, - blockh * 16 - ] - ], - tl: /* [] */0 - }); - _acc = newacc$1; - _inc = inc + 1; - continue; - }; -} - -function convert_to_block_obj(lst, context) { - if (!lst) { - return /* [] */0; - } - let h = lst.hd; - let sblock_typ = choose_sblock_typ(h[0]); - let ob = spawn({ - TAG: "SBlock", - _0: sblock_typ - }, context, h[1]); - return Pervasives.$at({ - hd: ob, - tl: /* [] */0 - }, convert_to_block_obj(lst.tl, context)); -} - -function convert_to_enemy_obj(lst, context) { - if (!lst) { - return /* [] */0; - } - let h = lst.hd; - let senemy_typ = choose_enemy_typ(h[0]); - let ob = spawn({ - TAG: "SEnemy", - _0: senemy_typ - }, context, h[1]); - return Pervasives.$at({ - hd: ob, - tl: /* [] */0 - }, convert_to_enemy_obj(lst.tl, context)); -} - -function convert_to_coin_obj(lst, context) { - if (!lst) { - return /* [] */0; - } - let ob = spawn({ - TAG: "SItem", - _0: "Coin" - }, context, lst.hd[1]); - return Pervasives.$at({ - hd: ob, - tl: /* [] */0 - }, convert_to_coin_obj(lst.tl, context)); -} - -function generate_helper(blockw, blockh, cx, cy, context) { - let block_locs = generate_block_locs(blockw, blockh, 0, 0, /* [] */0); - let converted_block_locs = trim_edges(convert_list(block_locs), blockw, blockh); - let obj_converted_block_locs = convert_to_block_obj(converted_block_locs, context); - let ground_blocks = generate_ground(blockw, blockh, 0, /* [] */0); - let obj_converted_ground_blocks = convert_to_block_obj(ground_blocks, context); - let block_locations = Pervasives.$at(block_locs, ground_blocks); - let all_blocks = Pervasives.$at(obj_converted_block_locs, obj_converted_ground_blocks); - let enemy_locs = generate_enemies(blockw, blockh, 0, 0, block_locations); - let obj_converted_enemies = convert_to_enemy_obj(enemy_locs, context); - let coin_locs = generate_coins(converted_block_locs); - let undup_coin_locs = trim_edges(avoid_overlap(coin_locs, converted_block_locs), blockw, blockh); - let converted_block_coin_locs = Pervasives.$at(converted_block_locs, coin_locs); - let enemy_block_locs = generate_block_enemies(converted_block_locs); - let undup_enemy_block_locs = avoid_overlap(enemy_block_locs, converted_block_coin_locs); - let obj_enemy_blocks = convert_to_enemy_obj(undup_enemy_block_locs, context); - let coin_objects = convert_to_coin_obj(undup_coin_locs, context); - let obj_panel = generate_panel(context, blockw, blockh); - return Pervasives.$at(all_blocks, Pervasives.$at(obj_converted_enemies, Pervasives.$at(coin_objects, Pervasives.$at(obj_enemy_blocks, { - hd: obj_panel, - tl: /* [] */0 - })))); -} - -function generate(w, h, context) { - let blockw = w / 16; - let blockh = h / 16 - 1; - let collide_list = generate_helper(blockw, blockh, 0, 0, context); - let player = spawn({ - TAG: "SPlayer", - _0: "SmallM", - _1: "Standing" - }, context, [ - 100, - 224 - ]); - return [ - player, - collide_list - ]; -} - -function init() { - -} - -let Procedural_generator = { - init: init, - generate: generate -}; - -let loadCount = { - contents: 0 -}; - -function load(param) { - let canvas_id = "canvas"; - let el = document.getElementById(canvas_id); - let canvas = el !== null ? el : (console.log("cant find canvas " + canvas_id), Pervasives.failwith("fail")); - let context = canvas.getContext("2d"); - document.addEventListener("keydown", keydown, true); - document.addEventListener("keyup", keyup, true); - update_loop(canvas, generate(2400, 256, context), [ - 2400, - 256 - ]); - console.log("asd"); -} - -function inc_counter(param) { - loadCount.contents = loadCount.contents + 1 | 0; - if (loadCount.contents === 4) { - return load(); - } - -} - -function preload(param) { - return Belt_List.map({ - hd: "blocks.png", - tl: { - hd: "items.png", - tl: { - hd: "enemies.png", - tl: { - hd: "mario-small.png", - tl: /* [] */0 - } - } - } - }, img_src => { - let img_src$1 = "sprites/" + img_src; - let img = document.createElement("img"); - img.src = img_src$1; - img.addEventListener("load", ev => { - inc_counter(); - return true; - }, true); - }); -} - -window.onload = param => { - preload(); - return true; -}; - -let Main = { - Html: undefined, - Pg: undefined, - loadCount: loadCount, - imgsToLoad: 4, - level_width: 2400, - level_height: 256, - load: load, - inc_counter: inc_counter, - preload: preload -}; - -exports.Random = Random; -exports.Actors = Actors; -exports.Dom_html = Dom_html; -exports.Sprite = Sprite; -exports.Particle = Particle; -exports.$$Object = $$Object; -exports.Draw = Draw; -exports.Viewport = Viewport; -exports.Director = Director; -exports.Procedural_generator = Procedural_generator; -exports.Main = Main; -/* Not a pure module */ diff --git a/tests/tests/src/mario_game.mjs b/tests/tests/src/mario_game.mjs new file mode 100644 index 0000000000..d89d8cc315 --- /dev/null +++ b/tests/tests/src/mario_game.mjs @@ -0,0 +1,3336 @@ +// Generated by ReScript, PLEASE EDIT WITH CARE + +import * as Belt_List from "rescript/lib/es6/Belt_List.js"; +import * as Pervasives from "rescript/lib/es6/Pervasives.js"; +import * as Primitive_int from "rescript/lib/es6/Primitive_int.js"; +import * as Primitive_bool from "rescript/lib/es6/Primitive_bool.js"; +import * as Primitive_float from "rescript/lib/es6/Primitive_float.js"; +import * as Primitive_object from "rescript/lib/es6/Primitive_object.js"; +import * as Primitive_option from "rescript/lib/es6/Primitive_option.js"; + +function self_init() { + +} + +let int = ((max) => { + return ((Math.random() * 100) | 0) % max; + }); + +let Random = { + self_init: self_init, + int: int +}; + +let Actors = {}; + +let Dom_html = {}; + +function setup_sprite(loopOpt, bbox_offsetOpt, bbox_sizeOpt, img_src, max_frames, max_ticks, frame_size, src_offset) { + let loop = loopOpt !== undefined ? loopOpt : true; + let bbox_offset = bbox_offsetOpt !== undefined ? bbox_offsetOpt : [ + 0, + 0 + ]; + let bbox_size = bbox_sizeOpt !== undefined ? bbox_sizeOpt : [ + 0, + 0 + ]; + let bbox_size$1 = Primitive_object.equal(bbox_size, [ + 0, + 0 + ]) ? frame_size : bbox_size; + let img_src$1 = "./sprites/" + img_src; + return { + max_frames: max_frames, + max_ticks: max_ticks, + img_src: img_src$1, + frame_size: frame_size, + src_offset: src_offset, + bbox_offset: bbox_offset, + bbox_size: bbox_size$1, + loop: loop + }; +} + +function make_enemy(param) { + let dir = param[1]; + switch (param[0]) { + case "Goomba" : + return setup_sprite(undefined, [ + 1, + 1 + ], [ + 14, + 14 + ], "enemies.png", 2, 10, [ + 16, + 16 + ], [ + 0, + 128 + ]); + case "GKoopa" : + if (dir === "Left") { + return setup_sprite(undefined, [ + 4, + 10 + ], [ + 11, + 16 + ], "enemies.png", 2, 10, [ + 16, + 27 + ], [ + 0, + 69 + ]); + } else { + return setup_sprite(undefined, [ + 1, + 10 + ], [ + 11, + 16 + ], "enemies.png", 2, 10, [ + 16, + 27 + ], [ + 32, + 69 + ]); + } + case "RKoopa" : + if (dir === "Left") { + return setup_sprite(undefined, [ + 4, + 10 + ], [ + 11, + 16 + ], "enemies.png", 2, 10, [ + 16, + 27 + ], [ + 0, + 5 + ]); + } else { + return setup_sprite(undefined, [ + 1, + 10 + ], [ + 11, + 16 + ], "enemies.png", 2, 10, [ + 16, + 27 + ], [ + 32, + 5 + ]); + } + case "GKoopaShell" : + return setup_sprite(undefined, [ + 2, + 2 + ], [ + 12, + 13 + ], "enemies.png", 4, 10, [ + 16, + 16 + ], [ + 0, + 96 + ]); + case "RKoopaShell" : + return setup_sprite(undefined, [ + 2, + 2 + ], [ + 12, + 13 + ], "enemies.png", 4, 10, [ + 16, + 16 + ], [ + 0, + 32 + ]); + } +} + +function make_particle(x) { + switch (x) { + case "GoombaSquish" : + return setup_sprite(undefined, undefined, undefined, "enemies.png", 1, 0, [ + 16, + 16 + ], [ + 0, + 144 + ]); + case "BrickChunkL" : + return setup_sprite(undefined, undefined, undefined, "chunks.png", 1, 0, [ + 8, + 8 + ], [ + 0, + 0 + ]); + case "BrickChunkR" : + return setup_sprite(undefined, undefined, undefined, "chunks.png", 1, 0, [ + 8, + 8 + ], [ + 8, + 0 + ]); + case "Score100" : + return setup_sprite(undefined, undefined, undefined, "score.png", 1, 0, [ + 12, + 8 + ], [ + 0, + 0 + ]); + case "Score200" : + return setup_sprite(undefined, undefined, undefined, "score.png", 1, 0, [ + 12, + 9 + ], [ + 0, + 9 + ]); + case "Score400" : + return setup_sprite(undefined, undefined, undefined, "score.png", 1, 0, [ + 12, + 9 + ], [ + 0, + 18 + ]); + case "Score800" : + return setup_sprite(undefined, undefined, undefined, "score.png", 1, 0, [ + 12, + 9 + ], [ + 0, + 27 + ]); + case "Score1000" : + return setup_sprite(undefined, undefined, undefined, "score.png", 1, 0, [ + 14, + 9 + ], [ + 13, + 0 + ]); + case "Score2000" : + return setup_sprite(undefined, undefined, undefined, "score.png", 1, 0, [ + 14, + 9 + ], [ + 13, + 9 + ]); + case "Score4000" : + return setup_sprite(undefined, undefined, undefined, "score.png", 1, 0, [ + 14, + 9 + ], [ + 13, + 18 + ]); + case "Score8000" : + return setup_sprite(undefined, undefined, undefined, "score.png", 1, 0, [ + 14, + 9 + ], [ + 13, + 27 + ]); + } +} + +function make_type(typ, dir) { + switch (typ.TAG) { + case "SPlayer" : + let pt = typ._0; + let spr_type = [ + typ._1, + dir + ]; + if (pt === "BigM") { + let typ$1 = spr_type[0]; + if (spr_type[1] === "Left") { + switch (typ$1) { + case "Standing" : + return setup_sprite(undefined, [ + 2, + 1 + ], [ + 13, + 25 + ], "mario-big.png", 1, 0, [ + 16, + 27 + ], [ + 16, + 5 + ]); + case "Jumping" : + return setup_sprite(undefined, [ + 2, + 1 + ], [ + 12, + 25 + ], "mario-big.png", 1, 0, [ + 16, + 26 + ], [ + 48, + 6 + ]); + case "Running" : + return setup_sprite(undefined, [ + 2, + 1 + ], [ + 13, + 25 + ], "mario-big.png", 4, 10, [ + 16, + 27 + ], [ + 0, + 37 + ]); + case "Crouching" : + return setup_sprite(undefined, [ + 2, + 10 + ], [ + 13, + 17 + ], "mario-big.png", 1, 0, [ + 16, + 27 + ], [ + 32, + 5 + ]); + } + } else { + switch (typ$1) { + case "Standing" : + return setup_sprite(undefined, [ + 1, + 1 + ], [ + 13, + 25 + ], "mario-big.png", 1, 0, [ + 16, + 26 + ], [ + 16, + 69 + ]); + case "Jumping" : + return setup_sprite(undefined, [ + 2, + 1 + ], [ + 12, + 25 + ], "mario-big.png", 1, 0, [ + 16, + 26 + ], [ + 48, + 70 + ]); + case "Running" : + return setup_sprite(undefined, [ + 2, + 1 + ], [ + 13, + 25 + ], "mario-big.png", 4, 10, [ + 16, + 27 + ], [ + 0, + 101 + ]); + case "Crouching" : + return setup_sprite(undefined, [ + 2, + 10 + ], [ + 13, + 17 + ], "mario-big.png", 1, 0, [ + 16, + 27 + ], [ + 32, + 69 + ]); + } + } + } else { + let typ$2 = spr_type[0]; + if (spr_type[1] === "Left") { + switch (typ$2) { + case "Standing" : + return setup_sprite(undefined, [ + 3, + 1 + ], [ + 11, + 15 + ], "mario-small.png", 1, 0, [ + 16, + 16 + ], [ + 0, + 0 + ]); + case "Jumping" : + return setup_sprite(undefined, [ + 2, + 1 + ], [ + 13, + 15 + ], "mario-small.png", 2, 10, [ + 16, + 16 + ], [ + 16, + 16 + ]); + case "Running" : + return setup_sprite(undefined, [ + 2, + 1 + ], [ + 12, + 15 + ], "mario-small.png", 3, 5, [ + 16, + 16 + ], [ + 16, + 0 + ]); + case "Crouching" : + return setup_sprite(undefined, [ + 1, + 5 + ], [ + 14, + 10 + ], "mario-small.png", 1, 0, [ + 16, + 16 + ], [ + 0, + 64 + ]); + } + } else { + switch (typ$2) { + case "Standing" : + return setup_sprite(undefined, [ + 1, + 1 + ], [ + 11, + 15 + ], "mario-small.png", 1, 0, [ + 16, + 16 + ], [ + 0, + 32 + ]); + case "Jumping" : + return setup_sprite(undefined, [ + 2, + 1 + ], [ + 13, + 15 + ], "mario-small.png", 2, 10, [ + 16, + 16 + ], [ + 16, + 48 + ]); + case "Running" : + return setup_sprite(undefined, [ + 2, + 1 + ], [ + 12, + 15 + ], "mario-small.png", 3, 5, [ + 16, + 16 + ], [ + 16, + 32 + ]); + case "Crouching" : + return setup_sprite(undefined, [ + 1, + 5 + ], [ + 14, + 10 + ], "mario-small.png", 1, 0, [ + 16, + 16 + ], [ + 0, + 64 + ]); + } + } + } + case "SEnemy" : + return make_enemy([ + typ._0, + dir + ]); + case "SItem" : + let x = typ._0; + switch (x) { + case "Mushroom" : + return setup_sprite(undefined, [ + 2, + 0 + ], [ + 12, + 16 + ], "items.png", 1, 0, [ + 16, + 16 + ], [ + 0, + 0 + ]); + case "FireFlower" : + return setup_sprite(undefined, undefined, undefined, "items.png", 1, 0, [ + 16, + 16 + ], [ + 0, + 188 + ]); + case "Star" : + return setup_sprite(undefined, undefined, undefined, "items.png", 1, 0, [ + 16, + 16 + ], [ + 16, + 48 + ]); + case "Coin" : + return setup_sprite(undefined, [ + 3, + 0 + ], [ + 12, + 16 + ], "items.png", 3, 15, [ + 16, + 16 + ], [ + 0, + 80 + ]); + } + case "SBlock" : + let x$1 = typ._0; + if (typeof x$1 === "object") { + return setup_sprite(undefined, undefined, undefined, "blocks.png", 4, 15, [ + 16, + 16 + ], [ + 0, + 16 + ]); + } + switch (x$1) { + case "QBlockUsed" : + return setup_sprite(undefined, undefined, undefined, "blocks.png", 1, 0, [ + 16, + 16 + ], [ + 0, + 32 + ]); + case "Brick" : + return setup_sprite(undefined, undefined, undefined, "blocks.png", 5, 10, [ + 16, + 16 + ], [ + 0, + 0 + ]); + case "UnBBlock" : + return setup_sprite(undefined, undefined, undefined, "blocks.png", 1, 0, [ + 16, + 16 + ], [ + 0, + 48 + ]); + case "Cloud" : + return setup_sprite(undefined, undefined, undefined, "blocks.png", 1, 0, [ + 16, + 16 + ], [ + 0, + 64 + ]); + case "Panel" : + return setup_sprite(undefined, undefined, undefined, "panel.png", 3, 15, [ + 26, + 26 + ], [ + 0, + 0 + ]); + case "Ground" : + return setup_sprite(undefined, undefined, undefined, "ground.png", 1, 0, [ + 16, + 16 + ], [ + 0, + 32 + ]); + } + } +} + +function make_from_params(params, context) { + let img = document.createElement("img"); + img.src = params.img_src; + return { + params: params, + context: context, + frame: { + contents: 0 + }, + ticks: { + contents: 0 + }, + img: img + }; +} + +function make(spawn, dir, context) { + let params = make_type(spawn, dir); + return make_from_params(params, context); +} + +function make_bgd(context) { + let params = setup_sprite(undefined, undefined, undefined, "bgd-1.png", 1, 0, [ + 512, + 256 + ], [ + 0, + 0 + ]); + return make_from_params(params, context); +} + +function make_particle$1(ptyp, context) { + let params = make_particle(ptyp); + return make_from_params(params, context); +} + +function transform_enemy(enemy_typ, spr, dir) { + let params = make_enemy([ + enemy_typ, + dir + ]); + let img = document.createElement("img"); + img.src = params.img_src; + spr.params = params; + spr.img = img; +} + +function update_animation(spr) { + let curr_ticks = spr.ticks.contents; + if (curr_ticks >= spr.params.max_ticks) { + spr.ticks.contents = 0; + if (spr.params.loop) { + spr.frame.contents = Primitive_int.mod_(spr.frame.contents + 1 | 0, spr.params.max_frames); + return; + } else { + return; + } + } else { + spr.ticks.contents = curr_ticks + 1 | 0; + return; + } +} + +let Sprite = { + setup_sprite: setup_sprite, + make: make, + make_bgd: make_bgd, + make_particle: make_particle$1, + transform_enemy: transform_enemy, + update_animation: update_animation +}; + +function pair_to_xy(pair) { + return { + x: pair[0], + y: pair[1] + }; +} + +function make_type$1(typ, ctx) { + switch (typ) { + case "BrickChunkL" : + case "BrickChunkR" : + return { + sprite: make_particle$1(typ, ctx), + rot: 0, + lifetime: 300 + }; + default: + return { + sprite: make_particle$1(typ, ctx), + rot: 0, + lifetime: 30 + }; + } +} + +function make$1(velOpt, accOpt, part_type, pos, ctx) { + let vel = velOpt !== undefined ? velOpt : [ + 0, + 0 + ]; + let acc = accOpt !== undefined ? accOpt : [ + 0, + 0 + ]; + let params = make_type$1(part_type, ctx); + let pos$1 = pair_to_xy(pos); + let vel$1 = pair_to_xy(vel); + let acc$1 = pair_to_xy(acc); + return { + params: params, + part_type: part_type, + pos: pos$1, + vel: vel$1, + acc: acc$1, + kill: false, + life: params.lifetime + }; +} + +function make_score(score, pos, ctx) { + let t = score >= 801 ? ( + score >= 2001 ? ( + score !== 4000 ? ( + score !== 8000 ? "Score100" : "Score8000" + ) : "Score4000" + ) : ( + score !== 1000 ? ( + score >= 2000 ? "Score2000" : "Score100" + ) : "Score1000" + ) + ) : ( + score >= 201 ? ( + score !== 400 ? ( + score >= 800 ? "Score800" : "Score100" + ) : "Score400" + ) : ( + score !== 100 && score >= 200 ? "Score200" : "Score100" + ) + ); + return make$1([ + 0.5, + -0.7 + ], undefined, t, pos, ctx); +} + +function update_vel(part) { + part.vel.x = part.vel.x + part.acc.x; + part.vel.y = part.vel.y + part.acc.y; +} + +function process(part) { + part.life = part.life - 1 | 0; + if (part.life === 0) { + part.kill = true; + } + update_vel(part); + part.pos.x = part.vel.x + part.pos.x; + part.pos.y = part.vel.y + part.pos.y; +} + +let Particle = { + make: make$1, + make_score: make_score, + process: process +}; + +let id_counter = { + contents: Pervasives.min_int +}; + +function setup_obj(has_gravityOpt, speedOpt, param) { + let has_gravity = has_gravityOpt !== undefined ? has_gravityOpt : true; + let speed = speedOpt !== undefined ? speedOpt : 1; + return { + has_gravity: has_gravity, + speed: speed + }; +} + +function set_vel_to_speed(obj) { + let speed = obj.params.speed; + let match = obj.dir; + if (match === "Left") { + obj.vel.x = - speed; + } else { + obj.vel.x = speed; + } +} + +function make_player() { + return setup_obj(undefined, 2.8, undefined); +} + +function make_type$2(x) { + switch (x.TAG) { + case "SPlayer" : + return make_player(); + case "SEnemy" : + let x$1 = x._0; + switch (x$1) { + case "GKoopaShell" : + case "RKoopaShell" : + return setup_obj(undefined, 3, undefined); + default: + return setup_obj(undefined, undefined, undefined); + } + case "SItem" : + let x$2 = x._0; + if (x$2 === "Coin") { + return setup_obj(false, undefined, undefined); + } else { + return setup_obj(undefined, undefined, undefined); + } + case "SBlock" : + return setup_obj(false, undefined, undefined); + } +} + +function new_id() { + id_counter.contents = id_counter.contents + 1 | 0; + return id_counter.contents; +} + +function make$2($staropt$star, $staropt$star$1, spawnable, context, param) { + let id = $staropt$star !== undefined ? Primitive_option.valFromOption($staropt$star) : undefined; + let dir = $staropt$star$1 !== undefined ? $staropt$star$1 : "Left"; + let spr = make(spawnable, dir, context); + let params = make_type$2(spawnable); + let id$1 = id !== undefined ? id : new_id(); + let obj = { + params: params, + pos: { + x: param[0], + y: param[1] + }, + vel: { + x: 0.0, + y: 0.0 + }, + id: id$1, + jumping: false, + grounded: false, + dir: dir, + invuln: 0, + kill: false, + health: 1, + crouch: false, + score: 0 + }; + return [ + spr, + obj + ]; +} + +function spawn(spawnable, context, param) { + let match = make$2(undefined, undefined, spawnable, context, [ + param[0], + param[1] + ]); + let obj = match[1]; + let spr = match[0]; + switch (spawnable.TAG) { + case "SPlayer" : + return { + TAG: "Player", + _0: spawnable._0, + _1: spr, + _2: obj + }; + case "SEnemy" : + set_vel_to_speed(obj); + return { + TAG: "Enemy", + _0: spawnable._0, + _1: spr, + _2: obj + }; + case "SItem" : + return { + TAG: "Item", + _0: spawnable._0, + _1: spr, + _2: obj + }; + case "SBlock" : + return { + TAG: "Block", + _0: spawnable._0, + _1: spr, + _2: obj + }; + } +} + +function get_sprite(x) { + return x._1; +} + +function get_obj(x) { + return x._2; +} + +function is_player(x) { + if (x.TAG === "Player") { + return true; + } else { + return false; + } +} + +function is_enemy(x) { + if (x.TAG === "Enemy") { + return true; + } else { + return false; + } +} + +function equals(col1, col2) { + return col1._2.id === col2._2.id; +} + +function normalize_pos(pos, p1, p2) { + let match = p1.bbox_offset; + let match$1 = p2.bbox_offset; + let match$2 = p1.bbox_size; + let match$3 = p2.bbox_size; + pos.x = pos.x - (match$3[0] + match$1[0]) + (match$2[0] + match[0]); + pos.y = pos.y - (match$3[1] + match$1[1]) + (match$2[1] + match[1]); +} + +function update_player(player, keys, context) { + let prev_jumping = player.jumping; + let prev_dir = player.dir; + let prev_vx = Math.abs(player.vel.x); + Belt_List.forEach(keys, extra => { + let lr_acc = player.vel.x * 0.2; + switch (extra) { + case "CLeft" : + if (!player.crouch) { + if (player.vel.x > - player.params.speed) { + player.vel.x = player.vel.x - (0.4 - lr_acc); + } + player.dir = "Left"; + return; + } else { + return; + } + case "CRight" : + if (!player.crouch) { + if (player.vel.x < player.params.speed) { + player.vel.x = player.vel.x + (0.4 + lr_acc); + } + player.dir = "Right"; + return; + } else { + return; + } + case "CUp" : + if (!player.jumping && player.grounded) { + player.jumping = true; + player.grounded = false; + player.vel.y = Primitive_bool.max(player.vel.y - (5.7 + Math.abs(player.vel.x) * 0.25), -6); + return; + } else { + return; + } + case "CDown" : + if (!player.jumping && player.grounded) { + player.crouch = true; + return; + } else { + return; + } + } + }); + let v = player.vel.x * 0.9; + let vel_damped = Math.abs(v) < 0.1 ? 0 : v; + player.vel.x = vel_damped; + let pl_typ = player.health <= 1 ? "SmallM" : "BigM"; + if (!prev_jumping && player.jumping) { + return [ + pl_typ, + make({ + TAG: "SPlayer", + _0: pl_typ, + _1: "Jumping" + }, player.dir, context) + ]; + } else if (prev_dir !== player.dir || prev_vx === 0 && Math.abs(player.vel.x) > 0 && !player.jumping) { + return [ + pl_typ, + make({ + TAG: "SPlayer", + _0: pl_typ, + _1: "Running" + }, player.dir, context) + ]; + } else if (prev_dir !== player.dir && player.jumping && prev_jumping) { + return [ + pl_typ, + make({ + TAG: "SPlayer", + _0: pl_typ, + _1: "Jumping" + }, player.dir, context) + ]; + } else if (player.vel.y === 0 && player.crouch) { + return [ + pl_typ, + make({ + TAG: "SPlayer", + _0: pl_typ, + _1: "Crouching" + }, player.dir, context) + ]; + } else if (player.vel.y === 0 && player.vel.x === 0) { + return [ + pl_typ, + make({ + TAG: "SPlayer", + _0: pl_typ, + _1: "Standing" + }, player.dir, context) + ]; + } else { + return; + } +} + +function update_vel$1(obj) { + if (obj.grounded) { + obj.vel.y = 0; + return; + } else if (obj.params.has_gravity) { + obj.vel.y = Primitive_float.min(obj.vel.y + 0.2 + Math.abs(obj.vel.y) * 0.01, 4.5); + return; + } else { + return; + } +} + +function update_pos(obj) { + obj.pos.x = obj.vel.x + obj.pos.x; + if (obj.params.has_gravity) { + obj.pos.y = obj.vel.y + obj.pos.y; + return; + } + +} + +function process_obj(obj, mapy) { + update_vel$1(obj); + update_pos(obj); + if (obj.pos.y > mapy) { + obj.kill = true; + return; + } + +} + +function normalize_origin(pos, spr) { + let p = spr.params; + let match = p.bbox_offset; + let match$1 = p.bbox_size; + pos.x = pos.x - match[0]; + pos.y = pos.y - (match[1] + match$1[1]); +} + +function collide_block(check_xOpt, dir, obj) { + let check_x = check_xOpt !== undefined ? check_xOpt : true; + switch (dir) { + case "North" : + obj.vel.y = -0.001; + return; + case "South" : + obj.vel.y = 0; + obj.grounded = true; + obj.jumping = false; + return; + case "East" : + case "West" : + break; + } + if (check_x) { + obj.vel.x = 0; + return; + } + +} + +function opposite_dir(dir) { + if (dir === "Left") { + return "Right"; + } else { + return "Left"; + } +} + +function reverse_left_right(obj) { + obj.vel.x = - obj.vel.x; + obj.dir = opposite_dir(obj.dir); +} + +function evolve_enemy(player_dir, typ, spr, obj, context) { + switch (typ) { + case "Goomba" : + obj.kill = true; + return; + case "GKoopa" : + let match = make$2(undefined, obj.dir, { + TAG: "SEnemy", + _0: "GKoopaShell" + }, context, [ + obj.pos.x, + obj.pos.y + ]); + let new_obj = match[1]; + let new_spr = match[0]; + normalize_pos(new_obj.pos, spr.params, new_spr.params); + return { + TAG: "Enemy", + _0: "GKoopaShell", + _1: new_spr, + _2: new_obj + }; + case "RKoopa" : + let match$1 = make$2(undefined, obj.dir, { + TAG: "SEnemy", + _0: "RKoopaShell" + }, context, [ + obj.pos.x, + obj.pos.y + ]); + let new_obj$1 = match$1[1]; + let new_spr$1 = match$1[0]; + normalize_pos(new_obj$1.pos, spr.params, new_spr$1.params); + return { + TAG: "Enemy", + _0: "RKoopaShell", + _1: new_spr$1, + _2: new_obj$1 + }; + case "GKoopaShell" : + case "RKoopaShell" : + break; + } + obj.dir = player_dir; + if (obj.vel.x !== 0) { + obj.vel.x = 0; + } else { + set_vel_to_speed(obj); + } +} + +function rev_dir(o, t, s) { + reverse_left_right(o); + let old_params = s.params; + transform_enemy(t, s, o.dir); + normalize_pos(o.pos, old_params, s.params); +} + +function dec_health(obj) { + let health = obj.health - 1 | 0; + if (health === 0) { + obj.kill = true; + return; + } else if (obj.invuln === 0) { + obj.health = health; + return; + } else { + return; + } +} + +function evolve_block(obj, context) { + dec_health(obj); + let match = make$2(undefined, undefined, { + TAG: "SBlock", + _0: "QBlockUsed" + }, context, [ + obj.pos.x, + obj.pos.y + ]); + return { + TAG: "Block", + _0: "QBlockUsed", + _1: match[0], + _2: match[1] + }; +} + +function spawn_above(player_dir, obj, typ, context) { + let item = spawn({ + TAG: "SItem", + _0: typ + }, context, [ + obj.pos.x, + obj.pos.y + ]); + let item_obj = item._2; + item_obj.pos.y = item_obj.pos.y - item._1.params.frame_size[1]; + item_obj.dir = opposite_dir(player_dir); + set_vel_to_speed(item_obj); + return item; +} + +function get_aabb(obj) { + let spr = obj._1.params; + let obj$1 = obj._2; + let match = spr.bbox_offset; + let box = obj$1.pos.x + match[0]; + let boy = obj$1.pos.y + match[1]; + let match$1 = spr.bbox_size; + let sy = match$1[1]; + let sx = match$1[0]; + return { + center: { + x: box + sx / 2, + y: boy + sy / 2 + }, + half: { + x: sx / 2, + y: sy / 2 + } + }; +} + +function col_bypass(c1, c2) { + let o1 = c1._2; + let o2 = c2._2; + let ctypes; + switch (c1.TAG) { + case "Player" : + ctypes = c2.TAG === "Enemy" ? c1._2.invuln > 0 : false; + break; + case "Enemy" : + ctypes = c2.TAG === "Item" ? true : false; + break; + case "Item" : + switch (c2.TAG) { + case "Enemy" : + case "Item" : + ctypes = true; + break; + case "Player" : + case "Block" : + ctypes = false; + break; + } + break; + case "Block" : + ctypes = false; + break; + } + if (o1.kill || o2.kill) { + return true; + } else { + return ctypes; + } +} + +function check_collision(c1, c2) { + let b1 = get_aabb(c1); + let b2 = get_aabb(c2); + let o1 = c1._2; + if (col_bypass(c1, c2)) { + return; + } + let vx = b1.center.x - b2.center.x; + let vy = b1.center.y - b2.center.y; + let hwidths = b1.half.x + b2.half.x; + let hheights = b1.half.y + b2.half.y; + if (!(Math.abs(vx) < hwidths && Math.abs(vy) < hheights)) { + return; + } + let ox = hwidths - Math.abs(vx); + let oy = hheights - Math.abs(vy); + if (ox >= oy) { + if (vy > 0) { + o1.pos.y = o1.pos.y + oy; + return "North"; + } else { + o1.pos.y = o1.pos.y - oy; + return "South"; + } + } else if (vx > 0) { + o1.pos.x = o1.pos.x + ox; + return "West"; + } else { + o1.pos.x = o1.pos.x - ox; + return "East"; + } +} + +function kill(collid, ctx) { + switch (collid.TAG) { + case "Player" : + return /* [] */0; + case "Enemy" : + let o = collid._2; + let pos_0 = o.pos.x; + let pos_1 = o.pos.y; + let pos = [ + pos_0, + pos_1 + ]; + let score = o.score > 0 ? ({ + hd: make_score(o.score, pos, ctx), + tl: /* [] */0 + }) : /* [] */0; + let remains; + remains = collid._0 === "Goomba" ? ({ + hd: make$1(undefined, undefined, "GoombaSquish", pos, ctx), + tl: /* [] */0 + }) : /* [] */0; + return Pervasives.$at(score, remains); + case "Item" : + let o$1 = collid._2; + if (collid._0 === "Mushroom") { + return { + hd: make_score(o$1.score, [ + o$1.pos.x, + o$1.pos.y + ], ctx), + tl: /* [] */0 + }; + } else { + return /* [] */0; + } + case "Block" : + let o$2 = collid._2; + let tmp = collid._0; + if (typeof tmp === "object") { + return /* [] */0; + } + if (tmp !== "Brick") { + return /* [] */0; + } + let pos_0$1 = o$2.pos.x; + let pos_1$1 = o$2.pos.y; + let pos$1 = [ + pos_0$1, + pos_1$1 + ]; + let p1 = make$1([ + -5, + -5 + ], [ + 0, + 0.2 + ], "BrickChunkL", pos$1, ctx); + let p2 = make$1([ + -3, + -4 + ], [ + 0, + 0.2 + ], "BrickChunkL", pos$1, ctx); + let p3 = make$1([ + 3, + -4 + ], [ + 0, + 0.2 + ], "BrickChunkR", pos$1, ctx); + let p4 = make$1([ + 5, + -5 + ], [ + 0, + 0.2 + ], "BrickChunkR", pos$1, ctx); + return { + hd: p1, + tl: { + hd: p2, + tl: { + hd: p3, + tl: { + hd: p4, + tl: /* [] */0 + } + } + } + }; + } +} + +let $$Object = { + invuln: 60, + dampen_jump: 4, + get_sprite: get_sprite, + get_obj: get_obj, + spawn: spawn, + equals: equals, + is_player: is_player, + is_enemy: is_enemy, + normalize_origin: normalize_origin, + normalize_pos: normalize_pos, + kill: kill, + process_obj: process_obj, + update_player: update_player, + check_collision: check_collision, + evolve_enemy: evolve_enemy, + evolve_block: evolve_block, + dec_health: dec_health, + rev_dir: rev_dir, + reverse_left_right: reverse_left_right, + collide_block: collide_block, + spawn_above: spawn_above +}; + +function render_bbox(sprite, param) { + let context = sprite.context; + let match = sprite.params.bbox_offset; + let match$1 = sprite.params.bbox_size; + context.strokeStyle = "#FF0000"; + return context.strokeRect(param[0] + match[0], param[1] + match[1], match$1[0], match$1[1]); +} + +function render(sprite, param) { + let context = sprite.context; + let match = sprite.params.src_offset; + let match$1 = sprite.params.frame_size; + let sw = match$1[0]; + let match$2 = sprite.params.frame_size; + let sx = match[0] + sprite.frame.contents * sw; + return context.drawImage(sprite.img, sx, match[1], sw, match$1[1], param[0], param[1], match$2[0], match$2[1]); +} + +function draw_bgd(bgd, off_x) { + render(bgd, [ + - off_x, + 0 + ]); + return render(bgd, [ + bgd.params.frame_size[0] - off_x, + 0 + ]); +} + +function clear_canvas(canvas) { + let context = canvas.getContext("2d"); + let cwidth = canvas.width; + let cheight = canvas.height; + context.clearRect(0, 0, cwidth, cheight); +} + +function hud(canvas, score, coins) { + let score_string = score.toString(); + let coin_string = coins.toString(); + let context = canvas.getContext("2d"); + context.font = "10px 'Press Start 2P'"; + context.fillText("Score: " + score_string, canvas.width - 140, 18); + context.fillText("Coins: " + coin_string, 120, 18); +} + +function fps(canvas, fps_val) { + let fps_str = fps_val.toFixed(); + let context = canvas.getContext("2d"); + context.fillText(fps_str, 10, 18); +} + +function game_win(ctx) { + ctx.rect(0, 0, 512, 512); + ctx.fillStyle = "black"; + ctx.fill(); + ctx.fillStyle = "white"; + ctx.font = "20px 'Press Start 2P'"; + ctx.fillText("You win!", 180, 128); + return Pervasives.failwith("Game over."); +} + +function game_loss(ctx) { + ctx.rect(0, 0, 512, 512); + ctx.fillStyle = "black"; + ctx.fill(); + ctx.fillStyle = "white"; + ctx.font = "20px 'Press Start 2P'"; + ctx.fillText("GAME OVER. You lose!", 60, 128); + return Pervasives.failwith("Game over."); +} + +let Draw = { + render: render, + clear_canvas: clear_canvas, + draw_bgd: draw_bgd, + render_bbox: render_bbox, + fps: fps, + hud: hud, + game_win: game_win, + game_loss: game_loss +}; + +function make$3(param, param$1) { + return { + pos: { + x: 0, + y: 0 + }, + v_dim: { + x: param[0], + y: param[1] + }, + m_dim: { + x: param$1[0], + y: param$1[1] + } + }; +} + +function calc_viewport_point(cc, vc, mc) { + let vc_half = vc / 2; + return Primitive_float.min(Primitive_bool.max(cc - vc_half, 0), Primitive_float.min(mc - vc, Math.abs(cc - vc_half))); +} + +function in_viewport(v, pos) { + let v_min_x = v.pos.x - 32; + let v_max_x = v.pos.x + v.v_dim.x; + let v_min_y = v.pos.y - 32; + let v_max_y = v.pos.y + v.v_dim.y; + let x = pos.x; + let y = pos.y; + if (x >= v_min_x && x <= v_max_x && y >= v_min_y) { + return y <= v_max_y; + } else { + return false; + } +} + +function out_of_viewport_below(v, y) { + let v_max_y = v.pos.y + v.v_dim.y; + return y >= v_max_y; +} + +function coord_to_viewport(viewport, coord) { + return { + x: coord.x - viewport.pos.x, + y: coord.y - viewport.pos.y + }; +} + +function update(vpt, ctr) { + let new_x = calc_viewport_point(ctr.x, vpt.v_dim.x, vpt.m_dim.x); + let new_y = calc_viewport_point(ctr.y, vpt.v_dim.y, vpt.m_dim.y); + let pos = { + x: new_x, + y: new_y + }; + return { + pos: pos, + v_dim: vpt.v_dim, + m_dim: vpt.m_dim + }; +} + +let Viewport = { + make: make$3, + calc_viewport_point: calc_viewport_point, + in_viewport: in_viewport, + out_of_viewport_below: out_of_viewport_below, + coord_to_viewport: coord_to_viewport, + update: update +}; + +let pressed_keys = { + left: false, + right: false, + up: false, + down: false, + bbox: 0 +}; + +let collid_objs = { + contents: /* [] */0 +}; + +let particles = { + contents: /* [] */0 +}; + +let last_time = { + contents: 0 +}; + +function calc_fps(t0, t1) { + let delta = (t1 - t0) / 1000; + return 1 / delta; +} + +function update_score(state, i) { + state.score = state.score + i | 0; +} + +function process_collision(dir, c1, c2, state) { + let context = state.ctx; + let exit = 0; + let s1; + let o1; + let typ; + let s2; + let o2; + let s1$1; + let o1$1; + let t2; + let s2$1; + let o2$1; + let o1$2; + let t2$1; + let o2$2; + switch (c1.TAG) { + case "Player" : + let o1$3 = c1._2; + let s1$2 = c1._1; + switch (c2.TAG) { + case "Player" : + return [ + undefined, + undefined + ]; + case "Enemy" : + let o2$3 = c2._2; + let s2$2 = c2._1; + let typ$1 = c2._0; + if (dir === "South") { + s1 = s1$2; + o1 = o1$3; + typ = typ$1; + s2 = s2$2; + o2 = o2$3; + exit = 1; + } else { + s1$1 = s1$2; + o1$1 = o1$3; + t2 = typ$1; + s2$1 = s2$2; + o2$1 = o2$3; + exit = 2; + } + break; + case "Item" : + o1$2 = o1$3; + t2$1 = c2._0; + o2$2 = c2._2; + exit = 3; + break; + case "Block" : + let o2$4 = c2._2; + let t = c2._0; + if (dir === "North") { + if (typeof t !== "object") { + switch (t) { + case "Brick" : + if (c1._0 === "BigM") { + collide_block(undefined, dir, o1$3); + dec_health(o2$4); + return [ + undefined, + undefined + ]; + } else { + collide_block(undefined, dir, o1$3); + return [ + undefined, + undefined + ]; + } + case "Panel" : + game_win(state.ctx); + return [ + undefined, + undefined + ]; + default: + collide_block(undefined, dir, o1$3); + return [ + undefined, + undefined + ]; + } + } else { + let updated_block = evolve_block(o2$4, context); + let spawned_item = spawn_above(o1$3.dir, o2$4, t._0, context); + collide_block(undefined, dir, o1$3); + return [ + spawned_item, + updated_block + ]; + } + } else { + let exit$1 = 0; + if (typeof t !== "object") { + if (t === "Panel") { + game_win(state.ctx); + return [ + undefined, + undefined + ]; + } + exit$1 = 4; + } else { + exit$1 = 4; + } + if (exit$1 === 4) { + if (dir === "South") { + state.multiplier = 1; + collide_block(undefined, dir, o1$3); + return [ + undefined, + undefined + ]; + } + collide_block(undefined, dir, o1$3); + return [ + undefined, + undefined + ]; + } + + } + break; + } + break; + case "Enemy" : + let o1$4 = c1._2; + let s1$3 = c1._1; + let t1 = c1._0; + switch (c2.TAG) { + case "Player" : + let o1$5 = c2._2; + let s1$4 = c2._1; + if (dir === "North") { + s1 = s1$4; + o1 = o1$5; + typ = t1; + s2 = s1$3; + o2 = o1$4; + exit = 1; + } else { + s1$1 = s1$4; + o1$1 = o1$5; + t2 = t1; + s2$1 = s1$3; + o2$1 = o1$4; + exit = 2; + } + break; + case "Enemy" : + let t2$2 = c2._0; + let s2$3 = c2._1; + let o2$5 = c2._2; + let exit$2 = 0; + switch (t1) { + case "GKoopaShell" : + switch (t2$2) { + case "GKoopaShell" : + case "RKoopaShell" : + exit$2 = 1; + break; + default: + exit$2 = 2; + } + break; + case "RKoopaShell" : + switch (t2$2) { + case "GKoopaShell" : + case "RKoopaShell" : + exit$2 = 1; + break; + default: + exit$2 = 2; + } + break; + default: + switch (t2$2) { + case "GKoopaShell" : + case "RKoopaShell" : + exit$2 = 3; + break; + default: + let exit$3 = 0; + switch (dir) { + case "North" : + case "South" : + return [ + undefined, + undefined + ]; + case "East" : + case "West" : + exit$3 = 4; + break; + } + if (exit$3 === 4) { + rev_dir(o1$4, t1, s1$3); + rev_dir(o2$5, t2$2, s2$3); + return [ + undefined, + undefined + ]; + } + + } + } + switch (exit$2) { + case 1 : + dec_health(o1$4); + dec_health(o2$5); + return [ + undefined, + undefined + ]; + case 2 : + if (o1$4.vel.x === 0) { + rev_dir(o2$5, t2$2, s2$3); + return [ + undefined, + undefined + ]; + } else { + dec_health(o2$5); + return [ + undefined, + undefined + ]; + } + case 3 : + if (o2$5.vel.x === 0) { + rev_dir(o1$4, t1, s1$3); + return [ + undefined, + undefined + ]; + } else { + dec_health(o1$4); + return [ + undefined, + undefined + ]; + } + } + case "Item" : + return [ + undefined, + undefined + ]; + case "Block" : + let o2$6 = c2._2; + let t2$3 = c2._0; + let exit$4 = 0; + switch (dir) { + case "North" : + case "South" : + collide_block(undefined, dir, o1$4); + return [ + undefined, + undefined + ]; + case "East" : + case "West" : + exit$4 = 4; + break; + } + if (exit$4 === 4) { + let exit$5 = 0; + let typ$2; + switch (t1) { + case "GKoopaShell" : + if (typeof t2$3 !== "object") { + if (t2$3 === "Brick") { + dec_health(o2$6); + reverse_left_right(o1$4); + return [ + undefined, + undefined + ]; + } + exit$5 = 5; + } else { + typ$2 = t2$3._0; + exit$5 = 6; + } + break; + case "RKoopaShell" : + if (typeof t2$3 !== "object") { + if (t2$3 === "Brick") { + dec_health(o2$6); + reverse_left_right(o1$4); + return [ + undefined, + undefined + ]; + } + exit$5 = 5; + } else { + typ$2 = t2$3._0; + exit$5 = 6; + } + break; + default: + exit$5 = 5; + } + switch (exit$5) { + case 5 : + rev_dir(o1$4, t1, s1$3); + return [ + undefined, + undefined + ]; + case 6 : + let updated_block$1 = evolve_block(o2$6, context); + let spawned_item$1 = spawn_above(o1$4.dir, o2$6, typ$2, context); + rev_dir(o1$4, t1, s1$3); + return [ + updated_block$1, + spawned_item$1 + ]; + } + } + break; + } + break; + case "Item" : + let o2$7 = c1._2; + switch (c2.TAG) { + case "Player" : + o1$2 = c2._2; + t2$1 = c1._0; + o2$2 = o2$7; + exit = 3; + break; + case "Enemy" : + case "Item" : + return [ + undefined, + undefined + ]; + case "Block" : + switch (dir) { + case "North" : + case "South" : + collide_block(undefined, dir, o2$7); + return [ + undefined, + undefined + ]; + case "East" : + case "West" : + reverse_left_right(o2$7); + return [ + undefined, + undefined + ]; + } + } + break; + case "Block" : + return [ + undefined, + undefined + ]; + } + switch (exit) { + case 1 : + o1.invuln = 10; + o1.jumping = false; + o1.grounded = true; + switch (typ) { + case "GKoopaShell" : + case "RKoopaShell" : + break; + default: + dec_health(o2); + o1.vel.y = - 4; + if (state.multiplier === 8) { + update_score(state, 800); + o2.score = 800; + return [ + undefined, + evolve_enemy(o1.dir, typ, s2, o2, context) + ]; + } + let score = Math.imul(100, state.multiplier); + update_score(state, score); + o2.score = score; + state.multiplier = (state.multiplier << 1); + return [ + undefined, + evolve_enemy(o1.dir, typ, s2, o2, context) + ]; + } + let r2 = evolve_enemy(o1.dir, typ, s2, o2, context); + o1.vel.y = - 4; + o1.pos.y = o1.pos.y - 5; + return [ + undefined, + r2 + ]; + case 2 : + switch (t2) { + case "GKoopaShell" : + case "RKoopaShell" : + break; + default: + dec_health(o1$1); + o1$1.invuln = 60; + return [ + undefined, + undefined + ]; + } + let r2$1 = o2$1.vel.x === 0 ? evolve_enemy(o1$1.dir, t2, s2$1, o2$1, context) : (dec_health(o1$1), o1$1.invuln = 60, undefined); + return [ + undefined, + r2$1 + ]; + case 3 : + let exit$6 = 0; + switch (t2$1) { + case "Mushroom" : + dec_health(o2$2); + if (o1$2.health === 2) { + + } else { + o1$2.health = o1$2.health + 1 | 0; + } + o1$2.vel.x = 0; + o1$2.vel.y = 0; + update_score(state, 1000); + o2$2.score = 1000; + return [ + undefined, + undefined + ]; + case "FireFlower" : + case "Star" : + exit$6 = 4; + break; + case "Coin" : + state.coins = state.coins + 1 | 0; + dec_health(o2$2); + update_score(state, 100); + return [ + undefined, + undefined + ]; + } + if (exit$6 === 4) { + dec_health(o2$2); + update_score(state, 1000); + return [ + undefined, + undefined + ]; + } + break; + } +} + +function broad_phase(collid, all_collids, state) { + let obj = collid._2; + return Belt_List.filter(all_collids, c => { + if (in_viewport(state.vpt, obj.pos) || is_player(collid)) { + return true; + } else { + return out_of_viewport_below(state.vpt, obj.pos.y); + } + }); +} + +function check_collisions(collid, all_collids, state) { + if (collid.TAG === "Block") { + return /* [] */0; + } + let broad = broad_phase(collid, all_collids, state); + let _cs = broad; + let _acc = /* [] */0; + while (true) { + let acc = _acc; + let cs = _cs; + if (!cs) { + return acc; + } + let h = cs.hd; + let c_obj = collid._2; + let new_objs; + if (equals(collid, h)) { + new_objs = [ + undefined, + undefined + ]; + } else { + let dir = check_collision(collid, h); + new_objs = dir !== undefined && h._2.id !== c_obj.id ? process_collision(dir, collid, h, state) : [ + undefined, + undefined + ]; + } + let o = new_objs[0]; + let acc$1; + if (o !== undefined) { + let o2 = new_objs[1]; + acc$1 = o2 !== undefined ? ({ + hd: o, + tl: { + hd: o2, + tl: acc + } + }) : ({ + hd: o, + tl: acc + }); + } else { + let o$1 = new_objs[1]; + acc$1 = o$1 !== undefined ? ({ + hd: o$1, + tl: acc + }) : acc; + } + _acc = acc$1; + _cs = cs.tl; + continue; + }; +} + +function update_collidable(state, collid, all_collids) { + let obj = collid._2; + let spr = collid._1; + obj.invuln = obj.invuln > 0 ? obj.invuln - 1 | 0 : 0; + let viewport_filter = in_viewport(state.vpt, obj.pos) || is_player(collid) || out_of_viewport_below(state.vpt, obj.pos.y); + if (!(!obj.kill && viewport_filter)) { + return /* [] */0; + } + obj.grounded = false; + process_obj(obj, state.map); + let evolved = check_collisions(collid, all_collids, state); + let vpt_adj_xy = coord_to_viewport(state.vpt, obj.pos); + render(spr, [ + vpt_adj_xy.x, + vpt_adj_xy.y + ]); + if (pressed_keys.bbox === 1) { + render_bbox(spr, [ + vpt_adj_xy.x, + vpt_adj_xy.y + ]); + } + if (obj.vel.x !== 0 || !is_enemy(collid)) { + update_animation(spr); + } + return evolved; +} + +function translate_keys() { + let ctrls_0 = [ + pressed_keys.left, + "CLeft" + ]; + let ctrls_1 = { + hd: [ + pressed_keys.right, + "CRight" + ], + tl: { + hd: [ + pressed_keys.up, + "CUp" + ], + tl: { + hd: [ + pressed_keys.down, + "CDown" + ], + tl: /* [] */0 + } + } + }; + let ctrls = { + hd: ctrls_0, + tl: ctrls_1 + }; + return Belt_List.reduceReverse(ctrls, /* [] */0, (a, x) => { + if (x[0]) { + return { + hd: x[1], + tl: a + }; + } else { + return a; + } + }); +} + +function run_update_collid(state, collid, all_collids) { + if (collid.TAG === "Player") { + let o = collid._2; + let keys = translate_keys(); + o.crouch = false; + let match = update_player(o, keys, state.ctx); + let player; + if (match !== undefined) { + let new_spr = match[1]; + normalize_pos(o.pos, collid._1.params, new_spr.params); + player = { + TAG: "Player", + _0: match[0], + _1: new_spr, + _2: o + }; + } else { + player = collid; + } + let evolved = update_collidable(state, player, all_collids); + collid_objs.contents = Pervasives.$at(collid_objs.contents, evolved); + return player; + } + let obj = collid._2; + let evolved$1 = update_collidable(state, collid, all_collids); + if (!obj.kill) { + collid_objs.contents = { + hd: collid, + tl: Pervasives.$at(collid_objs.contents, evolved$1) + }; + } + let new_parts = obj.kill ? kill(collid, state.ctx) : /* [] */0; + particles.contents = Pervasives.$at(particles.contents, new_parts); + return collid; +} + +function update_loop(canvas, param, map_dim) { + let player = param[0]; + let ctx = canvas.getContext("2d"); + let cwidth = canvas.width / 1; + let cheight = canvas.height / 1; + let viewport = make$3([ + cwidth, + cheight + ], map_dim); + let state = { + bgd: make_bgd(ctx), + ctx: ctx, + vpt: update(viewport, player._2.pos), + map: map_dim[1], + score: 0, + coins: 0, + multiplier: 1, + game_over: false + }; + state.ctx.scale(1, 1); + let update_helper = (time, state, player, objs, parts) => { + if (state.game_over === true) { + return game_win(state.ctx); + } + collid_objs.contents = /* [] */0; + particles.contents = /* [] */0; + let fps$1 = calc_fps(last_time.contents, time); + last_time.contents = time; + clear_canvas(canvas); + let vpos_x_int = state.vpt.pos.x / 5 | 0; + let bgd_width = state.bgd.params.frame_size[0] | 0; + draw_bgd(state.bgd, Primitive_int.mod_(vpos_x_int, bgd_width)); + let player$1 = run_update_collid(state, player, objs); + if (player$1._2.kill === true) { + return game_loss(state.ctx); + } + let state$1 = { + bgd: state.bgd, + ctx: state.ctx, + vpt: update(state.vpt, player$1._2.pos), + map: state.map, + score: state.score, + coins: state.coins, + multiplier: state.multiplier, + game_over: state.game_over + }; + Belt_List.forEach(objs, obj => { + run_update_collid(state$1, obj, objs); + }); + Belt_List.forEach(parts, part => { + process(part); + let x = part.pos.x - state$1.vpt.pos.x; + let y = part.pos.y - state$1.vpt.pos.y; + render(part.params.sprite, [ + x, + y + ]); + if (!part.kill) { + particles.contents = { + hd: part, + tl: particles.contents + }; + return; + } + + }); + fps(canvas, fps$1); + hud(canvas, state$1.score, state$1.coins); + requestAnimationFrame(t => update_helper(t, state$1, player$1, collid_objs.contents, particles.contents)); + }; + update_helper(0, state, player, param[1], /* [] */0); +} + +function keydown(evt) { + let match = evt.keyCode; + if (match >= 41) { + switch (match) { + case 65 : + pressed_keys.left = true; + break; + case 66 : + pressed_keys.bbox = (pressed_keys.bbox + 1 | 0) % 2; + break; + case 68 : + pressed_keys.right = true; + break; + case 83 : + pressed_keys.down = true; + break; + case 87 : + pressed_keys.up = true; + break; + } + } else if (match >= 32) { + switch (match) { + case 33 : + case 34 : + case 35 : + case 36 : + break; + case 37 : + pressed_keys.left = true; + break; + case 32 : + case 38 : + pressed_keys.up = true; + break; + case 39 : + pressed_keys.right = true; + break; + case 40 : + pressed_keys.down = true; + break; + } + } + return true; +} + +function keyup(evt) { + let match = evt.keyCode; + if (match >= 68) { + if (match !== 83) { + if (match !== 87) { + if (match >= 69) { + + } else { + pressed_keys.right = false; + } + } else { + pressed_keys.up = false; + } + } else { + pressed_keys.down = false; + } + } else if (match >= 41) { + if (match !== 65) { + + } else { + pressed_keys.left = false; + } + } else if (match >= 32) { + switch (match) { + case 33 : + case 34 : + case 35 : + case 36 : + break; + case 37 : + pressed_keys.left = false; + break; + case 32 : + case 38 : + pressed_keys.up = false; + break; + case 39 : + pressed_keys.right = false; + break; + case 40 : + pressed_keys.down = false; + break; + } + } + return true; +} + +let Director = { + update_loop: update_loop, + keydown: keydown, + keyup: keyup +}; + +function mem_loc(checkloc, _loclist) { + while (true) { + let loclist = _loclist; + if (!loclist) { + return false; + } + if (Primitive_object.equal(checkloc, loclist.hd[1])) { + return true; + } + _loclist = loclist.tl; + continue; + }; +} + +function convert_list(lst) { + if (!lst) { + return /* [] */0; + } + let h = lst.hd; + return Pervasives.$at({ + hd: [ + h[0], + [ + h[1][0] * 16, + h[1][1] * 16 + ] + ], + tl: /* [] */0 + }, convert_list(lst.tl)); +} + +function choose_enemy_typ(typ) { + switch (typ) { + case 0 : + return "RKoopa"; + case 1 : + return "GKoopa"; + case 2 : + return "Goomba"; + default: + return Pervasives.failwith("Shouldn't reach here"); + } +} + +function choose_sblock_typ(typ) { + switch (typ) { + case 0 : + return "Brick"; + case 1 : + return "UnBBlock"; + case 2 : + return "Cloud"; + case 3 : + return { + TAG: "QBlock", + _0: "Mushroom" + }; + case 4 : + return "Ground"; + default: + return Pervasives.failwith("Shouldn't reach here"); + } +} + +function avoid_overlap(_lst, currentLst) { + while (true) { + let lst = _lst; + if (!lst) { + return /* [] */0; + } + let t = lst.tl; + let h = lst.hd; + if (!mem_loc(h[1], currentLst)) { + return Pervasives.$at({ + hd: h, + tl: /* [] */0 + }, avoid_overlap(t, currentLst)); + } + _lst = t; + continue; + }; +} + +function trim_edges(_lst, blockw, blockh) { + while (true) { + let lst = _lst; + if (!lst) { + return /* [] */0; + } + let t = lst.tl; + let h = lst.hd; + let cx = h[1][0]; + let cy = h[1][1]; + let pixx = blockw * 16; + let pixy = blockh * 16; + if (!(cx < 128 || pixx - cx < 528 || cy === 0 || pixy - cy < 48)) { + return Pervasives.$at({ + hd: h, + tl: /* [] */0 + }, trim_edges(t, blockw, blockh)); + } + _lst = t; + continue; + }; +} + +function generate_clouds(cbx, cby, typ, num) { + if (num === 0) { + return /* [] */0; + } else { + return Pervasives.$at({ + hd: [ + typ, + [ + cbx, + cby + ] + ], + tl: /* [] */0 + }, generate_clouds(cbx + 1, cby, typ, num - 1 | 0)); + } +} + +function generate_coins(_block_coord) { + while (true) { + let block_coord = _block_coord; + let place_coin = int(2); + if (!block_coord) { + return /* [] */0; + } + let t = block_coord.tl; + let h = block_coord.hd; + if (place_coin === 0) { + let xc = h[1][0]; + let yc = h[1][1]; + return Pervasives.$at({ + hd: [ + 0, + [ + xc, + yc - 16 + ] + ], + tl: /* [] */0 + }, generate_coins(t)); + } + _block_coord = t; + continue; + }; +} + +function choose_block_pattern(blockw, blockh, cbx, cby, prob) { + if (cbx > blockw || cby > blockh) { + return /* [] */0; + } + let block_typ = int(4); + let stair_typ = int(2); + let life_block_chance = int(5); + let middle_block = life_block_chance === 0 ? 3 : stair_typ; + switch (prob) { + case 0 : + if (blockw - cbx > 2) { + return { + hd: [ + stair_typ, + [ + cbx, + cby + ] + ], + tl: { + hd: [ + middle_block, + [ + cbx + 1, + cby + ] + ], + tl: { + hd: [ + stair_typ, + [ + cbx + 2, + cby + ] + ], + tl: /* [] */0 + } + } + }; + } else if (blockw - cbx > 1) { + return { + hd: [ + block_typ, + [ + cbx, + cby + ] + ], + tl: { + hd: [ + block_typ, + [ + cbx + 1, + cby + ] + ], + tl: /* [] */0 + } + }; + } else { + return { + hd: [ + block_typ, + [ + cbx, + cby + ] + ], + tl: /* [] */0 + }; + } + case 1 : + let num_clouds = int(5) + 5 | 0; + if (cby < 5) { + return generate_clouds(cbx, cby, 2, num_clouds); + } else { + return /* [] */0; + } + case 2 : + if (blockh - cby === 1) { + let four_0 = [ + stair_typ, + [ + cbx, + cby + ] + ]; + let four_1 = { + hd: [ + stair_typ, + [ + cbx + 1, + cby + ] + ], + tl: { + hd: [ + stair_typ, + [ + cbx + 2, + cby + ] + ], + tl: { + hd: [ + stair_typ, + [ + cbx + 3, + cby + ] + ], + tl: /* [] */0 + } + } + }; + let four = { + hd: four_0, + tl: four_1 + }; + let three_0 = [ + stair_typ, + [ + cbx + 1, + cby - 1 + ] + ]; + let three_1 = { + hd: [ + stair_typ, + [ + cbx + 2, + cby - 1 + ] + ], + tl: { + hd: [ + stair_typ, + [ + cbx + 3, + cby - 1 + ] + ], + tl: /* [] */0 + } + }; + let three = { + hd: three_0, + tl: three_1 + }; + let two_0 = [ + stair_typ, + [ + cbx + 2, + cby - 2 + ] + ]; + let two_1 = { + hd: [ + stair_typ, + [ + cbx + 3, + cby - 2 + ] + ], + tl: /* [] */0 + }; + let two = { + hd: two_0, + tl: two_1 + }; + let one_0 = [ + stair_typ, + [ + cbx + 3, + cby - 3 + ] + ]; + let one = { + hd: one_0, + tl: /* [] */0 + }; + return Pervasives.$at(four, Pervasives.$at(three, Pervasives.$at(two, one))); + } else { + return /* [] */0; + } + case 3 : + if (stair_typ === 0 && blockh - cby > 3) { + let three_0$1 = [ + stair_typ, + [ + cbx, + cby + ] + ]; + let three_1$1 = { + hd: [ + stair_typ, + [ + cbx + 1, + cby + ] + ], + tl: { + hd: [ + stair_typ, + [ + cbx + 2, + cby + ] + ], + tl: /* [] */0 + } + }; + let three$1 = { + hd: three_0$1, + tl: three_1$1 + }; + let two_0$1 = [ + stair_typ, + [ + cbx + 2, + cby + 1 + ] + ]; + let two_1$1 = { + hd: [ + stair_typ, + [ + cbx + 3, + cby + 1 + ] + ], + tl: /* [] */0 + }; + let two$1 = { + hd: two_0$1, + tl: two_1$1 + }; + let one_0$1 = [ + stair_typ, + [ + cbx + 5, + cby + 2 + ] + ]; + let one_1 = { + hd: [ + stair_typ, + [ + cbx + 6, + cby + 2 + ] + ], + tl: /* [] */0 + }; + let one$1 = { + hd: one_0$1, + tl: one_1 + }; + return Pervasives.$at(three$1, Pervasives.$at(two$1, one$1)); + } else if (blockh - cby > 2) { + let one_0$2 = [ + stair_typ, + [ + cbx, + cby + ] + ]; + let one_1$1 = { + hd: [ + stair_typ, + [ + cbx + 1, + cby + ] + ], + tl: /* [] */0 + }; + let one$2 = { + hd: one_0$2, + tl: one_1$1 + }; + let two_0$2 = [ + stair_typ, + [ + cbx + 3, + cby - 1 + ] + ]; + let two_1$2 = { + hd: [ + stair_typ, + [ + cbx + 4, + cby - 1 + ] + ], + tl: /* [] */0 + }; + let two$2 = { + hd: two_0$2, + tl: two_1$2 + }; + let three_0$2 = [ + stair_typ, + [ + cbx + 4, + cby - 2 + ] + ]; + let three_1$2 = { + hd: [ + stair_typ, + [ + cbx + 5, + cby - 2 + ] + ], + tl: { + hd: [ + stair_typ, + [ + cbx + 6, + cby - 2 + ] + ], + tl: /* [] */0 + } + }; + let three$2 = { + hd: three_0$2, + tl: three_1$2 + }; + return Pervasives.$at(one$2, Pervasives.$at(two$2, three$2)); + } else { + return { + hd: [ + stair_typ, + [ + cbx, + cby + ] + ], + tl: /* [] */0 + }; + } + case 4 : + if (cby + 3 - blockh === 2) { + return { + hd: [ + stair_typ, + [ + cbx, + cby + ] + ], + tl: /* [] */0 + }; + } else if (cby + 3 - blockh === 1) { + return { + hd: [ + stair_typ, + [ + cbx, + cby + ] + ], + tl: { + hd: [ + stair_typ, + [ + cbx, + cby + 1 + ] + ], + tl: /* [] */0 + } + }; + } else { + return { + hd: [ + stair_typ, + [ + cbx, + cby + ] + ], + tl: { + hd: [ + stair_typ, + [ + cbx, + cby + 1 + ] + ], + tl: { + hd: [ + stair_typ, + [ + cbx, + cby + 2 + ] + ], + tl: /* [] */0 + } + } + }; + } + case 5 : + return { + hd: [ + 3, + [ + cbx, + cby + ] + ], + tl: /* [] */0 + }; + default: + return Pervasives.failwith("Shouldn't reach here"); + } +} + +function generate_enemies(blockw, blockh, _cbx, _cby, acc) { + while (true) { + let cby = _cby; + let cbx = _cbx; + if (cbx > blockw - 32) { + return /* [] */0; + } + if (cby > blockh - 1 || cbx < 15) { + _cby = 0; + _cbx = cbx + 1; + continue; + } + if (mem_loc([ + cbx, + cby + ], acc) || cby === 0) { + _cby = cby + 1; + continue; + } + let prob = int(30); + if (prob < 3 && blockh - 1 === cby) { + let enemy_0 = [ + prob, + [ + cbx * 16, + cby * 16 + ] + ]; + let enemy = { + hd: enemy_0, + tl: /* [] */0 + }; + return Pervasives.$at(enemy, generate_enemies(blockw, blockh, cbx, cby + 1, acc)); + } + _cby = cby + 1; + continue; + }; +} + +function generate_block_enemies(_block_coord) { + while (true) { + let block_coord = _block_coord; + let place_enemy = int(20); + let enemy_typ = int(3); + if (!block_coord) { + return /* [] */0; + } + let t = block_coord.tl; + let h = block_coord.hd; + if (place_enemy === 0) { + let xc = h[1][0]; + let yc = h[1][1]; + return Pervasives.$at({ + hd: [ + enemy_typ, + [ + xc, + yc - 16 + ] + ], + tl: /* [] */0 + }, generate_block_enemies(t)); + } + _block_coord = t; + continue; + }; +} + +function generate_block_locs(blockw, blockh, _cbx, _cby, _acc) { + while (true) { + let acc = _acc; + let cby = _cby; + let cbx = _cbx; + if (blockw - cbx < 33) { + return acc; + } + if (cby > blockh - 1) { + _cby = 0; + _cbx = cbx + 1; + continue; + } + if (mem_loc([ + cbx, + cby + ], acc) || cby === 0) { + _cby = cby + 1; + continue; + } + let prob = int(100); + if (prob < 5) { + let newacc = choose_block_pattern(blockw, blockh, cbx, cby, prob); + let undup_lst = avoid_overlap(newacc, acc); + let called_acc = Pervasives.$at(acc, undup_lst); + _acc = called_acc; + _cby = cby + 1; + continue; + } + _cby = cby + 1; + continue; + }; +} + +function generate_panel(context, blockw, blockh) { + return spawn({ + TAG: "SBlock", + _0: "Panel" + }, context, [ + blockw * 16 - 256, + blockh * 16 * 2 / 3 + ]); +} + +function generate_ground(blockw, blockh, _inc, _acc) { + while (true) { + let acc = _acc; + let inc = _inc; + if (inc > blockw) { + return acc; + } + if (inc > 10) { + let skip = int(10); + let newacc = Pervasives.$at(acc, { + hd: [ + 4, + [ + inc * 16, + blockh * 16 + ] + ], + tl: /* [] */0 + }); + if (skip === 7 && blockw - inc > 32) { + _inc = inc + 1; + continue; + } + _acc = newacc; + _inc = inc + 1; + continue; + } + let newacc$1 = Pervasives.$at(acc, { + hd: [ + 4, + [ + inc * 16, + blockh * 16 + ] + ], + tl: /* [] */0 + }); + _acc = newacc$1; + _inc = inc + 1; + continue; + }; +} + +function convert_to_block_obj(lst, context) { + if (!lst) { + return /* [] */0; + } + let h = lst.hd; + let sblock_typ = choose_sblock_typ(h[0]); + let ob = spawn({ + TAG: "SBlock", + _0: sblock_typ + }, context, h[1]); + return Pervasives.$at({ + hd: ob, + tl: /* [] */0 + }, convert_to_block_obj(lst.tl, context)); +} + +function convert_to_enemy_obj(lst, context) { + if (!lst) { + return /* [] */0; + } + let h = lst.hd; + let senemy_typ = choose_enemy_typ(h[0]); + let ob = spawn({ + TAG: "SEnemy", + _0: senemy_typ + }, context, h[1]); + return Pervasives.$at({ + hd: ob, + tl: /* [] */0 + }, convert_to_enemy_obj(lst.tl, context)); +} + +function convert_to_coin_obj(lst, context) { + if (!lst) { + return /* [] */0; + } + let ob = spawn({ + TAG: "SItem", + _0: "Coin" + }, context, lst.hd[1]); + return Pervasives.$at({ + hd: ob, + tl: /* [] */0 + }, convert_to_coin_obj(lst.tl, context)); +} + +function generate_helper(blockw, blockh, cx, cy, context) { + let block_locs = generate_block_locs(blockw, blockh, 0, 0, /* [] */0); + let converted_block_locs = trim_edges(convert_list(block_locs), blockw, blockh); + let obj_converted_block_locs = convert_to_block_obj(converted_block_locs, context); + let ground_blocks = generate_ground(blockw, blockh, 0, /* [] */0); + let obj_converted_ground_blocks = convert_to_block_obj(ground_blocks, context); + let block_locations = Pervasives.$at(block_locs, ground_blocks); + let all_blocks = Pervasives.$at(obj_converted_block_locs, obj_converted_ground_blocks); + let enemy_locs = generate_enemies(blockw, blockh, 0, 0, block_locations); + let obj_converted_enemies = convert_to_enemy_obj(enemy_locs, context); + let coin_locs = generate_coins(converted_block_locs); + let undup_coin_locs = trim_edges(avoid_overlap(coin_locs, converted_block_locs), blockw, blockh); + let converted_block_coin_locs = Pervasives.$at(converted_block_locs, coin_locs); + let enemy_block_locs = generate_block_enemies(converted_block_locs); + let undup_enemy_block_locs = avoid_overlap(enemy_block_locs, converted_block_coin_locs); + let obj_enemy_blocks = convert_to_enemy_obj(undup_enemy_block_locs, context); + let coin_objects = convert_to_coin_obj(undup_coin_locs, context); + let obj_panel = generate_panel(context, blockw, blockh); + return Pervasives.$at(all_blocks, Pervasives.$at(obj_converted_enemies, Pervasives.$at(coin_objects, Pervasives.$at(obj_enemy_blocks, { + hd: obj_panel, + tl: /* [] */0 + })))); +} + +function generate(w, h, context) { + let blockw = w / 16; + let blockh = h / 16 - 1; + let collide_list = generate_helper(blockw, blockh, 0, 0, context); + let player = spawn({ + TAG: "SPlayer", + _0: "SmallM", + _1: "Standing" + }, context, [ + 100, + 224 + ]); + return [ + player, + collide_list + ]; +} + +function init() { + +} + +let Procedural_generator = { + init: init, + generate: generate +}; + +let loadCount = { + contents: 0 +}; + +function load(param) { + let canvas_id = "canvas"; + let el = document.getElementById(canvas_id); + let canvas = el !== null ? el : (console.log("cant find canvas " + canvas_id), Pervasives.failwith("fail")); + let context = canvas.getContext("2d"); + document.addEventListener("keydown", keydown, true); + document.addEventListener("keyup", keyup, true); + update_loop(canvas, generate(2400, 256, context), [ + 2400, + 256 + ]); + console.log("asd"); +} + +function inc_counter(param) { + loadCount.contents = loadCount.contents + 1 | 0; + if (loadCount.contents === 4) { + return load(); + } + +} + +function preload(param) { + return Belt_List.map({ + hd: "blocks.png", + tl: { + hd: "items.png", + tl: { + hd: "enemies.png", + tl: { + hd: "mario-small.png", + tl: /* [] */0 + } + } + } + }, img_src => { + let img_src$1 = "sprites/" + img_src; + let img = document.createElement("img"); + img.src = img_src$1; + img.addEventListener("load", ev => { + inc_counter(); + return true; + }, true); + }); +} + +window.onload = param => { + preload(); + return true; +}; + +let Main = { + Html: undefined, + Pg: undefined, + loadCount: loadCount, + imgsToLoad: 4, + level_width: 2400, + level_height: 256, + load: load, + inc_counter: inc_counter, + preload: preload +}; + +export { + Random, + Actors, + Dom_html, + Sprite, + Particle, + $$Object, + Draw, + Viewport, + Director, + Procedural_generator, + Main, +} +/* Not a pure module */ diff --git a/tests/tests/src/meth_annotation.js b/tests/tests/src/meth_annotation.js deleted file mode 100644 index 3471959ac4..0000000000 --- a/tests/tests/src/meth_annotation.js +++ /dev/null @@ -1,7 +0,0 @@ -// Generated by ReScript, PLEASE EDIT WITH CARE -'use strict'; - - -john.say("hey", "jude"); - -/* Not a pure module */ diff --git a/tests/tests/src/meth_annotation.mjs b/tests/tests/src/meth_annotation.mjs new file mode 100644 index 0000000000..6278885f42 --- /dev/null +++ b/tests/tests/src/meth_annotation.mjs @@ -0,0 +1,6 @@ +// Generated by ReScript, PLEASE EDIT WITH CARE + + +john.say("hey", "jude"); + +/* Not a pure module */ diff --git a/tests/tests/src/method_name_test.js b/tests/tests/src/method_name_test.js deleted file mode 100644 index 3d9d32b3c4..0000000000 --- a/tests/tests/src/method_name_test.js +++ /dev/null @@ -1,69 +0,0 @@ -// Generated by ReScript, PLEASE EDIT WITH CARE -'use strict'; - -let Mt = require("./mt.js"); - -let suites = { - contents: /* [] */0 -}; - -let test_id = { - contents: 0 -}; - -function eq(loc, x, y) { - test_id.contents = test_id.contents + 1 | 0; - suites.contents = { - hd: [ - loc + (" id " + test_id.contents.toString()), - () => ({ - TAG: "Eq", - _0: x, - _1: y - }) - ], - tl: suites.contents - }; -} - -function f(x, i, file, v) { - x.case(i); - x.case__set(i, v); - x._open(file); - x.open__(file); - return x._MAX_LENGTH; -} - -function ff(x, i, v) { - x.make__config = v; - x.make_config = v; - x.case__unsafe(i); - return x._open__(3); -} - -let u = { - "_Content'type": "x" -}; - -let h = { - _open: 3, - _end: 32 -}; - -function hg(x) { - return x._open + x._end | 0; -} - -eq("File \"method_name_test.res\", line 42, characters 12-19", 35, hg(h)); - -Mt.from_pair_suites("Method_name_test", suites.contents); - -exports.suites = suites; -exports.test_id = test_id; -exports.eq = eq; -exports.f = f; -exports.ff = ff; -exports.u = u; -exports.h = h; -exports.hg = hg; -/* Not a pure module */ diff --git a/tests/tests/src/method_name_test.mjs b/tests/tests/src/method_name_test.mjs new file mode 100644 index 0000000000..bf27ef95db --- /dev/null +++ b/tests/tests/src/method_name_test.mjs @@ -0,0 +1,70 @@ +// Generated by ReScript, PLEASE EDIT WITH CARE + +import * as Mt from "./mt.mjs"; + +let suites = { + contents: /* [] */0 +}; + +let test_id = { + contents: 0 +}; + +function eq(loc, x, y) { + test_id.contents = test_id.contents + 1 | 0; + suites.contents = { + hd: [ + loc + (" id " + test_id.contents.toString()), + () => ({ + TAG: "Eq", + _0: x, + _1: y + }) + ], + tl: suites.contents + }; +} + +function f(x, i, file, v) { + x.case(i); + x.case__set(i, v); + x._open(file); + x.open__(file); + return x._MAX_LENGTH; +} + +function ff(x, i, v) { + x.make__config = v; + x.make_config = v; + x.case__unsafe(i); + return x._open__(3); +} + +let u = { + "_Content'type": "x" +}; + +let h = { + _open: 3, + _end: 32 +}; + +function hg(x) { + return x._open + x._end | 0; +} + +eq("File \"method_name_test.res\", line 42, characters 12-19", 35, hg(h)); + +Mt.from_pair_suites("Method_name_test", suites.contents); + +export { + suites, + test_id, + eq, + f, + ff, + u, + h, + hg, +} +/* Not a pure module */ diff --git a/tests/tests/src/method_string_name.js b/tests/tests/src/method_string_name.js deleted file mode 100644 index 96e725df69..0000000000 --- a/tests/tests/src/method_string_name.js +++ /dev/null @@ -1,20 +0,0 @@ -// Generated by ReScript, PLEASE EDIT WITH CARE -'use strict'; - - -let f = { - "Content-Type": 3 -}; - -console.log(f["Content-Type"]); - -function ff(x) { - x["Content-Type"] = "hello"; - console.log(({ - "Content-Type": "hello" - })["Content-Type"]); -} - -exports.f = f; -exports.ff = ff; -/* Not a pure module */ diff --git a/tests/tests/src/method_string_name.mjs b/tests/tests/src/method_string_name.mjs new file mode 100644 index 0000000000..2a5bebdfc7 --- /dev/null +++ b/tests/tests/src/method_string_name.mjs @@ -0,0 +1,21 @@ +// Generated by ReScript, PLEASE EDIT WITH CARE + + +let f = { + "Content-Type": 3 +}; + +console.log(f["Content-Type"]); + +function ff(x) { + x["Content-Type"] = "hello"; + console.log(({ + "Content-Type": "hello" + })["Content-Type"]); +} + +export { + f, + ff, +} +/* Not a pure module */ diff --git a/tests/tests/src/minimal_test.js b/tests/tests/src/minimal_test.js deleted file mode 100644 index ed66ae46d2..0000000000 --- a/tests/tests/src/minimal_test.js +++ /dev/null @@ -1,20 +0,0 @@ -// Generated by ReScript, PLEASE EDIT WITH CARE -'use strict'; - - -let fake_y = { - hd: 2, - tl: { - hd: 3, - tl: /* [] */0 - } -}; - -let fake_z = { - hd: 1, - tl: fake_y -}; - -exports.fake_y = fake_y; -exports.fake_z = fake_z; -/* No side effect */ diff --git a/tests/tests/src/minimal_test.mjs b/tests/tests/src/minimal_test.mjs new file mode 100644 index 0000000000..f88602eb73 --- /dev/null +++ b/tests/tests/src/minimal_test.mjs @@ -0,0 +1,21 @@ +// Generated by ReScript, PLEASE EDIT WITH CARE + + +let fake_y = { + hd: 2, + tl: { + hd: 3, + tl: /* [] */0 + } +}; + +let fake_z = { + hd: 1, + tl: fake_y +}; + +export { + fake_y, + fake_z, +} +/* No side effect */ diff --git a/tests/tests/src/miss_colon_test.js b/tests/tests/src/miss_colon_test.js deleted file mode 100644 index 00fe9286d4..0000000000 --- a/tests/tests/src/miss_colon_test.js +++ /dev/null @@ -1,129 +0,0 @@ -// Generated by ReScript, PLEASE EDIT WITH CARE -'use strict'; - - -function $plus$colon(_f, _g) { - while (true) { - let g = _g; - let f = _f; - if (f.TAG === "Int") { - let n = f._0; - if (g.TAG === "Int") { - return { - TAG: "Int", - _0: n + g._0 | 0 - }; - } - if (n === 0) { - return g; - } - - } - switch (g.TAG) { - case "Int" : - if (g._0 !== 0) { - return { - TAG: "Add", - _0: f, - _1: g - }; - } else { - return f; - } - case "Add" : - _g = g._1; - _f = $plus$colon(f, g._0); - continue; - case "Var" : - case "Mul" : - return { - TAG: "Add", - _0: f, - _1: g - }; - } - }; -} - -function $star$colon(_f, _g) { - while (true) { - let g = _g; - let f = _f; - let exit = 0; - let exit$1 = 0; - if (f.TAG === "Int") { - let n = f._0; - if (g.TAG === "Int") { - return { - TAG: "Int", - _0: Math.imul(n, g._0) - }; - } - if (n === 0) { - return { - TAG: "Int", - _0: 0 - }; - } - exit$1 = 3; - } else { - exit$1 = 3; - } - if (exit$1 === 3) { - if (g.TAG === "Int") { - if (g._0 === 0) { - return { - TAG: "Int", - _0: 0 - }; - } - exit = 2; - } else { - exit = 2; - } - } - if (exit === 2 && f.TAG === "Int" && f._0 === 1) { - return g; - } - switch (g.TAG) { - case "Int" : - if (g._0 !== 1) { - return { - TAG: "Mul", - _0: f, - _1: g - }; - } else { - return f; - } - case "Var" : - case "Add" : - return { - TAG: "Mul", - _0: f, - _1: g - }; - case "Mul" : - _g = g._1; - _f = $star$colon(f, g._0); - continue; - } - }; -} - -function simplify(x) { - switch (x.TAG) { - case "Int" : - case "Var" : - return x; - case "Add" : - return $plus$colon(simplify(x._0), simplify(x._1)); - case "Mul" : - return $star$colon(simplify(x._0), simplify(x._1)); - } -} - -exports.$plus$colon = $plus$colon; -exports.$star$colon = $star$colon; -exports.simplify = simplify; -/* No side effect */ diff --git a/tests/tests/src/miss_colon_test.mjs b/tests/tests/src/miss_colon_test.mjs new file mode 100644 index 0000000000..1a96a1dd91 --- /dev/null +++ b/tests/tests/src/miss_colon_test.mjs @@ -0,0 +1,130 @@ +// Generated by ReScript, PLEASE EDIT WITH CARE + + +function $plus$colon(_f, _g) { + while (true) { + let g = _g; + let f = _f; + if (f.TAG === "Int") { + let n = f._0; + if (g.TAG === "Int") { + return { + TAG: "Int", + _0: n + g._0 | 0 + }; + } + if (n === 0) { + return g; + } + + } + switch (g.TAG) { + case "Int" : + if (g._0 !== 0) { + return { + TAG: "Add", + _0: f, + _1: g + }; + } else { + return f; + } + case "Add" : + _g = g._1; + _f = $plus$colon(f, g._0); + continue; + case "Var" : + case "Mul" : + return { + TAG: "Add", + _0: f, + _1: g + }; + } + }; +} + +function $star$colon(_f, _g) { + while (true) { + let g = _g; + let f = _f; + let exit = 0; + let exit$1 = 0; + if (f.TAG === "Int") { + let n = f._0; + if (g.TAG === "Int") { + return { + TAG: "Int", + _0: Math.imul(n, g._0) + }; + } + if (n === 0) { + return { + TAG: "Int", + _0: 0 + }; + } + exit$1 = 3; + } else { + exit$1 = 3; + } + if (exit$1 === 3) { + if (g.TAG === "Int") { + if (g._0 === 0) { + return { + TAG: "Int", + _0: 0 + }; + } + exit = 2; + } else { + exit = 2; + } + } + if (exit === 2 && f.TAG === "Int" && f._0 === 1) { + return g; + } + switch (g.TAG) { + case "Int" : + if (g._0 !== 1) { + return { + TAG: "Mul", + _0: f, + _1: g + }; + } else { + return f; + } + case "Var" : + case "Add" : + return { + TAG: "Mul", + _0: f, + _1: g + }; + case "Mul" : + _g = g._1; + _f = $star$colon(f, g._0); + continue; + } + }; +} + +function simplify(x) { + switch (x.TAG) { + case "Int" : + case "Var" : + return x; + case "Add" : + return $plus$colon(simplify(x._0), simplify(x._1)); + case "Mul" : + return $star$colon(simplify(x._0), simplify(x._1)); + } +} + +export { + $plus$colon, + $star$colon, + simplify, +} +/* No side effect */ diff --git a/tests/tests/src/mocha.js b/tests/tests/src/mocha.mjs similarity index 100% rename from tests/tests/src/mocha.js rename to tests/tests/src/mocha.mjs diff --git a/tests/tests/src/mock_mt.js b/tests/tests/src/mock_mt.js deleted file mode 100644 index eb51584f58..0000000000 --- a/tests/tests/src/mock_mt.js +++ /dev/null @@ -1,86 +0,0 @@ -// Generated by ReScript, PLEASE EDIT WITH CARE -'use strict'; - -let Belt_List = require("rescript/lib/js/Belt_List.js"); - -function from_pair_suites(name, suites) { - console.log([ - name, - "testing" - ]); - Belt_List.forEach(suites, param => { - let name = param[0]; - let fn = param[1](); - switch (fn.TAG) { - case "Eq" : - console.log([ - name, - fn._0, - "eq?", - fn._1 - ]); - return; - case "Neq" : - console.log([ - name, - fn._0, - "neq?", - fn._1 - ]); - return; - case "StrictEq" : - console.log([ - name, - fn._0, - "strict_eq?", - fn._1 - ]); - return; - case "StrictNeq" : - console.log([ - name, - fn._0, - "strict_neq?", - fn._1 - ]); - return; - case "Ok" : - console.log([ - name, - fn._0, - "ok?" - ]); - return; - case "Approx" : - console.log([ - name, - fn._0, - "~", - fn._1 - ]); - return; - case "ApproxThreshold" : - console.log([ - name, - fn._1, - "~", - fn._2, - " (", - fn._0, - ")" - ]); - return; - case "ThrowAny" : - return; - case "Fail" : - console.log("failed"); - return; - case "FailWith" : - console.log("failed: " + fn._0); - return; - } - }); -} - -exports.from_pair_suites = from_pair_suites; -/* No side effect */ diff --git a/tests/tests/src/mock_mt.mjs b/tests/tests/src/mock_mt.mjs new file mode 100644 index 0000000000..17def2e3a6 --- /dev/null +++ b/tests/tests/src/mock_mt.mjs @@ -0,0 +1,87 @@ +// Generated by ReScript, PLEASE EDIT WITH CARE + +import * as Belt_List from "rescript/lib/es6/Belt_List.js"; + +function from_pair_suites(name, suites) { + console.log([ + name, + "testing" + ]); + Belt_List.forEach(suites, param => { + let name = param[0]; + let fn = param[1](); + switch (fn.TAG) { + case "Eq" : + console.log([ + name, + fn._0, + "eq?", + fn._1 + ]); + return; + case "Neq" : + console.log([ + name, + fn._0, + "neq?", + fn._1 + ]); + return; + case "StrictEq" : + console.log([ + name, + fn._0, + "strict_eq?", + fn._1 + ]); + return; + case "StrictNeq" : + console.log([ + name, + fn._0, + "strict_neq?", + fn._1 + ]); + return; + case "Ok" : + console.log([ + name, + fn._0, + "ok?" + ]); + return; + case "Approx" : + console.log([ + name, + fn._0, + "~", + fn._1 + ]); + return; + case "ApproxThreshold" : + console.log([ + name, + fn._1, + "~", + fn._2, + " (", + fn._0, + ")" + ]); + return; + case "ThrowAny" : + return; + case "Fail" : + console.log("failed"); + return; + case "FailWith" : + console.log("failed: " + fn._0); + return; + } + }); +} + +export { + from_pair_suites, +} +/* No side effect */ diff --git a/tests/tests/src/module_alias_test.js b/tests/tests/src/module_alias_test.js deleted file mode 100644 index eac2d19e5b..0000000000 --- a/tests/tests/src/module_alias_test.js +++ /dev/null @@ -1,67 +0,0 @@ -// Generated by ReScript, PLEASE EDIT WITH CARE -'use strict'; - -let Mt = require("./mt.js"); -let Belt_List = require("rescript/lib/js/Belt_List.js"); - -let suites = { - contents: /* [] */0 -}; - -let test_id = { - contents: 0 -}; - -function eq(loc, x, y) { - test_id.contents = test_id.contents + 1 | 0; - suites.contents = { - hd: [ - loc + (" id " + test_id.contents.toString()), - () => ({ - TAG: "Eq", - _0: x, - _1: y - }) - ], - tl: suites.contents - }; -} - -function f(x) { - console.log(x); - console.log(Belt_List.length(x)); - return Belt_List; -} - -let h = f(/* [] */0); - -let a = h.length({ - hd: 1, - tl: { - hd: 2, - tl: { - hd: 3, - tl: /* [] */0 - } - } -}); - -eq("File \"module_alias_test.res\", line 35, characters 3-10", a, 3); - -Mt.from_pair_suites("Module_alias_test", suites.contents); - -let N; - -let V; - -let J; - -exports.suites = suites; -exports.test_id = test_id; -exports.eq = eq; -exports.N = N; -exports.V = V; -exports.J = J; -exports.f = f; -exports.a = a; -/* h Not a pure module */ diff --git a/tests/tests/src/module_alias_test.mjs b/tests/tests/src/module_alias_test.mjs new file mode 100644 index 0000000000..f3cf8b2972 --- /dev/null +++ b/tests/tests/src/module_alias_test.mjs @@ -0,0 +1,68 @@ +// Generated by ReScript, PLEASE EDIT WITH CARE + +import * as Mt from "./mt.mjs"; +import * as Belt_List from "rescript/lib/es6/Belt_List.js"; + +let suites = { + contents: /* [] */0 +}; + +let test_id = { + contents: 0 +}; + +function eq(loc, x, y) { + test_id.contents = test_id.contents + 1 | 0; + suites.contents = { + hd: [ + loc + (" id " + test_id.contents.toString()), + () => ({ + TAG: "Eq", + _0: x, + _1: y + }) + ], + tl: suites.contents + }; +} + +function f(x) { + console.log(x); + console.log(Belt_List.length(x)); + return Belt_List; +} + +let h = f(/* [] */0); + +let a = h.length({ + hd: 1, + tl: { + hd: 2, + tl: { + hd: 3, + tl: /* [] */0 + } + } +}); + +eq("File \"module_alias_test.res\", line 35, characters 3-10", a, 3); + +Mt.from_pair_suites("Module_alias_test", suites.contents); + +let N; + +let V; + +let J; + +export { + suites, + test_id, + eq, + N, + V, + J, + f, + a, +} +/* h Not a pure module */ diff --git a/tests/tests/src/module_as_class_ffi.js b/tests/tests/src/module_as_class_ffi.js deleted file mode 100644 index 487e85c4bc..0000000000 --- a/tests/tests/src/module_as_class_ffi.js +++ /dev/null @@ -1,16 +0,0 @@ -// Generated by ReScript, PLEASE EDIT WITH CARE -'use strict'; - -let Foo_class = require("xx/foo_class"); - -function f() { - return new Foo_class(3); -} - -function v() { - return Foo_class.ff(3); -} - -exports.f = f; -exports.v = v; -/* xx/foo_class Not a pure module */ diff --git a/tests/tests/src/module_as_class_ffi.mjs b/tests/tests/src/module_as_class_ffi.mjs new file mode 100644 index 0000000000..79d8648213 --- /dev/null +++ b/tests/tests/src/module_as_class_ffi.mjs @@ -0,0 +1,17 @@ +// Generated by ReScript, PLEASE EDIT WITH CARE + +import * as Foo_class from "xx/foo_class"; + +function f() { + return new Foo_class(3); +} + +function v() { + return Foo_class.ff(3); +} + +export { + f, + v, +} +/* xx/foo_class Not a pure module */ diff --git a/tests/tests/src/module_as_function.js b/tests/tests/src/module_as_function.js deleted file mode 100644 index 2ee8e65ede..0000000000 --- a/tests/tests/src/module_as_function.js +++ /dev/null @@ -1,11 +0,0 @@ -// Generated by ReScript, PLEASE EDIT WITH CARE -'use strict'; - -let Nightmare = require("nightmare"); - -let v = Nightmare({ - show: true -}); - -exports.v = v; -/* v Not a pure module */ diff --git a/tests/tests/src/module_as_function.mjs b/tests/tests/src/module_as_function.mjs new file mode 100644 index 0000000000..813100d42f --- /dev/null +++ b/tests/tests/src/module_as_function.mjs @@ -0,0 +1,12 @@ +// Generated by ReScript, PLEASE EDIT WITH CARE + +import * as Nightmare from "nightmare"; + +let v = Nightmare({ + show: true +}); + +export { + v, +} +/* v Not a pure module */ diff --git a/tests/tests/src/module_missing_conversion.js b/tests/tests/src/module_missing_conversion.js deleted file mode 100644 index 79576d6618..0000000000 --- a/tests/tests/src/module_missing_conversion.js +++ /dev/null @@ -1,97 +0,0 @@ -// Generated by ReScript, PLEASE EDIT WITH CARE -'use strict'; - -let $$String = require("rescript/lib/js/String.js"); -let Belt_Array = require("rescript/lib/js/Belt_Array.js"); - -function f(x) { - return x; -} - -let XX = { - get: Belt_Array.get, - getExn: Belt_Array.getExn, - set: Belt_Array.set, - setExn: Belt_Array.setExn, - shuffleInPlace: Belt_Array.shuffleInPlace, - shuffle: Belt_Array.shuffle, - reverseInPlace: Belt_Array.reverseInPlace, - reverse: Belt_Array.reverse, - make: Belt_Array.make, - range: Belt_Array.range, - rangeBy: Belt_Array.rangeBy, - makeByU: Belt_Array.makeByU, - makeBy: Belt_Array.makeBy, - makeByAndShuffleU: Belt_Array.makeByAndShuffleU, - makeByAndShuffle: Belt_Array.makeByAndShuffle, - zip: Belt_Array.zip, - zipByU: Belt_Array.zipByU, - zipBy: Belt_Array.zipBy, - unzip: Belt_Array.unzip, - concat: Belt_Array.concat, - concatMany: Belt_Array.concatMany, - slice: Belt_Array.slice, - sliceToEnd: Belt_Array.sliceToEnd, - fill: Belt_Array.fill, - blit: Belt_Array.blit, - blitUnsafe: Belt_Array.blitUnsafe, - forEachU: Belt_Array.forEachU, - forEach: Belt_Array.forEach, - mapU: Belt_Array.mapU, - map: Belt_Array.map, - flatMapU: Belt_Array.flatMapU, - flatMap: Belt_Array.flatMap, - getByU: Belt_Array.getByU, - getBy: Belt_Array.getBy, - getIndexByU: Belt_Array.getIndexByU, - getIndexBy: Belt_Array.getIndexBy, - keepU: Belt_Array.keepU, - keep: Belt_Array.keep, - keepWithIndexU: Belt_Array.keepWithIndexU, - keepWithIndex: Belt_Array.keepWithIndex, - keepMapU: Belt_Array.keepMapU, - keepMap: Belt_Array.keepMap, - forEachWithIndexU: Belt_Array.forEachWithIndexU, - forEachWithIndex: Belt_Array.forEachWithIndex, - mapWithIndexU: Belt_Array.mapWithIndexU, - mapWithIndex: Belt_Array.mapWithIndex, - partitionU: Belt_Array.partitionU, - partition: Belt_Array.partition, - reduceU: Belt_Array.reduceU, - reduce: Belt_Array.reduce, - reduceReverseU: Belt_Array.reduceReverseU, - reduceReverse: Belt_Array.reduceReverse, - reduceReverse2U: Belt_Array.reduceReverse2U, - reduceReverse2: Belt_Array.reduceReverse2, - reduceWithIndexU: Belt_Array.reduceWithIndexU, - reduceWithIndex: Belt_Array.reduceWithIndex, - joinWithU: Belt_Array.joinWithU, - joinWith: Belt_Array.joinWith, - someU: Belt_Array.someU, - some: Belt_Array.some, - everyU: Belt_Array.everyU, - every: Belt_Array.every, - every2U: Belt_Array.every2U, - every2: Belt_Array.every2, - some2U: Belt_Array.some2U, - some2: Belt_Array.some2, - cmpU: Belt_Array.cmpU, - cmp: Belt_Array.cmp, - eqU: Belt_Array.eqU, - eq: Belt_Array.eq, - initU: Belt_Array.initU, - init: Belt_Array.init, - f: f -}; - -let u = [$$String]; - -let hh = "x".length; - -let $$Array; - -exports.$$Array = $$Array; -exports.XX = XX; -exports.u = u; -exports.hh = hh; -/* hh Not a pure module */ diff --git a/tests/tests/src/module_missing_conversion.mjs b/tests/tests/src/module_missing_conversion.mjs new file mode 100644 index 0000000000..7c833511f5 --- /dev/null +++ b/tests/tests/src/module_missing_conversion.mjs @@ -0,0 +1,98 @@ +// Generated by ReScript, PLEASE EDIT WITH CARE + +import * as $$String from "rescript/lib/es6/String.js"; +import * as Belt_Array from "rescript/lib/es6/Belt_Array.js"; + +function f(x) { + return x; +} + +let XX = { + get: Belt_Array.get, + getExn: Belt_Array.getExn, + set: Belt_Array.set, + setExn: Belt_Array.setExn, + shuffleInPlace: Belt_Array.shuffleInPlace, + shuffle: Belt_Array.shuffle, + reverseInPlace: Belt_Array.reverseInPlace, + reverse: Belt_Array.reverse, + make: Belt_Array.make, + range: Belt_Array.range, + rangeBy: Belt_Array.rangeBy, + makeByU: Belt_Array.makeByU, + makeBy: Belt_Array.makeBy, + makeByAndShuffleU: Belt_Array.makeByAndShuffleU, + makeByAndShuffle: Belt_Array.makeByAndShuffle, + zip: Belt_Array.zip, + zipByU: Belt_Array.zipByU, + zipBy: Belt_Array.zipBy, + unzip: Belt_Array.unzip, + concat: Belt_Array.concat, + concatMany: Belt_Array.concatMany, + slice: Belt_Array.slice, + sliceToEnd: Belt_Array.sliceToEnd, + fill: Belt_Array.fill, + blit: Belt_Array.blit, + blitUnsafe: Belt_Array.blitUnsafe, + forEachU: Belt_Array.forEachU, + forEach: Belt_Array.forEach, + mapU: Belt_Array.mapU, + map: Belt_Array.map, + flatMapU: Belt_Array.flatMapU, + flatMap: Belt_Array.flatMap, + getByU: Belt_Array.getByU, + getBy: Belt_Array.getBy, + getIndexByU: Belt_Array.getIndexByU, + getIndexBy: Belt_Array.getIndexBy, + keepU: Belt_Array.keepU, + keep: Belt_Array.keep, + keepWithIndexU: Belt_Array.keepWithIndexU, + keepWithIndex: Belt_Array.keepWithIndex, + keepMapU: Belt_Array.keepMapU, + keepMap: Belt_Array.keepMap, + forEachWithIndexU: Belt_Array.forEachWithIndexU, + forEachWithIndex: Belt_Array.forEachWithIndex, + mapWithIndexU: Belt_Array.mapWithIndexU, + mapWithIndex: Belt_Array.mapWithIndex, + partitionU: Belt_Array.partitionU, + partition: Belt_Array.partition, + reduceU: Belt_Array.reduceU, + reduce: Belt_Array.reduce, + reduceReverseU: Belt_Array.reduceReverseU, + reduceReverse: Belt_Array.reduceReverse, + reduceReverse2U: Belt_Array.reduceReverse2U, + reduceReverse2: Belt_Array.reduceReverse2, + reduceWithIndexU: Belt_Array.reduceWithIndexU, + reduceWithIndex: Belt_Array.reduceWithIndex, + joinWithU: Belt_Array.joinWithU, + joinWith: Belt_Array.joinWith, + someU: Belt_Array.someU, + some: Belt_Array.some, + everyU: Belt_Array.everyU, + every: Belt_Array.every, + every2U: Belt_Array.every2U, + every2: Belt_Array.every2, + some2U: Belt_Array.some2U, + some2: Belt_Array.some2, + cmpU: Belt_Array.cmpU, + cmp: Belt_Array.cmp, + eqU: Belt_Array.eqU, + eq: Belt_Array.eq, + initU: Belt_Array.initU, + init: Belt_Array.init, + f: f +}; + +let u = [$$String]; + +let hh = "x".length; + +let $$Array; + +export { + $$Array, + XX, + u, + hh, +} +/* hh Not a pure module */ diff --git a/tests/tests/src/module_parameter_test.js b/tests/tests/src/module_parameter_test.js deleted file mode 100644 index d34dbf1226..0000000000 --- a/tests/tests/src/module_parameter_test.js +++ /dev/null @@ -1,56 +0,0 @@ -// Generated by ReScript, PLEASE EDIT WITH CARE -'use strict'; - -let Mt = require("./mt.js"); -let $$String = require("rescript/lib/js/String.js"); - -function u(v) { - return v; -} - -let s = $$String; - -let N = { - s: s -}; - -let v0 = "x".length; - -function v(x) { - return x.length; -} - -let suites_0 = [ - "const", - param => ({ - TAG: "Eq", - _0: 1, - _1: v0 - }) -]; - -let suites_1 = { - hd: [ - "other", - param => ({ - TAG: "Eq", - _0: 3, - _1: v("abc") - }) - ], - tl: /* [] */0 -}; - -let suites = { - hd: suites_0, - tl: suites_1 -}; - -Mt.from_pair_suites("Module_parameter_test", suites); - -exports.u = u; -exports.N = N; -exports.v0 = v0; -exports.v = v; -exports.suites = suites; -/* v0 Not a pure module */ diff --git a/tests/tests/src/module_parameter_test.mjs b/tests/tests/src/module_parameter_test.mjs new file mode 100644 index 0000000000..18610c8278 --- /dev/null +++ b/tests/tests/src/module_parameter_test.mjs @@ -0,0 +1,57 @@ +// Generated by ReScript, PLEASE EDIT WITH CARE + +import * as Mt from "./mt.mjs"; +import * as $$String from "rescript/lib/es6/String.js"; + +function u(v) { + return v; +} + +let s = $$String; + +let N = { + s: s +}; + +let v0 = "x".length; + +function v(x) { + return x.length; +} + +let suites_0 = [ + "const", + param => ({ + TAG: "Eq", + _0: 1, + _1: v0 + }) +]; + +let suites_1 = { + hd: [ + "other", + param => ({ + TAG: "Eq", + _0: 3, + _1: v("abc") + }) + ], + tl: /* [] */0 +}; + +let suites = { + hd: suites_0, + tl: suites_1 +}; + +Mt.from_pair_suites("Module_parameter_test", suites); + +export { + u, + N, + v0, + v, + suites, +} +/* v0 Not a pure module */ diff --git a/tests/tests/src/module_splice_test.js b/tests/tests/src/module_splice_test.js deleted file mode 100644 index efe83b456d..0000000000 --- a/tests/tests/src/module_splice_test.js +++ /dev/null @@ -1,54 +0,0 @@ -// Generated by ReScript, PLEASE EDIT WITH CARE -'use strict'; - -let Mt = require("./mt.js"); -let JoinClasses = require("./joinClasses"); - -let suites = { - contents: /* [] */0 -}; - -let test_id = { - contents: 0 -}; - -function eq(loc, param) { - let y = param[1]; - let x = param[0]; - test_id.contents = test_id.contents + 1 | 0; - suites.contents = { - hd: [ - loc + (" id " + test_id.contents.toString()), - () => ({ - TAG: "Eq", - _0: x, - _1: y - }) - ], - tl: suites.contents - }; -} - -function joinClasses(prim) { - return JoinClasses(...prim); -} - -let a = JoinClasses(1, 2, 3); - -let pair = [ - a, - 6 -]; - -console.log(pair); - -eq("File \"module_splice_test.res\", line 19, characters 5-12", pair); - -Mt.from_pair_suites("Module_splice_test", suites.contents); - -exports.suites = suites; -exports.test_id = test_id; -exports.eq = eq; -exports.joinClasses = joinClasses; -exports.a = a; -/* a Not a pure module */ diff --git a/tests/tests/src/module_splice_test.mjs b/tests/tests/src/module_splice_test.mjs new file mode 100644 index 0000000000..111149fe4e --- /dev/null +++ b/tests/tests/src/module_splice_test.mjs @@ -0,0 +1,55 @@ +// Generated by ReScript, PLEASE EDIT WITH CARE + +import * as Mt from "./mt.mjs"; +import JoinClassesMjs from "./joinClasses.mjs"; + +let suites = { + contents: /* [] */0 +}; + +let test_id = { + contents: 0 +}; + +function eq(loc, param) { + let y = param[1]; + let x = param[0]; + test_id.contents = test_id.contents + 1 | 0; + suites.contents = { + hd: [ + loc + (" id " + test_id.contents.toString()), + () => ({ + TAG: "Eq", + _0: x, + _1: y + }) + ], + tl: suites.contents + }; +} + +function joinClasses(prim) { + return JoinClassesMjs(...prim); +} + +let a = JoinClassesMjs(1, 2, 3); + +let pair = [ + a, + 6 +]; + +console.log(pair); + +eq("File \"module_splice_test.res\", line 19, characters 5-12", pair); + +Mt.from_pair_suites("Module_splice_test", suites.contents); + +export { + suites, + test_id, + eq, + joinClasses, + a, +} +/* a Not a pure module */ diff --git a/tests/tests/src/module_splice_test.res b/tests/tests/src/module_splice_test.res index 3a34e52f80..f76c5f50b0 100644 --- a/tests/tests/src/module_splice_test.res +++ b/tests/tests/src/module_splice_test.res @@ -9,7 +9,7 @@ let eq = (loc, (x, y)) => { } } -@module @variadic external joinClasses: array => int = "./joinClasses" +@module("./joinClasses.mjs") @variadic external joinClasses: array => int = "default" let a = joinClasses([1, 2, 3]) diff --git a/tests/tests/src/module_test.js b/tests/tests/src/module_test.js deleted file mode 100644 index af658246fe..0000000000 --- a/tests/tests/src/module_test.js +++ /dev/null @@ -1,40 +0,0 @@ -// Generated by ReScript, PLEASE EDIT WITH CARE -'use strict'; - -let Mt = require("./mt.js"); -let Belt_List = require("rescript/lib/js/Belt_List.js"); - -function length(param) { - return 3; -} - -Mt.from_pair_suites("Module_test", { - hd: [ - "list_length", - () => ({ - TAG: "Eq", - _0: Belt_List.length({ - hd: 1, - tl: { - hd: 2, - tl: /* [] */0 - } - }), - _1: 2 - }) - ], - tl: { - hd: [ - "length", - () => ({ - TAG: "Eq", - _0: 3, - _1: 3 - }) - ], - tl: /* [] */0 - } -}); - -exports.length = length; -/* Not a pure module */ diff --git a/tests/tests/src/module_test.mjs b/tests/tests/src/module_test.mjs new file mode 100644 index 0000000000..345fd1084f --- /dev/null +++ b/tests/tests/src/module_test.mjs @@ -0,0 +1,41 @@ +// Generated by ReScript, PLEASE EDIT WITH CARE + +import * as Mt from "./mt.mjs"; +import * as Belt_List from "rescript/lib/es6/Belt_List.js"; + +function length(param) { + return 3; +} + +Mt.from_pair_suites("Module_test", { + hd: [ + "list_length", + () => ({ + TAG: "Eq", + _0: Belt_List.length({ + hd: 1, + tl: { + hd: 2, + tl: /* [] */0 + } + }), + _1: 2 + }) + ], + tl: { + hd: [ + "length", + () => ({ + TAG: "Eq", + _0: 3, + _1: 3 + }) + ], + tl: /* [] */0 + } +}); + +export { + length, +} +/* Not a pure module */ diff --git a/tests/tests/src/more_poly_variant_test.js b/tests/tests/src/more_poly_variant_test.js deleted file mode 100644 index e21d0d4b5c..0000000000 --- a/tests/tests/src/more_poly_variant_test.js +++ /dev/null @@ -1,90 +0,0 @@ -// Generated by ReScript, PLEASE EDIT WITH CARE -'use strict'; - - -function map(f) { - return x => { - if (typeof x !== "object") { - return "Nil"; - } - let match = x.VAL; - return { - NAME: "Cons", - VAL: [ - f(match[0]), - map(f)(match[1]) - ] - }; - }; -} - -function split_cases(x) { - if (typeof x === "object" && x.NAME === "Snoc") { - return { - NAME: "B", - VAL: x - }; - } else { - return { - NAME: "A", - VAL: x - }; - } -} - -function f(x) { - if (typeof x === "object") { - return "myvariant"; - } else { - return "Tag3"; - } -} - -function g1(x) { - if (x.NAME === "Tag2") { - return "Tag2"; - } else { - return "Tag1"; - } -} - -function g(x) { - if (typeof x === "object") { - return g1(x); - } else { - return "Tag3"; - } -} - -function f1(x) { - if (x === "As") { - return "A"; - } else { - return "other"; - } -} - -function f2(x) { - if (typeof x === "object") { - console.log(x); - return 2; - } else if (x === "h") { - return 2; - } else if (x === "hello") { - return 3; - } else if (x === "Tag4") { - console.log(x); - return 2; - } else { - return 333; - } -} - -exports.map = map; -exports.split_cases = split_cases; -exports.f = f; -exports.g1 = g1; -exports.g = g; -exports.f1 = f1; -exports.f2 = f2; -/* No side effect */ diff --git a/tests/tests/src/more_poly_variant_test.mjs b/tests/tests/src/more_poly_variant_test.mjs new file mode 100644 index 0000000000..559c274991 --- /dev/null +++ b/tests/tests/src/more_poly_variant_test.mjs @@ -0,0 +1,91 @@ +// Generated by ReScript, PLEASE EDIT WITH CARE + + +function map(f) { + return x => { + if (typeof x !== "object") { + return "Nil"; + } + let match = x.VAL; + return { + NAME: "Cons", + VAL: [ + f(match[0]), + map(f)(match[1]) + ] + }; + }; +} + +function split_cases(x) { + if (typeof x === "object" && x.NAME === "Snoc") { + return { + NAME: "B", + VAL: x + }; + } else { + return { + NAME: "A", + VAL: x + }; + } +} + +function f(x) { + if (typeof x === "object") { + return "myvariant"; + } else { + return "Tag3"; + } +} + +function g1(x) { + if (x.NAME === "Tag2") { + return "Tag2"; + } else { + return "Tag1"; + } +} + +function g(x) { + if (typeof x === "object") { + return g1(x); + } else { + return "Tag3"; + } +} + +function f1(x) { + if (x === "As") { + return "A"; + } else { + return "other"; + } +} + +function f2(x) { + if (typeof x === "object") { + console.log(x); + return 2; + } else if (x === "h") { + return 2; + } else if (x === "hello") { + return 3; + } else if (x === "Tag4") { + console.log(x); + return 2; + } else { + return 333; + } +} + +export { + map, + split_cases, + f, + g1, + g, + f1, + f2, +} +/* No side effect */ diff --git a/tests/tests/src/more_uncurry.js b/tests/tests/src/more_uncurry.js deleted file mode 100644 index a89f66de65..0000000000 --- a/tests/tests/src/more_uncurry.js +++ /dev/null @@ -1,14 +0,0 @@ -// Generated by ReScript, PLEASE EDIT WITH CARE -'use strict'; - - -function f(x, y, x_) { - if (x_ !== undefined) { - return (x + y | 0) + x_ | 0; - } else { - return x + y | 0; - } -} - -exports.f = f; -/* No side effect */ diff --git a/tests/tests/src/more_uncurry.mjs b/tests/tests/src/more_uncurry.mjs new file mode 100644 index 0000000000..a8b2b4d3c2 --- /dev/null +++ b/tests/tests/src/more_uncurry.mjs @@ -0,0 +1,15 @@ +// Generated by ReScript, PLEASE EDIT WITH CARE + + +function f(x, y, x_) { + if (x_ !== undefined) { + return (x + y | 0) + x_ | 0; + } else { + return x + y | 0; + } +} + +export { + f, +} +/* No side effect */ diff --git a/tests/tests/src/mpr_6033_test.js b/tests/tests/src/mpr_6033_test.js deleted file mode 100644 index ffa039435f..0000000000 --- a/tests/tests/src/mpr_6033_test.js +++ /dev/null @@ -1,49 +0,0 @@ -// Generated by ReScript, PLEASE EDIT WITH CARE -'use strict'; - -let Mt = require("./mt.js"); -let Lazy = require("rescript/lib/js/Lazy.js"); - -let suites = { - contents: /* [] */0 -}; - -let test_id = { - contents: 0 -}; - -function eq(loc, x, y) { - test_id.contents = test_id.contents + 1 | 0; - suites.contents = { - hd: [ - loc + (" id " + test_id.contents.toString()), - () => ({ - TAG: "Eq", - _0: x, - _1: y - }) - ], - tl: suites.contents - }; -} - -function f(x) { - return Lazy.force(x) + "abc"; -} - -let x = Lazy.from_fun(() => "def"); - -Lazy.force(x); - -let u = Lazy.force(x) + "abc"; - -eq("File \"mpr_6033_test.res\", line 23, characters 3-10", u, "defabc"); - -Mt.from_pair_suites("Mpr_6033_test", suites.contents); - -exports.suites = suites; -exports.test_id = test_id; -exports.eq = eq; -exports.f = f; -exports.u = u; -/* Not a pure module */ diff --git a/tests/tests/src/mpr_6033_test.mjs b/tests/tests/src/mpr_6033_test.mjs new file mode 100644 index 0000000000..70d3e5036c --- /dev/null +++ b/tests/tests/src/mpr_6033_test.mjs @@ -0,0 +1,50 @@ +// Generated by ReScript, PLEASE EDIT WITH CARE + +import * as Mt from "./mt.mjs"; +import * as Lazy from "rescript/lib/es6/Lazy.js"; + +let suites = { + contents: /* [] */0 +}; + +let test_id = { + contents: 0 +}; + +function eq(loc, x, y) { + test_id.contents = test_id.contents + 1 | 0; + suites.contents = { + hd: [ + loc + (" id " + test_id.contents.toString()), + () => ({ + TAG: "Eq", + _0: x, + _1: y + }) + ], + tl: suites.contents + }; +} + +function f(x) { + return Lazy.force(x) + "abc"; +} + +let x = Lazy.from_fun(() => "def"); + +Lazy.force(x); + +let u = Lazy.force(x) + "abc"; + +eq("File \"mpr_6033_test.res\", line 23, characters 3-10", u, "defabc"); + +Mt.from_pair_suites("Mpr_6033_test", suites.contents); + +export { + suites, + test_id, + eq, + f, + u, +} +/* Not a pure module */ diff --git a/tests/tests/src/mt.js b/tests/tests/src/mt.js deleted file mode 100644 index 0fd287b291..0000000000 --- a/tests/tests/src/mt.js +++ /dev/null @@ -1,288 +0,0 @@ -// Generated by ReScript, PLEASE EDIT WITH CARE -'use strict'; - -let Path = require("path"); -let Assert = require("assert"); -let Process = require("process"); -let Belt_List = require("rescript/lib/js/Belt_List.js"); -let Js_promise = require("rescript/lib/js/Js_promise.js"); - -function assert_fail(msg) { - Assert.fail(undefined, undefined, msg, ""); -} - -function is_mocha() { - let match = Belt_List.fromArray(Process.argv); - if (!match) { - return false; - } - let match$1 = match.tl; - if (!match$1) { - return false; - } - let exec = Path.basename(match$1.hd); - if (exec === "mocha") { - return true; - } else { - return exec === "_mocha"; - } -} - -let from_suites = (function from_suites(name, suites) { - var match = Belt_List.fromArray(Process.argv); - if (match && is_mocha(undefined)) { - describe(name, (function () { - return Belt_List.forEach(suites, (function (param) { - var partial_arg = param[1]; - it(param[0], (function () { - return partial_arg(undefined); - })); - })); - })); - return ; - } - -}); - -function close_enough(thresholdOpt, a, b) { - let threshold = thresholdOpt !== undefined ? thresholdOpt : 0.0000001; - return Math.abs(a - b) < threshold; -} - -function handleCode(spec) { - switch (spec.TAG) { - case "Eq" : - Assert.deepEqual(spec._0, spec._1); - return; - case "Neq" : - Assert.notDeepEqual(spec._0, spec._1); - return; - case "StrictEq" : - Assert.strictEqual(spec._0, spec._1); - return; - case "StrictNeq" : - Assert.notStrictEqual(spec._0, spec._1); - return; - case "Ok" : - Assert.ok(spec._0); - return; - case "Approx" : - let b = spec._1; - let a = spec._0; - if (!close_enough(undefined, a, b)) { - Assert.deepEqual(a, b); - return; - } else { - return; - } - case "ApproxThreshold" : - let b$1 = spec._2; - let a$1 = spec._1; - if (!close_enough(spec._0, a$1, b$1)) { - Assert.deepEqual(a$1, b$1); - return; - } else { - return; - } - case "ThrowAny" : - Assert.throws(spec._0); - return; - case "Fail" : - return assert_fail("failed"); - case "FailWith" : - return assert_fail(spec._0); - } -} - -let from_pair_suites = (function from_pair_suites(name, suites) { - var match = Belt_List.fromArray(Process.argv); - if (match) { - if (is_mocha(undefined)) { - describe(name, (function () { - return Belt_List.forEach(suites, (function (param) { - var code = param[1]; - it(param[0], (function () { - return handleCode(code(undefined)); - })); - })); - })); - return ; - } else { - console.log([ - name, - "testing" - ]); - return Belt_List.forEach(suites, (function (param) { - var name = param[0]; - var fn = param[1](undefined); - switch (fn.TAG) { - case "Eq" : - console.log([ - name, - fn._0, - "eq?", - fn._1 - ]); - return ; - case "Neq" : - console.log([ - name, - fn._0, - "neq?", - fn._1 - ]); - return ; - case "StrictEq" : - console.log([ - name, - fn._0, - "strict_eq?", - fn._1 - ]); - return ; - case "StrictNeq" : - console.log([ - name, - fn._0, - "strict_neq?", - fn._1 - ]); - return ; - case "Ok" : - console.log([ - name, - fn._0, - "ok?" - ]); - return ; - case "Approx" : - console.log([ - name, - fn._0, - "~", - fn._1 - ]); - return ; - case "ApproxThreshold" : - console.log([ - name, - fn._1, - "~", - fn._2, - " (", - fn._0, - ")" - ]); - return ; - case "ThrowAny" : - return ; - case "Fail" : - console.log("failed"); - return ; - case "FailWith" : - console.log("failed: " + fn._0); - return ; - - } - })); - } - } - -}); - -let val_unit = Promise.resolve(); - -let from_promise_suites = (function from_promise_suites(name, suites) { - var match = Belt_List.fromArray(Process.argv); - if (match) { - if (is_mocha(undefined)) { - describe(name, (function () { - return Belt_List.forEach(suites, (function (param) { - var code = param[1]; - it(param[0], (function () { - var arg1 = function (x) { - handleCode(x); - return val_unit; - }; - return code.then(arg1); - })); - })); - })); - } else { - console.log("promise suites"); - } - return ; - } - -}); - -function old_from_promise_suites_donotuse(name, suites) { - let match = Belt_List.fromArray(Process.argv); - if (match) { - if (is_mocha()) { - describe(name, () => Belt_List.forEach(suites, param => { - let code = param[1]; - it(param[0], () => Js_promise.then_(x => { - handleCode(x); - return val_unit; - }, code)); - })); - } else { - console.log("promise suites"); - } - return; - } - -} - -function eq_suites(test_id, suites, loc, x, y) { - test_id.contents = test_id.contents + 1 | 0; - suites.contents = { - hd: [ - loc + (" id " + test_id.contents.toString()), - param => ({ - TAG: "Eq", - _0: x, - _1: y - }) - ], - tl: suites.contents - }; -} - -function bool_suites(test_id, suites, loc, x) { - test_id.contents = test_id.contents + 1 | 0; - suites.contents = { - hd: [ - loc + (" id " + test_id.contents.toString()), - param => ({ - TAG: "Ok", - _0: x - }) - ], - tl: suites.contents - }; -} - -function throw_suites(test_id, suites, loc, x) { - test_id.contents = test_id.contents + 1 | 0; - suites.contents = { - hd: [ - loc + (" id " + test_id.contents.toString()), - param => ({ - TAG: "ThrowAny", - _0: x - }) - ], - tl: suites.contents - }; -} - -exports.from_suites = from_suites; -exports.from_pair_suites = from_pair_suites; -exports.from_promise_suites = from_promise_suites; -exports.old_from_promise_suites_donotuse = old_from_promise_suites_donotuse; -exports.eq_suites = eq_suites; -exports.bool_suites = bool_suites; -exports.throw_suites = throw_suites; -/* val_unit Not a pure module */ diff --git a/tests/tests/src/mt.mjs b/tests/tests/src/mt.mjs new file mode 100644 index 0000000000..1534dbe473 --- /dev/null +++ b/tests/tests/src/mt.mjs @@ -0,0 +1,289 @@ +// Generated by ReScript, PLEASE EDIT WITH CARE + +import * as Path from "path"; +import * as Assert from "assert"; +import * as Process from "process"; +import * as Belt_List from "rescript/lib/es6/Belt_List.js"; +import * as Js_promise from "rescript/lib/es6/Js_promise.js"; + +function assert_fail(msg) { + Assert.fail(undefined, undefined, msg, ""); +} + +function is_mocha() { + let match = Belt_List.fromArray(Process.argv); + if (!match) { + return false; + } + let match$1 = match.tl; + if (!match$1) { + return false; + } + let exec = Path.basename(match$1.hd); + if (exec === "mocha") { + return true; + } else { + return exec === "_mocha"; + } +} + +let from_suites = (function from_suites(name, suites) { + var match = Belt_List.fromArray(Process.argv); + if (match && is_mocha(undefined)) { + describe(name, (function () { + return Belt_List.forEach(suites, (function (param) { + var partial_arg = param[1]; + it(param[0], (function () { + return partial_arg(undefined); + })); + })); + })); + return ; + } + +}); + +function close_enough(thresholdOpt, a, b) { + let threshold = thresholdOpt !== undefined ? thresholdOpt : 0.0000001; + return Math.abs(a - b) < threshold; +} + +function handleCode(spec) { + switch (spec.TAG) { + case "Eq" : + Assert.deepEqual(spec._0, spec._1); + return; + case "Neq" : + Assert.notDeepEqual(spec._0, spec._1); + return; + case "StrictEq" : + Assert.strictEqual(spec._0, spec._1); + return; + case "StrictNeq" : + Assert.notStrictEqual(spec._0, spec._1); + return; + case "Ok" : + Assert.ok(spec._0); + return; + case "Approx" : + let b = spec._1; + let a = spec._0; + if (!close_enough(undefined, a, b)) { + Assert.deepEqual(a, b); + return; + } else { + return; + } + case "ApproxThreshold" : + let b$1 = spec._2; + let a$1 = spec._1; + if (!close_enough(spec._0, a$1, b$1)) { + Assert.deepEqual(a$1, b$1); + return; + } else { + return; + } + case "ThrowAny" : + Assert.throws(spec._0); + return; + case "Fail" : + return assert_fail("failed"); + case "FailWith" : + return assert_fail(spec._0); + } +} + +let from_pair_suites = (function from_pair_suites(name, suites) { + var match = Belt_List.fromArray(Process.argv); + if (match) { + if (is_mocha(undefined)) { + describe(name, (function () { + return Belt_List.forEach(suites, (function (param) { + var code = param[1]; + it(param[0], (function () { + return handleCode(code(undefined)); + })); + })); + })); + return ; + } else { + console.log([ + name, + "testing" + ]); + return Belt_List.forEach(suites, (function (param) { + var name = param[0]; + var fn = param[1](undefined); + switch (fn.TAG) { + case "Eq" : + console.log([ + name, + fn._0, + "eq?", + fn._1 + ]); + return ; + case "Neq" : + console.log([ + name, + fn._0, + "neq?", + fn._1 + ]); + return ; + case "StrictEq" : + console.log([ + name, + fn._0, + "strict_eq?", + fn._1 + ]); + return ; + case "StrictNeq" : + console.log([ + name, + fn._0, + "strict_neq?", + fn._1 + ]); + return ; + case "Ok" : + console.log([ + name, + fn._0, + "ok?" + ]); + return ; + case "Approx" : + console.log([ + name, + fn._0, + "~", + fn._1 + ]); + return ; + case "ApproxThreshold" : + console.log([ + name, + fn._1, + "~", + fn._2, + " (", + fn._0, + ")" + ]); + return ; + case "ThrowAny" : + return ; + case "Fail" : + console.log("failed"); + return ; + case "FailWith" : + console.log("failed: " + fn._0); + return ; + + } + })); + } + } + +}); + +let val_unit = Promise.resolve(); + +let from_promise_suites = (function from_promise_suites(name, suites) { + var match = Belt_List.fromArray(Process.argv); + if (match) { + if (is_mocha(undefined)) { + describe(name, (function () { + return Belt_List.forEach(suites, (function (param) { + var code = param[1]; + it(param[0], (function () { + var arg1 = function (x) { + handleCode(x); + return val_unit; + }; + return code.then(arg1); + })); + })); + })); + } else { + console.log("promise suites"); + } + return ; + } + +}); + +function old_from_promise_suites_donotuse(name, suites) { + let match = Belt_List.fromArray(Process.argv); + if (match) { + if (is_mocha()) { + describe(name, () => Belt_List.forEach(suites, param => { + let code = param[1]; + it(param[0], () => Js_promise.then_(x => { + handleCode(x); + return val_unit; + }, code)); + })); + } else { + console.log("promise suites"); + } + return; + } + +} + +function eq_suites(test_id, suites, loc, x, y) { + test_id.contents = test_id.contents + 1 | 0; + suites.contents = { + hd: [ + loc + (" id " + test_id.contents.toString()), + param => ({ + TAG: "Eq", + _0: x, + _1: y + }) + ], + tl: suites.contents + }; +} + +function bool_suites(test_id, suites, loc, x) { + test_id.contents = test_id.contents + 1 | 0; + suites.contents = { + hd: [ + loc + (" id " + test_id.contents.toString()), + param => ({ + TAG: "Ok", + _0: x + }) + ], + tl: suites.contents + }; +} + +function throw_suites(test_id, suites, loc, x) { + test_id.contents = test_id.contents + 1 | 0; + suites.contents = { + hd: [ + loc + (" id " + test_id.contents.toString()), + param => ({ + TAG: "ThrowAny", + _0: x + }) + ], + tl: suites.contents + }; +} + +export { + from_suites, + from_pair_suites, + from_promise_suites, + old_from_promise_suites_donotuse, + eq_suites, + bool_suites, + throw_suites, +} +/* val_unit Not a pure module */ diff --git a/tests/tests/src/mt_global.js b/tests/tests/src/mt_global.js deleted file mode 100644 index e3d0bb4f70..0000000000 --- a/tests/tests/src/mt_global.js +++ /dev/null @@ -1,53 +0,0 @@ -// Generated by ReScript, PLEASE EDIT WITH CARE -'use strict'; - - -function collect_eq(test_id, suites, loc, x, y) { - test_id.contents = test_id.contents + 1 | 0; - suites.contents = { - hd: [ - loc + (" id " + test_id.contents.toString()), - param => ({ - TAG: "Eq", - _0: x, - _1: y - }) - ], - tl: suites.contents - }; -} - -function collect_neq(test_id, suites, loc, x, y) { - test_id.contents = test_id.contents + 1 | 0; - suites.contents = { - hd: [ - loc + (" id " + test_id.contents.toString()), - param => ({ - TAG: "Neq", - _0: x, - _1: y - }) - ], - tl: suites.contents - }; -} - -function collect_approx(test_id, suites, loc, x, y) { - test_id.contents = test_id.contents + 1 | 0; - suites.contents = { - hd: [ - loc + (" id " + test_id.contents.toString()), - param => ({ - TAG: "Approx", - _0: x, - _1: y - }) - ], - tl: suites.contents - }; -} - -exports.collect_eq = collect_eq; -exports.collect_neq = collect_neq; -exports.collect_approx = collect_approx; -/* No side effect */ diff --git a/tests/tests/src/mt_global.mjs b/tests/tests/src/mt_global.mjs new file mode 100644 index 0000000000..93474e5736 --- /dev/null +++ b/tests/tests/src/mt_global.mjs @@ -0,0 +1,54 @@ +// Generated by ReScript, PLEASE EDIT WITH CARE + + +function collect_eq(test_id, suites, loc, x, y) { + test_id.contents = test_id.contents + 1 | 0; + suites.contents = { + hd: [ + loc + (" id " + test_id.contents.toString()), + param => ({ + TAG: "Eq", + _0: x, + _1: y + }) + ], + tl: suites.contents + }; +} + +function collect_neq(test_id, suites, loc, x, y) { + test_id.contents = test_id.contents + 1 | 0; + suites.contents = { + hd: [ + loc + (" id " + test_id.contents.toString()), + param => ({ + TAG: "Neq", + _0: x, + _1: y + }) + ], + tl: suites.contents + }; +} + +function collect_approx(test_id, suites, loc, x, y) { + test_id.contents = test_id.contents + 1 | 0; + suites.contents = { + hd: [ + loc + (" id " + test_id.contents.toString()), + param => ({ + TAG: "Approx", + _0: x, + _1: y + }) + ], + tl: suites.contents + }; +} + +export { + collect_eq, + collect_neq, + collect_approx, +} +/* No side effect */ diff --git a/tests/tests/src/mutable_obj_test.js b/tests/tests/src/mutable_obj_test.js deleted file mode 100644 index 19f7c687a9..0000000000 --- a/tests/tests/src/mutable_obj_test.js +++ /dev/null @@ -1,13 +0,0 @@ -// Generated by ReScript, PLEASE EDIT WITH CARE -'use strict'; - - -function f(x) { - x.dec = x => ({ - x: x, - y: x - }); -} - -exports.f = f; -/* No side effect */ diff --git a/tests/tests/src/mutable_obj_test.mjs b/tests/tests/src/mutable_obj_test.mjs new file mode 100644 index 0000000000..fa23fbd6f6 --- /dev/null +++ b/tests/tests/src/mutable_obj_test.mjs @@ -0,0 +1,14 @@ +// Generated by ReScript, PLEASE EDIT WITH CARE + + +function f(x) { + x.dec = x => ({ + x: x, + y: x + }); +} + +export { + f, +} +/* No side effect */ diff --git a/tests/tests/src/mutable_uncurry_test.js b/tests/tests/src/mutable_uncurry_test.js deleted file mode 100644 index 84d7b216e1..0000000000 --- a/tests/tests/src/mutable_uncurry_test.js +++ /dev/null @@ -1,223 +0,0 @@ -// Generated by ReScript, PLEASE EDIT WITH CARE -'use strict'; - -let Mt = require("./mt.js"); -let Primitive_object = require("rescript/lib/js/Primitive_object.js"); - -let suites = { - contents: /* [] */0 -}; - -let test_id = { - contents: 0 -}; - -function eqs(loc, x, y) { - Mt.eq_suites(test_id, suites, loc, x, y); -} - -function eq(param, param$1) { - let x = param.contents; - let y = param$1.contents; - return x === y; -} - -function eq2(x, param) { - let y = param.contents; - return Primitive_object.equal(x.contents, y); -} - -eqs("File \"mutable_uncurry_test.res\", line 15, characters 4-11", false, eq({ - contents: 1 -}, { - contents: 2 -})); - -eqs("File \"mutable_uncurry_test.res\", line 16, characters 4-11", true, eq({ - contents: 2 -}, { - contents: 2 -})); - -function ut3(param, param$1, param$2) { - let x0 = param.contents; - let x1 = param$1.contents; - let x2 = param$2.contents; - return [ - x0, - x1, - x2 - ]; -} - -function t3(param, param$1, param$2) { - let x0 = param.contents; - let x1 = param$1.contents; - let x2 = param$2.contents; - return [ - x0, - x1, - x2 - ]; -} - -function ut4(param, param$1, param$2, param$3) { - let x0 = param.contents; - let x1 = param$1.contents; - return (param => { - let x2 = param.contents; - return param => { - let x3 = param.contents; - return [ - x0, - x1, - x2, - x3 - ]; - }; - })(param$2)(param$3); -} - -function t4(param, param$1, param$2, param$3) { - let x0 = param.contents; - let x1 = param$1.contents; - return (param => { - let x2 = param.contents; - return param => { - let x3 = param.contents; - return [ - x0, - x1, - x2, - x3 - ]; - }; - })(param$2)(param$3); -} - -function ut5(param, param$1, param$2, param$3, param$4) { - let x0 = param.contents; - let x1 = param$1.contents; - return (param => { - let x2 = param.contents; - return param => { - let x3 = param.contents; - return param => { - let x4 = param.contents; - return [ - x0, - x1, - x2, - x3, - x4 - ]; - }; - }; - })(param$2)(param$3)(param$4); -} - -function t5(param, param$1, param$2, param$3, param$4) { - let x0 = param.contents; - let x1 = param$1.contents; - return (param => { - let x2 = param.contents; - return param => { - let x3 = param.contents; - return param => { - let x4 = param.contents; - return [ - x0, - x1, - x2, - x3, - x4 - ]; - }; - }; - })(param$2)(param$3)(param$4); -} - -function nested0(param, param$1, param$2) { - let x0 = param.contents; - let x1 = param$1.contents; - let x2 = param$2.contents; - let a = (x0 + x1 | 0) + x2 | 0; - return (param, param$1, param$2) => { - let x0 = param.contents; - let x1 = param$1.contents; - let x2 = param$2.contents; - return ((a + x0 | 0) + x1 | 0) + x2 | 0; - }; -} - -function nested1(param, param$1, param$2) { - let x0 = param.contents; - let x1 = param$1.contents; - let x2 = param$2.contents; - let a = (x0 + x1 | 0) + x2 | 0; - return (param, param$1, param$2) => { - let x0 = param.contents; - let x1 = param$1.contents; - let x2 = param$2.contents; - return ((a + x0 | 0) + x1 | 0) + x2 | 0; - }; -} - -eqs("File \"mutable_uncurry_test.res\", line 51, characters 4-11", ut3({ - contents: 1 -}, { - contents: 2 -}, { - contents: 3 -}), [ - 1, - 2, - 3 -]); - -eqs("File \"mutable_uncurry_test.res\", line 52, characters 4-11", t3({ - contents: 1 -}, { - contents: 2 -}, { - contents: 3 -}), [ - 1, - 2, - 3 -]); - -eqs("File \"mutable_uncurry_test.res\", line 54, characters 4-11", ut5({ - contents: 1 -}, { - contents: 2 -}, { - contents: 3 -}, { - contents: 1 -}, { - contents: 1 -}), [ - 1, - 2, - 3, - 1, - 1 -]); - -Mt.from_pair_suites("mutable_uncurry_test.res", suites.contents); - -exports.suites = suites; -exports.test_id = test_id; -exports.eqs = eqs; -exports.eq = eq; -exports.eq2 = eq2; -exports.ut3 = ut3; -exports.t3 = t3; -exports.ut4 = ut4; -exports.t4 = t4; -exports.ut5 = ut5; -exports.t5 = t5; -exports.nested0 = nested0; -exports.nested1 = nested1; -/* Not a pure module */ diff --git a/tests/tests/src/mutable_uncurry_test.mjs b/tests/tests/src/mutable_uncurry_test.mjs new file mode 100644 index 0000000000..a07e5065a4 --- /dev/null +++ b/tests/tests/src/mutable_uncurry_test.mjs @@ -0,0 +1,224 @@ +// Generated by ReScript, PLEASE EDIT WITH CARE + +import * as Mt from "./mt.mjs"; +import * as Primitive_object from "rescript/lib/es6/Primitive_object.js"; + +let suites = { + contents: /* [] */0 +}; + +let test_id = { + contents: 0 +}; + +function eqs(loc, x, y) { + Mt.eq_suites(test_id, suites, loc, x, y); +} + +function eq(param, param$1) { + let x = param.contents; + let y = param$1.contents; + return x === y; +} + +function eq2(x, param) { + let y = param.contents; + return Primitive_object.equal(x.contents, y); +} + +eqs("File \"mutable_uncurry_test.res\", line 15, characters 4-11", false, eq({ + contents: 1 +}, { + contents: 2 +})); + +eqs("File \"mutable_uncurry_test.res\", line 16, characters 4-11", true, eq({ + contents: 2 +}, { + contents: 2 +})); + +function ut3(param, param$1, param$2) { + let x0 = param.contents; + let x1 = param$1.contents; + let x2 = param$2.contents; + return [ + x0, + x1, + x2 + ]; +} + +function t3(param, param$1, param$2) { + let x0 = param.contents; + let x1 = param$1.contents; + let x2 = param$2.contents; + return [ + x0, + x1, + x2 + ]; +} + +function ut4(param, param$1, param$2, param$3) { + let x0 = param.contents; + let x1 = param$1.contents; + return (param => { + let x2 = param.contents; + return param => { + let x3 = param.contents; + return [ + x0, + x1, + x2, + x3 + ]; + }; + })(param$2)(param$3); +} + +function t4(param, param$1, param$2, param$3) { + let x0 = param.contents; + let x1 = param$1.contents; + return (param => { + let x2 = param.contents; + return param => { + let x3 = param.contents; + return [ + x0, + x1, + x2, + x3 + ]; + }; + })(param$2)(param$3); +} + +function ut5(param, param$1, param$2, param$3, param$4) { + let x0 = param.contents; + let x1 = param$1.contents; + return (param => { + let x2 = param.contents; + return param => { + let x3 = param.contents; + return param => { + let x4 = param.contents; + return [ + x0, + x1, + x2, + x3, + x4 + ]; + }; + }; + })(param$2)(param$3)(param$4); +} + +function t5(param, param$1, param$2, param$3, param$4) { + let x0 = param.contents; + let x1 = param$1.contents; + return (param => { + let x2 = param.contents; + return param => { + let x3 = param.contents; + return param => { + let x4 = param.contents; + return [ + x0, + x1, + x2, + x3, + x4 + ]; + }; + }; + })(param$2)(param$3)(param$4); +} + +function nested0(param, param$1, param$2) { + let x0 = param.contents; + let x1 = param$1.contents; + let x2 = param$2.contents; + let a = (x0 + x1 | 0) + x2 | 0; + return (param, param$1, param$2) => { + let x0 = param.contents; + let x1 = param$1.contents; + let x2 = param$2.contents; + return ((a + x0 | 0) + x1 | 0) + x2 | 0; + }; +} + +function nested1(param, param$1, param$2) { + let x0 = param.contents; + let x1 = param$1.contents; + let x2 = param$2.contents; + let a = (x0 + x1 | 0) + x2 | 0; + return (param, param$1, param$2) => { + let x0 = param.contents; + let x1 = param$1.contents; + let x2 = param$2.contents; + return ((a + x0 | 0) + x1 | 0) + x2 | 0; + }; +} + +eqs("File \"mutable_uncurry_test.res\", line 51, characters 4-11", ut3({ + contents: 1 +}, { + contents: 2 +}, { + contents: 3 +}), [ + 1, + 2, + 3 +]); + +eqs("File \"mutable_uncurry_test.res\", line 52, characters 4-11", t3({ + contents: 1 +}, { + contents: 2 +}, { + contents: 3 +}), [ + 1, + 2, + 3 +]); + +eqs("File \"mutable_uncurry_test.res\", line 54, characters 4-11", ut5({ + contents: 1 +}, { + contents: 2 +}, { + contents: 3 +}, { + contents: 1 +}, { + contents: 1 +}), [ + 1, + 2, + 3, + 1, + 1 +]); + +Mt.from_pair_suites("mutable_uncurry_test.res", suites.contents); + +export { + suites, + test_id, + eqs, + eq, + eq2, + ut3, + t3, + ut4, + t4, + ut5, + t5, + nested0, + nested1, +} +/* Not a pure module */ diff --git a/tests/tests/src/mutual_non_recursive_type.js b/tests/tests/src/mutual_non_recursive_type.js deleted file mode 100644 index adb7f2d4ba..0000000000 --- a/tests/tests/src/mutual_non_recursive_type.js +++ /dev/null @@ -1,20 +0,0 @@ -// Generated by ReScript, PLEASE EDIT WITH CARE -'use strict'; - - -function f(x) { - return x; -} - -let U = { - f: f -}; - -let v = { - TAG: "H", - _0: "OT" -}; - -exports.U = U; -exports.v = v; -/* No side effect */ diff --git a/tests/tests/src/mutual_non_recursive_type.mjs b/tests/tests/src/mutual_non_recursive_type.mjs new file mode 100644 index 0000000000..5c724a744e --- /dev/null +++ b/tests/tests/src/mutual_non_recursive_type.mjs @@ -0,0 +1,21 @@ +// Generated by ReScript, PLEASE EDIT WITH CARE + + +function f(x) { + return x; +} + +let U = { + f: f +}; + +let v = { + TAG: "H", + _0: "OT" +}; + +export { + U, + v, +} +/* No side effect */ diff --git a/tests/tests/src/name_mangle_test.js b/tests/tests/src/name_mangle_test.js deleted file mode 100644 index e7fc9f8d0c..0000000000 --- a/tests/tests/src/name_mangle_test.js +++ /dev/null @@ -1,151 +0,0 @@ -// Generated by ReScript, PLEASE EDIT WITH CARE -'use strict'; - -let Mt = require("./mt.js"); - -let suites = { - contents: /* [] */0 -}; - -let test_id = { - contents: 0 -}; - -function eq(loc, x, y) { - test_id.contents = test_id.contents + 1 | 0; - suites.contents = { - hd: [ - loc + (" id " + test_id.contents.toString()), - () => ({ - TAG: "Eq", - _0: x, - _1: y - }) - ], - tl: suites.contents - }; -} - -function f0(x) { - let old = x._open; - x._open = old + 1 | 0; - return x._open; -} - -function f1(x) { - let old = x._in; - x._in = old + 1 | 0; - return x._in; -} - -function f2(x) { - let old = x._MAX_LENGTH; - x._MAX_LENGTH = old + 1 | 0; - return x._MAX_LENGTH; -} - -function f3(x) { - let old = x._Capital; - x._Capital = old + 1 | 0; - return x._Capital; -} - -function f4(x) { - let old = x._open__; - x._open__ = old + 1 | 0; - return x._open__; -} - -function f5(x) { - let old = x.open__; - x.open__ = old + 1 | 0; - return x.open__; -} - -function f6(x) { - let old = x["_'x"]; - x["_'x"] = old + 1 | 0; - return x["_'x"]; -} - -function f7(x) { - let old = x._Capital__; - x._Capital__ = old + 1 | 0; - return x._Capital__; -} - -function f8(x) { - let old = x._MAX__; - x._MAX__ = old + 1 | 0; - return x._MAX__; -} - -function f9(x) { - let old = x.__; - x.__ = old + 1 | 0; - return x.__; -} - -function f10(x) { - let old = x.__x; - x.__x = old + 1 | 0; - return x.__x; -} - -function f11(x) { - let old = x.___; - x.___ = old + 1 | 0; - return x.___; -} - -function f12(x) { - let old = x.____; - x.____ = old + 1 | 0; - return x.____; -} - -eq("File \"name_mangle_test.res\", line 97, characters 5-12", f0({_open:0}), 1); - -eq("File \"name_mangle_test.res\", line 98, characters 5-12", f1({_in:0}), 1); - -eq("File \"name_mangle_test.res\", line 99, characters 5-12", f2({_MAX_LENGTH:0}), 1); - -eq("File \"name_mangle_test.res\", line 100, characters 5-12", f3({_Capital:0}), 1); - -eq("File \"name_mangle_test.res\", line 101, characters 5-12", f4({_open__:0}), 1); - -eq("File \"name_mangle_test.res\", line 102, characters 5-12", f5({open__:0}), 1); - -eq("File \"name_mangle_test.res\", line 103, characters 5-12", f6({ "_'x" :0}), 1); - -eq("File \"name_mangle_test.res\", line 104, characters 5-12", f7({_Capital__:0}), 1); - -eq("File \"name_mangle_test.res\", line 105, characters 5-12", f8({_MAX__:0}), 1); - -eq("File \"name_mangle_test.res\", line 106, characters 5-12", f9({__:0}), 1); - -eq("File \"name_mangle_test.res\", line 107, characters 5-12", f10({__x:0}), 1); - -eq("File \"name_mangle_test.res\", line 108, characters 5-12", f11({___:0}), 1); - -eq("File \"name_mangle_test.res\", line 109, characters 5-12", f12({____:0}), 1); - -Mt.from_pair_suites("File \"name_mangle_test.res\", line 112, characters 20-27", suites.contents); - -exports.suites = suites; -exports.test_id = test_id; -exports.eq = eq; -exports.f0 = f0; -exports.f1 = f1; -exports.f2 = f2; -exports.f3 = f3; -exports.f4 = f4; -exports.f5 = f5; -exports.f6 = f6; -exports.f7 = f7; -exports.f8 = f8; -exports.f9 = f9; -exports.f10 = f10; -exports.f11 = f11; -exports.f12 = f12; -/* Not a pure module */ diff --git a/tests/tests/src/name_mangle_test.mjs b/tests/tests/src/name_mangle_test.mjs new file mode 100644 index 0000000000..c632f343a6 --- /dev/null +++ b/tests/tests/src/name_mangle_test.mjs @@ -0,0 +1,152 @@ +// Generated by ReScript, PLEASE EDIT WITH CARE + +import * as Mt from "./mt.mjs"; + +let suites = { + contents: /* [] */0 +}; + +let test_id = { + contents: 0 +}; + +function eq(loc, x, y) { + test_id.contents = test_id.contents + 1 | 0; + suites.contents = { + hd: [ + loc + (" id " + test_id.contents.toString()), + () => ({ + TAG: "Eq", + _0: x, + _1: y + }) + ], + tl: suites.contents + }; +} + +function f0(x) { + let old = x._open; + x._open = old + 1 | 0; + return x._open; +} + +function f1(x) { + let old = x._in; + x._in = old + 1 | 0; + return x._in; +} + +function f2(x) { + let old = x._MAX_LENGTH; + x._MAX_LENGTH = old + 1 | 0; + return x._MAX_LENGTH; +} + +function f3(x) { + let old = x._Capital; + x._Capital = old + 1 | 0; + return x._Capital; +} + +function f4(x) { + let old = x._open__; + x._open__ = old + 1 | 0; + return x._open__; +} + +function f5(x) { + let old = x.open__; + x.open__ = old + 1 | 0; + return x.open__; +} + +function f6(x) { + let old = x["_'x"]; + x["_'x"] = old + 1 | 0; + return x["_'x"]; +} + +function f7(x) { + let old = x._Capital__; + x._Capital__ = old + 1 | 0; + return x._Capital__; +} + +function f8(x) { + let old = x._MAX__; + x._MAX__ = old + 1 | 0; + return x._MAX__; +} + +function f9(x) { + let old = x.__; + x.__ = old + 1 | 0; + return x.__; +} + +function f10(x) { + let old = x.__x; + x.__x = old + 1 | 0; + return x.__x; +} + +function f11(x) { + let old = x.___; + x.___ = old + 1 | 0; + return x.___; +} + +function f12(x) { + let old = x.____; + x.____ = old + 1 | 0; + return x.____; +} + +eq("File \"name_mangle_test.res\", line 97, characters 5-12", f0({_open:0}), 1); + +eq("File \"name_mangle_test.res\", line 98, characters 5-12", f1({_in:0}), 1); + +eq("File \"name_mangle_test.res\", line 99, characters 5-12", f2({_MAX_LENGTH:0}), 1); + +eq("File \"name_mangle_test.res\", line 100, characters 5-12", f3({_Capital:0}), 1); + +eq("File \"name_mangle_test.res\", line 101, characters 5-12", f4({_open__:0}), 1); + +eq("File \"name_mangle_test.res\", line 102, characters 5-12", f5({open__:0}), 1); + +eq("File \"name_mangle_test.res\", line 103, characters 5-12", f6({ "_'x" :0}), 1); + +eq("File \"name_mangle_test.res\", line 104, characters 5-12", f7({_Capital__:0}), 1); + +eq("File \"name_mangle_test.res\", line 105, characters 5-12", f8({_MAX__:0}), 1); + +eq("File \"name_mangle_test.res\", line 106, characters 5-12", f9({__:0}), 1); + +eq("File \"name_mangle_test.res\", line 107, characters 5-12", f10({__x:0}), 1); + +eq("File \"name_mangle_test.res\", line 108, characters 5-12", f11({___:0}), 1); + +eq("File \"name_mangle_test.res\", line 109, characters 5-12", f12({____:0}), 1); + +Mt.from_pair_suites("File \"name_mangle_test.res\", line 112, characters 20-27", suites.contents); + +export { + suites, + test_id, + eq, + f0, + f1, + f2, + f3, + f4, + f5, + f6, + f7, + f8, + f9, + f10, + f11, + f12, +} +/* Not a pure module */ diff --git a/tests/tests/src/nested_include.js b/tests/tests/src/nested_include.js deleted file mode 100644 index 2107e1e40b..0000000000 --- a/tests/tests/src/nested_include.js +++ /dev/null @@ -1,10 +0,0 @@ -// Generated by ReScript, PLEASE EDIT WITH CARE -'use strict'; - - -function f(x) { - return x; -} - -exports.f = f; -/* No side effect */ diff --git a/tests/tests/src/nested_include.mjs b/tests/tests/src/nested_include.mjs new file mode 100644 index 0000000000..66f8e6ee73 --- /dev/null +++ b/tests/tests/src/nested_include.mjs @@ -0,0 +1,11 @@ +// Generated by ReScript, PLEASE EDIT WITH CARE + + +function f(x) { + return x; +} + +export { + f, +} +/* No side effect */ diff --git a/tests/tests/src/nested_module_alias.js b/tests/tests/src/nested_module_alias.js deleted file mode 100644 index 83971cd474..0000000000 --- a/tests/tests/src/nested_module_alias.js +++ /dev/null @@ -1,17 +0,0 @@ -// Generated by ReScript, PLEASE EDIT WITH CARE -'use strict'; - -let Belt_List = require("rescript/lib/js/Belt_List.js"); - -function v(x) { - return [ - Belt_List.length(x), - Belt_List.length(x) - ]; -} - -let L; - -exports.L = L; -exports.v = v; -/* No side effect */ diff --git a/tests/tests/src/nested_module_alias.mjs b/tests/tests/src/nested_module_alias.mjs new file mode 100644 index 0000000000..446690811d --- /dev/null +++ b/tests/tests/src/nested_module_alias.mjs @@ -0,0 +1,18 @@ +// Generated by ReScript, PLEASE EDIT WITH CARE + +import * as Belt_List from "rescript/lib/es6/Belt_List.js"; + +function v(x) { + return [ + Belt_List.length(x), + Belt_List.length(x) + ]; +} + +let L; + +export { + L, + v, +} +/* No side effect */ diff --git a/tests/tests/src/nested_obj_literal.js b/tests/tests/src/nested_obj_literal.js deleted file mode 100644 index a6b2f626cb..0000000000 --- a/tests/tests/src/nested_obj_literal.js +++ /dev/null @@ -1,23 +0,0 @@ -// Generated by ReScript, PLEASE EDIT WITH CARE -'use strict'; - - -let structural_obj = { - x: { - y: { - z: 3 - } - } -}; - -let f_record = { - x: { - y: { - z: 3 - } - } -}; - -exports.structural_obj = structural_obj; -exports.f_record = f_record; -/* No side effect */ diff --git a/tests/tests/src/nested_obj_literal.mjs b/tests/tests/src/nested_obj_literal.mjs new file mode 100644 index 0000000000..21c853737e --- /dev/null +++ b/tests/tests/src/nested_obj_literal.mjs @@ -0,0 +1,24 @@ +// Generated by ReScript, PLEASE EDIT WITH CARE + + +let structural_obj = { + x: { + y: { + z: 3 + } + } +}; + +let f_record = { + x: { + y: { + z: 3 + } + } +}; + +export { + structural_obj, + f_record, +} +/* No side effect */ diff --git a/tests/tests/src/nested_obj_test.js b/tests/tests/src/nested_obj_test.js deleted file mode 100644 index c10b05ba77..0000000000 --- a/tests/tests/src/nested_obj_test.js +++ /dev/null @@ -1,75 +0,0 @@ -// Generated by ReScript, PLEASE EDIT WITH CARE -'use strict'; - - -let f = { - x: { - y: { - z: 3 - } - } -}; - -let f2_0 = { - hd: { - x: { - y: { - z: 3 - } - } - }, - tl: { - hd: { - x: { - y: { - z: 31 - } - } - }, - tl: /* [] */0 - } -}; - -let f2_1 = [ - { - x: { - y: { - z: 3 - } - } - }, - { - x: { - y: { - z: 31 - } - } - } -]; - -let f2 = [ - f2_0, - f2_1 -]; - -let f3 = { - x: { - y: { - z: 3 - } - } -}; - -let f_record = { - x: { - y: { - z: 3 - } - } -}; - -exports.f_record = f_record; -exports.f = f; -exports.f2 = f2; -exports.f3 = f3; -/* No side effect */ diff --git a/tests/tests/src/nested_obj_test.mjs b/tests/tests/src/nested_obj_test.mjs new file mode 100644 index 0000000000..cbc1e97d25 --- /dev/null +++ b/tests/tests/src/nested_obj_test.mjs @@ -0,0 +1,76 @@ +// Generated by ReScript, PLEASE EDIT WITH CARE + + +let f = { + x: { + y: { + z: 3 + } + } +}; + +let f2_0 = { + hd: { + x: { + y: { + z: 3 + } + } + }, + tl: { + hd: { + x: { + y: { + z: 31 + } + } + }, + tl: /* [] */0 + } +}; + +let f2_1 = [ + { + x: { + y: { + z: 3 + } + } + }, + { + x: { + y: { + z: 31 + } + } + } +]; + +let f2 = [ + f2_0, + f2_1 +]; + +let f3 = { + x: { + y: { + z: 3 + } + } +}; + +let f_record = { + x: { + y: { + z: 3 + } + } +}; + +export { + f_record, + f, + f2, + f3, +} +/* No side effect */ diff --git a/tests/tests/src/nested_pattern_match_test.js b/tests/tests/src/nested_pattern_match_test.js deleted file mode 100644 index 934a4e028b..0000000000 --- a/tests/tests/src/nested_pattern_match_test.js +++ /dev/null @@ -1,142 +0,0 @@ -// Generated by ReScript, PLEASE EDIT WITH CARE -'use strict'; - - -function f_list(x) { - if (!x) { - return 0; - } - let match = x.tl; - if (!match) { - return 0; - } - let match$1 = match.tl; - if (!match$1) { - return 0; - } - let match$2 = match$1.tl; - if (!match$2) { - return 0; - } - let match$3 = match$2.tl; - if (!match$3) { - return 0; - } - let match$4 = match$3.tl; - if (match$4) { - return ((((x.hd + match.hd | 0) + match$1.hd | 0) + match$2.hd | 0) + match$3.hd | 0) + match$4.hd | 0; - } else { - return 0; - } -} - -function f_arr(x) { - if (x.length !== 6) { - return 0; - } - let a0 = x[0]; - let a1 = x[1]; - let a2 = x[2]; - let a3 = x[3]; - let a4 = x[4]; - let a5 = x[5]; - return ((((a0 + a1 | 0) + a2 | 0) + a3 | 0) + a4 | 0) + a5 | 0; -} - -function f_opion(x) { - let match = x.hi; - if (match !== 2) { - if (match !== 3) { - return 0; - } - let match$1 = x.lo; - if (!match$1) { - return 0; - } - if (match$1.hd !== undefined) { - return 0; - } - let match$2 = match$1.tl; - if (!match$2) { - return 0; - } - if (match$2.hd !== undefined) { - return 0; - } - let match$3 = match$2.tl; - if (!match$3) { - return 0; - } - let match$4 = match$3.hd; - if (match$4 === undefined) { - return 0; - } - if (match$4 !== 2) { - return 0; - } - let match$5 = match$3.tl; - if (!match$5) { - return 0; - } - let match$6 = match$5.hd; - if (match$6 === undefined) { - return 0; - } - if (match$6 !== 1) { - return 0; - } - let match$7 = match$5.tl; - if (match$7 && match$7.hd !== undefined) { - return 2; - } else { - return 0; - } - } - let match$8 = x.lo; - if (!match$8) { - return 0; - } - if (match$8.hd !== undefined) { - return 0; - } - let match$9 = match$8.tl; - if (!match$9) { - return 0; - } - if (match$9.hd !== undefined) { - return 0; - } - let match$10 = match$9.tl; - if (!match$10) { - return 0; - } - let match$11 = match$10.hd; - if (match$11 === undefined) { - return 0; - } - if (match$11 !== 2) { - return 0; - } - let match$12 = match$10.tl; - if (!match$12) { - return 0; - } - let match$13 = match$12.hd; - if (match$13 === undefined) { - return 0; - } - if (match$13 !== 1) { - return 0; - } - let match$14 = match$12.tl; - if (match$14 && match$14.hd !== undefined) { - return 3; - } else { - return 0; - } -} - -exports.f_list = f_list; -exports.f_arr = f_arr; -exports.f_opion = f_opion; -/* No side effect */ diff --git a/tests/tests/src/nested_pattern_match_test.mjs b/tests/tests/src/nested_pattern_match_test.mjs new file mode 100644 index 0000000000..5fe0182b48 --- /dev/null +++ b/tests/tests/src/nested_pattern_match_test.mjs @@ -0,0 +1,143 @@ +// Generated by ReScript, PLEASE EDIT WITH CARE + + +function f_list(x) { + if (!x) { + return 0; + } + let match = x.tl; + if (!match) { + return 0; + } + let match$1 = match.tl; + if (!match$1) { + return 0; + } + let match$2 = match$1.tl; + if (!match$2) { + return 0; + } + let match$3 = match$2.tl; + if (!match$3) { + return 0; + } + let match$4 = match$3.tl; + if (match$4) { + return ((((x.hd + match.hd | 0) + match$1.hd | 0) + match$2.hd | 0) + match$3.hd | 0) + match$4.hd | 0; + } else { + return 0; + } +} + +function f_arr(x) { + if (x.length !== 6) { + return 0; + } + let a0 = x[0]; + let a1 = x[1]; + let a2 = x[2]; + let a3 = x[3]; + let a4 = x[4]; + let a5 = x[5]; + return ((((a0 + a1 | 0) + a2 | 0) + a3 | 0) + a4 | 0) + a5 | 0; +} + +function f_opion(x) { + let match = x.hi; + if (match !== 2) { + if (match !== 3) { + return 0; + } + let match$1 = x.lo; + if (!match$1) { + return 0; + } + if (match$1.hd !== undefined) { + return 0; + } + let match$2 = match$1.tl; + if (!match$2) { + return 0; + } + if (match$2.hd !== undefined) { + return 0; + } + let match$3 = match$2.tl; + if (!match$3) { + return 0; + } + let match$4 = match$3.hd; + if (match$4 === undefined) { + return 0; + } + if (match$4 !== 2) { + return 0; + } + let match$5 = match$3.tl; + if (!match$5) { + return 0; + } + let match$6 = match$5.hd; + if (match$6 === undefined) { + return 0; + } + if (match$6 !== 1) { + return 0; + } + let match$7 = match$5.tl; + if (match$7 && match$7.hd !== undefined) { + return 2; + } else { + return 0; + } + } + let match$8 = x.lo; + if (!match$8) { + return 0; + } + if (match$8.hd !== undefined) { + return 0; + } + let match$9 = match$8.tl; + if (!match$9) { + return 0; + } + if (match$9.hd !== undefined) { + return 0; + } + let match$10 = match$9.tl; + if (!match$10) { + return 0; + } + let match$11 = match$10.hd; + if (match$11 === undefined) { + return 0; + } + if (match$11 !== 2) { + return 0; + } + let match$12 = match$10.tl; + if (!match$12) { + return 0; + } + let match$13 = match$12.hd; + if (match$13 === undefined) { + return 0; + } + if (match$13 !== 1) { + return 0; + } + let match$14 = match$12.tl; + if (match$14 && match$14.hd !== undefined) { + return 3; + } else { + return 0; + } +} + +export { + f_list, + f_arr, + f_opion, +} +/* No side effect */ diff --git a/tests/tests/src/noassert.js b/tests/tests/src/noassert.js deleted file mode 100644 index 9626fa7296..0000000000 --- a/tests/tests/src/noassert.js +++ /dev/null @@ -1,23 +0,0 @@ -// Generated by ReScript, PLEASE EDIT WITH CARE -'use strict'; - - -function f() { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "noassert.res", - 1, - 14 - ], - Error: new Error() - }; -} - -function h() { - -} - -exports.f = f; -exports.h = h; -/* No side effect */ diff --git a/tests/tests/src/noassert.mjs b/tests/tests/src/noassert.mjs new file mode 100644 index 0000000000..1b4adeaceb --- /dev/null +++ b/tests/tests/src/noassert.mjs @@ -0,0 +1,24 @@ +// Generated by ReScript, PLEASE EDIT WITH CARE + + +function f() { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "noassert.res", + 1, + 14 + ], + Error: new Error() + }; +} + +function h() { + +} + +export { + f, + h, +} +/* No side effect */ diff --git a/tests/tests/src/node_assert.js b/tests/tests/src/node_assert.mjs similarity index 100% rename from tests/tests/src/node_assert.js rename to tests/tests/src/node_assert.mjs diff --git a/tests/tests/src/node_path_test.js b/tests/tests/src/node_path_test.js deleted file mode 100644 index f836175860..0000000000 --- a/tests/tests/src/node_path_test.js +++ /dev/null @@ -1,8 +0,0 @@ -// Generated by ReScript, PLEASE EDIT WITH CARE -'use strict'; - -let Path = require("path"); - -console.log(Path.join(".", "Node_path_test")); - -/* Not a pure module */ diff --git a/tests/tests/src/node_path_test.mjs b/tests/tests/src/node_path_test.mjs new file mode 100644 index 0000000000..0a2829b681 --- /dev/null +++ b/tests/tests/src/node_path_test.mjs @@ -0,0 +1,7 @@ +// Generated by ReScript, PLEASE EDIT WITH CARE + +import * as Path from "path"; + +console.log(Path.join(".", "Node_path_test")); + +/* Not a pure module */ diff --git a/tests/tests/src/obj_literal_ppx.js b/tests/tests/src/obj_literal_ppx.js deleted file mode 100644 index 2d58df4583..0000000000 --- a/tests/tests/src/obj_literal_ppx.js +++ /dev/null @@ -1,30 +0,0 @@ -// Generated by ReScript, PLEASE EDIT WITH CARE -'use strict'; - - -let a = { - x: 3, - y: [1] -}; - -let b = { - x: 3, - y: [1], - z: 3, - u: (x, y) => x + y | 0 -}; - -function f(obj) { - return obj.x + obj.y.length | 0; -} - -let u = f(a); - -let v = f(b); - -exports.a = a; -exports.b = b; -exports.f = f; -exports.u = u; -exports.v = v; -/* u Not a pure module */ diff --git a/tests/tests/src/obj_literal_ppx.mjs b/tests/tests/src/obj_literal_ppx.mjs new file mode 100644 index 0000000000..e3e2e82616 --- /dev/null +++ b/tests/tests/src/obj_literal_ppx.mjs @@ -0,0 +1,31 @@ +// Generated by ReScript, PLEASE EDIT WITH CARE + + +let a = { + x: 3, + y: [1] +}; + +let b = { + x: 3, + y: [1], + z: 3, + u: (x, y) => x + y | 0 +}; + +function f(obj) { + return obj.x + obj.y.length | 0; +} + +let u = f(a); + +let v = f(b); + +export { + a, + b, + f, + u, + v, +} +/* u Not a pure module */ diff --git a/tests/tests/src/obj_literal_ppx_test.js b/tests/tests/src/obj_literal_ppx_test.js deleted file mode 100644 index b71026113e..0000000000 --- a/tests/tests/src/obj_literal_ppx_test.js +++ /dev/null @@ -1,20 +0,0 @@ -// Generated by ReScript, PLEASE EDIT WITH CARE -'use strict'; - - -let a = { - x: 3, - y: { - hd: 1, - tl: { - hd: 2, - tl: { - hd: 3, - tl: /* [] */0 - } - } - } -}; - -exports.a = a; -/* No side effect */ diff --git a/tests/tests/src/obj_literal_ppx_test.mjs b/tests/tests/src/obj_literal_ppx_test.mjs new file mode 100644 index 0000000000..3bbb16c650 --- /dev/null +++ b/tests/tests/src/obj_literal_ppx_test.mjs @@ -0,0 +1,21 @@ +// Generated by ReScript, PLEASE EDIT WITH CARE + + +let a = { + x: 3, + y: { + hd: 1, + tl: { + hd: 2, + tl: { + hd: 3, + tl: /* [] */0 + } + } + } +}; + +export { + a, +} +/* No side effect */ diff --git a/tests/tests/src/obj_magic_test.js b/tests/tests/src/obj_magic_test.js deleted file mode 100644 index 7e6071f1f2..0000000000 --- a/tests/tests/src/obj_magic_test.js +++ /dev/null @@ -1,63 +0,0 @@ -// Generated by ReScript, PLEASE EDIT WITH CARE -'use strict'; - -let Mt = require("./mt.js"); - -function is_block(x) { - return typeof x !== "number"; -} - -let suites_0 = [ - "is_block_test1", - param => ({ - TAG: "Eq", - _0: false, - _1: "number" !== "number" - }) -]; - -let suites_1 = { - hd: [ - "is_block_test2", - param => ({ - TAG: "Eq", - _0: true, - _1: typeof ({ - hd: 3, - tl: /* [] */0 - }) !== "number" - }) - ], - tl: { - hd: [ - "is_block_test3", - param => ({ - TAG: "Eq", - _0: true, - _1: "string" !== "number" - }) - ], - tl: { - hd: [ - "is_block_test4", - param => ({ - TAG: "Eq", - _0: false, - _1: "number" !== "number" - }) - ], - tl: /* [] */0 - } - } -}; - -let suites = { - hd: suites_0, - tl: suites_1 -}; - -Mt.from_pair_suites("Obj_magic_test", suites); - -exports.is_block = is_block; -exports.suites = suites; -/* Not a pure module */ diff --git a/tests/tests/src/obj_magic_test.mjs b/tests/tests/src/obj_magic_test.mjs new file mode 100644 index 0000000000..b77c2c16e2 --- /dev/null +++ b/tests/tests/src/obj_magic_test.mjs @@ -0,0 +1,64 @@ +// Generated by ReScript, PLEASE EDIT WITH CARE + +import * as Mt from "./mt.mjs"; + +function is_block(x) { + return typeof x !== "number"; +} + +let suites_0 = [ + "is_block_test1", + param => ({ + TAG: "Eq", + _0: false, + _1: "number" !== "number" + }) +]; + +let suites_1 = { + hd: [ + "is_block_test2", + param => ({ + TAG: "Eq", + _0: true, + _1: typeof ({ + hd: 3, + tl: /* [] */0 + }) !== "number" + }) + ], + tl: { + hd: [ + "is_block_test3", + param => ({ + TAG: "Eq", + _0: true, + _1: "string" !== "number" + }) + ], + tl: { + hd: [ + "is_block_test4", + param => ({ + TAG: "Eq", + _0: false, + _1: "number" !== "number" + }) + ], + tl: /* [] */0 + } + } +}; + +let suites = { + hd: suites_0, + tl: suites_1 +}; + +Mt.from_pair_suites("Obj_magic_test", suites); + +export { + is_block, + suites, +} +/* Not a pure module */ diff --git a/tests/tests/src/obj_type_test.js b/tests/tests/src/obj_type_test.js deleted file mode 100644 index 7cabf0ecd1..0000000000 --- a/tests/tests/src/obj_type_test.js +++ /dev/null @@ -1,10 +0,0 @@ -// Generated by ReScript, PLEASE EDIT WITH CARE -'use strict'; - - -function f(u) { - return u; -} - -exports.f = f; -/* No side effect */ diff --git a/tests/tests/src/obj_type_test.mjs b/tests/tests/src/obj_type_test.mjs new file mode 100644 index 0000000000..138dee4724 --- /dev/null +++ b/tests/tests/src/obj_type_test.mjs @@ -0,0 +1,11 @@ +// Generated by ReScript, PLEASE EDIT WITH CARE + + +function f(u) { + return u; +} + +export { + f, +} +/* No side effect */ diff --git a/tests/tests/src/ocaml_compat/Ocaml_Array.js b/tests/tests/src/ocaml_compat/Ocaml_Array.js deleted file mode 100644 index 15cf696cd9..0000000000 --- a/tests/tests/src/ocaml_compat/Ocaml_Array.js +++ /dev/null @@ -1,480 +0,0 @@ -// Generated by ReScript, PLEASE EDIT WITH CARE -'use strict'; - -let Ocaml_List = require("./Ocaml_List.js"); -let Pervasives = require("rescript/lib/js/Pervasives.js"); -let Primitive_array = require("rescript/lib/js/Primitive_array.js"); -let Primitive_exceptions = require("rescript/lib/js/Primitive_exceptions.js"); - -let init = ((length, f) => Array.from({ length }, f)); - -function make(len, x) { - return init(len, param => x); -} - -function unsafe_sub(array, offset, length) { - return array.slice(offset, offset + length | 0); -} - -function concat(list) { - return Ocaml_List.fold_left((arr1, arr2) => arr1.concat(arr2), [], list); -} - -function create_float(len) { - return init(len, param => 0.0); -} - -function make_matrix(sx, sy, init$1) { - let x = []; - let res = init(sx, param => x); - for (let x$1 = 0; x$1 < sx; ++x$1) { - res[x$1] = init(sy, param => init$1); - } - return res; -} - -function append(a1, a2) { - let l1 = a1.length; - if (l1 === 0) { - return a2.slice(); - } else if (a2.length === 0) { - return unsafe_sub(a1, 0, l1); - } else { - return a1.concat(a2); - } -} - -function sub(a, ofs, len) { - if (ofs < 0 || len < 0 || ofs > (a.length - len | 0)) { - return Pervasives.invalid_arg("Array.sub"); - } else { - return unsafe_sub(a, ofs, len); - } -} - -function fill(a, ofs, len, v) { - if (ofs < 0 || len < 0 || ofs > (a.length - len | 0)) { - return Pervasives.invalid_arg("Array.fill"); - } - for (let i = ofs, i_finish = ofs + len | 0; i < i_finish; ++i) { - a[i] = v; - } -} - -function blit(a1, ofs1, a2, ofs2, len) { - if (len < 0 || ofs1 < 0 || ofs1 > (a1.length - len | 0) || ofs2 < 0 || ofs2 > (a2.length - len | 0)) { - return Pervasives.invalid_arg("Array.blit"); - } else { - for (let i = 0; i < len; ++i) { - a2[ofs2 + i | 0] = a1[ofs1 + i | 0]; - } - return; - } -} - -function iter(f, a) { - for (let i = 0, i_finish = a.length; i < i_finish; ++i) { - f(a[i]); - } -} - -function iter2(f, a, b) { - if (a.length !== b.length) { - return Pervasives.invalid_arg("Array.iter2: arrays must have the same length"); - } - for (let i = 0, i_finish = a.length; i < i_finish; ++i) { - f(a[i], b[i]); - } -} - -function map(f, a) { - let l = a.length; - if (l === 0) { - return []; - } - let x = f(a[0]); - let r = init(l, param => x); - for (let i = 1; i < l; ++i) { - r[i] = f(a[i]); - } - return r; -} - -function map2(f, a, b) { - let la = a.length; - let lb = b.length; - if (la !== lb) { - return Pervasives.invalid_arg("Array.map2: arrays must have the same length"); - } - if (la === 0) { - return []; - } - let x = f(a[0], b[0]); - let r = init(la, param => x); - for (let i = 1; i < la; ++i) { - r[i] = f(a[i], b[i]); - } - return r; -} - -function iteri(f, a) { - for (let i = 0, i_finish = a.length; i < i_finish; ++i) { - f(i, a[i]); - } -} - -function mapi(f, a) { - let l = a.length; - if (l === 0) { - return []; - } - let x = f(0, a[0]); - let r = init(l, param => x); - for (let i = 1; i < l; ++i) { - r[i] = f(i, a[i]); - } - return r; -} - -function to_list(a) { - let _i = a.length - 1 | 0; - let _res = /* [] */0; - while (true) { - let res = _res; - let i = _i; - if (i < 0) { - return res; - } - _res = { - hd: a[i], - tl: res - }; - _i = i - 1 | 0; - continue; - }; -} - -function list_length(_accu, _param) { - while (true) { - let param = _param; - let accu = _accu; - if (!param) { - return accu; - } - _param = param.tl; - _accu = accu + 1 | 0; - continue; - }; -} - -function of_list(param) { - if (!param) { - return []; - } - let hd = param.hd; - let len = list_length(0, param); - let a = init(len, param => hd); - let _i = 1; - let _param = param.tl; - while (true) { - let param$1 = _param; - let i = _i; - if (!param$1) { - return a; - } - a[i] = param$1.hd; - _param = param$1.tl; - _i = i + 1 | 0; - continue; - }; -} - -function fold_left(f, x, a) { - let r = x; - for (let i = 0, i_finish = a.length; i < i_finish; ++i) { - r = f(r, a[i]); - } - return r; -} - -function fold_right(f, a, x) { - let r = x; - for (let i = a.length - 1 | 0; i >= 0; --i) { - r = f(a[i], r); - } - return r; -} - -function exists(p, a) { - let n = a.length; - let _i = 0; - while (true) { - let i = _i; - if (i === n) { - return false; - } - if (p(a[i])) { - return true; - } - _i = i + 1 | 0; - continue; - }; -} - -function for_all(p, a) { - let n = a.length; - let _i = 0; - while (true) { - let i = _i; - if (i === n) { - return true; - } - if (!p(a[i])) { - return false; - } - _i = i + 1 | 0; - continue; - }; -} - -function mem(x, a) { - let n = a.length; - let _i = 0; - while (true) { - let i = _i; - if (i === n) { - return false; - } - if (a[i] === x) { - return true; - } - _i = i + 1 | 0; - continue; - }; -} - -function memq(x, a) { - let n = a.length; - let _i = 0; - while (true) { - let i = _i; - if (i === n) { - return false; - } - if (x === a[i]) { - return true; - } - _i = i + 1 | 0; - continue; - }; -} - -let Bottom = /* @__PURE__ */Primitive_exceptions.create("Ocaml_Array.Bottom"); - -function sort(cmp, a) { - let maxson = (l, i) => { - let i31 = ((i + i | 0) + i | 0) + 1 | 0; - let x = i31; - if ((i31 + 2 | 0) < l) { - if (cmp(Primitive_array.get(a, i31), Primitive_array.get(a, i31 + 1 | 0)) < 0) { - x = i31 + 1 | 0; - } - if (cmp(Primitive_array.get(a, x), Primitive_array.get(a, i31 + 2 | 0)) < 0) { - x = i31 + 2 | 0; - } - return x; - } - if ((i31 + 1 | 0) < l && cmp(Primitive_array.get(a, i31), Primitive_array.get(a, i31 + 1 | 0)) < 0) { - return i31 + 1 | 0; - } - if (i31 < l) { - return i31; - } - throw { - RE_EXN_ID: Bottom, - _1: i, - Error: new Error() - }; - }; - let trickle = (l, i, e) => { - try { - let _i = i; - while (true) { - let i$1 = _i; - let j = maxson(l, i$1); - if (cmp(Primitive_array.get(a, j), e) <= 0) { - return Primitive_array.set(a, i$1, e); - } - Primitive_array.set(a, i$1, Primitive_array.get(a, j)); - _i = j; - continue; - }; - } catch (raw_i) { - let i$2 = Primitive_exceptions.internalToException(raw_i); - if (i$2.RE_EXN_ID === Bottom) { - return Primitive_array.set(a, i$2._1, e); - } - throw i$2; - } - }; - let bubble = (l, i) => { - try { - let _i = i; - while (true) { - let i$1 = _i; - let j = maxson(l, i$1); - Primitive_array.set(a, i$1, Primitive_array.get(a, j)); - _i = j; - continue; - }; - } catch (raw_i) { - let i$2 = Primitive_exceptions.internalToException(raw_i); - if (i$2.RE_EXN_ID === Bottom) { - return i$2._1; - } - throw i$2; - } - }; - let trickleup = (_i, e) => { - while (true) { - let i = _i; - let father = (i - 1 | 0) / 3 | 0; - if (i === father) { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "Ocaml_Array.res", - 296, - 4 - ], - Error: new Error() - }; - } - if (cmp(Primitive_array.get(a, father), e) >= 0) { - return Primitive_array.set(a, i, e); - } - Primitive_array.set(a, i, Primitive_array.get(a, father)); - if (father <= 0) { - return Primitive_array.set(a, 0, e); - } - _i = father; - continue; - }; - }; - let l = a.length; - for (let i = ((l + 1 | 0) / 3 | 0) - 1 | 0; i >= 0; --i) { - trickle(l, i, Primitive_array.get(a, i)); - } - for (let i$1 = l - 1 | 0; i$1 >= 2; --i$1) { - let e = Primitive_array.get(a, i$1); - Primitive_array.set(a, i$1, Primitive_array.get(a, 0)); - trickleup(bubble(i$1, 0), e); - } - if (l <= 1) { - return; - } - let e$1 = Primitive_array.get(a, 1); - Primitive_array.set(a, 1, Primitive_array.get(a, 0)); - Primitive_array.set(a, 0, e$1); -} - -function stable_sort(cmp, a) { - let merge = (src1ofs, src1len, src2, src2ofs, src2len, dst, dstofs) => { - let src1r = src1ofs + src1len | 0; - let src2r = src2ofs + src2len | 0; - let _i1 = src1ofs; - let _s1 = Primitive_array.get(a, src1ofs); - let _i2 = src2ofs; - let _s2 = Primitive_array.get(src2, src2ofs); - let _d = dstofs; - while (true) { - let d = _d; - let s2 = _s2; - let i2 = _i2; - let s1 = _s1; - let i1 = _i1; - if (cmp(s1, s2) <= 0) { - Primitive_array.set(dst, d, s1); - let i1$1 = i1 + 1 | 0; - if (i1$1 >= src1r) { - return blit(src2, i2, dst, d + 1 | 0, src2r - i2 | 0); - } - _d = d + 1 | 0; - _s1 = Primitive_array.get(a, i1$1); - _i1 = i1$1; - continue; - } - Primitive_array.set(dst, d, s2); - let i2$1 = i2 + 1 | 0; - if (i2$1 >= src2r) { - return blit(a, i1, dst, d + 1 | 0, src1r - i1 | 0); - } - _d = d + 1 | 0; - _s2 = Primitive_array.get(src2, i2$1); - _i2 = i2$1; - continue; - }; - }; - let isortto = (srcofs, dst, dstofs, len) => { - for (let i = 0; i < len; ++i) { - let e = Primitive_array.get(a, srcofs + i | 0); - let j = (dstofs + i | 0) - 1 | 0; - while (j >= dstofs && cmp(Primitive_array.get(dst, j), e) > 0) { - Primitive_array.set(dst, j + 1 | 0, Primitive_array.get(dst, j)); - j = j - 1 | 0; - }; - Primitive_array.set(dst, j + 1 | 0, e); - } - }; - let sortto = (srcofs, dst, dstofs, len) => { - if (len <= 5) { - return isortto(srcofs, dst, dstofs, len); - } - let l1 = len / 2 | 0; - let l2 = len - l1 | 0; - sortto(srcofs + l1 | 0, dst, dstofs + l1 | 0, l2); - sortto(srcofs, a, srcofs + l2 | 0, l1); - merge(srcofs + l2 | 0, l1, dst, dstofs + l1 | 0, l2, dst, dstofs); - }; - let l = a.length; - if (l <= 5) { - return isortto(0, a, 0, l); - } - let l1 = l / 2 | 0; - let l2 = l - l1 | 0; - let x = Primitive_array.get(a, 0); - let t = init(l2, param => x); - sortto(l1, t, 0, l2); - sortto(0, a, l2, l1); - merge(l2, l1, t, 0, l2, a, 0); -} - -let fast_sort = stable_sort; - -exports.make = make; -exports.create_float = create_float; -exports.init = init; -exports.make_matrix = make_matrix; -exports.append = append; -exports.concat = concat; -exports.sub = sub; -exports.fill = fill; -exports.blit = blit; -exports.to_list = to_list; -exports.of_list = of_list; -exports.iter = iter; -exports.iteri = iteri; -exports.map = map; -exports.mapi = mapi; -exports.fold_left = fold_left; -exports.fold_right = fold_right; -exports.iter2 = iter2; -exports.map2 = map2; -exports.for_all = for_all; -exports.exists = exists; -exports.mem = mem; -exports.memq = memq; -exports.sort = sort; -exports.stable_sort = stable_sort; -exports.fast_sort = fast_sort; -/* No side effect */ diff --git a/tests/tests/src/ocaml_compat/Ocaml_Array.mjs b/tests/tests/src/ocaml_compat/Ocaml_Array.mjs new file mode 100644 index 0000000000..7fb5f35aa4 --- /dev/null +++ b/tests/tests/src/ocaml_compat/Ocaml_Array.mjs @@ -0,0 +1,481 @@ +// Generated by ReScript, PLEASE EDIT WITH CARE + +import * as Ocaml_List from "./Ocaml_List.mjs"; +import * as Pervasives from "rescript/lib/es6/Pervasives.js"; +import * as Primitive_array from "rescript/lib/es6/Primitive_array.js"; +import * as Primitive_exceptions from "rescript/lib/es6/Primitive_exceptions.js"; + +let init = ((length, f) => Array.from({ length }, f)); + +function make(len, x) { + return init(len, param => x); +} + +function unsafe_sub(array, offset, length) { + return array.slice(offset, offset + length | 0); +} + +function concat(list) { + return Ocaml_List.fold_left((arr1, arr2) => arr1.concat(arr2), [], list); +} + +function create_float(len) { + return init(len, param => 0.0); +} + +function make_matrix(sx, sy, init$1) { + let x = []; + let res = init(sx, param => x); + for (let x$1 = 0; x$1 < sx; ++x$1) { + res[x$1] = init(sy, param => init$1); + } + return res; +} + +function append(a1, a2) { + let l1 = a1.length; + if (l1 === 0) { + return a2.slice(); + } else if (a2.length === 0) { + return unsafe_sub(a1, 0, l1); + } else { + return a1.concat(a2); + } +} + +function sub(a, ofs, len) { + if (ofs < 0 || len < 0 || ofs > (a.length - len | 0)) { + return Pervasives.invalid_arg("Array.sub"); + } else { + return unsafe_sub(a, ofs, len); + } +} + +function fill(a, ofs, len, v) { + if (ofs < 0 || len < 0 || ofs > (a.length - len | 0)) { + return Pervasives.invalid_arg("Array.fill"); + } + for (let i = ofs, i_finish = ofs + len | 0; i < i_finish; ++i) { + a[i] = v; + } +} + +function blit(a1, ofs1, a2, ofs2, len) { + if (len < 0 || ofs1 < 0 || ofs1 > (a1.length - len | 0) || ofs2 < 0 || ofs2 > (a2.length - len | 0)) { + return Pervasives.invalid_arg("Array.blit"); + } else { + for (let i = 0; i < len; ++i) { + a2[ofs2 + i | 0] = a1[ofs1 + i | 0]; + } + return; + } +} + +function iter(f, a) { + for (let i = 0, i_finish = a.length; i < i_finish; ++i) { + f(a[i]); + } +} + +function iter2(f, a, b) { + if (a.length !== b.length) { + return Pervasives.invalid_arg("Array.iter2: arrays must have the same length"); + } + for (let i = 0, i_finish = a.length; i < i_finish; ++i) { + f(a[i], b[i]); + } +} + +function map(f, a) { + let l = a.length; + if (l === 0) { + return []; + } + let x = f(a[0]); + let r = init(l, param => x); + for (let i = 1; i < l; ++i) { + r[i] = f(a[i]); + } + return r; +} + +function map2(f, a, b) { + let la = a.length; + let lb = b.length; + if (la !== lb) { + return Pervasives.invalid_arg("Array.map2: arrays must have the same length"); + } + if (la === 0) { + return []; + } + let x = f(a[0], b[0]); + let r = init(la, param => x); + for (let i = 1; i < la; ++i) { + r[i] = f(a[i], b[i]); + } + return r; +} + +function iteri(f, a) { + for (let i = 0, i_finish = a.length; i < i_finish; ++i) { + f(i, a[i]); + } +} + +function mapi(f, a) { + let l = a.length; + if (l === 0) { + return []; + } + let x = f(0, a[0]); + let r = init(l, param => x); + for (let i = 1; i < l; ++i) { + r[i] = f(i, a[i]); + } + return r; +} + +function to_list(a) { + let _i = a.length - 1 | 0; + let _res = /* [] */0; + while (true) { + let res = _res; + let i = _i; + if (i < 0) { + return res; + } + _res = { + hd: a[i], + tl: res + }; + _i = i - 1 | 0; + continue; + }; +} + +function list_length(_accu, _param) { + while (true) { + let param = _param; + let accu = _accu; + if (!param) { + return accu; + } + _param = param.tl; + _accu = accu + 1 | 0; + continue; + }; +} + +function of_list(param) { + if (!param) { + return []; + } + let hd = param.hd; + let len = list_length(0, param); + let a = init(len, param => hd); + let _i = 1; + let _param = param.tl; + while (true) { + let param$1 = _param; + let i = _i; + if (!param$1) { + return a; + } + a[i] = param$1.hd; + _param = param$1.tl; + _i = i + 1 | 0; + continue; + }; +} + +function fold_left(f, x, a) { + let r = x; + for (let i = 0, i_finish = a.length; i < i_finish; ++i) { + r = f(r, a[i]); + } + return r; +} + +function fold_right(f, a, x) { + let r = x; + for (let i = a.length - 1 | 0; i >= 0; --i) { + r = f(a[i], r); + } + return r; +} + +function exists(p, a) { + let n = a.length; + let _i = 0; + while (true) { + let i = _i; + if (i === n) { + return false; + } + if (p(a[i])) { + return true; + } + _i = i + 1 | 0; + continue; + }; +} + +function for_all(p, a) { + let n = a.length; + let _i = 0; + while (true) { + let i = _i; + if (i === n) { + return true; + } + if (!p(a[i])) { + return false; + } + _i = i + 1 | 0; + continue; + }; +} + +function mem(x, a) { + let n = a.length; + let _i = 0; + while (true) { + let i = _i; + if (i === n) { + return false; + } + if (a[i] === x) { + return true; + } + _i = i + 1 | 0; + continue; + }; +} + +function memq(x, a) { + let n = a.length; + let _i = 0; + while (true) { + let i = _i; + if (i === n) { + return false; + } + if (x === a[i]) { + return true; + } + _i = i + 1 | 0; + continue; + }; +} + +let Bottom = /* @__PURE__ */Primitive_exceptions.create("Ocaml_Array.Bottom"); + +function sort(cmp, a) { + let maxson = (l, i) => { + let i31 = ((i + i | 0) + i | 0) + 1 | 0; + let x = i31; + if ((i31 + 2 | 0) < l) { + if (cmp(Primitive_array.get(a, i31), Primitive_array.get(a, i31 + 1 | 0)) < 0) { + x = i31 + 1 | 0; + } + if (cmp(Primitive_array.get(a, x), Primitive_array.get(a, i31 + 2 | 0)) < 0) { + x = i31 + 2 | 0; + } + return x; + } + if ((i31 + 1 | 0) < l && cmp(Primitive_array.get(a, i31), Primitive_array.get(a, i31 + 1 | 0)) < 0) { + return i31 + 1 | 0; + } + if (i31 < l) { + return i31; + } + throw { + RE_EXN_ID: Bottom, + _1: i, + Error: new Error() + }; + }; + let trickle = (l, i, e) => { + try { + let _i = i; + while (true) { + let i$1 = _i; + let j = maxson(l, i$1); + if (cmp(Primitive_array.get(a, j), e) <= 0) { + return Primitive_array.set(a, i$1, e); + } + Primitive_array.set(a, i$1, Primitive_array.get(a, j)); + _i = j; + continue; + }; + } catch (raw_i) { + let i$2 = Primitive_exceptions.internalToException(raw_i); + if (i$2.RE_EXN_ID === Bottom) { + return Primitive_array.set(a, i$2._1, e); + } + throw i$2; + } + }; + let bubble = (l, i) => { + try { + let _i = i; + while (true) { + let i$1 = _i; + let j = maxson(l, i$1); + Primitive_array.set(a, i$1, Primitive_array.get(a, j)); + _i = j; + continue; + }; + } catch (raw_i) { + let i$2 = Primitive_exceptions.internalToException(raw_i); + if (i$2.RE_EXN_ID === Bottom) { + return i$2._1; + } + throw i$2; + } + }; + let trickleup = (_i, e) => { + while (true) { + let i = _i; + let father = (i - 1 | 0) / 3 | 0; + if (i === father) { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "Ocaml_Array.res", + 296, + 4 + ], + Error: new Error() + }; + } + if (cmp(Primitive_array.get(a, father), e) >= 0) { + return Primitive_array.set(a, i, e); + } + Primitive_array.set(a, i, Primitive_array.get(a, father)); + if (father <= 0) { + return Primitive_array.set(a, 0, e); + } + _i = father; + continue; + }; + }; + let l = a.length; + for (let i = ((l + 1 | 0) / 3 | 0) - 1 | 0; i >= 0; --i) { + trickle(l, i, Primitive_array.get(a, i)); + } + for (let i$1 = l - 1 | 0; i$1 >= 2; --i$1) { + let e = Primitive_array.get(a, i$1); + Primitive_array.set(a, i$1, Primitive_array.get(a, 0)); + trickleup(bubble(i$1, 0), e); + } + if (l <= 1) { + return; + } + let e$1 = Primitive_array.get(a, 1); + Primitive_array.set(a, 1, Primitive_array.get(a, 0)); + Primitive_array.set(a, 0, e$1); +} + +function stable_sort(cmp, a) { + let merge = (src1ofs, src1len, src2, src2ofs, src2len, dst, dstofs) => { + let src1r = src1ofs + src1len | 0; + let src2r = src2ofs + src2len | 0; + let _i1 = src1ofs; + let _s1 = Primitive_array.get(a, src1ofs); + let _i2 = src2ofs; + let _s2 = Primitive_array.get(src2, src2ofs); + let _d = dstofs; + while (true) { + let d = _d; + let s2 = _s2; + let i2 = _i2; + let s1 = _s1; + let i1 = _i1; + if (cmp(s1, s2) <= 0) { + Primitive_array.set(dst, d, s1); + let i1$1 = i1 + 1 | 0; + if (i1$1 >= src1r) { + return blit(src2, i2, dst, d + 1 | 0, src2r - i2 | 0); + } + _d = d + 1 | 0; + _s1 = Primitive_array.get(a, i1$1); + _i1 = i1$1; + continue; + } + Primitive_array.set(dst, d, s2); + let i2$1 = i2 + 1 | 0; + if (i2$1 >= src2r) { + return blit(a, i1, dst, d + 1 | 0, src1r - i1 | 0); + } + _d = d + 1 | 0; + _s2 = Primitive_array.get(src2, i2$1); + _i2 = i2$1; + continue; + }; + }; + let isortto = (srcofs, dst, dstofs, len) => { + for (let i = 0; i < len; ++i) { + let e = Primitive_array.get(a, srcofs + i | 0); + let j = (dstofs + i | 0) - 1 | 0; + while (j >= dstofs && cmp(Primitive_array.get(dst, j), e) > 0) { + Primitive_array.set(dst, j + 1 | 0, Primitive_array.get(dst, j)); + j = j - 1 | 0; + }; + Primitive_array.set(dst, j + 1 | 0, e); + } + }; + let sortto = (srcofs, dst, dstofs, len) => { + if (len <= 5) { + return isortto(srcofs, dst, dstofs, len); + } + let l1 = len / 2 | 0; + let l2 = len - l1 | 0; + sortto(srcofs + l1 | 0, dst, dstofs + l1 | 0, l2); + sortto(srcofs, a, srcofs + l2 | 0, l1); + merge(srcofs + l2 | 0, l1, dst, dstofs + l1 | 0, l2, dst, dstofs); + }; + let l = a.length; + if (l <= 5) { + return isortto(0, a, 0, l); + } + let l1 = l / 2 | 0; + let l2 = l - l1 | 0; + let x = Primitive_array.get(a, 0); + let t = init(l2, param => x); + sortto(l1, t, 0, l2); + sortto(0, a, l2, l1); + merge(l2, l1, t, 0, l2, a, 0); +} + +let fast_sort = stable_sort; + +export { + make, + create_float, + init, + make_matrix, + append, + concat, + sub, + fill, + blit, + to_list, + of_list, + iter, + iteri, + map, + mapi, + fold_left, + fold_right, + iter2, + map2, + for_all, + exists, + mem, + memq, + sort, + stable_sort, + fast_sort, +} +/* No side effect */ diff --git a/tests/tests/src/ocaml_compat/Ocaml_Hashtbl.js b/tests/tests/src/ocaml_compat/Ocaml_Hashtbl.js deleted file mode 100644 index bdc1ba676a..0000000000 --- a/tests/tests/src/ocaml_compat/Ocaml_Hashtbl.js +++ /dev/null @@ -1,11 +0,0 @@ -// Generated by ReScript, PLEASE EDIT WITH CARE -'use strict'; - -let Primitive_hash = require("rescript/lib/js/Primitive_hash.js"); - -function hash(x) { - return Primitive_hash.hash(10, 100, 0, x); -} - -exports.hash = hash; -/* No side effect */ diff --git a/tests/tests/src/ocaml_compat/Ocaml_Hashtbl.mjs b/tests/tests/src/ocaml_compat/Ocaml_Hashtbl.mjs new file mode 100644 index 0000000000..9afbe2d520 --- /dev/null +++ b/tests/tests/src/ocaml_compat/Ocaml_Hashtbl.mjs @@ -0,0 +1,12 @@ +// Generated by ReScript, PLEASE EDIT WITH CARE + +import * as Primitive_hash from "rescript/lib/es6/Primitive_hash.js"; + +function hash(x) { + return Primitive_hash.hash(10, 100, 0, x); +} + +export { + hash, +} +/* No side effect */ diff --git a/tests/tests/src/ocaml_compat/Ocaml_List.js b/tests/tests/src/ocaml_compat/Ocaml_List.js deleted file mode 100644 index e0dbc3d73e..0000000000 --- a/tests/tests/src/ocaml_compat/Ocaml_List.js +++ /dev/null @@ -1,1629 +0,0 @@ -// Generated by ReScript, PLEASE EDIT WITH CARE -'use strict'; - -let Pervasives = require("rescript/lib/js/Pervasives.js"); -let Primitive_option = require("rescript/lib/js/Primitive_option.js"); - -function length(l) { - let _len = 0; - let _param = l; - while (true) { - let param = _param; - let len = _len; - if (!param) { - return len; - } - _param = param.tl; - _len = len + 1 | 0; - continue; - }; -} - -function cons(a, l) { - return { - hd: a, - tl: l - }; -} - -function hd(param) { - if (param) { - return param.hd; - } else { - return Pervasives.failwith("hd"); - } -} - -function tl(param) { - if (param) { - return param.tl; - } else { - return Pervasives.failwith("tl"); - } -} - -function nth(l, n) { - if (n < 0) { - return Pervasives.invalid_arg("List.nth"); - } - let _l = l; - let _n = n; - while (true) { - let n$1 = _n; - let l$1 = _l; - if (!l$1) { - return Pervasives.failwith("nth"); - } - if (n$1 === 0) { - return l$1.hd; - } - _n = n$1 - 1 | 0; - _l = l$1.tl; - continue; - }; -} - -function nth_opt(l, n) { - if (n < 0) { - return Pervasives.invalid_arg("List.nth"); - } - let _l = l; - let _n = n; - while (true) { - let n$1 = _n; - let l$1 = _l; - if (!l$1) { - return; - } - if (n$1 === 0) { - return Primitive_option.some(l$1.hd); - } - _n = n$1 - 1 | 0; - _l = l$1.tl; - continue; - }; -} - -function rev_append(_l1, _l2) { - while (true) { - let l2 = _l2; - let l1 = _l1; - if (!l1) { - return l2; - } - _l2 = { - hd: l1.hd, - tl: l2 - }; - _l1 = l1.tl; - continue; - }; -} - -function rev(l) { - return rev_append(l, /* [] */0); -} - -function init_tailrec_aux(_acc, _i, n, f) { - while (true) { - let i = _i; - let acc = _acc; - if (i >= n) { - return acc; - } - _i = i + 1 | 0; - _acc = { - hd: f(i), - tl: acc - }; - continue; - }; -} - -function init_aux(i, n, f) { - if (i >= n) { - return /* [] */0; - } - let r = f(i); - return { - hd: r, - tl: init_aux(i + 1 | 0, n, f) - }; -} - -function init(len, f) { - if (len < 0) { - return Pervasives.invalid_arg("List.init"); - } else if (len > 10000) { - return rev_append(init_tailrec_aux(/* [] */0, 0, len, f), /* [] */0); - } else { - return init_aux(0, len, f); - } -} - -function flatten(param) { - if (param) { - return Pervasives.$at(param.hd, flatten(param.tl)); - } else { - return /* [] */0; - } -} - -function map(f, param) { - if (!param) { - return /* [] */0; - } - let r = f(param.hd); - return { - hd: r, - tl: map(f, param.tl) - }; -} - -function mapi(i, f, param) { - if (!param) { - return /* [] */0; - } - let r = f(i, param.hd); - return { - hd: r, - tl: mapi(i + 1 | 0, f, param.tl) - }; -} - -function mapi$1(f, l) { - return mapi(0, f, l); -} - -function rev_map(f, l) { - let _accu = /* [] */0; - let _param = l; - while (true) { - let param = _param; - let accu = _accu; - if (!param) { - return accu; - } - _param = param.tl; - _accu = { - hd: f(param.hd), - tl: accu - }; - continue; - }; -} - -function iter(f, _param) { - while (true) { - let param = _param; - if (!param) { - return; - } - f(param.hd); - _param = param.tl; - continue; - }; -} - -function iteri(f, l) { - let _i = 0; - let _param = l; - while (true) { - let param = _param; - let i = _i; - if (!param) { - return; - } - f(i, param.hd); - _param = param.tl; - _i = i + 1 | 0; - continue; - }; -} - -function fold_left(f, _accu, _l) { - while (true) { - let l = _l; - let accu = _accu; - if (!l) { - return accu; - } - _l = l.tl; - _accu = f(accu, l.hd); - continue; - }; -} - -function fold_right(f, l, accu) { - if (l) { - return f(l.hd, fold_right(f, l.tl, accu)); - } else { - return accu; - } -} - -function map2(f, l1, l2) { - if (!l1) { - if (l2) { - return Pervasives.invalid_arg("List.map2"); - } else { - return /* [] */0; - } - } - if (!l2) { - return Pervasives.invalid_arg("List.map2"); - } - let r = f(l1.hd, l2.hd); - return { - hd: r, - tl: map2(f, l1.tl, l2.tl) - }; -} - -function rev_map2(f, l1, l2) { - let _accu = /* [] */0; - let _l1 = l1; - let _l2 = l2; - while (true) { - let l2$1 = _l2; - let l1$1 = _l1; - let accu = _accu; - if (!l1$1) { - if (l2$1) { - return Pervasives.invalid_arg("List.rev_map2"); - } else { - return accu; - } - } - if (!l2$1) { - return Pervasives.invalid_arg("List.rev_map2"); - } - _l2 = l2$1.tl; - _l1 = l1$1.tl; - _accu = { - hd: f(l1$1.hd, l2$1.hd), - tl: accu - }; - continue; - }; -} - -function iter2(f, _l1, _l2) { - while (true) { - let l2 = _l2; - let l1 = _l1; - if (!l1) { - if (l2) { - return Pervasives.invalid_arg("List.iter2"); - } else { - return; - } - } - if (!l2) { - return Pervasives.invalid_arg("List.iter2"); - } - f(l1.hd, l2.hd); - _l2 = l2.tl; - _l1 = l1.tl; - continue; - }; -} - -function fold_left2(f, _accu, _l1, _l2) { - while (true) { - let l2 = _l2; - let l1 = _l1; - let accu = _accu; - if (!l1) { - if (l2) { - return Pervasives.invalid_arg("List.fold_left2"); - } else { - return accu; - } - } - if (!l2) { - return Pervasives.invalid_arg("List.fold_left2"); - } - _l2 = l2.tl; - _l1 = l1.tl; - _accu = f(accu, l1.hd, l2.hd); - continue; - }; -} - -function fold_right2(f, l1, l2, accu) { - if (l1) { - if (l2) { - return f(l1.hd, l2.hd, fold_right2(f, l1.tl, l2.tl, accu)); - } else { - return Pervasives.invalid_arg("List.fold_right2"); - } - } else if (l2) { - return Pervasives.invalid_arg("List.fold_right2"); - } else { - return accu; - } -} - -function for_all(p, _param) { - while (true) { - let param = _param; - if (!param) { - return true; - } - if (!p(param.hd)) { - return false; - } - _param = param.tl; - continue; - }; -} - -function exists(p, _param) { - while (true) { - let param = _param; - if (!param) { - return false; - } - if (p(param.hd)) { - return true; - } - _param = param.tl; - continue; - }; -} - -function for_all2(p, _l1, _l2) { - while (true) { - let l2 = _l2; - let l1 = _l1; - if (!l1) { - if (l2) { - return Pervasives.invalid_arg("List.for_all2"); - } else { - return true; - } - } - if (!l2) { - return Pervasives.invalid_arg("List.for_all2"); - } - if (!p(l1.hd, l2.hd)) { - return false; - } - _l2 = l2.tl; - _l1 = l1.tl; - continue; - }; -} - -function exists2(p, _l1, _l2) { - while (true) { - let l2 = _l2; - let l1 = _l1; - if (!l1) { - if (l2) { - return Pervasives.invalid_arg("List.exists2"); - } else { - return false; - } - } - if (!l2) { - return Pervasives.invalid_arg("List.exists2"); - } - if (p(l1.hd, l2.hd)) { - return true; - } - _l2 = l2.tl; - _l1 = l1.tl; - continue; - }; -} - -function mem(x, _param) { - while (true) { - let param = _param; - if (!param) { - return false; - } - if (param.hd === x) { - return true; - } - _param = param.tl; - continue; - }; -} - -function memq(x, _param) { - while (true) { - let param = _param; - if (!param) { - return false; - } - if (param.hd === x) { - return true; - } - _param = param.tl; - continue; - }; -} - -function assoc(x, _param) { - while (true) { - let param = _param; - if (param) { - let match = param.hd; - if (match[0] === x) { - return match[1]; - } - _param = param.tl; - continue; - } - throw { - RE_EXN_ID: "Not_found", - Error: new Error() - }; - }; -} - -function assoc_opt(x, _param) { - while (true) { - let param = _param; - if (!param) { - return; - } - let match = param.hd; - if (match[0] === x) { - return Primitive_option.some(match[1]); - } - _param = param.tl; - continue; - }; -} - -function assq(x, _param) { - while (true) { - let param = _param; - if (param) { - let match = param.hd; - if (match[0] === x) { - return match[1]; - } - _param = param.tl; - continue; - } - throw { - RE_EXN_ID: "Not_found", - Error: new Error() - }; - }; -} - -function assq_opt(x, _param) { - while (true) { - let param = _param; - if (!param) { - return; - } - let match = param.hd; - if (match[0] === x) { - return Primitive_option.some(match[1]); - } - _param = param.tl; - continue; - }; -} - -function mem_assoc(x, _param) { - while (true) { - let param = _param; - if (!param) { - return false; - } - if (param.hd[0] === x) { - return true; - } - _param = param.tl; - continue; - }; -} - -function mem_assq(x, _param) { - while (true) { - let param = _param; - if (!param) { - return false; - } - if (param.hd[0] === x) { - return true; - } - _param = param.tl; - continue; - }; -} - -function remove_assoc(x, param) { - if (!param) { - return /* [] */0; - } - let l = param.tl; - let pair = param.hd; - if (pair[0] === x) { - return l; - } else { - return { - hd: pair, - tl: remove_assoc(x, l) - }; - } -} - -function remove_assq(x, param) { - if (!param) { - return /* [] */0; - } - let l = param.tl; - let pair = param.hd; - if (pair[0] === x) { - return l; - } else { - return { - hd: pair, - tl: remove_assq(x, l) - }; - } -} - -function find(p, _param) { - while (true) { - let param = _param; - if (param) { - let x = param.hd; - if (p(x)) { - return x; - } - _param = param.tl; - continue; - } - throw { - RE_EXN_ID: "Not_found", - Error: new Error() - }; - }; -} - -function find_opt(p, _param) { - while (true) { - let param = _param; - if (!param) { - return; - } - let x = param.hd; - if (p(x)) { - return Primitive_option.some(x); - } - _param = param.tl; - continue; - }; -} - -function find_all(p, l) { - let _accu = /* [] */0; - let _param = l; - while (true) { - let param = _param; - let accu = _accu; - if (!param) { - return rev_append(accu, /* [] */0); - } - let l$1 = param.tl; - let x = param.hd; - if (p(x)) { - _param = l$1; - _accu = { - hd: x, - tl: accu - }; - continue; - } - _param = l$1; - continue; - }; -} - -function partition(p, l) { - let _yes = /* [] */0; - let _no = /* [] */0; - let _param = l; - while (true) { - let param = _param; - let no = _no; - let yes = _yes; - if (!param) { - return [ - rev_append(yes, /* [] */0), - rev_append(no, /* [] */0) - ]; - } - let l$1 = param.tl; - let x = param.hd; - if (p(x)) { - _param = l$1; - _yes = { - hd: x, - tl: yes - }; - continue; - } - _param = l$1; - _no = { - hd: x, - tl: no - }; - continue; - }; -} - -function split(param) { - if (!param) { - return [ - /* [] */0, - /* [] */0 - ]; - } - let match = param.hd; - let match$1 = split(param.tl); - return [ - { - hd: match[0], - tl: match$1[0] - }, - { - hd: match[1], - tl: match$1[1] - } - ]; -} - -function combine(l1, l2) { - if (l1) { - if (l2) { - return { - hd: [ - l1.hd, - l2.hd - ], - tl: combine(l1.tl, l2.tl) - }; - } else { - return Pervasives.invalid_arg("List.combine"); - } - } else if (l2) { - return Pervasives.invalid_arg("List.combine"); - } else { - return /* [] */0; - } -} - -function merge(cmp, l1, l2) { - if (!l1) { - return l2; - } - if (!l2) { - return l1; - } - let h2 = l2.hd; - let h1 = l1.hd; - if (cmp(h1, h2) <= 0) { - return { - hd: h1, - tl: merge(cmp, l1.tl, l2) - }; - } else { - return { - hd: h2, - tl: merge(cmp, l1, l2.tl) - }; - } -} - -function chop(_k, _l) { - while (true) { - let l = _l; - let k = _k; - if (k === 0) { - return l; - } - if (l) { - _l = l.tl; - _k = k - 1 | 0; - continue; - } - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "Ocaml_List.res", - 411, - 11 - ], - Error: new Error() - }; - }; -} - -function stable_sort(cmp, l) { - let sort = (n, l) => { - if (n !== 2) { - if (n === 3 && l) { - let match = l.tl; - if (match) { - let match$1 = match.tl; - if (match$1) { - let x3 = match$1.hd; - let x2 = match.hd; - let x1 = l.hd; - if (cmp(x1, x2) <= 0) { - if (cmp(x2, x3) <= 0) { - return { - hd: x1, - tl: { - hd: x2, - tl: { - hd: x3, - tl: /* [] */0 - } - } - }; - } else if (cmp(x1, x3) <= 0) { - return { - hd: x1, - tl: { - hd: x3, - tl: { - hd: x2, - tl: /* [] */0 - } - } - }; - } else { - return { - hd: x3, - tl: { - hd: x1, - tl: { - hd: x2, - tl: /* [] */0 - } - } - }; - } - } else if (cmp(x1, x3) <= 0) { - return { - hd: x2, - tl: { - hd: x1, - tl: { - hd: x3, - tl: /* [] */0 - } - } - }; - } else if (cmp(x2, x3) <= 0) { - return { - hd: x2, - tl: { - hd: x3, - tl: { - hd: x1, - tl: /* [] */0 - } - } - }; - } else { - return { - hd: x3, - tl: { - hd: x2, - tl: { - hd: x1, - tl: /* [] */0 - } - } - }; - } - } - - } - - } - - } else if (l) { - let match$2 = l.tl; - if (match$2) { - let x2$1 = match$2.hd; - let x1$1 = l.hd; - if (cmp(x1$1, x2$1) <= 0) { - return { - hd: x1$1, - tl: { - hd: x2$1, - tl: /* [] */0 - } - }; - } else { - return { - hd: x2$1, - tl: { - hd: x1$1, - tl: /* [] */0 - } - }; - } - } - - } - let n1 = (n >> 1); - let n2 = n - n1 | 0; - let l2 = chop(n1, l); - let s1 = rev_sort(n1, l); - let s2 = rev_sort(n2, l2); - let _l1 = s1; - let _l2 = s2; - let _accu = /* [] */0; - while (true) { - let accu = _accu; - let l2$1 = _l2; - let l1 = _l1; - if (!l1) { - return rev_append(l2$1, accu); - } - if (!l2$1) { - return rev_append(l1, accu); - } - let h2 = l2$1.hd; - let h1 = l1.hd; - if (cmp(h1, h2) > 0) { - _accu = { - hd: h1, - tl: accu - }; - _l1 = l1.tl; - continue; - } - _accu = { - hd: h2, - tl: accu - }; - _l2 = l2$1.tl; - continue; - }; - }; - let rev_sort = (n, l) => { - if (n !== 2) { - if (n === 3 && l) { - let match = l.tl; - if (match) { - let match$1 = match.tl; - if (match$1) { - let x3 = match$1.hd; - let x2 = match.hd; - let x1 = l.hd; - if (cmp(x1, x2) > 0) { - if (cmp(x2, x3) > 0) { - return { - hd: x1, - tl: { - hd: x2, - tl: { - hd: x3, - tl: /* [] */0 - } - } - }; - } else if (cmp(x1, x3) > 0) { - return { - hd: x1, - tl: { - hd: x3, - tl: { - hd: x2, - tl: /* [] */0 - } - } - }; - } else { - return { - hd: x3, - tl: { - hd: x1, - tl: { - hd: x2, - tl: /* [] */0 - } - } - }; - } - } else if (cmp(x1, x3) > 0) { - return { - hd: x2, - tl: { - hd: x1, - tl: { - hd: x3, - tl: /* [] */0 - } - } - }; - } else if (cmp(x2, x3) > 0) { - return { - hd: x2, - tl: { - hd: x3, - tl: { - hd: x1, - tl: /* [] */0 - } - } - }; - } else { - return { - hd: x3, - tl: { - hd: x2, - tl: { - hd: x1, - tl: /* [] */0 - } - } - }; - } - } - - } - - } - - } else if (l) { - let match$2 = l.tl; - if (match$2) { - let x2$1 = match$2.hd; - let x1$1 = l.hd; - if (cmp(x1$1, x2$1) > 0) { - return { - hd: x1$1, - tl: { - hd: x2$1, - tl: /* [] */0 - } - }; - } else { - return { - hd: x2$1, - tl: { - hd: x1$1, - tl: /* [] */0 - } - }; - } - } - - } - let n1 = (n >> 1); - let n2 = n - n1 | 0; - let l2 = chop(n1, l); - let s1 = sort(n1, l); - let s2 = sort(n2, l2); - let _l1 = s1; - let _l2 = s2; - let _accu = /* [] */0; - while (true) { - let accu = _accu; - let l2$1 = _l2; - let l1 = _l1; - if (!l1) { - return rev_append(l2$1, accu); - } - if (!l2$1) { - return rev_append(l1, accu); - } - let h2 = l2$1.hd; - let h1 = l1.hd; - if (cmp(h1, h2) <= 0) { - _accu = { - hd: h1, - tl: accu - }; - _l1 = l1.tl; - continue; - } - _accu = { - hd: h2, - tl: accu - }; - _l2 = l2$1.tl; - continue; - }; - }; - let len = length(l); - if (len < 2) { - return l; - } else { - return sort(len, l); - } -} - -function sort_uniq(cmp, l) { - let sort = (n, l) => { - if (n !== 2) { - if (n === 3 && l) { - let match = l.tl; - if (match) { - let match$1 = match.tl; - if (match$1) { - let x3 = match$1.hd; - let x2 = match.hd; - let x1 = l.hd; - let c = cmp(x1, x2); - if (c === 0) { - let c$1 = cmp(x2, x3); - if (c$1 === 0) { - return { - hd: x2, - tl: /* [] */0 - }; - } else if (c$1 < 0) { - return { - hd: x2, - tl: { - hd: x3, - tl: /* [] */0 - } - }; - } else { - return { - hd: x3, - tl: { - hd: x2, - tl: /* [] */0 - } - }; - } - } - if (c < 0) { - let c$2 = cmp(x2, x3); - if (c$2 === 0) { - return { - hd: x1, - tl: { - hd: x2, - tl: /* [] */0 - } - }; - } - if (c$2 < 0) { - return { - hd: x1, - tl: { - hd: x2, - tl: { - hd: x3, - tl: /* [] */0 - } - } - }; - } - let c$3 = cmp(x1, x3); - if (c$3 === 0) { - return { - hd: x1, - tl: { - hd: x2, - tl: /* [] */0 - } - }; - } else if (c$3 < 0) { - return { - hd: x1, - tl: { - hd: x3, - tl: { - hd: x2, - tl: /* [] */0 - } - } - }; - } else { - return { - hd: x3, - tl: { - hd: x1, - tl: { - hd: x2, - tl: /* [] */0 - } - } - }; - } - } - let c$4 = cmp(x1, x3); - if (c$4 === 0) { - return { - hd: x2, - tl: { - hd: x1, - tl: /* [] */0 - } - }; - } - if (c$4 < 0) { - return { - hd: x2, - tl: { - hd: x1, - tl: { - hd: x3, - tl: /* [] */0 - } - } - }; - } - let c$5 = cmp(x2, x3); - if (c$5 === 0) { - return { - hd: x2, - tl: { - hd: x1, - tl: /* [] */0 - } - }; - } else if (c$5 < 0) { - return { - hd: x2, - tl: { - hd: x3, - tl: { - hd: x1, - tl: /* [] */0 - } - } - }; - } else { - return { - hd: x3, - tl: { - hd: x2, - tl: { - hd: x1, - tl: /* [] */0 - } - } - }; - } - } - - } - - } - - } else if (l) { - let match$2 = l.tl; - if (match$2) { - let x2$1 = match$2.hd; - let x1$1 = l.hd; - let c$6 = cmp(x1$1, x2$1); - if (c$6 === 0) { - return { - hd: x1$1, - tl: /* [] */0 - }; - } else if (c$6 < 0) { - return { - hd: x1$1, - tl: { - hd: x2$1, - tl: /* [] */0 - } - }; - } else { - return { - hd: x2$1, - tl: { - hd: x1$1, - tl: /* [] */0 - } - }; - } - } - - } - let n1 = (n >> 1); - let n2 = n - n1 | 0; - let l2 = chop(n1, l); - let s1 = rev_sort(n1, l); - let s2 = rev_sort(n2, l2); - let _l1 = s1; - let _l2 = s2; - let _accu = /* [] */0; - while (true) { - let accu = _accu; - let l2$1 = _l2; - let l1 = _l1; - if (!l1) { - return rev_append(l2$1, accu); - } - if (!l2$1) { - return rev_append(l1, accu); - } - let t2 = l2$1.tl; - let h2 = l2$1.hd; - let t1 = l1.tl; - let h1 = l1.hd; - let c$7 = cmp(h1, h2); - if (c$7 === 0) { - _accu = { - hd: h1, - tl: accu - }; - _l2 = t2; - _l1 = t1; - continue; - } - if (c$7 > 0) { - _accu = { - hd: h1, - tl: accu - }; - _l1 = t1; - continue; - } - _accu = { - hd: h2, - tl: accu - }; - _l2 = t2; - continue; - }; - }; - let rev_sort = (n, l) => { - if (n !== 2) { - if (n === 3 && l) { - let match = l.tl; - if (match) { - let match$1 = match.tl; - if (match$1) { - let x3 = match$1.hd; - let x2 = match.hd; - let x1 = l.hd; - let c = cmp(x1, x2); - if (c === 0) { - let c$1 = cmp(x2, x3); - if (c$1 === 0) { - return { - hd: x2, - tl: /* [] */0 - }; - } else if (c$1 > 0) { - return { - hd: x2, - tl: { - hd: x3, - tl: /* [] */0 - } - }; - } else { - return { - hd: x3, - tl: { - hd: x2, - tl: /* [] */0 - } - }; - } - } - if (c > 0) { - let c$2 = cmp(x2, x3); - if (c$2 === 0) { - return { - hd: x1, - tl: { - hd: x2, - tl: /* [] */0 - } - }; - } - if (c$2 > 0) { - return { - hd: x1, - tl: { - hd: x2, - tl: { - hd: x3, - tl: /* [] */0 - } - } - }; - } - let c$3 = cmp(x1, x3); - if (c$3 === 0) { - return { - hd: x1, - tl: { - hd: x2, - tl: /* [] */0 - } - }; - } else if (c$3 > 0) { - return { - hd: x1, - tl: { - hd: x3, - tl: { - hd: x2, - tl: /* [] */0 - } - } - }; - } else { - return { - hd: x3, - tl: { - hd: x1, - tl: { - hd: x2, - tl: /* [] */0 - } - } - }; - } - } - let c$4 = cmp(x1, x3); - if (c$4 === 0) { - return { - hd: x2, - tl: { - hd: x1, - tl: /* [] */0 - } - }; - } - if (c$4 > 0) { - return { - hd: x2, - tl: { - hd: x1, - tl: { - hd: x3, - tl: /* [] */0 - } - } - }; - } - let c$5 = cmp(x2, x3); - if (c$5 === 0) { - return { - hd: x2, - tl: { - hd: x1, - tl: /* [] */0 - } - }; - } else if (c$5 > 0) { - return { - hd: x2, - tl: { - hd: x3, - tl: { - hd: x1, - tl: /* [] */0 - } - } - }; - } else { - return { - hd: x3, - tl: { - hd: x2, - tl: { - hd: x1, - tl: /* [] */0 - } - } - }; - } - } - - } - - } - - } else if (l) { - let match$2 = l.tl; - if (match$2) { - let x2$1 = match$2.hd; - let x1$1 = l.hd; - let c$6 = cmp(x1$1, x2$1); - if (c$6 === 0) { - return { - hd: x1$1, - tl: /* [] */0 - }; - } else if (c$6 > 0) { - return { - hd: x1$1, - tl: { - hd: x2$1, - tl: /* [] */0 - } - }; - } else { - return { - hd: x2$1, - tl: { - hd: x1$1, - tl: /* [] */0 - } - }; - } - } - - } - let n1 = (n >> 1); - let n2 = n - n1 | 0; - let l2 = chop(n1, l); - let s1 = sort(n1, l); - let s2 = sort(n2, l2); - let _l1 = s1; - let _l2 = s2; - let _accu = /* [] */0; - while (true) { - let accu = _accu; - let l2$1 = _l2; - let l1 = _l1; - if (!l1) { - return rev_append(l2$1, accu); - } - if (!l2$1) { - return rev_append(l1, accu); - } - let t2 = l2$1.tl; - let h2 = l2$1.hd; - let t1 = l1.tl; - let h1 = l1.hd; - let c$7 = cmp(h1, h2); - if (c$7 === 0) { - _accu = { - hd: h1, - tl: accu - }; - _l2 = t2; - _l1 = t1; - continue; - } - if (c$7 < 0) { - _accu = { - hd: h1, - tl: accu - }; - _l1 = t1; - continue; - } - _accu = { - hd: h2, - tl: accu - }; - _l2 = t2; - continue; - }; - }; - let len = length(l); - if (len < 2) { - return l; - } else { - return sort(len, l); - } -} - -function compare_lengths(_l1, _l2) { - while (true) { - let l2 = _l2; - let l1 = _l1; - if (!l1) { - if (l2) { - return -1; - } else { - return 0; - } - } - if (!l2) { - return 1; - } - _l2 = l2.tl; - _l1 = l1.tl; - continue; - }; -} - -function compare_length_with(_l, _n) { - while (true) { - let n = _n; - let l = _l; - if (!l) { - if (n === 0) { - return 0; - } else if (n > 0) { - return -1; - } else { - return 1; - } - } - if (n <= 0) { - return 1; - } - _n = n - 1 | 0; - _l = l.tl; - continue; - }; -} - -let append = Pervasives.$at; - -let concat = flatten; - -let filter = find_all; - -let sort = stable_sort; - -let fast_sort = stable_sort; - -exports.length = length; -exports.compare_lengths = compare_lengths; -exports.compare_length_with = compare_length_with; -exports.cons = cons; -exports.hd = hd; -exports.tl = tl; -exports.nth = nth; -exports.nth_opt = nth_opt; -exports.rev = rev; -exports.init = init; -exports.append = append; -exports.rev_append = rev_append; -exports.concat = concat; -exports.flatten = flatten; -exports.iter = iter; -exports.iteri = iteri; -exports.map = map; -exports.mapi = mapi$1; -exports.rev_map = rev_map; -exports.fold_left = fold_left; -exports.fold_right = fold_right; -exports.iter2 = iter2; -exports.map2 = map2; -exports.rev_map2 = rev_map2; -exports.fold_left2 = fold_left2; -exports.fold_right2 = fold_right2; -exports.for_all = for_all; -exports.exists = exists; -exports.for_all2 = for_all2; -exports.exists2 = exists2; -exports.mem = mem; -exports.memq = memq; -exports.find = find; -exports.find_opt = find_opt; -exports.filter = filter; -exports.find_all = find_all; -exports.partition = partition; -exports.assoc = assoc; -exports.assoc_opt = assoc_opt; -exports.assq = assq; -exports.assq_opt = assq_opt; -exports.mem_assoc = mem_assoc; -exports.mem_assq = mem_assq; -exports.remove_assoc = remove_assoc; -exports.remove_assq = remove_assq; -exports.split = split; -exports.combine = combine; -exports.sort = sort; -exports.stable_sort = stable_sort; -exports.fast_sort = fast_sort; -exports.sort_uniq = sort_uniq; -exports.merge = merge; -/* No side effect */ diff --git a/tests/tests/src/ocaml_compat/Ocaml_List.mjs b/tests/tests/src/ocaml_compat/Ocaml_List.mjs new file mode 100644 index 0000000000..64703b8cd5 --- /dev/null +++ b/tests/tests/src/ocaml_compat/Ocaml_List.mjs @@ -0,0 +1,1630 @@ +// Generated by ReScript, PLEASE EDIT WITH CARE + +import * as Pervasives from "rescript/lib/es6/Pervasives.js"; +import * as Primitive_option from "rescript/lib/es6/Primitive_option.js"; + +function length(l) { + let _len = 0; + let _param = l; + while (true) { + let param = _param; + let len = _len; + if (!param) { + return len; + } + _param = param.tl; + _len = len + 1 | 0; + continue; + }; +} + +function cons(a, l) { + return { + hd: a, + tl: l + }; +} + +function hd(param) { + if (param) { + return param.hd; + } else { + return Pervasives.failwith("hd"); + } +} + +function tl(param) { + if (param) { + return param.tl; + } else { + return Pervasives.failwith("tl"); + } +} + +function nth(l, n) { + if (n < 0) { + return Pervasives.invalid_arg("List.nth"); + } + let _l = l; + let _n = n; + while (true) { + let n$1 = _n; + let l$1 = _l; + if (!l$1) { + return Pervasives.failwith("nth"); + } + if (n$1 === 0) { + return l$1.hd; + } + _n = n$1 - 1 | 0; + _l = l$1.tl; + continue; + }; +} + +function nth_opt(l, n) { + if (n < 0) { + return Pervasives.invalid_arg("List.nth"); + } + let _l = l; + let _n = n; + while (true) { + let n$1 = _n; + let l$1 = _l; + if (!l$1) { + return; + } + if (n$1 === 0) { + return Primitive_option.some(l$1.hd); + } + _n = n$1 - 1 | 0; + _l = l$1.tl; + continue; + }; +} + +function rev_append(_l1, _l2) { + while (true) { + let l2 = _l2; + let l1 = _l1; + if (!l1) { + return l2; + } + _l2 = { + hd: l1.hd, + tl: l2 + }; + _l1 = l1.tl; + continue; + }; +} + +function rev(l) { + return rev_append(l, /* [] */0); +} + +function init_tailrec_aux(_acc, _i, n, f) { + while (true) { + let i = _i; + let acc = _acc; + if (i >= n) { + return acc; + } + _i = i + 1 | 0; + _acc = { + hd: f(i), + tl: acc + }; + continue; + }; +} + +function init_aux(i, n, f) { + if (i >= n) { + return /* [] */0; + } + let r = f(i); + return { + hd: r, + tl: init_aux(i + 1 | 0, n, f) + }; +} + +function init(len, f) { + if (len < 0) { + return Pervasives.invalid_arg("List.init"); + } else if (len > 10000) { + return rev_append(init_tailrec_aux(/* [] */0, 0, len, f), /* [] */0); + } else { + return init_aux(0, len, f); + } +} + +function flatten(param) { + if (param) { + return Pervasives.$at(param.hd, flatten(param.tl)); + } else { + return /* [] */0; + } +} + +function map(f, param) { + if (!param) { + return /* [] */0; + } + let r = f(param.hd); + return { + hd: r, + tl: map(f, param.tl) + }; +} + +function mapi(i, f, param) { + if (!param) { + return /* [] */0; + } + let r = f(i, param.hd); + return { + hd: r, + tl: mapi(i + 1 | 0, f, param.tl) + }; +} + +function mapi$1(f, l) { + return mapi(0, f, l); +} + +function rev_map(f, l) { + let _accu = /* [] */0; + let _param = l; + while (true) { + let param = _param; + let accu = _accu; + if (!param) { + return accu; + } + _param = param.tl; + _accu = { + hd: f(param.hd), + tl: accu + }; + continue; + }; +} + +function iter(f, _param) { + while (true) { + let param = _param; + if (!param) { + return; + } + f(param.hd); + _param = param.tl; + continue; + }; +} + +function iteri(f, l) { + let _i = 0; + let _param = l; + while (true) { + let param = _param; + let i = _i; + if (!param) { + return; + } + f(i, param.hd); + _param = param.tl; + _i = i + 1 | 0; + continue; + }; +} + +function fold_left(f, _accu, _l) { + while (true) { + let l = _l; + let accu = _accu; + if (!l) { + return accu; + } + _l = l.tl; + _accu = f(accu, l.hd); + continue; + }; +} + +function fold_right(f, l, accu) { + if (l) { + return f(l.hd, fold_right(f, l.tl, accu)); + } else { + return accu; + } +} + +function map2(f, l1, l2) { + if (!l1) { + if (l2) { + return Pervasives.invalid_arg("List.map2"); + } else { + return /* [] */0; + } + } + if (!l2) { + return Pervasives.invalid_arg("List.map2"); + } + let r = f(l1.hd, l2.hd); + return { + hd: r, + tl: map2(f, l1.tl, l2.tl) + }; +} + +function rev_map2(f, l1, l2) { + let _accu = /* [] */0; + let _l1 = l1; + let _l2 = l2; + while (true) { + let l2$1 = _l2; + let l1$1 = _l1; + let accu = _accu; + if (!l1$1) { + if (l2$1) { + return Pervasives.invalid_arg("List.rev_map2"); + } else { + return accu; + } + } + if (!l2$1) { + return Pervasives.invalid_arg("List.rev_map2"); + } + _l2 = l2$1.tl; + _l1 = l1$1.tl; + _accu = { + hd: f(l1$1.hd, l2$1.hd), + tl: accu + }; + continue; + }; +} + +function iter2(f, _l1, _l2) { + while (true) { + let l2 = _l2; + let l1 = _l1; + if (!l1) { + if (l2) { + return Pervasives.invalid_arg("List.iter2"); + } else { + return; + } + } + if (!l2) { + return Pervasives.invalid_arg("List.iter2"); + } + f(l1.hd, l2.hd); + _l2 = l2.tl; + _l1 = l1.tl; + continue; + }; +} + +function fold_left2(f, _accu, _l1, _l2) { + while (true) { + let l2 = _l2; + let l1 = _l1; + let accu = _accu; + if (!l1) { + if (l2) { + return Pervasives.invalid_arg("List.fold_left2"); + } else { + return accu; + } + } + if (!l2) { + return Pervasives.invalid_arg("List.fold_left2"); + } + _l2 = l2.tl; + _l1 = l1.tl; + _accu = f(accu, l1.hd, l2.hd); + continue; + }; +} + +function fold_right2(f, l1, l2, accu) { + if (l1) { + if (l2) { + return f(l1.hd, l2.hd, fold_right2(f, l1.tl, l2.tl, accu)); + } else { + return Pervasives.invalid_arg("List.fold_right2"); + } + } else if (l2) { + return Pervasives.invalid_arg("List.fold_right2"); + } else { + return accu; + } +} + +function for_all(p, _param) { + while (true) { + let param = _param; + if (!param) { + return true; + } + if (!p(param.hd)) { + return false; + } + _param = param.tl; + continue; + }; +} + +function exists(p, _param) { + while (true) { + let param = _param; + if (!param) { + return false; + } + if (p(param.hd)) { + return true; + } + _param = param.tl; + continue; + }; +} + +function for_all2(p, _l1, _l2) { + while (true) { + let l2 = _l2; + let l1 = _l1; + if (!l1) { + if (l2) { + return Pervasives.invalid_arg("List.for_all2"); + } else { + return true; + } + } + if (!l2) { + return Pervasives.invalid_arg("List.for_all2"); + } + if (!p(l1.hd, l2.hd)) { + return false; + } + _l2 = l2.tl; + _l1 = l1.tl; + continue; + }; +} + +function exists2(p, _l1, _l2) { + while (true) { + let l2 = _l2; + let l1 = _l1; + if (!l1) { + if (l2) { + return Pervasives.invalid_arg("List.exists2"); + } else { + return false; + } + } + if (!l2) { + return Pervasives.invalid_arg("List.exists2"); + } + if (p(l1.hd, l2.hd)) { + return true; + } + _l2 = l2.tl; + _l1 = l1.tl; + continue; + }; +} + +function mem(x, _param) { + while (true) { + let param = _param; + if (!param) { + return false; + } + if (param.hd === x) { + return true; + } + _param = param.tl; + continue; + }; +} + +function memq(x, _param) { + while (true) { + let param = _param; + if (!param) { + return false; + } + if (param.hd === x) { + return true; + } + _param = param.tl; + continue; + }; +} + +function assoc(x, _param) { + while (true) { + let param = _param; + if (param) { + let match = param.hd; + if (match[0] === x) { + return match[1]; + } + _param = param.tl; + continue; + } + throw { + RE_EXN_ID: "Not_found", + Error: new Error() + }; + }; +} + +function assoc_opt(x, _param) { + while (true) { + let param = _param; + if (!param) { + return; + } + let match = param.hd; + if (match[0] === x) { + return Primitive_option.some(match[1]); + } + _param = param.tl; + continue; + }; +} + +function assq(x, _param) { + while (true) { + let param = _param; + if (param) { + let match = param.hd; + if (match[0] === x) { + return match[1]; + } + _param = param.tl; + continue; + } + throw { + RE_EXN_ID: "Not_found", + Error: new Error() + }; + }; +} + +function assq_opt(x, _param) { + while (true) { + let param = _param; + if (!param) { + return; + } + let match = param.hd; + if (match[0] === x) { + return Primitive_option.some(match[1]); + } + _param = param.tl; + continue; + }; +} + +function mem_assoc(x, _param) { + while (true) { + let param = _param; + if (!param) { + return false; + } + if (param.hd[0] === x) { + return true; + } + _param = param.tl; + continue; + }; +} + +function mem_assq(x, _param) { + while (true) { + let param = _param; + if (!param) { + return false; + } + if (param.hd[0] === x) { + return true; + } + _param = param.tl; + continue; + }; +} + +function remove_assoc(x, param) { + if (!param) { + return /* [] */0; + } + let l = param.tl; + let pair = param.hd; + if (pair[0] === x) { + return l; + } else { + return { + hd: pair, + tl: remove_assoc(x, l) + }; + } +} + +function remove_assq(x, param) { + if (!param) { + return /* [] */0; + } + let l = param.tl; + let pair = param.hd; + if (pair[0] === x) { + return l; + } else { + return { + hd: pair, + tl: remove_assq(x, l) + }; + } +} + +function find(p, _param) { + while (true) { + let param = _param; + if (param) { + let x = param.hd; + if (p(x)) { + return x; + } + _param = param.tl; + continue; + } + throw { + RE_EXN_ID: "Not_found", + Error: new Error() + }; + }; +} + +function find_opt(p, _param) { + while (true) { + let param = _param; + if (!param) { + return; + } + let x = param.hd; + if (p(x)) { + return Primitive_option.some(x); + } + _param = param.tl; + continue; + }; +} + +function find_all(p, l) { + let _accu = /* [] */0; + let _param = l; + while (true) { + let param = _param; + let accu = _accu; + if (!param) { + return rev_append(accu, /* [] */0); + } + let l$1 = param.tl; + let x = param.hd; + if (p(x)) { + _param = l$1; + _accu = { + hd: x, + tl: accu + }; + continue; + } + _param = l$1; + continue; + }; +} + +function partition(p, l) { + let _yes = /* [] */0; + let _no = /* [] */0; + let _param = l; + while (true) { + let param = _param; + let no = _no; + let yes = _yes; + if (!param) { + return [ + rev_append(yes, /* [] */0), + rev_append(no, /* [] */0) + ]; + } + let l$1 = param.tl; + let x = param.hd; + if (p(x)) { + _param = l$1; + _yes = { + hd: x, + tl: yes + }; + continue; + } + _param = l$1; + _no = { + hd: x, + tl: no + }; + continue; + }; +} + +function split(param) { + if (!param) { + return [ + /* [] */0, + /* [] */0 + ]; + } + let match = param.hd; + let match$1 = split(param.tl); + return [ + { + hd: match[0], + tl: match$1[0] + }, + { + hd: match[1], + tl: match$1[1] + } + ]; +} + +function combine(l1, l2) { + if (l1) { + if (l2) { + return { + hd: [ + l1.hd, + l2.hd + ], + tl: combine(l1.tl, l2.tl) + }; + } else { + return Pervasives.invalid_arg("List.combine"); + } + } else if (l2) { + return Pervasives.invalid_arg("List.combine"); + } else { + return /* [] */0; + } +} + +function merge(cmp, l1, l2) { + if (!l1) { + return l2; + } + if (!l2) { + return l1; + } + let h2 = l2.hd; + let h1 = l1.hd; + if (cmp(h1, h2) <= 0) { + return { + hd: h1, + tl: merge(cmp, l1.tl, l2) + }; + } else { + return { + hd: h2, + tl: merge(cmp, l1, l2.tl) + }; + } +} + +function chop(_k, _l) { + while (true) { + let l = _l; + let k = _k; + if (k === 0) { + return l; + } + if (l) { + _l = l.tl; + _k = k - 1 | 0; + continue; + } + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "Ocaml_List.res", + 411, + 11 + ], + Error: new Error() + }; + }; +} + +function stable_sort(cmp, l) { + let sort = (n, l) => { + if (n !== 2) { + if (n === 3 && l) { + let match = l.tl; + if (match) { + let match$1 = match.tl; + if (match$1) { + let x3 = match$1.hd; + let x2 = match.hd; + let x1 = l.hd; + if (cmp(x1, x2) <= 0) { + if (cmp(x2, x3) <= 0) { + return { + hd: x1, + tl: { + hd: x2, + tl: { + hd: x3, + tl: /* [] */0 + } + } + }; + } else if (cmp(x1, x3) <= 0) { + return { + hd: x1, + tl: { + hd: x3, + tl: { + hd: x2, + tl: /* [] */0 + } + } + }; + } else { + return { + hd: x3, + tl: { + hd: x1, + tl: { + hd: x2, + tl: /* [] */0 + } + } + }; + } + } else if (cmp(x1, x3) <= 0) { + return { + hd: x2, + tl: { + hd: x1, + tl: { + hd: x3, + tl: /* [] */0 + } + } + }; + } else if (cmp(x2, x3) <= 0) { + return { + hd: x2, + tl: { + hd: x3, + tl: { + hd: x1, + tl: /* [] */0 + } + } + }; + } else { + return { + hd: x3, + tl: { + hd: x2, + tl: { + hd: x1, + tl: /* [] */0 + } + } + }; + } + } + + } + + } + + } else if (l) { + let match$2 = l.tl; + if (match$2) { + let x2$1 = match$2.hd; + let x1$1 = l.hd; + if (cmp(x1$1, x2$1) <= 0) { + return { + hd: x1$1, + tl: { + hd: x2$1, + tl: /* [] */0 + } + }; + } else { + return { + hd: x2$1, + tl: { + hd: x1$1, + tl: /* [] */0 + } + }; + } + } + + } + let n1 = (n >> 1); + let n2 = n - n1 | 0; + let l2 = chop(n1, l); + let s1 = rev_sort(n1, l); + let s2 = rev_sort(n2, l2); + let _l1 = s1; + let _l2 = s2; + let _accu = /* [] */0; + while (true) { + let accu = _accu; + let l2$1 = _l2; + let l1 = _l1; + if (!l1) { + return rev_append(l2$1, accu); + } + if (!l2$1) { + return rev_append(l1, accu); + } + let h2 = l2$1.hd; + let h1 = l1.hd; + if (cmp(h1, h2) > 0) { + _accu = { + hd: h1, + tl: accu + }; + _l1 = l1.tl; + continue; + } + _accu = { + hd: h2, + tl: accu + }; + _l2 = l2$1.tl; + continue; + }; + }; + let rev_sort = (n, l) => { + if (n !== 2) { + if (n === 3 && l) { + let match = l.tl; + if (match) { + let match$1 = match.tl; + if (match$1) { + let x3 = match$1.hd; + let x2 = match.hd; + let x1 = l.hd; + if (cmp(x1, x2) > 0) { + if (cmp(x2, x3) > 0) { + return { + hd: x1, + tl: { + hd: x2, + tl: { + hd: x3, + tl: /* [] */0 + } + } + }; + } else if (cmp(x1, x3) > 0) { + return { + hd: x1, + tl: { + hd: x3, + tl: { + hd: x2, + tl: /* [] */0 + } + } + }; + } else { + return { + hd: x3, + tl: { + hd: x1, + tl: { + hd: x2, + tl: /* [] */0 + } + } + }; + } + } else if (cmp(x1, x3) > 0) { + return { + hd: x2, + tl: { + hd: x1, + tl: { + hd: x3, + tl: /* [] */0 + } + } + }; + } else if (cmp(x2, x3) > 0) { + return { + hd: x2, + tl: { + hd: x3, + tl: { + hd: x1, + tl: /* [] */0 + } + } + }; + } else { + return { + hd: x3, + tl: { + hd: x2, + tl: { + hd: x1, + tl: /* [] */0 + } + } + }; + } + } + + } + + } + + } else if (l) { + let match$2 = l.tl; + if (match$2) { + let x2$1 = match$2.hd; + let x1$1 = l.hd; + if (cmp(x1$1, x2$1) > 0) { + return { + hd: x1$1, + tl: { + hd: x2$1, + tl: /* [] */0 + } + }; + } else { + return { + hd: x2$1, + tl: { + hd: x1$1, + tl: /* [] */0 + } + }; + } + } + + } + let n1 = (n >> 1); + let n2 = n - n1 | 0; + let l2 = chop(n1, l); + let s1 = sort(n1, l); + let s2 = sort(n2, l2); + let _l1 = s1; + let _l2 = s2; + let _accu = /* [] */0; + while (true) { + let accu = _accu; + let l2$1 = _l2; + let l1 = _l1; + if (!l1) { + return rev_append(l2$1, accu); + } + if (!l2$1) { + return rev_append(l1, accu); + } + let h2 = l2$1.hd; + let h1 = l1.hd; + if (cmp(h1, h2) <= 0) { + _accu = { + hd: h1, + tl: accu + }; + _l1 = l1.tl; + continue; + } + _accu = { + hd: h2, + tl: accu + }; + _l2 = l2$1.tl; + continue; + }; + }; + let len = length(l); + if (len < 2) { + return l; + } else { + return sort(len, l); + } +} + +function sort_uniq(cmp, l) { + let sort = (n, l) => { + if (n !== 2) { + if (n === 3 && l) { + let match = l.tl; + if (match) { + let match$1 = match.tl; + if (match$1) { + let x3 = match$1.hd; + let x2 = match.hd; + let x1 = l.hd; + let c = cmp(x1, x2); + if (c === 0) { + let c$1 = cmp(x2, x3); + if (c$1 === 0) { + return { + hd: x2, + tl: /* [] */0 + }; + } else if (c$1 < 0) { + return { + hd: x2, + tl: { + hd: x3, + tl: /* [] */0 + } + }; + } else { + return { + hd: x3, + tl: { + hd: x2, + tl: /* [] */0 + } + }; + } + } + if (c < 0) { + let c$2 = cmp(x2, x3); + if (c$2 === 0) { + return { + hd: x1, + tl: { + hd: x2, + tl: /* [] */0 + } + }; + } + if (c$2 < 0) { + return { + hd: x1, + tl: { + hd: x2, + tl: { + hd: x3, + tl: /* [] */0 + } + } + }; + } + let c$3 = cmp(x1, x3); + if (c$3 === 0) { + return { + hd: x1, + tl: { + hd: x2, + tl: /* [] */0 + } + }; + } else if (c$3 < 0) { + return { + hd: x1, + tl: { + hd: x3, + tl: { + hd: x2, + tl: /* [] */0 + } + } + }; + } else { + return { + hd: x3, + tl: { + hd: x1, + tl: { + hd: x2, + tl: /* [] */0 + } + } + }; + } + } + let c$4 = cmp(x1, x3); + if (c$4 === 0) { + return { + hd: x2, + tl: { + hd: x1, + tl: /* [] */0 + } + }; + } + if (c$4 < 0) { + return { + hd: x2, + tl: { + hd: x1, + tl: { + hd: x3, + tl: /* [] */0 + } + } + }; + } + let c$5 = cmp(x2, x3); + if (c$5 === 0) { + return { + hd: x2, + tl: { + hd: x1, + tl: /* [] */0 + } + }; + } else if (c$5 < 0) { + return { + hd: x2, + tl: { + hd: x3, + tl: { + hd: x1, + tl: /* [] */0 + } + } + }; + } else { + return { + hd: x3, + tl: { + hd: x2, + tl: { + hd: x1, + tl: /* [] */0 + } + } + }; + } + } + + } + + } + + } else if (l) { + let match$2 = l.tl; + if (match$2) { + let x2$1 = match$2.hd; + let x1$1 = l.hd; + let c$6 = cmp(x1$1, x2$1); + if (c$6 === 0) { + return { + hd: x1$1, + tl: /* [] */0 + }; + } else if (c$6 < 0) { + return { + hd: x1$1, + tl: { + hd: x2$1, + tl: /* [] */0 + } + }; + } else { + return { + hd: x2$1, + tl: { + hd: x1$1, + tl: /* [] */0 + } + }; + } + } + + } + let n1 = (n >> 1); + let n2 = n - n1 | 0; + let l2 = chop(n1, l); + let s1 = rev_sort(n1, l); + let s2 = rev_sort(n2, l2); + let _l1 = s1; + let _l2 = s2; + let _accu = /* [] */0; + while (true) { + let accu = _accu; + let l2$1 = _l2; + let l1 = _l1; + if (!l1) { + return rev_append(l2$1, accu); + } + if (!l2$1) { + return rev_append(l1, accu); + } + let t2 = l2$1.tl; + let h2 = l2$1.hd; + let t1 = l1.tl; + let h1 = l1.hd; + let c$7 = cmp(h1, h2); + if (c$7 === 0) { + _accu = { + hd: h1, + tl: accu + }; + _l2 = t2; + _l1 = t1; + continue; + } + if (c$7 > 0) { + _accu = { + hd: h1, + tl: accu + }; + _l1 = t1; + continue; + } + _accu = { + hd: h2, + tl: accu + }; + _l2 = t2; + continue; + }; + }; + let rev_sort = (n, l) => { + if (n !== 2) { + if (n === 3 && l) { + let match = l.tl; + if (match) { + let match$1 = match.tl; + if (match$1) { + let x3 = match$1.hd; + let x2 = match.hd; + let x1 = l.hd; + let c = cmp(x1, x2); + if (c === 0) { + let c$1 = cmp(x2, x3); + if (c$1 === 0) { + return { + hd: x2, + tl: /* [] */0 + }; + } else if (c$1 > 0) { + return { + hd: x2, + tl: { + hd: x3, + tl: /* [] */0 + } + }; + } else { + return { + hd: x3, + tl: { + hd: x2, + tl: /* [] */0 + } + }; + } + } + if (c > 0) { + let c$2 = cmp(x2, x3); + if (c$2 === 0) { + return { + hd: x1, + tl: { + hd: x2, + tl: /* [] */0 + } + }; + } + if (c$2 > 0) { + return { + hd: x1, + tl: { + hd: x2, + tl: { + hd: x3, + tl: /* [] */0 + } + } + }; + } + let c$3 = cmp(x1, x3); + if (c$3 === 0) { + return { + hd: x1, + tl: { + hd: x2, + tl: /* [] */0 + } + }; + } else if (c$3 > 0) { + return { + hd: x1, + tl: { + hd: x3, + tl: { + hd: x2, + tl: /* [] */0 + } + } + }; + } else { + return { + hd: x3, + tl: { + hd: x1, + tl: { + hd: x2, + tl: /* [] */0 + } + } + }; + } + } + let c$4 = cmp(x1, x3); + if (c$4 === 0) { + return { + hd: x2, + tl: { + hd: x1, + tl: /* [] */0 + } + }; + } + if (c$4 > 0) { + return { + hd: x2, + tl: { + hd: x1, + tl: { + hd: x3, + tl: /* [] */0 + } + } + }; + } + let c$5 = cmp(x2, x3); + if (c$5 === 0) { + return { + hd: x2, + tl: { + hd: x1, + tl: /* [] */0 + } + }; + } else if (c$5 > 0) { + return { + hd: x2, + tl: { + hd: x3, + tl: { + hd: x1, + tl: /* [] */0 + } + } + }; + } else { + return { + hd: x3, + tl: { + hd: x2, + tl: { + hd: x1, + tl: /* [] */0 + } + } + }; + } + } + + } + + } + + } else if (l) { + let match$2 = l.tl; + if (match$2) { + let x2$1 = match$2.hd; + let x1$1 = l.hd; + let c$6 = cmp(x1$1, x2$1); + if (c$6 === 0) { + return { + hd: x1$1, + tl: /* [] */0 + }; + } else if (c$6 > 0) { + return { + hd: x1$1, + tl: { + hd: x2$1, + tl: /* [] */0 + } + }; + } else { + return { + hd: x2$1, + tl: { + hd: x1$1, + tl: /* [] */0 + } + }; + } + } + + } + let n1 = (n >> 1); + let n2 = n - n1 | 0; + let l2 = chop(n1, l); + let s1 = sort(n1, l); + let s2 = sort(n2, l2); + let _l1 = s1; + let _l2 = s2; + let _accu = /* [] */0; + while (true) { + let accu = _accu; + let l2$1 = _l2; + let l1 = _l1; + if (!l1) { + return rev_append(l2$1, accu); + } + if (!l2$1) { + return rev_append(l1, accu); + } + let t2 = l2$1.tl; + let h2 = l2$1.hd; + let t1 = l1.tl; + let h1 = l1.hd; + let c$7 = cmp(h1, h2); + if (c$7 === 0) { + _accu = { + hd: h1, + tl: accu + }; + _l2 = t2; + _l1 = t1; + continue; + } + if (c$7 < 0) { + _accu = { + hd: h1, + tl: accu + }; + _l1 = t1; + continue; + } + _accu = { + hd: h2, + tl: accu + }; + _l2 = t2; + continue; + }; + }; + let len = length(l); + if (len < 2) { + return l; + } else { + return sort(len, l); + } +} + +function compare_lengths(_l1, _l2) { + while (true) { + let l2 = _l2; + let l1 = _l1; + if (!l1) { + if (l2) { + return -1; + } else { + return 0; + } + } + if (!l2) { + return 1; + } + _l2 = l2.tl; + _l1 = l1.tl; + continue; + }; +} + +function compare_length_with(_l, _n) { + while (true) { + let n = _n; + let l = _l; + if (!l) { + if (n === 0) { + return 0; + } else if (n > 0) { + return -1; + } else { + return 1; + } + } + if (n <= 0) { + return 1; + } + _n = n - 1 | 0; + _l = l.tl; + continue; + }; +} + +let append = Pervasives.$at; + +let concat = flatten; + +let filter = find_all; + +let sort = stable_sort; + +let fast_sort = stable_sort; + +export { + length, + compare_lengths, + compare_length_with, + cons, + hd, + tl, + nth, + nth_opt, + rev, + init, + append, + rev_append, + concat, + flatten, + iter, + iteri, + map, + mapi$1 as mapi, + rev_map, + fold_left, + fold_right, + iter2, + map2, + rev_map2, + fold_left2, + fold_right2, + for_all, + exists, + for_all2, + exists2, + mem, + memq, + find, + find_opt, + filter, + find_all, + partition, + assoc, + assoc_opt, + assq, + assq_opt, + mem_assoc, + mem_assq, + remove_assoc, + remove_assq, + split, + combine, + sort, + stable_sort, + fast_sort, + sort_uniq, + merge, +} +/* No side effect */ diff --git a/tests/tests/src/ocaml_compat/Ocaml_String.js b/tests/tests/src/ocaml_compat/Ocaml_String.js deleted file mode 100644 index 8e38ceb32d..0000000000 --- a/tests/tests/src/ocaml_compat/Ocaml_String.js +++ /dev/null @@ -1,303 +0,0 @@ -// Generated by ReScript, PLEASE EDIT WITH CARE -'use strict'; - -let Char = require("rescript/lib/js/Char.js"); -let Pervasives = require("rescript/lib/js/Pervasives.js"); -let Ocaml_Array = require("./Ocaml_Array.js"); -let Primitive_exceptions = require("rescript/lib/js/Primitive_exceptions.js"); - -function apply1(f, bytes) { - if (bytes.length === 0) { - return bytes; - } - let r = bytes.slice(); - r[0] = f(bytes[0]); - return r; -} - -function concat(sep, xs) { - return Ocaml_Array.of_list(xs).join(sep); -} - -function bos(str) { - return Ocaml_Array.map(str => str.codePointAt(0), Array.from(str)); -} - -function make(len, ch) { - return String.fromCodePoint(ch).repeat(len); -} - -function init(len, f) { - return Ocaml_Array.init(len, i => String.fromCodePoint(f(i))).join(""); -} - -function sub(s, ofs, len) { - return String.fromCodePoint(...Ocaml_Array.sub(bos(s), ofs, len)); -} - -function iter(f, s) { - for (let i = 0, i_finish = s.length; i < i_finish; ++i) { - f(s.codePointAt(i)); - } -} - -function iteri(f, s) { - for (let i = 0, i_finish = s.length; i < i_finish; ++i) { - f(i, s.codePointAt(i)); - } -} - -function map(f, s) { - return String.fromCodePoint(...Ocaml_Array.map(f, bos(s))); -} - -function mapi(f, s) { - return String.fromCodePoint(...Ocaml_Array.mapi(f, bos(s))); -} - -function escaped(s) { - let needs_escape = _i => { - while (true) { - let i = _i; - if (i >= s.length) { - return false; - } - let match = s.codePointAt(i); - if (match < 32) { - return true; - } - if (match > 92 || match < 34) { - if (match >= 127) { - return true; - } - _i = i + 1 | 0; - continue; - } - if (match > 91 || match < 35) { - return true; - } - _i = i + 1 | 0; - continue; - }; - }; - if (!needs_escape(0)) { - return s; - } - let bytes = bos(s); - return Ocaml_Array.map(Char.escaped, bytes).join(""); -} - -function index_rec(s, lim, _i, c) { - while (true) { - let i = _i; - if (i >= lim) { - throw { - RE_EXN_ID: "Not_found", - Error: new Error() - }; - } - if (s.codePointAt(i) === c) { - return i; - } - _i = i + 1 | 0; - continue; - }; -} - -function index(s, c) { - return index_rec(s, s.length, 0, c); -} - -function index_rec_opt(s, lim, _i, c) { - while (true) { - let i = _i; - if (i >= lim) { - return; - } - if (s.codePointAt(i) === c) { - return i; - } - _i = i + 1 | 0; - continue; - }; -} - -function index_opt(s, c) { - return index_rec_opt(s, s.length, 0, c); -} - -function index_from(s, i, c) { - let l = s.length; - if (i < 0 || i > l) { - return Pervasives.invalid_arg("String.index_from / Bytes.index_from"); - } else { - return index_rec(s, l, i, c); - } -} - -function index_from_opt(s, i, c) { - let l = s.length; - if (i < 0 || i > l) { - return Pervasives.invalid_arg("String.index_from_opt / Bytes.index_from_opt"); - } else { - return index_rec_opt(s, l, i, c); - } -} - -function rindex_rec(s, _i, c) { - while (true) { - let i = _i; - if (i < 0) { - throw { - RE_EXN_ID: "Not_found", - Error: new Error() - }; - } - if (s.codePointAt(i) === c) { - return i; - } - _i = i - 1 | 0; - continue; - }; -} - -function rindex(s, c) { - return rindex_rec(s, s.length - 1 | 0, c); -} - -function rindex_from(s, i, c) { - if (i < -1 || i >= s.length) { - return Pervasives.invalid_arg("String.rindex_from / Bytes.rindex_from"); - } else { - return rindex_rec(s, i, c); - } -} - -function rindex_rec_opt(s, _i, c) { - while (true) { - let i = _i; - if (i < 0) { - return; - } - if (s.codePointAt(i) === c) { - return i; - } - _i = i - 1 | 0; - continue; - }; -} - -function rindex_opt(s, c) { - return rindex_rec_opt(s, s.length - 1 | 0, c); -} - -function rindex_from_opt(s, i, c) { - if (i < -1 || i >= s.length) { - return Pervasives.invalid_arg("String.rindex_from_opt / Bytes.rindex_from_opt"); - } else { - return rindex_rec_opt(s, i, c); - } -} - -function contains_from(s, i, c) { - let l = s.length; - if (i < 0 || i > l) { - return Pervasives.invalid_arg("String.contains_from / Bytes.contains_from"); - } - try { - index_rec(s, l, i, c); - return true; - } catch (raw_exn) { - let exn = Primitive_exceptions.internalToException(raw_exn); - if (exn.RE_EXN_ID === "Not_found") { - return false; - } - throw exn; - } -} - -function contains(s, c) { - return contains_from(s, 0, c); -} - -function rcontains_from(s, i, c) { - if (i < 0 || i >= s.length) { - return Pervasives.invalid_arg("String.rcontains_from / Bytes.rcontains_from"); - } - try { - rindex_rec(s, i, c); - return true; - } catch (raw_exn) { - let exn = Primitive_exceptions.internalToException(raw_exn); - if (exn.RE_EXN_ID === "Not_found") { - return false; - } - throw exn; - } -} - -function uppercase_ascii(s) { - let bytes = bos(s); - return String.fromCodePoint(...Ocaml_Array.map(Char.uppercase_ascii, bytes)); -} - -function lowercase_ascii(s) { - let bytes = bos(s); - return String.fromCodePoint(...Ocaml_Array.map(Char.lowercase_ascii, bytes)); -} - -function capitalize_ascii(s) { - let bytes = bos(s); - return String.fromCodePoint(...apply1(Char.uppercase_ascii, bytes)); -} - -function uncapitalize_ascii(s) { - let bytes = bos(s); - return String.fromCodePoint(...apply1(Char.lowercase_ascii, bytes)); -} - -function split_on_char(sep, s) { - let r = /* [] */0; - let j = s.length; - for (let i = s.length - 1 | 0; i >= 0; --i) { - if (s.codePointAt(i) === sep) { - r = { - hd: sub(s, i + 1 | 0, (j - i | 0) - 1 | 0), - tl: r - }; - j = i; - } - - } - return { - hd: sub(s, 0, j), - tl: r - }; -} - -exports.make = make; -exports.init = init; -exports.sub = sub; -exports.concat = concat; -exports.iter = iter; -exports.iteri = iteri; -exports.map = map; -exports.mapi = mapi; -exports.escaped = escaped; -exports.index = index; -exports.index_opt = index_opt; -exports.rindex = rindex; -exports.rindex_opt = rindex_opt; -exports.index_from = index_from; -exports.index_from_opt = index_from_opt; -exports.rindex_from = rindex_from; -exports.rindex_from_opt = rindex_from_opt; -exports.contains = contains; -exports.contains_from = contains_from; -exports.rcontains_from = rcontains_from; -exports.uppercase_ascii = uppercase_ascii; -exports.lowercase_ascii = lowercase_ascii; -exports.capitalize_ascii = capitalize_ascii; -exports.uncapitalize_ascii = uncapitalize_ascii; -exports.split_on_char = split_on_char; -/* No side effect */ diff --git a/tests/tests/src/ocaml_compat/Ocaml_String.mjs b/tests/tests/src/ocaml_compat/Ocaml_String.mjs new file mode 100644 index 0000000000..42bc5b9d05 --- /dev/null +++ b/tests/tests/src/ocaml_compat/Ocaml_String.mjs @@ -0,0 +1,304 @@ +// Generated by ReScript, PLEASE EDIT WITH CARE + +import * as Char from "rescript/lib/es6/Char.js"; +import * as Pervasives from "rescript/lib/es6/Pervasives.js"; +import * as Ocaml_Array from "./Ocaml_Array.mjs"; +import * as Primitive_exceptions from "rescript/lib/es6/Primitive_exceptions.js"; + +function apply1(f, bytes) { + if (bytes.length === 0) { + return bytes; + } + let r = bytes.slice(); + r[0] = f(bytes[0]); + return r; +} + +function concat(sep, xs) { + return Ocaml_Array.of_list(xs).join(sep); +} + +function bos(str) { + return Ocaml_Array.map(str => str.codePointAt(0), Array.from(str)); +} + +function make(len, ch) { + return String.fromCodePoint(ch).repeat(len); +} + +function init(len, f) { + return Ocaml_Array.init(len, i => String.fromCodePoint(f(i))).join(""); +} + +function sub(s, ofs, len) { + return String.fromCodePoint(...Ocaml_Array.sub(bos(s), ofs, len)); +} + +function iter(f, s) { + for (let i = 0, i_finish = s.length; i < i_finish; ++i) { + f(s.codePointAt(i)); + } +} + +function iteri(f, s) { + for (let i = 0, i_finish = s.length; i < i_finish; ++i) { + f(i, s.codePointAt(i)); + } +} + +function map(f, s) { + return String.fromCodePoint(...Ocaml_Array.map(f, bos(s))); +} + +function mapi(f, s) { + return String.fromCodePoint(...Ocaml_Array.mapi(f, bos(s))); +} + +function escaped(s) { + let needs_escape = _i => { + while (true) { + let i = _i; + if (i >= s.length) { + return false; + } + let match = s.codePointAt(i); + if (match < 32) { + return true; + } + if (match > 92 || match < 34) { + if (match >= 127) { + return true; + } + _i = i + 1 | 0; + continue; + } + if (match > 91 || match < 35) { + return true; + } + _i = i + 1 | 0; + continue; + }; + }; + if (!needs_escape(0)) { + return s; + } + let bytes = bos(s); + return Ocaml_Array.map(Char.escaped, bytes).join(""); +} + +function index_rec(s, lim, _i, c) { + while (true) { + let i = _i; + if (i >= lim) { + throw { + RE_EXN_ID: "Not_found", + Error: new Error() + }; + } + if (s.codePointAt(i) === c) { + return i; + } + _i = i + 1 | 0; + continue; + }; +} + +function index(s, c) { + return index_rec(s, s.length, 0, c); +} + +function index_rec_opt(s, lim, _i, c) { + while (true) { + let i = _i; + if (i >= lim) { + return; + } + if (s.codePointAt(i) === c) { + return i; + } + _i = i + 1 | 0; + continue; + }; +} + +function index_opt(s, c) { + return index_rec_opt(s, s.length, 0, c); +} + +function index_from(s, i, c) { + let l = s.length; + if (i < 0 || i > l) { + return Pervasives.invalid_arg("String.index_from / Bytes.index_from"); + } else { + return index_rec(s, l, i, c); + } +} + +function index_from_opt(s, i, c) { + let l = s.length; + if (i < 0 || i > l) { + return Pervasives.invalid_arg("String.index_from_opt / Bytes.index_from_opt"); + } else { + return index_rec_opt(s, l, i, c); + } +} + +function rindex_rec(s, _i, c) { + while (true) { + let i = _i; + if (i < 0) { + throw { + RE_EXN_ID: "Not_found", + Error: new Error() + }; + } + if (s.codePointAt(i) === c) { + return i; + } + _i = i - 1 | 0; + continue; + }; +} + +function rindex(s, c) { + return rindex_rec(s, s.length - 1 | 0, c); +} + +function rindex_from(s, i, c) { + if (i < -1 || i >= s.length) { + return Pervasives.invalid_arg("String.rindex_from / Bytes.rindex_from"); + } else { + return rindex_rec(s, i, c); + } +} + +function rindex_rec_opt(s, _i, c) { + while (true) { + let i = _i; + if (i < 0) { + return; + } + if (s.codePointAt(i) === c) { + return i; + } + _i = i - 1 | 0; + continue; + }; +} + +function rindex_opt(s, c) { + return rindex_rec_opt(s, s.length - 1 | 0, c); +} + +function rindex_from_opt(s, i, c) { + if (i < -1 || i >= s.length) { + return Pervasives.invalid_arg("String.rindex_from_opt / Bytes.rindex_from_opt"); + } else { + return rindex_rec_opt(s, i, c); + } +} + +function contains_from(s, i, c) { + let l = s.length; + if (i < 0 || i > l) { + return Pervasives.invalid_arg("String.contains_from / Bytes.contains_from"); + } + try { + index_rec(s, l, i, c); + return true; + } catch (raw_exn) { + let exn = Primitive_exceptions.internalToException(raw_exn); + if (exn.RE_EXN_ID === "Not_found") { + return false; + } + throw exn; + } +} + +function contains(s, c) { + return contains_from(s, 0, c); +} + +function rcontains_from(s, i, c) { + if (i < 0 || i >= s.length) { + return Pervasives.invalid_arg("String.rcontains_from / Bytes.rcontains_from"); + } + try { + rindex_rec(s, i, c); + return true; + } catch (raw_exn) { + let exn = Primitive_exceptions.internalToException(raw_exn); + if (exn.RE_EXN_ID === "Not_found") { + return false; + } + throw exn; + } +} + +function uppercase_ascii(s) { + let bytes = bos(s); + return String.fromCodePoint(...Ocaml_Array.map(Char.uppercase_ascii, bytes)); +} + +function lowercase_ascii(s) { + let bytes = bos(s); + return String.fromCodePoint(...Ocaml_Array.map(Char.lowercase_ascii, bytes)); +} + +function capitalize_ascii(s) { + let bytes = bos(s); + return String.fromCodePoint(...apply1(Char.uppercase_ascii, bytes)); +} + +function uncapitalize_ascii(s) { + let bytes = bos(s); + return String.fromCodePoint(...apply1(Char.lowercase_ascii, bytes)); +} + +function split_on_char(sep, s) { + let r = /* [] */0; + let j = s.length; + for (let i = s.length - 1 | 0; i >= 0; --i) { + if (s.codePointAt(i) === sep) { + r = { + hd: sub(s, i + 1 | 0, (j - i | 0) - 1 | 0), + tl: r + }; + j = i; + } + + } + return { + hd: sub(s, 0, j), + tl: r + }; +} + +export { + make, + init, + sub, + concat, + iter, + iteri, + map, + mapi, + escaped, + index, + index_opt, + rindex, + rindex_opt, + index_from, + index_from_opt, + rindex_from, + rindex_from_opt, + contains, + contains_from, + rcontains_from, + uppercase_ascii, + lowercase_ascii, + capitalize_ascii, + uncapitalize_ascii, + split_on_char, +} +/* No side effect */ diff --git a/tests/tests/src/offset.js b/tests/tests/src/offset.js deleted file mode 100644 index 49483f0586..0000000000 --- a/tests/tests/src/offset.js +++ /dev/null @@ -1,17 +0,0 @@ -// Generated by ReScript, PLEASE EDIT WITH CARE -'use strict'; - - -let $$Set; - -let M = { - x: 1, - $$Set: $$Set -}; - -let x = 1; - -exports.M = M; -exports.x = x; -exports.$$Set = $$Set; -/* No side effect */ diff --git a/tests/tests/src/offset.mjs b/tests/tests/src/offset.mjs new file mode 100644 index 0000000000..5cf7f303f0 --- /dev/null +++ b/tests/tests/src/offset.mjs @@ -0,0 +1,18 @@ +// Generated by ReScript, PLEASE EDIT WITH CARE + + +let $$Set; + +let M = { + x: 1, + $$Set: $$Set +}; + +let x = 1; + +export { + M, + x, + $$Set, +} +/* No side effect */ diff --git a/tests/tests/src/omit_trailing_undefined_in_external_calls.js b/tests/tests/src/omit_trailing_undefined_in_external_calls.js deleted file mode 100644 index 39d603cf54..0000000000 --- a/tests/tests/src/omit_trailing_undefined_in_external_calls.js +++ /dev/null @@ -1,19 +0,0 @@ -// Generated by ReScript, PLEASE EDIT WITH CARE -'use strict'; - -let SomeModule = require("SomeModule"); - -SomeModule.formatDate(new Date()); - -SomeModule.formatDate(new Date(), { - someOption: true -}); - -SomeModule.formatDate(new Date(), undefined, true); - -(42).toString(); - -let x = new RegExp("ab+c"); - -exports.x = x; -/* Not a pure module */ diff --git a/tests/tests/src/omit_trailing_undefined_in_external_calls.mjs b/tests/tests/src/omit_trailing_undefined_in_external_calls.mjs new file mode 100644 index 0000000000..e328377636 --- /dev/null +++ b/tests/tests/src/omit_trailing_undefined_in_external_calls.mjs @@ -0,0 +1,20 @@ +// Generated by ReScript, PLEASE EDIT WITH CARE + +import * as SomeModule from "SomeModule"; + +SomeModule.formatDate(new Date()); + +SomeModule.formatDate(new Date(), { + someOption: true +}); + +SomeModule.formatDate(new Date(), undefined, true); + +(42).toString(); + +let x = new RegExp("ab+c"); + +export { + x, +} +/* Not a pure module */ diff --git a/tests/tests/src/option_encoding_test.js b/tests/tests/src/option_encoding_test.js deleted file mode 100644 index b4a64b646b..0000000000 --- a/tests/tests/src/option_encoding_test.js +++ /dev/null @@ -1,17 +0,0 @@ -// Generated by ReScript, PLEASE EDIT WITH CARE -'use strict'; - - -let N = {}; - -let u = [ - undefined, - 3 -]; - -let h; - -exports.N = N; -exports.u = u; -exports.h = h; -/* No side effect */ diff --git a/tests/tests/src/option_encoding_test.mjs b/tests/tests/src/option_encoding_test.mjs new file mode 100644 index 0000000000..58f1c889ff --- /dev/null +++ b/tests/tests/src/option_encoding_test.mjs @@ -0,0 +1,18 @@ +// Generated by ReScript, PLEASE EDIT WITH CARE + + +let N = {}; + +let u = [ + undefined, + 3 +]; + +let h; + +export { + N, + u, + h, +} +/* No side effect */ diff --git a/tests/tests/src/option_repr_test.js b/tests/tests/src/option_repr_test.js deleted file mode 100644 index d4f0641d34..0000000000 --- a/tests/tests/src/option_repr_test.js +++ /dev/null @@ -1,302 +0,0 @@ -// Generated by ReScript, PLEASE EDIT WITH CARE -'use strict'; - -let Mt = require("./mt.js"); -let Belt_List = require("rescript/lib/js/Belt_List.js"); -let Primitive_object = require("rescript/lib/js/Primitive_object.js"); -let Primitive_option = require("rescript/lib/js/Primitive_option.js"); - -let suites = { - contents: /* [] */0 -}; - -let test_id = { - contents: 0 -}; - -function eq(loc, x, y) { - Mt.eq_suites(test_id, suites, loc, x, y); -} - -function b(loc, v) { - Mt.bool_suites(test_id, suites, loc, v); -} - -function f0(x) { - let match = x[1]; - if (match !== undefined && match) { - return 1; - } else { - return 2; - } -} - -function f1(u) { - if (typeof u !== "object") { - return 1; - } else { - return 0; - } -} - -function f2(x, y, zOpt, param) { - let z = zOpt !== undefined ? zOpt : 3; - console.log(x); - if (y !== undefined) { - return y + z | 0; - } else { - return 0; - } -} - -function f3(x) { - if (x !== undefined) { - return 1; - } else { - return 0; - } -} - -function f4(x) { - if (x !== undefined) { - return x + 1 | 0; - } else { - return 0; - } -} - -function f5(a) { - return false; -} - -function f6(a) { - return true; -} - -let f10 = Primitive_option.some(Primitive_option.some(Primitive_option.some(Primitive_option.some(undefined)))); - -let f11 = Primitive_option.some(f10); - -let randomized = { - contents: false -}; - -function create(randomOpt, param) { - let random = randomOpt !== undefined ? randomOpt : randomized.contents; - if (random) { - return 2; - } else { - return 1; - } -} - -let ff = create(false, undefined); - -function f13(xOpt, yOpt, param) { - let x = xOpt !== undefined ? xOpt : 3; - let y = yOpt !== undefined ? yOpt : 4; - return x + y | 0; -} - -let a = f13(2, undefined, undefined); - -function f12(x) { - return x; -} - -let length_8_id = Belt_List.makeBy(8, x => x); - -let length_10_id = Belt_List.makeBy(10, x => x); - -function f13$1() { - return Primitive_object.equal(Belt_List.take(length_10_id, 8), { - hd: 1, - tl: { - hd: 2, - tl: { - hd: 3, - tl: /* [] */0 - } - } - }); -} - -b("File \"option_repr_test.res\", line 93, characters 4-11", Primitive_object.lessthan(undefined, null)); - -b("File \"option_repr_test.res\", line 94, characters 4-11", !Primitive_object.greaterthan(undefined, null)); - -b("File \"option_repr_test.res\", line 95, characters 4-11", Primitive_object.greaterthan(null, undefined)); - -b("File \"option_repr_test.res\", line 96, characters 4-11", Primitive_object.lessthan(undefined, Primitive_option.some(undefined))); - -b("File \"option_repr_test.res\", line 97, characters 4-11", Primitive_object.greaterthan(Primitive_option.some(undefined), undefined)); - -console.log(6, undefined); - -function ltx(a, b) { - if (Primitive_object.lessthan(a, b)) { - return Primitive_object.greaterthan(b, a); - } else { - return false; - } -} - -function gtx(a, b) { - if (Primitive_object.greaterthan(a, b)) { - return Primitive_object.lessthan(b, a); - } else { - return false; - } -} - -function eqx(a, b) { - if (Primitive_object.equal(a, b)) { - return Primitive_object.equal(b, a); - } else { - return false; - } -} - -function neqx(a, b) { - if (Primitive_object.notequal(a, b)) { - return Primitive_object.notequal(b, a); - } else { - return false; - } -} - -function all_true(xs) { - return Belt_List.every(xs, x => x); -} - -let xs_0 = gtx(Primitive_option.some(null), Primitive_option.some(undefined)); - -let xs = { - hd: xs_0, - tl: /* [] */0 -}; - -b("File \"option_repr_test.res\", line 125, characters 8-15", Belt_List.every(xs, x => x)); - -let xs_0$1 = Primitive_object.lessthan(Primitive_option.some(undefined), 3) && Primitive_object.greaterthan(3, Primitive_option.some(undefined)); - -let xs_1 = { - hd: Primitive_object.lessthan(Primitive_option.some(undefined), Primitive_option.some(Primitive_option.some(undefined))) && Primitive_object.greaterthan(Primitive_option.some(Primitive_option.some(undefined)), Primitive_option.some(undefined)), - tl: { - hd: Primitive_object.lessthan(Primitive_option.some(undefined), "3") && Primitive_object.greaterthan("3", Primitive_option.some(undefined)), - tl: { - hd: Primitive_object.lessthan(Primitive_option.some(undefined), true) && Primitive_object.greaterthan(true, Primitive_option.some(undefined)), - tl: { - hd: Primitive_object.lessthan(Primitive_option.some(undefined), false) && Primitive_object.greaterthan(false, Primitive_option.some(undefined)), - tl: { - hd: Primitive_object.lessthan(false, true) && Primitive_object.greaterthan(true, false), - tl: { - hd: Primitive_object.lessthan(false, true) && Primitive_object.greaterthan(true, false), - tl: { - hd: Primitive_object.lessthan(undefined, Primitive_option.some(undefined)) && Primitive_object.greaterthan(Primitive_option.some(undefined), undefined), - tl: { - hd: ltx(undefined, null), - tl: { - hd: ltx(undefined, x => x), - tl: { - hd: ltx(null, 3), - tl: /* [] */0 - } - } - } - } - } - } - } - } - } -}; - -let xs$1 = { - hd: xs_0$1, - tl: xs_1 -}; - -b("File \"option_repr_test.res\", line 128, characters 4-11", Belt_List.every(xs$1, x => x)); - -let xs_0$2 = true && true; - -let xs_1$1 = { - hd: neqx(undefined, null), - tl: { - hd: Primitive_object.equal(Primitive_option.some(undefined), Primitive_option.some(undefined)) && Primitive_object.equal(Primitive_option.some(undefined), Primitive_option.some(undefined)), - tl: { - hd: Primitive_object.equal(Primitive_option.some(Primitive_option.some(undefined)), Primitive_option.some(Primitive_option.some(undefined))) && Primitive_object.equal(Primitive_option.some(Primitive_option.some(undefined)), Primitive_option.some(Primitive_option.some(undefined))), - tl: { - hd: Primitive_object.notequal(Primitive_option.some(Primitive_option.some(Primitive_option.some(undefined))), Primitive_option.some(Primitive_option.some(undefined))) && Primitive_object.notequal(Primitive_option.some(Primitive_option.some(undefined)), Primitive_option.some(Primitive_option.some(Primitive_option.some(undefined)))), - tl: /* [] */0 - } - } - } -}; - -let xs$2 = { - hd: xs_0$2, - tl: xs_1$1 -}; - -b("File \"option_repr_test.res\", line 145, characters 4-11", Belt_List.every(xs$2, x => x)); - -function v(x) { - return x; -} - -function v0(x) { - return x; -} - -let N0 = { - v: v, - v0: v0 -}; - -Mt.from_pair_suites("Option_repr_test", suites.contents); - -let f7; - -let f8 = Primitive_option.some(undefined); - -let f9 = Primitive_option.some(Primitive_option.some(undefined)); - -let N; - -let none_arg; - -exports.suites = suites; -exports.test_id = test_id; -exports.eq = eq; -exports.b = b; -exports.f0 = f0; -exports.f1 = f1; -exports.f2 = f2; -exports.f3 = f3; -exports.f4 = f4; -exports.f5 = f5; -exports.f6 = f6; -exports.f7 = f7; -exports.f8 = f8; -exports.f9 = f9; -exports.f10 = f10; -exports.f11 = f11; -exports.randomized = randomized; -exports.create = create; -exports.ff = ff; -exports.a = a; -exports.f12 = f12; -exports.N = N; -exports.length_8_id = length_8_id; -exports.length_10_id = length_10_id; -exports.f13 = f13$1; -exports.none_arg = none_arg; -exports.ltx = ltx; -exports.gtx = gtx; -exports.eqx = eqx; -exports.neqx = neqx; -exports.all_true = all_true; -exports.N0 = N0; -/* ff Not a pure module */ diff --git a/tests/tests/src/option_repr_test.mjs b/tests/tests/src/option_repr_test.mjs new file mode 100644 index 0000000000..84b3ae1fe9 --- /dev/null +++ b/tests/tests/src/option_repr_test.mjs @@ -0,0 +1,303 @@ +// Generated by ReScript, PLEASE EDIT WITH CARE + +import * as Mt from "./mt.mjs"; +import * as Belt_List from "rescript/lib/es6/Belt_List.js"; +import * as Primitive_object from "rescript/lib/es6/Primitive_object.js"; +import * as Primitive_option from "rescript/lib/es6/Primitive_option.js"; + +let suites = { + contents: /* [] */0 +}; + +let test_id = { + contents: 0 +}; + +function eq(loc, x, y) { + Mt.eq_suites(test_id, suites, loc, x, y); +} + +function b(loc, v) { + Mt.bool_suites(test_id, suites, loc, v); +} + +function f0(x) { + let match = x[1]; + if (match !== undefined && match) { + return 1; + } else { + return 2; + } +} + +function f1(u) { + if (typeof u !== "object") { + return 1; + } else { + return 0; + } +} + +function f2(x, y, zOpt, param) { + let z = zOpt !== undefined ? zOpt : 3; + console.log(x); + if (y !== undefined) { + return y + z | 0; + } else { + return 0; + } +} + +function f3(x) { + if (x !== undefined) { + return 1; + } else { + return 0; + } +} + +function f4(x) { + if (x !== undefined) { + return x + 1 | 0; + } else { + return 0; + } +} + +function f5(a) { + return false; +} + +function f6(a) { + return true; +} + +let f10 = Primitive_option.some(Primitive_option.some(Primitive_option.some(Primitive_option.some(undefined)))); + +let f11 = Primitive_option.some(f10); + +let randomized = { + contents: false +}; + +function create(randomOpt, param) { + let random = randomOpt !== undefined ? randomOpt : randomized.contents; + if (random) { + return 2; + } else { + return 1; + } +} + +let ff = create(false, undefined); + +function f13(xOpt, yOpt, param) { + let x = xOpt !== undefined ? xOpt : 3; + let y = yOpt !== undefined ? yOpt : 4; + return x + y | 0; +} + +let a = f13(2, undefined, undefined); + +function f12(x) { + return x; +} + +let length_8_id = Belt_List.makeBy(8, x => x); + +let length_10_id = Belt_List.makeBy(10, x => x); + +function f13$1() { + return Primitive_object.equal(Belt_List.take(length_10_id, 8), { + hd: 1, + tl: { + hd: 2, + tl: { + hd: 3, + tl: /* [] */0 + } + } + }); +} + +b("File \"option_repr_test.res\", line 93, characters 4-11", Primitive_object.lessthan(undefined, null)); + +b("File \"option_repr_test.res\", line 94, characters 4-11", !Primitive_object.greaterthan(undefined, null)); + +b("File \"option_repr_test.res\", line 95, characters 4-11", Primitive_object.greaterthan(null, undefined)); + +b("File \"option_repr_test.res\", line 96, characters 4-11", Primitive_object.lessthan(undefined, Primitive_option.some(undefined))); + +b("File \"option_repr_test.res\", line 97, characters 4-11", Primitive_object.greaterthan(Primitive_option.some(undefined), undefined)); + +console.log(6, undefined); + +function ltx(a, b) { + if (Primitive_object.lessthan(a, b)) { + return Primitive_object.greaterthan(b, a); + } else { + return false; + } +} + +function gtx(a, b) { + if (Primitive_object.greaterthan(a, b)) { + return Primitive_object.lessthan(b, a); + } else { + return false; + } +} + +function eqx(a, b) { + if (Primitive_object.equal(a, b)) { + return Primitive_object.equal(b, a); + } else { + return false; + } +} + +function neqx(a, b) { + if (Primitive_object.notequal(a, b)) { + return Primitive_object.notequal(b, a); + } else { + return false; + } +} + +function all_true(xs) { + return Belt_List.every(xs, x => x); +} + +let xs_0 = gtx(Primitive_option.some(null), Primitive_option.some(undefined)); + +let xs = { + hd: xs_0, + tl: /* [] */0 +}; + +b("File \"option_repr_test.res\", line 125, characters 8-15", Belt_List.every(xs, x => x)); + +let xs_0$1 = Primitive_object.lessthan(Primitive_option.some(undefined), 3) && Primitive_object.greaterthan(3, Primitive_option.some(undefined)); + +let xs_1 = { + hd: Primitive_object.lessthan(Primitive_option.some(undefined), Primitive_option.some(Primitive_option.some(undefined))) && Primitive_object.greaterthan(Primitive_option.some(Primitive_option.some(undefined)), Primitive_option.some(undefined)), + tl: { + hd: Primitive_object.lessthan(Primitive_option.some(undefined), "3") && Primitive_object.greaterthan("3", Primitive_option.some(undefined)), + tl: { + hd: Primitive_object.lessthan(Primitive_option.some(undefined), true) && Primitive_object.greaterthan(true, Primitive_option.some(undefined)), + tl: { + hd: Primitive_object.lessthan(Primitive_option.some(undefined), false) && Primitive_object.greaterthan(false, Primitive_option.some(undefined)), + tl: { + hd: Primitive_object.lessthan(false, true) && Primitive_object.greaterthan(true, false), + tl: { + hd: Primitive_object.lessthan(false, true) && Primitive_object.greaterthan(true, false), + tl: { + hd: Primitive_object.lessthan(undefined, Primitive_option.some(undefined)) && Primitive_object.greaterthan(Primitive_option.some(undefined), undefined), + tl: { + hd: ltx(undefined, null), + tl: { + hd: ltx(undefined, x => x), + tl: { + hd: ltx(null, 3), + tl: /* [] */0 + } + } + } + } + } + } + } + } + } +}; + +let xs$1 = { + hd: xs_0$1, + tl: xs_1 +}; + +b("File \"option_repr_test.res\", line 128, characters 4-11", Belt_List.every(xs$1, x => x)); + +let xs_0$2 = true && true; + +let xs_1$1 = { + hd: neqx(undefined, null), + tl: { + hd: Primitive_object.equal(Primitive_option.some(undefined), Primitive_option.some(undefined)) && Primitive_object.equal(Primitive_option.some(undefined), Primitive_option.some(undefined)), + tl: { + hd: Primitive_object.equal(Primitive_option.some(Primitive_option.some(undefined)), Primitive_option.some(Primitive_option.some(undefined))) && Primitive_object.equal(Primitive_option.some(Primitive_option.some(undefined)), Primitive_option.some(Primitive_option.some(undefined))), + tl: { + hd: Primitive_object.notequal(Primitive_option.some(Primitive_option.some(Primitive_option.some(undefined))), Primitive_option.some(Primitive_option.some(undefined))) && Primitive_object.notequal(Primitive_option.some(Primitive_option.some(undefined)), Primitive_option.some(Primitive_option.some(Primitive_option.some(undefined)))), + tl: /* [] */0 + } + } + } +}; + +let xs$2 = { + hd: xs_0$2, + tl: xs_1$1 +}; + +b("File \"option_repr_test.res\", line 145, characters 4-11", Belt_List.every(xs$2, x => x)); + +function v(x) { + return x; +} + +function v0(x) { + return x; +} + +let N0 = { + v: v, + v0: v0 +}; + +Mt.from_pair_suites("Option_repr_test", suites.contents); + +let f7; + +let f8 = Primitive_option.some(undefined); + +let f9 = Primitive_option.some(Primitive_option.some(undefined)); + +let N; + +let none_arg; + +export { + suites, + test_id, + eq, + b, + f0, + f1, + f2, + f3, + f4, + f5, + f6, + f7, + f8, + f9, + f10, + f11, + randomized, + create, + ff, + a, + f12, + N, + length_8_id, + length_10_id, + f13$1 as f13, + none_arg, + ltx, + gtx, + eqx, + neqx, + all_true, + N0, +} +/* ff Not a pure module */ diff --git a/tests/tests/src/optional_ffi_test.js b/tests/tests/src/optional_ffi_test.js deleted file mode 100644 index 8a2f05fbc4..0000000000 --- a/tests/tests/src/optional_ffi_test.js +++ /dev/null @@ -1,145 +0,0 @@ -// Generated by ReScript, PLEASE EDIT WITH CARE -'use strict'; - -let Mt = require("./mt.js"); -let Primitive_option = require("rescript/lib/js/Primitive_option.js"); - -let suites = { - contents: /* [] */0 -}; - -let test_id = { - contents: 0 -}; - -function eq(loc, param) { - let y = param[1]; - let x = param[0]; - test_id.contents = test_id.contents + 1 | 0; - suites.contents = { - hd: [ - loc + (" id " + test_id.contents.toString()), - () => ({ - TAG: "Eq", - _0: x, - _1: y - }) - ], - tl: suites.contents - }; -} - -function hey(x, y) { - if (x === void 0) { x = 3; } - return x + y; - } -; - -let u = hey(undefined, 3); - -let z = hey(5, 3); - -eq("File \"optional_ffi_test.res\", line 24, characters 12-19", [ - [ - u, - z - ], - [ - 6, - 8 - ] -]); - -let counter = { - contents: 0 -}; - -function side_effect(x) { - x.contents = x.contents + 1 | 0; - return x.contents; -} - -function bug_to_fix(f, x) { - return hey(f(x), 3); -} - -function bug_to_fix2(f, x) { - return hey(Primitive_option.toUndefined(f(x)), 3); -} - -let counter2 = { - contents: 0 -}; - -function side_effect2(x) { - x.contents = x.contents + 1 | 0; - return x.contents; -} - -let v = bug_to_fix(side_effect, counter); - -let pair_0 = [ - v, - counter.contents -]; - -let pair_1 = [ - 4, - 1 -]; - -let pair = [ - pair_0, - pair_1 -]; - -let v2 = bug_to_fix2(side_effect2, counter2); - -let pair2_0 = [ - v2, - counter.contents -]; - -let pair2_1 = [ - 4, - 1 -]; - -let pair2 = [ - pair2_0, - pair2_1 -]; - -eq("File \"optional_ffi_test.res\", line 48, characters 5-12", pair); - -eq("File \"optional_ffi_test.res\", line 49, characters 5-12", pair2); - -function heystr(x, y) { - if (x === void 0) { x = "3"; } - return x + y; - } -; - -let pair_1$1 = heystr("name", "4"); - -let pair$1 = [ - "name4", - pair_1$1 -]; - -eq("File \"optional_ffi_test.res\", line 64, characters 5-12", pair$1); - -Mt.from_pair_suites("Optional_ffi_test", suites.contents); - -exports.suites = suites; -exports.test_id = test_id; -exports.eq = eq; -exports.u = u; -exports.z = z; -exports.counter = counter; -exports.side_effect = side_effect; -exports.bug_to_fix = bug_to_fix; -exports.bug_to_fix2 = bug_to_fix2; -exports.counter2 = counter2; -exports.side_effect2 = side_effect2; -/* Not a pure module */ diff --git a/tests/tests/src/optional_ffi_test.mjs b/tests/tests/src/optional_ffi_test.mjs new file mode 100644 index 0000000000..20a1972729 --- /dev/null +++ b/tests/tests/src/optional_ffi_test.mjs @@ -0,0 +1,146 @@ +// Generated by ReScript, PLEASE EDIT WITH CARE + +import * as Mt from "./mt.mjs"; +import * as Primitive_option from "rescript/lib/es6/Primitive_option.js"; + +let suites = { + contents: /* [] */0 +}; + +let test_id = { + contents: 0 +}; + +function eq(loc, param) { + let y = param[1]; + let x = param[0]; + test_id.contents = test_id.contents + 1 | 0; + suites.contents = { + hd: [ + loc + (" id " + test_id.contents.toString()), + () => ({ + TAG: "Eq", + _0: x, + _1: y + }) + ], + tl: suites.contents + }; +} + +function hey(x, y) { + if (x === void 0) { x = 3; } + return x + y; + } +; + +let u = hey(undefined, 3); + +let z = hey(5, 3); + +eq("File \"optional_ffi_test.res\", line 24, characters 12-19", [ + [ + u, + z + ], + [ + 6, + 8 + ] +]); + +let counter = { + contents: 0 +}; + +function side_effect(x) { + x.contents = x.contents + 1 | 0; + return x.contents; +} + +function bug_to_fix(f, x) { + return hey(f(x), 3); +} + +function bug_to_fix2(f, x) { + return hey(Primitive_option.toUndefined(f(x)), 3); +} + +let counter2 = { + contents: 0 +}; + +function side_effect2(x) { + x.contents = x.contents + 1 | 0; + return x.contents; +} + +let v = bug_to_fix(side_effect, counter); + +let pair_0 = [ + v, + counter.contents +]; + +let pair_1 = [ + 4, + 1 +]; + +let pair = [ + pair_0, + pair_1 +]; + +let v2 = bug_to_fix2(side_effect2, counter2); + +let pair2_0 = [ + v2, + counter.contents +]; + +let pair2_1 = [ + 4, + 1 +]; + +let pair2 = [ + pair2_0, + pair2_1 +]; + +eq("File \"optional_ffi_test.res\", line 48, characters 5-12", pair); + +eq("File \"optional_ffi_test.res\", line 49, characters 5-12", pair2); + +function heystr(x, y) { + if (x === void 0) { x = "3"; } + return x + y; + } +; + +let pair_1$1 = heystr("name", "4"); + +let pair$1 = [ + "name4", + pair_1$1 +]; + +eq("File \"optional_ffi_test.res\", line 64, characters 5-12", pair$1); + +Mt.from_pair_suites("Optional_ffi_test", suites.contents); + +export { + suites, + test_id, + eq, + u, + z, + counter, + side_effect, + bug_to_fix, + bug_to_fix2, + counter2, + side_effect2, +} +/* Not a pure module */ diff --git a/tests/tests/src/optional_regression_test.js b/tests/tests/src/optional_regression_test.js deleted file mode 100644 index dee0d2a171..0000000000 --- a/tests/tests/src/optional_regression_test.js +++ /dev/null @@ -1,54 +0,0 @@ -// Generated by ReScript, PLEASE EDIT WITH CARE -'use strict'; - -let Mt = require("./mt.js"); -let Primitive_option = require("rescript/lib/js/Primitive_option.js"); - -let suites = { - contents: /* [] */0 -}; - -let test_id = { - contents: 0 -}; - -function eq(loc, x, y) { - Mt.eq_suites(test_id, suites, loc, x, y); -} - -function make(s, b, i, param) { - let tmp = {}; - if (s !== undefined) { - tmp.s = Primitive_option.valFromOption(s); - } - if (b !== undefined) { - tmp.b = Primitive_option.valFromOption(b); - } - if (i !== undefined) { - tmp.i = Primitive_option.valFromOption(i); - } - return tmp; -} - -let hh = { - s: "", - b: false, - i: 0 -}; - -eq("File \"optional_regression_test.res\", line 16, characters 3-10", Primitive_option.fromUndefined(hh.s), ""); - -eq("File \"optional_regression_test.res\", line 17, characters 3-10", Primitive_option.fromUndefined(hh.b), false); - -eq("File \"optional_regression_test.res\", line 18, characters 3-10", Primitive_option.fromUndefined(hh.i), 0); - -console.log(hh); - -Mt.from_pair_suites("Optional_regression_test", suites.contents); - -exports.suites = suites; -exports.test_id = test_id; -exports.eq = eq; -exports.make = make; -exports.hh = hh; -/* Not a pure module */ diff --git a/tests/tests/src/optional_regression_test.mjs b/tests/tests/src/optional_regression_test.mjs new file mode 100644 index 0000000000..a3baf11fc1 --- /dev/null +++ b/tests/tests/src/optional_regression_test.mjs @@ -0,0 +1,55 @@ +// Generated by ReScript, PLEASE EDIT WITH CARE + +import * as Mt from "./mt.mjs"; +import * as Primitive_option from "rescript/lib/es6/Primitive_option.js"; + +let suites = { + contents: /* [] */0 +}; + +let test_id = { + contents: 0 +}; + +function eq(loc, x, y) { + Mt.eq_suites(test_id, suites, loc, x, y); +} + +function make(s, b, i, param) { + let tmp = {}; + if (s !== undefined) { + tmp.s = Primitive_option.valFromOption(s); + } + if (b !== undefined) { + tmp.b = Primitive_option.valFromOption(b); + } + if (i !== undefined) { + tmp.i = Primitive_option.valFromOption(i); + } + return tmp; +} + +let hh = { + s: "", + b: false, + i: 0 +}; + +eq("File \"optional_regression_test.res\", line 16, characters 3-10", Primitive_option.fromUndefined(hh.s), ""); + +eq("File \"optional_regression_test.res\", line 17, characters 3-10", Primitive_option.fromUndefined(hh.b), false); + +eq("File \"optional_regression_test.res\", line 18, characters 3-10", Primitive_option.fromUndefined(hh.i), 0); + +console.log(hh); + +Mt.from_pair_suites("Optional_regression_test", suites.contents); + +export { + suites, + test_id, + eq, + make, + hh, +} +/* Not a pure module */ diff --git a/tests/tests/src/pipe_send_readline.js b/tests/tests/src/pipe_send_readline.js deleted file mode 100644 index 5d450e7f9e..0000000000 --- a/tests/tests/src/pipe_send_readline.js +++ /dev/null @@ -1,24 +0,0 @@ -// Generated by ReScript, PLEASE EDIT WITH CARE -'use strict'; - - -function u(rl) { - return rl.on("line", x => { - console.log(x); - }).on("close", () => { - console.log("finished"); - }); -} - -function xx(h) { - return h.send("x").hi; -} - -function yy(h) { - return h.send("x"); -} - -exports.u = u; -exports.xx = xx; -exports.yy = yy; -/* No side effect */ diff --git a/tests/tests/src/pipe_send_readline.mjs b/tests/tests/src/pipe_send_readline.mjs new file mode 100644 index 0000000000..eda33d26c7 --- /dev/null +++ b/tests/tests/src/pipe_send_readline.mjs @@ -0,0 +1,25 @@ +// Generated by ReScript, PLEASE EDIT WITH CARE + + +function u(rl) { + return rl.on("line", x => { + console.log(x); + }).on("close", () => { + console.log("finished"); + }); +} + +function xx(h) { + return h.send("x").hi; +} + +function yy(h) { + return h.send("x"); +} + +export { + u, + xx, + yy, +} +/* No side effect */ diff --git a/tests/tests/src/pipe_syntax.js b/tests/tests/src/pipe_syntax.js deleted file mode 100644 index 0fe0a5a9d6..0000000000 --- a/tests/tests/src/pipe_syntax.js +++ /dev/null @@ -1,101 +0,0 @@ -// Generated by ReScript, PLEASE EDIT WITH CARE -'use strict'; - -let Primitive_option = require("rescript/lib/js/Primitive_option.js"); - -function t0(x, f) { - return f(f(f(x))); -} - -function t1(x, f) { - return f(x); -} - -function t2(x, f, g) { - return f(g(f(x), x, x)); -} - -function t3(x, f) { - return f(x, 1, 2); -} - -function f(a, b, c) { - return [ - b(a), - c(a) - ]; -} - -function f1(a, b, c, d) { - let __tuple_internal_obj = a(b); - return [ - c(__tuple_internal_obj), - d(__tuple_internal_obj) - ]; -} - -function f2(a, b, c, d) { - let __tuple_internal_obj = a(b); - let u = c(__tuple_internal_obj); - let v = d(__tuple_internal_obj); - return u + v | 0; -} - -function f3(a, b, c, d, e) { - let __tuple_internal_obj = a(b); - let param_0 = c(__tuple_internal_obj, d); - let param_1 = d(__tuple_internal_obj, 1, 2); - let param_2 = e(__tuple_internal_obj); - return (param_0 + param_1 | 0) + param_2 | 0; -} - -function f4(a, b, c) { - return [ - b(a, c), - b(a, c) - ]; -} - -function f5(a, b, c, d) { - let v0 = b(a, c, c); - let v1 = b(a, c, c); - let v2 = b(a, d, d); - return (v0 + v1 | 0) + v2 | 0; -} - -function f6(a) { - return Primitive_option.some(a); -} - -function f7(a) { - return [ - Primitive_option.some(a), - Primitive_option.some(a), - Primitive_option.some(a) - ]; -} - -function f8(a) { - return Primitive_option.some(Primitive_option.some(a)); -} - -let with_poly = { - NAME: "Foo", - VAL: 1 -}; - -exports.t0 = t0; -exports.t1 = t1; -exports.t2 = t2; -exports.t3 = t3; -exports.f = f; -exports.f1 = f1; -exports.f2 = f2; -exports.f3 = f3; -exports.f4 = f4; -exports.f5 = f5; -exports.f6 = f6; -exports.f7 = f7; -exports.f8 = f8; -exports.with_poly = with_poly; -/* No side effect */ diff --git a/tests/tests/src/pipe_syntax.mjs b/tests/tests/src/pipe_syntax.mjs new file mode 100644 index 0000000000..2eced48633 --- /dev/null +++ b/tests/tests/src/pipe_syntax.mjs @@ -0,0 +1,102 @@ +// Generated by ReScript, PLEASE EDIT WITH CARE + +import * as Primitive_option from "rescript/lib/es6/Primitive_option.js"; + +function t0(x, f) { + return f(f(f(x))); +} + +function t1(x, f) { + return f(x); +} + +function t2(x, f, g) { + return f(g(f(x), x, x)); +} + +function t3(x, f) { + return f(x, 1, 2); +} + +function f(a, b, c) { + return [ + b(a), + c(a) + ]; +} + +function f1(a, b, c, d) { + let __tuple_internal_obj = a(b); + return [ + c(__tuple_internal_obj), + d(__tuple_internal_obj) + ]; +} + +function f2(a, b, c, d) { + let __tuple_internal_obj = a(b); + let u = c(__tuple_internal_obj); + let v = d(__tuple_internal_obj); + return u + v | 0; +} + +function f3(a, b, c, d, e) { + let __tuple_internal_obj = a(b); + let param_0 = c(__tuple_internal_obj, d); + let param_1 = d(__tuple_internal_obj, 1, 2); + let param_2 = e(__tuple_internal_obj); + return (param_0 + param_1 | 0) + param_2 | 0; +} + +function f4(a, b, c) { + return [ + b(a, c), + b(a, c) + ]; +} + +function f5(a, b, c, d) { + let v0 = b(a, c, c); + let v1 = b(a, c, c); + let v2 = b(a, d, d); + return (v0 + v1 | 0) + v2 | 0; +} + +function f6(a) { + return Primitive_option.some(a); +} + +function f7(a) { + return [ + Primitive_option.some(a), + Primitive_option.some(a), + Primitive_option.some(a) + ]; +} + +function f8(a) { + return Primitive_option.some(Primitive_option.some(a)); +} + +let with_poly = { + NAME: "Foo", + VAL: 1 +}; + +export { + t0, + t1, + t2, + t3, + f, + f1, + f2, + f3, + f4, + f5, + f6, + f7, + f8, + with_poly, +} +/* No side effect */ diff --git a/tests/tests/src/poly_empty_array.js b/tests/tests/src/poly_empty_array.js deleted file mode 100644 index 0427c97349..0000000000 --- a/tests/tests/src/poly_empty_array.js +++ /dev/null @@ -1,8 +0,0 @@ -// Generated by ReScript, PLEASE EDIT WITH CARE -'use strict'; - - -let a = []; - -exports.a = a; -/* No side effect */ diff --git a/tests/tests/src/poly_empty_array.mjs b/tests/tests/src/poly_empty_array.mjs new file mode 100644 index 0000000000..99ba29d762 --- /dev/null +++ b/tests/tests/src/poly_empty_array.mjs @@ -0,0 +1,9 @@ +// Generated by ReScript, PLEASE EDIT WITH CARE + + +let a = []; + +export { + a, +} +/* No side effect */ diff --git a/tests/tests/src/poly_variant_test.js b/tests/tests/src/poly_variant_test.js deleted file mode 100644 index 5c6983b4ea..0000000000 --- a/tests/tests/src/poly_variant_test.js +++ /dev/null @@ -1,102 +0,0 @@ -// Generated by ReScript, PLEASE EDIT WITH CARE -'use strict'; - -let Mt = require("./mt.js"); - -let suites = { - contents: /* [] */0 -}; - -let test_id = { - contents: 0 -}; - -function eq(loc, x, y) { - test_id.contents = test_id.contents + 1 | 0; - suites.contents = { - hd: [ - loc + (" id " + test_id.contents.toString()), - () => ({ - TAG: "Eq", - _0: x, - _1: y - }) - ], - tl: suites.contents - }; -} - -function hey_string (option){ - switch(option){ - case "on_closed" : - case "on_open" : - case "in" : return option - default : throw Error ("impossible") - } -} -function hey_int (option){ - switch (option){ - case 0 : - case 3 : - case 4 : - case 5: - case 6 : return option - default : throw Error("impossible") - } - } -; - -let uu = [ - hey_string("on_open"), - hey_string("on_closed"), - hey_string("in") -]; - -let vv = [ - hey_int(3), - hey_int(0), - hey_int(4) -]; - -eq("File \"poly_variant_test.res\", line 68, characters 5-12", vv, [ - 3, - 0, - 4 -]); - -eq("File \"poly_variant_test.res\", line 69, characters 5-12", [ - hey_int(5), - hey_int(6) -], [ - 5, - 6 -]); - -eq("File \"poly_variant_test.res\", line 70, characters 5-12", uu, [ - "on_open", - "on_closed", - "in" -]); - -hey_string("on_closed"); - -hey_string("in"); - -function p_is_int_test(x) { - if (typeof x === "object") { - return 3; - } else { - return 2; - } -} - -eq("File \"poly_variant_test.res\", line 160, characters 5-12", 2, 2); - -eq("File \"poly_variant_test.res\", line 161, characters 5-12", 3, p_is_int_test({ - NAME: "b", - VAL: 2 -})); - -Mt.from_pair_suites("Poly_variant_test", suites.contents); - -/* Not a pure module */ diff --git a/tests/tests/src/poly_variant_test.mjs b/tests/tests/src/poly_variant_test.mjs new file mode 100644 index 0000000000..93b031b3ea --- /dev/null +++ b/tests/tests/src/poly_variant_test.mjs @@ -0,0 +1,101 @@ +// Generated by ReScript, PLEASE EDIT WITH CARE + +import * as Mt from "./mt.mjs"; + +let suites = { + contents: /* [] */0 +}; + +let test_id = { + contents: 0 +}; + +function eq(loc, x, y) { + test_id.contents = test_id.contents + 1 | 0; + suites.contents = { + hd: [ + loc + (" id " + test_id.contents.toString()), + () => ({ + TAG: "Eq", + _0: x, + _1: y + }) + ], + tl: suites.contents + }; +} + +function hey_string (option){ + switch(option){ + case "on_closed" : + case "on_open" : + case "in" : return option + default : throw Error ("impossible") + } +} +function hey_int (option){ + switch (option){ + case 0 : + case 3 : + case 4 : + case 5: + case 6 : return option + default : throw Error("impossible") + } + } +; + +let uu = [ + hey_string("on_open"), + hey_string("on_closed"), + hey_string("in") +]; + +let vv = [ + hey_int(3), + hey_int(0), + hey_int(4) +]; + +eq("File \"poly_variant_test.res\", line 68, characters 5-12", vv, [ + 3, + 0, + 4 +]); + +eq("File \"poly_variant_test.res\", line 69, characters 5-12", [ + hey_int(5), + hey_int(6) +], [ + 5, + 6 +]); + +eq("File \"poly_variant_test.res\", line 70, characters 5-12", uu, [ + "on_open", + "on_closed", + "in" +]); + +hey_string("on_closed"); + +hey_string("in"); + +function p_is_int_test(x) { + if (typeof x === "object") { + return 3; + } else { + return 2; + } +} + +eq("File \"poly_variant_test.res\", line 160, characters 5-12", 2, 2); + +eq("File \"poly_variant_test.res\", line 161, characters 5-12", 3, p_is_int_test({ + NAME: "b", + VAL: 2 +})); + +Mt.from_pair_suites("Poly_variant_test", suites.contents); + +/* Not a pure module */ diff --git a/tests/tests/src/polymorphic_raw_test.js b/tests/tests/src/polymorphic_raw_test.js deleted file mode 100644 index 60975b707d..0000000000 --- a/tests/tests/src/polymorphic_raw_test.js +++ /dev/null @@ -1,47 +0,0 @@ -// Generated by ReScript, PLEASE EDIT WITH CARE -'use strict'; - -let Mt = require("./mt.js"); - -let suites = { - contents: /* [] */0 -}; - -let test_id = { - contents: 0 -}; - -function eq(loc, x, y) { - test_id.contents = test_id.contents + 1 | 0; - suites.contents = { - hd: [ - loc + (" id " + test_id.contents.toString()), - () => ({ - TAG: "Eq", - _0: x, - _1: y - }) - ], - tl: suites.contents - }; -} - -let f = ((a) => typeof a); - -let a = f(3); - -let b = f("3"); - -eq("File \"polymorphic_raw_test.res\", line 21, characters 3-10", a, "number"); - -eq("File \"polymorphic_raw_test.res\", line 22, characters 3-10", b, "string"); - -Mt.from_pair_suites("polymorphic_raw_test.res", suites.contents); - -exports.suites = suites; -exports.test_id = test_id; -exports.eq = eq; -exports.f = f; -exports.a = a; -exports.b = b; -/* a Not a pure module */ diff --git a/tests/tests/src/polymorphic_raw_test.mjs b/tests/tests/src/polymorphic_raw_test.mjs new file mode 100644 index 0000000000..8d364eb5a1 --- /dev/null +++ b/tests/tests/src/polymorphic_raw_test.mjs @@ -0,0 +1,48 @@ +// Generated by ReScript, PLEASE EDIT WITH CARE + +import * as Mt from "./mt.mjs"; + +let suites = { + contents: /* [] */0 +}; + +let test_id = { + contents: 0 +}; + +function eq(loc, x, y) { + test_id.contents = test_id.contents + 1 | 0; + suites.contents = { + hd: [ + loc + (" id " + test_id.contents.toString()), + () => ({ + TAG: "Eq", + _0: x, + _1: y + }) + ], + tl: suites.contents + }; +} + +let f = ((a) => typeof a); + +let a = f(3); + +let b = f("3"); + +eq("File \"polymorphic_raw_test.res\", line 21, characters 3-10", a, "number"); + +eq("File \"polymorphic_raw_test.res\", line 22, characters 3-10", b, "string"); + +Mt.from_pair_suites("polymorphic_raw_test.res", suites.contents); + +export { + suites, + test_id, + eq, + f, + a, + b, +} +/* a Not a pure module */ diff --git a/tests/tests/src/polymorphism_test.js b/tests/tests/src/polymorphism_test.js deleted file mode 100644 index 040ba393b5..0000000000 --- a/tests/tests/src/polymorphism_test.js +++ /dev/null @@ -1,17 +0,0 @@ -// Generated by ReScript, PLEASE EDIT WITH CARE -'use strict'; - - -function map(f, x) { - if (!x) { - return /* [] */0; - } - let r = f(x.hd); - return { - hd: r, - tl: map(f, x.tl) - }; -} - -exports.map = map; -/* No side effect */ diff --git a/tests/tests/src/polymorphism_test.mjs b/tests/tests/src/polymorphism_test.mjs new file mode 100644 index 0000000000..8acb18b56a --- /dev/null +++ b/tests/tests/src/polymorphism_test.mjs @@ -0,0 +1,18 @@ +// Generated by ReScript, PLEASE EDIT WITH CARE + + +function map(f, x) { + if (!x) { + return /* [] */0; + } + let r = f(x.hd); + return { + hd: r, + tl: map(f, x.tl) + }; +} + +export { + map, +} +/* No side effect */ diff --git a/tests/tests/src/polyvar_convert.js b/tests/tests/src/polyvar_convert.js deleted file mode 100644 index 3d1411fe6a..0000000000 --- a/tests/tests/src/polyvar_convert.js +++ /dev/null @@ -1,26 +0,0 @@ -// Generated by ReScript, PLEASE EDIT WITH CARE -'use strict'; - - -let revData = {"x":"a","b":"b"}; - -let data = {"a":"x","b":"b"}; - -function tToJs(x) { - return data[x]; -} - -function vFromJsOpt(s) { - return revData[s]; -} - -function vFromJs(s) { - return revData[s]; -} - -exports.revData = revData; -exports.data = data; -exports.tToJs = tToJs; -exports.vFromJsOpt = vFromJsOpt; -exports.vFromJs = vFromJs; -/* No side effect */ diff --git a/tests/tests/src/polyvar_convert.mjs b/tests/tests/src/polyvar_convert.mjs new file mode 100644 index 0000000000..5880a4aa0f --- /dev/null +++ b/tests/tests/src/polyvar_convert.mjs @@ -0,0 +1,27 @@ +// Generated by ReScript, PLEASE EDIT WITH CARE + + +let revData = {"x":"a","b":"b"}; + +let data = {"a":"x","b":"b"}; + +function tToJs(x) { + return data[x]; +} + +function vFromJsOpt(s) { + return revData[s]; +} + +function vFromJs(s) { + return revData[s]; +} + +export { + revData, + data, + tToJs, + vFromJsOpt, + vFromJs, +} +/* No side effect */ diff --git a/tests/tests/src/polyvar_test.js b/tests/tests/src/polyvar_test.js deleted file mode 100644 index 605ddcd972..0000000000 --- a/tests/tests/src/polyvar_test.js +++ /dev/null @@ -1,13 +0,0 @@ -// Generated by ReScript, PLEASE EDIT WITH CARE -'use strict'; - - -let ff = "B"; - -console.log([ - "A", - ff, - "A" -]); - -/* Not a pure module */ diff --git a/tests/tests/src/polyvar_test.mjs b/tests/tests/src/polyvar_test.mjs new file mode 100644 index 0000000000..4dfe5c4158 --- /dev/null +++ b/tests/tests/src/polyvar_test.mjs @@ -0,0 +1,12 @@ +// Generated by ReScript, PLEASE EDIT WITH CARE + + +let ff = "B"; + +console.log([ + "A", + ff, + "A" +]); + +/* Not a pure module */ diff --git a/tests/tests/src/ppx_apply_test.js b/tests/tests/src/ppx_apply_test.js deleted file mode 100644 index 760b0fb5b7..0000000000 --- a/tests/tests/src/ppx_apply_test.js +++ /dev/null @@ -1,57 +0,0 @@ -// Generated by ReScript, PLEASE EDIT WITH CARE -'use strict'; - -let Mt = require("./mt.js"); - -let suites = { - contents: /* [] */0 -}; - -let test_id = { - contents: 0 -}; - -function eq(loc, x, y) { - test_id.contents = test_id.contents + 1 | 0; - suites.contents = { - hd: [ - loc + (" id " + test_id.contents.toString()), - () => ({ - TAG: "Eq", - _0: x, - _1: y - }) - ], - tl: suites.contents - }; -} - -let u = 3; - -function nullary() { - return 3; -} - -function unary(a) { - return a + 3 | 0; -} - -let xx = 6; - -eq("File \"ppx_apply_test.res\", line 19, characters 12-19", u, 3); - -function h(a) { - return xx(a); -} - -Mt.from_pair_suites("Ppx_apply_test", suites.contents); - -exports.suites = suites; -exports.test_id = test_id; -exports.eq = eq; -exports.u = u; -exports.nullary = nullary; -exports.unary = unary; -exports.xx = xx; -exports.h = h; -/* Not a pure module */ diff --git a/tests/tests/src/ppx_apply_test.mjs b/tests/tests/src/ppx_apply_test.mjs new file mode 100644 index 0000000000..8c8197511b --- /dev/null +++ b/tests/tests/src/ppx_apply_test.mjs @@ -0,0 +1,58 @@ +// Generated by ReScript, PLEASE EDIT WITH CARE + +import * as Mt from "./mt.mjs"; + +let suites = { + contents: /* [] */0 +}; + +let test_id = { + contents: 0 +}; + +function eq(loc, x, y) { + test_id.contents = test_id.contents + 1 | 0; + suites.contents = { + hd: [ + loc + (" id " + test_id.contents.toString()), + () => ({ + TAG: "Eq", + _0: x, + _1: y + }) + ], + tl: suites.contents + }; +} + +let u = 3; + +function nullary() { + return 3; +} + +function unary(a) { + return a + 3 | 0; +} + +let xx = 6; + +eq("File \"ppx_apply_test.res\", line 19, characters 12-19", u, 3); + +function h(a) { + return xx(a); +} + +Mt.from_pair_suites("Ppx_apply_test", suites.contents); + +export { + suites, + test_id, + eq, + u, + nullary, + unary, + xx, + h, +} +/* Not a pure module */ diff --git a/tests/tests/src/pq_test.js b/tests/tests/src/pq_test.js deleted file mode 100644 index 93c43a6400..0000000000 --- a/tests/tests/src/pq_test.js +++ /dev/null @@ -1,101 +0,0 @@ -// Generated by ReScript, PLEASE EDIT WITH CARE -'use strict'; - -let Primitive_exceptions = require("rescript/lib/js/Primitive_exceptions.js"); - -function insert(queue, prio, elt) { - if (typeof queue !== "object") { - return { - TAG: "Node", - _0: prio, - _1: elt, - _2: "Empty", - _3: "Empty" - }; - } - let right = queue._3; - let left = queue._2; - let e = queue._1; - let p = queue._0; - if (prio <= p) { - return { - TAG: "Node", - _0: prio, - _1: elt, - _2: insert(right, p, e), - _3: left - }; - } else { - return { - TAG: "Node", - _0: p, - _1: e, - _2: insert(right, prio, elt), - _3: left - }; - } -} - -let Queue_is_empty = /* @__PURE__ */Primitive_exceptions.create("Pq_test.PrioQueue.Queue_is_empty"); - -function remove_top(x) { - if (typeof x !== "object") { - throw { - RE_EXN_ID: Queue_is_empty, - Error: new Error() - }; - } - let left = x._2; - let tmp = x._3; - if (typeof tmp !== "object") { - return left; - } - if (typeof left !== "object") { - return x._3; - } - let right = x._3; - let rprio = right._0; - let lprio = left._0; - if (lprio <= rprio) { - return { - TAG: "Node", - _0: lprio, - _1: left._1, - _2: remove_top(left), - _3: right - }; - } else { - return { - TAG: "Node", - _0: rprio, - _1: right._1, - _2: left, - _3: remove_top(right) - }; - } -} - -function extract(x) { - if (typeof x === "object") { - return [ - x._0, - x._1, - remove_top(x) - ]; - } - throw { - RE_EXN_ID: Queue_is_empty, - Error: new Error() - }; -} - -let PrioQueue = { - empty: "Empty", - insert: insert, - Queue_is_empty: Queue_is_empty, - remove_top: remove_top, - extract: extract -}; - -exports.PrioQueue = PrioQueue; -/* No side effect */ diff --git a/tests/tests/src/pq_test.mjs b/tests/tests/src/pq_test.mjs new file mode 100644 index 0000000000..82f6e9bbbd --- /dev/null +++ b/tests/tests/src/pq_test.mjs @@ -0,0 +1,102 @@ +// Generated by ReScript, PLEASE EDIT WITH CARE + +import * as Primitive_exceptions from "rescript/lib/es6/Primitive_exceptions.js"; + +function insert(queue, prio, elt) { + if (typeof queue !== "object") { + return { + TAG: "Node", + _0: prio, + _1: elt, + _2: "Empty", + _3: "Empty" + }; + } + let right = queue._3; + let left = queue._2; + let e = queue._1; + let p = queue._0; + if (prio <= p) { + return { + TAG: "Node", + _0: prio, + _1: elt, + _2: insert(right, p, e), + _3: left + }; + } else { + return { + TAG: "Node", + _0: p, + _1: e, + _2: insert(right, prio, elt), + _3: left + }; + } +} + +let Queue_is_empty = /* @__PURE__ */Primitive_exceptions.create("Pq_test.PrioQueue.Queue_is_empty"); + +function remove_top(x) { + if (typeof x !== "object") { + throw { + RE_EXN_ID: Queue_is_empty, + Error: new Error() + }; + } + let left = x._2; + let tmp = x._3; + if (typeof tmp !== "object") { + return left; + } + if (typeof left !== "object") { + return x._3; + } + let right = x._3; + let rprio = right._0; + let lprio = left._0; + if (lprio <= rprio) { + return { + TAG: "Node", + _0: lprio, + _1: left._1, + _2: remove_top(left), + _3: right + }; + } else { + return { + TAG: "Node", + _0: rprio, + _1: right._1, + _2: left, + _3: remove_top(right) + }; + } +} + +function extract(x) { + if (typeof x === "object") { + return [ + x._0, + x._1, + remove_top(x) + ]; + } + throw { + RE_EXN_ID: Queue_is_empty, + Error: new Error() + }; +} + +let PrioQueue = { + empty: "Empty", + insert: insert, + Queue_is_empty: Queue_is_empty, + remove_top: remove_top, + extract: extract +}; + +export { + PrioQueue, +} +/* No side effect */ diff --git a/tests/tests/src/pr6726.js b/tests/tests/src/pr6726.js deleted file mode 100644 index ff6e484b7a..0000000000 --- a/tests/tests/src/pr6726.js +++ /dev/null @@ -1,35 +0,0 @@ -// Generated by ReScript, PLEASE EDIT WITH CARE -'use strict'; - - -function get_uint8(str, off) { - return 33; -} - -let BigEndian = { - get_uint8: get_uint8 -}; - -let ExtUnixAll = { - BigEndian: BigEndian -}; - -let ExtUnix = { - All: undefined -}; - -function test_endian_string(x) { - return 33; -} - -let v = test_endian_string(1); - -let Test = { - test_endian_string: test_endian_string, - v: v -}; - -exports.ExtUnixAll = ExtUnixAll; -exports.ExtUnix = ExtUnix; -exports.Test = Test; -/* v Not a pure module */ diff --git a/tests/tests/src/pr6726.mjs b/tests/tests/src/pr6726.mjs new file mode 100644 index 0000000000..9f149a2cb0 --- /dev/null +++ b/tests/tests/src/pr6726.mjs @@ -0,0 +1,36 @@ +// Generated by ReScript, PLEASE EDIT WITH CARE + + +function get_uint8(str, off) { + return 33; +} + +let BigEndian = { + get_uint8: get_uint8 +}; + +let ExtUnixAll = { + BigEndian: BigEndian +}; + +let ExtUnix = { + All: undefined +}; + +function test_endian_string(x) { + return 33; +} + +let v = test_endian_string(1); + +let Test = { + test_endian_string: test_endian_string, + v: v +}; + +export { + ExtUnixAll, + ExtUnix, + Test, +} +/* v Not a pure module */ diff --git a/tests/tests/src/prepend_data_ffi.js b/tests/tests/src/prepend_data_ffi.js deleted file mode 100644 index 4fcb1c6268..0000000000 --- a/tests/tests/src/prepend_data_ffi.js +++ /dev/null @@ -1,61 +0,0 @@ -// Generated by ReScript, PLEASE EDIT WITH CARE -'use strict'; - - -let v1 = { - stdio: "inherit", - v: 3 -}; - -let v2 = { - stdio: 1, - v: 2 -}; - -process.on("exit", exit_code => exit_code.toString()); - -process.on(1, param => {}); - -process.on(i => i.toString(), "exit"); - -process.on(i => i.toString(), 1); - -xx(3, 3, "xxx", "a", "b"); - -function f(x) { - x.xx(72, [ - 1, - 2, - 3 - ]); - x.xx(73, 3, "xxx", [ - 1, - 2, - 3 - ]); - x.xx(74, 3, "xxx", 1, 2, 3); - x.xx(75, 3, "xxx", 0, "b", 1, 2, 3, 4, 5); - x.xx(76, 3, true, false, "你好", ["你好",1,2,3] , [{ "arr" : ["你好",1,2,3], "encoding" : "utf8"}] , [{ "arr" : ["你好",1,2,3], "encoding" : "utf8"}] , "xxx", 0, "yyy", "b", 1, 2, 3, 4, 5); -} - -process.on("exit", exit_code => { - console.log("error code: %d", exit_code); -}); - -function register(p) { - p.on("exit", i => { - console.log(i); - }); -} - -let config = { - stdio: "inherit", - cwd: "." -}; - -exports.v1 = v1; -exports.v2 = v2; -exports.f = f; -exports.register = register; -exports.config = config; -/* Not a pure module */ diff --git a/tests/tests/src/prepend_data_ffi.mjs b/tests/tests/src/prepend_data_ffi.mjs new file mode 100644 index 0000000000..9ae19366a9 --- /dev/null +++ b/tests/tests/src/prepend_data_ffi.mjs @@ -0,0 +1,62 @@ +// Generated by ReScript, PLEASE EDIT WITH CARE + + +let v1 = { + stdio: "inherit", + v: 3 +}; + +let v2 = { + stdio: 1, + v: 2 +}; + +process.on("exit", exit_code => exit_code.toString()); + +process.on(1, param => {}); + +process.on(i => i.toString(), "exit"); + +process.on(i => i.toString(), 1); + +xx(3, 3, "xxx", "a", "b"); + +function f(x) { + x.xx(72, [ + 1, + 2, + 3 + ]); + x.xx(73, 3, "xxx", [ + 1, + 2, + 3 + ]); + x.xx(74, 3, "xxx", 1, 2, 3); + x.xx(75, 3, "xxx", 0, "b", 1, 2, 3, 4, 5); + x.xx(76, 3, true, false, "你好", ["你好",1,2,3] , [{ "arr" : ["你好",1,2,3], "encoding" : "utf8"}] , [{ "arr" : ["你好",1,2,3], "encoding" : "utf8"}] , "xxx", 0, "yyy", "b", 1, 2, 3, 4, 5); +} + +process.on("exit", exit_code => { + console.log("error code: %d", exit_code); +}); + +function register(p) { + p.on("exit", i => { + console.log(i); + }); +} + +let config = { + stdio: "inherit", + cwd: "." +}; + +export { + v1, + v2, + f, + register, + config, +} +/* Not a pure module */ diff --git a/tests/tests/src/print_alpha_test.js b/tests/tests/src/print_alpha_test.js deleted file mode 100644 index 36dc07f707..0000000000 --- a/tests/tests/src/print_alpha_test.js +++ /dev/null @@ -1,24 +0,0 @@ -// Generated by ReScript, PLEASE EDIT WITH CARE -'use strict'; - -let Mt = require("./mt.js"); - -function f(h, param) { - console.log(3); - return (x, y) => h(x, y); -} - -Mt.from_pair_suites("Print_alpha_test", { - hd: [ - "File \"print_alpha_test.res\", line 16, characters 10-17", - () => ({ - TAG: "Eq", - _0: f((prim0, prim1) => prim0 + prim1 | 0, undefined)(1, 2), - _1: 3 - }) - ], - tl: /* [] */0 -}); - -exports.f = f; -/* Not a pure module */ diff --git a/tests/tests/src/print_alpha_test.mjs b/tests/tests/src/print_alpha_test.mjs new file mode 100644 index 0000000000..e43ad54b00 --- /dev/null +++ b/tests/tests/src/print_alpha_test.mjs @@ -0,0 +1,25 @@ +// Generated by ReScript, PLEASE EDIT WITH CARE + +import * as Mt from "./mt.mjs"; + +function f(h, param) { + console.log(3); + return (x, y) => h(x, y); +} + +Mt.from_pair_suites("Print_alpha_test", { + hd: [ + "File \"print_alpha_test.res\", line 16, characters 10-17", + () => ({ + TAG: "Eq", + _0: f((prim0, prim1) => prim0 + prim1 | 0, undefined)(1, 2), + _1: 3 + }) + ], + tl: /* [] */0 +}); + +export { + f, +} +/* Not a pure module */ diff --git a/tests/tests/src/queue_402.js b/tests/tests/src/queue_402.js deleted file mode 100644 index 057d73c2f4..0000000000 --- a/tests/tests/src/queue_402.js +++ /dev/null @@ -1,190 +0,0 @@ -// Generated by ReScript, PLEASE EDIT WITH CARE -'use strict'; - -let Primitive_object = require("rescript/lib/js/Primitive_object.js"); -let Primitive_exceptions = require("rescript/lib/js/Primitive_exceptions.js"); - -let Empty = /* @__PURE__ */Primitive_exceptions.create("Queue_402.Empty"); - -function create() { - return { - length: 0, - tail: undefined - }; -} - -function clear(q) { - q.length = 0; - q.tail = undefined; -} - -function add(x, q) { - if (q.length === 0) { - let cell = {}; - cell.content = x; - cell.next = cell; - q.length = 1; - q.tail = cell; - return; - } - let tail = q.tail; - let head = tail.next; - let cell$1 = { - content: x, - next: head - }; - q.length = q.length + 1 | 0; - tail.next = cell$1; - q.tail = cell$1; -} - -function peek(q) { - if (q.length === 0) { - throw { - RE_EXN_ID: Empty, - Error: new Error() - }; - } - return q.tail.next.content; -} - -function take(q) { - if (q.length === 0) { - throw { - RE_EXN_ID: Empty, - Error: new Error() - }; - } - q.length = q.length - 1 | 0; - let tail = q.tail; - let head = tail.next; - if (head === tail) { - q.tail = undefined; - } else { - tail.next = head.next; - } - return head.content; -} - -function copy(q) { - if (q.length === 0) { - return { - length: 0, - tail: undefined - }; - } - let tail = q.tail; - let tail$p = {}; - Primitive_object.updateDummy(tail$p, { - content: tail.content, - next: tail$p - }); - let copy$1 = (_prev, _cell) => { - while (true) { - let cell = _cell; - let prev = _prev; - if (cell === tail) { - return; - } - let res = { - content: cell.content, - next: tail$p - }; - prev.next = res; - _cell = cell.next; - _prev = res; - continue; - }; - }; - copy$1(tail$p, tail.next); - return { - length: q.length, - tail: tail$p - }; -} - -function is_empty(q) { - return q.length === 0; -} - -function length(q) { - return q.length; -} - -function iter(f, q) { - if (q.length <= 0) { - return; - } - let tail = q.tail; - let _cell = tail.next; - while (true) { - let cell = _cell; - f(cell.content); - if (cell === tail) { - return; - } - _cell = cell.next; - continue; - }; -} - -function fold(f, accu, q) { - if (q.length === 0) { - return accu; - } - let tail = q.tail; - let _accu = accu; - let _cell = tail.next; - while (true) { - let cell = _cell; - let accu$1 = _accu; - let accu$2 = f(accu$1, cell.content); - if (cell === tail) { - return accu$2; - } - _cell = cell.next; - _accu = accu$2; - continue; - }; -} - -function transfer(q1, q2) { - let length1 = q1.length; - if (length1 <= 0) { - return; - } - let tail1 = q1.tail; - clear(q1); - if (q2.length > 0) { - let tail2 = q2.tail; - let head1 = tail1.next; - let head2 = tail2.next; - tail1.next = head2; - tail2.next = head1; - } - q2.length = q2.length + length1 | 0; - q2.tail = tail1; -} - -let push = add; - -let top = peek; - -let pop = take; - -exports.Empty = Empty; -exports.create = create; -exports.clear = clear; -exports.add = add; -exports.push = push; -exports.peek = peek; -exports.top = top; -exports.take = take; -exports.pop = pop; -exports.copy = copy; -exports.is_empty = is_empty; -exports.length = length; -exports.iter = iter; -exports.fold = fold; -exports.transfer = transfer; -/* No side effect */ diff --git a/tests/tests/src/queue_402.mjs b/tests/tests/src/queue_402.mjs new file mode 100644 index 0000000000..9c369f8526 --- /dev/null +++ b/tests/tests/src/queue_402.mjs @@ -0,0 +1,191 @@ +// Generated by ReScript, PLEASE EDIT WITH CARE + +import * as Primitive_object from "rescript/lib/es6/Primitive_object.js"; +import * as Primitive_exceptions from "rescript/lib/es6/Primitive_exceptions.js"; + +let Empty = /* @__PURE__ */Primitive_exceptions.create("Queue_402.Empty"); + +function create() { + return { + length: 0, + tail: undefined + }; +} + +function clear(q) { + q.length = 0; + q.tail = undefined; +} + +function add(x, q) { + if (q.length === 0) { + let cell = {}; + cell.content = x; + cell.next = cell; + q.length = 1; + q.tail = cell; + return; + } + let tail = q.tail; + let head = tail.next; + let cell$1 = { + content: x, + next: head + }; + q.length = q.length + 1 | 0; + tail.next = cell$1; + q.tail = cell$1; +} + +function peek(q) { + if (q.length === 0) { + throw { + RE_EXN_ID: Empty, + Error: new Error() + }; + } + return q.tail.next.content; +} + +function take(q) { + if (q.length === 0) { + throw { + RE_EXN_ID: Empty, + Error: new Error() + }; + } + q.length = q.length - 1 | 0; + let tail = q.tail; + let head = tail.next; + if (head === tail) { + q.tail = undefined; + } else { + tail.next = head.next; + } + return head.content; +} + +function copy(q) { + if (q.length === 0) { + return { + length: 0, + tail: undefined + }; + } + let tail = q.tail; + let tail$p = {}; + Primitive_object.updateDummy(tail$p, { + content: tail.content, + next: tail$p + }); + let copy$1 = (_prev, _cell) => { + while (true) { + let cell = _cell; + let prev = _prev; + if (cell === tail) { + return; + } + let res = { + content: cell.content, + next: tail$p + }; + prev.next = res; + _cell = cell.next; + _prev = res; + continue; + }; + }; + copy$1(tail$p, tail.next); + return { + length: q.length, + tail: tail$p + }; +} + +function is_empty(q) { + return q.length === 0; +} + +function length(q) { + return q.length; +} + +function iter(f, q) { + if (q.length <= 0) { + return; + } + let tail = q.tail; + let _cell = tail.next; + while (true) { + let cell = _cell; + f(cell.content); + if (cell === tail) { + return; + } + _cell = cell.next; + continue; + }; +} + +function fold(f, accu, q) { + if (q.length === 0) { + return accu; + } + let tail = q.tail; + let _accu = accu; + let _cell = tail.next; + while (true) { + let cell = _cell; + let accu$1 = _accu; + let accu$2 = f(accu$1, cell.content); + if (cell === tail) { + return accu$2; + } + _cell = cell.next; + _accu = accu$2; + continue; + }; +} + +function transfer(q1, q2) { + let length1 = q1.length; + if (length1 <= 0) { + return; + } + let tail1 = q1.tail; + clear(q1); + if (q2.length > 0) { + let tail2 = q2.tail; + let head1 = tail1.next; + let head2 = tail2.next; + tail1.next = head2; + tail2.next = head1; + } + q2.length = q2.length + length1 | 0; + q2.tail = tail1; +} + +let push = add; + +let top = peek; + +let pop = take; + +export { + Empty, + create, + clear, + add, + push, + peek, + top, + take, + pop, + copy, + is_empty, + length, + iter, + fold, + transfer, +} +/* No side effect */ diff --git a/tests/tests/src/raw_output_test.js b/tests/tests/src/raw_output_test.js deleted file mode 100644 index 156dcbbf3f..0000000000 --- a/tests/tests/src/raw_output_test.js +++ /dev/null @@ -1,14 +0,0 @@ -// Generated by ReScript, PLEASE EDIT WITH CARE -'use strict'; - - -function mk(fn) { - return fn(); -} - -(((_)=> console.log('should works'))()); - -console.log(1); - -exports.mk = mk; -/* Not a pure module */ diff --git a/tests/tests/src/raw_output_test.mjs b/tests/tests/src/raw_output_test.mjs new file mode 100644 index 0000000000..2ff4d352b1 --- /dev/null +++ b/tests/tests/src/raw_output_test.mjs @@ -0,0 +1,15 @@ +// Generated by ReScript, PLEASE EDIT WITH CARE + + +function mk(fn) { + return fn(); +} + +(((_)=> console.log('should works'))()); + +console.log(1); + +export { + mk, +} +/* Not a pure module */ diff --git a/tests/tests/src/raw_pure_test.js b/tests/tests/src/raw_pure_test.js deleted file mode 100644 index d033ef424c..0000000000 --- a/tests/tests/src/raw_pure_test.js +++ /dev/null @@ -1,33 +0,0 @@ -// Generated by ReScript, PLEASE EDIT WITH CARE -/** - * copyright -*/ -// hello -'use strict'; - -let Belt_List = require("rescript/lib/js/Belt_List.js"); - -let x0 = null; - -let x2 = "荷兰"; - -let x3 = /ghoghos/; - -/** - * copyright -*/ - -function f(x) { - //eslint-disable - /*hgosgh */ - return x; -} - -let hh = Belt_List.length; - -exports.x0 = x0; -exports.x2 = x2; -exports.x3 = x3; -exports.hh = hh; -exports.f = f; -/* No side effect */ diff --git a/tests/tests/src/raw_pure_test.mjs b/tests/tests/src/raw_pure_test.mjs new file mode 100644 index 0000000000..ddc349d419 --- /dev/null +++ b/tests/tests/src/raw_pure_test.mjs @@ -0,0 +1,34 @@ +// Generated by ReScript, PLEASE EDIT WITH CARE +/** + * copyright +*/ +// hello + +import * as Belt_List from "rescript/lib/es6/Belt_List.js"; + +let x0 = null; + +let x2 = "荷兰"; + +let x3 = /ghoghos/; + +/** + * copyright +*/ + +function f(x) { + //eslint-disable + /*hgosgh */ + return x; +} + +let hh = Belt_List.length; + +export { + x0, + x2, + x3, + hh, + f, +} +/* No side effect */ diff --git a/tests/tests/src/rbset.js b/tests/tests/src/rbset.js deleted file mode 100644 index ceb920a14c..0000000000 --- a/tests/tests/src/rbset.js +++ /dev/null @@ -1,756 +0,0 @@ -// Generated by ReScript, PLEASE EDIT WITH CARE -'use strict'; - - -function blackify(x) { - if (typeof x !== "object" || x._0 === "Black") { - return [ - x, - true - ]; - } else { - return [ - { - TAG: "Node", - _0: "Black", - _1: x._1, - _2: x._2, - _3: x._3 - }, - false - ]; - } -} - -function is_empty(x) { - if (typeof x !== "object") { - return true; - } else { - return false; - } -} - -function mem(x, _x_) { - while (true) { - let x_ = _x_; - if (typeof x_ !== "object") { - return false; - } - let y = x_._2; - if (x === y) { - return true; - } - if (x < y) { - _x_ = x_._1; - continue; - } - _x_ = x_._3; - continue; - }; -} - -function balance_left(l, x, r) { - let exit = 0; - let a; - let x$1; - let b; - let y; - let c; - let z; - let d; - if (typeof l !== "object" || l._0 === "Black") { - exit = 1; - } else { - let a$1 = l._1; - let exit$1 = 0; - if (typeof a$1 !== "object" || a$1._0 === "Black") { - exit$1 = 3; - } else { - a = a$1._1; - x$1 = a$1._2; - b = a$1._3; - y = l._2; - c = l._3; - z = x; - d = r; - exit = 2; - } - if (exit$1 === 3) { - let match = l._3; - if (typeof match !== "object" || match._0 === "Black") { - exit = 1; - } else { - a = a$1; - x$1 = l._2; - b = match._1; - y = match._2; - c = match._3; - z = x; - d = r; - exit = 2; - } - } - - } - switch (exit) { - case 1 : - return { - TAG: "Node", - _0: "Black", - _1: l, - _2: x, - _3: r - }; - case 2 : - return { - TAG: "Node", - _0: "Red", - _1: { - TAG: "Node", - _0: "Black", - _1: a, - _2: x$1, - _3: b - }, - _2: y, - _3: { - TAG: "Node", - _0: "Black", - _1: c, - _2: z, - _3: d - } - }; - } -} - -function balance_right(l, x, r) { - let exit = 0; - let a; - let x$1; - let b; - let y; - let c; - let z; - let d; - if (typeof r !== "object" || r._0 === "Black") { - exit = 1; - } else { - let b$1 = r._1; - let exit$1 = 0; - if (typeof b$1 !== "object" || b$1._0 === "Black") { - exit$1 = 3; - } else { - a = l; - x$1 = x; - b = b$1._1; - y = b$1._2; - c = b$1._3; - z = r._2; - d = r._3; - exit = 2; - } - if (exit$1 === 3) { - let match = r._3; - if (typeof match !== "object" || match._0 === "Black") { - exit = 1; - } else { - a = l; - x$1 = x; - b = b$1; - y = r._2; - c = match._1; - z = match._2; - d = match._3; - exit = 2; - } - } - - } - switch (exit) { - case 1 : - return { - TAG: "Node", - _0: "Black", - _1: l, - _2: x, - _3: r - }; - case 2 : - return { - TAG: "Node", - _0: "Red", - _1: { - TAG: "Node", - _0: "Black", - _1: a, - _2: x$1, - _3: b - }, - _2: y, - _3: { - TAG: "Node", - _0: "Black", - _1: c, - _2: z, - _3: d - } - }; - } -} - -function singleton(x) { - return { - TAG: "Node", - _0: "Black", - _1: "Empty", - _2: x, - _3: "Empty" - }; -} - -function unbalanced_left(x) { - if (typeof x === "object") { - if (x._0 === "Black") { - let match = x._1; - if (typeof match === "object") { - if (match._0 === "Black") { - return [ - balance_left({ - TAG: "Node", - _0: "Red", - _1: match._1, - _2: match._2, - _3: match._3 - }, x._2, x._3), - true - ]; - } - let match$1 = match._3; - if (typeof match$1 === "object" && match$1._0 === "Black") { - return [ - { - TAG: "Node", - _0: "Black", - _1: match._1, - _2: match._2, - _3: balance_left({ - TAG: "Node", - _0: "Red", - _1: match$1._1, - _2: match$1._2, - _3: match$1._3 - }, x._2, x._3) - }, - false - ]; - } - - } - - } else { - let match$2 = x._1; - if (typeof match$2 === "object" && match$2._0 === "Black") { - return [ - balance_left({ - TAG: "Node", - _0: "Red", - _1: match$2._1, - _2: match$2._2, - _3: match$2._3 - }, x._2, x._3), - false - ]; - } - - } - } - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "rbset.res", - 64, - 9 - ], - Error: new Error() - }; -} - -function unbalanced_right(x) { - if (typeof x === "object") { - if (x._0 === "Black") { - let match = x._3; - let x$1 = x._2; - let a = x._1; - if (typeof match === "object") { - if (match._0 === "Black") { - return [ - balance_right(a, x$1, { - TAG: "Node", - _0: "Red", - _1: match._1, - _2: match._2, - _3: match._3 - }), - true - ]; - } - let match$1 = match._1; - if (typeof match$1 === "object" && match$1._0 === "Black") { - return [ - { - TAG: "Node", - _0: "Black", - _1: balance_right(a, x$1, { - TAG: "Node", - _0: "Red", - _1: match$1._1, - _2: match$1._2, - _3: match$1._3 - }), - _2: match._2, - _3: match._3 - }, - false - ]; - } - - } - - } else { - let match$2 = x._3; - if (typeof match$2 === "object" && match$2._0 === "Black") { - return [ - balance_right(x._1, x._2, { - TAG: "Node", - _0: "Red", - _1: match$2._1, - _2: match$2._2, - _3: match$2._3 - }), - false - ]; - } - - } - } - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "rbset.res", - 75, - 9 - ], - Error: new Error() - }; -} - -function lbalance(x1, x2, x3) { - if (typeof x1 !== "object") { - return { - TAG: "Node", - _0: "Black", - _1: x1, - _2: x2, - _3: x3 - }; - } - if (x1._0 === "Black") { - return { - TAG: "Node", - _0: "Black", - _1: x1, - _2: x2, - _3: x3 - }; - } - let r = x1._3; - let l = x1._1; - if (typeof l === "object" && l._0 !== "Black") { - return { - TAG: "Node", - _0: "Red", - _1: { - TAG: "Node", - _0: "Black", - _1: l._1, - _2: l._2, - _3: l._3 - }, - _2: x1._2, - _3: { - TAG: "Node", - _0: "Black", - _1: r, - _2: x2, - _3: x3 - } - }; - } - if (typeof r !== "object") { - return { - TAG: "Node", - _0: "Black", - _1: x1, - _2: x2, - _3: x3 - }; - } - if (r._0 === "Black") { - return { - TAG: "Node", - _0: "Black", - _1: x1, - _2: x2, - _3: x3 - }; - } - let y = r._2; - return { - TAG: "Node", - _0: "Red", - _1: { - TAG: "Node", - _0: "Black", - _1: l, - _2: y, - _3: r._1 - }, - _2: y, - _3: { - TAG: "Node", - _0: "Black", - _1: r._3, - _2: x2, - _3: x3 - } - }; -} - -function rbalance(x1, x2, x3) { - if (typeof x3 === "object" && x3._0 !== "Black") { - let b = x3._1; - let exit = 0; - if (typeof b !== "object") { - exit = 2; - } else { - if (b._0 !== "Black") { - return { - TAG: "Node", - _0: "Red", - _1: { - TAG: "Node", - _0: "Black", - _1: x1, - _2: x2, - _3: b._1 - }, - _2: b._2, - _3: { - TAG: "Node", - _0: "Black", - _1: b._3, - _2: x3._2, - _3: x3._3 - } - }; - } - exit = 2; - } - if (exit === 2) { - let match = x3._3; - if (typeof match === "object" && match._0 !== "Black") { - return { - TAG: "Node", - _0: "Red", - _1: { - TAG: "Node", - _0: "Black", - _1: x1, - _2: x2, - _3: b - }, - _2: x3._2, - _3: { - TAG: "Node", - _0: "Black", - _1: match._1, - _2: match._2, - _3: match._3 - } - }; - } - - } - - } - return { - TAG: "Node", - _0: "Black", - _1: x1, - _2: x2, - _3: x3 - }; -} - -function ins(x, x_) { - if (typeof x_ !== "object") { - return { - TAG: "Node", - _0: "Red", - _1: "Empty", - _2: x, - _3: "Empty" - }; - } - if (x_._0 === "Black") { - let y = x_._2; - if (x === y) { - return x_; - } - let b = x_._3; - let a = x_._1; - if (x < y) { - return lbalance(ins(x, a), y, b); - } else { - return rbalance(a, y, ins(x, b)); - } - } - let y$1 = x_._2; - if (x === y$1) { - return x_; - } - let b$1 = x_._3; - let a$1 = x_._1; - if (x < y$1) { - return { - TAG: "Node", - _0: "Red", - _1: ins(x, a$1), - _2: y$1, - _3: b$1 - }; - } else { - return { - TAG: "Node", - _0: "Red", - _1: a$1, - _2: y$1, - _3: ins(x, b$1) - }; - } -} - -function add(x, s) { - let s$1 = ins(x, s); - if (typeof s$1 !== "object" || s$1._0 === "Black") { - return s$1; - } else { - return { - TAG: "Node", - _0: "Black", - _1: s$1._1, - _2: s$1._2, - _3: s$1._3 - }; - } -} - -function remove_min(x) { - if (typeof x !== "object") { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "rbset.res", - 138, - 4 - ], - Error: new Error() - }; - } - let c = x._0; - if (c === "Black") { - let tmp = x._1; - if (typeof tmp !== "object") { - let match = x._3; - let x$1 = x._2; - if (typeof match !== "object") { - return [ - "Empty", - x$1, - true - ]; - } - if (match._0 !== "Black") { - return [ - { - TAG: "Node", - _0: "Black", - _1: match._1, - _2: match._2, - _3: match._3 - }, - x$1, - false - ]; - } - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "rbset.res", - 138, - 4 - ], - Error: new Error() - }; - } - - } else { - let tmp$1 = x._1; - if (typeof tmp$1 !== "object") { - return [ - x._3, - x._2, - false - ]; - } - - } - let match$1 = remove_min(x._1); - let y = match$1[1]; - let s_1 = match$1[0]; - let s_2 = x._2; - let s_3 = x._3; - let s = { - TAG: "Node", - _0: c, - _1: s_1, - _2: s_2, - _3: s_3 - }; - if (!match$1[2]) { - return [ - s, - y, - false - ]; - } - let match$2 = unbalanced_right(s); - return [ - match$2[0], - y, - match$2[1] - ]; -} - -function remove_aux(x, n) { - if (typeof n !== "object") { - return [ - "Empty", - false - ]; - } - let r = n._3; - let y = n._2; - let l = n._1; - let c = n._0; - if (x === y) { - if (typeof r !== "object") { - if (c === "Red") { - return [ - l, - false - ]; - } else { - return blackify(l); - } - } - let match = remove_min(r); - let n_2 = match[1]; - let n_3 = match[0]; - let n$1 = { - TAG: "Node", - _0: c, - _1: l, - _2: n_2, - _3: n_3 - }; - if (match[2]) { - return unbalanced_left(n$1); - } else { - return [ - n$1, - false - ]; - } - } - if (x < y) { - let match$1 = remove_aux(x, l); - let n_1 = match$1[0]; - let n$2 = { - TAG: "Node", - _0: c, - _1: n_1, - _2: y, - _3: r - }; - if (match$1[1]) { - return unbalanced_right(n$2); - } else { - return [ - n$2, - false - ]; - } - } - let match$2 = remove_aux(x, r); - let n_3$1 = match$2[0]; - let n$3 = { - TAG: "Node", - _0: c, - _1: l, - _2: y, - _3: n_3$1 - }; - if (match$2[1]) { - return unbalanced_left(n$3); - } else { - return [ - n$3, - false - ]; - } -} - -function remove(x, s) { - return remove_aux(x, s)[0]; -} - -function cardinal(x) { - if (typeof x !== "object") { - return 0; - } else { - return (1 + cardinal(x._1) | 0) + cardinal(x._3) | 0; - } -} - -let empty = "Empty"; - -exports.blackify = blackify; -exports.empty = empty; -exports.is_empty = is_empty; -exports.mem = mem; -exports.balance_left = balance_left; -exports.balance_right = balance_right; -exports.singleton = singleton; -exports.unbalanced_left = unbalanced_left; -exports.unbalanced_right = unbalanced_right; -exports.lbalance = lbalance; -exports.rbalance = rbalance; -exports.ins = ins; -exports.add = add; -exports.remove_min = remove_min; -exports.remove_aux = remove_aux; -exports.remove = remove; -exports.cardinal = cardinal; -/* No side effect */ diff --git a/tests/tests/src/rbset.mjs b/tests/tests/src/rbset.mjs new file mode 100644 index 0000000000..37a65f5e37 --- /dev/null +++ b/tests/tests/src/rbset.mjs @@ -0,0 +1,757 @@ +// Generated by ReScript, PLEASE EDIT WITH CARE + + +function blackify(x) { + if (typeof x !== "object" || x._0 === "Black") { + return [ + x, + true + ]; + } else { + return [ + { + TAG: "Node", + _0: "Black", + _1: x._1, + _2: x._2, + _3: x._3 + }, + false + ]; + } +} + +function is_empty(x) { + if (typeof x !== "object") { + return true; + } else { + return false; + } +} + +function mem(x, _x_) { + while (true) { + let x_ = _x_; + if (typeof x_ !== "object") { + return false; + } + let y = x_._2; + if (x === y) { + return true; + } + if (x < y) { + _x_ = x_._1; + continue; + } + _x_ = x_._3; + continue; + }; +} + +function balance_left(l, x, r) { + let exit = 0; + let a; + let x$1; + let b; + let y; + let c; + let z; + let d; + if (typeof l !== "object" || l._0 === "Black") { + exit = 1; + } else { + let a$1 = l._1; + let exit$1 = 0; + if (typeof a$1 !== "object" || a$1._0 === "Black") { + exit$1 = 3; + } else { + a = a$1._1; + x$1 = a$1._2; + b = a$1._3; + y = l._2; + c = l._3; + z = x; + d = r; + exit = 2; + } + if (exit$1 === 3) { + let match = l._3; + if (typeof match !== "object" || match._0 === "Black") { + exit = 1; + } else { + a = a$1; + x$1 = l._2; + b = match._1; + y = match._2; + c = match._3; + z = x; + d = r; + exit = 2; + } + } + + } + switch (exit) { + case 1 : + return { + TAG: "Node", + _0: "Black", + _1: l, + _2: x, + _3: r + }; + case 2 : + return { + TAG: "Node", + _0: "Red", + _1: { + TAG: "Node", + _0: "Black", + _1: a, + _2: x$1, + _3: b + }, + _2: y, + _3: { + TAG: "Node", + _0: "Black", + _1: c, + _2: z, + _3: d + } + }; + } +} + +function balance_right(l, x, r) { + let exit = 0; + let a; + let x$1; + let b; + let y; + let c; + let z; + let d; + if (typeof r !== "object" || r._0 === "Black") { + exit = 1; + } else { + let b$1 = r._1; + let exit$1 = 0; + if (typeof b$1 !== "object" || b$1._0 === "Black") { + exit$1 = 3; + } else { + a = l; + x$1 = x; + b = b$1._1; + y = b$1._2; + c = b$1._3; + z = r._2; + d = r._3; + exit = 2; + } + if (exit$1 === 3) { + let match = r._3; + if (typeof match !== "object" || match._0 === "Black") { + exit = 1; + } else { + a = l; + x$1 = x; + b = b$1; + y = r._2; + c = match._1; + z = match._2; + d = match._3; + exit = 2; + } + } + + } + switch (exit) { + case 1 : + return { + TAG: "Node", + _0: "Black", + _1: l, + _2: x, + _3: r + }; + case 2 : + return { + TAG: "Node", + _0: "Red", + _1: { + TAG: "Node", + _0: "Black", + _1: a, + _2: x$1, + _3: b + }, + _2: y, + _3: { + TAG: "Node", + _0: "Black", + _1: c, + _2: z, + _3: d + } + }; + } +} + +function singleton(x) { + return { + TAG: "Node", + _0: "Black", + _1: "Empty", + _2: x, + _3: "Empty" + }; +} + +function unbalanced_left(x) { + if (typeof x === "object") { + if (x._0 === "Black") { + let match = x._1; + if (typeof match === "object") { + if (match._0 === "Black") { + return [ + balance_left({ + TAG: "Node", + _0: "Red", + _1: match._1, + _2: match._2, + _3: match._3 + }, x._2, x._3), + true + ]; + } + let match$1 = match._3; + if (typeof match$1 === "object" && match$1._0 === "Black") { + return [ + { + TAG: "Node", + _0: "Black", + _1: match._1, + _2: match._2, + _3: balance_left({ + TAG: "Node", + _0: "Red", + _1: match$1._1, + _2: match$1._2, + _3: match$1._3 + }, x._2, x._3) + }, + false + ]; + } + + } + + } else { + let match$2 = x._1; + if (typeof match$2 === "object" && match$2._0 === "Black") { + return [ + balance_left({ + TAG: "Node", + _0: "Red", + _1: match$2._1, + _2: match$2._2, + _3: match$2._3 + }, x._2, x._3), + false + ]; + } + + } + } + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "rbset.res", + 64, + 9 + ], + Error: new Error() + }; +} + +function unbalanced_right(x) { + if (typeof x === "object") { + if (x._0 === "Black") { + let match = x._3; + let x$1 = x._2; + let a = x._1; + if (typeof match === "object") { + if (match._0 === "Black") { + return [ + balance_right(a, x$1, { + TAG: "Node", + _0: "Red", + _1: match._1, + _2: match._2, + _3: match._3 + }), + true + ]; + } + let match$1 = match._1; + if (typeof match$1 === "object" && match$1._0 === "Black") { + return [ + { + TAG: "Node", + _0: "Black", + _1: balance_right(a, x$1, { + TAG: "Node", + _0: "Red", + _1: match$1._1, + _2: match$1._2, + _3: match$1._3 + }), + _2: match._2, + _3: match._3 + }, + false + ]; + } + + } + + } else { + let match$2 = x._3; + if (typeof match$2 === "object" && match$2._0 === "Black") { + return [ + balance_right(x._1, x._2, { + TAG: "Node", + _0: "Red", + _1: match$2._1, + _2: match$2._2, + _3: match$2._3 + }), + false + ]; + } + + } + } + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "rbset.res", + 75, + 9 + ], + Error: new Error() + }; +} + +function lbalance(x1, x2, x3) { + if (typeof x1 !== "object") { + return { + TAG: "Node", + _0: "Black", + _1: x1, + _2: x2, + _3: x3 + }; + } + if (x1._0 === "Black") { + return { + TAG: "Node", + _0: "Black", + _1: x1, + _2: x2, + _3: x3 + }; + } + let r = x1._3; + let l = x1._1; + if (typeof l === "object" && l._0 !== "Black") { + return { + TAG: "Node", + _0: "Red", + _1: { + TAG: "Node", + _0: "Black", + _1: l._1, + _2: l._2, + _3: l._3 + }, + _2: x1._2, + _3: { + TAG: "Node", + _0: "Black", + _1: r, + _2: x2, + _3: x3 + } + }; + } + if (typeof r !== "object") { + return { + TAG: "Node", + _0: "Black", + _1: x1, + _2: x2, + _3: x3 + }; + } + if (r._0 === "Black") { + return { + TAG: "Node", + _0: "Black", + _1: x1, + _2: x2, + _3: x3 + }; + } + let y = r._2; + return { + TAG: "Node", + _0: "Red", + _1: { + TAG: "Node", + _0: "Black", + _1: l, + _2: y, + _3: r._1 + }, + _2: y, + _3: { + TAG: "Node", + _0: "Black", + _1: r._3, + _2: x2, + _3: x3 + } + }; +} + +function rbalance(x1, x2, x3) { + if (typeof x3 === "object" && x3._0 !== "Black") { + let b = x3._1; + let exit = 0; + if (typeof b !== "object") { + exit = 2; + } else { + if (b._0 !== "Black") { + return { + TAG: "Node", + _0: "Red", + _1: { + TAG: "Node", + _0: "Black", + _1: x1, + _2: x2, + _3: b._1 + }, + _2: b._2, + _3: { + TAG: "Node", + _0: "Black", + _1: b._3, + _2: x3._2, + _3: x3._3 + } + }; + } + exit = 2; + } + if (exit === 2) { + let match = x3._3; + if (typeof match === "object" && match._0 !== "Black") { + return { + TAG: "Node", + _0: "Red", + _1: { + TAG: "Node", + _0: "Black", + _1: x1, + _2: x2, + _3: b + }, + _2: x3._2, + _3: { + TAG: "Node", + _0: "Black", + _1: match._1, + _2: match._2, + _3: match._3 + } + }; + } + + } + + } + return { + TAG: "Node", + _0: "Black", + _1: x1, + _2: x2, + _3: x3 + }; +} + +function ins(x, x_) { + if (typeof x_ !== "object") { + return { + TAG: "Node", + _0: "Red", + _1: "Empty", + _2: x, + _3: "Empty" + }; + } + if (x_._0 === "Black") { + let y = x_._2; + if (x === y) { + return x_; + } + let b = x_._3; + let a = x_._1; + if (x < y) { + return lbalance(ins(x, a), y, b); + } else { + return rbalance(a, y, ins(x, b)); + } + } + let y$1 = x_._2; + if (x === y$1) { + return x_; + } + let b$1 = x_._3; + let a$1 = x_._1; + if (x < y$1) { + return { + TAG: "Node", + _0: "Red", + _1: ins(x, a$1), + _2: y$1, + _3: b$1 + }; + } else { + return { + TAG: "Node", + _0: "Red", + _1: a$1, + _2: y$1, + _3: ins(x, b$1) + }; + } +} + +function add(x, s) { + let s$1 = ins(x, s); + if (typeof s$1 !== "object" || s$1._0 === "Black") { + return s$1; + } else { + return { + TAG: "Node", + _0: "Black", + _1: s$1._1, + _2: s$1._2, + _3: s$1._3 + }; + } +} + +function remove_min(x) { + if (typeof x !== "object") { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "rbset.res", + 138, + 4 + ], + Error: new Error() + }; + } + let c = x._0; + if (c === "Black") { + let tmp = x._1; + if (typeof tmp !== "object") { + let match = x._3; + let x$1 = x._2; + if (typeof match !== "object") { + return [ + "Empty", + x$1, + true + ]; + } + if (match._0 !== "Black") { + return [ + { + TAG: "Node", + _0: "Black", + _1: match._1, + _2: match._2, + _3: match._3 + }, + x$1, + false + ]; + } + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "rbset.res", + 138, + 4 + ], + Error: new Error() + }; + } + + } else { + let tmp$1 = x._1; + if (typeof tmp$1 !== "object") { + return [ + x._3, + x._2, + false + ]; + } + + } + let match$1 = remove_min(x._1); + let y = match$1[1]; + let s_1 = match$1[0]; + let s_2 = x._2; + let s_3 = x._3; + let s = { + TAG: "Node", + _0: c, + _1: s_1, + _2: s_2, + _3: s_3 + }; + if (!match$1[2]) { + return [ + s, + y, + false + ]; + } + let match$2 = unbalanced_right(s); + return [ + match$2[0], + y, + match$2[1] + ]; +} + +function remove_aux(x, n) { + if (typeof n !== "object") { + return [ + "Empty", + false + ]; + } + let r = n._3; + let y = n._2; + let l = n._1; + let c = n._0; + if (x === y) { + if (typeof r !== "object") { + if (c === "Red") { + return [ + l, + false + ]; + } else { + return blackify(l); + } + } + let match = remove_min(r); + let n_2 = match[1]; + let n_3 = match[0]; + let n$1 = { + TAG: "Node", + _0: c, + _1: l, + _2: n_2, + _3: n_3 + }; + if (match[2]) { + return unbalanced_left(n$1); + } else { + return [ + n$1, + false + ]; + } + } + if (x < y) { + let match$1 = remove_aux(x, l); + let n_1 = match$1[0]; + let n$2 = { + TAG: "Node", + _0: c, + _1: n_1, + _2: y, + _3: r + }; + if (match$1[1]) { + return unbalanced_right(n$2); + } else { + return [ + n$2, + false + ]; + } + } + let match$2 = remove_aux(x, r); + let n_3$1 = match$2[0]; + let n$3 = { + TAG: "Node", + _0: c, + _1: l, + _2: y, + _3: n_3$1 + }; + if (match$2[1]) { + return unbalanced_left(n$3); + } else { + return [ + n$3, + false + ]; + } +} + +function remove(x, s) { + return remove_aux(x, s)[0]; +} + +function cardinal(x) { + if (typeof x !== "object") { + return 0; + } else { + return (1 + cardinal(x._1) | 0) + cardinal(x._3) | 0; + } +} + +let empty = "Empty"; + +export { + blackify, + empty, + is_empty, + mem, + balance_left, + balance_right, + singleton, + unbalanced_left, + unbalanced_right, + lbalance, + rbalance, + ins, + add, + remove_min, + remove_aux, + remove, + cardinal, +} +/* No side effect */ diff --git a/tests/tests/src/react.js b/tests/tests/src/react.js deleted file mode 100644 index 05c8865770..0000000000 --- a/tests/tests/src/react.js +++ /dev/null @@ -1,20 +0,0 @@ -// Generated by ReScript, PLEASE EDIT WITH CARE -'use strict'; - - -let Ref = {}; - -let Children = {}; - -let Context = {}; - -let Fragment = {}; - -let Suspense = {}; - -exports.Ref = Ref; -exports.Children = Children; -exports.Context = Context; -exports.Fragment = Fragment; -exports.Suspense = Suspense; -/* No side effect */ diff --git a/tests/tests/src/react.mjs b/tests/tests/src/react.mjs new file mode 100644 index 0000000000..fb408bebf1 --- /dev/null +++ b/tests/tests/src/react.mjs @@ -0,0 +1,21 @@ +// Generated by ReScript, PLEASE EDIT WITH CARE + + +let Ref = {}; + +let Children = {}; + +let Context = {}; + +let Fragment = {}; + +let Suspense = {}; + +export { + Ref, + Children, + Context, + Fragment, + Suspense, +} +/* No side effect */ diff --git a/tests/tests/src/reactDOMRe.js b/tests/tests/src/reactDOMRe.js deleted file mode 100644 index e2d25b1772..0000000000 --- a/tests/tests/src/reactDOMRe.js +++ /dev/null @@ -1,110 +0,0 @@ -// Generated by ReScript, PLEASE EDIT WITH CARE -'use strict'; - -let React = require("react"); -let Js_array = require("rescript/lib/js/Js_array.js"); -let ReactDom = require("react-dom"); - -function renderToElementWithClassName(reactElement, className) { - let elements = document.getElementsByClassName(className); - if (elements.length !== 0) { - ReactDom.render(reactElement, elements[0]); - } else { - console.error("ReactDOMRe.renderToElementWithClassName: no element of class " + (className + " found in the HTML.")); - } -} - -function renderToElementWithId(reactElement, id) { - let element = document.getElementById(id); - if (element == null) { - console.error("ReactDOMRe.renderToElementWithId : no element of id " + (id + " found in the HTML.")); - } else { - ReactDom.render(reactElement, element); - } -} - -function createRootWithClassName(className) { - let elements = document.getElementsByClassName(className); - if (elements.length !== 0) { - return { - TAG: "Ok", - _0: ReactDom.createRoot(elements[0]) - }; - } else { - return { - TAG: "Error", - _0: "ReactDOMRe.Unstable.createRootWithClassName: no element of class " + (className + " found in the HTML.") - }; - } -} - -function createRootWithId(id) { - let element = document.getElementById(id); - if (element == null) { - return { - TAG: "Error", - _0: "ReactDOMRe.Unstable.createRootWithId: no element of id " + (id + " found in the HTML.") - }; - } else { - return { - TAG: "Ok", - _0: ReactDom.createRoot(element) - }; - } -} - -let Experimental = { - createRootWithClassName: createRootWithClassName, - createRootWithId: createRootWithId -}; - -function hydrateToElementWithClassName(reactElement, className) { - let elements = document.getElementsByClassName(className); - if (elements.length !== 0) { - ReactDom.hydrate(reactElement, elements[0]); - } else { - console.error("ReactDOMRe.hydrateToElementWithClassName: no element of class " + (className + " found in the HTML.")); - } -} - -function hydrateToElementWithId(reactElement, id) { - let element = document.getElementById(id); - if (element == null) { - throw { - RE_EXN_ID: "Invalid_argument", - _1: "ReactDOMRe.hydrateToElementWithId : no element of id " + (id + " found in the HTML."), - Error: new Error() - }; - } - ReactDom.hydrate(reactElement, element); -} - -let Ref = {}; - -function createElementVariadic(domClassName, props, children) { - let variadicArguments = Js_array.concat(children, [ - domClassName, - props - ]); - return React.createElement.apply(null, variadicArguments); -} - -function unsafeAddProp(style, key, value) { - let dict = {}; - dict[key] = value; - return Object.assign({}, style, dict); -} - -let Style = { - unsafeAddProp: unsafeAddProp -}; - -exports.renderToElementWithClassName = renderToElementWithClassName; -exports.renderToElementWithId = renderToElementWithId; -exports.Experimental = Experimental; -exports.hydrateToElementWithClassName = hydrateToElementWithClassName; -exports.hydrateToElementWithId = hydrateToElementWithId; -exports.Ref = Ref; -exports.createElementVariadic = createElementVariadic; -exports.Style = Style; -/* react Not a pure module */ diff --git a/tests/tests/src/reactDOMRe.mjs b/tests/tests/src/reactDOMRe.mjs new file mode 100644 index 0000000000..4a02d17a7b --- /dev/null +++ b/tests/tests/src/reactDOMRe.mjs @@ -0,0 +1,111 @@ +// Generated by ReScript, PLEASE EDIT WITH CARE + +import * as React from "react"; +import * as Js_array from "rescript/lib/es6/Js_array.js"; +import * as ReactDom from "react-dom"; + +function renderToElementWithClassName(reactElement, className) { + let elements = document.getElementsByClassName(className); + if (elements.length !== 0) { + ReactDom.render(reactElement, elements[0]); + } else { + console.error("ReactDOMRe.renderToElementWithClassName: no element of class " + (className + " found in the HTML.")); + } +} + +function renderToElementWithId(reactElement, id) { + let element = document.getElementById(id); + if (element == null) { + console.error("ReactDOMRe.renderToElementWithId : no element of id " + (id + " found in the HTML.")); + } else { + ReactDom.render(reactElement, element); + } +} + +function createRootWithClassName(className) { + let elements = document.getElementsByClassName(className); + if (elements.length !== 0) { + return { + TAG: "Ok", + _0: ReactDom.createRoot(elements[0]) + }; + } else { + return { + TAG: "Error", + _0: "ReactDOMRe.Unstable.createRootWithClassName: no element of class " + (className + " found in the HTML.") + }; + } +} + +function createRootWithId(id) { + let element = document.getElementById(id); + if (element == null) { + return { + TAG: "Error", + _0: "ReactDOMRe.Unstable.createRootWithId: no element of id " + (id + " found in the HTML.") + }; + } else { + return { + TAG: "Ok", + _0: ReactDom.createRoot(element) + }; + } +} + +let Experimental = { + createRootWithClassName: createRootWithClassName, + createRootWithId: createRootWithId +}; + +function hydrateToElementWithClassName(reactElement, className) { + let elements = document.getElementsByClassName(className); + if (elements.length !== 0) { + ReactDom.hydrate(reactElement, elements[0]); + } else { + console.error("ReactDOMRe.hydrateToElementWithClassName: no element of class " + (className + " found in the HTML.")); + } +} + +function hydrateToElementWithId(reactElement, id) { + let element = document.getElementById(id); + if (element == null) { + throw { + RE_EXN_ID: "Invalid_argument", + _1: "ReactDOMRe.hydrateToElementWithId : no element of id " + (id + " found in the HTML."), + Error: new Error() + }; + } + ReactDom.hydrate(reactElement, element); +} + +let Ref = {}; + +function createElementVariadic(domClassName, props, children) { + let variadicArguments = Js_array.concat(children, [ + domClassName, + props + ]); + return React.createElement.apply(null, variadicArguments); +} + +function unsafeAddProp(style, key, value) { + let dict = {}; + dict[key] = value; + return Object.assign({}, style, dict); +} + +let Style = { + unsafeAddProp: unsafeAddProp +}; + +export { + renderToElementWithClassName, + renderToElementWithId, + Experimental, + hydrateToElementWithClassName, + hydrateToElementWithId, + Ref, + createElementVariadic, + Style, +} +/* react Not a pure module */ diff --git a/tests/tests/src/reactDOMServerRe.js b/tests/tests/src/reactDOMServerRe.mjs similarity index 100% rename from tests/tests/src/reactDOMServerRe.js rename to tests/tests/src/reactDOMServerRe.mjs diff --git a/tests/tests/src/reactEvent.js b/tests/tests/src/reactEvent.js deleted file mode 100644 index ad6c3b1c3b..0000000000 --- a/tests/tests/src/reactEvent.js +++ /dev/null @@ -1,50 +0,0 @@ -// Generated by ReScript, PLEASE EDIT WITH CARE -'use strict'; - - -let Synthetic = {}; - -let Clipboard = {}; - -let Composition = {}; - -let Keyboard = {}; - -let Focus = {}; - -let Form = {}; - -let Mouse = {}; - -let Selection = {}; - -let Touch = {}; - -let UI = {}; - -let Wheel = {}; - -let Media = {}; - -let Image = {}; - -let Animation = {}; - -let Transition = {}; - -exports.Synthetic = Synthetic; -exports.Clipboard = Clipboard; -exports.Composition = Composition; -exports.Keyboard = Keyboard; -exports.Focus = Focus; -exports.Form = Form; -exports.Mouse = Mouse; -exports.Selection = Selection; -exports.Touch = Touch; -exports.UI = UI; -exports.Wheel = Wheel; -exports.Media = Media; -exports.Image = Image; -exports.Animation = Animation; -exports.Transition = Transition; -/* No side effect */ diff --git a/tests/tests/src/reactEvent.mjs b/tests/tests/src/reactEvent.mjs new file mode 100644 index 0000000000..093c936081 --- /dev/null +++ b/tests/tests/src/reactEvent.mjs @@ -0,0 +1,51 @@ +// Generated by ReScript, PLEASE EDIT WITH CARE + + +let Synthetic = {}; + +let Clipboard = {}; + +let Composition = {}; + +let Keyboard = {}; + +let Focus = {}; + +let Form = {}; + +let Mouse = {}; + +let Selection = {}; + +let Touch = {}; + +let UI = {}; + +let Wheel = {}; + +let Media = {}; + +let Image = {}; + +let Animation = {}; + +let Transition = {}; + +export { + Synthetic, + Clipboard, + Composition, + Keyboard, + Focus, + Form, + Mouse, + Selection, + Touch, + UI, + Wheel, + Media, + Image, + Animation, + Transition, +} +/* No side effect */ diff --git a/tests/tests/src/reactTestUtils.js b/tests/tests/src/reactTestUtils.js deleted file mode 100644 index 9ed8dc9cbb..0000000000 --- a/tests/tests/src/reactTestUtils.js +++ /dev/null @@ -1,90 +0,0 @@ -// Generated by ReScript, PLEASE EDIT WITH CARE -'use strict'; - -let Belt_Array = require("rescript/lib/js/Belt_Array.js"); -let Belt_Option = require("rescript/lib/js/Belt_Option.js"); -let Primitive_option = require("rescript/lib/js/Primitive_option.js"); -let TestUtils = require("react-dom/test-utils"); - -function act(func) { - let reactFunc = () => { - func(); - }; - TestUtils.act(reactFunc); -} - -function actAsync(func) { - return TestUtils.act(() => func()); -} - -function changeWithValue(element, value) { - let event = { - target: { - value: value - } - }; - TestUtils.Simulate.change(element, event); -} - -function changeWithChecked(element, value) { - let event = { - target: { - checked: value - } - }; - TestUtils.Simulate.change(element, event); -} - -let Simulate = { - changeWithValue: changeWithValue, - changeWithChecked: changeWithChecked -}; - -function findBySelector(element, selector) { - return element.querySelector(selector); -} - -function findByAllSelector(element, selector) { - return Array.from(element.querySelectorAll(selector)); -} - -function findBySelectorAndTextContent(element, selector, content) { - return Belt_Array.getBy(Array.from(element.querySelectorAll(selector)), node => node.textContent === content); -} - -function findBySelectorAndPartialTextContent(element, selector, content) { - return Belt_Array.getBy(Array.from(element.querySelectorAll(selector)), node => node.textContent.includes(content)); -} - -let DOM = { - findBySelector: findBySelector, - findByAllSelector: findByAllSelector, - findBySelectorAndTextContent: findBySelectorAndTextContent, - findBySelectorAndPartialTextContent: findBySelectorAndPartialTextContent -}; - -function prepareContainer(container, param) { - let containerElement = document.createElement("div"); - Belt_Option.map(document.body, body => body.appendChild(containerElement)); - container.contents = Primitive_option.some(containerElement); -} - -function cleanupContainer(container, param) { - Belt_Option.map(container.contents, prim => { - prim.remove(); - }); - container.contents = undefined; -} - -function getContainer(container) { - return Belt_Option.getExn(container.contents); -} - -exports.act = act; -exports.actAsync = actAsync; -exports.Simulate = Simulate; -exports.DOM = DOM; -exports.prepareContainer = prepareContainer; -exports.cleanupContainer = cleanupContainer; -exports.getContainer = getContainer; -/* react-dom/test-utils Not a pure module */ diff --git a/tests/tests/src/reactTestUtils.mjs b/tests/tests/src/reactTestUtils.mjs new file mode 100644 index 0000000000..33c59321af --- /dev/null +++ b/tests/tests/src/reactTestUtils.mjs @@ -0,0 +1,91 @@ +// Generated by ReScript, PLEASE EDIT WITH CARE + +import * as Belt_Array from "rescript/lib/es6/Belt_Array.js"; +import * as Belt_Option from "rescript/lib/es6/Belt_Option.js"; +import * as Primitive_option from "rescript/lib/es6/Primitive_option.js"; +import * as TestUtils from "react-dom/test-utils"; + +function act(func) { + let reactFunc = () => { + func(); + }; + TestUtils.act(reactFunc); +} + +function actAsync(func) { + return TestUtils.act(() => func()); +} + +function changeWithValue(element, value) { + let event = { + target: { + value: value + } + }; + TestUtils.Simulate.change(element, event); +} + +function changeWithChecked(element, value) { + let event = { + target: { + checked: value + } + }; + TestUtils.Simulate.change(element, event); +} + +let Simulate = { + changeWithValue: changeWithValue, + changeWithChecked: changeWithChecked +}; + +function findBySelector(element, selector) { + return element.querySelector(selector); +} + +function findByAllSelector(element, selector) { + return Array.from(element.querySelectorAll(selector)); +} + +function findBySelectorAndTextContent(element, selector, content) { + return Belt_Array.getBy(Array.from(element.querySelectorAll(selector)), node => node.textContent === content); +} + +function findBySelectorAndPartialTextContent(element, selector, content) { + return Belt_Array.getBy(Array.from(element.querySelectorAll(selector)), node => node.textContent.includes(content)); +} + +let DOM = { + findBySelector: findBySelector, + findByAllSelector: findByAllSelector, + findBySelectorAndTextContent: findBySelectorAndTextContent, + findBySelectorAndPartialTextContent: findBySelectorAndPartialTextContent +}; + +function prepareContainer(container, param) { + let containerElement = document.createElement("div"); + Belt_Option.map(document.body, body => body.appendChild(containerElement)); + container.contents = Primitive_option.some(containerElement); +} + +function cleanupContainer(container, param) { + Belt_Option.map(container.contents, prim => { + prim.remove(); + }); + container.contents = undefined; +} + +function getContainer(container) { + return Belt_Option.getExn(container.contents); +} + +export { + act, + actAsync, + Simulate, + DOM, + prepareContainer, + cleanupContainer, + getContainer, +} +/* react-dom/test-utils Not a pure module */ diff --git a/tests/tests/src/reasonReact.js b/tests/tests/src/reasonReact.js deleted file mode 100644 index 572883ebf9..0000000000 --- a/tests/tests/src/reasonReact.js +++ /dev/null @@ -1,136 +0,0 @@ -// Generated by ReScript, PLEASE EDIT WITH CARE -'use strict'; - -let React = require("react"); -let Js_array = require("rescript/lib/js/Js_array.js"); - -function createDomElement(s, props, children) { - let vararg = Js_array.concat(children, [ - s, - props - ]); - return React.createElement.apply(null, vararg); -} - -function anyToUnit(param) { - -} - -function anyToTrue(param) { - return true; -} - -function willReceivePropsDefault(param) { - return param.state; -} - -function renderDefault(_self) { - return "RenderNotImplemented"; -} - -function initialStateDefault() { - -} - -function reducerDefault(_action, _state) { - return "NoUpdate"; -} - -function basicComponent(debugName) { - return { - debugName: debugName, - reactClassInternal: debugName, - handedOffState: { - contents: undefined - }, - willReceiveProps: willReceivePropsDefault, - didMount: anyToUnit, - didUpdate: anyToUnit, - willUnmount: anyToUnit, - willUpdate: anyToUnit, - shouldUpdate: anyToTrue, - render: renderDefault, - initialState: initialStateDefault, - retainedProps: undefined, - reducer: reducerDefault, - jsElementWrapped: undefined - }; -} - -let statelessComponent = basicComponent; - -let statelessComponentWithRetainedProps = basicComponent; - -let reducerComponent = basicComponent; - -let reducerComponentWithRetainedProps = basicComponent; - -function element(keyOpt, refOpt, component) { - let key = keyOpt !== undefined ? keyOpt : undefined; - let ref = refOpt !== undefined ? refOpt : undefined; - let element$1 = { - TAG: "Element", - _0: component - }; - let jsElementWrapped = component.jsElementWrapped; - if (jsElementWrapped !== undefined) { - return jsElementWrapped(key, ref); - } else { - return React.createElement(component.reactClassInternal, { - key: key, - ref: ref, - reasonProps: element$1 - }); - } -} - -function wrapReasonForJs(component, jsPropsToReason) { - let uncurriedJsPropsToReason = jsProps => jsPropsToReason(jsProps); - component.reactClassInternal.prototype.jsPropsToReason = uncurriedJsPropsToReason; - return component.reactClassInternal; -} - -let dummyInteropComponent = basicComponent("interop"); - -function wrapJsForReason(reactClass, props, children) { - let jsElementWrapped = (extra, extra$1) => { - let props$1 = Object.assign(Object.assign({}, props), { - ref: extra$1, - key: extra - }); - let varargs = Js_array.concat(children, [ - reactClass, - props$1 - ]); - return React.createElement.apply(null, varargs); - }; - return { - debugName: dummyInteropComponent.debugName, - reactClassInternal: dummyInteropComponent.reactClassInternal, - handedOffState: dummyInteropComponent.handedOffState, - willReceiveProps: dummyInteropComponent.willReceiveProps, - didMount: dummyInteropComponent.didMount, - didUpdate: dummyInteropComponent.didUpdate, - willUnmount: dummyInteropComponent.willUnmount, - willUpdate: dummyInteropComponent.willUpdate, - shouldUpdate: dummyInteropComponent.shouldUpdate, - render: dummyInteropComponent.render, - initialState: dummyInteropComponent.initialState, - retainedProps: dummyInteropComponent.retainedProps, - reducer: dummyInteropComponent.reducer, - jsElementWrapped: jsElementWrapped - }; -} - -let Router; - -exports.statelessComponent = statelessComponent; -exports.statelessComponentWithRetainedProps = statelessComponentWithRetainedProps; -exports.reducerComponent = reducerComponent; -exports.reducerComponentWithRetainedProps = reducerComponentWithRetainedProps; -exports.element = element; -exports.wrapReasonForJs = wrapReasonForJs; -exports.createDomElement = createDomElement; -exports.wrapJsForReason = wrapJsForReason; -exports.Router = Router; -/* dummyInteropComponent Not a pure module */ diff --git a/tests/tests/src/reasonReact.mjs b/tests/tests/src/reasonReact.mjs new file mode 100644 index 0000000000..e1f8ab1ec5 --- /dev/null +++ b/tests/tests/src/reasonReact.mjs @@ -0,0 +1,137 @@ +// Generated by ReScript, PLEASE EDIT WITH CARE + +import * as React from "react"; +import * as Js_array from "rescript/lib/es6/Js_array.js"; + +function createDomElement(s, props, children) { + let vararg = Js_array.concat(children, [ + s, + props + ]); + return React.createElement.apply(null, vararg); +} + +function anyToUnit(param) { + +} + +function anyToTrue(param) { + return true; +} + +function willReceivePropsDefault(param) { + return param.state; +} + +function renderDefault(_self) { + return "RenderNotImplemented"; +} + +function initialStateDefault() { + +} + +function reducerDefault(_action, _state) { + return "NoUpdate"; +} + +function basicComponent(debugName) { + return { + debugName: debugName, + reactClassInternal: debugName, + handedOffState: { + contents: undefined + }, + willReceiveProps: willReceivePropsDefault, + didMount: anyToUnit, + didUpdate: anyToUnit, + willUnmount: anyToUnit, + willUpdate: anyToUnit, + shouldUpdate: anyToTrue, + render: renderDefault, + initialState: initialStateDefault, + retainedProps: undefined, + reducer: reducerDefault, + jsElementWrapped: undefined + }; +} + +let statelessComponent = basicComponent; + +let statelessComponentWithRetainedProps = basicComponent; + +let reducerComponent = basicComponent; + +let reducerComponentWithRetainedProps = basicComponent; + +function element(keyOpt, refOpt, component) { + let key = keyOpt !== undefined ? keyOpt : undefined; + let ref = refOpt !== undefined ? refOpt : undefined; + let element$1 = { + TAG: "Element", + _0: component + }; + let jsElementWrapped = component.jsElementWrapped; + if (jsElementWrapped !== undefined) { + return jsElementWrapped(key, ref); + } else { + return React.createElement(component.reactClassInternal, { + key: key, + ref: ref, + reasonProps: element$1 + }); + } +} + +function wrapReasonForJs(component, jsPropsToReason) { + let uncurriedJsPropsToReason = jsProps => jsPropsToReason(jsProps); + component.reactClassInternal.prototype.jsPropsToReason = uncurriedJsPropsToReason; + return component.reactClassInternal; +} + +let dummyInteropComponent = basicComponent("interop"); + +function wrapJsForReason(reactClass, props, children) { + let jsElementWrapped = (extra, extra$1) => { + let props$1 = Object.assign(Object.assign({}, props), { + ref: extra$1, + key: extra + }); + let varargs = Js_array.concat(children, [ + reactClass, + props$1 + ]); + return React.createElement.apply(null, varargs); + }; + return { + debugName: dummyInteropComponent.debugName, + reactClassInternal: dummyInteropComponent.reactClassInternal, + handedOffState: dummyInteropComponent.handedOffState, + willReceiveProps: dummyInteropComponent.willReceiveProps, + didMount: dummyInteropComponent.didMount, + didUpdate: dummyInteropComponent.didUpdate, + willUnmount: dummyInteropComponent.willUnmount, + willUpdate: dummyInteropComponent.willUpdate, + shouldUpdate: dummyInteropComponent.shouldUpdate, + render: dummyInteropComponent.render, + initialState: dummyInteropComponent.initialState, + retainedProps: dummyInteropComponent.retainedProps, + reducer: dummyInteropComponent.reducer, + jsElementWrapped: jsElementWrapped + }; +} + +let Router; + +export { + statelessComponent, + statelessComponentWithRetainedProps, + reducerComponent, + reducerComponentWithRetainedProps, + element, + wrapReasonForJs, + createDomElement, + wrapJsForReason, + Router, +} +/* dummyInteropComponent Not a pure module */ diff --git a/tests/tests/src/reasonReactCompat.js b/tests/tests/src/reasonReactCompat.js deleted file mode 100644 index 43f178a76d..0000000000 --- a/tests/tests/src/reasonReactCompat.js +++ /dev/null @@ -1,12 +0,0 @@ -// Generated by ReScript, PLEASE EDIT WITH CARE -'use strict'; - -let ReasonReact = require("./reasonReact.js"); - -let wrapReactForReasonReact = ReasonReact.wrapJsForReason; - -let wrapReasonReactForReact = ReasonReact.wrapReasonForJs; - -exports.wrapReactForReasonReact = wrapReactForReasonReact; -exports.wrapReasonReactForReact = wrapReasonReactForReact; -/* ReasonReact Not a pure module */ diff --git a/tests/tests/src/reasonReactCompat.mjs b/tests/tests/src/reasonReactCompat.mjs new file mode 100644 index 0000000000..0080545c14 --- /dev/null +++ b/tests/tests/src/reasonReactCompat.mjs @@ -0,0 +1,13 @@ +// Generated by ReScript, PLEASE EDIT WITH CARE + +import * as ReasonReact from "./reasonReact.mjs"; + +let wrapReactForReasonReact = ReasonReact.wrapJsForReason; + +let wrapReasonReactForReact = ReasonReact.wrapReasonForJs; + +export { + wrapReactForReasonReact, + wrapReasonReactForReact, +} +/* ReasonReact Not a pure module */ diff --git a/tests/tests/src/reasonReactOptimizedCreateClass.js b/tests/tests/src/reasonReactOptimizedCreateClass.js deleted file mode 100644 index 0502aed5a9..0000000000 --- a/tests/tests/src/reasonReactOptimizedCreateClass.js +++ /dev/null @@ -1,893 +0,0 @@ -// Generated by ReScript, PLEASE EDIT WITH CARE -'use strict'; - -let React = require("react"); - -function _assign(prim0, prim1) { - return Object.assign(prim0, prim1); -} - -let emptyObject = {}; - -/** - * Copyright 2013-present, Facebook, Inc. - * All rights reserved. - * - * This source code is licensed under the BSD-style license found in the - * LICENSE file in the root directory of this source tree. An additional grant - * of patent rights can be found in the PATENTS file in the same directory. - * - */ - -// 'use strict'; - -// var _assign = require('object-assign'); - -// var emptyObject = require('emptyObject'); -// var _invariant = require('invariant'); - -// if (process.env.NODE_ENV !== 'production') { -// var warning = require('fbjs/lib/warning'); -// } - -var MIXINS_KEY = 'mixins'; - -// Helper function to allow the creation of anonymous functions which do not -// have .name set to the name of the variable being assigned to. -function identity(fn) { - return fn; -} - -var ReactPropTypeLocationNames; -// if (process.env.NODE_ENV !== 'production') { -// ReactPropTypeLocationNames = { -// prop: 'prop', -// context: 'context', -// childContext: 'child context' -// }; -// } else { - ReactPropTypeLocationNames = {}; -// } -; - -let factory = (function factory(ReactComponent, isValidElement, ReactNoopUpdateQueue) { - /** - * Policies that describe methods in \`ReactClassInterface\`. - */ - - var injectedMixins = []; - - /** - * Composite components are higher-level components that compose other composite - * or host components. - * - * To create a new type of \`ReactClass\`, pass a specification of - * your new class to \`React.createClass\`. The only requirement of your class - * specification is that you implement a \`render\` method. - * - * var MyComponent = React.createClass({ - * render: function() { - * return
Hello World
; - * } - * }); - * - * The class specification supports a specific protocol of methods that have - * special meaning (e.g. \`render\`). See \`ReactClassInterface\` for - * more the comprehensive protocol. Any other properties and methods in the - * class specification will be available on the prototype. - * - * @interface ReactClassInterface - * @internal - */ - var ReactClassInterface = { - /** - * An array of Mixin objects to include when defining your component. - * - * @type {array} - * @optional - */ - mixins: 'DEFINE_MANY', - - /** - * An object containing properties and methods that should be defined on - * the component's constructor instead of its prototype (static methods). - * - * @type {object} - * @optional - */ - statics: 'DEFINE_MANY', - - /** - * Definition of prop types for this component. - * - * @type {object} - * @optional - */ - propTypes: 'DEFINE_MANY', - - /** - * Definition of context types for this component. - * - * @type {object} - * @optional - */ - contextTypes: 'DEFINE_MANY', - - /** - * Definition of context types this component sets for its children. - * - * @type {object} - * @optional - */ - childContextTypes: 'DEFINE_MANY', - - // ==== Definition methods ==== - - /** - * Invoked when the component is mounted. Values in the mapping will be set on - * \`this.props\` if that prop is not specified (i.e. using an \`in\` check). - * - * This method is invoked before \`getInitialState\` and therefore cannot rely - * on \`this.state\` or use \`this.setState\`. - * - * @return {object} - * @optional - */ - getDefaultProps: 'DEFINE_MANY_MERGED', - - /** - * Invoked once before the component is mounted. The return value will be used - * as the initial value of \`this.state\`. - * - * getInitialState: function() { - * return { - * isOn: false, - * fooBaz: new BazFoo() - * } - * } - * - * @return {object} - * @optional - */ - getInitialState: 'DEFINE_MANY_MERGED', - - /** - * @return {object} - * @optional - */ - getChildContext: 'DEFINE_MANY_MERGED', - - /** - * Uses props from \`this.props\` and state from \`this.state\` to render the - * structure of the component. - * - * No guarantees are made about when or how often this method is invoked, so - * it must not have side effects. - * - * render: function() { - * var name = this.props.name; - * return
Hello, {name}!
; - * } - * - * @return {ReactComponent} - * @required - */ - render: 'DEFINE_ONCE', - - // ==== Delegate methods ==== - - /** - * Invoked when the component is initially created and about to be mounted. - * This may have side effects, but any external subscriptions or data created - * by this method must be cleaned up in \`componentWillUnmount\`. - * - * @optional - */ - componentWillMount: 'DEFINE_MANY', - - /** - * Invoked when the component has been mounted and has a DOM representation. - * However, there is no guarantee that the DOM node is in the document. - * - * Use this as an opportunity to operate on the DOM when the component has - * been mounted (initialized and rendered) for the first time. - * - * @param {DOMElement} rootNode DOM element representing the component. - * @optional - */ - componentDidMount: 'DEFINE_MANY', - - /** - * Invoked before the component receives new props. - * - * Use this as an opportunity to react to a prop transition by updating the - * state using \`this.setState\`. Current props are accessed via \`this.props\`. - * - * componentWillReceiveProps: function(nextProps, nextContext) { - * this.setState({ - * likesIncreasing: nextProps.likeCount > this.props.likeCount - * }); - * } - * - * NOTE: There is no equivalent \`componentWillReceiveState\`. An incoming prop - * transition may cause a state change, but the opposite is not true. If you - * need it, you are probably looking for \`componentWillUpdate\`. - * - * @param {object} nextProps - * @optional - */ - componentWillReceiveProps: 'DEFINE_MANY', - - /** - * Invoked while deciding if the component should be updated as a result of - * receiving new props, state and/or context. - * - * Use this as an opportunity to \`return false\` when you're certain that the - * transition to the new props/state/context will not require a component - * update. - * - * shouldComponentUpdate: function(nextProps, nextState, nextContext) { - * return !equal(nextProps, this.props) || - * !equal(nextState, this.state) || - * !equal(nextContext, this.context); - * } - * - * @param {object} nextProps - * @param {?object} nextState - * @param {?object} nextContext - * @return {boolean} True if the component should update. - * @optional - */ - shouldComponentUpdate: 'DEFINE_ONCE', - - /** - * Invoked when the component is about to update due to a transition from - * \`this.props\`, \`this.state\` and \`this.context\` to \`nextProps\`, \`nextState\` - * and \`nextContext\`. - * - * Use this as an opportunity to perform preparation before an update occurs. - * - * NOTE: You **cannot** use \`this.setState()\` in this method. - * - * @param {object} nextProps - * @param {?object} nextState - * @param {?object} nextContext - * @param {ReactReconcileTransaction} transaction - * @optional - */ - componentWillUpdate: 'DEFINE_MANY', - - /** - * Invoked when the component's DOM representation has been updated. - * - * Use this as an opportunity to operate on the DOM when the component has - * been updated. - * - * @param {object} prevProps - * @param {?object} prevState - * @param {?object} prevContext - * @param {DOMElement} rootNode DOM element representing the component. - * @optional - */ - componentDidUpdate: 'DEFINE_MANY', - - /** - * Invoked when the component is about to be removed from its parent and have - * its DOM representation destroyed. - * - * Use this as an opportunity to deallocate any external resources. - * - * NOTE: There is no \`componentDidUnmount\` since your component will have been - * destroyed by that point. - * - * @optional - */ - componentWillUnmount: 'DEFINE_MANY', - - // ==== Advanced methods ==== - - /** - * Updates the component's currently mounted DOM representation. - * - * By default, this implements React's rendering and reconciliation algorithm. - * Sophisticated clients may wish to override this. - * - * @param {ReactReconcileTransaction} transaction - * @internal - * @overridable - */ - updateComponent: 'OVERRIDE_BASE' - }; - - /** - * Mapping from class specification keys to special processing functions. - * - * Although these are declared like instance properties in the specification - * when defining classes using \`React.createClass\`, they are actually static - * and are accessible on the constructor instead of the prototype. Despite - * being static, they must be defined outside of the "statics" key under - * which all other static methods are defined. - */ - var RESERVED_SPEC_KEYS = { - displayName: function(Constructor, displayName) { - Constructor.displayName = displayName; - }, - mixins: function(Constructor, mixins) { - if (mixins) { - for (var i = 0; i < mixins.length; i++) { - mixSpecIntoComponent(Constructor, mixins[i]); - } - } - }, - childContextTypes: function(Constructor, childContextTypes) { - // if (process.env.NODE_ENV !== 'production') { - // validateTypeDef(Constructor, childContextTypes, 'childContext'); - // } - Constructor.childContextTypes = _assign( - {}, - Constructor.childContextTypes, - childContextTypes - ); - }, - contextTypes: function(Constructor, contextTypes) { - // if (process.env.NODE_ENV !== 'production') { - // validateTypeDef(Constructor, contextTypes, 'context'); - // } - Constructor.contextTypes = _assign( - {}, - Constructor.contextTypes, - contextTypes - ); - }, - /** - * Special case getDefaultProps which should move into statics but requires - * automatic merging. - */ - getDefaultProps: function(Constructor, getDefaultProps) { - if (Constructor.getDefaultProps) { - Constructor.getDefaultProps = createMergedResultFunction( - Constructor.getDefaultProps, - getDefaultProps - ); - } else { - Constructor.getDefaultProps = getDefaultProps; - } - }, - propTypes: function(Constructor, propTypes) { - // if (process.env.NODE_ENV !== 'production') { - // validateTypeDef(Constructor, propTypes, 'prop'); - // } - Constructor.propTypes = _assign({}, Constructor.propTypes, propTypes); - }, - statics: function(Constructor, statics) { - mixStaticSpecIntoComponent(Constructor, statics); - }, - autobind: function() {} - }; - - function validateTypeDef(Constructor, typeDef, location) { - for (var propName in typeDef) { - // if (typeDef.hasOwnProperty(propName)) { - // // use a warning instead of an _invariant so components - // // don't show up in prod but only in __DEV__ - // // if (process.env.NODE_ENV !== 'production') { - // // warning( - // // typeof typeDef[propName] === 'function', - // // '%s: %s type \`%s\` is invalid; it must be a function, usually from ' + - // // 'React.PropTypes.', - // // Constructor.displayName || 'ReactClass', - // // ReactPropTypeLocationNames[location], - // // propName - // // ); - // // } - // } - } - } - - function validateMethodOverride(isAlreadyDefined, name) { - var specPolicy = ReactClassInterface.hasOwnProperty(name) - ? ReactClassInterface[name] - : null; - - // Disallow overriding of base class methods unless explicitly allowed. - if (ReactClassMixin.hasOwnProperty(name)) { - // _invariant( - // specPolicy === 'OVERRIDE_BASE', - // 'ReactClassInterface: You are attempting to override ' + - // '\`%s\` from your class specification. Ensure that your method names ' + - // 'do not overlap with React methods.', - // name - // ); - } - - // Disallow defining methods more than once unless explicitly allowed. - if (isAlreadyDefined) { - // _invariant( - // specPolicy === 'DEFINE_MANY' || specPolicy === 'DEFINE_MANY_MERGED', - // 'ReactClassInterface: You are attempting to define ' + - // '\`%s\` on your component more than once. This conflict may be due ' + - // 'to a mixin.', - // name - // ); - } - } - - /** - * Mixin helper which handles policy validation and reserved - * specification keys when building React classes. - */ - function mixSpecIntoComponent(Constructor, spec) { - if (!spec) { - // if (process.env.NODE_ENV !== 'production') { - // var typeofSpec = typeof spec; - // var isMixinValid = typeofSpec === 'object' && spec !== null; - // - // if (process.env.NODE_ENV !== 'production') { - // warning( - // isMixinValid, - // "%s: You're attempting to include a mixin that is either null " + - // 'or not an object. Check the mixins included by the component, ' + - // 'as well as any mixins they include themselves. ' + - // 'Expected object but got %s.', - // Constructor.displayName || 'ReactClass', - // spec === null ? null : typeofSpec - // ); - // } - // } - - return; - } - - // _invariant( - // typeof spec !== 'function', - // "ReactClass: You're attempting to " + - // 'use a component class or function as a mixin. Instead, just use a ' + - // 'regular object.' - // ); - // _invariant( - // !isValidElement(spec), - // "ReactClass: You're attempting to " + - // 'use a component as a mixin. Instead, just use a regular object.' - // ); - - var proto = Constructor.prototype; - var autoBindPairs = proto.__reactAutoBindPairs; - - // By handling mixins before any other properties, we ensure the same - // chaining order is applied to methods with DEFINE_MANY policy, whether - // mixins are listed before or after these methods in the spec. - if (spec.hasOwnProperty(MIXINS_KEY)) { - RESERVED_SPEC_KEYS.mixins(Constructor, spec.mixins); - } - - for (var name in spec) { - if (!spec.hasOwnProperty(name)) { - continue; - } - - if (name === MIXINS_KEY) { - // We have already handled mixins in a special case above. - continue; - } - - var property = spec[name]; - var isAlreadyDefined = proto.hasOwnProperty(name); - validateMethodOverride(isAlreadyDefined, name); - - if (RESERVED_SPEC_KEYS.hasOwnProperty(name)) { - RESERVED_SPEC_KEYS[name](Constructor, property); - } else { - // Setup methods on prototype: - // The following member methods should not be automatically bound: - // 1. Expected ReactClass methods (in the "interface"). - // 2. Overridden methods (that were mixed in). - var isReactClassMethod = ReactClassInterface.hasOwnProperty(name); - var isFunction = typeof property === 'function'; - var shouldAutoBind = - isFunction && - !isReactClassMethod && - !isAlreadyDefined && - spec.autobind !== false; - - if (shouldAutoBind) { - autoBindPairs.push(name, property); - proto[name] = property; - } else { - if (isAlreadyDefined) { - var specPolicy = ReactClassInterface[name]; - - // These cases should already be caught by validateMethodOverride. - // _invariant( - // isReactClassMethod && - // (specPolicy === 'DEFINE_MANY_MERGED' || - // specPolicy === 'DEFINE_MANY'), - // 'ReactClass: Unexpected spec policy %s for key %s ' + - // 'when mixing in component specs.', - // specPolicy, - // name - // ); - - // For methods which are defined more than once, call the existing - // methods before calling the new property, merging if appropriate. - if (specPolicy === 'DEFINE_MANY_MERGED') { - proto[name] = createMergedResultFunction(proto[name], property); - } else if (specPolicy === 'DEFINE_MANY') { - proto[name] = createChainedFunction(proto[name], property); - } - } else { - proto[name] = property; - // if (process.env.NODE_ENV !== 'production') { - // // Add verbose displayName to the function, which helps when looking - // // at profiling tools. - // if (typeof property === 'function' && spec.displayName) { - // proto[name].displayName = spec.displayName + '_' + name; - // } - // } - } - } - } - } - } - - function mixStaticSpecIntoComponent(Constructor, statics) { - if (!statics) { - return; - } - for (var name in statics) { - var property = statics[name]; - if (!statics.hasOwnProperty(name)) { - continue; - } - - var isReserved = name in RESERVED_SPEC_KEYS; - // _invariant( - // !isReserved, - // 'ReactClass: You are attempting to define a reserved ' + - // 'property, \`%s\`, that shouldn\\'t be on the "statics" key. Define it ' + - // 'as an instance property instead; it will still be accessible on the ' + - // 'constructor.', - // name - // ); - - var isInherited = name in Constructor; - // _invariant( - // !isInherited, - // 'ReactClass: You are attempting to define ' + - // '\`%s\` on your component more than once. This conflict may be ' + - // 'due to a mixin.', - // name - // ); - Constructor[name] = property; - } - } - - /** - * Merge two objects, but throw if both contain the same key. - * - * @param {object} one The first object, which is mutated. - * @param {object} two The second object - * @return {object} one after it has been mutated to contain everything in two. - */ - function mergeIntoWithNoDuplicateKeys(one, two) { - // _invariant( - // one && two && typeof one === 'object' && typeof two === 'object', - // 'mergeIntoWithNoDuplicateKeys(): Cannot merge non-objects.' - // ); - - for (var key in two) { - if (two.hasOwnProperty(key)) { - // _invariant( - // one[key] === undefined, - // 'mergeIntoWithNoDuplicateKeys(): ' + - // 'Tried to merge two objects with the same key: \`%s\`. This conflict ' + - // 'may be due to a mixin; in particular, this may be caused by two ' + - // 'getInitialState() or getDefaultProps() methods returning objects ' + - // 'with clashing keys.', - // key - // ); - one[key] = two[key]; - } - } - return one; - } - - /** - * Creates a function that invokes two functions and merges their return values. - * - * @param {function} one Function to invoke first. - * @param {function} two Function to invoke second. - * @return {function} Function that invokes the two argument functions. - * @private - */ - function createMergedResultFunction(one, two) { - return function mergedResult() { - var a = one.apply(this, arguments); - var b = two.apply(this, arguments); - if (a == null) { - return b; - } else if (b == null) { - return a; - } - var c = {}; - mergeIntoWithNoDuplicateKeys(c, a); - mergeIntoWithNoDuplicateKeys(c, b); - return c; - }; - } - - /** - * Creates a function that invokes two functions and ignores their return vales. - * - * @param {function} one Function to invoke first. - * @param {function} two Function to invoke second. - * @return {function} Function that invokes the two argument functions. - * @private - */ - function createChainedFunction(one, two) { - return function chainedFunction() { - one.apply(this, arguments); - two.apply(this, arguments); - }; - } - - /** - * Binds a method to the component. - * - * @param {object} component Component whose method is going to be bound. - * @param {function} method Method to be bound. - * @return {function} The bound method. - */ - function bindAutoBindMethod(component, method) { - var boundMethod = method.bind(component); - // if (process.env.NODE_ENV !== 'production') { - // boundMethod.__reactBoundContext = component; - // boundMethod.__reactBoundMethod = method; - // boundMethod.__reactBoundArguments = null; - // var componentName = component.constructor.displayName; - // var _bind = boundMethod.bind; - // boundMethod.bind = function(newThis) { - // for ( - // var _len = arguments.length, - // args = Array(_len > 1 ? _len - 1 : 0), - // _key = 1; - // _key < _len; - // _key++ - // ) { - // args[_key - 1] = arguments[_key]; - // } - // - // // User is trying to bind() an autobound method; we effectively will - // // ignore the value of "this" that the user is trying to use, so - // // let's warn. - // if (newThis !== component && newThis !== null) { - // if (process.env.NODE_ENV !== 'production') { - // warning( - // false, - // 'bind(): React component methods may only be bound to the ' + - // 'component instance. See %s', - // componentName - // ); - // } - // } else if (!args.length) { - // if (process.env.NODE_ENV !== 'production') { - // warning( - // false, - // 'bind(): You are binding a component method to the component. ' + - // 'React does this for you automatically in a high-performance ' + - // 'way, so you can safely remove this call. See %s', - // componentName - // ); - // } - // return boundMethod; - // } - // var reboundMethod = _bind.apply(boundMethod, arguments); - // reboundMethod.__reactBoundContext = component; - // reboundMethod.__reactBoundMethod = method; - // reboundMethod.__reactBoundArguments = args; - // return reboundMethod; - // }; - // } - return boundMethod; - } - - /** - * Binds all auto-bound methods in a component. - * - * @param {object} component Component whose method is going to be bound. - */ - function bindAutoBindMethods(component) { - var pairs = component.__reactAutoBindPairs; - for (var i = 0; i < pairs.length; i += 2) { - var autoBindKey = pairs[i]; - var method = pairs[i + 1]; - component[autoBindKey] = bindAutoBindMethod(component, method); - } - } - - var IsMountedPreMixin = { - componentDidMount: function() { - this.__isMounted = true; - } - }; - - var IsMountedPostMixin = { - componentWillUnmount: function() { - this.__isMounted = false; - } - }; - - /** - * Add more to the ReactClass base class. These are all legacy features and - * therefore not already part of the modern ReactComponent. - */ - var ReactClassMixin = { - /** - * TODO: This will be deprecated because state should always keep a consistent - * type signature and the only use case for this, is to avoid that. - */ - replaceState: function(newState, callback) { - this.updater.enqueueReplaceState(this, newState, callback); - }, - - /** - * Checks whether or not this composite component is mounted. - * @return {boolean} True if mounted, false otherwise. - * @protected - * @final - */ - isMounted: function() { - // if (process.env.NODE_ENV !== 'production') { - // warning( - // this.__didWarnIsMounted, - // '%s: isMounted is deprecated. Instead, make sure to clean up ' + - // 'subscriptions and pending requests in componentWillUnmount to ' + - // 'prevent memory leaks.', - // (this.constructor && this.constructor.displayName) || - // this.name || - // 'Component' - // ); - // this.__didWarnIsMounted = true; - // } - return !!this.__isMounted; - } - }; - - var ReactClassComponent = function() {}; - _assign( - ReactClassComponent.prototype, - ReactComponent.prototype, - ReactClassMixin - ); - - /** - * Creates a composite component class given a class specification. - * See https://facebook.github.io/react/docs/top-level-api.html#react.createclass - * - * @param {object} spec Class specification (which must define \`render\`). - * @return {function} Component constructor function. - * @public - */ - function createClass(spec) { - // To keep our warnings more understandable, we'll use a little hack here to - // ensure that Constructor.name !== 'Constructor'. This makes sure we don't - // unnecessarily identify a class without displayName as 'Constructor'. - var Constructor = identity(function(props, context, updater) { - // This constructor gets overridden by mocks. The argument is used - // by mocks to assert on what gets mounted. - - // if (process.env.NODE_ENV !== 'production') { - // warning( - // this instanceof Constructor, - // 'Something is calling a React component directly. Use a factory or ' + - // 'JSX instead. See: https://fb.me/react-legacyfactory' - // ); - // } - - // Wire up auto-binding - if (this.__reactAutoBindPairs.length) { - bindAutoBindMethods(this); - } - - this.props = props; - this.context = context; - this.refs = emptyObject; - this.updater = updater || ReactNoopUpdateQueue; - - this.state = null; - - // ReactClasses doesn't have constructors. Instead, they use the - // getInitialState and componentWillMount methods for initialization. - - var initialState = this.getInitialState ? this.getInitialState() : null; - // if (process.env.NODE_ENV !== 'production') { - // // We allow auto-mocks to proceed as if they're returning null. - // if ( - // initialState === undefined && - // this.getInitialState._isMockFunction - // ) { - // // This is probably bad practice. Consider warning here and - // // deprecating this convenience. - // initialState = null; - // } - // } - // _invariant( - // typeof initialState === 'object' && !Array.isArray(initialState), - // '%s.getInitialState(): must return an object or null', - // Constructor.displayName || 'ReactCompositeComponent' - // ); - - this.state = initialState; - }); - Constructor.prototype = new ReactClassComponent(); - Constructor.prototype.constructor = Constructor; - Constructor.prototype.__reactAutoBindPairs = []; - - injectedMixins.forEach(mixSpecIntoComponent.bind(null, Constructor)); - - mixSpecIntoComponent(Constructor, IsMountedPreMixin); - mixSpecIntoComponent(Constructor, spec); - mixSpecIntoComponent(Constructor, IsMountedPostMixin); - - // Initialize the defaultProps property after all mixins have been merged. - if (Constructor.getDefaultProps) { - Constructor.defaultProps = Constructor.getDefaultProps(); - } - - // if (process.env.NODE_ENV !== 'production') { - // // This is a tag to indicate that the use of these method names is ok, - // // since it's used with createClass. If it's not, then it's likely a - // // mistake so we'll warn you to use the static property, property - // // initializer or constructor respectively. - // if (Constructor.getDefaultProps) { - // Constructor.getDefaultProps.isReactClassApproved = {}; - // } - // if (Constructor.prototype.getInitialState) { - // Constructor.prototype.getInitialState.isReactClassApproved = {}; - // } - // } - - // _invariant( - // Constructor.prototype.render, - // 'createClass(...): Class specification must implement a \`render\` method.' - // ); - - // if (process.env.NODE_ENV !== 'production') { - // warning( - // !Constructor.prototype.componentShouldUpdate, - // '%s has a method called ' + - // 'componentShouldUpdate(). Did you mean shouldComponentUpdate()? ' + - // 'The name is phrased as a question because the function is ' + - // 'expected to return a value.', - // spec.displayName || 'A component' - // ); - // warning( - // !Constructor.prototype.componentWillRecieveProps, - // '%s has a method called ' + - // 'componentWillRecieveProps(). Did you mean componentWillReceiveProps()?', - // spec.displayName || 'A component' - // ); - // } - - // Reduce time spent doing lookups by setting these on the prototype. - for (var methodName in ReactClassInterface) { - if (!Constructor.prototype[methodName]) { - Constructor.prototype[methodName] = null; - } - } - - return Constructor; - } - - return createClass; -}); - -let reactNoopUpdateQueue = new React.Component().updater; - -let createClass = factory(React.Component, React.isValidElement, reactNoopUpdateQueue); - -exports._assign = _assign; -exports.emptyObject = emptyObject; -exports.factory = factory; -exports.reactNoopUpdateQueue = reactNoopUpdateQueue; -exports.createClass = createClass; -/* Not a pure module */ diff --git a/tests/tests/src/reasonReactOptimizedCreateClass.mjs b/tests/tests/src/reasonReactOptimizedCreateClass.mjs new file mode 100644 index 0000000000..1f5612b73c --- /dev/null +++ b/tests/tests/src/reasonReactOptimizedCreateClass.mjs @@ -0,0 +1,894 @@ +// Generated by ReScript, PLEASE EDIT WITH CARE + +import * as React from "react"; + +function _assign(prim0, prim1) { + return Object.assign(prim0, prim1); +} + +let emptyObject = {}; + +/** + * Copyright 2013-present, Facebook, Inc. + * All rights reserved. + * + * This source code is licensed under the BSD-style license found in the + * LICENSE file in the root directory of this source tree. An additional grant + * of patent rights can be found in the PATENTS file in the same directory. + * + */ + +// 'use strict'; + +// var _assign = require('object-assign'); + +// var emptyObject = require('emptyObject'); +// var _invariant = require('invariant'); + +// if (process.env.NODE_ENV !== 'production') { +// var warning = require('fbjs/lib/warning'); +// } + +var MIXINS_KEY = 'mixins'; + +// Helper function to allow the creation of anonymous functions which do not +// have .name set to the name of the variable being assigned to. +function identity(fn) { + return fn; +} + +var ReactPropTypeLocationNames; +// if (process.env.NODE_ENV !== 'production') { +// ReactPropTypeLocationNames = { +// prop: 'prop', +// context: 'context', +// childContext: 'child context' +// }; +// } else { + ReactPropTypeLocationNames = {}; +// } +; + +let factory = (function factory(ReactComponent, isValidElement, ReactNoopUpdateQueue) { + /** + * Policies that describe methods in \`ReactClassInterface\`. + */ + + var injectedMixins = []; + + /** + * Composite components are higher-level components that compose other composite + * or host components. + * + * To create a new type of \`ReactClass\`, pass a specification of + * your new class to \`React.createClass\`. The only requirement of your class + * specification is that you implement a \`render\` method. + * + * var MyComponent = React.createClass({ + * render: function() { + * return
Hello World
; + * } + * }); + * + * The class specification supports a specific protocol of methods that have + * special meaning (e.g. \`render\`). See \`ReactClassInterface\` for + * more the comprehensive protocol. Any other properties and methods in the + * class specification will be available on the prototype. + * + * @interface ReactClassInterface + * @internal + */ + var ReactClassInterface = { + /** + * An array of Mixin objects to include when defining your component. + * + * @type {array} + * @optional + */ + mixins: 'DEFINE_MANY', + + /** + * An object containing properties and methods that should be defined on + * the component's constructor instead of its prototype (static methods). + * + * @type {object} + * @optional + */ + statics: 'DEFINE_MANY', + + /** + * Definition of prop types for this component. + * + * @type {object} + * @optional + */ + propTypes: 'DEFINE_MANY', + + /** + * Definition of context types for this component. + * + * @type {object} + * @optional + */ + contextTypes: 'DEFINE_MANY', + + /** + * Definition of context types this component sets for its children. + * + * @type {object} + * @optional + */ + childContextTypes: 'DEFINE_MANY', + + // ==== Definition methods ==== + + /** + * Invoked when the component is mounted. Values in the mapping will be set on + * \`this.props\` if that prop is not specified (i.e. using an \`in\` check). + * + * This method is invoked before \`getInitialState\` and therefore cannot rely + * on \`this.state\` or use \`this.setState\`. + * + * @return {object} + * @optional + */ + getDefaultProps: 'DEFINE_MANY_MERGED', + + /** + * Invoked once before the component is mounted. The return value will be used + * as the initial value of \`this.state\`. + * + * getInitialState: function() { + * return { + * isOn: false, + * fooBaz: new BazFoo() + * } + * } + * + * @return {object} + * @optional + */ + getInitialState: 'DEFINE_MANY_MERGED', + + /** + * @return {object} + * @optional + */ + getChildContext: 'DEFINE_MANY_MERGED', + + /** + * Uses props from \`this.props\` and state from \`this.state\` to render the + * structure of the component. + * + * No guarantees are made about when or how often this method is invoked, so + * it must not have side effects. + * + * render: function() { + * var name = this.props.name; + * return
Hello, {name}!
; + * } + * + * @return {ReactComponent} + * @required + */ + render: 'DEFINE_ONCE', + + // ==== Delegate methods ==== + + /** + * Invoked when the component is initially created and about to be mounted. + * This may have side effects, but any external subscriptions or data created + * by this method must be cleaned up in \`componentWillUnmount\`. + * + * @optional + */ + componentWillMount: 'DEFINE_MANY', + + /** + * Invoked when the component has been mounted and has a DOM representation. + * However, there is no guarantee that the DOM node is in the document. + * + * Use this as an opportunity to operate on the DOM when the component has + * been mounted (initialized and rendered) for the first time. + * + * @param {DOMElement} rootNode DOM element representing the component. + * @optional + */ + componentDidMount: 'DEFINE_MANY', + + /** + * Invoked before the component receives new props. + * + * Use this as an opportunity to react to a prop transition by updating the + * state using \`this.setState\`. Current props are accessed via \`this.props\`. + * + * componentWillReceiveProps: function(nextProps, nextContext) { + * this.setState({ + * likesIncreasing: nextProps.likeCount > this.props.likeCount + * }); + * } + * + * NOTE: There is no equivalent \`componentWillReceiveState\`. An incoming prop + * transition may cause a state change, but the opposite is not true. If you + * need it, you are probably looking for \`componentWillUpdate\`. + * + * @param {object} nextProps + * @optional + */ + componentWillReceiveProps: 'DEFINE_MANY', + + /** + * Invoked while deciding if the component should be updated as a result of + * receiving new props, state and/or context. + * + * Use this as an opportunity to \`return false\` when you're certain that the + * transition to the new props/state/context will not require a component + * update. + * + * shouldComponentUpdate: function(nextProps, nextState, nextContext) { + * return !equal(nextProps, this.props) || + * !equal(nextState, this.state) || + * !equal(nextContext, this.context); + * } + * + * @param {object} nextProps + * @param {?object} nextState + * @param {?object} nextContext + * @return {boolean} True if the component should update. + * @optional + */ + shouldComponentUpdate: 'DEFINE_ONCE', + + /** + * Invoked when the component is about to update due to a transition from + * \`this.props\`, \`this.state\` and \`this.context\` to \`nextProps\`, \`nextState\` + * and \`nextContext\`. + * + * Use this as an opportunity to perform preparation before an update occurs. + * + * NOTE: You **cannot** use \`this.setState()\` in this method. + * + * @param {object} nextProps + * @param {?object} nextState + * @param {?object} nextContext + * @param {ReactReconcileTransaction} transaction + * @optional + */ + componentWillUpdate: 'DEFINE_MANY', + + /** + * Invoked when the component's DOM representation has been updated. + * + * Use this as an opportunity to operate on the DOM when the component has + * been updated. + * + * @param {object} prevProps + * @param {?object} prevState + * @param {?object} prevContext + * @param {DOMElement} rootNode DOM element representing the component. + * @optional + */ + componentDidUpdate: 'DEFINE_MANY', + + /** + * Invoked when the component is about to be removed from its parent and have + * its DOM representation destroyed. + * + * Use this as an opportunity to deallocate any external resources. + * + * NOTE: There is no \`componentDidUnmount\` since your component will have been + * destroyed by that point. + * + * @optional + */ + componentWillUnmount: 'DEFINE_MANY', + + // ==== Advanced methods ==== + + /** + * Updates the component's currently mounted DOM representation. + * + * By default, this implements React's rendering and reconciliation algorithm. + * Sophisticated clients may wish to override this. + * + * @param {ReactReconcileTransaction} transaction + * @internal + * @overridable + */ + updateComponent: 'OVERRIDE_BASE' + }; + + /** + * Mapping from class specification keys to special processing functions. + * + * Although these are declared like instance properties in the specification + * when defining classes using \`React.createClass\`, they are actually static + * and are accessible on the constructor instead of the prototype. Despite + * being static, they must be defined outside of the "statics" key under + * which all other static methods are defined. + */ + var RESERVED_SPEC_KEYS = { + displayName: function(Constructor, displayName) { + Constructor.displayName = displayName; + }, + mixins: function(Constructor, mixins) { + if (mixins) { + for (var i = 0; i < mixins.length; i++) { + mixSpecIntoComponent(Constructor, mixins[i]); + } + } + }, + childContextTypes: function(Constructor, childContextTypes) { + // if (process.env.NODE_ENV !== 'production') { + // validateTypeDef(Constructor, childContextTypes, 'childContext'); + // } + Constructor.childContextTypes = _assign( + {}, + Constructor.childContextTypes, + childContextTypes + ); + }, + contextTypes: function(Constructor, contextTypes) { + // if (process.env.NODE_ENV !== 'production') { + // validateTypeDef(Constructor, contextTypes, 'context'); + // } + Constructor.contextTypes = _assign( + {}, + Constructor.contextTypes, + contextTypes + ); + }, + /** + * Special case getDefaultProps which should move into statics but requires + * automatic merging. + */ + getDefaultProps: function(Constructor, getDefaultProps) { + if (Constructor.getDefaultProps) { + Constructor.getDefaultProps = createMergedResultFunction( + Constructor.getDefaultProps, + getDefaultProps + ); + } else { + Constructor.getDefaultProps = getDefaultProps; + } + }, + propTypes: function(Constructor, propTypes) { + // if (process.env.NODE_ENV !== 'production') { + // validateTypeDef(Constructor, propTypes, 'prop'); + // } + Constructor.propTypes = _assign({}, Constructor.propTypes, propTypes); + }, + statics: function(Constructor, statics) { + mixStaticSpecIntoComponent(Constructor, statics); + }, + autobind: function() {} + }; + + function validateTypeDef(Constructor, typeDef, location) { + for (var propName in typeDef) { + // if (typeDef.hasOwnProperty(propName)) { + // // use a warning instead of an _invariant so components + // // don't show up in prod but only in __DEV__ + // // if (process.env.NODE_ENV !== 'production') { + // // warning( + // // typeof typeDef[propName] === 'function', + // // '%s: %s type \`%s\` is invalid; it must be a function, usually from ' + + // // 'React.PropTypes.', + // // Constructor.displayName || 'ReactClass', + // // ReactPropTypeLocationNames[location], + // // propName + // // ); + // // } + // } + } + } + + function validateMethodOverride(isAlreadyDefined, name) { + var specPolicy = ReactClassInterface.hasOwnProperty(name) + ? ReactClassInterface[name] + : null; + + // Disallow overriding of base class methods unless explicitly allowed. + if (ReactClassMixin.hasOwnProperty(name)) { + // _invariant( + // specPolicy === 'OVERRIDE_BASE', + // 'ReactClassInterface: You are attempting to override ' + + // '\`%s\` from your class specification. Ensure that your method names ' + + // 'do not overlap with React methods.', + // name + // ); + } + + // Disallow defining methods more than once unless explicitly allowed. + if (isAlreadyDefined) { + // _invariant( + // specPolicy === 'DEFINE_MANY' || specPolicy === 'DEFINE_MANY_MERGED', + // 'ReactClassInterface: You are attempting to define ' + + // '\`%s\` on your component more than once. This conflict may be due ' + + // 'to a mixin.', + // name + // ); + } + } + + /** + * Mixin helper which handles policy validation and reserved + * specification keys when building React classes. + */ + function mixSpecIntoComponent(Constructor, spec) { + if (!spec) { + // if (process.env.NODE_ENV !== 'production') { + // var typeofSpec = typeof spec; + // var isMixinValid = typeofSpec === 'object' && spec !== null; + // + // if (process.env.NODE_ENV !== 'production') { + // warning( + // isMixinValid, + // "%s: You're attempting to include a mixin that is either null " + + // 'or not an object. Check the mixins included by the component, ' + + // 'as well as any mixins they include themselves. ' + + // 'Expected object but got %s.', + // Constructor.displayName || 'ReactClass', + // spec === null ? null : typeofSpec + // ); + // } + // } + + return; + } + + // _invariant( + // typeof spec !== 'function', + // "ReactClass: You're attempting to " + + // 'use a component class or function as a mixin. Instead, just use a ' + + // 'regular object.' + // ); + // _invariant( + // !isValidElement(spec), + // "ReactClass: You're attempting to " + + // 'use a component as a mixin. Instead, just use a regular object.' + // ); + + var proto = Constructor.prototype; + var autoBindPairs = proto.__reactAutoBindPairs; + + // By handling mixins before any other properties, we ensure the same + // chaining order is applied to methods with DEFINE_MANY policy, whether + // mixins are listed before or after these methods in the spec. + if (spec.hasOwnProperty(MIXINS_KEY)) { + RESERVED_SPEC_KEYS.mixins(Constructor, spec.mixins); + } + + for (var name in spec) { + if (!spec.hasOwnProperty(name)) { + continue; + } + + if (name === MIXINS_KEY) { + // We have already handled mixins in a special case above. + continue; + } + + var property = spec[name]; + var isAlreadyDefined = proto.hasOwnProperty(name); + validateMethodOverride(isAlreadyDefined, name); + + if (RESERVED_SPEC_KEYS.hasOwnProperty(name)) { + RESERVED_SPEC_KEYS[name](Constructor, property); + } else { + // Setup methods on prototype: + // The following member methods should not be automatically bound: + // 1. Expected ReactClass methods (in the "interface"). + // 2. Overridden methods (that were mixed in). + var isReactClassMethod = ReactClassInterface.hasOwnProperty(name); + var isFunction = typeof property === 'function'; + var shouldAutoBind = + isFunction && + !isReactClassMethod && + !isAlreadyDefined && + spec.autobind !== false; + + if (shouldAutoBind) { + autoBindPairs.push(name, property); + proto[name] = property; + } else { + if (isAlreadyDefined) { + var specPolicy = ReactClassInterface[name]; + + // These cases should already be caught by validateMethodOverride. + // _invariant( + // isReactClassMethod && + // (specPolicy === 'DEFINE_MANY_MERGED' || + // specPolicy === 'DEFINE_MANY'), + // 'ReactClass: Unexpected spec policy %s for key %s ' + + // 'when mixing in component specs.', + // specPolicy, + // name + // ); + + // For methods which are defined more than once, call the existing + // methods before calling the new property, merging if appropriate. + if (specPolicy === 'DEFINE_MANY_MERGED') { + proto[name] = createMergedResultFunction(proto[name], property); + } else if (specPolicy === 'DEFINE_MANY') { + proto[name] = createChainedFunction(proto[name], property); + } + } else { + proto[name] = property; + // if (process.env.NODE_ENV !== 'production') { + // // Add verbose displayName to the function, which helps when looking + // // at profiling tools. + // if (typeof property === 'function' && spec.displayName) { + // proto[name].displayName = spec.displayName + '_' + name; + // } + // } + } + } + } + } + } + + function mixStaticSpecIntoComponent(Constructor, statics) { + if (!statics) { + return; + } + for (var name in statics) { + var property = statics[name]; + if (!statics.hasOwnProperty(name)) { + continue; + } + + var isReserved = name in RESERVED_SPEC_KEYS; + // _invariant( + // !isReserved, + // 'ReactClass: You are attempting to define a reserved ' + + // 'property, \`%s\`, that shouldn\\'t be on the "statics" key. Define it ' + + // 'as an instance property instead; it will still be accessible on the ' + + // 'constructor.', + // name + // ); + + var isInherited = name in Constructor; + // _invariant( + // !isInherited, + // 'ReactClass: You are attempting to define ' + + // '\`%s\` on your component more than once. This conflict may be ' + + // 'due to a mixin.', + // name + // ); + Constructor[name] = property; + } + } + + /** + * Merge two objects, but throw if both contain the same key. + * + * @param {object} one The first object, which is mutated. + * @param {object} two The second object + * @return {object} one after it has been mutated to contain everything in two. + */ + function mergeIntoWithNoDuplicateKeys(one, two) { + // _invariant( + // one && two && typeof one === 'object' && typeof two === 'object', + // 'mergeIntoWithNoDuplicateKeys(): Cannot merge non-objects.' + // ); + + for (var key in two) { + if (two.hasOwnProperty(key)) { + // _invariant( + // one[key] === undefined, + // 'mergeIntoWithNoDuplicateKeys(): ' + + // 'Tried to merge two objects with the same key: \`%s\`. This conflict ' + + // 'may be due to a mixin; in particular, this may be caused by two ' + + // 'getInitialState() or getDefaultProps() methods returning objects ' + + // 'with clashing keys.', + // key + // ); + one[key] = two[key]; + } + } + return one; + } + + /** + * Creates a function that invokes two functions and merges their return values. + * + * @param {function} one Function to invoke first. + * @param {function} two Function to invoke second. + * @return {function} Function that invokes the two argument functions. + * @private + */ + function createMergedResultFunction(one, two) { + return function mergedResult() { + var a = one.apply(this, arguments); + var b = two.apply(this, arguments); + if (a == null) { + return b; + } else if (b == null) { + return a; + } + var c = {}; + mergeIntoWithNoDuplicateKeys(c, a); + mergeIntoWithNoDuplicateKeys(c, b); + return c; + }; + } + + /** + * Creates a function that invokes two functions and ignores their return vales. + * + * @param {function} one Function to invoke first. + * @param {function} two Function to invoke second. + * @return {function} Function that invokes the two argument functions. + * @private + */ + function createChainedFunction(one, two) { + return function chainedFunction() { + one.apply(this, arguments); + two.apply(this, arguments); + }; + } + + /** + * Binds a method to the component. + * + * @param {object} component Component whose method is going to be bound. + * @param {function} method Method to be bound. + * @return {function} The bound method. + */ + function bindAutoBindMethod(component, method) { + var boundMethod = method.bind(component); + // if (process.env.NODE_ENV !== 'production') { + // boundMethod.__reactBoundContext = component; + // boundMethod.__reactBoundMethod = method; + // boundMethod.__reactBoundArguments = null; + // var componentName = component.constructor.displayName; + // var _bind = boundMethod.bind; + // boundMethod.bind = function(newThis) { + // for ( + // var _len = arguments.length, + // args = Array(_len > 1 ? _len - 1 : 0), + // _key = 1; + // _key < _len; + // _key++ + // ) { + // args[_key - 1] = arguments[_key]; + // } + // + // // User is trying to bind() an autobound method; we effectively will + // // ignore the value of "this" that the user is trying to use, so + // // let's warn. + // if (newThis !== component && newThis !== null) { + // if (process.env.NODE_ENV !== 'production') { + // warning( + // false, + // 'bind(): React component methods may only be bound to the ' + + // 'component instance. See %s', + // componentName + // ); + // } + // } else if (!args.length) { + // if (process.env.NODE_ENV !== 'production') { + // warning( + // false, + // 'bind(): You are binding a component method to the component. ' + + // 'React does this for you automatically in a high-performance ' + + // 'way, so you can safely remove this call. See %s', + // componentName + // ); + // } + // return boundMethod; + // } + // var reboundMethod = _bind.apply(boundMethod, arguments); + // reboundMethod.__reactBoundContext = component; + // reboundMethod.__reactBoundMethod = method; + // reboundMethod.__reactBoundArguments = args; + // return reboundMethod; + // }; + // } + return boundMethod; + } + + /** + * Binds all auto-bound methods in a component. + * + * @param {object} component Component whose method is going to be bound. + */ + function bindAutoBindMethods(component) { + var pairs = component.__reactAutoBindPairs; + for (var i = 0; i < pairs.length; i += 2) { + var autoBindKey = pairs[i]; + var method = pairs[i + 1]; + component[autoBindKey] = bindAutoBindMethod(component, method); + } + } + + var IsMountedPreMixin = { + componentDidMount: function() { + this.__isMounted = true; + } + }; + + var IsMountedPostMixin = { + componentWillUnmount: function() { + this.__isMounted = false; + } + }; + + /** + * Add more to the ReactClass base class. These are all legacy features and + * therefore not already part of the modern ReactComponent. + */ + var ReactClassMixin = { + /** + * TODO: This will be deprecated because state should always keep a consistent + * type signature and the only use case for this, is to avoid that. + */ + replaceState: function(newState, callback) { + this.updater.enqueueReplaceState(this, newState, callback); + }, + + /** + * Checks whether or not this composite component is mounted. + * @return {boolean} True if mounted, false otherwise. + * @protected + * @final + */ + isMounted: function() { + // if (process.env.NODE_ENV !== 'production') { + // warning( + // this.__didWarnIsMounted, + // '%s: isMounted is deprecated. Instead, make sure to clean up ' + + // 'subscriptions and pending requests in componentWillUnmount to ' + + // 'prevent memory leaks.', + // (this.constructor && this.constructor.displayName) || + // this.name || + // 'Component' + // ); + // this.__didWarnIsMounted = true; + // } + return !!this.__isMounted; + } + }; + + var ReactClassComponent = function() {}; + _assign( + ReactClassComponent.prototype, + ReactComponent.prototype, + ReactClassMixin + ); + + /** + * Creates a composite component class given a class specification. + * See https://facebook.github.io/react/docs/top-level-api.html#react.createclass + * + * @param {object} spec Class specification (which must define \`render\`). + * @return {function} Component constructor function. + * @public + */ + function createClass(spec) { + // To keep our warnings more understandable, we'll use a little hack here to + // ensure that Constructor.name !== 'Constructor'. This makes sure we don't + // unnecessarily identify a class without displayName as 'Constructor'. + var Constructor = identity(function(props, context, updater) { + // This constructor gets overridden by mocks. The argument is used + // by mocks to assert on what gets mounted. + + // if (process.env.NODE_ENV !== 'production') { + // warning( + // this instanceof Constructor, + // 'Something is calling a React component directly. Use a factory or ' + + // 'JSX instead. See: https://fb.me/react-legacyfactory' + // ); + // } + + // Wire up auto-binding + if (this.__reactAutoBindPairs.length) { + bindAutoBindMethods(this); + } + + this.props = props; + this.context = context; + this.refs = emptyObject; + this.updater = updater || ReactNoopUpdateQueue; + + this.state = null; + + // ReactClasses doesn't have constructors. Instead, they use the + // getInitialState and componentWillMount methods for initialization. + + var initialState = this.getInitialState ? this.getInitialState() : null; + // if (process.env.NODE_ENV !== 'production') { + // // We allow auto-mocks to proceed as if they're returning null. + // if ( + // initialState === undefined && + // this.getInitialState._isMockFunction + // ) { + // // This is probably bad practice. Consider warning here and + // // deprecating this convenience. + // initialState = null; + // } + // } + // _invariant( + // typeof initialState === 'object' && !Array.isArray(initialState), + // '%s.getInitialState(): must return an object or null', + // Constructor.displayName || 'ReactCompositeComponent' + // ); + + this.state = initialState; + }); + Constructor.prototype = new ReactClassComponent(); + Constructor.prototype.constructor = Constructor; + Constructor.prototype.__reactAutoBindPairs = []; + + injectedMixins.forEach(mixSpecIntoComponent.bind(null, Constructor)); + + mixSpecIntoComponent(Constructor, IsMountedPreMixin); + mixSpecIntoComponent(Constructor, spec); + mixSpecIntoComponent(Constructor, IsMountedPostMixin); + + // Initialize the defaultProps property after all mixins have been merged. + if (Constructor.getDefaultProps) { + Constructor.defaultProps = Constructor.getDefaultProps(); + } + + // if (process.env.NODE_ENV !== 'production') { + // // This is a tag to indicate that the use of these method names is ok, + // // since it's used with createClass. If it's not, then it's likely a + // // mistake so we'll warn you to use the static property, property + // // initializer or constructor respectively. + // if (Constructor.getDefaultProps) { + // Constructor.getDefaultProps.isReactClassApproved = {}; + // } + // if (Constructor.prototype.getInitialState) { + // Constructor.prototype.getInitialState.isReactClassApproved = {}; + // } + // } + + // _invariant( + // Constructor.prototype.render, + // 'createClass(...): Class specification must implement a \`render\` method.' + // ); + + // if (process.env.NODE_ENV !== 'production') { + // warning( + // !Constructor.prototype.componentShouldUpdate, + // '%s has a method called ' + + // 'componentShouldUpdate(). Did you mean shouldComponentUpdate()? ' + + // 'The name is phrased as a question because the function is ' + + // 'expected to return a value.', + // spec.displayName || 'A component' + // ); + // warning( + // !Constructor.prototype.componentWillRecieveProps, + // '%s has a method called ' + + // 'componentWillRecieveProps(). Did you mean componentWillReceiveProps()?', + // spec.displayName || 'A component' + // ); + // } + + // Reduce time spent doing lookups by setting these on the prototype. + for (var methodName in ReactClassInterface) { + if (!Constructor.prototype[methodName]) { + Constructor.prototype[methodName] = null; + } + } + + return Constructor; + } + + return createClass; +}); + +let reactNoopUpdateQueue = new React.Component().updater; + +let createClass = factory(React.Component, React.isValidElement, reactNoopUpdateQueue); + +export { + _assign, + emptyObject, + factory, + reactNoopUpdateQueue, + createClass, +} +/* Not a pure module */ diff --git a/tests/tests/src/reasonReactRouter.js b/tests/tests/src/reasonReactRouter.js deleted file mode 100644 index 6df5ded58d..0000000000 --- a/tests/tests/src/reasonReactRouter.js +++ /dev/null @@ -1,187 +0,0 @@ -// Generated by ReScript, PLEASE EDIT WITH CARE -'use strict'; - -let React = require("react"); -let Js_string = require("rescript/lib/js/Js_string.js"); -let Primitive_option = require("rescript/lib/js/Primitive_option.js"); - -function safeMakeEvent(eventName) { - if (typeof Event === "function") { - return new Event(eventName); - } - let event = document.createEvent("Event"); - event.initEvent(eventName, true, true); - return event; -} - -function path() { - let window = globalThis.window; - if (window === undefined) { - return /* [] */0; - } - let raw = Primitive_option.valFromOption(window).location.pathname; - switch (raw) { - case "" : - case "/" : - return /* [] */0; - default: - let raw$1 = Js_string.sliceToEnd(1, raw); - let match = raw$1[raw$1.length - 1 | 0]; - let raw$2 = match === "/" ? Js_string.slice(0, -1, raw$1) : raw$1; - let a = Js_string.split("/", raw$2); - let _i = a.length - 1 | 0; - let _res = /* [] */0; - while (true) { - let res = _res; - let i = _i; - if (i < 0) { - return res; - } - _res = { - hd: a[i], - tl: res - }; - _i = i - 1 | 0; - continue; - }; - } -} - -function hash() { - let window = globalThis.window; - if (window === undefined) { - return ""; - } - let raw = Primitive_option.valFromOption(window).location.hash; - switch (raw) { - case "" : - case "#" : - return ""; - default: - return Js_string.sliceToEnd(1, raw); - } -} - -function search() { - let window = globalThis.window; - if (window === undefined) { - return ""; - } - let raw = Primitive_option.valFromOption(window).location.search; - switch (raw) { - case "" : - case "?" : - return ""; - default: - return Js_string.sliceToEnd(1, raw); - } -} - -function push(path) { - let match = globalThis.history; - let match$1 = globalThis.window; - if (match !== undefined && match$1 !== undefined) { - Primitive_option.valFromOption(match).pushState(null, "", path); - Primitive_option.valFromOption(match$1).dispatchEvent(safeMakeEvent("popstate")); - return; - } - -} - -function replace(path) { - let match = globalThis.history; - let match$1 = globalThis.window; - if (match !== undefined && match$1 !== undefined) { - Primitive_option.valFromOption(match).replaceState(null, "", path); - Primitive_option.valFromOption(match$1).dispatchEvent(safeMakeEvent("popstate")); - return; - } - -} - -function urlNotEqual(a, b) { - if (a.hash !== b.hash || a.search !== b.search) { - return true; - } else { - let _aList = a.path; - let _bList = b.path; - while (true) { - let bList = _bList; - let aList = _aList; - if (!aList) { - if (bList) { - return true; - } else { - return false; - } - } - if (!bList) { - return true; - } - if (aList.hd !== bList.hd) { - return true; - } - _bList = bList.tl; - _aList = aList.tl; - continue; - }; - } -} - -function url() { - return { - path: path(), - hash: hash(), - search: search() - }; -} - -function watchUrl(callback) { - let window = globalThis.window; - if (window === undefined) { - return () => {}; - } - let watcherID = () => callback(url()); - Primitive_option.valFromOption(window).addEventListener("popstate", watcherID); - return watcherID; -} - -function unwatchUrl(watcherID) { - let window = globalThis.window; - if (window !== undefined) { - Primitive_option.valFromOption(window).removeEventListener("popstate", watcherID); - return; - } - -} - -function useUrl(serverUrl, param) { - let match = React.useState(() => { - if (serverUrl !== undefined) { - return serverUrl; - } else { - return url(); - } - }); - let setUrl = match[1]; - let url$1 = match[0]; - React.useEffect(() => { - let watcherId = watchUrl(url => setUrl(param => url)); - let newUrl = url(); - if (urlNotEqual(newUrl, url$1)) { - setUrl(param => newUrl); - } - return () => unwatchUrl(watcherId); - }, []); - return url$1; -} - -let dangerouslyGetInitialUrl = url; - -exports.push = push; -exports.replace = replace; -exports.watchUrl = watchUrl; -exports.unwatchUrl = unwatchUrl; -exports.dangerouslyGetInitialUrl = dangerouslyGetInitialUrl; -exports.useUrl = useUrl; -/* react Not a pure module */ diff --git a/tests/tests/src/reasonReactRouter.mjs b/tests/tests/src/reasonReactRouter.mjs new file mode 100644 index 0000000000..aae73dc38a --- /dev/null +++ b/tests/tests/src/reasonReactRouter.mjs @@ -0,0 +1,188 @@ +// Generated by ReScript, PLEASE EDIT WITH CARE + +import * as React from "react"; +import * as Js_string from "rescript/lib/es6/Js_string.js"; +import * as Primitive_option from "rescript/lib/es6/Primitive_option.js"; + +function safeMakeEvent(eventName) { + if (typeof Event === "function") { + return new Event(eventName); + } + let event = document.createEvent("Event"); + event.initEvent(eventName, true, true); + return event; +} + +function path() { + let window = globalThis.window; + if (window === undefined) { + return /* [] */0; + } + let raw = Primitive_option.valFromOption(window).location.pathname; + switch (raw) { + case "" : + case "/" : + return /* [] */0; + default: + let raw$1 = Js_string.sliceToEnd(1, raw); + let match = raw$1[raw$1.length - 1 | 0]; + let raw$2 = match === "/" ? Js_string.slice(0, -1, raw$1) : raw$1; + let a = Js_string.split("/", raw$2); + let _i = a.length - 1 | 0; + let _res = /* [] */0; + while (true) { + let res = _res; + let i = _i; + if (i < 0) { + return res; + } + _res = { + hd: a[i], + tl: res + }; + _i = i - 1 | 0; + continue; + }; + } +} + +function hash() { + let window = globalThis.window; + if (window === undefined) { + return ""; + } + let raw = Primitive_option.valFromOption(window).location.hash; + switch (raw) { + case "" : + case "#" : + return ""; + default: + return Js_string.sliceToEnd(1, raw); + } +} + +function search() { + let window = globalThis.window; + if (window === undefined) { + return ""; + } + let raw = Primitive_option.valFromOption(window).location.search; + switch (raw) { + case "" : + case "?" : + return ""; + default: + return Js_string.sliceToEnd(1, raw); + } +} + +function push(path) { + let match = globalThis.history; + let match$1 = globalThis.window; + if (match !== undefined && match$1 !== undefined) { + Primitive_option.valFromOption(match).pushState(null, "", path); + Primitive_option.valFromOption(match$1).dispatchEvent(safeMakeEvent("popstate")); + return; + } + +} + +function replace(path) { + let match = globalThis.history; + let match$1 = globalThis.window; + if (match !== undefined && match$1 !== undefined) { + Primitive_option.valFromOption(match).replaceState(null, "", path); + Primitive_option.valFromOption(match$1).dispatchEvent(safeMakeEvent("popstate")); + return; + } + +} + +function urlNotEqual(a, b) { + if (a.hash !== b.hash || a.search !== b.search) { + return true; + } else { + let _aList = a.path; + let _bList = b.path; + while (true) { + let bList = _bList; + let aList = _aList; + if (!aList) { + if (bList) { + return true; + } else { + return false; + } + } + if (!bList) { + return true; + } + if (aList.hd !== bList.hd) { + return true; + } + _bList = bList.tl; + _aList = aList.tl; + continue; + }; + } +} + +function url() { + return { + path: path(), + hash: hash(), + search: search() + }; +} + +function watchUrl(callback) { + let window = globalThis.window; + if (window === undefined) { + return () => {}; + } + let watcherID = () => callback(url()); + Primitive_option.valFromOption(window).addEventListener("popstate", watcherID); + return watcherID; +} + +function unwatchUrl(watcherID) { + let window = globalThis.window; + if (window !== undefined) { + Primitive_option.valFromOption(window).removeEventListener("popstate", watcherID); + return; + } + +} + +function useUrl(serverUrl, param) { + let match = React.useState(() => { + if (serverUrl !== undefined) { + return serverUrl; + } else { + return url(); + } + }); + let setUrl = match[1]; + let url$1 = match[0]; + React.useEffect(() => { + let watcherId = watchUrl(url => setUrl(param => url)); + let newUrl = url(); + if (urlNotEqual(newUrl, url$1)) { + setUrl(param => newUrl); + } + return () => unwatchUrl(watcherId); + }, []); + return url$1; +} + +let dangerouslyGetInitialUrl = url; + +export { + push, + replace, + watchUrl, + unwatchUrl, + dangerouslyGetInitialUrl, + useUrl, +} +/* react Not a pure module */ diff --git a/tests/tests/src/rebind_module.js b/tests/tests/src/rebind_module.js deleted file mode 100644 index a87c34b1c4..0000000000 --- a/tests/tests/src/rebind_module.js +++ /dev/null @@ -1,12 +0,0 @@ -// Generated by ReScript, PLEASE EDIT WITH CARE -'use strict'; - -let Primitive_exceptions = require("rescript/lib/js/Primitive_exceptions.js"); - -let A = /* @__PURE__ */Primitive_exceptions.create("Rebind_module.A"); - -let AA = /* @__PURE__ */Primitive_exceptions.create("Rebind_module.AA"); - -exports.A = A; -exports.AA = AA; -/* No side effect */ diff --git a/tests/tests/src/rebind_module.mjs b/tests/tests/src/rebind_module.mjs new file mode 100644 index 0000000000..22ba80cd67 --- /dev/null +++ b/tests/tests/src/rebind_module.mjs @@ -0,0 +1,13 @@ +// Generated by ReScript, PLEASE EDIT WITH CARE + +import * as Primitive_exceptions from "rescript/lib/es6/Primitive_exceptions.js"; + +let A = /* @__PURE__ */Primitive_exceptions.create("Rebind_module.A"); + +let AA = /* @__PURE__ */Primitive_exceptions.create("Rebind_module.AA"); + +export { + A, + AA, +} +/* No side effect */ diff --git a/tests/tests/src/rebind_module_test.js b/tests/tests/src/rebind_module_test.js deleted file mode 100644 index 5e0744b7f3..0000000000 --- a/tests/tests/src/rebind_module_test.js +++ /dev/null @@ -1,15 +0,0 @@ -// Generated by ReScript, PLEASE EDIT WITH CARE -'use strict'; - -let Rebind_module = require("./rebind_module.js"); - -function x(v) { - if (v.RE_EXN_ID === Rebind_module.AA) { - return 0; - } else { - return 1; - } -} - -exports.x = x; -/* No side effect */ diff --git a/tests/tests/src/rebind_module_test.mjs b/tests/tests/src/rebind_module_test.mjs new file mode 100644 index 0000000000..6ebf1333f3 --- /dev/null +++ b/tests/tests/src/rebind_module_test.mjs @@ -0,0 +1,16 @@ +// Generated by ReScript, PLEASE EDIT WITH CARE + +import * as Rebind_module from "./rebind_module.mjs"; + +function x(v) { + if (v.RE_EXN_ID === Rebind_module.AA) { + return 0; + } else { + return 1; + } +} + +export { + x, +} +/* No side effect */ diff --git a/tests/tests/src/rec_array_test.js b/tests/tests/src/rec_array_test.js deleted file mode 100644 index a9304bd993..0000000000 --- a/tests/tests/src/rec_array_test.js +++ /dev/null @@ -1,20 +0,0 @@ -// Generated by ReScript, PLEASE EDIT WITH CARE -'use strict'; - -let Primitive_object = require("rescript/lib/js/Primitive_object.js"); - -let vicky = {}; - -let teacher = {}; - -Primitive_object.updateDummy(vicky, { - taughtBy: teacher -}); - -Primitive_object.updateDummy(teacher, { - students: [vicky] -}); - -exports.vicky = vicky; -exports.teacher = teacher; -/* No side effect */ diff --git a/tests/tests/src/rec_array_test.mjs b/tests/tests/src/rec_array_test.mjs new file mode 100644 index 0000000000..8abcd8592b --- /dev/null +++ b/tests/tests/src/rec_array_test.mjs @@ -0,0 +1,21 @@ +// Generated by ReScript, PLEASE EDIT WITH CARE + +import * as Primitive_object from "rescript/lib/es6/Primitive_object.js"; + +let vicky = {}; + +let teacher = {}; + +Primitive_object.updateDummy(vicky, { + taughtBy: teacher +}); + +Primitive_object.updateDummy(teacher, { + students: [vicky] +}); + +export { + vicky, + teacher, +} +/* No side effect */ diff --git a/tests/tests/src/rec_fun_test.js b/tests/tests/src/rec_fun_test.js deleted file mode 100644 index 9ae08fb641..0000000000 --- a/tests/tests/src/rec_fun_test.js +++ /dev/null @@ -1,76 +0,0 @@ -// Generated by ReScript, PLEASE EDIT WITH CARE -'use strict'; - -let Mt = require("./mt.js"); -let Primitive_object = require("rescript/lib/js/Primitive_object.js"); - -let suites = { - contents: /* [] */0 -}; - -let test_id = { - contents: 0 -}; - -function eq(loc, x, y) { - test_id.contents = test_id.contents + 1 | 0; - suites.contents = { - hd: [ - loc + (" id " + test_id.contents.toString()), - () => ({ - TAG: "Eq", - _0: x, - _1: y - }) - ], - tl: suites.contents - }; -} - -let called = { - contents: 0 -}; - -function g() { - let v = {}; - let next = (i, b) => { - called.contents = called.contents + 1 | 0; - if (b) { - v.contents(i, false); - } - return i + 1 | 0; - }; - Primitive_object.updateDummy(v, { - contents: next - }); - console.log(next(0, true).toString()); -} - -g(); - -let x = {}; - -let y = {}; - -Primitive_object.updateDummy(x, { - hd: 1, - tl: y -}); - -Primitive_object.updateDummy(y, { - hd: 2, - tl: x -}); - -eq("File \"rec_fun_test.res\", line 32, characters 3-10", called.contents, 2); - -Mt.from_pair_suites("Rec_fun_test", suites.contents); - -exports.suites = suites; -exports.test_id = test_id; -exports.eq = eq; -exports.called = called; -exports.g = g; -exports.x = x; -exports.y = y; -/* Not a pure module */ diff --git a/tests/tests/src/rec_fun_test.mjs b/tests/tests/src/rec_fun_test.mjs new file mode 100644 index 0000000000..d24791fbb4 --- /dev/null +++ b/tests/tests/src/rec_fun_test.mjs @@ -0,0 +1,77 @@ +// Generated by ReScript, PLEASE EDIT WITH CARE + +import * as Mt from "./mt.mjs"; +import * as Primitive_object from "rescript/lib/es6/Primitive_object.js"; + +let suites = { + contents: /* [] */0 +}; + +let test_id = { + contents: 0 +}; + +function eq(loc, x, y) { + test_id.contents = test_id.contents + 1 | 0; + suites.contents = { + hd: [ + loc + (" id " + test_id.contents.toString()), + () => ({ + TAG: "Eq", + _0: x, + _1: y + }) + ], + tl: suites.contents + }; +} + +let called = { + contents: 0 +}; + +function g() { + let v = {}; + let next = (i, b) => { + called.contents = called.contents + 1 | 0; + if (b) { + v.contents(i, false); + } + return i + 1 | 0; + }; + Primitive_object.updateDummy(v, { + contents: next + }); + console.log(next(0, true).toString()); +} + +g(); + +let x = {}; + +let y = {}; + +Primitive_object.updateDummy(x, { + hd: 1, + tl: y +}); + +Primitive_object.updateDummy(y, { + hd: 2, + tl: x +}); + +eq("File \"rec_fun_test.res\", line 32, characters 3-10", called.contents, 2); + +Mt.from_pair_suites("Rec_fun_test", suites.contents); + +export { + suites, + test_id, + eq, + called, + g, + x, + y, +} +/* Not a pure module */ diff --git a/tests/tests/src/rec_module_opt.js b/tests/tests/src/rec_module_opt.js deleted file mode 100644 index b20c4ebfe3..0000000000 --- a/tests/tests/src/rec_module_opt.js +++ /dev/null @@ -1,111 +0,0 @@ -// Generated by ReScript, PLEASE EDIT WITH CARE -'use strict'; - -let Belt_Id = require("rescript/lib/js/Belt_Id.js"); -let Primitive_module = require("rescript/lib/js/Primitive_module.js"); -let Primitive_string = require("rescript/lib/js/Primitive_string.js"); - -let A = Primitive_module.init([ - "rec_module_opt.res", - 15, - 4 -], { - TAG: "Module", - _0: [[ - "Function", - "cmp" - ]] -}); - -let AComparable = Belt_Id.MakeComparable(A); - -function cmp(t1, t2) { - if (t1.TAG === "Leaf") { - if (t2.TAG === "Leaf") { - return Primitive_string.compare(t1._0, t2._0); - } else { - return 1; - } - } else if (t2.TAG === "Leaf") { - return -1; - } else { - return AComparable.cmp(t1._0, t2._0); - } -} - -Primitive_module.update({ - TAG: "Module", - _0: [[ - "Function", - "cmp" - ]] -}, A, { - cmp: cmp -}); - -let X0 = {}; - -let Y0 = {}; - -let X1 = Primitive_module.init([ - "rec_module_opt.res", - 44, - 19 -], { - TAG: "Module", - _0: [[ - "Function", - "f" - ]] -}); - -let Y1 = Primitive_module.init([ - "rec_module_opt.res", - 47, - 12 -], { - TAG: "Module", - _0: [[ - "Function", - "f" - ]] -}); - -function f(x) { - return x + 1 | 0; -} - -Primitive_module.update({ - TAG: "Module", - _0: [[ - "Function", - "f" - ]] -}, X1, { - f: f -}); - -function f$1(x) { - return x + 2 | 0; -} - -Primitive_module.update({ - TAG: "Module", - _0: [[ - "Function", - "f" - ]] -}, Y1, { - f: f$1 -}); - -let X; - -exports.A = A; -exports.AComparable = AComparable; -exports.X = X; -exports.X0 = X0; -exports.Y0 = Y0; -exports.X1 = X1; -exports.Y1 = Y1; -/* A Not a pure module */ diff --git a/tests/tests/src/rec_module_opt.mjs b/tests/tests/src/rec_module_opt.mjs new file mode 100644 index 0000000000..70ca2fe998 --- /dev/null +++ b/tests/tests/src/rec_module_opt.mjs @@ -0,0 +1,112 @@ +// Generated by ReScript, PLEASE EDIT WITH CARE + +import * as Belt_Id from "rescript/lib/es6/Belt_Id.js"; +import * as Primitive_module from "rescript/lib/es6/Primitive_module.js"; +import * as Primitive_string from "rescript/lib/es6/Primitive_string.js"; + +let A = Primitive_module.init([ + "rec_module_opt.res", + 15, + 4 +], { + TAG: "Module", + _0: [[ + "Function", + "cmp" + ]] +}); + +let AComparable = Belt_Id.MakeComparable(A); + +function cmp(t1, t2) { + if (t1.TAG === "Leaf") { + if (t2.TAG === "Leaf") { + return Primitive_string.compare(t1._0, t2._0); + } else { + return 1; + } + } else if (t2.TAG === "Leaf") { + return -1; + } else { + return AComparable.cmp(t1._0, t2._0); + } +} + +Primitive_module.update({ + TAG: "Module", + _0: [[ + "Function", + "cmp" + ]] +}, A, { + cmp: cmp +}); + +let X0 = {}; + +let Y0 = {}; + +let X1 = Primitive_module.init([ + "rec_module_opt.res", + 44, + 19 +], { + TAG: "Module", + _0: [[ + "Function", + "f" + ]] +}); + +let Y1 = Primitive_module.init([ + "rec_module_opt.res", + 47, + 12 +], { + TAG: "Module", + _0: [[ + "Function", + "f" + ]] +}); + +function f(x) { + return x + 1 | 0; +} + +Primitive_module.update({ + TAG: "Module", + _0: [[ + "Function", + "f" + ]] +}, X1, { + f: f +}); + +function f$1(x) { + return x + 2 | 0; +} + +Primitive_module.update({ + TAG: "Module", + _0: [[ + "Function", + "f" + ]] +}, Y1, { + f: f$1 +}); + +let X; + +export { + A, + AComparable, + X, + X0, + Y0, + X1, + Y1, +} +/* A Not a pure module */ diff --git a/tests/tests/src/rec_module_test.js b/tests/tests/src/rec_module_test.js deleted file mode 100644 index 99c1875d34..0000000000 --- a/tests/tests/src/rec_module_test.js +++ /dev/null @@ -1,258 +0,0 @@ -// Generated by ReScript, PLEASE EDIT WITH CARE -'use strict'; - -let Mt = require("./mt.js"); -let Primitive_module = require("rescript/lib/js/Primitive_module.js"); - -let A = Primitive_module.init([ - "rec_module_test.res", - 3, - 4 -], { - TAG: "Module", - _0: [[ - "Function", - "even" - ]] -}); - -let B = Primitive_module.init([ - "rec_module_test.res", - 15, - 4 -], { - TAG: "Module", - _0: [[ - "Function", - "odd" - ]] -}); - -function even(n) { - if (n === 0) { - return true; - } else if (n === 1) { - return false; - } else { - return B.odd(n - 1 | 0); - } -} - -Primitive_module.update({ - TAG: "Module", - _0: [[ - "Function", - "even" - ]] -}, A, { - even: even -}); - -function odd(n) { - if (n === 1) { - return true; - } else if (n === 0) { - return false; - } else { - return A.even(n - 1 | 0); - } -} - -Primitive_module.update({ - TAG: "Module", - _0: [[ - "Function", - "odd" - ]] -}, B, { - odd: odd -}); - -let AA = Primitive_module.init([ - "rec_module_test.res", - 29, - 4 -], { - TAG: "Module", - _0: [ - [ - "Function", - "even" - ], - [ - "Function", - "x" - ] - ] -}); - -let BB = Primitive_module.init([ - "rec_module_test.res", - 43, - 4 -], { - TAG: "Module", - _0: [ - [ - "Function", - "odd" - ], - [ - "Function", - "y" - ] - ] -}); - -function even$1(n) { - if (n === 0) { - return true; - } else if (n === 1) { - return false; - } else { - return BB.odd(n - 1 | 0); - } -} - -function x() { - return BB.y() + 3 | 0; -} - -Primitive_module.update({ - TAG: "Module", - _0: [ - [ - "Function", - "even" - ], - [ - "Function", - "x" - ] - ] -}, AA, { - even: even$1, - x: x -}); - -function odd$1(n) { - if (n === 1) { - return true; - } else if (n === 0) { - return false; - } else { - return AA.even(n - 1 | 0); - } -} - -function y() { - return 32; -} - -Primitive_module.update({ - TAG: "Module", - _0: [ - [ - "Function", - "odd" - ], - [ - "Function", - "y" - ] - ] -}, BB, { - odd: odd$1, - y: y -}); - -let Even = {}; - -let Odd = {}; - -let suites_0 = [ - "test1", - param => ({ - TAG: "Eq", - _0: [ - true, - true, - false, - false - ], - _1: [ - A.even(2), - AA.even(4), - B.odd(2), - BB.odd(4) - ] - }) -]; - -let suites_1 = { - hd: [ - "test2", - param => ({ - TAG: "Eq", - _0: BB.y(), - _1: 32 - }) - ], - tl: { - hd: [ - "test3", - param => ({ - TAG: "Eq", - _0: AA.x(), - _1: 35 - }) - ], - tl: { - hd: [ - "test4", - param => ({ - TAG: "Eq", - _0: true, - _1: A.even(2) - }) - ], - tl: { - hd: [ - "test4", - param => ({ - TAG: "Eq", - _0: true, - _1: AA.even(4) - }) - ], - tl: { - hd: [ - "test5", - param => ({ - TAG: "Eq", - _0: false, - _1: B.odd(2) - }) - ], - tl: /* [] */0 - } - } - } - } -}; - -let suites = { - hd: suites_0, - tl: suites_1 -}; - -Mt.from_pair_suites("Rec_module_test", suites); - -exports.A = A; -exports.B = B; -exports.AA = AA; -exports.BB = BB; -exports.Even = Even; -exports.Odd = Odd; -exports.suites = suites; -/* A Not a pure module */ diff --git a/tests/tests/src/rec_module_test.mjs b/tests/tests/src/rec_module_test.mjs new file mode 100644 index 0000000000..bafd930e4a --- /dev/null +++ b/tests/tests/src/rec_module_test.mjs @@ -0,0 +1,259 @@ +// Generated by ReScript, PLEASE EDIT WITH CARE + +import * as Mt from "./mt.mjs"; +import * as Primitive_module from "rescript/lib/es6/Primitive_module.js"; + +let A = Primitive_module.init([ + "rec_module_test.res", + 3, + 4 +], { + TAG: "Module", + _0: [[ + "Function", + "even" + ]] +}); + +let B = Primitive_module.init([ + "rec_module_test.res", + 15, + 4 +], { + TAG: "Module", + _0: [[ + "Function", + "odd" + ]] +}); + +function even(n) { + if (n === 0) { + return true; + } else if (n === 1) { + return false; + } else { + return B.odd(n - 1 | 0); + } +} + +Primitive_module.update({ + TAG: "Module", + _0: [[ + "Function", + "even" + ]] +}, A, { + even: even +}); + +function odd(n) { + if (n === 1) { + return true; + } else if (n === 0) { + return false; + } else { + return A.even(n - 1 | 0); + } +} + +Primitive_module.update({ + TAG: "Module", + _0: [[ + "Function", + "odd" + ]] +}, B, { + odd: odd +}); + +let AA = Primitive_module.init([ + "rec_module_test.res", + 29, + 4 +], { + TAG: "Module", + _0: [ + [ + "Function", + "even" + ], + [ + "Function", + "x" + ] + ] +}); + +let BB = Primitive_module.init([ + "rec_module_test.res", + 43, + 4 +], { + TAG: "Module", + _0: [ + [ + "Function", + "odd" + ], + [ + "Function", + "y" + ] + ] +}); + +function even$1(n) { + if (n === 0) { + return true; + } else if (n === 1) { + return false; + } else { + return BB.odd(n - 1 | 0); + } +} + +function x() { + return BB.y() + 3 | 0; +} + +Primitive_module.update({ + TAG: "Module", + _0: [ + [ + "Function", + "even" + ], + [ + "Function", + "x" + ] + ] +}, AA, { + even: even$1, + x: x +}); + +function odd$1(n) { + if (n === 1) { + return true; + } else if (n === 0) { + return false; + } else { + return AA.even(n - 1 | 0); + } +} + +function y() { + return 32; +} + +Primitive_module.update({ + TAG: "Module", + _0: [ + [ + "Function", + "odd" + ], + [ + "Function", + "y" + ] + ] +}, BB, { + odd: odd$1, + y: y +}); + +let Even = {}; + +let Odd = {}; + +let suites_0 = [ + "test1", + param => ({ + TAG: "Eq", + _0: [ + true, + true, + false, + false + ], + _1: [ + A.even(2), + AA.even(4), + B.odd(2), + BB.odd(4) + ] + }) +]; + +let suites_1 = { + hd: [ + "test2", + param => ({ + TAG: "Eq", + _0: BB.y(), + _1: 32 + }) + ], + tl: { + hd: [ + "test3", + param => ({ + TAG: "Eq", + _0: AA.x(), + _1: 35 + }) + ], + tl: { + hd: [ + "test4", + param => ({ + TAG: "Eq", + _0: true, + _1: A.even(2) + }) + ], + tl: { + hd: [ + "test4", + param => ({ + TAG: "Eq", + _0: true, + _1: AA.even(4) + }) + ], + tl: { + hd: [ + "test5", + param => ({ + TAG: "Eq", + _0: false, + _1: B.odd(2) + }) + ], + tl: /* [] */0 + } + } + } + } +}; + +let suites = { + hd: suites_0, + tl: suites_1 +}; + +Mt.from_pair_suites("Rec_module_test", suites); + +export { + A, + B, + AA, + BB, + Even, + Odd, + suites, +} +/* A Not a pure module */ diff --git a/tests/tests/src/recmodule.js b/tests/tests/src/recmodule.js deleted file mode 100644 index 4d46322793..0000000000 --- a/tests/tests/src/recmodule.js +++ /dev/null @@ -1,198 +0,0 @@ -// Generated by ReScript, PLEASE EDIT WITH CARE -'use strict'; - -let Primitive_module = require("rescript/lib/js/Primitive_module.js"); - -let Entity = {}; - -function MakeLayer(Deps) { - let getLight = id => Deps.presentLight({ - id: id, - name: "Light 1" - }); - return { - getLight: getLight - }; -} - -let UseCase = { - MakeLayer: MakeLayer -}; - -function MakeLayer$1(Deps, UC) { - let presentLight = light => Deps.presentJson(light, 200); - let handleGetLight = req => UC.getLight(req.params.id); - return { - handleGetLight: handleGetLight, - presentLight: presentLight - }; -} - -let Adapter = { - MakeLayer: MakeLayer$1 -}; - -function MakeLayer$2(Deps) { - let presentJson = (json, status) => { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "recmodule.res", - 60, - 41 - ], - Error: new Error() - }; - }; - let routes = () => [[ - "/lights", - Deps.handleGetLight - ]]; - return { - presentJson: presentJson, - routes: routes - }; -} - -let Infra = { - MakeLayer: MakeLayer$2 -}; - -let I = Primitive_module.init([ - "recmodule.res", - 67, - 30 -], { - TAG: "Module", - _0: [ - [ - "Function", - "presentJson" - ], - [ - "Function", - "routes" - ] - ] -}); - -let A = Primitive_module.init([ - "recmodule.res", - 68, - 25 -], { - TAG: "Module", - _0: [ - [ - "Function", - "handleGetLight" - ], - [ - "Function", - "presentLight" - ] - ] -}); - -let U = Primitive_module.init([ - "recmodule.res", - 69, - 25 -], { - TAG: "Module", - _0: [[ - "Function", - "getLight" - ]] -}); - -function presentJson(json, status) { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "recmodule.res", - 60, - 41 - ], - Error: new Error() - }; -} - -function routes() { - return [[ - "/lights", - A.handleGetLight - ]]; -} - -Primitive_module.update({ - TAG: "Module", - _0: [ - [ - "Function", - "presentJson" - ], - [ - "Function", - "routes" - ] - ] -}, I, { - presentJson: presentJson, - routes: routes -}); - -function presentLight(light) { - return I.presentJson(light, 200); -} - -function handleGetLight(req) { - return U.getLight(req.params.id); -} - -Primitive_module.update({ - TAG: "Module", - _0: [ - [ - "Function", - "handleGetLight" - ], - [ - "Function", - "presentLight" - ] - ] -}, A, { - handleGetLight: handleGetLight, - presentLight: presentLight -}); - -function getLight(id) { - return A.presentLight({ - id: id, - name: "Light 1" - }); -} - -Primitive_module.update({ - TAG: "Module", - _0: [[ - "Function", - "getLight" - ]] -}, U, { - getLight: getLight -}); - -let App = { - I: I, - A: A, - U: U -}; - -exports.Entity = Entity; -exports.UseCase = UseCase; -exports.Adapter = Adapter; -exports.Infra = Infra; -exports.App = App; -/* I Not a pure module */ diff --git a/tests/tests/src/recmodule.mjs b/tests/tests/src/recmodule.mjs new file mode 100644 index 0000000000..1b5fde4180 --- /dev/null +++ b/tests/tests/src/recmodule.mjs @@ -0,0 +1,199 @@ +// Generated by ReScript, PLEASE EDIT WITH CARE + +import * as Primitive_module from "rescript/lib/es6/Primitive_module.js"; + +let Entity = {}; + +function MakeLayer(Deps) { + let getLight = id => Deps.presentLight({ + id: id, + name: "Light 1" + }); + return { + getLight: getLight + }; +} + +let UseCase = { + MakeLayer: MakeLayer +}; + +function MakeLayer$1(Deps, UC) { + let presentLight = light => Deps.presentJson(light, 200); + let handleGetLight = req => UC.getLight(req.params.id); + return { + handleGetLight: handleGetLight, + presentLight: presentLight + }; +} + +let Adapter = { + MakeLayer: MakeLayer$1 +}; + +function MakeLayer$2(Deps) { + let presentJson = (json, status) => { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "recmodule.res", + 60, + 41 + ], + Error: new Error() + }; + }; + let routes = () => [[ + "/lights", + Deps.handleGetLight + ]]; + return { + presentJson: presentJson, + routes: routes + }; +} + +let Infra = { + MakeLayer: MakeLayer$2 +}; + +let I = Primitive_module.init([ + "recmodule.res", + 67, + 30 +], { + TAG: "Module", + _0: [ + [ + "Function", + "presentJson" + ], + [ + "Function", + "routes" + ] + ] +}); + +let A = Primitive_module.init([ + "recmodule.res", + 68, + 25 +], { + TAG: "Module", + _0: [ + [ + "Function", + "handleGetLight" + ], + [ + "Function", + "presentLight" + ] + ] +}); + +let U = Primitive_module.init([ + "recmodule.res", + 69, + 25 +], { + TAG: "Module", + _0: [[ + "Function", + "getLight" + ]] +}); + +function presentJson(json, status) { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "recmodule.res", + 60, + 41 + ], + Error: new Error() + }; +} + +function routes() { + return [[ + "/lights", + A.handleGetLight + ]]; +} + +Primitive_module.update({ + TAG: "Module", + _0: [ + [ + "Function", + "presentJson" + ], + [ + "Function", + "routes" + ] + ] +}, I, { + presentJson: presentJson, + routes: routes +}); + +function presentLight(light) { + return I.presentJson(light, 200); +} + +function handleGetLight(req) { + return U.getLight(req.params.id); +} + +Primitive_module.update({ + TAG: "Module", + _0: [ + [ + "Function", + "handleGetLight" + ], + [ + "Function", + "presentLight" + ] + ] +}, A, { + handleGetLight: handleGetLight, + presentLight: presentLight +}); + +function getLight(id) { + return A.presentLight({ + id: id, + name: "Light 1" + }); +} + +Primitive_module.update({ + TAG: "Module", + _0: [[ + "Function", + "getLight" + ]] +}, U, { + getLight: getLight +}); + +let App = { + I: I, + A: A, + U: U +}; + +export { + Entity, + UseCase, + Adapter, + Infra, + App, +} +/* I Not a pure module */ diff --git a/tests/tests/src/record_debug_test.js b/tests/tests/src/record_debug_test.js deleted file mode 100644 index 266aad75ff..0000000000 --- a/tests/tests/src/record_debug_test.js +++ /dev/null @@ -1,142 +0,0 @@ -// Generated by ReScript, PLEASE EDIT WITH CARE -'use strict'; - -let Mt = require("./mt.js"); -let Primitive_exceptions = require("rescript/lib/js/Primitive_exceptions.js"); - -let suites = { - contents: /* [] */0 -}; - -let test_id = { - contents: 0 -}; - -function eq(loc, x, y) { - Mt.eq_suites(test_id, suites, loc, x, y); -} - -let v = { - a: 3, - b: { - xx: 2, - yy: 3 - } -}; - -let u_a = 2; - -let u_b = { - xx: 2, - yy: 3 -}; - -let u = { - a: u_a, - b: u_b -}; - -let A = /* @__PURE__ */Primitive_exceptions.create("Record_debug_test.A"); - -let B = /* @__PURE__ */Primitive_exceptions.create("Record_debug_test.B"); - -let v0 = { - RE_EXN_ID: A, - _1: 3 -}; - -let v1 = { - RE_EXN_ID: B, - _1: 3, - _2: 2 -}; - -let N = { - a: 0, - b: 1 -}; - -function N0_f(prim) { - return prim; -} - -let N0 = { - a: 0, - b: 1, - f: N0_f -}; - -console.log("hei", v); - -let a = [ - 1, - 2, - 2, - 4, - 3 -]; - -let c = [ - 1, - 2, - 3, - 4, - 5 -]; - -console.log(a, c); - -eq("File \"record_debug_test.res\", line 56, characters 3-10", [ - "", - "a" -], [ - "", - "a" -]); - -Mt.from_pair_suites("record_debug_test.res", suites.contents); - -let h = { - hd: 1, - tl: { - hd: 2, - tl: { - hd: 3, - tl: { - hd: 4, - tl: /* [] */0 - } - } - } -}; - -let v2 = { - NAME: "C", - VAL: 2 -}; - -let v3 = { - NAME: "C", - VAL: [ - 2, - 3 - ] -}; - -exports.suites = suites; -exports.test_id = test_id; -exports.eq = eq; -exports.v = v; -exports.u = u; -exports.h = h; -exports.A = A; -exports.B = B; -exports.v0 = v0; -exports.v1 = v1; -exports.v2 = v2; -exports.v3 = v3; -exports.N = N; -exports.N0 = N0; -exports.a = a; -exports.c = c; -/* Not a pure module */ diff --git a/tests/tests/src/record_debug_test.mjs b/tests/tests/src/record_debug_test.mjs new file mode 100644 index 0000000000..0ab7728101 --- /dev/null +++ b/tests/tests/src/record_debug_test.mjs @@ -0,0 +1,143 @@ +// Generated by ReScript, PLEASE EDIT WITH CARE + +import * as Mt from "./mt.mjs"; +import * as Primitive_exceptions from "rescript/lib/es6/Primitive_exceptions.js"; + +let suites = { + contents: /* [] */0 +}; + +let test_id = { + contents: 0 +}; + +function eq(loc, x, y) { + Mt.eq_suites(test_id, suites, loc, x, y); +} + +let v = { + a: 3, + b: { + xx: 2, + yy: 3 + } +}; + +let u_a = 2; + +let u_b = { + xx: 2, + yy: 3 +}; + +let u = { + a: u_a, + b: u_b +}; + +let A = /* @__PURE__ */Primitive_exceptions.create("Record_debug_test.A"); + +let B = /* @__PURE__ */Primitive_exceptions.create("Record_debug_test.B"); + +let v0 = { + RE_EXN_ID: A, + _1: 3 +}; + +let v1 = { + RE_EXN_ID: B, + _1: 3, + _2: 2 +}; + +let N = { + a: 0, + b: 1 +}; + +function N0_f(prim) { + return prim; +} + +let N0 = { + a: 0, + b: 1, + f: N0_f +}; + +console.log("hei", v); + +let a = [ + 1, + 2, + 2, + 4, + 3 +]; + +let c = [ + 1, + 2, + 3, + 4, + 5 +]; + +console.log(a, c); + +eq("File \"record_debug_test.res\", line 56, characters 3-10", [ + "", + "a" +], [ + "", + "a" +]); + +Mt.from_pair_suites("record_debug_test.res", suites.contents); + +let h = { + hd: 1, + tl: { + hd: 2, + tl: { + hd: 3, + tl: { + hd: 4, + tl: /* [] */0 + } + } + } +}; + +let v2 = { + NAME: "C", + VAL: 2 +}; + +let v3 = { + NAME: "C", + VAL: [ + 2, + 3 + ] +}; + +export { + suites, + test_id, + eq, + v, + u, + h, + A, + B, + v0, + v1, + v2, + v3, + N, + N0, + a, + c, +} +/* Not a pure module */ diff --git a/tests/tests/src/record_extension_test.js b/tests/tests/src/record_extension_test.js deleted file mode 100644 index 395ad3e321..0000000000 --- a/tests/tests/src/record_extension_test.js +++ /dev/null @@ -1,149 +0,0 @@ -// Generated by ReScript, PLEASE EDIT WITH CARE -'use strict'; - -let Mt = require("./mt.js"); -let Belt_Int = require("rescript/lib/js/Belt_Int.js"); -let Primitive_exceptions = require("rescript/lib/js/Primitive_exceptions.js"); - -let suites = { - contents: /* [] */0 -}; - -let test_id = { - contents: 0 -}; - -function eq(loc, x, y) { - Mt.eq_suites(test_id, suites, loc, x, y); -} - -let Inline_record = /* @__PURE__ */Primitive_exceptions.create("Record_extension_test.Inline_record"); - -let SinglePayload = /* @__PURE__ */Primitive_exceptions.create("Record_extension_test.SinglePayload"); - -let TuplePayload = /* @__PURE__ */Primitive_exceptions.create("Record_extension_test.TuplePayload"); - -function f(x) { - if (x.RE_EXN_ID === Inline_record) { - let y = Belt_Int.fromString(x.y); - if (y !== undefined) { - return x.x + y | 0; - } else { - return; - } - } - if (x.RE_EXN_ID === SinglePayload) { - return Belt_Int.fromString(x._1); - } - if (x.RE_EXN_ID !== TuplePayload) { - return; - } - let v1 = Belt_Int.fromString(x._2); - if (v1 !== undefined) { - return x._1 + v1 | 0; - } - -} - -eq("File \"record_extension_test.res\", line 26, characters 3-10", f({ - RE_EXN_ID: Inline_record, - x: 3, - y: "4" -}), 7); - -eq("File \"record_extension_test.res\", line 27, characters 3-10", f({ - RE_EXN_ID: SinglePayload, - _1: "1" -}), 1); - -eq("File \"record_extension_test.res\", line 28, characters 3-10", f({ - RE_EXN_ID: TuplePayload, - _1: 1, - _2: "2" -}), 3); - -function f2(x) { - if (typeof x !== "object" || x.TAG !== "C") { - return 0; - } else { - return x.x; - } -} - -function f2_with(x) { - if (typeof x !== "object" || x.TAG !== "C") { - return x; - } else { - return { - TAG: "C", - x: 0, - y: x.y - }; - } -} - -let A = /* @__PURE__ */Primitive_exceptions.create("Record_extension_test.A"); - -let B = /* @__PURE__ */Primitive_exceptions.create("Record_extension_test.B"); - -let C = /* @__PURE__ */Primitive_exceptions.create("Record_extension_test.C"); - -function u(f) { - try { - return f(); - } catch (raw_x) { - let x = Primitive_exceptions.internalToException(raw_x); - if (x.RE_EXN_ID === A) { - return x.name + x.x | 0; - } else if (x.RE_EXN_ID === B) { - return x._1 + x._2 | 0; - } else if (x.RE_EXN_ID === C) { - return x.name; - } else { - return -1; - } - } -} - -eq("File \"record_extension_test.res\", line 65, characters 3-10", u(() => { - throw { - RE_EXN_ID: A, - name: 1, - x: 1, - Error: new Error() - }; -}), 2); - -eq("File \"record_extension_test.res\", line 66, characters 3-10", u(() => { - throw { - RE_EXN_ID: B, - _1: 1, - _2: 2, - Error: new Error() - }; -}), 3); - -eq("File \"record_extension_test.res\", line 67, characters 3-10", u(() => { - throw { - RE_EXN_ID: C, - name: 4, - Error: new Error() - }; -}), 4); - -Mt.from_pair_suites("File \"record_extension_test.res\", line 69, characters 29-36", suites.contents); - -exports.suites = suites; -exports.test_id = test_id; -exports.eq = eq; -exports.Inline_record = Inline_record; -exports.SinglePayload = SinglePayload; -exports.TuplePayload = TuplePayload; -exports.f = f; -exports.f2 = f2; -exports.f2_with = f2_with; -exports.A = A; -exports.B = B; -exports.C = C; -exports.u = u; -/* Not a pure module */ diff --git a/tests/tests/src/record_extension_test.mjs b/tests/tests/src/record_extension_test.mjs new file mode 100644 index 0000000000..08fc2ba78f --- /dev/null +++ b/tests/tests/src/record_extension_test.mjs @@ -0,0 +1,150 @@ +// Generated by ReScript, PLEASE EDIT WITH CARE + +import * as Mt from "./mt.mjs"; +import * as Belt_Int from "rescript/lib/es6/Belt_Int.js"; +import * as Primitive_exceptions from "rescript/lib/es6/Primitive_exceptions.js"; + +let suites = { + contents: /* [] */0 +}; + +let test_id = { + contents: 0 +}; + +function eq(loc, x, y) { + Mt.eq_suites(test_id, suites, loc, x, y); +} + +let Inline_record = /* @__PURE__ */Primitive_exceptions.create("Record_extension_test.Inline_record"); + +let SinglePayload = /* @__PURE__ */Primitive_exceptions.create("Record_extension_test.SinglePayload"); + +let TuplePayload = /* @__PURE__ */Primitive_exceptions.create("Record_extension_test.TuplePayload"); + +function f(x) { + if (x.RE_EXN_ID === Inline_record) { + let y = Belt_Int.fromString(x.y); + if (y !== undefined) { + return x.x + y | 0; + } else { + return; + } + } + if (x.RE_EXN_ID === SinglePayload) { + return Belt_Int.fromString(x._1); + } + if (x.RE_EXN_ID !== TuplePayload) { + return; + } + let v1 = Belt_Int.fromString(x._2); + if (v1 !== undefined) { + return x._1 + v1 | 0; + } + +} + +eq("File \"record_extension_test.res\", line 26, characters 3-10", f({ + RE_EXN_ID: Inline_record, + x: 3, + y: "4" +}), 7); + +eq("File \"record_extension_test.res\", line 27, characters 3-10", f({ + RE_EXN_ID: SinglePayload, + _1: "1" +}), 1); + +eq("File \"record_extension_test.res\", line 28, characters 3-10", f({ + RE_EXN_ID: TuplePayload, + _1: 1, + _2: "2" +}), 3); + +function f2(x) { + if (typeof x !== "object" || x.TAG !== "C") { + return 0; + } else { + return x.x; + } +} + +function f2_with(x) { + if (typeof x !== "object" || x.TAG !== "C") { + return x; + } else { + return { + TAG: "C", + x: 0, + y: x.y + }; + } +} + +let A = /* @__PURE__ */Primitive_exceptions.create("Record_extension_test.A"); + +let B = /* @__PURE__ */Primitive_exceptions.create("Record_extension_test.B"); + +let C = /* @__PURE__ */Primitive_exceptions.create("Record_extension_test.C"); + +function u(f) { + try { + return f(); + } catch (raw_x) { + let x = Primitive_exceptions.internalToException(raw_x); + if (x.RE_EXN_ID === A) { + return x.name + x.x | 0; + } else if (x.RE_EXN_ID === B) { + return x._1 + x._2 | 0; + } else if (x.RE_EXN_ID === C) { + return x.name; + } else { + return -1; + } + } +} + +eq("File \"record_extension_test.res\", line 65, characters 3-10", u(() => { + throw { + RE_EXN_ID: A, + name: 1, + x: 1, + Error: new Error() + }; +}), 2); + +eq("File \"record_extension_test.res\", line 66, characters 3-10", u(() => { + throw { + RE_EXN_ID: B, + _1: 1, + _2: 2, + Error: new Error() + }; +}), 3); + +eq("File \"record_extension_test.res\", line 67, characters 3-10", u(() => { + throw { + RE_EXN_ID: C, + name: 4, + Error: new Error() + }; +}), 4); + +Mt.from_pair_suites("File \"record_extension_test.res\", line 69, characters 29-36", suites.contents); + +export { + suites, + test_id, + eq, + Inline_record, + SinglePayload, + TuplePayload, + f, + f2, + f2_with, + A, + B, + C, + u, +} +/* Not a pure module */ diff --git a/tests/tests/src/record_name_test.js b/tests/tests/src/record_name_test.js deleted file mode 100644 index df9245bcb9..0000000000 --- a/tests/tests/src/record_name_test.js +++ /dev/null @@ -1,52 +0,0 @@ -// Generated by ReScript, PLEASE EDIT WITH CARE -'use strict'; - - -function f(x) { - return { - THIS_IS_NOT_EXPRESSIBLE_IN_BUCKLE: x - }; -} - -function set(x) { - x.THIS_IS_NOT_EXPRESSIBLE_IN_BUCKLE = 3; - return (x.THIS_IS_NOT_EXPRESSIBLE_IN_BUCKLE << 1); -} - -function f1(u) { - return u.x.x.x.y; -} - -function f2(x) { - x["x'"] = x["x'"] + 3 | 0; - return { - "x'": x["x'"] + 3 | 0 - }; -} - -function f3(x) { - x.in = x.in + 3 | 0; - return { - in: x.in + 3 | 0 - }; -} - -function f4(param) { - return (((param.EXACT_MAPPING_TO_JS_LABEL + param.EXACT_2 | 0) + param.z.hello | 0) << 1); -} - -function u() { - return { - x: 22, - h: 3 - }; -} - -exports.f = f; -exports.set = set; -exports.f1 = f1; -exports.f2 = f2; -exports.f3 = f3; -exports.f4 = f4; -exports.u = u; -/* No side effect */ diff --git a/tests/tests/src/record_name_test.mjs b/tests/tests/src/record_name_test.mjs new file mode 100644 index 0000000000..80ec9615be --- /dev/null +++ b/tests/tests/src/record_name_test.mjs @@ -0,0 +1,53 @@ +// Generated by ReScript, PLEASE EDIT WITH CARE + + +function f(x) { + return { + THIS_IS_NOT_EXPRESSIBLE_IN_BUCKLE: x + }; +} + +function set(x) { + x.THIS_IS_NOT_EXPRESSIBLE_IN_BUCKLE = 3; + return (x.THIS_IS_NOT_EXPRESSIBLE_IN_BUCKLE << 1); +} + +function f1(u) { + return u.x.x.x.y; +} + +function f2(x) { + x["x'"] = x["x'"] + 3 | 0; + return { + "x'": x["x'"] + 3 | 0 + }; +} + +function f3(x) { + x.in = x.in + 3 | 0; + return { + in: x.in + 3 | 0 + }; +} + +function f4(param) { + return (((param.EXACT_MAPPING_TO_JS_LABEL + param.EXACT_2 | 0) + param.z.hello | 0) << 1); +} + +function u() { + return { + x: 22, + h: 3 + }; +} + +export { + f, + set, + f1, + f2, + f3, + f4, + u, +} +/* No side effect */ diff --git a/tests/tests/src/record_regression.js b/tests/tests/src/record_regression.js deleted file mode 100644 index 74d349853e..0000000000 --- a/tests/tests/src/record_regression.js +++ /dev/null @@ -1,292 +0,0 @@ -// Generated by ReScript, PLEASE EDIT WITH CARE -'use strict'; - -let Primitive_option = require("rescript/lib/js/Primitive_option.js"); - -let f1 = { - x: 3, - z: 2 -}; - -let newrecord = {...f1}; - -newrecord.y = 3; - -let newrecord$1 = {...newrecord}; - -newrecord$1.yy = Primitive_option.some(undefined); - -let theseTwoShouldBeIdentical = [ - newrecord$1.yy, - Primitive_option.some(undefined) -]; - -let v = { - x: 2, - z: 3 -}; - -let newrecord$2 = {...v}; - -newrecord$2.y1 = 22; - -let v1 = { - x: 2, - z: 3 -}; - -let newrecord$3 = {...v1}; - -newrecord$3.y1 = 22; - -function h11(v1) { - let newrecord = {...v1}; - newrecord.y1 = 22; - return newrecord; -} - -let po = { - aa: 3, - bb: 4 -}; - -let newrecord$4 = {...po}; - -newrecord$4.aa = undefined; - -function setAA(ao) { - return { - aa: ao - }; -} - -let ir0 = { - TAG: "V0", - x0: "v0", - x3: 3 -}; - -let ir1 = { - TAG: "V0", - x0: "v0", - x1: "v1", - x3: 3 -}; - -let ir2 = { - TAG: "V0", - x0: "v0", - x1: "v1", - x2: 2, - x3: 3 -}; - -let ir3 = { - TAG: "V1", - y0: "v0", - y1: 1 -}; - -let pm0; - -pm0 = ir0.TAG === "V0" ? [ - "v0", - 3 - ] : [ - "v0", - undefined - ]; - -let pm1; - -if (ir1.TAG === "V0") { - let x1 = "v1"; - let x0 = "v0"; - pm1 = x1 !== undefined ? [ - x0, - x1, - 3 - ] : [ - x0, - "n/a", - 3 - ]; -} else { - pm1 = [ - "v0", - "n/a", - "v1" - ]; -} - -let pm2; - -if (ir2.TAG === "V0") { - let x1$1 = "v1"; - let x0$1 = "v0"; - if (x1$1 !== undefined) { - let x2 = 2; - pm2 = x2 !== undefined ? [ - x0$1, - x1$1, - x2, - 3 - ] : [ - x0$1, - x1$1, - 0, - 3 - ]; - } else { - let x2$1 = 2; - pm2 = x2$1 !== undefined ? [ - x0$1, - "n/a", - x2$1, - 3 - ] : [ - x0$1, - "n/a", - 0, - 3 - ]; - } -} else { - pm2 = [ - "v0", - "n/a", - 0, - "v1" - ]; -} - -function inlinedRecord(ir) { - if (ir.TAG !== "V0") { - return [ - ir.y0, - "n/a", - 0, - ir.y1 - ]; - } - let x1 = ir.x1; - let x0 = ir.x0; - if (x1 !== undefined) { - switch (x1) { - case "x1" : - let x2 = ir.x2; - if (x2 !== undefined) { - return [ - x0, - "x1", - x2, - ir.x3 - ]; - } - break; - case "xx1" : - let x2$1 = ir.x2; - if (x2$1 !== undefined) { - return [ - x0, - "xx1", - x2$1, - ir.x3 - ]; - } - break; - } - let x2$2 = ir.x2; - if (x2$2 !== undefined) { - return [ - x0, - x1, - x2$2, - ir.x3 - ]; - } else { - return [ - x0, - x1, - 0, - ir.x3 - ]; - } - } - let x2$3 = ir.x2; - if (x2$3 !== undefined) { - return [ - x0, - "n/a", - x2$3, - ir.x3 - ]; - } else { - return [ - x0, - "n/a", - 0, - ir.x3 - ]; - } -} - -let pm3 = inlinedRecord(ir2); - -let pm4 = inlinedRecord(ir3); - -let f2 = { - x: 3, - y: 3, - z: 3 -}; - -let f3 = newrecord; - -let f4 = newrecord$1; - -let v2 = { - x: 3, - y: undefined, - z: 2 -}; - -let h = newrecord$2; - -let h10 = newrecord$3; - -let ir4 = { - TAG: "V0", - x: 3 -}; - -let ir5 = { - TAG: "V0" -}; - -exports.f1 = f1; -exports.f2 = f2; -exports.f3 = f3; -exports.f4 = f4; -exports.theseTwoShouldBeIdentical = theseTwoShouldBeIdentical; -exports.v2 = v2; -exports.v = v; -exports.h = h; -exports.v1 = v1; -exports.h10 = h10; -exports.h11 = h11; -exports.po = po; -exports.setAA = setAA; -exports.ir0 = ir0; -exports.ir1 = ir1; -exports.ir2 = ir2; -exports.ir3 = ir3; -exports.pm0 = pm0; -exports.pm1 = pm1; -exports.pm2 = pm2; -exports.inlinedRecord = inlinedRecord; -exports.pm3 = pm3; -exports.pm4 = pm4; -exports.ir4 = ir4; -exports.ir5 = ir5; -/* Not a pure module */ diff --git a/tests/tests/src/record_regression.mjs b/tests/tests/src/record_regression.mjs new file mode 100644 index 0000000000..f936ef2908 --- /dev/null +++ b/tests/tests/src/record_regression.mjs @@ -0,0 +1,293 @@ +// Generated by ReScript, PLEASE EDIT WITH CARE + +import * as Primitive_option from "rescript/lib/es6/Primitive_option.js"; + +let f1 = { + x: 3, + z: 2 +}; + +let newrecord = {...f1}; + +newrecord.y = 3; + +let newrecord$1 = {...newrecord}; + +newrecord$1.yy = Primitive_option.some(undefined); + +let theseTwoShouldBeIdentical = [ + newrecord$1.yy, + Primitive_option.some(undefined) +]; + +let v = { + x: 2, + z: 3 +}; + +let newrecord$2 = {...v}; + +newrecord$2.y1 = 22; + +let v1 = { + x: 2, + z: 3 +}; + +let newrecord$3 = {...v1}; + +newrecord$3.y1 = 22; + +function h11(v1) { + let newrecord = {...v1}; + newrecord.y1 = 22; + return newrecord; +} + +let po = { + aa: 3, + bb: 4 +}; + +let newrecord$4 = {...po}; + +newrecord$4.aa = undefined; + +function setAA(ao) { + return { + aa: ao + }; +} + +let ir0 = { + TAG: "V0", + x0: "v0", + x3: 3 +}; + +let ir1 = { + TAG: "V0", + x0: "v0", + x1: "v1", + x3: 3 +}; + +let ir2 = { + TAG: "V0", + x0: "v0", + x1: "v1", + x2: 2, + x3: 3 +}; + +let ir3 = { + TAG: "V1", + y0: "v0", + y1: 1 +}; + +let pm0; + +pm0 = ir0.TAG === "V0" ? [ + "v0", + 3 + ] : [ + "v0", + undefined + ]; + +let pm1; + +if (ir1.TAG === "V0") { + let x1 = "v1"; + let x0 = "v0"; + pm1 = x1 !== undefined ? [ + x0, + x1, + 3 + ] : [ + x0, + "n/a", + 3 + ]; +} else { + pm1 = [ + "v0", + "n/a", + "v1" + ]; +} + +let pm2; + +if (ir2.TAG === "V0") { + let x1$1 = "v1"; + let x0$1 = "v0"; + if (x1$1 !== undefined) { + let x2 = 2; + pm2 = x2 !== undefined ? [ + x0$1, + x1$1, + x2, + 3 + ] : [ + x0$1, + x1$1, + 0, + 3 + ]; + } else { + let x2$1 = 2; + pm2 = x2$1 !== undefined ? [ + x0$1, + "n/a", + x2$1, + 3 + ] : [ + x0$1, + "n/a", + 0, + 3 + ]; + } +} else { + pm2 = [ + "v0", + "n/a", + 0, + "v1" + ]; +} + +function inlinedRecord(ir) { + if (ir.TAG !== "V0") { + return [ + ir.y0, + "n/a", + 0, + ir.y1 + ]; + } + let x1 = ir.x1; + let x0 = ir.x0; + if (x1 !== undefined) { + switch (x1) { + case "x1" : + let x2 = ir.x2; + if (x2 !== undefined) { + return [ + x0, + "x1", + x2, + ir.x3 + ]; + } + break; + case "xx1" : + let x2$1 = ir.x2; + if (x2$1 !== undefined) { + return [ + x0, + "xx1", + x2$1, + ir.x3 + ]; + } + break; + } + let x2$2 = ir.x2; + if (x2$2 !== undefined) { + return [ + x0, + x1, + x2$2, + ir.x3 + ]; + } else { + return [ + x0, + x1, + 0, + ir.x3 + ]; + } + } + let x2$3 = ir.x2; + if (x2$3 !== undefined) { + return [ + x0, + "n/a", + x2$3, + ir.x3 + ]; + } else { + return [ + x0, + "n/a", + 0, + ir.x3 + ]; + } +} + +let pm3 = inlinedRecord(ir2); + +let pm4 = inlinedRecord(ir3); + +let f2 = { + x: 3, + y: 3, + z: 3 +}; + +let f3 = newrecord; + +let f4 = newrecord$1; + +let v2 = { + x: 3, + y: undefined, + z: 2 +}; + +let h = newrecord$2; + +let h10 = newrecord$3; + +let ir4 = { + TAG: "V0", + x: 3 +}; + +let ir5 = { + TAG: "V0" +}; + +export { + f1, + f2, + f3, + f4, + theseTwoShouldBeIdentical, + v2, + v, + h, + v1, + h10, + h11, + po, + setAA, + ir0, + ir1, + ir2, + ir3, + pm0, + pm1, + pm2, + inlinedRecord, + pm3, + pm4, + ir4, + ir5, +} +/* Not a pure module */ diff --git a/tests/tests/src/record_type_spread.js b/tests/tests/src/record_type_spread.js deleted file mode 100644 index 3a024b12e2..0000000000 --- a/tests/tests/src/record_type_spread.js +++ /dev/null @@ -1,51 +0,0 @@ -// Generated by ReScript, PLEASE EDIT WITH CARE -'use strict'; - - -function getY(v) { - return v.y; -} - -function getX(v) { - return v.x; -} - -let DeepSub = { - d: { - x: { - TAG: "Ok", - _0: 1 - }, - z: { - NAME: "Two", - VAL: 1 - } - } -}; - -let v = { - y: 3, - x: 3 -}; - -let d = { - a: "", - b: 1, - c: undefined, - d: { - TAG: "Ok", - _0: 1 - } -}; - -let x = { - c: "hello" -}; - -exports.getY = getY; -exports.getX = getX; -exports.v = v; -exports.d = d; -exports.x = x; -exports.DeepSub = DeepSub; -/* No side effect */ diff --git a/tests/tests/src/record_type_spread.mjs b/tests/tests/src/record_type_spread.mjs new file mode 100644 index 0000000000..e13971b417 --- /dev/null +++ b/tests/tests/src/record_type_spread.mjs @@ -0,0 +1,52 @@ +// Generated by ReScript, PLEASE EDIT WITH CARE + + +function getY(v) { + return v.y; +} + +function getX(v) { + return v.x; +} + +let DeepSub = { + d: { + x: { + TAG: "Ok", + _0: 1 + }, + z: { + NAME: "Two", + VAL: 1 + } + } +}; + +let v = { + y: 3, + x: 3 +}; + +let d = { + a: "", + b: 1, + c: undefined, + d: { + TAG: "Ok", + _0: 1 + } +}; + +let x = { + c: "hello" +}; + +export { + getY, + getX, + v, + d, + x, + DeepSub, +} +/* No side effect */ diff --git a/tests/tests/src/record_with_test.js b/tests/tests/src/record_with_test.js deleted file mode 100644 index 174a4a9d9d..0000000000 --- a/tests/tests/src/record_with_test.js +++ /dev/null @@ -1,70 +0,0 @@ -// Generated by ReScript, PLEASE EDIT WITH CARE -'use strict'; - -let Mt = require("./mt.js"); - -let v = { - syntax: undefined, - imports: 0, - file_options: 0, - package: 0, - messages: 0, - enums: 0, - extends: 0 -}; - -let u_v = { - syntax: undefined, - imports: 0, - file_options: 0, - package: 0, - messages: 0, - enums: 0, - extends: 0 -}; - -function f(g, h) { - let init = g(h); - return { - syntax: init.syntax, - imports: 0, - file_options: init.file_options, - package: init.package, - messages: init.messages, - enums: init.enums, - extends: init.extends - }; -} - -let suites_0 = [ - "eq_with", - param => ({ - TAG: "Eq", - _0: v, - _1: u_v - }) -]; - -let suites = { - hd: suites_0, - tl: /* [] */0 -}; - -Mt.from_pair_suites("Record_with_test", suites); - -let uv = { - syntax: undefined, - imports: 1, - file_options: 0, - package: 0, - messages: 0, - enums: 0, - extends: 0 -}; - -exports.v = v; -exports.uv = uv; -exports.u_v = u_v; -exports.f = f; -exports.suites = suites; -/* Not a pure module */ diff --git a/tests/tests/src/record_with_test.mjs b/tests/tests/src/record_with_test.mjs new file mode 100644 index 0000000000..630c776259 --- /dev/null +++ b/tests/tests/src/record_with_test.mjs @@ -0,0 +1,71 @@ +// Generated by ReScript, PLEASE EDIT WITH CARE + +import * as Mt from "./mt.mjs"; + +let v = { + syntax: undefined, + imports: 0, + file_options: 0, + package: 0, + messages: 0, + enums: 0, + extends: 0 +}; + +let u_v = { + syntax: undefined, + imports: 0, + file_options: 0, + package: 0, + messages: 0, + enums: 0, + extends: 0 +}; + +function f(g, h) { + let init = g(h); + return { + syntax: init.syntax, + imports: 0, + file_options: init.file_options, + package: init.package, + messages: init.messages, + enums: init.enums, + extends: init.extends + }; +} + +let suites_0 = [ + "eq_with", + param => ({ + TAG: "Eq", + _0: v, + _1: u_v + }) +]; + +let suites = { + hd: suites_0, + tl: /* [] */0 +}; + +Mt.from_pair_suites("Record_with_test", suites); + +let uv = { + syntax: undefined, + imports: 1, + file_options: 0, + package: 0, + messages: 0, + enums: 0, + extends: 0 +}; + +export { + v, + uv, + u_v, + f, + suites, +} +/* Not a pure module */ diff --git a/tests/tests/src/recursive_module.js b/tests/tests/src/recursive_module.js deleted file mode 100644 index 56d78243d7..0000000000 --- a/tests/tests/src/recursive_module.js +++ /dev/null @@ -1,195 +0,0 @@ -// Generated by ReScript, PLEASE EDIT WITH CARE -'use strict'; - -let Mt = require("./mt.js"); -let Lazy = require("rescript/lib/js/Lazy.js"); -let Primitive_module = require("rescript/lib/js/Primitive_module.js"); -let Primitive_exceptions = require("rescript/lib/js/Primitive_exceptions.js"); - -let suites = { - contents: /* [] */0 -}; - -let test_id = { - contents: 0 -}; - -function eq(loc, x, y) { - Mt.eq_suites(test_id, suites, loc, x, y); -} - -let Xx = { - f: (prim0, prim1) => hfiehi(prim0, prim1) -}; - -let Int3 = Primitive_module.init([ - "recursive_module.res", - 25, - 4 -], { - TAG: "Module", - _0: [[ - "Function", - "u" - ]] -}); - -Primitive_module.update({ - TAG: "Module", - _0: [[ - "Function", - "u" - ]] -}, Int3, Int3); - -let Inta = Primitive_module.init([ - "recursive_module.res", - 29, - 4 -], { - TAG: "Module", - _0: [[ - "Lazy", - "a" - ]] -}); - -let Intb = Primitive_module.init([ - "recursive_module.res", - 34, - 4 -], { - TAG: "Module", - _0: [[ - "Lazy", - "a" - ]] -}); - -let a = Lazy.from_fun(() => Lazy.force(Intb.a)); - -Primitive_module.update({ - TAG: "Module", - _0: [[ - "Lazy", - "a" - ]] -}, Inta, { - a: a -}); - -let a$1 = Lazy.from_fun(() => Lazy.force(Inta.a) + 1 | 0); - -Primitive_module.update({ - TAG: "Module", - _0: [[ - "Lazy", - "a" - ]] -}, Intb, { - a: a$1 -}); - -let tmp; - -try { - tmp = Lazy.force(Intb.a); -} catch (raw_exn) { - let exn = Primitive_exceptions.internalToException(raw_exn); - if (exn.RE_EXN_ID === Lazy.Undefined) { - tmp = -1; - } else { - throw exn; - } -} - -eq("File \"recursive_module.res\", line 39, characters 2-9", -1, tmp); - -let Inta$1 = Primitive_module.init([ - "recursive_module.res", - 49, - 6 -], { - TAG: "Module", - _0: [[ - "Lazy", - "a" - ]] -}); - -let Intb$1 = Primitive_module.init([ - "recursive_module.res", - 54, - 6 -], { - TAG: "Module", - _0: [[ - "Lazy", - "a" - ]] -}); - -let a$2 = Lazy.from_fun(() => Lazy.force(Intb$1.a) + 1 | 0); - -Primitive_module.update({ - TAG: "Module", - _0: [[ - "Lazy", - "a" - ]] -}, Inta$1, { - a: a$2 -}); - -let a$3 = Lazy.from_fun(() => 2); - -Primitive_module.update({ - TAG: "Module", - _0: [[ - "Lazy", - "a" - ]] -}, Intb$1, { - a: a$3 -}); - -let A = { - Inta: Inta$1, - Intb: Intb$1 -}; - -eq("File \"recursive_module.res\", line 59, characters 3-10", Lazy.force(Inta$1.a), 3); - -let tmp$1; - -try { - Int3.u(3); - tmp$1 = 3; -} catch (raw_exn$1) { - let exn$1 = Primitive_exceptions.internalToException(raw_exn$1); - if (exn$1.RE_EXN_ID === "Undefined_recursive_module") { - tmp$1 = 4; - } else { - throw exn$1; - } -} - -eq("File \"recursive_module.res\", line 62, characters 2-9", 4, tmp$1); - -Mt.from_pair_suites("Recursive_module", suites.contents); - -let Int32; - -let uuu = Xx.f; - -exports.suites = suites; -exports.test_id = test_id; -exports.eq = eq; -exports.Int32 = Int32; -exports.Xx = Xx; -exports.uuu = uuu; -exports.Int3 = Int3; -exports.Inta = Inta; -exports.Intb = Intb; -exports.A = A; -/* Int3 Not a pure module */ diff --git a/tests/tests/src/recursive_module.mjs b/tests/tests/src/recursive_module.mjs new file mode 100644 index 0000000000..e2bb2a6fb3 --- /dev/null +++ b/tests/tests/src/recursive_module.mjs @@ -0,0 +1,196 @@ +// Generated by ReScript, PLEASE EDIT WITH CARE + +import * as Mt from "./mt.mjs"; +import * as Lazy from "rescript/lib/es6/Lazy.js"; +import * as Primitive_module from "rescript/lib/es6/Primitive_module.js"; +import * as Primitive_exceptions from "rescript/lib/es6/Primitive_exceptions.js"; + +let suites = { + contents: /* [] */0 +}; + +let test_id = { + contents: 0 +}; + +function eq(loc, x, y) { + Mt.eq_suites(test_id, suites, loc, x, y); +} + +let Xx = { + f: (prim0, prim1) => hfiehi(prim0, prim1) +}; + +let Int3 = Primitive_module.init([ + "recursive_module.res", + 25, + 4 +], { + TAG: "Module", + _0: [[ + "Function", + "u" + ]] +}); + +Primitive_module.update({ + TAG: "Module", + _0: [[ + "Function", + "u" + ]] +}, Int3, Int3); + +let Inta = Primitive_module.init([ + "recursive_module.res", + 29, + 4 +], { + TAG: "Module", + _0: [[ + "Lazy", + "a" + ]] +}); + +let Intb = Primitive_module.init([ + "recursive_module.res", + 34, + 4 +], { + TAG: "Module", + _0: [[ + "Lazy", + "a" + ]] +}); + +let a = Lazy.from_fun(() => Lazy.force(Intb.a)); + +Primitive_module.update({ + TAG: "Module", + _0: [[ + "Lazy", + "a" + ]] +}, Inta, { + a: a +}); + +let a$1 = Lazy.from_fun(() => Lazy.force(Inta.a) + 1 | 0); + +Primitive_module.update({ + TAG: "Module", + _0: [[ + "Lazy", + "a" + ]] +}, Intb, { + a: a$1 +}); + +let tmp; + +try { + tmp = Lazy.force(Intb.a); +} catch (raw_exn) { + let exn = Primitive_exceptions.internalToException(raw_exn); + if (exn.RE_EXN_ID === Lazy.Undefined) { + tmp = -1; + } else { + throw exn; + } +} + +eq("File \"recursive_module.res\", line 39, characters 2-9", -1, tmp); + +let Inta$1 = Primitive_module.init([ + "recursive_module.res", + 49, + 6 +], { + TAG: "Module", + _0: [[ + "Lazy", + "a" + ]] +}); + +let Intb$1 = Primitive_module.init([ + "recursive_module.res", + 54, + 6 +], { + TAG: "Module", + _0: [[ + "Lazy", + "a" + ]] +}); + +let a$2 = Lazy.from_fun(() => Lazy.force(Intb$1.a) + 1 | 0); + +Primitive_module.update({ + TAG: "Module", + _0: [[ + "Lazy", + "a" + ]] +}, Inta$1, { + a: a$2 +}); + +let a$3 = Lazy.from_fun(() => 2); + +Primitive_module.update({ + TAG: "Module", + _0: [[ + "Lazy", + "a" + ]] +}, Intb$1, { + a: a$3 +}); + +let A = { + Inta: Inta$1, + Intb: Intb$1 +}; + +eq("File \"recursive_module.res\", line 59, characters 3-10", Lazy.force(Inta$1.a), 3); + +let tmp$1; + +try { + Int3.u(3); + tmp$1 = 3; +} catch (raw_exn$1) { + let exn$1 = Primitive_exceptions.internalToException(raw_exn$1); + if (exn$1.RE_EXN_ID === "Undefined_recursive_module") { + tmp$1 = 4; + } else { + throw exn$1; + } +} + +eq("File \"recursive_module.res\", line 62, characters 2-9", 4, tmp$1); + +Mt.from_pair_suites("Recursive_module", suites.contents); + +let Int32; + +let uuu = Xx.f; + +export { + suites, + test_id, + eq, + Int32, + Xx, + uuu, + Int3, + Inta, + Intb, + A, +} +/* Int3 Not a pure module */ diff --git a/tests/tests/src/recursive_module_test.js b/tests/tests/src/recursive_module_test.js deleted file mode 100644 index b3ab42cb56..0000000000 --- a/tests/tests/src/recursive_module_test.js +++ /dev/null @@ -1,114 +0,0 @@ -// Generated by ReScript, PLEASE EDIT WITH CARE -'use strict'; - -let Mt = require("./mt.js"); -let Primitive_module = require("rescript/lib/js/Primitive_module.js"); - -let suites = { - contents: /* [] */0 -}; - -let test_id = { - contents: 0 -}; - -function eq(loc, x, y) { - test_id.contents = test_id.contents + 1 | 0; - suites.contents = { - hd: [ - loc + (" id " + test_id.contents.toString()), - () => ({ - TAG: "Eq", - _0: x, - _1: y - }) - ], - tl: suites.contents - }; -} - -function add(suite) { - suites.contents = { - hd: suite, - tl: suites.contents - }; -} - -let Int3 = Primitive_module.init([ - "recursive_module_test.res", - 15, - 4 -], { - TAG: "Module", - _0: [[ - "Function", - "u" - ]] -}); - -Primitive_module.update({ - TAG: "Module", - _0: [[ - "Function", - "u" - ]] -}, Int3, Int3); - -let M = Primitive_module.init([ - "recursive_module_test.res", - 21, - 20 -], { - TAG: "Module", - _0: [[ - "Function", - "fact" - ]] -}); - -function fact(n) { - if (n <= 1) { - return 1; - } else { - return Math.imul(n, M.fact(n - 1 | 0)); - } -} - -Primitive_module.update({ - TAG: "Module", - _0: [[ - "Function", - "fact" - ]] -}, M, { - fact: fact -}); - -let fact$1 = M.fact; - -let Fact = { - M: M, - fact: fact$1 -}; - -eq("File \"recursive_module_test.res\", line 32, characters 12-19", 120, fact$1(5)); - -add([ - "File \"recursive_module_test.res\", line 34, characters 14-21", - () => ({ - TAG: "ThrowAny", - _0: () => { - Int3.u(3); - } - }) -]); - -Mt.from_pair_suites("Recursive_module_test", suites.contents); - -exports.suites = suites; -exports.test_id = test_id; -exports.eq = eq; -exports.add = add; -exports.Int3 = Int3; -exports.Fact = Fact; -/* Int3 Not a pure module */ diff --git a/tests/tests/src/recursive_module_test.mjs b/tests/tests/src/recursive_module_test.mjs new file mode 100644 index 0000000000..1d2b18e5f6 --- /dev/null +++ b/tests/tests/src/recursive_module_test.mjs @@ -0,0 +1,115 @@ +// Generated by ReScript, PLEASE EDIT WITH CARE + +import * as Mt from "./mt.mjs"; +import * as Primitive_module from "rescript/lib/es6/Primitive_module.js"; + +let suites = { + contents: /* [] */0 +}; + +let test_id = { + contents: 0 +}; + +function eq(loc, x, y) { + test_id.contents = test_id.contents + 1 | 0; + suites.contents = { + hd: [ + loc + (" id " + test_id.contents.toString()), + () => ({ + TAG: "Eq", + _0: x, + _1: y + }) + ], + tl: suites.contents + }; +} + +function add(suite) { + suites.contents = { + hd: suite, + tl: suites.contents + }; +} + +let Int3 = Primitive_module.init([ + "recursive_module_test.res", + 15, + 4 +], { + TAG: "Module", + _0: [[ + "Function", + "u" + ]] +}); + +Primitive_module.update({ + TAG: "Module", + _0: [[ + "Function", + "u" + ]] +}, Int3, Int3); + +let M = Primitive_module.init([ + "recursive_module_test.res", + 21, + 20 +], { + TAG: "Module", + _0: [[ + "Function", + "fact" + ]] +}); + +function fact(n) { + if (n <= 1) { + return 1; + } else { + return Math.imul(n, M.fact(n - 1 | 0)); + } +} + +Primitive_module.update({ + TAG: "Module", + _0: [[ + "Function", + "fact" + ]] +}, M, { + fact: fact +}); + +let fact$1 = M.fact; + +let Fact = { + M: M, + fact: fact$1 +}; + +eq("File \"recursive_module_test.res\", line 32, characters 12-19", 120, fact$1(5)); + +add([ + "File \"recursive_module_test.res\", line 34, characters 14-21", + () => ({ + TAG: "ThrowAny", + _0: () => { + Int3.u(3); + } + }) +]); + +Mt.from_pair_suites("Recursive_module_test", suites.contents); + +export { + suites, + test_id, + eq, + add, + Int3, + Fact, +} +/* Int3 Not a pure module */ diff --git a/tests/tests/src/recursive_react_component.js b/tests/tests/src/recursive_react_component.js deleted file mode 100644 index b90857cf2b..0000000000 --- a/tests/tests/src/recursive_react_component.js +++ /dev/null @@ -1,13 +0,0 @@ -// Generated by ReScript, PLEASE EDIT WITH CARE -'use strict'; - -let React = require("react"); - -function make(props) { - return React.createElement(make, { - foo: props.foo - }); -} - -exports.make = make; -/* react Not a pure module */ diff --git a/tests/tests/src/recursive_react_component.mjs b/tests/tests/src/recursive_react_component.mjs new file mode 100644 index 0000000000..554e87ec77 --- /dev/null +++ b/tests/tests/src/recursive_react_component.mjs @@ -0,0 +1,14 @@ +// Generated by ReScript, PLEASE EDIT WITH CARE + +import * as React from "react"; + +function make(props) { + return React.createElement(make, { + foo: props.foo + }); +} + +export { + make, +} +/* react Not a pure module */ diff --git a/tests/tests/src/recursive_records_test.js b/tests/tests/src/recursive_records_test.js deleted file mode 100644 index 4192b487a3..0000000000 --- a/tests/tests/src/recursive_records_test.js +++ /dev/null @@ -1,123 +0,0 @@ -// Generated by ReScript, PLEASE EDIT WITH CARE -'use strict'; - -let Mt = require("./mt.js"); -let Belt_List = require("rescript/lib/js/Belt_List.js"); -let Primitive_object = require("rescript/lib/js/Primitive_object.js"); - -let suites = { - contents: /* [] */0 -}; - -let test_id = { - contents: 0 -}; - -function eq(loc, x, y) { - Mt.eq_suites(test_id, suites, loc, x, y); -} - -let rec_cell = {}; - -rec_cell.content = 3; - -rec_cell.next = rec_cell; - -function f0(x) { - let rec_cell = {}; - Primitive_object.updateDummy(rec_cell, { - content: Math.imul(x, x) - 6 | 0, - next: rec_cell - }); - return rec_cell; -} - -function a0(x) { - return (x.content + x.next.content | 0) + x.next.next.content | 0; -} - -eq("File \"recursive_records_test.res\", line 26, characters 5-12", a0(rec_cell), 9); - -eq("File \"recursive_records_test.res\", line 27, characters 5-12", a0(f0(3)), 9); - -let rec_cell2 = {}; - -rec_cell2.content = 3; - -rec_cell2.next = rec_cell2; - -function f2(x) { - let rec_cell2 = {}; - Primitive_object.updateDummy(rec_cell2, { - TAG: "Cons", - content: Math.imul(x, x) - 6 | 0, - next: rec_cell2 - }); - return rec_cell2; -} - -function hd(x) { - if (typeof x !== "object") { - return 0; - } else { - return x.content; - } -} - -function tl_exn(x) { - if (typeof x === "object") { - return x.next; - } - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "recursive_records_test.res", - 49, - 11 - ], - Error: new Error() - }; -} - -eq("File \"recursive_records_test.res\", line 54, characters 5-12", (hd(rec_cell2) + hd(tl_exn(rec_cell2)) | 0) + hd(tl_exn(tl_exn(rec_cell2))) | 0, 9); - -let rec_cell2$1 = f2(3); - -eq("File \"recursive_records_test.res\", line 56, characters 5-12", (hd(rec_cell2$1) + hd(tl_exn(rec_cell2$1)) | 0) + hd(tl_exn(tl_exn(rec_cell2$1))) | 0, 9); - -let rec_cell3 = {}; - -rec_cell3.hd = 3; - -rec_cell3.tl = rec_cell3; - -function f3(x) { - let rec_cell3 = {}; - Primitive_object.updateDummy(rec_cell3, { - hd: Math.imul(x, x) - 6 | 0, - tl: rec_cell3 - }); - return rec_cell3; -} - -eq("File \"recursive_records_test.res\", line 68, characters 4-11", (Belt_List.headExn(rec_cell3) + Belt_List.headExn(Belt_List.tailExn(rec_cell3)) | 0) + Belt_List.headExn(Belt_List.tailExn(Belt_List.tailExn(rec_cell3))) | 0, 9); - -let rec_cell3$1 = f3(3); - -eq("File \"recursive_records_test.res\", line 78, characters 4-11", (Belt_List.headExn(rec_cell3$1) + Belt_List.headExn(Belt_List.tailExn(rec_cell3$1)) | 0) + Belt_List.headExn(Belt_List.tailExn(Belt_List.tailExn(rec_cell3$1))) | 0, 9); - -Mt.from_pair_suites("recursive_records_test.res", suites.contents); - -exports.suites = suites; -exports.test_id = test_id; -exports.eq = eq; -exports.rec_cell = rec_cell; -exports.f0 = f0; -exports.a0 = a0; -exports.rec_cell2 = rec_cell2; -exports.f2 = f2; -exports.hd = hd; -exports.tl_exn = tl_exn; -exports.rec_cell3 = rec_cell3; -exports.f3 = f3; -/* Not a pure module */ diff --git a/tests/tests/src/recursive_records_test.mjs b/tests/tests/src/recursive_records_test.mjs new file mode 100644 index 0000000000..0505ade90e --- /dev/null +++ b/tests/tests/src/recursive_records_test.mjs @@ -0,0 +1,124 @@ +// Generated by ReScript, PLEASE EDIT WITH CARE + +import * as Mt from "./mt.mjs"; +import * as Belt_List from "rescript/lib/es6/Belt_List.js"; +import * as Primitive_object from "rescript/lib/es6/Primitive_object.js"; + +let suites = { + contents: /* [] */0 +}; + +let test_id = { + contents: 0 +}; + +function eq(loc, x, y) { + Mt.eq_suites(test_id, suites, loc, x, y); +} + +let rec_cell = {}; + +rec_cell.content = 3; + +rec_cell.next = rec_cell; + +function f0(x) { + let rec_cell = {}; + Primitive_object.updateDummy(rec_cell, { + content: Math.imul(x, x) - 6 | 0, + next: rec_cell + }); + return rec_cell; +} + +function a0(x) { + return (x.content + x.next.content | 0) + x.next.next.content | 0; +} + +eq("File \"recursive_records_test.res\", line 26, characters 5-12", a0(rec_cell), 9); + +eq("File \"recursive_records_test.res\", line 27, characters 5-12", a0(f0(3)), 9); + +let rec_cell2 = {}; + +rec_cell2.content = 3; + +rec_cell2.next = rec_cell2; + +function f2(x) { + let rec_cell2 = {}; + Primitive_object.updateDummy(rec_cell2, { + TAG: "Cons", + content: Math.imul(x, x) - 6 | 0, + next: rec_cell2 + }); + return rec_cell2; +} + +function hd(x) { + if (typeof x !== "object") { + return 0; + } else { + return x.content; + } +} + +function tl_exn(x) { + if (typeof x === "object") { + return x.next; + } + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "recursive_records_test.res", + 49, + 11 + ], + Error: new Error() + }; +} + +eq("File \"recursive_records_test.res\", line 54, characters 5-12", (hd(rec_cell2) + hd(tl_exn(rec_cell2)) | 0) + hd(tl_exn(tl_exn(rec_cell2))) | 0, 9); + +let rec_cell2$1 = f2(3); + +eq("File \"recursive_records_test.res\", line 56, characters 5-12", (hd(rec_cell2$1) + hd(tl_exn(rec_cell2$1)) | 0) + hd(tl_exn(tl_exn(rec_cell2$1))) | 0, 9); + +let rec_cell3 = {}; + +rec_cell3.hd = 3; + +rec_cell3.tl = rec_cell3; + +function f3(x) { + let rec_cell3 = {}; + Primitive_object.updateDummy(rec_cell3, { + hd: Math.imul(x, x) - 6 | 0, + tl: rec_cell3 + }); + return rec_cell3; +} + +eq("File \"recursive_records_test.res\", line 68, characters 4-11", (Belt_List.headExn(rec_cell3) + Belt_List.headExn(Belt_List.tailExn(rec_cell3)) | 0) + Belt_List.headExn(Belt_List.tailExn(Belt_List.tailExn(rec_cell3))) | 0, 9); + +let rec_cell3$1 = f3(3); + +eq("File \"recursive_records_test.res\", line 78, characters 4-11", (Belt_List.headExn(rec_cell3$1) + Belt_List.headExn(Belt_List.tailExn(rec_cell3$1)) | 0) + Belt_List.headExn(Belt_List.tailExn(Belt_List.tailExn(rec_cell3$1))) | 0, 9); + +Mt.from_pair_suites("recursive_records_test.res", suites.contents); + +export { + suites, + test_id, + eq, + rec_cell, + f0, + a0, + rec_cell2, + f2, + hd, + tl_exn, + rec_cell3, + f3, +} +/* Not a pure module */ diff --git a/tests/tests/src/recursive_unbound_module_test.js b/tests/tests/src/recursive_unbound_module_test.js deleted file mode 100644 index dcb32a8c3d..0000000000 --- a/tests/tests/src/recursive_unbound_module_test.js +++ /dev/null @@ -1,63 +0,0 @@ -// Generated by ReScript, PLEASE EDIT WITH CARE -'use strict'; - -let Primitive_module = require("rescript/lib/js/Primitive_module.js"); - -function Make(X) { - let f = () => {}; - let M = { - f: f - }; - return { - M: M - }; -} - -let B = Primitive_module.init([ - "recursive_unbound_module_test.res", - 14, - 11 -], { - TAG: "Module", - _0: [[ - { - TAG: "Module", - _0: [[ - "Function", - "f" - ]] - }, - "M" - ]] -}); - -function f() { - -} - -let M = { - f: f -}; - -Primitive_module.update({ - TAG: "Module", - _0: [[ - { - TAG: "Module", - _0: [[ - "Function", - "f" - ]] - }, - "M" - ]] -}, B, { - M: M -}); - -let A; - -exports.Make = Make; -exports.A = A; -exports.B = B; -/* B Not a pure module */ diff --git a/tests/tests/src/recursive_unbound_module_test.mjs b/tests/tests/src/recursive_unbound_module_test.mjs new file mode 100644 index 0000000000..858cc2da1c --- /dev/null +++ b/tests/tests/src/recursive_unbound_module_test.mjs @@ -0,0 +1,64 @@ +// Generated by ReScript, PLEASE EDIT WITH CARE + +import * as Primitive_module from "rescript/lib/es6/Primitive_module.js"; + +function Make(X) { + let f = () => {}; + let M = { + f: f + }; + return { + M: M + }; +} + +let B = Primitive_module.init([ + "recursive_unbound_module_test.res", + 14, + 11 +], { + TAG: "Module", + _0: [[ + { + TAG: "Module", + _0: [[ + "Function", + "f" + ]] + }, + "M" + ]] +}); + +function f() { + +} + +let M = { + f: f +}; + +Primitive_module.update({ + TAG: "Module", + _0: [[ + { + TAG: "Module", + _0: [[ + "Function", + "f" + ]] + }, + "M" + ]] +}, B, { + M: M +}); + +let A; + +export { + Make, + A, + B, +} +/* B Not a pure module */ diff --git a/tests/tests/src/regression_print.js b/tests/tests/src/regression_print.js deleted file mode 100644 index f174166c84..0000000000 --- a/tests/tests/src/regression_print.js +++ /dev/null @@ -1,9 +0,0 @@ -// Generated by ReScript, PLEASE EDIT WITH CARE -'use strict'; - - -console.log(JSON.stringify(2)); - -console.log(JSON.stringify(1)); - -/* Not a pure module */ diff --git a/tests/tests/src/regression_print.mjs b/tests/tests/src/regression_print.mjs new file mode 100644 index 0000000000..3328b9efd1 --- /dev/null +++ b/tests/tests/src/regression_print.mjs @@ -0,0 +1,8 @@ +// Generated by ReScript, PLEASE EDIT WITH CARE + + +console.log(JSON.stringify(2)); + +console.log(JSON.stringify(1)); + +/* Not a pure module */ diff --git a/tests/tests/src/relative_path.js b/tests/tests/src/relative_path.js deleted file mode 100644 index abb04a0a8f..0000000000 --- a/tests/tests/src/relative_path.js +++ /dev/null @@ -1,17 +0,0 @@ -// Generated by ReScript, PLEASE EDIT WITH CARE -'use strict'; - -let FileJs = require("./File.js"); - -let foo = FileJs.foo; - -function foo2(prim) { - return FileJs.foo2(prim); -} - -let bar = foo; - -exports.foo = foo; -exports.foo2 = foo2; -exports.bar = bar; -/* foo Not a pure module */ diff --git a/tests/tests/src/relative_path.mjs b/tests/tests/src/relative_path.mjs new file mode 100644 index 0000000000..4083f38ea3 --- /dev/null +++ b/tests/tests/src/relative_path.mjs @@ -0,0 +1,18 @@ +// Generated by ReScript, PLEASE EDIT WITH CARE + +import * as FileJs from "./File.js"; + +let foo = FileJs.foo; + +function foo2(prim) { + return FileJs.foo2(prim); +} + +let bar = foo; + +export { + foo, + foo2, + bar, +} +/* foo Not a pure module */ diff --git a/tests/tests/src/res_debug.js b/tests/tests/src/res_debug.js deleted file mode 100644 index 7e39050de3..0000000000 --- a/tests/tests/src/res_debug.js +++ /dev/null @@ -1,89 +0,0 @@ -// Generated by ReScript, PLEASE EDIT WITH CARE -'use strict'; - -let Primitive_option = require("rescript/lib/js/Primitive_option.js"); - -function f(window, a, b) { - return window.location(a, b); -} - -let v0 = { - x: 3, - z: 2 -}; - -let newrecord = {...v0}; - -newrecord.x = 3; - -function testMatch(v) { - let y = v.y; - if (y !== undefined) { - return y; - } else { - return 42; - } -} - -function optionMap(x, f) { - if (x !== undefined) { - return Primitive_option.some(f(Primitive_option.valFromOption(x))); - } - -} - -let ok_name = optionMap(undefined, x => x); - -let ok = { - name: ok_name -}; - -let bad_name = optionMap(undefined, x => x); - -let bad = { - name: bad_name -}; - -function identity(x) { - return x; -} - -let name1 = "ReScript"; - -let ok1 = { - name: name1 -}; - -let bad1 = { - name: name1 -}; - -let v2 = newrecord; - -let v1 = { - x: 3, - z: 3 -}; - -let h = /* '😊' */128522; - -let hey = "hello, 世界"; - -let name; - -exports.f = f; -exports.v0 = v0; -exports.v2 = v2; -exports.v1 = v1; -exports.testMatch = testMatch; -exports.h = h; -exports.hey = hey; -exports.optionMap = optionMap; -exports.name = name; -exports.ok = ok; -exports.bad = bad; -exports.identity = identity; -exports.name1 = name1; -exports.ok1 = ok1; -exports.bad1 = bad1; -/* Not a pure module */ diff --git a/tests/tests/src/res_debug.mjs b/tests/tests/src/res_debug.mjs new file mode 100644 index 0000000000..c6a5369011 --- /dev/null +++ b/tests/tests/src/res_debug.mjs @@ -0,0 +1,90 @@ +// Generated by ReScript, PLEASE EDIT WITH CARE + +import * as Primitive_option from "rescript/lib/es6/Primitive_option.js"; + +function f(window, a, b) { + return window.location(a, b); +} + +let v0 = { + x: 3, + z: 2 +}; + +let newrecord = {...v0}; + +newrecord.x = 3; + +function testMatch(v) { + let y = v.y; + if (y !== undefined) { + return y; + } else { + return 42; + } +} + +function optionMap(x, f) { + if (x !== undefined) { + return Primitive_option.some(f(Primitive_option.valFromOption(x))); + } + +} + +let ok_name = optionMap(undefined, x => x); + +let ok = { + name: ok_name +}; + +let bad_name = optionMap(undefined, x => x); + +let bad = { + name: bad_name +}; + +function identity(x) { + return x; +} + +let name1 = "ReScript"; + +let ok1 = { + name: name1 +}; + +let bad1 = { + name: name1 +}; + +let v2 = newrecord; + +let v1 = { + x: 3, + z: 3 +}; + +let h = /* '😊' */128522; + +let hey = "hello, 世界"; + +let name; + +export { + f, + v0, + v2, + v1, + testMatch, + h, + hey, + optionMap, + name, + ok, + bad, + identity, + name1, + ok1, + bad1, +} +/* Not a pure module */ diff --git a/tests/tests/src/return_check.js b/tests/tests/src/return_check.js deleted file mode 100644 index fb013559e5..0000000000 --- a/tests/tests/src/return_check.js +++ /dev/null @@ -1,96 +0,0 @@ -// Generated by ReScript, PLEASE EDIT WITH CARE -'use strict'; - -let Primitive_option = require("rescript/lib/js/Primitive_option.js"); - -function test(dom) { - let elem = dom.getElementById("haha"); - if (elem !== null) { - console.log(elem); - return 2; - } else { - return 1; - } -} - -function f_undefined(xs, i) { - let k = xs[i]; - if (k !== undefined) { - return k; - } - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "return_check.res", - 23, - 12 - ], - Error: new Error() - }; -} - -function f_escaped_not(xs, i) { - let x = xs[i]; - console.log("hei"); - if (x !== undefined) { - return x; - } else { - return 1; - } -} - -function f_escaped_1(xs, i) { - let x = xs[i]; - return () => { - if (x !== undefined) { - return x; - } else { - return 1; - } - }; -} - -function f_escaped_2(xs, i) { - console.log(Primitive_option.fromUndefined(xs[i])); -} - -function f_null(xs, i) { - let k = xs[i]; - if (k !== null) { - return k; - } - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "return_check.res", - 51, - 12 - ], - Error: new Error() - }; -} - -function f_null_undefined(xs, i) { - let k = xs[i]; - if (!(k == null)) { - return k; - } - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "return_check.res", - 59, - 12 - ], - Error: new Error() - }; -} - -exports.test = test; -exports.f_undefined = f_undefined; -exports.f_escaped_not = f_escaped_not; -exports.f_escaped_1 = f_escaped_1; -exports.f_escaped_2 = f_escaped_2; -exports.f_null = f_null; -exports.f_null_undefined = f_null_undefined; -/* No side effect */ diff --git a/tests/tests/src/return_check.mjs b/tests/tests/src/return_check.mjs new file mode 100644 index 0000000000..de09f71e8f --- /dev/null +++ b/tests/tests/src/return_check.mjs @@ -0,0 +1,97 @@ +// Generated by ReScript, PLEASE EDIT WITH CARE + +import * as Primitive_option from "rescript/lib/es6/Primitive_option.js"; + +function test(dom) { + let elem = dom.getElementById("haha"); + if (elem !== null) { + console.log(elem); + return 2; + } else { + return 1; + } +} + +function f_undefined(xs, i) { + let k = xs[i]; + if (k !== undefined) { + return k; + } + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "return_check.res", + 23, + 12 + ], + Error: new Error() + }; +} + +function f_escaped_not(xs, i) { + let x = xs[i]; + console.log("hei"); + if (x !== undefined) { + return x; + } else { + return 1; + } +} + +function f_escaped_1(xs, i) { + let x = xs[i]; + return () => { + if (x !== undefined) { + return x; + } else { + return 1; + } + }; +} + +function f_escaped_2(xs, i) { + console.log(Primitive_option.fromUndefined(xs[i])); +} + +function f_null(xs, i) { + let k = xs[i]; + if (k !== null) { + return k; + } + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "return_check.res", + 51, + 12 + ], + Error: new Error() + }; +} + +function f_null_undefined(xs, i) { + let k = xs[i]; + if (!(k == null)) { + return k; + } + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "return_check.res", + 59, + 12 + ], + Error: new Error() + }; +} + +export { + test, + f_undefined, + f_escaped_not, + f_escaped_1, + f_escaped_2, + f_null, + f_null_undefined, +} +/* No side effect */ diff --git a/tests/tests/src/runtime_encoding_test.js b/tests/tests/src/runtime_encoding_test.js deleted file mode 100644 index f466a374c3..0000000000 --- a/tests/tests/src/runtime_encoding_test.js +++ /dev/null @@ -1,11 +0,0 @@ -// Generated by ReScript, PLEASE EDIT WITH CARE -'use strict'; - - -let v = [ - 0, - 1 -]; - -exports.v = v; -/* No side effect */ diff --git a/tests/tests/src/runtime_encoding_test.mjs b/tests/tests/src/runtime_encoding_test.mjs new file mode 100644 index 0000000000..79c054c4c5 --- /dev/null +++ b/tests/tests/src/runtime_encoding_test.mjs @@ -0,0 +1,12 @@ +// Generated by ReScript, PLEASE EDIT WITH CARE + + +let v = [ + 0, + 1 +]; + +export { + v, +} +/* No side effect */ diff --git a/tests/tests/src/set_annotation.js b/tests/tests/src/set_annotation.js deleted file mode 100644 index ac80862af3..0000000000 --- a/tests/tests/src/set_annotation.js +++ /dev/null @@ -1,8 +0,0 @@ -// Generated by ReScript, PLEASE EDIT WITH CARE -'use strict'; - -let MyJSFile = require("MyJSFile"); - -MyJSFile.student1.name = "Mary"; - -/* Not a pure module */ diff --git a/tests/tests/src/set_annotation.mjs b/tests/tests/src/set_annotation.mjs new file mode 100644 index 0000000000..a4823026c5 --- /dev/null +++ b/tests/tests/src/set_annotation.mjs @@ -0,0 +1,7 @@ +// Generated by ReScript, PLEASE EDIT WITH CARE + +import * as MyJSFile from "MyJSFile"; + +MyJSFile.student1.name = "Mary"; + +/* Not a pure module */ diff --git a/tests/tests/src/set_gen.js b/tests/tests/src/set_gen.js deleted file mode 100644 index acbc9e8319..0000000000 --- a/tests/tests/src/set_gen.js +++ /dev/null @@ -1,754 +0,0 @@ -// Generated by ReScript, PLEASE EDIT WITH CARE -'use strict'; - -let Belt_List = require("rescript/lib/js/Belt_List.js"); -let Pervasives = require("rescript/lib/js/Pervasives.js"); -let Primitive_exceptions = require("rescript/lib/js/Primitive_exceptions.js"); - -function cons_enum(_s, _e) { - while (true) { - let e = _e; - let s = _s; - if (typeof s !== "object") { - return e; - } - _e = { - TAG: "More", - _0: s._1, - _1: s._2, - _2: e - }; - _s = s._0; - continue; - }; -} - -function height(x) { - if (typeof x !== "object") { - return 0; - } else { - return x._3; - } -} - -function min_elt(_x) { - while (true) { - let x = _x; - if (typeof x !== "object") { - throw { - RE_EXN_ID: "Not_found", - Error: new Error() - }; - } - let l = x._0; - if (typeof l !== "object") { - return x._1; - } - _x = l; - continue; - }; -} - -function max_elt(_x) { - while (true) { - let x = _x; - if (typeof x !== "object") { - throw { - RE_EXN_ID: "Not_found", - Error: new Error() - }; - } - let r = x._2; - if (typeof r !== "object") { - return x._1; - } - _x = r; - continue; - }; -} - -function is_empty(x) { - if (typeof x !== "object") { - return true; - } else { - return false; - } -} - -function cardinal_aux(_acc, _x) { - while (true) { - let x = _x; - let acc = _acc; - if (typeof x !== "object") { - return acc; - } - _x = x._0; - _acc = cardinal_aux(acc + 1 | 0, x._2); - continue; - }; -} - -function cardinal(s) { - return cardinal_aux(0, s); -} - -function elements_aux(_accu, _x) { - while (true) { - let x = _x; - let accu = _accu; - if (typeof x !== "object") { - return accu; - } - _x = x._0; - _accu = { - hd: x._1, - tl: elements_aux(accu, x._2) - }; - continue; - }; -} - -function elements(s) { - return elements_aux(/* [] */0, s); -} - -function iter(f, _x) { - while (true) { - let x = _x; - if (typeof x !== "object") { - return; - } - iter(f, x._0); - f(x._1); - _x = x._2; - continue; - }; -} - -function fold(f, _s, _accu) { - while (true) { - let accu = _accu; - let s = _s; - if (typeof s !== "object") { - return accu; - } - _accu = f(s._1, fold(f, s._0, accu)); - _s = s._2; - continue; - }; -} - -function for_all(p, _x) { - while (true) { - let x = _x; - if (typeof x !== "object") { - return true; - } - if (!p(x._1)) { - return false; - } - if (!for_all(p, x._0)) { - return false; - } - _x = x._2; - continue; - }; -} - -function exists(p, _x) { - while (true) { - let x = _x; - if (typeof x !== "object") { - return false; - } - if (p(x._1)) { - return true; - } - if (exists(p, x._0)) { - return true; - } - _x = x._2; - continue; - }; -} - -function max_int3(a, b, c) { - if (a >= b) { - if (a >= c) { - return a; - } else { - return c; - } - } else if (b >= c) { - return b; - } else { - return c; - } -} - -function max_int_2(a, b) { - if (a >= b) { - return a; - } else { - return b; - } -} - -let Height_invariant_broken = /* @__PURE__ */Primitive_exceptions.create("Set_gen.Height_invariant_broken"); - -let Height_diff_borken = /* @__PURE__ */Primitive_exceptions.create("Set_gen.Height_diff_borken"); - -function check_height_and_diff(x) { - if (typeof x !== "object") { - return 0; - } - let h = x._3; - let hl = check_height_and_diff(x._0); - let hr = check_height_and_diff(x._2); - if (h !== (max_int_2(hl, hr) + 1 | 0)) { - throw { - RE_EXN_ID: Height_invariant_broken, - Error: new Error() - }; - } - let diff = Pervasives.abs(hl - hr | 0); - if (diff > 2) { - throw { - RE_EXN_ID: Height_diff_borken, - Error: new Error() - }; - } - return h; -} - -function check(tree) { - check_height_and_diff(tree); -} - -function create(l, v, r) { - let hl; - hl = typeof l !== "object" ? 0 : l._3; - let hr; - hr = typeof r !== "object" ? 0 : r._3; - return { - TAG: "Node", - _0: l, - _1: v, - _2: r, - _3: hl >= hr ? hl + 1 | 0 : hr + 1 | 0 - }; -} - -function internal_bal(l, v, r) { - let hl; - hl = typeof l !== "object" ? 0 : l._3; - let hr; - hr = typeof r !== "object" ? 0 : r._3; - if (hl > (hr + 2 | 0)) { - if (typeof l !== "object") { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "set_gen.res", - 278, - 15 - ], - Error: new Error() - }; - } - let lr = l._2; - let lv = l._1; - let ll = l._0; - if (height(ll) >= height(lr)) { - return create(ll, lv, create(lr, v, r)); - } - if (typeof lr === "object") { - return create(create(ll, lv, lr._0), lr._1, create(lr._2, v, r)); - } - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "set_gen.res", - 288, - 19 - ], - Error: new Error() - }; - } - if (hr <= (hl + 2 | 0)) { - return { - TAG: "Node", - _0: l, - _1: v, - _2: r, - _3: hl >= hr ? hl + 1 | 0 : hr + 1 | 0 - }; - } - if (typeof r !== "object") { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "set_gen.res", - 300, - 15 - ], - Error: new Error() - }; - } - let rr = r._2; - let rv = r._1; - let rl = r._0; - if (height(rr) >= height(rl)) { - return create(create(l, v, rl), rv, rr); - } - if (typeof rl === "object") { - return create(create(l, v, rl._0), rl._1, create(rl._2, rv, rr)); - } - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "set_gen.res", - 306, - 19 - ], - Error: new Error() - }; -} - -function remove_min_elt(x) { - if (typeof x !== "object") { - return Pervasives.invalid_arg("Set.remove_min_elt"); - } - let l = x._0; - if (typeof l !== "object") { - return x._2; - } else { - return internal_bal(remove_min_elt(l), x._1, x._2); - } -} - -function singleton(x) { - return { - TAG: "Node", - _0: "Empty", - _1: x, - _2: "Empty", - _3: 1 - }; -} - -function internal_merge(l, r) { - if (typeof l !== "object") { - return r; - } else if (typeof r !== "object") { - return l; - } else { - return internal_bal(l, min_elt(r), remove_min_elt(r)); - } -} - -function add_min_element(v, x) { - if (typeof x !== "object") { - return singleton(v); - } else { - return internal_bal(add_min_element(v, x._0), x._1, x._2); - } -} - -function add_max_element(v, x) { - if (typeof x !== "object") { - return singleton(v); - } else { - return internal_bal(x._0, x._1, add_max_element(v, x._2)); - } -} - -function internal_join(l, v, r) { - if (typeof l !== "object") { - return add_min_element(v, r); - } - let lh = l._3; - if (typeof r !== "object") { - return add_max_element(v, l); - } - let rh = r._3; - if (lh > (rh + 2 | 0)) { - return internal_bal(l._0, l._1, internal_join(l._2, v, r)); - } else if (rh > (lh + 2 | 0)) { - return internal_bal(internal_join(l, v, r._0), r._1, r._2); - } else { - return create(l, v, r); - } -} - -function internal_concat(t1, t2) { - if (typeof t1 !== "object") { - return t2; - } else if (typeof t2 !== "object") { - return t1; - } else { - return internal_join(t1, min_elt(t2), remove_min_elt(t2)); - } -} - -function filter(p, x) { - if (typeof x !== "object") { - return "Empty"; - } - let v = x._1; - let l$p = filter(p, x._0); - let pv = p(v); - let r$p = filter(p, x._2); - if (pv) { - return internal_join(l$p, v, r$p); - } else { - return internal_concat(l$p, r$p); - } -} - -function partition(p, x) { - if (typeof x !== "object") { - return [ - "Empty", - "Empty" - ]; - } - let v = x._1; - let match = partition(p, x._0); - let lf = match[1]; - let lt = match[0]; - let pv = p(v); - let match$1 = partition(p, x._2); - let rf = match$1[1]; - let rt = match$1[0]; - if (pv) { - return [ - internal_join(lt, v, rt), - internal_concat(lf, rf) - ]; - } else { - return [ - internal_concat(lt, rt), - internal_join(lf, v, rf) - ]; - } -} - -function of_sorted_list(l) { - let sub = (n, l) => { - switch (n) { - case 0 : - return [ - "Empty", - l - ]; - case 1 : - if (l) { - return [ - { - TAG: "Node", - _0: "Empty", - _1: l.hd, - _2: "Empty", - _3: 1 - }, - l.tl - ]; - } - break; - case 2 : - if (l) { - let match = l.tl; - if (match) { - return [ - { - TAG: "Node", - _0: { - TAG: "Node", - _0: "Empty", - _1: l.hd, - _2: "Empty", - _3: 1 - }, - _1: match.hd, - _2: "Empty", - _3: 2 - }, - match.tl - ]; - } - - } - break; - case 3 : - if (l) { - let match$1 = l.tl; - if (match$1) { - let match$2 = match$1.tl; - if (match$2) { - return [ - { - TAG: "Node", - _0: { - TAG: "Node", - _0: "Empty", - _1: l.hd, - _2: "Empty", - _3: 1 - }, - _1: match$1.hd, - _2: { - TAG: "Node", - _0: "Empty", - _1: match$2.hd, - _2: "Empty", - _3: 1 - }, - _3: 2 - }, - match$2.tl - ]; - } - - } - - } - break; - } - let nl = n / 2 | 0; - let match$3 = sub(nl, l); - let l$1 = match$3[1]; - if (l$1) { - let match$4 = sub((n - nl | 0) - 1 | 0, l$1.tl); - return [ - create(match$3[0], l$1.hd, match$4[0]), - match$4[1] - ]; - } - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "set_gen.res", - 447, - 18 - ], - Error: new Error() - }; - }; - return sub(Belt_List.length(l), l)[0]; -} - -function of_sorted_array(l) { - let sub = (start, n, l) => { - if (n === 0) { - return "Empty"; - } - if (n === 1) { - let x0 = l[start]; - return { - TAG: "Node", - _0: "Empty", - _1: x0, - _2: "Empty", - _3: 1 - }; - } - if (n === 2) { - let x0$1 = l[start]; - let x1 = l[start + 1 | 0]; - return { - TAG: "Node", - _0: { - TAG: "Node", - _0: "Empty", - _1: x0$1, - _2: "Empty", - _3: 1 - }, - _1: x1, - _2: "Empty", - _3: 2 - }; - } - if (n === 3) { - let x0$2 = l[start]; - let x1$1 = l[start + 1 | 0]; - let x2 = l[start + 2 | 0]; - return { - TAG: "Node", - _0: { - TAG: "Node", - _0: "Empty", - _1: x0$2, - _2: "Empty", - _3: 1 - }, - _1: x1$1, - _2: { - TAG: "Node", - _0: "Empty", - _1: x2, - _2: "Empty", - _3: 1 - }, - _3: 2 - }; - } - let nl = n / 2 | 0; - let left = sub(start, nl, l); - let mid = start + nl | 0; - let v = l[mid]; - let right = sub(mid + 1 | 0, (n - nl | 0) - 1 | 0, l); - return create(left, v, right); - }; - return sub(0, l.length, l); -} - -function is_ordered(cmp, tree) { - let is_ordered_min_max = tree => { - if (typeof tree !== "object") { - return "Empty"; - } - let r = tree._2; - let v = tree._1; - let match = is_ordered_min_max(tree._0); - if (typeof match === "object") { - let match$1 = match.VAL; - let max_v = match$1[1]; - let min_v = match$1[0]; - let match$2 = is_ordered_min_max(r); - if (typeof match$2 !== "object") { - if (match$2 === "Empty" && cmp(max_v, v) < 0) { - return { - NAME: "V", - VAL: [ - min_v, - v - ] - }; - } else { - return "No"; - } - } - let match$3 = match$2.VAL; - if (cmp(max_v, match$3[0]) < 0) { - return { - NAME: "V", - VAL: [ - min_v, - match$3[1] - ] - }; - } else { - return "No"; - } - } - if (match !== "Empty") { - return "No"; - } - let match$4 = is_ordered_min_max(r); - if (typeof match$4 !== "object") { - if (match$4 === "Empty") { - return { - NAME: "V", - VAL: [ - v, - v - ] - }; - } else { - return "No"; - } - } - let match$5 = match$4.VAL; - if (cmp(v, match$5[0]) < 0) { - return { - NAME: "V", - VAL: [ - v, - match$5[1] - ] - }; - } else { - return "No"; - } - }; - return is_ordered_min_max(tree) !== "No"; -} - -function invariant(cmp, t) { - check_height_and_diff(t); - return is_ordered(cmp, t); -} - -function compare_aux(cmp, _e1, _e2) { - while (true) { - let e2 = _e2; - let e1 = _e1; - if (typeof e1 !== "object") { - if (typeof e2 !== "object") { - return 0; - } else { - return -1; - } - } - if (typeof e2 !== "object") { - return 1; - } - let c = cmp(e1._0, e2._0); - if (c !== 0) { - return c; - } - _e2 = cons_enum(e2._1, e2._2); - _e1 = cons_enum(e1._1, e1._2); - continue; - }; -} - -function compare(cmp, s1, s2) { - return compare_aux(cmp, cons_enum(s1, "End"), cons_enum(s2, "End")); -} - -let empty = "Empty"; - -let choose = min_elt; - -exports.cons_enum = cons_enum; -exports.height = height; -exports.min_elt = min_elt; -exports.max_elt = max_elt; -exports.empty = empty; -exports.is_empty = is_empty; -exports.cardinal_aux = cardinal_aux; -exports.cardinal = cardinal; -exports.elements_aux = elements_aux; -exports.elements = elements; -exports.choose = choose; -exports.iter = iter; -exports.fold = fold; -exports.for_all = for_all; -exports.exists = exists; -exports.max_int3 = max_int3; -exports.max_int_2 = max_int_2; -exports.Height_invariant_broken = Height_invariant_broken; -exports.Height_diff_borken = Height_diff_borken; -exports.check_height_and_diff = check_height_and_diff; -exports.check = check; -exports.create = create; -exports.internal_bal = internal_bal; -exports.remove_min_elt = remove_min_elt; -exports.singleton = singleton; -exports.internal_merge = internal_merge; -exports.add_min_element = add_min_element; -exports.add_max_element = add_max_element; -exports.internal_join = internal_join; -exports.internal_concat = internal_concat; -exports.filter = filter; -exports.partition = partition; -exports.of_sorted_list = of_sorted_list; -exports.of_sorted_array = of_sorted_array; -exports.is_ordered = is_ordered; -exports.invariant = invariant; -exports.compare_aux = compare_aux; -exports.compare = compare; -/* No side effect */ diff --git a/tests/tests/src/set_gen.mjs b/tests/tests/src/set_gen.mjs new file mode 100644 index 0000000000..d6ced61c31 --- /dev/null +++ b/tests/tests/src/set_gen.mjs @@ -0,0 +1,755 @@ +// Generated by ReScript, PLEASE EDIT WITH CARE + +import * as Belt_List from "rescript/lib/es6/Belt_List.js"; +import * as Pervasives from "rescript/lib/es6/Pervasives.js"; +import * as Primitive_exceptions from "rescript/lib/es6/Primitive_exceptions.js"; + +function cons_enum(_s, _e) { + while (true) { + let e = _e; + let s = _s; + if (typeof s !== "object") { + return e; + } + _e = { + TAG: "More", + _0: s._1, + _1: s._2, + _2: e + }; + _s = s._0; + continue; + }; +} + +function height(x) { + if (typeof x !== "object") { + return 0; + } else { + return x._3; + } +} + +function min_elt(_x) { + while (true) { + let x = _x; + if (typeof x !== "object") { + throw { + RE_EXN_ID: "Not_found", + Error: new Error() + }; + } + let l = x._0; + if (typeof l !== "object") { + return x._1; + } + _x = l; + continue; + }; +} + +function max_elt(_x) { + while (true) { + let x = _x; + if (typeof x !== "object") { + throw { + RE_EXN_ID: "Not_found", + Error: new Error() + }; + } + let r = x._2; + if (typeof r !== "object") { + return x._1; + } + _x = r; + continue; + }; +} + +function is_empty(x) { + if (typeof x !== "object") { + return true; + } else { + return false; + } +} + +function cardinal_aux(_acc, _x) { + while (true) { + let x = _x; + let acc = _acc; + if (typeof x !== "object") { + return acc; + } + _x = x._0; + _acc = cardinal_aux(acc + 1 | 0, x._2); + continue; + }; +} + +function cardinal(s) { + return cardinal_aux(0, s); +} + +function elements_aux(_accu, _x) { + while (true) { + let x = _x; + let accu = _accu; + if (typeof x !== "object") { + return accu; + } + _x = x._0; + _accu = { + hd: x._1, + tl: elements_aux(accu, x._2) + }; + continue; + }; +} + +function elements(s) { + return elements_aux(/* [] */0, s); +} + +function iter(f, _x) { + while (true) { + let x = _x; + if (typeof x !== "object") { + return; + } + iter(f, x._0); + f(x._1); + _x = x._2; + continue; + }; +} + +function fold(f, _s, _accu) { + while (true) { + let accu = _accu; + let s = _s; + if (typeof s !== "object") { + return accu; + } + _accu = f(s._1, fold(f, s._0, accu)); + _s = s._2; + continue; + }; +} + +function for_all(p, _x) { + while (true) { + let x = _x; + if (typeof x !== "object") { + return true; + } + if (!p(x._1)) { + return false; + } + if (!for_all(p, x._0)) { + return false; + } + _x = x._2; + continue; + }; +} + +function exists(p, _x) { + while (true) { + let x = _x; + if (typeof x !== "object") { + return false; + } + if (p(x._1)) { + return true; + } + if (exists(p, x._0)) { + return true; + } + _x = x._2; + continue; + }; +} + +function max_int3(a, b, c) { + if (a >= b) { + if (a >= c) { + return a; + } else { + return c; + } + } else if (b >= c) { + return b; + } else { + return c; + } +} + +function max_int_2(a, b) { + if (a >= b) { + return a; + } else { + return b; + } +} + +let Height_invariant_broken = /* @__PURE__ */Primitive_exceptions.create("Set_gen.Height_invariant_broken"); + +let Height_diff_borken = /* @__PURE__ */Primitive_exceptions.create("Set_gen.Height_diff_borken"); + +function check_height_and_diff(x) { + if (typeof x !== "object") { + return 0; + } + let h = x._3; + let hl = check_height_and_diff(x._0); + let hr = check_height_and_diff(x._2); + if (h !== (max_int_2(hl, hr) + 1 | 0)) { + throw { + RE_EXN_ID: Height_invariant_broken, + Error: new Error() + }; + } + let diff = Pervasives.abs(hl - hr | 0); + if (diff > 2) { + throw { + RE_EXN_ID: Height_diff_borken, + Error: new Error() + }; + } + return h; +} + +function check(tree) { + check_height_and_diff(tree); +} + +function create(l, v, r) { + let hl; + hl = typeof l !== "object" ? 0 : l._3; + let hr; + hr = typeof r !== "object" ? 0 : r._3; + return { + TAG: "Node", + _0: l, + _1: v, + _2: r, + _3: hl >= hr ? hl + 1 | 0 : hr + 1 | 0 + }; +} + +function internal_bal(l, v, r) { + let hl; + hl = typeof l !== "object" ? 0 : l._3; + let hr; + hr = typeof r !== "object" ? 0 : r._3; + if (hl > (hr + 2 | 0)) { + if (typeof l !== "object") { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "set_gen.res", + 278, + 15 + ], + Error: new Error() + }; + } + let lr = l._2; + let lv = l._1; + let ll = l._0; + if (height(ll) >= height(lr)) { + return create(ll, lv, create(lr, v, r)); + } + if (typeof lr === "object") { + return create(create(ll, lv, lr._0), lr._1, create(lr._2, v, r)); + } + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "set_gen.res", + 288, + 19 + ], + Error: new Error() + }; + } + if (hr <= (hl + 2 | 0)) { + return { + TAG: "Node", + _0: l, + _1: v, + _2: r, + _3: hl >= hr ? hl + 1 | 0 : hr + 1 | 0 + }; + } + if (typeof r !== "object") { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "set_gen.res", + 300, + 15 + ], + Error: new Error() + }; + } + let rr = r._2; + let rv = r._1; + let rl = r._0; + if (height(rr) >= height(rl)) { + return create(create(l, v, rl), rv, rr); + } + if (typeof rl === "object") { + return create(create(l, v, rl._0), rl._1, create(rl._2, rv, rr)); + } + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "set_gen.res", + 306, + 19 + ], + Error: new Error() + }; +} + +function remove_min_elt(x) { + if (typeof x !== "object") { + return Pervasives.invalid_arg("Set.remove_min_elt"); + } + let l = x._0; + if (typeof l !== "object") { + return x._2; + } else { + return internal_bal(remove_min_elt(l), x._1, x._2); + } +} + +function singleton(x) { + return { + TAG: "Node", + _0: "Empty", + _1: x, + _2: "Empty", + _3: 1 + }; +} + +function internal_merge(l, r) { + if (typeof l !== "object") { + return r; + } else if (typeof r !== "object") { + return l; + } else { + return internal_bal(l, min_elt(r), remove_min_elt(r)); + } +} + +function add_min_element(v, x) { + if (typeof x !== "object") { + return singleton(v); + } else { + return internal_bal(add_min_element(v, x._0), x._1, x._2); + } +} + +function add_max_element(v, x) { + if (typeof x !== "object") { + return singleton(v); + } else { + return internal_bal(x._0, x._1, add_max_element(v, x._2)); + } +} + +function internal_join(l, v, r) { + if (typeof l !== "object") { + return add_min_element(v, r); + } + let lh = l._3; + if (typeof r !== "object") { + return add_max_element(v, l); + } + let rh = r._3; + if (lh > (rh + 2 | 0)) { + return internal_bal(l._0, l._1, internal_join(l._2, v, r)); + } else if (rh > (lh + 2 | 0)) { + return internal_bal(internal_join(l, v, r._0), r._1, r._2); + } else { + return create(l, v, r); + } +} + +function internal_concat(t1, t2) { + if (typeof t1 !== "object") { + return t2; + } else if (typeof t2 !== "object") { + return t1; + } else { + return internal_join(t1, min_elt(t2), remove_min_elt(t2)); + } +} + +function filter(p, x) { + if (typeof x !== "object") { + return "Empty"; + } + let v = x._1; + let l$p = filter(p, x._0); + let pv = p(v); + let r$p = filter(p, x._2); + if (pv) { + return internal_join(l$p, v, r$p); + } else { + return internal_concat(l$p, r$p); + } +} + +function partition(p, x) { + if (typeof x !== "object") { + return [ + "Empty", + "Empty" + ]; + } + let v = x._1; + let match = partition(p, x._0); + let lf = match[1]; + let lt = match[0]; + let pv = p(v); + let match$1 = partition(p, x._2); + let rf = match$1[1]; + let rt = match$1[0]; + if (pv) { + return [ + internal_join(lt, v, rt), + internal_concat(lf, rf) + ]; + } else { + return [ + internal_concat(lt, rt), + internal_join(lf, v, rf) + ]; + } +} + +function of_sorted_list(l) { + let sub = (n, l) => { + switch (n) { + case 0 : + return [ + "Empty", + l + ]; + case 1 : + if (l) { + return [ + { + TAG: "Node", + _0: "Empty", + _1: l.hd, + _2: "Empty", + _3: 1 + }, + l.tl + ]; + } + break; + case 2 : + if (l) { + let match = l.tl; + if (match) { + return [ + { + TAG: "Node", + _0: { + TAG: "Node", + _0: "Empty", + _1: l.hd, + _2: "Empty", + _3: 1 + }, + _1: match.hd, + _2: "Empty", + _3: 2 + }, + match.tl + ]; + } + + } + break; + case 3 : + if (l) { + let match$1 = l.tl; + if (match$1) { + let match$2 = match$1.tl; + if (match$2) { + return [ + { + TAG: "Node", + _0: { + TAG: "Node", + _0: "Empty", + _1: l.hd, + _2: "Empty", + _3: 1 + }, + _1: match$1.hd, + _2: { + TAG: "Node", + _0: "Empty", + _1: match$2.hd, + _2: "Empty", + _3: 1 + }, + _3: 2 + }, + match$2.tl + ]; + } + + } + + } + break; + } + let nl = n / 2 | 0; + let match$3 = sub(nl, l); + let l$1 = match$3[1]; + if (l$1) { + let match$4 = sub((n - nl | 0) - 1 | 0, l$1.tl); + return [ + create(match$3[0], l$1.hd, match$4[0]), + match$4[1] + ]; + } + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "set_gen.res", + 447, + 18 + ], + Error: new Error() + }; + }; + return sub(Belt_List.length(l), l)[0]; +} + +function of_sorted_array(l) { + let sub = (start, n, l) => { + if (n === 0) { + return "Empty"; + } + if (n === 1) { + let x0 = l[start]; + return { + TAG: "Node", + _0: "Empty", + _1: x0, + _2: "Empty", + _3: 1 + }; + } + if (n === 2) { + let x0$1 = l[start]; + let x1 = l[start + 1 | 0]; + return { + TAG: "Node", + _0: { + TAG: "Node", + _0: "Empty", + _1: x0$1, + _2: "Empty", + _3: 1 + }, + _1: x1, + _2: "Empty", + _3: 2 + }; + } + if (n === 3) { + let x0$2 = l[start]; + let x1$1 = l[start + 1 | 0]; + let x2 = l[start + 2 | 0]; + return { + TAG: "Node", + _0: { + TAG: "Node", + _0: "Empty", + _1: x0$2, + _2: "Empty", + _3: 1 + }, + _1: x1$1, + _2: { + TAG: "Node", + _0: "Empty", + _1: x2, + _2: "Empty", + _3: 1 + }, + _3: 2 + }; + } + let nl = n / 2 | 0; + let left = sub(start, nl, l); + let mid = start + nl | 0; + let v = l[mid]; + let right = sub(mid + 1 | 0, (n - nl | 0) - 1 | 0, l); + return create(left, v, right); + }; + return sub(0, l.length, l); +} + +function is_ordered(cmp, tree) { + let is_ordered_min_max = tree => { + if (typeof tree !== "object") { + return "Empty"; + } + let r = tree._2; + let v = tree._1; + let match = is_ordered_min_max(tree._0); + if (typeof match === "object") { + let match$1 = match.VAL; + let max_v = match$1[1]; + let min_v = match$1[0]; + let match$2 = is_ordered_min_max(r); + if (typeof match$2 !== "object") { + if (match$2 === "Empty" && cmp(max_v, v) < 0) { + return { + NAME: "V", + VAL: [ + min_v, + v + ] + }; + } else { + return "No"; + } + } + let match$3 = match$2.VAL; + if (cmp(max_v, match$3[0]) < 0) { + return { + NAME: "V", + VAL: [ + min_v, + match$3[1] + ] + }; + } else { + return "No"; + } + } + if (match !== "Empty") { + return "No"; + } + let match$4 = is_ordered_min_max(r); + if (typeof match$4 !== "object") { + if (match$4 === "Empty") { + return { + NAME: "V", + VAL: [ + v, + v + ] + }; + } else { + return "No"; + } + } + let match$5 = match$4.VAL; + if (cmp(v, match$5[0]) < 0) { + return { + NAME: "V", + VAL: [ + v, + match$5[1] + ] + }; + } else { + return "No"; + } + }; + return is_ordered_min_max(tree) !== "No"; +} + +function invariant(cmp, t) { + check_height_and_diff(t); + return is_ordered(cmp, t); +} + +function compare_aux(cmp, _e1, _e2) { + while (true) { + let e2 = _e2; + let e1 = _e1; + if (typeof e1 !== "object") { + if (typeof e2 !== "object") { + return 0; + } else { + return -1; + } + } + if (typeof e2 !== "object") { + return 1; + } + let c = cmp(e1._0, e2._0); + if (c !== 0) { + return c; + } + _e2 = cons_enum(e2._1, e2._2); + _e1 = cons_enum(e1._1, e1._2); + continue; + }; +} + +function compare(cmp, s1, s2) { + return compare_aux(cmp, cons_enum(s1, "End"), cons_enum(s2, "End")); +} + +let empty = "Empty"; + +let choose = min_elt; + +export { + cons_enum, + height, + min_elt, + max_elt, + empty, + is_empty, + cardinal_aux, + cardinal, + elements_aux, + elements, + choose, + iter, + fold, + for_all, + exists, + max_int3, + max_int_2, + Height_invariant_broken, + Height_diff_borken, + check_height_and_diff, + check, + create, + internal_bal, + remove_min_elt, + singleton, + internal_merge, + add_min_element, + add_max_element, + internal_join, + internal_concat, + filter, + partition, + of_sorted_list, + of_sorted_array, + is_ordered, + invariant, + compare_aux, + compare, +} +/* No side effect */ diff --git a/tests/tests/src/side_effect.js b/tests/tests/src/side_effect.js deleted file mode 100644 index 8db15a2f23..0000000000 --- a/tests/tests/src/side_effect.js +++ /dev/null @@ -1,7 +0,0 @@ -// Generated by ReScript, PLEASE EDIT WITH CARE -'use strict'; - - -console.log("Side_effect"); - -/* Not a pure module */ diff --git a/tests/tests/src/side_effect.mjs b/tests/tests/src/side_effect.mjs new file mode 100644 index 0000000000..245fd35395 --- /dev/null +++ b/tests/tests/src/side_effect.mjs @@ -0,0 +1,6 @@ +// Generated by ReScript, PLEASE EDIT WITH CARE + + +console.log("Side_effect"); + +/* Not a pure module */ diff --git a/tests/tests/src/side_effect2.js b/tests/tests/src/side_effect2.js deleted file mode 100644 index 2309e5078a..0000000000 --- a/tests/tests/src/side_effect2.js +++ /dev/null @@ -1,9 +0,0 @@ -// Generated by ReScript, PLEASE EDIT WITH CARE -'use strict'; - -let Belt_Array = require("rescript/lib/js/Belt_Array.js"); - -let a = Belt_Array.map([1], x => x); - -exports.a = a; -/* a Not a pure module */ diff --git a/tests/tests/src/side_effect2.mjs b/tests/tests/src/side_effect2.mjs new file mode 100644 index 0000000000..50ee67dbd4 --- /dev/null +++ b/tests/tests/src/side_effect2.mjs @@ -0,0 +1,10 @@ +// Generated by ReScript, PLEASE EDIT WITH CARE + +import * as Belt_Array from "rescript/lib/es6/Belt_Array.js"; + +let a = Belt_Array.map([1], x => x); + +export { + a, +} +/* a Not a pure module */ diff --git a/tests/tests/src/side_effect_free.js b/tests/tests/src/side_effect_free.js deleted file mode 100644 index 7a46d38e23..0000000000 --- a/tests/tests/src/side_effect_free.js +++ /dev/null @@ -1,8 +0,0 @@ -// Generated by ReScript, PLEASE EDIT WITH CARE -'use strict'; - - -let a = 3; - -exports.a = a; -/* No side effect */ diff --git a/tests/tests/src/side_effect_free.mjs b/tests/tests/src/side_effect_free.mjs new file mode 100644 index 0000000000..a81ebd8f92 --- /dev/null +++ b/tests/tests/src/side_effect_free.mjs @@ -0,0 +1,9 @@ +// Generated by ReScript, PLEASE EDIT WITH CARE + + +let a = 3; + +export { + a, +} +/* No side effect */ diff --git a/tests/tests/src/simplify_lambda_632o.js b/tests/tests/src/simplify_lambda_632o.js deleted file mode 100644 index b2cf689ace..0000000000 --- a/tests/tests/src/simplify_lambda_632o.js +++ /dev/null @@ -1,33 +0,0 @@ -// Generated by ReScript, PLEASE EDIT WITH CARE -'use strict'; - - -function f(x) { - switch (x) { - case "X1" : - return "X1"; - case "X2" : - return "X2"; - case "X3" : - return "X3"; - case "X4" : - return "X4"; - } -} - -function f2(x) { - switch (x) { - case "X1" : - return "X1"; - case "X2" : - return "X2"; - case "X3" : - return "X3"; - case "X4" : - return "X4"; - } -} - -exports.f = f; -exports.f2 = f2; -/* No side effect */ diff --git a/tests/tests/src/simplify_lambda_632o.mjs b/tests/tests/src/simplify_lambda_632o.mjs new file mode 100644 index 0000000000..32ffda7c45 --- /dev/null +++ b/tests/tests/src/simplify_lambda_632o.mjs @@ -0,0 +1,34 @@ +// Generated by ReScript, PLEASE EDIT WITH CARE + + +function f(x) { + switch (x) { + case "X1" : + return "X1"; + case "X2" : + return "X2"; + case "X3" : + return "X3"; + case "X4" : + return "X4"; + } +} + +function f2(x) { + switch (x) { + case "X1" : + return "X1"; + case "X2" : + return "X2"; + case "X3" : + return "X3"; + case "X4" : + return "X4"; + } +} + +export { + f, + f2, +} +/* No side effect */ diff --git a/tests/tests/src/singular_unit_test.js b/tests/tests/src/singular_unit_test.js deleted file mode 100644 index 90276b9545..0000000000 --- a/tests/tests/src/singular_unit_test.js +++ /dev/null @@ -1,27 +0,0 @@ -// Generated by ReScript, PLEASE EDIT WITH CARE -'use strict'; - - -function f0(x) { - return x; -} - -function f1(x) { - return 2; -} - -function f3(x) { - if (x !== undefined) { - return x; - } else { - return "A"; - } -} - -let v0; - -exports.f0 = f0; -exports.f1 = f1; -exports.f3 = f3; -exports.v0 = v0; -/* No side effect */ diff --git a/tests/tests/src/singular_unit_test.mjs b/tests/tests/src/singular_unit_test.mjs new file mode 100644 index 0000000000..5fdcf74b3f --- /dev/null +++ b/tests/tests/src/singular_unit_test.mjs @@ -0,0 +1,28 @@ +// Generated by ReScript, PLEASE EDIT WITH CARE + + +function f0(x) { + return x; +} + +function f1(x) { + return 2; +} + +function f3(x) { + if (x !== undefined) { + return x; + } else { + return "A"; + } +} + +let v0; + +export { + f0, + f1, + f3, + v0, +} +/* No side effect */ diff --git a/tests/tests/src/small_inline_test.js b/tests/tests/src/small_inline_test.js deleted file mode 100644 index 0654859b97..0000000000 --- a/tests/tests/src/small_inline_test.js +++ /dev/null @@ -1,66 +0,0 @@ -// Generated by ReScript, PLEASE EDIT WITH CARE -'use strict'; - - -function $pipe$great(x, f) { - return f(x); -} - -function hello1(y, f) { - return f(y); -} - -function hello2(y, f) { - return f(y); -} - -function hello3(y, f) { - return f(y); -} - -function hello4(y, f) { - return f(y); -} - -function hello5(y, f) { - return f(y); -} - -function f(_x) { - while (true) { - let x = _x; - _x = x + 1 | 0; - continue; - }; -} - -function ff(_x, _y) { - while (true) { - let y = _y; - let x = _x; - _y = x + 1 | 0; - _x = y; - continue; - }; -} - -function fff(_x, _y) { - while (true) { - let y = _y; - let x = _x; - _y = x; - _x = y; - continue; - }; -} - -exports.$pipe$great = $pipe$great; -exports.hello1 = hello1; -exports.hello2 = hello2; -exports.hello3 = hello3; -exports.hello4 = hello4; -exports.hello5 = hello5; -exports.f = f; -exports.ff = ff; -exports.fff = fff; -/* No side effect */ diff --git a/tests/tests/src/small_inline_test.mjs b/tests/tests/src/small_inline_test.mjs new file mode 100644 index 0000000000..209be6faaa --- /dev/null +++ b/tests/tests/src/small_inline_test.mjs @@ -0,0 +1,67 @@ +// Generated by ReScript, PLEASE EDIT WITH CARE + + +function $pipe$great(x, f) { + return f(x); +} + +function hello1(y, f) { + return f(y); +} + +function hello2(y, f) { + return f(y); +} + +function hello3(y, f) { + return f(y); +} + +function hello4(y, f) { + return f(y); +} + +function hello5(y, f) { + return f(y); +} + +function f(_x) { + while (true) { + let x = _x; + _x = x + 1 | 0; + continue; + }; +} + +function ff(_x, _y) { + while (true) { + let y = _y; + let x = _x; + _y = x + 1 | 0; + _x = y; + continue; + }; +} + +function fff(_x, _y) { + while (true) { + let y = _y; + let x = _x; + _y = x; + _x = y; + continue; + }; +} + +export { + $pipe$great, + hello1, + hello2, + hello3, + hello4, + hello5, + f, + ff, + fff, +} +/* No side effect */ diff --git a/tests/tests/src/splice_test.js b/tests/tests/src/splice_test.js deleted file mode 100644 index d5a9897a07..0000000000 --- a/tests/tests/src/splice_test.js +++ /dev/null @@ -1,183 +0,0 @@ -// Generated by ReScript, PLEASE EDIT WITH CARE -'use strict'; - -let Mt = require("./mt.js"); -let Belt_Array = require("rescript/lib/js/Belt_Array.js"); - -let suites = { - contents: /* [] */0 -}; - -let test_id = { - contents: 0 -}; - -function eq(loc, x, y) { - Mt.eq_suites(test_id, suites, loc, x, y); -} - -let Caml_splice_call = {}; - -Math.max(1); - -function f00(a, b) { - return a.send(b); -} - -let a = []; - -a.push(1, 2, 3, 4); - -eq("File \"splice_test.res\", line 25, characters 5-12", a, [ - 1, - 2, - 3, - 4 -]); - -function dynamic(arr) { - let a = []; - a.push(1, ...arr); - eq("File \"splice_test.res\", line 31, characters 5-12", a, Belt_Array.concatMany([ - [1], - arr - ])); -} - -dynamic([ - 2, - 3, - 4 -]); - -dynamic([]); - -dynamic([ - 1, - 1, - 3 -]); - -let a$1 = new Array(1, 2, 3, 4); - -eq("File \"splice_test.res\", line 46, characters 5-12", a$1, [ - 1, - 2, - 3, - 4 -]); - -function dynamicNew(arr) { - let a = new Array(1, 2, ...arr); - eq("File \"splice_test.res\", line 51, characters 5-12", a, Belt_Array.concatMany([ - [ - 1, - 2 - ], - arr - ])); -} - -dynamicNew([ - 3, - 4 -]); - -dynamicNew([]); - -dynamicNew([ - 1, - 3 -]); - -class Foo { - constructor(...names) { - this.names = names; - } -} -; - -let f = new Foo("a", "b", "c"); - -eq("File \"splice_test.res\", line 73, characters 5-12", f.names, [ - "a", - "b", - "c" -]); - -function dynamicFoo(arr) { - let f = new Foo(...arr); - eq("File \"splice_test.res\", line 78, characters 5-12", f.names, arr); -} - -dynamicFoo([]); - -dynamicFoo(["a"]); - -dynamicFoo([ - "a", - "b", - "c" -]); - -let a$2 = []; - -a$2.push(1, 2, 3, 4); - -eq("File \"splice_test.res\", line 95, characters 7-14", a$2, [ - 1, - 2, - 3, - 4 -]); - -function dynamic$1(arr) { - let a = []; - a.push(1, ...arr); - eq("File \"splice_test.res\", line 101, characters 7-14", a, Belt_Array.concatMany([ - [1], - arr - ])); -} - -dynamic$1([ - 2, - 3, - 4 -]); - -dynamic$1([]); - -dynamic$1([ - 1, - 1, - 3 -]); - -let Pipe = { - dynamic: dynamic$1 -}; - -function f1(c) { - return Math.max(1, ...c); -} - -eq("File \"splice_test.res\", line 111, characters 3-10", Math.max(1, 2, 3), 3); - -eq("File \"splice_test.res\", line 112, characters 3-10", Math.max(1), 1); - -eq("File \"splice_test.res\", line 113, characters 3-10", Math.max(1, 1, 2, 3, 4, 5, 2, 3), 5); - -Mt.from_pair_suites("splice_test.res", suites.contents); - -exports.suites = suites; -exports.test_id = test_id; -exports.eq = eq; -exports.Caml_splice_call = Caml_splice_call; -exports.f00 = f00; -exports.dynamic = dynamic; -exports.dynamicNew = dynamicNew; -exports.dynamicFoo = dynamicFoo; -exports.Pipe = Pipe; -exports.f1 = f1; -/* Not a pure module */ diff --git a/tests/tests/src/splice_test.mjs b/tests/tests/src/splice_test.mjs new file mode 100644 index 0000000000..41c5c7975d --- /dev/null +++ b/tests/tests/src/splice_test.mjs @@ -0,0 +1,184 @@ +// Generated by ReScript, PLEASE EDIT WITH CARE + +import * as Mt from "./mt.mjs"; +import * as Belt_Array from "rescript/lib/es6/Belt_Array.js"; + +let suites = { + contents: /* [] */0 +}; + +let test_id = { + contents: 0 +}; + +function eq(loc, x, y) { + Mt.eq_suites(test_id, suites, loc, x, y); +} + +let Caml_splice_call = {}; + +Math.max(1); + +function f00(a, b) { + return a.send(b); +} + +let a = []; + +a.push(1, 2, 3, 4); + +eq("File \"splice_test.res\", line 25, characters 5-12", a, [ + 1, + 2, + 3, + 4 +]); + +function dynamic(arr) { + let a = []; + a.push(1, ...arr); + eq("File \"splice_test.res\", line 31, characters 5-12", a, Belt_Array.concatMany([ + [1], + arr + ])); +} + +dynamic([ + 2, + 3, + 4 +]); + +dynamic([]); + +dynamic([ + 1, + 1, + 3 +]); + +let a$1 = new Array(1, 2, 3, 4); + +eq("File \"splice_test.res\", line 46, characters 5-12", a$1, [ + 1, + 2, + 3, + 4 +]); + +function dynamicNew(arr) { + let a = new Array(1, 2, ...arr); + eq("File \"splice_test.res\", line 51, characters 5-12", a, Belt_Array.concatMany([ + [ + 1, + 2 + ], + arr + ])); +} + +dynamicNew([ + 3, + 4 +]); + +dynamicNew([]); + +dynamicNew([ + 1, + 3 +]); + +class Foo { + constructor(...names) { + this.names = names; + } +} +; + +let f = new Foo("a", "b", "c"); + +eq("File \"splice_test.res\", line 73, characters 5-12", f.names, [ + "a", + "b", + "c" +]); + +function dynamicFoo(arr) { + let f = new Foo(...arr); + eq("File \"splice_test.res\", line 78, characters 5-12", f.names, arr); +} + +dynamicFoo([]); + +dynamicFoo(["a"]); + +dynamicFoo([ + "a", + "b", + "c" +]); + +let a$2 = []; + +a$2.push(1, 2, 3, 4); + +eq("File \"splice_test.res\", line 95, characters 7-14", a$2, [ + 1, + 2, + 3, + 4 +]); + +function dynamic$1(arr) { + let a = []; + a.push(1, ...arr); + eq("File \"splice_test.res\", line 101, characters 7-14", a, Belt_Array.concatMany([ + [1], + arr + ])); +} + +dynamic$1([ + 2, + 3, + 4 +]); + +dynamic$1([]); + +dynamic$1([ + 1, + 1, + 3 +]); + +let Pipe = { + dynamic: dynamic$1 +}; + +function f1(c) { + return Math.max(1, ...c); +} + +eq("File \"splice_test.res\", line 111, characters 3-10", Math.max(1, 2, 3), 3); + +eq("File \"splice_test.res\", line 112, characters 3-10", Math.max(1), 1); + +eq("File \"splice_test.res\", line 113, characters 3-10", Math.max(1, 1, 2, 3, 4, 5, 2, 3), 5); + +Mt.from_pair_suites("splice_test.res", suites.contents); + +export { + suites, + test_id, + eq, + Caml_splice_call, + f00, + dynamic, + dynamicNew, + dynamicFoo, + Pipe, + f1, +} +/* Not a pure module */ diff --git a/tests/tests/src/string_bound_get_test.js b/tests/tests/src/string_bound_get_test.js deleted file mode 100644 index f175f52790..0000000000 --- a/tests/tests/src/string_bound_get_test.js +++ /dev/null @@ -1,24 +0,0 @@ -// Generated by ReScript, PLEASE EDIT WITH CARE -'use strict'; - - -let v = "ghos"; - -let u_a = v[0]; - -function u_b() { - return v[-1]; -} - -let u_c = "ghos"[0]; - -function u_d() { - return "ghos"[-1]; -} - -exports.v = v; -exports.u_a = u_a; -exports.u_b = u_b; -exports.u_c = u_c; -exports.u_d = u_d; -/* u_a Not a pure module */ diff --git a/tests/tests/src/string_bound_get_test.mjs b/tests/tests/src/string_bound_get_test.mjs new file mode 100644 index 0000000000..c581652a4d --- /dev/null +++ b/tests/tests/src/string_bound_get_test.mjs @@ -0,0 +1,25 @@ +// Generated by ReScript, PLEASE EDIT WITH CARE + + +let v = "ghos"; + +let u_a = v[0]; + +function u_b() { + return v[-1]; +} + +let u_c = "ghos"[0]; + +function u_d() { + return "ghos"[-1]; +} + +export { + v, + u_a, + u_b, + u_c, + u_d, +} +/* u_a Not a pure module */ diff --git a/tests/tests/src/string_constant_compare.js b/tests/tests/src/string_constant_compare.js deleted file mode 100644 index 62e69f6b6a..0000000000 --- a/tests/tests/src/string_constant_compare.js +++ /dev/null @@ -1,17 +0,0 @@ -// Generated by ReScript, PLEASE EDIT WITH CARE -'use strict'; - - -let a1 = true; - -let a2 = false; - -let a3 = "'" === "\'"; - -let a4 = "'" !== "\'"; - -exports.a1 = a1; -exports.a2 = a2; -exports.a3 = a3; -exports.a4 = a4; -/* No side effect */ diff --git a/tests/tests/src/string_constant_compare.mjs b/tests/tests/src/string_constant_compare.mjs new file mode 100644 index 0000000000..8fe5706c0c --- /dev/null +++ b/tests/tests/src/string_constant_compare.mjs @@ -0,0 +1,18 @@ +// Generated by ReScript, PLEASE EDIT WITH CARE + + +let a1 = true; + +let a2 = false; + +let a3 = "'" === "\'"; + +let a4 = "'" !== "\'"; + +export { + a1, + a2, + a3, + a4, +} +/* No side effect */ diff --git a/tests/tests/src/string_set.js b/tests/tests/src/string_set.js deleted file mode 100644 index b5262a9fb0..0000000000 --- a/tests/tests/src/string_set.js +++ /dev/null @@ -1,349 +0,0 @@ -// Generated by ReScript, PLEASE EDIT WITH CARE -'use strict'; - -let Set_gen = require("./set_gen.js"); -let Belt_List = require("rescript/lib/js/Belt_List.js"); -let Belt_Array = require("rescript/lib/js/Belt_Array.js"); -let Primitive_string = require("rescript/lib/js/Primitive_string.js"); - -let compare_elt = Primitive_string.compare; - -function split(x, tree) { - if (typeof tree !== "object") { - return [ - "Empty", - false, - "Empty" - ]; - } - let r = tree._2; - let v = tree._1; - let l = tree._0; - let c = Primitive_string.compare(x, v); - if (c === 0) { - return [ - l, - true, - r - ]; - } - if (c < 0) { - let match = split(x, l); - return [ - match[0], - match[1], - Set_gen.internal_join(match[2], v, r) - ]; - } - let match$1 = split(x, r); - return [ - Set_gen.internal_join(l, v, match$1[0]), - match$1[1], - match$1[2] - ]; -} - -function add(x, tree) { - if (typeof tree !== "object") { - return { - TAG: "Node", - _0: "Empty", - _1: x, - _2: "Empty", - _3: 1 - }; - } - let r = tree._2; - let v = tree._1; - let l = tree._0; - let c = Primitive_string.compare(x, v); - if (c === 0) { - return tree; - } else if (c < 0) { - return Set_gen.internal_bal(add(x, l), v, r); - } else { - return Set_gen.internal_bal(l, v, add(x, r)); - } -} - -function union(s1, s2) { - if (typeof s1 !== "object") { - return s2; - } - let h1 = s1._3; - let v1 = s1._1; - if (typeof s2 !== "object") { - return s1; - } - let h2 = s2._3; - let v2 = s2._1; - if (h1 >= h2) { - if (h2 === 1) { - return add(v2, s1); - } - let match = split(v1, s2); - return Set_gen.internal_join(union(s1._0, match[0]), v1, union(s1._2, match[2])); - } - if (h1 === 1) { - return add(v1, s2); - } - let match$1 = split(v2, s1); - return Set_gen.internal_join(union(match$1[0], s2._0), v2, union(match$1[2], s2._2)); -} - -function inter(s1, s2) { - if (typeof s1 !== "object") { - return "Empty"; - } - if (typeof s2 !== "object") { - return "Empty"; - } - let r1 = s1._2; - let v1 = s1._1; - let l1 = s1._0; - let match = split(v1, s2); - let l2 = match[0]; - if (match[1]) { - return Set_gen.internal_join(inter(l1, l2), v1, inter(r1, match[2])); - } else { - return Set_gen.internal_concat(inter(l1, l2), inter(r1, match[2])); - } -} - -function diff(s1, s2) { - if (typeof s1 !== "object") { - return "Empty"; - } - if (typeof s2 !== "object") { - return s1; - } - let r1 = s1._2; - let v1 = s1._1; - let l1 = s1._0; - let match = split(v1, s2); - let l2 = match[0]; - if (match[1]) { - return Set_gen.internal_concat(diff(l1, l2), diff(r1, match[2])); - } else { - return Set_gen.internal_join(diff(l1, l2), v1, diff(r1, match[2])); - } -} - -function mem(x, _tree) { - while (true) { - let tree = _tree; - if (typeof tree !== "object") { - return false; - } - let c = Primitive_string.compare(x, tree._1); - if (c === 0) { - return true; - } - _tree = c < 0 ? tree._0 : tree._2; - continue; - }; -} - -function remove(x, tree) { - if (typeof tree !== "object") { - return "Empty"; - } - let r = tree._2; - let v = tree._1; - let l = tree._0; - let c = Primitive_string.compare(x, v); - if (c === 0) { - return Set_gen.internal_merge(l, r); - } else if (c < 0) { - return Set_gen.internal_bal(remove(x, l), v, r); - } else { - return Set_gen.internal_bal(l, v, remove(x, r)); - } -} - -function compare(s1, s2) { - return Set_gen.compare(compare_elt, s1, s2); -} - -function equal(s1, s2) { - return Set_gen.compare(compare_elt, s1, s2) === 0; -} - -function subset(_s1, _s2) { - while (true) { - let s2 = _s2; - let s1 = _s1; - if (typeof s1 !== "object") { - return true; - } - let r1 = s1._2; - let v1 = s1._1; - let l1 = s1._0; - if (typeof s2 !== "object") { - return false; - } - let r2 = s2._2; - let l2 = s2._0; - let c = Primitive_string.compare(v1, s2._1); - if (c === 0) { - if (!subset(l1, l2)) { - return false; - } - _s2 = r2; - _s1 = r1; - continue; - } - if (c < 0) { - if (!subset({ - TAG: "Node", - _0: l1, - _1: v1, - _2: "Empty", - _3: 0 - }, l2)) { - return false; - } - _s1 = r1; - continue; - } - if (!subset({ - TAG: "Node", - _0: "Empty", - _1: v1, - _2: r1, - _3: 0 - }, r2)) { - return false; - } - _s1 = l1; - continue; - }; -} - -function find(x, _tree) { - while (true) { - let tree = _tree; - if (typeof tree !== "object") { - throw { - RE_EXN_ID: "Not_found", - Error: new Error() - }; - } - let v = tree._1; - let c = Primitive_string.compare(x, v); - if (c === 0) { - return v; - } - _tree = c < 0 ? tree._0 : tree._2; - continue; - }; -} - -function of_list(l) { - if (!l) { - return Set_gen.empty; - } - let match = l.tl; - let x0 = l.hd; - if (!match) { - return Set_gen.singleton(x0); - } - let match$1 = match.tl; - let x1 = match.hd; - if (!match$1) { - return add(x1, Set_gen.singleton(x0)); - } - let match$2 = match$1.tl; - let x2 = match$1.hd; - if (!match$2) { - return add(x2, add(x1, Set_gen.singleton(x0))); - } - let match$3 = match$2.tl; - let x3 = match$2.hd; - if (match$3) { - if (match$3.tl) { - return Set_gen.of_sorted_list(Belt_List.sort(l, compare_elt)); - } else { - return add(match$3.hd, add(x3, add(x2, add(x1, Set_gen.singleton(x0))))); - } - } else { - return add(x3, add(x2, add(x1, Set_gen.singleton(x0)))); - } -} - -function of_array(l) { - return Belt_Array.reduceReverse(l, Set_gen.empty, (acc, x) => add(x, acc)); -} - -function invariant(t) { - Set_gen.check(t); - return Set_gen.is_ordered(compare_elt, t); -} - -let $$String; - -let empty = Set_gen.empty; - -let is_empty = Set_gen.is_empty; - -let iter = Set_gen.iter; - -let fold = Set_gen.fold; - -let for_all = Set_gen.for_all; - -let exists = Set_gen.exists; - -let singleton = Set_gen.singleton; - -let cardinal = Set_gen.cardinal; - -let elements = Set_gen.elements; - -let min_elt = Set_gen.min_elt; - -let max_elt = Set_gen.max_elt; - -let choose = Set_gen.choose; - -let partition = Set_gen.partition; - -let filter = Set_gen.filter; - -let of_sorted_list = Set_gen.of_sorted_list; - -let of_sorted_array = Set_gen.of_sorted_array; - -exports.$$String = $$String; -exports.compare_elt = compare_elt; -exports.empty = empty; -exports.is_empty = is_empty; -exports.iter = iter; -exports.fold = fold; -exports.for_all = for_all; -exports.exists = exists; -exports.singleton = singleton; -exports.cardinal = cardinal; -exports.elements = elements; -exports.min_elt = min_elt; -exports.max_elt = max_elt; -exports.choose = choose; -exports.partition = partition; -exports.filter = filter; -exports.of_sorted_list = of_sorted_list; -exports.of_sorted_array = of_sorted_array; -exports.split = split; -exports.add = add; -exports.union = union; -exports.inter = inter; -exports.diff = diff; -exports.mem = mem; -exports.remove = remove; -exports.compare = compare; -exports.equal = equal; -exports.subset = subset; -exports.find = find; -exports.of_list = of_list; -exports.of_array = of_array; -exports.invariant = invariant; -/* No side effect */ diff --git a/tests/tests/src/string_set.mjs b/tests/tests/src/string_set.mjs new file mode 100644 index 0000000000..e5ba524aef --- /dev/null +++ b/tests/tests/src/string_set.mjs @@ -0,0 +1,350 @@ +// Generated by ReScript, PLEASE EDIT WITH CARE + +import * as Set_gen from "./set_gen.mjs"; +import * as Belt_List from "rescript/lib/es6/Belt_List.js"; +import * as Belt_Array from "rescript/lib/es6/Belt_Array.js"; +import * as Primitive_string from "rescript/lib/es6/Primitive_string.js"; + +let compare_elt = Primitive_string.compare; + +function split(x, tree) { + if (typeof tree !== "object") { + return [ + "Empty", + false, + "Empty" + ]; + } + let r = tree._2; + let v = tree._1; + let l = tree._0; + let c = Primitive_string.compare(x, v); + if (c === 0) { + return [ + l, + true, + r + ]; + } + if (c < 0) { + let match = split(x, l); + return [ + match[0], + match[1], + Set_gen.internal_join(match[2], v, r) + ]; + } + let match$1 = split(x, r); + return [ + Set_gen.internal_join(l, v, match$1[0]), + match$1[1], + match$1[2] + ]; +} + +function add(x, tree) { + if (typeof tree !== "object") { + return { + TAG: "Node", + _0: "Empty", + _1: x, + _2: "Empty", + _3: 1 + }; + } + let r = tree._2; + let v = tree._1; + let l = tree._0; + let c = Primitive_string.compare(x, v); + if (c === 0) { + return tree; + } else if (c < 0) { + return Set_gen.internal_bal(add(x, l), v, r); + } else { + return Set_gen.internal_bal(l, v, add(x, r)); + } +} + +function union(s1, s2) { + if (typeof s1 !== "object") { + return s2; + } + let h1 = s1._3; + let v1 = s1._1; + if (typeof s2 !== "object") { + return s1; + } + let h2 = s2._3; + let v2 = s2._1; + if (h1 >= h2) { + if (h2 === 1) { + return add(v2, s1); + } + let match = split(v1, s2); + return Set_gen.internal_join(union(s1._0, match[0]), v1, union(s1._2, match[2])); + } + if (h1 === 1) { + return add(v1, s2); + } + let match$1 = split(v2, s1); + return Set_gen.internal_join(union(match$1[0], s2._0), v2, union(match$1[2], s2._2)); +} + +function inter(s1, s2) { + if (typeof s1 !== "object") { + return "Empty"; + } + if (typeof s2 !== "object") { + return "Empty"; + } + let r1 = s1._2; + let v1 = s1._1; + let l1 = s1._0; + let match = split(v1, s2); + let l2 = match[0]; + if (match[1]) { + return Set_gen.internal_join(inter(l1, l2), v1, inter(r1, match[2])); + } else { + return Set_gen.internal_concat(inter(l1, l2), inter(r1, match[2])); + } +} + +function diff(s1, s2) { + if (typeof s1 !== "object") { + return "Empty"; + } + if (typeof s2 !== "object") { + return s1; + } + let r1 = s1._2; + let v1 = s1._1; + let l1 = s1._0; + let match = split(v1, s2); + let l2 = match[0]; + if (match[1]) { + return Set_gen.internal_concat(diff(l1, l2), diff(r1, match[2])); + } else { + return Set_gen.internal_join(diff(l1, l2), v1, diff(r1, match[2])); + } +} + +function mem(x, _tree) { + while (true) { + let tree = _tree; + if (typeof tree !== "object") { + return false; + } + let c = Primitive_string.compare(x, tree._1); + if (c === 0) { + return true; + } + _tree = c < 0 ? tree._0 : tree._2; + continue; + }; +} + +function remove(x, tree) { + if (typeof tree !== "object") { + return "Empty"; + } + let r = tree._2; + let v = tree._1; + let l = tree._0; + let c = Primitive_string.compare(x, v); + if (c === 0) { + return Set_gen.internal_merge(l, r); + } else if (c < 0) { + return Set_gen.internal_bal(remove(x, l), v, r); + } else { + return Set_gen.internal_bal(l, v, remove(x, r)); + } +} + +function compare(s1, s2) { + return Set_gen.compare(compare_elt, s1, s2); +} + +function equal(s1, s2) { + return Set_gen.compare(compare_elt, s1, s2) === 0; +} + +function subset(_s1, _s2) { + while (true) { + let s2 = _s2; + let s1 = _s1; + if (typeof s1 !== "object") { + return true; + } + let r1 = s1._2; + let v1 = s1._1; + let l1 = s1._0; + if (typeof s2 !== "object") { + return false; + } + let r2 = s2._2; + let l2 = s2._0; + let c = Primitive_string.compare(v1, s2._1); + if (c === 0) { + if (!subset(l1, l2)) { + return false; + } + _s2 = r2; + _s1 = r1; + continue; + } + if (c < 0) { + if (!subset({ + TAG: "Node", + _0: l1, + _1: v1, + _2: "Empty", + _3: 0 + }, l2)) { + return false; + } + _s1 = r1; + continue; + } + if (!subset({ + TAG: "Node", + _0: "Empty", + _1: v1, + _2: r1, + _3: 0 + }, r2)) { + return false; + } + _s1 = l1; + continue; + }; +} + +function find(x, _tree) { + while (true) { + let tree = _tree; + if (typeof tree !== "object") { + throw { + RE_EXN_ID: "Not_found", + Error: new Error() + }; + } + let v = tree._1; + let c = Primitive_string.compare(x, v); + if (c === 0) { + return v; + } + _tree = c < 0 ? tree._0 : tree._2; + continue; + }; +} + +function of_list(l) { + if (!l) { + return Set_gen.empty; + } + let match = l.tl; + let x0 = l.hd; + if (!match) { + return Set_gen.singleton(x0); + } + let match$1 = match.tl; + let x1 = match.hd; + if (!match$1) { + return add(x1, Set_gen.singleton(x0)); + } + let match$2 = match$1.tl; + let x2 = match$1.hd; + if (!match$2) { + return add(x2, add(x1, Set_gen.singleton(x0))); + } + let match$3 = match$2.tl; + let x3 = match$2.hd; + if (match$3) { + if (match$3.tl) { + return Set_gen.of_sorted_list(Belt_List.sort(l, compare_elt)); + } else { + return add(match$3.hd, add(x3, add(x2, add(x1, Set_gen.singleton(x0))))); + } + } else { + return add(x3, add(x2, add(x1, Set_gen.singleton(x0)))); + } +} + +function of_array(l) { + return Belt_Array.reduceReverse(l, Set_gen.empty, (acc, x) => add(x, acc)); +} + +function invariant(t) { + Set_gen.check(t); + return Set_gen.is_ordered(compare_elt, t); +} + +let $$String; + +let empty = Set_gen.empty; + +let is_empty = Set_gen.is_empty; + +let iter = Set_gen.iter; + +let fold = Set_gen.fold; + +let for_all = Set_gen.for_all; + +let exists = Set_gen.exists; + +let singleton = Set_gen.singleton; + +let cardinal = Set_gen.cardinal; + +let elements = Set_gen.elements; + +let min_elt = Set_gen.min_elt; + +let max_elt = Set_gen.max_elt; + +let choose = Set_gen.choose; + +let partition = Set_gen.partition; + +let filter = Set_gen.filter; + +let of_sorted_list = Set_gen.of_sorted_list; + +let of_sorted_array = Set_gen.of_sorted_array; + +export { + $$String, + compare_elt, + empty, + is_empty, + iter, + fold, + for_all, + exists, + singleton, + cardinal, + elements, + min_elt, + max_elt, + choose, + partition, + filter, + of_sorted_list, + of_sorted_array, + split, + add, + union, + inter, + diff, + mem, + remove, + compare, + equal, + subset, + find, + of_list, + of_array, + invariant, +} +/* No side effect */ diff --git a/tests/tests/src/string_set_test.js b/tests/tests/src/string_set_test.js deleted file mode 100644 index 74d8022ecd..0000000000 --- a/tests/tests/src/string_set_test.js +++ /dev/null @@ -1,43 +0,0 @@ -// Generated by ReScript, PLEASE EDIT WITH CARE -'use strict'; - -let Mt = require("./mt.js"); -let String_set = require("./string_set.js"); - -let suites = { - contents: /* [] */0 -}; - -let test_id = { - contents: 0 -}; - -function eq(loc, x, y) { - test_id.contents = test_id.contents + 1 | 0; - suites.contents = { - hd: [ - loc + (" id " + test_id.contents.toString()), - () => ({ - TAG: "Eq", - _0: x, - _1: y - }) - ], - tl: suites.contents - }; -} - -let s = String_set.empty; - -for (let i = 0; i <= 99999; ++i) { - s = String_set.add(i.toString(), s); -} - -eq("File \"string_set_test.res\", line 18, characters 5-12", String_set.cardinal(s), 100000); - -Mt.from_pair_suites("String_set_test", suites.contents); - -exports.suites = suites; -exports.test_id = test_id; -exports.eq = eq; -/* Not a pure module */ diff --git a/tests/tests/src/string_set_test.mjs b/tests/tests/src/string_set_test.mjs new file mode 100644 index 0000000000..98f9851391 --- /dev/null +++ b/tests/tests/src/string_set_test.mjs @@ -0,0 +1,44 @@ +// Generated by ReScript, PLEASE EDIT WITH CARE + +import * as Mt from "./mt.mjs"; +import * as String_set from "./string_set.mjs"; + +let suites = { + contents: /* [] */0 +}; + +let test_id = { + contents: 0 +}; + +function eq(loc, x, y) { + test_id.contents = test_id.contents + 1 | 0; + suites.contents = { + hd: [ + loc + (" id " + test_id.contents.toString()), + () => ({ + TAG: "Eq", + _0: x, + _1: y + }) + ], + tl: suites.contents + }; +} + +let s = String_set.empty; + +for (let i = 0; i <= 99999; ++i) { + s = String_set.add(i.toString(), s); +} + +eq("File \"string_set_test.res\", line 18, characters 5-12", String_set.cardinal(s), 100000); + +Mt.from_pair_suites("String_set_test", suites.contents); + +export { + suites, + test_id, + eq, +} +/* Not a pure module */ diff --git a/tests/tests/src/string_unicode_test.js b/tests/tests/src/string_unicode_test.js deleted file mode 100644 index 3386e50e01..0000000000 --- a/tests/tests/src/string_unicode_test.js +++ /dev/null @@ -1,59 +0,0 @@ -// Generated by ReScript, PLEASE EDIT WITH CARE -'use strict'; - -let Mt = require("./mt.js"); - -let suites = { - contents: /* [] */0 -}; - -let test_id = { - contents: 0 -}; - -function eq(loc, x, y) { - test_id.contents = test_id.contents + 1 | 0; - suites.contents = { - hd: [ - loc + (" id " + test_id.contents.toString()), - () => ({ - TAG: "Eq", - _0: x, - _1: y - }) - ], - tl: suites.contents - }; -} - -console.log("你好"); - -console.log("你好"); - -console.log("你好"); - -function f(x) { - if (x !== 333) { - if (x >= 256) { - return 3; - } else { - return 0; - } - } else { - return 2; - } -} - -eq("File \"string_unicode_test.res\", line 26, characters 5-12", f(/* '{' */123), 0); - -eq("File \"string_unicode_test.res\", line 27, characters 5-12", f(/* 'ō' */333), 2); - -eq("File \"string_unicode_test.res\", line 28, characters 5-12", f(/* 'Ƽ' */444), 3); - -Mt.from_pair_suites("string_unicode_test.res", suites.contents); - -exports.suites = suites; -exports.test_id = test_id; -exports.eq = eq; -exports.f = f; -/* Not a pure module */ diff --git a/tests/tests/src/string_unicode_test.mjs b/tests/tests/src/string_unicode_test.mjs new file mode 100644 index 0000000000..7df5ee7745 --- /dev/null +++ b/tests/tests/src/string_unicode_test.mjs @@ -0,0 +1,60 @@ +// Generated by ReScript, PLEASE EDIT WITH CARE + +import * as Mt from "./mt.mjs"; + +let suites = { + contents: /* [] */0 +}; + +let test_id = { + contents: 0 +}; + +function eq(loc, x, y) { + test_id.contents = test_id.contents + 1 | 0; + suites.contents = { + hd: [ + loc + (" id " + test_id.contents.toString()), + () => ({ + TAG: "Eq", + _0: x, + _1: y + }) + ], + tl: suites.contents + }; +} + +console.log("你好"); + +console.log("你好"); + +console.log("你好"); + +function f(x) { + if (x !== 333) { + if (x >= 256) { + return 3; + } else { + return 0; + } + } else { + return 2; + } +} + +eq("File \"string_unicode_test.res\", line 26, characters 5-12", f(/* '{' */123), 0); + +eq("File \"string_unicode_test.res\", line 27, characters 5-12", f(/* 'ō' */333), 2); + +eq("File \"string_unicode_test.res\", line 28, characters 5-12", f(/* 'Ƽ' */444), 3); + +Mt.from_pair_suites("string_unicode_test.res", suites.contents); + +export { + suites, + test_id, + eq, + f, +} +/* Not a pure module */ diff --git a/tests/tests/src/stringmatch_test.js b/tests/tests/src/stringmatch_test.js deleted file mode 100644 index f517fd954e..0000000000 --- a/tests/tests/src/stringmatch_test.js +++ /dev/null @@ -1,4299 +0,0 @@ -// Generated by ReScript, PLEASE EDIT WITH CARE -'use strict'; - - -function tst01(s) { - if (s === "") { - return 0; - } else { - return 1; - } -} - -if (tst01("") !== 0) { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "stringmatch_test.res", - 22, - 2 - ], - Error: new Error() - }; -} - -if (tst01("\x00\x00\x00\x03") !== 1) { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "stringmatch_test.res", - 23, - 2 - ], - Error: new Error() - }; -} - -if (tst01("\x00\x00\x00\x00\x00\x00\x00\x07") !== 1) { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "stringmatch_test.res", - 24, - 2 - ], - Error: new Error() - }; -} - -function tst02(s) { - let len = s.length; - if (s === "") { - if (len >= 0) { - return 1; - } - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "stringmatch_test.res", - 33, - 21 - ], - Error: new Error() - }; - } - if (len === 0) { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "stringmatch_test.res", - 35, - 21 - ], - Error: new Error() - }; - } - if (s === "A") { - return 2; - } else { - return 3; - } -} - -if (tst02("") !== 1) { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "stringmatch_test.res", - 42, - 2 - ], - Error: new Error() - }; -} - -if (tst02("A") !== 2) { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "stringmatch_test.res", - 43, - 2 - ], - Error: new Error() - }; -} - -if (tst02("B") !== 3) { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "stringmatch_test.res", - 44, - 2 - ], - Error: new Error() - }; -} - -if (tst02("\x00\x00\x00\x00\x00\x00\x00\x07") !== 3) { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "stringmatch_test.res", - 45, - 2 - ], - Error: new Error() - }; -} - -if (tst02("\x00\x00\x00\x03") !== 3) { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "stringmatch_test.res", - 46, - 2 - ], - Error: new Error() - }; -} - -function tst03(s) { - switch (s) { - case "app_const" : - return 5; - case "app_const_const" : - return 9; - case "app_const_env" : - return 11; - case "app_const_meth" : - return 12; - case "app_const_var" : - return 10; - case "app_env" : - return 7; - case "app_env_const" : - return 14; - case "app_meth" : - return 8; - case "app_meth_const" : - return 15; - case "app_var" : - return 6; - case "app_var_const" : - return 13; - case "get_const" : - return 0; - case "get_env" : - return 2; - case "get_meth" : - return 3; - case "get_var" : - return 1; - case "meth_app_const" : - return 16; - case "meth_app_env" : - return 18; - case "meth_app_meth" : - return 19; - case "meth_app_var" : - return 17; - case "send_const" : - return 20; - case "send_env" : - return 22; - case "send_meth" : - return 23; - case "send_var" : - return 21; - case "set_var" : - return 4; - default: - return -1; - } -} - -if (tst03("get_const") !== 0) { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "stringmatch_test.res", - 131, - 2 - ], - Error: new Error() - }; -} - -if (tst03("set_congt") !== -1) { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "stringmatch_test.res", - 132, - 2 - ], - Error: new Error() - }; -} - -if (tst03("get_var") !== 1) { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "stringmatch_test.res", - 133, - 2 - ], - Error: new Error() - }; -} - -if (tst03("gat_ver") !== -1) { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "stringmatch_test.res", - 134, - 2 - ], - Error: new Error() - }; -} - -if (tst03("get_env") !== 2) { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "stringmatch_test.res", - 135, - 2 - ], - Error: new Error() - }; -} - -if (tst03("get_env") !== 2) { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "stringmatch_test.res", - 136, - 2 - ], - Error: new Error() - }; -} - -if (tst03("get_meth") !== 3) { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "stringmatch_test.res", - 137, - 2 - ], - Error: new Error() - }; -} - -if (tst03("met_geth") !== -1) { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "stringmatch_test.res", - 138, - 2 - ], - Error: new Error() - }; -} - -if (tst03("set_var") !== 4) { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "stringmatch_test.res", - 139, - 2 - ], - Error: new Error() - }; -} - -if (tst03("sev_tar") !== -1) { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "stringmatch_test.res", - 140, - 2 - ], - Error: new Error() - }; -} - -if (tst03("app_const") !== 5) { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "stringmatch_test.res", - 141, - 2 - ], - Error: new Error() - }; -} - -if (tst03("ppa_const") !== -1) { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "stringmatch_test.res", - 142, - 2 - ], - Error: new Error() - }; -} - -if (tst03("app_var") !== 6) { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "stringmatch_test.res", - 143, - 2 - ], - Error: new Error() - }; -} - -if (tst03("app_var") !== 6) { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "stringmatch_test.res", - 144, - 2 - ], - Error: new Error() - }; -} - -if (tst03("app_env") !== 7) { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "stringmatch_test.res", - 145, - 2 - ], - Error: new Error() - }; -} - -if (tst03("epp_anv") !== -1) { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "stringmatch_test.res", - 146, - 2 - ], - Error: new Error() - }; -} - -if (tst03("app_meth") !== 8) { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "stringmatch_test.res", - 147, - 2 - ], - Error: new Error() - }; -} - -if (tst03("atp_meph") !== -1) { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "stringmatch_test.res", - 148, - 2 - ], - Error: new Error() - }; -} - -if (tst03("app_const_const") !== 9) { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "stringmatch_test.res", - 149, - 2 - ], - Error: new Error() - }; -} - -if (tst03("app_const_const") !== 9) { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "stringmatch_test.res", - 150, - 2 - ], - Error: new Error() - }; -} - -if (tst03("app_const_var") !== 10) { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "stringmatch_test.res", - 151, - 2 - ], - Error: new Error() - }; -} - -if (tst03("atp_consp_var") !== -1) { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "stringmatch_test.res", - 152, - 2 - ], - Error: new Error() - }; -} - -if (tst03("app_const_env") !== 11) { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "stringmatch_test.res", - 153, - 2 - ], - Error: new Error() - }; -} - -if (tst03("app_constne_v") !== -1) { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "stringmatch_test.res", - 154, - 2 - ], - Error: new Error() - }; -} - -if (tst03("app_const_meth") !== 12) { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "stringmatch_test.res", - 155, - 2 - ], - Error: new Error() - }; -} - -if (tst03("spp_conat_meth") !== -1) { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "stringmatch_test.res", - 156, - 2 - ], - Error: new Error() - }; -} - -if (tst03("app_var_const") !== 13) { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "stringmatch_test.res", - 157, - 2 - ], - Error: new Error() - }; -} - -if (tst03("app_va_rconst") !== -1) { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "stringmatch_test.res", - 158, - 2 - ], - Error: new Error() - }; -} - -if (tst03("app_env_const") !== 14) { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "stringmatch_test.res", - 159, - 2 - ], - Error: new Error() - }; -} - -if (tst03("app_env_const") !== 14) { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "stringmatch_test.res", - 160, - 2 - ], - Error: new Error() - }; -} - -if (tst03("app_meth_const") !== 15) { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "stringmatch_test.res", - 161, - 2 - ], - Error: new Error() - }; -} - -if (tst03("app_teth_consm") !== -1) { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "stringmatch_test.res", - 162, - 2 - ], - Error: new Error() - }; -} - -if (tst03("meth_app_const") !== 16) { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "stringmatch_test.res", - 163, - 2 - ], - Error: new Error() - }; -} - -if (tst03("math_epp_const") !== -1) { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "stringmatch_test.res", - 164, - 2 - ], - Error: new Error() - }; -} - -if (tst03("meth_app_var") !== 17) { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "stringmatch_test.res", - 165, - 2 - ], - Error: new Error() - }; -} - -if (tst03("meth_app_var") !== 17) { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "stringmatch_test.res", - 166, - 2 - ], - Error: new Error() - }; -} - -if (tst03("meth_app_env") !== 18) { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "stringmatch_test.res", - 167, - 2 - ], - Error: new Error() - }; -} - -if (tst03("eeth_app_mnv") !== -1) { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "stringmatch_test.res", - 168, - 2 - ], - Error: new Error() - }; -} - -if (tst03("meth_app_meth") !== 19) { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "stringmatch_test.res", - 169, - 2 - ], - Error: new Error() - }; -} - -if (tst03("meth_apt_meph") !== -1) { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "stringmatch_test.res", - 170, - 2 - ], - Error: new Error() - }; -} - -if (tst03("send_const") !== 20) { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "stringmatch_test.res", - 171, - 2 - ], - Error: new Error() - }; -} - -if (tst03("tend_conss") !== -1) { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "stringmatch_test.res", - 172, - 2 - ], - Error: new Error() - }; -} - -if (tst03("send_var") !== 21) { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "stringmatch_test.res", - 173, - 2 - ], - Error: new Error() - }; -} - -if (tst03("serd_van") !== -1) { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "stringmatch_test.res", - 174, - 2 - ], - Error: new Error() - }; -} - -if (tst03("send_env") !== 22) { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "stringmatch_test.res", - 175, - 2 - ], - Error: new Error() - }; -} - -if (tst03("sen_denv") !== -1) { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "stringmatch_test.res", - 176, - 2 - ], - Error: new Error() - }; -} - -if (tst03("send_meth") !== 23) { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "stringmatch_test.res", - 177, - 2 - ], - Error: new Error() - }; -} - -if (tst03("tend_mesh") !== -1) { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "stringmatch_test.res", - 178, - 2 - ], - Error: new Error() - }; -} - -function tst04(s) { - switch (s) { - case "AAAAAAAA" : - return 0; - case "AAAAAAAAAAAAAAAA" : - return 1; - case "AAAAAAAAAAAAAAAAAAAAAAAA" : - return 2; - case "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA" : - return 3; - case "BBBBBBBB" : - return 4; - case "BBBBBBBBBBBBBBBB" : - return 5; - case "BBBBBBBBBBBBBBBBBBBBBBBB" : - return 6; - case "BBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBB" : - return 7; - case "CCCCCCCC" : - return 8; - case "CCCCCCCCCCCCCCCC" : - return 9; - case "CCCCCCCCCCCCCCCCCCCCCCCC" : - return 10; - case "CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC" : - return 11; - default: - return -1; - } -} - -if (tst04("AAAAAAAA") !== 0) { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "stringmatch_test.res", - 215, - 2 - ], - Error: new Error() - }; -} - -if (tst04("AAAAAAAAAAAAAAAA") !== 1) { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "stringmatch_test.res", - 216, - 2 - ], - Error: new Error() - }; -} - -if (tst04("AAAAAAAAAAAAAAAAAAAAAAAA") !== 2) { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "stringmatch_test.res", - 217, - 2 - ], - Error: new Error() - }; -} - -if (tst04("AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA") !== 3) { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "stringmatch_test.res", - 218, - 2 - ], - Error: new Error() - }; -} - -if (tst04("BBBBBBBB") !== 4) { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "stringmatch_test.res", - 219, - 2 - ], - Error: new Error() - }; -} - -if (tst04("BBBBBBBBBBBBBBBB") !== 5) { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "stringmatch_test.res", - 220, - 2 - ], - Error: new Error() - }; -} - -if (tst04("BBBBBBBBBBBBBBBBBBBBBBBB") !== 6) { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "stringmatch_test.res", - 221, - 2 - ], - Error: new Error() - }; -} - -if (tst04("BBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBB") !== 7) { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "stringmatch_test.res", - 222, - 2 - ], - Error: new Error() - }; -} - -if (tst04("CCCCCCCC") !== 8) { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "stringmatch_test.res", - 223, - 2 - ], - Error: new Error() - }; -} - -if (tst04("CCCCCCCCCCCCCCCC") !== 9) { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "stringmatch_test.res", - 224, - 2 - ], - Error: new Error() - }; -} - -if (tst04("CCCCCCCCCCCCCCCCCCCCCCCC") !== 10) { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "stringmatch_test.res", - 225, - 2 - ], - Error: new Error() - }; -} - -if (tst04("CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC") !== 11) { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "stringmatch_test.res", - 226, - 2 - ], - Error: new Error() - }; -} - -if (tst04("") !== -1) { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "stringmatch_test.res", - 227, - 2 - ], - Error: new Error() - }; -} - -if (tst04("DDD") !== -1) { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "stringmatch_test.res", - 228, - 2 - ], - Error: new Error() - }; -} - -if (tst04("DDDDDDD") !== -1) { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "stringmatch_test.res", - 229, - 2 - ], - Error: new Error() - }; -} - -if (tst04("AAADDDD") !== -1) { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "stringmatch_test.res", - 230, - 2 - ], - Error: new Error() - }; -} - -if (tst04("AAAAAAADDDDDDDD") !== -1) { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "stringmatch_test.res", - 231, - 2 - ], - Error: new Error() - }; -} - -if (tst04("AAAAAAADDDD") !== -1) { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "stringmatch_test.res", - 232, - 2 - ], - Error: new Error() - }; -} - -if (tst04("AAAAAAAAAAAAAAADDDD") !== -1) { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "stringmatch_test.res", - 233, - 2 - ], - Error: new Error() - }; -} - -function tst05(s) { - switch (s) { - case "AAA" : - return 0; - case "AAAA" : - return 1; - case "AAAAA" : - return 2; - case "AAAAAA" : - return 3; - case "AAAAAAA" : - return 4; - case "AAAAAAAAAAAA" : - return 5; - case "AAAAAAAAAAAAAAAA" : - return 6; - case "AAAAAAAAAAAAAAAAAAAA" : - return 7; - case "BBB" : - return 8; - case "BBBB" : - return 9; - case "BBBBB" : - return 10; - case "BBBBBB" : - return 11; - case "BBBBBBB" : - return 12; - default: - return -1; - } -} - -if (tst05("AAA") !== 0) { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "stringmatch_test.res", - 272, - 2 - ], - Error: new Error() - }; -} - -if (tst05("AAAA") !== 1) { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "stringmatch_test.res", - 273, - 2 - ], - Error: new Error() - }; -} - -if (tst05("AAAAA") !== 2) { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "stringmatch_test.res", - 274, - 2 - ], - Error: new Error() - }; -} - -if (tst05("AAAAAA") !== 3) { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "stringmatch_test.res", - 275, - 2 - ], - Error: new Error() - }; -} - -if (tst05("AAAAAAA") !== 4) { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "stringmatch_test.res", - 276, - 2 - ], - Error: new Error() - }; -} - -if (tst05("AAAAAAAAAAAA") !== 5) { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "stringmatch_test.res", - 277, - 2 - ], - Error: new Error() - }; -} - -if (tst05("AAAAAAAAAAAAAAAA") !== 6) { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "stringmatch_test.res", - 278, - 2 - ], - Error: new Error() - }; -} - -if (tst05("AAAAAAAAAAAAAAAAAAAA") !== 7) { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "stringmatch_test.res", - 279, - 2 - ], - Error: new Error() - }; -} - -if (tst05("BBB") !== 8) { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "stringmatch_test.res", - 280, - 2 - ], - Error: new Error() - }; -} - -if (tst05("BBBB") !== 9) { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "stringmatch_test.res", - 281, - 2 - ], - Error: new Error() - }; -} - -if (tst05("BBBBB") !== 10) { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "stringmatch_test.res", - 282, - 2 - ], - Error: new Error() - }; -} - -if (tst05("BBBBBB") !== 11) { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "stringmatch_test.res", - 283, - 2 - ], - Error: new Error() - }; -} - -if (tst05("BBBBBBB") !== 12) { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "stringmatch_test.res", - 284, - 2 - ], - Error: new Error() - }; -} - -if (tst05("") !== -1) { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "stringmatch_test.res", - 285, - 2 - ], - Error: new Error() - }; -} - -if (tst05("AAD") !== -1) { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "stringmatch_test.res", - 286, - 2 - ], - Error: new Error() - }; -} - -if (tst05("AAAD") !== -1) { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "stringmatch_test.res", - 287, - 2 - ], - Error: new Error() - }; -} - -if (tst05("AAAAAAD") !== -1) { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "stringmatch_test.res", - 288, - 2 - ], - Error: new Error() - }; -} - -if (tst05("AAAAAAAD") !== -1) { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "stringmatch_test.res", - 289, - 2 - ], - Error: new Error() - }; -} - -if (tst05("BBD") !== -1) { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "stringmatch_test.res", - 290, - 2 - ], - Error: new Error() - }; -} - -if (tst05("BBBD") !== -1) { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "stringmatch_test.res", - 291, - 2 - ], - Error: new Error() - }; -} - -if (tst05("BBBBBBD") !== -1) { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "stringmatch_test.res", - 292, - 2 - ], - Error: new Error() - }; -} - -if (tst05("BBBBBBBD") !== -1) { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "stringmatch_test.res", - 293, - 2 - ], - Error: new Error() - }; -} - -let s00 = "and"; - -let t00 = "nad"; - -let s01 = "as"; - -let t01 = "sa"; - -let s02 = "assert"; - -let t02 = "asesrt"; - -let s03 = "begin"; - -let t03 = "negib"; - -let s04 = "class"; - -let t04 = "lcass"; - -let s05 = "constraint"; - -let t05 = "constiarnt"; - -let s06 = "do"; - -let t06 = "od"; - -let s07 = "done"; - -let t07 = "eond"; - -let s08 = "downto"; - -let t08 = "dowtno"; - -let s09 = "else"; - -let t09 = "lese"; - -let s10 = "end"; - -let t10 = "edn"; - -let s11 = "exception"; - -let t11 = "exception"; - -let s12 = "external"; - -let t12 = "external"; - -let s13 = "false"; - -let t13 = "fslae"; - -let s14 = "for"; - -let t14 = "ofr"; - -let s15 = "fun"; - -let t15 = "fnu"; - -let s16 = "function"; - -let t16 = "function"; - -let s17 = "functor"; - -let t17 = "ounctfr"; - -let s18 = "if"; - -let t18 = "fi"; - -let s19 = "in"; - -let t19 = "in"; - -let s20 = "include"; - -let t20 = "inculde"; - -let s21 = "inherit"; - -let t21 = "iehnrit"; - -let s22 = "initializer"; - -let t22 = "enitializir"; - -let s23 = "lazy"; - -let t23 = "zaly"; - -let s24 = "let"; - -let t24 = "elt"; - -let s25 = "match"; - -let t25 = "match"; - -let s26 = "method"; - -let t26 = "methdo"; - -let s27 = "module"; - -let t27 = "modelu"; - -let s28 = "mutable"; - -let t28 = "butamle"; - -let s29 = "new"; - -let t29 = "wen"; - -let s30 = "object"; - -let t30 = "objcet"; - -let s31 = "of"; - -let t31 = "of"; - -let s32 = "open"; - -let t32 = "epon"; - -let s33 = "or"; - -let t33 = "ro"; - -let s34 = "private"; - -let t34 = "privaet"; - -let s35 = "rec"; - -let t35 = "rec"; - -let s36 = "sig"; - -let t36 = "gis"; - -let s37 = "struct"; - -let t37 = "scrutt"; - -let s38 = "then"; - -let t38 = "hten"; - -let s39 = "to"; - -let t39 = "to"; - -let s40 = "true"; - -let t40 = "teur"; - -let s41 = "try"; - -let t41 = "try"; - -let s42 = "type"; - -let t42 = "pyte"; - -let s43 = "val"; - -let t43 = "val"; - -let s44 = "virtual"; - -let t44 = "vritual"; - -let s45 = "when"; - -let t45 = "whne"; - -let s46 = "while"; - -let t46 = "wlihe"; - -let s47 = "with"; - -let t47 = "iwth"; - -let s48 = "mod"; - -let t48 = "mod"; - -let s49 = "land"; - -let t49 = "alnd"; - -let s50 = "lor"; - -let t50 = "rol"; - -let s51 = "lxor"; - -let t51 = "lxor"; - -let s52 = "lsl"; - -let t52 = "lsl"; - -let s53 = "lsr"; - -let t53 = "lsr"; - -let s54 = "asr"; - -let t54 = "sar"; - -let s55 = "A"; - -let t55 = "A"; - -let s56 = "AA"; - -let t56 = "AA"; - -let s57 = "AAA"; - -let t57 = "AAA"; - -let s58 = "AAAA"; - -let t58 = "AAAA"; - -let s59 = "AAAAA"; - -let t59 = "AAAAA"; - -let s60 = "AAAAAA"; - -let t60 = "AAAAAA"; - -let s61 = "AAAAAAA"; - -let t61 = "AAAAAAA"; - -let s62 = "AAAAAAAA"; - -let t62 = "AAAAAAAA"; - -let s63 = "AAAAAAAAA"; - -let t63 = "AAAAAAAAA"; - -let s64 = "AAAAAAAAAA"; - -let t64 = "AAAAAAAAAA"; - -let s65 = "AAAAAAAAAAA"; - -let t65 = "AAAAAAAAAAA"; - -let s66 = "AAAAAAAAAAAA"; - -let t66 = "AAAAAAAAAAAA"; - -let s67 = "AAAAAAAAAAAAA"; - -let t67 = "AAAAAAAAAAAAA"; - -let s68 = "AAAAAAAAAAAAAA"; - -let t68 = "AAAAAAAAAAAAAA"; - -let s69 = "AAAAAAAAAAAAAAA"; - -let t69 = "AAAAAAAAAAAAAAA"; - -let s70 = "AAAAAAAAAAAAAAAA"; - -let t70 = "AAAAAAAAAAAAAAAA"; - -let s71 = "AAAAAAAAAAAAAAAAA"; - -let t71 = "AAAAAAAAAAAAAAAAA"; - -let s72 = "AAAAAAAAAAAAAAAAAA"; - -let t72 = "AAAAAAAAAAAAAAAAAA"; - -let s73 = "AAAAAAAAAAAAAAAAAAA"; - -let t73 = "AAAAAAAAAAAAAAAAAAA"; - -let s74 = "AAAAAAAAAAAAAAAAAAAA"; - -let t74 = "AAAAAAAAAAAAAAAAAAAA"; - -let s75 = "AAAAAAAAAAAAAAAAAAAAA"; - -let t75 = "AAAAAAAAAAAAAAAAAAAAA"; - -let s76 = "AAAAAAAAAAAAAAAAAAAAAA"; - -let t76 = "AAAAAAAAAAAAAAAAAAAAAA"; - -let s77 = "AAAAAAAAAAAAAAAAAAAAAAA"; - -let t77 = "AAAAAAAAAAAAAAAAAAAAAAA"; - -let s78 = "AAAAAAAAAAAAAAAAAAAAAAAA"; - -let t78 = "AAAAAAAAAAAAAAAAAAAAAAAA"; - -let s79 = "AAAAAAAAAAAAAAAAAAAAAAAAA"; - -let t79 = "AAAAAAAAAAAAAAAAAAAAAAAAA"; - -let s80 = "AAAAAAAAAAAAAAAAAAAAAAAAAA"; - -let t80 = "AAAAAAAAAAAAAAAAAAAAAAAAAA"; - -let s81 = "AAAAAAAAAAAAAAAAAAAAAAAAAAA"; - -let t81 = "AAAAAAAAAAAAAAAAAAAAAAAAAAA"; - -let s82 = "AAAAAAAAAAAAAAAAAAAAAAAAAAAA"; - -let t82 = "AAAAAAAAAAAAAAAAAAAAAAAAAAAA"; - -let s83 = "AAAAAAAAAAAAAAAAAAAAAAAAAAAAA"; - -let t83 = "AAAAAAAAAAAAAAAAAAAAAAAAAAAAA"; - -let s84 = "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA"; - -let t84 = "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA"; - -let s85 = "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA"; - -let t85 = "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA"; - -let s86 = "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA"; - -let t86 = "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA"; - -let s87 = "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA"; - -let t87 = "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA"; - -let s88 = "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA"; - -let t88 = "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA"; - -let s89 = "BBBBBBBBBBBBBBB"; - -let t89 = "BBBBBBBBBBBBBBB"; - -let s90 = "BBBBBBBBBBBBBBBBBBBBBBBBBBBBBBB"; - -let t90 = "BBBBBBBBBBBBBBBBBBBBBBBBBBBBBBB"; - -let s91 = "BBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBB"; - -let t91 = "BBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBB"; - -function tst06(s) { - switch (s) { - case "A" : - return 55; - case "AA" : - return 56; - case "AAA" : - return 57; - case "AAAA" : - return 58; - case "AAAAA" : - return 59; - case "AAAAAA" : - return 60; - case "AAAAAAA" : - return 61; - case "AAAAAAAA" : - return 62; - case "AAAAAAAAA" : - return 63; - case "AAAAAAAAAA" : - return 64; - case "AAAAAAAAAAA" : - return 65; - case "AAAAAAAAAAAA" : - return 66; - case "AAAAAAAAAAAAA" : - return 67; - case "AAAAAAAAAAAAAA" : - return 68; - case "AAAAAAAAAAAAAAA" : - return 69; - case "AAAAAAAAAAAAAAAA" : - return 70; - case "AAAAAAAAAAAAAAAAA" : - return 71; - case "AAAAAAAAAAAAAAAAAA" : - return 72; - case "AAAAAAAAAAAAAAAAAAA" : - return 73; - case "AAAAAAAAAAAAAAAAAAAA" : - return 74; - case "AAAAAAAAAAAAAAAAAAAAA" : - return 75; - case "AAAAAAAAAAAAAAAAAAAAAA" : - return 76; - case "AAAAAAAAAAAAAAAAAAAAAAA" : - return 77; - case "AAAAAAAAAAAAAAAAAAAAAAAA" : - return 78; - case "AAAAAAAAAAAAAAAAAAAAAAAAA" : - return 79; - case "AAAAAAAAAAAAAAAAAAAAAAAAAA" : - return 80; - case "AAAAAAAAAAAAAAAAAAAAAAAAAAA" : - return 81; - case "AAAAAAAAAAAAAAAAAAAAAAAAAAAA" : - return 82; - case "AAAAAAAAAAAAAAAAAAAAAAAAAAAAA" : - return 83; - case "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA" : - return 84; - case "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA" : - return 85; - case "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA" : - return 86; - case "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA" : - return 87; - case "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA" : - return 88; - case "BBBBBBBBBBBBBBB" : - return 89; - case "BBBBBBBBBBBBBBBBBBBBBBBBBBBBBBB" : - return 90; - case "BBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBB" : - return 91; - case "and" : - return 0; - case "as" : - return 1; - case "asr" : - return 54; - case "assert" : - return 2; - case "begin" : - return 3; - case "class" : - return 4; - case "constraint" : - return 5; - case "do" : - return 6; - case "done" : - return 7; - case "downto" : - return 8; - case "else" : - return 9; - case "end" : - return 10; - case "exception" : - return 11; - case "external" : - return 12; - case "false" : - return 13; - case "for" : - return 14; - case "fun" : - return 15; - case "function" : - return 16; - case "functor" : - return 17; - case "if" : - return 18; - case "in" : - return 19; - case "include" : - return 20; - case "inherit" : - return 21; - case "initializer" : - return 22; - case "land" : - return 49; - case "lazy" : - return 23; - case "let" : - return 24; - case "lor" : - return 50; - case "lsl" : - return 52; - case "lsr" : - return 53; - case "lxor" : - return 51; - case "match" : - return 25; - case "method" : - return 26; - case "mod" : - return 48; - case "module" : - return 27; - case "mutable" : - return 28; - case "new" : - return 29; - case "object" : - return 30; - case "of" : - return 31; - case "open" : - return 32; - case "or" : - return 33; - case "private" : - return 34; - case "rec" : - return 35; - case "sig" : - return 36; - case "struct" : - return 37; - case "then" : - return 38; - case "to" : - return 39; - case "true" : - return 40; - case "try" : - return 41; - case "type" : - return 42; - case "val" : - return 43; - case "virtual" : - return 44; - case "when" : - return 45; - case "while" : - return 46; - case "with" : - return 47; - default: - return -1; - } -} - -if (tst06(s00) !== 0) { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "stringmatch_test.res", - 582, - 2 - ], - Error: new Error() - }; -} - -if (tst06(t00) !== -1) { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "stringmatch_test.res", - 583, - 2 - ], - Error: new Error() - }; -} - -if (tst06(s01) !== 1) { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "stringmatch_test.res", - 584, - 2 - ], - Error: new Error() - }; -} - -if (tst06(t01) !== -1) { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "stringmatch_test.res", - 585, - 2 - ], - Error: new Error() - }; -} - -if (tst06(s02) !== 2) { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "stringmatch_test.res", - 586, - 2 - ], - Error: new Error() - }; -} - -if (tst06(t02) !== -1) { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "stringmatch_test.res", - 587, - 2 - ], - Error: new Error() - }; -} - -if (tst06(s03) !== 3) { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "stringmatch_test.res", - 588, - 2 - ], - Error: new Error() - }; -} - -if (tst06(t03) !== -1) { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "stringmatch_test.res", - 589, - 2 - ], - Error: new Error() - }; -} - -if (tst06(s04) !== 4) { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "stringmatch_test.res", - 590, - 2 - ], - Error: new Error() - }; -} - -if (tst06(t04) !== -1) { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "stringmatch_test.res", - 591, - 2 - ], - Error: new Error() - }; -} - -if (tst06(s05) !== 5) { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "stringmatch_test.res", - 592, - 2 - ], - Error: new Error() - }; -} - -if (tst06(t05) !== -1) { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "stringmatch_test.res", - 593, - 2 - ], - Error: new Error() - }; -} - -if (tst06(s06) !== 6) { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "stringmatch_test.res", - 594, - 2 - ], - Error: new Error() - }; -} - -if (tst06(t06) !== -1) { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "stringmatch_test.res", - 595, - 2 - ], - Error: new Error() - }; -} - -if (tst06(s07) !== 7) { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "stringmatch_test.res", - 596, - 2 - ], - Error: new Error() - }; -} - -if (tst06(t07) !== -1) { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "stringmatch_test.res", - 597, - 2 - ], - Error: new Error() - }; -} - -if (tst06(s08) !== 8) { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "stringmatch_test.res", - 598, - 2 - ], - Error: new Error() - }; -} - -if (tst06(t08) !== -1) { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "stringmatch_test.res", - 599, - 2 - ], - Error: new Error() - }; -} - -if (tst06(s09) !== 9) { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "stringmatch_test.res", - 600, - 2 - ], - Error: new Error() - }; -} - -if (tst06(t09) !== -1) { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "stringmatch_test.res", - 601, - 2 - ], - Error: new Error() - }; -} - -if (tst06(s10) !== 10) { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "stringmatch_test.res", - 602, - 2 - ], - Error: new Error() - }; -} - -if (tst06(t10) !== -1) { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "stringmatch_test.res", - 603, - 2 - ], - Error: new Error() - }; -} - -if (tst06(s11) !== 11) { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "stringmatch_test.res", - 604, - 2 - ], - Error: new Error() - }; -} - -if (tst06(t11) !== 11) { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "stringmatch_test.res", - 605, - 2 - ], - Error: new Error() - }; -} - -if (tst06(s12) !== 12) { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "stringmatch_test.res", - 606, - 2 - ], - Error: new Error() - }; -} - -if (tst06(t12) !== 12) { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "stringmatch_test.res", - 607, - 2 - ], - Error: new Error() - }; -} - -if (tst06(s13) !== 13) { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "stringmatch_test.res", - 608, - 2 - ], - Error: new Error() - }; -} - -if (tst06(t13) !== -1) { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "stringmatch_test.res", - 609, - 2 - ], - Error: new Error() - }; -} - -if (tst06(s14) !== 14) { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "stringmatch_test.res", - 610, - 2 - ], - Error: new Error() - }; -} - -if (tst06(t14) !== -1) { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "stringmatch_test.res", - 611, - 2 - ], - Error: new Error() - }; -} - -if (tst06(s15) !== 15) { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "stringmatch_test.res", - 612, - 2 - ], - Error: new Error() - }; -} - -if (tst06(t15) !== -1) { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "stringmatch_test.res", - 613, - 2 - ], - Error: new Error() - }; -} - -if (tst06(s16) !== 16) { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "stringmatch_test.res", - 614, - 2 - ], - Error: new Error() - }; -} - -if (tst06(t16) !== 16) { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "stringmatch_test.res", - 615, - 2 - ], - Error: new Error() - }; -} - -if (tst06(s17) !== 17) { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "stringmatch_test.res", - 616, - 2 - ], - Error: new Error() - }; -} - -if (tst06(t17) !== -1) { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "stringmatch_test.res", - 617, - 2 - ], - Error: new Error() - }; -} - -if (tst06(s18) !== 18) { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "stringmatch_test.res", - 618, - 2 - ], - Error: new Error() - }; -} - -if (tst06(t18) !== -1) { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "stringmatch_test.res", - 619, - 2 - ], - Error: new Error() - }; -} - -if (tst06(s19) !== 19) { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "stringmatch_test.res", - 620, - 2 - ], - Error: new Error() - }; -} - -if (tst06(t19) !== 19) { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "stringmatch_test.res", - 621, - 2 - ], - Error: new Error() - }; -} - -if (tst06(s20) !== 20) { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "stringmatch_test.res", - 622, - 2 - ], - Error: new Error() - }; -} - -if (tst06(t20) !== -1) { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "stringmatch_test.res", - 623, - 2 - ], - Error: new Error() - }; -} - -if (tst06(s21) !== 21) { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "stringmatch_test.res", - 624, - 2 - ], - Error: new Error() - }; -} - -if (tst06(t21) !== -1) { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "stringmatch_test.res", - 625, - 2 - ], - Error: new Error() - }; -} - -if (tst06(s22) !== 22) { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "stringmatch_test.res", - 626, - 2 - ], - Error: new Error() - }; -} - -if (tst06(t22) !== -1) { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "stringmatch_test.res", - 627, - 2 - ], - Error: new Error() - }; -} - -if (tst06(s23) !== 23) { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "stringmatch_test.res", - 628, - 2 - ], - Error: new Error() - }; -} - -if (tst06(t23) !== -1) { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "stringmatch_test.res", - 629, - 2 - ], - Error: new Error() - }; -} - -if (tst06(s24) !== 24) { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "stringmatch_test.res", - 630, - 2 - ], - Error: new Error() - }; -} - -if (tst06(t24) !== -1) { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "stringmatch_test.res", - 631, - 2 - ], - Error: new Error() - }; -} - -if (tst06(s25) !== 25) { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "stringmatch_test.res", - 632, - 2 - ], - Error: new Error() - }; -} - -if (tst06(t25) !== 25) { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "stringmatch_test.res", - 633, - 2 - ], - Error: new Error() - }; -} - -if (tst06(s26) !== 26) { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "stringmatch_test.res", - 634, - 2 - ], - Error: new Error() - }; -} - -if (tst06(t26) !== -1) { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "stringmatch_test.res", - 635, - 2 - ], - Error: new Error() - }; -} - -if (tst06(s27) !== 27) { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "stringmatch_test.res", - 636, - 2 - ], - Error: new Error() - }; -} - -if (tst06(t27) !== -1) { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "stringmatch_test.res", - 637, - 2 - ], - Error: new Error() - }; -} - -if (tst06(s28) !== 28) { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "stringmatch_test.res", - 638, - 2 - ], - Error: new Error() - }; -} - -if (tst06(t28) !== -1) { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "stringmatch_test.res", - 639, - 2 - ], - Error: new Error() - }; -} - -if (tst06(s29) !== 29) { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "stringmatch_test.res", - 640, - 2 - ], - Error: new Error() - }; -} - -if (tst06(t29) !== -1) { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "stringmatch_test.res", - 641, - 2 - ], - Error: new Error() - }; -} - -if (tst06(s30) !== 30) { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "stringmatch_test.res", - 642, - 2 - ], - Error: new Error() - }; -} - -if (tst06(t30) !== -1) { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "stringmatch_test.res", - 643, - 2 - ], - Error: new Error() - }; -} - -if (tst06(s31) !== 31) { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "stringmatch_test.res", - 644, - 2 - ], - Error: new Error() - }; -} - -if (tst06(t31) !== 31) { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "stringmatch_test.res", - 645, - 2 - ], - Error: new Error() - }; -} - -if (tst06(s32) !== 32) { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "stringmatch_test.res", - 646, - 2 - ], - Error: new Error() - }; -} - -if (tst06(t32) !== -1) { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "stringmatch_test.res", - 647, - 2 - ], - Error: new Error() - }; -} - -if (tst06(s33) !== 33) { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "stringmatch_test.res", - 648, - 2 - ], - Error: new Error() - }; -} - -if (tst06(t33) !== -1) { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "stringmatch_test.res", - 649, - 2 - ], - Error: new Error() - }; -} - -if (tst06(s34) !== 34) { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "stringmatch_test.res", - 650, - 2 - ], - Error: new Error() - }; -} - -if (tst06(t34) !== -1) { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "stringmatch_test.res", - 651, - 2 - ], - Error: new Error() - }; -} - -if (tst06(s35) !== 35) { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "stringmatch_test.res", - 652, - 2 - ], - Error: new Error() - }; -} - -if (tst06(t35) !== 35) { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "stringmatch_test.res", - 653, - 2 - ], - Error: new Error() - }; -} - -if (tst06(s36) !== 36) { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "stringmatch_test.res", - 654, - 2 - ], - Error: new Error() - }; -} - -if (tst06(t36) !== -1) { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "stringmatch_test.res", - 655, - 2 - ], - Error: new Error() - }; -} - -if (tst06(s37) !== 37) { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "stringmatch_test.res", - 656, - 2 - ], - Error: new Error() - }; -} - -if (tst06(t37) !== -1) { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "stringmatch_test.res", - 657, - 2 - ], - Error: new Error() - }; -} - -if (tst06(s38) !== 38) { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "stringmatch_test.res", - 658, - 2 - ], - Error: new Error() - }; -} - -if (tst06(t38) !== -1) { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "stringmatch_test.res", - 659, - 2 - ], - Error: new Error() - }; -} - -if (tst06(s39) !== 39) { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "stringmatch_test.res", - 660, - 2 - ], - Error: new Error() - }; -} - -if (tst06(t39) !== 39) { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "stringmatch_test.res", - 661, - 2 - ], - Error: new Error() - }; -} - -if (tst06(s40) !== 40) { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "stringmatch_test.res", - 662, - 2 - ], - Error: new Error() - }; -} - -if (tst06(t40) !== -1) { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "stringmatch_test.res", - 663, - 2 - ], - Error: new Error() - }; -} - -if (tst06(s41) !== 41) { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "stringmatch_test.res", - 664, - 2 - ], - Error: new Error() - }; -} - -if (tst06(t41) !== 41) { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "stringmatch_test.res", - 665, - 2 - ], - Error: new Error() - }; -} - -if (tst06(s42) !== 42) { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "stringmatch_test.res", - 666, - 2 - ], - Error: new Error() - }; -} - -if (tst06(t42) !== -1) { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "stringmatch_test.res", - 667, - 2 - ], - Error: new Error() - }; -} - -if (tst06(s43) !== 43) { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "stringmatch_test.res", - 668, - 2 - ], - Error: new Error() - }; -} - -if (tst06(t43) !== 43) { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "stringmatch_test.res", - 669, - 2 - ], - Error: new Error() - }; -} - -if (tst06(s44) !== 44) { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "stringmatch_test.res", - 670, - 2 - ], - Error: new Error() - }; -} - -if (tst06(t44) !== -1) { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "stringmatch_test.res", - 671, - 2 - ], - Error: new Error() - }; -} - -if (tst06(s45) !== 45) { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "stringmatch_test.res", - 672, - 2 - ], - Error: new Error() - }; -} - -if (tst06(t45) !== -1) { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "stringmatch_test.res", - 673, - 2 - ], - Error: new Error() - }; -} - -if (tst06(s46) !== 46) { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "stringmatch_test.res", - 674, - 2 - ], - Error: new Error() - }; -} - -if (tst06(t46) !== -1) { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "stringmatch_test.res", - 675, - 2 - ], - Error: new Error() - }; -} - -if (tst06(s47) !== 47) { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "stringmatch_test.res", - 676, - 2 - ], - Error: new Error() - }; -} - -if (tst06(t47) !== -1) { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "stringmatch_test.res", - 677, - 2 - ], - Error: new Error() - }; -} - -if (tst06(s48) !== 48) { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "stringmatch_test.res", - 678, - 2 - ], - Error: new Error() - }; -} - -if (tst06(t48) !== 48) { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "stringmatch_test.res", - 679, - 2 - ], - Error: new Error() - }; -} - -if (tst06(s49) !== 49) { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "stringmatch_test.res", - 680, - 2 - ], - Error: new Error() - }; -} - -if (tst06(t49) !== -1) { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "stringmatch_test.res", - 681, - 2 - ], - Error: new Error() - }; -} - -if (tst06(s50) !== 50) { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "stringmatch_test.res", - 682, - 2 - ], - Error: new Error() - }; -} - -if (tst06(t50) !== -1) { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "stringmatch_test.res", - 683, - 2 - ], - Error: new Error() - }; -} - -if (tst06(s51) !== 51) { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "stringmatch_test.res", - 684, - 2 - ], - Error: new Error() - }; -} - -if (tst06(t51) !== 51) { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "stringmatch_test.res", - 685, - 2 - ], - Error: new Error() - }; -} - -if (tst06(s52) !== 52) { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "stringmatch_test.res", - 686, - 2 - ], - Error: new Error() - }; -} - -if (tst06(t52) !== 52) { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "stringmatch_test.res", - 687, - 2 - ], - Error: new Error() - }; -} - -if (tst06(s53) !== 53) { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "stringmatch_test.res", - 688, - 2 - ], - Error: new Error() - }; -} - -if (tst06(t53) !== 53) { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "stringmatch_test.res", - 689, - 2 - ], - Error: new Error() - }; -} - -if (tst06(s54) !== 54) { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "stringmatch_test.res", - 690, - 2 - ], - Error: new Error() - }; -} - -if (tst06(t54) !== -1) { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "stringmatch_test.res", - 691, - 2 - ], - Error: new Error() - }; -} - -if (tst06(s55) !== 55) { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "stringmatch_test.res", - 692, - 2 - ], - Error: new Error() - }; -} - -if (tst06(t55) !== 55) { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "stringmatch_test.res", - 693, - 2 - ], - Error: new Error() - }; -} - -if (tst06(s56) !== 56) { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "stringmatch_test.res", - 694, - 2 - ], - Error: new Error() - }; -} - -if (tst06(t56) !== 56) { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "stringmatch_test.res", - 695, - 2 - ], - Error: new Error() - }; -} - -if (tst06(s57) !== 57) { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "stringmatch_test.res", - 696, - 2 - ], - Error: new Error() - }; -} - -if (tst06(t57) !== 57) { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "stringmatch_test.res", - 697, - 2 - ], - Error: new Error() - }; -} - -if (tst06(s58) !== 58) { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "stringmatch_test.res", - 698, - 2 - ], - Error: new Error() - }; -} - -if (tst06(t58) !== 58) { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "stringmatch_test.res", - 699, - 2 - ], - Error: new Error() - }; -} - -if (tst06(s59) !== 59) { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "stringmatch_test.res", - 700, - 2 - ], - Error: new Error() - }; -} - -if (tst06(t59) !== 59) { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "stringmatch_test.res", - 701, - 2 - ], - Error: new Error() - }; -} - -if (tst06(s60) !== 60) { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "stringmatch_test.res", - 702, - 2 - ], - Error: new Error() - }; -} - -if (tst06(t60) !== 60) { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "stringmatch_test.res", - 703, - 2 - ], - Error: new Error() - }; -} - -if (tst06(s61) !== 61) { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "stringmatch_test.res", - 704, - 2 - ], - Error: new Error() - }; -} - -if (tst06(t61) !== 61) { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "stringmatch_test.res", - 705, - 2 - ], - Error: new Error() - }; -} - -if (tst06(s62) !== 62) { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "stringmatch_test.res", - 706, - 2 - ], - Error: new Error() - }; -} - -if (tst06(t62) !== 62) { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "stringmatch_test.res", - 707, - 2 - ], - Error: new Error() - }; -} - -if (tst06(s63) !== 63) { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "stringmatch_test.res", - 708, - 2 - ], - Error: new Error() - }; -} - -if (tst06(t63) !== 63) { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "stringmatch_test.res", - 709, - 2 - ], - Error: new Error() - }; -} - -if (tst06(s64) !== 64) { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "stringmatch_test.res", - 710, - 2 - ], - Error: new Error() - }; -} - -if (tst06(t64) !== 64) { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "stringmatch_test.res", - 711, - 2 - ], - Error: new Error() - }; -} - -if (tst06(s65) !== 65) { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "stringmatch_test.res", - 712, - 2 - ], - Error: new Error() - }; -} - -if (tst06(t65) !== 65) { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "stringmatch_test.res", - 713, - 2 - ], - Error: new Error() - }; -} - -if (tst06(s66) !== 66) { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "stringmatch_test.res", - 714, - 2 - ], - Error: new Error() - }; -} - -if (tst06(t66) !== 66) { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "stringmatch_test.res", - 715, - 2 - ], - Error: new Error() - }; -} - -if (tst06(s67) !== 67) { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "stringmatch_test.res", - 716, - 2 - ], - Error: new Error() - }; -} - -if (tst06(t67) !== 67) { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "stringmatch_test.res", - 717, - 2 - ], - Error: new Error() - }; -} - -if (tst06(s68) !== 68) { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "stringmatch_test.res", - 718, - 2 - ], - Error: new Error() - }; -} - -if (tst06(t68) !== 68) { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "stringmatch_test.res", - 719, - 2 - ], - Error: new Error() - }; -} - -if (tst06(s69) !== 69) { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "stringmatch_test.res", - 720, - 2 - ], - Error: new Error() - }; -} - -if (tst06(t69) !== 69) { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "stringmatch_test.res", - 721, - 2 - ], - Error: new Error() - }; -} - -if (tst06(s70) !== 70) { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "stringmatch_test.res", - 722, - 2 - ], - Error: new Error() - }; -} - -if (tst06(t70) !== 70) { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "stringmatch_test.res", - 723, - 2 - ], - Error: new Error() - }; -} - -if (tst06(s71) !== 71) { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "stringmatch_test.res", - 724, - 2 - ], - Error: new Error() - }; -} - -if (tst06(t71) !== 71) { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "stringmatch_test.res", - 725, - 2 - ], - Error: new Error() - }; -} - -if (tst06(s72) !== 72) { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "stringmatch_test.res", - 726, - 2 - ], - Error: new Error() - }; -} - -if (tst06(t72) !== 72) { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "stringmatch_test.res", - 727, - 2 - ], - Error: new Error() - }; -} - -if (tst06(s73) !== 73) { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "stringmatch_test.res", - 728, - 2 - ], - Error: new Error() - }; -} - -if (tst06(t73) !== 73) { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "stringmatch_test.res", - 729, - 2 - ], - Error: new Error() - }; -} - -if (tst06(s74) !== 74) { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "stringmatch_test.res", - 730, - 2 - ], - Error: new Error() - }; -} - -if (tst06(t74) !== 74) { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "stringmatch_test.res", - 731, - 2 - ], - Error: new Error() - }; -} - -if (tst06(s75) !== 75) { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "stringmatch_test.res", - 732, - 2 - ], - Error: new Error() - }; -} - -if (tst06(t75) !== 75) { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "stringmatch_test.res", - 733, - 2 - ], - Error: new Error() - }; -} - -if (tst06(s76) !== 76) { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "stringmatch_test.res", - 734, - 2 - ], - Error: new Error() - }; -} - -if (tst06(t76) !== 76) { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "stringmatch_test.res", - 735, - 2 - ], - Error: new Error() - }; -} - -if (tst06(s77) !== 77) { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "stringmatch_test.res", - 736, - 2 - ], - Error: new Error() - }; -} - -if (tst06(t77) !== 77) { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "stringmatch_test.res", - 737, - 2 - ], - Error: new Error() - }; -} - -if (tst06(s78) !== 78) { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "stringmatch_test.res", - 738, - 2 - ], - Error: new Error() - }; -} - -if (tst06(t78) !== 78) { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "stringmatch_test.res", - 739, - 2 - ], - Error: new Error() - }; -} - -if (tst06(s79) !== 79) { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "stringmatch_test.res", - 740, - 2 - ], - Error: new Error() - }; -} - -if (tst06(t79) !== 79) { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "stringmatch_test.res", - 741, - 2 - ], - Error: new Error() - }; -} - -if (tst06(s80) !== 80) { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "stringmatch_test.res", - 742, - 2 - ], - Error: new Error() - }; -} - -if (tst06(t80) !== 80) { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "stringmatch_test.res", - 743, - 2 - ], - Error: new Error() - }; -} - -if (tst06(s81) !== 81) { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "stringmatch_test.res", - 744, - 2 - ], - Error: new Error() - }; -} - -if (tst06(t81) !== 81) { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "stringmatch_test.res", - 745, - 2 - ], - Error: new Error() - }; -} - -if (tst06(s82) !== 82) { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "stringmatch_test.res", - 746, - 2 - ], - Error: new Error() - }; -} - -if (tst06(t82) !== 82) { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "stringmatch_test.res", - 747, - 2 - ], - Error: new Error() - }; -} - -if (tst06(s83) !== 83) { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "stringmatch_test.res", - 748, - 2 - ], - Error: new Error() - }; -} - -if (tst06(t83) !== 83) { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "stringmatch_test.res", - 749, - 2 - ], - Error: new Error() - }; -} - -if (tst06(s84) !== 84) { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "stringmatch_test.res", - 750, - 2 - ], - Error: new Error() - }; -} - -if (tst06(t84) !== 84) { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "stringmatch_test.res", - 751, - 2 - ], - Error: new Error() - }; -} - -if (tst06(s85) !== 85) { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "stringmatch_test.res", - 752, - 2 - ], - Error: new Error() - }; -} - -if (tst06(t85) !== 85) { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "stringmatch_test.res", - 753, - 2 - ], - Error: new Error() - }; -} - -if (tst06(s86) !== 86) { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "stringmatch_test.res", - 754, - 2 - ], - Error: new Error() - }; -} - -if (tst06(t86) !== 86) { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "stringmatch_test.res", - 755, - 2 - ], - Error: new Error() - }; -} - -if (tst06(s87) !== 87) { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "stringmatch_test.res", - 756, - 2 - ], - Error: new Error() - }; -} - -if (tst06(t87) !== 87) { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "stringmatch_test.res", - 757, - 2 - ], - Error: new Error() - }; -} - -if (tst06(s88) !== 88) { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "stringmatch_test.res", - 758, - 2 - ], - Error: new Error() - }; -} - -if (tst06(t88) !== 88) { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "stringmatch_test.res", - 759, - 2 - ], - Error: new Error() - }; -} - -if (tst06(s89) !== 89) { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "stringmatch_test.res", - 760, - 2 - ], - Error: new Error() - }; -} - -if (tst06(t89) !== 89) { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "stringmatch_test.res", - 761, - 2 - ], - Error: new Error() - }; -} - -if (tst06(s90) !== 90) { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "stringmatch_test.res", - 762, - 2 - ], - Error: new Error() - }; -} - -if (tst06(t90) !== 90) { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "stringmatch_test.res", - 763, - 2 - ], - Error: new Error() - }; -} - -if (tst06(s91) !== 91) { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "stringmatch_test.res", - 764, - 2 - ], - Error: new Error() - }; -} - -if (tst06(t91) !== 91) { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "stringmatch_test.res", - 765, - 2 - ], - Error: new Error() - }; -} - -if (tst06("") !== -1) { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "stringmatch_test.res", - 766, - 2 - ], - Error: new Error() - }; -} - -exports.tst01 = tst01; -exports.tst02 = tst02; -exports.tst03 = tst03; -exports.tst04 = tst04; -exports.tst05 = tst05; -exports.s00 = s00; -exports.t00 = t00; -exports.s01 = s01; -exports.t01 = t01; -exports.s02 = s02; -exports.t02 = t02; -exports.s03 = s03; -exports.t03 = t03; -exports.s04 = s04; -exports.t04 = t04; -exports.s05 = s05; -exports.t05 = t05; -exports.s06 = s06; -exports.t06 = t06; -exports.s07 = s07; -exports.t07 = t07; -exports.s08 = s08; -exports.t08 = t08; -exports.s09 = s09; -exports.t09 = t09; -exports.s10 = s10; -exports.t10 = t10; -exports.s11 = s11; -exports.t11 = t11; -exports.s12 = s12; -exports.t12 = t12; -exports.s13 = s13; -exports.t13 = t13; -exports.s14 = s14; -exports.t14 = t14; -exports.s15 = s15; -exports.t15 = t15; -exports.s16 = s16; -exports.t16 = t16; -exports.s17 = s17; -exports.t17 = t17; -exports.s18 = s18; -exports.t18 = t18; -exports.s19 = s19; -exports.t19 = t19; -exports.s20 = s20; -exports.t20 = t20; -exports.s21 = s21; -exports.t21 = t21; -exports.s22 = s22; -exports.t22 = t22; -exports.s23 = s23; -exports.t23 = t23; -exports.s24 = s24; -exports.t24 = t24; -exports.s25 = s25; -exports.t25 = t25; -exports.s26 = s26; -exports.t26 = t26; -exports.s27 = s27; -exports.t27 = t27; -exports.s28 = s28; -exports.t28 = t28; -exports.s29 = s29; -exports.t29 = t29; -exports.s30 = s30; -exports.t30 = t30; -exports.s31 = s31; -exports.t31 = t31; -exports.s32 = s32; -exports.t32 = t32; -exports.s33 = s33; -exports.t33 = t33; -exports.s34 = s34; -exports.t34 = t34; -exports.s35 = s35; -exports.t35 = t35; -exports.s36 = s36; -exports.t36 = t36; -exports.s37 = s37; -exports.t37 = t37; -exports.s38 = s38; -exports.t38 = t38; -exports.s39 = s39; -exports.t39 = t39; -exports.s40 = s40; -exports.t40 = t40; -exports.s41 = s41; -exports.t41 = t41; -exports.s42 = s42; -exports.t42 = t42; -exports.s43 = s43; -exports.t43 = t43; -exports.s44 = s44; -exports.t44 = t44; -exports.s45 = s45; -exports.t45 = t45; -exports.s46 = s46; -exports.t46 = t46; -exports.s47 = s47; -exports.t47 = t47; -exports.s48 = s48; -exports.t48 = t48; -exports.s49 = s49; -exports.t49 = t49; -exports.s50 = s50; -exports.t50 = t50; -exports.s51 = s51; -exports.t51 = t51; -exports.s52 = s52; -exports.t52 = t52; -exports.s53 = s53; -exports.t53 = t53; -exports.s54 = s54; -exports.t54 = t54; -exports.s55 = s55; -exports.t55 = t55; -exports.s56 = s56; -exports.t56 = t56; -exports.s57 = s57; -exports.t57 = t57; -exports.s58 = s58; -exports.t58 = t58; -exports.s59 = s59; -exports.t59 = t59; -exports.s60 = s60; -exports.t60 = t60; -exports.s61 = s61; -exports.t61 = t61; -exports.s62 = s62; -exports.t62 = t62; -exports.s63 = s63; -exports.t63 = t63; -exports.s64 = s64; -exports.t64 = t64; -exports.s65 = s65; -exports.t65 = t65; -exports.s66 = s66; -exports.t66 = t66; -exports.s67 = s67; -exports.t67 = t67; -exports.s68 = s68; -exports.t68 = t68; -exports.s69 = s69; -exports.t69 = t69; -exports.s70 = s70; -exports.t70 = t70; -exports.s71 = s71; -exports.t71 = t71; -exports.s72 = s72; -exports.t72 = t72; -exports.s73 = s73; -exports.t73 = t73; -exports.s74 = s74; -exports.t74 = t74; -exports.s75 = s75; -exports.t75 = t75; -exports.s76 = s76; -exports.t76 = t76; -exports.s77 = s77; -exports.t77 = t77; -exports.s78 = s78; -exports.t78 = t78; -exports.s79 = s79; -exports.t79 = t79; -exports.s80 = s80; -exports.t80 = t80; -exports.s81 = s81; -exports.t81 = t81; -exports.s82 = s82; -exports.t82 = t82; -exports.s83 = s83; -exports.t83 = t83; -exports.s84 = s84; -exports.t84 = t84; -exports.s85 = s85; -exports.t85 = t85; -exports.s86 = s86; -exports.t86 = t86; -exports.s87 = s87; -exports.t87 = t87; -exports.s88 = s88; -exports.t88 = t88; -exports.s89 = s89; -exports.t89 = t89; -exports.s90 = s90; -exports.t90 = t90; -exports.s91 = s91; -exports.t91 = t91; -exports.tst06 = tst06; -/* Not a pure module */ diff --git a/tests/tests/src/stringmatch_test.mjs b/tests/tests/src/stringmatch_test.mjs new file mode 100644 index 0000000000..a6df5db225 --- /dev/null +++ b/tests/tests/src/stringmatch_test.mjs @@ -0,0 +1,4300 @@ +// Generated by ReScript, PLEASE EDIT WITH CARE + + +function tst01(s) { + if (s === "") { + return 0; + } else { + return 1; + } +} + +if (tst01("") !== 0) { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "stringmatch_test.res", + 22, + 2 + ], + Error: new Error() + }; +} + +if (tst01("\x00\x00\x00\x03") !== 1) { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "stringmatch_test.res", + 23, + 2 + ], + Error: new Error() + }; +} + +if (tst01("\x00\x00\x00\x00\x00\x00\x00\x07") !== 1) { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "stringmatch_test.res", + 24, + 2 + ], + Error: new Error() + }; +} + +function tst02(s) { + let len = s.length; + if (s === "") { + if (len >= 0) { + return 1; + } + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "stringmatch_test.res", + 33, + 21 + ], + Error: new Error() + }; + } + if (len === 0) { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "stringmatch_test.res", + 35, + 21 + ], + Error: new Error() + }; + } + if (s === "A") { + return 2; + } else { + return 3; + } +} + +if (tst02("") !== 1) { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "stringmatch_test.res", + 42, + 2 + ], + Error: new Error() + }; +} + +if (tst02("A") !== 2) { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "stringmatch_test.res", + 43, + 2 + ], + Error: new Error() + }; +} + +if (tst02("B") !== 3) { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "stringmatch_test.res", + 44, + 2 + ], + Error: new Error() + }; +} + +if (tst02("\x00\x00\x00\x00\x00\x00\x00\x07") !== 3) { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "stringmatch_test.res", + 45, + 2 + ], + Error: new Error() + }; +} + +if (tst02("\x00\x00\x00\x03") !== 3) { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "stringmatch_test.res", + 46, + 2 + ], + Error: new Error() + }; +} + +function tst03(s) { + switch (s) { + case "app_const" : + return 5; + case "app_const_const" : + return 9; + case "app_const_env" : + return 11; + case "app_const_meth" : + return 12; + case "app_const_var" : + return 10; + case "app_env" : + return 7; + case "app_env_const" : + return 14; + case "app_meth" : + return 8; + case "app_meth_const" : + return 15; + case "app_var" : + return 6; + case "app_var_const" : + return 13; + case "get_const" : + return 0; + case "get_env" : + return 2; + case "get_meth" : + return 3; + case "get_var" : + return 1; + case "meth_app_const" : + return 16; + case "meth_app_env" : + return 18; + case "meth_app_meth" : + return 19; + case "meth_app_var" : + return 17; + case "send_const" : + return 20; + case "send_env" : + return 22; + case "send_meth" : + return 23; + case "send_var" : + return 21; + case "set_var" : + return 4; + default: + return -1; + } +} + +if (tst03("get_const") !== 0) { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "stringmatch_test.res", + 131, + 2 + ], + Error: new Error() + }; +} + +if (tst03("set_congt") !== -1) { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "stringmatch_test.res", + 132, + 2 + ], + Error: new Error() + }; +} + +if (tst03("get_var") !== 1) { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "stringmatch_test.res", + 133, + 2 + ], + Error: new Error() + }; +} + +if (tst03("gat_ver") !== -1) { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "stringmatch_test.res", + 134, + 2 + ], + Error: new Error() + }; +} + +if (tst03("get_env") !== 2) { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "stringmatch_test.res", + 135, + 2 + ], + Error: new Error() + }; +} + +if (tst03("get_env") !== 2) { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "stringmatch_test.res", + 136, + 2 + ], + Error: new Error() + }; +} + +if (tst03("get_meth") !== 3) { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "stringmatch_test.res", + 137, + 2 + ], + Error: new Error() + }; +} + +if (tst03("met_geth") !== -1) { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "stringmatch_test.res", + 138, + 2 + ], + Error: new Error() + }; +} + +if (tst03("set_var") !== 4) { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "stringmatch_test.res", + 139, + 2 + ], + Error: new Error() + }; +} + +if (tst03("sev_tar") !== -1) { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "stringmatch_test.res", + 140, + 2 + ], + Error: new Error() + }; +} + +if (tst03("app_const") !== 5) { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "stringmatch_test.res", + 141, + 2 + ], + Error: new Error() + }; +} + +if (tst03("ppa_const") !== -1) { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "stringmatch_test.res", + 142, + 2 + ], + Error: new Error() + }; +} + +if (tst03("app_var") !== 6) { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "stringmatch_test.res", + 143, + 2 + ], + Error: new Error() + }; +} + +if (tst03("app_var") !== 6) { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "stringmatch_test.res", + 144, + 2 + ], + Error: new Error() + }; +} + +if (tst03("app_env") !== 7) { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "stringmatch_test.res", + 145, + 2 + ], + Error: new Error() + }; +} + +if (tst03("epp_anv") !== -1) { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "stringmatch_test.res", + 146, + 2 + ], + Error: new Error() + }; +} + +if (tst03("app_meth") !== 8) { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "stringmatch_test.res", + 147, + 2 + ], + Error: new Error() + }; +} + +if (tst03("atp_meph") !== -1) { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "stringmatch_test.res", + 148, + 2 + ], + Error: new Error() + }; +} + +if (tst03("app_const_const") !== 9) { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "stringmatch_test.res", + 149, + 2 + ], + Error: new Error() + }; +} + +if (tst03("app_const_const") !== 9) { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "stringmatch_test.res", + 150, + 2 + ], + Error: new Error() + }; +} + +if (tst03("app_const_var") !== 10) { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "stringmatch_test.res", + 151, + 2 + ], + Error: new Error() + }; +} + +if (tst03("atp_consp_var") !== -1) { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "stringmatch_test.res", + 152, + 2 + ], + Error: new Error() + }; +} + +if (tst03("app_const_env") !== 11) { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "stringmatch_test.res", + 153, + 2 + ], + Error: new Error() + }; +} + +if (tst03("app_constne_v") !== -1) { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "stringmatch_test.res", + 154, + 2 + ], + Error: new Error() + }; +} + +if (tst03("app_const_meth") !== 12) { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "stringmatch_test.res", + 155, + 2 + ], + Error: new Error() + }; +} + +if (tst03("spp_conat_meth") !== -1) { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "stringmatch_test.res", + 156, + 2 + ], + Error: new Error() + }; +} + +if (tst03("app_var_const") !== 13) { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "stringmatch_test.res", + 157, + 2 + ], + Error: new Error() + }; +} + +if (tst03("app_va_rconst") !== -1) { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "stringmatch_test.res", + 158, + 2 + ], + Error: new Error() + }; +} + +if (tst03("app_env_const") !== 14) { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "stringmatch_test.res", + 159, + 2 + ], + Error: new Error() + }; +} + +if (tst03("app_env_const") !== 14) { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "stringmatch_test.res", + 160, + 2 + ], + Error: new Error() + }; +} + +if (tst03("app_meth_const") !== 15) { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "stringmatch_test.res", + 161, + 2 + ], + Error: new Error() + }; +} + +if (tst03("app_teth_consm") !== -1) { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "stringmatch_test.res", + 162, + 2 + ], + Error: new Error() + }; +} + +if (tst03("meth_app_const") !== 16) { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "stringmatch_test.res", + 163, + 2 + ], + Error: new Error() + }; +} + +if (tst03("math_epp_const") !== -1) { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "stringmatch_test.res", + 164, + 2 + ], + Error: new Error() + }; +} + +if (tst03("meth_app_var") !== 17) { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "stringmatch_test.res", + 165, + 2 + ], + Error: new Error() + }; +} + +if (tst03("meth_app_var") !== 17) { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "stringmatch_test.res", + 166, + 2 + ], + Error: new Error() + }; +} + +if (tst03("meth_app_env") !== 18) { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "stringmatch_test.res", + 167, + 2 + ], + Error: new Error() + }; +} + +if (tst03("eeth_app_mnv") !== -1) { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "stringmatch_test.res", + 168, + 2 + ], + Error: new Error() + }; +} + +if (tst03("meth_app_meth") !== 19) { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "stringmatch_test.res", + 169, + 2 + ], + Error: new Error() + }; +} + +if (tst03("meth_apt_meph") !== -1) { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "stringmatch_test.res", + 170, + 2 + ], + Error: new Error() + }; +} + +if (tst03("send_const") !== 20) { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "stringmatch_test.res", + 171, + 2 + ], + Error: new Error() + }; +} + +if (tst03("tend_conss") !== -1) { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "stringmatch_test.res", + 172, + 2 + ], + Error: new Error() + }; +} + +if (tst03("send_var") !== 21) { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "stringmatch_test.res", + 173, + 2 + ], + Error: new Error() + }; +} + +if (tst03("serd_van") !== -1) { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "stringmatch_test.res", + 174, + 2 + ], + Error: new Error() + }; +} + +if (tst03("send_env") !== 22) { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "stringmatch_test.res", + 175, + 2 + ], + Error: new Error() + }; +} + +if (tst03("sen_denv") !== -1) { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "stringmatch_test.res", + 176, + 2 + ], + Error: new Error() + }; +} + +if (tst03("send_meth") !== 23) { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "stringmatch_test.res", + 177, + 2 + ], + Error: new Error() + }; +} + +if (tst03("tend_mesh") !== -1) { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "stringmatch_test.res", + 178, + 2 + ], + Error: new Error() + }; +} + +function tst04(s) { + switch (s) { + case "AAAAAAAA" : + return 0; + case "AAAAAAAAAAAAAAAA" : + return 1; + case "AAAAAAAAAAAAAAAAAAAAAAAA" : + return 2; + case "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA" : + return 3; + case "BBBBBBBB" : + return 4; + case "BBBBBBBBBBBBBBBB" : + return 5; + case "BBBBBBBBBBBBBBBBBBBBBBBB" : + return 6; + case "BBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBB" : + return 7; + case "CCCCCCCC" : + return 8; + case "CCCCCCCCCCCCCCCC" : + return 9; + case "CCCCCCCCCCCCCCCCCCCCCCCC" : + return 10; + case "CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC" : + return 11; + default: + return -1; + } +} + +if (tst04("AAAAAAAA") !== 0) { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "stringmatch_test.res", + 215, + 2 + ], + Error: new Error() + }; +} + +if (tst04("AAAAAAAAAAAAAAAA") !== 1) { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "stringmatch_test.res", + 216, + 2 + ], + Error: new Error() + }; +} + +if (tst04("AAAAAAAAAAAAAAAAAAAAAAAA") !== 2) { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "stringmatch_test.res", + 217, + 2 + ], + Error: new Error() + }; +} + +if (tst04("AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA") !== 3) { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "stringmatch_test.res", + 218, + 2 + ], + Error: new Error() + }; +} + +if (tst04("BBBBBBBB") !== 4) { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "stringmatch_test.res", + 219, + 2 + ], + Error: new Error() + }; +} + +if (tst04("BBBBBBBBBBBBBBBB") !== 5) { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "stringmatch_test.res", + 220, + 2 + ], + Error: new Error() + }; +} + +if (tst04("BBBBBBBBBBBBBBBBBBBBBBBB") !== 6) { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "stringmatch_test.res", + 221, + 2 + ], + Error: new Error() + }; +} + +if (tst04("BBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBB") !== 7) { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "stringmatch_test.res", + 222, + 2 + ], + Error: new Error() + }; +} + +if (tst04("CCCCCCCC") !== 8) { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "stringmatch_test.res", + 223, + 2 + ], + Error: new Error() + }; +} + +if (tst04("CCCCCCCCCCCCCCCC") !== 9) { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "stringmatch_test.res", + 224, + 2 + ], + Error: new Error() + }; +} + +if (tst04("CCCCCCCCCCCCCCCCCCCCCCCC") !== 10) { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "stringmatch_test.res", + 225, + 2 + ], + Error: new Error() + }; +} + +if (tst04("CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC") !== 11) { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "stringmatch_test.res", + 226, + 2 + ], + Error: new Error() + }; +} + +if (tst04("") !== -1) { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "stringmatch_test.res", + 227, + 2 + ], + Error: new Error() + }; +} + +if (tst04("DDD") !== -1) { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "stringmatch_test.res", + 228, + 2 + ], + Error: new Error() + }; +} + +if (tst04("DDDDDDD") !== -1) { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "stringmatch_test.res", + 229, + 2 + ], + Error: new Error() + }; +} + +if (tst04("AAADDDD") !== -1) { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "stringmatch_test.res", + 230, + 2 + ], + Error: new Error() + }; +} + +if (tst04("AAAAAAADDDDDDDD") !== -1) { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "stringmatch_test.res", + 231, + 2 + ], + Error: new Error() + }; +} + +if (tst04("AAAAAAADDDD") !== -1) { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "stringmatch_test.res", + 232, + 2 + ], + Error: new Error() + }; +} + +if (tst04("AAAAAAAAAAAAAAADDDD") !== -1) { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "stringmatch_test.res", + 233, + 2 + ], + Error: new Error() + }; +} + +function tst05(s) { + switch (s) { + case "AAA" : + return 0; + case "AAAA" : + return 1; + case "AAAAA" : + return 2; + case "AAAAAA" : + return 3; + case "AAAAAAA" : + return 4; + case "AAAAAAAAAAAA" : + return 5; + case "AAAAAAAAAAAAAAAA" : + return 6; + case "AAAAAAAAAAAAAAAAAAAA" : + return 7; + case "BBB" : + return 8; + case "BBBB" : + return 9; + case "BBBBB" : + return 10; + case "BBBBBB" : + return 11; + case "BBBBBBB" : + return 12; + default: + return -1; + } +} + +if (tst05("AAA") !== 0) { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "stringmatch_test.res", + 272, + 2 + ], + Error: new Error() + }; +} + +if (tst05("AAAA") !== 1) { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "stringmatch_test.res", + 273, + 2 + ], + Error: new Error() + }; +} + +if (tst05("AAAAA") !== 2) { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "stringmatch_test.res", + 274, + 2 + ], + Error: new Error() + }; +} + +if (tst05("AAAAAA") !== 3) { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "stringmatch_test.res", + 275, + 2 + ], + Error: new Error() + }; +} + +if (tst05("AAAAAAA") !== 4) { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "stringmatch_test.res", + 276, + 2 + ], + Error: new Error() + }; +} + +if (tst05("AAAAAAAAAAAA") !== 5) { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "stringmatch_test.res", + 277, + 2 + ], + Error: new Error() + }; +} + +if (tst05("AAAAAAAAAAAAAAAA") !== 6) { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "stringmatch_test.res", + 278, + 2 + ], + Error: new Error() + }; +} + +if (tst05("AAAAAAAAAAAAAAAAAAAA") !== 7) { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "stringmatch_test.res", + 279, + 2 + ], + Error: new Error() + }; +} + +if (tst05("BBB") !== 8) { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "stringmatch_test.res", + 280, + 2 + ], + Error: new Error() + }; +} + +if (tst05("BBBB") !== 9) { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "stringmatch_test.res", + 281, + 2 + ], + Error: new Error() + }; +} + +if (tst05("BBBBB") !== 10) { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "stringmatch_test.res", + 282, + 2 + ], + Error: new Error() + }; +} + +if (tst05("BBBBBB") !== 11) { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "stringmatch_test.res", + 283, + 2 + ], + Error: new Error() + }; +} + +if (tst05("BBBBBBB") !== 12) { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "stringmatch_test.res", + 284, + 2 + ], + Error: new Error() + }; +} + +if (tst05("") !== -1) { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "stringmatch_test.res", + 285, + 2 + ], + Error: new Error() + }; +} + +if (tst05("AAD") !== -1) { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "stringmatch_test.res", + 286, + 2 + ], + Error: new Error() + }; +} + +if (tst05("AAAD") !== -1) { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "stringmatch_test.res", + 287, + 2 + ], + Error: new Error() + }; +} + +if (tst05("AAAAAAD") !== -1) { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "stringmatch_test.res", + 288, + 2 + ], + Error: new Error() + }; +} + +if (tst05("AAAAAAAD") !== -1) { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "stringmatch_test.res", + 289, + 2 + ], + Error: new Error() + }; +} + +if (tst05("BBD") !== -1) { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "stringmatch_test.res", + 290, + 2 + ], + Error: new Error() + }; +} + +if (tst05("BBBD") !== -1) { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "stringmatch_test.res", + 291, + 2 + ], + Error: new Error() + }; +} + +if (tst05("BBBBBBD") !== -1) { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "stringmatch_test.res", + 292, + 2 + ], + Error: new Error() + }; +} + +if (tst05("BBBBBBBD") !== -1) { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "stringmatch_test.res", + 293, + 2 + ], + Error: new Error() + }; +} + +let s00 = "and"; + +let t00 = "nad"; + +let s01 = "as"; + +let t01 = "sa"; + +let s02 = "assert"; + +let t02 = "asesrt"; + +let s03 = "begin"; + +let t03 = "negib"; + +let s04 = "class"; + +let t04 = "lcass"; + +let s05 = "constraint"; + +let t05 = "constiarnt"; + +let s06 = "do"; + +let t06 = "od"; + +let s07 = "done"; + +let t07 = "eond"; + +let s08 = "downto"; + +let t08 = "dowtno"; + +let s09 = "else"; + +let t09 = "lese"; + +let s10 = "end"; + +let t10 = "edn"; + +let s11 = "exception"; + +let t11 = "exception"; + +let s12 = "external"; + +let t12 = "external"; + +let s13 = "false"; + +let t13 = "fslae"; + +let s14 = "for"; + +let t14 = "ofr"; + +let s15 = "fun"; + +let t15 = "fnu"; + +let s16 = "function"; + +let t16 = "function"; + +let s17 = "functor"; + +let t17 = "ounctfr"; + +let s18 = "if"; + +let t18 = "fi"; + +let s19 = "in"; + +let t19 = "in"; + +let s20 = "include"; + +let t20 = "inculde"; + +let s21 = "inherit"; + +let t21 = "iehnrit"; + +let s22 = "initializer"; + +let t22 = "enitializir"; + +let s23 = "lazy"; + +let t23 = "zaly"; + +let s24 = "let"; + +let t24 = "elt"; + +let s25 = "match"; + +let t25 = "match"; + +let s26 = "method"; + +let t26 = "methdo"; + +let s27 = "module"; + +let t27 = "modelu"; + +let s28 = "mutable"; + +let t28 = "butamle"; + +let s29 = "new"; + +let t29 = "wen"; + +let s30 = "object"; + +let t30 = "objcet"; + +let s31 = "of"; + +let t31 = "of"; + +let s32 = "open"; + +let t32 = "epon"; + +let s33 = "or"; + +let t33 = "ro"; + +let s34 = "private"; + +let t34 = "privaet"; + +let s35 = "rec"; + +let t35 = "rec"; + +let s36 = "sig"; + +let t36 = "gis"; + +let s37 = "struct"; + +let t37 = "scrutt"; + +let s38 = "then"; + +let t38 = "hten"; + +let s39 = "to"; + +let t39 = "to"; + +let s40 = "true"; + +let t40 = "teur"; + +let s41 = "try"; + +let t41 = "try"; + +let s42 = "type"; + +let t42 = "pyte"; + +let s43 = "val"; + +let t43 = "val"; + +let s44 = "virtual"; + +let t44 = "vritual"; + +let s45 = "when"; + +let t45 = "whne"; + +let s46 = "while"; + +let t46 = "wlihe"; + +let s47 = "with"; + +let t47 = "iwth"; + +let s48 = "mod"; + +let t48 = "mod"; + +let s49 = "land"; + +let t49 = "alnd"; + +let s50 = "lor"; + +let t50 = "rol"; + +let s51 = "lxor"; + +let t51 = "lxor"; + +let s52 = "lsl"; + +let t52 = "lsl"; + +let s53 = "lsr"; + +let t53 = "lsr"; + +let s54 = "asr"; + +let t54 = "sar"; + +let s55 = "A"; + +let t55 = "A"; + +let s56 = "AA"; + +let t56 = "AA"; + +let s57 = "AAA"; + +let t57 = "AAA"; + +let s58 = "AAAA"; + +let t58 = "AAAA"; + +let s59 = "AAAAA"; + +let t59 = "AAAAA"; + +let s60 = "AAAAAA"; + +let t60 = "AAAAAA"; + +let s61 = "AAAAAAA"; + +let t61 = "AAAAAAA"; + +let s62 = "AAAAAAAA"; + +let t62 = "AAAAAAAA"; + +let s63 = "AAAAAAAAA"; + +let t63 = "AAAAAAAAA"; + +let s64 = "AAAAAAAAAA"; + +let t64 = "AAAAAAAAAA"; + +let s65 = "AAAAAAAAAAA"; + +let t65 = "AAAAAAAAAAA"; + +let s66 = "AAAAAAAAAAAA"; + +let t66 = "AAAAAAAAAAAA"; + +let s67 = "AAAAAAAAAAAAA"; + +let t67 = "AAAAAAAAAAAAA"; + +let s68 = "AAAAAAAAAAAAAA"; + +let t68 = "AAAAAAAAAAAAAA"; + +let s69 = "AAAAAAAAAAAAAAA"; + +let t69 = "AAAAAAAAAAAAAAA"; + +let s70 = "AAAAAAAAAAAAAAAA"; + +let t70 = "AAAAAAAAAAAAAAAA"; + +let s71 = "AAAAAAAAAAAAAAAAA"; + +let t71 = "AAAAAAAAAAAAAAAAA"; + +let s72 = "AAAAAAAAAAAAAAAAAA"; + +let t72 = "AAAAAAAAAAAAAAAAAA"; + +let s73 = "AAAAAAAAAAAAAAAAAAA"; + +let t73 = "AAAAAAAAAAAAAAAAAAA"; + +let s74 = "AAAAAAAAAAAAAAAAAAAA"; + +let t74 = "AAAAAAAAAAAAAAAAAAAA"; + +let s75 = "AAAAAAAAAAAAAAAAAAAAA"; + +let t75 = "AAAAAAAAAAAAAAAAAAAAA"; + +let s76 = "AAAAAAAAAAAAAAAAAAAAAA"; + +let t76 = "AAAAAAAAAAAAAAAAAAAAAA"; + +let s77 = "AAAAAAAAAAAAAAAAAAAAAAA"; + +let t77 = "AAAAAAAAAAAAAAAAAAAAAAA"; + +let s78 = "AAAAAAAAAAAAAAAAAAAAAAAA"; + +let t78 = "AAAAAAAAAAAAAAAAAAAAAAAA"; + +let s79 = "AAAAAAAAAAAAAAAAAAAAAAAAA"; + +let t79 = "AAAAAAAAAAAAAAAAAAAAAAAAA"; + +let s80 = "AAAAAAAAAAAAAAAAAAAAAAAAAA"; + +let t80 = "AAAAAAAAAAAAAAAAAAAAAAAAAA"; + +let s81 = "AAAAAAAAAAAAAAAAAAAAAAAAAAA"; + +let t81 = "AAAAAAAAAAAAAAAAAAAAAAAAAAA"; + +let s82 = "AAAAAAAAAAAAAAAAAAAAAAAAAAAA"; + +let t82 = "AAAAAAAAAAAAAAAAAAAAAAAAAAAA"; + +let s83 = "AAAAAAAAAAAAAAAAAAAAAAAAAAAAA"; + +let t83 = "AAAAAAAAAAAAAAAAAAAAAAAAAAAAA"; + +let s84 = "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA"; + +let t84 = "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA"; + +let s85 = "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA"; + +let t85 = "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA"; + +let s86 = "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA"; + +let t86 = "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA"; + +let s87 = "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA"; + +let t87 = "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA"; + +let s88 = "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA"; + +let t88 = "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA"; + +let s89 = "BBBBBBBBBBBBBBB"; + +let t89 = "BBBBBBBBBBBBBBB"; + +let s90 = "BBBBBBBBBBBBBBBBBBBBBBBBBBBBBBB"; + +let t90 = "BBBBBBBBBBBBBBBBBBBBBBBBBBBBBBB"; + +let s91 = "BBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBB"; + +let t91 = "BBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBB"; + +function tst06(s) { + switch (s) { + case "A" : + return 55; + case "AA" : + return 56; + case "AAA" : + return 57; + case "AAAA" : + return 58; + case "AAAAA" : + return 59; + case "AAAAAA" : + return 60; + case "AAAAAAA" : + return 61; + case "AAAAAAAA" : + return 62; + case "AAAAAAAAA" : + return 63; + case "AAAAAAAAAA" : + return 64; + case "AAAAAAAAAAA" : + return 65; + case "AAAAAAAAAAAA" : + return 66; + case "AAAAAAAAAAAAA" : + return 67; + case "AAAAAAAAAAAAAA" : + return 68; + case "AAAAAAAAAAAAAAA" : + return 69; + case "AAAAAAAAAAAAAAAA" : + return 70; + case "AAAAAAAAAAAAAAAAA" : + return 71; + case "AAAAAAAAAAAAAAAAAA" : + return 72; + case "AAAAAAAAAAAAAAAAAAA" : + return 73; + case "AAAAAAAAAAAAAAAAAAAA" : + return 74; + case "AAAAAAAAAAAAAAAAAAAAA" : + return 75; + case "AAAAAAAAAAAAAAAAAAAAAA" : + return 76; + case "AAAAAAAAAAAAAAAAAAAAAAA" : + return 77; + case "AAAAAAAAAAAAAAAAAAAAAAAA" : + return 78; + case "AAAAAAAAAAAAAAAAAAAAAAAAA" : + return 79; + case "AAAAAAAAAAAAAAAAAAAAAAAAAA" : + return 80; + case "AAAAAAAAAAAAAAAAAAAAAAAAAAA" : + return 81; + case "AAAAAAAAAAAAAAAAAAAAAAAAAAAA" : + return 82; + case "AAAAAAAAAAAAAAAAAAAAAAAAAAAAA" : + return 83; + case "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA" : + return 84; + case "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA" : + return 85; + case "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA" : + return 86; + case "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA" : + return 87; + case "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA" : + return 88; + case "BBBBBBBBBBBBBBB" : + return 89; + case "BBBBBBBBBBBBBBBBBBBBBBBBBBBBBBB" : + return 90; + case "BBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBB" : + return 91; + case "and" : + return 0; + case "as" : + return 1; + case "asr" : + return 54; + case "assert" : + return 2; + case "begin" : + return 3; + case "class" : + return 4; + case "constraint" : + return 5; + case "do" : + return 6; + case "done" : + return 7; + case "downto" : + return 8; + case "else" : + return 9; + case "end" : + return 10; + case "exception" : + return 11; + case "external" : + return 12; + case "false" : + return 13; + case "for" : + return 14; + case "fun" : + return 15; + case "function" : + return 16; + case "functor" : + return 17; + case "if" : + return 18; + case "in" : + return 19; + case "include" : + return 20; + case "inherit" : + return 21; + case "initializer" : + return 22; + case "land" : + return 49; + case "lazy" : + return 23; + case "let" : + return 24; + case "lor" : + return 50; + case "lsl" : + return 52; + case "lsr" : + return 53; + case "lxor" : + return 51; + case "match" : + return 25; + case "method" : + return 26; + case "mod" : + return 48; + case "module" : + return 27; + case "mutable" : + return 28; + case "new" : + return 29; + case "object" : + return 30; + case "of" : + return 31; + case "open" : + return 32; + case "or" : + return 33; + case "private" : + return 34; + case "rec" : + return 35; + case "sig" : + return 36; + case "struct" : + return 37; + case "then" : + return 38; + case "to" : + return 39; + case "true" : + return 40; + case "try" : + return 41; + case "type" : + return 42; + case "val" : + return 43; + case "virtual" : + return 44; + case "when" : + return 45; + case "while" : + return 46; + case "with" : + return 47; + default: + return -1; + } +} + +if (tst06(s00) !== 0) { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "stringmatch_test.res", + 582, + 2 + ], + Error: new Error() + }; +} + +if (tst06(t00) !== -1) { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "stringmatch_test.res", + 583, + 2 + ], + Error: new Error() + }; +} + +if (tst06(s01) !== 1) { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "stringmatch_test.res", + 584, + 2 + ], + Error: new Error() + }; +} + +if (tst06(t01) !== -1) { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "stringmatch_test.res", + 585, + 2 + ], + Error: new Error() + }; +} + +if (tst06(s02) !== 2) { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "stringmatch_test.res", + 586, + 2 + ], + Error: new Error() + }; +} + +if (tst06(t02) !== -1) { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "stringmatch_test.res", + 587, + 2 + ], + Error: new Error() + }; +} + +if (tst06(s03) !== 3) { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "stringmatch_test.res", + 588, + 2 + ], + Error: new Error() + }; +} + +if (tst06(t03) !== -1) { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "stringmatch_test.res", + 589, + 2 + ], + Error: new Error() + }; +} + +if (tst06(s04) !== 4) { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "stringmatch_test.res", + 590, + 2 + ], + Error: new Error() + }; +} + +if (tst06(t04) !== -1) { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "stringmatch_test.res", + 591, + 2 + ], + Error: new Error() + }; +} + +if (tst06(s05) !== 5) { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "stringmatch_test.res", + 592, + 2 + ], + Error: new Error() + }; +} + +if (tst06(t05) !== -1) { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "stringmatch_test.res", + 593, + 2 + ], + Error: new Error() + }; +} + +if (tst06(s06) !== 6) { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "stringmatch_test.res", + 594, + 2 + ], + Error: new Error() + }; +} + +if (tst06(t06) !== -1) { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "stringmatch_test.res", + 595, + 2 + ], + Error: new Error() + }; +} + +if (tst06(s07) !== 7) { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "stringmatch_test.res", + 596, + 2 + ], + Error: new Error() + }; +} + +if (tst06(t07) !== -1) { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "stringmatch_test.res", + 597, + 2 + ], + Error: new Error() + }; +} + +if (tst06(s08) !== 8) { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "stringmatch_test.res", + 598, + 2 + ], + Error: new Error() + }; +} + +if (tst06(t08) !== -1) { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "stringmatch_test.res", + 599, + 2 + ], + Error: new Error() + }; +} + +if (tst06(s09) !== 9) { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "stringmatch_test.res", + 600, + 2 + ], + Error: new Error() + }; +} + +if (tst06(t09) !== -1) { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "stringmatch_test.res", + 601, + 2 + ], + Error: new Error() + }; +} + +if (tst06(s10) !== 10) { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "stringmatch_test.res", + 602, + 2 + ], + Error: new Error() + }; +} + +if (tst06(t10) !== -1) { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "stringmatch_test.res", + 603, + 2 + ], + Error: new Error() + }; +} + +if (tst06(s11) !== 11) { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "stringmatch_test.res", + 604, + 2 + ], + Error: new Error() + }; +} + +if (tst06(t11) !== 11) { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "stringmatch_test.res", + 605, + 2 + ], + Error: new Error() + }; +} + +if (tst06(s12) !== 12) { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "stringmatch_test.res", + 606, + 2 + ], + Error: new Error() + }; +} + +if (tst06(t12) !== 12) { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "stringmatch_test.res", + 607, + 2 + ], + Error: new Error() + }; +} + +if (tst06(s13) !== 13) { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "stringmatch_test.res", + 608, + 2 + ], + Error: new Error() + }; +} + +if (tst06(t13) !== -1) { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "stringmatch_test.res", + 609, + 2 + ], + Error: new Error() + }; +} + +if (tst06(s14) !== 14) { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "stringmatch_test.res", + 610, + 2 + ], + Error: new Error() + }; +} + +if (tst06(t14) !== -1) { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "stringmatch_test.res", + 611, + 2 + ], + Error: new Error() + }; +} + +if (tst06(s15) !== 15) { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "stringmatch_test.res", + 612, + 2 + ], + Error: new Error() + }; +} + +if (tst06(t15) !== -1) { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "stringmatch_test.res", + 613, + 2 + ], + Error: new Error() + }; +} + +if (tst06(s16) !== 16) { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "stringmatch_test.res", + 614, + 2 + ], + Error: new Error() + }; +} + +if (tst06(t16) !== 16) { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "stringmatch_test.res", + 615, + 2 + ], + Error: new Error() + }; +} + +if (tst06(s17) !== 17) { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "stringmatch_test.res", + 616, + 2 + ], + Error: new Error() + }; +} + +if (tst06(t17) !== -1) { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "stringmatch_test.res", + 617, + 2 + ], + Error: new Error() + }; +} + +if (tst06(s18) !== 18) { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "stringmatch_test.res", + 618, + 2 + ], + Error: new Error() + }; +} + +if (tst06(t18) !== -1) { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "stringmatch_test.res", + 619, + 2 + ], + Error: new Error() + }; +} + +if (tst06(s19) !== 19) { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "stringmatch_test.res", + 620, + 2 + ], + Error: new Error() + }; +} + +if (tst06(t19) !== 19) { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "stringmatch_test.res", + 621, + 2 + ], + Error: new Error() + }; +} + +if (tst06(s20) !== 20) { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "stringmatch_test.res", + 622, + 2 + ], + Error: new Error() + }; +} + +if (tst06(t20) !== -1) { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "stringmatch_test.res", + 623, + 2 + ], + Error: new Error() + }; +} + +if (tst06(s21) !== 21) { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "stringmatch_test.res", + 624, + 2 + ], + Error: new Error() + }; +} + +if (tst06(t21) !== -1) { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "stringmatch_test.res", + 625, + 2 + ], + Error: new Error() + }; +} + +if (tst06(s22) !== 22) { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "stringmatch_test.res", + 626, + 2 + ], + Error: new Error() + }; +} + +if (tst06(t22) !== -1) { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "stringmatch_test.res", + 627, + 2 + ], + Error: new Error() + }; +} + +if (tst06(s23) !== 23) { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "stringmatch_test.res", + 628, + 2 + ], + Error: new Error() + }; +} + +if (tst06(t23) !== -1) { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "stringmatch_test.res", + 629, + 2 + ], + Error: new Error() + }; +} + +if (tst06(s24) !== 24) { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "stringmatch_test.res", + 630, + 2 + ], + Error: new Error() + }; +} + +if (tst06(t24) !== -1) { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "stringmatch_test.res", + 631, + 2 + ], + Error: new Error() + }; +} + +if (tst06(s25) !== 25) { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "stringmatch_test.res", + 632, + 2 + ], + Error: new Error() + }; +} + +if (tst06(t25) !== 25) { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "stringmatch_test.res", + 633, + 2 + ], + Error: new Error() + }; +} + +if (tst06(s26) !== 26) { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "stringmatch_test.res", + 634, + 2 + ], + Error: new Error() + }; +} + +if (tst06(t26) !== -1) { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "stringmatch_test.res", + 635, + 2 + ], + Error: new Error() + }; +} + +if (tst06(s27) !== 27) { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "stringmatch_test.res", + 636, + 2 + ], + Error: new Error() + }; +} + +if (tst06(t27) !== -1) { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "stringmatch_test.res", + 637, + 2 + ], + Error: new Error() + }; +} + +if (tst06(s28) !== 28) { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "stringmatch_test.res", + 638, + 2 + ], + Error: new Error() + }; +} + +if (tst06(t28) !== -1) { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "stringmatch_test.res", + 639, + 2 + ], + Error: new Error() + }; +} + +if (tst06(s29) !== 29) { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "stringmatch_test.res", + 640, + 2 + ], + Error: new Error() + }; +} + +if (tst06(t29) !== -1) { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "stringmatch_test.res", + 641, + 2 + ], + Error: new Error() + }; +} + +if (tst06(s30) !== 30) { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "stringmatch_test.res", + 642, + 2 + ], + Error: new Error() + }; +} + +if (tst06(t30) !== -1) { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "stringmatch_test.res", + 643, + 2 + ], + Error: new Error() + }; +} + +if (tst06(s31) !== 31) { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "stringmatch_test.res", + 644, + 2 + ], + Error: new Error() + }; +} + +if (tst06(t31) !== 31) { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "stringmatch_test.res", + 645, + 2 + ], + Error: new Error() + }; +} + +if (tst06(s32) !== 32) { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "stringmatch_test.res", + 646, + 2 + ], + Error: new Error() + }; +} + +if (tst06(t32) !== -1) { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "stringmatch_test.res", + 647, + 2 + ], + Error: new Error() + }; +} + +if (tst06(s33) !== 33) { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "stringmatch_test.res", + 648, + 2 + ], + Error: new Error() + }; +} + +if (tst06(t33) !== -1) { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "stringmatch_test.res", + 649, + 2 + ], + Error: new Error() + }; +} + +if (tst06(s34) !== 34) { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "stringmatch_test.res", + 650, + 2 + ], + Error: new Error() + }; +} + +if (tst06(t34) !== -1) { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "stringmatch_test.res", + 651, + 2 + ], + Error: new Error() + }; +} + +if (tst06(s35) !== 35) { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "stringmatch_test.res", + 652, + 2 + ], + Error: new Error() + }; +} + +if (tst06(t35) !== 35) { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "stringmatch_test.res", + 653, + 2 + ], + Error: new Error() + }; +} + +if (tst06(s36) !== 36) { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "stringmatch_test.res", + 654, + 2 + ], + Error: new Error() + }; +} + +if (tst06(t36) !== -1) { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "stringmatch_test.res", + 655, + 2 + ], + Error: new Error() + }; +} + +if (tst06(s37) !== 37) { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "stringmatch_test.res", + 656, + 2 + ], + Error: new Error() + }; +} + +if (tst06(t37) !== -1) { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "stringmatch_test.res", + 657, + 2 + ], + Error: new Error() + }; +} + +if (tst06(s38) !== 38) { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "stringmatch_test.res", + 658, + 2 + ], + Error: new Error() + }; +} + +if (tst06(t38) !== -1) { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "stringmatch_test.res", + 659, + 2 + ], + Error: new Error() + }; +} + +if (tst06(s39) !== 39) { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "stringmatch_test.res", + 660, + 2 + ], + Error: new Error() + }; +} + +if (tst06(t39) !== 39) { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "stringmatch_test.res", + 661, + 2 + ], + Error: new Error() + }; +} + +if (tst06(s40) !== 40) { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "stringmatch_test.res", + 662, + 2 + ], + Error: new Error() + }; +} + +if (tst06(t40) !== -1) { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "stringmatch_test.res", + 663, + 2 + ], + Error: new Error() + }; +} + +if (tst06(s41) !== 41) { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "stringmatch_test.res", + 664, + 2 + ], + Error: new Error() + }; +} + +if (tst06(t41) !== 41) { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "stringmatch_test.res", + 665, + 2 + ], + Error: new Error() + }; +} + +if (tst06(s42) !== 42) { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "stringmatch_test.res", + 666, + 2 + ], + Error: new Error() + }; +} + +if (tst06(t42) !== -1) { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "stringmatch_test.res", + 667, + 2 + ], + Error: new Error() + }; +} + +if (tst06(s43) !== 43) { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "stringmatch_test.res", + 668, + 2 + ], + Error: new Error() + }; +} + +if (tst06(t43) !== 43) { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "stringmatch_test.res", + 669, + 2 + ], + Error: new Error() + }; +} + +if (tst06(s44) !== 44) { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "stringmatch_test.res", + 670, + 2 + ], + Error: new Error() + }; +} + +if (tst06(t44) !== -1) { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "stringmatch_test.res", + 671, + 2 + ], + Error: new Error() + }; +} + +if (tst06(s45) !== 45) { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "stringmatch_test.res", + 672, + 2 + ], + Error: new Error() + }; +} + +if (tst06(t45) !== -1) { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "stringmatch_test.res", + 673, + 2 + ], + Error: new Error() + }; +} + +if (tst06(s46) !== 46) { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "stringmatch_test.res", + 674, + 2 + ], + Error: new Error() + }; +} + +if (tst06(t46) !== -1) { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "stringmatch_test.res", + 675, + 2 + ], + Error: new Error() + }; +} + +if (tst06(s47) !== 47) { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "stringmatch_test.res", + 676, + 2 + ], + Error: new Error() + }; +} + +if (tst06(t47) !== -1) { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "stringmatch_test.res", + 677, + 2 + ], + Error: new Error() + }; +} + +if (tst06(s48) !== 48) { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "stringmatch_test.res", + 678, + 2 + ], + Error: new Error() + }; +} + +if (tst06(t48) !== 48) { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "stringmatch_test.res", + 679, + 2 + ], + Error: new Error() + }; +} + +if (tst06(s49) !== 49) { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "stringmatch_test.res", + 680, + 2 + ], + Error: new Error() + }; +} + +if (tst06(t49) !== -1) { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "stringmatch_test.res", + 681, + 2 + ], + Error: new Error() + }; +} + +if (tst06(s50) !== 50) { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "stringmatch_test.res", + 682, + 2 + ], + Error: new Error() + }; +} + +if (tst06(t50) !== -1) { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "stringmatch_test.res", + 683, + 2 + ], + Error: new Error() + }; +} + +if (tst06(s51) !== 51) { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "stringmatch_test.res", + 684, + 2 + ], + Error: new Error() + }; +} + +if (tst06(t51) !== 51) { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "stringmatch_test.res", + 685, + 2 + ], + Error: new Error() + }; +} + +if (tst06(s52) !== 52) { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "stringmatch_test.res", + 686, + 2 + ], + Error: new Error() + }; +} + +if (tst06(t52) !== 52) { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "stringmatch_test.res", + 687, + 2 + ], + Error: new Error() + }; +} + +if (tst06(s53) !== 53) { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "stringmatch_test.res", + 688, + 2 + ], + Error: new Error() + }; +} + +if (tst06(t53) !== 53) { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "stringmatch_test.res", + 689, + 2 + ], + Error: new Error() + }; +} + +if (tst06(s54) !== 54) { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "stringmatch_test.res", + 690, + 2 + ], + Error: new Error() + }; +} + +if (tst06(t54) !== -1) { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "stringmatch_test.res", + 691, + 2 + ], + Error: new Error() + }; +} + +if (tst06(s55) !== 55) { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "stringmatch_test.res", + 692, + 2 + ], + Error: new Error() + }; +} + +if (tst06(t55) !== 55) { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "stringmatch_test.res", + 693, + 2 + ], + Error: new Error() + }; +} + +if (tst06(s56) !== 56) { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "stringmatch_test.res", + 694, + 2 + ], + Error: new Error() + }; +} + +if (tst06(t56) !== 56) { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "stringmatch_test.res", + 695, + 2 + ], + Error: new Error() + }; +} + +if (tst06(s57) !== 57) { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "stringmatch_test.res", + 696, + 2 + ], + Error: new Error() + }; +} + +if (tst06(t57) !== 57) { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "stringmatch_test.res", + 697, + 2 + ], + Error: new Error() + }; +} + +if (tst06(s58) !== 58) { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "stringmatch_test.res", + 698, + 2 + ], + Error: new Error() + }; +} + +if (tst06(t58) !== 58) { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "stringmatch_test.res", + 699, + 2 + ], + Error: new Error() + }; +} + +if (tst06(s59) !== 59) { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "stringmatch_test.res", + 700, + 2 + ], + Error: new Error() + }; +} + +if (tst06(t59) !== 59) { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "stringmatch_test.res", + 701, + 2 + ], + Error: new Error() + }; +} + +if (tst06(s60) !== 60) { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "stringmatch_test.res", + 702, + 2 + ], + Error: new Error() + }; +} + +if (tst06(t60) !== 60) { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "stringmatch_test.res", + 703, + 2 + ], + Error: new Error() + }; +} + +if (tst06(s61) !== 61) { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "stringmatch_test.res", + 704, + 2 + ], + Error: new Error() + }; +} + +if (tst06(t61) !== 61) { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "stringmatch_test.res", + 705, + 2 + ], + Error: new Error() + }; +} + +if (tst06(s62) !== 62) { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "stringmatch_test.res", + 706, + 2 + ], + Error: new Error() + }; +} + +if (tst06(t62) !== 62) { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "stringmatch_test.res", + 707, + 2 + ], + Error: new Error() + }; +} + +if (tst06(s63) !== 63) { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "stringmatch_test.res", + 708, + 2 + ], + Error: new Error() + }; +} + +if (tst06(t63) !== 63) { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "stringmatch_test.res", + 709, + 2 + ], + Error: new Error() + }; +} + +if (tst06(s64) !== 64) { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "stringmatch_test.res", + 710, + 2 + ], + Error: new Error() + }; +} + +if (tst06(t64) !== 64) { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "stringmatch_test.res", + 711, + 2 + ], + Error: new Error() + }; +} + +if (tst06(s65) !== 65) { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "stringmatch_test.res", + 712, + 2 + ], + Error: new Error() + }; +} + +if (tst06(t65) !== 65) { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "stringmatch_test.res", + 713, + 2 + ], + Error: new Error() + }; +} + +if (tst06(s66) !== 66) { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "stringmatch_test.res", + 714, + 2 + ], + Error: new Error() + }; +} + +if (tst06(t66) !== 66) { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "stringmatch_test.res", + 715, + 2 + ], + Error: new Error() + }; +} + +if (tst06(s67) !== 67) { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "stringmatch_test.res", + 716, + 2 + ], + Error: new Error() + }; +} + +if (tst06(t67) !== 67) { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "stringmatch_test.res", + 717, + 2 + ], + Error: new Error() + }; +} + +if (tst06(s68) !== 68) { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "stringmatch_test.res", + 718, + 2 + ], + Error: new Error() + }; +} + +if (tst06(t68) !== 68) { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "stringmatch_test.res", + 719, + 2 + ], + Error: new Error() + }; +} + +if (tst06(s69) !== 69) { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "stringmatch_test.res", + 720, + 2 + ], + Error: new Error() + }; +} + +if (tst06(t69) !== 69) { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "stringmatch_test.res", + 721, + 2 + ], + Error: new Error() + }; +} + +if (tst06(s70) !== 70) { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "stringmatch_test.res", + 722, + 2 + ], + Error: new Error() + }; +} + +if (tst06(t70) !== 70) { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "stringmatch_test.res", + 723, + 2 + ], + Error: new Error() + }; +} + +if (tst06(s71) !== 71) { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "stringmatch_test.res", + 724, + 2 + ], + Error: new Error() + }; +} + +if (tst06(t71) !== 71) { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "stringmatch_test.res", + 725, + 2 + ], + Error: new Error() + }; +} + +if (tst06(s72) !== 72) { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "stringmatch_test.res", + 726, + 2 + ], + Error: new Error() + }; +} + +if (tst06(t72) !== 72) { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "stringmatch_test.res", + 727, + 2 + ], + Error: new Error() + }; +} + +if (tst06(s73) !== 73) { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "stringmatch_test.res", + 728, + 2 + ], + Error: new Error() + }; +} + +if (tst06(t73) !== 73) { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "stringmatch_test.res", + 729, + 2 + ], + Error: new Error() + }; +} + +if (tst06(s74) !== 74) { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "stringmatch_test.res", + 730, + 2 + ], + Error: new Error() + }; +} + +if (tst06(t74) !== 74) { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "stringmatch_test.res", + 731, + 2 + ], + Error: new Error() + }; +} + +if (tst06(s75) !== 75) { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "stringmatch_test.res", + 732, + 2 + ], + Error: new Error() + }; +} + +if (tst06(t75) !== 75) { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "stringmatch_test.res", + 733, + 2 + ], + Error: new Error() + }; +} + +if (tst06(s76) !== 76) { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "stringmatch_test.res", + 734, + 2 + ], + Error: new Error() + }; +} + +if (tst06(t76) !== 76) { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "stringmatch_test.res", + 735, + 2 + ], + Error: new Error() + }; +} + +if (tst06(s77) !== 77) { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "stringmatch_test.res", + 736, + 2 + ], + Error: new Error() + }; +} + +if (tst06(t77) !== 77) { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "stringmatch_test.res", + 737, + 2 + ], + Error: new Error() + }; +} + +if (tst06(s78) !== 78) { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "stringmatch_test.res", + 738, + 2 + ], + Error: new Error() + }; +} + +if (tst06(t78) !== 78) { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "stringmatch_test.res", + 739, + 2 + ], + Error: new Error() + }; +} + +if (tst06(s79) !== 79) { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "stringmatch_test.res", + 740, + 2 + ], + Error: new Error() + }; +} + +if (tst06(t79) !== 79) { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "stringmatch_test.res", + 741, + 2 + ], + Error: new Error() + }; +} + +if (tst06(s80) !== 80) { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "stringmatch_test.res", + 742, + 2 + ], + Error: new Error() + }; +} + +if (tst06(t80) !== 80) { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "stringmatch_test.res", + 743, + 2 + ], + Error: new Error() + }; +} + +if (tst06(s81) !== 81) { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "stringmatch_test.res", + 744, + 2 + ], + Error: new Error() + }; +} + +if (tst06(t81) !== 81) { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "stringmatch_test.res", + 745, + 2 + ], + Error: new Error() + }; +} + +if (tst06(s82) !== 82) { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "stringmatch_test.res", + 746, + 2 + ], + Error: new Error() + }; +} + +if (tst06(t82) !== 82) { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "stringmatch_test.res", + 747, + 2 + ], + Error: new Error() + }; +} + +if (tst06(s83) !== 83) { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "stringmatch_test.res", + 748, + 2 + ], + Error: new Error() + }; +} + +if (tst06(t83) !== 83) { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "stringmatch_test.res", + 749, + 2 + ], + Error: new Error() + }; +} + +if (tst06(s84) !== 84) { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "stringmatch_test.res", + 750, + 2 + ], + Error: new Error() + }; +} + +if (tst06(t84) !== 84) { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "stringmatch_test.res", + 751, + 2 + ], + Error: new Error() + }; +} + +if (tst06(s85) !== 85) { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "stringmatch_test.res", + 752, + 2 + ], + Error: new Error() + }; +} + +if (tst06(t85) !== 85) { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "stringmatch_test.res", + 753, + 2 + ], + Error: new Error() + }; +} + +if (tst06(s86) !== 86) { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "stringmatch_test.res", + 754, + 2 + ], + Error: new Error() + }; +} + +if (tst06(t86) !== 86) { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "stringmatch_test.res", + 755, + 2 + ], + Error: new Error() + }; +} + +if (tst06(s87) !== 87) { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "stringmatch_test.res", + 756, + 2 + ], + Error: new Error() + }; +} + +if (tst06(t87) !== 87) { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "stringmatch_test.res", + 757, + 2 + ], + Error: new Error() + }; +} + +if (tst06(s88) !== 88) { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "stringmatch_test.res", + 758, + 2 + ], + Error: new Error() + }; +} + +if (tst06(t88) !== 88) { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "stringmatch_test.res", + 759, + 2 + ], + Error: new Error() + }; +} + +if (tst06(s89) !== 89) { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "stringmatch_test.res", + 760, + 2 + ], + Error: new Error() + }; +} + +if (tst06(t89) !== 89) { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "stringmatch_test.res", + 761, + 2 + ], + Error: new Error() + }; +} + +if (tst06(s90) !== 90) { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "stringmatch_test.res", + 762, + 2 + ], + Error: new Error() + }; +} + +if (tst06(t90) !== 90) { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "stringmatch_test.res", + 763, + 2 + ], + Error: new Error() + }; +} + +if (tst06(s91) !== 91) { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "stringmatch_test.res", + 764, + 2 + ], + Error: new Error() + }; +} + +if (tst06(t91) !== 91) { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "stringmatch_test.res", + 765, + 2 + ], + Error: new Error() + }; +} + +if (tst06("") !== -1) { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "stringmatch_test.res", + 766, + 2 + ], + Error: new Error() + }; +} + +export { + tst01, + tst02, + tst03, + tst04, + tst05, + s00, + t00, + s01, + t01, + s02, + t02, + s03, + t03, + s04, + t04, + s05, + t05, + s06, + t06, + s07, + t07, + s08, + t08, + s09, + t09, + s10, + t10, + s11, + t11, + s12, + t12, + s13, + t13, + s14, + t14, + s15, + t15, + s16, + t16, + s17, + t17, + s18, + t18, + s19, + t19, + s20, + t20, + s21, + t21, + s22, + t22, + s23, + t23, + s24, + t24, + s25, + t25, + s26, + t26, + s27, + t27, + s28, + t28, + s29, + t29, + s30, + t30, + s31, + t31, + s32, + t32, + s33, + t33, + s34, + t34, + s35, + t35, + s36, + t36, + s37, + t37, + s38, + t38, + s39, + t39, + s40, + t40, + s41, + t41, + s42, + t42, + s43, + t43, + s44, + t44, + s45, + t45, + s46, + t46, + s47, + t47, + s48, + t48, + s49, + t49, + s50, + t50, + s51, + t51, + s52, + t52, + s53, + t53, + s54, + t54, + s55, + t55, + s56, + t56, + s57, + t57, + s58, + t58, + s59, + t59, + s60, + t60, + s61, + t61, + s62, + t62, + s63, + t63, + s64, + t64, + s65, + t65, + s66, + t66, + s67, + t67, + s68, + t68, + s69, + t69, + s70, + t70, + s71, + t71, + s72, + t72, + s73, + t73, + s74, + t74, + s75, + t75, + s76, + t76, + s77, + t77, + s78, + t78, + s79, + t79, + s80, + t80, + s81, + t81, + s82, + t82, + s83, + t83, + s84, + t84, + s85, + t85, + s86, + t86, + s87, + t87, + s88, + t88, + s89, + t89, + s90, + t90, + s91, + t91, + tst06, +} +/* Not a pure module */ diff --git a/tests/tests/src/submodule.js b/tests/tests/src/submodule.js deleted file mode 100644 index ed6c208606..0000000000 --- a/tests/tests/src/submodule.js +++ /dev/null @@ -1,75 +0,0 @@ -// Generated by ReScript, PLEASE EDIT WITH CARE -'use strict'; - - -console.log(2); - -function a0(x, y) { - return (x + y | 0) + 1 | 0; -} - -console.log(5); - -function a1(x, y) { - return a0(x, y) + 1 | 0; -} - -console.log(8); - -function a2(x, y) { - return a1(x, y) + 1 | 0; -} - -console.log(11); - -function a3(x, y) { - return a2(x, y) + 1 | 0; -} - -console.log(14); - -function a4(x, y) { - return a3(x, y) + 1 | 0; -} - -let A4 = { - a4: a4 -}; - -let A3 = { - a3: a3, - A4: A4 -}; - -let A2 = { - a2: a2, - A3: A3 -}; - -let A1 = { - a1: a1, - A2: A2 -}; - -let A0 = { - a0: a0, - A1: A1 -}; - -let v0 = 4; - -let v1 = a1(1, 2); - -let v2 = a2(1, 2); - -let v3 = a3(1, 2); - -let v4 = a4(1, 2); - -exports.A0 = A0; -exports.v0 = v0; -exports.v1 = v1; -exports.v2 = v2; -exports.v3 = v3; -exports.v4 = v4; -/* Not a pure module */ diff --git a/tests/tests/src/submodule.mjs b/tests/tests/src/submodule.mjs new file mode 100644 index 0000000000..59022e564c --- /dev/null +++ b/tests/tests/src/submodule.mjs @@ -0,0 +1,76 @@ +// Generated by ReScript, PLEASE EDIT WITH CARE + + +console.log(2); + +function a0(x, y) { + return (x + y | 0) + 1 | 0; +} + +console.log(5); + +function a1(x, y) { + return a0(x, y) + 1 | 0; +} + +console.log(8); + +function a2(x, y) { + return a1(x, y) + 1 | 0; +} + +console.log(11); + +function a3(x, y) { + return a2(x, y) + 1 | 0; +} + +console.log(14); + +function a4(x, y) { + return a3(x, y) + 1 | 0; +} + +let A4 = { + a4: a4 +}; + +let A3 = { + a3: a3, + A4: A4 +}; + +let A2 = { + a2: a2, + A3: A3 +}; + +let A1 = { + a1: a1, + A2: A2 +}; + +let A0 = { + a0: a0, + A1: A1 +}; + +let v0 = 4; + +let v1 = a1(1, 2); + +let v2 = a2(1, 2); + +let v3 = a3(1, 2); + +let v4 = a4(1, 2); + +export { + A0, + v0, + v1, + v2, + v3, + v4, +} +/* Not a pure module */ diff --git a/tests/tests/src/submodule_call.js b/tests/tests/src/submodule_call.js deleted file mode 100644 index 6bbfb22c22..0000000000 --- a/tests/tests/src/submodule_call.js +++ /dev/null @@ -1,21 +0,0 @@ -// Generated by ReScript, PLEASE EDIT WITH CARE -'use strict'; - -let Submodule = require("./submodule.js"); - -let a0 = Submodule.A0.a0(1, 2); - -let a1 = Submodule.A0.A1.a1(1, 2); - -let a2 = Submodule.A0.A1.A2.a2(1, 2); - -let a3 = Submodule.A0.A1.A2.A3.a3(1, 2); - -let a4 = Submodule.A0.A1.A2.A3.A4.a4(1, 2); - -exports.a0 = a0; -exports.a1 = a1; -exports.a2 = a2; -exports.a3 = a3; -exports.a4 = a4; -/* a0 Not a pure module */ diff --git a/tests/tests/src/submodule_call.mjs b/tests/tests/src/submodule_call.mjs new file mode 100644 index 0000000000..5f9c3fc7c7 --- /dev/null +++ b/tests/tests/src/submodule_call.mjs @@ -0,0 +1,22 @@ +// Generated by ReScript, PLEASE EDIT WITH CARE + +import * as Submodule from "./submodule.mjs"; + +let a0 = Submodule.A0.a0(1, 2); + +let a1 = Submodule.A0.A1.a1(1, 2); + +let a2 = Submodule.A0.A1.A2.a2(1, 2); + +let a3 = Submodule.A0.A1.A2.A3.a3(1, 2); + +let a4 = Submodule.A0.A1.A2.A3.A4.a4(1, 2); + +export { + a0, + a1, + a2, + a3, + a4, +} +/* a0 Not a pure module */ diff --git a/tests/tests/src/switch_case_test.js b/tests/tests/src/switch_case_test.js deleted file mode 100644 index 434d9e717b..0000000000 --- a/tests/tests/src/switch_case_test.js +++ /dev/null @@ -1,58 +0,0 @@ -// Generated by ReScript, PLEASE EDIT WITH CARE -'use strict'; - -let Mt = require("./mt.js"); - -let suites = { - contents: /* [] */0 -}; - -let test_id = { - contents: 0 -}; - -function eq(loc, x, y) { - test_id.contents = test_id.contents + 1 | 0; - suites.contents = { - hd: [ - loc + (" id " + test_id.contents.toString()), - () => ({ - TAG: "Eq", - _0: x, - _1: y - }) - ], - tl: suites.contents - }; -} - -function f(x) { - switch (x) { - case "xx'''" : - return 0; - case "xx\"" : - return 1; - case "xx\\\"" : - return 2; - case "xx\\\"\"" : - return 3; - default: - return 4; - } -} - -eq("File \"switch_case_test.res\", line 22, characters 5-12", f("xx'''"), 0); - -eq("File \"switch_case_test.res\", line 23, characters 5-12", f("xx\""), 1); - -eq("File \"switch_case_test.res\", line 24, characters 5-12", f("xx\\\""), 2); - -eq("File \"switch_case_test.res\", line 25, characters 5-12", f("xx\\\"\""), 3); - -Mt.from_pair_suites("Switch_case_test", suites.contents); - -exports.suites = suites; -exports.test_id = test_id; -exports.eq = eq; -exports.f = f; -/* Not a pure module */ diff --git a/tests/tests/src/switch_case_test.mjs b/tests/tests/src/switch_case_test.mjs new file mode 100644 index 0000000000..652b5ec795 --- /dev/null +++ b/tests/tests/src/switch_case_test.mjs @@ -0,0 +1,59 @@ +// Generated by ReScript, PLEASE EDIT WITH CARE + +import * as Mt from "./mt.mjs"; + +let suites = { + contents: /* [] */0 +}; + +let test_id = { + contents: 0 +}; + +function eq(loc, x, y) { + test_id.contents = test_id.contents + 1 | 0; + suites.contents = { + hd: [ + loc + (" id " + test_id.contents.toString()), + () => ({ + TAG: "Eq", + _0: x, + _1: y + }) + ], + tl: suites.contents + }; +} + +function f(x) { + switch (x) { + case "xx'''" : + return 0; + case "xx\"" : + return 1; + case "xx\\\"" : + return 2; + case "xx\\\"\"" : + return 3; + default: + return 4; + } +} + +eq("File \"switch_case_test.res\", line 22, characters 5-12", f("xx'''"), 0); + +eq("File \"switch_case_test.res\", line 23, characters 5-12", f("xx\""), 1); + +eq("File \"switch_case_test.res\", line 24, characters 5-12", f("xx\\\""), 2); + +eq("File \"switch_case_test.res\", line 25, characters 5-12", f("xx\\\"\""), 3); + +Mt.from_pair_suites("Switch_case_test", suites.contents); + +export { + suites, + test_id, + eq, + f, +} +/* Not a pure module */ diff --git a/tests/tests/src/switch_string.js b/tests/tests/src/switch_string.js deleted file mode 100644 index 4cdd65b785..0000000000 --- a/tests/tests/src/switch_string.js +++ /dev/null @@ -1,29 +0,0 @@ -// Generated by ReScript, PLEASE EDIT WITH CARE -'use strict'; - - -function foo(x) { - if (x === "\"") { - return "\""; - } else { - return ""; - } -} - -function bar(x) { - switch (x) { - case "\\" : - return "\\"; - case "😀" : - return "😀"; - default: - return ""; - } -} - -let s = "😀"; - -exports.foo = foo; -exports.s = s; -exports.bar = bar; -/* No side effect */ diff --git a/tests/tests/src/switch_string.mjs b/tests/tests/src/switch_string.mjs new file mode 100644 index 0000000000..8f4d0293c5 --- /dev/null +++ b/tests/tests/src/switch_string.mjs @@ -0,0 +1,30 @@ +// Generated by ReScript, PLEASE EDIT WITH CARE + + +function foo(x) { + if (x === "\"") { + return "\""; + } else { + return ""; + } +} + +function bar(x) { + switch (x) { + case "\\" : + return "\\"; + case "😀" : + return "😀"; + default: + return ""; + } +} + +let s = "😀"; + +export { + foo, + s, + bar, +} +/* No side effect */ diff --git a/tests/tests/src/tagged_template_test.js b/tests/tests/src/tagged_template_test.js deleted file mode 100644 index 457d8894e6..0000000000 --- a/tests/tests/src/tagged_template_test.js +++ /dev/null @@ -1,116 +0,0 @@ -// Generated by ReScript, PLEASE EDIT WITH CARE -'use strict'; - -let Mt = require("./mt.js"); -let Primitive_array = require("rescript/lib/js/Primitive_array.js"); -let Tagged_template_libJs = require("./tagged_template_lib.js"); - -function sql(prim0, prim1) { - return Tagged_template_libJs.sql(prim0, ...prim1); -} - -let Pg = { - sql: sql -}; - -let table = "users"; - -let id = "5"; - -let queryWithModule = Tagged_template_libJs.sql`SELECT * FROM ${table} WHERE id = ${id}`; - -let query = Tagged_template_libJs.sql`SELECT * FROM ${table} WHERE id = ${id}`; - -let length = Tagged_template_libJs.length`hello ${10} what's the total length? Is it ${3}?`; - -function foo(strings, values) { - let res = ""; - let valueCount = values.length; - for (let i = 0; i < valueCount; ++i) { - res = res + Primitive_array.get(strings, i) + Math.imul(Primitive_array.get(values, i), 10).toString(); - } - return res + Primitive_array.get(strings, valueCount); -} - -let res = foo([ - "| 5 × 10 = ", - " |" -], [5]); - -Mt.from_pair_suites("tagged templates", { - hd: [ - "with externals, it should return a string with the correct interpolations", - () => ({ - TAG: "Eq", - _0: query, - _1: "SELECT * FROM 'users' WHERE id = '5'" - }) - ], - tl: { - hd: [ - "with module scoped externals, it should also return a string with the correct interpolations", - () => ({ - TAG: "Eq", - _0: queryWithModule, - _1: "SELECT * FROM 'users' WHERE id = '5'" - }) - ], - tl: { - hd: [ - "with externals, it should return the result of the function", - () => ({ - TAG: "Eq", - _0: length, - _1: 52 - }) - ], - tl: { - hd: [ - "with rescript function, it should return a string with the correct encoding and interpolations", - () => ({ - TAG: "Eq", - _0: res, - _1: "| 5 × 10 = 50 |" - }) - ], - tl: { - hd: [ - "a template literal tagged with json should generate a regular string interpolation for now", - () => ({ - TAG: "Eq", - _0: "some random " + "string", - _1: "some random string" - }) - ], - tl: { - hd: [ - "a regular string interpolation should continue working", - () => ({ - TAG: "Eq", - _0: "some random string interpolation", - _1: "some random string interpolation" - }) - ], - tl: /* [] */0 - } - } - } - } - } -}); - -let $$Array; - -let extraLength = 10; - -exports.$$Array = $$Array; -exports.Pg = Pg; -exports.table = table; -exports.id = id; -exports.queryWithModule = queryWithModule; -exports.query = query; -exports.extraLength = extraLength; -exports.length = length; -exports.foo = foo; -exports.res = res; -/* queryWithModule Not a pure module */ diff --git a/tests/tests/src/tagged_template_test.mjs b/tests/tests/src/tagged_template_test.mjs new file mode 100644 index 0000000000..2dbaaacc24 --- /dev/null +++ b/tests/tests/src/tagged_template_test.mjs @@ -0,0 +1,117 @@ +// Generated by ReScript, PLEASE EDIT WITH CARE + +import * as Mt from "./mt.mjs"; +import * as Primitive_array from "rescript/lib/es6/Primitive_array.js"; +import * as Tagged_template_libJs from "./tagged_template_lib.js"; + +function sql(prim0, prim1) { + return Tagged_template_libJs.sql(prim0, ...prim1); +} + +let Pg = { + sql: sql +}; + +let table = "users"; + +let id = "5"; + +let queryWithModule = Tagged_template_libJs.sql`SELECT * FROM ${table} WHERE id = ${id}`; + +let query = Tagged_template_libJs.sql`SELECT * FROM ${table} WHERE id = ${id}`; + +let length = Tagged_template_libJs.length`hello ${10} what's the total length? Is it ${3}?`; + +function foo(strings, values) { + let res = ""; + let valueCount = values.length; + for (let i = 0; i < valueCount; ++i) { + res = res + Primitive_array.get(strings, i) + Math.imul(Primitive_array.get(values, i), 10).toString(); + } + return res + Primitive_array.get(strings, valueCount); +} + +let res = foo([ + "| 5 × 10 = ", + " |" +], [5]); + +Mt.from_pair_suites("tagged templates", { + hd: [ + "with externals, it should return a string with the correct interpolations", + () => ({ + TAG: "Eq", + _0: query, + _1: "SELECT * FROM 'users' WHERE id = '5'" + }) + ], + tl: { + hd: [ + "with module scoped externals, it should also return a string with the correct interpolations", + () => ({ + TAG: "Eq", + _0: queryWithModule, + _1: "SELECT * FROM 'users' WHERE id = '5'" + }) + ], + tl: { + hd: [ + "with externals, it should return the result of the function", + () => ({ + TAG: "Eq", + _0: length, + _1: 52 + }) + ], + tl: { + hd: [ + "with rescript function, it should return a string with the correct encoding and interpolations", + () => ({ + TAG: "Eq", + _0: res, + _1: "| 5 × 10 = 50 |" + }) + ], + tl: { + hd: [ + "a template literal tagged with json should generate a regular string interpolation for now", + () => ({ + TAG: "Eq", + _0: "some random " + "string", + _1: "some random string" + }) + ], + tl: { + hd: [ + "a regular string interpolation should continue working", + () => ({ + TAG: "Eq", + _0: "some random string interpolation", + _1: "some random string interpolation" + }) + ], + tl: /* [] */0 + } + } + } + } + } +}); + +let $$Array; + +let extraLength = 10; + +export { + $$Array, + Pg, + table, + id, + queryWithModule, + query, + extraLength, + length, + foo, + res, +} +/* queryWithModule Not a pure module */ diff --git a/tests/tests/src/tailcall_inline_test.js b/tests/tests/src/tailcall_inline_test.js deleted file mode 100644 index ca75e120e6..0000000000 --- a/tests/tests/src/tailcall_inline_test.js +++ /dev/null @@ -1,56 +0,0 @@ -// Generated by ReScript, PLEASE EDIT WITH CARE -'use strict'; - -let Mt = require("./mt.js"); -let Belt_Array = require("rescript/lib/js/Belt_Array.js"); - -function f() { - let f$1 = (_acc, _n) => { - while (true) { - let n = _n; - let acc = _acc; - if (n <= 0) { - return acc; - } - _n = n - 1 | 0; - _acc = acc + n | 0; - continue; - }; - }; - let v = Belt_Array.make(10, 0); - for (let i = 0; i <= 9; ++i) { - v[i] = f$1(0, i); - } - return v; -} - -let suites_0 = [ - "acc", - param => ({ - TAG: "Eq", - _0: f(), - _1: [ - 0, - 1, - 3, - 6, - 10, - 15, - 21, - 28, - 36, - 45 - ] - }) -]; - -let suites = { - hd: suites_0, - tl: /* [] */0 -}; - -Mt.from_pair_suites("Tailcall_inline_test", suites); - -exports.f = f; -exports.suites = suites; -/* Not a pure module */ diff --git a/tests/tests/src/tailcall_inline_test.mjs b/tests/tests/src/tailcall_inline_test.mjs new file mode 100644 index 0000000000..657936af63 --- /dev/null +++ b/tests/tests/src/tailcall_inline_test.mjs @@ -0,0 +1,57 @@ +// Generated by ReScript, PLEASE EDIT WITH CARE + +import * as Mt from "./mt.mjs"; +import * as Belt_Array from "rescript/lib/es6/Belt_Array.js"; + +function f() { + let f$1 = (_acc, _n) => { + while (true) { + let n = _n; + let acc = _acc; + if (n <= 0) { + return acc; + } + _n = n - 1 | 0; + _acc = acc + n | 0; + continue; + }; + }; + let v = Belt_Array.make(10, 0); + for (let i = 0; i <= 9; ++i) { + v[i] = f$1(0, i); + } + return v; +} + +let suites_0 = [ + "acc", + param => ({ + TAG: "Eq", + _0: f(), + _1: [ + 0, + 1, + 3, + 6, + 10, + 15, + 21, + 28, + 36, + 45 + ] + }) +]; + +let suites = { + hd: suites_0, + tl: /* [] */0 +}; + +Mt.from_pair_suites("Tailcall_inline_test", suites); + +export { + f, + suites, +} +/* Not a pure module */ diff --git a/tests/tests/src/template.js b/tests/tests/src/template.js deleted file mode 100644 index c869a3b5b2..0000000000 --- a/tests/tests/src/template.js +++ /dev/null @@ -1,13 +0,0 @@ -// Generated by ReScript, PLEASE EDIT WITH CARE -'use strict'; - - -let bla2 = ""; - -function concat() { - return "\n display:\r flex;\n " + bla2; -} - -exports.bla2 = bla2; -exports.concat = concat; -/* No side effect */ diff --git a/tests/tests/src/template.mjs b/tests/tests/src/template.mjs new file mode 100644 index 0000000000..e205477ca3 --- /dev/null +++ b/tests/tests/src/template.mjs @@ -0,0 +1,14 @@ +// Generated by ReScript, PLEASE EDIT WITH CARE + + +let bla2 = ""; + +function concat() { + return "\n display:\r flex;\n " + bla2; +} + +export { + bla2, + concat, +} +/* No side effect */ diff --git a/tests/tests/src/test2.js b/tests/tests/src/test2.js deleted file mode 100644 index 0fc9b0c8cc..0000000000 --- a/tests/tests/src/test2.js +++ /dev/null @@ -1,12 +0,0 @@ -// Generated by ReScript, PLEASE EDIT WITH CARE -'use strict'; - - -let H = {}; - -let U = { - H: H -}; - -exports.U = U; -/* No side effect */ diff --git a/tests/tests/src/test2.mjs b/tests/tests/src/test2.mjs new file mode 100644 index 0000000000..00d8b4e9a9 --- /dev/null +++ b/tests/tests/src/test2.mjs @@ -0,0 +1,13 @@ +// Generated by ReScript, PLEASE EDIT WITH CARE + + +let H = {}; + +let U = { + H: H +}; + +export { + U, +} +/* No side effect */ diff --git a/tests/tests/src/test_ari.js b/tests/tests/src/test_ari.js deleted file mode 100644 index 199227620c..0000000000 --- a/tests/tests/src/test_ari.js +++ /dev/null @@ -1,317 +0,0 @@ -// Generated by ReScript, PLEASE EDIT WITH CARE -'use strict'; - -let U = require("U"); -let VV = require("VV"); -let Belt_List = require("rescript/lib/js/Belt_List.js"); - -function f(x, y) { - return x + y | 0; -} - -function f1(x, y) { - return x + y | 0; -} - -function f3(g, x) { - return g(x); -} - -function f2(extra) { - return 3 + extra | 0; -} - -let g = 7; - -function ff(extra) { - return U.test_primit(3, extra); -} - -let fff = VV.test_primit2(3); - -function length_aux(_len, _x) { - while (true) { - let x = _x; - let len = _len; - if (!x) { - return len; - } - _x = x.tl; - _len = len + 1 | 0; - continue; - }; -} - -let length = Belt_List.length; - -let size = Belt_List.size; - -let head = Belt_List.head; - -let headExn = Belt_List.headExn; - -let tail = Belt_List.tail; - -let tailExn = Belt_List.tailExn; - -let add = Belt_List.add; - -let get = Belt_List.get; - -let getExn = Belt_List.getExn; - -let make = Belt_List.make; - -let makeByU = Belt_List.makeByU; - -let makeBy = Belt_List.makeBy; - -let shuffle = Belt_List.shuffle; - -let drop = Belt_List.drop; - -let take = Belt_List.take; - -let splitAt = Belt_List.splitAt; - -let concat = Belt_List.concat; - -let concatMany = Belt_List.concatMany; - -let reverseConcat = Belt_List.reverseConcat; - -let flatten = Belt_List.flatten; - -let mapU = Belt_List.mapU; - -let map = Belt_List.map; - -let zip = Belt_List.zip; - -let zipByU = Belt_List.zipByU; - -let zipBy = Belt_List.zipBy; - -let mapWithIndexU = Belt_List.mapWithIndexU; - -let mapWithIndex = Belt_List.mapWithIndex; - -let fromArray = Belt_List.fromArray; - -let toArray = Belt_List.toArray; - -let reverse = Belt_List.reverse; - -let mapReverseU = Belt_List.mapReverseU; - -let mapReverse = Belt_List.mapReverse; - -let forEachU = Belt_List.forEachU; - -let forEach = Belt_List.forEach; - -let forEachWithIndexU = Belt_List.forEachWithIndexU; - -let forEachWithIndex = Belt_List.forEachWithIndex; - -let reduceU = Belt_List.reduceU; - -let reduce = Belt_List.reduce; - -let reduceWithIndexU = Belt_List.reduceWithIndexU; - -let reduceWithIndex = Belt_List.reduceWithIndex; - -let reduceReverseU = Belt_List.reduceReverseU; - -let reduceReverse = Belt_List.reduceReverse; - -let mapReverse2U = Belt_List.mapReverse2U; - -let mapReverse2 = Belt_List.mapReverse2; - -let forEach2U = Belt_List.forEach2U; - -let forEach2 = Belt_List.forEach2; - -let reduce2U = Belt_List.reduce2U; - -let reduce2 = Belt_List.reduce2; - -let reduceReverse2U = Belt_List.reduceReverse2U; - -let reduceReverse2 = Belt_List.reduceReverse2; - -let everyU = Belt_List.everyU; - -let every = Belt_List.every; - -let someU = Belt_List.someU; - -let some = Belt_List.some; - -let every2U = Belt_List.every2U; - -let every2 = Belt_List.every2; - -let some2U = Belt_List.some2U; - -let some2 = Belt_List.some2; - -let cmpByLength = Belt_List.cmpByLength; - -let cmpU = Belt_List.cmpU; - -let cmp = Belt_List.cmp; - -let eqU = Belt_List.eqU; - -let eq = Belt_List.eq; - -let hasU = Belt_List.hasU; - -let has = Belt_List.has; - -let getByU = Belt_List.getByU; - -let getBy = Belt_List.getBy; - -let keepU = Belt_List.keepU; - -let keep = Belt_List.keep; - -let filter = Belt_List.filter; - -let keepWithIndexU = Belt_List.keepWithIndexU; - -let keepWithIndex = Belt_List.keepWithIndex; - -let filterWithIndex = Belt_List.filterWithIndex; - -let keepMapU = Belt_List.keepMapU; - -let keepMap = Belt_List.keepMap; - -let partitionU = Belt_List.partitionU; - -let partition = Belt_List.partition; - -let unzip = Belt_List.unzip; - -let getAssocU = Belt_List.getAssocU; - -let getAssoc = Belt_List.getAssoc; - -let hasAssocU = Belt_List.hasAssocU; - -let hasAssoc = Belt_List.hasAssoc; - -let removeAssocU = Belt_List.removeAssocU; - -let removeAssoc = Belt_List.removeAssoc; - -let setAssocU = Belt_List.setAssocU; - -let setAssoc = Belt_List.setAssoc; - -let sortU = Belt_List.sortU; - -let sort = Belt_List.sort; - -exports.f = f; -exports.f1 = f1; -exports.f3 = f3; -exports.f2 = f2; -exports.g = g; -exports.ff = ff; -exports.fff = fff; -exports.length_aux = length_aux; -exports.length = length; -exports.size = size; -exports.head = head; -exports.headExn = headExn; -exports.tail = tail; -exports.tailExn = tailExn; -exports.add = add; -exports.get = get; -exports.getExn = getExn; -exports.make = make; -exports.makeByU = makeByU; -exports.makeBy = makeBy; -exports.shuffle = shuffle; -exports.drop = drop; -exports.take = take; -exports.splitAt = splitAt; -exports.concat = concat; -exports.concatMany = concatMany; -exports.reverseConcat = reverseConcat; -exports.flatten = flatten; -exports.mapU = mapU; -exports.map = map; -exports.zip = zip; -exports.zipByU = zipByU; -exports.zipBy = zipBy; -exports.mapWithIndexU = mapWithIndexU; -exports.mapWithIndex = mapWithIndex; -exports.fromArray = fromArray; -exports.toArray = toArray; -exports.reverse = reverse; -exports.mapReverseU = mapReverseU; -exports.mapReverse = mapReverse; -exports.forEachU = forEachU; -exports.forEach = forEach; -exports.forEachWithIndexU = forEachWithIndexU; -exports.forEachWithIndex = forEachWithIndex; -exports.reduceU = reduceU; -exports.reduce = reduce; -exports.reduceWithIndexU = reduceWithIndexU; -exports.reduceWithIndex = reduceWithIndex; -exports.reduceReverseU = reduceReverseU; -exports.reduceReverse = reduceReverse; -exports.mapReverse2U = mapReverse2U; -exports.mapReverse2 = mapReverse2; -exports.forEach2U = forEach2U; -exports.forEach2 = forEach2; -exports.reduce2U = reduce2U; -exports.reduce2 = reduce2; -exports.reduceReverse2U = reduceReverse2U; -exports.reduceReverse2 = reduceReverse2; -exports.everyU = everyU; -exports.every = every; -exports.someU = someU; -exports.some = some; -exports.every2U = every2U; -exports.every2 = every2; -exports.some2U = some2U; -exports.some2 = some2; -exports.cmpByLength = cmpByLength; -exports.cmpU = cmpU; -exports.cmp = cmp; -exports.eqU = eqU; -exports.eq = eq; -exports.hasU = hasU; -exports.has = has; -exports.getByU = getByU; -exports.getBy = getBy; -exports.keepU = keepU; -exports.keep = keep; -exports.filter = filter; -exports.keepWithIndexU = keepWithIndexU; -exports.keepWithIndex = keepWithIndex; -exports.filterWithIndex = filterWithIndex; -exports.keepMapU = keepMapU; -exports.keepMap = keepMap; -exports.partitionU = partitionU; -exports.partition = partition; -exports.unzip = unzip; -exports.getAssocU = getAssocU; -exports.getAssoc = getAssoc; -exports.hasAssocU = hasAssocU; -exports.hasAssoc = hasAssoc; -exports.removeAssocU = removeAssocU; -exports.removeAssoc = removeAssoc; -exports.setAssocU = setAssocU; -exports.setAssoc = setAssoc; -exports.sortU = sortU; -exports.sort = sort; -/* fff Not a pure module */ diff --git a/tests/tests/src/test_ari.mjs b/tests/tests/src/test_ari.mjs new file mode 100644 index 0000000000..a016c7a1c8 --- /dev/null +++ b/tests/tests/src/test_ari.mjs @@ -0,0 +1,318 @@ +// Generated by ReScript, PLEASE EDIT WITH CARE + +import * as U from "U"; +import * as VV from "VV"; +import * as Belt_List from "rescript/lib/es6/Belt_List.js"; + +function f(x, y) { + return x + y | 0; +} + +function f1(x, y) { + return x + y | 0; +} + +function f3(g, x) { + return g(x); +} + +function f2(extra) { + return 3 + extra | 0; +} + +let g = 7; + +function ff(extra) { + return U.test_primit(3, extra); +} + +let fff = VV.test_primit2(3); + +function length_aux(_len, _x) { + while (true) { + let x = _x; + let len = _len; + if (!x) { + return len; + } + _x = x.tl; + _len = len + 1 | 0; + continue; + }; +} + +let length = Belt_List.length; + +let size = Belt_List.size; + +let head = Belt_List.head; + +let headExn = Belt_List.headExn; + +let tail = Belt_List.tail; + +let tailExn = Belt_List.tailExn; + +let add = Belt_List.add; + +let get = Belt_List.get; + +let getExn = Belt_List.getExn; + +let make = Belt_List.make; + +let makeByU = Belt_List.makeByU; + +let makeBy = Belt_List.makeBy; + +let shuffle = Belt_List.shuffle; + +let drop = Belt_List.drop; + +let take = Belt_List.take; + +let splitAt = Belt_List.splitAt; + +let concat = Belt_List.concat; + +let concatMany = Belt_List.concatMany; + +let reverseConcat = Belt_List.reverseConcat; + +let flatten = Belt_List.flatten; + +let mapU = Belt_List.mapU; + +let map = Belt_List.map; + +let zip = Belt_List.zip; + +let zipByU = Belt_List.zipByU; + +let zipBy = Belt_List.zipBy; + +let mapWithIndexU = Belt_List.mapWithIndexU; + +let mapWithIndex = Belt_List.mapWithIndex; + +let fromArray = Belt_List.fromArray; + +let toArray = Belt_List.toArray; + +let reverse = Belt_List.reverse; + +let mapReverseU = Belt_List.mapReverseU; + +let mapReverse = Belt_List.mapReverse; + +let forEachU = Belt_List.forEachU; + +let forEach = Belt_List.forEach; + +let forEachWithIndexU = Belt_List.forEachWithIndexU; + +let forEachWithIndex = Belt_List.forEachWithIndex; + +let reduceU = Belt_List.reduceU; + +let reduce = Belt_List.reduce; + +let reduceWithIndexU = Belt_List.reduceWithIndexU; + +let reduceWithIndex = Belt_List.reduceWithIndex; + +let reduceReverseU = Belt_List.reduceReverseU; + +let reduceReverse = Belt_List.reduceReverse; + +let mapReverse2U = Belt_List.mapReverse2U; + +let mapReverse2 = Belt_List.mapReverse2; + +let forEach2U = Belt_List.forEach2U; + +let forEach2 = Belt_List.forEach2; + +let reduce2U = Belt_List.reduce2U; + +let reduce2 = Belt_List.reduce2; + +let reduceReverse2U = Belt_List.reduceReverse2U; + +let reduceReverse2 = Belt_List.reduceReverse2; + +let everyU = Belt_List.everyU; + +let every = Belt_List.every; + +let someU = Belt_List.someU; + +let some = Belt_List.some; + +let every2U = Belt_List.every2U; + +let every2 = Belt_List.every2; + +let some2U = Belt_List.some2U; + +let some2 = Belt_List.some2; + +let cmpByLength = Belt_List.cmpByLength; + +let cmpU = Belt_List.cmpU; + +let cmp = Belt_List.cmp; + +let eqU = Belt_List.eqU; + +let eq = Belt_List.eq; + +let hasU = Belt_List.hasU; + +let has = Belt_List.has; + +let getByU = Belt_List.getByU; + +let getBy = Belt_List.getBy; + +let keepU = Belt_List.keepU; + +let keep = Belt_List.keep; + +let filter = Belt_List.filter; + +let keepWithIndexU = Belt_List.keepWithIndexU; + +let keepWithIndex = Belt_List.keepWithIndex; + +let filterWithIndex = Belt_List.filterWithIndex; + +let keepMapU = Belt_List.keepMapU; + +let keepMap = Belt_List.keepMap; + +let partitionU = Belt_List.partitionU; + +let partition = Belt_List.partition; + +let unzip = Belt_List.unzip; + +let getAssocU = Belt_List.getAssocU; + +let getAssoc = Belt_List.getAssoc; + +let hasAssocU = Belt_List.hasAssocU; + +let hasAssoc = Belt_List.hasAssoc; + +let removeAssocU = Belt_List.removeAssocU; + +let removeAssoc = Belt_List.removeAssoc; + +let setAssocU = Belt_List.setAssocU; + +let setAssoc = Belt_List.setAssoc; + +let sortU = Belt_List.sortU; + +let sort = Belt_List.sort; + +export { + f, + f1, + f3, + f2, + g, + ff, + fff, + length_aux, + length, + size, + head, + headExn, + tail, + tailExn, + add, + get, + getExn, + make, + makeByU, + makeBy, + shuffle, + drop, + take, + splitAt, + concat, + concatMany, + reverseConcat, + flatten, + mapU, + map, + zip, + zipByU, + zipBy, + mapWithIndexU, + mapWithIndex, + fromArray, + toArray, + reverse, + mapReverseU, + mapReverse, + forEachU, + forEach, + forEachWithIndexU, + forEachWithIndex, + reduceU, + reduce, + reduceWithIndexU, + reduceWithIndex, + reduceReverseU, + reduceReverse, + mapReverse2U, + mapReverse2, + forEach2U, + forEach2, + reduce2U, + reduce2, + reduceReverse2U, + reduceReverse2, + everyU, + every, + someU, + some, + every2U, + every2, + some2U, + some2, + cmpByLength, + cmpU, + cmp, + eqU, + eq, + hasU, + has, + getByU, + getBy, + keepU, + keep, + filter, + keepWithIndexU, + keepWithIndex, + filterWithIndex, + keepMapU, + keepMap, + partitionU, + partition, + unzip, + getAssocU, + getAssoc, + hasAssocU, + hasAssoc, + removeAssocU, + removeAssoc, + setAssocU, + setAssoc, + sortU, + sort, +} +/* fff Not a pure module */ diff --git a/tests/tests/src/test_array.js b/tests/tests/src/test_array.js deleted file mode 100644 index 4faa21cb35..0000000000 --- a/tests/tests/src/test_array.js +++ /dev/null @@ -1,44 +0,0 @@ -// Generated by ReScript, PLEASE EDIT WITH CARE -'use strict'; - -let Belt_Array = require("rescript/lib/js/Belt_Array.js"); - -let v = Belt_Array.make(6, 5); - -let h = Belt_Array.slice(v, 0, 2); - -let hhh = Belt_Array.concat([ - 1, - 2, - 3, - 4 -], [ - 1, - 2, - 3, - 5 -]); - -let u = Belt_Array.concatMany([ - [ - 1, - 2 - ], - [ - 2, - 3 - ], - [ - 3, - 4 - ] -]); - -let hh = Belt_Array.blit; - -exports.v = v; -exports.h = h; -exports.hh = hh; -exports.hhh = hhh; -exports.u = u; -/* v Not a pure module */ diff --git a/tests/tests/src/test_array.mjs b/tests/tests/src/test_array.mjs new file mode 100644 index 0000000000..e6b14c0101 --- /dev/null +++ b/tests/tests/src/test_array.mjs @@ -0,0 +1,45 @@ +// Generated by ReScript, PLEASE EDIT WITH CARE + +import * as Belt_Array from "rescript/lib/es6/Belt_Array.js"; + +let v = Belt_Array.make(6, 5); + +let h = Belt_Array.slice(v, 0, 2); + +let hhh = Belt_Array.concat([ + 1, + 2, + 3, + 4 +], [ + 1, + 2, + 3, + 5 +]); + +let u = Belt_Array.concatMany([ + [ + 1, + 2 + ], + [ + 2, + 3 + ], + [ + 3, + 4 + ] +]); + +let hh = Belt_Array.blit; + +export { + v, + h, + hh, + hhh, + u, +} +/* v Not a pure module */ diff --git a/tests/tests/src/test_array_append.js b/tests/tests/src/test_array_append.js deleted file mode 100644 index 126b53bdcb..0000000000 --- a/tests/tests/src/test_array_append.js +++ /dev/null @@ -1,12 +0,0 @@ -// Generated by ReScript, PLEASE EDIT WITH CARE -'use strict'; - -let Belt_Array = require("rescript/lib/js/Belt_Array.js"); - -let const_v = Belt_Array.concat([ - 1, - 2 -], [3]); - -exports.const_v = const_v; -/* const_v Not a pure module */ diff --git a/tests/tests/src/test_array_append.mjs b/tests/tests/src/test_array_append.mjs new file mode 100644 index 0000000000..f0e63db473 --- /dev/null +++ b/tests/tests/src/test_array_append.mjs @@ -0,0 +1,13 @@ +// Generated by ReScript, PLEASE EDIT WITH CARE + +import * as Belt_Array from "rescript/lib/es6/Belt_Array.js"; + +let const_v = Belt_Array.concat([ + 1, + 2 +], [3]); + +export { + const_v, +} +/* const_v Not a pure module */ diff --git a/tests/tests/src/test_bool_equal.js b/tests/tests/src/test_bool_equal.js deleted file mode 100644 index 549f7c36a7..0000000000 --- a/tests/tests/src/test_bool_equal.js +++ /dev/null @@ -1,146 +0,0 @@ -// Generated by ReScript, PLEASE EDIT WITH CARE -'use strict'; - - -function bool_equal(x, y) { - if (x) { - if (y) { - return true; - } else { - return false; - } - } else if (y) { - return false; - } else { - return true; - } -} - -function assertions() { - if (!bool_equal(true, true)) { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "test_bool_equal.res", - 16, - 2 - ], - Error: new Error() - }; - } - if (!bool_equal(false, false)) { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "test_bool_equal.res", - 17, - 2 - ], - Error: new Error() - }; - } - if (bool_equal(true, false)) { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "test_bool_equal.res", - 18, - 2 - ], - Error: new Error() - }; - } - if (bool_equal(false, true)) { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "test_bool_equal.res", - 19, - 2 - ], - Error: new Error() - }; - } - -} - -function f0(x) { - if (x === true) { - return 1; - } else { - return 2; - } -} - -function f1(x) { - if (x !== true) { - return 1; - } else { - return 2; - } -} - -function f2(x) { - if (x === true) { - return 1; - } else { - return 2; - } -} - -function f3(x) { - if (x === false) { - return 1; - } else { - return 2; - } -} - -function f4(x) { - if (x !== true) { - return 1; - } else { - return 2; - } -} - -function f5(x) { - if (x) { - return 2; - } else { - return 1; - } -} - -function f6(x) { - if (x === /* [] */0) { - return 1; - } else { - return 2; - } -} - -function f7(x) { - if (x.length !== 0) { - return 1; - } else { - return 2; - } -} - -function f8(x) { - return 1; -} - -exports.bool_equal = bool_equal; -exports.assertions = assertions; -exports.f0 = f0; -exports.f1 = f1; -exports.f2 = f2; -exports.f3 = f3; -exports.f4 = f4; -exports.f5 = f5; -exports.f6 = f6; -exports.f7 = f7; -exports.f8 = f8; -/* No side effect */ diff --git a/tests/tests/src/test_bool_equal.mjs b/tests/tests/src/test_bool_equal.mjs new file mode 100644 index 0000000000..ad966edbb9 --- /dev/null +++ b/tests/tests/src/test_bool_equal.mjs @@ -0,0 +1,147 @@ +// Generated by ReScript, PLEASE EDIT WITH CARE + + +function bool_equal(x, y) { + if (x) { + if (y) { + return true; + } else { + return false; + } + } else if (y) { + return false; + } else { + return true; + } +} + +function assertions() { + if (!bool_equal(true, true)) { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "test_bool_equal.res", + 16, + 2 + ], + Error: new Error() + }; + } + if (!bool_equal(false, false)) { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "test_bool_equal.res", + 17, + 2 + ], + Error: new Error() + }; + } + if (bool_equal(true, false)) { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "test_bool_equal.res", + 18, + 2 + ], + Error: new Error() + }; + } + if (bool_equal(false, true)) { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "test_bool_equal.res", + 19, + 2 + ], + Error: new Error() + }; + } + +} + +function f0(x) { + if (x === true) { + return 1; + } else { + return 2; + } +} + +function f1(x) { + if (x !== true) { + return 1; + } else { + return 2; + } +} + +function f2(x) { + if (x === true) { + return 1; + } else { + return 2; + } +} + +function f3(x) { + if (x === false) { + return 1; + } else { + return 2; + } +} + +function f4(x) { + if (x !== true) { + return 1; + } else { + return 2; + } +} + +function f5(x) { + if (x) { + return 2; + } else { + return 1; + } +} + +function f6(x) { + if (x === /* [] */0) { + return 1; + } else { + return 2; + } +} + +function f7(x) { + if (x.length !== 0) { + return 1; + } else { + return 2; + } +} + +function f8(x) { + return 1; +} + +export { + bool_equal, + assertions, + f0, + f1, + f2, + f3, + f4, + f5, + f6, + f7, + f8, +} +/* No side effect */ diff --git a/tests/tests/src/test_bs_this.js b/tests/tests/src/test_bs_this.js deleted file mode 100644 index 0edc78d137..0000000000 --- a/tests/tests/src/test_bs_this.js +++ /dev/null @@ -1,58 +0,0 @@ -// Generated by ReScript, PLEASE EDIT WITH CARE -'use strict'; - - -function uux_this(x, y) { - let o = this ; - return (o.length + x | 0) + y | 0; -} - -function even(x) { - let o = this ; - return x + o | 0; -} - -function bark() { - return function (x, y) { - let o = this ; - console.log([ - o.length, - o.x, - o.y, - x, - y - ]); - return x + y | 0; - }; -} - -let js_obj = { - bark: function (x, y) { - let o = this ; - console.log(o); - return x + y | 0; - } -}; - -function f(x) { - x.onload = function () { - let o = this ; - console.log(o); - }; - return x.addEventListener("onload", function () { - let o = this ; - console.log(o.response); - }); -} - -function u(x) { - return x; -} - -exports.uux_this = uux_this; -exports.even = even; -exports.bark = bark; -exports.js_obj = js_obj; -exports.f = f; -exports.u = u; -/* uux_this Not a pure module */ diff --git a/tests/tests/src/test_bs_this.mjs b/tests/tests/src/test_bs_this.mjs new file mode 100644 index 0000000000..2a23e292be --- /dev/null +++ b/tests/tests/src/test_bs_this.mjs @@ -0,0 +1,59 @@ +// Generated by ReScript, PLEASE EDIT WITH CARE + + +function uux_this(x, y) { + let o = this ; + return (o.length + x | 0) + y | 0; +} + +function even(x) { + let o = this ; + return x + o | 0; +} + +function bark() { + return function (x, y) { + let o = this ; + console.log([ + o.length, + o.x, + o.y, + x, + y + ]); + return x + y | 0; + }; +} + +let js_obj = { + bark: function (x, y) { + let o = this ; + console.log(o); + return x + y | 0; + } +}; + +function f(x) { + x.onload = function () { + let o = this ; + console.log(o); + }; + return x.addEventListener("onload", function () { + let o = this ; + console.log(o.response); + }); +} + +function u(x) { + return x; +} + +export { + uux_this, + even, + bark, + js_obj, + f, + u, +} +/* uux_this Not a pure module */ diff --git a/tests/tests/src/test_case_opt_collision.js b/tests/tests/src/test_case_opt_collision.js deleted file mode 100644 index 752287d60a..0000000000 --- a/tests/tests/src/test_case_opt_collision.js +++ /dev/null @@ -1,37 +0,0 @@ -// Generated by ReScript, PLEASE EDIT WITH CARE -'use strict'; - -let Mt = require("./mt.js"); - -let suites = { - contents: /* [] */0 -}; - -let test_id = { - contents: 0 -}; - -function eq(loc, x, y) { - Mt.eq_suites(test_id, suites, loc, x, y); -} - -function f(xOpt, y) { - let x = xOpt !== undefined ? xOpt : 3; - let xOpt$1 = x + 2 | 0; - console.log(xOpt$1); - return xOpt$1 + y | 0; -} - -console.log(f(undefined, 2)); - -eq("File \"test_case_opt_collision.res\", line 13, characters 3-10", f(undefined, 2), 7); - -eq("File \"test_case_opt_collision.res\", line 15, characters 3-10", f(4, 2), 8); - -Mt.from_pair_suites("test_case_opt_collision.res", suites.contents); - -exports.suites = suites; -exports.test_id = test_id; -exports.eq = eq; -exports.f = f; -/* Not a pure module */ diff --git a/tests/tests/src/test_case_opt_collision.mjs b/tests/tests/src/test_case_opt_collision.mjs new file mode 100644 index 0000000000..d270b299ac --- /dev/null +++ b/tests/tests/src/test_case_opt_collision.mjs @@ -0,0 +1,38 @@ +// Generated by ReScript, PLEASE EDIT WITH CARE + +import * as Mt from "./mt.mjs"; + +let suites = { + contents: /* [] */0 +}; + +let test_id = { + contents: 0 +}; + +function eq(loc, x, y) { + Mt.eq_suites(test_id, suites, loc, x, y); +} + +function f(xOpt, y) { + let x = xOpt !== undefined ? xOpt : 3; + let xOpt$1 = x + 2 | 0; + console.log(xOpt$1); + return xOpt$1 + y | 0; +} + +console.log(f(undefined, 2)); + +eq("File \"test_case_opt_collision.res\", line 13, characters 3-10", f(undefined, 2), 7); + +eq("File \"test_case_opt_collision.res\", line 15, characters 3-10", f(4, 2), 8); + +Mt.from_pair_suites("test_case_opt_collision.res", suites.contents); + +export { + suites, + test_id, + eq, + f, +} +/* Not a pure module */ diff --git a/tests/tests/src/test_case_set.js b/tests/tests/src/test_case_set.js deleted file mode 100644 index 7b74291121..0000000000 --- a/tests/tests/src/test_case_set.js +++ /dev/null @@ -1,15 +0,0 @@ -// Generated by ReScript, PLEASE EDIT WITH CARE -'use strict'; - - -function f(x) { - x.case = 3; -} - -function g(x) { - return x.item(3); -} - -exports.f = f; -exports.g = g; -/* No side effect */ diff --git a/tests/tests/src/test_case_set.mjs b/tests/tests/src/test_case_set.mjs new file mode 100644 index 0000000000..f704019107 --- /dev/null +++ b/tests/tests/src/test_case_set.mjs @@ -0,0 +1,16 @@ +// Generated by ReScript, PLEASE EDIT WITH CARE + + +function f(x) { + x.case = 3; +} + +function g(x) { + return x.item(3); +} + +export { + f, + g, +} +/* No side effect */ diff --git a/tests/tests/src/test_char.js b/tests/tests/src/test_char.js deleted file mode 100644 index 636c789c1d..0000000000 --- a/tests/tests/src/test_char.js +++ /dev/null @@ -1,14 +0,0 @@ -// Generated by ReScript, PLEASE EDIT WITH CARE -'use strict'; - - -function caml_is_printable(c) { - if (c > 31) { - return c < 127; - } else { - return false; - } -} - -exports.caml_is_printable = caml_is_printable; -/* No side effect */ diff --git a/tests/tests/src/test_char.mjs b/tests/tests/src/test_char.mjs new file mode 100644 index 0000000000..24448c4a27 --- /dev/null +++ b/tests/tests/src/test_char.mjs @@ -0,0 +1,15 @@ +// Generated by ReScript, PLEASE EDIT WITH CARE + + +function caml_is_printable(c) { + if (c > 31) { + return c < 127; + } else { + return false; + } +} + +export { + caml_is_printable, +} +/* No side effect */ diff --git a/tests/tests/src/test_closure.js b/tests/tests/src/test_closure.js deleted file mode 100644 index f428a3f74d..0000000000 --- a/tests/tests/src/test_closure.js +++ /dev/null @@ -1,38 +0,0 @@ -// Generated by ReScript, PLEASE EDIT WITH CARE -'use strict'; - -let Belt_Array = require("rescript/lib/js/Belt_Array.js"); - -let v = { - contents: 0 -}; - -function f() { - let arr = Belt_Array.make(10, param => {}); - for (let i = 0; i <= 9; ++i) { - arr[i] = param => { - v.contents = v.contents + i | 0; - }; - } - return arr; -} - -let u = f(); - -Belt_Array.forEach(u, x => x()); - -if (v.contents !== 45) { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "test_closure.res", - 52, - 2 - ], - Error: new Error() - }; -} - -exports.v = v; -exports.f = f; -/* u Not a pure module */ diff --git a/tests/tests/src/test_closure.mjs b/tests/tests/src/test_closure.mjs new file mode 100644 index 0000000000..59a3736feb --- /dev/null +++ b/tests/tests/src/test_closure.mjs @@ -0,0 +1,39 @@ +// Generated by ReScript, PLEASE EDIT WITH CARE + +import * as Belt_Array from "rescript/lib/es6/Belt_Array.js"; + +let v = { + contents: 0 +}; + +function f() { + let arr = Belt_Array.make(10, param => {}); + for (let i = 0; i <= 9; ++i) { + arr[i] = param => { + v.contents = v.contents + i | 0; + }; + } + return arr; +} + +let u = f(); + +Belt_Array.forEach(u, x => x()); + +if (v.contents !== 45) { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "test_closure.res", + 52, + 2 + ], + Error: new Error() + }; +} + +export { + v, + f, +} +/* u Not a pure module */ diff --git a/tests/tests/src/test_common.js b/tests/tests/src/test_common.js deleted file mode 100644 index 814b5c07a8..0000000000 --- a/tests/tests/src/test_common.js +++ /dev/null @@ -1,12 +0,0 @@ -// Generated by ReScript, PLEASE EDIT WITH CARE -'use strict'; - -let Primitive_exceptions = require("rescript/lib/js/Primitive_exceptions.js"); - -let U = /* @__PURE__ */Primitive_exceptions.create("Test_common.U"); - -let H = /* @__PURE__ */Primitive_exceptions.create("Test_common.H"); - -exports.U = U; -exports.H = H; -/* No side effect */ diff --git a/tests/tests/src/test_common.mjs b/tests/tests/src/test_common.mjs new file mode 100644 index 0000000000..c8b85f9535 --- /dev/null +++ b/tests/tests/src/test_common.mjs @@ -0,0 +1,13 @@ +// Generated by ReScript, PLEASE EDIT WITH CARE + +import * as Primitive_exceptions from "rescript/lib/es6/Primitive_exceptions.js"; + +let U = /* @__PURE__ */Primitive_exceptions.create("Test_common.U"); + +let H = /* @__PURE__ */Primitive_exceptions.create("Test_common.H"); + +export { + U, + H, +} +/* No side effect */ diff --git a/tests/tests/src/test_const_elim.js b/tests/tests/src/test_const_elim.mjs similarity index 100% rename from tests/tests/src/test_const_elim.js rename to tests/tests/src/test_const_elim.mjs diff --git a/tests/tests/src/test_const_propogate.js b/tests/tests/src/test_const_propogate.js deleted file mode 100644 index 2107e1e40b..0000000000 --- a/tests/tests/src/test_const_propogate.js +++ /dev/null @@ -1,10 +0,0 @@ -// Generated by ReScript, PLEASE EDIT WITH CARE -'use strict'; - - -function f(x) { - return x; -} - -exports.f = f; -/* No side effect */ diff --git a/tests/tests/src/test_const_propogate.mjs b/tests/tests/src/test_const_propogate.mjs new file mode 100644 index 0000000000..66f8e6ee73 --- /dev/null +++ b/tests/tests/src/test_const_propogate.mjs @@ -0,0 +1,11 @@ +// Generated by ReScript, PLEASE EDIT WITH CARE + + +function f(x) { + return x; +} + +export { + f, +} +/* No side effect */ diff --git a/tests/tests/src/test_cpp.js b/tests/tests/src/test_cpp.js deleted file mode 100644 index 14dc63bc37..0000000000 --- a/tests/tests/src/test_cpp.js +++ /dev/null @@ -1,9 +0,0 @@ -// Generated by ReScript, PLEASE EDIT WITH CARE -'use strict'; - -let Primitive_int = require("rescript/lib/js/Primitive_int.js"); - -let f = Primitive_int.compare; - -exports.f = f; -/* No side effect */ diff --git a/tests/tests/src/test_cpp.mjs b/tests/tests/src/test_cpp.mjs new file mode 100644 index 0000000000..f17c6831ad --- /dev/null +++ b/tests/tests/src/test_cpp.mjs @@ -0,0 +1,10 @@ +// Generated by ReScript, PLEASE EDIT WITH CARE + +import * as Primitive_int from "rescript/lib/es6/Primitive_int.js"; + +let f = Primitive_int.compare; + +export { + f, +} +/* No side effect */ diff --git a/tests/tests/src/test_cps.js b/tests/tests/src/test_cps.js deleted file mode 100644 index 67b6c0f289..0000000000 --- a/tests/tests/src/test_cps.js +++ /dev/null @@ -1,34 +0,0 @@ -// Generated by ReScript, PLEASE EDIT WITH CARE -'use strict'; - -let Belt_Array = require("rescript/lib/js/Belt_Array.js"); - -function f(_n, _acc) { - while (true) { - let acc = _acc; - let n = _n; - if (n === 0) { - return acc(); - } - _acc = () => { - console.log(n.toString()); - return acc(); - }; - _n = n - 1 | 0; - continue; - }; -} - -function test_closure() { - let arr = Belt_Array.make(6, x => x); - for (let i = 0; i <= 6; ++i) { - arr[i] = param => i; - } - return arr; -} - -f(10, () => {}); - -exports.f = f; -exports.test_closure = test_closure; -/* Not a pure module */ diff --git a/tests/tests/src/test_cps.mjs b/tests/tests/src/test_cps.mjs new file mode 100644 index 0000000000..89336d0710 --- /dev/null +++ b/tests/tests/src/test_cps.mjs @@ -0,0 +1,35 @@ +// Generated by ReScript, PLEASE EDIT WITH CARE + +import * as Belt_Array from "rescript/lib/es6/Belt_Array.js"; + +function f(_n, _acc) { + while (true) { + let acc = _acc; + let n = _n; + if (n === 0) { + return acc(); + } + _acc = () => { + console.log(n.toString()); + return acc(); + }; + _n = n - 1 | 0; + continue; + }; +} + +function test_closure() { + let arr = Belt_Array.make(6, x => x); + for (let i = 0; i <= 6; ++i) { + arr[i] = param => i; + } + return arr; +} + +f(10, () => {}); + +export { + f, + test_closure, +} +/* Not a pure module */ diff --git a/tests/tests/src/test_demo.js b/tests/tests/src/test_demo.js deleted file mode 100644 index bf0dc5c15e..0000000000 --- a/tests/tests/src/test_demo.js +++ /dev/null @@ -1,80 +0,0 @@ -// Generated by ReScript, PLEASE EDIT WITH CARE -'use strict'; - -let Belt_List = require("rescript/lib/js/Belt_List.js"); - -function fib(x) { - if (x === 2 || x === 1) { - return 1; - } else { - return fib(x - 1 | 0) + fib(x - 2 | 0) | 0; - } -} - -function cons(x, y) { - return { - TAG: "Cons", - _0: x, - _1: y - }; -} - -function map(f, x) { - if (typeof x !== "object") { - return "Nil"; - } else { - return { - TAG: "Cons", - _0: f(x._0), - _1: map(f, x._1) - }; - } -} - -function sum(n) { - let v = 0; - for (let i = 0; i <= n; ++i) { - v = v + i | 0; - } - return v; -} - -function f(x, y, z) { - return (x + y | 0) + z | 0; -} - -function g(x, y) { - let u = x + y | 0; - return z => u + z | 0; -} - -function g1(x, y) { - let u = x + y | 0; - return (xx, yy) => (xx + yy | 0) + u | 0; -} - -let u = 8; - -let x = u + 6 | 0; - -function v(extra) { - let u = 7; - return (6 + extra | 0) + u | 0; -} - -let nil = "Nil"; - -let len = Belt_List.length; - -exports.fib = fib; -exports.nil = nil; -exports.cons = cons; -exports.map = map; -exports.sum = sum; -exports.len = len; -exports.f = f; -exports.g = g; -exports.g1 = g1; -exports.x = x; -exports.v = v; -/* No side effect */ diff --git a/tests/tests/src/test_demo.mjs b/tests/tests/src/test_demo.mjs new file mode 100644 index 0000000000..048494ef32 --- /dev/null +++ b/tests/tests/src/test_demo.mjs @@ -0,0 +1,81 @@ +// Generated by ReScript, PLEASE EDIT WITH CARE + +import * as Belt_List from "rescript/lib/es6/Belt_List.js"; + +function fib(x) { + if (x === 2 || x === 1) { + return 1; + } else { + return fib(x - 1 | 0) + fib(x - 2 | 0) | 0; + } +} + +function cons(x, y) { + return { + TAG: "Cons", + _0: x, + _1: y + }; +} + +function map(f, x) { + if (typeof x !== "object") { + return "Nil"; + } else { + return { + TAG: "Cons", + _0: f(x._0), + _1: map(f, x._1) + }; + } +} + +function sum(n) { + let v = 0; + for (let i = 0; i <= n; ++i) { + v = v + i | 0; + } + return v; +} + +function f(x, y, z) { + return (x + y | 0) + z | 0; +} + +function g(x, y) { + let u = x + y | 0; + return z => u + z | 0; +} + +function g1(x, y) { + let u = x + y | 0; + return (xx, yy) => (xx + yy | 0) + u | 0; +} + +let u = 8; + +let x = u + 6 | 0; + +function v(extra) { + let u = 7; + return (6 + extra | 0) + u | 0; +} + +let nil = "Nil"; + +let len = Belt_List.length; + +export { + fib, + nil, + cons, + map, + sum, + len, + f, + g, + g1, + x, + v, +} +/* No side effect */ diff --git a/tests/tests/src/test_dup_param.js b/tests/tests/src/test_dup_param.js deleted file mode 100644 index 9930299529..0000000000 --- a/tests/tests/src/test_dup_param.js +++ /dev/null @@ -1,10 +0,0 @@ -// Generated by ReScript, PLEASE EDIT WITH CARE -'use strict'; - - -function f(x, x$1) { - return x$1; -} - -exports.f = f; -/* No side effect */ diff --git a/tests/tests/src/test_dup_param.mjs b/tests/tests/src/test_dup_param.mjs new file mode 100644 index 0000000000..0ab6f9daff --- /dev/null +++ b/tests/tests/src/test_dup_param.mjs @@ -0,0 +1,11 @@ +// Generated by ReScript, PLEASE EDIT WITH CARE + + +function f(x, x$1) { + return x$1; +} + +export { + f, +} +/* No side effect */ diff --git a/tests/tests/src/test_eq.js b/tests/tests/src/test_eq.js deleted file mode 100644 index 4ce016ec7b..0000000000 --- a/tests/tests/src/test_eq.js +++ /dev/null @@ -1,10 +0,0 @@ -// Generated by ReScript, PLEASE EDIT WITH CARE -'use strict'; - - -function f(x, y) { - return x + y | 0; -} - -exports.f = f; -/* No side effect */ diff --git a/tests/tests/src/test_eq.mjs b/tests/tests/src/test_eq.mjs new file mode 100644 index 0000000000..83b3d3164c --- /dev/null +++ b/tests/tests/src/test_eq.mjs @@ -0,0 +1,11 @@ +// Generated by ReScript, PLEASE EDIT WITH CARE + + +function f(x, y) { + return x + y | 0; +} + +export { + f, +} +/* No side effect */ diff --git a/tests/tests/src/test_exception.js b/tests/tests/src/test_exception.js deleted file mode 100644 index bf7454696d..0000000000 --- a/tests/tests/src/test_exception.js +++ /dev/null @@ -1,61 +0,0 @@ -// Generated by ReScript, PLEASE EDIT WITH CARE -'use strict'; - -let Test_common = require("./test_common.js"); -let Primitive_exceptions = require("rescript/lib/js/Primitive_exceptions.js"); - -let Local = /* @__PURE__ */Primitive_exceptions.create("Test_exception.Local"); - -function f() { - throw { - RE_EXN_ID: Local, - _1: 3, - Error: new Error() - }; -} - -function g() { - throw { - RE_EXN_ID: "Not_found", - Error: new Error() - }; -} - -function h() { - throw { - RE_EXN_ID: Test_common.U, - _1: 3, - Error: new Error() - }; -} - -function x() { - throw { - RE_EXN_ID: Test_common.H, - Error: new Error() - }; -} - -function xx() { - throw { - RE_EXN_ID: "Invalid_argument", - _1: "x", - Error: new Error() - }; -} - -let Nullary = /* @__PURE__ */Primitive_exceptions.create("Test_exception.Nullary"); - -let a = { - RE_EXN_ID: Nullary -}; - -exports.Local = Local; -exports.f = f; -exports.g = g; -exports.h = h; -exports.x = x; -exports.xx = xx; -exports.Nullary = Nullary; -exports.a = a; -/* No side effect */ diff --git a/tests/tests/src/test_exception.mjs b/tests/tests/src/test_exception.mjs new file mode 100644 index 0000000000..414bbec886 --- /dev/null +++ b/tests/tests/src/test_exception.mjs @@ -0,0 +1,62 @@ +// Generated by ReScript, PLEASE EDIT WITH CARE + +import * as Test_common from "./test_common.mjs"; +import * as Primitive_exceptions from "rescript/lib/es6/Primitive_exceptions.js"; + +let Local = /* @__PURE__ */Primitive_exceptions.create("Test_exception.Local"); + +function f() { + throw { + RE_EXN_ID: Local, + _1: 3, + Error: new Error() + }; +} + +function g() { + throw { + RE_EXN_ID: "Not_found", + Error: new Error() + }; +} + +function h() { + throw { + RE_EXN_ID: Test_common.U, + _1: 3, + Error: new Error() + }; +} + +function x() { + throw { + RE_EXN_ID: Test_common.H, + Error: new Error() + }; +} + +function xx() { + throw { + RE_EXN_ID: "Invalid_argument", + _1: "x", + Error: new Error() + }; +} + +let Nullary = /* @__PURE__ */Primitive_exceptions.create("Test_exception.Nullary"); + +let a = { + RE_EXN_ID: Nullary +}; + +export { + Local, + f, + g, + h, + x, + xx, + Nullary, + a, +} +/* No side effect */ diff --git a/tests/tests/src/test_exception_escape.js b/tests/tests/src/test_exception_escape.js deleted file mode 100644 index a00a6ff896..0000000000 --- a/tests/tests/src/test_exception_escape.js +++ /dev/null @@ -1,25 +0,0 @@ -// Generated by ReScript, PLEASE EDIT WITH CARE -'use strict'; - -let Primitive_exceptions = require("rescript/lib/js/Primitive_exceptions.js"); - -let A = /* @__PURE__ */Primitive_exceptions.create("Test_exception_escape.N.A"); - -let f; - -try { - throw { - RE_EXN_ID: A, - _1: 3, - Error: new Error() - }; -} catch (exn) { - f = 3; -} - -let N = { - f: f -}; - -exports.N = N; -/* f Not a pure module */ diff --git a/tests/tests/src/test_exception_escape.mjs b/tests/tests/src/test_exception_escape.mjs new file mode 100644 index 0000000000..13e07cfb24 --- /dev/null +++ b/tests/tests/src/test_exception_escape.mjs @@ -0,0 +1,26 @@ +// Generated by ReScript, PLEASE EDIT WITH CARE + +import * as Primitive_exceptions from "rescript/lib/es6/Primitive_exceptions.js"; + +let A = /* @__PURE__ */Primitive_exceptions.create("Test_exception_escape.N.A"); + +let f; + +try { + throw { + RE_EXN_ID: A, + _1: 3, + Error: new Error() + }; +} catch (exn) { + f = 3; +} + +let N = { + f: f +}; + +export { + N, +} +/* f Not a pure module */ diff --git a/tests/tests/src/test_export2.js b/tests/tests/src/test_export2.js deleted file mode 100644 index b40a0f34f4..0000000000 --- a/tests/tests/src/test_export2.js +++ /dev/null @@ -1,10 +0,0 @@ -// Generated by ReScript, PLEASE EDIT WITH CARE -'use strict'; - - -function f(x, y) { - return Math.imul(x, y); -} - -exports.f = f; -/* No side effect */ diff --git a/tests/tests/src/test_export2.mjs b/tests/tests/src/test_export2.mjs new file mode 100644 index 0000000000..d3b61d62a5 --- /dev/null +++ b/tests/tests/src/test_export2.mjs @@ -0,0 +1,11 @@ +// Generated by ReScript, PLEASE EDIT WITH CARE + + +function f(x, y) { + return Math.imul(x, y); +} + +export { + f, +} +/* No side effect */ diff --git a/tests/tests/src/test_external.js b/tests/tests/src/test_external.js deleted file mode 100644 index 6267a58ca0..0000000000 --- a/tests/tests/src/test_external.js +++ /dev/null @@ -1,13 +0,0 @@ -// Generated by ReScript, PLEASE EDIT WITH CARE -'use strict'; - - -let xx = document(); - -alert("hehha"); - -let b = ff("x")(3); - -exports.xx = xx; -exports.b = b; -/* xx Not a pure module */ diff --git a/tests/tests/src/test_external.mjs b/tests/tests/src/test_external.mjs new file mode 100644 index 0000000000..9edba70916 --- /dev/null +++ b/tests/tests/src/test_external.mjs @@ -0,0 +1,14 @@ +// Generated by ReScript, PLEASE EDIT WITH CARE + + +let xx = document(); + +alert("hehha"); + +let b = ff("x")(3); + +export { + xx, + b, +} +/* xx Not a pure module */ diff --git a/tests/tests/src/test_external_unit.js b/tests/tests/src/test_external_unit.js deleted file mode 100644 index 17e452ce04..0000000000 --- a/tests/tests/src/test_external_unit.js +++ /dev/null @@ -1,13 +0,0 @@ -// Generated by ReScript, PLEASE EDIT WITH CARE -'use strict'; - - -console.log(3); - -let v = console.log(3); - -let u; - -exports.u = u; -exports.v = v; -/* Not a pure module */ diff --git a/tests/tests/src/test_external_unit.mjs b/tests/tests/src/test_external_unit.mjs new file mode 100644 index 0000000000..8283f7e76b --- /dev/null +++ b/tests/tests/src/test_external_unit.mjs @@ -0,0 +1,14 @@ +// Generated by ReScript, PLEASE EDIT WITH CARE + + +console.log(3); + +let v = console.log(3); + +let u; + +export { + u, + v, +} +/* Not a pure module */ diff --git a/tests/tests/src/test_ffi.js b/tests/tests/src/test_ffi.js deleted file mode 100644 index e063b040a4..0000000000 --- a/tests/tests/src/test_ffi.js +++ /dev/null @@ -1,13 +0,0 @@ -// Generated by ReScript, PLEASE EDIT WITH CARE -'use strict'; - - -function v(u) { - log(u); - console.log(u); - console.log(u); - return u; -} - -exports.v = v; -/* No side effect */ diff --git a/tests/tests/src/test_ffi.mjs b/tests/tests/src/test_ffi.mjs new file mode 100644 index 0000000000..cc9017d40e --- /dev/null +++ b/tests/tests/src/test_ffi.mjs @@ -0,0 +1,14 @@ +// Generated by ReScript, PLEASE EDIT WITH CARE + + +function v(u) { + log(u); + console.log(u); + console.log(u); + return u; +} + +export { + v, +} +/* No side effect */ diff --git a/tests/tests/src/test_fib.js b/tests/tests/src/test_fib.js deleted file mode 100644 index 935791bd55..0000000000 --- a/tests/tests/src/test_fib.js +++ /dev/null @@ -1,105 +0,0 @@ -// Generated by ReScript, PLEASE EDIT WITH CARE -'use strict'; - - -function fib(x) { - if (x === 0 || x === 1) { - return 1; - } else { - return fib(x - 1 | 0) + fib(x - 2 | 0) | 0; - } -} - -function fib2(x) { - if (x === 2 || x === 1) { - return 1; - } else { - return fib2(x - 1 | 0) + fib2(x - 2 | 0) | 0; - } -} - -let v = 0; - -for (let i = 0; i <= 10; ++i) { - v = v + i | 0; -} - -let sum = v; - -let v$1 = 0; - -for (let i$1 = 10; i$1 >= 0; --i$1) { - v$1 = v$1 + i$1 | 0; -} - -let sumdown = v$1; - -function cons(x, y) { - return { - TAG: "Cons", - _0: x, - _1: y - }; -} - -function length(x) { - if (typeof x !== "object") { - return 0; - } else { - return 1 + length(x._1) | 0; - } -} - -function map(f, x) { - if (typeof x !== "object") { - return "Nil"; - } else { - return { - TAG: "Cons", - _0: f(x._0), - _1: map(f, x._1) - }; - } -} - -function f(x) { - let v = x; - let sum = 0; - while (v > 0) { - sum = sum + v | 0; - v = v - 1 | 0; - }; - return sum; -} - -function fib3(n) { - let _a = 0; - let _b = 1; - let _n = n; - while (true) { - let n$1 = _n; - let b = _b; - let a = _a; - if (n$1 <= 0) { - return a; - } - _n = n$1 - 1 | 0; - _b = a + b | 0; - _a = b; - continue; - }; -} - -let b = fib; - -exports.fib = fib; -exports.fib2 = fib2; -exports.b = b; -exports.sum = sum; -exports.sumdown = sumdown; -exports.cons = cons; -exports.length = length; -exports.map = map; -exports.f = f; -exports.fib3 = fib3; -/* Not a pure module */ diff --git a/tests/tests/src/test_fib.mjs b/tests/tests/src/test_fib.mjs new file mode 100644 index 0000000000..982775b5a6 --- /dev/null +++ b/tests/tests/src/test_fib.mjs @@ -0,0 +1,106 @@ +// Generated by ReScript, PLEASE EDIT WITH CARE + + +function fib(x) { + if (x === 0 || x === 1) { + return 1; + } else { + return fib(x - 1 | 0) + fib(x - 2 | 0) | 0; + } +} + +function fib2(x) { + if (x === 2 || x === 1) { + return 1; + } else { + return fib2(x - 1 | 0) + fib2(x - 2 | 0) | 0; + } +} + +let v = 0; + +for (let i = 0; i <= 10; ++i) { + v = v + i | 0; +} + +let sum = v; + +let v$1 = 0; + +for (let i$1 = 10; i$1 >= 0; --i$1) { + v$1 = v$1 + i$1 | 0; +} + +let sumdown = v$1; + +function cons(x, y) { + return { + TAG: "Cons", + _0: x, + _1: y + }; +} + +function length(x) { + if (typeof x !== "object") { + return 0; + } else { + return 1 + length(x._1) | 0; + } +} + +function map(f, x) { + if (typeof x !== "object") { + return "Nil"; + } else { + return { + TAG: "Cons", + _0: f(x._0), + _1: map(f, x._1) + }; + } +} + +function f(x) { + let v = x; + let sum = 0; + while (v > 0) { + sum = sum + v | 0; + v = v - 1 | 0; + }; + return sum; +} + +function fib3(n) { + let _a = 0; + let _b = 1; + let _n = n; + while (true) { + let n$1 = _n; + let b = _b; + let a = _a; + if (n$1 <= 0) { + return a; + } + _n = n$1 - 1 | 0; + _b = a + b | 0; + _a = b; + continue; + }; +} + +let b = fib; + +export { + fib, + fib2, + b, + sum, + sumdown, + cons, + length, + map, + f, + fib3, +} +/* Not a pure module */ diff --git a/tests/tests/src/test_for_loop.js b/tests/tests/src/test_for_loop.js deleted file mode 100644 index 44ee773e42..0000000000 --- a/tests/tests/src/test_for_loop.js +++ /dev/null @@ -1,100 +0,0 @@ -// Generated by ReScript, PLEASE EDIT WITH CARE -'use strict'; - -let Belt_Array = require("rescript/lib/js/Belt_Array.js"); - -function for_(x) { - for (let i = 0, i_finish = (console.log("hi"), x.length); i <= i_finish; ++i) { - console.log(x[i]); - } -} - -function for_2(x) { - for (let i = 0, i_finish = x.length; i <= i_finish; ++i) { - console.log(x[i]); - } -} - -function for_3(x) { - let v = { - contents: 0 - }; - let arr = Belt_Array.map(x, param => (() => {})); - for (let i = 0, i_finish = x.length; i <= i_finish; ++i) { - let j = (i << 1); - arr[i] = () => { - v.contents = v.contents + j | 0; - }; - } - Belt_Array.forEach(arr, x => x()); - return v.contents; -} - -function for_4(x) { - let v = { - contents: 0 - }; - let arr = Belt_Array.map(x, param => (() => {})); - for (let i = 0, i_finish = x.length; i <= i_finish; ++i) { - let j = (i << 1); - let k = (j << 1); - arr[i] = () => { - v.contents = v.contents + k | 0; - }; - } - Belt_Array.forEach(arr, x => x()); - return v.contents; -} - -function for_5(x, u) { - let v = { - contents: 0 - }; - let arr = Belt_Array.map(x, param => (() => {})); - for (let i = 0, i_finish = x.length; i <= i_finish; ++i) { - let k = Math.imul((u << 1), u); - arr[i] = () => { - v.contents = v.contents + k | 0; - }; - } - Belt_Array.forEach(arr, x => x()); - return v.contents; -} - -function for_6(x, u) { - let v = { - contents: 0 - }; - let arr = Belt_Array.map(x, param => (() => {})); - let v4 = { - contents: 0 - }; - let v5 = { - contents: 0 - }; - v4.contents = v4.contents + 1 | 0; - for (let j = 0; j <= 1; ++j) { - v5.contents = v5.contents + 1 | 0; - let v2 = { - contents: 0 - }; - for (let i = 0, i_finish = x.length; i <= i_finish; ++i) { - let k = Math.imul((u << 1), u); - let h = (v5.contents << 1); - v2.contents = v2.contents + 1 | 0; - arr[i] = () => { - v.contents = (((((v.contents + k | 0) + v2.contents | 0) + u | 0) + v4.contents | 0) + v5.contents | 0) + h | 0; - }; - } - } - Belt_Array.forEach(arr, x => x()); - return v.contents; -} - -exports.for_ = for_; -exports.for_2 = for_2; -exports.for_3 = for_3; -exports.for_4 = for_4; -exports.for_5 = for_5; -exports.for_6 = for_6; -/* No side effect */ diff --git a/tests/tests/src/test_for_loop.mjs b/tests/tests/src/test_for_loop.mjs new file mode 100644 index 0000000000..c0aa40b8b7 --- /dev/null +++ b/tests/tests/src/test_for_loop.mjs @@ -0,0 +1,101 @@ +// Generated by ReScript, PLEASE EDIT WITH CARE + +import * as Belt_Array from "rescript/lib/es6/Belt_Array.js"; + +function for_(x) { + for (let i = 0, i_finish = (console.log("hi"), x.length); i <= i_finish; ++i) { + console.log(x[i]); + } +} + +function for_2(x) { + for (let i = 0, i_finish = x.length; i <= i_finish; ++i) { + console.log(x[i]); + } +} + +function for_3(x) { + let v = { + contents: 0 + }; + let arr = Belt_Array.map(x, param => (() => {})); + for (let i = 0, i_finish = x.length; i <= i_finish; ++i) { + let j = (i << 1); + arr[i] = () => { + v.contents = v.contents + j | 0; + }; + } + Belt_Array.forEach(arr, x => x()); + return v.contents; +} + +function for_4(x) { + let v = { + contents: 0 + }; + let arr = Belt_Array.map(x, param => (() => {})); + for (let i = 0, i_finish = x.length; i <= i_finish; ++i) { + let j = (i << 1); + let k = (j << 1); + arr[i] = () => { + v.contents = v.contents + k | 0; + }; + } + Belt_Array.forEach(arr, x => x()); + return v.contents; +} + +function for_5(x, u) { + let v = { + contents: 0 + }; + let arr = Belt_Array.map(x, param => (() => {})); + for (let i = 0, i_finish = x.length; i <= i_finish; ++i) { + let k = Math.imul((u << 1), u); + arr[i] = () => { + v.contents = v.contents + k | 0; + }; + } + Belt_Array.forEach(arr, x => x()); + return v.contents; +} + +function for_6(x, u) { + let v = { + contents: 0 + }; + let arr = Belt_Array.map(x, param => (() => {})); + let v4 = { + contents: 0 + }; + let v5 = { + contents: 0 + }; + v4.contents = v4.contents + 1 | 0; + for (let j = 0; j <= 1; ++j) { + v5.contents = v5.contents + 1 | 0; + let v2 = { + contents: 0 + }; + for (let i = 0, i_finish = x.length; i <= i_finish; ++i) { + let k = Math.imul((u << 1), u); + let h = (v5.contents << 1); + v2.contents = v2.contents + 1 | 0; + arr[i] = () => { + v.contents = (((((v.contents + k | 0) + v2.contents | 0) + u | 0) + v4.contents | 0) + v5.contents | 0) + h | 0; + }; + } + } + Belt_Array.forEach(arr, x => x()); + return v.contents; +} + +export { + for_, + for_2, + for_3, + for_4, + for_5, + for_6, +} +/* No side effect */ diff --git a/tests/tests/src/test_for_map.js b/tests/tests/src/test_for_map.js deleted file mode 100644 index 2918e1cd55..0000000000 --- a/tests/tests/src/test_for_map.js +++ /dev/null @@ -1,20 +0,0 @@ -// Generated by ReScript, PLEASE EDIT WITH CARE -'use strict'; - -let Belt_MapInt = require("rescript/lib/js/Belt_MapInt.js"); - -function assertion_test() { - let m; - for (let i = 0; i <= 1000000; ++i) { - m = Belt_MapInt.set(m, i, i); - } - for (let i$1 = 0; i$1 <= 1000000; ++i$1) { - Belt_MapInt.get(m, i$1); - } -} - -let IntMap; - -exports.IntMap = IntMap; -exports.assertion_test = assertion_test; -/* No side effect */ diff --git a/tests/tests/src/test_for_map.mjs b/tests/tests/src/test_for_map.mjs new file mode 100644 index 0000000000..c7be3125a9 --- /dev/null +++ b/tests/tests/src/test_for_map.mjs @@ -0,0 +1,21 @@ +// Generated by ReScript, PLEASE EDIT WITH CARE + +import * as Belt_MapInt from "rescript/lib/es6/Belt_MapInt.js"; + +function assertion_test() { + let m; + for (let i = 0; i <= 1000000; ++i) { + m = Belt_MapInt.set(m, i, i); + } + for (let i$1 = 0; i$1 <= 1000000; ++i$1) { + Belt_MapInt.get(m, i$1); + } +} + +let IntMap; + +export { + IntMap, + assertion_test, +} +/* No side effect */ diff --git a/tests/tests/src/test_for_map2.js b/tests/tests/src/test_for_map2.js deleted file mode 100644 index 86139d082b..0000000000 --- a/tests/tests/src/test_for_map2.js +++ /dev/null @@ -1,20 +0,0 @@ -// Generated by ReScript, PLEASE EDIT WITH CARE -'use strict'; - -let Belt_MapInt = require("rescript/lib/js/Belt_MapInt.js"); - -function assertion_test() { - let m; - for (let i = 0; i <= 1000000; ++i) { - m = Belt_MapInt.set(m, i, i); - } - for (let i$1 = 0; i$1 <= 1000000; ++i$1) { - Belt_MapInt.get(m, i$1); - } -} - -let Int_map; - -exports.Int_map = Int_map; -exports.assertion_test = assertion_test; -/* No side effect */ diff --git a/tests/tests/src/test_for_map2.mjs b/tests/tests/src/test_for_map2.mjs new file mode 100644 index 0000000000..808c7ffb30 --- /dev/null +++ b/tests/tests/src/test_for_map2.mjs @@ -0,0 +1,21 @@ +// Generated by ReScript, PLEASE EDIT WITH CARE + +import * as Belt_MapInt from "rescript/lib/es6/Belt_MapInt.js"; + +function assertion_test() { + let m; + for (let i = 0; i <= 1000000; ++i) { + m = Belt_MapInt.set(m, i, i); + } + for (let i$1 = 0; i$1 <= 1000000; ++i$1) { + Belt_MapInt.get(m, i$1); + } +} + +let Int_map; + +export { + Int_map, + assertion_test, +} +/* No side effect */ diff --git a/tests/tests/src/test_functor_dead_code.js b/tests/tests/src/test_functor_dead_code.js deleted file mode 100644 index 3bec0b24dd..0000000000 --- a/tests/tests/src/test_functor_dead_code.js +++ /dev/null @@ -1,9 +0,0 @@ -// Generated by ReScript, PLEASE EDIT WITH CARE -'use strict'; - -let Belt_MapString = require("rescript/lib/js/Belt_MapString.js"); - -let v = Belt_MapString.isEmpty(undefined); - -exports.v = v; -/* v Not a pure module */ diff --git a/tests/tests/src/test_functor_dead_code.mjs b/tests/tests/src/test_functor_dead_code.mjs new file mode 100644 index 0000000000..d17315e1d1 --- /dev/null +++ b/tests/tests/src/test_functor_dead_code.mjs @@ -0,0 +1,10 @@ +// Generated by ReScript, PLEASE EDIT WITH CARE + +import * as Belt_MapString from "rescript/lib/es6/Belt_MapString.js"; + +let v = Belt_MapString.isEmpty(undefined); + +export { + v, +} +/* v Not a pure module */ diff --git a/tests/tests/src/test_generative_module.js b/tests/tests/src/test_generative_module.js deleted file mode 100644 index 32bc06daed..0000000000 --- a/tests/tests/src/test_generative_module.js +++ /dev/null @@ -1,17 +0,0 @@ -// Generated by ReScript, PLEASE EDIT WITH CARE -'use strict'; - - -function M($star) { - return { - v: 3 - }; -} - -let V = { - v: 3 -}; - -exports.M = M; -exports.V = V; -/* No side effect */ diff --git a/tests/tests/src/test_generative_module.mjs b/tests/tests/src/test_generative_module.mjs new file mode 100644 index 0000000000..503bcfed7f --- /dev/null +++ b/tests/tests/src/test_generative_module.mjs @@ -0,0 +1,18 @@ +// Generated by ReScript, PLEASE EDIT WITH CARE + + +function M($star) { + return { + v: 3 + }; +} + +let V = { + v: 3 +}; + +export { + M, + V, +} +/* No side effect */ diff --git a/tests/tests/src/test_google_closure.js b/tests/tests/src/test_google_closure.js deleted file mode 100644 index ec2b89005b..0000000000 --- a/tests/tests/src/test_google_closure.js +++ /dev/null @@ -1,42 +0,0 @@ -// Generated by ReScript, PLEASE EDIT WITH CARE -'use strict'; - -let Belt_Array = require("rescript/lib/js/Belt_Array.js"); - -function f(a, b, param) { - return a + b | 0; -} - -function f2(a) { - return extra => a + 1 | 0; -} - -let a = (3).toString(); - -function f3(extra) { - return 101; -} - -let b = f3(2); - -let arr = Belt_Array.init(2, param => 0); - -for (let i = 0; i <= 1; ++i) { - let f3$1 = extra => i + 1 | 0; - arr[i] = f3$1(2); -} - -console.log([ - a, - b, - arr -]); - -let c = arr; - -exports.f = f; -exports.f2 = f2; -exports.a = a; -exports.b = b; -exports.c = c; -/* a Not a pure module */ diff --git a/tests/tests/src/test_google_closure.mjs b/tests/tests/src/test_google_closure.mjs new file mode 100644 index 0000000000..9dea2a7626 --- /dev/null +++ b/tests/tests/src/test_google_closure.mjs @@ -0,0 +1,43 @@ +// Generated by ReScript, PLEASE EDIT WITH CARE + +import * as Belt_Array from "rescript/lib/es6/Belt_Array.js"; + +function f(a, b, param) { + return a + b | 0; +} + +function f2(a) { + return extra => a + 1 | 0; +} + +let a = (3).toString(); + +function f3(extra) { + return 101; +} + +let b = f3(2); + +let arr = Belt_Array.init(2, param => 0); + +for (let i = 0; i <= 1; ++i) { + let f3$1 = extra => i + 1 | 0; + arr[i] = f3$1(2); +} + +console.log([ + a, + b, + arr +]); + +let c = arr; + +export { + f, + f2, + a, + b, + c, +} +/* a Not a pure module */ diff --git a/tests/tests/src/test_include.js b/tests/tests/src/test_include.js deleted file mode 100644 index e9eab4d7c5..0000000000 --- a/tests/tests/src/test_include.js +++ /dev/null @@ -1,310 +0,0 @@ -// Generated by ReScript, PLEASE EDIT WITH CARE -'use strict'; - -let Belt_List = require("rescript/lib/js/Belt_List.js"); -let Test_order = require("./test_order.js"); - -function Make(U) { - return { - v: U.compare - }; -} - -let U = { - v: Test_order.compare -}; - -let N; - -let v = Belt_List.length; - -let N0; - -let N1; - -let N2; - -let N3; - -let N4; - -let N5; - -let N6; - -let length = Belt_List.length; - -let size = Belt_List.size; - -let head = Belt_List.head; - -let headExn = Belt_List.headExn; - -let tail = Belt_List.tail; - -let tailExn = Belt_List.tailExn; - -let add = Belt_List.add; - -let get = Belt_List.get; - -let getExn = Belt_List.getExn; - -let make = Belt_List.make; - -let makeByU = Belt_List.makeByU; - -let makeBy = Belt_List.makeBy; - -let shuffle = Belt_List.shuffle; - -let drop = Belt_List.drop; - -let take = Belt_List.take; - -let splitAt = Belt_List.splitAt; - -let concat = Belt_List.concat; - -let concatMany = Belt_List.concatMany; - -let reverseConcat = Belt_List.reverseConcat; - -let flatten = Belt_List.flatten; - -let mapU = Belt_List.mapU; - -let map = Belt_List.map; - -let zip = Belt_List.zip; - -let zipByU = Belt_List.zipByU; - -let zipBy = Belt_List.zipBy; - -let mapWithIndexU = Belt_List.mapWithIndexU; - -let mapWithIndex = Belt_List.mapWithIndex; - -let fromArray = Belt_List.fromArray; - -let toArray = Belt_List.toArray; - -let reverse = Belt_List.reverse; - -let mapReverseU = Belt_List.mapReverseU; - -let mapReverse = Belt_List.mapReverse; - -let forEachU = Belt_List.forEachU; - -let forEach = Belt_List.forEach; - -let forEachWithIndexU = Belt_List.forEachWithIndexU; - -let forEachWithIndex = Belt_List.forEachWithIndex; - -let reduceU = Belt_List.reduceU; - -let reduce = Belt_List.reduce; - -let reduceWithIndexU = Belt_List.reduceWithIndexU; - -let reduceWithIndex = Belt_List.reduceWithIndex; - -let reduceReverseU = Belt_List.reduceReverseU; - -let reduceReverse = Belt_List.reduceReverse; - -let mapReverse2U = Belt_List.mapReverse2U; - -let mapReverse2 = Belt_List.mapReverse2; - -let forEach2U = Belt_List.forEach2U; - -let forEach2 = Belt_List.forEach2; - -let reduce2U = Belt_List.reduce2U; - -let reduce2 = Belt_List.reduce2; - -let reduceReverse2U = Belt_List.reduceReverse2U; - -let reduceReverse2 = Belt_List.reduceReverse2; - -let everyU = Belt_List.everyU; - -let every = Belt_List.every; - -let someU = Belt_List.someU; - -let some = Belt_List.some; - -let every2U = Belt_List.every2U; - -let every2 = Belt_List.every2; - -let some2U = Belt_List.some2U; - -let some2 = Belt_List.some2; - -let cmpByLength = Belt_List.cmpByLength; - -let cmpU = Belt_List.cmpU; - -let cmp = Belt_List.cmp; - -let eqU = Belt_List.eqU; - -let eq = Belt_List.eq; - -let hasU = Belt_List.hasU; - -let has = Belt_List.has; - -let getByU = Belt_List.getByU; - -let getBy = Belt_List.getBy; - -let keepU = Belt_List.keepU; - -let keep = Belt_List.keep; - -let filter = Belt_List.filter; - -let keepWithIndexU = Belt_List.keepWithIndexU; - -let keepWithIndex = Belt_List.keepWithIndex; - -let filterWithIndex = Belt_List.filterWithIndex; - -let keepMapU = Belt_List.keepMapU; - -let keepMap = Belt_List.keepMap; - -let partitionU = Belt_List.partitionU; - -let partition = Belt_List.partition; - -let unzip = Belt_List.unzip; - -let getAssocU = Belt_List.getAssocU; - -let getAssoc = Belt_List.getAssoc; - -let hasAssocU = Belt_List.hasAssocU; - -let hasAssoc = Belt_List.hasAssoc; - -let removeAssocU = Belt_List.removeAssocU; - -let removeAssoc = Belt_List.removeAssoc; - -let setAssocU = Belt_List.setAssocU; - -let setAssoc = Belt_List.setAssoc; - -let sortU = Belt_List.sortU; - -let sort = Belt_List.sort; - -exports.N = N; -exports.v = v; -exports.Make = Make; -exports.U = U; -exports.N0 = N0; -exports.N1 = N1; -exports.N2 = N2; -exports.N3 = N3; -exports.N4 = N4; -exports.N5 = N5; -exports.N6 = N6; -exports.length = length; -exports.size = size; -exports.head = head; -exports.headExn = headExn; -exports.tail = tail; -exports.tailExn = tailExn; -exports.add = add; -exports.get = get; -exports.getExn = getExn; -exports.make = make; -exports.makeByU = makeByU; -exports.makeBy = makeBy; -exports.shuffle = shuffle; -exports.drop = drop; -exports.take = take; -exports.splitAt = splitAt; -exports.concat = concat; -exports.concatMany = concatMany; -exports.reverseConcat = reverseConcat; -exports.flatten = flatten; -exports.mapU = mapU; -exports.map = map; -exports.zip = zip; -exports.zipByU = zipByU; -exports.zipBy = zipBy; -exports.mapWithIndexU = mapWithIndexU; -exports.mapWithIndex = mapWithIndex; -exports.fromArray = fromArray; -exports.toArray = toArray; -exports.reverse = reverse; -exports.mapReverseU = mapReverseU; -exports.mapReverse = mapReverse; -exports.forEachU = forEachU; -exports.forEach = forEach; -exports.forEachWithIndexU = forEachWithIndexU; -exports.forEachWithIndex = forEachWithIndex; -exports.reduceU = reduceU; -exports.reduce = reduce; -exports.reduceWithIndexU = reduceWithIndexU; -exports.reduceWithIndex = reduceWithIndex; -exports.reduceReverseU = reduceReverseU; -exports.reduceReverse = reduceReverse; -exports.mapReverse2U = mapReverse2U; -exports.mapReverse2 = mapReverse2; -exports.forEach2U = forEach2U; -exports.forEach2 = forEach2; -exports.reduce2U = reduce2U; -exports.reduce2 = reduce2; -exports.reduceReverse2U = reduceReverse2U; -exports.reduceReverse2 = reduceReverse2; -exports.everyU = everyU; -exports.every = every; -exports.someU = someU; -exports.some = some; -exports.every2U = every2U; -exports.every2 = every2; -exports.some2U = some2U; -exports.some2 = some2; -exports.cmpByLength = cmpByLength; -exports.cmpU = cmpU; -exports.cmp = cmp; -exports.eqU = eqU; -exports.eq = eq; -exports.hasU = hasU; -exports.has = has; -exports.getByU = getByU; -exports.getBy = getBy; -exports.keepU = keepU; -exports.keep = keep; -exports.filter = filter; -exports.keepWithIndexU = keepWithIndexU; -exports.keepWithIndex = keepWithIndex; -exports.filterWithIndex = filterWithIndex; -exports.keepMapU = keepMapU; -exports.keepMap = keepMap; -exports.partitionU = partitionU; -exports.partition = partition; -exports.unzip = unzip; -exports.getAssocU = getAssocU; -exports.getAssoc = getAssoc; -exports.hasAssocU = hasAssocU; -exports.hasAssoc = hasAssoc; -exports.removeAssocU = removeAssocU; -exports.removeAssoc = removeAssoc; -exports.setAssocU = setAssocU; -exports.setAssoc = setAssoc; -exports.sortU = sortU; -exports.sort = sort; -/* No side effect */ diff --git a/tests/tests/src/test_include.mjs b/tests/tests/src/test_include.mjs new file mode 100644 index 0000000000..453e8f2a28 --- /dev/null +++ b/tests/tests/src/test_include.mjs @@ -0,0 +1,311 @@ +// Generated by ReScript, PLEASE EDIT WITH CARE + +import * as Belt_List from "rescript/lib/es6/Belt_List.js"; +import * as Test_order from "./test_order.mjs"; + +function Make(U) { + return { + v: U.compare + }; +} + +let U = { + v: Test_order.compare +}; + +let N; + +let v = Belt_List.length; + +let N0; + +let N1; + +let N2; + +let N3; + +let N4; + +let N5; + +let N6; + +let length = Belt_List.length; + +let size = Belt_List.size; + +let head = Belt_List.head; + +let headExn = Belt_List.headExn; + +let tail = Belt_List.tail; + +let tailExn = Belt_List.tailExn; + +let add = Belt_List.add; + +let get = Belt_List.get; + +let getExn = Belt_List.getExn; + +let make = Belt_List.make; + +let makeByU = Belt_List.makeByU; + +let makeBy = Belt_List.makeBy; + +let shuffle = Belt_List.shuffle; + +let drop = Belt_List.drop; + +let take = Belt_List.take; + +let splitAt = Belt_List.splitAt; + +let concat = Belt_List.concat; + +let concatMany = Belt_List.concatMany; + +let reverseConcat = Belt_List.reverseConcat; + +let flatten = Belt_List.flatten; + +let mapU = Belt_List.mapU; + +let map = Belt_List.map; + +let zip = Belt_List.zip; + +let zipByU = Belt_List.zipByU; + +let zipBy = Belt_List.zipBy; + +let mapWithIndexU = Belt_List.mapWithIndexU; + +let mapWithIndex = Belt_List.mapWithIndex; + +let fromArray = Belt_List.fromArray; + +let toArray = Belt_List.toArray; + +let reverse = Belt_List.reverse; + +let mapReverseU = Belt_List.mapReverseU; + +let mapReverse = Belt_List.mapReverse; + +let forEachU = Belt_List.forEachU; + +let forEach = Belt_List.forEach; + +let forEachWithIndexU = Belt_List.forEachWithIndexU; + +let forEachWithIndex = Belt_List.forEachWithIndex; + +let reduceU = Belt_List.reduceU; + +let reduce = Belt_List.reduce; + +let reduceWithIndexU = Belt_List.reduceWithIndexU; + +let reduceWithIndex = Belt_List.reduceWithIndex; + +let reduceReverseU = Belt_List.reduceReverseU; + +let reduceReverse = Belt_List.reduceReverse; + +let mapReverse2U = Belt_List.mapReverse2U; + +let mapReverse2 = Belt_List.mapReverse2; + +let forEach2U = Belt_List.forEach2U; + +let forEach2 = Belt_List.forEach2; + +let reduce2U = Belt_List.reduce2U; + +let reduce2 = Belt_List.reduce2; + +let reduceReverse2U = Belt_List.reduceReverse2U; + +let reduceReverse2 = Belt_List.reduceReverse2; + +let everyU = Belt_List.everyU; + +let every = Belt_List.every; + +let someU = Belt_List.someU; + +let some = Belt_List.some; + +let every2U = Belt_List.every2U; + +let every2 = Belt_List.every2; + +let some2U = Belt_List.some2U; + +let some2 = Belt_List.some2; + +let cmpByLength = Belt_List.cmpByLength; + +let cmpU = Belt_List.cmpU; + +let cmp = Belt_List.cmp; + +let eqU = Belt_List.eqU; + +let eq = Belt_List.eq; + +let hasU = Belt_List.hasU; + +let has = Belt_List.has; + +let getByU = Belt_List.getByU; + +let getBy = Belt_List.getBy; + +let keepU = Belt_List.keepU; + +let keep = Belt_List.keep; + +let filter = Belt_List.filter; + +let keepWithIndexU = Belt_List.keepWithIndexU; + +let keepWithIndex = Belt_List.keepWithIndex; + +let filterWithIndex = Belt_List.filterWithIndex; + +let keepMapU = Belt_List.keepMapU; + +let keepMap = Belt_List.keepMap; + +let partitionU = Belt_List.partitionU; + +let partition = Belt_List.partition; + +let unzip = Belt_List.unzip; + +let getAssocU = Belt_List.getAssocU; + +let getAssoc = Belt_List.getAssoc; + +let hasAssocU = Belt_List.hasAssocU; + +let hasAssoc = Belt_List.hasAssoc; + +let removeAssocU = Belt_List.removeAssocU; + +let removeAssoc = Belt_List.removeAssoc; + +let setAssocU = Belt_List.setAssocU; + +let setAssoc = Belt_List.setAssoc; + +let sortU = Belt_List.sortU; + +let sort = Belt_List.sort; + +export { + N, + v, + Make, + U, + N0, + N1, + N2, + N3, + N4, + N5, + N6, + length, + size, + head, + headExn, + tail, + tailExn, + add, + get, + getExn, + make, + makeByU, + makeBy, + shuffle, + drop, + take, + splitAt, + concat, + concatMany, + reverseConcat, + flatten, + mapU, + map, + zip, + zipByU, + zipBy, + mapWithIndexU, + mapWithIndex, + fromArray, + toArray, + reverse, + mapReverseU, + mapReverse, + forEachU, + forEach, + forEachWithIndexU, + forEachWithIndex, + reduceU, + reduce, + reduceWithIndexU, + reduceWithIndex, + reduceReverseU, + reduceReverse, + mapReverse2U, + mapReverse2, + forEach2U, + forEach2, + reduce2U, + reduce2, + reduceReverse2U, + reduceReverse2, + everyU, + every, + someU, + some, + every2U, + every2, + some2U, + some2, + cmpByLength, + cmpU, + cmp, + eqU, + eq, + hasU, + has, + getByU, + getBy, + keepU, + keep, + filter, + keepWithIndexU, + keepWithIndex, + filterWithIndex, + keepMapU, + keepMap, + partitionU, + partition, + unzip, + getAssocU, + getAssoc, + hasAssocU, + hasAssoc, + removeAssocU, + removeAssoc, + setAssocU, + setAssoc, + sortU, + sort, +} +/* No side effect */ diff --git a/tests/tests/src/test_incomplete.js b/tests/tests/src/test_incomplete.js deleted file mode 100644 index 22740d944e..0000000000 --- a/tests/tests/src/test_incomplete.js +++ /dev/null @@ -1,42 +0,0 @@ -// Generated by ReScript, PLEASE EDIT WITH CARE -'use strict'; - - -function f(x) { - if (!(x > 3 || x < 1)) { - return /* 'a' */97; - } - throw { - RE_EXN_ID: "Match_failure", - _1: [ - "test_incomplete.res", - 3, - 2 - ], - Error: new Error() - }; -} - -function f2(x) { - if (x !== undefined) { - return 0; - } else { - return 1; - } -} - -function f3(x) { - switch (x.TAG) { - case "A" : - case "C" : - return x._0 + 1 | 0; - case "B" : - case "D" : - return x._0 + 2 | 0; - } -} - -exports.f = f; -exports.f2 = f2; -exports.f3 = f3; -/* No side effect */ diff --git a/tests/tests/src/test_incomplete.mjs b/tests/tests/src/test_incomplete.mjs new file mode 100644 index 0000000000..27415a8be7 --- /dev/null +++ b/tests/tests/src/test_incomplete.mjs @@ -0,0 +1,43 @@ +// Generated by ReScript, PLEASE EDIT WITH CARE + + +function f(x) { + if (!(x > 3 || x < 1)) { + return /* 'a' */97; + } + throw { + RE_EXN_ID: "Match_failure", + _1: [ + "test_incomplete.res", + 3, + 2 + ], + Error: new Error() + }; +} + +function f2(x) { + if (x !== undefined) { + return 0; + } else { + return 1; + } +} + +function f3(x) { + switch (x.TAG) { + case "A" : + case "C" : + return x._0 + 1 | 0; + case "B" : + case "D" : + return x._0 + 2 | 0; + } +} + +export { + f, + f2, + f3, +} +/* No side effect */ diff --git a/tests/tests/src/test_incr_ref.js b/tests/tests/src/test_incr_ref.js deleted file mode 100644 index 4640d055fa..0000000000 --- a/tests/tests/src/test_incr_ref.js +++ /dev/null @@ -1,12 +0,0 @@ -// Generated by ReScript, PLEASE EDIT WITH CARE -'use strict'; - - -let u = 0; - -u = u + 1 | 0; - -let v; - -exports.v = v; -/* v Not a pure module */ diff --git a/tests/tests/src/test_incr_ref.mjs b/tests/tests/src/test_incr_ref.mjs new file mode 100644 index 0000000000..6e22f1919f --- /dev/null +++ b/tests/tests/src/test_incr_ref.mjs @@ -0,0 +1,13 @@ +// Generated by ReScript, PLEASE EDIT WITH CARE + + +let u = 0; + +u = u + 1 | 0; + +let v; + +export { + v, +} +/* v Not a pure module */ diff --git a/tests/tests/src/test_int_map_find.js b/tests/tests/src/test_int_map_find.js deleted file mode 100644 index 716e524dac..0000000000 --- a/tests/tests/src/test_int_map_find.js +++ /dev/null @@ -1,33 +0,0 @@ -// Generated by ReScript, PLEASE EDIT WITH CARE -'use strict'; - -let Belt_List = require("rescript/lib/js/Belt_List.js"); -let Belt_MapInt = require("rescript/lib/js/Belt_MapInt.js"); - -Belt_List.reduceReverse({ - hd: [ - 10, - /* 'a' */97 - ], - tl: { - hd: [ - 3, - /* 'b' */98 - ], - tl: { - hd: [ - 7, - /* 'c' */99 - ], - tl: { - hd: [ - 20, - /* 'd' */100 - ], - tl: /* [] */0 - } - } - } -}, undefined, (acc, param) => Belt_MapInt.set(acc, param[0], param[1])); - -/* Not a pure module */ diff --git a/tests/tests/src/test_int_map_find.mjs b/tests/tests/src/test_int_map_find.mjs new file mode 100644 index 0000000000..4418ec8f6f --- /dev/null +++ b/tests/tests/src/test_int_map_find.mjs @@ -0,0 +1,32 @@ +// Generated by ReScript, PLEASE EDIT WITH CARE + +import * as Belt_List from "rescript/lib/es6/Belt_List.js"; +import * as Belt_MapInt from "rescript/lib/es6/Belt_MapInt.js"; + +Belt_List.reduceReverse({ + hd: [ + 10, + /* 'a' */97 + ], + tl: { + hd: [ + 3, + /* 'b' */98 + ], + tl: { + hd: [ + 7, + /* 'c' */99 + ], + tl: { + hd: [ + 20, + /* 'd' */100 + ], + tl: /* [] */0 + } + } + } +}, undefined, (acc, param) => Belt_MapInt.set(acc, param[0], param[1])); + +/* Not a pure module */ diff --git a/tests/tests/src/test_is_js.js b/tests/tests/src/test_is_js.js deleted file mode 100644 index 3f7feeca4e..0000000000 --- a/tests/tests/src/test_is_js.js +++ /dev/null @@ -1,37 +0,0 @@ -// Generated by ReScript, PLEASE EDIT WITH CARE -'use strict'; - -let Mt = require("./mt.js"); - -let suites = { - contents: /* [] */0 -}; - -let test_id = { - contents: 0 -}; - -function eq(loc, x, y) { - Mt.eq_suites(test_id, suites, loc, x, y); -} - -function b(loc, x) { - Mt.bool_suites(test_id, suites, loc, x); -} - -b("File \"test_is_js.res\", line 8, characters 2-9", true); - -b("File \"test_is_js.res\", line 10, characters 2-9", true); - -b("File \"test_is_js.res\", line 12, characters 2-9", true); - -Mt.from_pair_suites("Test_is_js", suites.contents); - -let v = true; - -exports.v = v; -exports.suites = suites; -exports.test_id = test_id; -exports.eq = eq; -exports.b = b; -/* Not a pure module */ diff --git a/tests/tests/src/test_is_js.mjs b/tests/tests/src/test_is_js.mjs new file mode 100644 index 0000000000..3139d11e37 --- /dev/null +++ b/tests/tests/src/test_is_js.mjs @@ -0,0 +1,38 @@ +// Generated by ReScript, PLEASE EDIT WITH CARE + +import * as Mt from "./mt.mjs"; + +let suites = { + contents: /* [] */0 +}; + +let test_id = { + contents: 0 +}; + +function eq(loc, x, y) { + Mt.eq_suites(test_id, suites, loc, x, y); +} + +function b(loc, x) { + Mt.bool_suites(test_id, suites, loc, x); +} + +b("File \"test_is_js.res\", line 8, characters 2-9", true); + +b("File \"test_is_js.res\", line 10, characters 2-9", true); + +b("File \"test_is_js.res\", line 12, characters 2-9", true); + +Mt.from_pair_suites("Test_is_js", suites.contents); + +let v = true; + +export { + v, + suites, + test_id, + eq, + b, +} +/* Not a pure module */ diff --git a/tests/tests/src/test_js_ffi.js b/tests/tests/src/test_js_ffi.js deleted file mode 100644 index b441d700a9..0000000000 --- a/tests/tests/src/test_js_ffi.js +++ /dev/null @@ -1,19 +0,0 @@ -// Generated by ReScript, PLEASE EDIT WITH CARE -'use strict'; - -let Test_order = require("./test_order.js"); - -function v(u) { - t(Test_order); -} - -function u(v) { - return v; -} - -let s = Test_order; - -exports.v = v; -exports.u = u; -exports.s = s; -/* No side effect */ diff --git a/tests/tests/src/test_js_ffi.mjs b/tests/tests/src/test_js_ffi.mjs new file mode 100644 index 0000000000..f0860b2669 --- /dev/null +++ b/tests/tests/src/test_js_ffi.mjs @@ -0,0 +1,20 @@ +// Generated by ReScript, PLEASE EDIT WITH CARE + +import * as Test_order from "./test_order.mjs"; + +function v(u) { + t(Test_order); +} + +function u(v) { + return v; +} + +let s = Test_order; + +export { + v, + u, + s, +} +/* No side effect */ diff --git a/tests/tests/src/test_let.js b/tests/tests/src/test_let.js deleted file mode 100644 index 8ed1d482bc..0000000000 --- a/tests/tests/src/test_let.js +++ /dev/null @@ -1,10 +0,0 @@ -// Generated by ReScript, PLEASE EDIT WITH CARE -'use strict'; - - -console.log(3); - -let b = 3; - -exports.b = b; -/* Not a pure module */ diff --git a/tests/tests/src/test_let.mjs b/tests/tests/src/test_let.mjs new file mode 100644 index 0000000000..85e8739708 --- /dev/null +++ b/tests/tests/src/test_let.mjs @@ -0,0 +1,11 @@ +// Generated by ReScript, PLEASE EDIT WITH CARE + + +console.log(3); + +let b = 3; + +export { + b, +} +/* Not a pure module */ diff --git a/tests/tests/src/test_list.js b/tests/tests/src/test_list.js deleted file mode 100644 index 25bdf71861..0000000000 --- a/tests/tests/src/test_list.js +++ /dev/null @@ -1,1478 +0,0 @@ -// Generated by ReScript, PLEASE EDIT WITH CARE -'use strict'; - -let Belt_List = require("rescript/lib/js/Belt_List.js"); -let Pervasives = require("rescript/lib/js/Pervasives.js"); - -function length_aux(_len, _x) { - while (true) { - let x = _x; - let len = _len; - if (!x) { - return len; - } - _x = x.tl; - _len = len + 1 | 0; - continue; - }; -} - -function length(l) { - return length_aux(0, l); -} - -function hd(x) { - if (x) { - return x.hd; - } else { - return Pervasives.failwith("hd"); - } -} - -function tl(x) { - if (x) { - return x.tl; - } else { - return Pervasives.failwith("tl"); - } -} - -function nth(l, n) { - if (n < 0) { - return Pervasives.invalid_arg("List.nth"); - } - let _l = l; - let _n = n; - while (true) { - let n$1 = _n; - let l$1 = _l; - if (!l$1) { - return Pervasives.failwith("nth"); - } - if (n$1 === 0) { - return l$1.hd; - } - _n = n$1 - 1 | 0; - _l = l$1.tl; - continue; - }; -} - -function rev_append(_l1, _l2) { - while (true) { - let l2 = _l2; - let l1 = _l1; - if (!l1) { - return l2; - } - _l2 = { - hd: l1.hd, - tl: l2 - }; - _l1 = l1.tl; - continue; - }; -} - -function rev(l) { - return rev_append(l, /* [] */0); -} - -function flatten(x) { - if (x) { - return Pervasives.$at(x.hd, flatten(x.tl)); - } else { - return /* [] */0; - } -} - -function map(f, x) { - if (!x) { - return /* [] */0; - } - let r = f(x.hd); - return { - hd: r, - tl: map(f, x.tl) - }; -} - -function mapi(i, f, x) { - if (!x) { - return /* [] */0; - } - let r = f(i, x.hd); - return { - hd: r, - tl: mapi(i + 1 | 0, f, x.tl) - }; -} - -function mapi$1(f, l) { - return mapi(0, f, l); -} - -function rev_map(f, l) { - let _accu = /* [] */0; - let _x = l; - while (true) { - let x = _x; - let accu = _accu; - if (!x) { - return accu; - } - _x = x.tl; - _accu = { - hd: f(x.hd), - tl: accu - }; - continue; - }; -} - -function iter(f, _x) { - while (true) { - let x = _x; - if (!x) { - return; - } - f(x.hd); - _x = x.tl; - continue; - }; -} - -function iteri(f, l) { - let _i = 0; - let _x = l; - while (true) { - let x = _x; - let i = _i; - if (!x) { - return; - } - f(i, x.hd); - _x = x.tl; - _i = i + 1 | 0; - continue; - }; -} - -function fold_left(f, _accu, _l) { - while (true) { - let l = _l; - let accu = _accu; - if (!l) { - return accu; - } - _l = l.tl; - _accu = f(accu, l.hd); - continue; - }; -} - -function fold_right(f, l, accu) { - if (l) { - return f(l.hd, fold_right(f, l.tl, accu)); - } else { - return accu; - } -} - -function map2(f, l1, l2) { - if (!l1) { - if (l2) { - return Pervasives.invalid_arg("List.map2"); - } else { - return /* [] */0; - } - } - if (!l2) { - return Pervasives.invalid_arg("List.map2"); - } - let r = f(l1.hd, l2.hd); - return { - hd: r, - tl: map2(f, l1.tl, l2.tl) - }; -} - -function rev_map2(f, l1, l2) { - let _accu = /* [] */0; - let _l1 = l1; - let _l2 = l2; - while (true) { - let l2$1 = _l2; - let l1$1 = _l1; - let accu = _accu; - if (!l1$1) { - if (l2$1) { - return Pervasives.invalid_arg("List.rev_map2"); - } else { - return accu; - } - } - if (!l2$1) { - return Pervasives.invalid_arg("List.rev_map2"); - } - _l2 = l2$1.tl; - _l1 = l1$1.tl; - _accu = { - hd: f(l1$1.hd, l2$1.hd), - tl: accu - }; - continue; - }; -} - -function iter2(f, _l1, _l2) { - while (true) { - let l2 = _l2; - let l1 = _l1; - if (!l1) { - if (l2) { - return Pervasives.invalid_arg("List.iter2"); - } else { - return; - } - } - if (!l2) { - return Pervasives.invalid_arg("List.iter2"); - } - f(l1.hd, l2.hd); - _l2 = l2.tl; - _l1 = l1.tl; - continue; - }; -} - -function fold_left2(f, _accu, _l1, _l2) { - while (true) { - let l2 = _l2; - let l1 = _l1; - let accu = _accu; - if (!l1) { - if (l2) { - return Pervasives.invalid_arg("List.fold_left2"); - } else { - return accu; - } - } - if (!l2) { - return Pervasives.invalid_arg("List.fold_left2"); - } - _l2 = l2.tl; - _l1 = l1.tl; - _accu = f(accu, l1.hd, l2.hd); - continue; - }; -} - -function fold_right2(f, l1, l2, accu) { - if (l1) { - if (l2) { - return f(l1.hd, l2.hd, fold_right2(f, l1.tl, l2.tl, accu)); - } else { - return Pervasives.invalid_arg("List.fold_right2"); - } - } else if (l2) { - return Pervasives.invalid_arg("List.fold_right2"); - } else { - return accu; - } -} - -function for_all(p, _x) { - while (true) { - let x = _x; - if (!x) { - return true; - } - if (!p(x.hd)) { - return false; - } - _x = x.tl; - continue; - }; -} - -function exists(p, _x) { - while (true) { - let x = _x; - if (!x) { - return false; - } - if (p(x.hd)) { - return true; - } - _x = x.tl; - continue; - }; -} - -function for_all2(p, _l1, _l2) { - while (true) { - let l2 = _l2; - let l1 = _l1; - if (!l1) { - if (l2) { - return Pervasives.invalid_arg("List.for_all2"); - } else { - return true; - } - } - if (!l2) { - return Pervasives.invalid_arg("List.for_all2"); - } - if (!p(l1.hd, l2.hd)) { - return false; - } - _l2 = l2.tl; - _l1 = l1.tl; - continue; - }; -} - -function exists2(p, _l1, _l2) { - while (true) { - let l2 = _l2; - let l1 = _l1; - if (!l1) { - if (l2) { - return Pervasives.invalid_arg("List.exists2"); - } else { - return false; - } - } - if (!l2) { - return Pervasives.invalid_arg("List.exists2"); - } - if (p(l1.hd, l2.hd)) { - return true; - } - _l2 = l2.tl; - _l1 = l1.tl; - continue; - }; -} - -function mem(x, _x_) { - while (true) { - let x_ = _x_; - if (!x_) { - return false; - } - if (x_.hd === x) { - return true; - } - _x_ = x_.tl; - continue; - }; -} - -function memq(x, _x_) { - while (true) { - let x_ = _x_; - if (!x_) { - return false; - } - if (x_.hd === x) { - return true; - } - _x_ = x_.tl; - continue; - }; -} - -function assoc(x, _x_) { - while (true) { - let x_ = _x_; - if (x_) { - let match = x_.hd; - if (match[0] === x) { - return match[1]; - } - _x_ = x_.tl; - continue; - } - throw { - RE_EXN_ID: "Not_found", - Error: new Error() - }; - }; -} - -function assq(x, _x_) { - while (true) { - let x_ = _x_; - if (x_) { - let match = x_.hd; - if (match[0] === x) { - return match[1]; - } - _x_ = x_.tl; - continue; - } - throw { - RE_EXN_ID: "Not_found", - Error: new Error() - }; - }; -} - -function mem_assoc(x, _x_) { - while (true) { - let x_ = _x_; - if (!x_) { - return false; - } - if (x_.hd[0] === x) { - return true; - } - _x_ = x_.tl; - continue; - }; -} - -function mem_assq(x, _x_) { - while (true) { - let x_ = _x_; - if (!x_) { - return false; - } - if (x_.hd[0] === x) { - return true; - } - _x_ = x_.tl; - continue; - }; -} - -function remove_assoc(x, x_) { - if (!x_) { - return /* [] */0; - } - let l = x_.tl; - let pair = x_.hd; - if (pair[0] === x) { - return l; - } else { - return { - hd: pair, - tl: remove_assoc(x, l) - }; - } -} - -function remove_assq(x, x_) { - if (!x_) { - return /* [] */0; - } - let l = x_.tl; - let pair = x_.hd; - if (pair[0] === x) { - return l; - } else { - return { - hd: pair, - tl: remove_assq(x, l) - }; - } -} - -function find(p, _x) { - while (true) { - let x = _x; - if (x) { - let x$1 = x.hd; - if (p(x$1)) { - return x$1; - } - _x = x.tl; - continue; - } - throw { - RE_EXN_ID: "Not_found", - Error: new Error() - }; - }; -} - -function find_all(p) { - return __x => { - let _accu = /* [] */0; - let _x = __x; - while (true) { - let x = _x; - let accu = _accu; - if (!x) { - return rev_append(accu, /* [] */0); - } - let l = x.tl; - let x$1 = x.hd; - if (p(x$1)) { - _x = l; - _accu = { - hd: x$1, - tl: accu - }; - continue; - } - _x = l; - continue; - }; - }; -} - -function partition(p, l) { - let _yes = /* [] */0; - let _no = /* [] */0; - let _x = l; - while (true) { - let x = _x; - let no = _no; - let yes = _yes; - if (!x) { - return [ - rev_append(yes, /* [] */0), - rev_append(no, /* [] */0) - ]; - } - let l$1 = x.tl; - let x$1 = x.hd; - if (p(x$1)) { - _x = l$1; - _yes = { - hd: x$1, - tl: yes - }; - continue; - } - _x = l$1; - _no = { - hd: x$1, - tl: no - }; - continue; - }; -} - -function split(x) { - if (!x) { - return [ - /* [] */0, - /* [] */0 - ]; - } - let match = x.hd; - let match$1 = split(x.tl); - return [ - { - hd: match[0], - tl: match$1[0] - }, - { - hd: match[1], - tl: match$1[1] - } - ]; -} - -function combine(l1, l2) { - if (l1) { - if (l2) { - return { - hd: [ - l1.hd, - l2.hd - ], - tl: combine(l1.tl, l2.tl) - }; - } else { - return Pervasives.invalid_arg("List.combine"); - } - } else if (l2) { - return Pervasives.invalid_arg("List.combine"); - } else { - return /* [] */0; - } -} - -function merge(cmp, l1, l2) { - if (!l1) { - return l2; - } - if (!l2) { - return l1; - } - let h2 = l2.hd; - let h1 = l1.hd; - if (cmp(h1, h2) <= 0) { - return { - hd: h1, - tl: merge(cmp, l1.tl, l2) - }; - } else { - return { - hd: h2, - tl: merge(cmp, l1, l2.tl) - }; - } -} - -function chop(_k, _l) { - while (true) { - let l = _l; - let k = _k; - if (k === 0) { - return l; - } - if (l) { - _l = l.tl; - _k = k - 1 | 0; - continue; - } - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "test_list.res", - 343, - 11 - ], - Error: new Error() - }; - }; -} - -function stable_sort(cmp, l) { - let sort = (n, l) => { - if (n !== 2) { - if (n === 3 && l) { - let match = l.tl; - if (match) { - let match$1 = match.tl; - if (match$1) { - let x3 = match$1.hd; - let x2 = match.hd; - let x1 = l.hd; - if (cmp(x1, x2) <= 0) { - if (cmp(x2, x3) <= 0) { - return { - hd: x1, - tl: { - hd: x2, - tl: { - hd: x3, - tl: /* [] */0 - } - } - }; - } else if (cmp(x1, x3) <= 0) { - return { - hd: x1, - tl: { - hd: x3, - tl: { - hd: x2, - tl: /* [] */0 - } - } - }; - } else { - return { - hd: x3, - tl: { - hd: x1, - tl: { - hd: x2, - tl: /* [] */0 - } - } - }; - } - } else if (cmp(x1, x3) <= 0) { - return { - hd: x2, - tl: { - hd: x1, - tl: { - hd: x3, - tl: /* [] */0 - } - } - }; - } else if (cmp(x2, x3) <= 0) { - return { - hd: x2, - tl: { - hd: x3, - tl: { - hd: x1, - tl: /* [] */0 - } - } - }; - } else { - return { - hd: x3, - tl: { - hd: x2, - tl: { - hd: x1, - tl: /* [] */0 - } - } - }; - } - } - - } - - } - - } else if (l) { - let match$2 = l.tl; - if (match$2) { - let x2$1 = match$2.hd; - let x1$1 = l.hd; - if (cmp(x1$1, x2$1) <= 0) { - return { - hd: x1$1, - tl: { - hd: x2$1, - tl: /* [] */0 - } - }; - } else { - return { - hd: x2$1, - tl: { - hd: x1$1, - tl: /* [] */0 - } - }; - } - } - - } - let n1 = (n >> 1); - let n2 = n - n1 | 0; - let l2 = chop(n1, l); - let s1 = rev_sort(n1, l); - let s2 = rev_sort(n2, l2); - let _l1 = s1; - let _l2 = s2; - let _accu = /* [] */0; - while (true) { - let accu = _accu; - let l2$1 = _l2; - let l1 = _l1; - if (!l1) { - return rev_append(l2$1, accu); - } - if (!l2$1) { - return rev_append(l1, accu); - } - let h2 = l2$1.hd; - let h1 = l1.hd; - if (cmp(h1, h2) > 0) { - _accu = { - hd: h1, - tl: accu - }; - _l1 = l1.tl; - continue; - } - _accu = { - hd: h2, - tl: accu - }; - _l2 = l2$1.tl; - continue; - }; - }; - let rev_sort = (n, l) => { - if (n !== 2) { - if (n === 3 && l) { - let match = l.tl; - if (match) { - let match$1 = match.tl; - if (match$1) { - let x3 = match$1.hd; - let x2 = match.hd; - let x1 = l.hd; - if (cmp(x1, x2) > 0) { - if (cmp(x2, x3) > 0) { - return { - hd: x1, - tl: { - hd: x2, - tl: { - hd: x3, - tl: /* [] */0 - } - } - }; - } else if (cmp(x1, x3) > 0) { - return { - hd: x1, - tl: { - hd: x3, - tl: { - hd: x2, - tl: /* [] */0 - } - } - }; - } else { - return { - hd: x3, - tl: { - hd: x1, - tl: { - hd: x2, - tl: /* [] */0 - } - } - }; - } - } else if (cmp(x1, x3) > 0) { - return { - hd: x2, - tl: { - hd: x1, - tl: { - hd: x3, - tl: /* [] */0 - } - } - }; - } else if (cmp(x2, x3) > 0) { - return { - hd: x2, - tl: { - hd: x3, - tl: { - hd: x1, - tl: /* [] */0 - } - } - }; - } else { - return { - hd: x3, - tl: { - hd: x2, - tl: { - hd: x1, - tl: /* [] */0 - } - } - }; - } - } - - } - - } - - } else if (l) { - let match$2 = l.tl; - if (match$2) { - let x2$1 = match$2.hd; - let x1$1 = l.hd; - if (cmp(x1$1, x2$1) > 0) { - return { - hd: x1$1, - tl: { - hd: x2$1, - tl: /* [] */0 - } - }; - } else { - return { - hd: x2$1, - tl: { - hd: x1$1, - tl: /* [] */0 - } - }; - } - } - - } - let n1 = (n >> 1); - let n2 = n - n1 | 0; - let l2 = chop(n1, l); - let s1 = sort(n1, l); - let s2 = sort(n2, l2); - let _l1 = s1; - let _l2 = s2; - let _accu = /* [] */0; - while (true) { - let accu = _accu; - let l2$1 = _l2; - let l1 = _l1; - if (!l1) { - return rev_append(l2$1, accu); - } - if (!l2$1) { - return rev_append(l1, accu); - } - let h2 = l2$1.hd; - let h1 = l1.hd; - if (cmp(h1, h2) <= 0) { - _accu = { - hd: h1, - tl: accu - }; - _l1 = l1.tl; - continue; - } - _accu = { - hd: h2, - tl: accu - }; - _l2 = l2$1.tl; - continue; - }; - }; - let len = length_aux(0, l); - if (len < 2) { - return l; - } else { - return sort(len, l); - } -} - -function sort_uniq(cmp, l) { - let sort = (n, l) => { - if (n !== 2) { - if (n === 3 && l) { - let match = l.tl; - if (match) { - let match$1 = match.tl; - if (match$1) { - let x3 = match$1.hd; - let x2 = match.hd; - let x1 = l.hd; - let c = cmp(x1, x2); - if (c === 0) { - let c$1 = cmp(x2, x3); - if (c$1 === 0) { - return { - hd: x2, - tl: /* [] */0 - }; - } else if (c$1 < 0) { - return { - hd: x2, - tl: { - hd: x3, - tl: /* [] */0 - } - }; - } else { - return { - hd: x3, - tl: { - hd: x2, - tl: /* [] */0 - } - }; - } - } - if (c < 0) { - let c$2 = cmp(x2, x3); - if (c$2 === 0) { - return { - hd: x1, - tl: { - hd: x2, - tl: /* [] */0 - } - }; - } - if (c$2 < 0) { - return { - hd: x1, - tl: { - hd: x2, - tl: { - hd: x3, - tl: /* [] */0 - } - } - }; - } - let c$3 = cmp(x1, x3); - if (c$3 === 0) { - return { - hd: x1, - tl: { - hd: x2, - tl: /* [] */0 - } - }; - } else if (c$3 < 0) { - return { - hd: x1, - tl: { - hd: x3, - tl: { - hd: x2, - tl: /* [] */0 - } - } - }; - } else { - return { - hd: x3, - tl: { - hd: x1, - tl: { - hd: x2, - tl: /* [] */0 - } - } - }; - } - } - let c$4 = cmp(x1, x3); - if (c$4 === 0) { - return { - hd: x2, - tl: { - hd: x1, - tl: /* [] */0 - } - }; - } - if (c$4 < 0) { - return { - hd: x2, - tl: { - hd: x1, - tl: { - hd: x3, - tl: /* [] */0 - } - } - }; - } - let c$5 = cmp(x2, x3); - if (c$5 === 0) { - return { - hd: x2, - tl: { - hd: x1, - tl: /* [] */0 - } - }; - } else if (c$5 < 0) { - return { - hd: x2, - tl: { - hd: x3, - tl: { - hd: x1, - tl: /* [] */0 - } - } - }; - } else { - return { - hd: x3, - tl: { - hd: x2, - tl: { - hd: x1, - tl: /* [] */0 - } - } - }; - } - } - - } - - } - - } else if (l) { - let match$2 = l.tl; - if (match$2) { - let x2$1 = match$2.hd; - let x1$1 = l.hd; - let c$6 = cmp(x1$1, x2$1); - if (c$6 === 0) { - return { - hd: x1$1, - tl: /* [] */0 - }; - } else if (c$6 < 0) { - return { - hd: x1$1, - tl: { - hd: x2$1, - tl: /* [] */0 - } - }; - } else { - return { - hd: x2$1, - tl: { - hd: x1$1, - tl: /* [] */0 - } - }; - } - } - - } - let n1 = (n >> 1); - let n2 = n - n1 | 0; - let l2 = chop(n1, l); - let s1 = rev_sort(n1, l); - let s2 = rev_sort(n2, l2); - let _l1 = s1; - let _l2 = s2; - let _accu = /* [] */0; - while (true) { - let accu = _accu; - let l2$1 = _l2; - let l1 = _l1; - if (!l1) { - return rev_append(l2$1, accu); - } - if (!l2$1) { - return rev_append(l1, accu); - } - let t2 = l2$1.tl; - let h2 = l2$1.hd; - let t1 = l1.tl; - let h1 = l1.hd; - let c$7 = cmp(h1, h2); - if (c$7 === 0) { - _accu = { - hd: h1, - tl: accu - }; - _l2 = t2; - _l1 = t1; - continue; - } - if (c$7 > 0) { - _accu = { - hd: h1, - tl: accu - }; - _l1 = t1; - continue; - } - _accu = { - hd: h2, - tl: accu - }; - _l2 = t2; - continue; - }; - }; - let rev_sort = (n, l) => { - if (n !== 2) { - if (n === 3 && l) { - let match = l.tl; - if (match) { - let match$1 = match.tl; - if (match$1) { - let x3 = match$1.hd; - let x2 = match.hd; - let x1 = l.hd; - let c = cmp(x1, x2); - if (c === 0) { - let c$1 = cmp(x2, x3); - if (c$1 === 0) { - return { - hd: x2, - tl: /* [] */0 - }; - } else if (c$1 > 0) { - return { - hd: x2, - tl: { - hd: x3, - tl: /* [] */0 - } - }; - } else { - return { - hd: x3, - tl: { - hd: x2, - tl: /* [] */0 - } - }; - } - } - if (c > 0) { - let c$2 = cmp(x2, x3); - if (c$2 === 0) { - return { - hd: x1, - tl: { - hd: x2, - tl: /* [] */0 - } - }; - } - if (c$2 > 0) { - return { - hd: x1, - tl: { - hd: x2, - tl: { - hd: x3, - tl: /* [] */0 - } - } - }; - } - let c$3 = cmp(x1, x3); - if (c$3 === 0) { - return { - hd: x1, - tl: { - hd: x2, - tl: /* [] */0 - } - }; - } else if (c$3 > 0) { - return { - hd: x1, - tl: { - hd: x3, - tl: { - hd: x2, - tl: /* [] */0 - } - } - }; - } else { - return { - hd: x3, - tl: { - hd: x1, - tl: { - hd: x2, - tl: /* [] */0 - } - } - }; - } - } - let c$4 = cmp(x1, x3); - if (c$4 === 0) { - return { - hd: x2, - tl: { - hd: x1, - tl: /* [] */0 - } - }; - } - if (c$4 > 0) { - return { - hd: x2, - tl: { - hd: x1, - tl: { - hd: x3, - tl: /* [] */0 - } - } - }; - } - let c$5 = cmp(x2, x3); - if (c$5 === 0) { - return { - hd: x2, - tl: { - hd: x1, - tl: /* [] */0 - } - }; - } else if (c$5 > 0) { - return { - hd: x2, - tl: { - hd: x3, - tl: { - hd: x1, - tl: /* [] */0 - } - } - }; - } else { - return { - hd: x3, - tl: { - hd: x2, - tl: { - hd: x1, - tl: /* [] */0 - } - } - }; - } - } - - } - - } - - } else if (l) { - let match$2 = l.tl; - if (match$2) { - let x2$1 = match$2.hd; - let x1$1 = l.hd; - let c$6 = cmp(x1$1, x2$1); - if (c$6 === 0) { - return { - hd: x1$1, - tl: /* [] */0 - }; - } else if (c$6 > 0) { - return { - hd: x1$1, - tl: { - hd: x2$1, - tl: /* [] */0 - } - }; - } else { - return { - hd: x2$1, - tl: { - hd: x1$1, - tl: /* [] */0 - } - }; - } - } - - } - let n1 = (n >> 1); - let n2 = n - n1 | 0; - let l2 = chop(n1, l); - let s1 = sort(n1, l); - let s2 = sort(n2, l2); - let _l1 = s1; - let _l2 = s2; - let _accu = /* [] */0; - while (true) { - let accu = _accu; - let l2$1 = _l2; - let l1 = _l1; - if (!l1) { - return rev_append(l2$1, accu); - } - if (!l2$1) { - return rev_append(l1, accu); - } - let t2 = l2$1.tl; - let h2 = l2$1.hd; - let t1 = l1.tl; - let h1 = l1.hd; - let c$7 = cmp(h1, h2); - if (c$7 === 0) { - _accu = { - hd: h1, - tl: accu - }; - _l2 = t2; - _l1 = t1; - continue; - } - if (c$7 < 0) { - _accu = { - hd: h1, - tl: accu - }; - _l1 = t1; - continue; - } - _accu = { - hd: h2, - tl: accu - }; - _l2 = t2; - continue; - }; - }; - let len = length_aux(0, l); - if (len < 2) { - return l; - } else { - return sort(len, l); - } -} - -let u = Belt_List.length; - -let append = Pervasives.$at; - -let concat = flatten; - -let filter = find_all; - -let sort = stable_sort; - -let fast_sort = stable_sort; - -exports.u = u; -exports.length_aux = length_aux; -exports.length = length; -exports.hd = hd; -exports.tl = tl; -exports.nth = nth; -exports.append = append; -exports.rev_append = rev_append; -exports.rev = rev; -exports.flatten = flatten; -exports.concat = concat; -exports.map = map; -exports.mapi = mapi$1; -exports.rev_map = rev_map; -exports.iter = iter; -exports.iteri = iteri; -exports.fold_left = fold_left; -exports.fold_right = fold_right; -exports.map2 = map2; -exports.rev_map2 = rev_map2; -exports.iter2 = iter2; -exports.fold_left2 = fold_left2; -exports.fold_right2 = fold_right2; -exports.for_all = for_all; -exports.exists = exists; -exports.for_all2 = for_all2; -exports.exists2 = exists2; -exports.mem = mem; -exports.memq = memq; -exports.assoc = assoc; -exports.assq = assq; -exports.mem_assoc = mem_assoc; -exports.mem_assq = mem_assq; -exports.remove_assoc = remove_assoc; -exports.remove_assq = remove_assq; -exports.find = find; -exports.find_all = find_all; -exports.filter = filter; -exports.partition = partition; -exports.split = split; -exports.combine = combine; -exports.merge = merge; -exports.chop = chop; -exports.stable_sort = stable_sort; -exports.sort = sort; -exports.fast_sort = fast_sort; -exports.sort_uniq = sort_uniq; -/* No side effect */ diff --git a/tests/tests/src/test_list.mjs b/tests/tests/src/test_list.mjs new file mode 100644 index 0000000000..524ef92d6e --- /dev/null +++ b/tests/tests/src/test_list.mjs @@ -0,0 +1,1479 @@ +// Generated by ReScript, PLEASE EDIT WITH CARE + +import * as Belt_List from "rescript/lib/es6/Belt_List.js"; +import * as Pervasives from "rescript/lib/es6/Pervasives.js"; + +function length_aux(_len, _x) { + while (true) { + let x = _x; + let len = _len; + if (!x) { + return len; + } + _x = x.tl; + _len = len + 1 | 0; + continue; + }; +} + +function length(l) { + return length_aux(0, l); +} + +function hd(x) { + if (x) { + return x.hd; + } else { + return Pervasives.failwith("hd"); + } +} + +function tl(x) { + if (x) { + return x.tl; + } else { + return Pervasives.failwith("tl"); + } +} + +function nth(l, n) { + if (n < 0) { + return Pervasives.invalid_arg("List.nth"); + } + let _l = l; + let _n = n; + while (true) { + let n$1 = _n; + let l$1 = _l; + if (!l$1) { + return Pervasives.failwith("nth"); + } + if (n$1 === 0) { + return l$1.hd; + } + _n = n$1 - 1 | 0; + _l = l$1.tl; + continue; + }; +} + +function rev_append(_l1, _l2) { + while (true) { + let l2 = _l2; + let l1 = _l1; + if (!l1) { + return l2; + } + _l2 = { + hd: l1.hd, + tl: l2 + }; + _l1 = l1.tl; + continue; + }; +} + +function rev(l) { + return rev_append(l, /* [] */0); +} + +function flatten(x) { + if (x) { + return Pervasives.$at(x.hd, flatten(x.tl)); + } else { + return /* [] */0; + } +} + +function map(f, x) { + if (!x) { + return /* [] */0; + } + let r = f(x.hd); + return { + hd: r, + tl: map(f, x.tl) + }; +} + +function mapi(i, f, x) { + if (!x) { + return /* [] */0; + } + let r = f(i, x.hd); + return { + hd: r, + tl: mapi(i + 1 | 0, f, x.tl) + }; +} + +function mapi$1(f, l) { + return mapi(0, f, l); +} + +function rev_map(f, l) { + let _accu = /* [] */0; + let _x = l; + while (true) { + let x = _x; + let accu = _accu; + if (!x) { + return accu; + } + _x = x.tl; + _accu = { + hd: f(x.hd), + tl: accu + }; + continue; + }; +} + +function iter(f, _x) { + while (true) { + let x = _x; + if (!x) { + return; + } + f(x.hd); + _x = x.tl; + continue; + }; +} + +function iteri(f, l) { + let _i = 0; + let _x = l; + while (true) { + let x = _x; + let i = _i; + if (!x) { + return; + } + f(i, x.hd); + _x = x.tl; + _i = i + 1 | 0; + continue; + }; +} + +function fold_left(f, _accu, _l) { + while (true) { + let l = _l; + let accu = _accu; + if (!l) { + return accu; + } + _l = l.tl; + _accu = f(accu, l.hd); + continue; + }; +} + +function fold_right(f, l, accu) { + if (l) { + return f(l.hd, fold_right(f, l.tl, accu)); + } else { + return accu; + } +} + +function map2(f, l1, l2) { + if (!l1) { + if (l2) { + return Pervasives.invalid_arg("List.map2"); + } else { + return /* [] */0; + } + } + if (!l2) { + return Pervasives.invalid_arg("List.map2"); + } + let r = f(l1.hd, l2.hd); + return { + hd: r, + tl: map2(f, l1.tl, l2.tl) + }; +} + +function rev_map2(f, l1, l2) { + let _accu = /* [] */0; + let _l1 = l1; + let _l2 = l2; + while (true) { + let l2$1 = _l2; + let l1$1 = _l1; + let accu = _accu; + if (!l1$1) { + if (l2$1) { + return Pervasives.invalid_arg("List.rev_map2"); + } else { + return accu; + } + } + if (!l2$1) { + return Pervasives.invalid_arg("List.rev_map2"); + } + _l2 = l2$1.tl; + _l1 = l1$1.tl; + _accu = { + hd: f(l1$1.hd, l2$1.hd), + tl: accu + }; + continue; + }; +} + +function iter2(f, _l1, _l2) { + while (true) { + let l2 = _l2; + let l1 = _l1; + if (!l1) { + if (l2) { + return Pervasives.invalid_arg("List.iter2"); + } else { + return; + } + } + if (!l2) { + return Pervasives.invalid_arg("List.iter2"); + } + f(l1.hd, l2.hd); + _l2 = l2.tl; + _l1 = l1.tl; + continue; + }; +} + +function fold_left2(f, _accu, _l1, _l2) { + while (true) { + let l2 = _l2; + let l1 = _l1; + let accu = _accu; + if (!l1) { + if (l2) { + return Pervasives.invalid_arg("List.fold_left2"); + } else { + return accu; + } + } + if (!l2) { + return Pervasives.invalid_arg("List.fold_left2"); + } + _l2 = l2.tl; + _l1 = l1.tl; + _accu = f(accu, l1.hd, l2.hd); + continue; + }; +} + +function fold_right2(f, l1, l2, accu) { + if (l1) { + if (l2) { + return f(l1.hd, l2.hd, fold_right2(f, l1.tl, l2.tl, accu)); + } else { + return Pervasives.invalid_arg("List.fold_right2"); + } + } else if (l2) { + return Pervasives.invalid_arg("List.fold_right2"); + } else { + return accu; + } +} + +function for_all(p, _x) { + while (true) { + let x = _x; + if (!x) { + return true; + } + if (!p(x.hd)) { + return false; + } + _x = x.tl; + continue; + }; +} + +function exists(p, _x) { + while (true) { + let x = _x; + if (!x) { + return false; + } + if (p(x.hd)) { + return true; + } + _x = x.tl; + continue; + }; +} + +function for_all2(p, _l1, _l2) { + while (true) { + let l2 = _l2; + let l1 = _l1; + if (!l1) { + if (l2) { + return Pervasives.invalid_arg("List.for_all2"); + } else { + return true; + } + } + if (!l2) { + return Pervasives.invalid_arg("List.for_all2"); + } + if (!p(l1.hd, l2.hd)) { + return false; + } + _l2 = l2.tl; + _l1 = l1.tl; + continue; + }; +} + +function exists2(p, _l1, _l2) { + while (true) { + let l2 = _l2; + let l1 = _l1; + if (!l1) { + if (l2) { + return Pervasives.invalid_arg("List.exists2"); + } else { + return false; + } + } + if (!l2) { + return Pervasives.invalid_arg("List.exists2"); + } + if (p(l1.hd, l2.hd)) { + return true; + } + _l2 = l2.tl; + _l1 = l1.tl; + continue; + }; +} + +function mem(x, _x_) { + while (true) { + let x_ = _x_; + if (!x_) { + return false; + } + if (x_.hd === x) { + return true; + } + _x_ = x_.tl; + continue; + }; +} + +function memq(x, _x_) { + while (true) { + let x_ = _x_; + if (!x_) { + return false; + } + if (x_.hd === x) { + return true; + } + _x_ = x_.tl; + continue; + }; +} + +function assoc(x, _x_) { + while (true) { + let x_ = _x_; + if (x_) { + let match = x_.hd; + if (match[0] === x) { + return match[1]; + } + _x_ = x_.tl; + continue; + } + throw { + RE_EXN_ID: "Not_found", + Error: new Error() + }; + }; +} + +function assq(x, _x_) { + while (true) { + let x_ = _x_; + if (x_) { + let match = x_.hd; + if (match[0] === x) { + return match[1]; + } + _x_ = x_.tl; + continue; + } + throw { + RE_EXN_ID: "Not_found", + Error: new Error() + }; + }; +} + +function mem_assoc(x, _x_) { + while (true) { + let x_ = _x_; + if (!x_) { + return false; + } + if (x_.hd[0] === x) { + return true; + } + _x_ = x_.tl; + continue; + }; +} + +function mem_assq(x, _x_) { + while (true) { + let x_ = _x_; + if (!x_) { + return false; + } + if (x_.hd[0] === x) { + return true; + } + _x_ = x_.tl; + continue; + }; +} + +function remove_assoc(x, x_) { + if (!x_) { + return /* [] */0; + } + let l = x_.tl; + let pair = x_.hd; + if (pair[0] === x) { + return l; + } else { + return { + hd: pair, + tl: remove_assoc(x, l) + }; + } +} + +function remove_assq(x, x_) { + if (!x_) { + return /* [] */0; + } + let l = x_.tl; + let pair = x_.hd; + if (pair[0] === x) { + return l; + } else { + return { + hd: pair, + tl: remove_assq(x, l) + }; + } +} + +function find(p, _x) { + while (true) { + let x = _x; + if (x) { + let x$1 = x.hd; + if (p(x$1)) { + return x$1; + } + _x = x.tl; + continue; + } + throw { + RE_EXN_ID: "Not_found", + Error: new Error() + }; + }; +} + +function find_all(p) { + return __x => { + let _accu = /* [] */0; + let _x = __x; + while (true) { + let x = _x; + let accu = _accu; + if (!x) { + return rev_append(accu, /* [] */0); + } + let l = x.tl; + let x$1 = x.hd; + if (p(x$1)) { + _x = l; + _accu = { + hd: x$1, + tl: accu + }; + continue; + } + _x = l; + continue; + }; + }; +} + +function partition(p, l) { + let _yes = /* [] */0; + let _no = /* [] */0; + let _x = l; + while (true) { + let x = _x; + let no = _no; + let yes = _yes; + if (!x) { + return [ + rev_append(yes, /* [] */0), + rev_append(no, /* [] */0) + ]; + } + let l$1 = x.tl; + let x$1 = x.hd; + if (p(x$1)) { + _x = l$1; + _yes = { + hd: x$1, + tl: yes + }; + continue; + } + _x = l$1; + _no = { + hd: x$1, + tl: no + }; + continue; + }; +} + +function split(x) { + if (!x) { + return [ + /* [] */0, + /* [] */0 + ]; + } + let match = x.hd; + let match$1 = split(x.tl); + return [ + { + hd: match[0], + tl: match$1[0] + }, + { + hd: match[1], + tl: match$1[1] + } + ]; +} + +function combine(l1, l2) { + if (l1) { + if (l2) { + return { + hd: [ + l1.hd, + l2.hd + ], + tl: combine(l1.tl, l2.tl) + }; + } else { + return Pervasives.invalid_arg("List.combine"); + } + } else if (l2) { + return Pervasives.invalid_arg("List.combine"); + } else { + return /* [] */0; + } +} + +function merge(cmp, l1, l2) { + if (!l1) { + return l2; + } + if (!l2) { + return l1; + } + let h2 = l2.hd; + let h1 = l1.hd; + if (cmp(h1, h2) <= 0) { + return { + hd: h1, + tl: merge(cmp, l1.tl, l2) + }; + } else { + return { + hd: h2, + tl: merge(cmp, l1, l2.tl) + }; + } +} + +function chop(_k, _l) { + while (true) { + let l = _l; + let k = _k; + if (k === 0) { + return l; + } + if (l) { + _l = l.tl; + _k = k - 1 | 0; + continue; + } + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "test_list.res", + 343, + 11 + ], + Error: new Error() + }; + }; +} + +function stable_sort(cmp, l) { + let sort = (n, l) => { + if (n !== 2) { + if (n === 3 && l) { + let match = l.tl; + if (match) { + let match$1 = match.tl; + if (match$1) { + let x3 = match$1.hd; + let x2 = match.hd; + let x1 = l.hd; + if (cmp(x1, x2) <= 0) { + if (cmp(x2, x3) <= 0) { + return { + hd: x1, + tl: { + hd: x2, + tl: { + hd: x3, + tl: /* [] */0 + } + } + }; + } else if (cmp(x1, x3) <= 0) { + return { + hd: x1, + tl: { + hd: x3, + tl: { + hd: x2, + tl: /* [] */0 + } + } + }; + } else { + return { + hd: x3, + tl: { + hd: x1, + tl: { + hd: x2, + tl: /* [] */0 + } + } + }; + } + } else if (cmp(x1, x3) <= 0) { + return { + hd: x2, + tl: { + hd: x1, + tl: { + hd: x3, + tl: /* [] */0 + } + } + }; + } else if (cmp(x2, x3) <= 0) { + return { + hd: x2, + tl: { + hd: x3, + tl: { + hd: x1, + tl: /* [] */0 + } + } + }; + } else { + return { + hd: x3, + tl: { + hd: x2, + tl: { + hd: x1, + tl: /* [] */0 + } + } + }; + } + } + + } + + } + + } else if (l) { + let match$2 = l.tl; + if (match$2) { + let x2$1 = match$2.hd; + let x1$1 = l.hd; + if (cmp(x1$1, x2$1) <= 0) { + return { + hd: x1$1, + tl: { + hd: x2$1, + tl: /* [] */0 + } + }; + } else { + return { + hd: x2$1, + tl: { + hd: x1$1, + tl: /* [] */0 + } + }; + } + } + + } + let n1 = (n >> 1); + let n2 = n - n1 | 0; + let l2 = chop(n1, l); + let s1 = rev_sort(n1, l); + let s2 = rev_sort(n2, l2); + let _l1 = s1; + let _l2 = s2; + let _accu = /* [] */0; + while (true) { + let accu = _accu; + let l2$1 = _l2; + let l1 = _l1; + if (!l1) { + return rev_append(l2$1, accu); + } + if (!l2$1) { + return rev_append(l1, accu); + } + let h2 = l2$1.hd; + let h1 = l1.hd; + if (cmp(h1, h2) > 0) { + _accu = { + hd: h1, + tl: accu + }; + _l1 = l1.tl; + continue; + } + _accu = { + hd: h2, + tl: accu + }; + _l2 = l2$1.tl; + continue; + }; + }; + let rev_sort = (n, l) => { + if (n !== 2) { + if (n === 3 && l) { + let match = l.tl; + if (match) { + let match$1 = match.tl; + if (match$1) { + let x3 = match$1.hd; + let x2 = match.hd; + let x1 = l.hd; + if (cmp(x1, x2) > 0) { + if (cmp(x2, x3) > 0) { + return { + hd: x1, + tl: { + hd: x2, + tl: { + hd: x3, + tl: /* [] */0 + } + } + }; + } else if (cmp(x1, x3) > 0) { + return { + hd: x1, + tl: { + hd: x3, + tl: { + hd: x2, + tl: /* [] */0 + } + } + }; + } else { + return { + hd: x3, + tl: { + hd: x1, + tl: { + hd: x2, + tl: /* [] */0 + } + } + }; + } + } else if (cmp(x1, x3) > 0) { + return { + hd: x2, + tl: { + hd: x1, + tl: { + hd: x3, + tl: /* [] */0 + } + } + }; + } else if (cmp(x2, x3) > 0) { + return { + hd: x2, + tl: { + hd: x3, + tl: { + hd: x1, + tl: /* [] */0 + } + } + }; + } else { + return { + hd: x3, + tl: { + hd: x2, + tl: { + hd: x1, + tl: /* [] */0 + } + } + }; + } + } + + } + + } + + } else if (l) { + let match$2 = l.tl; + if (match$2) { + let x2$1 = match$2.hd; + let x1$1 = l.hd; + if (cmp(x1$1, x2$1) > 0) { + return { + hd: x1$1, + tl: { + hd: x2$1, + tl: /* [] */0 + } + }; + } else { + return { + hd: x2$1, + tl: { + hd: x1$1, + tl: /* [] */0 + } + }; + } + } + + } + let n1 = (n >> 1); + let n2 = n - n1 | 0; + let l2 = chop(n1, l); + let s1 = sort(n1, l); + let s2 = sort(n2, l2); + let _l1 = s1; + let _l2 = s2; + let _accu = /* [] */0; + while (true) { + let accu = _accu; + let l2$1 = _l2; + let l1 = _l1; + if (!l1) { + return rev_append(l2$1, accu); + } + if (!l2$1) { + return rev_append(l1, accu); + } + let h2 = l2$1.hd; + let h1 = l1.hd; + if (cmp(h1, h2) <= 0) { + _accu = { + hd: h1, + tl: accu + }; + _l1 = l1.tl; + continue; + } + _accu = { + hd: h2, + tl: accu + }; + _l2 = l2$1.tl; + continue; + }; + }; + let len = length_aux(0, l); + if (len < 2) { + return l; + } else { + return sort(len, l); + } +} + +function sort_uniq(cmp, l) { + let sort = (n, l) => { + if (n !== 2) { + if (n === 3 && l) { + let match = l.tl; + if (match) { + let match$1 = match.tl; + if (match$1) { + let x3 = match$1.hd; + let x2 = match.hd; + let x1 = l.hd; + let c = cmp(x1, x2); + if (c === 0) { + let c$1 = cmp(x2, x3); + if (c$1 === 0) { + return { + hd: x2, + tl: /* [] */0 + }; + } else if (c$1 < 0) { + return { + hd: x2, + tl: { + hd: x3, + tl: /* [] */0 + } + }; + } else { + return { + hd: x3, + tl: { + hd: x2, + tl: /* [] */0 + } + }; + } + } + if (c < 0) { + let c$2 = cmp(x2, x3); + if (c$2 === 0) { + return { + hd: x1, + tl: { + hd: x2, + tl: /* [] */0 + } + }; + } + if (c$2 < 0) { + return { + hd: x1, + tl: { + hd: x2, + tl: { + hd: x3, + tl: /* [] */0 + } + } + }; + } + let c$3 = cmp(x1, x3); + if (c$3 === 0) { + return { + hd: x1, + tl: { + hd: x2, + tl: /* [] */0 + } + }; + } else if (c$3 < 0) { + return { + hd: x1, + tl: { + hd: x3, + tl: { + hd: x2, + tl: /* [] */0 + } + } + }; + } else { + return { + hd: x3, + tl: { + hd: x1, + tl: { + hd: x2, + tl: /* [] */0 + } + } + }; + } + } + let c$4 = cmp(x1, x3); + if (c$4 === 0) { + return { + hd: x2, + tl: { + hd: x1, + tl: /* [] */0 + } + }; + } + if (c$4 < 0) { + return { + hd: x2, + tl: { + hd: x1, + tl: { + hd: x3, + tl: /* [] */0 + } + } + }; + } + let c$5 = cmp(x2, x3); + if (c$5 === 0) { + return { + hd: x2, + tl: { + hd: x1, + tl: /* [] */0 + } + }; + } else if (c$5 < 0) { + return { + hd: x2, + tl: { + hd: x3, + tl: { + hd: x1, + tl: /* [] */0 + } + } + }; + } else { + return { + hd: x3, + tl: { + hd: x2, + tl: { + hd: x1, + tl: /* [] */0 + } + } + }; + } + } + + } + + } + + } else if (l) { + let match$2 = l.tl; + if (match$2) { + let x2$1 = match$2.hd; + let x1$1 = l.hd; + let c$6 = cmp(x1$1, x2$1); + if (c$6 === 0) { + return { + hd: x1$1, + tl: /* [] */0 + }; + } else if (c$6 < 0) { + return { + hd: x1$1, + tl: { + hd: x2$1, + tl: /* [] */0 + } + }; + } else { + return { + hd: x2$1, + tl: { + hd: x1$1, + tl: /* [] */0 + } + }; + } + } + + } + let n1 = (n >> 1); + let n2 = n - n1 | 0; + let l2 = chop(n1, l); + let s1 = rev_sort(n1, l); + let s2 = rev_sort(n2, l2); + let _l1 = s1; + let _l2 = s2; + let _accu = /* [] */0; + while (true) { + let accu = _accu; + let l2$1 = _l2; + let l1 = _l1; + if (!l1) { + return rev_append(l2$1, accu); + } + if (!l2$1) { + return rev_append(l1, accu); + } + let t2 = l2$1.tl; + let h2 = l2$1.hd; + let t1 = l1.tl; + let h1 = l1.hd; + let c$7 = cmp(h1, h2); + if (c$7 === 0) { + _accu = { + hd: h1, + tl: accu + }; + _l2 = t2; + _l1 = t1; + continue; + } + if (c$7 > 0) { + _accu = { + hd: h1, + tl: accu + }; + _l1 = t1; + continue; + } + _accu = { + hd: h2, + tl: accu + }; + _l2 = t2; + continue; + }; + }; + let rev_sort = (n, l) => { + if (n !== 2) { + if (n === 3 && l) { + let match = l.tl; + if (match) { + let match$1 = match.tl; + if (match$1) { + let x3 = match$1.hd; + let x2 = match.hd; + let x1 = l.hd; + let c = cmp(x1, x2); + if (c === 0) { + let c$1 = cmp(x2, x3); + if (c$1 === 0) { + return { + hd: x2, + tl: /* [] */0 + }; + } else if (c$1 > 0) { + return { + hd: x2, + tl: { + hd: x3, + tl: /* [] */0 + } + }; + } else { + return { + hd: x3, + tl: { + hd: x2, + tl: /* [] */0 + } + }; + } + } + if (c > 0) { + let c$2 = cmp(x2, x3); + if (c$2 === 0) { + return { + hd: x1, + tl: { + hd: x2, + tl: /* [] */0 + } + }; + } + if (c$2 > 0) { + return { + hd: x1, + tl: { + hd: x2, + tl: { + hd: x3, + tl: /* [] */0 + } + } + }; + } + let c$3 = cmp(x1, x3); + if (c$3 === 0) { + return { + hd: x1, + tl: { + hd: x2, + tl: /* [] */0 + } + }; + } else if (c$3 > 0) { + return { + hd: x1, + tl: { + hd: x3, + tl: { + hd: x2, + tl: /* [] */0 + } + } + }; + } else { + return { + hd: x3, + tl: { + hd: x1, + tl: { + hd: x2, + tl: /* [] */0 + } + } + }; + } + } + let c$4 = cmp(x1, x3); + if (c$4 === 0) { + return { + hd: x2, + tl: { + hd: x1, + tl: /* [] */0 + } + }; + } + if (c$4 > 0) { + return { + hd: x2, + tl: { + hd: x1, + tl: { + hd: x3, + tl: /* [] */0 + } + } + }; + } + let c$5 = cmp(x2, x3); + if (c$5 === 0) { + return { + hd: x2, + tl: { + hd: x1, + tl: /* [] */0 + } + }; + } else if (c$5 > 0) { + return { + hd: x2, + tl: { + hd: x3, + tl: { + hd: x1, + tl: /* [] */0 + } + } + }; + } else { + return { + hd: x3, + tl: { + hd: x2, + tl: { + hd: x1, + tl: /* [] */0 + } + } + }; + } + } + + } + + } + + } else if (l) { + let match$2 = l.tl; + if (match$2) { + let x2$1 = match$2.hd; + let x1$1 = l.hd; + let c$6 = cmp(x1$1, x2$1); + if (c$6 === 0) { + return { + hd: x1$1, + tl: /* [] */0 + }; + } else if (c$6 > 0) { + return { + hd: x1$1, + tl: { + hd: x2$1, + tl: /* [] */0 + } + }; + } else { + return { + hd: x2$1, + tl: { + hd: x1$1, + tl: /* [] */0 + } + }; + } + } + + } + let n1 = (n >> 1); + let n2 = n - n1 | 0; + let l2 = chop(n1, l); + let s1 = sort(n1, l); + let s2 = sort(n2, l2); + let _l1 = s1; + let _l2 = s2; + let _accu = /* [] */0; + while (true) { + let accu = _accu; + let l2$1 = _l2; + let l1 = _l1; + if (!l1) { + return rev_append(l2$1, accu); + } + if (!l2$1) { + return rev_append(l1, accu); + } + let t2 = l2$1.tl; + let h2 = l2$1.hd; + let t1 = l1.tl; + let h1 = l1.hd; + let c$7 = cmp(h1, h2); + if (c$7 === 0) { + _accu = { + hd: h1, + tl: accu + }; + _l2 = t2; + _l1 = t1; + continue; + } + if (c$7 < 0) { + _accu = { + hd: h1, + tl: accu + }; + _l1 = t1; + continue; + } + _accu = { + hd: h2, + tl: accu + }; + _l2 = t2; + continue; + }; + }; + let len = length_aux(0, l); + if (len < 2) { + return l; + } else { + return sort(len, l); + } +} + +let u = Belt_List.length; + +let append = Pervasives.$at; + +let concat = flatten; + +let filter = find_all; + +let sort = stable_sort; + +let fast_sort = stable_sort; + +export { + u, + length_aux, + length, + hd, + tl, + nth, + append, + rev_append, + rev, + flatten, + concat, + map, + mapi$1 as mapi, + rev_map, + iter, + iteri, + fold_left, + fold_right, + map2, + rev_map2, + iter2, + fold_left2, + fold_right2, + for_all, + exists, + for_all2, + exists2, + mem, + memq, + assoc, + assq, + mem_assoc, + mem_assq, + remove_assoc, + remove_assq, + find, + find_all, + filter, + partition, + split, + combine, + merge, + chop, + stable_sort, + sort, + fast_sort, + sort_uniq, +} +/* No side effect */ diff --git a/tests/tests/src/test_literal.js b/tests/tests/src/test_literal.js deleted file mode 100644 index 3692350d4e..0000000000 --- a/tests/tests/src/test_literal.js +++ /dev/null @@ -1,49 +0,0 @@ -// Generated by ReScript, PLEASE EDIT WITH CARE -'use strict'; - -let Primitive_exceptions = require("rescript/lib/js/Primitive_exceptions.js"); - -let Custom_inline = /* @__PURE__ */Primitive_exceptions.create("Test_literal.Custom_inline"); - -let v = { - RE_EXN_ID: Custom_inline, - _1: 1, - _2: 2 -}; - -let vv = [ - 1, - 2, - 3 -]; - -let long_v = [ - 1, - 2, - 3, - 4, - 5, - 6 -]; - -let long_int_v = [ - 1, - 2, - 3, - 4, - 5, - 6 -]; - -let short_int_v = [1]; - -let empty = []; - -exports.Custom_inline = Custom_inline; -exports.v = v; -exports.vv = vv; -exports.long_v = long_v; -exports.long_int_v = long_int_v; -exports.short_int_v = short_int_v; -exports.empty = empty; -/* No side effect */ diff --git a/tests/tests/src/test_literal.mjs b/tests/tests/src/test_literal.mjs new file mode 100644 index 0000000000..3cf19ad48f --- /dev/null +++ b/tests/tests/src/test_literal.mjs @@ -0,0 +1,50 @@ +// Generated by ReScript, PLEASE EDIT WITH CARE + +import * as Primitive_exceptions from "rescript/lib/es6/Primitive_exceptions.js"; + +let Custom_inline = /* @__PURE__ */Primitive_exceptions.create("Test_literal.Custom_inline"); + +let v = { + RE_EXN_ID: Custom_inline, + _1: 1, + _2: 2 +}; + +let vv = [ + 1, + 2, + 3 +]; + +let long_v = [ + 1, + 2, + 3, + 4, + 5, + 6 +]; + +let long_int_v = [ + 1, + 2, + 3, + 4, + 5, + 6 +]; + +let short_int_v = [1]; + +let empty = []; + +export { + Custom_inline, + v, + vv, + long_v, + long_int_v, + short_int_v, + empty, +} +/* No side effect */ diff --git a/tests/tests/src/test_literals.js b/tests/tests/src/test_literals.js deleted file mode 100644 index 6497150fe4..0000000000 --- a/tests/tests/src/test_literals.js +++ /dev/null @@ -1,14 +0,0 @@ -// Generated by ReScript, PLEASE EDIT WITH CARE -'use strict'; - - -let node_modules_length = "node_modules".length; - -let node_modules = "node_modules"; - -let bsconfig_json = "bsconfig.json"; - -exports.node_modules = node_modules; -exports.node_modules_length = node_modules_length; -exports.bsconfig_json = bsconfig_json; -/* node_modules_length Not a pure module */ diff --git a/tests/tests/src/test_literals.mjs b/tests/tests/src/test_literals.mjs new file mode 100644 index 0000000000..4554d9b062 --- /dev/null +++ b/tests/tests/src/test_literals.mjs @@ -0,0 +1,15 @@ +// Generated by ReScript, PLEASE EDIT WITH CARE + + +let node_modules_length = "node_modules".length; + +let node_modules = "node_modules"; + +let bsconfig_json = "bsconfig.json"; + +export { + node_modules, + node_modules_length, + bsconfig_json, +} +/* node_modules_length Not a pure module */ diff --git a/tests/tests/src/test_match_exception.js b/tests/tests/src/test_match_exception.js deleted file mode 100644 index fbae443577..0000000000 --- a/tests/tests/src/test_match_exception.js +++ /dev/null @@ -1,19 +0,0 @@ -// Generated by ReScript, PLEASE EDIT WITH CARE -'use strict'; - -let Primitive_exceptions = require("rescript/lib/js/Primitive_exceptions.js"); - -function f(g, x) { - try { - return g(x); - } catch (raw_exn) { - let exn = Primitive_exceptions.internalToException(raw_exn); - if (exn.RE_EXN_ID === "Not_found") { - return 3; - } - throw exn; - } -} - -exports.f = f; -/* No side effect */ diff --git a/tests/tests/src/test_match_exception.mjs b/tests/tests/src/test_match_exception.mjs new file mode 100644 index 0000000000..7c53a518f6 --- /dev/null +++ b/tests/tests/src/test_match_exception.mjs @@ -0,0 +1,20 @@ +// Generated by ReScript, PLEASE EDIT WITH CARE + +import * as Primitive_exceptions from "rescript/lib/es6/Primitive_exceptions.js"; + +function f(g, x) { + try { + return g(x); + } catch (raw_exn) { + let exn = Primitive_exceptions.internalToException(raw_exn); + if (exn.RE_EXN_ID === "Not_found") { + return 3; + } + throw exn; + } +} + +export { + f, +} +/* No side effect */ diff --git a/tests/tests/src/test_nested_let.js b/tests/tests/src/test_nested_let.js deleted file mode 100644 index 8c54d12d6e..0000000000 --- a/tests/tests/src/test_nested_let.js +++ /dev/null @@ -1,8 +0,0 @@ -// Generated by ReScript, PLEASE EDIT WITH CARE -'use strict'; - - -let v = 68; - -exports.v = v; -/* No side effect */ diff --git a/tests/tests/src/test_nested_let.mjs b/tests/tests/src/test_nested_let.mjs new file mode 100644 index 0000000000..a010359412 --- /dev/null +++ b/tests/tests/src/test_nested_let.mjs @@ -0,0 +1,9 @@ +// Generated by ReScript, PLEASE EDIT WITH CARE + + +let v = 68; + +export { + v, +} +/* No side effect */ diff --git a/tests/tests/src/test_nested_print.js b/tests/tests/src/test_nested_print.js deleted file mode 100644 index d74ed08696..0000000000 --- a/tests/tests/src/test_nested_print.js +++ /dev/null @@ -1,16 +0,0 @@ -// Generated by ReScript, PLEASE EDIT WITH CARE -'use strict'; - - -function u(x, x$1) { - return x$1 + x$1 | 0; -} - -function f(g, x) { - let u = g(x); - return u + u | 0; -} - -exports.u = u; -exports.f = f; -/* No side effect */ diff --git a/tests/tests/src/test_nested_print.mjs b/tests/tests/src/test_nested_print.mjs new file mode 100644 index 0000000000..70a78d7dc1 --- /dev/null +++ b/tests/tests/src/test_nested_print.mjs @@ -0,0 +1,17 @@ +// Generated by ReScript, PLEASE EDIT WITH CARE + + +function u(x, x$1) { + return x$1 + x$1 | 0; +} + +function f(g, x) { + let u = g(x); + return u + u | 0; +} + +export { + u, + f, +} +/* No side effect */ diff --git a/tests/tests/src/test_non_export.js b/tests/tests/src/test_non_export.js deleted file mode 100644 index d5f7e2fcca..0000000000 --- a/tests/tests/src/test_non_export.js +++ /dev/null @@ -1,10 +0,0 @@ -// Generated by ReScript, PLEASE EDIT WITH CARE -'use strict'; - - -function Make(U) { - return U; -} - -exports.Make = Make; -/* No side effect */ diff --git a/tests/tests/src/test_non_export.mjs b/tests/tests/src/test_non_export.mjs new file mode 100644 index 0000000000..b64b18e493 --- /dev/null +++ b/tests/tests/src/test_non_export.mjs @@ -0,0 +1,11 @@ +// Generated by ReScript, PLEASE EDIT WITH CARE + + +function Make(U) { + return U; +} + +export { + Make, +} +/* No side effect */ diff --git a/tests/tests/src/test_nullary.js b/tests/tests/src/test_nullary.js deleted file mode 100644 index 286a047190..0000000000 --- a/tests/tests/src/test_nullary.js +++ /dev/null @@ -1,10 +0,0 @@ -// Generated by ReScript, PLEASE EDIT WITH CARE -'use strict'; - - -function f(param) { - console.log("hey"); -} - -exports.f = f; -/* No side effect */ diff --git a/tests/tests/src/test_nullary.mjs b/tests/tests/src/test_nullary.mjs new file mode 100644 index 0000000000..d07e33961f --- /dev/null +++ b/tests/tests/src/test_nullary.mjs @@ -0,0 +1,11 @@ +// Generated by ReScript, PLEASE EDIT WITH CARE + + +function f(param) { + console.log("hey"); +} + +export { + f, +} +/* No side effect */ diff --git a/tests/tests/src/test_obj.js b/tests/tests/src/test_obj.js deleted file mode 100644 index e34804b1aa..0000000000 --- a/tests/tests/src/test_obj.js +++ /dev/null @@ -1,10 +0,0 @@ -// Generated by ReScript, PLEASE EDIT WITH CARE -'use strict'; - - -function f(x) { - return x.say_hi; -} - -exports.f = f; -/* No side effect */ diff --git a/tests/tests/src/test_obj.mjs b/tests/tests/src/test_obj.mjs new file mode 100644 index 0000000000..fe4548bdf6 --- /dev/null +++ b/tests/tests/src/test_obj.mjs @@ -0,0 +1,11 @@ +// Generated by ReScript, PLEASE EDIT WITH CARE + + +function f(x) { + return x.say_hi; +} + +export { + f, +} +/* No side effect */ diff --git a/tests/tests/src/test_order.js b/tests/tests/src/test_order.js deleted file mode 100644 index 22b0bbc33e..0000000000 --- a/tests/tests/src/test_order.js +++ /dev/null @@ -1,9 +0,0 @@ -// Generated by ReScript, PLEASE EDIT WITH CARE -'use strict'; - -let Primitive_int = require("rescript/lib/js/Primitive_int.js"); - -let compare = Primitive_int.compare; - -exports.compare = compare; -/* No side effect */ diff --git a/tests/tests/src/test_order.mjs b/tests/tests/src/test_order.mjs new file mode 100644 index 0000000000..8e8f756279 --- /dev/null +++ b/tests/tests/src/test_order.mjs @@ -0,0 +1,10 @@ +// Generated by ReScript, PLEASE EDIT WITH CARE + +import * as Primitive_int from "rescript/lib/es6/Primitive_int.js"; + +let compare = Primitive_int.compare; + +export { + compare, +} +/* No side effect */ diff --git a/tests/tests/src/test_order_tailcall.js b/tests/tests/src/test_order_tailcall.js deleted file mode 100644 index a19ffd551a..0000000000 --- a/tests/tests/src/test_order_tailcall.js +++ /dev/null @@ -1,112 +0,0 @@ -// Generated by ReScript, PLEASE EDIT WITH CARE -'use strict'; - - -function f(_x, _y) { - while (true) { - let y = _y; - let x = _x; - _y = x; - _x = y; - continue; - }; -} - -function f1(_x, _y, _z) { - while (true) { - let z = _z; - let y = _y; - let x = _x; - console.log(z); - _z = x; - _y = z; - _x = y; - continue; - }; -} - -function f2(x, _y) { - while (true) { - let y = _y; - _y = y + 10 | 0; - continue; - }; -} - -function f3(_x, _y) { - while (true) { - let y = _y; - let x = _x; - _y = x + 10 | 0; - _x = y; - continue; - }; -} - -function f4(_x, _y) { - while (true) { - let y = _y; - let x = _x; - _y = y + x | 0; - _x = x + 10 | 0; - continue; - }; -} - -function f5(_x, _y, z) { - while (true) { - let y = _y; - _y = z + 20 | 0; - _x = y + 10 | 0; - continue; - }; -} - -function f6(b) { - while (true) { - if (!b) { - return false; - } - continue; - }; -} - -function f7(b) { - while (true) { - if (b) { - return true; - } - continue; - }; -} - -function f8(_x, _y) { - while (true) { - let y = _y; - let x = _x; - if (x > 10) { - _y = y + 1 | 0; - continue; - } - if (x < 5) { - _x = x - 1 | 0; - continue; - } - if (x <= 6) { - return f8(x, y + 1 | 0) + f8(x - 1 | 0, y) | 0; - } - _x = x - 2 | 0; - continue; - }; -} - -exports.f = f; -exports.f1 = f1; -exports.f2 = f2; -exports.f3 = f3; -exports.f4 = f4; -exports.f5 = f5; -exports.f6 = f6; -exports.f7 = f7; -exports.f8 = f8; -/* No side effect */ diff --git a/tests/tests/src/test_order_tailcall.mjs b/tests/tests/src/test_order_tailcall.mjs new file mode 100644 index 0000000000..dc36b87bd1 --- /dev/null +++ b/tests/tests/src/test_order_tailcall.mjs @@ -0,0 +1,113 @@ +// Generated by ReScript, PLEASE EDIT WITH CARE + + +function f(_x, _y) { + while (true) { + let y = _y; + let x = _x; + _y = x; + _x = y; + continue; + }; +} + +function f1(_x, _y, _z) { + while (true) { + let z = _z; + let y = _y; + let x = _x; + console.log(z); + _z = x; + _y = z; + _x = y; + continue; + }; +} + +function f2(x, _y) { + while (true) { + let y = _y; + _y = y + 10 | 0; + continue; + }; +} + +function f3(_x, _y) { + while (true) { + let y = _y; + let x = _x; + _y = x + 10 | 0; + _x = y; + continue; + }; +} + +function f4(_x, _y) { + while (true) { + let y = _y; + let x = _x; + _y = y + x | 0; + _x = x + 10 | 0; + continue; + }; +} + +function f5(_x, _y, z) { + while (true) { + let y = _y; + _y = z + 20 | 0; + _x = y + 10 | 0; + continue; + }; +} + +function f6(b) { + while (true) { + if (!b) { + return false; + } + continue; + }; +} + +function f7(b) { + while (true) { + if (b) { + return true; + } + continue; + }; +} + +function f8(_x, _y) { + while (true) { + let y = _y; + let x = _x; + if (x > 10) { + _y = y + 1 | 0; + continue; + } + if (x < 5) { + _x = x - 1 | 0; + continue; + } + if (x <= 6) { + return f8(x, y + 1 | 0) + f8(x - 1 | 0, y) | 0; + } + _x = x - 2 | 0; + continue; + }; +} + +export { + f, + f1, + f2, + f3, + f4, + f5, + f6, + f7, + f8, +} +/* No side effect */ diff --git a/tests/tests/src/test_other_exn.js b/tests/tests/src/test_other_exn.js deleted file mode 100644 index b7f43166b4..0000000000 --- a/tests/tests/src/test_other_exn.js +++ /dev/null @@ -1,16 +0,0 @@ -// Generated by ReScript, PLEASE EDIT WITH CARE -'use strict'; - - -function Make($star) { - return {}; -} - -let U = {}; - -let V = {}; - -exports.Make = Make; -exports.U = U; -exports.V = V; -/* No side effect */ diff --git a/tests/tests/src/test_other_exn.mjs b/tests/tests/src/test_other_exn.mjs new file mode 100644 index 0000000000..9e5e37637c --- /dev/null +++ b/tests/tests/src/test_other_exn.mjs @@ -0,0 +1,17 @@ +// Generated by ReScript, PLEASE EDIT WITH CARE + + +function Make($star) { + return {}; +} + +let U = {}; + +let V = {}; + +export { + Make, + U, + V, +} +/* No side effect */ diff --git a/tests/tests/src/test_per.js b/tests/tests/src/test_per.js deleted file mode 100644 index 473abaed41..0000000000 --- a/tests/tests/src/test_per.js +++ /dev/null @@ -1,78 +0,0 @@ -// Generated by ReScript, PLEASE EDIT WITH CARE -'use strict'; - -let Primitive_object = require("rescript/lib/js/Primitive_object.js"); -let Primitive_exceptions = require("rescript/lib/js/Primitive_exceptions.js"); - -function failwith(s) { - throw { - RE_EXN_ID: "Failure", - _1: s, - Error: new Error() - }; -} - -function invalid_arg(s) { - throw { - RE_EXN_ID: "Invalid_argument", - _1: s, - Error: new Error() - }; -} - -let Exit = /* @__PURE__ */Primitive_exceptions.create("Test_per.Exit"); - -function min(x, y) { - if (Primitive_object.lessequal(x, y)) { - return x; - } else { - return y; - } -} - -function max(x, y) { - if (Primitive_object.greaterequal(x, y)) { - return x; - } else { - return y; - } -} - -function abs(x) { - if (x >= 0) { - return x; - } else { - return -x | 0; - } -} - -function lnot(x) { - return x ^ -1; -} - -let min_int = -2147483648; - -function char_of_int(n) { - if (n < 0 || n > 255) { - throw { - RE_EXN_ID: "Invalid_argument", - _1: "char_of_int", - Error: new Error() - }; - } - return n; -} - -let max_int = 2147483647; - -exports.failwith = failwith; -exports.invalid_arg = invalid_arg; -exports.Exit = Exit; -exports.min = min; -exports.max = max; -exports.abs = abs; -exports.lnot = lnot; -exports.max_int = max_int; -exports.min_int = min_int; -exports.char_of_int = char_of_int; -/* No side effect */ diff --git a/tests/tests/src/test_per.mjs b/tests/tests/src/test_per.mjs new file mode 100644 index 0000000000..ace3fcb5a9 --- /dev/null +++ b/tests/tests/src/test_per.mjs @@ -0,0 +1,79 @@ +// Generated by ReScript, PLEASE EDIT WITH CARE + +import * as Primitive_object from "rescript/lib/es6/Primitive_object.js"; +import * as Primitive_exceptions from "rescript/lib/es6/Primitive_exceptions.js"; + +function failwith(s) { + throw { + RE_EXN_ID: "Failure", + _1: s, + Error: new Error() + }; +} + +function invalid_arg(s) { + throw { + RE_EXN_ID: "Invalid_argument", + _1: s, + Error: new Error() + }; +} + +let Exit = /* @__PURE__ */Primitive_exceptions.create("Test_per.Exit"); + +function min(x, y) { + if (Primitive_object.lessequal(x, y)) { + return x; + } else { + return y; + } +} + +function max(x, y) { + if (Primitive_object.greaterequal(x, y)) { + return x; + } else { + return y; + } +} + +function abs(x) { + if (x >= 0) { + return x; + } else { + return -x | 0; + } +} + +function lnot(x) { + return x ^ -1; +} + +let min_int = -2147483648; + +function char_of_int(n) { + if (n < 0 || n > 255) { + throw { + RE_EXN_ID: "Invalid_argument", + _1: "char_of_int", + Error: new Error() + }; + } + return n; +} + +let max_int = 2147483647; + +export { + failwith, + invalid_arg, + Exit, + min, + max, + abs, + lnot, + max_int, + min_int, + char_of_int, +} +/* No side effect */ diff --git a/tests/tests/src/test_pervasive.js b/tests/tests/src/test_pervasive.js deleted file mode 100644 index 6ec9dcd090..0000000000 --- a/tests/tests/src/test_pervasive.js +++ /dev/null @@ -1,217 +0,0 @@ -// Generated by ReScript, PLEASE EDIT WITH CARE -'use strict'; - -let Belt_List = require("rescript/lib/js/Belt_List.js"); -let Pervasives = require("rescript/lib/js/Pervasives.js"); - -let Pervasives$1 = { - length: Belt_List.length, - size: Belt_List.size, - head: Belt_List.head, - headExn: Belt_List.headExn, - tail: Belt_List.tail, - tailExn: Belt_List.tailExn, - add: Belt_List.add, - get: Belt_List.get, - getExn: Belt_List.getExn, - make: Belt_List.make, - makeByU: Belt_List.makeByU, - makeBy: Belt_List.makeBy, - shuffle: Belt_List.shuffle, - drop: Belt_List.drop, - take: Belt_List.take, - splitAt: Belt_List.splitAt, - concat: Belt_List.concat, - concatMany: Belt_List.concatMany, - reverseConcat: Belt_List.reverseConcat, - flatten: Belt_List.flatten, - mapU: Belt_List.mapU, - map: Belt_List.map, - zip: Belt_List.zip, - zipByU: Belt_List.zipByU, - zipBy: Belt_List.zipBy, - mapWithIndexU: Belt_List.mapWithIndexU, - mapWithIndex: Belt_List.mapWithIndex, - fromArray: Belt_List.fromArray, - toArray: Belt_List.toArray, - reverse: Belt_List.reverse, - mapReverseU: Belt_List.mapReverseU, - mapReverse: Belt_List.mapReverse, - forEachU: Belt_List.forEachU, - forEach: Belt_List.forEach, - forEachWithIndexU: Belt_List.forEachWithIndexU, - forEachWithIndex: Belt_List.forEachWithIndex, - reduceU: Belt_List.reduceU, - reduce: Belt_List.reduce, - reduceWithIndexU: Belt_List.reduceWithIndexU, - reduceWithIndex: Belt_List.reduceWithIndex, - reduceReverseU: Belt_List.reduceReverseU, - reduceReverse: Belt_List.reduceReverse, - mapReverse2U: Belt_List.mapReverse2U, - mapReverse2: Belt_List.mapReverse2, - forEach2U: Belt_List.forEach2U, - forEach2: Belt_List.forEach2, - reduce2U: Belt_List.reduce2U, - reduce2: Belt_List.reduce2, - reduceReverse2U: Belt_List.reduceReverse2U, - reduceReverse2: Belt_List.reduceReverse2, - everyU: Belt_List.everyU, - every: Belt_List.every, - someU: Belt_List.someU, - some: Belt_List.some, - every2U: Belt_List.every2U, - every2: Belt_List.every2, - some2U: Belt_List.some2U, - some2: Belt_List.some2, - cmpByLength: Belt_List.cmpByLength, - cmpU: Belt_List.cmpU, - cmp: Belt_List.cmp, - eqU: Belt_List.eqU, - eq: Belt_List.eq, - hasU: Belt_List.hasU, - has: Belt_List.has, - getByU: Belt_List.getByU, - getBy: Belt_List.getBy, - keepU: Belt_List.keepU, - keep: Belt_List.keep, - filter: Belt_List.filter, - keepWithIndexU: Belt_List.keepWithIndexU, - keepWithIndex: Belt_List.keepWithIndex, - filterWithIndex: Belt_List.filterWithIndex, - keepMapU: Belt_List.keepMapU, - keepMap: Belt_List.keepMap, - partitionU: Belt_List.partitionU, - partition: Belt_List.partition, - unzip: Belt_List.unzip, - getAssocU: Belt_List.getAssocU, - getAssoc: Belt_List.getAssoc, - hasAssocU: Belt_List.hasAssocU, - hasAssoc: Belt_List.hasAssoc, - removeAssocU: Belt_List.removeAssocU, - removeAssoc: Belt_List.removeAssoc, - setAssocU: Belt_List.setAssocU, - setAssoc: Belt_List.setAssoc, - sortU: Belt_List.sortU, - sort: Belt_List.sort, - failwith: Pervasives.failwith, - invalid_arg: Pervasives.invalid_arg, - Exit: Pervasives.Exit, - abs: Pervasives.abs, - lnot: Pervasives.lnot, - max_int: Pervasives.max_int, - min_int: Pervasives.min_int, - infinity: Pervasives.infinity, - neg_infinity: Pervasives.neg_infinity, - max_float: Pervasives.max_float, - min_float: Pervasives.min_float, - epsilon_float: Pervasives.epsilon_float, - classify_float: Pervasives.classify_float, - char_of_int: Pervasives.char_of_int, - string_of_bool: Pervasives.string_of_bool, - bool_of_string: Pervasives.bool_of_string, - bool_of_string_opt: Pervasives.bool_of_string_opt, - int_of_string_opt: Pervasives.int_of_string_opt, - $at: Pervasives.$at, - panic: Pervasives.panic -}; - -function a0(prim) { - return Math.abs(prim); -} - -function a1(prim) { - return Math.acos(prim); -} - -function a2(prim) { - return Math.tan(prim); -} - -function a3(prim) { - return Math.tanh(prim); -} - -function a4(prim) { - return Math.asin(prim); -} - -function a5(prim0, prim1) { - return Math.atan2(prim0, prim1); -} - -function a6(prim) { - return Math.atan(prim); -} - -function a7(prim) { - return Math.ceil(prim); -} - -function a8(prim) { - return Math.cos(prim); -} - -function a9(prim) { - return Math.cosh(prim); -} - -function a10(prim) { - return Math.exp(prim); -} - -function a11(prim) { - return Math.sin(prim); -} - -function a12(prim) { - return Math.sinh(prim); -} - -function a13(prim) { - return Math.sqrt(prim); -} - -function a14(prim) { - return Math.floor(prim); -} - -function a15(prim) { - return Math.log(prim); -} - -function a16(prim) { - return Math.log10(prim); -} - -function a17(prim) { - return Math.log1p(prim); -} - -function a18(prim0, prim1) { - return Math.pow(prim0, prim1); -} - -let f = Pervasives.$at; - -exports.Pervasives = Pervasives$1; -exports.f = f; -exports.a0 = a0; -exports.a1 = a1; -exports.a2 = a2; -exports.a3 = a3; -exports.a4 = a4; -exports.a5 = a5; -exports.a6 = a6; -exports.a7 = a7; -exports.a8 = a8; -exports.a9 = a9; -exports.a10 = a10; -exports.a11 = a11; -exports.a12 = a12; -exports.a13 = a13; -exports.a14 = a14; -exports.a15 = a15; -exports.a16 = a16; -exports.a17 = a17; -exports.a18 = a18; -/* No side effect */ diff --git a/tests/tests/src/test_pervasive.mjs b/tests/tests/src/test_pervasive.mjs new file mode 100644 index 0000000000..0653322903 --- /dev/null +++ b/tests/tests/src/test_pervasive.mjs @@ -0,0 +1,218 @@ +// Generated by ReScript, PLEASE EDIT WITH CARE + +import * as Belt_List from "rescript/lib/es6/Belt_List.js"; +import * as Pervasives from "rescript/lib/es6/Pervasives.js"; + +let Pervasives$1 = { + length: Belt_List.length, + size: Belt_List.size, + head: Belt_List.head, + headExn: Belt_List.headExn, + tail: Belt_List.tail, + tailExn: Belt_List.tailExn, + add: Belt_List.add, + get: Belt_List.get, + getExn: Belt_List.getExn, + make: Belt_List.make, + makeByU: Belt_List.makeByU, + makeBy: Belt_List.makeBy, + shuffle: Belt_List.shuffle, + drop: Belt_List.drop, + take: Belt_List.take, + splitAt: Belt_List.splitAt, + concat: Belt_List.concat, + concatMany: Belt_List.concatMany, + reverseConcat: Belt_List.reverseConcat, + flatten: Belt_List.flatten, + mapU: Belt_List.mapU, + map: Belt_List.map, + zip: Belt_List.zip, + zipByU: Belt_List.zipByU, + zipBy: Belt_List.zipBy, + mapWithIndexU: Belt_List.mapWithIndexU, + mapWithIndex: Belt_List.mapWithIndex, + fromArray: Belt_List.fromArray, + toArray: Belt_List.toArray, + reverse: Belt_List.reverse, + mapReverseU: Belt_List.mapReverseU, + mapReverse: Belt_List.mapReverse, + forEachU: Belt_List.forEachU, + forEach: Belt_List.forEach, + forEachWithIndexU: Belt_List.forEachWithIndexU, + forEachWithIndex: Belt_List.forEachWithIndex, + reduceU: Belt_List.reduceU, + reduce: Belt_List.reduce, + reduceWithIndexU: Belt_List.reduceWithIndexU, + reduceWithIndex: Belt_List.reduceWithIndex, + reduceReverseU: Belt_List.reduceReverseU, + reduceReverse: Belt_List.reduceReverse, + mapReverse2U: Belt_List.mapReverse2U, + mapReverse2: Belt_List.mapReverse2, + forEach2U: Belt_List.forEach2U, + forEach2: Belt_List.forEach2, + reduce2U: Belt_List.reduce2U, + reduce2: Belt_List.reduce2, + reduceReverse2U: Belt_List.reduceReverse2U, + reduceReverse2: Belt_List.reduceReverse2, + everyU: Belt_List.everyU, + every: Belt_List.every, + someU: Belt_List.someU, + some: Belt_List.some, + every2U: Belt_List.every2U, + every2: Belt_List.every2, + some2U: Belt_List.some2U, + some2: Belt_List.some2, + cmpByLength: Belt_List.cmpByLength, + cmpU: Belt_List.cmpU, + cmp: Belt_List.cmp, + eqU: Belt_List.eqU, + eq: Belt_List.eq, + hasU: Belt_List.hasU, + has: Belt_List.has, + getByU: Belt_List.getByU, + getBy: Belt_List.getBy, + keepU: Belt_List.keepU, + keep: Belt_List.keep, + filter: Belt_List.filter, + keepWithIndexU: Belt_List.keepWithIndexU, + keepWithIndex: Belt_List.keepWithIndex, + filterWithIndex: Belt_List.filterWithIndex, + keepMapU: Belt_List.keepMapU, + keepMap: Belt_List.keepMap, + partitionU: Belt_List.partitionU, + partition: Belt_List.partition, + unzip: Belt_List.unzip, + getAssocU: Belt_List.getAssocU, + getAssoc: Belt_List.getAssoc, + hasAssocU: Belt_List.hasAssocU, + hasAssoc: Belt_List.hasAssoc, + removeAssocU: Belt_List.removeAssocU, + removeAssoc: Belt_List.removeAssoc, + setAssocU: Belt_List.setAssocU, + setAssoc: Belt_List.setAssoc, + sortU: Belt_List.sortU, + sort: Belt_List.sort, + failwith: Pervasives.failwith, + invalid_arg: Pervasives.invalid_arg, + Exit: Pervasives.Exit, + abs: Pervasives.abs, + lnot: Pervasives.lnot, + max_int: Pervasives.max_int, + min_int: Pervasives.min_int, + infinity: Pervasives.infinity, + neg_infinity: Pervasives.neg_infinity, + max_float: Pervasives.max_float, + min_float: Pervasives.min_float, + epsilon_float: Pervasives.epsilon_float, + classify_float: Pervasives.classify_float, + char_of_int: Pervasives.char_of_int, + string_of_bool: Pervasives.string_of_bool, + bool_of_string: Pervasives.bool_of_string, + bool_of_string_opt: Pervasives.bool_of_string_opt, + int_of_string_opt: Pervasives.int_of_string_opt, + $at: Pervasives.$at, + panic: Pervasives.panic +}; + +function a0(prim) { + return Math.abs(prim); +} + +function a1(prim) { + return Math.acos(prim); +} + +function a2(prim) { + return Math.tan(prim); +} + +function a3(prim) { + return Math.tanh(prim); +} + +function a4(prim) { + return Math.asin(prim); +} + +function a5(prim0, prim1) { + return Math.atan2(prim0, prim1); +} + +function a6(prim) { + return Math.atan(prim); +} + +function a7(prim) { + return Math.ceil(prim); +} + +function a8(prim) { + return Math.cos(prim); +} + +function a9(prim) { + return Math.cosh(prim); +} + +function a10(prim) { + return Math.exp(prim); +} + +function a11(prim) { + return Math.sin(prim); +} + +function a12(prim) { + return Math.sinh(prim); +} + +function a13(prim) { + return Math.sqrt(prim); +} + +function a14(prim) { + return Math.floor(prim); +} + +function a15(prim) { + return Math.log(prim); +} + +function a16(prim) { + return Math.log10(prim); +} + +function a17(prim) { + return Math.log1p(prim); +} + +function a18(prim0, prim1) { + return Math.pow(prim0, prim1); +} + +let f = Pervasives.$at; + +export { + Pervasives$1 as Pervasives, + f, + a0, + a1, + a2, + a3, + a4, + a5, + a6, + a7, + a8, + a9, + a10, + a11, + a12, + a13, + a14, + a15, + a16, + a17, + a18, +} +/* No side effect */ diff --git a/tests/tests/src/test_pervasives3.js b/tests/tests/src/test_pervasives3.js deleted file mode 100644 index 3288799e75..0000000000 --- a/tests/tests/src/test_pervasives3.js +++ /dev/null @@ -1,122 +0,0 @@ -// Generated by ReScript, PLEASE EDIT WITH CARE -'use strict'; - -let Belt_List = require("rescript/lib/js/Belt_List.js"); -let Pervasives = require("rescript/lib/js/Pervasives.js"); - -let Pervasives$1 = { - failwith: Pervasives.failwith, - invalid_arg: Pervasives.invalid_arg, - Exit: Pervasives.Exit, - abs: Pervasives.abs, - lnot: Pervasives.lnot, - max_int: Pervasives.max_int, - min_int: Pervasives.min_int, - infinity: Pervasives.infinity, - neg_infinity: Pervasives.neg_infinity, - max_float: Pervasives.max_float, - min_float: Pervasives.min_float, - epsilon_float: Pervasives.epsilon_float, - classify_float: Pervasives.classify_float, - char_of_int: Pervasives.char_of_int, - string_of_bool: Pervasives.string_of_bool, - bool_of_string: Pervasives.bool_of_string, - bool_of_string_opt: Pervasives.bool_of_string_opt, - int_of_string_opt: Pervasives.int_of_string_opt, - $at: Pervasives.$at, - panic: Pervasives.panic, - length: Belt_List.length, - size: Belt_List.size, - head: Belt_List.head, - headExn: Belt_List.headExn, - tail: Belt_List.tail, - tailExn: Belt_List.tailExn, - add: Belt_List.add, - get: Belt_List.get, - getExn: Belt_List.getExn, - make: Belt_List.make, - makeByU: Belt_List.makeByU, - makeBy: Belt_List.makeBy, - shuffle: Belt_List.shuffle, - drop: Belt_List.drop, - take: Belt_List.take, - splitAt: Belt_List.splitAt, - concat: Belt_List.concat, - concatMany: Belt_List.concatMany, - reverseConcat: Belt_List.reverseConcat, - flatten: Belt_List.flatten, - mapU: Belt_List.mapU, - map: Belt_List.map, - zip: Belt_List.zip, - zipByU: Belt_List.zipByU, - zipBy: Belt_List.zipBy, - mapWithIndexU: Belt_List.mapWithIndexU, - mapWithIndex: Belt_List.mapWithIndex, - fromArray: Belt_List.fromArray, - toArray: Belt_List.toArray, - reverse: Belt_List.reverse, - mapReverseU: Belt_List.mapReverseU, - mapReverse: Belt_List.mapReverse, - forEachU: Belt_List.forEachU, - forEach: Belt_List.forEach, - forEachWithIndexU: Belt_List.forEachWithIndexU, - forEachWithIndex: Belt_List.forEachWithIndex, - reduceU: Belt_List.reduceU, - reduce: Belt_List.reduce, - reduceWithIndexU: Belt_List.reduceWithIndexU, - reduceWithIndex: Belt_List.reduceWithIndex, - reduceReverseU: Belt_List.reduceReverseU, - reduceReverse: Belt_List.reduceReverse, - mapReverse2U: Belt_List.mapReverse2U, - mapReverse2: Belt_List.mapReverse2, - forEach2U: Belt_List.forEach2U, - forEach2: Belt_List.forEach2, - reduce2U: Belt_List.reduce2U, - reduce2: Belt_List.reduce2, - reduceReverse2U: Belt_List.reduceReverse2U, - reduceReverse2: Belt_List.reduceReverse2, - everyU: Belt_List.everyU, - every: Belt_List.every, - someU: Belt_List.someU, - some: Belt_List.some, - every2U: Belt_List.every2U, - every2: Belt_List.every2, - some2U: Belt_List.some2U, - some2: Belt_List.some2, - cmpByLength: Belt_List.cmpByLength, - cmpU: Belt_List.cmpU, - cmp: Belt_List.cmp, - eqU: Belt_List.eqU, - eq: Belt_List.eq, - hasU: Belt_List.hasU, - has: Belt_List.has, - getByU: Belt_List.getByU, - getBy: Belt_List.getBy, - keepU: Belt_List.keepU, - keep: Belt_List.keep, - filter: Belt_List.filter, - keepWithIndexU: Belt_List.keepWithIndexU, - keepWithIndex: Belt_List.keepWithIndex, - filterWithIndex: Belt_List.filterWithIndex, - keepMapU: Belt_List.keepMapU, - keepMap: Belt_List.keepMap, - partitionU: Belt_List.partitionU, - partition: Belt_List.partition, - unzip: Belt_List.unzip, - getAssocU: Belt_List.getAssocU, - getAssoc: Belt_List.getAssoc, - hasAssocU: Belt_List.hasAssocU, - hasAssoc: Belt_List.hasAssoc, - removeAssocU: Belt_List.removeAssocU, - removeAssoc: Belt_List.removeAssoc, - setAssocU: Belt_List.setAssocU, - setAssoc: Belt_List.setAssoc, - sortU: Belt_List.sortU, - sort: Belt_List.sort -}; - -let v = Pervasives.$at; - -exports.Pervasives = Pervasives$1; -exports.v = v; -/* No side effect */ diff --git a/tests/tests/src/test_pervasives3.mjs b/tests/tests/src/test_pervasives3.mjs new file mode 100644 index 0000000000..6b8a65b676 --- /dev/null +++ b/tests/tests/src/test_pervasives3.mjs @@ -0,0 +1,123 @@ +// Generated by ReScript, PLEASE EDIT WITH CARE + +import * as Belt_List from "rescript/lib/es6/Belt_List.js"; +import * as Pervasives from "rescript/lib/es6/Pervasives.js"; + +let Pervasives$1 = { + failwith: Pervasives.failwith, + invalid_arg: Pervasives.invalid_arg, + Exit: Pervasives.Exit, + abs: Pervasives.abs, + lnot: Pervasives.lnot, + max_int: Pervasives.max_int, + min_int: Pervasives.min_int, + infinity: Pervasives.infinity, + neg_infinity: Pervasives.neg_infinity, + max_float: Pervasives.max_float, + min_float: Pervasives.min_float, + epsilon_float: Pervasives.epsilon_float, + classify_float: Pervasives.classify_float, + char_of_int: Pervasives.char_of_int, + string_of_bool: Pervasives.string_of_bool, + bool_of_string: Pervasives.bool_of_string, + bool_of_string_opt: Pervasives.bool_of_string_opt, + int_of_string_opt: Pervasives.int_of_string_opt, + $at: Pervasives.$at, + panic: Pervasives.panic, + length: Belt_List.length, + size: Belt_List.size, + head: Belt_List.head, + headExn: Belt_List.headExn, + tail: Belt_List.tail, + tailExn: Belt_List.tailExn, + add: Belt_List.add, + get: Belt_List.get, + getExn: Belt_List.getExn, + make: Belt_List.make, + makeByU: Belt_List.makeByU, + makeBy: Belt_List.makeBy, + shuffle: Belt_List.shuffle, + drop: Belt_List.drop, + take: Belt_List.take, + splitAt: Belt_List.splitAt, + concat: Belt_List.concat, + concatMany: Belt_List.concatMany, + reverseConcat: Belt_List.reverseConcat, + flatten: Belt_List.flatten, + mapU: Belt_List.mapU, + map: Belt_List.map, + zip: Belt_List.zip, + zipByU: Belt_List.zipByU, + zipBy: Belt_List.zipBy, + mapWithIndexU: Belt_List.mapWithIndexU, + mapWithIndex: Belt_List.mapWithIndex, + fromArray: Belt_List.fromArray, + toArray: Belt_List.toArray, + reverse: Belt_List.reverse, + mapReverseU: Belt_List.mapReverseU, + mapReverse: Belt_List.mapReverse, + forEachU: Belt_List.forEachU, + forEach: Belt_List.forEach, + forEachWithIndexU: Belt_List.forEachWithIndexU, + forEachWithIndex: Belt_List.forEachWithIndex, + reduceU: Belt_List.reduceU, + reduce: Belt_List.reduce, + reduceWithIndexU: Belt_List.reduceWithIndexU, + reduceWithIndex: Belt_List.reduceWithIndex, + reduceReverseU: Belt_List.reduceReverseU, + reduceReverse: Belt_List.reduceReverse, + mapReverse2U: Belt_List.mapReverse2U, + mapReverse2: Belt_List.mapReverse2, + forEach2U: Belt_List.forEach2U, + forEach2: Belt_List.forEach2, + reduce2U: Belt_List.reduce2U, + reduce2: Belt_List.reduce2, + reduceReverse2U: Belt_List.reduceReverse2U, + reduceReverse2: Belt_List.reduceReverse2, + everyU: Belt_List.everyU, + every: Belt_List.every, + someU: Belt_List.someU, + some: Belt_List.some, + every2U: Belt_List.every2U, + every2: Belt_List.every2, + some2U: Belt_List.some2U, + some2: Belt_List.some2, + cmpByLength: Belt_List.cmpByLength, + cmpU: Belt_List.cmpU, + cmp: Belt_List.cmp, + eqU: Belt_List.eqU, + eq: Belt_List.eq, + hasU: Belt_List.hasU, + has: Belt_List.has, + getByU: Belt_List.getByU, + getBy: Belt_List.getBy, + keepU: Belt_List.keepU, + keep: Belt_List.keep, + filter: Belt_List.filter, + keepWithIndexU: Belt_List.keepWithIndexU, + keepWithIndex: Belt_List.keepWithIndex, + filterWithIndex: Belt_List.filterWithIndex, + keepMapU: Belt_List.keepMapU, + keepMap: Belt_List.keepMap, + partitionU: Belt_List.partitionU, + partition: Belt_List.partition, + unzip: Belt_List.unzip, + getAssocU: Belt_List.getAssocU, + getAssoc: Belt_List.getAssoc, + hasAssocU: Belt_List.hasAssocU, + hasAssoc: Belt_List.hasAssoc, + removeAssocU: Belt_List.removeAssocU, + removeAssoc: Belt_List.removeAssoc, + setAssocU: Belt_List.setAssocU, + setAssoc: Belt_List.setAssoc, + sortU: Belt_List.sortU, + sort: Belt_List.sort +}; + +let v = Pervasives.$at; + +export { + Pervasives$1 as Pervasives, + v, +} +/* No side effect */ diff --git a/tests/tests/src/test_primitive.js b/tests/tests/src/test_primitive.js deleted file mode 100644 index e5367cca65..0000000000 --- a/tests/tests/src/test_primitive.js +++ /dev/null @@ -1,117 +0,0 @@ -// Generated by ReScript, PLEASE EDIT WITH CARE -'use strict'; - -let Lazy = require("rescript/lib/js/Lazy.js"); - -function a4(prim) { - return [ - "File \"test_primitive.res\", line 29, characters 9-19", - prim - ]; -} - -function a5(prim) { - return [ - 30, - prim - ]; -} - -function a6(prim) { - return [ - [ - "test_primitive.res", - 31, - 9, - 19 - ], - prim - ]; -} - -let test_float = 3; - -let test_abs = Math.abs(3.0); - -let v = [ - 1.0, - 2.0 -]; - -let xxx = "a"; - -let a = xxx[0]; - -function u(b) { - if (b) { - console.log(1); - return 32; - } else { - return 7; - } -} - -function f2(h, b, param) { - return h(b ? 32 : 7); -} - -v[1] = 3.0; - -let unboxed_x = { - u: 0, - v: 0 -}; - -function gg(x) { - x.u = 0; -} - -function f(x) { - return x.length; -} - -let is_lazy_force = Lazy.force; - -function fib(n) { - if (n === 0 || n === 1) { - return 1; - } - let fib1 = fib(n - 1 | 0); - let fib2 = fib(n - 2 | 0); - return (fib1 + fib2 | 0) + 3 | 0; -} - -let a0 = "File \"test_primitive.res\", line 25, characters 9-16"; - -let a1 = "Test_primitive"; - -let a2 = 27; - -let a3 = "Test_primitive"; - -let xx = [ - 0, - 0 -]; - -exports.a0 = a0; -exports.a1 = a1; -exports.a2 = a2; -exports.a3 = a3; -exports.a4 = a4; -exports.a5 = a5; -exports.a6 = a6; -exports.test_float = test_float; -exports.test_abs = test_abs; -exports.v = v; -exports.xxx = xxx; -exports.a = a; -exports.u = u; -exports.f2 = f2; -exports.xx = xx; -exports.unboxed_x = unboxed_x; -exports.gg = gg; -exports.f = f; -exports.is_lazy_force = is_lazy_force; -exports.fib = fib; -/* test_abs Not a pure module */ diff --git a/tests/tests/src/test_primitive.mjs b/tests/tests/src/test_primitive.mjs new file mode 100644 index 0000000000..c5788bdeb9 --- /dev/null +++ b/tests/tests/src/test_primitive.mjs @@ -0,0 +1,118 @@ +// Generated by ReScript, PLEASE EDIT WITH CARE + +import * as Lazy from "rescript/lib/es6/Lazy.js"; + +function a4(prim) { + return [ + "File \"test_primitive.res\", line 29, characters 9-19", + prim + ]; +} + +function a5(prim) { + return [ + 30, + prim + ]; +} + +function a6(prim) { + return [ + [ + "test_primitive.res", + 31, + 9, + 19 + ], + prim + ]; +} + +let test_float = 3; + +let test_abs = Math.abs(3.0); + +let v = [ + 1.0, + 2.0 +]; + +let xxx = "a"; + +let a = xxx[0]; + +function u(b) { + if (b) { + console.log(1); + return 32; + } else { + return 7; + } +} + +function f2(h, b, param) { + return h(b ? 32 : 7); +} + +v[1] = 3.0; + +let unboxed_x = { + u: 0, + v: 0 +}; + +function gg(x) { + x.u = 0; +} + +function f(x) { + return x.length; +} + +let is_lazy_force = Lazy.force; + +function fib(n) { + if (n === 0 || n === 1) { + return 1; + } + let fib1 = fib(n - 1 | 0); + let fib2 = fib(n - 2 | 0); + return (fib1 + fib2 | 0) + 3 | 0; +} + +let a0 = "File \"test_primitive.res\", line 25, characters 9-16"; + +let a1 = "Test_primitive"; + +let a2 = 27; + +let a3 = "Test_primitive"; + +let xx = [ + 0, + 0 +]; + +export { + a0, + a1, + a2, + a3, + a4, + a5, + a6, + test_float, + test_abs, + v, + xxx, + a, + u, + f2, + xx, + unboxed_x, + gg, + f, + is_lazy_force, + fib, +} +/* test_abs Not a pure module */ diff --git a/tests/tests/src/test_ramification.js b/tests/tests/src/test_ramification.js deleted file mode 100644 index d77e2eb12a..0000000000 --- a/tests/tests/src/test_ramification.js +++ /dev/null @@ -1,60 +0,0 @@ -// Generated by ReScript, PLEASE EDIT WITH CARE -'use strict'; - - -function ff(x) { - let a; - switch (x) { - case "0" : - case "1" : - case "2" : - a = 3; - break; - case "3" : - a = 4; - break; - case "4" : - a = 6; - break; - case "7" : - a = 7; - break; - default: - a = 8; - } - return a + 3 | 0; -} - -function f(x) { - let y; - y = x.TAG === "A" ? 3 : 4; - return y + 32 | 0; -} - -function f2(x) { - let v = 0; - let y; - v = 1; - if (x.TAG === "A") { - let z = 33; - y = z + 3 | 0; - } else { - let z$1 = 33; - y = z$1 + 4 | 0; - } - return y + 32 | 0; -} - -function f3(x) { - let v = 0; - let y; - v = 1; - y = x.TAG === "A" ? 3 : 4; - return y + 32 | 0; -} - -exports.ff = ff; -exports.f = f; -exports.f2 = f2; -exports.f3 = f3; -/* No side effect */ diff --git a/tests/tests/src/test_ramification.mjs b/tests/tests/src/test_ramification.mjs new file mode 100644 index 0000000000..18fb48f4f4 --- /dev/null +++ b/tests/tests/src/test_ramification.mjs @@ -0,0 +1,61 @@ +// Generated by ReScript, PLEASE EDIT WITH CARE + + +function ff(x) { + let a; + switch (x) { + case "0" : + case "1" : + case "2" : + a = 3; + break; + case "3" : + a = 4; + break; + case "4" : + a = 6; + break; + case "7" : + a = 7; + break; + default: + a = 8; + } + return a + 3 | 0; +} + +function f(x) { + let y; + y = x.TAG === "A" ? 3 : 4; + return y + 32 | 0; +} + +function f2(x) { + let v = 0; + let y; + v = 1; + if (x.TAG === "A") { + let z = 33; + y = z + 3 | 0; + } else { + let z$1 = 33; + y = z$1 + 4 | 0; + } + return y + 32 | 0; +} + +function f3(x) { + let v = 0; + let y; + v = 1; + y = x.TAG === "A" ? 3 : 4; + return y + 32 | 0; +} + +export { + ff, + f, + f2, + f3, +} +/* No side effect */ diff --git a/tests/tests/src/test_react.js b/tests/tests/src/test_react.js deleted file mode 100644 index ef127b3487..0000000000 --- a/tests/tests/src/test_react.js +++ /dev/null @@ -1,38 +0,0 @@ -// Generated by ReScript, PLEASE EDIT WITH CARE -'use strict'; - -let C = require("c"); -let C$1 = require("b/c"); -let Xxx = require("xxx"); -let C$2 = require("a/b/c"); -let React = require("react"); -let ReactDom = require("react-dom"); - -console.log(32); - -ReactDom.render(React.createClass({ - render: () => React.DOM.div({ - alt: "pic" - }, React.DOM.h1(undefined, "hello react"), React.DOM.h2(undefined, "type safe!"), React.DOM.h3(undefined, "type safe!")) -}), document.getElementById("hi")); - -function f() { - Xxx(); - Xxx.xx(); - Xxx.xxx(); - C$2.x(); - C$2.y(); - C$1.x(); - C$1.y(); - C.x(); - C.y(); -} - -let v; - -let u = 33; - -exports.v = v; -exports.u = u; -exports.f = f; -/* Not a pure module */ diff --git a/tests/tests/src/test_react.mjs b/tests/tests/src/test_react.mjs new file mode 100644 index 0000000000..f734e96bb0 --- /dev/null +++ b/tests/tests/src/test_react.mjs @@ -0,0 +1,39 @@ +// Generated by ReScript, PLEASE EDIT WITH CARE + +import * as C from "c"; +import * as C$1 from "b/c"; +import * as Xxx from "xxx"; +import * as C$2 from "a/b/c"; +import * as React from "react"; +import * as ReactDom from "react-dom"; + +console.log(32); + +ReactDom.render(React.createClass({ + render: () => React.DOM.div({ + alt: "pic" + }, React.DOM.h1(undefined, "hello react"), React.DOM.h2(undefined, "type safe!"), React.DOM.h3(undefined, "type safe!")) +}), document.getElementById("hi")); + +function f() { + Xxx(); + Xxx.xx(); + Xxx.xxx(); + C$2.x(); + C$2.y(); + C$1.x(); + C$1.y(); + C.x(); + C.y(); +} + +let v; + +let u = 33; + +export { + v, + u, + f, +} +/* Not a pure module */ diff --git a/tests/tests/src/test_react_case.js b/tests/tests/src/test_react_case.js deleted file mode 100644 index 182b8c2015..0000000000 --- a/tests/tests/src/test_react_case.js +++ /dev/null @@ -1,10 +0,0 @@ -// Generated by ReScript, PLEASE EDIT WITH CARE -'use strict'; - - -function v(prim) { - return {}; -} - -exports.v = v; -/* No side effect */ diff --git a/tests/tests/src/test_react_case.mjs b/tests/tests/src/test_react_case.mjs new file mode 100644 index 0000000000..88fc17d1ee --- /dev/null +++ b/tests/tests/src/test_react_case.mjs @@ -0,0 +1,11 @@ +// Generated by ReScript, PLEASE EDIT WITH CARE + + +function v(prim) { + return {}; +} + +export { + v, +} +/* No side effect */ diff --git a/tests/tests/src/test_regex.js b/tests/tests/src/test_regex.js deleted file mode 100644 index ead1c8fa2d..0000000000 --- a/tests/tests/src/test_regex.js +++ /dev/null @@ -1,14 +0,0 @@ -// Generated by ReScript, PLEASE EDIT WITH CARE -'use strict'; - - -let v = /b/ig; - -let r = /Bucklescript是一个程序语言/; - -let c = v; - -exports.v = v; -exports.r = r; -exports.c = c; -/* No side effect */ diff --git a/tests/tests/src/test_regex.mjs b/tests/tests/src/test_regex.mjs new file mode 100644 index 0000000000..086b195796 --- /dev/null +++ b/tests/tests/src/test_regex.mjs @@ -0,0 +1,15 @@ +// Generated by ReScript, PLEASE EDIT WITH CARE + + +let v = /b/ig; + +let r = /Bucklescript是一个程序语言/; + +let c = v; + +export { + v, + r, + c, +} +/* No side effect */ diff --git a/tests/tests/src/test_runtime_encoding.js b/tests/tests/src/test_runtime_encoding.js deleted file mode 100644 index 6bef667b3e..0000000000 --- a/tests/tests/src/test_runtime_encoding.js +++ /dev/null @@ -1,56 +0,0 @@ -// Generated by ReScript, PLEASE EDIT WITH CARE -'use strict'; - - -function g(x) { - return [ - 3, - x - ]; -} - -function ff(v, u) { - return { - v: v, - u: u - }; -} - -function fff(vv, uu) { - return { - vv: vv, - uu: uu - }; -} - -function a(x) { - return x[0]; -} - -function aa(x) { - return x[0]; -} - -function aaa(x) { - return x.v; -} - -function aaaa(x) { - return x.vv; -} - -function f(x) { - for (let i = 0; i <= 10; ++i) { - x[i] = i; - } -} - -exports.g = g; -exports.ff = ff; -exports.fff = fff; -exports.a = a; -exports.aa = aa; -exports.aaa = aaa; -exports.aaaa = aaaa; -exports.f = f; -/* No side effect */ diff --git a/tests/tests/src/test_runtime_encoding.mjs b/tests/tests/src/test_runtime_encoding.mjs new file mode 100644 index 0000000000..100f10c41e --- /dev/null +++ b/tests/tests/src/test_runtime_encoding.mjs @@ -0,0 +1,57 @@ +// Generated by ReScript, PLEASE EDIT WITH CARE + + +function g(x) { + return [ + 3, + x + ]; +} + +function ff(v, u) { + return { + v: v, + u: u + }; +} + +function fff(vv, uu) { + return { + vv: vv, + uu: uu + }; +} + +function a(x) { + return x[0]; +} + +function aa(x) { + return x[0]; +} + +function aaa(x) { + return x.v; +} + +function aaaa(x) { + return x.vv; +} + +function f(x) { + for (let i = 0; i <= 10; ++i) { + x[i] = i; + } +} + +export { + g, + ff, + fff, + a, + aa, + aaa, + aaaa, + f, +} +/* No side effect */ diff --git a/tests/tests/src/test_scope.js b/tests/tests/src/test_scope.js deleted file mode 100644 index bc5e6b9857..0000000000 --- a/tests/tests/src/test_scope.js +++ /dev/null @@ -1,16 +0,0 @@ -// Generated by ReScript, PLEASE EDIT WITH CARE -'use strict'; - - -let h = x(3); - -let hh = x(3); - -function f(x, y) { - return x + y; -} - -exports.h = h; -exports.hh = hh; -exports.f = f; -/* h Not a pure module */ diff --git a/tests/tests/src/test_scope.mjs b/tests/tests/src/test_scope.mjs new file mode 100644 index 0000000000..c46d943624 --- /dev/null +++ b/tests/tests/src/test_scope.mjs @@ -0,0 +1,17 @@ +// Generated by ReScript, PLEASE EDIT WITH CARE + + +let h = x(3); + +let hh = x(3); + +function f(x, y) { + return x + y; +} + +export { + h, + hh, + f, +} +/* h Not a pure module */ diff --git a/tests/tests/src/test_seq.js b/tests/tests/src/test_seq.js deleted file mode 100644 index 0babeabe89..0000000000 --- a/tests/tests/src/test_seq.js +++ /dev/null @@ -1,108 +0,0 @@ -// Generated by ReScript, PLEASE EDIT WITH CARE -'use strict'; - -let Pervasives = require("rescript/lib/js/Pervasives.js"); -let Primitive_object = require("rescript/lib/js/Primitive_object.js"); -let Primitive_exceptions = require("rescript/lib/js/Primitive_exceptions.js"); - -let Bad = /* @__PURE__ */Primitive_exceptions.create("Test_seq.Bad"); - -let Help = /* @__PURE__ */Primitive_exceptions.create("Test_seq.Help"); - -let Stop = /* @__PURE__ */Primitive_exceptions.create("Test_seq.Stop"); - -function assoc3(x, _l) { - while (true) { - let l = _l; - if (l) { - let match = l.hd; - if (Primitive_object.equal(match[0], x)) { - return match[1]; - } - _l = l.tl; - continue; - } - throw { - RE_EXN_ID: "Not_found", - Error: new Error() - }; - }; -} - -function help_action() { - throw { - RE_EXN_ID: Stop, - _1: { - TAG: "Unknown", - _0: "-help" - }, - Error: new Error() - }; -} - -function v(speclist) { - assoc3("-help", speclist); - return /* [] */0; -} - -function f(g, speclist) { - return g(assoc3("-help", speclist)); -} - -function add_help(speclist) { - let add1; - try { - assoc3("-help", speclist); - add1 = /* [] */0; - } catch (raw_exn) { - let exn = Primitive_exceptions.internalToException(raw_exn); - if (exn.RE_EXN_ID === "Not_found") { - add1 = { - hd: [ - "-help", - { - TAG: "Unit", - _0: help_action - }, - " Display this list of options" - ], - tl: /* [] */0 - }; - } else { - throw exn; - } - } - let add2; - try { - assoc3("--help", speclist); - add2 = /* [] */0; - } catch (raw_exn$1) { - let exn$1 = Primitive_exceptions.internalToException(raw_exn$1); - if (exn$1.RE_EXN_ID === "Not_found") { - add2 = { - hd: [ - "--help", - { - TAG: "Unit", - _0: help_action - }, - " Display this list of options" - ], - tl: /* [] */0 - }; - } else { - throw exn$1; - } - } - return Pervasives.$at(speclist, Pervasives.$at(add1, add2)); -} - -exports.Bad = Bad; -exports.Help = Help; -exports.Stop = Stop; -exports.assoc3 = assoc3; -exports.help_action = help_action; -exports.v = v; -exports.f = f; -exports.add_help = add_help; -/* No side effect */ diff --git a/tests/tests/src/test_seq.mjs b/tests/tests/src/test_seq.mjs new file mode 100644 index 0000000000..b436695590 --- /dev/null +++ b/tests/tests/src/test_seq.mjs @@ -0,0 +1,109 @@ +// Generated by ReScript, PLEASE EDIT WITH CARE + +import * as Pervasives from "rescript/lib/es6/Pervasives.js"; +import * as Primitive_object from "rescript/lib/es6/Primitive_object.js"; +import * as Primitive_exceptions from "rescript/lib/es6/Primitive_exceptions.js"; + +let Bad = /* @__PURE__ */Primitive_exceptions.create("Test_seq.Bad"); + +let Help = /* @__PURE__ */Primitive_exceptions.create("Test_seq.Help"); + +let Stop = /* @__PURE__ */Primitive_exceptions.create("Test_seq.Stop"); + +function assoc3(x, _l) { + while (true) { + let l = _l; + if (l) { + let match = l.hd; + if (Primitive_object.equal(match[0], x)) { + return match[1]; + } + _l = l.tl; + continue; + } + throw { + RE_EXN_ID: "Not_found", + Error: new Error() + }; + }; +} + +function help_action() { + throw { + RE_EXN_ID: Stop, + _1: { + TAG: "Unknown", + _0: "-help" + }, + Error: new Error() + }; +} + +function v(speclist) { + assoc3("-help", speclist); + return /* [] */0; +} + +function f(g, speclist) { + return g(assoc3("-help", speclist)); +} + +function add_help(speclist) { + let add1; + try { + assoc3("-help", speclist); + add1 = /* [] */0; + } catch (raw_exn) { + let exn = Primitive_exceptions.internalToException(raw_exn); + if (exn.RE_EXN_ID === "Not_found") { + add1 = { + hd: [ + "-help", + { + TAG: "Unit", + _0: help_action + }, + " Display this list of options" + ], + tl: /* [] */0 + }; + } else { + throw exn; + } + } + let add2; + try { + assoc3("--help", speclist); + add2 = /* [] */0; + } catch (raw_exn$1) { + let exn$1 = Primitive_exceptions.internalToException(raw_exn$1); + if (exn$1.RE_EXN_ID === "Not_found") { + add2 = { + hd: [ + "--help", + { + TAG: "Unit", + _0: help_action + }, + " Display this list of options" + ], + tl: /* [] */0 + }; + } else { + throw exn$1; + } + } + return Pervasives.$at(speclist, Pervasives.$at(add1, add2)); +} + +export { + Bad, + Help, + Stop, + assoc3, + help_action, + v, + f, + add_help, +} +/* No side effect */ diff --git a/tests/tests/src/test_set.js b/tests/tests/src/test_set.js deleted file mode 100644 index b6675b0f5b..0000000000 --- a/tests/tests/src/test_set.js +++ /dev/null @@ -1,738 +0,0 @@ -// Generated by ReScript, PLEASE EDIT WITH CARE -'use strict'; - -let Belt_List = require("rescript/lib/js/Belt_List.js"); -let Pervasives = require("rescript/lib/js/Pervasives.js"); - -function Make(Ord) { - let height = x => { - if (typeof x !== "object") { - return 0; - } else { - return x._3; - } - }; - let create = (l, v, r) => { - let hl; - hl = typeof l !== "object" ? 0 : l._3; - let hr; - hr = typeof r !== "object" ? 0 : r._3; - return { - TAG: "Node", - _0: l, - _1: v, - _2: r, - _3: hl >= hr ? hl + 1 | 0 : hr + 1 | 0 - }; - }; - let bal = (l, v, r) => { - let hl; - hl = typeof l !== "object" ? 0 : l._3; - let hr; - hr = typeof r !== "object" ? 0 : r._3; - if (hl > (hr + 2 | 0)) { - if (typeof l !== "object") { - return Pervasives.invalid_arg("Set.bal"); - } - let lr = l._2; - let lv = l._1; - let ll = l._0; - if (height(ll) >= height(lr)) { - return create(ll, lv, create(lr, v, r)); - } else if (typeof lr !== "object") { - return Pervasives.invalid_arg("Set.bal"); - } else { - return create(create(ll, lv, lr._0), lr._1, create(lr._2, v, r)); - } - } - if (hr <= (hl + 2 | 0)) { - return { - TAG: "Node", - _0: l, - _1: v, - _2: r, - _3: hl >= hr ? hl + 1 | 0 : hr + 1 | 0 - }; - } - if (typeof r !== "object") { - return Pervasives.invalid_arg("Set.bal"); - } - let rr = r._2; - let rv = r._1; - let rl = r._0; - if (height(rr) >= height(rl)) { - return create(create(l, v, rl), rv, rr); - } else if (typeof rl !== "object") { - return Pervasives.invalid_arg("Set.bal"); - } else { - return create(create(l, v, rl._0), rl._1, create(rl._2, rv, rr)); - } - }; - let add = (x, x_) => { - if (typeof x_ !== "object") { - return { - TAG: "Node", - _0: "Empty", - _1: x, - _2: "Empty", - _3: 1 - }; - } - let r = x_._2; - let v = x_._1; - let l = x_._0; - let c = Ord.compare(x, v); - if (c === 0) { - return x_; - } else if (c < 0) { - return bal(add(x, l), v, r); - } else { - return bal(l, v, add(x, r)); - } - }; - let singleton = x => ({ - TAG: "Node", - _0: "Empty", - _1: x, - _2: "Empty", - _3: 1 - }); - let add_min_element = (v, x) => { - if (typeof x !== "object") { - return singleton(v); - } else { - return bal(add_min_element(v, x._0), x._1, x._2); - } - }; - let add_max_element = (v, x) => { - if (typeof x !== "object") { - return singleton(v); - } else { - return bal(x._0, x._1, add_max_element(v, x._2)); - } - }; - let join = (l, v, r) => { - if (typeof l !== "object") { - return add_min_element(v, r); - } - let lh = l._3; - if (typeof r !== "object") { - return add_max_element(v, l); - } - let rh = r._3; - if (lh > (rh + 2 | 0)) { - return bal(l._0, l._1, join(l._2, v, r)); - } else if (rh > (lh + 2 | 0)) { - return bal(join(l, v, r._0), r._1, r._2); - } else { - return create(l, v, r); - } - }; - let min_elt = _x => { - while (true) { - let x = _x; - if (typeof x !== "object") { - throw { - RE_EXN_ID: "Not_found", - Error: new Error() - }; - } - let l = x._0; - if (typeof l !== "object") { - return x._1; - } - _x = l; - continue; - }; - }; - let max_elt = _x => { - while (true) { - let x = _x; - if (typeof x !== "object") { - throw { - RE_EXN_ID: "Not_found", - Error: new Error() - }; - } - let r = x._2; - if (typeof r !== "object") { - return x._1; - } - _x = r; - continue; - }; - }; - let remove_min_elt = x => { - if (typeof x !== "object") { - return Pervasives.invalid_arg("Set.remove_min_elt"); - } - let l = x._0; - if (typeof l !== "object") { - return x._2; - } else { - return bal(remove_min_elt(l), x._1, x._2); - } - }; - let merge = (t1, t2) => { - if (typeof t1 !== "object") { - return t2; - } else if (typeof t2 !== "object") { - return t1; - } else { - return bal(t1, min_elt(t2), remove_min_elt(t2)); - } - }; - let concat = (t1, t2) => { - if (typeof t1 !== "object") { - return t2; - } else if (typeof t2 !== "object") { - return t1; - } else { - return join(t1, min_elt(t2), remove_min_elt(t2)); - } - }; - let split = (x, x_) => { - if (typeof x_ !== "object") { - return [ - "Empty", - false, - "Empty" - ]; - } - let r = x_._2; - let v = x_._1; - let l = x_._0; - let c = Ord.compare(x, v); - if (c === 0) { - return [ - l, - true, - r - ]; - } - if (c < 0) { - let match = split(x, l); - return [ - match[0], - match[1], - join(match[2], v, r) - ]; - } - let match$1 = split(x, r); - return [ - join(l, v, match$1[0]), - match$1[1], - match$1[2] - ]; - }; - let is_empty = x => { - if (typeof x !== "object") { - return true; - } else { - return false; - } - }; - let mem = (x, _x_) => { - while (true) { - let x_ = _x_; - if (typeof x_ !== "object") { - return false; - } - let c = Ord.compare(x, x_._1); - if (c === 0) { - return true; - } - _x_ = c < 0 ? x_._0 : x_._2; - continue; - }; - }; - let remove = (x, x_) => { - if (typeof x_ !== "object") { - return "Empty"; - } - let r = x_._2; - let v = x_._1; - let l = x_._0; - let c = Ord.compare(x, v); - if (c === 0) { - return merge(l, r); - } else if (c < 0) { - return bal(remove(x, l), v, r); - } else { - return bal(l, v, remove(x, r)); - } - }; - let union = (s1, s2) => { - if (typeof s1 !== "object") { - return s2; - } - let h1 = s1._3; - let v1 = s1._1; - if (typeof s2 !== "object") { - return s1; - } - let h2 = s2._3; - let v2 = s2._1; - if (h1 >= h2) { - if (h2 === 1) { - return add(v2, s1); - } - let match = split(v1, s2); - return join(union(s1._0, match[0]), v1, union(s1._2, match[2])); - } - if (h1 === 1) { - return add(v1, s2); - } - let match$1 = split(v2, s1); - return join(union(match$1[0], s2._0), v2, union(match$1[2], s2._2)); - }; - let inter = (s1, s2) => { - if (typeof s1 !== "object") { - return "Empty"; - } - if (typeof s2 !== "object") { - return "Empty"; - } - let r1 = s1._2; - let v1 = s1._1; - let l1 = s1._0; - let match = split(v1, s2); - let l2 = match[0]; - if (match[1]) { - return join(inter(l1, l2), v1, inter(r1, match[2])); - } else { - return concat(inter(l1, l2), inter(r1, match[2])); - } - }; - let diff = (s1, s2) => { - if (typeof s1 !== "object") { - return "Empty"; - } - if (typeof s2 !== "object") { - return s1; - } - let r1 = s1._2; - let v1 = s1._1; - let l1 = s1._0; - let match = split(v1, s2); - let l2 = match[0]; - if (match[1]) { - return concat(diff(l1, l2), diff(r1, match[2])); - } else { - return join(diff(l1, l2), v1, diff(r1, match[2])); - } - }; - let cons_enum = (_s, _e) => { - while (true) { - let e = _e; - let s = _s; - if (typeof s !== "object") { - return e; - } - _e = { - TAG: "More", - _0: s._1, - _1: s._2, - _2: e - }; - _s = s._0; - continue; - }; - }; - let compare_aux = (_e1, _e2) => { - while (true) { - let e2 = _e2; - let e1 = _e1; - if (typeof e1 !== "object") { - if (typeof e2 !== "object") { - return 0; - } else { - return -1; - } - } - if (typeof e2 !== "object") { - return 1; - } - let c = Ord.compare(e1._0, e2._0); - if (c !== 0) { - return c; - } - _e2 = cons_enum(e2._1, e2._2); - _e1 = cons_enum(e1._1, e1._2); - continue; - }; - }; - let compare = (s1, s2) => compare_aux(cons_enum(s1, "End"), cons_enum(s2, "End")); - let equal = (s1, s2) => compare(s1, s2) === 0; - let subset = (_s1, _s2) => { - while (true) { - let s2 = _s2; - let s1 = _s1; - if (typeof s1 !== "object") { - return true; - } - let r1 = s1._2; - let v1 = s1._1; - let l1 = s1._0; - if (typeof s2 !== "object") { - return false; - } - let r2 = s2._2; - let l2 = s2._0; - let c = Ord.compare(v1, s2._1); - if (c === 0) { - if (!subset(l1, l2)) { - return false; - } - _s2 = r2; - _s1 = r1; - continue; - } - if (c < 0) { - if (!subset({ - TAG: "Node", - _0: l1, - _1: v1, - _2: "Empty", - _3: 0 - }, l2)) { - return false; - } - _s1 = r1; - continue; - } - if (!subset({ - TAG: "Node", - _0: "Empty", - _1: v1, - _2: r1, - _3: 0 - }, r2)) { - return false; - } - _s1 = l1; - continue; - }; - }; - let iter = (f, _x_) => { - while (true) { - let x_ = _x_; - if (typeof x_ !== "object") { - return; - } - iter(f, x_._0); - f(x_._1); - _x_ = x_._2; - continue; - }; - }; - let fold = (f, _s, _accu) => { - while (true) { - let accu = _accu; - let s = _s; - if (typeof s !== "object") { - return accu; - } - _accu = f(s._1, fold(f, s._0, accu)); - _s = s._2; - continue; - }; - }; - let for_all = (p, _x) => { - while (true) { - let x = _x; - if (typeof x !== "object") { - return true; - } - if (!p(x._1)) { - return false; - } - if (!for_all(p, x._0)) { - return false; - } - _x = x._2; - continue; - }; - }; - let exists = (p, _x) => { - while (true) { - let x = _x; - if (typeof x !== "object") { - return false; - } - if (p(x._1)) { - return true; - } - if (exists(p, x._0)) { - return true; - } - _x = x._2; - continue; - }; - }; - let filter = (p, x) => { - if (typeof x !== "object") { - return "Empty"; - } - let v = x._1; - let l$p = filter(p, x._0); - let pv = p(v); - let r$p = filter(p, x._2); - if (pv) { - return join(l$p, v, r$p); - } else { - return concat(l$p, r$p); - } - }; - let partition = (p, x) => { - if (typeof x !== "object") { - return [ - "Empty", - "Empty" - ]; - } - let v = x._1; - let match = partition(p, x._0); - let lf = match[1]; - let lt = match[0]; - let pv = p(v); - let match$1 = partition(p, x._2); - let rf = match$1[1]; - let rt = match$1[0]; - if (pv) { - return [ - join(lt, v, rt), - concat(lf, rf) - ]; - } else { - return [ - concat(lt, rt), - join(lf, v, rf) - ]; - } - }; - let cardinal = x => { - if (typeof x !== "object") { - return 0; - } else { - return (cardinal(x._0) + 1 | 0) + cardinal(x._2) | 0; - } - }; - let elements_aux = (_accu, _x) => { - while (true) { - let x = _x; - let accu = _accu; - if (typeof x !== "object") { - return accu; - } - _x = x._0; - _accu = { - hd: x._1, - tl: elements_aux(accu, x._2) - }; - continue; - }; - }; - let elements = s => elements_aux(/* [] */0, s); - let find = (x, _x_) => { - while (true) { - let x_ = _x_; - if (typeof x_ !== "object") { - throw { - RE_EXN_ID: "Not_found", - Error: new Error() - }; - } - let v = x_._1; - let c = Ord.compare(x, v); - if (c === 0) { - return v; - } - _x_ = c < 0 ? x_._0 : x_._2; - continue; - }; - }; - let of_sorted_list = l => { - let sub = (n, l) => { - switch (n) { - case 0 : - return [ - "Empty", - l - ]; - case 1 : - if (l) { - return [ - { - TAG: "Node", - _0: "Empty", - _1: l.hd, - _2: "Empty", - _3: 1 - }, - l.tl - ]; - } - break; - case 2 : - if (l) { - let match = l.tl; - if (match) { - return [ - { - TAG: "Node", - _0: { - TAG: "Node", - _0: "Empty", - _1: l.hd, - _2: "Empty", - _3: 1 - }, - _1: match.hd, - _2: "Empty", - _3: 2 - }, - match.tl - ]; - } - - } - break; - case 3 : - if (l) { - let match$1 = l.tl; - if (match$1) { - let match$2 = match$1.tl; - if (match$2) { - return [ - { - TAG: "Node", - _0: { - TAG: "Node", - _0: "Empty", - _1: l.hd, - _2: "Empty", - _3: 1 - }, - _1: match$1.hd, - _2: { - TAG: "Node", - _0: "Empty", - _1: match$2.hd, - _2: "Empty", - _3: 1 - }, - _3: 2 - }, - match$2.tl - ]; - } - - } - - } - break; - } - let nl = n / 2 | 0; - let match$3 = sub(nl, l); - let l$1 = match$3[1]; - if (l$1) { - let match$4 = sub((n - nl | 0) - 1 | 0, l$1.tl); - return [ - create(match$3[0], l$1.hd, match$4[0]), - match$4[1] - ]; - } - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "test_set.res", - 497, - 20 - ], - Error: new Error() - }; - }; - return sub(Belt_List.length(l), l)[0]; - }; - let of_list = l => { - if (!l) { - return "Empty"; - } - let match = l.tl; - let x0 = l.hd; - if (!match) { - return singleton(x0); - } - let match$1 = match.tl; - let x1 = match.hd; - if (!match$1) { - return add(x1, singleton(x0)); - } - let match$2 = match$1.tl; - let x2 = match$1.hd; - if (!match$2) { - return add(x2, add(x1, singleton(x0))); - } - let match$3 = match$2.tl; - let x3 = match$2.hd; - if (match$3) { - if (match$3.tl) { - return of_sorted_list(Belt_List.sort(l, Ord.compare)); - } else { - return add(match$3.hd, add(x3, add(x2, add(x1, singleton(x0))))); - } - } else { - return add(x3, add(x2, add(x1, singleton(x0)))); - } - }; - return { - height: height, - create: create, - bal: bal, - add: add, - singleton: singleton, - add_min_element: add_min_element, - add_max_element: add_max_element, - join: join, - min_elt: min_elt, - max_elt: max_elt, - remove_min_elt: remove_min_elt, - merge: merge, - concat: concat, - split: split, - empty: "Empty", - is_empty: is_empty, - mem: mem, - remove: remove, - union: union, - inter: inter, - diff: diff, - cons_enum: cons_enum, - compare_aux: compare_aux, - compare: compare, - equal: equal, - subset: subset, - iter: iter, - fold: fold, - for_all: for_all, - exists: exists, - filter: filter, - partition: partition, - cardinal: cardinal, - elements_aux: elements_aux, - elements: elements, - choose: min_elt, - find: find, - of_sorted_list: of_sorted_list, - of_list: of_list - }; -} - -let N = { - a: 3 -}; - -exports.Make = Make; -exports.N = N; -/* No side effect */ diff --git a/tests/tests/src/test_set.mjs b/tests/tests/src/test_set.mjs new file mode 100644 index 0000000000..00e9215886 --- /dev/null +++ b/tests/tests/src/test_set.mjs @@ -0,0 +1,739 @@ +// Generated by ReScript, PLEASE EDIT WITH CARE + +import * as Belt_List from "rescript/lib/es6/Belt_List.js"; +import * as Pervasives from "rescript/lib/es6/Pervasives.js"; + +function Make(Ord) { + let height = x => { + if (typeof x !== "object") { + return 0; + } else { + return x._3; + } + }; + let create = (l, v, r) => { + let hl; + hl = typeof l !== "object" ? 0 : l._3; + let hr; + hr = typeof r !== "object" ? 0 : r._3; + return { + TAG: "Node", + _0: l, + _1: v, + _2: r, + _3: hl >= hr ? hl + 1 | 0 : hr + 1 | 0 + }; + }; + let bal = (l, v, r) => { + let hl; + hl = typeof l !== "object" ? 0 : l._3; + let hr; + hr = typeof r !== "object" ? 0 : r._3; + if (hl > (hr + 2 | 0)) { + if (typeof l !== "object") { + return Pervasives.invalid_arg("Set.bal"); + } + let lr = l._2; + let lv = l._1; + let ll = l._0; + if (height(ll) >= height(lr)) { + return create(ll, lv, create(lr, v, r)); + } else if (typeof lr !== "object") { + return Pervasives.invalid_arg("Set.bal"); + } else { + return create(create(ll, lv, lr._0), lr._1, create(lr._2, v, r)); + } + } + if (hr <= (hl + 2 | 0)) { + return { + TAG: "Node", + _0: l, + _1: v, + _2: r, + _3: hl >= hr ? hl + 1 | 0 : hr + 1 | 0 + }; + } + if (typeof r !== "object") { + return Pervasives.invalid_arg("Set.bal"); + } + let rr = r._2; + let rv = r._1; + let rl = r._0; + if (height(rr) >= height(rl)) { + return create(create(l, v, rl), rv, rr); + } else if (typeof rl !== "object") { + return Pervasives.invalid_arg("Set.bal"); + } else { + return create(create(l, v, rl._0), rl._1, create(rl._2, rv, rr)); + } + }; + let add = (x, x_) => { + if (typeof x_ !== "object") { + return { + TAG: "Node", + _0: "Empty", + _1: x, + _2: "Empty", + _3: 1 + }; + } + let r = x_._2; + let v = x_._1; + let l = x_._0; + let c = Ord.compare(x, v); + if (c === 0) { + return x_; + } else if (c < 0) { + return bal(add(x, l), v, r); + } else { + return bal(l, v, add(x, r)); + } + }; + let singleton = x => ({ + TAG: "Node", + _0: "Empty", + _1: x, + _2: "Empty", + _3: 1 + }); + let add_min_element = (v, x) => { + if (typeof x !== "object") { + return singleton(v); + } else { + return bal(add_min_element(v, x._0), x._1, x._2); + } + }; + let add_max_element = (v, x) => { + if (typeof x !== "object") { + return singleton(v); + } else { + return bal(x._0, x._1, add_max_element(v, x._2)); + } + }; + let join = (l, v, r) => { + if (typeof l !== "object") { + return add_min_element(v, r); + } + let lh = l._3; + if (typeof r !== "object") { + return add_max_element(v, l); + } + let rh = r._3; + if (lh > (rh + 2 | 0)) { + return bal(l._0, l._1, join(l._2, v, r)); + } else if (rh > (lh + 2 | 0)) { + return bal(join(l, v, r._0), r._1, r._2); + } else { + return create(l, v, r); + } + }; + let min_elt = _x => { + while (true) { + let x = _x; + if (typeof x !== "object") { + throw { + RE_EXN_ID: "Not_found", + Error: new Error() + }; + } + let l = x._0; + if (typeof l !== "object") { + return x._1; + } + _x = l; + continue; + }; + }; + let max_elt = _x => { + while (true) { + let x = _x; + if (typeof x !== "object") { + throw { + RE_EXN_ID: "Not_found", + Error: new Error() + }; + } + let r = x._2; + if (typeof r !== "object") { + return x._1; + } + _x = r; + continue; + }; + }; + let remove_min_elt = x => { + if (typeof x !== "object") { + return Pervasives.invalid_arg("Set.remove_min_elt"); + } + let l = x._0; + if (typeof l !== "object") { + return x._2; + } else { + return bal(remove_min_elt(l), x._1, x._2); + } + }; + let merge = (t1, t2) => { + if (typeof t1 !== "object") { + return t2; + } else if (typeof t2 !== "object") { + return t1; + } else { + return bal(t1, min_elt(t2), remove_min_elt(t2)); + } + }; + let concat = (t1, t2) => { + if (typeof t1 !== "object") { + return t2; + } else if (typeof t2 !== "object") { + return t1; + } else { + return join(t1, min_elt(t2), remove_min_elt(t2)); + } + }; + let split = (x, x_) => { + if (typeof x_ !== "object") { + return [ + "Empty", + false, + "Empty" + ]; + } + let r = x_._2; + let v = x_._1; + let l = x_._0; + let c = Ord.compare(x, v); + if (c === 0) { + return [ + l, + true, + r + ]; + } + if (c < 0) { + let match = split(x, l); + return [ + match[0], + match[1], + join(match[2], v, r) + ]; + } + let match$1 = split(x, r); + return [ + join(l, v, match$1[0]), + match$1[1], + match$1[2] + ]; + }; + let is_empty = x => { + if (typeof x !== "object") { + return true; + } else { + return false; + } + }; + let mem = (x, _x_) => { + while (true) { + let x_ = _x_; + if (typeof x_ !== "object") { + return false; + } + let c = Ord.compare(x, x_._1); + if (c === 0) { + return true; + } + _x_ = c < 0 ? x_._0 : x_._2; + continue; + }; + }; + let remove = (x, x_) => { + if (typeof x_ !== "object") { + return "Empty"; + } + let r = x_._2; + let v = x_._1; + let l = x_._0; + let c = Ord.compare(x, v); + if (c === 0) { + return merge(l, r); + } else if (c < 0) { + return bal(remove(x, l), v, r); + } else { + return bal(l, v, remove(x, r)); + } + }; + let union = (s1, s2) => { + if (typeof s1 !== "object") { + return s2; + } + let h1 = s1._3; + let v1 = s1._1; + if (typeof s2 !== "object") { + return s1; + } + let h2 = s2._3; + let v2 = s2._1; + if (h1 >= h2) { + if (h2 === 1) { + return add(v2, s1); + } + let match = split(v1, s2); + return join(union(s1._0, match[0]), v1, union(s1._2, match[2])); + } + if (h1 === 1) { + return add(v1, s2); + } + let match$1 = split(v2, s1); + return join(union(match$1[0], s2._0), v2, union(match$1[2], s2._2)); + }; + let inter = (s1, s2) => { + if (typeof s1 !== "object") { + return "Empty"; + } + if (typeof s2 !== "object") { + return "Empty"; + } + let r1 = s1._2; + let v1 = s1._1; + let l1 = s1._0; + let match = split(v1, s2); + let l2 = match[0]; + if (match[1]) { + return join(inter(l1, l2), v1, inter(r1, match[2])); + } else { + return concat(inter(l1, l2), inter(r1, match[2])); + } + }; + let diff = (s1, s2) => { + if (typeof s1 !== "object") { + return "Empty"; + } + if (typeof s2 !== "object") { + return s1; + } + let r1 = s1._2; + let v1 = s1._1; + let l1 = s1._0; + let match = split(v1, s2); + let l2 = match[0]; + if (match[1]) { + return concat(diff(l1, l2), diff(r1, match[2])); + } else { + return join(diff(l1, l2), v1, diff(r1, match[2])); + } + }; + let cons_enum = (_s, _e) => { + while (true) { + let e = _e; + let s = _s; + if (typeof s !== "object") { + return e; + } + _e = { + TAG: "More", + _0: s._1, + _1: s._2, + _2: e + }; + _s = s._0; + continue; + }; + }; + let compare_aux = (_e1, _e2) => { + while (true) { + let e2 = _e2; + let e1 = _e1; + if (typeof e1 !== "object") { + if (typeof e2 !== "object") { + return 0; + } else { + return -1; + } + } + if (typeof e2 !== "object") { + return 1; + } + let c = Ord.compare(e1._0, e2._0); + if (c !== 0) { + return c; + } + _e2 = cons_enum(e2._1, e2._2); + _e1 = cons_enum(e1._1, e1._2); + continue; + }; + }; + let compare = (s1, s2) => compare_aux(cons_enum(s1, "End"), cons_enum(s2, "End")); + let equal = (s1, s2) => compare(s1, s2) === 0; + let subset = (_s1, _s2) => { + while (true) { + let s2 = _s2; + let s1 = _s1; + if (typeof s1 !== "object") { + return true; + } + let r1 = s1._2; + let v1 = s1._1; + let l1 = s1._0; + if (typeof s2 !== "object") { + return false; + } + let r2 = s2._2; + let l2 = s2._0; + let c = Ord.compare(v1, s2._1); + if (c === 0) { + if (!subset(l1, l2)) { + return false; + } + _s2 = r2; + _s1 = r1; + continue; + } + if (c < 0) { + if (!subset({ + TAG: "Node", + _0: l1, + _1: v1, + _2: "Empty", + _3: 0 + }, l2)) { + return false; + } + _s1 = r1; + continue; + } + if (!subset({ + TAG: "Node", + _0: "Empty", + _1: v1, + _2: r1, + _3: 0 + }, r2)) { + return false; + } + _s1 = l1; + continue; + }; + }; + let iter = (f, _x_) => { + while (true) { + let x_ = _x_; + if (typeof x_ !== "object") { + return; + } + iter(f, x_._0); + f(x_._1); + _x_ = x_._2; + continue; + }; + }; + let fold = (f, _s, _accu) => { + while (true) { + let accu = _accu; + let s = _s; + if (typeof s !== "object") { + return accu; + } + _accu = f(s._1, fold(f, s._0, accu)); + _s = s._2; + continue; + }; + }; + let for_all = (p, _x) => { + while (true) { + let x = _x; + if (typeof x !== "object") { + return true; + } + if (!p(x._1)) { + return false; + } + if (!for_all(p, x._0)) { + return false; + } + _x = x._2; + continue; + }; + }; + let exists = (p, _x) => { + while (true) { + let x = _x; + if (typeof x !== "object") { + return false; + } + if (p(x._1)) { + return true; + } + if (exists(p, x._0)) { + return true; + } + _x = x._2; + continue; + }; + }; + let filter = (p, x) => { + if (typeof x !== "object") { + return "Empty"; + } + let v = x._1; + let l$p = filter(p, x._0); + let pv = p(v); + let r$p = filter(p, x._2); + if (pv) { + return join(l$p, v, r$p); + } else { + return concat(l$p, r$p); + } + }; + let partition = (p, x) => { + if (typeof x !== "object") { + return [ + "Empty", + "Empty" + ]; + } + let v = x._1; + let match = partition(p, x._0); + let lf = match[1]; + let lt = match[0]; + let pv = p(v); + let match$1 = partition(p, x._2); + let rf = match$1[1]; + let rt = match$1[0]; + if (pv) { + return [ + join(lt, v, rt), + concat(lf, rf) + ]; + } else { + return [ + concat(lt, rt), + join(lf, v, rf) + ]; + } + }; + let cardinal = x => { + if (typeof x !== "object") { + return 0; + } else { + return (cardinal(x._0) + 1 | 0) + cardinal(x._2) | 0; + } + }; + let elements_aux = (_accu, _x) => { + while (true) { + let x = _x; + let accu = _accu; + if (typeof x !== "object") { + return accu; + } + _x = x._0; + _accu = { + hd: x._1, + tl: elements_aux(accu, x._2) + }; + continue; + }; + }; + let elements = s => elements_aux(/* [] */0, s); + let find = (x, _x_) => { + while (true) { + let x_ = _x_; + if (typeof x_ !== "object") { + throw { + RE_EXN_ID: "Not_found", + Error: new Error() + }; + } + let v = x_._1; + let c = Ord.compare(x, v); + if (c === 0) { + return v; + } + _x_ = c < 0 ? x_._0 : x_._2; + continue; + }; + }; + let of_sorted_list = l => { + let sub = (n, l) => { + switch (n) { + case 0 : + return [ + "Empty", + l + ]; + case 1 : + if (l) { + return [ + { + TAG: "Node", + _0: "Empty", + _1: l.hd, + _2: "Empty", + _3: 1 + }, + l.tl + ]; + } + break; + case 2 : + if (l) { + let match = l.tl; + if (match) { + return [ + { + TAG: "Node", + _0: { + TAG: "Node", + _0: "Empty", + _1: l.hd, + _2: "Empty", + _3: 1 + }, + _1: match.hd, + _2: "Empty", + _3: 2 + }, + match.tl + ]; + } + + } + break; + case 3 : + if (l) { + let match$1 = l.tl; + if (match$1) { + let match$2 = match$1.tl; + if (match$2) { + return [ + { + TAG: "Node", + _0: { + TAG: "Node", + _0: "Empty", + _1: l.hd, + _2: "Empty", + _3: 1 + }, + _1: match$1.hd, + _2: { + TAG: "Node", + _0: "Empty", + _1: match$2.hd, + _2: "Empty", + _3: 1 + }, + _3: 2 + }, + match$2.tl + ]; + } + + } + + } + break; + } + let nl = n / 2 | 0; + let match$3 = sub(nl, l); + let l$1 = match$3[1]; + if (l$1) { + let match$4 = sub((n - nl | 0) - 1 | 0, l$1.tl); + return [ + create(match$3[0], l$1.hd, match$4[0]), + match$4[1] + ]; + } + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "test_set.res", + 497, + 20 + ], + Error: new Error() + }; + }; + return sub(Belt_List.length(l), l)[0]; + }; + let of_list = l => { + if (!l) { + return "Empty"; + } + let match = l.tl; + let x0 = l.hd; + if (!match) { + return singleton(x0); + } + let match$1 = match.tl; + let x1 = match.hd; + if (!match$1) { + return add(x1, singleton(x0)); + } + let match$2 = match$1.tl; + let x2 = match$1.hd; + if (!match$2) { + return add(x2, add(x1, singleton(x0))); + } + let match$3 = match$2.tl; + let x3 = match$2.hd; + if (match$3) { + if (match$3.tl) { + return of_sorted_list(Belt_List.sort(l, Ord.compare)); + } else { + return add(match$3.hd, add(x3, add(x2, add(x1, singleton(x0))))); + } + } else { + return add(x3, add(x2, add(x1, singleton(x0)))); + } + }; + return { + height: height, + create: create, + bal: bal, + add: add, + singleton: singleton, + add_min_element: add_min_element, + add_max_element: add_max_element, + join: join, + min_elt: min_elt, + max_elt: max_elt, + remove_min_elt: remove_min_elt, + merge: merge, + concat: concat, + split: split, + empty: "Empty", + is_empty: is_empty, + mem: mem, + remove: remove, + union: union, + inter: inter, + diff: diff, + cons_enum: cons_enum, + compare_aux: compare_aux, + compare: compare, + equal: equal, + subset: subset, + iter: iter, + fold: fold, + for_all: for_all, + exists: exists, + filter: filter, + partition: partition, + cardinal: cardinal, + elements_aux: elements_aux, + elements: elements, + choose: min_elt, + find: find, + of_sorted_list: of_sorted_list, + of_list: of_list + }; +} + +let N = { + a: 3 +}; + +export { + Make, + N, +} +/* No side effect */ diff --git a/tests/tests/src/test_side_effect_functor.js b/tests/tests/src/test_side_effect_functor.js deleted file mode 100644 index 1d0ada6b4a..0000000000 --- a/tests/tests/src/test_side_effect_functor.js +++ /dev/null @@ -1,18 +0,0 @@ -// Generated by ReScript, PLEASE EDIT WITH CARE -'use strict'; - - -let v = 0; - -v = v + 1 | 0; - -console.log(v.toString()); - -function unuse_v() { - return 35; -} - -let h = unuse_v; - -exports.h = h; -/* Not a pure module */ diff --git a/tests/tests/src/test_side_effect_functor.mjs b/tests/tests/src/test_side_effect_functor.mjs new file mode 100644 index 0000000000..1ae2c66498 --- /dev/null +++ b/tests/tests/src/test_side_effect_functor.mjs @@ -0,0 +1,19 @@ +// Generated by ReScript, PLEASE EDIT WITH CARE + + +let v = 0; + +v = v + 1 | 0; + +console.log(v.toString()); + +function unuse_v() { + return 35; +} + +let h = unuse_v; + +export { + h, +} +/* Not a pure module */ diff --git a/tests/tests/src/test_simple_include.js b/tests/tests/src/test_simple_include.js deleted file mode 100644 index 05180988c5..0000000000 --- a/tests/tests/src/test_simple_include.js +++ /dev/null @@ -1,248 +0,0 @@ -// Generated by ReScript, PLEASE EDIT WITH CARE -'use strict'; - -let Belt_Array = require("rescript/lib/js/Belt_Array.js"); - -let v = { - contents: 32 -}; - -v.contents = 0; - -let N = { - a: 3, - v: v -}; - -let v$1 = { - contents: 32 -}; - -let NN = { - a: 3, - v: v$1 -}; - -let get = Belt_Array.get; - -let getExn = Belt_Array.getExn; - -let set = Belt_Array.set; - -let setExn = Belt_Array.setExn; - -let shuffleInPlace = Belt_Array.shuffleInPlace; - -let shuffle = Belt_Array.shuffle; - -let reverseInPlace = Belt_Array.reverseInPlace; - -let reverse = Belt_Array.reverse; - -let make = Belt_Array.make; - -let range = Belt_Array.range; - -let rangeBy = Belt_Array.rangeBy; - -let makeByU = Belt_Array.makeByU; - -let makeBy = Belt_Array.makeBy; - -let makeByAndShuffleU = Belt_Array.makeByAndShuffleU; - -let makeByAndShuffle = Belt_Array.makeByAndShuffle; - -let zip = Belt_Array.zip; - -let zipByU = Belt_Array.zipByU; - -let zipBy = Belt_Array.zipBy; - -let unzip = Belt_Array.unzip; - -let concat = Belt_Array.concat; - -let concatMany = Belt_Array.concatMany; - -let slice = Belt_Array.slice; - -let sliceToEnd = Belt_Array.sliceToEnd; - -let fill = Belt_Array.fill; - -let blit = Belt_Array.blit; - -let blitUnsafe = Belt_Array.blitUnsafe; - -let forEachU = Belt_Array.forEachU; - -let forEach = Belt_Array.forEach; - -let mapU = Belt_Array.mapU; - -let map = Belt_Array.map; - -let flatMapU = Belt_Array.flatMapU; - -let flatMap = Belt_Array.flatMap; - -let getByU = Belt_Array.getByU; - -let getBy = Belt_Array.getBy; - -let getIndexByU = Belt_Array.getIndexByU; - -let getIndexBy = Belt_Array.getIndexBy; - -let keepU = Belt_Array.keepU; - -let keep = Belt_Array.keep; - -let keepWithIndexU = Belt_Array.keepWithIndexU; - -let keepWithIndex = Belt_Array.keepWithIndex; - -let keepMapU = Belt_Array.keepMapU; - -let keepMap = Belt_Array.keepMap; - -let forEachWithIndexU = Belt_Array.forEachWithIndexU; - -let forEachWithIndex = Belt_Array.forEachWithIndex; - -let mapWithIndexU = Belt_Array.mapWithIndexU; - -let mapWithIndex = Belt_Array.mapWithIndex; - -let partitionU = Belt_Array.partitionU; - -let partition = Belt_Array.partition; - -let reduceU = Belt_Array.reduceU; - -let reduce = Belt_Array.reduce; - -let reduceReverseU = Belt_Array.reduceReverseU; - -let reduceReverse = Belt_Array.reduceReverse; - -let reduceReverse2U = Belt_Array.reduceReverse2U; - -let reduceReverse2 = Belt_Array.reduceReverse2; - -let reduceWithIndexU = Belt_Array.reduceWithIndexU; - -let reduceWithIndex = Belt_Array.reduceWithIndex; - -let joinWithU = Belt_Array.joinWithU; - -let joinWith = Belt_Array.joinWith; - -let someU = Belt_Array.someU; - -let some = Belt_Array.some; - -let everyU = Belt_Array.everyU; - -let every = Belt_Array.every; - -let every2U = Belt_Array.every2U; - -let every2 = Belt_Array.every2; - -let some2U = Belt_Array.some2U; - -let some2 = Belt_Array.some2; - -let cmpU = Belt_Array.cmpU; - -let cmp = Belt_Array.cmp; - -let eqU = Belt_Array.eqU; - -let eq = Belt_Array.eq; - -let initU = Belt_Array.initU; - -let init = Belt_Array.init; - -let a = 3; - -exports.get = get; -exports.getExn = getExn; -exports.set = set; -exports.setExn = setExn; -exports.shuffleInPlace = shuffleInPlace; -exports.shuffle = shuffle; -exports.reverseInPlace = reverseInPlace; -exports.reverse = reverse; -exports.make = make; -exports.range = range; -exports.rangeBy = rangeBy; -exports.makeByU = makeByU; -exports.makeBy = makeBy; -exports.makeByAndShuffleU = makeByAndShuffleU; -exports.makeByAndShuffle = makeByAndShuffle; -exports.zip = zip; -exports.zipByU = zipByU; -exports.zipBy = zipBy; -exports.unzip = unzip; -exports.concat = concat; -exports.concatMany = concatMany; -exports.slice = slice; -exports.sliceToEnd = sliceToEnd; -exports.fill = fill; -exports.blit = blit; -exports.blitUnsafe = blitUnsafe; -exports.forEachU = forEachU; -exports.forEach = forEach; -exports.mapU = mapU; -exports.map = map; -exports.flatMapU = flatMapU; -exports.flatMap = flatMap; -exports.getByU = getByU; -exports.getBy = getBy; -exports.getIndexByU = getIndexByU; -exports.getIndexBy = getIndexBy; -exports.keepU = keepU; -exports.keep = keep; -exports.keepWithIndexU = keepWithIndexU; -exports.keepWithIndex = keepWithIndex; -exports.keepMapU = keepMapU; -exports.keepMap = keepMap; -exports.forEachWithIndexU = forEachWithIndexU; -exports.forEachWithIndex = forEachWithIndex; -exports.mapWithIndexU = mapWithIndexU; -exports.mapWithIndex = mapWithIndex; -exports.partitionU = partitionU; -exports.partition = partition; -exports.reduceU = reduceU; -exports.reduce = reduce; -exports.reduceReverseU = reduceReverseU; -exports.reduceReverse = reduceReverse; -exports.reduceReverse2U = reduceReverse2U; -exports.reduceReverse2 = reduceReverse2; -exports.reduceWithIndexU = reduceWithIndexU; -exports.reduceWithIndex = reduceWithIndex; -exports.joinWithU = joinWithU; -exports.joinWith = joinWith; -exports.someU = someU; -exports.some = some; -exports.everyU = everyU; -exports.every = every; -exports.every2U = every2U; -exports.every2 = every2; -exports.some2U = some2U; -exports.some2 = some2; -exports.cmpU = cmpU; -exports.cmp = cmp; -exports.eqU = eqU; -exports.eq = eq; -exports.initU = initU; -exports.init = init; -exports.N = N; -exports.NN = NN; -exports.a = a; -exports.v = v; -/* Not a pure module */ diff --git a/tests/tests/src/test_simple_include.mjs b/tests/tests/src/test_simple_include.mjs new file mode 100644 index 0000000000..0d04e52126 --- /dev/null +++ b/tests/tests/src/test_simple_include.mjs @@ -0,0 +1,249 @@ +// Generated by ReScript, PLEASE EDIT WITH CARE + +import * as Belt_Array from "rescript/lib/es6/Belt_Array.js"; + +let v = { + contents: 32 +}; + +v.contents = 0; + +let N = { + a: 3, + v: v +}; + +let v$1 = { + contents: 32 +}; + +let NN = { + a: 3, + v: v$1 +}; + +let get = Belt_Array.get; + +let getExn = Belt_Array.getExn; + +let set = Belt_Array.set; + +let setExn = Belt_Array.setExn; + +let shuffleInPlace = Belt_Array.shuffleInPlace; + +let shuffle = Belt_Array.shuffle; + +let reverseInPlace = Belt_Array.reverseInPlace; + +let reverse = Belt_Array.reverse; + +let make = Belt_Array.make; + +let range = Belt_Array.range; + +let rangeBy = Belt_Array.rangeBy; + +let makeByU = Belt_Array.makeByU; + +let makeBy = Belt_Array.makeBy; + +let makeByAndShuffleU = Belt_Array.makeByAndShuffleU; + +let makeByAndShuffle = Belt_Array.makeByAndShuffle; + +let zip = Belt_Array.zip; + +let zipByU = Belt_Array.zipByU; + +let zipBy = Belt_Array.zipBy; + +let unzip = Belt_Array.unzip; + +let concat = Belt_Array.concat; + +let concatMany = Belt_Array.concatMany; + +let slice = Belt_Array.slice; + +let sliceToEnd = Belt_Array.sliceToEnd; + +let fill = Belt_Array.fill; + +let blit = Belt_Array.blit; + +let blitUnsafe = Belt_Array.blitUnsafe; + +let forEachU = Belt_Array.forEachU; + +let forEach = Belt_Array.forEach; + +let mapU = Belt_Array.mapU; + +let map = Belt_Array.map; + +let flatMapU = Belt_Array.flatMapU; + +let flatMap = Belt_Array.flatMap; + +let getByU = Belt_Array.getByU; + +let getBy = Belt_Array.getBy; + +let getIndexByU = Belt_Array.getIndexByU; + +let getIndexBy = Belt_Array.getIndexBy; + +let keepU = Belt_Array.keepU; + +let keep = Belt_Array.keep; + +let keepWithIndexU = Belt_Array.keepWithIndexU; + +let keepWithIndex = Belt_Array.keepWithIndex; + +let keepMapU = Belt_Array.keepMapU; + +let keepMap = Belt_Array.keepMap; + +let forEachWithIndexU = Belt_Array.forEachWithIndexU; + +let forEachWithIndex = Belt_Array.forEachWithIndex; + +let mapWithIndexU = Belt_Array.mapWithIndexU; + +let mapWithIndex = Belt_Array.mapWithIndex; + +let partitionU = Belt_Array.partitionU; + +let partition = Belt_Array.partition; + +let reduceU = Belt_Array.reduceU; + +let reduce = Belt_Array.reduce; + +let reduceReverseU = Belt_Array.reduceReverseU; + +let reduceReverse = Belt_Array.reduceReverse; + +let reduceReverse2U = Belt_Array.reduceReverse2U; + +let reduceReverse2 = Belt_Array.reduceReverse2; + +let reduceWithIndexU = Belt_Array.reduceWithIndexU; + +let reduceWithIndex = Belt_Array.reduceWithIndex; + +let joinWithU = Belt_Array.joinWithU; + +let joinWith = Belt_Array.joinWith; + +let someU = Belt_Array.someU; + +let some = Belt_Array.some; + +let everyU = Belt_Array.everyU; + +let every = Belt_Array.every; + +let every2U = Belt_Array.every2U; + +let every2 = Belt_Array.every2; + +let some2U = Belt_Array.some2U; + +let some2 = Belt_Array.some2; + +let cmpU = Belt_Array.cmpU; + +let cmp = Belt_Array.cmp; + +let eqU = Belt_Array.eqU; + +let eq = Belt_Array.eq; + +let initU = Belt_Array.initU; + +let init = Belt_Array.init; + +let a = 3; + +export { + get, + getExn, + set, + setExn, + shuffleInPlace, + shuffle, + reverseInPlace, + reverse, + make, + range, + rangeBy, + makeByU, + makeBy, + makeByAndShuffleU, + makeByAndShuffle, + zip, + zipByU, + zipBy, + unzip, + concat, + concatMany, + slice, + sliceToEnd, + fill, + blit, + blitUnsafe, + forEachU, + forEach, + mapU, + map, + flatMapU, + flatMap, + getByU, + getBy, + getIndexByU, + getIndexBy, + keepU, + keep, + keepWithIndexU, + keepWithIndex, + keepMapU, + keepMap, + forEachWithIndexU, + forEachWithIndex, + mapWithIndexU, + mapWithIndex, + partitionU, + partition, + reduceU, + reduce, + reduceReverseU, + reduceReverse, + reduceReverse2U, + reduceReverse2, + reduceWithIndexU, + reduceWithIndex, + joinWithU, + joinWith, + someU, + some, + everyU, + every, + every2U, + every2, + some2U, + some2, + cmpU, + cmp, + eqU, + eq, + initU, + init, + N, + NN, + a, + v, +} +/* Not a pure module */ diff --git a/tests/tests/src/test_simple_pattern_match.js b/tests/tests/src/test_simple_pattern_match.js deleted file mode 100644 index 154ec50b37..0000000000 --- a/tests/tests/src/test_simple_pattern_match.js +++ /dev/null @@ -1,31 +0,0 @@ -// Generated by ReScript, PLEASE EDIT WITH CARE -'use strict'; - -let Nodeos = require("node:os"); - -let match = Nodeos.platform(); - -let match$1; - -switch (match) { - case "darwin" : - case "linux" : - match$1 = [ - 1, - 2 - ]; - break; - default: - match$1 = [ - 3, - 4 - ]; -} - -let a = match$1[0]; - -let b = match$1[1]; - -exports.a = a; -exports.b = b; -/* match Not a pure module */ diff --git a/tests/tests/src/test_simple_pattern_match.mjs b/tests/tests/src/test_simple_pattern_match.mjs new file mode 100644 index 0000000000..76fb055a30 --- /dev/null +++ b/tests/tests/src/test_simple_pattern_match.mjs @@ -0,0 +1,32 @@ +// Generated by ReScript, PLEASE EDIT WITH CARE + +import * as Nodeos from "node:os"; + +let match = Nodeos.platform(); + +let match$1; + +switch (match) { + case "darwin" : + case "linux" : + match$1 = [ + 1, + 2 + ]; + break; + default: + match$1 = [ + 3, + 4 + ]; +} + +let a = match$1[0]; + +let b = match$1[1]; + +export { + a, + b, +} +/* match Not a pure module */ diff --git a/tests/tests/src/test_simple_ref.js b/tests/tests/src/test_simple_ref.js deleted file mode 100644 index 3fd4056ff3..0000000000 --- a/tests/tests/src/test_simple_ref.js +++ /dev/null @@ -1,36 +0,0 @@ -// Generated by ReScript, PLEASE EDIT WITH CARE -'use strict'; - - -let v = { - contents: 0 -}; - -function gen() { - v.contents = v.contents + 1 | 0; - return v.contents; -} - -let h = { - contents: 0 -}; - -let a = 0; - -let c = { - contents: 0 -}; - -let not_real_escape = a; - -function real_escape(f, v) { - return f(c); -} - -let u = h; - -exports.u = u; -exports.gen = gen; -exports.not_real_escape = not_real_escape; -exports.real_escape = real_escape; -/* No side effect */ diff --git a/tests/tests/src/test_simple_ref.mjs b/tests/tests/src/test_simple_ref.mjs new file mode 100644 index 0000000000..68d40783de --- /dev/null +++ b/tests/tests/src/test_simple_ref.mjs @@ -0,0 +1,37 @@ +// Generated by ReScript, PLEASE EDIT WITH CARE + + +let v = { + contents: 0 +}; + +function gen() { + v.contents = v.contents + 1 | 0; + return v.contents; +} + +let h = { + contents: 0 +}; + +let a = 0; + +let c = { + contents: 0 +}; + +let not_real_escape = a; + +function real_escape(f, v) { + return f(c); +} + +let u = h; + +export { + u, + gen, + not_real_escape, + real_escape, +} +/* No side effect */ diff --git a/tests/tests/src/test_simple_tailcall.js b/tests/tests/src/test_simple_tailcall.js deleted file mode 100644 index 016ca54fba..0000000000 --- a/tests/tests/src/test_simple_tailcall.js +++ /dev/null @@ -1,39 +0,0 @@ -// Generated by ReScript, PLEASE EDIT WITH CARE -'use strict'; - - -function tailcall(x) { - while (true) { - continue; - }; -} - -function non_length(x) { - if (x) { - return 1 + non_length(x.tl) | 0; - } else { - return 0; - } -} - -function length(_acc, _x) { - while (true) { - let x = _x; - let acc = _acc; - if (!x) { - return acc; - } - let tl = x.tl; - if (tl) { - return 1 + length(acc + 1 | 0, tl.tl) | 0; - } - _x = tl; - _acc = acc + 1 | 0; - continue; - }; -} - -exports.tailcall = tailcall; -exports.non_length = non_length; -exports.length = length; -/* No side effect */ diff --git a/tests/tests/src/test_simple_tailcall.mjs b/tests/tests/src/test_simple_tailcall.mjs new file mode 100644 index 0000000000..48ae85ce9c --- /dev/null +++ b/tests/tests/src/test_simple_tailcall.mjs @@ -0,0 +1,40 @@ +// Generated by ReScript, PLEASE EDIT WITH CARE + + +function tailcall(x) { + while (true) { + continue; + }; +} + +function non_length(x) { + if (x) { + return 1 + non_length(x.tl) | 0; + } else { + return 0; + } +} + +function length(_acc, _x) { + while (true) { + let x = _x; + let acc = _acc; + if (!x) { + return acc; + } + let tl = x.tl; + if (tl) { + return 1 + length(acc + 1 | 0, tl.tl) | 0; + } + _x = tl; + _acc = acc + 1 | 0; + continue; + }; +} + +export { + tailcall, + non_length, + length, +} +/* No side effect */ diff --git a/tests/tests/src/test_small.js b/tests/tests/src/test_small.js deleted file mode 100644 index ff80c9f6ce..0000000000 --- a/tests/tests/src/test_small.js +++ /dev/null @@ -1,11 +0,0 @@ -// Generated by ReScript, PLEASE EDIT WITH CARE -'use strict'; - - -let fib = 3; - -let u = 3; - -exports.fib = fib; -exports.u = u; -/* No side effect */ diff --git a/tests/tests/src/test_small.mjs b/tests/tests/src/test_small.mjs new file mode 100644 index 0000000000..1622679a11 --- /dev/null +++ b/tests/tests/src/test_small.mjs @@ -0,0 +1,12 @@ +// Generated by ReScript, PLEASE EDIT WITH CARE + + +let fib = 3; + +let u = 3; + +export { + fib, + u, +} +/* No side effect */ diff --git a/tests/tests/src/test_static_catch_ident.js b/tests/tests/src/test_static_catch_ident.js deleted file mode 100644 index 0dc258c014..0000000000 --- a/tests/tests/src/test_static_catch_ident.js +++ /dev/null @@ -1,23 +0,0 @@ -// Generated by ReScript, PLEASE EDIT WITH CARE -'use strict'; - -let Primitive_exceptions = require("rescript/lib/js/Primitive_exceptions.js"); - -let Scan_failure = /* @__PURE__ */Primitive_exceptions.create("Test_static_catch_ident.Scan_failure"); - -function scanf_bad_input(ib, x) { - let s; - if (x.RE_EXN_ID === Scan_failure || x.RE_EXN_ID === "Failure") { - s = x._1; - } else { - throw x; - } - for (let i = 0; i <= 100; ++i) { - console.log(s); - console.log("don't inlinie"); - } -} - -exports.Scan_failure = Scan_failure; -exports.scanf_bad_input = scanf_bad_input; -/* No side effect */ diff --git a/tests/tests/src/test_static_catch_ident.mjs b/tests/tests/src/test_static_catch_ident.mjs new file mode 100644 index 0000000000..53485171d9 --- /dev/null +++ b/tests/tests/src/test_static_catch_ident.mjs @@ -0,0 +1,24 @@ +// Generated by ReScript, PLEASE EDIT WITH CARE + +import * as Primitive_exceptions from "rescript/lib/es6/Primitive_exceptions.js"; + +let Scan_failure = /* @__PURE__ */Primitive_exceptions.create("Test_static_catch_ident.Scan_failure"); + +function scanf_bad_input(ib, x) { + let s; + if (x.RE_EXN_ID === Scan_failure || x.RE_EXN_ID === "Failure") { + s = x._1; + } else { + throw x; + } + for (let i = 0; i <= 100; ++i) { + console.log(s); + console.log("don't inlinie"); + } +} + +export { + Scan_failure, + scanf_bad_input, +} +/* No side effect */ diff --git a/tests/tests/src/test_string.js b/tests/tests/src/test_string.js deleted file mode 100644 index c850635499..0000000000 --- a/tests/tests/src/test_string.js +++ /dev/null @@ -1,51 +0,0 @@ -// Generated by ReScript, PLEASE EDIT WITH CARE -'use strict'; - - -function f(x) { - switch (x) { - case "aaaabb" : - return 0; - case "bbbb" : - return 1; - default: - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "test_string.res", - 7, - 17 - ], - Error: new Error() - }; - } -} - -function a(x) { - return "helloworldhello" + x; -} - -function b(y, x) { - return y + ("helloworldhello" + x); -} - -function c(x, y) { - return x + "hellohiuhi" + y; -} - -let v = "xx".length; - -function h(s) { - return s.codePointAt(0) === /* 'a' */97; -} - -let $$String; - -exports.$$String = $$String; -exports.f = f; -exports.a = a; -exports.b = b; -exports.c = c; -exports.v = v; -exports.h = h; -/* No side effect */ diff --git a/tests/tests/src/test_string.mjs b/tests/tests/src/test_string.mjs new file mode 100644 index 0000000000..2a2632bab0 --- /dev/null +++ b/tests/tests/src/test_string.mjs @@ -0,0 +1,52 @@ +// Generated by ReScript, PLEASE EDIT WITH CARE + + +function f(x) { + switch (x) { + case "aaaabb" : + return 0; + case "bbbb" : + return 1; + default: + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "test_string.res", + 7, + 17 + ], + Error: new Error() + }; + } +} + +function a(x) { + return "helloworldhello" + x; +} + +function b(y, x) { + return y + ("helloworldhello" + x); +} + +function c(x, y) { + return x + "hellohiuhi" + y; +} + +let v = "xx".length; + +function h(s) { + return s.codePointAt(0) === /* 'a' */97; +} + +let $$String; + +export { + $$String, + f, + a, + b, + c, + v, + h, +} +/* No side effect */ diff --git a/tests/tests/src/test_string_case.js b/tests/tests/src/test_string_case.js deleted file mode 100644 index dcd3cb6352..0000000000 --- a/tests/tests/src/test_string_case.js +++ /dev/null @@ -1,25 +0,0 @@ -// Generated by ReScript, PLEASE EDIT WITH CARE -'use strict'; - - -function f(x) { - switch (x) { - case "abcd" : - return 0; - case "bcde" : - return 1; - default: - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "test_string_case.res", - 5, - 9 - ], - Error: new Error() - }; - } -} - -exports.f = f; -/* No side effect */ diff --git a/tests/tests/src/test_string_case.mjs b/tests/tests/src/test_string_case.mjs new file mode 100644 index 0000000000..a02aafe9a9 --- /dev/null +++ b/tests/tests/src/test_string_case.mjs @@ -0,0 +1,26 @@ +// Generated by ReScript, PLEASE EDIT WITH CARE + + +function f(x) { + switch (x) { + case "abcd" : + return 0; + case "bcde" : + return 1; + default: + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "test_string_case.res", + 5, + 9 + ], + Error: new Error() + }; + } +} + +export { + f, +} +/* No side effect */ diff --git a/tests/tests/src/test_string_const.js b/tests/tests/src/test_string_const.js deleted file mode 100644 index a5c39aa243..0000000000 --- a/tests/tests/src/test_string_const.js +++ /dev/null @@ -1,27 +0,0 @@ -// Generated by ReScript, PLEASE EDIT WITH CARE -'use strict'; - -let Primitive_exceptions = require("rescript/lib/js/Primitive_exceptions.js"); - -let f = "ghsogh".codePointAt(3); - -let hh; - -try { - hh = "ghsogh".codePointAt(-3); -} catch (raw_e) { - let e = Primitive_exceptions.internalToException(raw_e); - if (e.RE_EXN_ID === "Invalid_argument") { - console.log(e._1); - hh = /* 'a' */97; - } else { - throw e; - } -} - -let $$String; - -exports.$$String = $$String; -exports.f = f; -exports.hh = hh; -/* f Not a pure module */ diff --git a/tests/tests/src/test_string_const.mjs b/tests/tests/src/test_string_const.mjs new file mode 100644 index 0000000000..e130e3b86f --- /dev/null +++ b/tests/tests/src/test_string_const.mjs @@ -0,0 +1,28 @@ +// Generated by ReScript, PLEASE EDIT WITH CARE + +import * as Primitive_exceptions from "rescript/lib/es6/Primitive_exceptions.js"; + +let f = "ghsogh".codePointAt(3); + +let hh; + +try { + hh = "ghsogh".codePointAt(-3); +} catch (raw_e) { + let e = Primitive_exceptions.internalToException(raw_e); + if (e.RE_EXN_ID === "Invalid_argument") { + console.log(e._1); + hh = /* 'a' */97; + } else { + throw e; + } +} + +let $$String; + +export { + $$String, + f, + hh, +} +/* f Not a pure module */ diff --git a/tests/tests/src/test_string_map.js b/tests/tests/src/test_string_map.js deleted file mode 100644 index 5e3d854d6e..0000000000 --- a/tests/tests/src/test_string_map.js +++ /dev/null @@ -1,29 +0,0 @@ -// Generated by ReScript, PLEASE EDIT WITH CARE -'use strict'; - -let Belt_MapString = require("rescript/lib/js/Belt_MapString.js"); - -function timing(label, f) { - console.time(label); - f(); - console.timeEnd(label); -} - -function assertion_test() { - let m = { - contents: undefined - }; - timing("building", () => { - for (let i = 0; i <= 1000000; ++i) { - m.contents = Belt_MapString.set(m.contents, i.toString(), i.toString()); - } - }); - timing("querying", () => { - for (let i = 0; i <= 1000000; ++i) { - Belt_MapString.get(m.contents, i.toString()); - } - }); -} - -exports.assertion_test = assertion_test; -/* No side effect */ diff --git a/tests/tests/src/test_string_map.mjs b/tests/tests/src/test_string_map.mjs new file mode 100644 index 0000000000..519403a178 --- /dev/null +++ b/tests/tests/src/test_string_map.mjs @@ -0,0 +1,30 @@ +// Generated by ReScript, PLEASE EDIT WITH CARE + +import * as Belt_MapString from "rescript/lib/es6/Belt_MapString.js"; + +function timing(label, f) { + console.time(label); + f(); + console.timeEnd(label); +} + +function assertion_test() { + let m = { + contents: undefined + }; + timing("building", () => { + for (let i = 0; i <= 1000000; ++i) { + m.contents = Belt_MapString.set(m.contents, i.toString(), i.toString()); + } + }); + timing("querying", () => { + for (let i = 0; i <= 1000000; ++i) { + Belt_MapString.get(m.contents, i.toString()); + } + }); +} + +export { + assertion_test, +} +/* No side effect */ diff --git a/tests/tests/src/test_string_switch.js b/tests/tests/src/test_string_switch.js deleted file mode 100644 index 3f93840d85..0000000000 --- a/tests/tests/src/test_string_switch.js +++ /dev/null @@ -1,22 +0,0 @@ -// Generated by ReScript, PLEASE EDIT WITH CARE -'use strict'; - -let Nodeos = require("node:os"); - -let match = Nodeos.platform(); - -let version; - -switch (match) { - case "darwin" : - version = 2; - break; - case "linux" : - version = 1; - break; - default: - version = 3; -} - -exports.version = version; -/* match Not a pure module */ diff --git a/tests/tests/src/test_string_switch.mjs b/tests/tests/src/test_string_switch.mjs new file mode 100644 index 0000000000..edad912e6b --- /dev/null +++ b/tests/tests/src/test_string_switch.mjs @@ -0,0 +1,23 @@ +// Generated by ReScript, PLEASE EDIT WITH CARE + +import * as Nodeos from "node:os"; + +let match = Nodeos.platform(); + +let version; + +switch (match) { + case "darwin" : + version = 2; + break; + case "linux" : + version = 1; + break; + default: + version = 3; +} + +export { + version, +} +/* match Not a pure module */ diff --git a/tests/tests/src/test_switch.js b/tests/tests/src/test_switch.js deleted file mode 100644 index ccb9fab571..0000000000 --- a/tests/tests/src/test_switch.js +++ /dev/null @@ -1,38 +0,0 @@ -// Generated by ReScript, PLEASE EDIT WITH CARE -'use strict'; - - -function f(x) { - if (typeof x !== "object") { - if (x === "G") { - return 4; - } else { - return 5; - } - } - switch (x.TAG) { - case "A" : - return 0; - case "B" : - return 1; - case "C" : - return 2; - case "F" : - return 3; - } -} - -function bind(x, f) { - if (x.TAG === "Left") { - return { - TAG: "Left", - _0: f(x._0) - }; - } else { - return x; - } -} - -exports.f = f; -exports.bind = bind; -/* No side effect */ diff --git a/tests/tests/src/test_switch.mjs b/tests/tests/src/test_switch.mjs new file mode 100644 index 0000000000..576285e67c --- /dev/null +++ b/tests/tests/src/test_switch.mjs @@ -0,0 +1,39 @@ +// Generated by ReScript, PLEASE EDIT WITH CARE + + +function f(x) { + if (typeof x !== "object") { + if (x === "G") { + return 4; + } else { + return 5; + } + } + switch (x.TAG) { + case "A" : + return 0; + case "B" : + return 1; + case "C" : + return 2; + case "F" : + return 3; + } +} + +function bind(x, f) { + if (x.TAG === "Left") { + return { + TAG: "Left", + _0: f(x._0) + }; + } else { + return x; + } +} + +export { + f, + bind, +} +/* No side effect */ diff --git a/tests/tests/src/test_trywith.js b/tests/tests/src/test_trywith.js deleted file mode 100644 index 8de11ff0c0..0000000000 --- a/tests/tests/src/test_trywith.js +++ /dev/null @@ -1,145 +0,0 @@ -// Generated by ReScript, PLEASE EDIT WITH CARE -'use strict'; - -let Primitive_exceptions = require("rescript/lib/js/Primitive_exceptions.js"); - -let Out_of_memory = /* @__PURE__ */Primitive_exceptions.create("Test_trywith.Out_of_memory"); - -let Sys_error = /* @__PURE__ */Primitive_exceptions.create("Test_trywith.Sys_error"); - -let Stack_overflow = /* @__PURE__ */Primitive_exceptions.create("Test_trywith.Stack_overflow"); - -let Sys_blocked_io = /* @__PURE__ */Primitive_exceptions.create("Test_trywith.Sys_blocked_io"); - -function ff(g, x) { - try { - g(x); - } catch (raw_exn) { - let exn = Primitive_exceptions.internalToException(raw_exn); - if (exn.RE_EXN_ID !== "Not_found") { - throw exn; - } - - } - try { - g(x); - } catch (raw_exn$1) { - let exn$1 = Primitive_exceptions.internalToException(raw_exn$1); - if (exn$1.RE_EXN_ID !== Out_of_memory) { - throw exn$1; - } - - } - try { - g(x); - } catch (raw_exn$2) { - let exn$2 = Primitive_exceptions.internalToException(raw_exn$2); - if (exn$2.RE_EXN_ID !== Sys_error) { - throw exn$2; - } - - } - try { - g(x); - } catch (raw_exn$3) { - let exn$3 = Primitive_exceptions.internalToException(raw_exn$3); - if (exn$3.RE_EXN_ID !== "Invalid_argument") { - throw exn$3; - } - - } - try { - g(x); - } catch (raw_exn$4) { - let exn$4 = Primitive_exceptions.internalToException(raw_exn$4); - if (exn$4.RE_EXN_ID !== "End_of_file") { - throw exn$4; - } - - } - try { - g(x); - } catch (raw_exn$5) { - let exn$5 = Primitive_exceptions.internalToException(raw_exn$5); - if (exn$5.RE_EXN_ID !== "Match_failure") { - throw exn$5; - } - - } - try { - g(x); - } catch (raw_exn$6) { - let exn$6 = Primitive_exceptions.internalToException(raw_exn$6); - if (exn$6.RE_EXN_ID !== Stack_overflow) { - throw exn$6; - } - - } - try { - g(x); - } catch (raw_exn$7) { - let exn$7 = Primitive_exceptions.internalToException(raw_exn$7); - if (exn$7.RE_EXN_ID !== Sys_blocked_io) { - throw exn$7; - } - - } - try { - g(x); - } catch (raw_exn$8) { - let exn$8 = Primitive_exceptions.internalToException(raw_exn$8); - if (exn$8.RE_EXN_ID !== "Assert_failure") { - throw exn$8; - } - - } - try { - return g(x); - } catch (raw_exn$9) { - let exn$9 = Primitive_exceptions.internalToException(raw_exn$9); - if (exn$9.RE_EXN_ID === "Undefined_recursive_module") { - return; - } - throw exn$9; - } -} - -function u() { - throw { - RE_EXN_ID: "Not_found", - Error: new Error() - }; -} - -function f(x) { - if (typeof x !== "object") { - return 2; - } - if (x.TAG === "D") { - return 1; - } - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "test_trywith.res", - 59, - 9 - ], - Error: new Error() - }; -} - -let u1 = "bad character decimal encoding \\"; - -let v = "bad character decimal encoding \\%c%c%c"; - -exports.Out_of_memory = Out_of_memory; -exports.Sys_error = Sys_error; -exports.Stack_overflow = Stack_overflow; -exports.Sys_blocked_io = Sys_blocked_io; -exports.ff = ff; -exports.u = u; -exports.u1 = u1; -exports.v = v; -exports.f = f; -/* No side effect */ diff --git a/tests/tests/src/test_trywith.mjs b/tests/tests/src/test_trywith.mjs new file mode 100644 index 0000000000..0d1007a336 --- /dev/null +++ b/tests/tests/src/test_trywith.mjs @@ -0,0 +1,146 @@ +// Generated by ReScript, PLEASE EDIT WITH CARE + +import * as Primitive_exceptions from "rescript/lib/es6/Primitive_exceptions.js"; + +let Out_of_memory = /* @__PURE__ */Primitive_exceptions.create("Test_trywith.Out_of_memory"); + +let Sys_error = /* @__PURE__ */Primitive_exceptions.create("Test_trywith.Sys_error"); + +let Stack_overflow = /* @__PURE__ */Primitive_exceptions.create("Test_trywith.Stack_overflow"); + +let Sys_blocked_io = /* @__PURE__ */Primitive_exceptions.create("Test_trywith.Sys_blocked_io"); + +function ff(g, x) { + try { + g(x); + } catch (raw_exn) { + let exn = Primitive_exceptions.internalToException(raw_exn); + if (exn.RE_EXN_ID !== "Not_found") { + throw exn; + } + + } + try { + g(x); + } catch (raw_exn$1) { + let exn$1 = Primitive_exceptions.internalToException(raw_exn$1); + if (exn$1.RE_EXN_ID !== Out_of_memory) { + throw exn$1; + } + + } + try { + g(x); + } catch (raw_exn$2) { + let exn$2 = Primitive_exceptions.internalToException(raw_exn$2); + if (exn$2.RE_EXN_ID !== Sys_error) { + throw exn$2; + } + + } + try { + g(x); + } catch (raw_exn$3) { + let exn$3 = Primitive_exceptions.internalToException(raw_exn$3); + if (exn$3.RE_EXN_ID !== "Invalid_argument") { + throw exn$3; + } + + } + try { + g(x); + } catch (raw_exn$4) { + let exn$4 = Primitive_exceptions.internalToException(raw_exn$4); + if (exn$4.RE_EXN_ID !== "End_of_file") { + throw exn$4; + } + + } + try { + g(x); + } catch (raw_exn$5) { + let exn$5 = Primitive_exceptions.internalToException(raw_exn$5); + if (exn$5.RE_EXN_ID !== "Match_failure") { + throw exn$5; + } + + } + try { + g(x); + } catch (raw_exn$6) { + let exn$6 = Primitive_exceptions.internalToException(raw_exn$6); + if (exn$6.RE_EXN_ID !== Stack_overflow) { + throw exn$6; + } + + } + try { + g(x); + } catch (raw_exn$7) { + let exn$7 = Primitive_exceptions.internalToException(raw_exn$7); + if (exn$7.RE_EXN_ID !== Sys_blocked_io) { + throw exn$7; + } + + } + try { + g(x); + } catch (raw_exn$8) { + let exn$8 = Primitive_exceptions.internalToException(raw_exn$8); + if (exn$8.RE_EXN_ID !== "Assert_failure") { + throw exn$8; + } + + } + try { + return g(x); + } catch (raw_exn$9) { + let exn$9 = Primitive_exceptions.internalToException(raw_exn$9); + if (exn$9.RE_EXN_ID === "Undefined_recursive_module") { + return; + } + throw exn$9; + } +} + +function u() { + throw { + RE_EXN_ID: "Not_found", + Error: new Error() + }; +} + +function f(x) { + if (typeof x !== "object") { + return 2; + } + if (x.TAG === "D") { + return 1; + } + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "test_trywith.res", + 59, + 9 + ], + Error: new Error() + }; +} + +let u1 = "bad character decimal encoding \\"; + +let v = "bad character decimal encoding \\%c%c%c"; + +export { + Out_of_memory, + Sys_error, + Stack_overflow, + Sys_blocked_io, + ff, + u, + u1, + v, + f, +} +/* No side effect */ diff --git a/tests/tests/src/test_tuple.js b/tests/tests/src/test_tuple.js deleted file mode 100644 index 2cf819e9e3..0000000000 --- a/tests/tests/src/test_tuple.js +++ /dev/null @@ -1,20 +0,0 @@ -// Generated by ReScript, PLEASE EDIT WITH CARE -'use strict'; - - -let r = 0; - -for (let k = 1; k <= 10; ++k) { - for (let i = 1; i <= 10; ++i) { - let match = i % 2 === 0 ? [ - 1, - (i << 1) - ] : [ - 2, - Math.imul(i, 3) - ]; - r = Math.imul(r, match[0]) + match[1] | 0; - } -} - -/* Not a pure module */ diff --git a/tests/tests/src/test_tuple.mjs b/tests/tests/src/test_tuple.mjs new file mode 100644 index 0000000000..70c8d929d9 --- /dev/null +++ b/tests/tests/src/test_tuple.mjs @@ -0,0 +1,19 @@ +// Generated by ReScript, PLEASE EDIT WITH CARE + + +let r = 0; + +for (let k = 1; k <= 10; ++k) { + for (let i = 1; i <= 10; ++i) { + let match = i % 2 === 0 ? [ + 1, + (i << 1) + ] : [ + 2, + Math.imul(i, 3) + ]; + r = Math.imul(r, match[0]) + match[1] | 0; + } +} + +/* Not a pure module */ diff --git a/tests/tests/src/test_tuple_destructring.js b/tests/tests/src/test_tuple_destructring.js deleted file mode 100644 index 0603900110..0000000000 --- a/tests/tests/src/test_tuple_destructring.js +++ /dev/null @@ -1,25 +0,0 @@ -// Generated by ReScript, PLEASE EDIT WITH CARE -'use strict'; - - -let N = { - b: 3 -}; - -let v = 3; - -let u = 3; - -let h = 4; - -let g = 3; - -let gg = 4; - -exports.N = N; -exports.v = v; -exports.u = u; -exports.h = h; -exports.g = g; -exports.gg = gg; -/* No side effect */ diff --git a/tests/tests/src/test_tuple_destructring.mjs b/tests/tests/src/test_tuple_destructring.mjs new file mode 100644 index 0000000000..2c2aa5c582 --- /dev/null +++ b/tests/tests/src/test_tuple_destructring.mjs @@ -0,0 +1,26 @@ +// Generated by ReScript, PLEASE EDIT WITH CARE + + +let N = { + b: 3 +}; + +let v = 3; + +let u = 3; + +let h = 4; + +let g = 3; + +let gg = 4; + +export { + N, + v, + u, + h, + g, + gg, +} +/* No side effect */ diff --git a/tests/tests/src/test_type_based_arity.js b/tests/tests/src/test_type_based_arity.js deleted file mode 100644 index 89fd9368c5..0000000000 --- a/tests/tests/src/test_type_based_arity.js +++ /dev/null @@ -1,90 +0,0 @@ -// Generated by ReScript, PLEASE EDIT WITH CARE -'use strict'; - - -function f0(g, x) { - return g(x); -} - -function f1(g, x) { - g(x); -} - -let X = {}; - -function f2(g, x) { - return g(x); -} - -function f3(g, x) { - g(x); -} - -function f4(g, x) { - return g(x); -} - -function f5(g, x) { - return g(x); -} - -function f6(g, x) { - return g(x); -} - -function f7(g, x) { - return g(x); -} - -let X0 = {}; - -function f8(g, x) { - return g(x); -} - -function f9(g, x) { - return g(x); -} - -function f10(g, x) { - return g(x); -} - -function f11(g, x) { - return g(x); -} - -function f12(g, x) { - return g(x); -} - -function f13(g, x) { - return g(x); -} - -let X2 = { - f13: f13 -}; - -function f14(h, g, x) { - h(g, x); -} - -exports.f0 = f0; -exports.f1 = f1; -exports.X = X; -exports.f2 = f2; -exports.f3 = f3; -exports.f4 = f4; -exports.f5 = f5; -exports.f6 = f6; -exports.f7 = f7; -exports.X0 = X0; -exports.f8 = f8; -exports.f9 = f9; -exports.f10 = f10; -exports.f11 = f11; -exports.f12 = f12; -exports.X2 = X2; -exports.f14 = f14; -/* No side effect */ diff --git a/tests/tests/src/test_type_based_arity.mjs b/tests/tests/src/test_type_based_arity.mjs new file mode 100644 index 0000000000..100b152504 --- /dev/null +++ b/tests/tests/src/test_type_based_arity.mjs @@ -0,0 +1,91 @@ +// Generated by ReScript, PLEASE EDIT WITH CARE + + +function f0(g, x) { + return g(x); +} + +function f1(g, x) { + g(x); +} + +let X = {}; + +function f2(g, x) { + return g(x); +} + +function f3(g, x) { + g(x); +} + +function f4(g, x) { + return g(x); +} + +function f5(g, x) { + return g(x); +} + +function f6(g, x) { + return g(x); +} + +function f7(g, x) { + return g(x); +} + +let X0 = {}; + +function f8(g, x) { + return g(x); +} + +function f9(g, x) { + return g(x); +} + +function f10(g, x) { + return g(x); +} + +function f11(g, x) { + return g(x); +} + +function f12(g, x) { + return g(x); +} + +function f13(g, x) { + return g(x); +} + +let X2 = { + f13: f13 +}; + +function f14(h, g, x) { + h(g, x); +} + +export { + f0, + f1, + X, + f2, + f3, + f4, + f5, + f6, + f7, + X0, + f8, + f9, + f10, + f11, + f12, + X2, + f14, +} +/* No side effect */ diff --git a/tests/tests/src/test_u.js b/tests/tests/src/test_u.js deleted file mode 100644 index bf3c0112f3..0000000000 --- a/tests/tests/src/test_u.js +++ /dev/null @@ -1,16 +0,0 @@ -// Generated by ReScript, PLEASE EDIT WITH CARE -'use strict'; - - -function f(x) { - let v = x; - let sum = 0; - while (v > 0) { - sum = sum + v | 0; - v = v - 1 | 0; - }; - return sum; -} - -exports.f = f; -/* No side effect */ diff --git a/tests/tests/src/test_u.mjs b/tests/tests/src/test_u.mjs new file mode 100644 index 0000000000..a2c9e2d99c --- /dev/null +++ b/tests/tests/src/test_u.mjs @@ -0,0 +1,17 @@ +// Generated by ReScript, PLEASE EDIT WITH CARE + + +function f(x) { + let v = x; + let sum = 0; + while (v > 0) { + sum = sum + v | 0; + v = v - 1 | 0; + }; + return sum; +} + +export { + f, +} +/* No side effect */ diff --git a/tests/tests/src/test_unknown.js b/tests/tests/src/test_unknown.js deleted file mode 100644 index 1100d0d57d..0000000000 --- a/tests/tests/src/test_unknown.js +++ /dev/null @@ -1,23 +0,0 @@ -// Generated by ReScript, PLEASE EDIT WITH CARE -'use strict'; - -let Primitive_option = require("rescript/lib/js/Primitive_option.js"); - -function some(x) { - return Primitive_option.some(x); -} - -function some2(x) { - return Primitive_option.some(x); -} - -let h = [ - 3, - 2, - 2 -]; - -exports.some = some; -exports.some2 = some2; -exports.h = h; -/* No side effect */ diff --git a/tests/tests/src/test_unknown.mjs b/tests/tests/src/test_unknown.mjs new file mode 100644 index 0000000000..5017d9c46e --- /dev/null +++ b/tests/tests/src/test_unknown.mjs @@ -0,0 +1,24 @@ +// Generated by ReScript, PLEASE EDIT WITH CARE + +import * as Primitive_option from "rescript/lib/es6/Primitive_option.js"; + +function some(x) { + return Primitive_option.some(x); +} + +function some2(x) { + return Primitive_option.some(x); +} + +let h = [ + 3, + 2, + 2 +]; + +export { + some, + some2, + h, +} +/* No side effect */ diff --git a/tests/tests/src/test_unsafe_cmp.js b/tests/tests/src/test_unsafe_cmp.js deleted file mode 100644 index d57878aeb4..0000000000 --- a/tests/tests/src/test_unsafe_cmp.js +++ /dev/null @@ -1,24 +0,0 @@ -// Generated by ReScript, PLEASE EDIT WITH CARE -'use strict'; - - -function f(x, y) { - return [ - x < y, - x <= y, - x > y, - x >= y - ]; -} - -function ff(x, y) { - if (x < y) { - return 1; - } else { - return 2; - } -} - -exports.f = f; -exports.ff = ff; -/* No side effect */ diff --git a/tests/tests/src/test_unsafe_cmp.mjs b/tests/tests/src/test_unsafe_cmp.mjs new file mode 100644 index 0000000000..b7e3afca7b --- /dev/null +++ b/tests/tests/src/test_unsafe_cmp.mjs @@ -0,0 +1,25 @@ +// Generated by ReScript, PLEASE EDIT WITH CARE + + +function f(x, y) { + return [ + x < y, + x <= y, + x > y, + x >= y + ]; +} + +function ff(x, y) { + if (x < y) { + return 1; + } else { + return 2; + } +} + +export { + f, + ff, +} +/* No side effect */ diff --git a/tests/tests/src/test_unsafe_obj_ffi.js b/tests/tests/src/test_unsafe_obj_ffi.js deleted file mode 100644 index 2f4592cb5b..0000000000 --- a/tests/tests/src/test_unsafe_obj_ffi.js +++ /dev/null @@ -1,10 +0,0 @@ -// Generated by ReScript, PLEASE EDIT WITH CARE -'use strict'; - - -function f(x) { - return x.height + x.width | 0; -} - -exports.f = f; -/* No side effect */ diff --git a/tests/tests/src/test_unsafe_obj_ffi.mjs b/tests/tests/src/test_unsafe_obj_ffi.mjs new file mode 100644 index 0000000000..5186a27317 --- /dev/null +++ b/tests/tests/src/test_unsafe_obj_ffi.mjs @@ -0,0 +1,11 @@ +// Generated by ReScript, PLEASE EDIT WITH CARE + + +function f(x) { + return x.height + x.width | 0; +} + +export { + f, +} +/* No side effect */ diff --git a/tests/tests/src/test_unsafe_obj_ffi_ppx.js b/tests/tests/src/test_unsafe_obj_ffi_ppx.js deleted file mode 100644 index fab000080c..0000000000 --- a/tests/tests/src/test_unsafe_obj_ffi_ppx.js +++ /dev/null @@ -1,15 +0,0 @@ -// Generated by ReScript, PLEASE EDIT WITH CARE -'use strict'; - - -function f(x) { - return x.length + x.width; -} - -function chain(x) { - return x.element.length + x.element.length | 0; -} - -exports.f = f; -exports.chain = chain; -/* No side effect */ diff --git a/tests/tests/src/test_unsafe_obj_ffi_ppx.mjs b/tests/tests/src/test_unsafe_obj_ffi_ppx.mjs new file mode 100644 index 0000000000..15e792c160 --- /dev/null +++ b/tests/tests/src/test_unsafe_obj_ffi_ppx.mjs @@ -0,0 +1,16 @@ +// Generated by ReScript, PLEASE EDIT WITH CARE + + +function f(x) { + return x.length + x.width; +} + +function chain(x) { + return x.element.length + x.element.length | 0; +} + +export { + f, + chain, +} +/* No side effect */ diff --git a/tests/tests/src/test_utils.js b/tests/tests/src/test_utils.js deleted file mode 100644 index 272a721080..0000000000 --- a/tests/tests/src/test_utils.js +++ /dev/null @@ -1,21 +0,0 @@ -// Generated by ReScript, PLEASE EDIT WITH CARE -'use strict'; - -let Nodeassert = require("node:assert"); - -function ok(loc, a) { - Nodeassert.ok(a, loc); -} - -function eq(loc, a, b) { - Nodeassert.deepStrictEqual(a, b, loc); -} - -function $$throw(loc, f) { - Nodeassert.throws(f, undefined, loc); -} - -exports.ok = ok; -exports.eq = eq; -exports.$$throw = $$throw; -/* node:assert Not a pure module */ diff --git a/tests/tests/src/test_utils.mjs b/tests/tests/src/test_utils.mjs new file mode 100644 index 0000000000..9bd41aa167 --- /dev/null +++ b/tests/tests/src/test_utils.mjs @@ -0,0 +1,22 @@ +// Generated by ReScript, PLEASE EDIT WITH CARE + +import * as Nodeassert from "node:assert"; + +function ok(loc, a) { + Nodeassert.ok(a, loc); +} + +function eq(loc, a, b) { + Nodeassert.deepStrictEqual(a, b, loc); +} + +function $$throw(loc, f) { + Nodeassert.throws(f, undefined, loc); +} + +export { + ok, + eq, + $$throw, +} +/* node:assert Not a pure module */ diff --git a/tests/tests/src/test_while_closure.js b/tests/tests/src/test_while_closure.js deleted file mode 100644 index cc31ce3aca..0000000000 --- a/tests/tests/src/test_while_closure.js +++ /dev/null @@ -1,47 +0,0 @@ -// Generated by ReScript, PLEASE EDIT WITH CARE -'use strict'; - -let Belt_Array = require("rescript/lib/js/Belt_Array.js"); - -let v = { - contents: 0 -}; - -let arr = Belt_Array.make(10, () => {}); - -function f() { - let n = 0; - while (n < 10) { - let j = n; - arr[j] = () => { - v.contents = v.contents + j | 0; - }; - n = n + 1 | 0; - }; -} - -f(); - -Belt_Array.forEach(arr, x => x()); - -console.log(v.contents.toString()); - -if (v.contents !== 45) { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "test_while_closure.res", - 55, - 2 - ], - Error: new Error() - }; -} - -let count = 10; - -exports.v = v; -exports.count = count; -exports.arr = arr; -exports.f = f; -/* arr Not a pure module */ diff --git a/tests/tests/src/test_while_closure.mjs b/tests/tests/src/test_while_closure.mjs new file mode 100644 index 0000000000..088597f023 --- /dev/null +++ b/tests/tests/src/test_while_closure.mjs @@ -0,0 +1,48 @@ +// Generated by ReScript, PLEASE EDIT WITH CARE + +import * as Belt_Array from "rescript/lib/es6/Belt_Array.js"; + +let v = { + contents: 0 +}; + +let arr = Belt_Array.make(10, () => {}); + +function f() { + let n = 0; + while (n < 10) { + let j = n; + arr[j] = () => { + v.contents = v.contents + j | 0; + }; + n = n + 1 | 0; + }; +} + +f(); + +Belt_Array.forEach(arr, x => x()); + +console.log(v.contents.toString()); + +if (v.contents !== 45) { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "test_while_closure.res", + 55, + 2 + ], + Error: new Error() + }; +} + +let count = 10; + +export { + v, + count, + arr, + f, +} +/* arr Not a pure module */ diff --git a/tests/tests/src/test_while_side_effect.js b/tests/tests/src/test_while_side_effect.js deleted file mode 100644 index c9f6b1d952..0000000000 --- a/tests/tests/src/test_while_side_effect.js +++ /dev/null @@ -1,38 +0,0 @@ -// Generated by ReScript, PLEASE EDIT WITH CARE -'use strict'; - - -let v = { - contents: 0 -}; - -while (console.log(v.contents.toString()), v.contents = v.contents + 1 | 0, v.contents < 10) { - -}; - -function fib(x) { - if (x === 0 || x === 1) { - return 1; - } else { - return fib(x - 1 | 0) + fib(x - 2 | 0) | 0; - } -} - -let x = { - contents: 3 -}; - -while ((() => { - let y = 3; - console.log(x.contents.toString()); - y = y + 1 | 0; - x.contents = x.contents + 1 | 0; - return (fib(x.contents) + fib(x.contents) | 0) < 20; - })()) { - console.log((3).toString()); -}; - -exports.v = v; -exports.fib = fib; -exports.x = x; -/* Not a pure module */ diff --git a/tests/tests/src/test_while_side_effect.mjs b/tests/tests/src/test_while_side_effect.mjs new file mode 100644 index 0000000000..2cbc733d44 --- /dev/null +++ b/tests/tests/src/test_while_side_effect.mjs @@ -0,0 +1,39 @@ +// Generated by ReScript, PLEASE EDIT WITH CARE + + +let v = { + contents: 0 +}; + +while (console.log(v.contents.toString()), v.contents = v.contents + 1 | 0, v.contents < 10) { + +}; + +function fib(x) { + if (x === 0 || x === 1) { + return 1; + } else { + return fib(x - 1 | 0) + fib(x - 2 | 0) | 0; + } +} + +let x = { + contents: 3 +}; + +while ((() => { + let y = 3; + console.log(x.contents.toString()); + y = y + 1 | 0; + x.contents = x.contents + 1 | 0; + return (fib(x.contents) + fib(x.contents) | 0) < 20; + })()) { + console.log((3).toString()); +}; + +export { + v, + fib, + x, +} +/* Not a pure module */ diff --git a/tests/tests/src/test_zero_nullable.js b/tests/tests/src/test_zero_nullable.js deleted file mode 100644 index 45b57037ad..0000000000 --- a/tests/tests/src/test_zero_nullable.js +++ /dev/null @@ -1,305 +0,0 @@ -// Generated by ReScript, PLEASE EDIT WITH CARE -'use strict'; - -let Mt = require("./mt.js"); -let Primitive_option = require("rescript/lib/js/Primitive_option.js"); - -let suites = { - contents: /* [] */0 -}; - -let test_id = { - contents: 0 -}; - -function eq(loc, x, y) { - test_id.contents = test_id.contents + 1 | 0; - suites.contents = { - hd: [ - loc + (" id " + test_id.contents.toString()), - () => ({ - TAG: "Eq", - _0: x, - _1: y - }) - ], - tl: suites.contents - }; -} - -function f1(x) { - if (x !== null) { - return x + 1 | 0; - } else { - return 3; - } -} - -function f2(x) { - if (x !== null) { - return x + 1 | 0; - } else { - return 3; - } -} - -function f5(h, x) { - let u = h(32); - if (u !== null) { - return u + 1 | 0; - } else { - return 3; - } -} - -function f4(h, x) { - let u = h(32); - let v = 32 + x | 0; - if (u !== null) { - return u + 1 | 0; - } else { - return 1 + v | 0; - } -} - -function f6(x, y) { - return x === y; -} - -function f7(x) { - return x; -} - -function f8(x) { - if (x !== null) { - if (x !== null) { - return 0; - } else { - return 1; - } - } else { - return 2; - } -} - -let u = f8(undefined); - -function f9(x) { - if (x === null) { - return; - } else { - return Primitive_option.some(x); - } -} - -function f10(x) { - return x === null; -} - -let f11 = false; - -let Test_null = { - f1: f1, - f2: f2, - f5: f5, - f4: f4, - f6: f6, - f7: f7, - f8: f8, - u: u, - f9: f9, - f10: f10, - f11: f11 -}; - -function f1$1(x) { - if (x !== undefined) { - return x + 1 | 0; - } else { - return 3; - } -} - -function f2$1(x) { - if (x !== undefined) { - return x + 1 | 0; - } else { - return 3; - } -} - -function f5$1(h, x) { - let u = h(32); - if (u !== undefined) { - return u + 1 | 0; - } else { - return 3; - } -} - -function f4$1(h, x) { - let u = h(32); - let v = 32 + x | 0; - if (u !== undefined) { - return u + 1 | 0; - } else { - return 1 + v | 0; - } -} - -function f6$1(x, y) { - return x === y; -} - -function f7$1(x) { - return x; -} - -function f8$1(x) { - if (x !== undefined) { - if (x !== undefined) { - return 0; - } else { - return 1; - } - } else { - return 2; - } -} - -let u$1 = f8$1(undefined); - -function f9$1(x) { - if (x === undefined) { - return; - } else { - return Primitive_option.some(x); - } -} - -function f10$1(x) { - return x === undefined; -} - -let f11$1 = false; - -let Test_def = { - f1: f1$1, - f2: f2$1, - f5: f5$1, - f4: f4$1, - f6: f6$1, - f7: f7$1, - f8: f8$1, - u: u$1, - f9: f9$1, - f10: f10$1, - f11: f11$1 -}; - -function f1$2(x) { - if (x == null) { - return 3; - } else { - return x + 1 | 0; - } -} - -function f2$2(x) { - if (x == null) { - return 3; - } else { - return x + 1 | 0; - } -} - -function f5$2(h, x) { - let u = h(32); - if (u == null) { - return 3; - } else { - return u + 1 | 0; - } -} - -function f4$2(h, x) { - let u = h(32); - let v = 32 + x | 0; - if (u == null) { - return 1 + v | 0; - } else { - return u + 1 | 0; - } -} - -function f6$2(x, y) { - return x === y; -} - -function f7$2(x) { - return x; -} - -function f8$2(x) { - if (x == null) { - return 2; - } else if (x == null) { - return 1; - } else { - return 0; - } -} - -let u$2 = f8$2(undefined); - -function f9$2(x) { - if (x == null) { - return; - } else { - return Primitive_option.some(x); - } -} - -function f10$2(x) { - return x == null; -} - -let f11$2 = false; - -let Test_null_def = { - f1: f1$2, - f2: f2$2, - f5: f5$2, - f4: f4$2, - f6: f6$2, - f7: f7$2, - f8: f8$2, - u: u$2, - f9: f9$2, - f10: f10$2, - f11: f11$2 -}; - -eq("File \"test_zero_nullable.res\", line 247, characters 5-12", f1$2(0), 1); - -eq("File \"test_zero_nullable.res\", line 248, characters 5-12", f1$2(null), 3); - -eq("File \"test_zero_nullable.res\", line 249, characters 5-12", f1$2(undefined), 3); - -eq("File \"test_zero_nullable.res\", line 251, characters 5-12", f1(0), 1); - -eq("File \"test_zero_nullable.res\", line 252, characters 5-12", f1(null), 3); - -eq("File \"test_zero_nullable.res\", line 254, characters 5-12", f1$1(0), 1); - -eq("File \"test_zero_nullable.res\", line 255, characters 5-12", f1$1(undefined), 3); - -Mt.from_pair_suites("Test_zero_nullable", suites.contents); - -exports.suites = suites; -exports.test_id = test_id; -exports.eq = eq; -exports.Test_null = Test_null; -exports.Test_def = Test_def; -exports.Test_null_def = Test_null_def; -/* u Not a pure module */ diff --git a/tests/tests/src/test_zero_nullable.mjs b/tests/tests/src/test_zero_nullable.mjs new file mode 100644 index 0000000000..ebb251de0f --- /dev/null +++ b/tests/tests/src/test_zero_nullable.mjs @@ -0,0 +1,306 @@ +// Generated by ReScript, PLEASE EDIT WITH CARE + +import * as Mt from "./mt.mjs"; +import * as Primitive_option from "rescript/lib/es6/Primitive_option.js"; + +let suites = { + contents: /* [] */0 +}; + +let test_id = { + contents: 0 +}; + +function eq(loc, x, y) { + test_id.contents = test_id.contents + 1 | 0; + suites.contents = { + hd: [ + loc + (" id " + test_id.contents.toString()), + () => ({ + TAG: "Eq", + _0: x, + _1: y + }) + ], + tl: suites.contents + }; +} + +function f1(x) { + if (x !== null) { + return x + 1 | 0; + } else { + return 3; + } +} + +function f2(x) { + if (x !== null) { + return x + 1 | 0; + } else { + return 3; + } +} + +function f5(h, x) { + let u = h(32); + if (u !== null) { + return u + 1 | 0; + } else { + return 3; + } +} + +function f4(h, x) { + let u = h(32); + let v = 32 + x | 0; + if (u !== null) { + return u + 1 | 0; + } else { + return 1 + v | 0; + } +} + +function f6(x, y) { + return x === y; +} + +function f7(x) { + return x; +} + +function f8(x) { + if (x !== null) { + if (x !== null) { + return 0; + } else { + return 1; + } + } else { + return 2; + } +} + +let u = f8(undefined); + +function f9(x) { + if (x === null) { + return; + } else { + return Primitive_option.some(x); + } +} + +function f10(x) { + return x === null; +} + +let f11 = false; + +let Test_null = { + f1: f1, + f2: f2, + f5: f5, + f4: f4, + f6: f6, + f7: f7, + f8: f8, + u: u, + f9: f9, + f10: f10, + f11: f11 +}; + +function f1$1(x) { + if (x !== undefined) { + return x + 1 | 0; + } else { + return 3; + } +} + +function f2$1(x) { + if (x !== undefined) { + return x + 1 | 0; + } else { + return 3; + } +} + +function f5$1(h, x) { + let u = h(32); + if (u !== undefined) { + return u + 1 | 0; + } else { + return 3; + } +} + +function f4$1(h, x) { + let u = h(32); + let v = 32 + x | 0; + if (u !== undefined) { + return u + 1 | 0; + } else { + return 1 + v | 0; + } +} + +function f6$1(x, y) { + return x === y; +} + +function f7$1(x) { + return x; +} + +function f8$1(x) { + if (x !== undefined) { + if (x !== undefined) { + return 0; + } else { + return 1; + } + } else { + return 2; + } +} + +let u$1 = f8$1(undefined); + +function f9$1(x) { + if (x === undefined) { + return; + } else { + return Primitive_option.some(x); + } +} + +function f10$1(x) { + return x === undefined; +} + +let f11$1 = false; + +let Test_def = { + f1: f1$1, + f2: f2$1, + f5: f5$1, + f4: f4$1, + f6: f6$1, + f7: f7$1, + f8: f8$1, + u: u$1, + f9: f9$1, + f10: f10$1, + f11: f11$1 +}; + +function f1$2(x) { + if (x == null) { + return 3; + } else { + return x + 1 | 0; + } +} + +function f2$2(x) { + if (x == null) { + return 3; + } else { + return x + 1 | 0; + } +} + +function f5$2(h, x) { + let u = h(32); + if (u == null) { + return 3; + } else { + return u + 1 | 0; + } +} + +function f4$2(h, x) { + let u = h(32); + let v = 32 + x | 0; + if (u == null) { + return 1 + v | 0; + } else { + return u + 1 | 0; + } +} + +function f6$2(x, y) { + return x === y; +} + +function f7$2(x) { + return x; +} + +function f8$2(x) { + if (x == null) { + return 2; + } else if (x == null) { + return 1; + } else { + return 0; + } +} + +let u$2 = f8$2(undefined); + +function f9$2(x) { + if (x == null) { + return; + } else { + return Primitive_option.some(x); + } +} + +function f10$2(x) { + return x == null; +} + +let f11$2 = false; + +let Test_null_def = { + f1: f1$2, + f2: f2$2, + f5: f5$2, + f4: f4$2, + f6: f6$2, + f7: f7$2, + f8: f8$2, + u: u$2, + f9: f9$2, + f10: f10$2, + f11: f11$2 +}; + +eq("File \"test_zero_nullable.res\", line 247, characters 5-12", f1$2(0), 1); + +eq("File \"test_zero_nullable.res\", line 248, characters 5-12", f1$2(null), 3); + +eq("File \"test_zero_nullable.res\", line 249, characters 5-12", f1$2(undefined), 3); + +eq("File \"test_zero_nullable.res\", line 251, characters 5-12", f1(0), 1); + +eq("File \"test_zero_nullable.res\", line 252, characters 5-12", f1(null), 3); + +eq("File \"test_zero_nullable.res\", line 254, characters 5-12", f1$1(0), 1); + +eq("File \"test_zero_nullable.res\", line 255, characters 5-12", f1$1(undefined), 3); + +Mt.from_pair_suites("Test_zero_nullable", suites.contents); + +export { + suites, + test_id, + eq, + Test_null, + Test_def, + Test_null_def, +} +/* u Not a pure module */ diff --git a/tests/tests/src/then_mangle_test.js b/tests/tests/src/then_mangle_test.js deleted file mode 100644 index 4fcfa30d44..0000000000 --- a/tests/tests/src/then_mangle_test.js +++ /dev/null @@ -1,27 +0,0 @@ -// Generated by ReScript, PLEASE EDIT WITH CARE -'use strict'; - -let Mt = require("./mt.js"); - -let suites = { - contents: /* [] */0 -}; - -let test_id = { - contents: 0 -}; - -function eq(loc, x, y) { - Mt.eq_suites(test_id, suites, loc, x, y); -} - -function then(a, b) { - console.log("no inline"); - return Math.imul(a, a) + Math.imul(b, b) | 0; -} - -eq("File \"then_mangle_test.res\", line 14, characters 3-10", then(1, 2), 5); - -Mt.from_pair_suites("then_mangle_test.res", suites.contents); - -/* Not a pure module */ diff --git a/tests/tests/src/then_mangle_test.mjs b/tests/tests/src/then_mangle_test.mjs new file mode 100644 index 0000000000..1552358a36 --- /dev/null +++ b/tests/tests/src/then_mangle_test.mjs @@ -0,0 +1,26 @@ +// Generated by ReScript, PLEASE EDIT WITH CARE + +import * as Mt from "./mt.mjs"; + +let suites = { + contents: /* [] */0 +}; + +let test_id = { + contents: 0 +}; + +function eq(loc, x, y) { + Mt.eq_suites(test_id, suites, loc, x, y); +} + +function then(a, b) { + console.log("no inline"); + return Math.imul(a, a) + Math.imul(b, b) | 0; +} + +eq("File \"then_mangle_test.res\", line 14, characters 3-10", then(1, 2), 5); + +Mt.from_pair_suites("then_mangle_test.res", suites.contents); + +/* Not a pure module */ diff --git a/tests/tests/src/ticker.js b/tests/tests/src/ticker.js deleted file mode 100644 index 17fd71eb26..0000000000 --- a/tests/tests/src/ticker.js +++ /dev/null @@ -1,360 +0,0 @@ -// Generated by ReScript, PLEASE EDIT WITH CARE -'use strict'; - -let Belt_List = require("rescript/lib/js/Belt_List.js"); -let Belt_Float = require("rescript/lib/js/Belt_Float.js"); -let Pervasives = require("rescript/lib/js/Pervasives.js"); -let Belt_Option = require("rescript/lib/js/Belt_Option.js"); -let Primitive_int = require("rescript/lib/js/Primitive_int.js"); -let Belt_MapString = require("rescript/lib/js/Belt_MapString.js"); -let Primitive_option = require("rescript/lib/js/Primitive_option.js"); - -function split(delim, s) { - let len = s.length; - if (len !== 0) { - let _l = /* [] */0; - let _x = len; - while (true) { - let x = _x; - let l = _l; - if (x === 0) { - return l; - } - let i$p = s.lastIndexOf(delim, x - 1 | 0); - if (i$p === -1) { - return { - hd: s.substr(0, x), - tl: l - }; - } - let l_0 = s.substr(i$p + 1 | 0, (x - i$p | 0) - 1 | 0); - let l$1 = { - hd: l_0, - tl: l - }; - let l$2 = i$p === 0 ? ({ - hd: "", - tl: l$1 - }) : l$1; - _x = i$p; - _l = l$2; - continue; - }; - } else { - return /* [] */0; - } -} - -function string_of_float_option(x) { - if (x !== undefined) { - return x.toString(); - } else { - return "nan"; - } -} - -let Util = { - split: split, - string_of_float_option: string_of_float_option -}; - -function string_of_rank(x) { - if (typeof x !== "object") { - if (x === "Uninitialized") { - return "Uninitialized"; - } else { - return "Visited"; - } - } else { - return "Ranked(" + x._0 + ")"; - } -} - -function find_ticker_by_name(all_tickers, ticker) { - return Belt_Option.getExn(Belt_List.getBy(all_tickers, param => param.ticker_name === ticker)); -} - -function print_all_composite(all_tickers) { - Belt_List.forEach(all_tickers, x => { - let tmp = x.type_; - if (typeof tmp !== "object") { - return; - } - console.log(x.ticker_name); - }); -} - -function compute_update_sequences(all_tickers) { - Belt_List.reduceReverse(all_tickers, 0, (counter, ticker) => { - let loop = (counter, ticker) => { - let rank = ticker.rank; - if (typeof rank === "object") { - return counter; - } - if (rank !== "Uninitialized") { - return counter; - } - ticker.rank = "Visited"; - let match = ticker.type_; - if (typeof match !== "object") { - let counter$1 = counter + 1 | 0; - ticker.rank = { - TAG: "Ranked", - _0: counter$1 - }; - return counter$1; - } - let match$1 = match._0; - let counter$2 = loop(counter, match$1.lhs); - let counter$3 = loop(counter$2, match$1.rhs); - let counter$4 = counter$3 + 1 | 0; - ticker.rank = { - TAG: "Ranked", - _0: counter$4 - }; - return counter$4; - }; - return loop(counter, ticker); - }); - let map = Belt_List.reduceReverse(Belt_List.reverse(all_tickers), undefined, (map, ticker) => { - let tmp = ticker.type_; - if (typeof tmp !== "object") { - return Belt_MapString.set(map, ticker.ticker_name, { - hd: ticker, - tl: /* [] */0 - }); - } - let loop = (_up, _map, _ticker) => { - while (true) { - let ticker = _ticker; - let map = _map; - let up = _up; - let type_ = ticker.type_; - let ticker_name = ticker.ticker_name; - if (typeof type_ !== "object") { - let l = Belt_MapString.getExn(map, ticker_name); - return Belt_MapString.set(map, ticker_name, Pervasives.$at(up, l)); - } - let match = type_._0; - let map$1 = loop({ - hd: ticker, - tl: up - }, map, match.lhs); - _ticker = match.rhs; - _map = map$1; - _up = { - hd: ticker, - tl: up - }; - continue; - }; - }; - return loop(/* [] */0, map, ticker); - }); - return Belt_MapString.reduce(map, map, (map, k, l) => { - let l$1 = Belt_List.sort(l, (lhs, rhs) => { - let x = lhs.rank; - if (typeof x !== "object") { - return Pervasives.failwith("All nodes should be ranked"); - } - let y = rhs.rank; - if (typeof y !== "object") { - return Pervasives.failwith("All nodes should be ranked"); - } else { - return Primitive_int.compare(x._0, y._0); - } - }); - return Belt_MapString.set(map, k, l$1); - }); -} - -function process_quote(ticker_map, new_ticker, new_value) { - let update_sequence = Belt_MapString.getExn(ticker_map, new_ticker); - Belt_List.forEach(update_sequence, ticker => { - let match = ticker.type_; - if (typeof match !== "object") { - if (ticker.ticker_name === new_ticker) { - ticker.value = new_value; - return; - } else { - return Pervasives.failwith("Only single Market ticker should be udpated upon a new quote"); - } - } - let match$1 = match._0; - let match$2 = match$1.lhs.value; - let match$3 = match$1.rhs.value; - let value = match$2 !== undefined && match$3 !== undefined ? ( - match$1.op === "PLUS" ? match$2 + match$3 : match$2 - match$3 - ) : undefined; - ticker.value = value; - }); -} - -function process_input_line(ticker_map, all_tickers, line) { - let make_binary_op = (ticker_name, lhs, rhs, op) => { - let lhs$1 = find_ticker_by_name(all_tickers, lhs); - let rhs$1 = find_ticker_by_name(all_tickers, rhs); - return { - value: undefined, - rank: "Uninitialized", - ticker_name: ticker_name, - type_: { - TAG: "Binary_op", - _0: { - op: op, - rhs: rhs$1, - lhs: lhs$1 - } - } - }; - }; - let tokens = split("|", line); - if (!tokens) { - return Pervasives.failwith("Invalid input line"); - } - switch (tokens.hd) { - case "Q" : - let match = tokens.tl; - if (!match) { - return Pervasives.failwith("Invalid input line"); - } - let match$1 = match.tl; - if (!match$1) { - return Pervasives.failwith("Invalid input line"); - } - if (match$1.tl) { - return Pervasives.failwith("Invalid input line"); - } - let ticker_map$1 = ticker_map !== undefined ? Primitive_option.valFromOption(ticker_map) : compute_update_sequences(all_tickers); - let value = Belt_Option.getExn(Belt_Float.fromString(match$1.hd)); - process_quote(ticker_map$1, match.hd, value); - return [ - all_tickers, - Primitive_option.some(ticker_map$1) - ]; - case "R" : - let match$2 = tokens.tl; - if (!match$2) { - return Pervasives.failwith("Invalid input line"); - } - let match$3 = match$2.tl; - if (!match$3) { - return Pervasives.failwith("Invalid input line"); - } - let ticker_name = match$2.hd; - switch (match$3.hd) { - case "+" : - let match$4 = match$3.tl; - if (!match$4) { - return Pervasives.failwith("Invalid input line"); - } - let match$5 = match$4.tl; - if (match$5 && !match$5.tl) { - return [ - { - hd: make_binary_op(ticker_name, match$4.hd, match$5.hd, "PLUS"), - tl: all_tickers - }, - ticker_map - ]; - } else { - return Pervasives.failwith("Invalid input line"); - } - case "-" : - let match$6 = match$3.tl; - if (!match$6) { - return Pervasives.failwith("Invalid input line"); - } - let match$7 = match$6.tl; - if (match$7 && !match$7.tl) { - return [ - { - hd: make_binary_op(ticker_name, match$6.hd, match$7.hd, "MINUS"), - tl: all_tickers - }, - ticker_map - ]; - } else { - return Pervasives.failwith("Invalid input line"); - } - case "S" : - if (match$3.tl) { - return Pervasives.failwith("Invalid input line"); - } else { - return [ - { - hd: { - value: undefined, - rank: "Uninitialized", - ticker_name: ticker_name, - type_: "Market" - }, - tl: all_tickers - }, - ticker_map - ]; - } - default: - return Pervasives.failwith("Invalid input line"); - } - default: - return Pervasives.failwith("Invalid input line"); - } -} - -function loop(_lines, _param) { - while (true) { - let param = _param; - let lines = _lines; - let all_tickers = param[0]; - if (!lines) { - return print_all_composite(all_tickers); - } - _param = process_input_line(param[1], all_tickers, lines.hd); - _lines = lines.tl; - continue; - }; -} - -let Ticker_map; - -let lines = { - hd: "R|MSFT|S", - tl: { - hd: "R|IBM|S", - tl: { - hd: "R|FB|S", - tl: { - hd: "R|CP1|+|MSFT|IBM", - tl: { - hd: "R|CP2|-|FB|IBM", - tl: { - hd: "R|CP12|+|CP1|CP2", - tl: { - hd: "Q|MSFT|120.", - tl: { - hd: "Q|IBM|130.", - tl: { - hd: "Q|FB|80.", - tl: /* [] */0 - } - } - } - } - } - } - } - } -}; - -exports.Util = Util; -exports.string_of_rank = string_of_rank; -exports.find_ticker_by_name = find_ticker_by_name; -exports.print_all_composite = print_all_composite; -exports.Ticker_map = Ticker_map; -exports.compute_update_sequences = compute_update_sequences; -exports.process_quote = process_quote; -exports.process_input_line = process_input_line; -exports.lines = lines; -exports.loop = loop; -/* No side effect */ diff --git a/tests/tests/src/ticker.mjs b/tests/tests/src/ticker.mjs new file mode 100644 index 0000000000..a4eca36b56 --- /dev/null +++ b/tests/tests/src/ticker.mjs @@ -0,0 +1,361 @@ +// Generated by ReScript, PLEASE EDIT WITH CARE + +import * as Belt_List from "rescript/lib/es6/Belt_List.js"; +import * as Belt_Float from "rescript/lib/es6/Belt_Float.js"; +import * as Pervasives from "rescript/lib/es6/Pervasives.js"; +import * as Belt_Option from "rescript/lib/es6/Belt_Option.js"; +import * as Primitive_int from "rescript/lib/es6/Primitive_int.js"; +import * as Belt_MapString from "rescript/lib/es6/Belt_MapString.js"; +import * as Primitive_option from "rescript/lib/es6/Primitive_option.js"; + +function split(delim, s) { + let len = s.length; + if (len !== 0) { + let _l = /* [] */0; + let _x = len; + while (true) { + let x = _x; + let l = _l; + if (x === 0) { + return l; + } + let i$p = s.lastIndexOf(delim, x - 1 | 0); + if (i$p === -1) { + return { + hd: s.substr(0, x), + tl: l + }; + } + let l_0 = s.substr(i$p + 1 | 0, (x - i$p | 0) - 1 | 0); + let l$1 = { + hd: l_0, + tl: l + }; + let l$2 = i$p === 0 ? ({ + hd: "", + tl: l$1 + }) : l$1; + _x = i$p; + _l = l$2; + continue; + }; + } else { + return /* [] */0; + } +} + +function string_of_float_option(x) { + if (x !== undefined) { + return x.toString(); + } else { + return "nan"; + } +} + +let Util = { + split: split, + string_of_float_option: string_of_float_option +}; + +function string_of_rank(x) { + if (typeof x !== "object") { + if (x === "Uninitialized") { + return "Uninitialized"; + } else { + return "Visited"; + } + } else { + return "Ranked(" + x._0 + ")"; + } +} + +function find_ticker_by_name(all_tickers, ticker) { + return Belt_Option.getExn(Belt_List.getBy(all_tickers, param => param.ticker_name === ticker)); +} + +function print_all_composite(all_tickers) { + Belt_List.forEach(all_tickers, x => { + let tmp = x.type_; + if (typeof tmp !== "object") { + return; + } + console.log(x.ticker_name); + }); +} + +function compute_update_sequences(all_tickers) { + Belt_List.reduceReverse(all_tickers, 0, (counter, ticker) => { + let loop = (counter, ticker) => { + let rank = ticker.rank; + if (typeof rank === "object") { + return counter; + } + if (rank !== "Uninitialized") { + return counter; + } + ticker.rank = "Visited"; + let match = ticker.type_; + if (typeof match !== "object") { + let counter$1 = counter + 1 | 0; + ticker.rank = { + TAG: "Ranked", + _0: counter$1 + }; + return counter$1; + } + let match$1 = match._0; + let counter$2 = loop(counter, match$1.lhs); + let counter$3 = loop(counter$2, match$1.rhs); + let counter$4 = counter$3 + 1 | 0; + ticker.rank = { + TAG: "Ranked", + _0: counter$4 + }; + return counter$4; + }; + return loop(counter, ticker); + }); + let map = Belt_List.reduceReverse(Belt_List.reverse(all_tickers), undefined, (map, ticker) => { + let tmp = ticker.type_; + if (typeof tmp !== "object") { + return Belt_MapString.set(map, ticker.ticker_name, { + hd: ticker, + tl: /* [] */0 + }); + } + let loop = (_up, _map, _ticker) => { + while (true) { + let ticker = _ticker; + let map = _map; + let up = _up; + let type_ = ticker.type_; + let ticker_name = ticker.ticker_name; + if (typeof type_ !== "object") { + let l = Belt_MapString.getExn(map, ticker_name); + return Belt_MapString.set(map, ticker_name, Pervasives.$at(up, l)); + } + let match = type_._0; + let map$1 = loop({ + hd: ticker, + tl: up + }, map, match.lhs); + _ticker = match.rhs; + _map = map$1; + _up = { + hd: ticker, + tl: up + }; + continue; + }; + }; + return loop(/* [] */0, map, ticker); + }); + return Belt_MapString.reduce(map, map, (map, k, l) => { + let l$1 = Belt_List.sort(l, (lhs, rhs) => { + let x = lhs.rank; + if (typeof x !== "object") { + return Pervasives.failwith("All nodes should be ranked"); + } + let y = rhs.rank; + if (typeof y !== "object") { + return Pervasives.failwith("All nodes should be ranked"); + } else { + return Primitive_int.compare(x._0, y._0); + } + }); + return Belt_MapString.set(map, k, l$1); + }); +} + +function process_quote(ticker_map, new_ticker, new_value) { + let update_sequence = Belt_MapString.getExn(ticker_map, new_ticker); + Belt_List.forEach(update_sequence, ticker => { + let match = ticker.type_; + if (typeof match !== "object") { + if (ticker.ticker_name === new_ticker) { + ticker.value = new_value; + return; + } else { + return Pervasives.failwith("Only single Market ticker should be udpated upon a new quote"); + } + } + let match$1 = match._0; + let match$2 = match$1.lhs.value; + let match$3 = match$1.rhs.value; + let value = match$2 !== undefined && match$3 !== undefined ? ( + match$1.op === "PLUS" ? match$2 + match$3 : match$2 - match$3 + ) : undefined; + ticker.value = value; + }); +} + +function process_input_line(ticker_map, all_tickers, line) { + let make_binary_op = (ticker_name, lhs, rhs, op) => { + let lhs$1 = find_ticker_by_name(all_tickers, lhs); + let rhs$1 = find_ticker_by_name(all_tickers, rhs); + return { + value: undefined, + rank: "Uninitialized", + ticker_name: ticker_name, + type_: { + TAG: "Binary_op", + _0: { + op: op, + rhs: rhs$1, + lhs: lhs$1 + } + } + }; + }; + let tokens = split("|", line); + if (!tokens) { + return Pervasives.failwith("Invalid input line"); + } + switch (tokens.hd) { + case "Q" : + let match = tokens.tl; + if (!match) { + return Pervasives.failwith("Invalid input line"); + } + let match$1 = match.tl; + if (!match$1) { + return Pervasives.failwith("Invalid input line"); + } + if (match$1.tl) { + return Pervasives.failwith("Invalid input line"); + } + let ticker_map$1 = ticker_map !== undefined ? Primitive_option.valFromOption(ticker_map) : compute_update_sequences(all_tickers); + let value = Belt_Option.getExn(Belt_Float.fromString(match$1.hd)); + process_quote(ticker_map$1, match.hd, value); + return [ + all_tickers, + Primitive_option.some(ticker_map$1) + ]; + case "R" : + let match$2 = tokens.tl; + if (!match$2) { + return Pervasives.failwith("Invalid input line"); + } + let match$3 = match$2.tl; + if (!match$3) { + return Pervasives.failwith("Invalid input line"); + } + let ticker_name = match$2.hd; + switch (match$3.hd) { + case "+" : + let match$4 = match$3.tl; + if (!match$4) { + return Pervasives.failwith("Invalid input line"); + } + let match$5 = match$4.tl; + if (match$5 && !match$5.tl) { + return [ + { + hd: make_binary_op(ticker_name, match$4.hd, match$5.hd, "PLUS"), + tl: all_tickers + }, + ticker_map + ]; + } else { + return Pervasives.failwith("Invalid input line"); + } + case "-" : + let match$6 = match$3.tl; + if (!match$6) { + return Pervasives.failwith("Invalid input line"); + } + let match$7 = match$6.tl; + if (match$7 && !match$7.tl) { + return [ + { + hd: make_binary_op(ticker_name, match$6.hd, match$7.hd, "MINUS"), + tl: all_tickers + }, + ticker_map + ]; + } else { + return Pervasives.failwith("Invalid input line"); + } + case "S" : + if (match$3.tl) { + return Pervasives.failwith("Invalid input line"); + } else { + return [ + { + hd: { + value: undefined, + rank: "Uninitialized", + ticker_name: ticker_name, + type_: "Market" + }, + tl: all_tickers + }, + ticker_map + ]; + } + default: + return Pervasives.failwith("Invalid input line"); + } + default: + return Pervasives.failwith("Invalid input line"); + } +} + +function loop(_lines, _param) { + while (true) { + let param = _param; + let lines = _lines; + let all_tickers = param[0]; + if (!lines) { + return print_all_composite(all_tickers); + } + _param = process_input_line(param[1], all_tickers, lines.hd); + _lines = lines.tl; + continue; + }; +} + +let Ticker_map; + +let lines = { + hd: "R|MSFT|S", + tl: { + hd: "R|IBM|S", + tl: { + hd: "R|FB|S", + tl: { + hd: "R|CP1|+|MSFT|IBM", + tl: { + hd: "R|CP2|-|FB|IBM", + tl: { + hd: "R|CP12|+|CP1|CP2", + tl: { + hd: "Q|MSFT|120.", + tl: { + hd: "Q|IBM|130.", + tl: { + hd: "Q|FB|80.", + tl: /* [] */0 + } + } + } + } + } + } + } + } +}; + +export { + Util, + string_of_rank, + find_ticker_by_name, + print_all_composite, + Ticker_map, + compute_update_sequences, + process_quote, + process_input_line, + lines, + loop, +} +/* No side effect */ diff --git a/tests/tests/src/to_string_test.js b/tests/tests/src/to_string_test.js deleted file mode 100644 index 1fd1558219..0000000000 --- a/tests/tests/src/to_string_test.js +++ /dev/null @@ -1,39 +0,0 @@ -// Generated by ReScript, PLEASE EDIT WITH CARE -'use strict'; - -let Mt = require("./mt.js"); -let Pervasives = require("rescript/lib/js/Pervasives.js"); - -function ff(v) { - return v.toString(); -} - -function f(v) { - return v.toString(); -} - -Mt.from_pair_suites("To_string_test", { - hd: [ - "File \"to_string_test.res\", line 7, characters 5-12", - () => ({ - TAG: "Eq", - _0: Pervasives.infinity.toString(), - _1: "Infinity" - }) - ], - tl: { - hd: [ - "File \"to_string_test.res\", line 8, characters 5-12", - () => ({ - TAG: "Eq", - _0: Pervasives.neg_infinity.toString(), - _1: "-Infinity" - }) - ], - tl: /* [] */0 - } -}); - -exports.ff = ff; -exports.f = f; -/* Not a pure module */ diff --git a/tests/tests/src/to_string_test.mjs b/tests/tests/src/to_string_test.mjs new file mode 100644 index 0000000000..2e07742d41 --- /dev/null +++ b/tests/tests/src/to_string_test.mjs @@ -0,0 +1,40 @@ +// Generated by ReScript, PLEASE EDIT WITH CARE + +import * as Mt from "./mt.mjs"; +import * as Pervasives from "rescript/lib/es6/Pervasives.js"; + +function ff(v) { + return v.toString(); +} + +function f(v) { + return v.toString(); +} + +Mt.from_pair_suites("To_string_test", { + hd: [ + "File \"to_string_test.res\", line 7, characters 5-12", + () => ({ + TAG: "Eq", + _0: Pervasives.infinity.toString(), + _1: "Infinity" + }) + ], + tl: { + hd: [ + "File \"to_string_test.res\", line 8, characters 5-12", + () => ({ + TAG: "Eq", + _0: Pervasives.neg_infinity.toString(), + _1: "-Infinity" + }) + ], + tl: /* [] */0 + } +}); + +export { + ff, + f, +} +/* Not a pure module */ diff --git a/tests/tests/src/topsort_test.js b/tests/tests/src/topsort_test.js deleted file mode 100644 index 10bdf9fe99..0000000000 --- a/tests/tests/src/topsort_test.js +++ /dev/null @@ -1,591 +0,0 @@ -// Generated by ReScript, PLEASE EDIT WITH CARE -'use strict'; - -let Belt_List = require("rescript/lib/js/Belt_List.js"); -let Pervasives = require("rescript/lib/js/Pervasives.js"); -let Belt_SetString = require("rescript/lib/js/Belt_SetString.js"); -let Primitive_object = require("rescript/lib/js/Primitive_object.js"); -let Primitive_exceptions = require("rescript/lib/js/Primitive_exceptions.js"); - -let graph = { - hd: [ - "a", - "b" - ], - tl: { - hd: [ - "a", - "c" - ], - tl: { - hd: [ - "a", - "d" - ], - tl: { - hd: [ - "b", - "e" - ], - tl: { - hd: [ - "c", - "f" - ], - tl: { - hd: [ - "d", - "e" - ], - tl: { - hd: [ - "e", - "f" - ], - tl: { - hd: [ - "e", - "g" - ], - tl: /* [] */0 - } - } - } - } - } - } - } -}; - -function nexts(x, g) { - return Belt_List.reduce(g, /* [] */0, (acc, param) => { - if (param[0] === x) { - return { - hd: param[1], - tl: acc - }; - } else { - return acc; - } - }); -} - -function dfs1(_nodes, graph, _visited) { - while (true) { - let visited = _visited; - let nodes = _nodes; - if (!nodes) { - return Belt_List.reverse(visited); - } - let xs = nodes.tl; - let x = nodes.hd; - if (Belt_List.has(visited, x, (prim0, prim1) => prim0 === prim1)) { - _nodes = xs; - continue; - } - console.log(x); - _visited = { - hd: x, - tl: visited - }; - _nodes = Pervasives.$at(nexts(x, graph), xs); - continue; - }; -} - -if (!Primitive_object.equal(dfs1({ - hd: "a", - tl: /* [] */0 - }, graph, /* [] */0), { - hd: "a", - tl: { - hd: "d", - tl: { - hd: "e", - tl: { - hd: "g", - tl: { - hd: "f", - tl: { - hd: "c", - tl: { - hd: "b", - tl: /* [] */0 - } - } - } - } - } - } - })) { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "topsort_test.res", - 38, - 2 - ], - Error: new Error() - }; -} - -console.log(); - -if (!Primitive_object.equal(dfs1({ - hd: "b", - tl: /* [] */0 - }, { - hd: [ - "f", - "d" - ], - tl: graph - }, /* [] */0), { - hd: "b", - tl: { - hd: "e", - tl: { - hd: "g", - tl: { - hd: "f", - tl: { - hd: "d", - tl: /* [] */0 - } - } - } - } - })) { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "topsort_test.res", - 41, - 2 - ], - Error: new Error() - }; -} - -function dfs2(nodes, graph, visited) { - let aux = (_nodes, graph, _visited) => { - while (true) { - let visited = _visited; - let nodes = _nodes; - if (!nodes) { - return visited; - } - let xs = nodes.tl; - let x = nodes.hd; - if (Belt_List.has(visited, x, (prim0, prim1) => prim0 === prim1)) { - _nodes = xs; - continue; - } - _visited = aux(nexts(x, graph), graph, { - hd: x, - tl: visited - }); - _nodes = xs; - continue; - }; - }; - return Belt_List.reverse(aux(nodes, graph, visited)); -} - -if (!Primitive_object.equal(dfs2({ - hd: "a", - tl: /* [] */0 - }, graph, /* [] */0), { - hd: "a", - tl: { - hd: "d", - tl: { - hd: "e", - tl: { - hd: "g", - tl: { - hd: "f", - tl: { - hd: "c", - tl: { - hd: "b", - tl: /* [] */0 - } - } - } - } - } - } - })) { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "topsort_test.res", - 60, - 2 - ], - Error: new Error() - }; -} - -if (!Primitive_object.equal(dfs2({ - hd: "b", - tl: /* [] */0 - }, { - hd: [ - "f", - "d" - ], - tl: graph - }, /* [] */0), { - hd: "b", - tl: { - hd: "e", - tl: { - hd: "g", - tl: { - hd: "f", - tl: { - hd: "d", - tl: /* [] */0 - } - } - } - } - })) { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "topsort_test.res", - 61, - 2 - ], - Error: new Error() - }; -} - -function dfs3(nodes, graph) { - let visited = { - contents: /* [] */0 - }; - let aux = (node, graph) => { - if (!Belt_List.has(visited.contents, node, (prim0, prim1) => prim0 === prim1)) { - visited.contents = { - hd: node, - tl: visited.contents - }; - return Belt_List.forEach(nexts(node, graph), x => aux(x, graph)); - } - - }; - Belt_List.forEach(nodes, node => aux(node, graph)); - return Belt_List.reverse(visited.contents); -} - -if (!Primitive_object.equal(dfs3({ - hd: "a", - tl: /* [] */0 - }, graph), { - hd: "a", - tl: { - hd: "d", - tl: { - hd: "e", - tl: { - hd: "g", - tl: { - hd: "f", - tl: { - hd: "c", - tl: { - hd: "b", - tl: /* [] */0 - } - } - } - } - } - } - })) { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "topsort_test.res", - 77, - 2 - ], - Error: new Error() - }; -} - -if (!Primitive_object.equal(dfs3({ - hd: "b", - tl: /* [] */0 - }, { - hd: [ - "f", - "d" - ], - tl: graph - }), { - hd: "b", - tl: { - hd: "e", - tl: { - hd: "g", - tl: { - hd: "f", - tl: { - hd: "d", - tl: /* [] */0 - } - } - } - } - })) { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "topsort_test.res", - 78, - 2 - ], - Error: new Error() - }; -} - -let grwork = { - hd: [ - "wake", - "shower" - ], - tl: { - hd: [ - "shower", - "dress" - ], - tl: { - hd: [ - "dress", - "go" - ], - tl: { - hd: [ - "wake", - "eat" - ], - tl: { - hd: [ - "eat", - "washup" - ], - tl: { - hd: [ - "washup", - "go" - ], - tl: /* [] */0 - } - } - } - } - } -}; - -function unsafe_topsort(graph) { - let visited = { - contents: /* [] */0 - }; - let sort_node = node => { - if (Belt_List.has(visited.contents, node, (prim0, prim1) => prim0 === prim1)) { - return; - } - let nodes = nexts(node, graph); - Belt_List.forEach(nodes, sort_node); - visited.contents = { - hd: node, - tl: visited.contents - }; - }; - Belt_List.forEach(graph, param => sort_node(param[0])); - return visited.contents; -} - -if (!Primitive_object.equal(unsafe_topsort(grwork), { - hd: "wake", - tl: { - hd: "shower", - tl: { - hd: "dress", - tl: { - hd: "eat", - tl: { - hd: "washup", - tl: { - hd: "go", - tl: /* [] */0 - } - } - } - } - } - })) { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "topsort_test.res", - 115, - 9 - ], - Error: new Error() - }; -} - -let Cycle = /* @__PURE__ */Primitive_exceptions.create("Topsort_test.Cycle"); - -function pathsort(graph) { - let visited = { - contents: /* [] */0 - }; - let empty_path = [ - undefined, - /* [] */0 - ]; - let $plus$great = (node, param) => { - let stack = param[1]; - let set = param[0]; - if (Belt_SetString.has(set, node)) { - throw { - RE_EXN_ID: Cycle, - _1: { - hd: node, - tl: stack - }, - Error: new Error() - }; - } - return [ - Belt_SetString.add(set, node), - { - hd: node, - tl: stack - } - ]; - }; - let sort_nodes = (path, nodes) => Belt_List.forEach(nodes, node => sort_node(path, node)); - let sort_node = (path, node) => { - if (!Belt_List.has(visited.contents, node, (prim0, prim1) => prim0 === prim1)) { - sort_nodes($plus$great(node, path), nexts(node, graph)); - visited.contents = { - hd: node, - tl: visited.contents - }; - return; - } - - }; - Belt_List.forEach(graph, param => sort_node(empty_path, param[0])); - return visited.contents; -} - -if (!Primitive_object.equal(pathsort(grwork), { - hd: "wake", - tl: { - hd: "shower", - tl: { - hd: "dress", - tl: { - hd: "eat", - tl: { - hd: "washup", - tl: { - hd: "go", - tl: /* [] */0 - } - } - } - } - } - })) { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "topsort_test.res", - 147, - 9 - ], - Error: new Error() - }; -} - -try { - pathsort({ - hd: [ - "go", - "eat" - ], - tl: grwork - }); - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "topsort_test.res", - 151, - 2 - ], - Error: new Error() - }; -} catch (raw_exn) { - let exn = Primitive_exceptions.internalToException(raw_exn); - let exit = 0; - if (exn.RE_EXN_ID === Cycle) { - let match = exn._1; - if (match && match.hd === "go") { - let match$1 = match.tl; - if (match$1 && match$1.hd === "washup") { - let match$2 = match$1.tl; - if (match$2 && match$2.hd === "eat") { - let match$3 = match$2.tl; - if (!(match$3 && match$3.hd === "go" && !match$3.tl)) { - exit = 1; - } - - } else { - exit = 1; - } - } else { - exit = 1; - } - } else { - exit = 1; - } - } else { - exit = 1; - } - if (exit === 1) { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "topsort_test.res", - 154, - 7 - ], - Error: new Error() - }; - } - -} - -let String_set; - -exports.graph = graph; -exports.nexts = nexts; -exports.dfs1 = dfs1; -exports.dfs2 = dfs2; -exports.dfs3 = dfs3; -exports.grwork = grwork; -exports.unsafe_topsort = unsafe_topsort; -exports.String_set = String_set; -exports.Cycle = Cycle; -exports.pathsort = pathsort; -/* Not a pure module */ diff --git a/tests/tests/src/topsort_test.mjs b/tests/tests/src/topsort_test.mjs new file mode 100644 index 0000000000..90fdebb6c5 --- /dev/null +++ b/tests/tests/src/topsort_test.mjs @@ -0,0 +1,592 @@ +// Generated by ReScript, PLEASE EDIT WITH CARE + +import * as Belt_List from "rescript/lib/es6/Belt_List.js"; +import * as Pervasives from "rescript/lib/es6/Pervasives.js"; +import * as Belt_SetString from "rescript/lib/es6/Belt_SetString.js"; +import * as Primitive_object from "rescript/lib/es6/Primitive_object.js"; +import * as Primitive_exceptions from "rescript/lib/es6/Primitive_exceptions.js"; + +let graph = { + hd: [ + "a", + "b" + ], + tl: { + hd: [ + "a", + "c" + ], + tl: { + hd: [ + "a", + "d" + ], + tl: { + hd: [ + "b", + "e" + ], + tl: { + hd: [ + "c", + "f" + ], + tl: { + hd: [ + "d", + "e" + ], + tl: { + hd: [ + "e", + "f" + ], + tl: { + hd: [ + "e", + "g" + ], + tl: /* [] */0 + } + } + } + } + } + } + } +}; + +function nexts(x, g) { + return Belt_List.reduce(g, /* [] */0, (acc, param) => { + if (param[0] === x) { + return { + hd: param[1], + tl: acc + }; + } else { + return acc; + } + }); +} + +function dfs1(_nodes, graph, _visited) { + while (true) { + let visited = _visited; + let nodes = _nodes; + if (!nodes) { + return Belt_List.reverse(visited); + } + let xs = nodes.tl; + let x = nodes.hd; + if (Belt_List.has(visited, x, (prim0, prim1) => prim0 === prim1)) { + _nodes = xs; + continue; + } + console.log(x); + _visited = { + hd: x, + tl: visited + }; + _nodes = Pervasives.$at(nexts(x, graph), xs); + continue; + }; +} + +if (!Primitive_object.equal(dfs1({ + hd: "a", + tl: /* [] */0 + }, graph, /* [] */0), { + hd: "a", + tl: { + hd: "d", + tl: { + hd: "e", + tl: { + hd: "g", + tl: { + hd: "f", + tl: { + hd: "c", + tl: { + hd: "b", + tl: /* [] */0 + } + } + } + } + } + } + })) { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "topsort_test.res", + 38, + 2 + ], + Error: new Error() + }; +} + +console.log(); + +if (!Primitive_object.equal(dfs1({ + hd: "b", + tl: /* [] */0 + }, { + hd: [ + "f", + "d" + ], + tl: graph + }, /* [] */0), { + hd: "b", + tl: { + hd: "e", + tl: { + hd: "g", + tl: { + hd: "f", + tl: { + hd: "d", + tl: /* [] */0 + } + } + } + } + })) { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "topsort_test.res", + 41, + 2 + ], + Error: new Error() + }; +} + +function dfs2(nodes, graph, visited) { + let aux = (_nodes, graph, _visited) => { + while (true) { + let visited = _visited; + let nodes = _nodes; + if (!nodes) { + return visited; + } + let xs = nodes.tl; + let x = nodes.hd; + if (Belt_List.has(visited, x, (prim0, prim1) => prim0 === prim1)) { + _nodes = xs; + continue; + } + _visited = aux(nexts(x, graph), graph, { + hd: x, + tl: visited + }); + _nodes = xs; + continue; + }; + }; + return Belt_List.reverse(aux(nodes, graph, visited)); +} + +if (!Primitive_object.equal(dfs2({ + hd: "a", + tl: /* [] */0 + }, graph, /* [] */0), { + hd: "a", + tl: { + hd: "d", + tl: { + hd: "e", + tl: { + hd: "g", + tl: { + hd: "f", + tl: { + hd: "c", + tl: { + hd: "b", + tl: /* [] */0 + } + } + } + } + } + } + })) { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "topsort_test.res", + 60, + 2 + ], + Error: new Error() + }; +} + +if (!Primitive_object.equal(dfs2({ + hd: "b", + tl: /* [] */0 + }, { + hd: [ + "f", + "d" + ], + tl: graph + }, /* [] */0), { + hd: "b", + tl: { + hd: "e", + tl: { + hd: "g", + tl: { + hd: "f", + tl: { + hd: "d", + tl: /* [] */0 + } + } + } + } + })) { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "topsort_test.res", + 61, + 2 + ], + Error: new Error() + }; +} + +function dfs3(nodes, graph) { + let visited = { + contents: /* [] */0 + }; + let aux = (node, graph) => { + if (!Belt_List.has(visited.contents, node, (prim0, prim1) => prim0 === prim1)) { + visited.contents = { + hd: node, + tl: visited.contents + }; + return Belt_List.forEach(nexts(node, graph), x => aux(x, graph)); + } + + }; + Belt_List.forEach(nodes, node => aux(node, graph)); + return Belt_List.reverse(visited.contents); +} + +if (!Primitive_object.equal(dfs3({ + hd: "a", + tl: /* [] */0 + }, graph), { + hd: "a", + tl: { + hd: "d", + tl: { + hd: "e", + tl: { + hd: "g", + tl: { + hd: "f", + tl: { + hd: "c", + tl: { + hd: "b", + tl: /* [] */0 + } + } + } + } + } + } + })) { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "topsort_test.res", + 77, + 2 + ], + Error: new Error() + }; +} + +if (!Primitive_object.equal(dfs3({ + hd: "b", + tl: /* [] */0 + }, { + hd: [ + "f", + "d" + ], + tl: graph + }), { + hd: "b", + tl: { + hd: "e", + tl: { + hd: "g", + tl: { + hd: "f", + tl: { + hd: "d", + tl: /* [] */0 + } + } + } + } + })) { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "topsort_test.res", + 78, + 2 + ], + Error: new Error() + }; +} + +let grwork = { + hd: [ + "wake", + "shower" + ], + tl: { + hd: [ + "shower", + "dress" + ], + tl: { + hd: [ + "dress", + "go" + ], + tl: { + hd: [ + "wake", + "eat" + ], + tl: { + hd: [ + "eat", + "washup" + ], + tl: { + hd: [ + "washup", + "go" + ], + tl: /* [] */0 + } + } + } + } + } +}; + +function unsafe_topsort(graph) { + let visited = { + contents: /* [] */0 + }; + let sort_node = node => { + if (Belt_List.has(visited.contents, node, (prim0, prim1) => prim0 === prim1)) { + return; + } + let nodes = nexts(node, graph); + Belt_List.forEach(nodes, sort_node); + visited.contents = { + hd: node, + tl: visited.contents + }; + }; + Belt_List.forEach(graph, param => sort_node(param[0])); + return visited.contents; +} + +if (!Primitive_object.equal(unsafe_topsort(grwork), { + hd: "wake", + tl: { + hd: "shower", + tl: { + hd: "dress", + tl: { + hd: "eat", + tl: { + hd: "washup", + tl: { + hd: "go", + tl: /* [] */0 + } + } + } + } + } + })) { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "topsort_test.res", + 115, + 9 + ], + Error: new Error() + }; +} + +let Cycle = /* @__PURE__ */Primitive_exceptions.create("Topsort_test.Cycle"); + +function pathsort(graph) { + let visited = { + contents: /* [] */0 + }; + let empty_path = [ + undefined, + /* [] */0 + ]; + let $plus$great = (node, param) => { + let stack = param[1]; + let set = param[0]; + if (Belt_SetString.has(set, node)) { + throw { + RE_EXN_ID: Cycle, + _1: { + hd: node, + tl: stack + }, + Error: new Error() + }; + } + return [ + Belt_SetString.add(set, node), + { + hd: node, + tl: stack + } + ]; + }; + let sort_nodes = (path, nodes) => Belt_List.forEach(nodes, node => sort_node(path, node)); + let sort_node = (path, node) => { + if (!Belt_List.has(visited.contents, node, (prim0, prim1) => prim0 === prim1)) { + sort_nodes($plus$great(node, path), nexts(node, graph)); + visited.contents = { + hd: node, + tl: visited.contents + }; + return; + } + + }; + Belt_List.forEach(graph, param => sort_node(empty_path, param[0])); + return visited.contents; +} + +if (!Primitive_object.equal(pathsort(grwork), { + hd: "wake", + tl: { + hd: "shower", + tl: { + hd: "dress", + tl: { + hd: "eat", + tl: { + hd: "washup", + tl: { + hd: "go", + tl: /* [] */0 + } + } + } + } + } + })) { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "topsort_test.res", + 147, + 9 + ], + Error: new Error() + }; +} + +try { + pathsort({ + hd: [ + "go", + "eat" + ], + tl: grwork + }); + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "topsort_test.res", + 151, + 2 + ], + Error: new Error() + }; +} catch (raw_exn) { + let exn = Primitive_exceptions.internalToException(raw_exn); + let exit = 0; + if (exn.RE_EXN_ID === Cycle) { + let match = exn._1; + if (match && match.hd === "go") { + let match$1 = match.tl; + if (match$1 && match$1.hd === "washup") { + let match$2 = match$1.tl; + if (match$2 && match$2.hd === "eat") { + let match$3 = match$2.tl; + if (!(match$3 && match$3.hd === "go" && !match$3.tl)) { + exit = 1; + } + + } else { + exit = 1; + } + } else { + exit = 1; + } + } else { + exit = 1; + } + } else { + exit = 1; + } + if (exit === 1) { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "topsort_test.res", + 154, + 7 + ], + Error: new Error() + }; + } + +} + +let String_set; + +export { + graph, + nexts, + dfs1, + dfs2, + dfs3, + grwork, + unsafe_topsort, + String_set, + Cycle, + pathsort, +} +/* Not a pure module */ diff --git a/tests/tests/src/tramp_fib.js b/tests/tests/src/tramp_fib.js deleted file mode 100644 index 9e70049c28..0000000000 --- a/tests/tests/src/tramp_fib.js +++ /dev/null @@ -1,98 +0,0 @@ -// Generated by ReScript, PLEASE EDIT WITH CARE -'use strict'; - -let Mt = require("./mt.js"); - -let suites = { - contents: /* [] */0 -}; - -let test_id = { - contents: 0 -}; - -function eq(loc, x, y) { - Mt.eq_suites(test_id, suites, loc, x, y); -} - -function fib(n, k) { - if (n === 0 || n === 1) { - return k(1); - } else { - return { - TAG: "Suspend", - _0: () => fib(n - 1 | 0, v0 => fib(n - 2 | 0, v1 => k(v0 + v1 | 0))) - }; - } -} - -let u = fib(10, x => ({ - TAG: "Continue", - _0: x -})); - -function iter(_bounce) { - while (true) { - let bounce = _bounce; - if (bounce.TAG === "Continue") { - return bounce._0; - } - _bounce = bounce._0(); - continue; - }; -} - -function isEven(n) { - if (n !== 0) { - if (n !== 1) { - return { - TAG: "Suspend", - _0: () => isOdd(n - 1 | 0) - }; - } else { - return { - TAG: "Continue", - _0: false - }; - } - } else { - return { - TAG: "Continue", - _0: true - }; - } -} - -function isOdd(n) { - if (n !== 0) { - if (n !== 1) { - return isEven(n - 1 | 0); - } else { - return { - TAG: "Continue", - _0: true - }; - } - } else { - return { - TAG: "Continue", - _0: false - }; - } -} - -eq("File \"tramp_fib.res\", line 53, characters 3-10", iter(u), 89); - -eq("File \"tramp_fib.res\", line 55, characters 3-10", iter(isEven(20000)), true); - -Mt.from_pair_suites("File \"tramp_fib.res\", line 57, characters 20-27", suites.contents); - -exports.suites = suites; -exports.test_id = test_id; -exports.eq = eq; -exports.fib = fib; -exports.u = u; -exports.iter = iter; -exports.isEven = isEven; -exports.isOdd = isOdd; -/* u Not a pure module */ diff --git a/tests/tests/src/tramp_fib.mjs b/tests/tests/src/tramp_fib.mjs new file mode 100644 index 0000000000..69ceed051f --- /dev/null +++ b/tests/tests/src/tramp_fib.mjs @@ -0,0 +1,99 @@ +// Generated by ReScript, PLEASE EDIT WITH CARE + +import * as Mt from "./mt.mjs"; + +let suites = { + contents: /* [] */0 +}; + +let test_id = { + contents: 0 +}; + +function eq(loc, x, y) { + Mt.eq_suites(test_id, suites, loc, x, y); +} + +function fib(n, k) { + if (n === 0 || n === 1) { + return k(1); + } else { + return { + TAG: "Suspend", + _0: () => fib(n - 1 | 0, v0 => fib(n - 2 | 0, v1 => k(v0 + v1 | 0))) + }; + } +} + +let u = fib(10, x => ({ + TAG: "Continue", + _0: x +})); + +function iter(_bounce) { + while (true) { + let bounce = _bounce; + if (bounce.TAG === "Continue") { + return bounce._0; + } + _bounce = bounce._0(); + continue; + }; +} + +function isEven(n) { + if (n !== 0) { + if (n !== 1) { + return { + TAG: "Suspend", + _0: () => isOdd(n - 1 | 0) + }; + } else { + return { + TAG: "Continue", + _0: false + }; + } + } else { + return { + TAG: "Continue", + _0: true + }; + } +} + +function isOdd(n) { + if (n !== 0) { + if (n !== 1) { + return isEven(n - 1 | 0); + } else { + return { + TAG: "Continue", + _0: true + }; + } + } else { + return { + TAG: "Continue", + _0: false + }; + } +} + +eq("File \"tramp_fib.res\", line 53, characters 3-10", iter(u), 89); + +eq("File \"tramp_fib.res\", line 55, characters 3-10", iter(isEven(20000)), true); + +Mt.from_pair_suites("File \"tramp_fib.res\", line 57, characters 20-27", suites.contents); + +export { + suites, + test_id, + eq, + fib, + u, + iter, + isEven, + isOdd, +} +/* u Not a pure module */ diff --git a/tests/tests/src/tuple_alloc.js b/tests/tests/src/tuple_alloc.js deleted file mode 100644 index 2e63775eeb..0000000000 --- a/tests/tests/src/tuple_alloc.js +++ /dev/null @@ -1,53 +0,0 @@ -// Generated by ReScript, PLEASE EDIT WITH CARE -'use strict'; - - -let v = { - contents: 0 -}; - -function reset(param) { - v.contents = 0; -} - -function incr(param) { - v.contents = v.contents + 1 | 0; -} - -let vv = { - contents: 0 -}; - -function reset2() { - vv.contents = 0; -} - -function incr2() { - v.contents = v.contents + 1 | 0; -} - -function f(a, b, d, e) { - let h = a(b); - let u = d(h); - let v = e(h); - return u + v | 0; -} - -function kf(cb, v) { - cb(v); - return v + v | 0; -} - -function ikf(v) { - return kf(prim => {}, v); -} - -exports.v = v; -exports.reset = reset; -exports.incr = incr; -exports.reset2 = reset2; -exports.incr2 = incr2; -exports.f = f; -exports.kf = kf; -exports.ikf = ikf; -/* No side effect */ diff --git a/tests/tests/src/tuple_alloc.mjs b/tests/tests/src/tuple_alloc.mjs new file mode 100644 index 0000000000..8709386cca --- /dev/null +++ b/tests/tests/src/tuple_alloc.mjs @@ -0,0 +1,54 @@ +// Generated by ReScript, PLEASE EDIT WITH CARE + + +let v = { + contents: 0 +}; + +function reset(param) { + v.contents = 0; +} + +function incr(param) { + v.contents = v.contents + 1 | 0; +} + +let vv = { + contents: 0 +}; + +function reset2() { + vv.contents = 0; +} + +function incr2() { + v.contents = v.contents + 1 | 0; +} + +function f(a, b, d, e) { + let h = a(b); + let u = d(h); + let v = e(h); + return u + v | 0; +} + +function kf(cb, v) { + cb(v); + return v + v | 0; +} + +function ikf(v) { + return kf(prim => {}, v); +} + +export { + v, + reset, + incr, + reset2, + incr2, + f, + kf, + ikf, +} +/* No side effect */ diff --git a/tests/tests/src/type_coercion_free_vars.js b/tests/tests/src/type_coercion_free_vars.js deleted file mode 100644 index e2efaa8c17..0000000000 --- a/tests/tests/src/type_coercion_free_vars.js +++ /dev/null @@ -1,73 +0,0 @@ -// Generated by ReScript, PLEASE EDIT WITH CARE -'use strict'; - - -function f(x) { - return x; -} - -function g(y) { - -} - -function h(x) { - return [ - undefined, - x - ]; -} - -let NoFreeVars = { - f: f, - g: g, - h: h -}; - -function f$1(x) { - return x; -} - -let WithTypeArg = { - f: f$1 -}; - -function f$2(param) { - return 3; -} - -let FunctionType = { - f: f$2 -}; - -function f1(param) { - -} - -function f2(param, param$1) { - -} - -let Contravariant = { - f1: f1, - f2: f2 -}; - -function f$3(x) { - return x; -} - -function idint(x) { - return x; -} - -let Totallypoly = { - f: f$3, - idint: idint -}; - -exports.NoFreeVars = NoFreeVars; -exports.WithTypeArg = WithTypeArg; -exports.FunctionType = FunctionType; -exports.Contravariant = Contravariant; -exports.Totallypoly = Totallypoly; -/* No side effect */ diff --git a/tests/tests/src/type_coercion_free_vars.mjs b/tests/tests/src/type_coercion_free_vars.mjs new file mode 100644 index 0000000000..5d3eb1d0eb --- /dev/null +++ b/tests/tests/src/type_coercion_free_vars.mjs @@ -0,0 +1,74 @@ +// Generated by ReScript, PLEASE EDIT WITH CARE + + +function f(x) { + return x; +} + +function g(y) { + +} + +function h(x) { + return [ + undefined, + x + ]; +} + +let NoFreeVars = { + f: f, + g: g, + h: h +}; + +function f$1(x) { + return x; +} + +let WithTypeArg = { + f: f$1 +}; + +function f$2(param) { + return 3; +} + +let FunctionType = { + f: f$2 +}; + +function f1(param) { + +} + +function f2(param, param$1) { + +} + +let Contravariant = { + f1: f1, + f2: f2 +}; + +function f$3(x) { + return x; +} + +function idint(x) { + return x; +} + +let Totallypoly = { + f: f$3, + idint: idint +}; + +export { + NoFreeVars, + WithTypeArg, + FunctionType, + Contravariant, + Totallypoly, +} +/* No side effect */ diff --git a/tests/tests/src/type_disambiguate.js b/tests/tests/src/type_disambiguate.js deleted file mode 100644 index 22dd58bcc4..0000000000 --- a/tests/tests/src/type_disambiguate.js +++ /dev/null @@ -1,19 +0,0 @@ -// Generated by ReScript, PLEASE EDIT WITH CARE -'use strict'; - - -let N = {}; - -function f(e) { - return (e.a + e.b | 0) + e.c | 0; -} - -function f1(e) { - let c = e.c; - return ((e.a + e.b | 0) + c | 0) + e.d(c) | 0; -} - -exports.N = N; -exports.f = f; -exports.f1 = f1; -/* No side effect */ diff --git a/tests/tests/src/type_disambiguate.mjs b/tests/tests/src/type_disambiguate.mjs new file mode 100644 index 0000000000..41f040b7e4 --- /dev/null +++ b/tests/tests/src/type_disambiguate.mjs @@ -0,0 +1,20 @@ +// Generated by ReScript, PLEASE EDIT WITH CARE + + +let N = {}; + +function f(e) { + return (e.a + e.b | 0) + e.c | 0; +} + +function f1(e) { + let c = e.c; + return ((e.a + e.b | 0) + c | 0) + e.d(c) | 0; +} + +export { + N, + f, + f1, +} +/* No side effect */ diff --git a/tests/tests/src/typeof_test.js b/tests/tests/src/typeof_test.js deleted file mode 100644 index 2e8c178079..0000000000 --- a/tests/tests/src/typeof_test.js +++ /dev/null @@ -1,166 +0,0 @@ -// Generated by ReScript, PLEASE EDIT WITH CARE -'use strict'; - -let Mt = require("./mt.js"); -let Js_types = require("rescript/lib/js/Js_types.js"); - -function string_or_number(x) { - let ty = Js_types.classify(x); - if (typeof ty !== "object") { - switch (ty) { - default: - return false; - } - } else { - switch (ty.TAG) { - case "JSNumber" : - console.log(ty._0 + 3); - return true; - case "JSString" : - console.log(ty._0 + "hei"); - return true; - case "JSFunction" : - console.log("Function"); - return false; - case "JSBigInt" : - console.log(ty._0.toString()); - return true; - default: - return false; - } - } -} - -let suites_0 = [ - "int_type", - param => ({ - TAG: "Eq", - _0: "number", - _1: "number" - }) -]; - -let suites_1 = { - hd: [ - "string_type", - param => ({ - TAG: "Eq", - _0: "string", - _1: "string" - }) - ], - tl: { - hd: [ - "number_gadt_test", - param => ({ - TAG: "Eq", - _0: Js_types.test(3, "Number"), - _1: true - }) - ], - tl: { - hd: [ - "boolean_gadt_test", - param => ({ - TAG: "Eq", - _0: Js_types.test(true, "Boolean"), - _1: true - }) - ], - tl: { - hd: [ - "undefined_gadt_test", - param => ({ - TAG: "Eq", - _0: Js_types.test(undefined, "Undefined"), - _1: true - }) - ], - tl: { - hd: [ - "string_on_number1", - param => ({ - TAG: "Eq", - _0: string_or_number("xx"), - _1: true - }) - ], - tl: { - hd: [ - "string_on_number2", - param => ({ - TAG: "Eq", - _0: string_or_number(3.02), - _1: true - }) - ], - tl: { - hd: [ - "string_on_number3", - param => ({ - TAG: "Eq", - _0: string_or_number(x => x), - _1: false - }) - ], - tl: { - hd: [ - "string_gadt_test", - param => ({ - TAG: "Eq", - _0: Js_types.test("3", "String"), - _1: true - }) - ], - tl: { - hd: [ - "string_gadt_test_neg", - param => ({ - TAG: "Eq", - _0: Js_types.test(3, "String"), - _1: false - }) - ], - tl: { - hd: [ - "function_gadt_test", - param => ({ - TAG: "Eq", - _0: Js_types.test(x => x, "Function"), - _1: true - }) - ], - tl: { - hd: [ - "object_gadt_test", - param => ({ - TAG: "Eq", - _0: Js_types.test({ - x: 3 - }, "Object"), - _1: true - }) - ], - tl: /* [] */0 - } - } - } - } - } - } - } - } - } - } -}; - -let suites = { - hd: suites_0, - tl: suites_1 -}; - -Mt.from_pair_suites("Typeof_test", suites); - -exports.string_or_number = string_or_number; -exports.suites = suites; -/* Not a pure module */ diff --git a/tests/tests/src/typeof_test.mjs b/tests/tests/src/typeof_test.mjs new file mode 100644 index 0000000000..f65c6cc482 --- /dev/null +++ b/tests/tests/src/typeof_test.mjs @@ -0,0 +1,167 @@ +// Generated by ReScript, PLEASE EDIT WITH CARE + +import * as Mt from "./mt.mjs"; +import * as Js_types from "rescript/lib/es6/Js_types.js"; + +function string_or_number(x) { + let ty = Js_types.classify(x); + if (typeof ty !== "object") { + switch (ty) { + default: + return false; + } + } else { + switch (ty.TAG) { + case "JSNumber" : + console.log(ty._0 + 3); + return true; + case "JSString" : + console.log(ty._0 + "hei"); + return true; + case "JSFunction" : + console.log("Function"); + return false; + case "JSBigInt" : + console.log(ty._0.toString()); + return true; + default: + return false; + } + } +} + +let suites_0 = [ + "int_type", + param => ({ + TAG: "Eq", + _0: "number", + _1: "number" + }) +]; + +let suites_1 = { + hd: [ + "string_type", + param => ({ + TAG: "Eq", + _0: "string", + _1: "string" + }) + ], + tl: { + hd: [ + "number_gadt_test", + param => ({ + TAG: "Eq", + _0: Js_types.test(3, "Number"), + _1: true + }) + ], + tl: { + hd: [ + "boolean_gadt_test", + param => ({ + TAG: "Eq", + _0: Js_types.test(true, "Boolean"), + _1: true + }) + ], + tl: { + hd: [ + "undefined_gadt_test", + param => ({ + TAG: "Eq", + _0: Js_types.test(undefined, "Undefined"), + _1: true + }) + ], + tl: { + hd: [ + "string_on_number1", + param => ({ + TAG: "Eq", + _0: string_or_number("xx"), + _1: true + }) + ], + tl: { + hd: [ + "string_on_number2", + param => ({ + TAG: "Eq", + _0: string_or_number(3.02), + _1: true + }) + ], + tl: { + hd: [ + "string_on_number3", + param => ({ + TAG: "Eq", + _0: string_or_number(x => x), + _1: false + }) + ], + tl: { + hd: [ + "string_gadt_test", + param => ({ + TAG: "Eq", + _0: Js_types.test("3", "String"), + _1: true + }) + ], + tl: { + hd: [ + "string_gadt_test_neg", + param => ({ + TAG: "Eq", + _0: Js_types.test(3, "String"), + _1: false + }) + ], + tl: { + hd: [ + "function_gadt_test", + param => ({ + TAG: "Eq", + _0: Js_types.test(x => x, "Function"), + _1: true + }) + ], + tl: { + hd: [ + "object_gadt_test", + param => ({ + TAG: "Eq", + _0: Js_types.test({ + x: 3 + }, "Object"), + _1: true + }) + ], + tl: /* [] */0 + } + } + } + } + } + } + } + } + } + } +}; + +let suites = { + hd: suites_0, + tl: suites_1 +}; + +Mt.from_pair_suites("Typeof_test", suites); + +export { + string_or_number, + suites, +} +/* Not a pure module */ diff --git a/tests/tests/src/unboxed_attribute.js b/tests/tests/src/unboxed_attribute.js deleted file mode 100644 index ca01d88ecf..0000000000 --- a/tests/tests/src/unboxed_attribute.js +++ /dev/null @@ -1,13 +0,0 @@ -// Generated by ReScript, PLEASE EDIT WITH CARE -'use strict'; - - -function u(param) { - return [ - 3, - u - ]; -} - -exports.u = u; -/* No side effect */ diff --git a/tests/tests/src/unboxed_attribute.mjs b/tests/tests/src/unboxed_attribute.mjs new file mode 100644 index 0000000000..92b45250a3 --- /dev/null +++ b/tests/tests/src/unboxed_attribute.mjs @@ -0,0 +1,14 @@ +// Generated by ReScript, PLEASE EDIT WITH CARE + + +function u(param) { + return [ + 3, + u + ]; +} + +export { + u, +} +/* No side effect */ diff --git a/tests/tests/src/unboxed_attribute_test.js b/tests/tests/src/unboxed_attribute_test.js deleted file mode 100644 index 9bc33ddede..0000000000 --- a/tests/tests/src/unboxed_attribute_test.js +++ /dev/null @@ -1,53 +0,0 @@ -// Generated by ReScript, PLEASE EDIT WITH CARE -'use strict'; - -let Mt = require("./mt.js"); - -let suites = { - contents: /* [] */0 -}; - -let test_id = { - contents: 0 -}; - -function eq(loc, x, y) { - Mt.eq_suites(test_id, suites, loc, x, y); -} - -function make(x) { - return x; -} - -function get(x) { - return x; -} - -let x = "foo"; - -eq("File \"unboxed_attribute_test.res\", line 19, characters 4-11", x, x); - -let x$1 = "foo"; - -eq("File \"unboxed_attribute_test.res\", line 34, characters 5-12", x$1, x$1); - -let x$2 = "foo"; - -eq("File \"unboxed_attribute_test.res\", line 43, characters 4-11", x$2, x$2); - -let y = {}; - -y._0 = y; - -Mt.from_pair_suites("unboxed_attribute_test.res", suites.contents); - -let v0 = 3; - -exports.suites = suites; -exports.test_id = test_id; -exports.eq = eq; -exports.v0 = v0; -exports.make = make; -exports.get = get; -exports.y = y; -/* Not a pure module */ diff --git a/tests/tests/src/unboxed_attribute_test.mjs b/tests/tests/src/unboxed_attribute_test.mjs new file mode 100644 index 0000000000..0211c7fb70 --- /dev/null +++ b/tests/tests/src/unboxed_attribute_test.mjs @@ -0,0 +1,54 @@ +// Generated by ReScript, PLEASE EDIT WITH CARE + +import * as Mt from "./mt.mjs"; + +let suites = { + contents: /* [] */0 +}; + +let test_id = { + contents: 0 +}; + +function eq(loc, x, y) { + Mt.eq_suites(test_id, suites, loc, x, y); +} + +function make(x) { + return x; +} + +function get(x) { + return x; +} + +let x = "foo"; + +eq("File \"unboxed_attribute_test.res\", line 19, characters 4-11", x, x); + +let x$1 = "foo"; + +eq("File \"unboxed_attribute_test.res\", line 34, characters 5-12", x$1, x$1); + +let x$2 = "foo"; + +eq("File \"unboxed_attribute_test.res\", line 43, characters 4-11", x$2, x$2); + +let y = {}; + +y._0 = y; + +Mt.from_pair_suites("unboxed_attribute_test.res", suites.contents); + +let v0 = 3; + +export { + suites, + test_id, + eq, + v0, + make, + get, + y, +} +/* Not a pure module */ diff --git a/tests/tests/src/unboxed_crash.js b/tests/tests/src/unboxed_crash.js deleted file mode 100644 index f556f3b58a..0000000000 --- a/tests/tests/src/unboxed_crash.js +++ /dev/null @@ -1,13 +0,0 @@ -// Generated by ReScript, PLEASE EDIT WITH CARE -'use strict'; - - -function g(x) { - return x(x); -} - -let loop = g(g); - -exports.g = g; -exports.loop = loop; -/* loop Not a pure module */ diff --git a/tests/tests/src/unboxed_crash.mjs b/tests/tests/src/unboxed_crash.mjs new file mode 100644 index 0000000000..43d31f8148 --- /dev/null +++ b/tests/tests/src/unboxed_crash.mjs @@ -0,0 +1,14 @@ +// Generated by ReScript, PLEASE EDIT WITH CARE + + +function g(x) { + return x(x); +} + +let loop = g(g); + +export { + g, + loop, +} +/* loop Not a pure module */ diff --git a/tests/tests/src/unboxed_use_case.js b/tests/tests/src/unboxed_use_case.js deleted file mode 100644 index f7d5cad5be..0000000000 --- a/tests/tests/src/unboxed_use_case.js +++ /dev/null @@ -1,47 +0,0 @@ -// Generated by ReScript, PLEASE EDIT WITH CARE -'use strict'; - -let Primitive_object = require("rescript/lib/js/Primitive_object.js"); - -function map_pair(r, param) { - return [ - r(param[0]), - r(param[1]) - ]; -} - -function u(x) { - return x; -} - -map_pair(u, [ - 3, - true -]); - -let hi = [ - 3, - 2, - "x" -]; - -console.log(3); - -console.log("x"); - -let v0 = {}; - -Primitive_object.updateDummy(v0, { - NAME: "A", - VAL: v0 -}); - -let v1 = { - NAME: "A", - VAL: "B" -}; - -exports.hi = hi; -exports.v0 = v0; -exports.v1 = v1; -/* Not a pure module */ diff --git a/tests/tests/src/unboxed_use_case.mjs b/tests/tests/src/unboxed_use_case.mjs new file mode 100644 index 0000000000..600487961e --- /dev/null +++ b/tests/tests/src/unboxed_use_case.mjs @@ -0,0 +1,48 @@ +// Generated by ReScript, PLEASE EDIT WITH CARE + +import * as Primitive_object from "rescript/lib/es6/Primitive_object.js"; + +function map_pair(r, param) { + return [ + r(param[0]), + r(param[1]) + ]; +} + +function u(x) { + return x; +} + +map_pair(u, [ + 3, + true +]); + +let hi = [ + 3, + 2, + "x" +]; + +console.log(3); + +console.log("x"); + +let v0 = {}; + +Primitive_object.updateDummy(v0, { + NAME: "A", + VAL: v0 +}); + +let v1 = { + NAME: "A", + VAL: "B" +}; + +export { + hi, + v0, + v1, +} +/* Not a pure module */ diff --git a/tests/tests/src/uncurried_cast.js b/tests/tests/src/uncurried_cast.js deleted file mode 100644 index e0ed8d3bf5..0000000000 --- a/tests/tests/src/uncurried_cast.js +++ /dev/null @@ -1,106 +0,0 @@ -// Generated by ReScript, PLEASE EDIT WITH CARE -'use strict'; - -let Belt_List = require("rescript/lib/js/Belt_List.js"); -let Primitive_exceptions = require("rescript/lib/js/Primitive_exceptions.js"); - -function raise(e) { - throw e; -} - -let map = Belt_List.map; - -let List = { - map: map -}; - -let Uncurried = { - raise: raise, - List: List -}; - -let E = /* @__PURE__ */Primitive_exceptions.create("Uncurried_cast.E"); - -function testRaise() { - throw { - RE_EXN_ID: E, - Error: new Error() - }; -} - -let l = Belt_List.map({ - hd: 1, - tl: { - hd: 2, - tl: /* [] */0 - } -}, x => x + 1 | 0); - -function partial(x) { - return Belt_List.map({ - hd: 1, - tl: { - hd: 2, - tl: /* [] */0 - } - }, x); -} - -let ll = partial(x => x + 1 | 0); - -function withOpts(xOpt, y, zOpt, w) { - let x = xOpt !== undefined ? xOpt : 3; - let z = zOpt !== undefined ? zOpt : 4; - return ((x + y | 0) + z | 0) + w | 0; -} - -let StandardNotation = { - testRaise: testRaise, - l: l, - partial: partial, - ll: ll, - withOpts: withOpts -}; - -function testRaise$1() { - throw { - RE_EXN_ID: E, - Error: new Error() - }; -} - -let l$1 = Belt_List.map({ - hd: 1, - tl: { - hd: 2, - tl: /* [] */0 - } -}, x => x + 1 | 0); - -function partial$1(extra) { - return Belt_List.map({ - hd: 1, - tl: { - hd: 2, - tl: /* [] */0 - } - }, extra); -} - -let ll$1 = partial$1(x => x + 1 | 0); - -function withOpts$1(xOpt, y, zOpt, w) { - let x = xOpt !== undefined ? xOpt : 3; - let z = zOpt !== undefined ? zOpt : 4; - return ((x + y | 0) + z | 0) + w | 0; -} - -exports.Uncurried = Uncurried; -exports.E = E; -exports.StandardNotation = StandardNotation; -exports.testRaise = testRaise$1; -exports.l = l$1; -exports.partial = partial$1; -exports.ll = ll$1; -exports.withOpts = withOpts$1; -/* l Not a pure module */ diff --git a/tests/tests/src/uncurried_cast.mjs b/tests/tests/src/uncurried_cast.mjs new file mode 100644 index 0000000000..9120570a74 --- /dev/null +++ b/tests/tests/src/uncurried_cast.mjs @@ -0,0 +1,107 @@ +// Generated by ReScript, PLEASE EDIT WITH CARE + +import * as Belt_List from "rescript/lib/es6/Belt_List.js"; +import * as Primitive_exceptions from "rescript/lib/es6/Primitive_exceptions.js"; + +function raise(e) { + throw e; +} + +let map = Belt_List.map; + +let List = { + map: map +}; + +let Uncurried = { + raise: raise, + List: List +}; + +let E = /* @__PURE__ */Primitive_exceptions.create("Uncurried_cast.E"); + +function testRaise() { + throw { + RE_EXN_ID: E, + Error: new Error() + }; +} + +let l = Belt_List.map({ + hd: 1, + tl: { + hd: 2, + tl: /* [] */0 + } +}, x => x + 1 | 0); + +function partial(x) { + return Belt_List.map({ + hd: 1, + tl: { + hd: 2, + tl: /* [] */0 + } + }, x); +} + +let ll = partial(x => x + 1 | 0); + +function withOpts(xOpt, y, zOpt, w) { + let x = xOpt !== undefined ? xOpt : 3; + let z = zOpt !== undefined ? zOpt : 4; + return ((x + y | 0) + z | 0) + w | 0; +} + +let StandardNotation = { + testRaise: testRaise, + l: l, + partial: partial, + ll: ll, + withOpts: withOpts +}; + +function testRaise$1() { + throw { + RE_EXN_ID: E, + Error: new Error() + }; +} + +let l$1 = Belt_List.map({ + hd: 1, + tl: { + hd: 2, + tl: /* [] */0 + } +}, x => x + 1 | 0); + +function partial$1(extra) { + return Belt_List.map({ + hd: 1, + tl: { + hd: 2, + tl: /* [] */0 + } + }, extra); +} + +let ll$1 = partial$1(x => x + 1 | 0); + +function withOpts$1(xOpt, y, zOpt, w) { + let x = xOpt !== undefined ? xOpt : 3; + let z = zOpt !== undefined ? zOpt : 4; + return ((x + y | 0) + z | 0) + w | 0; +} + +export { + Uncurried, + E, + StandardNotation, + testRaise$1 as testRaise, + l$1 as l, + partial$1 as partial, + ll$1 as ll, + withOpts$1 as withOpts, +} +/* l Not a pure module */ diff --git a/tests/tests/src/uncurried_default.args.js b/tests/tests/src/uncurried_default.args.js deleted file mode 100644 index 3cf995aa9b..0000000000 --- a/tests/tests/src/uncurried_default.args.js +++ /dev/null @@ -1,112 +0,0 @@ -// Generated by ReScript, PLEASE EDIT WITH CARE -'use strict'; - - -function withOpt(xOpt, y) { - let x = xOpt !== undefined ? xOpt : 1; - return (zOpt, w) => { - let z = zOpt !== undefined ? zOpt : 1; - return ((x + y | 0) + z | 0) + w | 0; - }; -} - -let testWithOpt = withOpt(undefined, 3)(undefined, 4); - -let partial = withOpt(10, 3)(4, 11); - -let total = withOpt(10, 3)(4, 11); - -function foo1(xOpt, y) { - let x = xOpt !== undefined ? xOpt : 3; - return x + y | 0; -} - -let x = 3; - -let r1 = x + 11 | 0; - -function foo2(y, xOpt, zOpt) { - let x = xOpt !== undefined ? xOpt : 3; - let z = zOpt !== undefined ? zOpt : 4; - return (x + y | 0) + z | 0; -} - -let r2 = foo2(11, undefined, undefined); - -function foo3(xOpt, yOpt) { - let x = xOpt !== undefined ? xOpt : 3; - let y = yOpt !== undefined ? yOpt : 4; - return x + y | 0; -} - -let r3 = foo3(undefined, undefined); - -let StandardNotation = { - withOpt: withOpt, - testWithOpt: testWithOpt, - partial: partial, - total: total, - foo1: foo1, - r1: r1, - foo2: foo2, - r2: r2, - foo3: foo3, - r3: r3 -}; - -function withOpt$1(xOpt, y) { - let x = xOpt !== undefined ? xOpt : 1; - return (zOpt, w) => { - let z = zOpt !== undefined ? zOpt : 1; - return ((x + y | 0) + z | 0) + w | 0; - }; -} - -let testWithOpt$1 = withOpt$1(undefined, 3)(undefined, 4); - -let total$1 = withOpt$1(10, 3)(4, 11); - -function foo1$1(xOpt, y) { - let x = xOpt !== undefined ? xOpt : 3; - return x + y | 0; -} - -let x$1 = 3; - -let r1$1 = x$1 + 11 | 0; - -function foo2$1(y, xOpt, zOpt, param) { - let x = xOpt !== undefined ? xOpt : 3; - let z = zOpt !== undefined ? zOpt : 4; - return (x + y | 0) + z | 0; -} - -function r2$1(extra, extra$1, extra$2) { - return foo2$1(11, extra, extra$1, extra$2); -} - -function foo3$1(xOpt, yOpt, param) { - let x = xOpt !== undefined ? xOpt : 3; - let y = yOpt !== undefined ? yOpt : 4; - return x + y | 0; -} - -function foo(func) { - return func() + 1 | 0; -} - -let M = { - foo: foo -}; - -exports.StandardNotation = StandardNotation; -exports.withOpt = withOpt$1; -exports.testWithOpt = testWithOpt$1; -exports.total = total$1; -exports.foo1 = foo1$1; -exports.r1 = r1$1; -exports.foo2 = foo2$1; -exports.r2 = r2$1; -exports.foo3 = foo3$1; -exports.M = M; -/* testWithOpt Not a pure module */ diff --git a/tests/tests/src/uncurried_default.args.mjs b/tests/tests/src/uncurried_default.args.mjs new file mode 100644 index 0000000000..2cabf6e06a --- /dev/null +++ b/tests/tests/src/uncurried_default.args.mjs @@ -0,0 +1,113 @@ +// Generated by ReScript, PLEASE EDIT WITH CARE + + +function withOpt(xOpt, y) { + let x = xOpt !== undefined ? xOpt : 1; + return (zOpt, w) => { + let z = zOpt !== undefined ? zOpt : 1; + return ((x + y | 0) + z | 0) + w | 0; + }; +} + +let testWithOpt = withOpt(undefined, 3)(undefined, 4); + +let partial = withOpt(10, 3)(4, 11); + +let total = withOpt(10, 3)(4, 11); + +function foo1(xOpt, y) { + let x = xOpt !== undefined ? xOpt : 3; + return x + y | 0; +} + +let x = 3; + +let r1 = x + 11 | 0; + +function foo2(y, xOpt, zOpt) { + let x = xOpt !== undefined ? xOpt : 3; + let z = zOpt !== undefined ? zOpt : 4; + return (x + y | 0) + z | 0; +} + +let r2 = foo2(11, undefined, undefined); + +function foo3(xOpt, yOpt) { + let x = xOpt !== undefined ? xOpt : 3; + let y = yOpt !== undefined ? yOpt : 4; + return x + y | 0; +} + +let r3 = foo3(undefined, undefined); + +let StandardNotation = { + withOpt: withOpt, + testWithOpt: testWithOpt, + partial: partial, + total: total, + foo1: foo1, + r1: r1, + foo2: foo2, + r2: r2, + foo3: foo3, + r3: r3 +}; + +function withOpt$1(xOpt, y) { + let x = xOpt !== undefined ? xOpt : 1; + return (zOpt, w) => { + let z = zOpt !== undefined ? zOpt : 1; + return ((x + y | 0) + z | 0) + w | 0; + }; +} + +let testWithOpt$1 = withOpt$1(undefined, 3)(undefined, 4); + +let total$1 = withOpt$1(10, 3)(4, 11); + +function foo1$1(xOpt, y) { + let x = xOpt !== undefined ? xOpt : 3; + return x + y | 0; +} + +let x$1 = 3; + +let r1$1 = x$1 + 11 | 0; + +function foo2$1(y, xOpt, zOpt, param) { + let x = xOpt !== undefined ? xOpt : 3; + let z = zOpt !== undefined ? zOpt : 4; + return (x + y | 0) + z | 0; +} + +function r2$1(extra, extra$1, extra$2) { + return foo2$1(11, extra, extra$1, extra$2); +} + +function foo3$1(xOpt, yOpt, param) { + let x = xOpt !== undefined ? xOpt : 3; + let y = yOpt !== undefined ? yOpt : 4; + return x + y | 0; +} + +function foo(func) { + return func() + 1 | 0; +} + +let M = { + foo: foo +}; + +export { + StandardNotation, + withOpt$1 as withOpt, + testWithOpt$1 as testWithOpt, + total$1 as total, + foo1$1 as foo1, + r1$1 as r1, + foo2$1 as foo2, + r2$1 as r2, + foo3$1 as foo3, + M, +} +/* testWithOpt Not a pure module */ diff --git a/tests/tests/src/uncurried_pipe.js b/tests/tests/src/uncurried_pipe.js deleted file mode 100644 index 55c0ae9d4e..0000000000 --- a/tests/tests/src/uncurried_pipe.js +++ /dev/null @@ -1,51 +0,0 @@ -// Generated by ReScript, PLEASE EDIT WITH CARE -'use strict'; - - -function add(x, y) { - return x + y | 0; -} - -function addC(x, y) { - return x + y | 0; -} - -let v7 = 7; - -let v17 = 17; - -let v27 = 27; - -let v37 = 37; - -function unary(x) { - return x + 1 | 0; -} - -let StandardNotation = { - add: add, - addC: addC, - v7: v7, - v17: v17, - v27: v27, - v37: v37, - unary: unary -}; - -let v7$1 = 7; - -let v17$1 = 17; - -let v27$1 = 27; - -let v37$1 = 37; - -let v100 = 100; - -exports.StandardNotation = StandardNotation; -exports.v7 = v7$1; -exports.v17 = v17$1; -exports.v27 = v27$1; -exports.v37 = v37$1; -exports.v100 = v100; -/* No side effect */ diff --git a/tests/tests/src/uncurried_pipe.mjs b/tests/tests/src/uncurried_pipe.mjs new file mode 100644 index 0000000000..e89588197d --- /dev/null +++ b/tests/tests/src/uncurried_pipe.mjs @@ -0,0 +1,52 @@ +// Generated by ReScript, PLEASE EDIT WITH CARE + + +function add(x, y) { + return x + y | 0; +} + +function addC(x, y) { + return x + y | 0; +} + +let v7 = 7; + +let v17 = 17; + +let v27 = 27; + +let v37 = 37; + +function unary(x) { + return x + 1 | 0; +} + +let StandardNotation = { + add: add, + addC: addC, + v7: v7, + v17: v17, + v27: v27, + v37: v37, + unary: unary +}; + +let v7$1 = 7; + +let v17$1 = 17; + +let v27$1 = 27; + +let v37$1 = 37; + +let v100 = 100; + +export { + StandardNotation, + v7$1 as v7, + v17$1 as v17, + v27$1 as v27, + v37$1 as v37, + v100, +} +/* No side effect */ diff --git a/tests/tests/src/uncurry_external_test.js b/tests/tests/src/uncurry_external_test.js deleted file mode 100644 index aec9171cd6..0000000000 --- a/tests/tests/src/uncurry_external_test.js +++ /dev/null @@ -1,44 +0,0 @@ -// Generated by ReScript, PLEASE EDIT WITH CARE -'use strict'; - -let Mt = require("./mt.js"); - -let suites = { - contents: /* [] */0 -}; - -let test_id = { - contents: 0 -}; - -function eq(loc, x, y) { - test_id.contents = test_id.contents + 1 | 0; - suites.contents = { - hd: [ - loc + (" id " + test_id.contents.toString()), - () => ({ - TAG: "Eq", - _0: x, - _1: y - }) - ], - tl: suites.contents - }; -} - -function sum(a,b){ - return a + b -} -; - -let h = sum(1.0, 2.0); - -eq("File \"uncurry_external_test.res\", line 22, characters 12-19", h, 3); - -Mt.from_pair_suites("Uncurry_external_test", suites.contents); - -exports.suites = suites; -exports.test_id = test_id; -exports.eq = eq; -exports.h = h; -/* Not a pure module */ diff --git a/tests/tests/src/uncurry_external_test.mjs b/tests/tests/src/uncurry_external_test.mjs new file mode 100644 index 0000000000..3ad2681cbe --- /dev/null +++ b/tests/tests/src/uncurry_external_test.mjs @@ -0,0 +1,45 @@ +// Generated by ReScript, PLEASE EDIT WITH CARE + +import * as Mt from "./mt.mjs"; + +let suites = { + contents: /* [] */0 +}; + +let test_id = { + contents: 0 +}; + +function eq(loc, x, y) { + test_id.contents = test_id.contents + 1 | 0; + suites.contents = { + hd: [ + loc + (" id " + test_id.contents.toString()), + () => ({ + TAG: "Eq", + _0: x, + _1: y + }) + ], + tl: suites.contents + }; +} + +function sum(a,b){ + return a + b +} +; + +let h = sum(1.0, 2.0); + +eq("File \"uncurry_external_test.res\", line 22, characters 12-19", h, 3); + +Mt.from_pair_suites("Uncurry_external_test", suites.contents); + +export { + suites, + test_id, + eq, + h, +} +/* Not a pure module */ diff --git a/tests/tests/src/uncurry_glob_test.js b/tests/tests/src/uncurry_glob_test.js deleted file mode 100644 index cd2c5f391a..0000000000 --- a/tests/tests/src/uncurry_glob_test.js +++ /dev/null @@ -1,28 +0,0 @@ -// Generated by ReScript, PLEASE EDIT WITH CARE -'use strict'; - - -function M(U) { - let v = U.f(100, "x"); - return { - v: v - }; -} - -function f() { - return 3; -} - -function $plus$great(a, h) { - return h(a); -} - -function u(h) { - return h(3); -} - -exports.M = M; -exports.f = f; -exports.$plus$great = $plus$great; -exports.u = u; -/* No side effect */ diff --git a/tests/tests/src/uncurry_glob_test.mjs b/tests/tests/src/uncurry_glob_test.mjs new file mode 100644 index 0000000000..a23089840a --- /dev/null +++ b/tests/tests/src/uncurry_glob_test.mjs @@ -0,0 +1,29 @@ +// Generated by ReScript, PLEASE EDIT WITH CARE + + +function M(U) { + let v = U.f(100, "x"); + return { + v: v + }; +} + +function f() { + return 3; +} + +function $plus$great(a, h) { + return h(a); +} + +function u(h) { + return h(3); +} + +export { + M, + f, + $plus$great, + u, +} +/* No side effect */ diff --git a/tests/tests/src/uncurry_test.js b/tests/tests/src/uncurry_test.js deleted file mode 100644 index 878d77dae1..0000000000 --- a/tests/tests/src/uncurry_test.js +++ /dev/null @@ -1,44 +0,0 @@ -// Generated by ReScript, PLEASE EDIT WITH CARE -'use strict'; - - -function f0() { - return 0; -} - -function f1(a0) { - return a0; -} - -function f2(a0, a1) { - return [ - a0, - a1 - ]; -} - -console.log(0); - -console.log(0); - -console.log([ - 0, - 1 -]); - -function xx() { - while (true) { - continue; - }; -} - -function log2(logger, message, obj) { - logger.log2(message, obj); -} - -exports.f0 = f0; -exports.f1 = f1; -exports.f2 = f2; -exports.xx = xx; -exports.log2 = log2; -/* Not a pure module */ diff --git a/tests/tests/src/uncurry_test.mjs b/tests/tests/src/uncurry_test.mjs new file mode 100644 index 0000000000..d837ee78e0 --- /dev/null +++ b/tests/tests/src/uncurry_test.mjs @@ -0,0 +1,45 @@ +// Generated by ReScript, PLEASE EDIT WITH CARE + + +function f0() { + return 0; +} + +function f1(a0) { + return a0; +} + +function f2(a0, a1) { + return [ + a0, + a1 + ]; +} + +console.log(0); + +console.log(0); + +console.log([ + 0, + 1 +]); + +function xx() { + while (true) { + continue; + }; +} + +function log2(logger, message, obj) { + logger.log2(message, obj); +} + +export { + f0, + f1, + f2, + xx, + log2, +} +/* Not a pure module */ diff --git a/tests/tests/src/undef_regression_test.js b/tests/tests/src/undef_regression_test.js deleted file mode 100644 index b0f7d3fa3c..0000000000 --- a/tests/tests/src/undef_regression_test.js +++ /dev/null @@ -1,18 +0,0 @@ -// Generated by ReScript, PLEASE EDIT WITH CARE -'use strict'; - - -function f(obj) { - if (typeof obj === "function") { - return; - } - let size = obj.length; - if (size !== undefined) { - console.log(size); - return; - } - -} - -exports.f = f; -/* No side effect */ diff --git a/tests/tests/src/undef_regression_test.mjs b/tests/tests/src/undef_regression_test.mjs new file mode 100644 index 0000000000..7508734332 --- /dev/null +++ b/tests/tests/src/undef_regression_test.mjs @@ -0,0 +1,19 @@ +// Generated by ReScript, PLEASE EDIT WITH CARE + + +function f(obj) { + if (typeof obj === "function") { + return; + } + let size = obj.length; + if (size !== undefined) { + console.log(size); + return; + } + +} + +export { + f, +} +/* No side effect */ diff --git a/tests/tests/src/unit_undefined_test.js b/tests/tests/src/unit_undefined_test.js deleted file mode 100644 index 839d110d4e..0000000000 --- a/tests/tests/src/unit_undefined_test.js +++ /dev/null @@ -1,82 +0,0 @@ -// Generated by ReScript, PLEASE EDIT WITH CARE -'use strict'; - -let Mt = require("./mt.js"); -let Primitive_option = require("rescript/lib/js/Primitive_option.js"); - -let suites = { - contents: /* [] */0 -}; - -let test_id = { - contents: 0 -}; - -function eq(loc, x, y) { - Mt.eq_suites(test_id, suites, loc, x, y); -} - -function f_01() { - return hi(x => { - if (x === undefined) { - console.log("x"); - return; - } - - }); -} - -function u(x) { - if (x > 3) { - return 1; - } else if (x < 2) { - return 2; - } else if (x > 4) { - return 0; - } else { - return 3; - } -} - -function fx() { - -} - -function u0(x) { - return Primitive_option.some(x); -} - -let u1 = Primitive_option.some(undefined); - -function u2(x) { - return Primitive_option.some(x); -} - -let u3 = Primitive_option.some(undefined); - -eq("File \"unit_undefined_test.res\", line 41, characters 3-10", Primitive_option.some(), Primitive_option.some(undefined)); - -eq("File \"unit_undefined_test.res\", line 42, characters 3-10", u1, Primitive_option.some(undefined)); - -eq("File \"unit_undefined_test.res\", line 43, characters 3-10", Primitive_option.some(), Primitive_option.some(undefined)); - -eq("File \"unit_undefined_test.res\", line 44, characters 3-10", u3, Primitive_option.some(undefined)); - -eq("File \"unit_undefined_test.res\", line 45, characters 3-10", undefined, undefined); - -Mt.from_pair_suites("unit_undefined_test.res", suites.contents); - -let u4; - -exports.suites = suites; -exports.test_id = test_id; -exports.eq = eq; -exports.f_01 = f_01; -exports.u = u; -exports.fx = fx; -exports.u0 = u0; -exports.u1 = u1; -exports.u2 = u2; -exports.u3 = u3; -exports.u4 = u4; -/* Not a pure module */ diff --git a/tests/tests/src/unit_undefined_test.mjs b/tests/tests/src/unit_undefined_test.mjs new file mode 100644 index 0000000000..c7751f3612 --- /dev/null +++ b/tests/tests/src/unit_undefined_test.mjs @@ -0,0 +1,83 @@ +// Generated by ReScript, PLEASE EDIT WITH CARE + +import * as Mt from "./mt.mjs"; +import * as Primitive_option from "rescript/lib/es6/Primitive_option.js"; + +let suites = { + contents: /* [] */0 +}; + +let test_id = { + contents: 0 +}; + +function eq(loc, x, y) { + Mt.eq_suites(test_id, suites, loc, x, y); +} + +function f_01() { + return hi(x => { + if (x === undefined) { + console.log("x"); + return; + } + + }); +} + +function u(x) { + if (x > 3) { + return 1; + } else if (x < 2) { + return 2; + } else if (x > 4) { + return 0; + } else { + return 3; + } +} + +function fx() { + +} + +function u0(x) { + return Primitive_option.some(x); +} + +let u1 = Primitive_option.some(undefined); + +function u2(x) { + return Primitive_option.some(x); +} + +let u3 = Primitive_option.some(undefined); + +eq("File \"unit_undefined_test.res\", line 41, characters 3-10", Primitive_option.some(), Primitive_option.some(undefined)); + +eq("File \"unit_undefined_test.res\", line 42, characters 3-10", u1, Primitive_option.some(undefined)); + +eq("File \"unit_undefined_test.res\", line 43, characters 3-10", Primitive_option.some(), Primitive_option.some(undefined)); + +eq("File \"unit_undefined_test.res\", line 44, characters 3-10", u3, Primitive_option.some(undefined)); + +eq("File \"unit_undefined_test.res\", line 45, characters 3-10", undefined, undefined); + +Mt.from_pair_suites("unit_undefined_test.res", suites.contents); + +let u4; + +export { + suites, + test_id, + eq, + f_01, + u, + fx, + u0, + u1, + u2, + u3, + u4, +} +/* Not a pure module */ diff --git a/tests/tests/src/unsafe_full_apply_primitive.js b/tests/tests/src/unsafe_full_apply_primitive.js deleted file mode 100644 index 08bdde1f35..0000000000 --- a/tests/tests/src/unsafe_full_apply_primitive.js +++ /dev/null @@ -1,12 +0,0 @@ -// Generated by ReScript, PLEASE EDIT WITH CARE -'use strict'; - - -function f(a) { - while (true) { - continue; - }; -} - -exports.f = f; -/* No side effect */ diff --git a/tests/tests/src/unsafe_full_apply_primitive.mjs b/tests/tests/src/unsafe_full_apply_primitive.mjs new file mode 100644 index 0000000000..6a4864c90a --- /dev/null +++ b/tests/tests/src/unsafe_full_apply_primitive.mjs @@ -0,0 +1,13 @@ +// Generated by ReScript, PLEASE EDIT WITH CARE + + +function f(a) { + while (true) { + continue; + }; +} + +export { + f, +} +/* No side effect */ diff --git a/tests/tests/src/unsafe_ppx_test.js b/tests/tests/src/unsafe_ppx_test.js deleted file mode 100644 index 73cdb272c0..0000000000 --- a/tests/tests/src/unsafe_ppx_test.js +++ /dev/null @@ -1,106 +0,0 @@ -// Generated by ReScript, PLEASE EDIT WITH CARE -'use strict'; - -let Mt = require("./mt.js"); -let Pervasives = require("rescript/lib/js/Pervasives.js"); -let Ffi_js_test = require("./ffi_js_test.js"); - -let x = "\\x01\\x02\\x03"; - -let max = Math.max; - -function $$test(x,y){ - return x + y; -} -; - -let regression3 = Math.max; - -let regression4 = Math.max; - -function g(a) { - let regression = (function(x,y){ - return "" -}); - let regression2 = Math.max; - regression(a, Pervasives.failwith); - regression2(3, 2); - regression3(3, 2); - regression4(3, x => x); -} - -let max2 = Math.max; - -function umax(a, b) { - return max2(a, b); -} - -function u(h) { - return max2(3, h); -} - -let max3 = Math.max; - -function uu(h) { - return max2(3, h); -} - -let empty = Object.keys(3); - -let v = $$test(1, 2); - -Mt.from_pair_suites("Unsafe_ppx_test", { - hd: [ - "unsafe_max", - () => ({ - TAG: "Eq", - _0: 2, - _1: max(1, 2) - }) - ], - tl: { - hd: [ - "unsafe_test", - () => ({ - TAG: "Eq", - _0: 3, - _1: v - }) - ], - tl: { - hd: [ - "unsafe_max2", - () => ({ - TAG: "Eq", - _0: 2, - _1: Math.max(1, 2) - }) - ], - tl: { - hd: [ - "ffi_keys", - () => ({ - TAG: "Eq", - _0: ["a"], - _1: Ffi_js_test.keys({a : 3}) - }) - ], - tl: /* [] */0 - } - } - } -}); - -exports.x = x; -exports.max = max; -exports.regression3 = regression3; -exports.regression4 = regression4; -exports.g = g; -exports.max2 = max2; -exports.umax = umax; -exports.u = u; -exports.max3 = max3; -exports.uu = uu; -exports.empty = empty; -exports.v = v; -/* max Not a pure module */ diff --git a/tests/tests/src/unsafe_ppx_test.mjs b/tests/tests/src/unsafe_ppx_test.mjs new file mode 100644 index 0000000000..803e1b9f97 --- /dev/null +++ b/tests/tests/src/unsafe_ppx_test.mjs @@ -0,0 +1,107 @@ +// Generated by ReScript, PLEASE EDIT WITH CARE + +import * as Mt from "./mt.mjs"; +import * as Pervasives from "rescript/lib/es6/Pervasives.js"; +import * as Ffi_js_test from "./ffi_js_test.mjs"; + +let x = "\\x01\\x02\\x03"; + +let max = Math.max; + +function $$test(x,y){ + return x + y; +} +; + +let regression3 = Math.max; + +let regression4 = Math.max; + +function g(a) { + let regression = (function(x,y){ + return "" +}); + let regression2 = Math.max; + regression(a, Pervasives.failwith); + regression2(3, 2); + regression3(3, 2); + regression4(3, x => x); +} + +let max2 = Math.max; + +function umax(a, b) { + return max2(a, b); +} + +function u(h) { + return max2(3, h); +} + +let max3 = Math.max; + +function uu(h) { + return max2(3, h); +} + +let empty = Object.keys(3); + +let v = $$test(1, 2); + +Mt.from_pair_suites("Unsafe_ppx_test", { + hd: [ + "unsafe_max", + () => ({ + TAG: "Eq", + _0: 2, + _1: max(1, 2) + }) + ], + tl: { + hd: [ + "unsafe_test", + () => ({ + TAG: "Eq", + _0: 3, + _1: v + }) + ], + tl: { + hd: [ + "unsafe_max2", + () => ({ + TAG: "Eq", + _0: 2, + _1: Math.max(1, 2) + }) + ], + tl: { + hd: [ + "ffi_keys", + () => ({ + TAG: "Eq", + _0: ["a"], + _1: Ffi_js_test.keys({a : 3}) + }) + ], + tl: /* [] */0 + } + } + } +}); + +export { + x, + max, + regression3, + regression4, + g, + max2, + umax, + u, + max3, + uu, + empty, + v, +} +/* max Not a pure module */ diff --git a/tests/tests/src/update_record_test.js b/tests/tests/src/update_record_test.js deleted file mode 100644 index 75715296c5..0000000000 --- a/tests/tests/src/update_record_test.js +++ /dev/null @@ -1,81 +0,0 @@ -// Generated by ReScript, PLEASE EDIT WITH CARE -'use strict'; - -let Mt = require("./mt.js"); - -let suites = { - contents: /* [] */0 -}; - -let test_id = { - contents: 0 -}; - -function eq(loc, x, y) { - console.log([ - x, - y - ]); - test_id.contents = test_id.contents + 1 | 0; - suites.contents = { - hd: [ - loc + (" id " + test_id.contents.toString()), - () => ({ - TAG: "Eq", - _0: x, - _1: y - }) - ], - tl: suites.contents - }; -} - -function f(x) { - let y = {...x}; - return { - a0: 1, - a1: y.a1, - a2: y.a2, - a3: y.a3, - a4: y.a4, - a5: y.a5 - }; -} - -eq("File \"update_record_test.res\", line 31, characters 5-12", 1, f({ - a0: 0, - a1: 0, - a2: 0, - a3: 0, - a4: 0, - a5: 0 -}).a0); - -let val0 = { - "invalid_js_id'": 3, - x: 2 -}; - -function fff(x) { - return { - "invalid_js_id'": x["invalid_js_id'"] + 2 | 0, - x: x.x - }; -} - -let val1 = fff(val0); - -eq("File \"update_record_test.res\", line 44, characters 5-12", 3, 3); - -eq("File \"update_record_test.res\", line 45, characters 5-12", val1["invalid_js_id'"], 5); - -Mt.from_pair_suites("Update_record_test", suites.contents); - -exports.suites = suites; -exports.test_id = test_id; -exports.eq = eq; -exports.f = f; -exports.val0 = val0; -exports.fff = fff; -exports.val1 = val1; -/* Not a pure module */ diff --git a/tests/tests/src/update_record_test.mjs b/tests/tests/src/update_record_test.mjs new file mode 100644 index 0000000000..c43e09cad7 --- /dev/null +++ b/tests/tests/src/update_record_test.mjs @@ -0,0 +1,82 @@ +// Generated by ReScript, PLEASE EDIT WITH CARE + +import * as Mt from "./mt.mjs"; + +let suites = { + contents: /* [] */0 +}; + +let test_id = { + contents: 0 +}; + +function eq(loc, x, y) { + console.log([ + x, + y + ]); + test_id.contents = test_id.contents + 1 | 0; + suites.contents = { + hd: [ + loc + (" id " + test_id.contents.toString()), + () => ({ + TAG: "Eq", + _0: x, + _1: y + }) + ], + tl: suites.contents + }; +} + +function f(x) { + let y = {...x}; + return { + a0: 1, + a1: y.a1, + a2: y.a2, + a3: y.a3, + a4: y.a4, + a5: y.a5 + }; +} + +eq("File \"update_record_test.res\", line 31, characters 5-12", 1, f({ + a0: 0, + a1: 0, + a2: 0, + a3: 0, + a4: 0, + a5: 0 +}).a0); + +let val0 = { + "invalid_js_id'": 3, + x: 2 +}; + +function fff(x) { + return { + "invalid_js_id'": x["invalid_js_id'"] + 2 | 0, + x: x.x + }; +} + +let val1 = fff(val0); + +eq("File \"update_record_test.res\", line 44, characters 5-12", 3, 3); + +eq("File \"update_record_test.res\", line 45, characters 5-12", val1["invalid_js_id'"], 5); + +Mt.from_pair_suites("Update_record_test", suites.contents); + +export { + suites, + test_id, + eq, + f, + val0, + fff, + val1, +} +/* Not a pure module */ diff --git a/tests/tests/src/variant.js b/tests/tests/src/variant.js deleted file mode 100644 index 938fdb9487..0000000000 --- a/tests/tests/src/variant.js +++ /dev/null @@ -1,175 +0,0 @@ -// Generated by ReScript, PLEASE EDIT WITH CARE -'use strict'; - -let Primitive_object = require("rescript/lib/js/Primitive_object.js"); -let Primitive_exceptions = require("rescript/lib/js/Primitive_exceptions.js"); - -function foo(x) { - if (typeof x !== "object") { - if (x === "A1") { - return 1; - } else { - return 2; - } - } - switch (x.TAG) { - case "B" : - return x._0; - case "C" : - return x._0 + x._1 | 0; - case "D" : - let match = x._0; - return match[0] + match[1] | 0; - } -} - -function fooA1(x) { - if (typeof x !== "object" && x === "A1") { - return 1; - } else { - return 42; - } -} - -function fooC(x) { - if (typeof x !== "object" || x.TAG !== "C") { - return 42; - } else { - return x._0 + x._1 | 0; - } -} - -function switchNum(x) { - switch (x) { - case 0 : - return "0"; - case 1 : - return "1"; - case 2 : - return "2"; - default: - return "_"; - } -} - -let same = Primitive_object.equal; - -let compare = Primitive_object.compare; - -let Path = { - same: same, - compare: compare -}; - -function Make(M) { - let find = x => {}; - return { - find: find - }; -} - -function find(x) { - -} - -let M = { - find: find -}; - -function rollback_path(subst, p) { - try { - return "try"; - } catch (raw_exn) { - let exn = Primitive_exceptions.internalToException(raw_exn); - if (exn.RE_EXN_ID === "Not_found") { - switch (p.TAG) { - case "Pdot" : - return "Pdot"; - case "Pident" : - case "Papply" : - return "Pident | Papply"; - } - } else { - throw exn; - } - } -} - -let EA1 = /* @__PURE__ */Primitive_exceptions.create("Variant.EA1"); - -let EA2 = /* @__PURE__ */Primitive_exceptions.create("Variant.EA2"); - -let EB = /* @__PURE__ */Primitive_exceptions.create("Variant.EB"); - -let EC = /* @__PURE__ */Primitive_exceptions.create("Variant.EC"); - -let ED = /* @__PURE__ */Primitive_exceptions.create("Variant.ED"); - -function fooExn(f) { - try { - return f(); - } catch (raw_n) { - let n = Primitive_exceptions.internalToException(raw_n); - if (n.RE_EXN_ID === EA1) { - return 1; - } - if (n.RE_EXN_ID === EA2) { - return 2; - } - if (n.RE_EXN_ID === EB) { - return n._1; - } - if (n.RE_EXN_ID === EC) { - return n._1 + n._2 | 0; - } - if (n.RE_EXN_ID === ED) { - let match = n._1; - return match[0] + match[1] | 0; - } - throw n; - } -} - -let a1 = "A1"; - -let a2 = "A2"; - -let b = { - TAG: "B", - _0: 34 -}; - -let c = { - TAG: "C", - _0: 4, - _1: 2 -}; - -let d = { - TAG: "D", - _0: [ - 4, - 2 - ] -}; - -exports.a1 = a1; -exports.a2 = a2; -exports.b = b; -exports.c = c; -exports.d = d; -exports.foo = foo; -exports.fooA1 = fooA1; -exports.fooC = fooC; -exports.switchNum = switchNum; -exports.Path = Path; -exports.Make = Make; -exports.M = M; -exports.rollback_path = rollback_path; -exports.EA1 = EA1; -exports.EA2 = EA2; -exports.EB = EB; -exports.EC = EC; -exports.ED = ED; -exports.fooExn = fooExn; -/* No side effect */ diff --git a/tests/tests/src/variant.mjs b/tests/tests/src/variant.mjs new file mode 100644 index 0000000000..4d745530c0 --- /dev/null +++ b/tests/tests/src/variant.mjs @@ -0,0 +1,176 @@ +// Generated by ReScript, PLEASE EDIT WITH CARE + +import * as Primitive_object from "rescript/lib/es6/Primitive_object.js"; +import * as Primitive_exceptions from "rescript/lib/es6/Primitive_exceptions.js"; + +function foo(x) { + if (typeof x !== "object") { + if (x === "A1") { + return 1; + } else { + return 2; + } + } + switch (x.TAG) { + case "B" : + return x._0; + case "C" : + return x._0 + x._1 | 0; + case "D" : + let match = x._0; + return match[0] + match[1] | 0; + } +} + +function fooA1(x) { + if (typeof x !== "object" && x === "A1") { + return 1; + } else { + return 42; + } +} + +function fooC(x) { + if (typeof x !== "object" || x.TAG !== "C") { + return 42; + } else { + return x._0 + x._1 | 0; + } +} + +function switchNum(x) { + switch (x) { + case 0 : + return "0"; + case 1 : + return "1"; + case 2 : + return "2"; + default: + return "_"; + } +} + +let same = Primitive_object.equal; + +let compare = Primitive_object.compare; + +let Path = { + same: same, + compare: compare +}; + +function Make(M) { + let find = x => {}; + return { + find: find + }; +} + +function find(x) { + +} + +let M = { + find: find +}; + +function rollback_path(subst, p) { + try { + return "try"; + } catch (raw_exn) { + let exn = Primitive_exceptions.internalToException(raw_exn); + if (exn.RE_EXN_ID === "Not_found") { + switch (p.TAG) { + case "Pdot" : + return "Pdot"; + case "Pident" : + case "Papply" : + return "Pident | Papply"; + } + } else { + throw exn; + } + } +} + +let EA1 = /* @__PURE__ */Primitive_exceptions.create("Variant.EA1"); + +let EA2 = /* @__PURE__ */Primitive_exceptions.create("Variant.EA2"); + +let EB = /* @__PURE__ */Primitive_exceptions.create("Variant.EB"); + +let EC = /* @__PURE__ */Primitive_exceptions.create("Variant.EC"); + +let ED = /* @__PURE__ */Primitive_exceptions.create("Variant.ED"); + +function fooExn(f) { + try { + return f(); + } catch (raw_n) { + let n = Primitive_exceptions.internalToException(raw_n); + if (n.RE_EXN_ID === EA1) { + return 1; + } + if (n.RE_EXN_ID === EA2) { + return 2; + } + if (n.RE_EXN_ID === EB) { + return n._1; + } + if (n.RE_EXN_ID === EC) { + return n._1 + n._2 | 0; + } + if (n.RE_EXN_ID === ED) { + let match = n._1; + return match[0] + match[1] | 0; + } + throw n; + } +} + +let a1 = "A1"; + +let a2 = "A2"; + +let b = { + TAG: "B", + _0: 34 +}; + +let c = { + TAG: "C", + _0: 4, + _1: 2 +}; + +let d = { + TAG: "D", + _0: [ + 4, + 2 + ] +}; + +export { + a1, + a2, + b, + c, + d, + foo, + fooA1, + fooC, + switchNum, + Path, + Make, + M, + rollback_path, + EA1, + EA2, + EB, + EC, + ED, + fooExn, +} +/* No side effect */ diff --git a/tests/tests/src/variantsMatching.js b/tests/tests/src/variantsMatching.js deleted file mode 100644 index 4ee6946d14..0000000000 --- a/tests/tests/src/variantsMatching.js +++ /dev/null @@ -1,436 +0,0 @@ -// Generated by ReScript, PLEASE EDIT WITH CARE -'use strict'; - - -function toEnum(x) { - switch (x) { - case "thisIsA" : - return 0; - case 42 : - return 1; - case null : - return 2; - case "D" : - return 3; - case 3.14 : - return 5; - } -} - -function toString(x) { - switch (x) { - case "thisIsA" : - return "A"; - case 42 : - return "B"; - case null : - return "C"; - case "D" : - return "D"; - case 3.14 : - return "Pi"; - } -} - -function bar(x) { - switch (x) { - case "thisIsA" : - case 3.14 : - return 10; - default: - return 0; - } -} - -function and_(x, y) { - if (x === "True" && y === "True") { - return "True"; - } else { - return "False"; - } -} - -function id(x) { - if (x === "True") { - return "True"; - } else { - return "False"; - } -} - -function not_(x) { - if (x === "True") { - return "False"; - } else { - return "True"; - } -} - -function st(state) { - if (typeof state !== "object") { - return 0; - } else { - return 23; - } -} - -function showToJs(x) { - if (typeof x !== "object" && x === "No") { - return false; - } else { - return true; - } -} - -function third(l) { - if (!l) { - return false; - } - if (l.hd !== 1) { - return false; - } - let match = l.tl; - if (!match) { - return false; - } - if (match.hd !== 2) { - return false; - } - let match$1 = match.tl; - if (match$1 && !(match$1.hd !== 3 || match$1.tl)) { - return true; - } else { - return false; - } -} - -function third2(l) { - if (typeof l !== "object") { - return false; - } - if (l._0 !== 1) { - return false; - } - let match = l._1; - if (typeof match !== "object") { - return false; - } - if (match._0 !== 2) { - return false; - } - let match$1 = match._1; - if (typeof match$1 !== "object") { - return false; - } - if (match$1._0 !== 3) { - return false; - } - let tmp = match$1._1; - if (typeof tmp !== "object") { - return true; - } else { - return false; - } -} - -function foo(x) { - if (typeof x !== "object") { - switch (x) { - case "dd" : - return 1; - case 12 : - return 2; - case false : - return 3; - } - } else { - switch (x.TAG) { - case "qq" : - return 4; - case 42 : - return 5; - case "F" : - return 6; - } - } -} - -let CustomizeTags_d = { - TAG: "qq", - _0: 42 -}; - -let CustomizeTags_e = { - TAG: 42, - _0: 0 -}; - -let CustomizeTags = { - foo: foo, - a: "dd", - b: 12, - c: false, - d: CustomizeTags_d, - e: CustomizeTags_e -}; - -function isUndefined(x) { - return x === undefined; -} - -function plus(x, y) { - if (x === undefined) { - return y; - } else if (y === undefined) { - return x; - } else { - return x + y | 0; - } -} - -let MyUndefined = { - $$undefined: undefined, - isUndefined: isUndefined, - plus: plus -}; - -function isNull(x) { - return x === null; -} - -function plus$1(x, y) { - if (x === null) { - return y; - } else if (y === null) { - return x; - } else { - return x + y | 0; - } -} - -let MyNull_null = null; - -let MyNull = { - $$null: MyNull_null, - isNull: isNull, - plus: plus$1 -}; - -function isNull$1(x) { - return x === null; -} - -function isUndefined$1(x) { - return x === undefined; -} - -function plus$2(x, y) { - if (x === null || x === undefined) { - return y; - } else if (y === null || y === undefined) { - return x; - } else { - return x + y | 0; - } -} - -function kind(x) { - if (x === null || x === undefined) { - if (x === null) { - return "null"; - } else { - return "undefined"; - } - } else { - return "present"; - } -} - -let expectSeven = plus$2(3, 4); - -console.log("expect 7:", expectSeven); - -let MyNullable_null = null; - -let MyNullable = { - $$null: MyNullable_null, - $$undefined: undefined, - isNull: isNull$1, - isUndefined: isUndefined$1, - plus: plus$2, - kind: kind, - expectSeven: expectSeven -}; - -function isNull$2(x) { - return x === null; -} - -function isUndefined$2(x) { - return x === undefined; -} - -function isWhyNot(x) { - return x === "WhyNotAnotherOne"; -} - -function plus$3(x, y) { - if (x === undefined || x === null || x === "WhyNotAnotherOne") { - switch (x) { - case null : - case undefined : - return y; - case "WhyNotAnotherOne" : - break; - } - } else if (!(y === undefined || y === null || y === "WhyNotAnotherOne")) { - return { - x: x.x + y.x, - y: x.y + y.y - }; - } - if (!(y === undefined || y === null || y === "WhyNotAnotherOne")) { - return "WhyNotAnotherOne"; - } - switch (y) { - case null : - case undefined : - return x; - case "WhyNotAnotherOne" : - return "WhyNotAnotherOne"; - } -} - -function kind$1(x) { - if (!(x === undefined || x === null || x === "WhyNotAnotherOne")) { - return "present"; - } - switch (x) { - case null : - return "null"; - case undefined : - return "undefined"; - case "WhyNotAnotherOne" : - return "whynot"; - } -} - -let expectSeven$1 = plus$3({ - x: 4, - y: 3 -}, { - x: 3, - y: 4 -}); - -console.log("expect {x:7, y:7}:", expectSeven$1); - -let MyNullableExtended_null = null; - -let MyNullableExtended = { - $$null: MyNullableExtended_null, - $$undefined: undefined, - whynot: "WhyNotAnotherOne", - isNull: isNull$2, - isUndefined: isUndefined$2, - isWhyNot: isWhyNot, - plus: plus$3, - kind: kind$1, - expectSeven: expectSeven$1 -}; - -function area(shape) { - switch (shape.kind) { - case 1 : - return Math.PI * Math.pow(shape.radius, 2); - case "square" : - return Math.pow(shape.sideLength, 2); - case "rectangle" : - return shape.width * shape.height; - } -} - -let TaggedUnions_circle = { - kind: 1, - radius: 10 -}; - -let TaggedUnions_square = { - kind: "square", - sideLength: 10 -}; - -let TaggedUnions = { - area: area, - circle: TaggedUnions_circle, - square: TaggedUnions_square -}; - -let CustomTagNotInline_a = { - "custom-tag": "A", - _0: 10 -}; - -let CustomTagNotInline_b = { - "custom-tag": "B", - _0: 20 -}; - -let CustomTagNotInline = { - a: CustomTagNotInline_a, - b: CustomTagNotInline_b -}; - -function classify(x) { - switch (typeof x) { - case "string" : - return "string"; - case "number" : - return "int"; - case "boolean" : - if (x) { - return "true"; - } else { - return "boolean"; - } - case "object" : - return "Object" + x.name; - } -} - -let UntaggedWithBool = { - classify: classify -}; - -function classify$1(x) { - if (typeof x === "string") { - return "string"; - } else { - return "tuple"; - } -} - -let UntaggedWithTuple = { - classify: classify$1 -}; - -exports.toEnum = toEnum; -exports.toString = toString; -exports.bar = bar; -exports.and_ = and_; -exports.id = id; -exports.not_ = not_; -exports.st = st; -exports.showToJs = showToJs; -exports.third = third; -exports.third2 = third2; -exports.CustomizeTags = CustomizeTags; -exports.MyUndefined = MyUndefined; -exports.MyNull = MyNull; -exports.MyNullable = MyNullable; -exports.MyNullableExtended = MyNullableExtended; -exports.TaggedUnions = TaggedUnions; -exports.CustomTagNotInline = CustomTagNotInline; -exports.UntaggedWithBool = UntaggedWithBool; -exports.UntaggedWithTuple = UntaggedWithTuple; -/* expectSeven Not a pure module */ diff --git a/tests/tests/src/variantsMatching.mjs b/tests/tests/src/variantsMatching.mjs new file mode 100644 index 0000000000..0a90661e6a --- /dev/null +++ b/tests/tests/src/variantsMatching.mjs @@ -0,0 +1,437 @@ +// Generated by ReScript, PLEASE EDIT WITH CARE + + +function toEnum(x) { + switch (x) { + case "thisIsA" : + return 0; + case 42 : + return 1; + case null : + return 2; + case "D" : + return 3; + case 3.14 : + return 5; + } +} + +function toString(x) { + switch (x) { + case "thisIsA" : + return "A"; + case 42 : + return "B"; + case null : + return "C"; + case "D" : + return "D"; + case 3.14 : + return "Pi"; + } +} + +function bar(x) { + switch (x) { + case "thisIsA" : + case 3.14 : + return 10; + default: + return 0; + } +} + +function and_(x, y) { + if (x === "True" && y === "True") { + return "True"; + } else { + return "False"; + } +} + +function id(x) { + if (x === "True") { + return "True"; + } else { + return "False"; + } +} + +function not_(x) { + if (x === "True") { + return "False"; + } else { + return "True"; + } +} + +function st(state) { + if (typeof state !== "object") { + return 0; + } else { + return 23; + } +} + +function showToJs(x) { + if (typeof x !== "object" && x === "No") { + return false; + } else { + return true; + } +} + +function third(l) { + if (!l) { + return false; + } + if (l.hd !== 1) { + return false; + } + let match = l.tl; + if (!match) { + return false; + } + if (match.hd !== 2) { + return false; + } + let match$1 = match.tl; + if (match$1 && !(match$1.hd !== 3 || match$1.tl)) { + return true; + } else { + return false; + } +} + +function third2(l) { + if (typeof l !== "object") { + return false; + } + if (l._0 !== 1) { + return false; + } + let match = l._1; + if (typeof match !== "object") { + return false; + } + if (match._0 !== 2) { + return false; + } + let match$1 = match._1; + if (typeof match$1 !== "object") { + return false; + } + if (match$1._0 !== 3) { + return false; + } + let tmp = match$1._1; + if (typeof tmp !== "object") { + return true; + } else { + return false; + } +} + +function foo(x) { + if (typeof x !== "object") { + switch (x) { + case "dd" : + return 1; + case 12 : + return 2; + case false : + return 3; + } + } else { + switch (x.TAG) { + case "qq" : + return 4; + case 42 : + return 5; + case "F" : + return 6; + } + } +} + +let CustomizeTags_d = { + TAG: "qq", + _0: 42 +}; + +let CustomizeTags_e = { + TAG: 42, + _0: 0 +}; + +let CustomizeTags = { + foo: foo, + a: "dd", + b: 12, + c: false, + d: CustomizeTags_d, + e: CustomizeTags_e +}; + +function isUndefined(x) { + return x === undefined; +} + +function plus(x, y) { + if (x === undefined) { + return y; + } else if (y === undefined) { + return x; + } else { + return x + y | 0; + } +} + +let MyUndefined = { + $$undefined: undefined, + isUndefined: isUndefined, + plus: plus +}; + +function isNull(x) { + return x === null; +} + +function plus$1(x, y) { + if (x === null) { + return y; + } else if (y === null) { + return x; + } else { + return x + y | 0; + } +} + +let MyNull_null = null; + +let MyNull = { + $$null: MyNull_null, + isNull: isNull, + plus: plus$1 +}; + +function isNull$1(x) { + return x === null; +} + +function isUndefined$1(x) { + return x === undefined; +} + +function plus$2(x, y) { + if (x === null || x === undefined) { + return y; + } else if (y === null || y === undefined) { + return x; + } else { + return x + y | 0; + } +} + +function kind(x) { + if (x === null || x === undefined) { + if (x === null) { + return "null"; + } else { + return "undefined"; + } + } else { + return "present"; + } +} + +let expectSeven = plus$2(3, 4); + +console.log("expect 7:", expectSeven); + +let MyNullable_null = null; + +let MyNullable = { + $$null: MyNullable_null, + $$undefined: undefined, + isNull: isNull$1, + isUndefined: isUndefined$1, + plus: plus$2, + kind: kind, + expectSeven: expectSeven +}; + +function isNull$2(x) { + return x === null; +} + +function isUndefined$2(x) { + return x === undefined; +} + +function isWhyNot(x) { + return x === "WhyNotAnotherOne"; +} + +function plus$3(x, y) { + if (x === undefined || x === null || x === "WhyNotAnotherOne") { + switch (x) { + case null : + case undefined : + return y; + case "WhyNotAnotherOne" : + break; + } + } else if (!(y === undefined || y === null || y === "WhyNotAnotherOne")) { + return { + x: x.x + y.x, + y: x.y + y.y + }; + } + if (!(y === undefined || y === null || y === "WhyNotAnotherOne")) { + return "WhyNotAnotherOne"; + } + switch (y) { + case null : + case undefined : + return x; + case "WhyNotAnotherOne" : + return "WhyNotAnotherOne"; + } +} + +function kind$1(x) { + if (!(x === undefined || x === null || x === "WhyNotAnotherOne")) { + return "present"; + } + switch (x) { + case null : + return "null"; + case undefined : + return "undefined"; + case "WhyNotAnotherOne" : + return "whynot"; + } +} + +let expectSeven$1 = plus$3({ + x: 4, + y: 3 +}, { + x: 3, + y: 4 +}); + +console.log("expect {x:7, y:7}:", expectSeven$1); + +let MyNullableExtended_null = null; + +let MyNullableExtended = { + $$null: MyNullableExtended_null, + $$undefined: undefined, + whynot: "WhyNotAnotherOne", + isNull: isNull$2, + isUndefined: isUndefined$2, + isWhyNot: isWhyNot, + plus: plus$3, + kind: kind$1, + expectSeven: expectSeven$1 +}; + +function area(shape) { + switch (shape.kind) { + case 1 : + return Math.PI * Math.pow(shape.radius, 2); + case "square" : + return Math.pow(shape.sideLength, 2); + case "rectangle" : + return shape.width * shape.height; + } +} + +let TaggedUnions_circle = { + kind: 1, + radius: 10 +}; + +let TaggedUnions_square = { + kind: "square", + sideLength: 10 +}; + +let TaggedUnions = { + area: area, + circle: TaggedUnions_circle, + square: TaggedUnions_square +}; + +let CustomTagNotInline_a = { + "custom-tag": "A", + _0: 10 +}; + +let CustomTagNotInline_b = { + "custom-tag": "B", + _0: 20 +}; + +let CustomTagNotInline = { + a: CustomTagNotInline_a, + b: CustomTagNotInline_b +}; + +function classify(x) { + switch (typeof x) { + case "string" : + return "string"; + case "number" : + return "int"; + case "boolean" : + if (x) { + return "true"; + } else { + return "boolean"; + } + case "object" : + return "Object" + x.name; + } +} + +let UntaggedWithBool = { + classify: classify +}; + +function classify$1(x) { + if (typeof x === "string") { + return "string"; + } else { + return "tuple"; + } +} + +let UntaggedWithTuple = { + classify: classify$1 +}; + +export { + toEnum, + toString, + bar, + and_, + id, + not_, + st, + showToJs, + third, + third2, + CustomizeTags, + MyUndefined, + MyNull, + MyNullable, + MyNullableExtended, + TaggedUnions, + CustomTagNotInline, + UntaggedWithBool, + UntaggedWithTuple, +} +/* expectSeven Not a pure module */ diff --git a/tests/tests/src/webpack_config.js b/tests/tests/src/webpack_config.js deleted file mode 100644 index 35e8480202..0000000000 --- a/tests/tests/src/webpack_config.js +++ /dev/null @@ -1,81 +0,0 @@ -// Generated by ReScript, PLEASE EDIT WITH CARE -'use strict'; - -let List = require("List"); -let List$1 = require("reactV"); -let List$2 = require("reactX"); -let Local = require("./local"); -let Belt_List = require("rescript/lib/js/Belt_List.js"); -let WebpackConfigJs = require("../../../webpack.config.js"); -let WebpackMiddlewareConfigJs = require("../../../webpack.middleware.config.js"); - -let configx = WebpackConfigJs; - -let WebpackConfig = { - configx: configx -}; - -let configx$1 = WebpackMiddlewareConfigJs; - -let WebpackDevMiddlewareConfig = { - configx: configx$1 -}; - -function configX(prim) { - return WebpackMiddlewareConfigJs.configX(); -} - -function configX$1(prim) { - return WebpackConfigJs.configX(); -} - -let U = { - configX: configX$1 -}; - -let A = {}; - -let B = {}; - -function f() { - return [ - prim => { - List$2.ff(); - }, - prim => { - List$2.ff2(); - }, - prim => { - List$1.ff(); - }, - prim => { - List$1.ff2(); - } - ]; -} - -List.xx(); - -Belt_List.length({ - hd: 1, - tl: { - hd: 2, - tl: /* [] */0 - } -}); - -Belt_List.length(/* [] */0); - -function ff(prim) { - return Local.ff(); -} - -exports.WebpackConfig = WebpackConfig; -exports.WebpackDevMiddlewareConfig = WebpackDevMiddlewareConfig; -exports.configX = configX; -exports.U = U; -exports.A = A; -exports.B = B; -exports.f = f; -exports.ff = ff; -/* configx Not a pure module */ diff --git a/tests/tests/src/webpack_config.mjs b/tests/tests/src/webpack_config.mjs new file mode 100644 index 0000000000..06526bbafc --- /dev/null +++ b/tests/tests/src/webpack_config.mjs @@ -0,0 +1,82 @@ +// Generated by ReScript, PLEASE EDIT WITH CARE + +import * as List from "List"; +import * as List$1 from "reactV"; +import * as List$2 from "reactX"; +import * as Local from "./local"; +import * as Belt_List from "rescript/lib/es6/Belt_List.js"; +import * as WebpackConfigJs from "../../../webpack.config.js"; +import * as WebpackMiddlewareConfigJs from "../../../webpack.middleware.config.js"; + +let configx = WebpackConfigJs; + +let WebpackConfig = { + configx: configx +}; + +let configx$1 = WebpackMiddlewareConfigJs; + +let WebpackDevMiddlewareConfig = { + configx: configx$1 +}; + +function configX(prim) { + return WebpackMiddlewareConfigJs.configX(); +} + +function configX$1(prim) { + return WebpackConfigJs.configX(); +} + +let U = { + configX: configX$1 +}; + +let A = {}; + +let B = {}; + +function f() { + return [ + prim => { + List$2.ff(); + }, + prim => { + List$2.ff2(); + }, + prim => { + List$1.ff(); + }, + prim => { + List$1.ff2(); + } + ]; +} + +List.xx(); + +Belt_List.length({ + hd: 1, + tl: { + hd: 2, + tl: /* [] */0 + } +}); + +Belt_List.length(/* [] */0); + +function ff(prim) { + return Local.ff(); +} + +export { + WebpackConfig, + WebpackDevMiddlewareConfig, + configX, + U, + A, + B, + f, + ff, +} +/* configx Not a pure module */ diff --git a/tests/tests_esmodule/rescript.json b/tests/tests_esmodule/rescript.json deleted file mode 100644 index c7dfdd6f05..0000000000 --- a/tests/tests_esmodule/rescript.json +++ /dev/null @@ -1,18 +0,0 @@ -{ - "name": "rescript-tests", - "sources": [ - { - "dir": "src", - "subdirs": true - } - ], - "package-specs": { - "module": "esmodule", - "in-source": true, - "suffix": ".mjs" - }, - "bsc-flags": [ - "-w -3-6-26-27-29-30-32..40-44-45-52-60-9-106+104", - "-warn-error A" - ] -} \ No newline at end of file