js/src/tests/ecma_5/eval/line-terminator-paragraph-terminator.js

branch
TOR_BUG_3246
changeset 7
129ffea94266
equal deleted inserted replaced
-1:000000000000 0:97a7d49f4381
1 // Any copyright is dedicated to the Public Domain.
2 // http://creativecommons.org/licenses/publicdomain/
3
4 //-----------------------------------------------------------------------------
5 var BUGNUMBER = 657367;
6 var summary = "eval must not parse strings containing U+2028 or U+2029";
7
8 print(BUGNUMBER + ": " + summary);
9
10 /**************
11 * BEGIN TEST *
12 **************/
13
14 function esc(s)
15 {
16 return s.split("").map(function(v)
17 {
18 var code =
19 ("000" + v.charCodeAt(0).toString(16)).slice(-4);
20 return "\\u" + code;
21 }).join("");
22 }
23
24 try
25 {
26 var r = eval('"\u2028"');
27 throw new Error("\"\\u2028\" didn't throw, returned " + esc(r));
28 }
29 catch (e)
30 {
31 assertEq(e instanceof SyntaxError, true,
32 "U+2028 is not a valid string character");
33 }
34
35 try
36 {
37 var r = eval('("\u2028")');
38 throw new Error("(\"\\u2028\") didn't throw, returned " + esc(r));
39 }
40 catch (e)
41 {
42 assertEq(e instanceof SyntaxError, true,
43 "U+2028 is not a valid string character");
44 }
45
46 try
47 {
48 var r = eval('"\u2029"');
49 throw new Error("\"\\u2029\" didn't throw, returned " + esc(r));
50 }
51 catch (e)
52 {
53 assertEq(e instanceof SyntaxError, true,
54 "U+2029 is not a valid string character");
55 }
56
57 try
58 {
59 var r = eval('("\u2029")');
60 throw new Error("(\"\\u2029\") didn't throw, returned " + esc(r));
61 }
62 catch (e)
63 {
64 assertEq(e instanceof SyntaxError, true,
65 "U+2029 is not a valid string character");
66 }
67
68 /******************************************************************************/
69
70 if (typeof reportCompare === "function")
71 reportCompare(true, true);
72
73 print("Tests complete!");

mercurial