writeonce/tests/corpus/run/mailbox-full-trap/fixture.wo
shoney.arickathil 23550e7021 feat(lang+wo-html): raw text literals, component layer, MVC samples
- lexer: backtick raw text literal — content verbatim, no escape
  processing, common source margin removed at lex time; `${ }` raw and
  `{{ }}` auto-escaping holes
- `{{ e }}` desugars to `esc(${e})` in parser.ml — a Call on the `esc`
  in scope, so types/owner/emit/.wob/VM are untouched
- WO-E004 unterminated raw literal; WO-E005 newline inside "..." —
  closes a hole where a missing quote silently ate the rest of the file
- wo-html: `Component` interface, `render_all`, `Layout`, README
- framework: `ok_html` joins ok_text/ok_json in http/types.wo
- site + shop restructured to one-feature-one-module MVC (view +
  controller per directory, model at the root, bootstrap-only main)
- removed the filler `pad: Int` convention — verified unnecessary for
  plain classes, interface dispatch, containers and actors
- corrected recorded claims: gap #1 blocks neither the build nor the
  layout; a class crosses module lines, only a free fn is scoped
- docs/guides/language-surface.md — the full grammar inventory
- story 37 landed and moved to done/

Gates: oop-accept MET, oop-e2e 116/0, woc-test 556/0, site 11/0,
web-app 46/0, fibers 10/0, db-actor 8/0

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-08-25 03:58:41 +02:00

50 lines
1.2 KiB
Text

use time
-- iteration 24: fail-fast backpressure from .wo. The sleeper parks in its
-- first receive, so the mailbox only ever drains by one; a send loop must
-- hit the cap (default 1024) and catch WO_T_ACTOR. The exact send count
-- at the first trap depends on scheduling, so the fixture prints the
-- trap's message once plus a bound check, never the count. `try` is an
-- expression, so the send is wrapped in a helper whose success is nil.
class Tick {
n: Int
}
class Sleeper {
fn receive(msg: Tick) {
time.sleep(5000);
}
}
fn send_one(s: actor Tick, n: Int) -> Text {
send(s, Tick { n: n });
return "";
}
fn main() -> Int {
let s: actor Tick = spawn Sleeper {};
let sent = 0;
let caught = "";
let i = 0;
while i < 2000 {
i = i + 1;
let r = try send_one(s, i) catch (e) e.msg;
if r == "" {
sent = sent + 1;
} else {
caught = "${r}";
i = 2000;
}
}
if caught == "actor mailbox full" {
print("trap: ${caught}");
} else {
print("NO TRAP after ${sent} sends");
}
if sent >= 1024 {
print("bounded: cap respected");
} else {
print("bounded: TRAPPED EARLY at ${sent}");
}
return 0;
}