js/src/jit-test/tests/xdr/trivial.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 load(libdir + 'bytecode-cache.js');
michael@0 2 var test = "";
michael@0 3
michael@0 4 // code a constant.
michael@0 5 test = "1;";
michael@0 6 evalWithCache(test, { assertEqBytecode: true, assertEqResult : true });
michael@0 7
michael@0 8 // code a string constant.
michael@0 9 test = "'string';";
michael@0 10 evalWithCache(test, { assertEqBytecode: true, assertEqResult : true });
michael@0 11
michael@0 12 // code a global variable access.
michael@0 13 test = "generation;";
michael@0 14 evalWithCache(test, { assertEqBytecode: true });
michael@0 15
michael@0 16 // code an object constant.
michael@0 17 test = "var obj = { a: 1, b: 2 };";
michael@0 18 evalWithCache(test, { assertEqBytecode: true, assertEqResult : true });
michael@0 19
michael@0 20 // code object literal with mutations.
michael@0 21 test = "var obj = { a: 1, b: 2 }; obj.a++; assertEq(obj.a, 2);";
michael@0 22 evalWithCache(test, { assertEqBytecode: true, assertEqResult : true });
michael@0 23
michael@0 24 // code object literals with mutations.
michael@0 25 test = "var obj = { a: 1, b: { c: 3, d: 4 } }; obj.b.c++; assertEq(obj.b.c, 4);";
michael@0 26 evalWithCache(test, { assertEqBytecode: true, assertEqResult : true });
michael@0 27
michael@0 28 // code a function which is used.
michael@0 29 test = "function f() { return 1; }; f();";
michael@0 30 evalWithCache(test, { assertEqBytecode: true, assertEqResult : true });
michael@0 31
michael@0 32 // code a function which is not used.
michael@0 33 test = "function f() { return 1; }; 1;";
michael@0 34 evalWithCache(test, { assertEqBytecode: true, assertEqResult : true });
michael@0 35
michael@0 36 // code a function which has an object literal.
michael@0 37 test = "function f() { return { x: 2 }; }; f();";
michael@0 38 evalWithCache(test, { assertEqBytecode: true });

mercurial