fix: 绑定 Function 和 Object prototype harness helper

This commit is contained in:
2026-06-09 19:31:46 +08:00
parent a6982bdf56
commit 06c313e802
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();