]>
git.saurik.com Git - apple/javascriptcore.git/blob - tests/stress/reserved-word-with-escape.js
60335f294345bcc98cf974f4f4f6cca1025974c7
1 function testSyntax ( script
) {
5 if ( error
instanceof SyntaxError
)
6 throw new Error ( "Bad error: " + String ( error
));
10 function testSyntaxError ( script
, message
) {
18 throw new Error ( "Expected syntax error not thrown" );
20 if ( String ( error
) !== message
)
21 throw new Error ( "Bad error: " + String ( error
));
24 testSyntax ( "var cocoa" );
25 testSyntax ( "var c \u006fc oa" );
27 testSyntaxError ( String
. raw
`var var` , String
. raw
`SyntaxError: Cannot use the keyword 'var' as a variable name.` );
28 testSyntaxError ( String
. raw
`var v \u0061 r` , String
. raw
`SyntaxError: Cannot use the keyword 'v \u0061 r' as a variable name.` );
29 testSyntaxError ( String
. raw
`var v \u{0061} r` , String
. raw
`SyntaxError: Cannot use the keyword 'v \u{0061} r' as a variable name.` );
31 testSyntaxError ( String
. raw
`var var = 2000000;` , String
. raw
`SyntaxError: Cannot use the keyword 'var' as a variable name.` );
32 testSyntaxError ( String
. raw
`var v \u0061 r = 2000000;` , String
. raw
`SyntaxError: Cannot use the keyword 'v \u0061 r' as a variable name.` );
33 testSyntaxError ( String
. raw
`var v \u{0061} r = 2000000` , String
. raw
`SyntaxError: Cannot use the keyword 'v \u{0061} r' as a variable name.` );
35 testSyntaxError ( String
. raw
`var {var} = obj)` , String
. raw
`SyntaxError: Cannot use abbreviated destructuring syntax for keyword 'var'.` );
36 testSyntaxError ( String
. raw
`var {v \u0061 r} = obj` , String
. raw
`SyntaxError: Cannot use abbreviated destructuring syntax for keyword 'var'.` );
37 testSyntaxError ( String
. raw
`var {v \u{0061} r} = obj` , String
. raw
`SyntaxError: Cannot use abbreviated destructuring syntax for keyword 'var'.` );
39 testSyntaxError ( String
. raw
`var {var:var} = obj)` , String
. raw
`SyntaxError: Cannot use the keyword 'var' as a variable name.` );
40 testSyntaxError ( String
. raw
`var {var:v \u0061 r} = obj` , String
. raw
`SyntaxError: Cannot use the keyword 'v \u0061 r' as a variable name.` );
41 testSyntaxError ( String
. raw
`var {var:v \u{0061} r} = obj` , String
. raw
`SyntaxError: Cannot use the keyword 'v \u{0061} r' as a variable name.` );
43 testSyntaxError ( String
. raw
`var [var] = obj` , String
. raw
`SyntaxError: Cannot use the keyword 'var' as a variable name.` );
44 testSyntaxError ( String
. raw
`var [v \u0061 r] = obj` , String
. raw
`SyntaxError: Cannot use the keyword 'v \u0061 r' as a variable name.` );
45 testSyntaxError ( String
. raw
`var [v \u{0061} r] = obj` , String
. raw
`SyntaxError: Cannot use the keyword 'v \u{0061} r' as a variable name.` );
47 testSyntaxError ( String
. raw
`[var] = obj` , String
. raw
`SyntaxError: Unexpected keyword 'var'` );
48 testSyntaxError ( String
. raw
`[v \u0061 r] = obj` , String
. raw
`SyntaxError: Unexpected keyword 'v \u0061 r'` );
49 testSyntaxError ( String
. raw
`[v \u{0061} r] = obj` , String
. raw
`SyntaxError: Unexpected keyword 'v \u{0061} r'` );
51 testSyntaxError ( String
. raw
`function var() { }` , String
. raw
`SyntaxError: Cannot use the keyword 'var' as a function name.` );
52 testSyntaxError ( String
. raw
`function v \u0061 r() { }` , String
. raw
`SyntaxError: Cannot use the keyword 'v \u0061 r' as a function name.` );
53 testSyntaxError ( String
. raw
`function v \u{0061} r() { }` , String
. raw
`SyntaxError: Cannot use the keyword 'v \u{0061} r' as a function name.` );
55 testSyntaxError ( String
. raw
`function a(var) { }` , String
. raw
`SyntaxError: Cannot use the keyword 'var' as a variable name.` );
56 testSyntaxError ( String
. raw
`function a(v \u0061 r) { }` , String
. raw
`SyntaxError: Cannot use the keyword 'v \u0061 r' as a variable name.` );
57 testSyntaxError ( String
. raw
`function a(v \u{0061} r) { }` , String
. raw
`SyntaxError: Cannot use the keyword 'v \u{0061} r' as a variable name.` );
59 testSyntaxError ( String
. raw
`function a({var}) { }` , String
. raw
`SyntaxError: Cannot use abbreviated destructuring syntax for keyword 'var'.` );
60 testSyntaxError ( String
. raw
`function a({v \u0061 r}) { }` , String
. raw
`SyntaxError: Cannot use abbreviated destructuring syntax for keyword 'var'.` );
61 testSyntaxError ( String
. raw
`function a({v \u{0061} r}) { }` , String
. raw
`SyntaxError: Cannot use abbreviated destructuring syntax for keyword 'var'.` );
63 testSyntaxError ( String
. raw
`function a({var:var}) { }` , String
. raw
`SyntaxError: Cannot use the keyword 'var' as a variable name.` );
64 testSyntaxError ( String
. raw
`function a({var:v \u0061 r}) { }` , String
. raw
`SyntaxError: Cannot use the keyword 'v \u0061 r' as a variable name.` );
65 testSyntaxError ( String
. raw
`function a({var:v \u{0061} r}) { }` , String
. raw
`SyntaxError: Cannot use the keyword 'v \u{0061} r' as a variable name.` );
67 testSyntaxError ( String
. raw
`function a([var]) { }` , String
. raw
`SyntaxError: Cannot use the keyword 'var' as a variable name.` );
68 testSyntaxError ( String
. raw
`function a([v \u0061 r]) { }` , String
. raw
`SyntaxError: Cannot use the keyword 'v \u0061 r' as a variable name.` );
69 testSyntaxError ( String
. raw
`function a([v \u{0061} r]) { }` , String
. raw
`SyntaxError: Cannot use the keyword 'v \u{0061} r' as a variable name.` );
71 testSyntaxError ( String
. raw
`(function var() { })` , String
. raw
`SyntaxError: Cannot use the keyword 'var' as a function name.` );
72 testSyntaxError ( String
. raw
`(function v \u0061 r() { })` , String
. raw
`SyntaxError: Cannot use the keyword 'v \u0061 r' as a function name.` );
73 testSyntaxError ( String
. raw
`(function v \u{0061} r() { })` , String
. raw
`SyntaxError: Cannot use the keyword 'v \u{0061} r' as a function name.` );
75 testSyntaxError ( String
. raw
`(function a(var) { })` , String
. raw
`SyntaxError: Cannot use the keyword 'var' as a variable name.` );
76 testSyntaxError ( String
. raw
`(function a(v \u0061 r) { })` , String
. raw
`SyntaxError: Cannot use the keyword 'v \u0061 r' as a variable name.` );
77 testSyntaxError ( String
. raw
`(function a(v \u{0061} r) { })` , String
. raw
`SyntaxError: Cannot use the keyword 'v \u{0061} r' as a variable name.` );
79 testSyntaxError ( String
. raw
`(function a({var}) { })` , String
. raw
`SyntaxError: Cannot use abbreviated destructuring syntax for keyword 'var'.` );
80 testSyntaxError ( String
. raw
`(function a({v \u0061 r}) { })` , String
. raw
`SyntaxError: Cannot use abbreviated destructuring syntax for keyword 'var'.` );
81 testSyntaxError ( String
. raw
`(function a({v \u{0061} r}) { })` , String
. raw
`SyntaxError: Cannot use abbreviated destructuring syntax for keyword 'var'.` );
83 testSyntaxError ( String
. raw
`(function a({var:var}) { })` , String
. raw
`SyntaxError: Cannot use the keyword 'var' as a variable name.` );
84 testSyntaxError ( String
. raw
`(function a({var:v \u0061 r}) { })` , String
. raw
`SyntaxError: Cannot use the keyword 'v \u0061 r' as a variable name.` );
85 testSyntaxError ( String
. raw
`(function a({var:v \u{0061} r}) { })` , String
. raw
`SyntaxError: Cannot use the keyword 'v \u{0061} r' as a variable name.` );
87 testSyntaxError ( String
. raw
`(function a([var]) { })` , String
. raw
`SyntaxError: Cannot use the keyword 'var' as a variable name.` );
88 testSyntaxError ( String
. raw
`(function a([v \u0061 r]) { })` , String
. raw
`SyntaxError: Cannot use the keyword 'v \u0061 r' as a variable name.` );
89 testSyntaxError ( String
. raw
`(function a([v \u{0061} r]) { })` , String
. raw
`SyntaxError: Cannot use the keyword 'v \u{0061} r' as a variable name.` );
91 testSyntaxError ( String
. raw
`(function a([{var}]) { })` , String
. raw
`SyntaxError: Cannot use abbreviated destructuring syntax for keyword 'var'.` );
92 testSyntaxError ( String
. raw
`(function a([{v \u0061 r}]) { })` , String
. raw
`SyntaxError: Cannot use abbreviated destructuring syntax for keyword 'var'.` );
93 testSyntaxError ( String
. raw
`(function a([{v \u{0061} r}]) { })` , String
. raw
`SyntaxError: Cannot use abbreviated destructuring syntax for keyword 'var'.` );
95 testSyntaxError ( String
. raw
`(function a([{var:var}]) { })` , String
. raw
`SyntaxError: Cannot use the keyword 'var' as a variable name.` );
96 testSyntaxError ( String
. raw
`(function a([{var:v \u0061 r}]) { })` , String
. raw
`SyntaxError: Cannot use the keyword 'v \u0061 r' as a variable name.` );
97 testSyntaxError ( String
. raw
`(function a([{var:v \u{0061} r}]) { })` , String
. raw
`SyntaxError: Cannot use the keyword 'v \u{0061} r' as a variable name.` );
99 testSyntaxError ( String
. raw
`(function a([[var]]) { })` , String
. raw
`SyntaxError: Cannot use the keyword 'var' as a variable name.` );
100 testSyntaxError ( String
. raw
`(function a([[v \u0061 r]]) { })` , String
. raw
`SyntaxError: Cannot use the keyword 'v \u0061 r' as a variable name.` );
101 testSyntaxError ( String
. raw
`(function a([[v \u{0061} r]]) { })` , String
. raw
`SyntaxError: Cannot use the keyword 'v \u{0061} r' as a variable name.` );
103 testSyntaxError ( String
. raw
`(function a({ hello: {var}}) { })` , String
. raw
`SyntaxError: Cannot use abbreviated destructuring syntax for keyword 'var'.` );
104 testSyntaxError ( String
. raw
`(function a({ hello: {v \u0061 r}}) { })` , String
. raw
`SyntaxError: Cannot use abbreviated destructuring syntax for keyword 'var'.` );
105 testSyntaxError ( String
. raw
`(function a({ hello: {v \u{0061} r}}) { })` , String
. raw
`SyntaxError: Cannot use abbreviated destructuring syntax for keyword 'var'.` );
107 testSyntaxError ( String
. raw
`(function a({ hello: {var:var}}) { })` , String
. raw
`SyntaxError: Cannot use the keyword 'var' as a variable name.` );
108 testSyntaxError ( String
. raw
`(function a({ hello: {var:v \u0061 r}}) { })` , String
. raw
`SyntaxError: Cannot use the keyword 'v \u0061 r' as a variable name.` );
109 testSyntaxError ( String
. raw
`(function a({ hello: {var:v \u{0061} r}}) { })` , String
. raw
`SyntaxError: Cannot use the keyword 'v \u{0061} r' as a variable name.` );
111 testSyntaxError ( String
. raw
`(function a({ hello: [var]}) { })` , String
. raw
`SyntaxError: Cannot use the keyword 'var' as a variable name.` );
112 testSyntaxError ( String
. raw
`(function a({ hello: [v \u0061 r]}) { })` , String
. raw
`SyntaxError: Cannot use the keyword 'v \u0061 r' as a variable name.` );
113 testSyntaxError ( String
. raw
`(function a({ hello: [v \u{0061} r]}) { })` , String
. raw
`SyntaxError: Cannot use the keyword 'v \u{0061} r' as a variable name.` );
115 testSyntaxError ( String
. raw
`(function a({ 0: {var} }) { })` , String
. raw
`SyntaxError: Cannot use abbreviated destructuring syntax for keyword 'var'.` );
116 testSyntaxError ( String
. raw
`(function a({ 0: {v \u0061 r}}) { })` , String
. raw
`SyntaxError: Cannot use abbreviated destructuring syntax for keyword 'var'.` );
117 testSyntaxError ( String
. raw
`(function a({ 0: {v \u{0061} r}}) { })` , String
. raw
`SyntaxError: Cannot use abbreviated destructuring syntax for keyword 'var'.` );
119 testSyntaxError ( String
. raw
`(function a({ 0: {var:var}}) { })` , String
. raw
`SyntaxError: Cannot use the keyword 'var' as a variable name.` );
120 testSyntaxError ( String
. raw
`(function a({ 0: {var:v \u0061 r}}) { })` , String
. raw
`SyntaxError: Cannot use the keyword 'v \u0061 r' as a variable name.` );
121 testSyntaxError ( String
. raw
`(function a({ 0: {var:v \u{0061} r}}) { })` , String
. raw
`SyntaxError: Cannot use the keyword 'v \u{0061} r' as a variable name.` );
123 testSyntaxError ( String
. raw
`(function a({ 0: {value:var}}) { })` , String
. raw
`SyntaxError: Cannot use the keyword 'var' as a variable name.` );
124 testSyntaxError ( String
. raw
`(function a({ 0: {value:v \u0061 r}}) { })` , String
. raw
`SyntaxError: Cannot use the keyword 'v \u0061 r' as a variable name.` );
125 testSyntaxError ( String
. raw
`(function a({ 0: {value:v \u{0061} r}}) { })` , String
. raw
`SyntaxError: Cannot use the keyword 'v \u{0061} r' as a variable name.` );
127 testSyntaxError ( String
. raw
`(function a({ 0: [var]}) { })` , String
. raw
`SyntaxError: Cannot use the keyword 'var' as a variable name.` );
128 testSyntaxError ( String
. raw
`(function a({ 0: [v \u0061 r]}) { })` , String
. raw
`SyntaxError: Cannot use the keyword 'v \u0061 r' as a variable name.` );
129 testSyntaxError ( String
. raw
`(function a({ 0: [v \u{0061} r]}) { })` , String
. raw
`SyntaxError: Cannot use the keyword 'v \u{0061} r' as a variable name.` );
131 testSyntaxError ( String
. raw
`try { } catch(var) { }` , String
. raw
`SyntaxError: Cannot use the keyword 'var' as a catch variable name.` );
132 testSyntaxError ( String
. raw
`try { } catch(v \u0061 r) { }` , String
. raw
`SyntaxError: Cannot use the keyword 'v \u0061 r' as a catch variable name.` );
133 testSyntaxError ( String
. raw
`try { } catch(v \u{0061} r) { }` , String
. raw
`SyntaxError: Cannot use the keyword 'v \u{0061} r' as a catch variable name.` );
135 testSyntaxError ( String
. raw
`class var { }` , String
. raw
`SyntaxError: Cannot use the keyword 'var' as a class name.` );
136 testSyntaxError ( String
. raw
`class v \u0061 r { }` , String
. raw
`SyntaxError: Cannot use the keyword 'v \u0061 r' as a class name.` );
137 testSyntaxError ( String
. raw
`class v \u{0061} r { }` , String
. raw
`SyntaxError: Cannot use the keyword 'v \u{0061} r' as a class name.` );
139 // Allowed in non-keyword aware context.
140 testSyntax ( String
. raw
`({ v \u0061 r: 'Cocoa' })` );
141 testSyntax ( String
. raw
`({ v \u{0061} r: 'Cocoa' })` );