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

Side by Side Diff: tracing/tracing/base/iteration_helpers_test.html

Issue 2955053002: Remove tr.b.identity. (Closed)
Patch Set: Created 3 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
« no previous file with comments | « tracing/tracing/base/iteration_helpers.html ('k') | tracing/tracing/base/math/range.html » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 <!DOCTYPE html> 1 <!DOCTYPE html>
2 <!-- 2 <!--
3 Copyright (c) 2014 The Chromium Authors. All rights reserved. 3 Copyright (c) 2014 The Chromium Authors. All rights reserved.
4 Use of this source code is governed by a BSD-style license that can be 4 Use of this source code is governed by a BSD-style license that can be
5 found in the LICENSE file. 5 found in the LICENSE file.
6 --> 6 -->
7 <link rel="import" href="/tracing/base/iteration_helpers.html"> 7 <link rel="import" href="/tracing/base/iteration_helpers.html">
8 <script> 8 <script>
9 'use strict'; 9 'use strict';
10 10
(...skipping 236 matching lines...) Expand 10 before | Expand all | Expand 10 after
247 const dict = tr.b.arrayToDict(array, function(value) { 247 const dict = tr.b.arrayToDict(array, function(value) {
248 return this.prefix + value; 248 return this.prefix + value;
249 }, fakeThis); 249 }, fakeThis);
250 assert.deepEqual(dict, { 250 assert.deepEqual(dict, {
251 'key_5': 5, 251 'key_5': 5,
252 'key_undefined': undefined, 252 'key_undefined': undefined,
253 'key_test': 'test' 253 'key_test': 'test'
254 }); 254 });
255 }); 255 });
256 256
257 test('identity', function() {
258 // Undefined value.
259 assert.isUndefined(tr.b.identity(undefined));
260
261 // Primitive value.
262 assert.strictEqual(tr.b.identity(-273.15), -273.15);
263
264 // List.
265 const list = ['list', 'with', 1, undefined, 'value'];
266 assert.strictEqual(tr.b.identity(list), list);
267
268 // Object.
269 const object = {'hasItems': true};
270 assert.strictEqual(tr.b.identity(object), object);
271 });
272
273 test('findFirstKeyInDictMatching', function() { 257 test('findFirstKeyInDictMatching', function() {
274 const dict = {a: 1, b: 2, c: 3}; 258 const dict = {a: 1, b: 2, c: 3};
275 259
276 let k = tr.b.findFirstKeyInDictMatching(dict, function(key, value) { 260 let k = tr.b.findFirstKeyInDictMatching(dict, function(key, value) {
277 return value === 2; 261 return value === 2;
278 }, this); 262 }, this);
279 assert.strictEqual(k, 'b'); 263 assert.strictEqual(k, 'b');
280 264
281 k = tr.b.findFirstKeyInDictMatching(dict, function(key, value) { 265 k = tr.b.findFirstKeyInDictMatching(dict, function(key, value) {
282 return false; 266 return false;
(...skipping 17 matching lines...) Expand all
300 const map = new Map(); 284 const map = new Map();
301 map.set('a', 1); 285 map.set('a', 1);
302 map.set('b', 2); 286 map.set('b', 2);
303 map.set('c', 3); 287 map.set('c', 3);
304 const values = tr.b.mapValues(map); 288 const values = tr.b.mapValues(map);
305 assert.strictEqual(values.length, 3); 289 assert.strictEqual(values.length, 3);
306 assert.sameMembers([1, 2, 3], values); 290 assert.sameMembers([1, 2, 3], values);
307 }); 291 });
308 }); 292 });
309 </script> 293 </script>
OLDNEW
« no previous file with comments | « tracing/tracing/base/iteration_helpers.html ('k') | tracing/tracing/base/math/range.html » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698