|
1 // Any copyright is dedicated to the Public Domain. |
|
2 // http://creativecommons.org/licenses/publicdomain/ |
|
3 |
|
4 //----------------------------------------------------------------------------- |
|
5 var BUGNUMBER = 601262; |
|
6 var summary = |
|
7 "A string literal containing an octal escape before a strict mode " + |
|
8 "directive should be a syntax error"; |
|
9 |
|
10 print(BUGNUMBER + ": " + summary); |
|
11 |
|
12 /************** |
|
13 * BEGIN TEST * |
|
14 **************/ |
|
15 |
|
16 try |
|
17 { |
|
18 eval(" '\\145'; 'use strict'; "); |
|
19 throw new Error("no error thrown for eval"); |
|
20 } |
|
21 catch (e) |
|
22 { |
|
23 assertEq(e instanceof SyntaxError, true, |
|
24 "wrong error for octal-escape before strict directive in eval"); |
|
25 } |
|
26 |
|
27 try |
|
28 { |
|
29 Function(" '\\145'; 'use strict'; "); |
|
30 throw new Error("no error thrown for Function"); |
|
31 } |
|
32 catch (e) |
|
33 { |
|
34 assertEq(e instanceof SyntaxError, true, |
|
35 "wrong error for octal-escape before strict directive in Function"); |
|
36 } |
|
37 |
|
38 try |
|
39 { |
|
40 eval(" function f(){ '\\145'; 'use strict'; } "); |
|
41 throw new Error("no error thrown for eval of function"); |
|
42 } |
|
43 catch (e) |
|
44 { |
|
45 assertEq(e instanceof SyntaxError, true, |
|
46 "wrong error for octal-escape before strict directive in eval of " + |
|
47 "function"); |
|
48 } |
|
49 |
|
50 try |
|
51 { |
|
52 Function(" function f(){ '\\145'; 'use strict'; } "); |
|
53 throw new Error("no error thrown for eval of function"); |
|
54 } |
|
55 catch (e) |
|
56 { |
|
57 assertEq(e instanceof SyntaxError, true, |
|
58 "wrong error for octal-escape before strict directive in eval of " + |
|
59 "function"); |
|
60 } |
|
61 |
|
62 eval("function notAnError1() { 5; '\\145'; function g() { 'use strict'; } }"); |
|
63 |
|
64 Function("function notAnError2() { 5; '\\145'; function g() { 'use strict'; } }"); |
|
65 |
|
66 function notAnError3() |
|
67 { |
|
68 5; |
|
69 "\145"; |
|
70 function g() { "use strict"; } |
|
71 } |
|
72 |
|
73 /******************************************************************************/ |
|
74 |
|
75 if (typeof reportCompare === "function") |
|
76 reportCompare(true, true); |
|
77 |
|
78 print("All tests passed!"); |