js/src/jit-test/tests/basic/testReplaceWithLambda.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 // optimized
michael@0 2 (function(b) {
michael@0 3 assertEq("abc".replace(/a|b/g, function(a) { return b[a] }), 'ABc');
michael@0 4 })({a:'A', b:'B' });
michael@0 5 (function() {
michael@0 6 var b = {a:'A', b:'B' };
michael@0 7 assertEq("abc".replace(/a|b/g, function(a) { return b[a] }), 'ABc');
michael@0 8 })();
michael@0 9 (function() {
michael@0 10 let (b = {a:'A', b:'B' }) {
michael@0 11 assertEq("abc".replace(/a|b/g, function(a) { return b[a] }), 'ABc');
michael@0 12 }
michael@0 13 })();
michael@0 14 (function() {
michael@0 15 var b = {a:'A', b:'B' };
michael@0 16 (function () {
michael@0 17 assertEq("abc".replace(/a|b/g, function(a) { return b[a] }), 'ABc');
michael@0 18 })();
michael@0 19 })();
michael@0 20 (function() {
michael@0 21 let (b = {a:'A', b:'B' }) {
michael@0 22 (function () {
michael@0 23 assertEq("abc".replace(/a|b/g, function(a) { return b[a] }), 'ABc');
michael@0 24 })();
michael@0 25 }
michael@0 26 })();
michael@0 27 (function() {
michael@0 28 var b = {a:'A', b:'B' };
michael@0 29 (function () {
michael@0 30 (function () {
michael@0 31 assertEq("abc".replace(/a|b/g, function(a) { return b[a] }), 'ABc');
michael@0 32 })();
michael@0 33 })();
michael@0 34 })();
michael@0 35
michael@0 36 // not optimized:
michael@0 37 (function() {
michael@0 38 var b = {a:'A', b:'B' };
michael@0 39 with ({}) {
michael@0 40 (function () {
michael@0 41 assertEq("abc".replace(/a|b/g, function(a) { return b[a] }), 'ABc');
michael@0 42 })();
michael@0 43 }
michael@0 44 })();
michael@0 45 (function() {
michael@0 46 var b = {a:'A', b:'B' };
michael@0 47 var bad = function() { b = {a:1, b:2}; return 'X' }
michael@0 48 Object.defineProperty(b, 'x', {get:bad});
michael@0 49 assertEq("xabc".replace(/x|a|b/g, function(a) { return b[a] }), 'X12c');
michael@0 50 })();

mercurial