OLD | NEW |
1 // Copyright 2011 the V8 project authors. All rights reserved. | 1 // Copyright 2011 the V8 project authors. All rights reserved. |
2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without |
3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are |
4 // met: | 4 // met: |
5 // | 5 // |
6 // * Redistributions of source code must retain the above copyright | 6 // * Redistributions of source code must retain the above copyright |
7 // notice, this list of conditions and the following disclaimer. | 7 // notice, this list of conditions and the following disclaimer. |
8 // * Redistributions in binary form must reproduce the above | 8 // * Redistributions in binary form must reproduce the above |
9 // copyright notice, this list of conditions and the following | 9 // copyright notice, this list of conditions and the following |
10 // disclaimer in the documentation and/or other materials provided | 10 // disclaimer in the documentation and/or other materials provided |
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
108 // "use strict";\ | 108 // "use strict";\ |
109 //}', SyntaxError); | 109 //}', SyntaxError); |
110 | 110 |
111 // Strict mode doesn't affect the outer stop of strict code. | 111 // Strict mode doesn't affect the outer stop of strict code. |
112 function NotStrict(eval) { | 112 function NotStrict(eval) { |
113 function Strict() { | 113 function Strict() { |
114 "use strict"; | 114 "use strict"; |
115 } | 115 } |
116 with ({}) {}; | 116 with ({}) {}; |
117 } | 117 } |
| 118 |
| 119 // Duplicate data properties. |
| 120 CheckStrictMode("var x = { dupe : 1, nondupe: 3, dupe : 2 };", SyntaxError) |
| 121 CheckStrictMode("var x = { '1234' : 1, '2345' : 2, '1234' : 3 };", SyntaxError) |
| 122 CheckStrictMode("var x = { '1234' : 1, '2345' : 2, 1234 : 3 };", SyntaxError) |
| 123 CheckStrictMode("var x = { 3.14 : 1, 2.71 : 2, 3.14 : 3 };", SyntaxError) |
| 124 CheckStrictMode("var x = { 3.14 : 1, '3.14' : 2 };", SyntaxError) |
| 125 CheckStrictMode("var x = { 123: 1, 123.00000000000000000000000000000000000000000
000000000000000000000000001 : 2 }", SyntaxError) |
| 126 |
| 127 // Non-conflicting data properties. |
| 128 function StrictModeNonDuplicate() { |
| 129 "use strict"; |
| 130 var x = { 123 : 1, "0123" : 2 }; |
| 131 var x = { 123: 1, '123.0000000000000000000000000000000000000000000000000000000
0000000000001' : 2 } |
| 132 } |
| 133 |
| 134 //CheckStrictMode("", SyntaxError) |
| 135 |
| 136 // Two getters (non-strict) |
| 137 assertThrows("var x = { get foo() { }, get foo() { } };", SyntaxError) |
| 138 assertThrows("var x = { get foo(){}, get 'foo'(){}};", SyntaxError) |
| 139 assertThrows("var x = { get 12(){}, get '12'(){}};", SyntaxError) |
| 140 |
| 141 // Two setters (non-strict) |
| 142 assertThrows("var x = { set foo(v) { }, set foo(v) { } };", SyntaxError) |
| 143 assertThrows("var x = { set foo(v) { }, set 'foo'(v) { } };", SyntaxError) |
| 144 assertThrows("var x = { set 13(v) { }, set '13'(v) { } };", SyntaxError) |
| 145 |
| 146 // Setter and data (non-strict) |
| 147 assertThrows("var x = { foo: 'data', set foo(v) { } };", SyntaxError) |
| 148 assertThrows("var x = { set foo(v) { }, foo: 'data' };", SyntaxError) |
| 149 assertThrows("var x = { foo: 'data', set 'foo'(v) { } };", SyntaxError) |
| 150 assertThrows("var x = { set foo(v) { }, 'foo': 'data' };", SyntaxError) |
| 151 assertThrows("var x = { 'foo': 'data', set foo(v) { } };", SyntaxError) |
| 152 assertThrows("var x = { set 'foo'(v) { }, foo: 'data' };", SyntaxError) |
| 153 assertThrows("var x = { 'foo': 'data', set 'foo'(v) { } };", SyntaxError) |
| 154 assertThrows("var x = { set 'foo'(v) { }, 'foo': 'data' };", SyntaxError) |
| 155 assertThrows("var x = { 12: 1, set '12'(v){}};", SyntaxError); |
| 156 assertThrows("var x = { 12: 1, set 12(v){}};", SyntaxError); |
| 157 assertThrows("var x = { '12': 1, set '12'(v){}};", SyntaxError); |
| 158 assertThrows("var x = { '12': 1, set 12(v){}};", SyntaxError); |
| 159 |
| 160 // Getter and data (non-strict) |
| 161 assertThrows("var x = { foo: 'data', get foo() { } };", SyntaxError) |
| 162 assertThrows("var x = { get foo() { }, foo: 'data' };", SyntaxError) |
| 163 assertThrows("var x = { 'foo': 'data', get foo() { } };", SyntaxError) |
| 164 assertThrows("var x = { get 'foo'() { }, 'foo': 'data' };", SyntaxError) |
| 165 assertThrows("var x = { '12': 1, get '12'(){}};", SyntaxError); |
| 166 assertThrows("var x = { '12': 1, get 12(){}};", SyntaxError); |
OLD | NEW |