090f082215
Adds three end-to-end tests for the 22b.3 mono pass, each with a matching one-property fixture under examples/. Defends mono-pass invariants 3, 4, and 6 from docs/specs/2026-05-09-22-typeclasses.md at the binary level (stdout-asserting, not AST-asserting): - coherence_two_instances_pick_correct_body_at_runtime — class R with instances at Int and Bool, both reachable from one main. Stdout `11\n22` proves both mono fns are synthesised AND each call site picks the matching body (no collapse). - class_default_method_runs_and_prints_default_value — empty instance body + class-level `default` clause must lower, link, and print the default value (`99`). Promotes the existing synthesise_mono_fn unit test to a binary-level guarantee. - cross_module_class_method_runs_and_prints_correct_value — class+instance in module A, called from module B's main. The qualified-name rewrite + cross-module synth-def placement was AST-tested in 22b.3.6; this pins down the emit-and-link path. All 18 typeclass_22b3 tests pass; full workspace green; 3 bench gates 0/0/0.
49 lines
1.2 KiB
JSON
49 lines
1.2 KiB
JSON
{
|
|
"schema": "ailang/v0",
|
|
"name": "test_22b3_default_e2e",
|
|
"imports": [],
|
|
"defs": [
|
|
{
|
|
"kind": "class", "name": "D", "param": "a",
|
|
"methods": [{
|
|
"name": "dval",
|
|
"type": {
|
|
"k": "fn", "params": [{ "k": "var", "name": "a" }],
|
|
"ret": { "k": "con", "name": "Int" }, "effects": []
|
|
},
|
|
"default": {
|
|
"t": "lam",
|
|
"params": ["x"],
|
|
"paramTypes": [{ "k": "var", "name": "a" }],
|
|
"retType": { "k": "con", "name": "Int" },
|
|
"body": { "t": "lit", "lit": { "kind": "int", "value": 99 } }
|
|
}
|
|
}]
|
|
},
|
|
{
|
|
"kind": "instance",
|
|
"class": "D",
|
|
"type": { "k": "con", "name": "Int" },
|
|
"methods": []
|
|
},
|
|
{
|
|
"kind": "fn",
|
|
"name": "main",
|
|
"type": {
|
|
"k": "fn", "params": [], "ret": { "k": "con", "name": "Unit" },
|
|
"effects": ["IO"]
|
|
},
|
|
"params": [],
|
|
"body": {
|
|
"t": "do",
|
|
"op": "io/print_int",
|
|
"args": [{
|
|
"t": "app",
|
|
"fn": { "t": "var", "name": "dval" },
|
|
"args": [{ "t": "lit", "lit": { "kind": "int", "value": 0 } }]
|
|
}]
|
|
}
|
|
}
|
|
]
|
|
}
|