// Generated by ReScript, PLEASE EDIT WITH CARE import * as Mocha from "mocha"; import * as Test_utils from "./test_utils.mjs"; import * as Stdlib_JsExn from "@rescript/runtime/lib/es6/Stdlib_JsExn.mjs"; import * as Inline_export from "./inline_export.mjs"; import * as Stdlib_JsError from "@rescript/runtime/lib/es6/Stdlib_JsError.mjs"; import * as Primitive_option from "@rescript/runtime/lib/es6/Primitive_option.mjs"; import * as Primitive_exceptions from "@rescript/runtime/lib/es6/Primitive_exceptions.mjs"; let mapped = 3; let flatMapped = 4; let nested = Primitive_option.some(undefined); let mappedNested = Primitive_option.some(Primitive_option.valFromOption(nested)); function mapValue(opt) { if (opt !== undefined) { return Primitive_option.some((x => x + 1 | 0)(Primitive_option.valFromOption(opt))); } } function flatMapValue(opt) { if (opt !== undefined) { let x = Primitive_option.valFromOption(opt); return x + 2 | 0; } } function forEachValue(opt, f) { if (opt !== undefined) { return f(Primitive_option.valFromOption(opt)); } } function filterValue(opt, p) { if (opt !== undefined && p(Primitive_option.valFromOption(opt))) { return opt; } } function mapOrValue(opt, $$default, f) { if (opt !== undefined) { return f(Primitive_option.valFromOption(opt)); } else { return $$default; } } function getOrValue(opt, $$default) { if (opt !== undefined) { return Primitive_option.valFromOption(opt); } else { return $$default; } } function orElseValue(opt, other) { if (opt !== undefined) { return opt; } else { return other; } } function isSomeValue(opt) { return opt !== undefined; } function isNoneValue(opt) { return opt === undefined; } let visited = []; visited.push(4); let fromOrdinary = Inline_export.ordinary(3, x => x + 1 | 0); let fromCatch; try { fromCatch = Stdlib_JsError.throwWithMessage("boom"); } catch (raw_e) { let e = Primitive_exceptions.internalToException(raw_e); fromCatch = e.RE_EXN_ID === "JsExn" ? Stdlib_JsExn.message(e._1) : undefined; } Mocha.describe("@inline across modules", () => { Mocha.test("Option helpers", () => { Test_utils.eq("File \"inline_export_test.res\", line 30, characters 7-14", mapped, 3); Test_utils.eq("File \"inline_export_test.res\", line 31, characters 7-14", flatMapped, 4); Test_utils.eq("File \"inline_export_test.res\", line 32, characters 7-14", mappedNested, Primitive_option.some(undefined)); Test_utils.eq("File \"inline_export_test.res\", line 33, characters 7-14", mapValue(2), 3); Test_utils.eq("File \"inline_export_test.res\", line 34, characters 7-14", mapValue(undefined), undefined); Test_utils.eq("File \"inline_export_test.res\", line 35, characters 7-14", flatMapValue(2), 4); Test_utils.eq("File \"inline_export_test.res\", line 36, characters 7-14", flatMapValue(undefined), undefined); visited.push(5); Test_utils.eq("File \"inline_export_test.res\", line 38, characters 7-14", visited, [ 4, 5 ]); }); Mocha.test("only marked exports are inlined", () => { Test_utils.eq("File \"inline_export_test.res\", line 41, characters 7-14", 4, 4); Test_utils.eq("File \"inline_export_test.res\", line 42, characters 7-14", fromOrdinary, 4); Test_utils.eq("File \"inline_export_test.res\", line 43, characters 7-14", fromCatch, "boom"); }); Mocha.test("additional Option helpers", () => { Test_utils.eq("File \"inline_export_test.res\", line 46, characters 7-14", 4, 4); Test_utils.eq("File \"inline_export_test.res\", line 47, characters 7-14", undefined, undefined); Test_utils.eq("File \"inline_export_test.res\", line 48, characters 7-14", undefined, undefined); Test_utils.eq("File \"inline_export_test.res\", line 49, characters 7-14", 3, 3); Test_utils.eq("File \"inline_export_test.res\", line 50, characters 7-14", 0, 0); Test_utils.eq("File \"inline_export_test.res\", line 51, characters 7-14", 2, 2); Test_utils.eq("File \"inline_export_test.res\", line 52, characters 7-14", 0, 0); Test_utils.eq("File \"inline_export_test.res\", line 53, characters 7-14", 2, 2); Test_utils.eq("File \"inline_export_test.res\", line 54, characters 7-14", 3, 3); Test_utils.eq("File \"inline_export_test.res\", line 55, characters 7-14", true, true); Test_utils.eq("File \"inline_export_test.res\", line 56, characters 7-14", false, false); Test_utils.eq("File \"inline_export_test.res\", line 57, characters 7-14", false, false); Test_utils.eq("File \"inline_export_test.res\", line 58, characters 7-14", true, true); }); Mocha.test("eager fallback arguments", () => { let effects = []; let getDefault = () => { effects.push("getOr"); return 0; }; let mapDefault = () => { effects.push("mapOr"); return 0; }; let other = () => { effects.push("orElse"); return 0; }; getDefault(); Test_utils.eq("File \"inline_export_test.res\", line 74, characters 7-14", 2, 2); mapDefault(); Test_utils.eq("File \"inline_export_test.res\", line 75, characters 7-14", 2, 2); other(); Test_utils.eq("File \"inline_export_test.res\", line 76, characters 7-14", 2, 2); Test_utils.eq("File \"inline_export_test.res\", line 77, characters 7-14", effects, [ "getOr", "mapOr", "orElse" ]); }); }); let fromExport = 4; export { mapped, flatMapped, nested, mappedNested, mapValue, flatMapValue, forEachValue, filterValue, mapOrValue, getOrValue, orElseValue, isSomeValue, isNoneValue, visited, fromExport, fromOrdinary, fromCatch, } /* Not a pure module */