|
| 1 | +// Generated by ReScript, PLEASE EDIT WITH CARE |
| 2 | + |
| 3 | +import * as Mocha from "mocha"; |
| 4 | +import * as Test_utils from "./test_utils.mjs"; |
| 5 | +import * as Stdlib_List from "@rescript/runtime/lib/es6/Stdlib_List.mjs"; |
| 6 | +import * as Primitive_list from "@rescript/runtime/lib/es6/Primitive_list.mjs"; |
| 7 | +import * as Primitive_array from "@rescript/runtime/lib/es6/Primitive_array.mjs"; |
| 8 | + |
| 9 | +let log = { |
| 10 | + contents: /* [] */0 |
| 11 | +}; |
| 12 | + |
| 13 | +function note(s, v) { |
| 14 | + log.contents = {hd: s, tl: log.contents}; |
| 15 | + return v; |
| 16 | +} |
| 17 | + |
| 18 | +Mocha.describe("Spread_literal_test", () => { |
| 19 | + Mocha.test("array spreads keep items and spreads in order", () => { |
| 20 | + let a = [ |
| 21 | + 1, |
| 22 | + 2 |
| 23 | + ]; |
| 24 | + let b = [5]; |
| 25 | + Test_utils.eq("File \"spread_literal_test.res\", line 14, characters 7-14", Primitive_array.spread([ |
| 26 | + a, |
| 27 | + [ |
| 28 | + 3, |
| 29 | + 4 |
| 30 | + ], |
| 31 | + b, |
| 32 | + [6] |
| 33 | + ]), [ |
| 34 | + 1, |
| 35 | + 2, |
| 36 | + 3, |
| 37 | + 4, |
| 38 | + 5, |
| 39 | + 6 |
| 40 | + ]); |
| 41 | + Test_utils.eq("File \"spread_literal_test.res\", line 15, characters 7-14", Primitive_array.spread([ |
| 42 | + [0], |
| 43 | + a, |
| 44 | + [], |
| 45 | + b |
| 46 | + ]), [ |
| 47 | + 0, |
| 48 | + 1, |
| 49 | + 2, |
| 50 | + 5 |
| 51 | + ]); |
| 52 | + }); |
| 53 | + Mocha.test("list spreads keep items and spreads in order", () => { |
| 54 | + let xs = {hd: 1, tl: {hd: 2, tl: /* [] */0}}; |
| 55 | + let ys = {hd: 5, tl: /* [] */0}; |
| 56 | + Test_utils.eq("File \"spread_literal_test.res\", line 21, characters 7-14", Primitive_list.spread([ |
| 57 | + xs, |
| 58 | + {hd: 3, tl: ys}, |
| 59 | + {hd: 6, tl: /* [] */0} |
| 60 | + ]), {hd: 1, tl: {hd: 2, tl: {hd: 3, tl: {hd: 5, tl: {hd: 6, tl: /* [] */0}}}}}); |
| 61 | + Test_utils.eq("File \"spread_literal_test.res\", line 22, characters 7-14", Primitive_list.spread([ |
| 62 | + {hd: 0, tl: xs}, |
| 63 | + /* [] */0, |
| 64 | + {hd: 4, tl: ys} |
| 65 | + ]), {hd: 0, tl: {hd: 1, tl: {hd: 2, tl: {hd: 4, tl: {hd: 5, tl: /* [] */0}}}}}); |
| 66 | + Test_utils.eq("File \"spread_literal_test.res\", line 23, characters 7-14", {hd: 0, tl: xs}, {hd: 0, tl: {hd: 1, tl: {hd: 2, tl: /* [] */0}}}); |
| 67 | + }); |
| 68 | + Mocha.test("items and spreads are evaluated left to right", () => { |
| 69 | + log.contents = /* [] */0; |
| 70 | + let arr = Primitive_array.spread([ |
| 71 | + [note("a", 1)], |
| 72 | + note("b", [2]), |
| 73 | + [note("c", 3)] |
| 74 | + ]); |
| 75 | + let lst = Primitive_list.spread([ |
| 76 | + {hd: note("d", 4), tl: note("e", {hd: 5, tl: /* [] */0})}, |
| 77 | + {hd: note("f", 6), tl: /* [] */0} |
| 78 | + ]); |
| 79 | + Test_utils.eq("File \"spread_literal_test.res\", line 30, characters 7-14", [ |
| 80 | + arr, |
| 81 | + lst |
| 82 | + ], [ |
| 83 | + [ |
| 84 | + 1, |
| 85 | + 2, |
| 86 | + 3 |
| 87 | + ], |
| 88 | + {hd: 4, tl: {hd: 5, tl: {hd: 6, tl: /* [] */0}}} |
| 89 | + ]); |
| 90 | + Test_utils.eq("File \"spread_literal_test.res\", line 31, characters 7-14", Stdlib_List.reverse(log.contents), {hd: "a", tl: {hd: "b", tl: {hd: "c", tl: {hd: "d", tl: {hd: "e", tl: {hd: "f", tl: /* [] */0}}}}}}); |
| 91 | + }); |
| 92 | +}); |
| 93 | + |
| 94 | +export { |
| 95 | + log, |
| 96 | + note, |
| 97 | +} |
| 98 | +/* Not a pure module */ |
0 commit comments