diff --git a/kmath-common/src/test/kotlin/scientifik/kmath/expressions/FieldExpressionContextTest.kt b/kmath-common/src/test/kotlin/scientifik/kmath/expressions/FieldExpressionContextTest.kt index 3d68a4674..dda267ec8 100644 --- a/kmath-common/src/test/kotlin/scientifik/kmath/expressions/FieldExpressionContextTest.kt +++ b/kmath-common/src/test/kotlin/scientifik/kmath/expressions/FieldExpressionContextTest.kt @@ -1,5 +1,7 @@ package scientifik.kmath.expressions +import scientifik.kmath.operations.Complex +import scientifik.kmath.operations.ComplexField import scientifik.kmath.operations.DoubleField import kotlin.test.Test import kotlin.test.assertEquals @@ -15,4 +17,15 @@ class FieldExpressionContextTest { assertEquals(expression("x" to 1.0), 4.0) assertEquals(expression(), 9.0) } + + @Test + fun testComplex() { + val context = FieldExpressionContext(ComplexField) + val expression = with(context) { + val x = variable("x", Complex(2.0, 0.0)) + x * x + 2 * x + 1.0 + } + assertEquals(expression("x" to Complex(1.0, 0.0)), Complex(4.0, 0.0)) + assertEquals(expression(), Complex(9.0, 0.0)) + } } \ No newline at end of file