Skip to content

Commit

Permalink
don't try to use real GeneratorPrototype for these tests
Browse files Browse the repository at this point in the history
  • Loading branch information
michaelficarra committed Dec 8, 2023
1 parent 14d690f commit 59176fc
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ features: [iterator-helpers]
---*/

let IteratorPrototype = Object.getPrototypeOf(Object.getPrototypeOf([][Symbol.iterator]()))
let GeneratorPrototype = Object.getPrototypeOf(function*(){}.prototype);

let sentinel = 'a';

Expand All @@ -40,18 +39,19 @@ assert.sameValue(get.call(), 'Iterator');

// 1. If _desc_ is *undefined*, then
// 1. Perform ? CreateDataPropertyOrThrow(_this_, _p_, _v_).
let o = {};
set.call(o, sentinel);
assert.sameValue(o[Symbol.toStringTag], sentinel);
let FakeGeneratorPrototype = Object.create(IteratorPrototype);
Object.freeze(IteratorPrototype);
FakeGeneratorPrototype[Symbol.toStringTag] = sentinel;
assert.sameValue(FakeGeneratorPrototype[Symbol.toStringTag], sentinel);

assert.sameValue(Iterator.prototype[Symbol.toStringTag], 'Iterator');
assert.sameValue(get.call(), 'Iterator');

// 1. Else,
// 1. Perform ? Set(_this_, _p_, _v_, *true*).
Object.freeze(IteratorPrototype);
GeneratorPrototype[Symbol.toStringTag] = sentinel;
assert.sameValue(GeneratorPrototype[Symbol.toStringTag], sentinel);
let o = { [Symbol.toStringTag]: sentinel + 'a' };
set.call(o, sentinel);
assert.sameValue(o[Symbol.toStringTag], sentinel);

assert.sameValue(Iterator.prototype[Symbol.toStringTag], 'Iterator');
assert.sameValue(get.call(), 'Iterator');
14 changes: 7 additions & 7 deletions test/built-ins/Iterator/prototype/constructor/weird-setter.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ features: [iterator-helpers]
---*/

let IteratorPrototype = Object.getPrototypeOf(Object.getPrototypeOf([][Symbol.iterator]()))
let GeneratorPrototype = Object.getPrototypeOf(function*(){}.prototype);

let sentinel = {};

Expand All @@ -40,18 +39,19 @@ assert.sameValue(get.call(), Iterator);

// 1. If _desc_ is *undefined*, then
// 1. Perform ? CreateDataPropertyOrThrow(_this_, _p_, _v_).
let o = {};
set.call(o, sentinel);
assert.sameValue(o.constructor, sentinel);
let FakeGeneratorPrototype = Object.create(IteratorPrototype);
Object.freeze(IteratorPrototype);
FakeGeneratorPrototype.constructor = sentinel;
assert.sameValue(FakeGeneratorPrototype.constructor, sentinel);

assert.sameValue(Iterator.prototype.constructor, Iterator);
assert.sameValue(get.call(), Iterator);

// 1. Else,
// 1. Perform ? Set(_this_, _p_, _v_, *true*).
Object.freeze(IteratorPrototype);
GeneratorPrototype.constructor = sentinel;
assert.sameValue(GeneratorPrototype.constructor, sentinel);
let o = { constructor: sentinel + 'a' };
set.call(o, sentinel);
assert.sameValue(o.constructor, sentinel);

assert.sameValue(Iterator.prototype.constructor, Iterator);
assert.sameValue(get.call(), Iterator);

0 comments on commit 59176fc

Please sign in to comment.