Iter 11: deeper dogfood — insertion sort
examples/sort.ail.json: insertion sort over IntList. Defines `insert :: Int -> IntList -> IntList` and `sort :: IntList -> IntList` recursively, plus print_list using Iter 10's seq. Sorts an 11-element input and prints `1 1 2 3 3 4 5 5 5 6 9` one-per-line. Validates that the language handles deeper ADT recursion + branching (if + <=) + ctor construction + IO sequencing without surprises. Wrote, typechecked, ran first try. The Iter 11 plan called for polymorphism, but on reflection the right move was one more validation cycle before disturbing the pipeline. Polymorphism is now queued explicitly as Iter 12 (12a typechecker substitution, 12b codegen monomorphisation, 12c docs + generic example). Tests: 52 green (was 51). New e2e `insertion_sort_orders_list`. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -93,6 +93,21 @@ fn list_map_doubles_then_prints() {
|
||||
assert_eq!(lines, vec!["2", "4", "6"]);
|
||||
}
|
||||
|
||||
/// Iter 11 dogfood: insertion sort over an 11-element IntList.
|
||||
/// Exercises `<=`, `if`, mutual-leaf recursion (`insert` and `sort`),
|
||||
/// nested ctor construction, and the Iter 10 seq operator inside
|
||||
/// print_list. Validates that the language handles deeper ADT
|
||||
/// recursion + branching without surprises.
|
||||
#[test]
|
||||
fn insertion_sort_orders_list() {
|
||||
let stdout = build_and_run("sort.ail.json");
|
||||
let lines: Vec<&str> = stdout.lines().collect();
|
||||
assert_eq!(
|
||||
lines,
|
||||
vec!["1", "1", "2", "3", "3", "4", "5", "5", "5", "6", "9"],
|
||||
);
|
||||
}
|
||||
|
||||
/// Guards `ail diff`: a modified body changes the hash of `sum`, while
|
||||
/// `main` stays unchanged. Expects exit code 1, `changed` contains exactly
|
||||
/// `sum`, `unchanged` contains `main`, `added`/`removed` empty.
|
||||
|
||||
Reference in New Issue
Block a user