argument-string.js (2614B)
1 // |reftest| skip-if(!this.hasOwnProperty('Temporal')) -- Temporal is not enabled unconditionally 2 // Copyright (C) 2022 Igalia, S.L. All rights reserved. 3 // This code is governed by the BSD license found in the LICENSE file. 4 5 /*--- 6 esid: sec-temporal.plaintime.from 7 description: Various ISO strings supported 8 includes: [compareArray.js, temporalHelpers.js] 9 features: [Temporal] 10 ---*/ 11 12 const tests = [ 13 ["15:23", 15, 23, 0, 0, 0, 0], 14 ["15:23:30", 15, 23, 30, 0, 0, 0], 15 ["15:23:30.123", 15, 23, 30, 123, 0, 0], 16 ["15:23:30.123456", 15, 23, 30, 123, 456, 0], 17 ["15:23:30.123456789", 15, 23, 30, 123, 456, 789], 18 ["1976-11-18T15:23:30.1", 15, 23, 30, 100, 0, 0], 19 ["1976-11-18T15:23:30.12", 15, 23, 30, 120, 0, 0], 20 ["1976-11-18T15:23:30.123", 15, 23, 30, 123, 0, 0], 21 ["1976-11-18T15:23:30.1234", 15, 23, 30, 123, 400, 0], 22 ["1976-11-18T15:23:30.12345", 15, 23, 30, 123, 450, 0], 23 ["1976-11-18T15:23:30.123456", 15, 23, 30, 123, 456, 0], 24 ["1976-11-18T15:23:30.1234567", 15, 23, 30, 123, 456, 700], 25 ["1976-11-18T15:23:30.12345678", 15, 23, 30, 123, 456, 780], 26 ["1976-11-18T15:23:30.123456789", 15, 23, 30, 123, 456, 789], 27 ["1976-11-18T15:23:30,12", 15, 23, 30, 120, 0, 0], 28 ["1976-11-18T15:23:30.12-02:00", 15, 23, 30, 120, 0, 0], 29 ["152330", 15, 23, 30, 0, 0, 0], 30 ["152330.1", 15, 23, 30, 100, 0, 0], 31 ["152330-08", 15, 23, 30, 0, 0, 0], 32 ["152330.1-08", 15, 23, 30, 100, 0, 0], 33 ["152330-0800", 15, 23, 30, 0, 0, 0], 34 ["152330.1-0800", 15, 23, 30, 100, 0, 0], 35 ["1976-11-18T152330.1+00:00", 15, 23, 30, 100, 0, 0], 36 ["19761118T15:23:30.1+00:00", 15, 23, 30, 100, 0, 0], 37 ["1976-11-18T15:23:30.1+0000", 15, 23, 30, 100, 0, 0], 38 ["1976-11-18T152330.1+0000", 15, 23, 30, 100, 0, 0], 39 ["19761118T15:23:30.1+0000", 15, 23, 30, 100, 0, 0], 40 ["19761118T152330.1+00:00", 15, 23, 30, 100, 0, 0], 41 ["19761118T152330.1+0000", 15, 23, 30, 100, 0, 0], 42 ["+001976-11-18T152330.1+00:00", 15, 23, 30, 100, 0, 0], 43 ["+0019761118T15:23:30.1+00:00", 15, 23, 30, 100, 0, 0], 44 ["+001976-11-18T15:23:30.1+0000", 15, 23, 30, 100, 0, 0], 45 ["+001976-11-18T152330.1+0000", 15, 23, 30, 100, 0, 0], 46 ["+0019761118T15:23:30.1+0000", 15, 23, 30, 100, 0, 0], 47 ["+0019761118T152330.1+00:00", 15, 23, 30, 100, 0, 0], 48 ["+0019761118T152330.1+0000", 15, 23, 30, 100, 0, 0], 49 ["15", 15, 0, 0, 0, 0, 0], 50 ["T15:23:30", 15, 23, 30, 0, 0, 0], 51 ["t152330", 15, 23, 30, 0, 0, 0], 52 ]; 53 54 for (const [input, ...expected] of tests) { 55 const result = Temporal.PlainTime.from(input); 56 assert.sameValue(expected.length, 6, input); 57 TemporalHelpers.assertPlainTime(result, ...expected, input); 58 } 59 60 reportCompare(0, 0);