prog8/compiler/test/codegeneration/TestVariables.kt

68 lines
1.8 KiB
Kotlin
Raw Normal View History

package prog8tests.codegeneration
import io.kotest.core.spec.style.FunSpec
2022-03-07 20:41:12 +00:00
import io.kotest.matchers.shouldNotBe
2022-03-11 19:35:25 +00:00
import prog8.code.target.C64Target
import prog8tests.helpers.compileText
class TestVariables: FunSpec({
test("shared variables without refs not removed for inlined asm") {
val text = """
main {
sub start() {
ubyte[] @shared arrayvar = [1,2,3,4]
str @shared stringvar = "test"
ubyte @shared bytevar = 0
%asm {{
lda arrayvar
lda stringvar
lda bytevar
}}
}
}
"""
2022-03-07 20:41:12 +00:00
compileText(C64Target(), true, text, writeAssembly = true) shouldNotBe null
}
test("array initialization with array literal") {
val text = """
main {
sub start() {
ubyte[] @shared arrayvar = [1,2,3,4]
}
}
"""
2022-03-07 20:41:12 +00:00
compileText(C64Target(), true, text, writeAssembly = true) shouldNotBe null
}
test("array initialization with array var assignment") {
val text = """
main {
sub start() {
ubyte[3] @shared arrayvar = main.values
}
ubyte[] values = [1,2,3]
}
"""
2022-03-07 20:41:12 +00:00
compileText(C64Target(), false, text, writeAssembly = true) shouldNotBe null
}
test("pipe character in string literal") {
val text = """
main {
sub start() {
str name = "first|second"
str name2 = "first | second"
}
}
"""
compileText(C64Target(), false, text, writeAssembly = true) shouldNotBe null
}
})