Commit 7a546525 authored by Georg Neis's avatar Georg Neis Committed by Commit Bot

[bigint] Implement BigInt constructor.

Actually all it does is throw a TypeError.

R=jkummerow@chromium.org

Bug: v8:6791
Change-Id: I884da4eaa937519c07c3516a1713829f52e28ad8
Reviewed-on: https://chromium-review.googlesource.com/753730Reviewed-by: 's avatarJakob Kummerow <jkummerow@chromium.org>
Commit-Queue: Georg Neis <neis@chromium.org>
Cr-Commit-Position: refs/heads/master@{#49171}
parent 146c6bd9
......@@ -31,19 +31,9 @@ BUILTIN(BigIntConstructor) {
BUILTIN(BigIntConstructor_ConstructStub) {
HandleScope scope(isolate);
Handle<Object> value = args.atOrUndefined(isolate, 1);
Handle<JSFunction> target = args.target();
Handle<JSReceiver> new_target = Handle<JSReceiver>::cast(args.new_target());
DCHECK(*target == target->native_context()->bigint_function());
Handle<JSObject> result;
ASSIGN_RETURN_FAILURE_ON_EXCEPTION(isolate, result,
JSObject::New(target, new_target));
// TODO(jkummerow): Implement.
USE(value);
USE(result);
UNIMPLEMENTED();
THROW_NEW_ERROR_RETURN_FAILURE(
isolate, NewTypeError(MessageTemplate::kNotConstructor,
isolate->factory()->BigInt_string()));
}
BUILTIN(BigIntParseInt) {
......
......@@ -18,6 +18,15 @@ const six = BigInt(6);
// BigInt
{
assertSame(BigInt, BigInt.prototype.constructor)
}{
assertThrows(() => new BigInt, TypeError);
assertThrows(() => new BigInt(), TypeError);
assertThrows(() => new BigInt(0), TypeError);
assertThrows(() => new BigInt(0n), TypeError);
assertThrows(() => new BigInt("0"), TypeError);
}{
class C extends BigInt { constructor() { throw 42 } };
assertThrowsEquals(() => new C, 42);
}
// ToBigInt, NumberToBigInt, BigInt
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment