js/src/jit-test/tests/ion/bug730977-implement-jsop-delprop.js

Thu, 22 Jan 2015 13:21:57 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Thu, 22 Jan 2015 13:21:57 +0100
branch
TOR_BUG_9701
changeset 15
b8a032363ba2
permissions
-rw-r--r--

Incorporate requested changes from Mozilla in review:
https://bugzilla.mozilla.org/show_bug.cgi?id=1123480#c6

michael@0 1
michael@0 2 function makeThing(i)
michael@0 3 {
michael@0 4 var thing = {};
michael@0 5 thing.foo = i;
michael@0 6 thing.bar = "bar_" + i;
michael@0 7 Object.defineProperty(thing, 'baz', {'configurable':false, 'value':[i]});
michael@0 8 return thing;
michael@0 9 }
michael@0 10 function makeArray(count)
michael@0 11 {
michael@0 12 var arr = new Array(count);
michael@0 13 for(var i = 0; i < count; i++) {
michael@0 14 arr[i] = makeThing(i);
michael@0 15 }
michael@0 16 return arr;
michael@0 17 }
michael@0 18 function delBar(obj)
michael@0 19 {
michael@0 20 assertEq(Object.getOwnPropertyDescriptor(obj, 'bar') === undefined, false);
michael@0 21 assertEq(delete obj.bar, true);
michael@0 22 assertEq(Object.getOwnPropertyDescriptor(obj, 'bar') === undefined, true);
michael@0 23 }
michael@0 24 function delBaz(obj)
michael@0 25 {
michael@0 26 var s = delete obj.baz;
michael@0 27 assertEq(Object.getOwnPropertyDescriptor(obj, 'baz') === undefined, false);
michael@0 28 assertEq(delete obj.baz, false);
michael@0 29 assertEq(Object.getOwnPropertyDescriptor(obj, 'baz') === undefined, false);
michael@0 30 }
michael@0 31 function delNonexistentThingy(obj)
michael@0 32 {
michael@0 33 assertEq(Object.getOwnPropertyDescriptor(obj, 'thingy') === undefined, true);
michael@0 34 assertEq(delete obj.thingy, true);
michael@0 35 assertEq(Object.getOwnPropertyDescriptor(obj, 'thingy') === undefined, true);
michael@0 36 }
michael@0 37 function testDelProp()
michael@0 38 {
michael@0 39 var arr = makeArray(10000);
michael@0 40 for(var i = 0; i < 10000; i++) {
michael@0 41 var obj = arr[i];
michael@0 42 assertEq(Object.getOwnPropertyDescriptor(obj, 'foo') === undefined, false);
michael@0 43 assertEq(delete obj.foo, true);
michael@0 44 assertEq(Object.getOwnPropertyDescriptor(obj, 'foo') === undefined, true);
michael@0 45 delBar(obj);
michael@0 46 delBaz(obj);
michael@0 47 delNonexistentThingy(obj);
michael@0 48 }
michael@0 49 }
michael@0 50
michael@0 51 testDelProp();

mercurial