Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 32 additions & 0 deletions quickjs.c
Original file line number Diff line number Diff line change
Expand Up @@ -39964,6 +39964,37 @@ static JSValue js_iterator_proto_iterator(JSContext *ctx, JSValue this_val,
return js_dup(this_val);
}

static JSValue js_iterator_proto_get_toStringTag(JSContext *ctx, JSValue this_val)
{
return JS_AtomToString(ctx, JS_ATOM_Iterator);
}

static JSValue js_iterator_proto_set_toStringTag(JSContext *ctx, JSValue this_val, JSValue val)
{
JSObject *p;
int res;

if (JS_VALUE_GET_TAG(this_val) != JS_TAG_OBJECT)
return JS_ThrowTypeError(ctx,
"set Iterator.prototype[Symbol.toStringTag] called on non-object");
p = JS_VALUE_GET_OBJ(this_val);
if (p->class_id == JS_CLASS_ITERATOR) {
// This is home.
return JS_ThrowTypeError(ctx, "Cannot assign to read only property");
}
res = JS_GetOwnProperty(ctx, NULL, this_val, JS_ATOM_Symbol_toStringTag);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For my curiosity: the JS_GetOwnProperty is because it's observable?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, AFAICT. The spec says to get the descriptor and either set or define a new property based on its presence.

if (res < 0)
return JS_EXCEPTION;
if (res) {
if (JS_SetProperty(ctx, this_val, JS_ATOM_Symbol_toStringTag, js_dup(val)) < 0)
return JS_EXCEPTION;
} else {
if (JS_DefinePropertyValue(ctx, this_val, JS_ATOM_Symbol_toStringTag, js_dup(val), JS_PROP_C_W_E) < 0)
return JS_EXCEPTION;
}
return JS_UNDEFINED;
}

static const JSCFunctionListEntry js_iterator_funcs[] = {
JS_CFUNC_DEF("from", 1, js_iterator_from ),
};
Expand All @@ -39981,6 +40012,7 @@ static const JSCFunctionListEntry js_iterator_proto_funcs[] = {
JS_CFUNC_DEF("take", 1, js_iterator_proto_take ),
JS_CFUNC_DEF("toArray", 0, js_iterator_proto_toArray ),
JS_CFUNC_DEF("[Symbol.iterator]", 0, js_iterator_proto_iterator ),
JS_CGETSET_DEF("[Symbol.toStringTag]", js_iterator_proto_get_toStringTag, js_iterator_proto_set_toStringTag),
};

static const JSCFunctionListEntry js_array_proto_funcs[] = {
Expand Down
12 changes: 0 additions & 12 deletions test262_errors.txt
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,6 @@ test262/test/built-ins/AsyncFromSyncIteratorPrototype/throw/throw-undefined-retu
test262/test/built-ins/AsyncFromSyncIteratorPrototype/throw/throw-undefined-return-object.js:66: strict mode: TypeError: $DONE() not called
test262/test/built-ins/Iterator/prototype/Symbol.iterator/prop-desc.js:15: Test262Error: obj should have an own property Symbol(Symbol.iterator)
test262/test/built-ins/Iterator/prototype/Symbol.iterator/prop-desc.js:15: strict mode: Test262Error: obj should have an own property Symbol(Symbol.iterator)
test262/test/built-ins/Iterator/prototype/Symbol.toStringTag/prop-desc.js:11: TypeError: cannot read property 'get' of undefined
test262/test/built-ins/Iterator/prototype/Symbol.toStringTag/prop-desc.js:11: strict mode: TypeError: cannot read property 'get' of undefined
test262/test/built-ins/Iterator/prototype/Symbol.toStringTag/weird-setter.js:20: TypeError: Cannot convert undefined or null to object
test262/test/built-ins/Iterator/prototype/Symbol.toStringTag/weird-setter.js:20: strict mode: TypeError: Cannot convert undefined or null to object
test262/test/built-ins/Iterator/prototype/constructor/prop-desc.js:10: Test262Error: Expected SameValue(«undefined», «function») to be true
test262/test/built-ins/Iterator/prototype/constructor/prop-desc.js:10: strict mode: Test262Error: Expected SameValue(«undefined», «function») to be true
test262/test/built-ins/Iterator/prototype/constructor/weird-setter.js:23: TypeError: cannot read property 'call' of undefined
Expand Down Expand Up @@ -566,14 +562,6 @@ test262/test/built-ins/Iterator/prototype/take/underlying-iterator-closed-in-par
test262/test/built-ins/Iterator/prototype/take/underlying-iterator-closed-in-parallel.js:19: strict mode: InternalError: TODO implement Iterator.prototype.take
test262/test/built-ins/Iterator/prototype/take/underlying-iterator-closed.js:21: InternalError: TODO implement Iterator.prototype.take
test262/test/built-ins/Iterator/prototype/take/underlying-iterator-closed.js:21: strict mode: InternalError: TODO implement Iterator.prototype.take
test262/test/built-ins/Object/prototype/toString/symbol-tag-array-builtin.js:24: Test262Error: Expected SameValue(«[object Object]», «[object Iterator]») to be true
test262/test/built-ins/Object/prototype/toString/symbol-tag-array-builtin.js:24: strict mode: Test262Error: Expected SameValue(«[object Object]», «[object Iterator]») to be true
test262/test/built-ins/Object/prototype/toString/symbol-tag-map-builtin.js:20: Test262Error: Expected SameValue(«[object Object]», «[object Iterator]») to be true
test262/test/built-ins/Object/prototype/toString/symbol-tag-map-builtin.js:20: strict mode: Test262Error: Expected SameValue(«[object Object]», «[object Iterator]») to be true
test262/test/built-ins/Object/prototype/toString/symbol-tag-set-builtin.js:20: Test262Error: Expected SameValue(«[object Object]», «[object Iterator]») to be true
test262/test/built-ins/Object/prototype/toString/symbol-tag-set-builtin.js:20: strict mode: Test262Error: Expected SameValue(«[object Object]», «[object Iterator]») to be true
test262/test/built-ins/Object/prototype/toString/symbol-tag-string-builtin.js:24: Test262Error: Expected SameValue(«[object Object]», «[object Iterator]») to be true
test262/test/built-ins/Object/prototype/toString/symbol-tag-string-builtin.js:24: strict mode: Test262Error: Expected SameValue(«[object Object]», «[object Iterator]») to be true
test262/test/built-ins/RegExp/property-escapes/generated/Alphabetic.js:16: Test262Error: `\p{Alphabetic}` should match U+02EBF0 (`𮯰`)
test262/test/built-ins/RegExp/property-escapes/generated/Alphabetic.js:16: strict mode: Test262Error: `\p{Alphabetic}` should match U+02EBF0 (`𮯰`)
test262/test/built-ins/RegExp/property-escapes/generated/Assigned.js:16: Test262Error: `\p{Assigned}` should match U+002FFC (`⿼`)
Expand Down
Loading