Object.prototype.toString: improve coverage

This commit is contained in:
Jordan Harband 2023-06-21 14:24:56 -05:00 committed by Philip Chimento
parent 45d52b90ee
commit e0436fc52d
8 changed files with 25 additions and 7 deletions

View File

@ -11,7 +11,7 @@ info: |
15. Let tag be ? Get(O, @@toStringTag).
16. If Type(tag) is not String, set tag to builtinTag.
17. Return the string-concatenation of "[object ", tag, and "]".
features: [Symbol.toStringTag, Symbol.iterator]
features: [Symbol.toStringTag, Symbol.iterator, iterator-helpers]
---*/
var toString = Object.prototype.toString;
@ -23,3 +23,6 @@ assert.sameValue(toString.call(arrIter), '[object Array Iterator]');
Object.defineProperty(arrIterProto, Symbol.toStringTag, {configurable: true, value: null});
assert.sameValue(toString.call(arrIter), '[object Object]');
delete arrIterProto[Symbol.toStringTag];
assert.sameValue(toString.call(arrIter), '[object Iterator]');

View File

@ -11,7 +11,7 @@ info: |
15. Let tag be ? Get(O, @@toStringTag).
16. If Type(tag) is not String, set tag to builtinTag.
17. Return the string-concatenation of "[object ", tag, and "]".
features: [Symbol.toStringTag, Symbol.iterator, generators]
features: [Symbol.toStringTag, Symbol.iterator, generators, iterator-helpers]
---*/
var toString = Object.prototype.toString;
@ -28,3 +28,6 @@ Object.defineProperty(genProto, Symbol.toStringTag, {
get: function() { return {}; },
});
assert.sameValue(toString.call(gen), '[object Object]');
delete genProto[Symbol.toStringTag];
assert.sameValue(toString.call(gen), '[object Iterator]');

View File

@ -11,7 +11,7 @@ info: |
15. Let tag be ? Get(O, @@toStringTag).
16. If Type(tag) is not String, set tag to builtinTag.
17. Return the string-concatenation of "[object ", tag, and "]".
features: [Symbol.toStringTag, Symbol.iterator, Map]
features: [Symbol.toStringTag, Symbol.iterator, Map, iterator-helpers]
---*/
var toString = Object.prototype.toString;
@ -28,3 +28,6 @@ Object.defineProperty(mapIterProto, Symbol.toStringTag, {
get: function() { return new String('ShouldNotBeUnwrapped'); },
});
assert.sameValue(toString.call(mapIter), '[object Object]');
delete mapIterProto[Symbol.toStringTag];
assert.sameValue(toString.call(mapIter), '[object Iterator]');

View File

@ -18,3 +18,6 @@ var toString = Object.prototype.toString;
var promise = new Promise(function () {});
assert.sameValue(toString.call(promise), '[object Promise]');
delete Promise.prototype[Symbol.toStringTag];
assert.sameValue(toString.call(promise), '[object Object]');

View File

@ -11,7 +11,7 @@ info: |
15. Let tag be ? Get(O, @@toStringTag).
16. If Type(tag) is not String, set tag to builtinTag.
17. Return the string-concatenation of "[object ", tag, and "]".
features: [Symbol.toStringTag, Symbol.iterator, Set]
features: [Symbol.toStringTag, Symbol.iterator, Set, iterator-helpers]
---*/
var toString = Object.prototype.toString;
@ -28,3 +28,6 @@ Object.defineProperty(setIterProto, Symbol.toStringTag, {
get: function() { return new String('ShouldNotBeUnwrapped'); },
});
assert.sameValue(toString.call(setIter), '[object Object]');
delete setIterProto[Symbol.toStringTag];
assert.sameValue(toString.call(setIter), '[object Iterator]');

View File

@ -11,7 +11,7 @@ info: |
15. Let tag be ? Get(O, @@toStringTag).
16. If Type(tag) is not String, set tag to builtinTag.
17. Return the string-concatenation of "[object ", tag, and "]".
features: [Symbol.toStringTag, Symbol.iterator]
features: [Symbol.toStringTag, Symbol.iterator, iterator-helpers]
---*/
var toString = Object.prototype.toString;
@ -26,3 +26,6 @@ Object.defineProperty(strIterProto, Symbol.toStringTag, {
get: function() { return new String('ShouldNotBeUnwrapped'); },
});
assert.sameValue(toString.call(strIter), '[object Object]');
delete strIterProto[Symbol.toStringTag];
assert.sameValue(toString.call(strIter), '[object Iterator]');

View File

@ -18,4 +18,4 @@ var toString = Object.prototype.toString;
var wm = new WeakMap();
delete WeakMap.prototype[Symbol.toStringTag];
assert.sameValue(toString.call(wm), '[object Object]');
assert.sameValue(toString.call(wm), '[object Object]');

View File

@ -18,4 +18,4 @@ var toString = Object.prototype.toString;
var wm = new WeakSet();
delete WeakSet.prototype[Symbol.toStringTag];
assert.sameValue(toString.call(wm), '[object Object]');
assert.sameValue(toString.call(wm), '[object Object]');