From c75bd97537ef1d6154719e812f4fd0abcd510412 Mon Sep 17 00:00:00 2001 From: Irmen de Jong Date: Sun, 26 Jun 2022 18:51:03 +0200 Subject: [PATCH] update kotest --- .../io_kotest_assertions_core_jvm.xml | 18 +-- .idea/libraries/io_kotest_property_jvm.xml | 18 +-- .../libraries/io_kotest_runner_junit5_jvm.xml | 50 ++++---- compiler/build.gradle | 2 +- compiler/test/ModuleImporterTests.kt | 44 +++---- compiler/test/TestCompilerOnExamples.kt | 20 +-- .../test/TestCompilerOnImportsAndIncludes.kt | 34 ++--- compiler/test/TestCompilerOnRanges.kt | 4 +- compiler/test/TestCompilerOptionLibdirs.kt | 25 ++-- .../TestImportedModulesOrderAndOptions.kt | 4 +- compiler/test/TestOptimization.kt | 2 +- compiler/test/ast/TestProg8Parser.kt | 18 +-- compiler/test/ast/TestSourceCode.kt | 31 ++--- compiler/test/helpers/compileXyz.kt | 8 +- compiler/test/helpers/mapCombinations.kt | 118 +++++++++--------- compiler/test/helpers/paths.kt | 107 ++++++++-------- compiler/test/helpers_pathsTests.kt | 116 ++++++++--------- virtualmachine/build.gradle | 2 +- 18 files changed, 313 insertions(+), 308 deletions(-) diff --git a/.idea/libraries/io_kotest_assertions_core_jvm.xml b/.idea/libraries/io_kotest_assertions_core_jvm.xml index 8868542ad..338a79262 100644 --- a/.idea/libraries/io_kotest_assertions_core_jvm.xml +++ b/.idea/libraries/io_kotest_assertions_core_jvm.xml @@ -1,21 +1,21 @@ - + - - - + + + - - + + - + - - + + diff --git a/.idea/libraries/io_kotest_property_jvm.xml b/.idea/libraries/io_kotest_property_jvm.xml index 2009f9c6f..1a833ac61 100644 --- a/.idea/libraries/io_kotest_property_jvm.xml +++ b/.idea/libraries/io_kotest_property_jvm.xml @@ -1,20 +1,20 @@ - + - + - - + + - - - - + + + + - + diff --git a/.idea/libraries/io_kotest_runner_junit5_jvm.xml b/.idea/libraries/io_kotest_runner_junit5_jvm.xml index 359e37478..5f1b661c3 100644 --- a/.idea/libraries/io_kotest_runner_junit5_jvm.xml +++ b/.idea/libraries/io_kotest_runner_junit5_jvm.xml @@ -1,38 +1,38 @@ - + - - - + + + - - - + + + - - + + - - + + - - - - - - - + + + + + + + - - - + + + @@ -41,11 +41,11 @@ - - + + - - + + diff --git a/compiler/build.gradle b/compiler/build.gradle index 2e1f6c977..308b6f982 100644 --- a/compiler/build.gradle +++ b/compiler/build.gradle @@ -40,7 +40,7 @@ dependencies { implementation 'org.jetbrains.kotlinx:kotlinx-cli:0.3.4' implementation "com.michael-bull.kotlin-result:kotlin-result-jvm:1.1.16" - testImplementation 'io.kotest:kotest-runner-junit5-jvm:5.2.3' + testImplementation 'io.kotest:kotest-runner-junit5-jvm:5.3.2' } configurations.all { diff --git a/compiler/test/ModuleImporterTests.kt b/compiler/test/ModuleImporterTests.kt index f9d8c96e7..b816b7561 100644 --- a/compiler/test/ModuleImporterTests.kt +++ b/compiler/test/ModuleImporterTests.kt @@ -39,9 +39,9 @@ class TestModuleImporter: FunSpec({ context("WithInvalidPath") { test("testNonexisting") { - val dirRel = Helpers.assumeDirectory(".", Helpers.workingDir.relativize(Helpers.fixturesDir)) + val dirRel = assumeDirectory(".", workingDir.relativize(fixturesDir)) val importer = makeImporter(null, dirRel.invariantSeparatorsPathString) - val srcPathRel = Helpers.assumeNotExists(dirRel, "i_do_not_exist") + val srcPathRel = assumeNotExists(dirRel, "i_do_not_exist") val srcPathAbs = srcPathRel.absolute() val error1 = importer.importModule(srcPathRel).getErrorOrElse { fail("should have import error") } withClue(".file should be normalized") { @@ -62,7 +62,7 @@ class TestModuleImporter: FunSpec({ } test("testDirectory") { - val srcPathRel = Helpers.assumeDirectory(Helpers.workingDir.relativize(Helpers.fixturesDir)) + val srcPathRel = assumeDirectory(workingDir.relativize(fixturesDir)) val srcPathAbs = srcPathRel.absolute() val searchIn = Path(".", "$srcPathRel").invariantSeparatorsPathString val importer = makeImporter(null, searchIn) @@ -95,11 +95,11 @@ class TestModuleImporter: FunSpec({ test("testAbsolute") { val searchIn = listOf( - Path(".").div(Helpers.workingDir.relativize(Helpers.fixturesDir)), // we do want a dot "." in front + Path(".").div(workingDir.relativize(fixturesDir)), // we do want a dot "." in front ).map { it.invariantSeparatorsPathString } val importer = makeImporter(null, searchIn) val fileName = "ast_simple_main.p8" - val path = Helpers.assumeReadableFile(searchIn[0], fileName) + val path = assumeReadableFile(searchIn[0], fileName) val module = importer.importModule(path.absolute()).getOrElse { throw it } program.modules.size shouldBe 2 @@ -109,11 +109,11 @@ class TestModuleImporter: FunSpec({ test("testRelativeToWorkingDir") { val searchIn = listOf( - Path(".").div(Helpers.workingDir.relativize(Helpers.fixturesDir)), // we do want a dot "." in front + Path(".").div(workingDir.relativize(fixturesDir)), // we do want a dot "." in front ).map { it.invariantSeparatorsPathString } val importer = makeImporter(null, searchIn) val fileName = "ast_simple_main.p8" - val path = Helpers.assumeReadableFile(searchIn[0], fileName) + val path = assumeReadableFile(searchIn[0], fileName) withClue("sanity check: path should NOT be absolute") { path.isAbsolute shouldBe false } @@ -126,12 +126,12 @@ class TestModuleImporter: FunSpec({ test("testRelativeTo1stDirInSearchList") { val searchIn = Path(".") - .div(Helpers.workingDir.relativize(Helpers.fixturesDir)) + .div(workingDir.relativize(fixturesDir)) .invariantSeparatorsPathString val importer = makeImporter(null, searchIn) val fileName = "ast_simple_main.p8" val path = Path(".", fileName) - Helpers.assumeReadableFile(searchIn, path) + assumeReadableFile(searchIn, path) val module = importer.importModule(path).getOrElse { throw it } program.modules.size shouldBe 2 @@ -141,9 +141,9 @@ class TestModuleImporter: FunSpec({ context("WithBadFile") { test("testWithSyntaxError") { - val searchIn = Helpers.assumeDirectory("./", Helpers.workingDir.relativize(Helpers.fixturesDir)) + val searchIn = assumeDirectory("./", workingDir.relativize(fixturesDir)) val importer = makeImporter(null, searchIn.invariantSeparatorsPathString) - val srcPath = Helpers.assumeReadableFile(Helpers.fixturesDir, "ast_file_with_syntax_error.p8") + val srcPath = assumeReadableFile(fixturesDir, "ast_file_with_syntax_error.p8") val act = { importer.importModule(srcPath) } @@ -160,10 +160,10 @@ class TestModuleImporter: FunSpec({ } fun doTestImportingFileWithSyntaxError(repetitions: Int) { - val searchIn = Helpers.assumeDirectory("./", Helpers.workingDir.relativize(Helpers.fixturesDir)) + val searchIn = assumeDirectory("./", workingDir.relativize(fixturesDir)) val importer = makeImporter(null, searchIn.invariantSeparatorsPathString) - val importing = Helpers.assumeReadableFile(Helpers.fixturesDir, "import_file_with_syntax_error.p8") - val imported = Helpers.assumeReadableFile(Helpers.fixturesDir, "file_with_syntax_error.p8") + val importing = assumeReadableFile(fixturesDir, "import_file_with_syntax_error.p8") + val imported = assumeReadableFile(fixturesDir, "file_with_syntax_error.p8") val act = { importer.importModule(importing) } @@ -194,11 +194,11 @@ class TestModuleImporter: FunSpec({ context("ImportLibraryModule") { context("WithInvalidName") { test("testWithNonExistingName") { - val searchIn = Helpers.assumeDirectory("./", Helpers.workingDir.relativize(Helpers.fixturesDir)) + val searchIn = assumeDirectory("./", workingDir.relativize(fixturesDir)) val errors = ErrorReporterForTests(false) val importer = makeImporter(errors, searchIn.invariantSeparatorsPathString) - val filenameNoExt = Helpers.assumeNotExists(Helpers.fixturesDir, "i_do_not_exist").name - val filenameWithExt = Helpers.assumeNotExists(Helpers.fixturesDir, "i_do_not_exist.p8").name + val filenameNoExt = assumeNotExists(fixturesDir, "i_do_not_exist").name + val filenameWithExt = assumeNotExists(fixturesDir, "i_do_not_exist.p8").name repeat(2) { n -> val result = importer.importLibraryModule(filenameNoExt) @@ -221,9 +221,9 @@ class TestModuleImporter: FunSpec({ context("WithValidName") { context("WithBadFile") { test("testWithSyntaxError") { - val searchIn = Helpers.assumeDirectory("./", Helpers.workingDir.relativize(Helpers.fixturesDir)) + val searchIn = assumeDirectory("./", workingDir.relativize(fixturesDir)) val importer = makeImporter(null, searchIn.invariantSeparatorsPathString) - val srcPath = Helpers.assumeReadableFile(Helpers.fixturesDir, "ast_file_with_syntax_error.p8") + val srcPath = assumeReadableFile(fixturesDir, "ast_file_with_syntax_error.p8") repeat(2) { n -> withClue(count[n] + " call") { shouldThrow() @@ -241,10 +241,10 @@ class TestModuleImporter: FunSpec({ fun doTestImportingFileWithSyntaxError(repetitions: Int) { - val searchIn = Helpers.assumeDirectory("./", Helpers.workingDir.relativize(Helpers.fixturesDir)) + val searchIn = assumeDirectory("./", workingDir.relativize(fixturesDir)) val importer = makeImporter(null, searchIn.invariantSeparatorsPathString) - val importing = Helpers.assumeReadableFile(Helpers.fixturesDir, "import_file_with_syntax_error.p8") - val imported = Helpers.assumeReadableFile(Helpers.fixturesDir, "file_with_syntax_error.p8") + val importing = assumeReadableFile(fixturesDir, "import_file_with_syntax_error.p8") + val imported = assumeReadableFile(fixturesDir, "file_with_syntax_error.p8") val act = { importer.importLibraryModule(importing.nameWithoutExtension) } diff --git a/compiler/test/TestCompilerOnExamples.kt b/compiler/test/TestCompilerOnExamples.kt index a722142bd..2f7381612 100644 --- a/compiler/test/TestCompilerOnExamples.kt +++ b/compiler/test/TestCompilerOnExamples.kt @@ -8,8 +8,10 @@ import prog8.code.target.Cx16Target import prog8.compiler.CompilationResult import prog8.compiler.CompilerArguments import prog8.compiler.compileProgram -import prog8tests.helpers.Combinations -import prog8tests.helpers.Helpers +import prog8tests.helpers.assumeDirectory +import prog8tests.helpers.cartesianProduct +import prog8tests.helpers.outputDir +import prog8tests.helpers.workingDir import java.nio.file.Path import kotlin.io.path.absolute import kotlin.io.path.exists @@ -21,7 +23,7 @@ import kotlin.io.path.exists * from source file loading all the way through to running 64tass. */ -private val examplesDir = Helpers.assumeDirectory(Helpers.workingDir, "../examples") +private val examplesDir = assumeDirectory(workingDir, "../examples") private fun compileTheThing(filepath: Path, optimize: Boolean, target: ICompilationTarget): CompilationResult? { val args = CompilerArguments( @@ -35,7 +37,7 @@ private fun compileTheThing(filepath: Path, optimize: Boolean, target: ICompilat asmListfile = false, experimentalCodegen = false, compilationTarget = target.name, - outputDir = Helpers.outputDir + outputDir = outputDir ) return compileProgram(args) } @@ -43,12 +45,12 @@ private fun compileTheThing(filepath: Path, optimize: Boolean, target: ICompilat private fun prepareTestFiles(source: String, optimize: Boolean, target: ICompilationTarget): Pair { val searchIn = mutableListOf(examplesDir) if (target is Cx16Target) { - searchIn.add(0, Helpers.assumeDirectory(examplesDir, "cx16")) + searchIn.add(0, assumeDirectory(examplesDir, "cx16")) } val filepath = searchIn.asSequence() .map { it.resolve("$source.p8") } .map { it.normalize().absolute() } - .map { Helpers.workingDir.relativize(it) } + .map { workingDir.relativize(it) } .first { it.exists() } val displayName = "${examplesDir.relativize(filepath.absolute())}: ${target.name}, optimize=$optimize" return Pair(displayName, filepath) @@ -57,7 +59,7 @@ private fun prepareTestFiles(source: String, optimize: Boolean, target: ICompila class TestCompilerOnExamplesC64: FunSpec({ - val onlyC64 = Combinations.cartesianProduct( + val onlyC64 = cartesianProduct( listOf( "balloonflight", "bdmusic", @@ -84,7 +86,7 @@ class TestCompilerOnExamplesC64: FunSpec({ class TestCompilerOnExamplesCx16: FunSpec({ - val onlyCx16 = Combinations.cartesianProduct( + val onlyCx16 = cartesianProduct( listOf( "vtui/testvtui", "amiga", @@ -116,7 +118,7 @@ class TestCompilerOnExamplesCx16: FunSpec({ class TestCompilerOnExamplesBothC64andCx16: FunSpec({ - val bothCx16AndC64 = Combinations.cartesianProduct( + val bothCx16AndC64 = cartesianProduct( listOf( "animals", "balls", diff --git a/compiler/test/TestCompilerOnImportsAndIncludes.kt b/compiler/test/TestCompilerOnImportsAndIncludes.kt index d3ec21fc4..353b38cde 100644 --- a/compiler/test/TestCompilerOnImportsAndIncludes.kt +++ b/compiler/test/TestCompilerOnImportsAndIncludes.kt @@ -10,7 +10,7 @@ import prog8.ast.expressions.StringLiteral import prog8.ast.statements.FunctionCallStatement import prog8.ast.statements.Label import prog8.code.target.Cx16Target -import prog8tests.helpers.Helpers +import prog8tests.helpers.* import prog8tests.helpers.compileFile import kotlin.io.path.name @@ -25,11 +25,11 @@ class TestCompilerOnImportsAndIncludes: FunSpec({ context("Import") { test("testImportFromSameFolder") { - val filepath = Helpers.assumeReadableFile(Helpers.fixturesDir, "importFromSameFolder.p8") - Helpers.assumeReadableFile(Helpers.fixturesDir, "foo_bar.p8") + val filepath = assumeReadableFile(fixturesDir, "importFromSameFolder.p8") + assumeReadableFile(fixturesDir, "foo_bar.p8") val platform = Cx16Target() - val result = compileFile(platform, optimize = false, Helpers.fixturesDir, filepath.name)!! + val result = compileFile(platform, optimize = false, fixturesDir, filepath.name)!! val program = result.program val startSub = program.entrypoint @@ -47,11 +47,11 @@ class TestCompilerOnImportsAndIncludes: FunSpec({ context("AsmInclude") { test("testAsmIncludeFromSameFolder") { - val filepath = Helpers.assumeReadableFile(Helpers.fixturesDir, "asmIncludeFromSameFolder.p8") - Helpers.assumeReadableFile(Helpers.fixturesDir, "foo_bar.asm") + val filepath = assumeReadableFile(fixturesDir, "asmIncludeFromSameFolder.p8") + assumeReadableFile(fixturesDir, "foo_bar.asm") val platform = Cx16Target() - val result = compileFile(platform, optimize = false, Helpers.fixturesDir, filepath.name)!! + val result = compileFile(platform, optimize = false, fixturesDir, filepath.name)!! val program = result.program val startSub = program.entrypoint @@ -72,17 +72,17 @@ class TestCompilerOnImportsAndIncludes: FunSpec({ context("Asmbinary") { test("testAsmbinaryDirectiveWithNonExistingFile") { - val p8Path = Helpers.assumeReadableFile(Helpers.fixturesDir, "asmBinaryNonExisting.p8") - Helpers.assumeNotExists(Helpers.fixturesDir, "i_do_not_exist.bin") + val p8Path = assumeReadableFile(fixturesDir, "asmBinaryNonExisting.p8") + assumeNotExists(fixturesDir, "i_do_not_exist.bin") - compileFile(Cx16Target(), false, p8Path.parent, p8Path.name, Helpers.outputDir) shouldBe null + compileFile(Cx16Target(), false, p8Path.parent, p8Path.name, outputDir) shouldBe null } test("testAsmbinaryDirectiveWithNonReadableFile") { - val p8Path = Helpers.assumeReadableFile(Helpers.fixturesDir, "asmBinaryNonReadable.p8") - Helpers.assumeDirectory(Helpers.fixturesDir, "subFolder") + val p8Path = assumeReadableFile(fixturesDir, "asmBinaryNonReadable.p8") + assumeDirectory(fixturesDir, "subFolder") - compileFile(Cx16Target(), false, p8Path.parent, p8Path.name, Helpers.outputDir) shouldBe null + compileFile(Cx16Target(), false, p8Path.parent, p8Path.name, outputDir) shouldBe null } val tests = listOf( @@ -93,18 +93,18 @@ class TestCompilerOnImportsAndIncludes: FunSpec({ tests.forEach { val (where, p8Str, _) = it test("%asmbinary from ${where}folder") { - val p8Path = Helpers.assumeReadableFile(Helpers.fixturesDir, p8Str) - // val binPath = Helpers.assumeReadableFile(Helpers.fixturesDir, binStr) + val p8Path = assumeReadableFile(fixturesDir, p8Str) + // val binPath = assumeReadableFile(fixturesDir, binStr) // the bug we're testing for (#54) was hidden if outputDir == workingDir withClue("sanity check: workingDir and outputDir should not be the same folder") { - Helpers.outputDir.normalize().toAbsolutePath() shouldNotBe Helpers.workingDir.normalize().toAbsolutePath() + outputDir.normalize().toAbsolutePath() shouldNotBe workingDir.normalize().toAbsolutePath() } withClue("argument to assembler directive .binary " + "should be relative to the generated .asm file (in output dir), " + "NOT relative to .p8 neither current working dir") { - compileFile(Cx16Target(), false, p8Path.parent, p8Path.name, Helpers.outputDir) shouldNotBe null + compileFile(Cx16Target(), false, p8Path.parent, p8Path.name, outputDir) shouldNotBe null } } } diff --git a/compiler/test/TestCompilerOnRanges.kt b/compiler/test/TestCompilerOnRanges.kt index 31e3b39d4..f3535d73f 100644 --- a/compiler/test/TestCompilerOnRanges.kt +++ b/compiler/test/TestCompilerOnRanges.kt @@ -17,9 +17,9 @@ import prog8.code.core.Encoding import prog8.code.core.Position import prog8.code.target.C64Target import prog8.code.target.Cx16Target -import prog8tests.helpers.Combinations import prog8tests.helpers.ErrorReporterForTests import prog8tests.helpers.compileText +import prog8tests.helpers.cartesianProduct /** @@ -93,7 +93,7 @@ class TestCompilerOnRanges: FunSpec({ } context("floatArrayInitializerWithRange") { - val combos = Combinations.cartesianProduct( + val combos = cartesianProduct( listOf("", "42", "41"), // sizeInDecl listOf("%import floats", ""), // optEnableFloats listOf(Cx16Target(), C64Target()), // platform diff --git a/compiler/test/TestCompilerOptionLibdirs.kt b/compiler/test/TestCompilerOptionLibdirs.kt index cc9861328..35325912d 100644 --- a/compiler/test/TestCompilerOptionLibdirs.kt +++ b/compiler/test/TestCompilerOptionLibdirs.kt @@ -6,7 +6,10 @@ import prog8.code.target.Cx16Target import prog8.compiler.CompilationResult import prog8.compiler.CompilerArguments import prog8.compiler.compileProgram -import prog8tests.helpers.Helpers +import prog8tests.helpers.assumeReadableFile +import prog8tests.helpers.fixturesDir +import prog8tests.helpers.outputDir +import prog8tests.helpers.workingDir import java.nio.file.Path import kotlin.io.path.absolute import kotlin.io.path.createTempFile @@ -23,7 +26,7 @@ class TestCompilerOptionSourcedirs: FunSpec({ lateinit var tempFileInWorkingDir: Path beforeSpec { - tempFileInWorkingDir = createTempFile(directory = Helpers.workingDir, prefix = "tmp_", suffix = ".p8") + tempFileInWorkingDir = createTempFile(directory = workingDir, prefix = "tmp_", suffix = ".p8") .also { it.writeText(""" main { sub start() { @@ -49,39 +52,39 @@ class TestCompilerOptionSourcedirs: FunSpec({ experimentalCodegen = false, compilationTarget = Cx16Target.NAME, sourceDirs, - Helpers.outputDir + outputDir ) return compileProgram(args) } test("testAbsoluteFilePathInWorkingDir") { - val filepath = Helpers.assumeReadableFile(tempFileInWorkingDir.absolute()) + val filepath = assumeReadableFile(tempFileInWorkingDir.absolute()) compileFile(filepath, listOf()) shouldNotBe null } test("testFilePathInWorkingDirRelativeToWorkingDir") { - val filepath = Helpers.assumeReadableFile(Helpers.workingDir.relativize(tempFileInWorkingDir.absolute())) + val filepath = assumeReadableFile(workingDir.relativize(tempFileInWorkingDir.absolute())) compileFile(filepath, listOf()) shouldNotBe null } test("testFilePathInWorkingDirRelativeTo1stInSourcedirs") { - val filepath = Helpers.assumeReadableFile(tempFileInWorkingDir) - compileFile(filepath.fileName, listOf(Helpers.workingDir.toString())) shouldNotBe null + val filepath = assumeReadableFile(tempFileInWorkingDir) + compileFile(filepath.fileName, listOf(workingDir.toString())) shouldNotBe null } test("testAbsoluteFilePathOutsideWorkingDir") { - val filepath = Helpers.assumeReadableFile(Helpers.fixturesDir, "ast_simple_main.p8") + val filepath = assumeReadableFile(fixturesDir, "ast_simple_main.p8") compileFile(filepath.absolute(), listOf()) shouldNotBe null } test("testFilePathOutsideWorkingDirRelativeToWorkingDir") { - val filepath = Helpers.workingDir.relativize(Helpers.assumeReadableFile(Helpers.fixturesDir, "ast_simple_main.p8").absolute()) + val filepath = workingDir.relativize(assumeReadableFile(fixturesDir, "ast_simple_main.p8").absolute()) compileFile(filepath, listOf()) shouldNotBe null } test("testFilePathOutsideWorkingDirRelativeTo1stInSourcedirs") { - val filepath = Helpers.assumeReadableFile(Helpers.fixturesDir, "ast_simple_main.p8") - val sourcedirs = listOf("${Helpers.fixturesDir}") + val filepath = assumeReadableFile(fixturesDir, "ast_simple_main.p8") + val sourcedirs = listOf("${fixturesDir}") compileFile(filepath.fileName, sourcedirs) shouldNotBe null } diff --git a/compiler/test/TestImportedModulesOrderAndOptions.kt b/compiler/test/TestImportedModulesOrderAndOptions.kt index 078a79baa..b3167a330 100644 --- a/compiler/test/TestImportedModulesOrderAndOptions.kt +++ b/compiler/test/TestImportedModulesOrderAndOptions.kt @@ -10,8 +10,8 @@ import prog8.code.target.C64Target import prog8.compiler.determineCompilationOptions import prog8.compiler.parseImports import prog8tests.helpers.ErrorReporterForTests -import prog8tests.helpers.Helpers import prog8tests.helpers.compileText +import prog8tests.helpers.outputDir class TestImportedModulesOrderAndOptions: FunSpec({ @@ -85,7 +85,7 @@ main { } """ val filenameBase = "on_the_fly_test_" + sourceText.hashCode().toUInt().toString(16) - val filepath = Helpers.outputDir.resolve("$filenameBase.p8") + val filepath = outputDir.resolve("$filenameBase.p8") filepath.toFile().writeText(sourceText) val (program, options, importedfiles) = parseImports(filepath, errors, C64Target(), emptyList()) diff --git a/compiler/test/TestOptimization.kt b/compiler/test/TestOptimization.kt index 40eae2453..5bdfbb3f1 100644 --- a/compiler/test/TestOptimization.kt +++ b/compiler/test/TestOptimization.kt @@ -299,7 +299,7 @@ class TestOptimization: FunSpec({ floats = false, noSysInit = true, compTarget = C64Target(), - loadAddress = 0u, outputDir= Helpers.outputDir) + loadAddress = 0u, outputDir= outputDir) result.program.processAstBeforeAsmGeneration(options, ErrorReporterForTests()) // assignment is now split into: diff --git a/compiler/test/ast/TestProg8Parser.kt b/compiler/test/ast/TestProg8Parser.kt index 54b34b69b..4a19a563d 100644 --- a/compiler/test/ast/TestProg8Parser.kt +++ b/compiler/test/ast/TestProg8Parser.kt @@ -23,6 +23,8 @@ import prog8.code.target.cbm.PetsciiEncoding import prog8.parser.ParseError import prog8.parser.Prog8Parser.parseModule import prog8tests.helpers.* +import prog8tests.helpers.DummyFunctions +import prog8tests.helpers.DummyMemsizer import kotlin.io.path.Path import kotlin.io.path.isRegularFile import kotlin.io.path.name @@ -173,8 +175,8 @@ class TestProg8Parser: FunSpec( { context("ImportDirectives") { test("should not be looked into by the parser") { - val importedNoExt = Helpers.assumeNotExists(Helpers.fixturesDir, "i_do_not_exist") - Helpers.assumeNotExists(Helpers.fixturesDir, "i_do_not_exist.p8") + val importedNoExt = assumeNotExists(fixturesDir, "i_do_not_exist") + assumeNotExists(fixturesDir, "i_do_not_exist.p8") val text = "%import ${importedNoExt.name}" val module = parseModule(SourceCode.Text(text)) @@ -189,7 +191,7 @@ class TestProg8Parser: FunSpec( { } test("from an empty file should result in empty Module") { - val path = Helpers.assumeReadableFile(Helpers.fixturesDir, "ast_empty.p8") + val path = assumeReadableFile(fixturesDir, "ast_empty.p8") val module = parseModule(SourceCode.File(path)) module.statements.size shouldBe 0 } @@ -208,7 +210,7 @@ class TestProg8Parser: FunSpec( { } test("parsed from a file") { - val path = Helpers.assumeReadableFile(Helpers.fixturesDir, "ast_simple_main.p8") + val path = assumeReadableFile(fixturesDir, "ast_simple_main.p8") val module = parseModule(SourceCode.File(path)) module.name shouldBe path.nameWithoutExtension } @@ -271,7 +273,7 @@ class TestProg8Parser: FunSpec( { } test("in ParseError from bad file source code") { - val path = Helpers.assumeReadableFile(Helpers.fixturesDir, "ast_file_with_syntax_error.p8") + val path = assumeReadableFile(fixturesDir, "ast_file_with_syntax_error.p8") val e = shouldThrow { parseModule(SourceCode.File(path)) } assertPosition(e.position, SourceCode.relative(path).toString(), 2, 6) @@ -287,13 +289,13 @@ class TestProg8Parser: FunSpec( { } test("of Module parsed from a file") { - val path = Helpers.assumeReadableFile(Helpers.fixturesDir, "ast_simple_main.p8") + val path = assumeReadableFile(fixturesDir, "ast_simple_main.p8") val module = parseModule(SourceCode.File(path)) assertPositionOf(module, SourceCode.relative(path).toString(), 1, 0) } test("of non-root Nodes parsed from file") { - val path = Helpers.assumeReadableFile(Helpers.fixturesDir, "ast_simple_main.p8") + val path = assumeReadableFile(fixturesDir, "ast_simple_main.p8") val module = parseModule(SourceCode.File(path)) val mpf = module.position.file @@ -357,7 +359,7 @@ class TestProg8Parser: FunSpec( { } test("isn't absolute for filesystem paths") { - val path = Helpers.assumeReadableFile(Helpers.fixturesDir, "ast_simple_main.p8") + val path = assumeReadableFile(fixturesDir, "ast_simple_main.p8") val module = parseModule(SourceCode.File(path)) assertSomethingForAllNodes(module) { Path(it.position.file).isAbsolute shouldBe false diff --git a/compiler/test/ast/TestSourceCode.kt b/compiler/test/ast/TestSourceCode.kt index 8bb3e9abe..ee9d04cfc 100644 --- a/compiler/test/ast/TestSourceCode.kt +++ b/compiler/test/ast/TestSourceCode.kt @@ -6,7 +6,10 @@ import io.kotest.matchers.shouldBe import io.kotest.matchers.string.shouldContain import prog8.code.core.SourceCode import prog8.code.core.SourceCode.Companion.libraryFilePrefix -import prog8tests.helpers.Helpers +import prog8tests.helpers.assumeNotExists +import prog8tests.helpers.assumeReadableFile +import prog8tests.helpers.fixturesDir +import prog8tests.helpers.resourcesDir import kotlin.io.path.Path @@ -29,26 +32,26 @@ class TestSourceCode: AnnotationSpec() { @Test fun testFromPathWithNonExistingPath() { val filename = "i_do_not_exist.p8" - val path = Helpers.assumeNotExists(Helpers.fixturesDir, filename) + val path = assumeNotExists(fixturesDir, filename) shouldThrow { SourceCode.File(path) } } @Test fun testFromPathWithMissingExtension_p8() { - val pathWithoutExt = Helpers.assumeNotExists(Helpers.fixturesDir,"simple_main") - Helpers.assumeReadableFile(Helpers.fixturesDir,"ast_simple_main.p8") + val pathWithoutExt = assumeNotExists(fixturesDir,"simple_main") + assumeReadableFile(fixturesDir,"ast_simple_main.p8") shouldThrow { SourceCode.File(pathWithoutExt) } } @Test fun testFromPathWithDirectory() { - shouldThrow { SourceCode.File(Helpers.fixturesDir) } + shouldThrow { SourceCode.File(fixturesDir) } } @Test fun testFromPathWithExistingPath() { val filename = "ast_simple_main.p8" - val path = Helpers.assumeReadableFile(Helpers.fixturesDir, filename) + val path = assumeReadableFile(fixturesDir, filename) val src = SourceCode.File(path) val expectedOrigin = SourceCode.relative(path).toString() src.origin shouldBe expectedOrigin @@ -61,7 +64,7 @@ class TestSourceCode: AnnotationSpec() { fun testFromPathWithExistingNonNormalizedPath() { val filename = "ast_simple_main.p8" val path = Path(".", "test", "..", "test", "fixtures", filename) - val srcFile = Helpers.assumeReadableFile(path).toFile() + val srcFile = assumeReadableFile(path).toFile() val src = SourceCode.File(path) val expectedOrigin = SourceCode.relative(path).toString() src.origin shouldBe expectedOrigin @@ -71,7 +74,7 @@ class TestSourceCode: AnnotationSpec() { @Test fun testFromResourcesWithExistingP8File_withoutLeadingSlash() { val pathString = "prog8lib/math.p8" - val srcFile = Helpers.assumeReadableFile(Helpers.resourcesDir, pathString).toFile() + val srcFile = assumeReadableFile(resourcesDir, pathString).toFile() val src = SourceCode.Resource(pathString) src.origin shouldBe "$libraryFilePrefix/$pathString" @@ -83,7 +86,7 @@ class TestSourceCode: AnnotationSpec() { @Test fun testFromResourcesWithExistingP8File_withLeadingSlash() { val pathString = "/prog8lib/math.p8" - val srcFile = Helpers.assumeReadableFile(Helpers.resourcesDir, pathString.substring(1)).toFile() + val srcFile = assumeReadableFile(resourcesDir, pathString.substring(1)).toFile() val src = SourceCode.Resource(pathString) src.origin shouldBe "$libraryFilePrefix$pathString" @@ -93,7 +96,7 @@ class TestSourceCode: AnnotationSpec() { @Test fun testFromResourcesWithExistingAsmFile_withoutLeadingSlash() { val pathString = "prog8lib/math.asm" - val srcFile = Helpers.assumeReadableFile(Helpers.resourcesDir, pathString).toFile() + val srcFile = assumeReadableFile(resourcesDir, pathString).toFile() val src = SourceCode.Resource(pathString) src.origin shouldBe "$libraryFilePrefix/$pathString" @@ -104,7 +107,7 @@ class TestSourceCode: AnnotationSpec() { @Test fun testFromResourcesWithExistingAsmFile_withLeadingSlash() { val pathString = "/prog8lib/math.asm" - val srcFile = Helpers.assumeReadableFile(Helpers.resourcesDir, pathString.substring(1)).toFile() + val srcFile = assumeReadableFile(resourcesDir, pathString.substring(1)).toFile() val src = SourceCode.Resource(pathString) src.origin shouldBe "$libraryFilePrefix$pathString" @@ -114,7 +117,7 @@ class TestSourceCode: AnnotationSpec() { @Test fun testFromResourcesWithNonNormalizedPath() { val pathString = "/prog8lib/../prog8lib/math.p8" - val srcFile = Helpers.assumeReadableFile(Helpers.resourcesDir, pathString.substring(1)).toFile() + val srcFile = assumeReadableFile(resourcesDir, pathString.substring(1)).toFile() val src = SourceCode.Resource(pathString) src.origin shouldBe "$libraryFilePrefix/prog8lib/math.p8" @@ -126,14 +129,14 @@ class TestSourceCode: AnnotationSpec() { @Test fun testFromResourcesWithNonExistingFile_withLeadingSlash() { val pathString = "/prog8lib/i_do_not_exist" - Helpers.assumeNotExists(Helpers.resourcesDir, pathString.substring(1)) + assumeNotExists(resourcesDir, pathString.substring(1)) shouldThrow { SourceCode.Resource(pathString) } } @Test fun testFromResourcesWithNonExistingFile_withoutLeadingSlash() { val pathString = "prog8lib/i_do_not_exist" - Helpers.assumeNotExists(Helpers.resourcesDir, pathString) + assumeNotExists(resourcesDir, pathString) shouldThrow { SourceCode.Resource(pathString) } } diff --git a/compiler/test/helpers/compileXyz.kt b/compiler/test/helpers/compileXyz.kt index 6d0f24139..c2bb6efd1 100644 --- a/compiler/test/helpers/compileXyz.kt +++ b/compiler/test/helpers/compileXyz.kt @@ -19,13 +19,13 @@ internal fun compileFile( optimize: Boolean, fileDir: Path, fileName: String, - outputDir: Path = prog8tests.helpers.Helpers.outputDir, + outputDir: Path = prog8tests.helpers.outputDir, errors: IErrorReporter? = null, writeAssembly: Boolean = true, optFloatExpr: Boolean = true ) : CompilationResult? { val filepath = fileDir.resolve(fileName) - Helpers.assumeReadableFile(filepath) + assumeReadableFile(filepath) val args = CompilerArguments( filepath, optimize, @@ -56,7 +56,7 @@ internal fun compileText( writeAssembly: Boolean = true, optFloatExpr: Boolean = true ) : CompilationResult? { - val filePath = Helpers.outputDir.resolve("on_the_fly_test_" + sourceText.hashCode().toUInt().toString(16) + ".p8") + val filePath = outputDir.resolve("on_the_fly_test_" + sourceText.hashCode().toUInt().toString(16) + ".p8") // we don't assumeNotExists(filePath) - should be ok to just overwrite it filePath.toFile().writeText(sourceText) return compileFile(platform, optimize, filePath.parent, filePath.name, errors=errors, writeAssembly=writeAssembly, optFloatExpr = optFloatExpr) @@ -71,7 +71,7 @@ internal fun generateAssembly( floats = true, noSysInit = true, compTarget = C64Target(), - loadAddress = 0u, outputDir = Helpers.outputDir) + loadAddress = 0u, outputDir = outputDir) coptions.compTarget.machine.zeropage = C64Zeropage(coptions) val st = SymbolTableMaker().makeFrom(program) val errors = ErrorReporterForTests() diff --git a/compiler/test/helpers/mapCombinations.kt b/compiler/test/helpers/mapCombinations.kt index cccfaabaa..3342a9905 100644 --- a/compiler/test/helpers/mapCombinations.kt +++ b/compiler/test/helpers/mapCombinations.kt @@ -1,68 +1,66 @@ package prog8tests.helpers -object Combinations { - fun cartesianProduct(c1: Collection, c2: Collection): Sequence> { - return c1.flatMap { lhsElem -> c2.map { rhsElem -> lhsElem to rhsElem } }.asSequence() +fun cartesianProduct(c1: Collection, c2: Collection): Sequence> { + return c1.flatMap { lhsElem -> c2.map { rhsElem -> lhsElem to rhsElem } }.asSequence() +} + +fun cartesianProduct(c1: Collection, c2: Collection, c3: Collection): Sequence> { + return sequence { + for (a in c1) + for (b in c2) + for (c in c3) + yield(Triple(a, b, c)) } +} - fun cartesianProduct(c1: Collection, c2: Collection, c3: Collection): Sequence> { - return sequence { - for (a in c1) - for (b in c2) - for (c in c3) - yield(Triple(a, b, c)) - } +data class Product(val first: T, val second: U, val third: V, val fourth: W) + +fun cartesianProduct( + c1: Collection, + c2: Collection, + c3: Collection, + c4: Collection +): Sequence> { + return sequence { + for (a in c1) + for (b in c2) + for (c in c3) + for (d in c4) + yield(Product(a, b, c, d)) } +} - data class Product(val first: T, val second: U, val third: V, val fourth: W) +fun mapCombinations(dim1: Iterable, dim2: Iterable, combine2: (A, B) -> R) = + sequence { + for (a in dim1) + for (b in dim2) + yield(combine2(a, b)) + }.toList() - fun cartesianProduct( - c1: Collection, - c2: Collection, - c3: Collection, - c4: Collection - ): Sequence> { - return sequence { - for (a in c1) - for (b in c2) - for (c in c3) - for (d in c4) - yield(Product(a, b, c, d)) - } - } +fun mapCombinations( + dim1: Iterable, + dim2: Iterable, + dim3: Iterable, + combine3: (A, B, C) -> R +) = + sequence { + for (a in dim1) + for (b in dim2) + for (c in dim3) + yield(combine3(a, b, c)) + }.toList() - fun mapCombinations(dim1: Iterable, dim2: Iterable, combine2: (A, B) -> R) = - sequence { - for (a in dim1) - for (b in dim2) - yield(combine2(a, b)) - }.toList() - - fun mapCombinations( - dim1: Iterable, - dim2: Iterable, - dim3: Iterable, - combine3: (A, B, C) -> R - ) = - sequence { - for (a in dim1) - for (b in dim2) - for (c in dim3) - yield(combine3(a, b, c)) - }.toList() - - fun mapCombinations( - dim1: Iterable, - dim2: Iterable, - dim3: Iterable, - dim4: Iterable, - combine4: (A, B, C, D) -> R - ) = - sequence { - for (a in dim1) - for (b in dim2) - for (c in dim3) - for (d in dim4) - yield(combine4(a, b, c, d)) - }.toList() -} \ No newline at end of file +fun mapCombinations( + dim1: Iterable, + dim2: Iterable, + dim3: Iterable, + dim4: Iterable, + combine4: (A, B, C, D) -> R +) = + sequence { + for (a in dim1) + for (b in dim2) + for (c in dim3) + for (d in dim4) + yield(combine4(a, b, c, d)) + }.toList() diff --git a/compiler/test/helpers/paths.kt b/compiler/test/helpers/paths.kt index 74b77eed4..bafa41232 100644 --- a/compiler/test/helpers/paths.kt +++ b/compiler/test/helpers/paths.kt @@ -7,69 +7,66 @@ import java.nio.file.Path import kotlin.io.path.* -object Helpers { - val workingDir = assumeDirectory("").absolute() // Note: "." does NOT work..! - val fixturesDir = assumeDirectory(workingDir, "test/fixtures") - val resourcesDir = assumeDirectory(workingDir, "res") - val outputDir: Path = - createIfNotExists(workingDir, "build/tmp/test").also { assumeDirectory(workingDir, "build/tmp/test") } +val workingDir = assumeDirectory("").absolute() // Note: "." does NOT work..! +val fixturesDir = assumeDirectory(workingDir, "test/fixtures") +val resourcesDir = assumeDirectory(workingDir, "res") +val outputDir: Path = + createIfNotExists(workingDir, "build/tmp/test").also { assumeDirectory(workingDir, "build/tmp/test") } - fun createIfNotExists(workingDir: Path, path: String): Path { - val dir = workingDir / path - if (!dir.toFile().isDirectory) - Files.createDirectories(dir) - return dir +fun createIfNotExists(workingDir: Path, path: String): Path { + val dir = workingDir / path + if (!dir.toFile().isDirectory) + Files.createDirectories(dir) + return dir +} + +fun assumeNotExists(path: Path): Path { + withClue("sanity check: should not exist: ${path.absolute()}") { + path.exists() shouldBe false } + return path +} - fun assumeNotExists(path: Path): Path { - withClue("sanity check: should not exist: ${path.absolute()}") { - path.exists() shouldBe false - } - return path +fun assumeNotExists(pathStr: String): Path = assumeNotExists(Path(pathStr)) +fun assumeNotExists(path: Path, other: String): Path = assumeNotExists(path / other) + +fun assumeReadable(path: Path): Path { + withClue("sanity check: should be readable: ${path.absolute()}") { + path.isReadable() shouldBe true } + return path +} - fun assumeNotExists(pathStr: String): Path = assumeNotExists(Path(pathStr)) - fun assumeNotExists(path: Path, other: String): Path = assumeNotExists(path / other) - - fun assumeReadable(path: Path): Path { - withClue("sanity check: should be readable: ${path.absolute()}") { - path.isReadable() shouldBe true - } - return path +fun assumeReadableFile(path: Path): Path { + withClue("sanity check: should be normal file: ${path.absolute()}") { + path.isRegularFile() shouldBe true } + return assumeReadable(path) +} - fun assumeReadableFile(path: Path): Path { - withClue("sanity check: should be normal file: ${path.absolute()}") { - path.isRegularFile() shouldBe true - } - return assumeReadable(path) +fun assumeReadableFile(pathStr: String): Path = assumeReadableFile(Path(pathStr)) +fun assumeReadableFile(pathStr: String, other: Path): Path = assumeReadableFile(Path(pathStr), other) +fun assumeReadableFile(pathStr: String, other: String): Path = assumeReadableFile(Path(pathStr), other) +fun assumeReadableFile(path: Path, other: String): Path = assumeReadableFile(path / other) +fun assumeReadableFile(path: Path, other: Path): Path = assumeReadableFile(path / other) + +fun assumeDirectory(path: Path): Path { + withClue("sanity check; should be directory: $path") { + path.isDirectory() shouldBe true } + return path +} - fun assumeReadableFile(pathStr: String): Path = assumeReadableFile(Path(pathStr)) - fun assumeReadableFile(pathStr: String, other: Path): Path = assumeReadableFile(Path(pathStr), other) - fun assumeReadableFile(pathStr: String, other: String): Path = assumeReadableFile(Path(pathStr), other) - fun assumeReadableFile(path: Path, other: String): Path = assumeReadableFile(path / other) - fun assumeReadableFile(path: Path, other: Path): Path = assumeReadableFile(path / other) - - fun assumeDirectory(path: Path): Path { - withClue("sanity check; should be directory: $path") { - path.isDirectory() shouldBe true - } - return path - } - - fun assumeDirectory(pathStr: String): Path = assumeDirectory(Path(pathStr)) - fun assumeDirectory(path: Path, other: String): Path = assumeDirectory(path / other) - fun assumeDirectory(pathStr: String, other: String): Path = assumeDirectory(Path(pathStr) / other) - fun assumeDirectory(pathStr: String, other: Path): Path = assumeDirectory(Path(pathStr) / other) +fun assumeDirectory(pathStr: String): Path = assumeDirectory(Path(pathStr)) +fun assumeDirectory(path: Path, other: String): Path = assumeDirectory(path / other) +fun assumeDirectory(pathStr: String, other: String): Path = assumeDirectory(Path(pathStr) / other) +fun assumeDirectory(pathStr: String, other: Path): Path = assumeDirectory(Path(pathStr) / other) - @Deprecated( - "Directories are checked automatically at init.", - ReplaceWith("/* nothing */") - ) - @Suppress("UNUSED_PARAMETER") - fun sanityCheckDirectories(workingDirName: String? = null) { - } - -} \ No newline at end of file +@Deprecated( + "Directories are checked automatically at init.", + ReplaceWith("/* nothing */") +) +@Suppress("UNUSED_PARAMETER") +fun sanityCheckDirectories(workingDirName: String? = null) { +} diff --git a/compiler/test/helpers_pathsTests.kt b/compiler/test/helpers_pathsTests.kt index 7dee6aeef..46964b5c4 100644 --- a/compiler/test/helpers_pathsTests.kt +++ b/compiler/test/helpers_pathsTests.kt @@ -4,7 +4,7 @@ import io.kotest.assertions.throwables.shouldThrow import io.kotest.assertions.withClue import io.kotest.core.spec.style.FunSpec import io.kotest.matchers.shouldBe -import prog8tests.helpers.Helpers +import prog8tests.helpers.* import kotlin.io.path.Path import kotlin.io.path.div @@ -20,21 +20,21 @@ class PathsHelpersTests: FunSpec({ context("WithOnePathArg") { test("on non-existing path") { - val path = Helpers.fixturesDir / "i_do_not_exist" + val path = fixturesDir / "i_do_not_exist" withClue("should return the path") { - Helpers.assumeNotExists(path) shouldBe path + assumeNotExists(path) shouldBe path } } test("on existing file") { shouldThrow { - Helpers.assumeNotExists(Helpers.fixturesDir / "ast_simple_main.p8") + assumeNotExists(fixturesDir / "ast_simple_main.p8") } } test("on existing directory") { shouldThrow { - Helpers.assumeNotExists(Helpers.fixturesDir) + assumeNotExists(fixturesDir) } } } @@ -42,22 +42,22 @@ class PathsHelpersTests: FunSpec({ context("WithOneStringArg") { test("on non-existing path") { - val path = Helpers.fixturesDir / "i_do_not_exist" + val path = fixturesDir / "i_do_not_exist" withClue("should return the path") { - Helpers.assumeNotExists("$path") shouldBe path + assumeNotExists("$path") shouldBe path } } test("on existing file") { - val path = Helpers.fixturesDir / "ast_simple_main.p8" + val path = fixturesDir / "ast_simple_main.p8" shouldThrow { - Helpers.assumeNotExists("$path") + assumeNotExists("$path") } } test("on existing directory") { shouldThrow { - Helpers.assumeNotExists("${Helpers.fixturesDir}") + assumeNotExists("${fixturesDir}") } } } @@ -65,21 +65,21 @@ class PathsHelpersTests: FunSpec({ context("WithPathAndStringArgs") { test("on non-existing path") { - val path = Helpers.fixturesDir / "i_do_not_exist" + val path = fixturesDir / "i_do_not_exist" withClue("should return the path") { - Helpers.assumeNotExists(Helpers.fixturesDir / "i_do_not_exist") shouldBe path + assumeNotExists(fixturesDir / "i_do_not_exist") shouldBe path } } test("on existing file") { shouldThrow { - Helpers.assumeNotExists(Helpers.fixturesDir, "ast_simple_main.p8") + assumeNotExists(fixturesDir, "ast_simple_main.p8") } } test("on existing directory") { shouldThrow { - Helpers.assumeNotExists(Helpers.fixturesDir, "..") + assumeNotExists(fixturesDir, "..") } } } @@ -89,46 +89,46 @@ class PathsHelpersTests: FunSpec({ context("WithOnePathArg") { test("on non-existing path") { - val path = Helpers.fixturesDir / "i_do_not_exist" + val path = fixturesDir / "i_do_not_exist" shouldThrow { - Helpers.assumeDirectory(path) + assumeDirectory(path) } } test("on existing file") { - val path = Helpers.fixturesDir / "ast_simple_main.p8" + val path = fixturesDir / "ast_simple_main.p8" shouldThrow { - Helpers.assumeDirectory(path) + assumeDirectory(path) } } test("on existing directory") { - val path = Helpers.workingDir + val path = workingDir withClue("should return the path") { - Helpers.assumeDirectory(path) shouldBe path + assumeDirectory(path) shouldBe path } } } context("WithOneStringArg") { test("on non-existing path") { - val path = Helpers.fixturesDir / "i_do_not_exist" + val path = fixturesDir / "i_do_not_exist" shouldThrow { - Helpers.assumeDirectory("$path") + assumeDirectory("$path") } } test("on existing file") { - val path = Helpers.fixturesDir / "ast_simple_main.p8" + val path = fixturesDir / "ast_simple_main.p8" shouldThrow { - Helpers.assumeDirectory("$path") + assumeDirectory("$path") } } test("on existing directory") { - val path = Helpers.workingDir + val path = workingDir withClue("should return the path") { - Helpers.assumeDirectory("$path") shouldBe path + assumeDirectory("$path") shouldBe path } } } @@ -136,20 +136,20 @@ class PathsHelpersTests: FunSpec({ context("WithPathAndStringArgs") { test("on non-existing path") { shouldThrow { - Helpers.assumeDirectory(Helpers.fixturesDir, "i_do_not_exist") + assumeDirectory(fixturesDir, "i_do_not_exist") } } test("on existing file") { shouldThrow { - Helpers.assumeDirectory(Helpers.fixturesDir, "ast_simple_main.p8") + assumeDirectory(fixturesDir, "ast_simple_main.p8") } } test("on existing directory") { - val path = Helpers.workingDir / ".." + val path = workingDir / ".." withClue("should return resulting path") { - Helpers.assumeDirectory(Helpers.workingDir / "..") shouldBe path + assumeDirectory(workingDir / "..") shouldBe path } } } @@ -157,20 +157,20 @@ class PathsHelpersTests: FunSpec({ context("WithStringAndStringArgs") { test("on non-existing path") { shouldThrow { - Helpers.assumeDirectory("${Helpers.fixturesDir}", "i_do_not_exist") + assumeDirectory("${fixturesDir}", "i_do_not_exist") } } test("on existing file") { shouldThrow { - Helpers.assumeDirectory("${Helpers.fixturesDir}", "ast_simple_main.p8") + assumeDirectory("${fixturesDir}", "ast_simple_main.p8") } } test("on existing directory") { - val path = Helpers.workingDir / ".." + val path = workingDir / ".." withClue("should return resulting path") { - Helpers.assumeDirectory(Helpers.workingDir / "..") shouldBe path + assumeDirectory(workingDir / "..") shouldBe path } } } @@ -178,20 +178,20 @@ class PathsHelpersTests: FunSpec({ context("WithStringAndPathArgs") { test("on non-existing path") { shouldThrow { - Helpers.assumeDirectory("${Helpers.fixturesDir}", Path("i_do_not_exist")) + assumeDirectory("${fixturesDir}", Path("i_do_not_exist")) } } test("on existing file") { shouldThrow { - Helpers.assumeDirectory("${Helpers.fixturesDir}", Path("ast_simple_main.p8")) + assumeDirectory("${fixturesDir}", Path("ast_simple_main.p8")) } } test("on existing directory") { - val path = Helpers.workingDir / ".." + val path = workingDir / ".." withClue("should return resulting path") { - Helpers.assumeDirectory(Helpers.workingDir / Path("..")) shouldBe path + assumeDirectory(workingDir / Path("..")) shouldBe path } } } @@ -202,22 +202,22 @@ class PathsHelpersTests: FunSpec({ context("WithOnePathArg") { test("on non-existing path") { - val path = Helpers.fixturesDir / "i_do_not_exist" + val path = fixturesDir / "i_do_not_exist" shouldThrow { - Helpers.assumeReadableFile(path) + assumeReadableFile(path) } } test("on readable file") { - val path = Helpers.fixturesDir / "ast_simple_main.p8" + val path = fixturesDir / "ast_simple_main.p8" withClue("should return the path") { - Helpers.assumeReadableFile(path) shouldBe path + assumeReadableFile(path) shouldBe path } } test("on directory") { shouldThrow { - Helpers.assumeReadableFile(Helpers.fixturesDir) + assumeReadableFile(fixturesDir) } } } @@ -225,22 +225,22 @@ class PathsHelpersTests: FunSpec({ context("WithOneStringArg") { test("on non-existing path") { - val path = Helpers.fixturesDir / "i_do_not_exist" + val path = fixturesDir / "i_do_not_exist" shouldThrow { - Helpers.assumeReadableFile("$path") + assumeReadableFile("$path") } } test("on readable file") { - val path = Helpers.fixturesDir / "ast_simple_main.p8" + val path = fixturesDir / "ast_simple_main.p8" withClue("should return the resulting path") { - Helpers.assumeReadableFile("$path") shouldBe path + assumeReadableFile("$path") shouldBe path } } test("on directory") { shouldThrow { - Helpers.assumeReadableFile("${Helpers.fixturesDir}") + assumeReadableFile("${fixturesDir}") } } } @@ -248,20 +248,20 @@ class PathsHelpersTests: FunSpec({ context("WithPathAndStringArgs") { test("on non-existing path") { shouldThrow { - Helpers.assumeReadableFile(Helpers.fixturesDir, "i_do_not_exist") + assumeReadableFile(fixturesDir, "i_do_not_exist") } } test("on readable file") { - val path = Helpers.fixturesDir / "ast_simple_main.p8" + val path = fixturesDir / "ast_simple_main.p8" withClue("should return the resulting path") { - Helpers.assumeReadableFile(Helpers.fixturesDir / "ast_simple_main.p8") shouldBe path + assumeReadableFile(fixturesDir / "ast_simple_main.p8") shouldBe path } } test("on directory") { shouldThrow { - Helpers.assumeReadableFile(Helpers.fixturesDir, "..") + assumeReadableFile(fixturesDir, "..") } } } @@ -269,19 +269,19 @@ class PathsHelpersTests: FunSpec({ context("WithPathAndPathArgs") { test("on non-existing path") { shouldThrow { - Helpers.assumeReadableFile(Helpers.fixturesDir, Path("i_do_not_exist")) + assumeReadableFile(fixturesDir, Path("i_do_not_exist")) } } test("on readable file") { withClue("should return the resulting path") { - Helpers.assumeReadableFile(Helpers.fixturesDir / Path("ast_simple_main.p8")) shouldBe Helpers.fixturesDir / "ast_simple_main.p8" + assumeReadableFile(fixturesDir / Path("ast_simple_main.p8")) shouldBe fixturesDir / "ast_simple_main.p8" } } test("on directory") { shouldThrow { - Helpers.assumeReadableFile(Helpers.fixturesDir, Path("..")) + assumeReadableFile(fixturesDir, Path("..")) } } } @@ -289,19 +289,19 @@ class PathsHelpersTests: FunSpec({ context("WithStringAndStringArgs") { test("on non-existing path") { shouldThrow { - Helpers.assumeReadableFile("${Helpers.fixturesDir}", "i_do_not_exist") + assumeReadableFile("${fixturesDir}", "i_do_not_exist") } } test("on readable file") { withClue("should return the resulting path") { - Helpers.assumeReadableFile(Helpers.fixturesDir / "ast_simple_main.p8") shouldBe Helpers.fixturesDir / "ast_simple_main.p8" + assumeReadableFile(fixturesDir / "ast_simple_main.p8") shouldBe fixturesDir / "ast_simple_main.p8" } } test("on directory") { shouldThrow { - Helpers.assumeReadableFile("${Helpers.fixturesDir}", "..") + assumeReadableFile("${fixturesDir}", "..") } } } diff --git a/virtualmachine/build.gradle b/virtualmachine/build.gradle index 1b111d9d8..e2a815a6b 100644 --- a/virtualmachine/build.gradle +++ b/virtualmachine/build.gradle @@ -28,7 +28,7 @@ dependencies { implementation project(':codeCore') implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk8" implementation "com.michael-bull.kotlin-result:kotlin-result-jvm:1.1.16" - testImplementation 'io.kotest:kotest-runner-junit5-jvm:5.2.3' + testImplementation 'io.kotest:kotest-runner-junit5-jvm:5.3.2' } sourceSets {