// Generated by ReScript, PLEASE EDIT WITH CARE

import * as Mocha from "mocha";
import * as Test_utils from "./test_utils.mjs";
import * as Primitive_option from "@rescript/runtime/lib/es6/Primitive_option.mjs";

function hey(x, y) {
    if (x === void 0) { x = 3; }
    return x + y;
  }
;

let counter = {
  contents: 0
};

function side_effect(x) {
  x.contents = x.contents + 1 | 0;
  return x.contents;
}

function bug_to_fix(f, x) {
  return hey(f(x), 3);
}

function bug_to_fix2(f, x) {
  return hey(Primitive_option.toUndefined(f(x)), 3);
}

let counter2 = {
  contents: 0
};

function side_effect2(x) {
  x.contents = x.contents + 1 | 0;
  return x.contents;
}

function heystr(x, y) {
    if (x === void 0) { x = "3"; }
    return x + y;
  }
;

Mocha.describe("Optional_ffi_test", () => {
  Mocha.test("optional ffi test", () => {
    let u = hey(undefined, 3);
    let z = hey(5, 3);
    Test_utils.eq("File \"optional_ffi_test.res\", line 41, characters 7-14", [
      u,
      z
    ], [
      6,
      8
    ]);
    let v = bug_to_fix(side_effect, counter);
    let pair_0 = [
      v,
      counter.contents
    ];
    let pair_1 = [
      4,
      1
    ];
    let pair = [
      pair_0,
      pair_1
    ];
    let v2 = bug_to_fix2(side_effect2, counter2);
    let pair2_0 = [
      v2,
      counter.contents
    ];
    let pair2_1 = [
      4,
      1
    ];
    let pair2 = [
      pair2_0,
      pair2_1
    ];
    Test_utils.eq("File \"optional_ffi_test.res\", line 48, characters 7-14", pair, [
      [
        4,
        1
      ],
      [
        4,
        1
      ]
    ]);
    Test_utils.eq("File \"optional_ffi_test.res\", line 49, characters 7-14", pair2, [
      [
        4,
        1
      ],
      [
        4,
        1
      ]
    ]);
    let pair_1$1 = heystr("name", "4");
    let pair$1 = [
      "name4",
      pair_1$1
    ];
    Test_utils.eq("File \"optional_ffi_test.res\", line 53, characters 7-14", pair$1, [
      "name4",
      "name4"
    ]);
  });
});

export {
  counter,
  side_effect,
  bug_to_fix,
  bug_to_fix2,
  counter2,
  side_effect2,
}
/*  Not a pure module */
