Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(173)

Side by Side Diff: test/mjsunit/object-literal.js

Issue 7348008: Merge up to 8597 to experimental/gc from the bleeding edge. (Closed) Base URL: http://v8.googlecode.com/svn/branches/experimental/gc/
Patch Set: '' Created 9 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « test/mjsunit/object-freeze.js ('k') | test/mjsunit/object-seal.js » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2009 the V8 project authors. All rights reserved. 1 // Copyright 2009 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 87 matching lines...) Expand 10 before | Expand all | Expand 10 after
98 assertFalse(a[0][0] === b[0][0]); 98 assertFalse(a[0][0] === b[0][0]);
99 assertFalse(a[0][1] === b[0][1]); 99 assertFalse(a[0][1] === b[0][1]);
100 100
101 function makeRegexpInObject() { return { a: { b: /b*/, c: {} } }; } 101 function makeRegexpInObject() { return { a: { b: /b*/, c: {} } }; }
102 a = makeRegexpInObject(); 102 a = makeRegexpInObject();
103 b = makeRegexpInObject(); 103 b = makeRegexpInObject();
104 assertFalse(a.a.b === b.a.b); 104 assertFalse(a.a.b === b.a.b);
105 assertFalse(a.a.c === b.a.c); 105 assertFalse(a.a.c === b.a.c);
106 106
107 107
108 // Test keywords valid as property names in initializers and dot-access. 108 // Test keywords are valid as property names in initializers and dot-access.
109 var keywords = [ 109 var keywords = [
110 "break", 110 "break",
111 "case", 111 "case",
112 "catch", 112 "catch",
113 "const", 113 "const",
114 "continue", 114 "continue",
115 "debugger", 115 "debugger",
116 "default", 116 "default",
117 "delete", 117 "delete",
118 "do", 118 "do",
119 "else", 119 "else",
120 "false", 120 "false",
121 "finally", 121 "finally",
122 "for", 122 "for",
123 "function", 123 "function",
124 "if", 124 "if",
125 "in", 125 "in",
126 "instanceof", 126 "instanceof",
127 "native",
128 "new", 127 "new",
129 "null", 128 "null",
130 "return", 129 "return",
131 "switch", 130 "switch",
132 "this", 131 "this",
133 "throw", 132 "throw",
134 "true", 133 "true",
135 "try", 134 "try",
136 "typeof", 135 "typeof",
137 "var", 136 "var",
138 "void", 137 "void",
139 "while", 138 "while",
140 "with", 139 "with"
141 ]; 140 ];
142 141
143 function testKeywordProperty(keyword) { 142 function testKeywordProperty(keyword) {
143 var exception = false;
144 try { 144 try {
145 // Sanity check that what we get is a keyword. 145 // Sanity check that what we get is a keyword.
146 eval("var " + keyword + " = 42;"); 146 eval("var " + keyword + " = 42;");
147 assertUnreachable("Not a keyword: " + keyword); 147 } catch (e) {
148 } catch (e) { } 148 exception = true;
149 }
150 assertTrue(exception);
149 151
150 // Simple property, read and write. 152 // Simple property, read and write.
151 var x = eval("({" + keyword + ": 42})"); 153 var x = eval("({" + keyword + ": 42})");
152 assertEquals(42, x[keyword]); 154 assertEquals(42, x[keyword]);
153 assertEquals(42, eval("x." + keyword)); 155 assertEquals(42, eval("x." + keyword));
154 eval("x." + keyword + " = 37"); 156 eval("x." + keyword + " = 37");
155 assertEquals(37, x[keyword]); 157 assertEquals(37, x[keyword]);
156 assertEquals(37, eval("x." + keyword)); 158 assertEquals(37, eval("x." + keyword));
157 159
158 // Getter/setter property, read and write. 160 // Getter/setter property, read and write.
(...skipping 21 matching lines...) Expand all
180 // Function property, constructed. 182 // Function property, constructed.
181 function construct() { this.constructed = true; } 183 function construct() { this.constructed = true; }
182 var v = eval("({" + keyword + ": construct})"); 184 var v = eval("({" + keyword + ": construct})");
183 var vo = eval("new v." + keyword + "()"); 185 var vo = eval("new v." + keyword + "()");
184 assertTrue(vo instanceof construct); 186 assertTrue(vo instanceof construct);
185 assertTrue(vo.constructed); 187 assertTrue(vo.constructed);
186 } 188 }
187 189
188 for (var i = 0; i < keywords.length; i++) { 190 for (var i = 0; i < keywords.length; i++) {
189 testKeywordProperty(keywords[i]); 191 testKeywordProperty(keywords[i]);
190 } 192 }
OLDNEW
« no previous file with comments | « test/mjsunit/object-freeze.js ('k') | test/mjsunit/object-seal.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698