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