summaryrefslogtreecommitdiffstats
path: root/js/src/jit-test/tests/ion/evalCallingName.js
blob: c2ca3ccef7ed19c0935c355df826df4a50678aff (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
function a() {
  return "a";
}
function b() {
  return "b";
}
function c() {
  return "c";
}
var names = ["a","b","c"];

function foo(name) {
  return eval(name + "()");
}

for (var i = 0; i < names.length; i++)
  assertEq(foo(names[i]), names[i]);

// Test bailout due to bad name passed to eval.
try {
  foo("missing");
} catch (e) {
  assertEq(/missing/.test(e), true);
}

function bar(name) {
  return eval(name + "()");
}

for (var i = 0; i < names.length; i++)
  assertEq(bar(names[i]), names[i]);

function recursion() {
  return bar({ valueOf: function() { return "gotcha"; }});
}

function gotcha() {
  return "gotcha";
}

// Test invalidation within call made after name lookup.
assertEq(bar("recursion"), "gotcha");