js/src/jit-test/tests/ion/evalCallingName.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 a() {
michael@0 3 return "a";
michael@0 4 }
michael@0 5 function b() {
michael@0 6 return "b";
michael@0 7 }
michael@0 8 function c() {
michael@0 9 return "c";
michael@0 10 }
michael@0 11 var names = ["a","b","c"];
michael@0 12
michael@0 13 function foo(name) {
michael@0 14 return eval(name + "()");
michael@0 15 }
michael@0 16
michael@0 17 for (var i = 0; i < names.length; i++)
michael@0 18 assertEq(foo(names[i]), names[i]);
michael@0 19
michael@0 20 // Test bailout due to bad name passed to eval.
michael@0 21 try {
michael@0 22 foo("missing");
michael@0 23 } catch (e) {
michael@0 24 assertEq(/missing/.test(e), true);
michael@0 25 }
michael@0 26
michael@0 27 function bar(name) {
michael@0 28 return eval(name + "()");
michael@0 29 }
michael@0 30
michael@0 31 for (var i = 0; i < names.length; i++)
michael@0 32 assertEq(bar(names[i]), names[i]);
michael@0 33
michael@0 34 function recursion() {
michael@0 35 return bar({ valueOf: function() { return "gotcha"; }});
michael@0 36 }
michael@0 37
michael@0 38 function gotcha() {
michael@0 39 return "gotcha";
michael@0 40 }
michael@0 41
michael@0 42 // Test invalidation within call made after name lookup.
michael@0 43 assertEq(bar("recursion"), "gotcha");

mercurial