File indexing completed on 2024-04-28 15:28:38
0001 function test() { return;} 0002 function test() { while(0) break; } 0003 function test() { while(0) continue; } 0004 0005 function test() { return lab;} 0006 function test() { while(0) break lab; } 0007 function test() { while(0) continue lab; } 0008 0009 function test() { return } 0010 function test() { while(0) break } 0011 function test() { while(0) continue } 0012 0013 function test() { return 0 } 0014 function test() { while(0) break lab } 0015 function test() { while(0) continue lab } 0016 0017 lab: 0018 0019 a = 1 0020 b = 123 // comment 0021 c = 2 0022 c = 3 /* comment */ 0023 d = 4 0024 0025 // non-ascii identifier letters (not working copy of Mozilla?!) 0026 var ident = ""; 0027 ident += "\u00E9"; // LATIN SMALL LETTER E WITH ACUTE 0028 ident += "\u0100"; // LATIN CAPITAL LETTER A WITH MACRON 0029 ident += "\u02af"; // LATIN SMALL LETTER TURNED H WITH FISHHOOK AND TAIL 0030 ident += "\u0388"; // GREEK CAPITAL LETTER EPSILON WITH TONOS 0031 ident += "\u18A8"; // MONGOLIAN LETTER MANCHU ALI GALI BHA 0032 var code = "var " + ident + " = 11; " + ident + ";"; 0033 var res; 0034 try { 0035 res = eval(code); 0036 } catch( e ) { 0037 res = "exception. Missing Unicode support?"; 0038 } 0039 shouldBe("res", "11"); 0040 0041 var f\u006fo = 33; 0042 shouldBe("foo", "33"); 0043 var \u0062ar = 44; 0044 shouldBe("bar", "44"); 0045 0046 // invalid identifier letters 0047 shouldThrow("var f\xF7;"); 0048 0049 // ASCII identifier characters as escape sequences 0050 shouldBe("var \\u0061 = 102; a", "102"); 0051 shouldBe("var f\\u0030 = 103; f0", "103"); 0052 0053 // non-ASCII identifier letters as escape sequences 0054 shouldBe("var \\u00E9\\u0100\\u02AF\\u0388\\u18A8 = 104; \\u00E9\\u0100\\u02AF\\u0388\\u18A8;", "104"); 0055 0056 // invalid identifier characters as escape sequences 0057 shouldThrow("var f\\u00F7;"); 0058 shouldThrow("var \\u0030;"); 0059 shouldThrow("var test = { }; test.i= 0; test.i\\u002b= 1; test.i;"); 0060 0061 shouldBe("var test = { }; test.i= 0; test.i\u002b= 1; test.i;", "1"); 0062 0063 var stringWithNull = "'a" + String.fromCharCode(0) + "x'"; 0064 shouldBe("eval(stringWithNull)", stringWithNull); 0065 0066 // keywords can't be escaped 0067 var caughtInvalidIf = false; 0068 try { 0069 eval("i\\u0066 (1);"); // escaped 'if' 0070 } catch (e) { 0071 caughtInvalidIf = true; 0072 } 0073 shouldBeTrue("caughtInvalidIf"); 0074 0075 var i\u0066 = "escapedIf"; 0076 shouldBe("i\\u0066", "'escapedIf'"); 0077 0078 debug("Done.");