|
| 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 Primitive_option from "@rescript/runtime/lib/es6/Primitive_option.mjs"; |
| 6 | + |
| 7 | +function nested(y) { |
| 8 | + if (y !== undefined) { |
| 9 | + return y; |
| 10 | + } else { |
| 11 | + return 0; |
| 12 | + } |
| 13 | +} |
| 14 | + |
| 15 | +function poly(y) { |
| 16 | + return [y]; |
| 17 | +} |
| 18 | + |
| 19 | +let calls = { |
| 20 | + contents: 0 |
| 21 | +}; |
| 22 | + |
| 23 | +function next() { |
| 24 | + calls.contents = calls.contents + 1 | 0; |
| 25 | + if (calls.contents > 1) { |
| 26 | + return calls.contents; |
| 27 | + } |
| 28 | +} |
| 29 | + |
| 30 | +function effectful() { |
| 31 | + let n = Primitive_option.some(next()); |
| 32 | + let n$1 = Primitive_option.valFromOption(n); |
| 33 | + if (n$1 !== undefined) { |
| 34 | + return n$1; |
| 35 | + } else { |
| 36 | + return 0; |
| 37 | + } |
| 38 | +} |
| 39 | + |
| 40 | +Mocha.describe("Option_known_some_test", () => { |
| 41 | + Mocha.test("nested payload", () => { |
| 42 | + Test_utils.eq("File \"option_known_some_test.res\", line 35, characters 7-14", 0, 0); |
| 43 | + Test_utils.eq("File \"option_known_some_test.res\", line 36, characters 7-14", 3, 3); |
| 44 | + }); |
| 45 | + Mocha.test("polymorphic payload", () => { |
| 46 | + Test_utils.eq("File \"option_known_some_test.res\", line 39, characters 7-14", [undefined], [undefined]); |
| 47 | + let v = Primitive_option.some(Primitive_option.some(undefined)); |
| 48 | + Test_utils.eq("File \"option_known_some_test.res\", line 40, characters 7-14", [Primitive_option.some(undefined)], [Primitive_option.valFromOption(v)]); |
| 49 | + Test_utils.eq("File \"option_known_some_test.res\", line 41, characters 7-14", [1], [1]); |
| 50 | + }); |
| 51 | + Mocha.test("payload with side effects", () => { |
| 52 | + Test_utils.eq("File \"option_known_some_test.res\", line 44, characters 7-14", 0, effectful()); |
| 53 | + Test_utils.eq("File \"option_known_some_test.res\", line 45, characters 7-14", 1, calls.contents); |
| 54 | + Test_utils.eq("File \"option_known_some_test.res\", line 46, characters 7-14", 2, effectful()); |
| 55 | + Test_utils.eq("File \"option_known_some_test.res\", line 47, characters 7-14", 2, calls.contents); |
| 56 | + }); |
| 57 | +}); |
| 58 | + |
| 59 | +export { |
| 60 | + nested, |
| 61 | + poly, |
| 62 | + calls, |
| 63 | + next, |
| 64 | + effectful, |
| 65 | +} |
| 66 | +/* Not a pure module */ |
0 commit comments