Verify control-flow invariants and document the development contract
This commit is contained in:
1 parent
71d29261a8
commit
1dc088b602
22 files changed
+269
-80
No files matched your search
@@ -437,6 +437,7 @@ fn multi_arm_branch_preserves_analysis_v2_and_carrier_positions() {
|
||||
"`if 数值 < 0`",
|
||||
"**else if 数值 == 0**",
|
||||
"*else if 数值 == 1*",
|
||||
"`else`",
|
||||
]) {
|
||||
let start = source.find(carrier).unwrap();
|
||||
let expected = serde_json::json!({"start": start, "end": start + carrier.len()});
|
||||
|
||||
@@ -429,3 +429,35 @@ fn narration_removal_preserves_execution() {
|
||||
);
|
||||
assert_eq!(values[0], marqdo_value::Value::int(120));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn control_flow_ir_is_independent_of_lists_quotes_and_prose() {
|
||||
let statements = [
|
||||
"`i = 0`",
|
||||
"`while true`",
|
||||
"`i = i + 1`",
|
||||
"`if i == 1`",
|
||||
"`continue`",
|
||||
"`else if i == 2`",
|
||||
"`break`",
|
||||
"`end`",
|
||||
"`end`",
|
||||
"`return i`",
|
||||
];
|
||||
let plain = format!("## @exec main\n\n{}\n", statements.join("\n\n"));
|
||||
let adorned = statements
|
||||
.iter()
|
||||
.enumerate()
|
||||
.map(|(index, statement)| match index % 3 {
|
||||
0 => format!("1. {statement} Ordinary prose follows the carrier."),
|
||||
1 => format!("> {statement}"),
|
||||
_ => format!("- {statement}"),
|
||||
})
|
||||
.collect::<Vec<_>>()
|
||||
.join("\n\n");
|
||||
let decorated = format!("## @exec main\n\n{adorned}\n");
|
||||
assert_eq!(
|
||||
executable_projection(&plain),
|
||||
executable_projection(&decorated)
|
||||
);
|
||||
}
|
||||
Reference in new issue
Block a user