Skip to content

Commit dd619eb

Browse files
committed
browser-rs: revive test_runner
1 parent 0be519d commit dd619eb

File tree

1 file changed

+25
-0
lines changed

1 file changed

+25
-0
lines changed

app/saji/tests/saji.rs

+25
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,31 @@ use saji::ast::{JsParser, Node};
1717
use saji::runtime::{JsRuntime, RuntimeValue};
1818
use saji::token::JsLexer;
1919

20+
#[cfg(test)]
21+
pub trait Testable {
22+
fn run(&self) -> ();
23+
}
24+
25+
#[cfg(test)]
26+
impl<T> Testable for T
27+
where
28+
T: Fn(),
29+
{
30+
fn run(&self) {
31+
print!("{} ...\t", core::any::type_name::<T>());
32+
self();
33+
println!("[ok]");
34+
}
35+
}
36+
37+
#[cfg(test)]
38+
pub fn test_runner(tests: &[&dyn Testable]) {
39+
println!("Running {} tests in saji.rs", tests.len());
40+
for test in tests {
41+
test.run();
42+
}
43+
}
44+
2045
#[macro_export]
2146
macro_rules! run_test {
2247
($input:expr, $expected_global_variables:expr) => {

0 commit comments

Comments
 (0)