summaryrefslogtreecommitdiffstats
path: root/js/src/tests/test262/built-ins/Temporal/PlainDate/basic.js
blob: fab877e5e5fd57ed88bca42093df11fa2d85e864 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
// |reftest| skip-if(!this.hasOwnProperty('Temporal')) -- Temporal is not enabled unconditionally
// Copyright (C) 2021 Igalia, S.L. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.

/*---
esid: sec-temporal.plaindate
description: Basic tests for the PlainDate constructor.
includes: [temporalHelpers.js]
features: [Temporal]
---*/

Object.defineProperty(Temporal.Calendar, "from", {
  get() {
    throw new Test262Error("Should not get Calendar.from");
  },
});

const calendar = new Temporal.Calendar("iso8601");
const plainDateWithObject = new Temporal.PlainDate(2020, 12, 24, calendar);
TemporalHelpers.assertPlainDate(plainDateWithObject, 2020, 12, "M12", 24, "with object");
assert.sameValue(plainDateWithObject.getCalendar(), calendar);

const plainDateWithString = new Temporal.PlainDate(2020, 12, 24, "iso8601");
TemporalHelpers.assertPlainDate(plainDateWithString, 2020, 12, "M12", 24, "with string");
assert.sameValue(plainDateWithString.getISOFields().calendar, "iso8601", "calendar slot should store a string");
assert.notSameValue(plainDateWithString.getCalendar(), calendar);

reportCompare(0, 0);