mirror of
https://github.com/MorizzG/rlox.git
synced 2025-12-06 04:12:42 +00:00
updated tests
This commit is contained in:
parent
6386df22c0
commit
65efdd2824
4 changed files with 1280 additions and 16 deletions
1263
interpreter/tests/all_tests.rs
Normal file
1263
interpreter/tests/all_tests.rs
Normal file
File diff suppressed because it is too large
Load diff
|
|
@ -6,7 +6,8 @@ use std::rc::Rc;
|
||||||
use rlox2_frontend::lexer::TokenType;
|
use rlox2_frontend::lexer::TokenType;
|
||||||
use rlox2_interpreter::{run, Runtime};
|
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();
|
let path = &path.into();
|
||||||
// path.insert_str(0, "./tests/lox/");
|
// 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 let TokenType::Comment(s) = token.token_type {
|
||||||
if s.starts_with(" expect: ") {
|
if s.starts_with(" expect: ") {
|
||||||
Some(s.strip_prefix(" expect: ").unwrap().trim().to_owned())
|
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())
|
Some(s.trim().into())
|
||||||
} else {
|
} else {
|
||||||
None
|
None
|
||||||
|
|
@ -79,17 +80,17 @@ fn run_test(path: impl Into<PathBuf>) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
// #[test]
|
||||||
fn run_all_tests() {
|
// fn run_all_tests() {
|
||||||
for lox_file in glob::glob("tests/lox/**/*.lox").unwrap() {
|
// for lox_file in glob::glob("tests/lox/**/*.lox").unwrap() {
|
||||||
let lox_file = lox_file.unwrap();
|
// let lox_file = lox_file.unwrap();
|
||||||
|
|
||||||
print!("\n\n\n");
|
// print!("\n\n\n");
|
||||||
println!(
|
// println!(
|
||||||
"================================================================================\n"
|
// "================================================================================\n"
|
||||||
);
|
// );
|
||||||
println!("Running test for file {}\n", lox_file.display());
|
// println!("Running test for file {}\n", lox_file.display());
|
||||||
|
|
||||||
run_test(lox_file);
|
// run_test(lox_file);
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
|
|
@ -2,4 +2,4 @@ if (false) {
|
||||||
print notDefined;
|
print notDefined;
|
||||||
}
|
}
|
||||||
|
|
||||||
print "ok"; // expect: ok
|
print "ok"; // expect: error
|
||||||
|
|
|
||||||
|
|
@ -1,3 +1,3 @@
|
||||||
var a = "value";
|
var a = "value";
|
||||||
var a = a;
|
var a = a;
|
||||||
print a; // expect: value
|
print a; // expect: error
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue