mirror of https://github.com/tc39/test262.git
Temporal: Clean up existing uses of foo.splice(0, foo.length)
The second parameter isn't needed if the intention is to empty the array. Additionally clearing it at the end of the test isn't needed.
This commit is contained in:
parent
47b9e32dc3
commit
1e9dc7f38e
|
@ -252,7 +252,7 @@ var TemporalHelpers = {
|
|||
Object.entries(expectedLargestUnitCalls).forEach(([largestUnit, expected], index) => {
|
||||
func(calendar, largestUnit, index);
|
||||
assert.compareArray(actual, expected, `largestUnit passed to calendar.dateUntil() for largestUnit ${largestUnit}`);
|
||||
actual.splice(0, actual.length); // empty it for the next check
|
||||
actual.splice(0); // empty it for the next check
|
||||
});
|
||||
},
|
||||
|
||||
|
|
|
@ -247,7 +247,7 @@ Temporal.Duration.compare(
|
|||
createOptionsObserver(zonedRelativeTo)
|
||||
);
|
||||
assert.compareArray(actual, expectedOpsForZonedRelativeTo, "order of operations with ZonedDateTime relativeTo and no calendar units");
|
||||
actual.splice(0, actual.length); // clear
|
||||
actual.splice(0); // clear
|
||||
|
||||
// code path through UnbalanceDurationRelative that balances higher units down
|
||||
// to days:
|
||||
|
|
|
@ -32,7 +32,7 @@ assert.compareArray(actual, expected1, "operations");
|
|||
// There is a second path, through BalanceDurationRelative, that calls
|
||||
// dateUntil() in a loop for each year in the duration plus one extra time
|
||||
|
||||
actual.splice(0, actual.length); // reset calls for next test
|
||||
actual.splice(0); // reset calls for next test
|
||||
const expected2 = [
|
||||
"call dateUntil",
|
||||
"call dateUntil",
|
||||
|
|
|
@ -84,7 +84,7 @@ const plainRelativeTo = TemporalHelpers.propertyBagObserver(actual, {
|
|||
// basic order of observable operations, without rounding:
|
||||
instance.round(createOptionsObserver({ relativeTo: plainRelativeTo }));
|
||||
assert.compareArray(actual, expectedOpsForPlainRelativeTo, "order of operations for PlainDate relativeTo");
|
||||
actual.splice(0, actual.length); // clear
|
||||
actual.splice(0); // clear
|
||||
|
||||
// code path through RoundDuration that rounds to the nearest year:
|
||||
const expectedOpsForYearRounding = expectedOpsForPlainRelativeTo.concat([
|
||||
|
@ -99,7 +99,7 @@ const expectedOpsForYearRounding = expectedOpsForPlainRelativeTo.concat([
|
|||
]);
|
||||
instance.round(createOptionsObserver({ smallestUnit: "years", relativeTo: plainRelativeTo }));
|
||||
assert.compareArray(actual, expectedOpsForYearRounding, "order of operations with smallestUnit = years");
|
||||
actual.splice(0, actual.length); // clear
|
||||
actual.splice(0); // clear
|
||||
|
||||
// code path through Duration.prototype.round that rounds to the nearest month:
|
||||
const expectedOpsForMonthRounding = expectedOpsForPlainRelativeTo.concat([
|
||||
|
@ -121,7 +121,7 @@ const expectedOpsForMonthRounding = expectedOpsForPlainRelativeTo.concat([
|
|||
const instance2 = new Temporal.Duration(1, 0, 0, 62);
|
||||
instance2.round(createOptionsObserver({ largestUnit: "months", smallestUnit: "months", relativeTo: plainRelativeTo }));
|
||||
assert.compareArray(actual, expectedOpsForMonthRounding, "order of operations with largestUnit = smallestUnit = months");
|
||||
actual.splice(0, actual.length); // clear
|
||||
actual.splice(0); // clear
|
||||
|
||||
// code path through Duration.prototype.round that rounds to the nearest week:
|
||||
const expectedOpsForWeekRounding = expectedOpsForPlainRelativeTo.concat([
|
||||
|
@ -140,7 +140,7 @@ const expectedOpsForWeekRounding = expectedOpsForPlainRelativeTo.concat([
|
|||
const instance3 = new Temporal.Duration(1, 1, 0, 15);
|
||||
instance3.round(createOptionsObserver({ largestUnit: "weeks", smallestUnit: "weeks", relativeTo: plainRelativeTo }));
|
||||
assert.compareArray(actual, expectedOpsForWeekRounding, "order of operations with largestUnit = smallestUnit = weeks");
|
||||
actual.splice(0, actual.length); // clear
|
||||
actual.splice(0); // clear
|
||||
|
||||
// code path through UnbalanceDurationRelative that rounds to the nearest day:
|
||||
const expectedOpsForDayRounding = expectedOpsForPlainRelativeTo.concat([
|
||||
|
@ -152,7 +152,7 @@ const expectedOpsForDayRounding = expectedOpsForPlainRelativeTo.concat([
|
|||
const instance4 = new Temporal.Duration(1, 1, 1)
|
||||
instance4.round(createOptionsObserver({ largestUnit: "days", smallestUnit: "days", relativeTo: plainRelativeTo }));
|
||||
assert.compareArray(actual, expectedOpsForDayRounding, "order of operations with largestUnit = smallestUnit = days");
|
||||
actual.splice(0, actual.length); // clear
|
||||
actual.splice(0); // clear
|
||||
|
||||
// code path through BalanceDurationRelative balancing from days up to years:
|
||||
const expectedOpsForDayToYearBalancing = expectedOpsForPlainRelativeTo.concat([
|
||||
|
@ -168,7 +168,7 @@ const expectedOpsForDayToYearBalancing = expectedOpsForPlainRelativeTo.concat([
|
|||
const instance5 = new Temporal.Duration(0, 0, 0, 0, /* hours = */ 396 * 24);
|
||||
instance5.round(createOptionsObserver({ largestUnit: "years", smallestUnit: "days", relativeTo: plainRelativeTo }));
|
||||
assert.compareArray(actual, expectedOpsForDayToYearBalancing, "order of operations with largestUnit = years, smallestUnit = days");
|
||||
actual.splice(0, actual.length); // clear
|
||||
actual.splice(0); // clear
|
||||
|
||||
// code path through Duration.prototype.round balancing from months up to years:
|
||||
const expectedOpsForMonthToYearBalancing = expectedOpsForPlainRelativeTo.concat([
|
||||
|
@ -190,7 +190,7 @@ const expectedOpsForMonthToYearBalancing = expectedOpsForPlainRelativeTo.concat(
|
|||
const instance6 = new Temporal.Duration(0, 12);
|
||||
instance6.round(createOptionsObserver({ largestUnit: "years", smallestUnit: "months", relativeTo: plainRelativeTo }));
|
||||
assert.compareArray(actual, expectedOpsForMonthToYearBalancing, "order of operations with largestUnit = years, smallestUnit = months");
|
||||
actual.splice(0, actual.length); // clear
|
||||
actual.splice(0); // clear
|
||||
|
||||
const expectedOpsForDayToMonthBalancing = expectedOpsForPlainRelativeTo.concat([
|
||||
// BalanceDurationRelative
|
||||
|
@ -201,7 +201,7 @@ const expectedOpsForDayToMonthBalancing = expectedOpsForPlainRelativeTo.concat([
|
|||
const instance7 = new Temporal.Duration(0, 0, 0, 0, /* hours = */ 32 * 24);
|
||||
instance7.round(createOptionsObserver({ largestUnit: "months", smallestUnit: "days", relativeTo: plainRelativeTo }));
|
||||
assert.compareArray(actual, expectedOpsForDayToMonthBalancing, "order of operations with largestUnit = months, smallestUnit = days");
|
||||
actual.splice(0, actual.length); // clear
|
||||
actual.splice(0); // clear
|
||||
|
||||
const expectedOpsForDayToWeekBalancing = expectedOpsForPlainRelativeTo.concat([
|
||||
// BalanceDurationRelative
|
||||
|
@ -212,7 +212,7 @@ const expectedOpsForDayToWeekBalancing = expectedOpsForPlainRelativeTo.concat([
|
|||
const instance8 = new Temporal.Duration(0, 0, 0, 0, /* hours = */ 8 * 24);
|
||||
instance8.round(createOptionsObserver({ largestUnit: "weeks", smallestUnit: "days", relativeTo: plainRelativeTo }));
|
||||
assert.compareArray(actual, expectedOpsForDayToWeekBalancing, "order of operations with largestUnit = weeks, smallestUnit = days");
|
||||
actual.splice(0, actual.length); // clear
|
||||
actual.splice(0); // clear
|
||||
|
||||
const expectedOpsForZonedRelativeTo = expected.concat([
|
||||
// ToRelativeTemporalObject
|
||||
|
|
|
@ -78,7 +78,7 @@ const plainRelativeTo = TemporalHelpers.propertyBagObserver(actual, {
|
|||
// basic order of observable operations, without rounding:
|
||||
instance.total(createOptionsObserver({ unit: "nanoseconds", relativeTo: plainRelativeTo }));
|
||||
assert.compareArray(actual, expectedOpsForPlainRelativeTo, "order of operations for PlainDate relativeTo");
|
||||
actual.splice(0, actual.length); // clear
|
||||
actual.splice(0); // clear
|
||||
|
||||
// code path through RoundDuration that rounds to the nearest year:
|
||||
const expectedOpsForYearRounding = expectedOpsForPlainRelativeTo.concat([
|
||||
|
@ -93,7 +93,7 @@ const expectedOpsForYearRounding = expectedOpsForPlainRelativeTo.concat([
|
|||
]);
|
||||
instance.total(createOptionsObserver({ unit: "years", relativeTo: plainRelativeTo }));
|
||||
assert.compareArray(actual, expectedOpsForYearRounding, "order of operations with unit = years");
|
||||
actual.splice(0, actual.length); // clear
|
||||
actual.splice(0); // clear
|
||||
|
||||
// code path through Duration.prototype.total that rounds to the nearest month:
|
||||
const expectedOpsForMonthRounding = expectedOpsForPlainRelativeTo.concat([
|
||||
|
@ -111,7 +111,7 @@ const expectedOpsForMonthRounding = expectedOpsForPlainRelativeTo.concat([
|
|||
const instance2 = new Temporal.Duration(1, 0, 0, 62);
|
||||
instance2.total(createOptionsObserver({ unit: "months", relativeTo: plainRelativeTo }));
|
||||
assert.compareArray(actual, expectedOpsForMonthRounding, "order of operations with unit = months");
|
||||
actual.splice(0, actual.length); // clear
|
||||
actual.splice(0); // clear
|
||||
|
||||
// code path through Duration.prototype.total that rounds to the nearest week:
|
||||
const expectedOpsForWeekRounding = expectedOpsForPlainRelativeTo.concat([
|
||||
|
@ -126,7 +126,7 @@ const expectedOpsForWeekRounding = expectedOpsForPlainRelativeTo.concat([
|
|||
const instance3 = new Temporal.Duration(1, 1, 0, 15);
|
||||
instance3.total(createOptionsObserver({ unit: "weeks", relativeTo: plainRelativeTo }));
|
||||
assert.compareArray(actual, expectedOpsForWeekRounding, "order of operations with unit = weeks");
|
||||
actual.splice(0, actual.length); // clear
|
||||
actual.splice(0); // clear
|
||||
|
||||
// code path through UnbalanceDurationRelative that rounds to the nearest day:
|
||||
const expectedOpsForDayRounding = expectedOpsForPlainRelativeTo.concat([
|
||||
|
@ -138,7 +138,7 @@ const expectedOpsForDayRounding = expectedOpsForPlainRelativeTo.concat([
|
|||
const instance4 = new Temporal.Duration(1, 1, 1)
|
||||
instance4.total(createOptionsObserver({ unit: "days", relativeTo: plainRelativeTo }));
|
||||
assert.compareArray(actual, expectedOpsForDayRounding, "order of operations with unit = days");
|
||||
actual.splice(0, actual.length); // clear
|
||||
actual.splice(0); // clear
|
||||
|
||||
const expectedOpsForZonedRelativeTo = [
|
||||
// ToRelativeTemporalObject
|
||||
|
|
|
@ -28,6 +28,6 @@ const result = Temporal.PlainDate.from("2021-05-17", object);
|
|||
assert.compareArray(actual, expected, "Successful call");
|
||||
TemporalHelpers.assertPlainDate(result, 2021, 5, "M05", 17);
|
||||
|
||||
actual.splice(0, actual.length); // empty it for the next check
|
||||
actual.splice(0); // empty it for the next check
|
||||
assert.throws(RangeError, () => Temporal.PlainDate.from(7, object));
|
||||
assert.compareArray(actual, expected, "Failing call");
|
||||
|
|
|
@ -90,12 +90,12 @@ function createOptionsObserver({ smallestUnit = "days", largestUnit = "auto", ro
|
|||
}
|
||||
|
||||
// clear any observable things that happened while constructing the objects
|
||||
actual.splice(0, actual.length);
|
||||
actual.splice(0);
|
||||
|
||||
// basic order of observable operations, without rounding:
|
||||
instance.since(otherDatePropertyBag, createOptionsObserver());
|
||||
assert.compareArray(actual, expected, "order of operations");
|
||||
actual.splice(0, actual.length); // clear
|
||||
actual.splice(0); // clear
|
||||
|
||||
// code path through RoundDuration that rounds to the nearest year:
|
||||
const expectedOpsForYearRounding = expected.concat([
|
||||
|
@ -110,7 +110,7 @@ const expectedOpsForYearRounding = expected.concat([
|
|||
]);
|
||||
instance.since(otherDatePropertyBag, createOptionsObserver({ smallestUnit: "years" }));
|
||||
assert.compareArray(actual, expectedOpsForYearRounding, "order of operations with smallestUnit = years");
|
||||
actual.splice(0, actual.length); // clear
|
||||
actual.splice(0); // clear
|
||||
|
||||
// code path through RoundDuration that rounds to the nearest month:
|
||||
const expectedOpsForMonthRounding = expected.concat([
|
||||
|
@ -121,7 +121,7 @@ const expectedOpsForMonthRounding = expected.concat([
|
|||
]); // (10.n.iii MoveRelativeDate not called because weeks == 0)
|
||||
instance.since(otherDatePropertyBag, createOptionsObserver({ smallestUnit: "months" }));
|
||||
assert.compareArray(actual, expectedOpsForMonthRounding, "order of operations with smallestUnit = months");
|
||||
actual.splice(0, actual.length); // clear
|
||||
actual.splice(0); // clear
|
||||
|
||||
// code path through RoundDuration that rounds to the nearest week:
|
||||
const expectedOpsForWeekRounding = expected.concat([
|
||||
|
@ -130,4 +130,3 @@ const expectedOpsForWeekRounding = expected.concat([
|
|||
]); // (11.g.iii MoveRelativeDate not called because days already balanced)
|
||||
instance.since(otherDatePropertyBag, createOptionsObserver({ smallestUnit: "weeks" }));
|
||||
assert.compareArray(actual.slice(expected.length), expectedOpsForWeekRounding.slice(expected.length), "order of operations with smallestUnit = weeks");
|
||||
actual.slice(0, actual.length); // clear
|
||||
|
|
|
@ -90,12 +90,12 @@ function createOptionsObserver({ smallestUnit = "days", largestUnit = "auto", ro
|
|||
}
|
||||
|
||||
// clear any observable things that happened while constructing the objects
|
||||
actual.splice(0, actual.length);
|
||||
actual.splice(0);
|
||||
|
||||
// basic order of observable operations, without rounding:
|
||||
instance.until(otherDatePropertyBag, createOptionsObserver());
|
||||
assert.compareArray(actual, expected, "order of operations");
|
||||
actual.splice(0, actual.length); // clear
|
||||
actual.splice(0); // clear
|
||||
|
||||
// code path through RoundDuration that rounds to the nearest year:
|
||||
const expectedOpsForYearRounding = expected.concat([
|
||||
|
@ -110,7 +110,7 @@ const expectedOpsForYearRounding = expected.concat([
|
|||
]);
|
||||
instance.until(otherDatePropertyBag, createOptionsObserver({ smallestUnit: "years" }));
|
||||
assert.compareArray(actual, expectedOpsForYearRounding, "order of operations with smallestUnit = years");
|
||||
actual.splice(0, actual.length); // clear
|
||||
actual.splice(0); // clear
|
||||
|
||||
// code path through RoundDuration that rounds to the nearest month:
|
||||
const expectedOpsForMonthRounding = expected.concat([
|
||||
|
@ -121,7 +121,7 @@ const expectedOpsForMonthRounding = expected.concat([
|
|||
]); // (10.n.iii MoveRelativeDate not called because weeks == 0)
|
||||
instance.until(otherDatePropertyBag, createOptionsObserver({ smallestUnit: "months" }));
|
||||
assert.compareArray(actual, expectedOpsForMonthRounding, "order of operations with smallestUnit = months");
|
||||
actual.splice(0, actual.length); // clear
|
||||
actual.splice(0); // clear
|
||||
|
||||
// code path through RoundDuration that rounds to the nearest week:
|
||||
const expectedOpsForWeekRounding = expected.concat([
|
||||
|
@ -130,4 +130,3 @@ const expectedOpsForWeekRounding = expected.concat([
|
|||
]); // (11.g.iii MoveRelativeDate not called because days already balanced)
|
||||
instance.until(otherDatePropertyBag, createOptionsObserver({ smallestUnit: "weeks" }));
|
||||
assert.compareArray(actual.slice(expected.length), expectedOpsForWeekRounding.slice(expected.length), "order of operations with smallestUnit = weeks");
|
||||
actual.slice(0, actual.length); // clear
|
||||
|
|
|
@ -23,7 +23,7 @@ assert.compareArray(actual, []);
|
|||
assert.sameValue(dt1.equals(dt2), true, "same calendar string");
|
||||
assert.compareArray(actual, ["get calendar1.toString", "call calendar1.toString", "get calendar2.toString", "call calendar2.toString"]);
|
||||
|
||||
actual.splice(0, actual.length); // empty it for the next check
|
||||
actual.splice(0); // empty it for the next check
|
||||
assert.sameValue(dt1.equals(dt3), false, "different calendar string");
|
||||
assert.compareArray(actual, ["get calendar1.toString", "call calendar1.toString", "get calendar3.toString", "call calendar3.toString"]);
|
||||
|
||||
|
|
|
@ -114,12 +114,12 @@ function createOptionsObserver({ smallestUnit = "nanoseconds", largestUnit = "au
|
|||
}
|
||||
|
||||
// clear any observable things that happened while constructing the objects
|
||||
actual.splice(0, actual.length);
|
||||
actual.splice(0);
|
||||
|
||||
// basic order of observable operations, without rounding:
|
||||
instance.since(otherDateTimePropertyBag, createOptionsObserver());
|
||||
assert.compareArray(actual, expected, "order of operations");
|
||||
actual.splice(0, actual.length); // clear
|
||||
actual.splice(0); // clear
|
||||
|
||||
// code path through RoundDuration that rounds to the nearest year:
|
||||
const expectedOpsForYearRounding = expected.concat([
|
||||
|
@ -134,7 +134,7 @@ const expectedOpsForYearRounding = expected.concat([
|
|||
]);
|
||||
instance.since(otherDateTimePropertyBag, createOptionsObserver({ smallestUnit: "years" }));
|
||||
assert.compareArray(actual, expectedOpsForYearRounding, "order of operations with smallestUnit = years");
|
||||
actual.splice(0, actual.length); // clear
|
||||
actual.splice(0); // clear
|
||||
|
||||
// code path through RoundDuration that rounds to the nearest month:
|
||||
const expectedOpsForMonthRounding = expected.concat([
|
||||
|
@ -145,7 +145,7 @@ const expectedOpsForMonthRounding = expected.concat([
|
|||
]); // (10.n.iii MoveRelativeDate not called because weeks == 0)
|
||||
instance.since(otherDateTimePropertyBag, createOptionsObserver({ smallestUnit: "months" }));
|
||||
assert.compareArray(actual, expectedOpsForMonthRounding, "order of operations with smallestUnit = months");
|
||||
actual.splice(0, actual.length); // clear
|
||||
actual.splice(0); // clear
|
||||
|
||||
// code path through RoundDuration that rounds to the nearest week:
|
||||
const expectedOpsForWeekRounding = expected.concat([
|
||||
|
@ -154,4 +154,3 @@ const expectedOpsForWeekRounding = expected.concat([
|
|||
]); // (11.g.iii MoveRelativeDate not called because days already balanced)
|
||||
instance.since(otherDateTimePropertyBag, createOptionsObserver({ smallestUnit: "weeks" }));
|
||||
assert.compareArray(actual.slice(expected.length), expectedOpsForWeekRounding.slice(expected.length), "order of operations with smallestUnit = weeks");
|
||||
actual.slice(0, actual.length); // clear
|
||||
|
|
|
@ -114,12 +114,12 @@ function createOptionsObserver({ smallestUnit = "nanoseconds", largestUnit = "au
|
|||
}
|
||||
|
||||
// clear any observable things that happened while constructing the objects
|
||||
actual.splice(0, actual.length);
|
||||
actual.splice(0);
|
||||
|
||||
// basic order of observable operations, without rounding:
|
||||
instance.until(otherDateTimePropertyBag, createOptionsObserver());
|
||||
assert.compareArray(actual, expected, "order of operations");
|
||||
actual.splice(0, actual.length); // clear
|
||||
actual.splice(0); // clear
|
||||
|
||||
// code path through RoundDuration that rounds to the nearest year:
|
||||
const expectedOpsForYearRounding = expected.concat([
|
||||
|
@ -134,7 +134,7 @@ const expectedOpsForYearRounding = expected.concat([
|
|||
]);
|
||||
instance.until(otherDateTimePropertyBag, createOptionsObserver({ smallestUnit: "years" }));
|
||||
assert.compareArray(actual, expectedOpsForYearRounding, "order of operations with smallestUnit = years");
|
||||
actual.splice(0, actual.length); // clear
|
||||
actual.splice(0); // clear
|
||||
|
||||
// code path through RoundDuration that rounds to the nearest month:
|
||||
const expectedOpsForMonthRounding = expected.concat([
|
||||
|
@ -145,7 +145,7 @@ const expectedOpsForMonthRounding = expected.concat([
|
|||
]); // (10.n.iii MoveRelativeDate not called because weeks == 0)
|
||||
instance.until(otherDateTimePropertyBag, createOptionsObserver({ smallestUnit: "months" }));
|
||||
assert.compareArray(actual, expectedOpsForMonthRounding, "order of operations with smallestUnit = years");
|
||||
actual.splice(0, actual.length); // clear
|
||||
actual.splice(0); // clear
|
||||
|
||||
// code path through RoundDuration that rounds to the nearest week:
|
||||
const expectedOpsForWeekRounding = expected.concat([
|
||||
|
@ -154,4 +154,3 @@ const expectedOpsForWeekRounding = expected.concat([
|
|||
]); // (11.g.iii MoveRelativeDate not called because days already balanced)
|
||||
instance.until(otherDateTimePropertyBag, createOptionsObserver({ smallestUnit: "weeks" }));
|
||||
assert.compareArray(actual.slice(expected.length), expectedOpsForWeekRounding.slice(expected.length), "order of operations with smallestUnit = weeks");
|
||||
actual.slice(0, actual.length); // clear
|
||||
|
|
|
@ -36,7 +36,7 @@ const ym6 = new Temporal.PlainYearMonth(2000, 1, new CustomCalendar("e"), 1);
|
|||
assert.sameValue(ym5.equals(ym6), false);
|
||||
assert.compareArray(actual, ["d", "e"], "order of operations");
|
||||
|
||||
actual.splice(0, actual.length); // empty it for the next check
|
||||
actual.splice(0); // empty it for the next check
|
||||
const ym7 = new Temporal.PlainYearMonth(2000, 1, new CustomCalendar("f"), 1);
|
||||
const ym8 = new Temporal.PlainYearMonth(2000, 1, new CustomCalendar("f"), 1);
|
||||
assert.sameValue(ym7.equals(ym8), true);
|
||||
|
|
|
@ -101,7 +101,7 @@ function createOptionsObserver({ smallestUnit = "months", largestUnit = "auto",
|
|||
}
|
||||
|
||||
// clear any observable things that happened while constructing the objects
|
||||
actual.splice(0, actual.length);
|
||||
actual.splice(0);
|
||||
|
||||
// code path through RoundDuration that rounds to the nearest year:
|
||||
const expectedOpsForYearRounding = expected.concat([
|
||||
|
@ -116,7 +116,7 @@ const expectedOpsForYearRounding = expected.concat([
|
|||
]);
|
||||
instance.since(otherYearMonthPropertyBag, createOptionsObserver({ smallestUnit: "years" }));
|
||||
assert.compareArray(actual, expectedOpsForYearRounding, "order of operations with smallestUnit = years");
|
||||
actual.splice(0, actual.length); // clear
|
||||
actual.splice(0); // clear
|
||||
|
||||
// code path through RoundDuration that rounds to the nearest month:
|
||||
const expectedOpsForMonthRounding = expected.concat([
|
||||
|
@ -127,4 +127,3 @@ const expectedOpsForMonthRounding = expected.concat([
|
|||
]); // (10.n.iii MoveRelativeDate not called because weeks == 0)
|
||||
instance.since(otherYearMonthPropertyBag, createOptionsObserver({ smallestUnit: "months", roundingIncrement: 2 }));
|
||||
assert.compareArray(actual, expectedOpsForMonthRounding, "order of operations with smallestUnit = months");
|
||||
actual.splice(0, actual.length); // clear
|
||||
|
|
|
@ -101,7 +101,7 @@ function createOptionsObserver({ smallestUnit = "months", largestUnit = "auto",
|
|||
}
|
||||
|
||||
// clear any observable things that happened while constructing the objects
|
||||
actual.splice(0, actual.length);
|
||||
actual.splice(0);
|
||||
|
||||
// code path through RoundDuration that rounds to the nearest year:
|
||||
const expectedOpsForYearRounding = expected.concat([
|
||||
|
@ -116,7 +116,7 @@ const expectedOpsForYearRounding = expected.concat([
|
|||
]);
|
||||
instance.until(otherYearMonthPropertyBag, createOptionsObserver({ smallestUnit: "years" }));
|
||||
assert.compareArray(actual, expectedOpsForYearRounding, "order of operations with smallestUnit = years");
|
||||
actual.splice(0, actual.length); // clear
|
||||
actual.splice(0); // clear
|
||||
|
||||
// code path through RoundDuration that rounds to the nearest month:
|
||||
const expectedOpsForMonthRounding = expected.concat([
|
||||
|
@ -127,4 +127,4 @@ const expectedOpsForMonthRounding = expected.concat([
|
|||
]); // (10.n.iii MoveRelativeDate not called because weeks == 0)
|
||||
instance.until(otherYearMonthPropertyBag, createOptionsObserver({ smallestUnit: "months", roundingIncrement: 2 }));
|
||||
assert.compareArray(actual, expectedOpsForMonthRounding, "order of operations with smallestUnit = months");
|
||||
actual.splice(0, actual.length); // clear
|
||||
actual.splice(0); // clear
|
||||
|
|
|
@ -111,12 +111,12 @@ function createOptionsObserver({ smallestUnit = "nanoseconds", largestUnit = "au
|
|||
}
|
||||
|
||||
// clear any observable things that happened while constructing the objects
|
||||
actual.splice(0, actual.length);
|
||||
actual.splice(0);
|
||||
|
||||
// basic order of observable operations, without rounding:
|
||||
instance.since(otherDateTimePropertyBag, createOptionsObserver());
|
||||
assert.compareArray(actual, expected, "order of operations");
|
||||
actual.splice(0, actual.length); // clear
|
||||
actual.splice(0); // clear
|
||||
|
||||
// Making largestUnit a calendar unit adds the following observable operations:
|
||||
const expectedOpsForCalendarDifference = [
|
||||
|
@ -216,7 +216,7 @@ const expectedOpsForYearRounding = expected.concat(expectedOpsForCalendarDiffere
|
|||
]);
|
||||
instance.since(otherDateTimePropertyBag, createOptionsObserver({ smallestUnit: "years" }));
|
||||
assert.compareArray(actual, expectedOpsForYearRounding, "order of operations with smallestUnit = years");
|
||||
actual.splice(0, actual.length); // clear
|
||||
actual.splice(0); // clear
|
||||
|
||||
// code path through RoundDuration that rounds to the nearest month:
|
||||
const expectedOpsForMonthRounding = expected.concat(expectedOpsForCalendarDifference, [
|
||||
|
@ -227,7 +227,7 @@ const expectedOpsForMonthRounding = expected.concat(expectedOpsForCalendarDiffer
|
|||
]); // (10.n.iii MoveRelativeDate not called because weeks == 0)
|
||||
instance.since(otherDateTimePropertyBag, createOptionsObserver({ smallestUnit: "months" }));
|
||||
assert.compareArray(actual, expectedOpsForMonthRounding, "order of operations with smallestUnit = months");
|
||||
actual.splice(0, actual.length); // clear
|
||||
actual.splice(0); // clear
|
||||
|
||||
// code path through RoundDuration that rounds to the nearest week:
|
||||
const expectedOpsForWeekRounding = expected.concat(expectedOpsForCalendarDifference, [
|
||||
|
@ -236,4 +236,3 @@ const expectedOpsForWeekRounding = expected.concat(expectedOpsForCalendarDiffere
|
|||
]); // (11.g.iii MoveRelativeDate not called because days already balanced)
|
||||
instance.since(otherDateTimePropertyBag, createOptionsObserver({ smallestUnit: "weeks" }));
|
||||
assert.compareArray(actual.slice(expected.length), expectedOpsForWeekRounding.slice(expected.length), "order of operations with smallestUnit = weeks");
|
||||
actual.slice(0, actual.length); // clear
|
||||
|
|
|
@ -111,12 +111,12 @@ function createOptionsObserver({ smallestUnit = "nanoseconds", largestUnit = "au
|
|||
}
|
||||
|
||||
// clear any observable things that happened while constructing the objects
|
||||
actual.splice(0, actual.length);
|
||||
actual.splice(0);
|
||||
|
||||
// basic order of observable operations, without rounding:
|
||||
instance.until(otherDateTimePropertyBag, createOptionsObserver());
|
||||
assert.compareArray(actual, expected, "order of operations");
|
||||
actual.splice(0, actual.length); // clear
|
||||
actual.splice(0); // clear
|
||||
|
||||
// Making largestUnit a calendar unit adds the following observable operations:
|
||||
const expectedOpsForCalendarDifference = [
|
||||
|
@ -216,7 +216,7 @@ const expectedOpsForYearRounding = expected.concat(expectedOpsForCalendarDiffere
|
|||
]);
|
||||
instance.until(otherDateTimePropertyBag, createOptionsObserver({ smallestUnit: "years" }));
|
||||
assert.compareArray(actual, expectedOpsForYearRounding, "order of operations with smallestUnit = years");
|
||||
actual.splice(0, actual.length); // clear
|
||||
actual.splice(0); // clear
|
||||
|
||||
// code path through RoundDuration that rounds to the nearest month:
|
||||
const expectedOpsForMonthRounding = expected.concat(expectedOpsForCalendarDifference, [
|
||||
|
@ -227,7 +227,7 @@ const expectedOpsForMonthRounding = expected.concat(expectedOpsForCalendarDiffer
|
|||
]); // (10.n.iii MoveRelativeDate not called because weeks == 0)
|
||||
instance.until(otherDateTimePropertyBag, createOptionsObserver({ smallestUnit: "months" }));
|
||||
assert.compareArray(actual, expectedOpsForMonthRounding, "order of operations with smallestUnit = months");
|
||||
actual.splice(0, actual.length); // clear
|
||||
actual.splice(0); // clear
|
||||
|
||||
// code path through RoundDuration that rounds to the nearest week:
|
||||
const expectedOpsForWeekRounding = expected.concat(expectedOpsForCalendarDifference, [
|
||||
|
@ -236,4 +236,3 @@ const expectedOpsForWeekRounding = expected.concat(expectedOpsForCalendarDiffere
|
|||
]); // (11.g.iii MoveRelativeDate not called because days already balanced)
|
||||
instance.until(otherDateTimePropertyBag, createOptionsObserver({ smallestUnit: "weeks" }));
|
||||
assert.compareArray(actual.slice(expected.length), expectedOpsForWeekRounding.slice(expected.length), "order of operations with smallestUnit = weeks");
|
||||
actual.slice(0, actual.length); // clear
|
||||
|
|
Loading…
Reference in New Issue