mirror of https://github.com/tc39/test262.git
add tests for tc39/proposal-iterator-helpers#281 (#3869)
Co-authored-by: Ms2ger <Ms2ger@igalia.com>
This commit is contained in:
parent
20e442011c
commit
550c11163e
|
@ -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');
|
||||
|
|
|
@ -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']);
|
||||
|
|
Loading…
Reference in New Issue