more fixes, not there yet tho

This commit is contained in:
filipriec
2025-07-05 10:00:04 +02:00
parent a757acf51c
commit 4c57b562e6
11 changed files with 1407 additions and 270 deletions

View File

@@ -114,63 +114,3 @@ impl Default for ScriptParser {
Self::new()
}
}
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn test_basic_math_transformation() {
let parser = ScriptParser::new();
let input = "(+ 1.5 2.3)";
let expected = "(decimal-add \"1.5\" \"2.3\")";
let result = parser.transform(input);
assert_eq!(result, expected);
}
#[test]
fn test_complex_expression() {
let parser = ScriptParser::new();
let input = "(+ (* 2 3) (/ 10 2))";
let expected = "(decimal-add (decimal-mul \"2\" \"3\") (decimal-div \"10\" \"2\"))";
let result = parser.transform(input);
assert_eq!(result, expected);
}
#[test]
fn test_variable_replacement() {
let parser = ScriptParser::new();
let input = "(+ $x $y)";
let expected = "(decimal-add (get-var \"x\") (get-var \"y\"))";
let result = parser.transform(input);
assert_eq!(result, expected);
}
#[test]
fn test_negative_numbers() {
let parser = ScriptParser::new();
let input = "(+ -1.5 2.3)";
let expected = "(decimal-add \"-1.5\" \"2.3\")";
let result = parser.transform(input);
assert_eq!(result, expected);
}
#[test]
fn test_scientific_notation() {
let parser = ScriptParser::new();
let input = "(+ 1.5e2 2.3E-1)";
let expected = "(decimal-add \"1.5e2\" \"2.3E-1\")";
let result = parser.transform(input);
assert_eq!(result, expected);
}
}