summaryrefslogtreecommitdiffstats
path: root/js/src/tests/non262/strict/directive-prologue-01.js
blob: 681fa9293348b9bfff1b6edd428e8bde602ba941 (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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
// Any copyright is dedicated to the Public Domain.
// http://creativecommons.org/licenses/publicdomain/

//-----------------------------------------------------------------------------
var BUGNUMBER = 601262;
var summary =
  "A string literal containing an octal escape before a strict mode " +
  "directive should be a syntax error";

print(BUGNUMBER + ": " + summary);

/**************
 * BEGIN TEST *
 **************/

try
{
  eval(" '\\145'; 'use strict'; ");
  throw new Error("no error thrown for eval");
}
catch (e)
{
  assertEq(e instanceof SyntaxError, true,
           "wrong error for octal-escape before strict directive in eval");
}

try
{
  Function(" '\\145'; 'use strict'; ");
  throw new Error("no error thrown for Function");
}
catch (e)
{
  assertEq(e instanceof SyntaxError, true,
           "wrong error for octal-escape before strict directive in Function");
}

try
{
  eval(" function f(){ '\\145'; 'use strict'; } ");
  throw new Error("no error thrown for eval of function");
}
catch (e)
{
  assertEq(e instanceof SyntaxError, true,
           "wrong error for octal-escape before strict directive in eval of " +
           "function");
}

try
{
  Function(" function f(){ '\\145'; 'use strict'; } ");
  throw new Error("no error thrown for eval of function");
}
catch (e)
{
  assertEq(e instanceof SyntaxError, true,
           "wrong error for octal-escape before strict directive in eval of " +
           "function");
}

eval("function notAnError1() { 5; '\\145'; function g() { 'use strict'; } }");

Function("function notAnError2() { 5; '\\145'; function g() { 'use strict'; } }");

function notAnError3()
{
  5;
  "\145";
  function g() { "use strict"; }
}

/******************************************************************************/

if (typeof reportCompare === "function")
  reportCompare(true, true);

print("All tests passed!");