diff --git a/compiler/test/AsmgenTests.kt b/compiler/test/AsmgenTests.kt index fe346680e..34ecf58cb 100644 --- a/compiler/test/AsmgenTests.kt +++ b/compiler/test/AsmgenTests.kt @@ -1,6 +1,7 @@ package prog8tests -import org.junit.jupiter.api.* +import org.junit.jupiter.api.TestInstance +import org.junit.jupiter.api.Test import org.hamcrest.MatcherAssert.assertThat import org.hamcrest.Matchers.equalTo import prog8tests.helpers.* diff --git a/compiler/test/Helpers.kt b/compiler/test/Helpers.kt index 00d5f36ff..de5a55217 100644 --- a/compiler/test/Helpers.kt +++ b/compiler/test/Helpers.kt @@ -43,23 +43,23 @@ val fixturesDir = workingDir.resolve("test/fixtures") val resourcesDir = workingDir.resolve("res") val outputDir = workingDir.resolve("build/tmp/test") -inline fun assumeReadable(path: Path) { +fun assumeReadable(path: Path) { assertTrue(path.isReadable(), "sanity check: should be readable: ${path.absolute()}") } -inline fun assumeReadableFile(path: Path) { +fun assumeReadableFile(path: Path) { assertTrue(path.isRegularFile(), "sanity check: should be normal file: ${path.absolute()}") } -inline fun assumeDirectory(path: Path) { +fun assumeDirectory(path: Path) { assertTrue(path.isDirectory(), "sanity check; should be directory: $path") } -inline fun assumeNotExists(path: Path) { +fun assumeNotExists(path: Path) { assertFalse(path.exists(), "sanity check: should not exist: ${path.absolute()}") } -inline fun sanityCheckDirectories(workingDirName: String? = null) { +fun sanityCheckDirectories(workingDirName: String? = null) { if (workingDirName != null) assertEquals(workingDirName, workingDir.fileName.toString(), "name of current working dir") assumeDirectory(workingDir) diff --git a/compiler/test/TestCompilerOnCharLit.kt b/compiler/test/TestCompilerOnCharLit.kt index 01561bac2..2c61ea191 100644 --- a/compiler/test/TestCompilerOnCharLit.kt +++ b/compiler/test/TestCompilerOnCharLit.kt @@ -1,6 +1,8 @@ package prog8tests -import org.junit.jupiter.api.* +import org.junit.jupiter.api.TestInstance +import org.junit.jupiter.api.Test +import org.junit.jupiter.api.BeforeAll import kotlin.test.* import prog8tests.helpers.* diff --git a/compiler/test/TestCompilerOnExamples.kt b/compiler/test/TestCompilerOnExamples.kt index dec08e28a..56932460a 100644 --- a/compiler/test/TestCompilerOnExamples.kt +++ b/compiler/test/TestCompilerOnExamples.kt @@ -1,6 +1,9 @@ package prog8tests -import org.junit.jupiter.api.* +import org.junit.jupiter.api.TestInstance +import org.junit.jupiter.api.Test +import org.junit.jupiter.api.BeforeAll +import org.junit.jupiter.api.Disabled import kotlin.test.* import prog8tests.helpers.* @@ -14,6 +17,7 @@ import prog8.compiler.target.ICompilationTarget * They are not really unit tests, but rather tests of the whole process, * from source file loading all the way through to running 64tass. */ +//@Disabled("to save some time") @TestInstance(TestInstance.Lifecycle.PER_CLASS) class TestCompilerOnExamples { private val examplesDir = workingDir.resolve("../examples") diff --git a/compiler/test/TestCompilerOnImportsAndIncludes.kt b/compiler/test/TestCompilerOnImportsAndIncludes.kt index 835c1ea1f..4ba084a39 100644 --- a/compiler/test/TestCompilerOnImportsAndIncludes.kt +++ b/compiler/test/TestCompilerOnImportsAndIncludes.kt @@ -1,7 +1,10 @@ package prog8tests -import org.junit.jupiter.api.* +import org.junit.jupiter.api.TestInstance +import org.junit.jupiter.api.Test +import org.junit.jupiter.api.BeforeAll import kotlin.test.* +import kotlin.io.path.* import prog8tests.helpers.* import prog8.ast.expressions.AddressOf @@ -9,9 +12,7 @@ import prog8.ast.expressions.IdentifierReference import prog8.ast.expressions.StringLiteralValue import prog8.ast.statements.FunctionCallStatement import prog8.ast.statements.Label -import prog8.compiler.compileProgram import prog8.compiler.target.Cx16Target -import kotlin.io.path.name /** diff --git a/compiler/test/TestMemory.kt b/compiler/test/TestMemory.kt index 4256398ab..25a1bf3bb 100644 --- a/compiler/test/TestMemory.kt +++ b/compiler/test/TestMemory.kt @@ -1,6 +1,7 @@ package prog8tests -import org.junit.jupiter.api.* +import org.junit.jupiter.api.TestInstance +import org.junit.jupiter.api.Test import kotlin.test.* import prog8tests.helpers.* @@ -14,6 +15,7 @@ import prog8.ast.expressions.* import prog8.ast.statements.* import prog8.compiler.target.C64Target + @TestInstance(TestInstance.Lifecycle.PER_CLASS) class TestMemory { diff --git a/compiler/test/TestNumbers.kt b/compiler/test/TestNumbers.kt index 499db45d7..a22d98e68 100644 --- a/compiler/test/TestNumbers.kt +++ b/compiler/test/TestNumbers.kt @@ -1,6 +1,7 @@ package prog8tests -import org.junit.jupiter.api.* +import org.junit.jupiter.api.TestInstance +import org.junit.jupiter.api.Test import kotlin.test.* import org.hamcrest.MatcherAssert.assertThat import org.hamcrest.Matchers.closeTo diff --git a/compiler/test/TestNumericLiteralValue.kt b/compiler/test/TestNumericLiteralValue.kt index 22d9ae03e..5492fc2cf 100644 --- a/compiler/test/TestNumericLiteralValue.kt +++ b/compiler/test/TestNumericLiteralValue.kt @@ -1,6 +1,7 @@ package prog8tests -import org.junit.jupiter.api.* +import org.junit.jupiter.api.TestInstance +import org.junit.jupiter.api.Test import kotlin.test.* import prog8.ast.base.DataType diff --git a/compiler/test/TestPetscii.kt b/compiler/test/TestPetscii.kt index 0fcc9a2dc..f658e93c0 100644 --- a/compiler/test/TestPetscii.kt +++ b/compiler/test/TestPetscii.kt @@ -1,6 +1,7 @@ package prog8tests -import org.junit.jupiter.api.* +import org.junit.jupiter.api.TestInstance +import org.junit.jupiter.api.Test import kotlin.test.* import org.hamcrest.MatcherAssert.assertThat import org.hamcrest.Matchers.equalTo diff --git a/compiler/test/ZeropageTests.kt b/compiler/test/ZeropageTests.kt index 4ece96e5e..01622d02a 100644 --- a/compiler/test/ZeropageTests.kt +++ b/compiler/test/ZeropageTests.kt @@ -1,6 +1,7 @@ package prog8tests -import org.junit.jupiter.api.* +import org.junit.jupiter.api.TestInstance +import org.junit.jupiter.api.Test import kotlin.test.* import prog8.ast.base.DataType diff --git a/compilerAst/test/Helpers.kt b/compilerAst/test/Helpers.kt index 0ffc8a5a4..5fc3d8870 100644 --- a/compilerAst/test/Helpers.kt +++ b/compilerAst/test/Helpers.kt @@ -20,23 +20,23 @@ val fixturesDir = workingDir.resolve("test/fixtures") val resourcesDir = workingDir.resolve("res") val outputDir = workingDir.resolve("build/tmp/test") -inline fun assumeReadable(path: Path) { +fun assumeReadable(path: Path) { assertTrue(path.isReadable(), "sanity check: should be readable: ${path.absolute()}") } -inline fun assumeReadableFile(path: Path) { +fun assumeReadableFile(path: Path) { assertTrue(path.isRegularFile(), "sanity check: should be normal file: ${path.absolute()}") } -inline fun assumeDirectory(path: Path) { +fun assumeDirectory(path: Path) { assertTrue(path.isDirectory(), "sanity check; should be directory: $path") } -inline fun assumeNotExists(path: Path) { +fun assumeNotExists(path: Path) { assertFalse(path.exists(), "sanity check: should not exist: ${path.absolute()}") } -inline fun sanityCheckDirectories(workingDirName: String? = null) { +fun sanityCheckDirectories(workingDirName: String? = null) { if (workingDirName != null) assertEquals(workingDirName, workingDir.fileName.toString(), "name of current working dir") assumeDirectory(workingDir) diff --git a/compilerAst/test/TestAstToSourceCode.kt b/compilerAst/test/TestAstToSourceCode.kt index 4f422a1b9..563b58528 100644 --- a/compilerAst/test/TestAstToSourceCode.kt +++ b/compilerAst/test/TestAstToSourceCode.kt @@ -1,6 +1,8 @@ package prog8tests -import org.junit.jupiter.api.* +import org.junit.jupiter.api.TestInstance +import org.junit.jupiter.api.Test +import org.junit.jupiter.api.Disabled import kotlin.test.* import prog8tests.helpers.* @@ -15,7 +17,7 @@ import prog8.parser.ParseError @TestInstance(TestInstance.Lifecycle.PER_CLASS) class TestAstToSourceCode { - fun generateP8(module: Module) : String { + private fun generateP8(module: Module) : String { val program = Program("test", mutableListOf(module), DummyFunctions, DummyMemsizer) module.linkParents(program) module.program = program @@ -27,7 +29,7 @@ class TestAstToSourceCode { return generatedText } - fun roundTrip(module: Module): Pair { + private fun roundTrip(module: Module): Pair { val generatedText = generateP8(module) try { val parsedAgain = parseModule(SourceCode.of(generatedText)) @@ -41,7 +43,7 @@ class TestAstToSourceCode { @Test fun testMentionsInternedStringsModule() { val orig = SourceCode.of("\n") - val (txt, module) = roundTrip(parseModule(orig)) + val (txt, _) = roundTrip(parseModule(orig)) // assertContains has *actual* first! assertContains(txt, Regex(";.*$internedStringsModuleName")) } @@ -49,7 +51,7 @@ class TestAstToSourceCode { @Test fun testTargetDirectiveAndComment() { val orig = SourceCode.of("%target 42 ; invalid arg - shouldn't matter\n") - val (txt, module) = roundTrip(parseModule(orig)) + val (txt, _) = roundTrip(parseModule(orig)) // assertContains has *actual* first! assertContains(txt, Regex("%target +42")) } @@ -57,7 +59,7 @@ class TestAstToSourceCode { @Test fun testImportDirectiveWithLib() { val orig = SourceCode.of("%import textio\n") - val (txt, module) = roundTrip(parseModule(orig)) + val (txt, _) = roundTrip(parseModule(orig)) // assertContains has *actual* first! assertContains(txt, Regex("%import +textio")) } @@ -65,7 +67,7 @@ class TestAstToSourceCode { @Test fun testImportDirectiveWithUserModule() { val orig = SourceCode.of("%import my_own_stuff\n") - val (txt, module) = roundTrip(parseModule(orig)) + val (txt, _) = roundTrip(parseModule(orig)) // assertContains has *actual* first! assertContains(txt, Regex("%import +my_own_stuff")) } @@ -78,7 +80,7 @@ class TestAstToSourceCode { str s = "fooBar\n" } """) - val (txt, module) = roundTrip(parseModule(orig)) + val (txt, _) = roundTrip(parseModule(orig)) // assertContains has *actual* first! assertContains(txt, Regex("str +s += +\"fooBar\\\\n\"")) } @@ -90,33 +92,33 @@ class TestAstToSourceCode { str sAlt = @"fooBar\n" } """) - val (txt, module) = roundTrip(parseModule(orig)) + val (txt, _) = roundTrip(parseModule(orig)) // assertContains has *actual* first! assertContains(txt, Regex("str +sAlt += +@\"fooBar\\\\n\"")) } @Test - @Disabled + @Disabled("TODO: char literals should be kept until code gen - step 4, 'introduce AST node CharLiteral'") fun testCharLiteral_noAlt() { val orig = SourceCode.of(""" main { ubyte c = 'x' } """) - val (txt, module) = roundTrip(parseModule(orig)) + val (txt, _) = roundTrip(parseModule(orig)) // assertContains has *actual* first! assertContains(txt, Regex("ubyte +c += +'x'"), "char literal") } @Test - @Disabled + @Disabled("TODO: char literals should be kept until code gen - step 4, 'introduce AST node CharLiteral'") fun testCharLiteral_withAlt() { val orig = SourceCode.of(""" main { ubyte cAlt = @'x' } """) - val (txt, module) = roundTrip(parseModule(orig)) + val (txt, _) = roundTrip(parseModule(orig)) // assertContains has *actual* first! assertContains(txt, Regex("ubyte +cAlt += +@'x'"), "alt char literal") } diff --git a/compilerAst/test/TestModuleImporter.kt b/compilerAst/test/TestModuleImporter.kt index b8458a2c3..68ebb41e4 100644 --- a/compilerAst/test/TestModuleImporter.kt +++ b/compilerAst/test/TestModuleImporter.kt @@ -1,11 +1,10 @@ package prog8tests -import org.junit.jupiter.api.Test import org.junit.jupiter.api.TestInstance +import org.junit.jupiter.api.Test import kotlin.test.* import prog8tests.helpers.* -import java.nio.file.Path // TODO: use kotlin.io.path.Path instead import kotlin.io.path.* import prog8.ast.Program diff --git a/compilerAst/test/TestProg8Parser.kt b/compilerAst/test/TestProg8Parser.kt index a718f98a0..42c8d67c4 100644 --- a/compilerAst/test/TestProg8Parser.kt +++ b/compilerAst/test/TestProg8Parser.kt @@ -1,6 +1,9 @@ package prog8tests -import org.junit.jupiter.api.* +import org.junit.jupiter.api.TestInstance +import org.junit.jupiter.api.Test +import org.junit.jupiter.api.Disabled +import org.junit.jupiter.api.BeforeAll import kotlin.test.* import prog8tests.helpers.* import kotlin.io.path.* @@ -295,7 +298,7 @@ class TestProg8Parser { * TODO: this test is testing way too much at once */ @Test - @Disabled + @Disabled("TODO: fix .position of nodes below Module - step 8, 'refactor AST gen'") fun testInnerNodePositionsForSourceFromString() { val srcText = """ %target 16, "abc" ; DirectiveArg directly inherits from Node - neither an Expression nor a Statement..? diff --git a/compilerAst/test/TestSourceCode.kt b/compilerAst/test/TestSourceCode.kt index dc9759fed..571f23eb2 100644 --- a/compilerAst/test/TestSourceCode.kt +++ b/compilerAst/test/TestSourceCode.kt @@ -1,5 +1,8 @@ package prog8tests +import org.junit.jupiter.api.TestInstance +import org.junit.jupiter.api.Test +import org.junit.jupiter.api.BeforeAll import org.junit.jupiter.api.* import kotlin.test.* import prog8tests.helpers.* @@ -8,7 +11,6 @@ import kotlin.io.path.* import prog8.parser.SourceCode - @TestInstance(TestInstance.Lifecycle.PER_CLASS) class TestSourceCode { @@ -156,10 +158,8 @@ class TestSourceCode { assertThrows { SourceCode.fromResources(pathString) } } - /** - * TODO("inside resources: cannot tell apart a folder from a file") - */ - //@Test + @Test + @Disabled("TODO: inside resources: cannot tell apart a folder from a file") fun testFromResourcesWithDirectory() { val pathString = "/prog8lib" assertThrows { SourceCode.fromResources(pathString) }