js/src/jit-test/tests/ion/setgname.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 // aaa is initially undefined. Make sure it's set to the
michael@0 3 // correct value - we have to store the type tag, even though
michael@0 4 // its known type is int32.
michael@0 5 var aaa;
michael@0 6 function f() {
michael@0 7 function g(x) {
michael@0 8 if (x)
michael@0 9 aaa = 22;
michael@0 10 }
michael@0 11 g(10);
michael@0 12
michael@0 13 function h() {
michael@0 14 aaa = 22;
michael@0 15 }
michael@0 16 for (var i=0; i<70; i++) {
michael@0 17 h();
michael@0 18 }
michael@0 19 assertEq(aaa, 22);
michael@0 20 }
michael@0 21 f();
michael@0 22
michael@0 23 x = 0;
michael@0 24 function setX(i) {
michael@0 25 x = i;
michael@0 26 }
michael@0 27 for (var i=0; i<70; i++)
michael@0 28 setX(i);
michael@0 29 assertEq(x, 69);
michael@0 30
michael@0 31 y = 3.14;
michael@0 32 y = true;
michael@0 33 y = [];
michael@0 34 function setY(arg) {
michael@0 35 y = arg;
michael@0 36 }
michael@0 37 for (var i=0; i<70; i++)
michael@0 38 setY([1]);
michael@0 39 setY([1, 2, 3]);
michael@0 40 assertEq(y.length, 3);
michael@0 41
michael@0 42 // z is non-configurable, but can be made non-writable.
michael@0 43 var z = 10;
michael@0 44
michael@0 45 function testNonWritable() {
michael@0 46 function g() {
michael@0 47 z = 11;
michael@0 48 }
michael@0 49 for (var i=0; i<70; i++) {
michael@0 50 g();
michael@0 51 }
michael@0 52 Object.defineProperty(this, "z", {value: 1234, writable: false});
michael@0 53 g();
michael@0 54 assertEq(z, 1234);
michael@0 55 }
michael@0 56 testNonWritable();

mercurial