Merge Chromium + Blink git repositories
[chromium-blink-merge.git] / third_party / WebKit / LayoutTests / fast / js / mozilla / strict / script-tests / directive-prologue-01.js
blob2b635c7c570c17548544b1bf2f18adf18f26b2b3
1 // Any copyright is dedicated to the Public Domain.
2 // http://creativecommons.org/licenses/publicdomain/
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";
10 print(BUGNUMBER + ": " + summary);
12 /**************
13 * BEGIN TEST *
14 **************/
16 try
18 eval(" '\\145'; 'use strict'; ");
19 throw new Error("no error thrown for eval");
21 catch (e)
23 assertEq(e instanceof SyntaxError, true,
24 "wrong error for octal-escape before strict directive in eval");
27 try
29 Function(" '\\145'; 'use strict'; ");
30 throw new Error("no error thrown for Function");
32 catch (e)
34 assertEq(e instanceof SyntaxError, true,
35 "wrong error for octal-escape before strict directive in Function");
38 try
40 eval(" function f(){ '\\145'; 'use strict'; } ");
41 throw new Error("no error thrown for eval of function");
43 catch (e)
45 assertEq(e instanceof SyntaxError, true,
46 "wrong error for octal-escape before strict directive in eval of " +
47 "function");
50 try
52 Function(" function f(){ '\\145'; 'use strict'; } ");
53 throw new Error("no error thrown for eval of function");
55 catch (e)
57 assertEq(e instanceof SyntaxError, true,
58 "wrong error for octal-escape before strict directive in eval of " +
59 "function");
62 eval("function notAnError1() { 5; '\\145'; function g() { 'use strict'; } }");
64 Function("function notAnError2() { 5; '\\145'; function g() { 'use strict'; } }");
66 function notAnError3()
69 "\145";
70 function g() { "use strict"; }
73 /******************************************************************************/
75 if (typeof reportCompare === "function")
76 reportCompare(true, true);
78 print("All tests passed!");
80 var successfullyParsed = true;