summaryrefslogtreecommitdiffstats
path: root/js/src/jit-test/tests/asm.js/testModuleFunctions.js
blob: 2e3c80f45febef671a0b5da206a6da1bed579845 (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
function testUniqueness(asmJSModule) {
    var f = asmJSModule();
    var g = asmJSModule();
    assertEq(f === g, false);
    f.x = 4;
    assertEq(f.x, 4);
    assertEq(g.x, undefined);
}

function deffun() {
    if (Math.sin) {
        function inner() { "use asm"; function g() {} return g }
    }
    return inner;
}

testUniqueness(deffun);

function lambda() {
    var x = function inner() { "use asm"; function g() {} return g };
    return x;
}

testUniqueness(lambda);

function inEval() {
    eval("function inner() { 'use asm'; function g() {} return g }");
    return inner;
}

testUniqueness(inEval);

function inWith() {
    with ({}) {
        function inner() { "use asm"; function g() {} return g }
    }
    return inner;
}

testUniqueness(inWith);