summaryrefslogtreecommitdiffstats
path: root/js/src/tests/test262/built-ins/Temporal/Duration/from/argument-string-fractional-with-zero-subparts.js
blob: 292dc1b7126c5129ce78b97d92839f22b23d4cb8 (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
29
30
31
32
33
34
35
36
// |reftest| skip-if(!this.hasOwnProperty('Temporal')) -- Temporal is not enabled unconditionally
// Copyright (C) 2022 André Bargull. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.

/*---
esid: sec-temporal.duration.from
description: >
  Throws when a fractional unit is present and a sub-part is zero.
features: [Temporal]
---*/

const invalid = [
  // Hours fraction with whole minutes.
  "PT0.1H0M",

  // Hours fraction with fractional minutes.
  "PT0.1H0.0M",

  // Hours fraction with whole seconds.
  "PT0.1H0S",

  // Hours fraction with fractional seconds.
  "PT0.1H0.0S",

  // Minutes fraction with whole seconds.
  "PT0.1M0S",

  // Minutes fraction with fractional seconds.
  "PT0.1M0.0S",
];

for (let string of invalid) {
  assert.throws(RangeError, () => Temporal.Duration.from(string));
}

reportCompare(0, 0);