// Generated by bynkc — do not edit by hand.
// test target: demo.shapes

import { Ok, Err, Some, None, type Result, type Option, type ValidationError } from "../runtime.js";
import * as demo_shapes from "./../demo/shapes.js";

class AssertionError extends Error {
  constructor(public location: string, public start: number, public end: number) {
    super(`assertion failed at ${location}`);
  }
}
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_bare_sum_mock_takes_the_first_declared_variant() {
  try {
    const deps = {};
    const { Cart, OrderId, Status } = demo_shapes as any;
    const s = Status.Active(0);
    if (!(s.tag === "Active")) { throw __bynkAssertionFailure("offset 209", 209, 223); }
    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" } };
  }
}

async function test_bare_record_mock_fills_every_field__including_an_opaque_one() {
  try {
    const deps = {};
    const { Cart, OrderId, Status } = demo_shapes as any;
    const c = { id: OrderId.unsafe("mock"), count: 0 };
    if (!(c.count === c.count)) { throw __bynkAssertionFailure("offset 334", 334, 352); }
    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: "bare sum mock takes the first declared variant", ...(await test_bare_sum_mock_takes_the_first_declared_variant()) });
  results.push({ name: "bare record mock fills every field, including an opaque one", ...(await test_bare_record_mock_fills_every_field__including_an_opaque_one()) });
  return results;
}
