Cleaning language

This commit is contained in:
2026-01-29 01:10:53 +01:00
parent db5237480a
commit 7e4f8d0e46
10 changed files with 57 additions and 68 deletions

View File

@@ -46,8 +46,8 @@ fn word_defined_in_one_forth_available_in_same() {
}
#[test]
fn unknown_word_errors() {
expect_error("nosuchword", "unknown word");
fn unknown_word_becomes_string() {
expect_str("nosuchword", "nosuchword");
}
#[test]

View File

@@ -11,8 +11,8 @@ fn whitespace_only() {
}
#[test]
fn unknown_word() {
expect_error("foobar", "unknown word");
fn unknown_word_becomes_string() {
expect_str("foobar", "foobar");
}
#[test]
@@ -22,12 +22,12 @@ fn string_not_number() {
#[test]
fn comment_ignored() {
expect_int("1 (this is a comment) 2 +", 3);
expect_int("1 ;; this is a comment\n2 +", 3);
}
#[test]
fn multiline_comment() {
expect_int("1 (multi\nline\ncomment) 2 +", 3);
expect_int("1 ;; first comment\n;; entire line comment\n2 +", 3);
}
#[test]

View File

@@ -88,6 +88,10 @@ pub fn expect_int(script: &str, expected: i64) {
expect_stack(script, &[Value::Int(expected, None)]);
}
pub fn expect_str(script: &str, expected: &str) {
expect_stack(script, &[Value::Str(expected.to_string(), None)]);
}
pub fn expect_float(script: &str, expected: f64) {
let f = run(script);
let stack = f.stack();