Chromium Code Reviews| 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 | |
|
Lasse Reichstein
2011/01/25 11:19:03
For good measure, try with
var x = {123: 1, "0123
Lasse Reichstein
2011/01/25 11:19:03
Also try get/set properties using strings and numb
Martin Maly
2011/01/25 18:29:23
Done.
Martin Maly
2011/01/25 18:29:23
Done.
| |
| 126 // Two getters (non-strict) | |
| 127 assertThrows("var x = { get foo() { }, get foo() { } };", SyntaxError) | |
| 128 | |
| 129 // Two setters (non-strict) | |
| 130 assertThrows("var x = { set foo(v) { }, set foo(v) { } };", SyntaxError) | |
| 131 | |
| 132 // Setter and data (non-strict) | |
| 133 assertThrows("var x = { foo: 'data', set foo(v) { } };", SyntaxError) | |
| 134 assertThrows("var x = { set foo(v) { }, foo: 'data' };", SyntaxError) | |
| 135 | |
| 136 // Getter and data (non-strict) | |
| 137 assertThrows("var x = { foo: 'data', get foo() { } };", SyntaxError) | |
| 138 assertThrows("var x = { get foo() { }, foo: 'data' };", SyntaxError) | |
| OLD | NEW |