Debian Codegraph @

js/src/jit-test/tests/basic/prop-access-error-message.js

raw
1 // |jit-test| skip-if: getBuildConfiguration('pbl')
2 // The decompiled expression used in the error messsage should not be confused
3 // by unrelated value on the stack.
4
5 var a = {};
6 var b = {};
7 var p = "c";
8
9 function doPropAccess() {
10 // Both "a.c" and "b.e" are undefined.
11 // "a.c" should be used.
12 a.c.d = b.e;
13 }
14
15 function testPropAccess() {
16 var caught = false;
17 try {
18 doPropAccess();
19 } catch (e) {
20 assertEq(e.message.includes("a.c is undefined"), true);
21 caught = true;
22 }
23 assertEq(caught, true);
24 }
25
26 function doElemAccess() {
27 // Both "a[x]" and "b.e" are undefined.
28 // "a[x]" should be used.
29 var x = "c";
30 a[x].d = b.e;
31 }
32
33 function testElemAccess() {
34 var caught = false;
35 try {
36 doElemAccess();
37 } catch (e) {
38 assertEq(e.message.includes("a[x] is undefined"), true);
39 caught = true;
40 }
41 assertEq(caught, true);
42 }
43
44 for (var i = 0; i < 10; i++) {
45 testPropAccess();
46 testElemAccess();
47 }