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

import { Ok, Err, Some, None, makeTestState, type Result, type Option, type ValidationError } from "../runtime.js";
import * as demo_slot from "./../demo/slot.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_a_fresh_Slot_key_resolves_to_Empty() {
  try {
    demo_slot.__resetAgents();
    const deps = makeTestDeps();
    const { Label, Slot, SlotError, __makeSlot, resolve } = demo_slot as any;
    void (await (async (__d) => {
        switch (__d.tag) {
          case "Err": {
            return __bynkAssert((false), "offset 195", 195, 200);
          }
          case "Ok": {
            const id = __d.value;
            const outcome = await resolve.call(id, deps);
            switch (outcome.tag) {
              case "Ok": {
                return __bynkAssert((false), "offset 290", 290, 295);
              }
              case "Err": {
                const slotError = outcome.error;
                return ((__d) => {
        switch (__d.tag) {
          case "Empty": {
            return __bynkAssert((true), "offset 357", 357, 361);
          }
        }
        throw new Error("non-exhaustive match");
      })(slotError);
              }
            }
            throw new Error("non-exhaustive match");
          }
        }
        throw new Error("non-exhaustive match");
      })(Label.of("fresh")));
    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: "a fresh Slot key resolves to Empty", ...(await test_a_fresh_Slot_key_resolves_to_Empty()) });
  return results;
}
