diff --git a/CHANGELOG.md b/CHANGELOG.md index 163f5bed43..97cb781c08 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -50,6 +50,7 @@ - Build tests with bsb and move them out of jscomp. https://github.com/rescript-lang/rescript-compiler/pull/7068 - Run `build_tests` on Windows. https://github.com/rescript-lang/rescript-compiler/pull/7065 - Rename folder "jscomp" to "compiler". https://github.com/rescript-lang/rescript-compiler/pull/7086 +- Disable -bs-cross-module-opt for tests. https://github.com/rescript-lang/rescript-compiler/pull/7071 # 12.0.0-alpha.3 diff --git a/lib/es6/char.js b/lib/es6/char.js index 6686f5d84f..b2a6536046 100644 --- a/lib/es6/char.js +++ b/lib/es6/char.js @@ -1,10 +1,6 @@ -function chr(prim) { - return prim; -} - function escaped(param) { let exit = 0; if (param >= 40) { @@ -83,7 +79,6 @@ function equal(c1, c2) { } export { - chr, escaped, lowercase_ascii, uppercase_ascii, diff --git a/lib/js/char.js b/lib/js/char.js index ae5ee0dba6..e854a99cd0 100644 --- a/lib/js/char.js +++ b/lib/js/char.js @@ -1,10 +1,6 @@ 'use strict'; -function chr(prim) { - return prim; -} - function escaped(param) { let exit = 0; if (param >= 40) { @@ -82,7 +78,6 @@ function equal(c1, c2) { return (c1 - c2 | 0) === 0; } -exports.chr = chr; exports.escaped = escaped; exports.lowercase_ascii = lowercase_ascii; exports.uppercase_ascii = uppercase_ascii; diff --git a/runtime/char.res b/runtime/char.res index a3f1b05ecc..133e63b873 100644 --- a/runtime/char.res +++ b/runtime/char.res @@ -10,7 +10,7 @@ external code: t => int = "%identity" external unsafe_chr: int => t = "%identity" -let chr = unsafe_chr +external chr: int => t = "%identity" external bytes_create: int => array = "Array" diff --git a/runtime/char.resi b/runtime/char.resi index 97320d7118..3ee638c888 100644 --- a/runtime/char.resi +++ b/runtime/char.resi @@ -10,7 +10,7 @@ external code: char => int = "%identity" Raise [Invalid_argument "Char.chr"] if the argument is outside the range 0--255. */ @deprecated("Use Core instead. This will be removed in v13") -let chr: int => char +external chr: int => char = "%identity" /** Return a string representing the given character, with special characters escaped following the lexical conventions diff --git a/tests/tests/rescript.json b/tests/tests/rescript.json index 71a10aaea0..69ceca9c90 100644 --- a/tests/tests/rescript.json +++ b/tests/tests/rescript.json @@ -11,7 +11,6 @@ "in-source": true }, "bsc-flags": [ - "-bs-cross-module-opt", "-w -3-6-26-27-29-30-32..40-44-45-52-60-9-106+104", "-warn-error A" ] diff --git a/tests/tests/src/Import.js b/tests/tests/src/Import.js index 5885147fd7..0831e85187 100644 --- a/tests/tests/src/Import.js +++ b/tests/tests/src/Import.js @@ -1,13 +1,14 @@ // 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 import("rescript/lib/js/belt_List.js").then(m => m.forEach).then(each => Promise.resolve(each(list, f))); + return Js_promise.then_(each => Promise.resolve(each(list, f)), import("rescript/lib/js/belt_List.js").then(m => m.forEach)); } eachIntLazy({ diff --git a/tests/tests/src/SafePromises.js b/tests/tests/src/SafePromises.js index 3dd5d546de..05a637b8a0 100644 --- a/tests/tests/src/SafePromises.js +++ b/tests/tests/src/SafePromises.js @@ -1,6 +1,7 @@ // 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) { @@ -10,7 +11,7 @@ async function nestedPromise(xxx) { console.log("Promise2.catch_", x); return Promise.resolve(0); }); - xx.then(x => Promise.resolve((console.log("Promise.then_", x), undefined))); + Js_promise.then_(x => Promise.resolve((console.log("Promise.then_", x), undefined)), xx); } async function create(x) { diff --git a/tests/tests/src/belt_hashmap_test.js b/tests/tests/src/belt_hashmap_test.js index b3ff0630a1..9500a537f2 100644 --- a/tests/tests/src/belt_hashmap_test.js +++ b/tests/tests/src/belt_hashmap_test.js @@ -2,6 +2,7 @@ 'use strict'; let Mocha = require("mocha"); +let Belt_Id = require("rescript/lib/js/belt_Id.js"); let Hashtbl = require("rescript/lib/js/hashtbl.js"); let Belt_Array = require("rescript/lib/js/belt_Array.js"); let Test_utils = require("./test_utils.js"); @@ -9,7 +10,6 @@ let Belt_HashMap = require("rescript/lib/js/belt_HashMap.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 Belt_internalBucketsType = require("rescript/lib/js/belt_internalBucketsType.js"); function intEq(x, y) { return x === y; @@ -19,19 +19,16 @@ let intHash = Hashtbl.hash; let cmp = Primitive_int.compare; -let Y = { - hash: intHash, - eq: intEq -}; +let Y = Belt_Id.hashable(intHash, intEq); -let empty = Belt_internalBucketsType.make(intHash, intEq, 30); +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 21, characters 7-14", xx.size, 91); + Test_utils.eq("File \"belt_hashmap_test.res\", line 21, characters 7-14", Belt_HashMap.size(xx), 91); Test_utils.eq("File \"belt_hashmap_test.res\", line 22, characters 7-14", Belt_SortArray.stableSortBy(Belt_HashMap.keysToArray(xx), cmp), Array_data_util.range(30, 120)); }); Mocha.test("mergeMany", () => { @@ -54,21 +51,21 @@ Mocha.describe("Belt_hashmap_test", () => { ] ]); Test_utils.eq("File \"belt_hashmap_test.res\", line 27, characters 7-14", Belt_HashMap.get(empty, 2), 2); - Test_utils.eq("File \"belt_hashmap_test.res\", line 28, characters 7-14", empty.size, 3); + Test_utils.eq("File \"belt_hashmap_test.res\", line 28, 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_internalBucketsType.make(intHash, intEq, 40); + 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 35, characters 7-14", v.size, 100001); + Test_utils.eq("File \"belt_hashmap_test.res\", line 35, 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 39, characters 7-14", v.size, 99000); + Test_utils.eq("File \"belt_hashmap_test.res\", line 39, 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 43, characters 7-14", v.size, 98000); + Test_utils.eq("File \"belt_hashmap_test.res\", line 43, characters 7-14", Belt_HashMap.size(v), 98000); Test_utils.ok("File \"belt_hashmap_test.res\", line 44, characters 7-14", Belt_Array.every(Array_data_util.range(2001, 100000), x => Belt_HashMap.has(v, x))); }); }); @@ -93,4 +90,4 @@ exports.intHash = intHash; exports.cmp = cmp; exports.Y = Y; exports.empty = empty; -/* empty Not a pure module */ +/* 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 index 4cce65ce9f..ae2f9df81d 100644 --- a/tests/tests/src/belt_hashset_int_test.js +++ b/tests/tests/src/belt_hashset_int_test.js @@ -8,7 +8,6 @@ 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"); -let Belt_internalBucketsType = require("rescript/lib/js/belt_internalBucketsType.js"); function add(x, y) { return x + y | 0; @@ -28,7 +27,7 @@ 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", v.size, 91); + 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); @@ -36,17 +35,17 @@ Mocha.describe("Belt_hashset_int_test", () => { }); Mocha.test("mergeMany", () => { let u = Belt_Array.concat(Array_data_util.randomRange(0, 100000), Array_data_util.randomRange(0, 100)); - let v = Belt_internalBucketsType.make(undefined, undefined, 40); + 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", v.size, 100001); + 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", v.size, 99000); + 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", v.size, 98000); + 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)); diff --git a/tests/tests/src/belt_list_test.js b/tests/tests/src/belt_list_test.js index 9fcd7ddb76..bfa1e498b1 100644 --- a/tests/tests/src/belt_list_test.js +++ b/tests/tests/src/belt_list_test.js @@ -1791,13 +1791,7 @@ Mocha.describe("Belt_list_test", () => { } }, (x, y) => x === y), false); }); - Mocha.test("add", () => Test_utils.eq("File \"belt_list_test.res\", line 307, characters 7-14", { - hd: 2, - tl: { - hd: 3, - tl: /* [] */0 - } - }, { + 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, diff --git a/tests/tests/src/belt_sortarray_test.js b/tests/tests/src/belt_sortarray_test.js index f3e6b0a8b6..67730112d2 100644 --- a/tests/tests/src/belt_sortarray_test.js +++ b/tests/tests/src/belt_sortarray_test.js @@ -4,6 +4,7 @@ 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"); @@ -215,12 +216,12 @@ Mocha.describe("Belt_sortarray_test", () => { ]); }); Mocha.test("binarySearchBy", () => { - Test_utils.eq("File \"belt_sortarray_test.res\", line 108, characters 7-14", Belt_SortArray.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) ^ -1, 2); + ], 4, cmp)), 2); Test_utils.eq("File \"belt_sortarray_test.res\", line 109, characters 7-14", Belt_SortArray.binarySearchBy([ 1, 2, @@ -269,11 +270,11 @@ Mocha.describe("Belt_sortarray_test", () => { 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", Belt_SortArray.binarySearchBy(cc, 5000, cmp) ^ -1, 2001); - Test_utils.eq("File \"belt_sortarray_test.res\", line 119, characters 7-14", Belt_SortArray.binarySearchBy(cc, -1, cmp) ^ -1, 0); + 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", Belt_SortArray.binarySearchBy(cc, 1, cmp) ^ -1, 1); - Test_utils.ok("File \"belt_sortarray_test.res\", line 124, characters 6-13", Belt_Range.every(0, 1999, i => (Belt_SortArray.binarySearchBy(cc, (i << 1) + 1 | 0, cmp) ^ -1) === (i + 1 | 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; diff --git a/tests/tests/src/bench.js b/tests/tests/src/bench.js index 90120890bf..1349784df0 100644 --- a/tests/tests/src/bench.js +++ b/tests/tests/src/bench.js @@ -2,6 +2,7 @@ '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); @@ -22,11 +23,7 @@ function init(l, f) { return []; } if (l < 0) { - throw { - RE_EXN_ID: "Invalid_argument", - _1: "Array.init", - Error: new Error() - }; + return Pervasives.invalid_arg("Array.init"); } let res = Belt_Array.make(l, f$1(0)); for (let i = 1; i < l; ++i) { diff --git a/tests/tests/src/bs_map_set_dict_test.js b/tests/tests/src/bs_map_set_dict_test.js index 1fc35b08e0..4314bf8138 100644 --- a/tests/tests/src/bs_map_set_dict_test.js +++ b/tests/tests/src/bs_map_set_dict_test.js @@ -2,7 +2,9 @@ '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"); @@ -26,51 +28,23 @@ function b(loc, v) { Mt.bool_suites(test_id, suites, loc, v); } -let Icmp = { - cmp: Primitive_int.compare -}; +let Icmp = Belt_Id.comparable(Primitive_int.compare); -let Icmp2 = { - cmp: Primitive_int.compare -}; +let Icmp2 = Belt_Id.comparable(Primitive_int.compare); -let Ic3 = { - cmp: Primitive_int.compare -}; +let Ic3 = Belt_Id.comparable(Primitive_int.compare); -let m0_cmp = Icmp.cmp; +let m0 = Belt_Map.make(Icmp); -let m0 = { - cmp: m0_cmp, - data: undefined -}; +let m00 = Belt_Set.make(Ic3); -let m00_cmp = Ic3.cmp; +let I2 = Belt_Id.comparable((x, y) => Primitive_int.compare(y, x)); -let m00 = { - cmp: m00_cmp, - data: undefined -}; +let m = Belt_Map.make(Icmp2); -let I2 = { - cmp: (x, y) => Primitive_int.compare(y, x) -}; - -let m_cmp = Icmp2.cmp; - -let m = { - cmp: m_cmp, - data: undefined -}; +let m2 = Belt_Map.make(I2); -let m2_cmp = I2.cmp; - -let m2 = { - cmp: m2_cmp, - data: undefined -}; - -let data; +let data = Belt_Map.getData(m); Belt_Map.getId(m2); @@ -80,32 +54,29 @@ for (let i = 0; i <= 100000; ++i) { data = Belt_MapDict.set(data, i, i, m_dict.cmp); } -let data$1 = data; - -let newm_cmp = m_dict.cmp; - -let newm = { - cmp: newm_cmp, - data: data$1 -}; +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$2; +let data$1 = Belt_Set.getData(v); for (let i$1 = 0; i$1 <= 100000; ++i$1) { - data$2 = Belt_SetDict.add(data$2, i$1, cmp); + data$1 = Belt_SetDict.add(data$1, i$1, cmp); } -console.log(data$2); +console.log(data$1); function f(none) { return Belt_Map.fromArray(none, Icmp); @@ -122,7 +93,7 @@ let u0 = Belt_Map.fromArray(Belt_Array.map(Array_data_util.randomRange(0, 39), x 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_MapDict.toArray(u0.data), Belt_Array.map(Array_data_util.range(0, 39), x => [ +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) => { @@ -133,7 +104,7 @@ b("File \"bs_map_set_dict_test.res\", line 72, characters 4-11", Belt_Array.ever } })); -b("File \"bs_map_set_dict_test.res\", line 79, characters 4-11", Belt_List.every2(Belt_MapDict.toList(u0.data), Belt_List.fromArray(Belt_Array.map(Array_data_util.range(0, 39), x => [ +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) => { @@ -156,7 +127,7 @@ let u = Belt_Map.fromArray(Belt_Array.makeByAndShuffle(10000, x => [ eq("File \"bs_map_set_dict_test.res\", line 90, characters 5-12", Belt_Array.makeBy(10000, x => [ x, x -]), Belt_MapDict.toArray(u.data)); +]), Belt_Map.toArray(u)); Mt.from_pair_suites("Bs_map_set_dict_test", suites.contents); @@ -204,4 +175,4 @@ exports.ISet = ISet; exports.S0 = S0; exports.f = f; exports.$eq$tilde = $eq$tilde; -/* Not a pure module */ +/* Icmp Not a pure module */ diff --git a/tests/tests/src/bs_mutable_set_test.js b/tests/tests/src/bs_mutable_set_test.js index 6ce4a559aa..7d51cde696 100644 --- a/tests/tests/src/bs_mutable_set_test.js +++ b/tests/tests/src/bs_mutable_set_test.js @@ -8,8 +8,6 @@ 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 Belt_internalAVLset = require("rescript/lib/js/belt_internalAVLset.js"); -let Belt_internalSetInt = require("rescript/lib/js/belt_internalSetInt.js"); let suites = { contents: /* [] */0 @@ -27,11 +25,7 @@ function b(loc, x) { Mt.bool_suites(test_id, suites, loc, x); } -let xs = Array_data_util.range(0, 30); - -let u = { - data: Belt_internalSetInt.fromArray(xs) -}; +let u = Belt_MutableSetInt.fromArray(Array_data_util.range(0, 30)); b("File \"bs_mutable_set_test.res\", line 21, characters 8-15", Belt_MutableSetInt.removeCheck(u, 0)); @@ -41,13 +35,13 @@ b("File \"bs_mutable_set_test.res\", line 23, characters 8-15", Belt_MutableSetI b("File \"bs_mutable_set_test.res\", line 24, characters 8-15", Belt_MutableSetInt.removeCheck(u, 20)); -eq("File \"bs_mutable_set_test.res\", line 25, characters 9-16", Belt_internalAVLset.size(u.data), 28); +eq("File \"bs_mutable_set_test.res\", line 25, characters 9-16", Belt_MutableSetInt.size(u), 28); let r = Array_data_util.randomRange(0, 30); -b("File \"bs_mutable_set_test.res\", line 27, characters 8-15", 29 === Belt_internalAVLset.maxUndefined(u.data)); +b("File \"bs_mutable_set_test.res\", line 27, characters 8-15", 29 === Belt_MutableSetInt.maxUndefined(u)); -b("File \"bs_mutable_set_test.res\", line 28, characters 8-15", 1 === Belt_internalAVLset.minUndefined(u.data)); +b("File \"bs_mutable_set_test.res\", line 28, characters 8-15", 1 === Belt_MutableSetInt.minUndefined(u)); Belt_MutableSetInt.add(u, 3); @@ -65,7 +59,7 @@ Belt_MutableSetInt.add(u, 2); Belt_MutableSetInt.add(u, 0); -eq("File \"bs_mutable_set_test.res\", line 38, characters 9-16", Belt_internalAVLset.size(u.data), 3); +eq("File \"bs_mutable_set_test.res\", line 38, characters 9-16", Belt_MutableSetInt.size(u), 3); b("File \"bs_mutable_set_test.res\", line 39, characters 8-15", !Belt_MutableSetInt.isEmpty(u)); @@ -79,39 +73,35 @@ 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 46, characters 9-16", Belt_internalAVLset.size(u.data), 20001); +eq("File \"bs_mutable_set_test.res\", line 46, 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 48, characters 9-16", Belt_internalAVLset.size(u.data), 19800); +eq("File \"bs_mutable_set_test.res\", line 48, 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 50, characters 9-16", Belt_internalAVLset.size(u.data), 19000); +eq("File \"bs_mutable_set_test.res\", line 50, 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 52, characters 9-16", Belt_internalAVLset.size(u.data), 19000); +eq("File \"bs_mutable_set_test.res\", line 52, 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 54, characters 9-16", Belt_internalAVLset.size(u.data), 10000); +eq("File \"bs_mutable_set_test.res\", line 54, 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 56, characters 9-16", Belt_internalAVLset.size(u.data), 1); +eq("File \"bs_mutable_set_test.res\", line 56, characters 9-16", Belt_MutableSetInt.size(u), 1); -b("File \"bs_mutable_set_test.res\", line 57, characters 8-15", Belt_internalSetInt.has(u.data, 20000)); +b("File \"bs_mutable_set_test.res\", line 57, 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 59, characters 8-15", Belt_MutableSetInt.isEmpty(u)); -let xs$1 = Array_data_util.randomRange(1000, 2000); - -let v = { - data: Belt_internalSetInt.fromArray(xs$1) -}; +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)); @@ -125,7 +115,7 @@ let indeedRemoved = Belt_Array.reduce(bs, 0, (acc, x) => { eq("File \"bs_mutable_set_test.res\", line 72, characters 9-16", indeedRemoved, 500); -eq("File \"bs_mutable_set_test.res\", line 73, characters 9-16", Belt_internalAVLset.size(v.data), 501); +eq("File \"bs_mutable_set_test.res\", line 73, 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)); @@ -139,31 +129,29 @@ let indeedAded = Belt_Array.reduce(cs, 0, (acc, x) => { eq("File \"bs_mutable_set_test.res\", line 82, characters 9-16", indeedAded, 1000); -eq("File \"bs_mutable_set_test.res\", line 83, characters 9-16", Belt_internalAVLset.size(v.data), 1501); +eq("File \"bs_mutable_set_test.res\", line 83, characters 9-16", Belt_MutableSetInt.size(v), 1501); -b("File \"bs_mutable_set_test.res\", line 84, characters 8-15", Belt_MutableSetInt.isEmpty({ - data: undefined -})); +b("File \"bs_mutable_set_test.res\", line 84, characters 8-15", Belt_MutableSetInt.isEmpty(Belt_MutableSetInt.make())); -eq("File \"bs_mutable_set_test.res\", line 85, characters 9-16", Belt_internalAVLset.minimum(v.data), 500); +eq("File \"bs_mutable_set_test.res\", line 85, characters 9-16", Belt_MutableSetInt.minimum(v), 500); -eq("File \"bs_mutable_set_test.res\", line 86, characters 9-16", Belt_internalAVLset.maximum(v.data), 2000); +eq("File \"bs_mutable_set_test.res\", line 86, characters 9-16", Belt_MutableSetInt.maximum(v), 2000); -eq("File \"bs_mutable_set_test.res\", line 87, characters 9-16", Belt_internalAVLset.minUndefined(v.data), 500); +eq("File \"bs_mutable_set_test.res\", line 87, characters 9-16", Belt_MutableSetInt.minUndefined(v), 500); -eq("File \"bs_mutable_set_test.res\", line 88, characters 9-16", Belt_internalAVLset.maxUndefined(v.data), 2000); +eq("File \"bs_mutable_set_test.res\", line 88, characters 9-16", Belt_MutableSetInt.maxUndefined(v), 2000); eq("File \"bs_mutable_set_test.res\", line 89, characters 9-16", Belt_MutableSetInt.reduce(v, 0, (x, y) => x + y | 0), 1876250); -b("File \"bs_mutable_set_test.res\", line 90, characters 8-15", Belt_List.eq(Belt_internalAVLset.toList(v.data), Belt_List.makeBy(1501, i => i + 500 | 0), (x, y) => x === y)); +b("File \"bs_mutable_set_test.res\", line 90, 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 91, characters 9-16", Belt_internalAVLset.toArray(v.data), Array_data_util.range(500, 2000)); +eq("File \"bs_mutable_set_test.res\", line 91, characters 9-16", Belt_MutableSetInt.toArray(v), Array_data_util.range(500, 2000)); -Belt_internalAVLset.checkInvariantInternal(v.data); +Belt_MutableSetInt.checkInvariantInternal(v); -eq("File \"bs_mutable_set_test.res\", line 93, characters 9-16", Belt_internalSetInt.get(v.data, 3), undefined); +eq("File \"bs_mutable_set_test.res\", line 93, characters 9-16", Belt_MutableSetInt.get(v, 3), undefined); -eq("File \"bs_mutable_set_test.res\", line 94, characters 9-16", Belt_internalSetInt.get(v.data, 1200), 1200); +eq("File \"bs_mutable_set_test.res\", line 94, characters 9-16", Belt_MutableSetInt.get(v, 1200), 1200); let match = Belt_MutableSetInt.split(v, 1000); @@ -175,9 +163,9 @@ let aa = match$1[0]; b("File \"bs_mutable_set_test.res\", line 96, characters 8-15", match[1]); -b("File \"bs_mutable_set_test.res\", line 97, characters 8-15", Belt_Array.eq(Belt_internalAVLset.toArray(aa.data), Array_data_util.range(500, 999), (x, y) => x === y)); +b("File \"bs_mutable_set_test.res\", line 97, 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 98, characters 8-15", Belt_Array.eq(Belt_internalAVLset.toArray(bb.data), Array_data_util.range(1001, 2000), (prim0, prim1) => prim0 === prim1)); +b("File \"bs_mutable_set_test.res\", line 98, 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 99, characters 8-15", Belt_MutableSetInt.subset(aa, v)); @@ -199,9 +187,9 @@ let aa$1 = match$3[0]; b("File \"bs_mutable_set_test.res\", line 105, characters 8-15", !match$2[1]); -b("File \"bs_mutable_set_test.res\", line 106, characters 8-15", Belt_Array.eq(Belt_internalAVLset.toArray(aa$1.data), Array_data_util.range(500, 999), (prim0, prim1) => prim0 === prim1)); +b("File \"bs_mutable_set_test.res\", line 106, 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 107, characters 8-15", Belt_Array.eq(Belt_internalAVLset.toArray(bb$1.data), Array_data_util.range(1001, 2000), (prim0, prim1) => prim0 === prim1)); +b("File \"bs_mutable_set_test.res\", line 107, 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 108, characters 8-15", Belt_MutableSetInt.subset(aa$1, v)); @@ -209,156 +197,54 @@ b("File \"bs_mutable_set_test.res\", line 109, characters 8-15", Belt_MutableSet b("File \"bs_mutable_set_test.res\", line 110, characters 8-15", Belt_MutableSetInt.isEmpty(Belt_MutableSetInt.intersect(aa$1, bb$1))); -let xs$2 = Array_data_util.randomRange(0, 100); +let aa$2 = Belt_MutableSetInt.fromArray(Array_data_util.randomRange(0, 100)); -let aa$2 = { - data: Belt_internalSetInt.fromArray(xs$2) -}; +let bb$2 = Belt_MutableSetInt.fromArray(Array_data_util.randomRange(40, 120)); -let xs$3 = Array_data_util.randomRange(40, 120); +let cc = Belt_MutableSetInt.union(aa$2, bb$2); -let bb$2 = { - data: Belt_internalSetInt.fromArray(xs$3) -}; +b("File \"bs_mutable_set_test.res\", line 120, characters 8-15", Belt_MutableSetInt.eq(cc, Belt_MutableSetInt.fromArray(Array_data_util.randomRange(0, 120)))); -let cc = Belt_MutableSetInt.union(aa$2, bb$2); +b("File \"bs_mutable_set_test.res\", line 123, 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 127, characters 8-15", Belt_MutableSetInt.eq(dd, Belt_MutableSetInt.fromArray(Array_data_util.randomRange(40, 100)))); -let xs$4 = Array_data_util.randomRange(0, 120); +b("File \"bs_mutable_set_test.res\", line 129, 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 120, characters 8-15", Belt_MutableSetInt.eq(cc, { - data: Belt_internalSetInt.fromArray(xs$4) -})); +b("File \"bs_mutable_set_test.res\", line 136, 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())); -let xs$5 = Array_data_util.randomRange(0, 20); +b("File \"bs_mutable_set_test.res\", line 142, 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 +]))); -let xs$6 = Array_data_util.randomRange(21, 40); +b("File \"bs_mutable_set_test.res\", line 143, characters 8-15", Belt_MutableSetInt.eq(Belt_MutableSetInt.diff(aa$2, bb$2), Belt_MutableSetInt.fromArray(Array_data_util.randomRange(0, 39)))); -let xs$7 = Array_data_util.randomRange(0, 40); +b("File \"bs_mutable_set_test.res\", line 144, 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 123, characters 8-15", Belt_MutableSetInt.eq(Belt_MutableSetInt.union({ - data: Belt_internalSetInt.fromArray(xs$5) -}, { - data: Belt_internalSetInt.fromArray(xs$6) -}), { - data: Belt_internalSetInt.fromArray(xs$7) -})); +b("File \"bs_mutable_set_test.res\", line 146, 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)))); -let dd = Belt_MutableSetInt.intersect(aa$2, bb$2); +b("File \"bs_mutable_set_test.res\", line 153, 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)))); -let xs$8 = Array_data_util.randomRange(40, 100); +b("File \"bs_mutable_set_test.res\", line 161, 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)))); -b("File \"bs_mutable_set_test.res\", line 127, characters 8-15", Belt_MutableSetInt.eq(dd, { - data: Belt_internalSetInt.fromArray(xs$8) -})); - -let xs$9 = Array_data_util.randomRange(0, 20); - -let xs$10 = Array_data_util.randomRange(21, 40); - -b("File \"bs_mutable_set_test.res\", line 129, characters 8-15", Belt_MutableSetInt.eq(Belt_MutableSetInt.intersect({ - data: Belt_internalSetInt.fromArray(xs$9) -}, { - data: Belt_internalSetInt.fromArray(xs$10) -}), { - data: undefined -})); - -let xs$11 = Array_data_util.randomRange(21, 40); - -let xs$12 = Array_data_util.randomRange(0, 20); - -b("File \"bs_mutable_set_test.res\", line 136, characters 8-15", Belt_MutableSetInt.eq(Belt_MutableSetInt.intersect({ - data: Belt_internalSetInt.fromArray(xs$11) -}, { - data: Belt_internalSetInt.fromArray(xs$12) -}), { - data: undefined -})); - -b("File \"bs_mutable_set_test.res\", line 142, characters 8-15", Belt_MutableSetInt.eq(Belt_MutableSetInt.intersect({ - data: Belt_internalSetInt.fromArray([ - 1, - 3, - 4, - 5, - 7, - 9 - ]) -}, { - data: Belt_internalSetInt.fromArray([ - 2, - 4, - 5, - 6, - 8, - 10 - ]) -}), { - data: Belt_internalSetInt.fromArray([ - 4, - 5 - ]) -})); - -let xs$13 = Array_data_util.randomRange(0, 39); - -b("File \"bs_mutable_set_test.res\", line 143, characters 8-15", Belt_MutableSetInt.eq(Belt_MutableSetInt.diff(aa$2, bb$2), { - data: Belt_internalSetInt.fromArray(xs$13) -})); - -let xs$14 = Array_data_util.randomRange(101, 120); - -b("File \"bs_mutable_set_test.res\", line 144, characters 8-15", Belt_MutableSetInt.eq(Belt_MutableSetInt.diff(bb$2, aa$2), { - data: Belt_internalSetInt.fromArray(xs$14) -})); - -let xs$15 = Array_data_util.randomRange(21, 40); - -let xs$16 = Array_data_util.randomRange(0, 20); - -let xs$17 = Array_data_util.randomRange(21, 40); - -b("File \"bs_mutable_set_test.res\", line 146, characters 8-15", Belt_MutableSetInt.eq(Belt_MutableSetInt.diff({ - data: Belt_internalSetInt.fromArray(xs$15) -}, { - data: Belt_internalSetInt.fromArray(xs$16) -}), { - data: Belt_internalSetInt.fromArray(xs$17) -})); - -let xs$18 = Array_data_util.randomRange(0, 20); - -let xs$19 = Array_data_util.randomRange(21, 40); - -let xs$20 = Array_data_util.randomRange(0, 20); - -b("File \"bs_mutable_set_test.res\", line 153, characters 8-15", Belt_MutableSetInt.eq(Belt_MutableSetInt.diff({ - data: Belt_internalSetInt.fromArray(xs$18) -}, { - data: Belt_internalSetInt.fromArray(xs$19) -}), { - data: Belt_internalSetInt.fromArray(xs$20) -})); - -let xs$21 = Array_data_util.randomRange(0, 20); - -let xs$22 = Array_data_util.randomRange(0, 40); - -let xs$23 = Array_data_util.randomRange(0, -1); - -b("File \"bs_mutable_set_test.res\", line 161, characters 8-15", Belt_MutableSetInt.eq(Belt_MutableSetInt.diff({ - data: Belt_internalSetInt.fromArray(xs$21) -}, { - data: Belt_internalSetInt.fromArray(xs$22) -}), { - data: Belt_internalSetInt.fromArray(xs$23) -})); - -let xs$24 = Array_data_util.randomRange(0, 1000); - -let a0 = { - data: Belt_internalSetInt.fromArray(xs$24) -}; +let a0 = Belt_MutableSetInt.fromArray(Array_data_util.randomRange(0, 1000)); let a1 = Belt_MutableSetInt.keep(a0, x => x % 2 === 0); @@ -389,41 +275,35 @@ Belt_List.forEach({ } } } -}, x => Belt_internalAVLset.checkInvariantInternal(x.data)); +}, Belt_MutableSetInt.checkInvariantInternal); -let v$1 = { - data: undefined -}; +let v$1 = Belt_MutableSetInt.make(); for (let i$2 = 0; i$2 <= 100000; ++i$2) { Belt_MutableSetInt.add(v$1, i$2); } -Belt_internalAVLset.checkInvariantInternal(v$1.data); +Belt_MutableSetInt.checkInvariantInternal(v$1); -b("File \"bs_mutable_set_test.res\", line 188, characters 10-17", Belt_Range.every(0, 100000, i => Belt_internalSetInt.has(v$1.data, i))); +b("File \"bs_mutable_set_test.res\", line 188, characters 10-17", Belt_Range.every(0, 100000, i => Belt_MutableSetInt.has(v$1, i))); -eq("File \"bs_mutable_set_test.res\", line 189, characters 5-12", Belt_internalAVLset.size(v$1.data), 100001); +eq("File \"bs_mutable_set_test.res\", line 189, 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 = { - data: undefined -}; +let v$2 = Belt_MutableSetInt.make(); Belt_MutableSetInt.mergeMany(v$2, u$1); -eq("File \"bs_mutable_set_test.res\", line 196, characters 5-12", Belt_internalAVLset.size(v$2.data), 91); +eq("File \"bs_mutable_set_test.res\", line 196, characters 5-12", Belt_MutableSetInt.size(v$2), 91); -eq("File \"bs_mutable_set_test.res\", line 197, characters 5-12", Belt_internalAVLset.toArray(v$2.data), Array_data_util.range(30, 120)); +eq("File \"bs_mutable_set_test.res\", line 197, 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 = { - data: Belt_internalSetInt.fromArray(u$2) -}; +let v$3 = Belt_MutableSetInt.fromArray(u$2); -eq("File \"bs_mutable_set_test.res\", line 203, characters 5-12", Belt_internalAVLset.size(v$3.data), 100001); +eq("File \"bs_mutable_set_test.res\", line 203, characters 5-12", Belt_MutableSetInt.size(v$3), 100001); let u$3 = Array_data_util.randomRange(50000, 80000); @@ -431,7 +311,7 @@ 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 210, characters 5-12", Belt_internalAVLset.size(v$3.data), 70000); +eq("File \"bs_mutable_set_test.res\", line 210, characters 5-12", Belt_MutableSetInt.size(v$3), 70000); let vv = Array_data_util.randomRange(0, 100000); @@ -439,27 +319,23 @@ 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 216, characters 5-12", Belt_internalAVLset.size(v$3.data), 0); +eq("File \"bs_mutable_set_test.res\", line 216, characters 5-12", Belt_MutableSetInt.size(v$3), 0); b("File \"bs_mutable_set_test.res\", line 217, characters 4-11", Belt_MutableSetInt.isEmpty(v$3)); -let xs$25 = Belt_Array.makeBy(30, i => i); - -let v$4 = { - data: Belt_internalSetInt.fromArray(xs$25) -}; +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 224, characters 4-11", 28 === Belt_internalAVLset.maxUndefined(v$4.data)); +b("File \"bs_mutable_set_test.res\", line 224, characters 4-11", 28 === Belt_MutableSetInt.maxUndefined(v$4)); Belt_MutableSetInt.remove(v$4, 0); -b("File \"bs_mutable_set_test.res\", line 226, characters 4-11", 1 === Belt_internalAVLset.minUndefined(v$4.data)); +b("File \"bs_mutable_set_test.res\", line 226, characters 4-11", 1 === Belt_MutableSetInt.minUndefined(v$4)); -eq("File \"bs_mutable_set_test.res\", line 227, characters 5-12", Belt_internalAVLset.size(v$4.data), 28); +eq("File \"bs_mutable_set_test.res\", line 227, characters 5-12", Belt_MutableSetInt.size(v$4), 28); let vv$1 = Array_data_util.randomRange(1, 28); @@ -467,14 +343,12 @@ 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 232, characters 5-12", Belt_internalAVLset.size(v$4.data), 0); +eq("File \"bs_mutable_set_test.res\", line 232, characters 5-12", Belt_MutableSetInt.size(v$4), 0); function id(loc, x) { - let u = { - data: Belt_internalAVLset.fromSortedArrayUnsafe(x) - }; - Belt_internalAVLset.checkInvariantInternal(u.data); - b(loc, Belt_Array.every2(Belt_internalAVLset.toArray(u.data), x, (prim0, prim1) => prim0 === prim1)); + 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 242, characters 5-12", []); @@ -560,11 +434,7 @@ id("File \"bs_mutable_set_test.res\", line 252, characters 5-12", [ id("File \"bs_mutable_set_test.res\", line 253, characters 5-12", Array_data_util.range(0, 1000)); -let xs$26 = Array_data_util.randomRange(0, 1000); - -let v$5 = { - data: Belt_internalSetInt.fromArray(xs$26) -}; +let v$5 = Belt_MutableSetInt.fromArray(Array_data_util.randomRange(0, 1000)); let copyV = Belt_MutableSetInt.keep(v$5, x => x % 8 === 0); @@ -576,204 +446,82 @@ 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 264, characters 5-12", Belt_internalAVLset.size(copyV.data), 126); +eq("File \"bs_mutable_set_test.res\", line 264, characters 5-12", Belt_MutableSetInt.size(copyV), 126); -eq("File \"bs_mutable_set_test.res\", line 265, characters 5-12", Belt_internalAVLset.toArray(copyV.data), Belt_Array.makeBy(126, i => (i << 3))); +eq("File \"bs_mutable_set_test.res\", line 265, characters 5-12", Belt_MutableSetInt.toArray(copyV), Belt_Array.makeBy(126, i => (i << 3))); -eq("File \"bs_mutable_set_test.res\", line 266, characters 5-12", Belt_internalAVLset.size(v$5.data), 800); +eq("File \"bs_mutable_set_test.res\", line 266, characters 5-12", Belt_MutableSetInt.size(v$5), 800); b("File \"bs_mutable_set_test.res\", line 267, characters 4-11", Belt_MutableSetInt.eq(copyV, match$5[0])); b("File \"bs_mutable_set_test.res\", line 268, characters 4-11", Belt_MutableSetInt.eq(cc$1, match$5[1])); -let xs$27 = Array_data_util.randomRange(0, 1000); - -let v$6 = { - data: Belt_internalSetInt.fromArray(xs$27) -}; +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]; -let xs$28 = Array_data_util.randomRange(0, 399); - -b("File \"bs_mutable_set_test.res\", line 274, characters 4-11", Belt_MutableSetInt.eq(match$7[0], { - data: Belt_internalSetInt.fromArray(xs$28) -})); - -let xs$29 = Array_data_util.randomRange(401, 1000); +b("File \"bs_mutable_set_test.res\", line 274, 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 275, characters 4-11", Belt_MutableSetInt.eq(match$7[1], { - data: Belt_internalSetInt.fromArray(xs$29) -})); +b("File \"bs_mutable_set_test.res\", line 275, characters 4-11", Belt_MutableSetInt.eq(match$7[1], Belt_MutableSetInt.fromArray(Array_data_util.randomRange(401, 1000)))); -let xs$30 = Belt_Array.map(Array_data_util.randomRange(0, 1000), x => (x << 1)); - -let d = { - data: Belt_internalSetInt.fromArray(xs$30) -}; +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]; -let xs$31 = Belt_Array.makeBy(501, x => (x << 1)); +b("File \"bs_mutable_set_test.res\", line 278, 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 278, characters 4-11", Belt_MutableSetInt.eq(match$9[0], { - data: Belt_internalSetInt.fromArray(xs$31) -})); +b("File \"bs_mutable_set_test.res\", line 279, characters 4-11", Belt_MutableSetInt.eq(match$9[1], Belt_MutableSetInt.fromArray(Belt_Array.makeBy(500, x => 1002 + (x << 1) | 0)))); -let xs$32 = Belt_Array.makeBy(500, x => 1002 + (x << 1) | 0); +let aa$3 = Belt_MutableSetInt.fromArray(Array_data_util.randomRange(0, 100)); -b("File \"bs_mutable_set_test.res\", line 279, characters 4-11", Belt_MutableSetInt.eq(match$9[1], { - data: Belt_internalSetInt.fromArray(xs$32) -})); +let bb$3 = Belt_MutableSetInt.fromArray(Array_data_util.randomRange(40, 120)); -let xs$33 = Array_data_util.randomRange(0, 100); - -let aa$3 = { - data: Belt_internalSetInt.fromArray(xs$33) -}; +let cc$2 = Belt_MutableSetInt.union(aa$3, bb$3); -let xs$34 = Array_data_util.randomRange(40, 120); +b("File \"bs_mutable_set_test.res\", line 289, characters 4-11", Belt_MutableSetInt.eq(cc$2, Belt_MutableSetInt.fromArray(Array_data_util.randomRange(0, 120)))); -let bb$3 = { - data: Belt_internalSetInt.fromArray(xs$34) -}; +b("File \"bs_mutable_set_test.res\", line 292, 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 cc$2 = Belt_MutableSetInt.union(aa$3, bb$3); +let dd$1 = Belt_MutableSetInt.intersect(aa$3, bb$3); -let xs$35 = Array_data_util.randomRange(0, 120); +b("File \"bs_mutable_set_test.res\", line 296, 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 289, characters 4-11", Belt_MutableSetInt.eq(cc$2, { - data: Belt_internalSetInt.fromArray(xs$35) -})); +b("File \"bs_mutable_set_test.res\", line 298, 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())); -let xs$36 = Array_data_util.randomRange(0, 20); +b("File \"bs_mutable_set_test.res\", line 302, 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())); -let xs$37 = Array_data_util.randomRange(21, 40); +b("File \"bs_mutable_set_test.res\", line 305, 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 +]))); -let xs$38 = Array_data_util.randomRange(0, 40); +b("File \"bs_mutable_set_test.res\", line 306, 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 292, characters 4-11", Belt_MutableSetInt.eq(Belt_MutableSetInt.union({ - data: Belt_internalSetInt.fromArray(xs$36) -}, { - data: Belt_internalSetInt.fromArray(xs$37) -}), { - data: Belt_internalSetInt.fromArray(xs$38) -})); +b("File \"bs_mutable_set_test.res\", line 307, characters 4-11", Belt_MutableSetInt.eq(Belt_MutableSetInt.diff(bb$3, aa$3), Belt_MutableSetInt.fromArray(Array_data_util.randomRange(101, 120)))); -let dd$1 = Belt_MutableSetInt.intersect(aa$3, bb$3); +b("File \"bs_mutable_set_test.res\", line 309, 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)))); -let xs$39 = Array_data_util.randomRange(40, 100); +b("File \"bs_mutable_set_test.res\", line 316, 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 296, characters 4-11", Belt_MutableSetInt.eq(dd$1, { - data: Belt_internalSetInt.fromArray(xs$39) -})); - -let xs$40 = Array_data_util.randomRange(0, 20); - -let xs$41 = Array_data_util.randomRange(21, 40); - -b("File \"bs_mutable_set_test.res\", line 298, characters 4-11", Belt_MutableSetInt.eq(Belt_MutableSetInt.intersect({ - data: Belt_internalSetInt.fromArray(xs$40) -}, { - data: Belt_internalSetInt.fromArray(xs$41) -}), { - data: undefined -})); - -let xs$42 = Array_data_util.randomRange(21, 40); - -let xs$43 = Array_data_util.randomRange(0, 20); - -b("File \"bs_mutable_set_test.res\", line 302, characters 4-11", Belt_MutableSetInt.eq(Belt_MutableSetInt.intersect({ - data: Belt_internalSetInt.fromArray(xs$42) -}, { - data: Belt_internalSetInt.fromArray(xs$43) -}), { - data: undefined -})); - -b("File \"bs_mutable_set_test.res\", line 305, characters 4-11", Belt_MutableSetInt.eq(Belt_MutableSetInt.intersect({ - data: Belt_internalSetInt.fromArray([ - 1, - 3, - 4, - 5, - 7, - 9 - ]) -}, { - data: Belt_internalSetInt.fromArray([ - 2, - 4, - 5, - 6, - 8, - 10 - ]) -}), { - data: Belt_internalSetInt.fromArray([ - 4, - 5 - ]) -})); - -let xs$44 = Array_data_util.randomRange(0, 39); - -b("File \"bs_mutable_set_test.res\", line 306, characters 4-11", Belt_MutableSetInt.eq(Belt_MutableSetInt.diff(aa$3, bb$3), { - data: Belt_internalSetInt.fromArray(xs$44) -})); - -let xs$45 = Array_data_util.randomRange(101, 120); - -b("File \"bs_mutable_set_test.res\", line 307, characters 4-11", Belt_MutableSetInt.eq(Belt_MutableSetInt.diff(bb$3, aa$3), { - data: Belt_internalSetInt.fromArray(xs$45) -})); - -let xs$46 = Array_data_util.randomRange(21, 40); - -let xs$47 = Array_data_util.randomRange(0, 20); - -let xs$48 = Array_data_util.randomRange(21, 40); - -b("File \"bs_mutable_set_test.res\", line 309, characters 4-11", Belt_MutableSetInt.eq(Belt_MutableSetInt.diff({ - data: Belt_internalSetInt.fromArray(xs$46) -}, { - data: Belt_internalSetInt.fromArray(xs$47) -}), { - data: Belt_internalSetInt.fromArray(xs$48) -})); - -let xs$49 = Array_data_util.randomRange(0, 20); - -let xs$50 = Array_data_util.randomRange(21, 40); - -let xs$51 = Array_data_util.randomRange(0, 20); - -b("File \"bs_mutable_set_test.res\", line 316, characters 4-11", Belt_MutableSetInt.eq(Belt_MutableSetInt.diff({ - data: Belt_internalSetInt.fromArray(xs$49) -}, { - data: Belt_internalSetInt.fromArray(xs$50) -}), { - data: Belt_internalSetInt.fromArray(xs$51) -})); - -let xs$52 = Array_data_util.randomRange(0, 20); - -let xs$53 = Array_data_util.randomRange(0, 40); - -let xs$54 = Array_data_util.randomRange(0, -1); - -b("File \"bs_mutable_set_test.res\", line 324, characters 4-11", Belt_MutableSetInt.eq(Belt_MutableSetInt.diff({ - data: Belt_internalSetInt.fromArray(xs$52) -}, { - data: Belt_internalSetInt.fromArray(xs$53) -}), { - data: Belt_internalSetInt.fromArray(xs$54) -})); +b("File \"bs_mutable_set_test.res\", line 324, 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); diff --git a/tests/tests/src/bs_poly_map_test.js b/tests/tests/src/bs_poly_map_test.js index 3cbeb6dc00..51db7fab94 100644 --- a/tests/tests/src/bs_poly_map_test.js +++ b/tests/tests/src/bs_poly_map_test.js @@ -2,10 +2,10 @@ '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 Belt_MapDict = require("rescript/lib/js/belt_MapDict.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"); @@ -26,9 +26,7 @@ function b(loc, v) { Mt.bool_suites(test_id, suites, loc, v); } -let Icmp = { - cmp: Primitive_int.compare -}; +let Icmp = Belt_Id.comparable(Primitive_int.compare); function mapOfArray(x) { return Belt_Map.fromArray(x, Icmp); @@ -39,40 +37,34 @@ function setOfArray(x) { } function emptyMap() { - return { - cmp: Icmp.cmp, - data: undefined - }; + return Belt_Map.make(Icmp); } function mergeInter(s1, s2) { - let m = Belt_Map.merge(s1, s2, (k, v1, v2) => { + 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); } - }); - return Belt_Set.fromArray(Belt_MapDict.keysToArray(m.data), Icmp); + })), Icmp); } function mergeUnion(s1, s2) { - let m = Belt_Map.merge(s1, s2, (k, v1, v2) => { + 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); } - }); - return Belt_Set.fromArray(Belt_MapDict.keysToArray(m.data), Icmp); + })), Icmp); } function mergeDiff(s1, s2) { - let m = Belt_Map.merge(s1, s2, (k, v1, v2) => { + 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); } - }); - return Belt_Set.fromArray(Belt_MapDict.keysToArray(m.data), Icmp); + })), Icmp); } function randomRange(i, j) { @@ -149,14 +141,14 @@ let a7 = Belt_Map.removeMany(a0, [ 6 ]); -eq("File \"bs_poly_map_test.res\", line 99, characters 5-12", Belt_MapDict.keysToArray(a7.data), [ +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_MapDict.isEmpty(a8.data)); +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); @@ -176,12 +168,7 @@ function acc(m, is) { })); } -let m_cmp = Icmp.cmp; - -let m = { - cmp: m_cmp, - data: undefined -}; +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))); @@ -190,12 +177,7 @@ b("File \"bs_poly_map_test.res\", line 125, characters 4-11", Belt_Map.eq(m1, Be i >= 10 && i <= 20 ? 2 : 1 ]), Icmp), (x, y) => x === y)); -let v0_cmp = Icmp.cmp; - -let v0 = { - cmp: v0_cmp, - data: undefined -}; +let v0 = Belt_Map.make(Icmp); let v1 = Belt_Map.mergeMany(v0, Belt_Array.map(Array_data_util.randomRange(0, 10000), x => [ x, @@ -239,25 +221,15 @@ 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); -let map = Belt_Map.remove({ - cmp: Icmp.cmp, - data: undefined -}, 0); - -b("File \"bs_poly_map_test.res\", line 180, characters 4-11", Belt_MapDict.isEmpty(map.data)); - -let map$1 = Belt_Map.removeMany({ - cmp: Icmp.cmp, - data: undefined -}, [0]); +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_MapDict.isEmpty(map$1.data)); +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_MapDict.keysToArray(match$1[0].data), Belt_Array.makeBy(5000, i => i), (prim0, prim1) => prim0 === prim1)); +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_MapDict.keysToArray(match$1[1].data), Belt_Array.makeBy(5000, i => 5001 + i | 0), (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); @@ -267,9 +239,9 @@ 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_MapDict.keysToArray(match$6[0].data), Belt_Array.makeBy(5000, i => i), (prim0, prim1) => prim0 === prim1)); +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_MapDict.keysToArray(match$6[1].data), Belt_Array.makeBy(5000, i => 5001 + i | 0), (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); @@ -298,4 +270,4 @@ exports.mergeUnion = mergeUnion; exports.mergeDiff = mergeDiff; exports.randomRange = randomRange; exports.acc = acc; -/* u0 Not a pure module */ +/* 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 index a81d4cbb4a..5b6ab9b546 100644 --- a/tests/tests/src/bs_poly_mutable_map_test.js +++ b/tests/tests/src/bs_poly_mutable_map_test.js @@ -2,12 +2,12 @@ '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 Belt_internalAVLtree = require("rescript/lib/js/belt_internalAVLtree.js"); let suites = { contents: /* [] */0 @@ -25,9 +25,7 @@ function b(loc, v) { Mt.bool_suites(test_id, suites, loc, v); } -let Icmp = { - cmp: Primitive_int.compare -}; +let Icmp = Belt_Id.comparable(Primitive_int.compare); function f(x) { return Belt_MutableMap.fromArray(x, Icmp); @@ -64,7 +62,7 @@ Belt_MutableMap.removeMany(a0, [ 6 ]); -eq("File \"bs_poly_mutable_map_test.res\", line 29, characters 5-12", Belt_internalAVLtree.keysToArray(a0.data), [ +eq("File \"bs_poly_mutable_map_test.res\", line 29, characters 5-12", Belt_MutableMap.keysToArray(a0), [ 9, 10 ]); @@ -81,7 +79,7 @@ Belt_MutableMap.removeMany(a0$1, Belt_Array.map(randomRange(0, 1998), prim => pr 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_internalAVLtree.toArray(a0$1.data), [ +eq("File \"bs_poly_mutable_map_test.res\", line 39, characters 5-12", Belt_MutableMap.toArray(a0$1), [ [ 1999, 1999 @@ -118,4 +116,4 @@ exports.I = I; exports.f = f; exports.ff = ff; exports.randomRange = randomRange; -/* a0 Not a pure module */ +/* 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 index 99f79dde25..5810c1cdfc 100644 --- a/tests/tests/src/bs_poly_mutable_set_test.js +++ b/tests/tests/src/bs_poly_mutable_set_test.js @@ -2,12 +2,12 @@ '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 Belt_internalAVLset = require("rescript/lib/js/belt_internalAVLset.js"); let suites = { contents: /* [] */0 @@ -25,19 +25,14 @@ function b(loc, x) { Mt.bool_suites(test_id, suites, loc, x); } -let IntCmp = { - cmp: Primitive_int.compare -}; +let IntCmp = Belt_Id.comparable(Primitive_int.compare); function fromArray(none) { return Belt_MutableSet.fromArray(none, IntCmp); } function empty() { - return { - cmp: IntCmp.cmp, - data: undefined - }; + return Belt_MutableSet.make(IntCmp); } let u = Belt_MutableSet.fromArray(Array_data_util.range(0, 30), IntCmp); @@ -50,13 +45,13 @@ b("File \"bs_poly_mutable_set_test.res\", line 18, characters 4-11", Belt_Mutabl 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_internalAVLset.size(u.data), 28); +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_internalAVLset.maxUndefined(u.data)); +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_internalAVLset.minUndefined(u.data)); +b("File \"bs_poly_mutable_set_test.res\", line 23, characters 4-11", 1 === Belt_MutableSet.minUndefined(u)); Belt_MutableSet.add(u, 3); @@ -74,7 +69,7 @@ Belt_MutableSet.add(u, 2); Belt_MutableSet.add(u, 0); -eq("File \"bs_poly_mutable_set_test.res\", line 33, characters 5-12", Belt_internalAVLset.size(u.data), 3); +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)); @@ -88,27 +83,27 @@ 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_internalAVLset.size(u.data), 20001); +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_internalAVLset.size(u.data), 19800); +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_internalAVLset.size(u.data), 19000); +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_internalAVLset.size(u.data), 19000); +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_internalAVLset.size(u.data), 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_internalAVLset.size(u.data), 1); +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)); @@ -130,7 +125,7 @@ let indeedRemoved = Belt_Array.reduce(bs, 0, (acc, x) => { 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_internalAVLset.size(v.data), 501); +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)); @@ -144,28 +139,25 @@ let indeedAded = Belt_Array.reduce(cs, 0, (acc, x) => { 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_internalAVLset.size(v.data), 1501); +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({ - cmp: IntCmp.cmp, - data: undefined -})); +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_internalAVLset.minimum(v.data), 500); +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_internalAVLset.maximum(v.data), 2000); +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_internalAVLset.minUndefined(v.data), 500); +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_internalAVLset.maxUndefined(v.data), 2000); +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_internalAVLset.toList(v.data), Belt_List.makeBy(1501, i => i + 500 | 0), (x, y) => x === y)); +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_internalAVLset.toArray(v.data), Array_data_util.range(500, 2000)); +eq("File \"bs_poly_mutable_set_test.res\", line 86, characters 5-12", Belt_MutableSet.toArray(v), Array_data_util.range(500, 2000)); -Belt_internalAVLset.checkInvariantInternal(v.data); +Belt_MutableSet.checkInvariantInternal(v); eq("File \"bs_poly_mutable_set_test.res\", line 88, characters 5-12", Belt_MutableSet.get(v, 3), undefined); @@ -181,9 +173,9 @@ 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_internalAVLset.toArray(aa.data), Array_data_util.range(500, 999), (prim0, prim1) => prim0 === prim1)); +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_internalAVLset.toArray(bb.data), Array_data_util.range(1001, 2000), (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)); @@ -205,9 +197,9 @@ 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_internalAVLset.toArray(aa$1.data), Array_data_util.range(500, 999), (prim0, prim1) => prim0 === prim1)); +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_internalAVLset.toArray(bb$1.data), Array_data_util.range(1001, 2000), (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)); @@ -229,15 +221,9 @@ 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)), { - cmp: IntCmp.cmp, - data: undefined -})); +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)), { - cmp: IntCmp.cmp, - data: undefined -})); +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, @@ -299,7 +285,7 @@ Belt_List.forEach({ } } } -}, x => Belt_internalAVLset.checkInvariantInternal(x.data)); +}, Belt_MutableSet.checkInvariantInternal); Mt.from_pair_suites("Bs_poly_mutable_set_test", suites.contents); @@ -331,4 +317,4 @@ exports.empty = empty; exports.$plus$plus = $plus$plus; exports.f = f; exports.$eq$tilde = $eq$tilde; -/* u Not a pure module */ +/* 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 index 6329f59150..d63957698a 100644 --- a/tests/tests/src/bs_poly_set_test.js +++ b/tests/tests/src/bs_poly_set_test.js @@ -2,6 +2,7 @@ '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"); @@ -31,9 +32,7 @@ function t(loc, x) { Mt.throw_suites(test_id, suites, loc, x); } -let IntCmp = { - cmp: Primitive_int.compare -}; +let IntCmp = Belt_Id.comparable(Primitive_int.compare); let u0 = Belt_Set.fromArray(Array_data_util.range(0, 30), IntCmp); @@ -85,43 +84,43 @@ 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_SetDict.size(u4.data), 28); +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_SetDict.maxUndefined(u4.data)); +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_SetDict.minUndefined(u4.data)); +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_SetDict.isEmpty(u6.data)); +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_SetDict.size(u7.data), 3); +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_SetDict.isEmpty(u7.data)); +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_SetDict.isEmpty(u8.data)); +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_SetDict.size(u10.data), 20001); +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_SetDict.size(u11.data), 19800); +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_SetDict.size(u12.data), 19000); +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_SetDict.size(u13.data), Belt_SetDict.size(u12.data)); +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_SetDict.size(u14.data), 10000); +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_SetDict.size(u15.data), 1); +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_SetDict.isEmpty(u16.data)); +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); @@ -141,10 +140,7 @@ let u24 = Belt_Set.union(u18, u17); let u25 = Belt_Set.add(u22, 59); -let u26 = Belt_Set.add({ - cmp: IntCmp.cmp, - data: undefined -}, 3); +let u26 = Belt_Set.add(Belt_Set.make(IntCmp), 3); let ss = Belt_Array.makeByAndShuffle(100, i => (i << 1)); @@ -156,17 +152,17 @@ 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_SetDict.toArray(u29.data), Belt_SortArray.stableSortBy(Belt_Array.concat(ss, [3]), Primitive_int.compare))); +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_SetDict.toArray(u21.data), Array_data_util.range(59, 100)); +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_SetDict.toArray(u22.data), Array_data_util.range(0, 58)); +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_SetDict.toArray(u23.data), Array_data_util.range(101, 200)); +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)); @@ -184,21 +180,21 @@ b("File \"bs_poly_set_test.res\", line 84, characters 4-11", Belt_Set.getUndefin 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_SetDict.size(u25.data), 60); +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_SetDict.minimum(undefined) === undefined); +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_SetDict.maximum(undefined) === 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_SetDict.minUndefined(undefined) === 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_SetDict.maxUndefined(undefined) === 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_SetDict.forEach(xs.data, x => { + Belt_Set.forEach(xs, x => { v.contents = { hd: x, tl: v.contents @@ -211,7 +207,7 @@ function testIterToList2(xs) { let v = { contents: /* [] */0 }; - Belt_SetDict.forEach(xs.data, x => { + Belt_SetDict.forEach(Belt_Set.getData(xs), x => { v.contents = { hd: x, tl: v.contents @@ -230,45 +226,23 @@ b("File \"bs_poly_set_test.res\", line 110, characters 4-11", Belt_List.every2(t 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_SetDict.toList(u0$1.data), (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)); -function f(x) { - return x === 17; -} +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 113, characters 4-11", Belt_SetDict.some(u0$1.data, f)); +b("File \"bs_poly_set_test.res\", line 114, characters 4-11", !Belt_Set.some(u1$1, x => x === 17)); -function f$1(x) { - return 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 114, characters 4-11", !Belt_SetDict.some(u1$1.data, f$1)); +b("File \"bs_poly_set_test.res\", line 116, characters 4-11", Belt_SetDict.every(Belt_Set.getData(u0$1), x => x < 24)); -function f$2(x) { - return 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 115, characters 4-11", Belt_SetDict.every(u0$1.data, f$2)); - -b("File \"bs_poly_set_test.res\", line 116, characters 4-11", Belt_SetDict.every(u0$1.data, x => x < 24)); - -function f$3(x) { - return x < 24; -} - -b("File \"bs_poly_set_test.res\", line 117, characters 4-11", !Belt_SetDict.every(u2$1.data, f$3)); - -function f$4(x) { - return x === 2; -} - -let m = Belt_Set.fromArray([ +b("File \"bs_poly_set_test.res\", line 118, characters 4-11", !Belt_Set.every(Belt_Set.fromArray([ 1, 2, 3 -], IntCmp); - -b("File \"bs_poly_set_test.res\", line 118, characters 4-11", !Belt_SetDict.every(m.data, f$4)); +], IntCmp), x => x === 2)); b("File \"bs_poly_set_test.res\", line 119, characters 4-11", Belt_Set.cmp(u1$1, u0$1) < 0); @@ -302,9 +276,9 @@ 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_SetDict.size(a0.data), 1001); +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_SetDict.isEmpty(a0.data)); +b("File \"bs_poly_set_test.res\", line 134, characters 4-11", !Belt_Set.isEmpty(a0)); let match$1 = Belt_Set.split(a0, 200); @@ -312,9 +286,9 @@ 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_SetDict.toArray(match$2[0].data), Belt_Array.makeBy(200, i => i)); +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_SetDict.toList(match$2[1].data), Belt_List.makeBy(800, i => i + 201 | 0)); +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); @@ -328,13 +302,13 @@ 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_SetDict.toArray(a8.data), Belt_Array.makeBy(200, i => i)); +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_SetDict.toList(a9.data), Belt_List.makeBy(800, i => i + 201 | 0)); +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_SetDict.minimum(a8.data), 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_SetDict.minimum(a9.data), 201); +eq("File \"bs_poly_set_test.res\", line 145, characters 5-12", Belt_Set.minimum(a9), 201); Belt_List.forEach({ hd: a0, @@ -351,24 +325,19 @@ Belt_List.forEach({ } } } -}, x => Belt_SetDict.checkInvariantInternal(x.data)); +}, Belt_Set.checkInvariantInternal); let a = Belt_Set.fromArray([], IntCmp); -let m$1 = Belt_Set.keep(a, x => x % 2 === 0); - -b("File \"bs_poly_set_test.res\", line 151, characters 4-11", Belt_SetDict.isEmpty(m$1.data)); +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({ - cmp: IntCmp.cmp, - data: undefined -}, 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_SetDict.isEmpty(match$6[0].data)); +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_SetDict.isEmpty(match$6[1].data)); +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]); @@ -400,4 +369,4 @@ exports.IntCmp = IntCmp; exports.L = L; exports.testIterToList = testIterToList; exports.testIterToList2 = testIterToList2; -/* u0 Not a pure module */ +/* IntCmp Not a pure module */ diff --git a/tests/tests/src/bs_queue_test.js b/tests/tests/src/bs_queue_test.js index 311d15799f..238b5d0f49 100644 --- a/tests/tests/src/bs_queue_test.js +++ b/tests/tests/src/bs_queue_test.js @@ -36,13 +36,9 @@ function $plus$plus(q, x) { return q; } -let q = { - length: 0, - first: undefined, - last: undefined -}; +let q = Belt_MutableQueue.make(); -if (!(Primitive_object.equal(Belt_MutableQueue.toArray(q), []) && q.length === 0)) { +if (!(Primitive_object.equal(Belt_MutableQueue.toArray(q), []) && Belt_MutableQueue.size(q) === 0)) { throw { RE_EXN_ID: "Assert_failure", _1: [ @@ -54,7 +50,7 @@ if (!(Primitive_object.equal(Belt_MutableQueue.toArray(q), []) && q.length === 0 }; } -if (!(Primitive_object.equal(Belt_MutableQueue.toArray((Belt_MutableQueue.add(q, 1), q)), [1]) && q.length === 1)) { +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: [ @@ -69,7 +65,7 @@ if (!(Primitive_object.equal(Belt_MutableQueue.toArray((Belt_MutableQueue.add(q, if (!(Primitive_object.equal(Belt_MutableQueue.toArray((Belt_MutableQueue.add(q, 2), q)), [ 1, 2 - ]) && q.length === 2)) { + ]) && Belt_MutableQueue.size(q) === 2)) { throw { RE_EXN_ID: "Assert_failure", _1: [ @@ -85,7 +81,7 @@ if (!(Primitive_object.equal(Belt_MutableQueue.toArray((Belt_MutableQueue.add(q, 1, 2, 3 - ]) && q.length === 3)) { + ]) && Belt_MutableQueue.size(q) === 3)) { throw { RE_EXN_ID: "Assert_failure", _1: [ @@ -102,7 +98,7 @@ if (!(Primitive_object.equal(Belt_MutableQueue.toArray((Belt_MutableQueue.add(q, 2, 3, 4 - ]) && q.length === 4)) { + ]) && Belt_MutableQueue.size(q) === 4)) { throw { RE_EXN_ID: "Assert_failure", _1: [ @@ -130,7 +126,7 @@ if (!(Primitive_object.equal(Belt_MutableQueue.toArray(q), [ 2, 3, 4 - ]) && q.length === 3)) { + ]) && Belt_MutableQueue.size(q) === 3)) { throw { RE_EXN_ID: "Assert_failure", _1: [ @@ -157,7 +153,7 @@ if (Belt_MutableQueue.popExn(q) !== 2) { if (!(Primitive_object.equal(Belt_MutableQueue.toArray(q), [ 3, 4 - ]) && q.length === 2)) { + ]) && Belt_MutableQueue.size(q) === 2)) { throw { RE_EXN_ID: "Assert_failure", _1: [ @@ -181,7 +177,7 @@ if (Belt_MutableQueue.popExn(q) !== 3) { }; } -if (!(Primitive_object.equal(Belt_MutableQueue.toArray(q), [4]) && q.length === 1)) { +if (!(Primitive_object.equal(Belt_MutableQueue.toArray(q), [4]) && Belt_MutableQueue.size(q) === 1)) { throw { RE_EXN_ID: "Assert_failure", _1: [ @@ -205,7 +201,7 @@ if (Belt_MutableQueue.popExn(q) !== 4) { }; } -if (!(Primitive_object.equal(Belt_MutableQueue.toArray(q), []) && q.length === 0)) { +if (!(Primitive_object.equal(Belt_MutableQueue.toArray(q), []) && Belt_MutableQueue.size(q) === 0)) { throw { RE_EXN_ID: "Assert_failure", _1: [ @@ -229,11 +225,7 @@ if (!does_raise(Belt_MutableQueue.popExn, q)) { }; } -let q$1 = { - length: 0, - first: undefined, - last: undefined -}; +let q$1 = Belt_MutableQueue.make(); if (Belt_MutableQueue.popExn((Belt_MutableQueue.add(q$1, 1), q$1)) !== 1) { throw { @@ -283,7 +275,7 @@ if (!does_raise(Belt_MutableQueue.popExn, q$1)) { }; } -if (q$1.length !== 0) { +if (Belt_MutableQueue.size(q$1) !== 0) { throw { RE_EXN_ID: "Assert_failure", _1: [ @@ -295,11 +287,7 @@ if (q$1.length !== 0) { }; } -let q$2 = { - length: 0, - first: undefined, - last: undefined -}; +let q$2 = Belt_MutableQueue.make(); if (Belt_MutableQueue.peekExn((Belt_MutableQueue.add(q$2, 1), q$2)) !== 1) { throw { @@ -433,11 +421,7 @@ if (!does_raise(Belt_MutableQueue.peekExn, q$2)) { }; } -let q$3 = { - length: 0, - first: undefined, - last: undefined -}; +let q$3 = Belt_MutableQueue.make(); for (let i = 1; i <= 10; ++i) { Belt_MutableQueue.add(q$3, i); @@ -445,7 +429,7 @@ for (let i = 1; i <= 10; ++i) { Belt_MutableQueue.clear(q$3); -if (q$3.length !== 0) { +if (Belt_MutableQueue.size(q$3) !== 0) { throw { RE_EXN_ID: "Assert_failure", _1: [ @@ -469,11 +453,7 @@ if (!does_raise(Belt_MutableQueue.popExn, q$3)) { }; } -if (!Primitive_object.equal(q$3, { - length: 0, - first: undefined, - last: undefined - })) { +if (!Primitive_object.equal(q$3, Belt_MutableQueue.make())) { throw { RE_EXN_ID: "Assert_failure", _1: [ @@ -499,11 +479,7 @@ if (Belt_MutableQueue.popExn(q$3) !== 42) { }; } -let q1 = { - length: 0, - first: undefined, - last: undefined -}; +let q1 = Belt_MutableQueue.make(); for (let i$1 = 1; i$1 <= 10; ++i$1) { Belt_MutableQueue.add(q1, i$1); @@ -557,7 +533,7 @@ if (!Primitive_object.equal(Belt_MutableQueue.toArray(q2), [ }; } -if (q1.length !== 10) { +if (Belt_MutableQueue.size(q1) !== 10) { throw { RE_EXN_ID: "Assert_failure", _1: [ @@ -569,7 +545,7 @@ if (q1.length !== 10) { }; } -if (q2.length !== 10) { +if (Belt_MutableQueue.size(q2) !== 10) { throw { RE_EXN_ID: "Assert_failure", _1: [ @@ -611,13 +587,9 @@ for (let i$3 = 1; i$3 <= 10; ++i$3) { } -let q$4 = { - length: 0, - first: undefined, - last: undefined -}; +let q$4 = Belt_MutableQueue.make(); -if (q$4.length !== 0) { +if (!Belt_MutableQueue.isEmpty(q$4)) { throw { RE_EXN_ID: "Assert_failure", _1: [ @@ -631,7 +603,7 @@ if (q$4.length !== 0) { for (let i$4 = 1; i$4 <= 10; ++i$4) { Belt_MutableQueue.add(q$4, i$4); - if (q$4.length !== i$4) { + if (Belt_MutableQueue.size(q$4) !== i$4) { throw { RE_EXN_ID: "Assert_failure", _1: [ @@ -642,7 +614,7 @@ for (let i$4 = 1; i$4 <= 10; ++i$4) { Error: new Error() }; } - if (q$4.length === 0) { + if (Belt_MutableQueue.isEmpty(q$4)) { throw { RE_EXN_ID: "Assert_failure", _1: [ @@ -657,7 +629,7 @@ for (let i$4 = 1; i$4 <= 10; ++i$4) { } for (let i$5 = 10; i$5 >= 1; --i$5) { - if (q$4.length !== i$5) { + if (Belt_MutableQueue.size(q$4) !== i$5) { throw { RE_EXN_ID: "Assert_failure", _1: [ @@ -668,7 +640,7 @@ for (let i$5 = 10; i$5 >= 1; --i$5) { Error: new Error() }; } - if (q$4.length === 0) { + if (Belt_MutableQueue.isEmpty(q$4)) { throw { RE_EXN_ID: "Assert_failure", _1: [ @@ -682,7 +654,7 @@ for (let i$5 = 10; i$5 >= 1; --i$5) { Belt_MutableQueue.popExn(q$4); } -if (q$4.length !== 0) { +if (Belt_MutableQueue.size(q$4) !== 0) { throw { RE_EXN_ID: "Assert_failure", _1: [ @@ -694,7 +666,7 @@ if (q$4.length !== 0) { }; } -if (q$4.length !== 0) { +if (!Belt_MutableQueue.isEmpty(q$4)) { throw { RE_EXN_ID: "Assert_failure", _1: [ @@ -706,11 +678,7 @@ if (q$4.length !== 0) { }; } -let q$5 = { - length: 0, - first: undefined, - last: undefined -}; +let q$5 = Belt_MutableQueue.make(); for (let i$6 = 1; i$6 <= 10; ++i$6) { Belt_MutableQueue.add(q$5, i$6); @@ -735,19 +703,11 @@ Belt_MutableQueue.forEach(q$5, j => { i$7.contents = i$7.contents + 1 | 0; }); -let q1$1 = { - length: 0, - first: undefined, - last: undefined -}; +let q1$1 = Belt_MutableQueue.make(); -let q2$1 = { - length: 0, - first: undefined, - last: undefined -}; +let q2$1 = Belt_MutableQueue.make(); -if (q1$1.length !== 0) { +if (Belt_MutableQueue.size(q1$1) !== 0) { throw { RE_EXN_ID: "Assert_failure", _1: [ @@ -771,7 +731,7 @@ if (!Primitive_object.equal(Belt_MutableQueue.toArray(q1$1), [])) { }; } -if (q2$1.length !== 0) { +if (Belt_MutableQueue.size(q2$1) !== 0) { throw { RE_EXN_ID: "Assert_failure", _1: [ @@ -797,7 +757,7 @@ if (!Primitive_object.equal(Belt_MutableQueue.toArray(q2$1), [])) { Belt_MutableQueue.transfer(q1$1, q2$1); -if (q1$1.length !== 0) { +if (Belt_MutableQueue.size(q1$1) !== 0) { throw { RE_EXN_ID: "Assert_failure", _1: [ @@ -821,7 +781,7 @@ if (!Primitive_object.equal(Belt_MutableQueue.toArray(q1$1), [])) { }; } -if (q2$1.length !== 0) { +if (Belt_MutableQueue.size(q2$1) !== 0) { throw { RE_EXN_ID: "Assert_failure", _1: [ @@ -845,23 +805,15 @@ if (!Primitive_object.equal(Belt_MutableQueue.toArray(q2$1), [])) { }; } -let q1$2 = { - length: 0, - first: undefined, - last: undefined -}; +let q1$2 = Belt_MutableQueue.make(); -let q2$2 = { - length: 0, - first: undefined, - last: undefined -}; +let q2$2 = Belt_MutableQueue.make(); for (let i$8 = 1; i$8 <= 4; ++i$8) { Belt_MutableQueue.add(q1$2, i$8); } -if (q1$2.length !== 4) { +if (Belt_MutableQueue.size(q1$2) !== 4) { throw { RE_EXN_ID: "Assert_failure", _1: [ @@ -890,7 +842,7 @@ if (!Primitive_object.equal(Belt_MutableQueue.toArray(q1$2), [ }; } -if (q2$2.length !== 0) { +if (Belt_MutableQueue.size(q2$2) !== 0) { throw { RE_EXN_ID: "Assert_failure", _1: [ @@ -916,7 +868,7 @@ if (!Primitive_object.equal(Belt_MutableQueue.toArray(q2$2), [])) { Belt_MutableQueue.transfer(q1$2, q2$2); -if (q1$2.length !== 0) { +if (Belt_MutableQueue.size(q1$2) !== 0) { throw { RE_EXN_ID: "Assert_failure", _1: [ @@ -940,7 +892,7 @@ if (!Primitive_object.equal(Belt_MutableQueue.toArray(q1$2), [])) { }; } -if (q2$2.length !== 4) { +if (Belt_MutableQueue.size(q2$2) !== 4) { throw { RE_EXN_ID: "Assert_failure", _1: [ @@ -969,23 +921,15 @@ if (!Primitive_object.equal(Belt_MutableQueue.toArray(q2$2), [ }; } -let q1$3 = { - length: 0, - first: undefined, - last: undefined -}; +let q1$3 = Belt_MutableQueue.make(); -let q2$3 = { - length: 0, - first: undefined, - last: undefined -}; +let q2$3 = Belt_MutableQueue.make(); for (let i$9 = 5; i$9 <= 8; ++i$9) { Belt_MutableQueue.add(q2$3, i$9); } -if (q1$3.length !== 0) { +if (Belt_MutableQueue.size(q1$3) !== 0) { throw { RE_EXN_ID: "Assert_failure", _1: [ @@ -1009,7 +953,7 @@ if (!Primitive_object.equal(Belt_MutableQueue.toArray(q1$3), [])) { }; } -if (q2$3.length !== 4) { +if (Belt_MutableQueue.size(q2$3) !== 4) { throw { RE_EXN_ID: "Assert_failure", _1: [ @@ -1040,7 +984,7 @@ if (!Primitive_object.equal(Belt_MutableQueue.toArray(q2$3), [ Belt_MutableQueue.transfer(q1$3, q2$3); -if (q1$3.length !== 0) { +if (Belt_MutableQueue.size(q1$3) !== 0) { throw { RE_EXN_ID: "Assert_failure", _1: [ @@ -1064,7 +1008,7 @@ if (!Primitive_object.equal(Belt_MutableQueue.toArray(q1$3), [])) { }; } -if (q2$3.length !== 4) { +if (Belt_MutableQueue.size(q2$3) !== 4) { throw { RE_EXN_ID: "Assert_failure", _1: [ @@ -1093,17 +1037,9 @@ if (!Primitive_object.equal(Belt_MutableQueue.toArray(q2$3), [ }; } -let q1$4 = { - length: 0, - first: undefined, - last: undefined -}; +let q1$4 = Belt_MutableQueue.make(); -let q2$4 = { - length: 0, - first: undefined, - last: undefined -}; +let q2$4 = Belt_MutableQueue.make(); for (let i$10 = 1; i$10 <= 4; ++i$10) { Belt_MutableQueue.add(q1$4, i$10); @@ -1113,7 +1049,7 @@ for (let i$11 = 5; i$11 <= 8; ++i$11) { Belt_MutableQueue.add(q2$4, i$11); } -if (q1$4.length !== 4) { +if (Belt_MutableQueue.size(q1$4) !== 4) { throw { RE_EXN_ID: "Assert_failure", _1: [ @@ -1142,7 +1078,7 @@ if (!Primitive_object.equal(Belt_MutableQueue.toArray(q1$4), [ }; } -if (q2$4.length !== 4) { +if (Belt_MutableQueue.size(q2$4) !== 4) { throw { RE_EXN_ID: "Assert_failure", _1: [ @@ -1173,7 +1109,7 @@ if (!Primitive_object.equal(Belt_MutableQueue.toArray(q2$4), [ Belt_MutableQueue.transfer(q1$4, q2$4); -if (q1$4.length !== 0) { +if (Belt_MutableQueue.size(q1$4) !== 0) { throw { RE_EXN_ID: "Assert_failure", _1: [ @@ -1208,7 +1144,7 @@ let v = [ 4 ]; -if (q2$4.length !== 8) { +if (Belt_MutableQueue.size(q2$4) !== 8) { throw { RE_EXN_ID: "Assert_failure", _1: [ @@ -1262,13 +1198,9 @@ eq("File \"bs_queue_test.res\", line 197, characters 5-12", Belt_MutableQueue.to 3 ]); -let q$7 = Belt_MutableQueue.fromArray([]); - -b("File \"bs_queue_test.res\", line 198, characters 4-11", q$7.length === 0); - -let q$8 = Belt_MutableQueue.map(Belt_MutableQueue.fromArray([]), x => x + 1 | 0); +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", q$8.length === 0); +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); @@ -1281,4 +1213,4 @@ exports.b = b; exports.Q = Q; exports.does_raise = does_raise; exports.$plus$plus = $plus$plus; -/* Not a pure module */ +/* q Not a pure module */ diff --git a/tests/tests/src/bs_stack_test.js b/tests/tests/src/bs_stack_test.js index 57e02c31ec..196666dbef 100644 --- a/tests/tests/src/bs_stack_test.js +++ b/tests/tests/src/bs_stack_test.js @@ -21,20 +21,14 @@ function eq(loc, x, y) { function inOrder(v) { let current = v; - let s = { - root: undefined - }; - let q = { - length: 0, - first: undefined, - last: undefined - }; + 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 (s.root !== undefined) { + while (!Belt_MutableStack.isEmpty(s)) { current = Belt_MutableStack.popUndefined(s); let v$2 = current; Belt_MutableQueue.add(q, v$2.value); @@ -50,14 +44,8 @@ function inOrder(v) { function inOrder3(v) { let current = v; - let s = { - root: undefined - }; - let q = { - length: 0, - first: undefined, - last: undefined - }; + let s = Belt_MutableStack.make(); + let q = Belt_MutableQueue.make(); while (current !== undefined) { let v$1 = current; Belt_MutableStack.push(s, v$1); @@ -78,26 +66,20 @@ function inOrder3(v) { function inOrder2(v) { let todo = true; let cursor = v; - let s = { - root: undefined - }; - let q = { - length: 0, - first: undefined, - last: undefined - }; + 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 (s.root !== undefined) { + } 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; - } else { - todo = false; } }; } diff --git a/tests/tests/src/coercion_module_alias_test.js b/tests/tests/src/coercion_module_alias_test.js index 85cb699628..43611c975f 100644 --- a/tests/tests/src/coercion_module_alias_test.js +++ b/tests/tests/src/coercion_module_alias_test.js @@ -16,9 +16,7 @@ console.log(66); let C3 = Char; -let prim = 66; - -console.log(prim); +console.log(66); let f = Belt_List.length; @@ -32,9 +30,7 @@ function F(X) { let C4 = Char; -let prim$1 = 66; - -console.log(prim$1); +console.log(66); function G(X) { return X; @@ -141,22 +137,28 @@ let M8 = { C$p: C$p$1 }; +let M9_C = { + chr: prim => prim +}; + let M9 = { - C: Char, + C: M9_C, C$p: C$p$1 }; -let prim$2 = Char.chr(66); +let prim = M9_C.chr(66); -console.log(prim$2); +console.log(prim); let M10 = { - C$p: Char + C$p: { + chr: prim => prim + } }; -let prim$3 = M10.C$p.chr(66); +let prim$1 = M10.C$p.chr(66); -console.log(prim$3); +console.log(prim$1); let C; diff --git a/tests/tests/src/const_defs_test.js b/tests/tests/src/const_defs_test.js index a1b5eba93b..5511950d6a 100644 --- a/tests/tests/src/const_defs_test.js +++ b/tests/tests/src/const_defs_test.js @@ -1,15 +1,12 @@ // Generated by ReScript, PLEASE EDIT WITH CARE 'use strict'; +let Pervasives = require("rescript/lib/js/pervasives.js"); let u = 3; function f() { - throw { - RE_EXN_ID: "Invalid_argument", - _1: "hi", - Error: new Error() - }; + return Pervasives.invalid_arg("hi"); } exports.u = u; diff --git a/tests/tests/src/defunctor_make_test.js b/tests/tests/src/defunctor_make_test.js index fd815af76e..09e8db0f75 100644 --- a/tests/tests/src/defunctor_make_test.js +++ b/tests/tests/src/defunctor_make_test.js @@ -1,6 +1,7 @@ // 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) { @@ -44,11 +45,7 @@ function bal(l, x, d, r) { hr = typeof r !== "object" ? 0 : r._4; if (hl > (hr + 2 | 0)) { if (typeof l !== "object") { - throw { - RE_EXN_ID: "Invalid_argument", - _1: "Map.bal", - Error: new Error() - }; + return Pervasives.invalid_arg("Map.bal"); } let lr = l._3; let ld = l._2; @@ -56,15 +53,11 @@ function bal(l, x, d, r) { let ll = l._0; if (height(ll) >= height(lr)) { return create(ll, lv, ld, create(lr, x, d, r)); - } - if (typeof lr === "object") { + } 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)); } - throw { - RE_EXN_ID: "Invalid_argument", - _1: "Map.bal", - Error: new Error() - }; } if (hr <= (hl + 2 | 0)) { return { @@ -77,11 +70,7 @@ function bal(l, x, d, r) { }; } if (typeof r !== "object") { - throw { - RE_EXN_ID: "Invalid_argument", - _1: "Map.bal", - Error: new Error() - }; + return Pervasives.invalid_arg("Map.bal"); } let rr = r._3; let rd = r._2; @@ -89,15 +78,11 @@ function bal(l, x, d, r) { let rl = r._0; if (height(rr) >= height(rl)) { return create(create(l, x, d, rl), rv, rd, rr); - } - if (typeof rl === "object") { + } 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)); } - throw { - RE_EXN_ID: "Invalid_argument", - _1: "Map.bal", - Error: new Error() - }; } function add(x, data, compare, x_) { diff --git a/tests/tests/src/earger_curry_test.js b/tests/tests/src/earger_curry_test.js index c2e3cea1be..f8a1a9d400 100644 --- a/tests/tests/src/earger_curry_test.js +++ b/tests/tests/src/earger_curry_test.js @@ -3,6 +3,7 @@ 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); @@ -23,11 +24,7 @@ function init(l, f) { return []; } if (l < 0) { - throw { - RE_EXN_ID: "Invalid_argument", - _1: "Array.init", - Error: new Error() - }; + return Pervasives.invalid_arg("Array.init"); } let res = Belt_Array.make(l, f$1(0)); for (let i = 1; i < l; ++i) { diff --git a/tests/tests/src/ext_array_test.js b/tests/tests/src/ext_array_test.js index af70707333..40e4a2ffea 100644 --- a/tests/tests/src/ext_array_test.js +++ b/tests/tests/src/ext_array_test.js @@ -3,6 +3,7 @@ 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) { @@ -104,25 +105,19 @@ function filter_map(f, a) { function range(from, to_) { if (from > to_) { - throw { - RE_EXN_ID: "Invalid_argument", - _1: "Ext_array_test.range", - Error: new Error() - }; + return Pervasives.invalid_arg("Ext_array_test.range"); + } else { + return Belt_Array.init((to_ - from | 0) + 1 | 0, i => i + from | 0); } - 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) { - throw { - RE_EXN_ID: "Invalid_argument", - _1: "Ext_array_test.map2i", - Error: new Error() - }; + return Pervasives.invalid_arg("Ext_array_test.map2i"); + } else { + return Belt_Array.mapWithIndex(a, (i, a) => f(i, a, b[i])); } - return Belt_Array.mapWithIndex(a, (i, a) => f(i, a, b[i])); } function tolist_aux(a, f, _i, _res) { diff --git a/tests/tests/src/flexible_array_test.js b/tests/tests/src/flexible_array_test.js index 8b53d5b11a..c08e701a7b 100644 --- a/tests/tests/src/flexible_array_test.js +++ b/tests/tests/src/flexible_array_test.js @@ -2,6 +2,7 @@ '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"); @@ -163,12 +164,9 @@ function length(param) { function get(param, i) { if (i >= 0 && i < param[1]) { return sub(param[0], i + 1 | 0); + } else { + return Pervasives.invalid_arg("Array.get"); } - throw { - RE_EXN_ID: "Invalid_argument", - _1: "Array.get", - Error: new Error() - }; } function set(param, i, v) { @@ -178,12 +176,9 @@ function set(param, i, v) { update(param[0], i + 1 | 0, v), k ]; + } else { + return Pervasives.invalid_arg("Array.set"); } - throw { - RE_EXN_ID: "Invalid_argument", - _1: "Array.set", - Error: new Error() - }; } function push_front(param, v) { @@ -200,12 +195,9 @@ function pop_front(param) { lorem(param[0]), k - 1 | 0 ]; + } else { + return Pervasives.invalid_arg("Array.pop_front"); } - throw { - RE_EXN_ID: "Invalid_argument", - _1: "Array.pop_front", - Error: new Error() - }; } function push_back(param, v) { @@ -223,12 +215,9 @@ function pop_back(param) { $$delete(param[0], k), k - 1 | 0 ]; + } else { + return Pervasives.invalid_arg("Array.pop_back"); } - throw { - RE_EXN_ID: "Invalid_argument", - _1: "Array.pop_back", - Error: new Error() - }; } function filter_from(i, p, s) { diff --git a/tests/tests/src/gpr_1423_app_test.js b/tests/tests/src/gpr_1423_app_test.js index f3e36863a1..ab493e1656 100644 --- a/tests/tests/src/gpr_1423_app_test.js +++ b/tests/tests/src/gpr_1423_app_test.js @@ -2,6 +2,7 @@ 'use strict'; let Mt = require("./mt.js"); +let Gpr_1423_nav = require("./gpr_1423_nav.js"); let suites = { contents: /* [] */0 @@ -30,13 +31,13 @@ function foo(f) { console.log(f("a1", undefined)); } -foo((none, extra) => none + "a2"); +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", "a1a2", "a1a2"); +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); diff --git a/tests/tests/src/gpr_2316_test.js b/tests/tests/src/gpr_2316_test.js index 75a2d85d7a..d899c5ae1c 100644 --- a/tests/tests/src/gpr_2316_test.js +++ b/tests/tests/src/gpr_2316_test.js @@ -2,6 +2,7 @@ '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 = { @@ -30,11 +31,8 @@ function eq(loc, x, y) { let y; try { - throw { - RE_EXN_ID: "Failure", - _1: "boo", - Error: new Error() - }; + Pervasives.failwith("boo"); + y = undefined; } catch (raw_msg) { let msg = Primitive_exceptions.internalToException(raw_msg); if (msg.RE_EXN_ID === "Failure") { @@ -48,12 +46,11 @@ let x; let exit = 0; +let e; + try { - throw { - RE_EXN_ID: "Failure", - _1: "boo", - Error: new Error() - }; + 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") { diff --git a/tests/tests/src/gpr_3865.js b/tests/tests/src/gpr_3865.js index 1eb9de4f87..332dd4de57 100644 --- a/tests/tests/src/gpr_3865.js +++ b/tests/tests/src/gpr_3865.js @@ -1,16 +1,17 @@ // 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_foo; +let B = Gpr_3865_bar.Make(Gpr_3865_foo); console.log(Gpr_3865_foo.$$return); -console.log(Gpr_3865_foo.$$return); +console.log(B.$$return); let F; exports.F = F; exports.B = B; -/* Not a pure module */ +/* B Not a pure module */ diff --git a/tests/tests/src/gpr_4265_test.js b/tests/tests/src/gpr_4265_test.js index 30f8a89405..639981fc25 100644 --- a/tests/tests/src/gpr_4265_test.js +++ b/tests/tests/src/gpr_4265_test.js @@ -3,7 +3,6 @@ let Mt = require("./mt.js"); let Belt_MutableMapInt = require("rescript/lib/js/belt_MutableMapInt.js"); -let Belt_internalMapInt = require("rescript/lib/js/belt_internalMapInt.js"); let suites = { contents: /* [] */0 @@ -17,9 +16,7 @@ function eq(loc, x, y) { Mt.eq_suites(test_id, suites, loc, x, y); } -let mockMap = { - data: undefined -}; +let mockMap = Belt_MutableMapInt.make(); function add(id) { Belt_MutableMapInt.set(mockMap, id, id); @@ -38,7 +35,7 @@ add(486); Belt_MutableMapInt.remove(mockMap, 1726); -let n1 = Belt_internalMapInt.getExn(mockMap.data, 6667); +let n1 = Belt_MutableMapInt.getExn(mockMap, 6667); eq("File \"gpr_4265_test.res\", line 18, characters 3-10", n, n1); @@ -52,4 +49,4 @@ exports.add = add; exports.remove = remove; exports.n = n; exports.n1 = n1; -/* Not a pure module */ +/* mockMap Not a pure module */ diff --git a/tests/tests/src/hello_res.js b/tests/tests/src/hello_res.js index 34fadda626..8c6da225f1 100644 --- a/tests/tests/src/hello_res.js +++ b/tests/tests/src/hello_res.js @@ -18,7 +18,7 @@ let a = b - 1 | 0; console.log("hello, res"); -Belt_List.length({ +Belt_List.add(/* [] */0, Belt_List.length({ hd: 1, tl: { hd: 2, @@ -27,7 +27,7 @@ Belt_List.length({ tl: /* [] */0 } } -}); +})); console.log(3); diff --git a/tests/tests/src/inline_const_test.js b/tests/tests/src/inline_const_test.js index 62db03c4f0..a04ff5fd8d 100644 --- a/tests/tests/src/inline_const_test.js +++ b/tests/tests/src/inline_const_test.js @@ -16,7 +16,7 @@ function eq(loc, x, y) { Mt.eq_suites(test_id, suites, loc, x, y); } -let H = {}; +let H = Inline_const.N1({}); let f = "hello"; @@ -64,4 +64,4 @@ exports.f4 = f4; exports.f5 = f5; exports.f6 = f6; exports.f7 = f7; -/* Not a pure module */ +/* H Not a pure module */ diff --git a/tests/tests/src/inline_map2_test.js b/tests/tests/src/inline_map2_test.js index 207455b1c8..baf869cdab 100644 --- a/tests/tests/src/inline_map2_test.js +++ b/tests/tests/src/inline_map2_test.js @@ -3,6 +3,7 @@ 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"); @@ -42,11 +43,7 @@ function Make(Ord) { hr = typeof r !== "object" ? 0 : r._4; if (hl > (hr + 2 | 0)) { if (typeof l !== "object") { - throw { - RE_EXN_ID: "Invalid_argument", - _1: "Map.bal", - Error: new Error() - }; + return Pervasives.invalid_arg("Map.bal"); } let lr = l._3; let ld = l._2; @@ -54,15 +51,11 @@ function Make(Ord) { let ll = l._0; if (height(ll) >= height(lr)) { return create(ll, lv, ld, create(lr, x, d, r)); - } - if (typeof lr === "object") { + } 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)); } - throw { - RE_EXN_ID: "Invalid_argument", - _1: "Map.bal", - Error: new Error() - }; } if (hr <= (hl + 2 | 0)) { return { @@ -75,11 +68,7 @@ function Make(Ord) { }; } if (typeof r !== "object") { - throw { - RE_EXN_ID: "Invalid_argument", - _1: "Map.bal", - Error: new Error() - }; + return Pervasives.invalid_arg("Map.bal"); } let rr = r._3; let rd = r._2; @@ -87,15 +76,11 @@ function Make(Ord) { let rl = r._0; if (height(rr) >= height(rl)) { return create(create(l, x, d, rl), rv, rd, rr); - } - if (typeof rl === "object") { + } 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)); } - throw { - RE_EXN_ID: "Invalid_argument", - _1: "Map.bal", - Error: new Error() - }; }; let is_empty = x => { if (typeof x !== "object") { @@ -208,11 +193,7 @@ function Make(Ord) { }; let remove_min_binding = x => { if (typeof x !== "object") { - throw { - RE_EXN_ID: "Invalid_argument", - _1: "Map.remove_min_elt", - Error: new Error() - }; + return Pervasives.invalid_arg("Map.remove_min_elt"); } let l = x._0; if (typeof l !== "object") { @@ -667,11 +648,7 @@ function bal(l, x, d, r) { hr = typeof r !== "object" ? 0 : r._4; if (hl > (hr + 2 | 0)) { if (typeof l !== "object") { - throw { - RE_EXN_ID: "Invalid_argument", - _1: "Map.bal", - Error: new Error() - }; + return Pervasives.invalid_arg("Map.bal"); } let lr = l._3; let ld = l._2; @@ -679,15 +656,11 @@ function bal(l, x, d, r) { let ll = l._0; if (height(ll) >= height(lr)) { return create(ll, lv, ld, create(lr, x, d, r)); - } - if (typeof lr === "object") { + } 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)); } - throw { - RE_EXN_ID: "Invalid_argument", - _1: "Map.bal", - Error: new Error() - }; } if (hr <= (hl + 2 | 0)) { return { @@ -700,11 +673,7 @@ function bal(l, x, d, r) { }; } if (typeof r !== "object") { - throw { - RE_EXN_ID: "Invalid_argument", - _1: "Map.bal", - Error: new Error() - }; + return Pervasives.invalid_arg("Map.bal"); } let rr = r._3; let rd = r._2; @@ -712,15 +681,11 @@ function bal(l, x, d, r) { let rl = r._0; if (height(rr) >= height(rl)) { return create(create(l, x, d, rl), rv, rd, rr); - } - if (typeof rl === "object") { + } 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)); } - throw { - RE_EXN_ID: "Invalid_argument", - _1: "Map.bal", - Error: new Error() - }; } function is_empty(x) { @@ -840,11 +805,7 @@ function max_binding(_x) { function remove_min_binding(x) { if (typeof x !== "object") { - throw { - RE_EXN_ID: "Invalid_argument", - _1: "Map.remove_min_elt", - Error: new Error() - }; + return Pervasives.invalid_arg("Map.remove_min_elt"); } let l = x._0; if (typeof l !== "object") { @@ -1349,11 +1310,7 @@ function bal$1(l, x, d, r) { hr = typeof r !== "object" ? 0 : r._4; if (hl > (hr + 2 | 0)) { if (typeof l !== "object") { - throw { - RE_EXN_ID: "Invalid_argument", - _1: "Map.bal", - Error: new Error() - }; + return Pervasives.invalid_arg("Map.bal"); } let lr = l._3; let ld = l._2; @@ -1361,15 +1318,11 @@ function bal$1(l, x, d, r) { let ll = l._0; if (height$1(ll) >= height$1(lr)) { return create$1(ll, lv, ld, create$1(lr, x, d, r)); - } - if (typeof lr === "object") { + } 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)); } - throw { - RE_EXN_ID: "Invalid_argument", - _1: "Map.bal", - Error: new Error() - }; } if (hr <= (hl + 2 | 0)) { return { @@ -1382,11 +1335,7 @@ function bal$1(l, x, d, r) { }; } if (typeof r !== "object") { - throw { - RE_EXN_ID: "Invalid_argument", - _1: "Map.bal", - Error: new Error() - }; + return Pervasives.invalid_arg("Map.bal"); } let rr = r._3; let rd = r._2; @@ -1394,15 +1343,11 @@ function bal$1(l, x, d, r) { let rl = r._0; if (height$1(rr) >= height$1(rl)) { return create$1(create$1(l, x, d, rl), rv, rd, rr); - } - if (typeof rl === "object") { + } 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)); } - throw { - RE_EXN_ID: "Invalid_argument", - _1: "Map.bal", - Error: new Error() - }; } function is_empty$1(x) { @@ -1522,11 +1467,7 @@ function max_binding$1(_x) { function remove_min_binding$1(x) { if (typeof x !== "object") { - throw { - RE_EXN_ID: "Invalid_argument", - _1: "Map.remove_min_elt", - Error: new Error() - }; + return Pervasives.invalid_arg("Map.remove_min_elt"); } let l = x._0; if (typeof l !== "object") { diff --git a/tests/tests/src/inline_map_test.js b/tests/tests/src/inline_map_test.js index 6da2b307a3..dd0942860a 100644 --- a/tests/tests/src/inline_map_test.js +++ b/tests/tests/src/inline_map_test.js @@ -3,6 +3,7 @@ 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) { @@ -33,11 +34,7 @@ function bal(l, x, d, r) { hr = typeof r !== "object" ? 0 : r._4; if (hl > (hr + 2 | 0)) { if (typeof l !== "object") { - throw { - RE_EXN_ID: "Invalid_argument", - _1: "Map.bal", - Error: new Error() - }; + return Pervasives.invalid_arg("Map.bal"); } let lr = l._3; let ld = l._2; @@ -45,15 +42,11 @@ function bal(l, x, d, r) { let ll = l._0; if (height(ll) >= height(lr)) { return create(ll, lv, ld, create(lr, x, d, r)); - } - if (typeof lr === "object") { + } 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)); } - throw { - RE_EXN_ID: "Invalid_argument", - _1: "Map.bal", - Error: new Error() - }; } if (hr <= (hl + 2 | 0)) { return { @@ -66,11 +59,7 @@ function bal(l, x, d, r) { }; } if (typeof r !== "object") { - throw { - RE_EXN_ID: "Invalid_argument", - _1: "Map.bal", - Error: new Error() - }; + return Pervasives.invalid_arg("Map.bal"); } let rr = r._3; let rd = r._2; @@ -78,15 +67,11 @@ function bal(l, x, d, r) { let rl = r._0; if (height(rr) >= height(rl)) { return create(create(l, x, d, rl), rv, rd, rr); - } - if (typeof rl === "object") { + } 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)); } - throw { - RE_EXN_ID: "Invalid_argument", - _1: "Map.bal", - Error: new Error() - }; } function add(x, data, x_) { diff --git a/tests/tests/src/int_map.js b/tests/tests/src/int_map.js index c3a14ba60c..cd29ea61bd 100644 --- a/tests/tests/src/int_map.js +++ b/tests/tests/src/int_map.js @@ -1,21 +1,17 @@ // 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 = { +let IntCmp = Belt_Id.MakeComparable({ cmp: cmp -}; +}); -let m_cmp = IntCmp.cmp; - -let m = { - cmp: m_cmp, - data: undefined -}; +let m = Belt_Map.make(IntCmp); let m$1 = Belt_Map.set(m, 0, "test"); diff --git a/tests/tests/src/js_exception_catch_test.js b/tests/tests/src/js_exception_catch_test.js index 9d89afdca8..961acada64 100644 --- a/tests/tests/src/js_exception_catch_test.js +++ b/tests/tests/src/js_exception_catch_test.js @@ -3,6 +3,7 @@ let Mt = require("./mt.js"); let Js_exn = require("rescript/lib/js/js_exn.js"); +let Pervasives = require("rescript/lib/js/pervasives.js"); let Primitive_exceptions = require("rescript/lib/js/primitive_exceptions.js"); let suites = { @@ -124,21 +125,9 @@ eq("File \"js_exception_catch_test.res\", line 45, characters 5-12", test(() => }; }), "Not_found"); -eq("File \"js_exception_catch_test.res\", line 46, characters 5-12", test(() => { - throw { - RE_EXN_ID: "Invalid_argument", - _1: "x", - Error: new Error() - }; -}), "Invalid_argument"); +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(() => { - throw { - RE_EXN_ID: "Invalid_argument", - _1: "", - Error: new Error() - }; -}), "Invalid_any"); +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 { @@ -181,17 +170,9 @@ eq("File \"js_exception_catch_test.res\", line 52, characters 5-12", test(() => }; }), "C_any"); -eq("File \"js_exception_catch_test.res\", line 53, characters 5-12", test(() => { - throw new Error("x"); -}), "Js_error"); +eq("File \"js_exception_catch_test.res\", line 53, characters 5-12", test(() => Js_exn.raiseError("x")), "Js_error"); -eq("File \"js_exception_catch_test.res\", line 54, characters 5-12", test(() => { - throw { - RE_EXN_ID: "Failure", - _1: "x", - Error: new Error() - }; -}), "Any"); +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); diff --git a/tests/tests/src/js_option_test.js b/tests/tests/src/js_option_test.js index af3d8a471a..6063f2a913 100644 --- a/tests/tests/src/js_option_test.js +++ b/tests/tests/src/js_option_test.js @@ -13,7 +13,7 @@ let option_suites_0 = [ param => ({ TAG: "Eq", _0: true, - _1: true + _1: Js_option.isSome(1) }) ]; @@ -23,7 +23,7 @@ let option_suites_1 = { param => ({ TAG: "Eq", _0: false, - _1: false + _1: Js_option.isSome(undefined) }) ], tl: { @@ -32,7 +32,7 @@ let option_suites_1 = { param => ({ TAG: "Eq", _0: false, - _1: false + _1: Js_option.isNone(1) }) ], tl: { @@ -41,7 +41,7 @@ let option_suites_1 = { param => ({ TAG: "Eq", _0: true, - _1: true + _1: Js_option.isNone(undefined) }) ], tl: { diff --git a/tests/tests/src/js_string_test.js b/tests/tests/src/js_string_test.js index f04e75c9c0..bf7b1a16f7 100644 --- a/tests/tests/src/js_string_test.js +++ b/tests/tests/src/js_string_test.js @@ -2,6 +2,7 @@ '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"); @@ -419,7 +420,7 @@ let suites_1 = { ":", "c" ], - _1: "a#b#:c".split(/(#)(:)?/) + _1: Js_string.splitByRe(/(#)(:)?/, "a#b#:c") }) ], tl: { @@ -432,7 +433,7 @@ let suites_1 = { "#", undefined ], - _1: "a#b#:c".split(/(#)(:)?/, 3) + _1: Js_string.splitByReAtMost(/(#)(:)?/, 3, "a#b#:c") }) ], tl: { diff --git a/tests/tests/src/mario_game.js b/tests/tests/src/mario_game.js index a183b1dd7a..e9a2900d90 100644 --- a/tests/tests/src/mario_game.js +++ b/tests/tests/src/mario_game.js @@ -1497,11 +1497,7 @@ function game_win(ctx) { ctx.fillStyle = "white"; ctx.font = "20px 'Press Start 2P'"; ctx.fillText("You win!", 180, 128); - throw { - RE_EXN_ID: "Failure", - _1: "Game over.", - Error: new Error() - }; + return Pervasives.failwith("Game over."); } function game_loss(ctx) { @@ -1511,11 +1507,7 @@ function game_loss(ctx) { ctx.fillStyle = "white"; ctx.font = "20px 'Press Start 2P'"; ctx.fillText("GAME OVER. You lose!", 60, 128); - throw { - RE_EXN_ID: "Failure", - _1: "Game over.", - Error: new Error() - }; + return Pervasives.failwith("Game over."); } let Draw = { @@ -2475,11 +2467,7 @@ function choose_enemy_typ(typ) { case 2 : return "Goomba"; default: - throw { - RE_EXN_ID: "Failure", - _1: "Shouldn't reach here", - Error: new Error() - }; + return Pervasives.failwith("Shouldn't reach here"); } } @@ -2499,11 +2487,7 @@ function choose_sblock_typ(typ) { case 4 : return "Ground"; default: - throw { - RE_EXN_ID: "Failure", - _1: "Shouldn't reach here", - Error: new Error() - }; + return Pervasives.failwith("Shouldn't reach here"); } } @@ -3014,11 +2998,7 @@ function choose_block_pattern(blockw, blockh, cbx, cby, prob) { tl: /* [] */0 }; default: - throw { - RE_EXN_ID: "Failure", - _1: "Shouldn't reach here", - Error: new Error() - }; + return Pervasives.failwith("Shouldn't reach here"); } } @@ -3281,17 +3261,7 @@ let loadCount = { function load(param) { let canvas_id = "canvas"; let el = document.getElementById(canvas_id); - let canvas; - if (el !== null) { - canvas = el; - } else { - console.log("cant find canvas " + canvas_id); - throw { - RE_EXN_ID: "Failure", - _1: "fail", - Error: new Error() - }; - } + 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); diff --git a/tests/tests/src/mt.js b/tests/tests/src/mt.js index fd42b6837b..efffe653b6 100644 --- a/tests/tests/src/mt.js +++ b/tests/tests/src/mt.js @@ -5,6 +5,7 @@ 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, ""); @@ -221,10 +222,10 @@ function old_from_promise_suites_donotuse(name, suites) { if (is_mocha()) { describe(name, () => Belt_List.forEach(suites, param => { let code = param[1]; - it(param[0], () => code.then(x => { + it(param[0], () => Js_promise.then_(x => { handleCode(x); return val_unit; - })); + }, code)); })); } else { console.log("promise suites"); diff --git a/tests/tests/src/reactDOMRe.js b/tests/tests/src/reactDOMRe.js index dee8919f57..c63357a109 100644 --- a/tests/tests/src/reactDOMRe.js +++ b/tests/tests/src/reactDOMRe.js @@ -2,6 +2,7 @@ '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) { @@ -81,10 +82,10 @@ function hydrateToElementWithId(reactElement, id) { let Ref = {}; function createElementVariadic(domClassName, props, children) { - let variadicArguments = [ + let variadicArguments = Js_array.concat(children, [ domClassName, props - ].concat(children); + ]); return React.createElement.apply(null, variadicArguments); } diff --git a/tests/tests/src/reasonReact.js b/tests/tests/src/reasonReact.js index afbce1d035..361212c8ed 100644 --- a/tests/tests/src/reasonReact.js +++ b/tests/tests/src/reasonReact.js @@ -2,12 +2,13 @@ 'use strict'; let React = require("react"); +let Js_array = require("rescript/lib/js/js_array.js"); function createDomElement(s, props, children) { - let vararg = [ + let vararg = Js_array.concat(children, [ s, props - ].concat(children); + ]); return React.createElement.apply(null, vararg); } @@ -97,10 +98,10 @@ function wrapJsForReason(reactClass, props, children) { ref: extra$1, key: extra }); - let varargs = [ + let varargs = Js_array.concat(children, [ reactClass, props$1 - ].concat(children); + ]); return React.createElement.apply(null, varargs); }; return { diff --git a/tests/tests/src/reasonReactRouter.js b/tests/tests/src/reasonReactRouter.js index 2df6d93fd1..767a4b64a3 100644 --- a/tests/tests/src/reasonReactRouter.js +++ b/tests/tests/src/reasonReactRouter.js @@ -2,6 +2,7 @@ '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) { @@ -24,10 +25,10 @@ function path() { case "/" : return /* [] */0; default: - let raw$1 = raw.slice(1); + let raw$1 = Js_string.sliceToEnd(1, raw); let match = raw$1[raw$1.length - 1 | 0]; - let raw$2 = match === "/" ? raw$1.slice(0, -1) : raw$1; - let a = raw$2.split("/"); + 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) { @@ -57,7 +58,7 @@ function hash() { case "#" : return ""; default: - return raw.slice(1); + return Js_string.sliceToEnd(1, raw); } } @@ -72,7 +73,7 @@ function search() { case "?" : return ""; default: - return raw.slice(1); + return Js_string.sliceToEnd(1, raw); } } diff --git a/tests/tests/src/set_gen.js b/tests/tests/src/set_gen.js index 3becff0e2e..83031c9875 100644 --- a/tests/tests/src/set_gen.js +++ b/tests/tests/src/set_gen.js @@ -317,11 +317,7 @@ function internal_bal(l, v, r) { function remove_min_elt(x) { if (typeof x !== "object") { - throw { - RE_EXN_ID: "Invalid_argument", - _1: "Set.remove_min_elt", - Error: new Error() - }; + return Pervasives.invalid_arg("Set.remove_min_elt"); } let l = x._0; if (typeof l !== "object") { diff --git a/tests/tests/src/string_set.js b/tests/tests/src/string_set.js index cc6a15abcf..63c209aee1 100644 --- a/tests/tests/src/string_set.js +++ b/tests/tests/src/string_set.js @@ -241,7 +241,7 @@ function find(x, _tree) { function of_list(l) { if (!l) { - return "Empty"; + return Set_gen.empty; } let match = l.tl; let x0 = l.hd; @@ -272,7 +272,7 @@ function of_list(l) { } function of_array(l) { - return Belt_Array.reduceReverse(l, "Empty", (acc, x) => add(x, acc)); + return Belt_Array.reduceReverse(l, Set_gen.empty, (acc, x) => add(x, acc)); } function invariant(t) { @@ -280,7 +280,7 @@ function invariant(t) { return Set_gen.is_ordered(compare_elt, t); } -let empty = "Empty"; +let empty = Set_gen.empty; let is_empty = Set_gen.is_empty; diff --git a/tests/tests/src/test_list.js b/tests/tests/src/test_list.js index 3d027ed08f..7b3a88a18f 100644 --- a/tests/tests/src/test_list.js +++ b/tests/tests/src/test_list.js @@ -24,51 +24,37 @@ function length(l) { function hd(x) { if (x) { return x.hd; + } else { + return Pervasives.failwith("hd"); } - throw { - RE_EXN_ID: "Failure", - _1: "hd", - Error: new Error() - }; } function tl(x) { if (x) { return x.tl; + } else { + return Pervasives.failwith("tl"); } - throw { - RE_EXN_ID: "Failure", - _1: "tl", - Error: new Error() - }; } function nth(l, n) { if (n < 0) { - throw { - RE_EXN_ID: "Invalid_argument", - _1: "List.nth", - Error: new Error() - }; + 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) { - if (n$1 === 0) { - return l$1.hd; - } - _n = n$1 - 1 | 0; - _l = l$1.tl; - continue; + if (!l$1) { + return Pervasives.failwith("nth"); } - throw { - RE_EXN_ID: "Failure", - _1: "nth", - Error: new Error() - }; + if (n$1 === 0) { + return l$1.hd; + } + _n = n$1 - 1 | 0; + _l = l$1.tl; + continue; }; } @@ -194,27 +180,20 @@ function fold_right(f, l, accu) { } function map2(f, l1, l2) { - if (l1) { + if (!l1) { if (l2) { - let r = f(l1.hd, l2.hd); - return { - hd: r, - tl: map2(f, l1.tl, l2.tl) - }; + return Pervasives.invalid_arg("List.map2"); + } else { + return /* [] */0; } - throw { - RE_EXN_ID: "Invalid_argument", - _1: "List.map2", - Error: new Error() - }; } if (!l2) { - return /* [] */0; + return Pervasives.invalid_arg("List.map2"); } - throw { - RE_EXN_ID: "Invalid_argument", - _1: "List.map2", - Error: new Error() + let r = f(l1.hd, l2.hd); + return { + hd: r, + tl: map2(f, l1.tl, l2.tl) }; } @@ -226,30 +205,23 @@ function rev_map2(f, l1, l2) { let l2$1 = _l2; let l1$1 = _l1; let accu = _accu; - if (l1$1) { + if (!l1$1) { if (l2$1) { - _l2 = l2$1.tl; - _l1 = l1$1.tl; - _accu = { - hd: f(l1$1.hd, l2$1.hd), - tl: accu - }; - continue; + return Pervasives.invalid_arg("List.rev_map2"); + } else { + return accu; } - throw { - RE_EXN_ID: "Invalid_argument", - _1: "List.rev_map2", - Error: new Error() - }; } - if (l2$1) { - throw { - RE_EXN_ID: "Invalid_argument", - _1: "List.rev_map2", - Error: new Error() - }; + if (!l2$1) { + return Pervasives.invalid_arg("List.rev_map2"); } - return accu; + _l2 = l2$1.tl; + _l1 = l1$1.tl; + _accu = { + hd: f(l1$1.hd, l2$1.hd), + tl: accu + }; + continue; }; } @@ -257,27 +229,20 @@ function iter2(f, _l1, _l2) { while (true) { let l2 = _l2; let l1 = _l1; - if (l1) { + if (!l1) { if (l2) { - f(l1.hd, l2.hd); - _l2 = l2.tl; - _l1 = l1.tl; - continue; + return Pervasives.invalid_arg("List.iter2"); + } else { + return; } - throw { - RE_EXN_ID: "Invalid_argument", - _1: "List.iter2", - Error: new Error() - }; } if (!l2) { - return; + return Pervasives.invalid_arg("List.iter2"); } - throw { - RE_EXN_ID: "Invalid_argument", - _1: "List.iter2", - Error: new Error() - }; + f(l1.hd, l2.hd); + _l2 = l2.tl; + _l1 = l1.tl; + continue; }; } @@ -286,27 +251,20 @@ function fold_left2(f, _accu, _l1, _l2) { let l2 = _l2; let l1 = _l1; let accu = _accu; - if (l1) { + if (!l1) { if (l2) { - _l2 = l2.tl; - _l1 = l1.tl; - _accu = f(accu, l1.hd, l2.hd); - continue; + return Pervasives.invalid_arg("List.fold_left2"); + } else { + return accu; } - throw { - RE_EXN_ID: "Invalid_argument", - _1: "List.fold_left2", - Error: new Error() - }; } - if (l2) { - throw { - RE_EXN_ID: "Invalid_argument", - _1: "List.fold_left2", - Error: new Error() - }; + if (!l2) { + return Pervasives.invalid_arg("List.fold_left2"); } - return accu; + _l2 = l2.tl; + _l1 = l1.tl; + _accu = f(accu, l1.hd, l2.hd); + continue; }; } @@ -314,21 +272,14 @@ 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"); } - throw { - RE_EXN_ID: "Invalid_argument", - _1: "List.fold_right2", - Error: new Error() - }; - } - if (l2) { - throw { - RE_EXN_ID: "Invalid_argument", - _1: "List.fold_right2", - Error: new Error() - }; + } else if (l2) { + return Pervasives.invalid_arg("List.fold_right2"); + } else { + return accu; } - return accu; } function for_all(p, _x) { @@ -363,29 +314,22 @@ function for_all2(p, _l1, _l2) { while (true) { let l2 = _l2; let l1 = _l1; - if (l1) { + if (!l1) { if (l2) { - if (!p(l1.hd, l2.hd)) { - return false; - } - _l2 = l2.tl; - _l1 = l1.tl; - continue; + return Pervasives.invalid_arg("List.for_all2"); + } else { + return true; } - throw { - RE_EXN_ID: "Invalid_argument", - _1: "List.for_all2", - Error: new Error() - }; } if (!l2) { - return true; + return Pervasives.invalid_arg("List.for_all2"); } - throw { - RE_EXN_ID: "Invalid_argument", - _1: "List.for_all2", - Error: new Error() - }; + if (!p(l1.hd, l2.hd)) { + return false; + } + _l2 = l2.tl; + _l1 = l1.tl; + continue; }; } @@ -393,29 +337,22 @@ function exists2(p, _l1, _l2) { while (true) { let l2 = _l2; let l1 = _l1; - if (l1) { + if (!l1) { if (l2) { - if (p(l1.hd, l2.hd)) { - return true; - } - _l2 = l2.tl; - _l1 = l1.tl; - continue; + return Pervasives.invalid_arg("List.exists2"); + } else { + return false; } - throw { - RE_EXN_ID: "Invalid_argument", - _1: "List.exists2", - Error: new Error() - }; } if (!l2) { - return false; + return Pervasives.invalid_arg("List.exists2"); } - throw { - RE_EXN_ID: "Invalid_argument", - _1: "List.exists2", - Error: new Error() - }; + if (p(l1.hd, l2.hd)) { + return true; + } + _l2 = l2.tl; + _l1 = l1.tl; + continue; }; } @@ -651,21 +588,14 @@ function combine(l1, l2) { ], tl: combine(l1.tl, l2.tl) }; + } else { + return Pervasives.invalid_arg("List.combine"); } - throw { - RE_EXN_ID: "Invalid_argument", - _1: "List.combine", - Error: new Error() - }; - } - if (!l2) { + } else if (l2) { + return Pervasives.invalid_arg("List.combine"); + } else { return /* [] */0; } - throw { - RE_EXN_ID: "Invalid_argument", - _1: "List.combine", - Error: new Error() - }; } function merge(cmp, l1, l2) { diff --git a/tests/tests/src/test_set.js b/tests/tests/src/test_set.js index fbfe093bc8..65f096c409 100644 --- a/tests/tests/src/test_set.js +++ b/tests/tests/src/test_set.js @@ -2,6 +2,7 @@ '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 => { @@ -31,26 +32,18 @@ function Make(Ord) { hr = typeof r !== "object" ? 0 : r._3; if (hl > (hr + 2 | 0)) { if (typeof l !== "object") { - throw { - RE_EXN_ID: "Invalid_argument", - _1: "Set.bal", - Error: new Error() - }; + 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)); - } - if (typeof lr === "object") { + } 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)); } - throw { - RE_EXN_ID: "Invalid_argument", - _1: "Set.bal", - Error: new Error() - }; } if (hr <= (hl + 2 | 0)) { return { @@ -62,26 +55,18 @@ function Make(Ord) { }; } if (typeof r !== "object") { - throw { - RE_EXN_ID: "Invalid_argument", - _1: "Set.bal", - Error: new Error() - }; + 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); - } - if (typeof rl === "object") { + } 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)); } - throw { - RE_EXN_ID: "Invalid_argument", - _1: "Set.bal", - Error: new Error() - }; }; let add = (x, x_) => { if (typeof x_ !== "object") { @@ -179,11 +164,7 @@ function Make(Ord) { }; let remove_min_elt = x => { if (typeof x !== "object") { - throw { - RE_EXN_ID: "Invalid_argument", - _1: "Set.remove_min_elt", - Error: new Error() - }; + return Pervasives.invalid_arg("Set.remove_min_elt"); } let l = x._0; if (typeof l !== "object") { diff --git a/tests/tests/src/ticker.js b/tests/tests/src/ticker.js index d073ec425a..b60ae4edd5 100644 --- a/tests/tests/src/ticker.js +++ b/tests/tests/src/ticker.js @@ -155,35 +155,13 @@ function compute_update_sequences(all_tickers) { let l$1 = Belt_List.sort(l, (lhs, rhs) => { let x = lhs.rank; if (typeof x !== "object") { - if (x === "Uninitialized") { - throw { - RE_EXN_ID: "Failure", - _1: "All nodes should be ranked", - Error: new Error() - }; - } - throw { - RE_EXN_ID: "Failure", - _1: "All nodes should be ranked", - Error: new Error() - }; + 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 { - let y = rhs.rank; - if (typeof y === "object") { - return Primitive_int.compare(x._0, y._0); - } - if (y === "Uninitialized") { - throw { - RE_EXN_ID: "Failure", - _1: "All nodes should be ranked", - Error: new Error() - }; - } - throw { - RE_EXN_ID: "Failure", - _1: "All nodes should be ranked", - Error: new Error() - }; + return Primitive_int.compare(x._0, y._0); } }); return Belt_MapString.set(map, k, l$1); @@ -198,12 +176,9 @@ function process_quote(ticker_map, new_ticker, new_value) { 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"); } - throw { - RE_EXN_ID: "Failure", - _1: "Only single Market ticker should be udpated upon a new quote", - Error: new Error() - }; } let match$1 = match._0; let match$2 = match$1.lhs.value; @@ -234,162 +209,96 @@ function process_input_line(ticker_map, all_tickers, line) { }; }; let tokens = split("|", line); - if (tokens) { - switch (tokens.hd) { - case "Q" : - let match = tokens.tl; - if (match) { - let match$1 = match.tl; - if (match$1) { - if (match$1.tl) { - throw { - RE_EXN_ID: "Failure", - _1: "Invalid input line", - Error: new Error() - }; - } - 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); + 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 [ - all_tickers, - Primitive_option.some(ticker_map$1) + { + 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"); } - throw { - RE_EXN_ID: "Failure", - _1: "Invalid input line", - Error: new Error() - }; - } - throw { - RE_EXN_ID: "Failure", - _1: "Invalid input line", - Error: new Error() - }; - case "R" : - let match$2 = tokens.tl; - if (match$2) { - let match$3 = match$2.tl; - if (match$3) { - let ticker_name = match$2.hd; - switch (match$3.hd) { - case "+" : - let match$4 = match$3.tl; - if (match$4) { - let match$5 = match$4.tl; - if (match$5) { - if (match$5.tl) { - throw { - RE_EXN_ID: "Failure", - _1: "Invalid input line", - Error: new Error() - }; - } - return [ - { - hd: make_binary_op(ticker_name, match$4.hd, match$5.hd, "PLUS"), - tl: all_tickers - }, - ticker_map - ]; - } - throw { - RE_EXN_ID: "Failure", - _1: "Invalid input line", - Error: new Error() - }; - } - throw { - RE_EXN_ID: "Failure", - _1: "Invalid input line", - Error: new Error() - }; - case "-" : - let match$6 = match$3.tl; - if (match$6) { - let match$7 = match$6.tl; - if (match$7) { - if (match$7.tl) { - throw { - RE_EXN_ID: "Failure", - _1: "Invalid input line", - Error: new Error() - }; - } - return [ - { - hd: make_binary_op(ticker_name, match$6.hd, match$7.hd, "MINUS"), - tl: all_tickers - }, - ticker_map - ]; - } - throw { - RE_EXN_ID: "Failure", - _1: "Invalid input line", - Error: new Error() - }; - } - throw { - RE_EXN_ID: "Failure", - _1: "Invalid input line", - Error: new Error() - }; - case "S" : - if (match$3.tl) { - throw { - RE_EXN_ID: "Failure", - _1: "Invalid input line", - Error: new Error() - }; - } - return [ - { - hd: { - value: undefined, - rank: "Uninitialized", - ticker_name: ticker_name, - type_: "Market" - }, - tl: all_tickers - }, - ticker_map - ]; - default: - throw { - RE_EXN_ID: "Failure", - _1: "Invalid input line", - Error: new Error() - }; - } + 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 { - throw { - RE_EXN_ID: "Failure", - _1: "Invalid input line", - Error: new Error() - }; + return Pervasives.failwith("Invalid input line"); } - } else { - throw { - RE_EXN_ID: "Failure", - _1: "Invalid input line", - Error: new Error() - }; - } - default: - throw { - RE_EXN_ID: "Failure", - _1: "Invalid input line", - Error: new Error() - }; - } - } else { - throw { - RE_EXN_ID: "Failure", - _1: "Invalid input line", - Error: new Error() - }; + 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"); } } diff --git a/tests/tests_esmodule/rescript.json b/tests/tests_esmodule/rescript.json index 7434c44b96..c7dfdd6f05 100644 --- a/tests/tests_esmodule/rescript.json +++ b/tests/tests_esmodule/rescript.json @@ -12,7 +12,6 @@ "suffix": ".mjs" }, "bsc-flags": [ - "-bs-cross-module-opt", "-w -3-6-26-27-29-30-32..40-44-45-52-60-9-106+104", "-warn-error A" ]