~ubuntu-branches/ubuntu/saucy/mozjs17/saucy

« back to all changes in this revision

Viewing changes to js/src/tests/ecma_5/Global/eval-02.js

  • Committer: Package Import Robot
  • Author(s): Rico Tzschichholz
  • Date: 2013-05-25 12:24:23 UTC
  • Revision ID: package-import@ubuntu.com-20130525122423-zmxucrhtensw90xy
Tags: upstream-17.0.0
ImportĀ upstreamĀ versionĀ 17.0.0

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
// Any copyright is dedicated to the Public Domain.
 
2
// http://creativecommons.org/licenses/publicdomain/
 
3
 
 
4
var a = 9;
 
5
 
 
6
function directArg(eval, s) {
 
7
    var a = 1;
 
8
    return eval(s);
 
9
}
 
10
 
 
11
function directVar(f, s) {
 
12
    var eval = f;
 
13
    var a = 1;
 
14
    return eval(s);
 
15
}
 
16
 
 
17
function directWith(obj, s) {
 
18
    var f;
 
19
    with (obj) {
 
20
        f = function () {
 
21
            var a = 1;
 
22
            return eval(s);
 
23
        };
 
24
    }
 
25
    return f();
 
26
}
 
27
 
 
28
// direct eval, even though 'eval' is an argument
 
29
assertEq(directArg(eval, 'a+1'), 2);
 
30
 
 
31
// direct eval, even though 'eval' is a var
 
32
assertEq(directVar(eval, 'a+1'), 2);
 
33
 
 
34
// direct eval, even though 'eval' is found via a with block
 
35
assertEq(directWith(this, 'a+1'), 2);
 
36
assertEq(directWith({eval: eval, a: -1000}, 'a+1'), 2);
 
37
 
 
38
reportCompare(0, 0);