All about temporal semantics

This commit is contained in:
2026-01-22 00:56:02 +01:00
parent 5e47e909d1
commit c73e25e207
12 changed files with 129102 additions and 145 deletions

View File

@@ -20,16 +20,6 @@ fn string_not_number() {
expect_error(r#""hello" neg"#, "expected number");
}
#[test]
fn get_expects_string() {
expect_error("42 get", "expected string");
}
#[test]
fn set_expects_string() {
expect_error("1 2 set", "expected string");
}
#[test]
fn comment_ignored() {
expect_int("1 (this is a comment) 2 +", 3);
@@ -54,7 +44,7 @@ fn float_literal() {
#[test]
fn string_with_spaces() {
let f = run(r#""hello world" "x" set "x" get"#);
let f = run(r#""hello world" !x @x"#);
match stack_top(&f) {
cagire::model::forth::Value::Str(s, _) => assert_eq!(s, "hello world"),
other => panic!("expected string, got {:?}", other),
@@ -63,7 +53,6 @@ fn string_with_spaces() {
#[test]
fn list_count() {
// [ 1 2 3 ] => stack: 1 2 3 3 (items + count on top)
let f = run("[ 1 2 3 ]");
assert_eq!(stack_int(&f), 3);
}
@@ -75,9 +64,6 @@ fn list_empty() {
#[test]
fn list_preserves_values() {
// [ 10 20 ] => stack: 10 20 2
// drop => 10 20
// + => 30
expect_int("[ 10 20 ] drop +", 30);
}
@@ -97,10 +83,10 @@ fn conditional_based_on_step() {
fn accumulator() {
let f = forth();
let ctx = default_ctx();
f.evaluate(r#"0 "acc" set"#, &ctx).unwrap();
f.evaluate(r#"0 !acc"#, &ctx).unwrap();
for _ in 0..5 {
f.clear_stack();
f.evaluate(r#""acc" get 1 + dup "acc" set"#, &ctx).unwrap();
f.evaluate(r#"@acc 1 + dup !acc"#, &ctx).unwrap();
}
assert_eq!(stack_int(&f), 5);
}