Fix limit test

The doAsserts is not correct for case like "P100000000000000000000000000Y"
If we test "P100000000000000000000000000Y" because the filed in Duration is only required to 
"A float64-representable integer is an integer that is exactly representable as a Number value. That is, for a float64-representable integer x, it must hold that ℝ(𝔽(x)) = x." per 
https://tc39.es/proposal-temporal/#sec-properties-of-temporal-duration-instances

The duration it hold may produce string such as
"P99999999999999987584860160Y" 

even the test only test the first 10 digits ( log(10^10)/log(2) = 33 bits)
Change the test to test 

"P100000000000001000000000000Y" instead, so a negative numerical error will not change the start of the string 
from "P1000000000" to "P9999999999"
This commit is contained in:
Frank Yung-Fong Tang 2022-09-15 16:32:30 -07:00 committed by Philip Chimento
parent 58a9cdc426
commit 9215420dee
1 changed files with 1 additions and 1 deletions

View File

@ -78,7 +78,7 @@ function test(ix, prefix, suffix, infix = "") {
doAsserts(new Temporal.Duration(...Array(ix).fill(0), 1e+26, ...Array(9 - ix).fill(0)));
doAsserts(Temporal.Duration.from({ [units[ix]]: 1e+26 }));
if (!infix)
doAsserts(Temporal.Duration.from(`${ prefix }100000000000000000000000000${ suffix }`));
doAsserts(Temporal.Duration.from(`${ prefix }100000000000001000000000000${ suffix }`));
}
test(0, "P", "Y");
test(1, "P", "M");