hare

[hare] The Hare programming language
git clone https://git.torresjrjr.com/hare.git
Log | Files | Refs | README | LICENSE

commit 62947fea9e429a580b0b81aff21aa4a078c483af
parent 485f452a544f53b4e452f3915f49b49200a27470
Author: Sebastian <sebastian@sebsite.pw>
Date:   Mon, 10 Oct 2022 17:28:50 -0400

hare::lex: disallow leading zeros in number literal

Signed-off-by: Sebastian <sebastian@sebsite.pw>

Diffstat:
Mdatetime/arithmetic.ha | 218++++++++++++++++++++++++++++++++++++++++----------------------------------------
Mdatetime/date.ha | 224++++++++++++++++++++++++++++++++++++++++----------------------------------------
Mdatetime/datetime.ha | 4++--
Mdatetime/format.ha | 8++++----
Mhare/lex/lex.ha | 4++++
Mtime/arithm.ha | 178++++++++++++++++++++++++++++++++++++++++----------------------------------------
6 files changed, 320 insertions(+), 316 deletions(-)

diff --git a/datetime/arithmetic.ha b/datetime/arithmetic.ha @@ -188,40 +188,40 @@ export fn truncate(dt: datetime, u: unit) datetime = { return switch (u) { case unit::ERA => yield new(dt.loc, 0, - 01, 01, 01, - 00, 00, 00, 0, + 1, 1, 1, + 0, 0, 0, 0, )!; case unit::YEAR => yield new(dt.loc, 0, - year(&dt), 01, 01, - 00, 00, 00, 0, + year(&dt), 1, 1, + 0, 0, 0, 0, )!; case unit::MONTH => yield new(dt.loc, 0, - year(&dt), month(&dt), 01, - 00, 00, 00, 0, + year(&dt), month(&dt), 1, + 0, 0, 0, 0, )!; case unit::WEEK => const date = dt.date - (weekday(&dt) - 1); const ymd = calc_ymd(date); yield new(dt.loc, 0, ymd.0, ymd.1, ymd.2, - 00, 00, 00, 0, + 0, 0, 0, 0, )!; case unit::DAY => yield new(dt.loc, 0, year(&dt), month(&dt), day(&dt), - 00, 00, 00, 0, + 0, 0, 0, 0, )!; case unit::HOUR => yield new(dt.loc, 0, year(&dt), month(&dt), day(&dt), - hour(&dt), 00, 00, 0, + hour(&dt), 0, 0, 0, )!; case unit::MINUTE => yield new(dt.loc, 0, year(&dt), month(&dt), day(&dt), - hour(&dt), min(&dt), 00, 0, + hour(&dt), min(&dt), 0, 0, )!; case unit::SECOND => yield new(dt.loc, 0, @@ -433,14 +433,14 @@ export fn sub(dt: datetime, flag: calculus, pp: period...) datetime = { }; @test fn eq() void = { - const dt = new(chrono::UTC, 0, 2022, 02, 04, 03, 14, 07, 0)!; + const dt = new(chrono::UTC, 0, 2022, 2, 4, 3, 14, 7, 0)!; const cases = [ - ((-768, 01, 01, 03, 14, 07, 0), false), - ((1, 1, 01, 14, 00, 00, 1234), false), - ((2022, 02, 04, 03, 14, 07, 0), true), - ((2022, 02, 04, 03, 14, 07, 1), false), - ((2038, 01, 19, 03, 14, 07, 0), false), - ((5555, 05, 05, 05, 55, 55, 5555), false), + ((-768, 1, 1, 3, 14, 7, 0), false), + (( 1, 1, 1, 14, 0, 0, 1234), false), + ((2022, 2, 4, 3, 14, 7, 0), true), + ((2022, 2, 4, 3, 14, 7, 1), false), + ((2038, 1, 19, 3, 14, 7, 0), false), + ((5555, 5, 5, 5, 55, 55, 5555), false), ]; for (let i = 0z; i < len(cases); i += 1) { const c = cases[i].0; @@ -453,15 +453,15 @@ export fn sub(dt: datetime, flag: calculus, pp: period...) datetime = { }; @test fn after() void = { - const dt = new(chrono::UTC, 0, 2022, 02, 04, 03, 14, 07, 0)!; + const dt = new(chrono::UTC, 0, 2022, 2, 4, 3, 14, 7, 0)!; const cases = [ - ((-768, 01, 01, 03, 14, 07, 0), false), - ((1, 1, 01, 14, 00, 00, 1234), false), - ((2020, 02, 04, 03, 14, 07, 1), false), - ((2022, 02, 04, 03, 14, 07, 0), false), - ((2022, 02, 04, 04, 01, 01, 0), true), - ((2038, 01, 19, 03, 14, 07, 0), true), - ((5555, 05, 05, 05, 55, 55, 5555), true), + ((-768, 1, 1, 3, 14, 7, 0), false), + (( 1, 1, 1, 14, 0, 0, 1234), false), + ((2020, 2, 4, 3, 14, 7, 1), false), + ((2022, 2, 4, 3, 14, 7, 0), false), + ((2022, 2, 4, 4, 1, 1, 0), true), + ((2038, 1, 19, 3, 14, 7, 0), true), + ((5555, 5, 5, 5, 55, 55, 5555), true), ]; for (let i = 0z; i < len(cases); i += 1) { const c = cases[i].0; @@ -474,15 +474,15 @@ export fn sub(dt: datetime, flag: calculus, pp: period...) datetime = { }; @test fn before() void = { - const dt = new(chrono::UTC, 0, 2022, 02, 04, 03, 14, 07, 0)!; + const dt = new(chrono::UTC, 0, 2022, 2, 4, 3, 14, 7, 0)!; const cases = [ - ((-768, 01, 01, 03, 14, 07, 0), true), - ((1, 1, 01, 14, 00, 00, 1234), true), - ((2020, 02, 04, 03, 14, 07, 1), true), - ((2022, 02, 04, 03, 14, 07, 0), false), - ((2022, 02, 04, 04, 01, 01, 0), false), - ((2038, 01, 19, 03, 14, 07, 0), false), - ((5555, 05, 05, 05, 55, 55, 5555), false), + ((-768, 1, 1, 3, 14, 7, 0), true), + (( 1, 1, 1, 14, 0, 0, 1234), true), + ((2020, 2, 4, 3, 14, 7, 1), true), + ((2022, 2, 4, 3, 14, 7, 0), false), + ((2022, 2, 4, 4, 1, 1, 0), false), + ((2038, 1, 19, 3, 14, 7, 0), false), + ((5555, 5, 5, 5, 55, 55, 5555), false), ]; for (let i = 0z; i < len(cases); i += 1) { const c = cases[i].0; @@ -497,8 +497,8 @@ export fn sub(dt: datetime, flag: calculus, pp: period...) datetime = { @test fn diff() void = { const cases = [ ( - new(chrono::UTC, 0, 2021, 01, 15, 00, 00, 00, 0)!, - new(chrono::UTC, 0, 2022, 02, 16, 00, 00, 00, 0)!, + new(chrono::UTC, 0, 2021, 1, 15, 0, 0, 0, 0)!, + new(chrono::UTC, 0, 2022, 2, 16, 0, 0, 0, 0)!, period { years = 1, months = 1, @@ -507,8 +507,8 @@ export fn sub(dt: datetime, flag: calculus, pp: period...) datetime = { }, ), ( - new(chrono::UTC, 0, 2021, 01, 15, 00, 00, 00, 0)!, - new(chrono::UTC, 0, 2022, 03, 27, 00, 00, 00, 0)!, + new(chrono::UTC, 0, 2021, 1, 15, 0, 0, 0, 0)!, + new(chrono::UTC, 0, 2022, 3, 27, 0, 0, 0, 0)!, period { years = 1, months = 2, @@ -517,8 +517,8 @@ export fn sub(dt: datetime, flag: calculus, pp: period...) datetime = { }, ), ( - new(chrono::UTC, 0, 2021, 01, 15, 00, 00, 00, 0)!, - new(chrono::UTC, 0, 2022, 03, 14, 00, 00, 00, 0)!, + new(chrono::UTC, 0, 2021, 1, 15, 0, 0, 0, 0)!, + new(chrono::UTC, 0, 2022, 3, 14, 0, 0, 0, 0)!, period { years = 1, months = 1, @@ -527,16 +527,16 @@ export fn sub(dt: datetime, flag: calculus, pp: period...) datetime = { }, ), ( - new(chrono::UTC, 0, 2021, 01, 15, 00, 00, 00, 0)!, - new(chrono::UTC, 0, 2021, 01, 16, 00, 00, 00, 0)!, + new(chrono::UTC, 0, 2021, 1, 15, 0, 0, 0, 0)!, + new(chrono::UTC, 0, 2021, 1, 16, 0, 0, 0, 0)!, period { days = 1, ... }, ), ( - new(chrono::UTC, 0, 2021, 01, 15, 00, 00, 00, 0)!, - new(chrono::UTC, 0, 2021, 01, 16, 01, 03, 02, 4)!, + new(chrono::UTC, 0, 2021, 1, 15, 0, 0, 0, 0)!, + new(chrono::UTC, 0, 2021, 1, 16, 1, 3, 2, 4)!, period { days = 1, hours = 1, @@ -547,8 +547,8 @@ export fn sub(dt: datetime, flag: calculus, pp: period...) datetime = { }, ), ( - new(chrono::UTC, 0, 2021, 01, 15, 02, 03, 02, 2)!, - new(chrono::UTC, 0, 2021, 01, 16, 01, 01, 02, 4)!, + new(chrono::UTC, 0, 2021, 1, 15, 2, 3, 2, 2)!, + new(chrono::UTC, 0, 2021, 1, 16, 1, 1, 2, 4)!, period { hours = 22, minutes = 58, @@ -557,8 +557,8 @@ export fn sub(dt: datetime, flag: calculus, pp: period...) datetime = { }, ), ( - new(chrono::UTC, 0, 0500, 01, 01, 00, 00, 00, 0)!, - new(chrono::UTC, 0, 3500, 01, 01, 00, 06, 00, 0)!, + new(chrono::UTC, 0, 500, 1, 1, 0, 0, 0, 0)!, + new(chrono::UTC, 0, 3500, 1, 1, 0, 6, 0, 0)!, period { years = 3000, minutes = 6, @@ -566,8 +566,8 @@ export fn sub(dt: datetime, flag: calculus, pp: period...) datetime = { }, ), ( - new(chrono::UTC, 0, -500, 01, 01, 00, 00, 00, 0)!, - new(chrono::UTC, 0, 2500, 01, 01, 00, 06, 00, 0)!, + new(chrono::UTC, 0, -500, 1, 1, 0, 0, 0, 0)!, + new(chrono::UTC, 0, 2500, 1, 1, 0, 6, 0, 0)!, period { years = 3000, minutes = 6, @@ -575,8 +575,8 @@ export fn sub(dt: datetime, flag: calculus, pp: period...) datetime = { }, ), ( - new(chrono::UTC, 0, 2000, 01, 01, 00, 00, 00, 0)!, - new(chrono::UTC, 0, 2000, 01, 01, 00, 06, 00, 999999999)!, + new(chrono::UTC, 0, 2000, 1, 1, 0, 0, 0, 0)!, + new(chrono::UTC, 0, 2000, 1, 1, 0, 6, 0, 999999999)!, period { minutes = 6, nanoseconds = 999999999, @@ -584,16 +584,16 @@ export fn sub(dt: datetime, flag: calculus, pp: period...) datetime = { }, ), ( - new(chrono::UTC, 0, 2000, 01, 01, 00, 06, 00, 999999999)!, - new(chrono::UTC, 0, 2000, 01, 01, 00, 06, 01, 0)!, + new(chrono::UTC, 0, 2000, 1, 1, 0, 6, 0, 999999999)!, + new(chrono::UTC, 0, 2000, 1, 1, 0, 6, 1, 0)!, period { nanoseconds = 1, ... }, ), ( - new(chrono::UTC, 0, -4000, 01, 01, 00, 06, 00, 999999999)!, - new(chrono::UTC, 0, 4000, 01, 01, 00, 06, 01, 0)!, + new(chrono::UTC, 0, -4000, 1, 1, 0, 6, 0, 999999999)!, + new(chrono::UTC, 0, 4000, 1, 1, 0, 6, 1, 0)!, period { years = 8000, nanoseconds = 1, @@ -613,25 +613,25 @@ export fn sub(dt: datetime, flag: calculus, pp: period...) datetime = { @test fn unitdiff() void = { const cases = [ ( - new(chrono::UTC, 0, 1994, 08, 27, 11, 20, 01, 2)!, - new(chrono::UTC, 0, 2022, 01, 05, 13, 53, 30, 20)!, + new(chrono::UTC, 0, 1994, 8, 27, 11, 20, 1, 2)!, + new(chrono::UTC, 0, 2022, 1, 5, 13, 53, 30, 20)!, (27, 328, 1427, 9993, 239834, 14390073, 863404409i64, (863404409i64 * time::SECOND) + 18), ), ( - new(chrono::UTC, 0, 1994, 08, 28, 11, 20, 01, 2)!, - new(chrono::UTC, 0, 1994, 08, 27, 11, 20, 01, 0)!, + new(chrono::UTC, 0, 1994, 8, 28, 11, 20, 1, 2)!, + new(chrono::UTC, 0, 1994, 8, 27, 11, 20, 1, 0)!, (0, 0, 0, 1, 24, 1440, 86400i64, (86400i64 * time::SECOND) + 2), ), ( - new(chrono::UTC, 0, 1994, 08, 27, 11, 20, 01, 0)!, - new(chrono::UTC, 0, 1994, 08, 27, 11, 20, 01, 0)!, + new(chrono::UTC, 0, 1994, 8, 27, 11, 20, 1, 0)!, + new(chrono::UTC, 0, 1994, 8, 27, 11, 20, 1, 0)!, (0, 0, 0, 0, 0, 0, 0i64, 0i64), ), ( - new(chrono::UTC, 0, -500, 01, 01, 00, 59, 01, 0)!, - new(chrono::UTC, 0, 2000, 01, 01, 23, 01, 01, 0)!, + new(chrono::UTC, 0, -500, 1, 1, 0, 59, 1, 0)!, + new(chrono::UTC, 0, 2000, 1, 1, 23, 1, 1, 0)!, (2500, 30000, 130443, 913106, 913106 * 24 + 22, (913106 * 24 + 22) * 60 + 2, ((913106 * 24 + 22) * 60 + 2) * 60i64, @@ -663,149 +663,149 @@ export fn sub(dt: datetime, flag: calculus, pp: period...) datetime = { }; @test fn truncate() void = { - const dt = new(chrono::UTC, 0, 1994, 08, 27, 11, 20, 01, 2)!; + const dt = new(chrono::UTC, 0, 1994, 8, 27, 11, 20, 1, 2)!; assert(eq(truncate(dt, unit::ERA), - new(chrono::UTC, 0, 01, 01, 01, 00, 00, 00, 0)!), + new(chrono::UTC, 0, 1, 1, 1, 0, 0, 0, 0)!), "invalid truncate() result"); assert(eq(truncate(dt, unit::YEAR), - new(chrono::UTC, 0, 1994, 01, 01, 00, 00, 00, 0)!), + new(chrono::UTC, 0, 1994, 1, 1, 0, 0, 0, 0)!), "invalid truncate() result"); assert(eq(truncate(dt, unit::MONTH), - new(chrono::UTC, 0, 1994, 08, 01, 00, 00, 00, 0)!), + new(chrono::UTC, 0, 1994, 8, 1, 0, 0, 0, 0)!), "invalid truncate() result"); assert(eq(truncate(dt, unit::WEEK), - new(chrono::UTC, 0, 1994, 08, 22, 00, 00, 00, 0)!), + new(chrono::UTC, 0, 1994, 8, 22, 0, 0, 0, 0)!), "invalid truncate() result"); assert(eq(truncate(dt, unit::DAY), - new(chrono::UTC, 0, 1994, 08, 27, 00, 00, 00, 0)!), + new(chrono::UTC, 0, 1994, 8, 27, 0, 0, 0, 0)!), "invalid truncate() result"); assert(eq(truncate(dt, unit::HOUR), - new(chrono::UTC, 0, 1994, 08, 27, 11, 00, 00, 0)!), + new(chrono::UTC, 0, 1994, 8, 27, 11, 0, 0, 0)!), "invalid truncate() result"); assert(eq(truncate(dt, unit::MINUTE), - new(chrono::UTC, 0, 1994, 08, 27, 11, 20, 00, 0)!), + new(chrono::UTC, 0, 1994, 8, 27, 11, 20, 0, 0)!), "invalid truncate() result"); assert(eq(truncate(dt, unit::SECOND), - new(chrono::UTC, 0, 1994, 08, 27, 11, 20, 01, 0)!), + new(chrono::UTC, 0, 1994, 8, 27, 11, 20, 1, 0)!), "invalid truncate() result"); assert(eq(truncate(dt, unit::NANOSECOND), dt), "invalid truncate() result"); }; @test fn add() void = { - const d = new(chrono::UTC, 0, 2022, 02, 04, 03, 14, 07, 0)!; + const d = new(chrono::UTC, 0, 2022, 2, 4, 3, 14, 7, 0)!; const cases = [ ( period { years = 1, ... }, - new(chrono::UTC, 0, 2023, 02, 04, 03, 14, 07, 0)!, + new(chrono::UTC, 0, 2023, 2, 4, 3, 14, 7, 0)!, ), ( period { years = -23, ... }, - new(chrono::UTC, 0, 1999, 02, 04, 03, 14, 07, 0)!, + new(chrono::UTC, 0, 1999, 2, 4, 3, 14, 7, 0)!, ), ( period { months = 2, ... }, - new(chrono::UTC, 0, 2022, 04, 04, 03, 14, 07, 0)!, + new(chrono::UTC, 0, 2022, 4, 4, 3, 14, 7, 0)!, ), ( period { months = 11, ... }, - new(chrono::UTC, 0, 2023, 01, 04, 03, 14, 07, 0)!, + new(chrono::UTC, 0, 2023, 1, 4, 3, 14, 7, 0)!, ), ( period { months = -1, ... }, - new(chrono::UTC, 0, 2022, 01, 04, 03, 14, 07, 0)!, + new(chrono::UTC, 0, 2022, 1, 4, 3, 14, 7, 0)!, ), ( period { months = -2, ... }, - new(chrono::UTC, 0, 2021, 12, 04, 03, 14, 07, 0)!, + new(chrono::UTC, 0, 2021, 12, 4, 3, 14, 7, 0)!, ), ( period { days = 3, ... }, - new(chrono::UTC, 0, 2022, 02, 07, 03, 14, 07, 0)!, + new(chrono::UTC, 0, 2022, 2, 7, 3, 14, 7, 0)!, ), ( period { days = 33, ... }, - new(chrono::UTC, 0, 2022, 03, 09, 03, 14, 07, 0)!, + new(chrono::UTC, 0, 2022, 3, 9, 3, 14, 7, 0)!, ), ( period { days = 333, ... }, - new(chrono::UTC, 0, 2023, 01, 03, 03, 14, 07, 0)!, + new(chrono::UTC, 0, 2023, 1, 3, 3, 14, 7, 0)!, ), ( period { days = -2, ... }, - new(chrono::UTC, 0, 2022, 02, 02, 03, 14, 07, 0)!, + new(chrono::UTC, 0, 2022, 2, 2, 3, 14, 7, 0)!, ), ( period { days = -4, ... }, - new(chrono::UTC, 0, 2022, 01, 31, 03, 14, 07, 0)!, + new(chrono::UTC, 0, 2022, 1, 31, 3, 14, 7, 0)!, ), ( period { days = -1337, ... }, - new(chrono::UTC, 0, 2018, 06, 08, 03, 14, 07, 0)!, + new(chrono::UTC, 0, 2018, 6, 8, 3, 14, 7, 0)!, ), ( period { hours = 1, ... }, - new(chrono::UTC, 0, 2022, 02, 04, 04, 14, 07, 0)!, + new(chrono::UTC, 0, 2022, 2, 4, 4, 14, 7, 0)!, ), ( period { hours = 24, ... }, - new(chrono::UTC, 0, 2022, 02, 05, 03, 14, 07, 0)!, + new(chrono::UTC, 0, 2022, 2, 5, 3, 14, 7, 0)!, ), ( period { hours = 25, ... }, - new(chrono::UTC, 0, 2022, 02, 05, 04, 14, 07, 0)!, + new(chrono::UTC, 0, 2022, 2, 5, 4, 14, 7, 0)!, ), ( period { hours = 123456, ... }, - new(chrono::UTC, 0, 2036, 03, 06, 03, 14, 07, 0)!, + new(chrono::UTC, 0, 2036, 3, 6, 3, 14, 7, 0)!, ), ( period { hours = -2, ... }, - new(chrono::UTC, 0, 2022, 02, 04, 01, 14, 07, 0)!, + new(chrono::UTC, 0, 2022, 2, 4, 1, 14, 7, 0)!, ), ( period { hours = -24, ... }, - new(chrono::UTC, 0, 2022, 02, 03, 03, 14, 07, 0)!, + new(chrono::UTC, 0, 2022, 2, 3, 3, 14, 7, 0)!, ), ( period { hours = -123456, ... }, - new(chrono::UTC, 0, 2008, 01, 05, 03, 14, 07, 0)!, + new(chrono::UTC, 0, 2008, 1, 5, 3, 14, 7, 0)!, ), ( period { seconds = 2, ... }, - new(chrono::UTC, 0, 2022, 02, 04, 03, 14, 09, 0)!, + new(chrono::UTC, 0, 2022, 2, 4, 3, 14, 9, 0)!, ), ( period { seconds = 666666666, ... }, - new(chrono::UTC, 0, 2043, 03, 22, 04, 25, 13, 0)!, + new(chrono::UTC, 0, 2043, 3, 22, 4, 25, 13, 0)!, ), ( period { seconds = -2, ... }, - new(chrono::UTC, 0, 2022, 02, 04, 03, 14, 05, 0)!, + new(chrono::UTC, 0, 2022, 2, 4, 3, 14, 5, 0)!, ), ( period { seconds = -666666666, ... }, - new(chrono::UTC, 0, 2000, 12, 20, 02, 03, 01, 0)!, + new(chrono::UTC, 0, 2000, 12, 20, 2, 3, 1, 0)!, ), ( period { nanoseconds = 123, ... }, - new(chrono::UTC, 0, 2022, 02, 04, 03, 14, 07, 123)!, + new(chrono::UTC, 0, 2022, 2, 4, 3, 14, 7, 123)!, ), ( period { nanoseconds = 1361661361461, ... }, - new(chrono::UTC, 0, 2022, 02, 04, 03, 36, 48, 661361461)!, + new(chrono::UTC, 0, 2022, 2, 4, 3, 36, 48, 661361461)!, ), ( period { nanoseconds = -1361661361461, ... }, - new(chrono::UTC, 0, 2022, 02, 04, 02, 51, 25, 338638539)!, + new(chrono::UTC, 0, 2022, 2, 4, 2, 51, 25, 338638539)!, ), ( period { months = 1, seconds = -666666666, ... }, - new(chrono::UTC, 0, 2001, 01, 17, 02, 03, 01, 0)!, + new(chrono::UTC, 0, 2001, 1, 17, 2, 3, 1, 0)!, ), ( period { months = 1, seconds = -666666666, ... }, - new(chrono::UTC, 0, 2001, 01, 17, 02, 03, 01, 0)!, + new(chrono::UTC, 0, 2001, 1, 17, 2, 3, 1, 0)!, ), ( period { @@ -819,7 +819,7 @@ export fn sub(dt: datetime, flag: calculus, pp: period...) datetime = { nanoseconds = -8, ... }, - new(chrono::UTC, 0, 2020, 11, 08, 22, 07, 59, 999999992)!, + new(chrono::UTC, 0, 2020, 11, 8, 22, 7, 59, 999999992)!, ), ( period { @@ -833,7 +833,7 @@ export fn sub(dt: datetime, flag: calculus, pp: period...) datetime = { nanoseconds = 8, ... }, - new(chrono::UTC, 0, 2023, 04, 29, 08, 20, 14, 8)!, + new(chrono::UTC, 0, 2023, 4, 29, 8, 20, 14, 8)!, ), ( period { @@ -847,7 +847,7 @@ export fn sub(dt: datetime, flag: calculus, pp: period...) datetime = { nanoseconds = -34, ... }, - new(chrono::UTC, 0, 2022, 12, 20, 11, 01, 27, 999999966)!, + new(chrono::UTC, 0, 2022, 12, 20, 11, 1, 27, 999999966)!, ), ( period { @@ -861,7 +861,7 @@ export fn sub(dt: datetime, flag: calculus, pp: period...) datetime = { nanoseconds = -86400000000000, ... }, - new(chrono::UTC, 0, 2021, 01, 02, 16, 14, 07, 0)!, + new(chrono::UTC, 0, 2021, 1, 2, 16, 14, 7, 0)!, ), ]; for (let i = 0z; i < len(cases); i += 1) { @@ -873,19 +873,19 @@ export fn sub(dt: datetime, flag: calculus, pp: period...) datetime = { }; @test fn sub() void = { - const d = new(chrono::UTC, 0, 2022, 02, 04, 03, 14, 07, 0)!; + const d = new(chrono::UTC, 0, 2022, 2, 4, 3, 14, 7, 0)!; const cases = [ ( period { years = 1, ... }, - new(chrono::UTC, 0, 2021, 02, 04, 03, 14, 07, 0)!, + new(chrono::UTC, 0, 2021, 2, 4, 3, 14, 7, 0)!, ), ( period { months = 2, ... }, - new(chrono::UTC, 0, 2021, 12, 04, 03, 14, 07, 0)!, + new(chrono::UTC, 0, 2021, 12, 4, 3, 14, 7, 0)!, ), ( period { months = 14, ... }, - new(chrono::UTC, 0, 2020, 12, 04, 03, 14, 07, 0)!, + new(chrono::UTC, 0, 2020, 12, 4, 3, 14, 7, 0)!, ), ]; for (let i = 0z; i < len(cases); i += 1) { diff --git a/datetime/date.ha b/datetime/date.ha @@ -255,34 +255,34 @@ fn calc_date_from_yd(y: int, yd: int) (chrono::date | invalid) = { @test fn calc_date_from_ymd() void = { const cases = [ - ((-0768, 02, 05), -999999, false), - ((-0001, 12, 31), -719529, false), - (( 0000, 01, 01), -719528, false), - (( 0000, 01, 02), -719527, false), - (( 0000, 12, 31), -719163, false), - (( 0001, 01, 01), -719162, false), - (( 0001, 01, 02), -719161, false), - (( 1965, 03, 23), -1745, false), + (( -768, 2, 5), -999999, false), + (( -1, 12, 31), -719529, false), + (( 0, 1, 1), -719528, false), + (( 0, 1, 2), -719527, false), + (( 0, 12, 31), -719163, false), + (( 1, 1, 1), -719162, false), + (( 1, 1, 2), -719161, false), + (( 1965, 3, 23), -1745, false), (( 1969, 12, 31), -1, false), - (( 1970, 01, 01), 0, false), - (( 1970, 01, 02), 1, false), + (( 1970, 1, 1), 0, false), + (( 1970, 1, 2), 1, false), (( 1999, 12, 31), 10956, false), - (( 2000, 01, 01), 10957, false), - (( 2000, 01, 02), 10958, false), - (( 2038, 01, 18), 24854, false), - (( 2038, 01, 19), 24855, false), - (( 2038, 01, 20), 24856, false), + (( 2000, 1, 1), 10957, false), + (( 2000, 1, 2), 10958, false), + (( 2038, 1, 18), 24854, false), + (( 2038, 1, 19), 24855, false), + (( 2038, 1, 20), 24856, false), (( 2243, 10, 17), 100000, false), (( 4707, 11, 28), 999999, false), (( 4707, 11, 29), 1000000, false), - ((29349, 01, 25), 9999999, false), + ((29349, 1, 25), 9999999, false), (( 1970,-99,-99), 0, true), (( 1970, -9, -9), 0, true), (( 1970, -1, -1), 0, true), - (( 1970, 00, 00), 0, true), - (( 1970, 00, 01), 0, true), - (( 1970, 01, 99), 0, true), + (( 1970, 0, 0), 0, true), + (( 1970, 0, 1), 0, true), + (( 1970, 1, 99), 0, true), (( 1970, 99, 99), 0, true), ]; for (let i = 0z; i < len(cases); i += 1) { @@ -304,37 +304,37 @@ fn calc_date_from_yd(y: int, yd: int) (chrono::date | invalid) = { @test fn calc_date_from_ywd() void = { const cases = [ - ((-0768, 00, 4), -1000034), - ((-0768, 05, 4), -999999), - ((-0001, 52, 5), -719529), - (( 0000, 00, 6), -719528), - (( 0000, 00, 7), -719527), - (( 0000, 52, 7), -719163), - (( 0001, 00, 1), -719162), - (( 0001, 00, 2), -719161), + (( -768, 0, 4), -1000034), + (( -768, 5, 4), -999999), + (( -1, 52, 5), -719529), + (( 0, 0, 6), -719528), + (( 0, 0, 7), -719527), + (( 0, 52, 7), -719163), + (( 1, 0, 1), -719162), + (( 1, 0, 2), -719161), (( 1965, 12, 2), -1745), (( 1969, 52, 3), -1), - (( 1970, 00, 4), 0), - (( 1970, 00, 5), 1), + (( 1970, 0, 4), 0), + (( 1970, 0, 5), 1), (( 1999, 52, 5), 10956), - (( 2000, 00, 6), 10957), - (( 2000, 00, 7), 10958), - (( 2020, 00, 3), 18262), - (( 2022, 09, 1), 19051), - (( 2022, 09, 2), 19052), + (( 2000, 0, 6), 10957), + (( 2000, 0, 7), 10958), + (( 2020, 0, 3), 18262), + (( 2022, 9, 1), 19051), + (( 2022, 9, 2), 19052), (( 2023, 51, 7), 19715), - (( 2024, 08, 3), 19781), - (( 2024, 08, 4), 19782), - (( 2024, 08, 5), 19783), + (( 2024, 8, 3), 19781), + (( 2024, 8, 4), 19782), + (( 2024, 8, 5), 19783), (( 2024, 49, 4), 20069), (( 2024, 52, 2), 20088), - (( 2038, 03, 1), 24854), - (( 2038, 03, 2), 24855), - (( 2038, 03, 3), 24856), + (( 2038, 3, 1), 24854), + (( 2038, 3, 2), 24855), + (( 2038, 3, 3), 24856), (( 2243, 41, 2), 99993), (( 4707, 47, 4), 999999), (( 4707, 47, 5), 1000000), - ((29349, 03, 6), 9999999), + ((29349, 3, 6), 9999999), ]; for (let i = 0z; i < len(cases); i += 1) { @@ -348,13 +348,13 @@ fn calc_date_from_yd(y: int, yd: int) (chrono::date | invalid) = { @test fn calc_date_from_yd() void = { const cases = [ - (-0768, 36, -999999), - (-0001, 365, -719529), - ( 0000, 1, -719528), - ( 0000, 2, -719527), - ( 0000, 366, -719163), - ( 0001, 1, -719162), - ( 0001, 2, -719161), + ( -768, 36, -999999), + ( -1, 365, -719529), + ( 0, 1, -719528), + ( 0, 2, -719527), + ( 0, 366, -719163), + ( 1, 1, -719162), + ( 1, 2, -719161), ( 1965, 82, -1745 ), ( 1969, 365, -1 ), ( 1970, 1, 0 ), @@ -387,27 +387,27 @@ fn calc_date_from_yd(y: int, yd: int) (chrono::date | invalid) = { @test fn calc_ymd() void = { const cases = [ - (-999999, (-0768, 02, 05)), - (-719529, (-0001, 12, 31)), - (-719528, ( 0000, 01, 01)), - (-719527, ( 0000, 01, 02)), - (-719163, ( 0000, 12, 31)), - (-719162, ( 0001, 01, 01)), - (-719161, ( 0001, 01, 02)), - ( -1745, ( 1965, 03, 23)), - ( -1, ( 1969, 12, 31)), - ( 0, ( 1970, 01, 01)), - ( 1, ( 1970, 01, 02)), - ( 10956, ( 1999, 12, 31)), - ( 10957, ( 2000, 01, 01)), - ( 10958, ( 2000, 01, 02)), - ( 24854, ( 2038, 01, 18)), - ( 24855, ( 2038, 01, 19)), - ( 24856, ( 2038, 01, 20)), - ( 100000, ( 2243, 10, 17)), - ( 999999, ( 4707, 11, 28)), - (1000000, ( 4707, 11, 29)), - (9999999, (29349, 01, 25)), + (-999999, ( -768, 2, 5)), + (-719529, ( -1, 12, 31)), + (-719528, ( 0, 1, 1)), + (-719527, ( 0, 1, 2)), + (-719163, ( 0, 12, 31)), + (-719162, ( 1, 1, 1)), + (-719161, ( 1, 1, 2)), + ( -1745, ( 1965, 3, 23)), + ( -1, ( 1969, 12, 31)), + ( 0, ( 1970, 1, 1)), + ( 1, ( 1970, 1, 2)), + ( 10956, ( 1999, 12, 31)), + ( 10957, ( 2000, 1, 1)), + ( 10958, ( 2000, 1, 2)), + ( 24854, ( 2038, 1, 18)), + ( 24855, ( 2038, 1, 19)), + ( 24856, ( 2038, 1, 20)), + ( 100000, ( 2243, 10, 17)), + ( 999999, ( 4707, 11, 28)), + (1000000, ( 4707, 11, 29)), + (9999999, (29349, 1, 25)), ]; for (let i = 0z; i < len(cases); i += 1) { const paramt = cases[i].0; @@ -421,28 +421,28 @@ fn calc_date_from_yd(y: int, yd: int) (chrono::date | invalid) = { @test fn calc_yearday() void = { const cases = [ - ((-0768, 02, 05), 036), - ((-0001, 12, 31), 365), - (( 0000, 01, 01), 001), - (( 0000, 01, 02), 002), - (( 0000, 12, 31), 366), - (( 0001, 01, 01), 001), - (( 0001, 01, 02), 002), - (( 1965, 03, 23), 082), - (( 1969, 12, 31), 365), - (( 1970, 01, 01), 001), - (( 1970, 01, 02), 002), - (( 1999, 12, 31), 365), - (( 2000, 01, 01), 001), - (( 2000, 01, 02), 002), - (( 2020, 02, 12), 043), - (( 2038, 01, 18), 018), - (( 2038, 01, 19), 019), - (( 2038, 01, 20), 020), - (( 2243, 10, 17), 290), - (( 4707, 11, 28), 332), - (( 4707, 11, 29), 333), - ((29349, 01, 25), 025), + (( -768, 2, 5), 36), + (( -1, 12, 31), 365), + (( 0, 1, 1), 1), + (( 0, 1, 2), 2), + (( 0, 12, 31), 366), + (( 1, 1, 1), 1), + (( 1, 1, 2), 2), + (( 1965, 3, 23), 82), + (( 1969, 12, 31), 365), + (( 1970, 1, 1), 1), + (( 1970, 1, 2), 2), + (( 1999, 12, 31), 365), + (( 2000, 1, 1), 1), + (( 2000, 1, 2), 2), + (( 2020, 2, 12), 43), + (( 2038, 1, 18), 18), + (( 2038, 1, 19), 19), + (( 2038, 1, 20), 20), + (( 2243, 10, 17), 290), + (( 4707, 11, 28), 332), + (( 4707, 11, 29), 333), + ((29349, 1, 25), 25), ]; for (let i = 0z; i < len(cases); i += 1) { const params = cases[i].0; @@ -508,27 +508,27 @@ fn calc_date_from_yd(y: int, yd: int) (chrono::date | invalid) = { @test fn calc_weekday() void = { const cases = [ - (-999999, 4), // -0768-02-05 - (-719529, 5), // -0001-12-31 - (-719528, 6), // 0000-01-01 - (-719527, 7), // 0000-01-02 - (-719163, 7), // 0000-12-31 - (-719162, 1), // 0001-01-01 - (-719161, 2), // 0001-01-02 - ( -1745, 2), // 1965-03-23 - ( -1, 3), // 1969-12-31 - ( 0, 4), // 1970-01-01 - ( 1, 5), // 1970-01-02 - ( 10956, 5), // 1999-12-31 - ( 10957, 6), // 2000-01-01 - ( 10958, 7), // 2000-01-02 - ( 24854, 1), // 2038-01-18 - ( 24855, 2), // 2038-01-19 - ( 24856, 3), // 2038-01-20 - ( 100000, 2), // 2243-10-17 - ( 999999, 4), // 4707-11-28 - (1000000, 5), // 4707-11-29 - (9999999, 6), // 29349-01-25 + (-999999, 4), // -0768-02-05 + (-719529, 5), // -0001-12-31 + (-719528, 6), // 0000-01-01 + (-719527, 7), // 0000-01-02 + (-719163, 7), // 0000-12-31 + (-719162, 1), // 0001-01-01 + (-719161, 2), // 0001-01-02 + ( -1745, 2), // 1965-03-23 + ( -1, 3), // 1969-12-31 + ( 0, 4), // 1970-01-01 + ( 1, 5), // 1970-01-02 + ( 10956, 5), // 1999-12-31 + ( 10957, 6), // 2000-01-01 + ( 10958, 7), // 2000-01-02 + ( 24854, 1), // 2038-01-18 + ( 24855, 2), // 2038-01-19 + ( 24856, 3), // 2038-01-20 + ( 100000, 2), // 2243-10-17 + ( 999999, 4), // 4707-11-28 + (1000000, 5), // 4707-11-29 + (9999999, 6), // 29349-01-25 ]; for (let i = 0z; i < len(cases); i += 1) { const paramt = cases[i].0; diff --git a/datetime/datetime.ha b/datetime/datetime.ha @@ -57,11 +57,11 @@ fn init() datetime = datetime { // datetime::new(time::chrono::UTC, 0); // // // 2038 Jan 19th 03:14:07.000000618 +0000 UTC -// datetime::new(time::chrono::UTC, 0, 2038, 01, 19, 03, 14, 07, 618); +// datetime::new(time::chrono::UTC, 0, 2038, 1, 19, 3, 14, 7, 618); // // // 2038 Jan 19th 02:00:00.000000000 +0100 Europe/Amsterdam // datetime::new(&time::chrono::tz("Europe/Amsterdam"), 1 * time::HOUR, -// 2038, 01, 19, 02); +// 2038, 1, 19, 2); // // 'offs' is the zone offset from the normal timezone (in most cases, UTC). For // example, the "Asia/Tokyo" timezone has a single zoffset of +9 hours, but the diff --git a/datetime/format.ha b/datetime/format.ha @@ -318,7 +318,7 @@ fn hour12(dt: *datetime) int = { }; @test fn format() void = { - const dt = new(chrono::UTC, 0, 1994, 01, 01, 02, 17, 05, 24)!; + const dt = new(chrono::UTC, 0, 1994, 1, 1, 2, 17, 5, 24)!; const cases = [ // special characters @@ -385,11 +385,11 @@ fn hour12(dt: *datetime) int = { // // General tests // parse("%Y-%m-%d %H:%M:%S.%N", "1994-08-27 11:01:02.123", &dt)!; // assert(dt.year as int == 1994 && -// dt.month as int == 08 && +// dt.month as int == 8 && // dt.day as int == 27 && // dt.hour as int == 11 && -// dt.min as int == 01 && -// dt.sec as int == 02 && +// dt.min as int == 1 && +// dt.sec as int == 2 && // dt.nsec as int == 123, "invalid parsing results"); // // General errors diff --git a/hare/lex/lex.ha b/hare/lex/lex.ha @@ -417,6 +417,10 @@ fn lex_literal(lex: *lexer) (token | error) = { case 'x' => base = 16; case => + if (ascii::isdigit(r.0)) { + return syntaxerr(loc, + "Leading zeros in number literals aren't permitted (for octal, use the 0o prefix instead)"); + }; started = true; unget(lex, r); }; diff --git a/time/arithm.ha b/time/arithm.ha @@ -80,69 +80,69 @@ export fn mult(a: instant, f: f64) instant = { @test fn add() void = { const cases = [ // instant a duration d instant b - ( 0, 000000000, -2000000001, -3, 999999999), - ( 0, 000000000, -2000000000, -2, 000000000), - ( 0, 000000000, -1999999999, -2, 000000001), - ( 0, 000000000, -1000000001, -2, 999999999), - ( 0, 000000000, -1000000000, -1, 000000000), - ( 0, 000000000, -0999999999, -1, 000000001), - ( 0, 000000000, -0000000001, -1, 999999999), - ( 0, 000000000, 0000000000, 0, 000000000), - ( 0, 000000000, 0000000001, 0, 000000001), - ( 0, 000000000, 0999999999, 0, 999999999), - ( 0, 000000000, 1000000000, 1, 000000000), - ( 0, 000000000, 1000000001, 1, 000000001), - ( 0, 000000000, 1999999999, 1, 999999999), - ( 0, 000000000, 2000000000, 2, 000000000), - ( 0, 000000000, 2000000001, 2, 000000001), - - ( 0, 000000001, -2000000001, -2, 000000000), - ( 0, 000000001, -2000000000, -2, 000000001), - ( 0, 000000001, -1999999999, -2, 000000002), - ( 0, 000000001, -1000000001, -1, 000000000), - ( 0, 000000001, -1000000000, -1, 000000001), - ( 0, 000000001, -0999999999, -1, 000000002), - ( 0, 000000001, -0000000001, 0, 000000000), - ( 0, 000000001, 0000000000, 0, 000000001), - ( 0, 000000001, 0000000001, 0, 000000002), - ( 0, 000000001, 0999999999, 1, 000000000), - ( 0, 000000001, 1000000000, 1, 000000001), - ( 0, 000000001, 1000000001, 1, 000000002), - ( 0, 000000001, 1999999999, 2, 000000000), - ( 0, 000000001, 2000000000, 2, 000000001), - ( 0, 000000001, 2000000001, 2, 000000002), + ( 0, 0, -2000000001, -3, 999999999), + ( 0, 0, -2000000000, -2, 0), + ( 0, 0, -1999999999, -2, 1), + ( 0, 0, -1000000001, -2, 999999999), + ( 0, 0, -1000000000, -1, 0), + ( 0, 0, -999999999, -1, 1), + ( 0, 0, -1, -1, 999999999), + ( 0, 0, 0, 0, 0), + ( 0, 0, 1, 0, 1), + ( 0, 0, 999999999, 0, 999999999), + ( 0, 0, 1000000000, 1, 0), + ( 0, 0, 1000000001, 1, 1), + ( 0, 0, 1999999999, 1, 999999999), + ( 0, 0, 2000000000, 2, 0), + ( 0, 0, 2000000001, 2, 1), + + ( 0, 1, -2000000001, -2, 0), + ( 0, 1, -2000000000, -2, 1), + ( 0, 1, -1999999999, -2, 2), + ( 0, 1, -1000000001, -1, 0), + ( 0, 1, -1000000000, -1, 1), + ( 0, 1, -999999999, -1, 2), + ( 0, 1, -1, 0, 0), + ( 0, 1, 0, 0, 1), + ( 0, 1, 1, 0, 2), + ( 0, 1, 999999999, 1, 0), + ( 0, 1, 1000000000, 1, 1), + ( 0, 1, 1000000001, 1, 2), + ( 0, 1, 1999999999, 2, 0), + ( 0, 1, 2000000000, 2, 1), + ( 0, 1, 2000000001, 2, 2), (-1, 999999999, -2000000001, -3, 999999998), (-1, 999999999, -2000000000, -3, 999999999), - (-1, 999999999, -1999999999, -2, 000000000), + (-1, 999999999, -1999999999, -2, 0), (-1, 999999999, -1000000001, -2, 999999998), (-1, 999999999, -1000000000, -2, 999999999), - (-1, 999999999, -0999999999, -1, 000000000), - (-1, 999999999, -0000000001, -1, 999999998), - (-1, 999999999, 0000000000, -1, 999999999), - (-1, 999999999, 0000000001, 0, 000000000), - (-1, 999999999, 0999999999, 0, 999999998), + (-1, 999999999, - 999999999, -1, 0), + (-1, 999999999, -1, -1, 999999998), + (-1, 999999999, 0, -1, 999999999), + (-1, 999999999, 1, 0, 0), + (-1, 999999999, 999999999, 0, 999999998), (-1, 999999999, 1000000000, 0, 999999999), - (-1, 999999999, 1000000001, 1, 000000000), + (-1, 999999999, 1000000001, 1, 0), (-1, 999999999, 1999999999, 1, 999999998), (-1, 999999999, 2000000000, 1, 999999999), - (-1, 999999999, 2000000001, 2, 000000000), + (-1, 999999999, 2000000001, 2, 0), ( 0, 999999999, -2000000001, -2, 999999998), ( 0, 999999999, -2000000000, -2, 999999999), - ( 0, 999999999, -1999999999, -1, 000000000), + ( 0, 999999999, -1999999999, -1, 0), ( 0, 999999999, -1000000001, -1, 999999998), ( 0, 999999999, -1000000000, -1, 999999999), - ( 0, 999999999, -0999999999, 0, 000000000), - ( 0, 999999999, -0000000001, 0, 999999998), - ( 0, 999999999, 0000000000, 0, 999999999), - ( 0, 999999999, 0000000001, 1, 000000000), - ( 0, 999999999, 0999999999, 1, 999999998), + ( 0, 999999999, -999999999, 0, 0), + ( 0, 999999999, -1, 0, 999999998), + ( 0, 999999999, 0, 0, 999999999), + ( 0, 999999999, 1, 1, 0), + ( 0, 999999999, 999999999, 1, 999999998), ( 0, 999999999, 1000000000, 1, 999999999), - ( 0, 999999999, 1000000001, 2, 000000000), + ( 0, 999999999, 1000000001, 2, 0), ( 0, 999999999, 1999999999, 2, 999999998), ( 0, 999999999, 2000000000, 2, 999999999), - ( 0, 999999999, 2000000001, 3, 000000000), + ( 0, 999999999, 2000000001, 3, 0), ]; for (let i = 0z; i < len(cases); i += 1) { @@ -168,48 +168,48 @@ export fn mult(a: instant, f: f64) instant = { @test fn mult() void = { const cases = [ // instant a factor f instant b interpretations - ( 0, 000000000, 000.000, 0, 000000000), // 0.000000000 - ( 9, 000000000, 000.000, 0, 000000000), // 0.000000000 - ( 0, 999999999, 000.000, 0, 000000000), // 0.000000000 - ( 9, 999999999, 000.000, 0, 000000000), // 0.000000000 - - ( 1, 000000000, 001.000, 1, 000000000), // 1.000000000 - ( 9, 000000000, 001.000, 9, 000000000), // 9.000000000 - ( 1, 999999999, 001.000, 1, 999999999), // 1.999999999 - ( 9, 999999999, 001.000, 9, 999999999), // 9.999999999 - - ( 1, 000000000, 000.001, 0, 001000000), // 0.001000000 - ( 1, 000000000, 000.010, 0, 010000000), // 0.010000000 - ( 1, 000000000, 000.100, 0, 100000000), // 0.100000000 - - (-1, 000000000, 000.001, -1, 999000000), // -0.001000000 - (-1, 000000000, 000.010, -1, 990000000), // -0.010000000 - (-1, 000000000, 000.100, -1, 900000000), // -0.100000000 - (-1, 000000000, 001.000, -1, 000000000), // -1.000000000 - - ( 0, 500000000, 000.001, 0, 000500000), // 0.005000000 - ( 0, 500000000, 000.010, 0, 005000000), // 0.050000000 - ( 0, 500000000, 000.100, 0, 050000000), // 0.500000000 - - ( 2, 000000000, 000.001, 0, 002000000), // 0.002000000 - ( 2, 000000000, 000.010, 0, 020000000), // 0.020000000 - ( 2, 000000000, 000.100, 0, 200000000), // 0.200000000 - - ( 3, 141592653, 003.141, 9, 867742523), // 9.867742523073 - ( 2, 718281828, 002.718, 7, 388290007), // 7.388290008504 (rounds down?) - ( 1, 414213562, 001.414, 1, 999697975), // 1.999697976668 (rounds down?) - - ( 3, 141592653, -003.141, -10, 132257477), // -9.867742523073 - ( 2, 718281828, -002.718, -8, 611709993), // -7.388290008504 - ( 1, 414213562, -001.414, -2, 000302025), // -1.999697976668 - - (-4, 858407347, 003.141, -10, 132257477), // -9.867742523073 - (-3, 281718172, 002.718, -8, 611709993), // -7.388290008504 - (-2, 585786438, 001.414, -2, 000302025), // -1.999697976668 - - (-4, 858407347, -003.141, 9, 867742523), // 9.867742523073 - (-3, 281718172, -002.718, 7, 388290007), // 7.388290008504 - (-2, 585786438, -001.414, 1, 999697975), // 1.999697976668 + ( 0, 0, 0.000, 0, 0), // 0.000000000 + ( 9, 0, 0.000, 0, 0), // 0.000000000 + ( 0, 999999999, 0.000, 0, 0), // 0.000000000 + ( 9, 999999999, 0.000, 0, 0), // 0.000000000 + + ( 1, 0, 1.000, 1, 0), // 1.000000000 + ( 9, 0, 1.000, 9, 0), // 9.000000000 + ( 1, 999999999, 1.000, 1, 999999999), // 1.999999999 + ( 9, 999999999, 1.000, 9, 999999999), // 9.999999999 + + ( 1, 0, 0.001, 0, 1000000), // 0.001000000 + ( 1, 0, 0.010, 0, 10000000), // 0.010000000 + ( 1, 0, 0.100, 0, 100000000), // 0.100000000 + + (-1, 0, 0.001, -1, 999000000), // -0.001000000 + (-1, 0, 0.010, -1, 990000000), // -0.010000000 + (-1, 0, 0.100, -1, 900000000), // -0.100000000 + (-1, 0, 1.000, -1, 0), // -1.000000000 + + ( 0, 500000000, 0.001, 0, 500000), // 0.005000000 + ( 0, 500000000, 0.010, 0, 5000000), // 0.050000000 + ( 0, 500000000, 0.100, 0, 50000000), // 0.500000000 + + ( 2, 0, 0.001, 0, 2000000), // 0.002000000 + ( 2, 0, 0.010, 0, 20000000), // 0.020000000 + ( 2, 0, 0.100, 0, 200000000), // 0.200000000 + + ( 3, 141592653, 3.141, 9, 867742523), // 9.867742523073 + ( 2, 718281828, 2.718, 7, 388290007), // 7.388290008504 (rounds down?) + ( 1, 414213562, 1.414, 1, 999697975), // 1.999697976668 (rounds down?) + + ( 3, 141592653, -3.141, -10, 132257477), // -9.867742523073 + ( 2, 718281828, -2.718, -8, 611709993), // -7.388290008504 + ( 1, 414213562, -1.414, -2, 302025), // -1.999697976668 + + (-4, 858407347, 3.141, -10, 132257477), // -9.867742523073 + (-3, 281718172, 2.718, -8, 611709993), // -7.388290008504 + (-2, 585786438, 1.414, -2, 302025), // -1.999697976668 + + (-4, 858407347, -3.141, 9, 867742523), // 9.867742523073 + (-3, 281718172, -2.718, 7, 388290007), // 7.388290008504 + (-2, 585786438, -1.414, 1, 999697975), // 1.999697976668 ]; for (let i = 0z; i < len(cases); i += 1) {