|
| 1 | +# LLM workflow primitives. |
| 2 | + |
| 3 | +fn assert_eq(actual, expected, msg) { |
| 4 | + if actual != expected { |
| 5 | + test_record_failure(msg + ": expected " + to_string(expected) + " got " + to_string(actual)); |
| 6 | + } |
| 7 | +} |
| 8 | + |
| 9 | +fn assert_true(cond, msg) { if !cond { test_record_failure(msg); } } |
| 10 | + |
| 11 | +# Cheatsheets |
| 12 | +fn test_cheatsheet_substrate_has_entries() { |
| 13 | + h s = omc_cheatsheet("substrate"); |
| 14 | + assert_true(str_len(s) > 100, "non-trivial cheatsheet"); |
| 15 | +} |
| 16 | + |
| 17 | +fn test_cheatsheet_autograd() { |
| 18 | + h s = omc_cheatsheet("autograd"); |
| 19 | + assert_true(str_len(s) > 100, "autograd cheatsheet non-empty"); |
| 20 | +} |
| 21 | + |
| 22 | +fn test_cheatsheet_unknown_lists_topics() { |
| 23 | + h s = omc_cheatsheet("nope_no_such_topic"); |
| 24 | + assert_true(re_match("Available topics", s) == 1, "lists topics on miss"); |
| 25 | +} |
| 26 | + |
| 27 | +# Unique overview |
| 28 | +fn test_unique_overview_nonempty() { |
| 29 | + h s = omc_unique_overview(); |
| 30 | + assert_true(str_len(s) > 100, "overview is substantive"); |
| 31 | +} |
| 32 | + |
| 33 | +fn test_unique_overview_mentions_attractor() { |
| 34 | + h s = omc_unique_overview(); |
| 35 | + assert_true(re_match("attractor", s) == 1, "mentions attractor"); |
| 36 | +} |
| 37 | + |
| 38 | +# Python translation |
| 39 | +fn test_python_translation_mentions_arr_get() { |
| 40 | + h s = omc_python_translation(); |
| 41 | + assert_true(re_match("arr_get", s) == 1, "has arr_get mapping"); |
| 42 | +} |
| 43 | + |
| 44 | +fn test_python_translation_mentions_softmax() { |
| 45 | + h s = omc_python_translation(); |
| 46 | + assert_true(re_match("softmax", s) == 1, "has softmax mapping"); |
| 47 | +} |
| 48 | + |
| 49 | +# Builtin index |
| 50 | +fn test_builtin_index_lists_categories() { |
| 51 | + h s = omc_builtin_index_markdown(); |
| 52 | + assert_true(re_match("## arrays", s) == 1, "has arrays section"); |
| 53 | + assert_true(re_match("## substrate", s) == 1, "has substrate section"); |
| 54 | +} |
| 55 | + |
| 56 | +# Bootstrap pack — large composite |
| 57 | +fn test_bootstrap_pack_substantive() { |
| 58 | + h s = omc_bootstrap_pack(); |
| 59 | + assert_true(str_len(s) > 5000, "bootstrap pack substantial"); |
| 60 | +} |
| 61 | + |
| 62 | +# Change report |
| 63 | +fn test_change_report_keys() { |
| 64 | + h r = omc_change_report( |
| 65 | + "fn f(x) { return x; }", |
| 66 | + "fn f(x) { return x + 1; } fn g() { return 0; }" |
| 67 | + ); |
| 68 | + assert_true(dict_has(r, "added"), "has added"); |
| 69 | + assert_true(dict_has(r, "removed"), "has removed"); |
| 70 | + assert_true(dict_has(r, "modified"), "has modified"); |
| 71 | + assert_true(dict_has(r, "suggested_action"), "has suggested action"); |
| 72 | +} |
| 73 | + |
| 74 | +fn test_change_report_detects_modification() { |
| 75 | + h r = omc_change_report( |
| 76 | + "fn f(x) { return x; }", |
| 77 | + "fn f(x) { return x + 1; }" |
| 78 | + ); |
| 79 | + assert_true(re_match("f", dict_get(r, "modified")) == 1, "f is in modified"); |
| 80 | +} |
| 81 | + |
| 82 | +# omc_id stability |
| 83 | +fn test_omc_id_stable() { |
| 84 | + h a = omc_id("fn f(x) { return x; }"); |
| 85 | + h b = omc_id("fn f(y) { return y; }"); |
| 86 | + assert_eq(a, b, "stable under alpha-rename"); |
| 87 | +} |
| 88 | + |
| 89 | +fn test_omc_id_format() { |
| 90 | + h a = omc_id("h x = 1;"); |
| 91 | + assert_true(re_match("^omcid-", a) == 1, "starts with omcid-"); |
| 92 | +} |
| 93 | + |
| 94 | +fn test_omc_id_changes_on_real_diff() { |
| 95 | + h a = omc_id("fn f(x) { return x; }"); |
| 96 | + h b = omc_id("fn f(x) { return x + 1; }"); |
| 97 | + assert_true(a != b, "different code → different id"); |
| 98 | +} |
0 commit comments