Skip to content

Commit

Permalink
fix broken Iterator.prototype constructor/Symbol.toStringTag tests (#…
Browse files Browse the repository at this point in the history
…3996)

* fix broken Iterator.prototype constructor/Symbol.toStringTag tests

* fix lint: unused includes
  • Loading branch information
michaelficarra committed Jan 25, 2024
1 parent fed13c1 commit e4f91b6
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,11 @@ description: Property descriptor
info: |
`Iterator.prototype[@@toStringTag]` is an accessor property with attributes { [[Enumerable]]: *false*, [[Configurable]]: *true* }
features: [iterator-helpers]
includes: [propertyHelper.js]
---*/
verifyConfigurable(Iterator.prototype, Symbol.toStringTag);
verifyNotEnumerable(Iterator.prototype, Symbol.toStringTag);

let desc = Object.getOwnPropertyDescriptor(Iterator.prototype, Symbol.toStringTag);
assert.sameValue(typeof desc.get, 'function');
assert.sameValue(typeof desc.set, 'function');
assert.sameValue(desc.configurable, true);
assert.sameValue(desc.enumerable, false);
assert.sameValue(desc.value, undefined);
assert.sameValue(desc.writable, undefined);
Original file line number Diff line number Diff line change
Expand Up @@ -24,15 +24,15 @@ assert.sameValue(get.call(), 'Iterator');

// 1. If _this_ is not an Object, then
// 1. Throw a *TypeError* exception.
assert.throws(() => set.call(undefined, ''));
assert.throws(() => set.call(null, ''));
assert.throws(() => set.call(true, ''));
assert.throws(TypeError, () => set.call(undefined, ''));
assert.throws(TypeError, () => set.call(null, ''));
assert.throws(TypeError, () => set.call(true, ''));

// 1. If _this_ is _home_, then
// 1. NOTE: Throwing here emulates assignment to a non-writable data property on the _home_ object in strict mode code.
// 1. Throw a *TypeError* exception.
assert.throws(() => set.call(IteratorPrototype, ''));
assert.throws(() => IteratorPrototype[Symbol.toStringTag] = '');
assert.throws(TypeError, () => set.call(IteratorPrototype, ''));
assert.throws(TypeError, () => IteratorPrototype[Symbol.toStringTag] = '');

assert.sameValue(Iterator.prototype[Symbol.toStringTag], 'Iterator');
assert.sameValue(get.call(), 'Iterator');
Expand Down
6 changes: 2 additions & 4 deletions test/built-ins/Iterator/prototype/constructor/prop-desc.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,11 @@ description: Property descriptor
info: |
`Iterator.prototype.constructor` is an accessor property with attributes { [[Enumerable]]: *false*, [[Configurable]]: *true* }
features: [iterator-helpers]
includes: [propertyHelper.js]
---*/
verifyConfigurable(Iterator.prototype, 'constructor');
verifyNotEnumerable(Iterator.prototype, 'constructor');

let desc = Object.getOwnPropertyDescriptor(Iterator.prototype, 'constructor');
assert.sameValue(typeof desc.get, 'function');
assert.sameValue(typeof desc.set, 'function');
assert.sameValue(desc.configurable, true);
assert.sameValue(desc.enumerable, false);
assert.sameValue(desc.value, undefined);
assert.sameValue(desc.writable, undefined);
10 changes: 5 additions & 5 deletions test/built-ins/Iterator/prototype/constructor/weird-setter.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,15 +24,15 @@ assert.sameValue(get.call(), Iterator);

// 1. If _this_ is not an Object, then
// 1. Throw a *TypeError* exception.
assert.throws(() => set.call(undefined, ''));
assert.throws(() => set.call(null, ''));
assert.throws(() => set.call(true, ''));
assert.throws(TypeError, () => set.call(undefined, ''));
assert.throws(TypeError, () => set.call(null, ''));
assert.throws(TypeError, () => set.call(true, ''));

// 1. If _this_ is _home_, then
// 1. NOTE: Throwing here emulates assignment to a non-writable data property on the _home_ object in strict mode code.
// 1. Throw a *TypeError* exception.
assert.throws(() => set.call(IteratorPrototype, ''));
assert.throws(() => IteratorPrototype.constructor = '');
assert.throws(TypeError, () => set.call(IteratorPrototype, ''));
assert.throws(TypeError, () => IteratorPrototype.constructor = '');

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

0 comments on commit e4f91b6

Please sign in to comment.