Added case when Object has valueOf and toString

This commit is contained in:
Caio Lima 2017-11-17 00:22:13 -02:00
parent 349baebc01
commit dd72bf0d26
2 changed files with 27 additions and 2 deletions

View File

@ -0,0 +1,25 @@
// Copyright (C) 2017 Caio Lima. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
description: ToPrimitive receives "hint Number" as parameter, then valueOf needs to be called
esid: sec-bigint-constructor-number-value
info: |
1. If NewTarget is not undefined, throw a TypeError exception.
2. Let prim be ? ToPrimitive(value, hint Number).
...
features: [BigInt]
---*/
let o = {
valueOf: function() {
return 44;
},
toString: function() {
throw new Test262Error("unreachable");
}
}
assert.sameValue(BigInt(o), 44n);

View File

@ -14,13 +14,13 @@ features: [BigInt]
assert.throws(Test262Error, function() {
BigInt({
valueOf: function() { throw new Test262Error("unreachable"); }
valueOf: function() { throw new Test262Error(); }
});
}
assert.throws(Test262Error, function() {
BigInt({
toString: function() { throw new Test262Error("unreachable"); }
toString: function() { throw new Test262Error(); }
});
}