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

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

Issue 12432005: ES6 symbols: refine test for getOwnPropertyNames (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Addressed comment 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 | « no previous file | 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 166 matching lines...) Expand 10 before | Expand all | Expand 10 after
177 } 177 }
178 178
179 179
180 function TestKeyEnum(obj) { 180 function TestKeyEnum(obj) {
181 for (var name in obj) { 181 for (var name in obj) {
182 assertFalse(%_IsSymbol(name)) 182 assertFalse(%_IsSymbol(name))
183 } 183 }
184 } 184 }
185 185
186 186
187 function TestKeyKeys(obj) { 187 function TestKeyNames(obj) {
188 assertEquals(0, Object.keys(obj).length) 188 assertEquals(0, Object.keys(obj).length)
189 assertTrue(symbols.length <= Object.getOwnPropertyNames(obj).length) 189
190 var names = Object.getOwnPropertyNames(obj)
191 assertTrue(symbols.length <= names.length)
192 // TODO(rossberg): once we have iterators, the following would be:
193 // var expected = new Set(symbols)
194 var expected = new Set
195 for (var i = 0; i < symbols.length; ++i) expected.add(symbols[i])
196 for (var i = 0; i < names.length; ++i) {
197 var name = names[i]
198 var asString = String(name)
199 if (asString !== name) {
200 assertEquals("[object Symbol]", asString)
201 assertTrue(expected.has(name))
202 expected.delete(name)
203 }
204 }
205 assertEquals(0, expected.size)
190 } 206 }
191 207
192 208
193 function TestKeyDescriptor(obj) { 209 function TestKeyDescriptor(obj) {
194 for (var i in symbols) { 210 for (var i in symbols) {
195 var desc = Object.getOwnPropertyDescriptor(obj, symbols[i]); 211 var desc = Object.getOwnPropertyDescriptor(obj, symbols[i]);
196 assertEquals(i|0, desc.value) 212 assertEquals(i|0, desc.value)
197 assertTrue(desc.configurable) 213 assertTrue(desc.configurable)
198 assertEquals(i % 2 == 0, desc.writable) 214 assertEquals(i % 2 == 0, desc.writable)
199 assertEquals(i % 2 == 0, desc.enumerable) 215 assertEquals(i % 2 == 0, desc.enumerable)
(...skipping 15 matching lines...) Expand all
215 231
216 var objs = [{}, [], Object.create(null), Object(1), new Map, function(){}] 232 var objs = [{}, [], Object.create(null), Object(1), new Map, function(){}]
217 233
218 for (var i in objs) { 234 for (var i in objs) {
219 var obj = objs[i] 235 var obj = objs[i]
220 TestKeySet(obj) 236 TestKeySet(obj)
221 TestKeyDefine(obj) 237 TestKeyDefine(obj)
222 TestKeyGet(obj) 238 TestKeyGet(obj)
223 TestKeyHas(obj) 239 TestKeyHas(obj)
224 TestKeyEnum(obj) 240 TestKeyEnum(obj)
225 TestKeyKeys(obj) 241 TestKeyNames(obj)
226 TestKeyDescriptor(obj) 242 TestKeyDescriptor(obj)
227 TestKeyDelete(obj) 243 TestKeyDelete(obj)
228 } 244 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698