| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 (function() { | 5 (function() { |
| 6 | 6 |
| 7 'use strict'; | 7 'use strict'; |
| 8 | 8 |
| 9 module('base'); | 9 module('base'); |
| 10 | 10 |
| (...skipping 23 matching lines...) Expand all Loading... |
| 34 }); | 34 }); |
| 35 | 35 |
| 36 test('values(obj) should return an array containing the values of |obj|', | 36 test('values(obj) should return an array containing the values of |obj|', |
| 37 function() { | 37 function() { |
| 38 var output = base.values({ a: 'a', b: 'b'}); | 38 var output = base.values({ a: 'a', b: 'b'}); |
| 39 | 39 |
| 40 notEqual(output.indexOf('a'), -1, '"a" should be in the output'); | 40 notEqual(output.indexOf('a'), -1, '"a" should be in the output'); |
| 41 notEqual(output.indexOf('b'), -1, '"b" should be in the output'); | 41 notEqual(output.indexOf('b'), -1, '"b" should be in the output'); |
| 42 }); | 42 }); |
| 43 | 43 |
| 44 test('deepCopy(obj) should return null on NaN and undefined', |
| 45 function() { |
| 46 QUnit.equal(base.deepCopy(NaN), null); |
| 47 QUnit.equal(base.deepCopy(undefined), null); |
| 48 }); |
| 49 |
| 50 test('deepCopy(obj) should copy primitive types recursively', |
| 51 function() { |
| 52 QUnit.equal(base.deepCopy(1), 1); |
| 53 QUnit.equal(base.deepCopy('hello'), 'hello'); |
| 54 QUnit.equal(base.deepCopy(false), false); |
| 55 QUnit.equal(base.deepCopy(null), null); |
| 56 QUnit.deepEqual(base.deepCopy([1, 2]), [1, 2]); |
| 57 QUnit.deepEqual(base.deepCopy({'key': 'value'}), {'key': 'value'}); |
| 58 QUnit.deepEqual(base.deepCopy( |
| 59 {'key': {'key_nested': 'value_nested'}}), |
| 60 {'key': {'key_nested': 'value_nested'}} |
| 61 ); |
| 62 QUnit.deepEqual(base.deepCopy([1, [2, [3]]]), [1, [2, [3]]]); |
| 63 }); |
| 64 |
| 65 test('modify the original after deepCopy(obj) should not affect the copy', |
| 66 function() { |
| 67 var original = [1, 2, 3, 4]; |
| 68 var copy = base.deepCopy(original); |
| 69 original[2] = 1000; |
| 70 QUnit.deepEqual(copy, [1, 2, 3, 4]); |
| 71 }); |
| 72 |
| 44 test('dispose(obj) should invoke the dispose method on |obj|', | 73 test('dispose(obj) should invoke the dispose method on |obj|', |
| 45 function() { | 74 function() { |
| 46 var obj = { | 75 var obj = { |
| 47 dispose: sinon.spy() | 76 dispose: sinon.spy() |
| 48 }; | 77 }; |
| 49 base.dispose(obj); | 78 base.dispose(obj); |
| 50 sinon.assert.called(obj.dispose); | 79 sinon.assert.called(obj.dispose); |
| 51 }); | 80 }); |
| 52 | 81 |
| 53 test('dispose(obj) should not crash if |obj| is null', | 82 test('dispose(obj) should not crash if |obj| is null', |
| (...skipping 219 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 273 /* Ѓ */ 0xD0, 0x83, | 302 /* Ѓ */ 0xD0, 0x83, |
| 274 /* ф */ 0xD1, 0x84]).buffer), | 303 /* ф */ 0xD1, 0x84]).buffer), |
| 275 "挂Ѓф"); | 304 "挂Ѓф"); |
| 276 | 305 |
| 277 // Unicode surrogate pair for U+1F603. | 306 // Unicode surrogate pair for U+1F603. |
| 278 QUnit.equal(base.decodeUtf8(new Uint8Array([0xF0, 0x9F, 0x98, 0x83]).buffer), | 307 QUnit.equal(base.decodeUtf8(new Uint8Array([0xF0, 0x9F, 0x98, 0x83]).buffer), |
| 279 "😃"); | 308 "😃"); |
| 280 }); | 309 }); |
| 281 | 310 |
| 282 })(); | 311 })(); |
| OLD | NEW |