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

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

Issue 12456004: ES6 symbols: enable symbols as weak map 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/runtime.cc ('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 96 matching lines...) Expand 10 before | Expand all | Expand 10 after
107 assertEquals(undefined, symbols[i].a) 107 assertEquals(undefined, symbols[i].a)
108 symbols[i]["a" + "b"] = 0 108 symbols[i]["a" + "b"] = 0
109 assertEquals(undefined, symbols[i]["a" + "b"]) 109 assertEquals(undefined, symbols[i]["a" + "b"])
110 symbols[i][62] = 0 110 symbols[i][62] = 0
111 assertEquals(undefined, symbols[i][62]) 111 assertEquals(undefined, symbols[i][62])
112 } 112 }
113 } 113 }
114 TestSet() 114 TestSet()
115 115
116 116
117 function TestMap() { 117 function TestCollections() {
118 var set = new Set
118 var map = new Map 119 var map = new Map
120 var weakmap = new WeakMap
119 for (var i in symbols) { 121 for (var i in symbols) {
122 set.add(symbols[i])
120 map.set(symbols[i], i) 123 map.set(symbols[i], i)
124 weakmap.set(symbols[i], i)
125 }
126 assertEquals(symbols.length, set.size)
127 assertEquals(symbols.length, map.size)
128 for (var i in symbols) {
129 assertTrue(set.has(symbols[i]))
130 assertTrue(map.has(symbols[i]))
131 assertTrue(weakmap.has(symbols[i]))
132 assertEquals(i, map.get(symbols[i]))
133 assertEquals(i, weakmap.get(symbols[i]))
121 } 134 }
122 for (var i in symbols) { 135 for (var i in symbols) {
123 assertTrue(map.has(symbols[i])) 136 assertTrue(set.delete(symbols[i]))
124 assertEquals(i, map.get(symbols[i])) 137 assertTrue(map.delete(symbols[i]))
138 assertTrue(weakmap.delete(symbols[i]))
125 } 139 }
140 assertEquals(0, set.size)
141 assertEquals(0, map.size)
126 } 142 }
127 TestMap() 143 TestCollections()
128 144
129 145
130 146
131 function TestKeySet(obj) { 147 function TestKeySet(obj) {
132 // Set the even symbols via assignment. 148 // Set the even symbols via assignment.
133 for (var i = 0; i < symbols.length; i += 2) { 149 for (var i = 0; i < symbols.length; i += 2) {
134 obj[symbols[i]] = i 150 obj[symbols[i]] = i
135 } 151 }
136 } 152 }
137 153
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after
215 var obj = objs[i] 231 var obj = objs[i]
216 TestKeySet(obj) 232 TestKeySet(obj)
217 TestKeyDefine(obj) 233 TestKeyDefine(obj)
218 TestKeyGet(obj) 234 TestKeyGet(obj)
219 TestKeyHas(obj) 235 TestKeyHas(obj)
220 TestKeyEnum(obj) 236 TestKeyEnum(obj)
221 TestKeyKeys(obj) 237 TestKeyKeys(obj)
222 TestKeyDescriptor(obj) 238 TestKeyDescriptor(obj)
223 TestKeyDelete(obj) 239 TestKeyDelete(obj)
224 } 240 }
OLDNEW
« no previous file with comments | « src/runtime.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698