Keelar/ExprK

Parse error when BigDecimal contains scientific notation

tblakers opened this issue · 0 comments

This unit test:

    @Test
    fun `test that scientific notation BigDecimals are parsed and equivalent to the plain representation`() {
        val expr = Expressions()
        val scival = BigDecimal("1E+7")
        expr.define("SCIVAL", scival)
        assertEquals(scival.toPlainString(), expr.eval("SCIVAL").toPlainString())
    }

Produces this result:

com.github.keelar.exprk.ExpressionException: Expected end of expression, found 'E'

	at com.github.keelar.exprk.internal.Parser.parse(Parser.kt:15)
	at com.github.keelar.exprk.Expressions.parse(Expressions.kt:173)
	at com.github.keelar.exprk.Expressions.parse(Expressions.kt:169)
	at com.github.keelar.exprk.Expressions.define(Expressions.kt:141)
	at com.github.keelar.exprk.Expressions.define(Expressions.kt:135)
	at com.github.keelar.exprk.TestExpressions.test that scientific notation BigDecimals are parsed and equivalent to the plain representation(TestExpressions.kt:13)