Improve tests
This commit is contained in:
parent
e6f97c532b
commit
89fae39013
@ -215,7 +215,7 @@ class AsmGenerationContext<T>(
|
|||||||
visitLoadAnyFromConstants(value, c)
|
visitLoadAnyFromConstants(value, c)
|
||||||
}
|
}
|
||||||
|
|
||||||
internal fun visitLoadFromVariables(name: String, defaultValue: T? = null) = invokeMethodVisitor.run {
|
internal fun visitLoadFromVariables(name: String, defaultValue: T? = null): Unit = invokeMethodVisitor.run {
|
||||||
maxStack += 2
|
maxStack += 2
|
||||||
visitVarInsn(Opcodes.ALOAD, invokeArgumentsVar)
|
visitVarInsn(Opcodes.ALOAD, invokeArgumentsVar)
|
||||||
|
|
||||||
@ -241,6 +241,7 @@ class AsmGenerationContext<T>(
|
|||||||
}
|
}
|
||||||
|
|
||||||
internal fun visitLoadAlgebra() {
|
internal fun visitLoadAlgebra() {
|
||||||
|
maxStack++
|
||||||
invokeMethodVisitor.visitVarInsn(Opcodes.ALOAD, invokeThisVar)
|
invokeMethodVisitor.visitVarInsn(Opcodes.ALOAD, invokeThisVar)
|
||||||
|
|
||||||
invokeMethodVisitor.visitFieldInsn(
|
invokeMethodVisitor.visitFieldInsn(
|
||||||
|
@ -3,6 +3,8 @@ package scientifik.kmath.expressions
|
|||||||
import scientifik.kmath.expressions.asm.AsmExpression
|
import scientifik.kmath.expressions.asm.AsmExpression
|
||||||
import scientifik.kmath.expressions.asm.AsmExpressionField
|
import scientifik.kmath.expressions.asm.AsmExpressionField
|
||||||
import scientifik.kmath.expressions.asm.asmField
|
import scientifik.kmath.expressions.asm.asmField
|
||||||
|
import scientifik.kmath.expressions.asm.asmRing
|
||||||
|
import scientifik.kmath.operations.IntRing
|
||||||
import scientifik.kmath.operations.RealField
|
import scientifik.kmath.operations.RealField
|
||||||
import kotlin.test.Test
|
import kotlin.test.Test
|
||||||
import kotlin.test.assertEquals
|
import kotlin.test.assertEquals
|
||||||
@ -15,26 +17,29 @@ class AsmTest {
|
|||||||
): Unit = assertEquals(expected = expected, actual = asmField(RealField, block)(arguments))
|
): Unit = assertEquals(expected = expected, actual = asmField(RealField, block)(arguments))
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
fun testConstantsSum() = testDoubleExpression(16.0) { const(8.0) + 8.0 }
|
fun testConstantsSum(): Unit = testDoubleExpression(16.0) { const(8.0) + 8.0 }
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
fun testVarsSum() = testDoubleExpression(1000.0, mapOf("x" to 500.0)) { variable("x") + 500.0 }
|
fun testVarsSum(): Unit = testDoubleExpression(1000.0, mapOf("x" to 500.0)) { variable("x") + 500.0 }
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
fun testProduct() = testDoubleExpression(24.0) { const(4.0) * const(6.0) }
|
fun testProduct(): Unit = testDoubleExpression(24.0) { const(4.0) * const(6.0) }
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
fun testConstantProduct() = testDoubleExpression(984.0) { const(8.0) * 123 }
|
fun testConstantProduct(): Unit = testDoubleExpression(984.0) { const(8.0) * 123 }
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
fun testSubtraction() = testDoubleExpression(2.0) { const(4.0) - 2.0 }
|
fun testVarsConstantProductVar(): Unit = testDoubleExpression(984.0, mapOf("x" to 8.0)) { variable("x") * 123 }
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
fun testDivision() = testDoubleExpression(64.0) { const(128.0) / 2 }
|
fun testSubtraction(): Unit = testDoubleExpression(2.0) { const(4.0) - 2.0 }
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
fun testDirectCall() = testDoubleExpression(4096.0) { binaryOperation("*", const(64.0), const(64.0)) }
|
fun testDivision(): Unit = testDoubleExpression(64.0) { const(128.0) / 2 }
|
||||||
|
|
||||||
// @Test
|
@Test
|
||||||
// fun testSine() = testDoubleExpression(0.0) { unaryOperation("sin", const(PI)) }
|
fun testDirectUnaryCall(): Unit = testDoubleExpression(64.0) { unaryOperation("+", const(64.0)) }
|
||||||
|
|
||||||
|
@Test
|
||||||
|
fun testDirectBinaryCall(): Unit = testDoubleExpression(4096.0) { binaryOperation("*", const(64.0), const(64.0)) }
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user