add tests for tc39/proposal-iterator-helpers#281 (#3869)

Co-authored-by: Ms2ger <Ms2ger@igalia.com>
This commit is contained in:
Michael Ficarra 2023-07-13 16:04:33 +02:00 committed by GitHub
parent 20e442011c
commit 550c11163e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 15 additions and 0 deletions

View File

@ -37,3 +37,17 @@ assert.throws(TypeError, function () {
assert.compareArray(Array.from(Iterator.from(new Number(5))), [0, 1, 2, 3, 4]);
assert.compareArray(Array.from(Iterator.from('string')), ['s', 't', 'r', 'i', 'n', 'g']);
const originalStringIterator = String.prototype[Symbol.iterator];
let observedType;
Object.defineProperty(String.prototype, Symbol.iterator, {
get() {
'use strict';
observedType = typeof this;
return originalStringIterator;
}
});
Iterator.from('');
assert.sameValue(observedType, 'string');
Iterator.from(new String(''));
assert.sameValue(observedType, 'object');

View File

@ -12,3 +12,4 @@ features: [iterator-helpers]
flags: []
---*/
assert.compareArray(Array.from(Iterator.from([0, 1, 2, 3])), [0, 1, 2, 3]);
assert.compareArray(Array.from(Iterator.from(new String('str'))), ['s', 't', 'r']);