fix: 绑定 Function 和 Object prototype harness helper

This commit is contained in:
爱特每羊队
2026-06-09 19:31:46 +08:00
parent 3987d39db9
commit e588fa4c8c
7 changed files with 103 additions and 7 deletions
@@ -30,6 +30,25 @@ fn function_bind_creates_wrapper() {
assert!((result.as_double() - 5.0).abs() < 0.0001);
}
#[test]
fn function_constructor_is_global() {
let mut vm = Vm::new();
let result = eval(&mut vm, "typeof Function").unwrap();
let rendered = vm.kernel().string_forge().lookup(result.as_string_index()).unwrap_or_default();
assert_eq!(rendered, "function");
}
#[test]
fn function_call_bind_supports_uncurried_native_methods() {
let mut vm = Vm::new();
let result = eval(
&mut vm,
"var __push = Function.prototype.call.bind(Array.prototype.push); var a = []; __push(a, 'x'); a.length",
)
.unwrap();
assert_eq!(result, JsValue::int(1));
}
#[test]
fn function_call_invokes_bytecode_function() {
let mut vm = Vm::new();
+19 -1
View File
@@ -118,7 +118,25 @@ fn object_get_prototype_of() {
#[test]
fn object_has_own_true() {
let (_vm, result) = eval("Object.hasOwn({a:1}, 'a')").unwrap();
assert!(result.is_bool());
assert_eq!(result, JsValue::bool(true));
}
#[test]
fn object_has_own_false_for_inherited_property() {
let (_vm, result) = eval("Object.hasOwn({}, 'toString')").unwrap();
assert_eq!(result, JsValue::bool(false));
}
#[test]
fn object_proto_has_own_property_call_works() {
let (_vm, result) = eval("Object.prototype.hasOwnProperty.call(Object, 'assign')").unwrap();
assert_eq!(result, JsValue::bool(true));
}
#[test]
fn object_proto_property_is_enumerable_call_works() {
let (_vm, result) = eval("Object.prototype.propertyIsEnumerable.call(Object, 'assign')").unwrap();
assert_eq!(result, JsValue::bool(true));
}
#[test]