Rust编写的JavaScript引擎,该项目是一个试验性质的项目。
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 

32 lines
769 B

extern crate boa;
use boa::js::value::{ToValue, ValueData};
#[test]
fn check_is_object() {
let val = ValueData::new_obj(None);
assert_eq!(val.is_object(), true);
}
#[test]
fn check_string_to_value() {
let s = String::from("Hello");
let v = s.to_value();
assert_eq!(v.is_string(), true);
assert_eq!(v.is_null(), false);
}
#[test]
fn check_undefined() {
let u = ValueData::Undefined;
assert_eq!(u.get_type(), "undefined");
assert_eq!(u.to_string(), "undefined");
}
#[test]
fn check_get_set_field() {
let obj = ValueData::new_obj(None);
// Create string and convert it to a Value
let s = String::from("bar").to_value();
obj.set_field_slice("foo", s);
assert_eq!(obj.get_field_slice("foo").to_string(), "bar");
}