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

Side by Side Diff: test/mjsunit/harmony/symbols.js

Issue 12455002: ES6 symbols: filter symbols form for-in loops and Object.keys (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 7 years, 9 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 | « src/v8natives.js ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2013 the V8 project authors. All rights reserved. 1 // Copyright 2013 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 144 matching lines...) Expand 10 before | Expand all | Expand 10 after
155 155
156 function TestKeyHas() { 156 function TestKeyHas() {
157 for (var i in symbols) { 157 for (var i in symbols) {
158 assertTrue(symbols[i] in obj) 158 assertTrue(symbols[i] in obj)
159 assertTrue(Object.hasOwnProperty.call(obj, symbols[i])) 159 assertTrue(Object.hasOwnProperty.call(obj, symbols[i]))
160 } 160 }
161 } 161 }
162 162
163 163
164 function TestKeyEnum(obj) { 164 function TestKeyEnum(obj) {
165 // TODO(rossberg): symbols should not show up at all in for-in. 165 for (var name in obj) {
166 var found = []; 166 assertFalse(%_IsSymbol(name))
167 names: for (var name in obj) {
168 for (var i in symbols) {
169 if (name === symbols[i]) {
170 found[i] = true;
171 continue names;
172 }
173 }
174 }
175 // All even symbols should have been enumerated.
176 for (var i = 0; i < symbols.length; i += 2) {
177 assertTrue(i in found)
178 } 167 }
179 } 168 }
180 169
181 170
182 function TestKeyKeys(obj) { 171 function TestKeyKeys(obj) {
183 // TODO(rossberg): symbols should not be returned by Object.keys. 172 assertEquals(0, Object.keys(obj).length)
184 assertEquals(symbols.length / 2, Object.keys(obj).length)
185 assertTrue(symbols.length <= Object.getOwnPropertyNames(obj).length) 173 assertTrue(symbols.length <= Object.getOwnPropertyNames(obj).length)
186 } 174 }
187 175
188 176
189 function TestKeyDescriptor(obj) { 177 function TestKeyDescriptor(obj) {
190 for (var i in symbols) { 178 for (var i in symbols) {
191 var desc = Object.getOwnPropertyDescriptor(obj, symbols[i]); 179 var desc = Object.getOwnPropertyDescriptor(obj, symbols[i]);
192 assertEquals(i|0, desc.value) 180 assertEquals(i|0, desc.value)
193 assertTrue(desc.configurable) 181 assertTrue(desc.configurable)
194 assertEquals(i % 2 == 0, desc.writable) 182 assertEquals(i % 2 == 0, desc.writable)
(...skipping 20 matching lines...) Expand all
215 var obj = objs[i] 203 var obj = objs[i]
216 TestKeySet(obj) 204 TestKeySet(obj)
217 TestKeyDefine(obj) 205 TestKeyDefine(obj)
218 TestKeyGet(obj) 206 TestKeyGet(obj)
219 TestKeyHas(obj) 207 TestKeyHas(obj)
220 TestKeyEnum(obj) 208 TestKeyEnum(obj)
221 TestKeyKeys(obj) 209 TestKeyKeys(obj)
222 TestKeyDescriptor(obj) 210 TestKeyDescriptor(obj)
223 TestKeyDelete(obj) 211 TestKeyDelete(obj)
224 } 212 }
OLDNEW
« no previous file with comments | « src/v8natives.js ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698