mirror of
https://github.com/DoneJS-Runtime/quickjs-done-nextgen.git
synced 2025-01-09 17:43:15 +00:00
Implement Iterator.prototype.some
This commit is contained in:
parent
de58faaee0
commit
82607f4deb
2 changed files with 51 additions and 53 deletions
52
quickjs.c
52
quickjs.c
|
@ -40174,7 +40174,57 @@ exception:
|
||||||
static JSValue js_iterator_proto_some(JSContext *ctx, JSValue this_val,
|
static JSValue js_iterator_proto_some(JSContext *ctx, JSValue this_val,
|
||||||
int argc, JSValue *argv)
|
int argc, JSValue *argv)
|
||||||
{
|
{
|
||||||
return JS_ThrowInternalError(ctx, "TODO implement Iterator.prototype.some");
|
JSValue item, method, ret, func, index_val, r;
|
||||||
|
JSValue args[2];
|
||||||
|
int64_t idx;
|
||||||
|
BOOL done;
|
||||||
|
|
||||||
|
if (!JS_IsObject(this_val))
|
||||||
|
return JS_ThrowTypeError(ctx, "Iterator.prototype.some called on non-object");
|
||||||
|
if (check_function(ctx, argv[0]))
|
||||||
|
return JS_EXCEPTION;
|
||||||
|
func = js_dup(argv[0]);
|
||||||
|
method = JS_GetProperty(ctx, this_val, JS_ATOM_next);
|
||||||
|
if (JS_IsException(method))
|
||||||
|
goto exception;
|
||||||
|
r = JS_FALSE;
|
||||||
|
for (idx = 0; /*empty*/; idx++) {
|
||||||
|
item = JS_IteratorNext(ctx, this_val, method, 0, NULL, &done);
|
||||||
|
if (JS_IsException(item))
|
||||||
|
goto exception;
|
||||||
|
if (done)
|
||||||
|
break;
|
||||||
|
index_val = JS_NewInt64(ctx, idx);
|
||||||
|
if (JS_IsException(index_val)) {
|
||||||
|
JS_FreeValue(ctx, item);
|
||||||
|
goto exception;
|
||||||
|
}
|
||||||
|
args[0] = item;
|
||||||
|
args[1] = index_val;
|
||||||
|
ret = JS_Call(ctx, func, JS_UNDEFINED, countof(args), args);
|
||||||
|
JS_FreeValue(ctx, item);
|
||||||
|
JS_FreeValue(ctx, index_val);
|
||||||
|
if (JS_IsException(ret))
|
||||||
|
goto exception;
|
||||||
|
if (JS_ToBoolFree(ctx, ret)) {
|
||||||
|
if (JS_IteratorClose(ctx, this_val, FALSE) < 0)
|
||||||
|
r = JS_EXCEPTION;
|
||||||
|
else
|
||||||
|
r = JS_TRUE;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
index_val = JS_UNDEFINED;
|
||||||
|
ret = JS_UNDEFINED;
|
||||||
|
item = JS_UNDEFINED;
|
||||||
|
}
|
||||||
|
JS_FreeValue(ctx, func);
|
||||||
|
JS_FreeValue(ctx, method);
|
||||||
|
return r;
|
||||||
|
exception:
|
||||||
|
JS_IteratorClose(ctx, this_val, TRUE);
|
||||||
|
JS_FreeValue(ctx, func);
|
||||||
|
JS_FreeValue(ctx, method);
|
||||||
|
return JS_EXCEPTION;
|
||||||
}
|
}
|
||||||
|
|
||||||
static JSValue js_iterator_proto_take(JSContext *ctx, JSValue this_val,
|
static JSValue js_iterator_proto_take(JSContext *ctx, JSValue this_val,
|
||||||
|
|
|
@ -270,58 +270,6 @@ test262/test/built-ins/Iterator/prototype/map/underlying-iterator-closed-in-para
|
||||||
test262/test/built-ins/Iterator/prototype/map/underlying-iterator-closed-in-parallel.js:19: strict mode: InternalError: TODO implement Iterator.prototype.map
|
test262/test/built-ins/Iterator/prototype/map/underlying-iterator-closed-in-parallel.js:19: strict mode: InternalError: TODO implement Iterator.prototype.map
|
||||||
test262/test/built-ins/Iterator/prototype/map/underlying-iterator-closed.js:21: InternalError: TODO implement Iterator.prototype.map
|
test262/test/built-ins/Iterator/prototype/map/underlying-iterator-closed.js:21: InternalError: TODO implement Iterator.prototype.map
|
||||||
test262/test/built-ins/Iterator/prototype/map/underlying-iterator-closed.js:21: strict mode: InternalError: TODO implement Iterator.prototype.map
|
test262/test/built-ins/Iterator/prototype/map/underlying-iterator-closed.js:21: strict mode: InternalError: TODO implement Iterator.prototype.map
|
||||||
test262/test/built-ins/Iterator/prototype/some/argument-effect-order.js:16: Test262Error: Expected a TypeError but got a InternalError
|
|
||||||
test262/test/built-ins/Iterator/prototype/some/argument-effect-order.js:16: strict mode: Test262Error: Expected a TypeError but got a InternalError
|
|
||||||
test262/test/built-ins/Iterator/prototype/some/callable.js:10: InternalError: TODO implement Iterator.prototype.some
|
|
||||||
test262/test/built-ins/Iterator/prototype/some/callable.js:10: strict mode: InternalError: TODO implement Iterator.prototype.some
|
|
||||||
test262/test/built-ins/Iterator/prototype/some/get-next-method-only-once.js:33: InternalError: TODO implement Iterator.prototype.some
|
|
||||||
test262/test/built-ins/Iterator/prototype/some/get-next-method-only-once.js:33: strict mode: InternalError: TODO implement Iterator.prototype.some
|
|
||||||
test262/test/built-ins/Iterator/prototype/some/get-next-method-throws.js:15: Test262Error: Expected a Test262Error but got a InternalError
|
|
||||||
test262/test/built-ins/Iterator/prototype/some/get-next-method-throws.js:15: strict mode: Test262Error: Expected a Test262Error but got a InternalError
|
|
||||||
test262/test/built-ins/Iterator/prototype/some/get-return-method-throws.js:21: Test262Error: Expected a Test262Error but got a InternalError
|
|
||||||
test262/test/built-ins/Iterator/prototype/some/get-return-method-throws.js:21: strict mode: Test262Error: Expected a Test262Error but got a InternalError
|
|
||||||
test262/test/built-ins/Iterator/prototype/some/iterator-already-exhausted.js:19: InternalError: TODO implement Iterator.prototype.some
|
|
||||||
test262/test/built-ins/Iterator/prototype/some/iterator-already-exhausted.js:19: strict mode: InternalError: TODO implement Iterator.prototype.some
|
|
||||||
test262/test/built-ins/Iterator/prototype/some/iterator-has-no-return.js:17: InternalError: TODO implement Iterator.prototype.some
|
|
||||||
test262/test/built-ins/Iterator/prototype/some/iterator-has-no-return.js:17: strict mode: InternalError: TODO implement Iterator.prototype.some
|
|
||||||
test262/test/built-ins/Iterator/prototype/some/iterator-return-method-throws.js:21: Test262Error: Expected a Test262Error but got a InternalError
|
|
||||||
test262/test/built-ins/Iterator/prototype/some/iterator-return-method-throws.js:21: strict mode: Test262Error: Expected a Test262Error but got a InternalError
|
|
||||||
test262/test/built-ins/Iterator/prototype/some/next-method-returns-non-object.js:21: Test262Error: Expected a TypeError but got a InternalError
|
|
||||||
test262/test/built-ins/Iterator/prototype/some/next-method-returns-non-object.js:21: strict mode: Test262Error: Expected a TypeError but got a InternalError
|
|
||||||
test262/test/built-ins/Iterator/prototype/some/next-method-returns-throwing-done.js:17: Test262Error: Expected a Test262Error but got a InternalError
|
|
||||||
test262/test/built-ins/Iterator/prototype/some/next-method-returns-throwing-done.js:17: strict mode: Test262Error: Expected a Test262Error but got a InternalError
|
|
||||||
test262/test/built-ins/Iterator/prototype/some/next-method-returns-throwing-value-done.js:28: InternalError: TODO implement Iterator.prototype.some
|
|
||||||
test262/test/built-ins/Iterator/prototype/some/next-method-returns-throwing-value-done.js:28: strict mode: InternalError: TODO implement Iterator.prototype.some
|
|
||||||
test262/test/built-ins/Iterator/prototype/some/next-method-returns-throwing-value.js:18: Test262Error: Expected a Test262Error but got a InternalError
|
|
||||||
test262/test/built-ins/Iterator/prototype/some/next-method-returns-throwing-value.js:18: strict mode: Test262Error: Expected a Test262Error but got a InternalError
|
|
||||||
test262/test/built-ins/Iterator/prototype/some/next-method-throws.js:15: Test262Error: Expected a Test262Error but got a InternalError
|
|
||||||
test262/test/built-ins/Iterator/prototype/some/next-method-throws.js:15: strict mode: Test262Error: Expected a Test262Error but got a InternalError
|
|
||||||
test262/test/built-ins/Iterator/prototype/some/non-callable-predicate.js:18: Test262Error: Expected a TypeError but got a InternalError
|
|
||||||
test262/test/built-ins/Iterator/prototype/some/non-callable-predicate.js:18: strict mode: Test262Error: Expected a TypeError but got a InternalError
|
|
||||||
test262/test/built-ins/Iterator/prototype/some/predicate-args.js:38: InternalError: TODO implement Iterator.prototype.some
|
|
||||||
test262/test/built-ins/Iterator/prototype/some/predicate-args.js:38: strict mode: InternalError: TODO implement Iterator.prototype.some
|
|
||||||
test262/test/built-ins/Iterator/prototype/some/predicate-returns-falsey-then-truthy.js:25: InternalError: TODO implement Iterator.prototype.some
|
|
||||||
test262/test/built-ins/Iterator/prototype/some/predicate-returns-falsey-then-truthy.js:25: strict mode: InternalError: TODO implement Iterator.prototype.some
|
|
||||||
test262/test/built-ins/Iterator/prototype/some/predicate-returns-falsey.js:20: InternalError: TODO implement Iterator.prototype.some
|
|
||||||
test262/test/built-ins/Iterator/prototype/some/predicate-returns-falsey.js:20: strict mode: InternalError: TODO implement Iterator.prototype.some
|
|
||||||
test262/test/built-ins/Iterator/prototype/some/predicate-returns-non-boolean.js:29: InternalError: TODO implement Iterator.prototype.some
|
|
||||||
test262/test/built-ins/Iterator/prototype/some/predicate-returns-non-boolean.js:29: strict mode: InternalError: TODO implement Iterator.prototype.some
|
|
||||||
test262/test/built-ins/Iterator/prototype/some/predicate-returns-truthy.js:25: InternalError: TODO implement Iterator.prototype.some
|
|
||||||
test262/test/built-ins/Iterator/prototype/some/predicate-returns-truthy.js:25: strict mode: InternalError: TODO implement Iterator.prototype.some
|
|
||||||
test262/test/built-ins/Iterator/prototype/some/predicate-this.js:28: InternalError: TODO implement Iterator.prototype.some
|
|
||||||
test262/test/built-ins/Iterator/prototype/some/predicate-this.js:28: strict mode: InternalError: TODO implement Iterator.prototype.some
|
|
||||||
test262/test/built-ins/Iterator/prototype/some/predicate-throws-then-closing-iterator-also-throws.js:30: Test262Error: Expected a Test262Error but got a InternalError
|
|
||||||
test262/test/built-ins/Iterator/prototype/some/predicate-throws-then-closing-iterator-also-throws.js:30: strict mode: Test262Error: Expected a Test262Error but got a InternalError
|
|
||||||
test262/test/built-ins/Iterator/prototype/some/predicate-throws.js:32: Test262Error: Expected a Test262Error but got a InternalError
|
|
||||||
test262/test/built-ins/Iterator/prototype/some/predicate-throws.js:32: strict mode: Test262Error: Expected a Test262Error but got a InternalError
|
|
||||||
test262/test/built-ins/Iterator/prototype/some/result-is-boolean.js:11: InternalError: TODO implement Iterator.prototype.some
|
|
||||||
test262/test/built-ins/Iterator/prototype/some/result-is-boolean.js:11: strict mode: InternalError: TODO implement Iterator.prototype.some
|
|
||||||
test262/test/built-ins/Iterator/prototype/some/this-non-callable-next.js:13: Test262Error: Expected a TypeError but got a InternalError
|
|
||||||
test262/test/built-ins/Iterator/prototype/some/this-non-callable-next.js:13: strict mode: Test262Error: Expected a TypeError but got a InternalError
|
|
||||||
test262/test/built-ins/Iterator/prototype/some/this-non-object.js:19: Test262Error: Expected a TypeError but got a InternalError
|
|
||||||
test262/test/built-ins/Iterator/prototype/some/this-non-object.js:19: strict mode: Test262Error: Expected a TypeError but got a InternalError
|
|
||||||
test262/test/built-ins/Iterator/prototype/some/this-plain-iterator.js:27: InternalError: TODO implement Iterator.prototype.some
|
|
||||||
test262/test/built-ins/Iterator/prototype/some/this-plain-iterator.js:27: strict mode: InternalError: TODO implement Iterator.prototype.some
|
|
||||||
test262/test/built-ins/Iterator/prototype/take/argument-effect-order.js:39: InternalError: TODO implement Iterator.prototype.take
|
test262/test/built-ins/Iterator/prototype/take/argument-effect-order.js:39: InternalError: TODO implement Iterator.prototype.take
|
||||||
test262/test/built-ins/Iterator/prototype/take/argument-effect-order.js:39: strict mode: InternalError: TODO implement Iterator.prototype.take
|
test262/test/built-ins/Iterator/prototype/take/argument-effect-order.js:39: strict mode: InternalError: TODO implement Iterator.prototype.take
|
||||||
test262/test/built-ins/Iterator/prototype/take/callable.js:10: InternalError: TODO implement Iterator.prototype.take
|
test262/test/built-ins/Iterator/prototype/take/callable.js:10: InternalError: TODO implement Iterator.prototype.take
|
||||||
|
|
Loading…
Reference in a new issue