feat: udpate boa test

This commit is contained in:
2022-07-08 00:58:22 +08:00
parent e2d6b9c54f
commit d17c718ee8
2 changed files with 66 additions and 66 deletions

View File

@@ -1,10 +1,12 @@
use boa::Context;
use boa::{Context, Result, Value};
fn main() {
let mut context = Context::new();
context.register_global_function("print", 0, print).unwrap();
let script = r##"
function helloworld() {
console.log('hello world');
print(1, 2, 3);
}
helloworld();
"hello world!!!"
@@ -12,3 +14,9 @@ fn main() {
let v = context.eval(script).expect("Eval failed!");
println!("{:?}", v);
}
fn print(_: &Value, args: &[Value], _: &mut Context) -> Result<Value> {
println!("[PRINT] {:?}", args);
Ok(Value::Undefined)
}