summaryrefslogtreecommitdiffstats
path: root/js/src/tests/ecma_6/LexicalEnvironment/block-scoped-functions-annex-b-label.js
blob: 0fe9f45fca332803dc3b2a7944660ca9f02a6cdd (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 expectSyntaxError(str) {
  var threwSyntaxError;
  try {
    eval(str);
  } catch (e) {
    threwSyntaxError = e instanceof SyntaxError;
  }
  assertEq(threwSyntaxError, true);

  try {
    eval('"use strict";' + str);
  } catch (e) {
    threwSyntaxError = e instanceof SyntaxError;
  }
  assertEq(threwSyntaxError, true);
}

function expectSloppyPass(str) {
  eval(str);

  try {
    eval('"use strict";' + str);
  } catch (e) {
    threwSyntaxError = e instanceof SyntaxError;
  }
  assertEq(threwSyntaxError, true);
}

expectSloppyPass(`l: function f1() {}`);
expectSloppyPass(`l0: l: function f1() {}`);
expectSloppyPass(`{ f1(); l: function f1() {} }`);
expectSloppyPass(`{ f1(); l0: l: function f1() {} }`);
expectSloppyPass(`{ f1(); l: function f1() { return 42; } } assertEq(f1(), 42);`);
expectSloppyPass(`eval("fe(); l: function fe() {}")`);
expectSyntaxError(`if (1) l: function f2() {}`);
expectSyntaxError(`if (1) {} else l: function f3() {}`);
expectSyntaxError(`do l: function f4() {} while (0)`);
expectSyntaxError(`while (0) l: function f5() {}`);
expectSyntaxError(`for (;;) l: function f6() {}`);
expectSloppyPass(`switch (1) { case 1: l: function f7() {} }`);
expectSloppyPass(`switch (1) { case 1: assertEq(f8(), 'f8'); case 2: l: function f8() { return 'f8'; } } assertEq(f8(), 'f8');`);

reportCompare(0, 0);