summaryrefslogtreecommitdiffstats
path: root/js/src/jit-test/tests/basic/property-error-message-fix.js
blob: 6f27416496a7c964e336b70a42aafff445abcab7 (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
// |jit-test| skip-if: getBuildConfiguration('pbl')

function check(f, message) {
  let caught = false;
  try {
    f();
  } catch (e) {
    assertEq(e.message, message);
    caught = true;
  }
  assertEq(caught, true);
}

check(() => {
  let obj = {
    prop: undefined
  };
  obj.prop.prop2();
}, "can't access property \"prop2\", obj.prop is undefined");

check(() => {
  let obj = {
    prop: null
  };
  obj.prop.prop2();
}, "can't access property \"prop2\", obj.prop is null");

check(() => {
  let prop = "prop";
  undefined[prop]();
}, "can't access property \"prop\" of undefined");

check(() => {
  let prop = "prop";
  null[prop]();
}, "can't access property \"prop\" of null");