minor additions

This commit is contained in:
sergeych committed 2026-04-01 02:51:00 +03:00
1 parent c140567e0c
commit 446c8d9a6e
2 files changed
+68 -71

No files matched your search

@@ -284,6 +284,31 @@ class DecimalModuleTest {
)
}
@Test
fun testDecimalTruncateToTwoFractionDigitsViaGlobalRound() = runTest {
val scope = Script.newScope()
scope.eval(
"""
import lyng.decimal
fun trunc2(x: Decimal): Decimal {
val scaled = x * 100.d
val whole = if (scaled >= 0.d) {
floor(scaled) as Decimal
} else {
ceil(scaled) as Decimal
}
whole / 100.d
}
assertEquals("12.34", trunc2("12.349".d).toStringExpanded())
assertEquals("12.34", trunc2("12.340".d).toStringExpanded())
assertEquals("-12.34", trunc2("-12.349".d).toStringExpanded())
assertEquals("-12.34", trunc2("-12.340".d).toStringExpanded())
""".trimIndent()
)
}
@Test
fun testDecimalMathHelpersFallbackThroughRealTemporarily() = runTest {
val scope = Script.newScope()