32 lines
828 B
Kotlin
32 lines
828 B
Kotlin
package net.shadowfacts.asmr.program
|
|
|
|
import net.shadowfacts.asmr.program.blocks.ConstantBlock
|
|
import net.shadowfacts.asmr.program.blocks.math.BinaryOperatorBlock
|
|
import org.junit.jupiter.api.Assertions.assertEquals
|
|
import org.junit.jupiter.api.Test
|
|
|
|
/**
|
|
* @author shadowfacts
|
|
*/
|
|
class ProgramTests {
|
|
|
|
@Test
|
|
fun testExecutionFlow() {
|
|
val program = Program()
|
|
val one = ConstantBlock(ProgramType.int, 3)
|
|
program.blocks.add(one)
|
|
val two = ConstantBlock(ProgramType.int, 7)
|
|
program.blocks.add(two)
|
|
val multiply = BinaryOperatorBlock(ProgramType.int, BinaryOperatorBlock.Operation.multiply)
|
|
multiply.left.source = one.output
|
|
multiply.right.source = two.output
|
|
program.blocks.add(multiply)
|
|
|
|
program.startBlock.nextExecutableBlock = multiply
|
|
|
|
program.execute()
|
|
|
|
assertEquals(21, multiply.output.value)
|
|
}
|
|
|
|
} |