[BREAKING] Feat: quotation is now using ()

This commit is contained in:
2026-02-28 20:25:59 +01:00
parent ec98274dfe
commit 651ed1219d
24 changed files with 182 additions and 169 deletions

View File

@@ -59,14 +59,14 @@ fn iter() {
#[test]
fn every_true_on_zero() {
let ctx = ctx_with(|c| c.iter = 0);
let f = run_ctx("{ 100 } 4 every", &ctx);
let f = run_ctx("( 100 ) 4 every", &ctx);
assert_eq!(stack_int(&f), 100);
}
#[test]
fn every_true_on_multiple() {
let ctx = ctx_with(|c| c.iter = 8);
let f = run_ctx("{ 100 } 4 every", &ctx);
let f = run_ctx("( 100 ) 4 every", &ctx);
assert_eq!(stack_int(&f), 100);
}
@@ -74,14 +74,14 @@ fn every_true_on_multiple() {
fn every_false_between() {
for i in 1..4 {
let ctx = ctx_with(|c| c.iter = i);
let f = run_ctx("{ 100 } 4 every", &ctx);
let f = run_ctx("( 100 ) 4 every", &ctx);
assert!(f.stack().is_empty(), "iter={} should not execute quotation", i);
}
}
#[test]
fn every_zero_count() {
expect_error("{ 1 } 0 every", "every count must be > 0");
expect_error("( 1 ) 0 every", "every count must be > 0");
}
#[test]
@@ -105,7 +105,7 @@ fn bjork_tresillo() {
// Bresenham(3,8) hits at positions 0, 2, 5
for runs in 0..8 {
let ctx = ctx_with(|c| c.runs = runs);
let f = run_ctx("{ 100 } 3 8 bjork", &ctx);
let f = run_ctx("( 100 ) 3 8 bjork", &ctx);
let hit = ((runs + 1) * 3) / 8 != (runs * 3) / 8;
if hit {
assert_eq!(stack_int(&f), 100, "runs={} should hit", runs);
@@ -121,7 +121,7 @@ fn bjork_hit_count() {
let mut hit_count = 0;
for runs in 0..8 {
let ctx = ctx_with(|c| c.runs = runs);
let f = run_ctx("{ 100 } 3 8 bjork", &ctx);
let f = run_ctx("( 100 ) 3 8 bjork", &ctx);
if !f.stack().is_empty() {
hit_count += 1;
}
@@ -132,20 +132,20 @@ fn bjork_hit_count() {
#[test]
fn bjork_all_hits() {
let ctx = ctx_with(|c| c.runs = 0);
let f = run_ctx("{ 100 } 8 8 bjork", &ctx);
let f = run_ctx("( 100 ) 8 8 bjork", &ctx);
assert_eq!(stack_int(&f), 100);
}
#[test]
fn bjork_zero_hits() {
let ctx = ctx_with(|c| c.runs = 0);
let f = run_ctx("{ 100 } 0 8 bjork", &ctx);
let f = run_ctx("( 100 ) 0 8 bjork", &ctx);
assert!(f.stack().is_empty());
}
#[test]
fn bjork_invalid() {
expect_error("{ 1 } 3 0 bjork", "bjork");
expect_error("( 1 ) 3 0 bjork", "bjork");
}
// pbjork (iter-based)
@@ -155,7 +155,7 @@ fn pbjork_cinquillo() {
let mut hit_count = 0;
for iter in 0..8 {
let ctx = ctx_with(|c| c.iter = iter);
let f = run_ctx("{ 100 } 5 8 pbjork", &ctx);
let f = run_ctx("( 100 ) 5 8 pbjork", &ctx);
if !f.stack().is_empty() {
hit_count += 1;
}
@@ -167,7 +167,7 @@ fn pbjork_cinquillo() {
fn pbjork_wraps() {
let ctx0 = ctx_with(|c| c.iter = 0);
let ctx8 = ctx_with(|c| c.iter = 8);
let f0 = run_ctx("{ 100 } 3 8 pbjork", &ctx0);
let f8 = run_ctx("{ 100 } 3 8 pbjork", &ctx8);
let f0 = run_ctx("( 100 ) 3 8 pbjork", &ctx0);
let f8 = run_ctx("( 100 ) 3 8 pbjork", &ctx8);
assert_eq!(f0.stack().is_empty(), f8.stack().is_empty());
}