// Generated by bynkc — do not edit by hand.
// test target: commerce.money

import { Ok, Err, Some, None, type Result, type Option, type ValidationError } from "../runtime.js";
import * as commerce_money from "./../commerce/money.js";

class AssertionError extends Error {
  location: string;
  start: number;
  end: number;
  constructor(location: string, start: number, end: number) {
    super(`assertion failed at ${location}`);
    this.location = location;
    this.start = start;
    this.end = end;
  }
}
function __bynkAssertionFailure(location: string, start: number, end: number) {
  return new AssertionError(location, start, end);
}
function __bynkAssert(cond: boolean, location: string, start: number, end: number): void {
  if (!cond) { throw __bynkAssertionFailure(location, start, end); }
}

function makeTestDeps() {
  return {  };
}

async function test_nested_match_assert() {
  try {
    const deps = {};
    const { Money } = commerce_money as any;
    const outer = Money.fromMinorUnits(10);
    const inner = Money.fromMinorUnits(-1);
    void (((__d) => {
        switch (__d.tag) {
          case "Ok": {
            return ((__d) => {
        switch (__d.tag) {
          case "Ok": {
            return __bynkAssert((false), "tests/money.test.bynk:7:25", 206, 211);
          }
          case "Err": {
            return __bynkAssert((true), "tests/money.test.bynk:8:26", 237, 241);
          }
        }
        throw new Error("non-exhaustive match");
      })(inner);
          }
          case "Err": {
            return __bynkAssert((false), "tests/money.test.bynk:10:24", 273, 278);
          }
        }
        throw new Error("non-exhaustive match");
      })(outer));
    return { pass: true };
  } catch (e) {
    if (e instanceof AssertionError) {
      return { pass: false, error: { message: e.message, location: e.location } };
    }
    return { pass: false, error: { message: String(e), location: "unknown" } };
  }
}

export async function run() {
  const results = [];
  results.push({ name: "nested match assert", ...(await test_nested_match_assert()) });
  return results;
}
