updated tests

This commit is contained in:
Moritz Gmeiner 2024-09-01 20:47:52 +02:00
commit 65efdd2824
4 changed files with 1280 additions and 16 deletions

File diff suppressed because it is too large Load diff

View file

@ -6,7 +6,8 @@ use std::rc::Rc;
use rlox2_frontend::lexer::TokenType;
use rlox2_interpreter::{run, Runtime};
fn run_test(path: impl Into<PathBuf>) {
#[cfg(test)]
pub fn run_test(path: impl Into<PathBuf>) {
let path = &path.into();
// path.insert_str(0, "./tests/lox/");
@ -20,7 +21,7 @@ fn run_test(path: impl Into<PathBuf>) {
if let TokenType::Comment(s) = token.token_type {
if s.starts_with(" expect: ") {
Some(s.strip_prefix(" expect: ").unwrap().trim().to_owned())
} else if s.starts_with(" Error") || s.contains("error") {
} else if s.contains("Error") || s.contains("error") {
Some(s.trim().into())
} else {
None
@ -79,17 +80,17 @@ fn run_test(path: impl Into<PathBuf>) {
}
}
#[test]
fn run_all_tests() {
for lox_file in glob::glob("tests/lox/**/*.lox").unwrap() {
let lox_file = lox_file.unwrap();
// #[test]
// fn run_all_tests() {
// for lox_file in glob::glob("tests/lox/**/*.lox").unwrap() {
// let lox_file = lox_file.unwrap();
print!("\n\n\n");
println!(
"================================================================================\n"
);
println!("Running test for file {}\n", lox_file.display());
// print!("\n\n\n");
// println!(
// "================================================================================\n"
// );
// println!("Running test for file {}\n", lox_file.display());
run_test(lox_file);
}
}
// run_test(lox_file);
// }
// }

View file

@ -2,4 +2,4 @@ if (false) {
print notDefined;
}
print "ok"; // expect: ok
print "ok"; // expect: error

View file

@ -1,3 +1,3 @@
var a = "value";
var a = a;
print a; // expect: value
print a; // expect: error