mirror of
https://github.com/pjh456/OxideJS.git
synced 2026-10-24 02:31:13 +08:00
fix: 修复不符合 JS 语义约束的错误行为测试
This commit is contained in:
@@ -166,7 +166,8 @@ fn object_proto_has_own_property_call_works() {
|
||||
#[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));
|
||||
// Built-in methods are non-enumerable per the ES spec.
|
||||
assert_eq!(result, JsValue::bool(false));
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
||||
@@ -159,12 +159,12 @@ fn eval_do_while_continue() {
|
||||
|
||||
#[test]
|
||||
fn eval_for_in_enumerates_keys() {
|
||||
assert_eq!(eval("var n=0; for (k in {a:1,b:2}) { n=n+1; } n"), "3");
|
||||
assert_eq!(eval("var n=0; for (k in {a:1,b:2}) { n=n+1; } n"), "2");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn eval_for_in_empty_object() {
|
||||
assert_eq!(eval("var r=0; for (k in {}) { r=1; } r"), "1");
|
||||
assert_eq!(eval("var r=0; for (k in {}) { r=1; } r"), "0");
|
||||
}
|
||||
|
||||
#[test]
|
||||
@@ -175,7 +175,7 @@ fn eval_for_in_non_object_throws() {
|
||||
|
||||
#[test]
|
||||
fn eval_for_in_nested() {
|
||||
assert_eq!(eval("var r=0; for (k in {a:{x:1}}) { for (j in {y:2}) { r=r+1; } } r"), "2");
|
||||
assert_eq!(eval("var r=0; for (k in {a:{x:1}}) { for (j in {y:2}) { r=r+1; } } r"), "1");
|
||||
}
|
||||
|
||||
#[test]
|
||||
@@ -185,7 +185,7 @@ fn eval_for_in_break() {
|
||||
|
||||
#[test]
|
||||
fn eval_for_in_continue() {
|
||||
assert_eq!(eval("var r=0; for (k in {a:1,b:2}) { if (k=='a') continue; r=r+1; } r"), "2");
|
||||
assert_eq!(eval("var r=0; for (k in {a:1,b:2}) { if (k=='a') continue; r=r+1; } r"), "1");
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
||||
@@ -104,8 +104,8 @@ fn regression_throw_statement_preserves_syntax_error_kind() {
|
||||
fn regression_for_in_prototype_chain() {
|
||||
assert_eq!(
|
||||
eval("var c=0;for(var k in {a:1}){c=c+1;}c"),
|
||||
"2",
|
||||
"for-in should include inherited constructor from prototype"
|
||||
"1",
|
||||
"for-in must not include non-enumerable prototype properties like constructor"
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user