From 6c25042f0f4feaf2bf6fbb358be1e0e08a020fcf Mon Sep 17 00:00:00 2001 From: Alexander Nozik Date: Sat, 25 Aug 2018 21:36:50 +0300 Subject: [PATCH] Context separation test for expressions --- .../kmath/expressions/FieldExpressionContextTest.kt | 11 +++++++++++ 1 file changed, 11 insertions(+) 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 dda267ec8..543e13d79 100644 --- a/kmath-common/src/test/kotlin/scientifik/kmath/expressions/FieldExpressionContextTest.kt +++ b/kmath-common/src/test/kotlin/scientifik/kmath/expressions/FieldExpressionContextTest.kt @@ -28,4 +28,15 @@ class FieldExpressionContextTest { assertEquals(expression("x" to Complex(1.0, 0.0)), Complex(4.0, 0.0)) assertEquals(expression(), Complex(9.0, 0.0)) } + + @Test + fun separateContext() { + fun FieldExpressionContext.expression(): Expression{ + val x = variable("x") + return x * x + 2 * x + 1.0 + } + + val expression = FieldExpressionContext(DoubleField).expression() + assertEquals(expression("x" to 1.0), 4.0) + } } \ No newline at end of file