Skip to content

Commit cf56354

Browse files
authored
Remove refs to goog.isObject, isArrayLike etc. that will be removed. (bazelbuild#645)
1 parent 7c293e2 commit cf56354

2 files changed

Lines changed: 14 additions & 9 deletions

File tree

closure/testing/library/asserts.js

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -387,7 +387,7 @@ var assertThrows = goog.testing.asserts.assertThrows;
387387
*/
388388
goog.testing.asserts.removeOperaStacktrace_ = function(e) {
389389
'use strict';
390-
if (!goog.isObject(e)) return;
390+
if (!e || typeof e != 'object') return;
391391
const stack = e['stacktrace'];
392392
const errorMsg = e['message'];
393393
if (typeof stack !== 'string' || typeof errorMsg !== 'string') {
@@ -513,7 +513,7 @@ goog.testing.asserts.assertRejects = function(a, opt_b) {
513513
var thenable = /** @type {!IThenable<*>} */ (nonCommentArg(1, 1, arguments));
514514
var comment = commentArg(1, arguments);
515515
_assert(
516-
comment, goog.isObject(thenable) && typeof thenable.then === 'function',
516+
comment, thenable && typeof thenable === 'object' && typeof thenable.then === 'function',
517517
() => 'Argument passed to assertRejects is not an IThenable');
518518

519519
return thenable.then(
@@ -1484,7 +1484,17 @@ var assertSameElements = goog.testing.asserts.assertSameElements;
14841484
*/
14851485
goog.testing.asserts.isArrayLikeOrIterable_ = function(obj) {
14861486
'use strict';
1487-
return goog.isArrayLike(obj) || goog.testing.asserts.isIterable_(obj);
1487+
return goog.testing.asserts.isArrayLike_(obj) || goog.testing.asserts.isIterable_(obj);
1488+
};
1489+
1490+
/**
1491+
* @param {*} obj Object to test.
1492+
* @return {boolean} Whether given object is array-like.
1493+
* @private
1494+
*/
1495+
goog.testing.asserts.isArrayLike_ = function(obj) {
1496+
'use strict';
1497+
return Array.isArray(obj) || obj != null && typeof obj == 'object' && typeof obj.length == 'number'
14881498
};
14891499

14901500
/**

closure/testing/library/testcase.js

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1537,14 +1537,9 @@ goog.testing.TestCase.prototype.addTestObj_ = function(obj, name, objChain) {
15371537
var fullTestName = name + (testName && name ? '_' : '') + testName;
15381538
if (typeof testProperty === 'function') {
15391539
this.addNewTest(fullTestName, testProperty, obj, objChain);
1540-
} else if (goog.isObject(testProperty) && !Array.isArray(testProperty)) {
1540+
} else if (testProperty != null && typeof testProperty === 'object' && !Array.isArray(testProperty)) {
15411541
// To prevent infinite loops.
15421542
if (Array.prototype.indexOf.call(objChain, testProperty) < 0) {
1543-
if (!goog.isObject(testProperty)) {
1544-
throw new Error(
1545-
'Expected object but got %s: %s.',
1546-
[goog.typeOf(testProperty), testProperty]);
1547-
}
15481543
var newObjChain = objChain.slice();
15491544
newObjChain.push(testProperty);
15501545
this.addTestObj_(testProperty, fullTestName, newObjChain);

0 commit comments

Comments
 (0)