forked from cory/tildefriends
quickjs-2024-01-13.tar.xz
git-svn-id: https://www.unprompted.com/svn/projects/tildefriends/trunk@4765 ed5197a5-7fde-0310-b194-c3ffbd925b24
This commit is contained in:
24
deps/quickjs/tests/test_loop.js
vendored
24
deps/quickjs/tests/test_loop.js
vendored
@@ -167,6 +167,29 @@ function test_for_in2()
|
||||
assert(tab.toString() == "x,y");
|
||||
}
|
||||
|
||||
function test_for_in_proxy() {
|
||||
let removed_key = "";
|
||||
let target = {}
|
||||
let proxy = new Proxy(target, {
|
||||
ownKeys: function() {
|
||||
return ["a", "b", "c"];
|
||||
},
|
||||
getOwnPropertyDescriptor: function(target, key) {
|
||||
if (removed_key != "" && key == removed_key)
|
||||
return undefined;
|
||||
else
|
||||
return { enumerable: true, configurable: true, value: this[key] };
|
||||
}
|
||||
});
|
||||
let str = "";
|
||||
for(let o in proxy) {
|
||||
str += " " + o;
|
||||
if (o == "a")
|
||||
removed_key = "b";
|
||||
}
|
||||
assert(str == " a c");
|
||||
}
|
||||
|
||||
function test_for_break()
|
||||
{
|
||||
var i, c;
|
||||
@@ -357,6 +380,7 @@ test_switch1();
|
||||
test_switch2();
|
||||
test_for_in();
|
||||
test_for_in2();
|
||||
test_for_in_proxy();
|
||||
|
||||
test_try_catch1();
|
||||
test_try_catch2();
|
||||
|
Reference in New Issue
Block a user