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 /** | 5 /** |
6 * Asserts that a given argument's value is undefined. | 6 * Asserts that a given argument's value is undefined. |
7 * @param {object} a The argument to check. | 7 * @param {object} a The argument to check. |
8 */ | 8 */ |
9 function assertUndefined(a) { | 9 function assertUndefined(a) { |
10 if (a !== undefined) { | 10 if (a !== undefined) { |
(...skipping 29 matching lines...) Expand all Loading... |
40 ' - ' + msg); | 40 ' - ' + msg); |
41 } | 41 } |
42 return; | 42 return; |
43 } | 43 } |
44 | 44 |
45 throw new Error('Expected to throw exception ' + error + ' - ' + msg); | 45 throw new Error('Expected to throw exception ' + error + ' - ' + msg); |
46 } | 46 } |
47 | 47 |
48 /** | 48 /** |
49 * Asserts that two arrays of strings are equal. | 49 * Asserts that two arrays of strings are equal. |
50 * @param {Array.<string>} array1 The expected array. | 50 * @param {Array<string>} array1 The expected array. |
51 * @param {Array.<string>} array2 The test array. | 51 * @param {Array<string>} array2 The test array. |
52 */ | 52 */ |
53 function assertEqualStringArrays(array1, array2) { | 53 function assertEqualStringArrays(array1, array2) { |
54 var same = true; | 54 var same = true; |
55 if (array1.length != array2.length) { | 55 if (array1.length != array2.length) { |
56 same = false; | 56 same = false; |
57 } | 57 } |
58 for (var i = 0; i < Math.min(array1.length, array2.length); i++) { | 58 for (var i = 0; i < Math.min(array1.length, array2.length); i++) { |
59 if (array1[i].trim() != array2[i].trim()) { | 59 if (array1[i].trim() != array2[i].trim()) { |
60 same = false; | 60 same = false; |
61 } | 61 } |
(...skipping 13 matching lines...) Expand all Loading... |
75 function assertEqualsJSON(expected, actual, opt_message) { | 75 function assertEqualsJSON(expected, actual, opt_message) { |
76 if (JSON.stringify(actual) !== JSON.stringify(expected)) { | 76 if (JSON.stringify(actual) !== JSON.stringify(expected)) { |
77 throw new Error((opt_message ? opt_message + '\n' : '') + | 77 throw new Error((opt_message ? opt_message + '\n' : '') + |
78 'Expected ' + JSON.stringify(expected) + '\n' + | 78 'Expected ' + JSON.stringify(expected) + '\n' + |
79 'Got ' + JSON.stringify(actual)); | 79 'Got ' + JSON.stringify(actual)); |
80 } | 80 } |
81 } | 81 } |
82 | 82 |
83 assertSame = assertEquals; | 83 assertSame = assertEquals; |
84 assertNotSame = assertNotEquals; | 84 assertNotSame = assertNotEquals; |
OLD | NEW |