Temporal: Add missing valueOf tests.

This commit is contained in:
Ms2ger 2022-06-10 14:52:20 +02:00 committed by Philip Chimento
parent bb926a1796
commit 267aab37c2
2 changed files with 42 additions and 0 deletions

View File

@ -0,0 +1,21 @@
// Copyright (C) 2022 Igalia, S.L. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
esid: sec-temporal.instant.prototype.valueof
description: Basic tests for valueOf().
features: [Temporal]
---*/
const instant = new Temporal.Instant(100n);
const instant2 = new Temporal.Instant(987654321n);
assert.throws(TypeError, () => instant.valueOf(), "valueOf");
assert.throws(TypeError, () => instant < instant, "<");
assert.throws(TypeError, () => instant <= instant, "<=");
assert.throws(TypeError, () => instant > instant, ">");
assert.throws(TypeError, () => instant >= instant, ">=");
assert.sameValue(instant === instant, true, "===");
assert.sameValue(instant === instant2, false, "===");
assert.sameValue(instant !== instant, false, "!==");
assert.sameValue(instant !== instant2, true, "!==");

View File

@ -0,0 +1,21 @@
// Copyright (C) 2022 Igalia, S.L. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
esid: sec-temporal.zoneddatetime.prototype.valueof
description: Basic tests for valueOf().
features: [Temporal]
---*/
const zonedDateTime = new Temporal.ZonedDateTime(100n, "UTC");
const zonedDateTime2 = new Temporal.ZonedDateTime(987654321n, "UTC");
assert.throws(TypeError, () => zonedDateTime.valueOf(), "valueOf");
assert.throws(TypeError, () => zonedDateTime < zonedDateTime, "<");
assert.throws(TypeError, () => zonedDateTime <= zonedDateTime, "<=");
assert.throws(TypeError, () => zonedDateTime > zonedDateTime, ">");
assert.throws(TypeError, () => zonedDateTime >= zonedDateTime, ">=");
assert.sameValue(zonedDateTime === zonedDateTime, true, "===");
assert.sameValue(zonedDateTime === zonedDateTime2, false, "===");
assert.sameValue(zonedDateTime !== zonedDateTime, false, "!==");
assert.sameValue(zonedDateTime !== zonedDateTime2, true, "!==");