mirror of
https://github.com/irmen/prog8.git
synced 2025-01-10 20:30:23 +00:00
* some more housekeeping re tests: gradle doesn't like .* imports for annotations, added @Disabled comments, made warnings go away
This commit is contained in:
parent
5e194536a8
commit
c80a15846d
@ -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.*
|
||||
|
@ -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)
|
||||
|
@ -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.*
|
||||
|
||||
|
@ -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")
|
||||
|
@ -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
|
||||
|
||||
|
||||
/**
|
||||
|
@ -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 {
|
||||
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
@ -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)
|
||||
|
@ -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<String, Module> {
|
||||
private fun roundTrip(module: Module): Pair<String, Module> {
|
||||
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")
|
||||
}
|
||||
|
@ -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
|
||||
|
@ -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..?
|
||||
|
@ -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<NoSuchFileException> { 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<AccessDeniedException> { SourceCode.fromResources(pathString) }
|
||||
|
Loading…
x
Reference in New Issue
Block a user