diff --git a/compiler/test/TestCompilerOnRanges.kt b/compiler/test/TestCompilerOnRanges.kt index 73ce6f9a7..46b78da46 100644 --- a/compiler/test/TestCompilerOnRanges.kt +++ b/compiler/test/TestCompilerOnRanges.kt @@ -5,6 +5,7 @@ import org.junit.jupiter.api.Test import org.junit.jupiter.api.TestFactory import org.junit.jupiter.api.TestInstance import prog8.ast.base.DataType +import prog8.ast.base.Position import prog8.ast.expressions.* import prog8.ast.statements.ForLoop import prog8.ast.statements.Subroutine @@ -265,5 +266,15 @@ class TestCompilerOnRanges { assertEquals(DataType.STR, iterable.inferType(program).getOr(DataType.UNDEFINED)) } + @Test + fun testRangeExprNumericSize() { + val expr = RangeExpr( + NumericLiteralValue.optimalInteger(10, Position.DUMMY), + NumericLiteralValue.optimalInteger(20, Position.DUMMY), + NumericLiteralValue.optimalInteger(2, Position.DUMMY), + Position.DUMMY) + assertEquals(6, expr.size()) + expr.toConstantIntegerRange() + } } diff --git a/compiler/test/ZeropageTests.kt b/compiler/test/ZeropageTests.kt index 3aece32ae..7c77eaa58 100644 --- a/compiler/test/ZeropageTests.kt +++ b/compiler/test/ZeropageTests.kt @@ -15,6 +15,61 @@ import kotlin.test.assertFalse import kotlin.test.assertTrue +@TestInstance(TestInstance.Lifecycle.PER_CLASS) +class TestAbstractZeropage { + + @Test + fun testAbstractZeropage() { + val compTarget = DummyCompilationTarget() + val zp = DummyZeropage( + CompilationOptions( + OutputType.RAW, + LauncherType.NONE, + ZeropageType.FULL, + listOf((0x50..0x5f)), + false, + false, + compTarget + ) + ) + assertEquals(256-6-16, zp.free.size) + } + + class DummyCompilationTarget: ICompilationTarget { + override val name: String = "dummy" + override val machine: IMachineDefinition + get() = throw NotImplementedError("dummy") + + override fun encodeString(str: String, altEncoding: Boolean): List { + throw NotImplementedError("dummy") + } + + override fun decodeString(bytes: List, altEncoding: Boolean): String { + throw NotImplementedError("dummy") + } + + override fun memorySize(dt: DataType): Int { + throw NotImplementedError("dummy") + } + + } + + class DummyZeropage(options: CompilationOptions) : Zeropage(options) { + override val SCRATCH_B1: Int = 0x10 + override val SCRATCH_REG: Int = 0x11 + override val SCRATCH_W1: Int= 0x20 + override val SCRATCH_W2: Int = 0x30 + + init { + free.addAll(0..255) + + removeReservedFromFreePool() + } + } + +} + + @TestInstance(TestInstance.Lifecycle.PER_CLASS) class TestC64Zeropage { diff --git a/compilerInterfaces/test/TestAstExtensions.kt b/compilerInterfaces/test/TestAstExtensions.kt deleted file mode 100644 index 54a042f4b..000000000 --- a/compilerInterfaces/test/TestAstExtensions.kt +++ /dev/null @@ -1,24 +0,0 @@ -package prog8tests.interfaces - -import org.junit.jupiter.api.Test -import org.junit.jupiter.api.TestInstance -import prog8.ast.base.Position -import prog8.ast.expressions.NumericLiteralValue -import prog8.ast.expressions.RangeExpr -import prog8.compilerinterface.size -import kotlin.test.assertEquals - - -@TestInstance(TestInstance.Lifecycle.PER_CLASS) -class TestAstExtensions { - - @Test - fun testRangeExprNumericSize() { - val expr = RangeExpr( - NumericLiteralValue.optimalInteger(10, Position.DUMMY), - NumericLiteralValue.optimalInteger(20, Position.DUMMY), - NumericLiteralValue.optimalInteger(2, Position.DUMMY), - Position.DUMMY) - assertEquals(6, expr.size()) - } -} diff --git a/compilerInterfaces/test/TestZeropage.kt b/compilerInterfaces/test/TestZeropage.kt deleted file mode 100644 index 7c065777a..000000000 --- a/compilerInterfaces/test/TestZeropage.kt +++ /dev/null @@ -1,62 +0,0 @@ -package prog8tests.interfaces - -import org.junit.jupiter.api.Test -import org.junit.jupiter.api.TestInstance -import prog8.ast.base.DataType -import prog8.compilerinterface.* -import kotlin.test.assertEquals - - -@TestInstance(TestInstance.Lifecycle.PER_CLASS) -class TestZeropage { - - @Test - fun testAbstractZeropage() { - val compTarget = DummyCompilationTarget() - val zp = DummyZeropage( - CompilationOptions( - OutputType.RAW, - LauncherType.NONE, - ZeropageType.FULL, - listOf((0x50..0x5f)), - false, - false, - compTarget - ) - ) - assertEquals(256-6-16, zp.free.size) - } - - class DummyCompilationTarget: ICompilationTarget { - override val name: String = "dummy" - override val machine: IMachineDefinition - get() = throw NotImplementedError("dummy") - - override fun encodeString(str: String, altEncoding: Boolean): List { - throw NotImplementedError("dummy") - } - - override fun decodeString(bytes: List, altEncoding: Boolean): String { - throw NotImplementedError("dummy") - } - - override fun memorySize(dt: DataType): Int { - throw NotImplementedError("dummy") - } - - } - - class DummyZeropage(options: CompilationOptions) : Zeropage(options) { - override val SCRATCH_B1: Int = 0x10 - override val SCRATCH_REG: Int = 0x11 - override val SCRATCH_W1: Int= 0x20 - override val SCRATCH_W2: Int = 0x30 - - init { - free.addAll(0..255) - - removeReservedFromFreePool() - } - } - -} diff --git a/compilerInterfaces/test/readme.txt b/compilerInterfaces/test/readme.txt new file mode 100644 index 000000000..4fac22136 --- /dev/null +++ b/compilerInterfaces/test/readme.txt @@ -0,0 +1,2 @@ +Unittests for things in this module are located in the Compiler module instead, +for convenience sake.