js/src/jit-test/tests/arrays/slice.js

Wed, 31 Dec 2014 06:09:35 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 06:09:35 +0100
changeset 0
6474c204b198
permissions
-rw-r--r--

Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.

michael@0 1 let invoked = false;
michael@0 2 Object.defineProperty(Array.prototype, '0', {set: function () {
michael@0 3 invoked = true;
michael@0 4 }});
michael@0 5
michael@0 6 let result = [1, 2, 3].slice(1);
michael@0 7 assertEq(invoked, false);
michael@0 8
michael@0 9 let proxy = new Proxy({}, {
michael@0 10 get: function (target, name, proxy) {
michael@0 11 switch (name) {
michael@0 12 case "length":
michael@0 13 return 2;
michael@0 14 case "0":
michael@0 15 return 15;
michael@0 16 case "1":
michael@0 17 // Should not invoke [[Get]] for this hole.
michael@0 18 default:
michael@0 19 assertEq(false, true);
michael@0 20 }
michael@0 21 },
michael@0 22 has: function (target, name) {
michael@0 23 switch (name) {
michael@0 24 case "0":
michael@0 25 return true;
michael@0 26 case "1":
michael@0 27 return false;
michael@0 28 default:
michael@0 29 assertEq(false, true);
michael@0 30 }
michael@0 31 }
michael@0 32 })
michael@0 33 result = Array.prototype.slice.call(proxy, 0);
michael@0 34 assertEq(result.length, 2);
michael@0 35 assertEq(0 in result, true);
michael@0 36 assertEq(1 in result, false);
michael@0 37 assertEq(result[0], 15);

mercurial