Fix Date.prototype[@@toPrimitive] hint handling (#3967)

The Date.prototype[@@toPrimitive] only allows the "string", "default" and "number"
hint values. Any other value should throw a TypeError.

JerryScript-DCO-1.0-Signed-off-by: Peter Gal pgal.usz@partner.samsung.com
This commit is contained in:
Péter Gál
2020-07-02 11:40:08 +02:00
committed by GitHub
parent e943d12286
commit 55d6637da5
3 changed files with 9 additions and 2 deletions
@@ -42,6 +42,14 @@ try {
assert(e instanceof TypeError);
}
// Test with invalid hint value
try {
dateObj[Symbol.toPrimitive]('error');
assert(false);
} catch (e) {
assert(e instanceof TypeError);
}
// Test when unable to call toPrimitive
try {
Date.prototype[Symbol.toPrimitive].call(undefined);