fields-overspecified.js (1182B)
1 // |reftest| skip-if(!this.hasOwnProperty('Temporal')) -- Temporal is not enabled unconditionally 2 // Copyright (C) 2024 Mozilla Corporation. All rights reserved. 3 // This code is governed by the BSD license found in the LICENSE file. 4 5 /*--- 6 esid: sec-temporal.plainmonthday.from 7 description: Throw a RangeError if fields conflict with each other 8 features: [Temporal, Intl.Era-monthcode] 9 ---*/ 10 11 // eraYear and year must be consistent when monthCode is present. 12 { 13 let fields = { 14 calendar: "gregory", 15 era: "ce", 16 eraYear: 2024, 17 year: 2023, 18 monthCode: "M01", 19 day: 1, 20 }; 21 assert.throws(RangeError, () => Temporal.PlainMonthDay.from(fields)); 22 } 23 24 // eraYear and year must be consistent when month is present. 25 { 26 let fields = { 27 calendar: "gregory", 28 era: "ce", 29 eraYear: 2024, 30 year: 2023, 31 month: 1, 32 day: 1, 33 }; 34 assert.throws(RangeError, () => Temporal.PlainMonthDay.from(fields)); 35 } 36 37 // monthCode and month must be consistent. 38 { 39 let fields = { 40 calendar: "gregory", 41 year: 2024, 42 monthCode: "M01", 43 month: 2, 44 day: 1, 45 }; 46 assert.throws(RangeError, () => Temporal.PlainMonthDay.from(fields)); 47 } 48 49 50 reportCompare(0, 0);