My working unpac space for OCaml projects in development
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

[Temporal] Add test for Duration.total precision bug

This bug was observed in temporal_rs.

authored by

Tim Chevalier and committed by
Ms2ger
8eedf359 458f19b1

+27
+27
vendor/git/test262/test/built-ins/Temporal/Duration/prototype/total/precision-exact-mathematical-values-5.js
··· 56 56 "BalanceTimeDuration should implement floating-point calculation correctly for largestUnit nanoseconds" 57 57 ); 58 58 } 59 + 60 + { 61 + const d = new Temporal.Duration(0, 0, 5, 5); 62 + 63 + const result = d.total({ unit: "months", relativeTo: "1972-01-31" }) 64 + 65 + /* 66 + Expected months checked using Decimals in Python: 67 + 68 + >>> from decimal import * 69 + >>> getcontext().prec = 18 70 + >>> dest_epoch_ns = Decimal(69120000000000000) 71 + >>> start_epoch_ns = Decimal(68169600000000000) 72 + >>> end_epoch_ns = 70848000000000000 73 + >>> progress = ((dest_epoch_ns - start_epoch_ns) / (end_epoch_ns - start_epoch_ns)) 74 + >>> progress 75 + Decimal('0.354838709677419355') 76 + >>> Decimal(1) + progress 77 + Decimal('1.35483870967741936') 78 + 79 + The result should be truncated. 80 + */ 81 + const expectedMonths = 1.3548387096774193; 82 + 83 + assert.sameValue(result, expectedMonths, 84 + "NudgeToCalendarUnit should implement floating-point calculation correctly for largestUnit months"); 85 + }