2021-06-01 19:21:33 +00:00
|
|
|
package prog8tests
|
|
|
|
|
2021-10-13 21:22:46 +00:00
|
|
|
import com.github.michaelbull.result.Ok
|
2021-10-20 21:48:20 +00:00
|
|
|
import com.github.michaelbull.result.expectError
|
2021-10-30 13:15:11 +00:00
|
|
|
import com.github.michaelbull.result.getOrElse
|
2021-11-08 14:50:29 +00:00
|
|
|
import io.kotest.assertions.withClue
|
2021-11-07 23:16:58 +00:00
|
|
|
import io.kotest.core.spec.style.FunSpec
|
2021-11-08 14:50:29 +00:00
|
|
|
import io.kotest.matchers.shouldBe
|
2022-03-07 20:41:12 +00:00
|
|
|
import io.kotest.matchers.shouldNotBe
|
2022-03-25 17:26:23 +00:00
|
|
|
import prog8.code.core.Encoding
|
2022-04-10 13:09:12 +00:00
|
|
|
import prog8.code.core.unescape
|
2022-03-11 19:35:25 +00:00
|
|
|
import prog8.code.target.C64Target
|
|
|
|
import prog8.code.target.Cx16Target
|
2022-03-25 17:26:23 +00:00
|
|
|
import prog8.code.target.Encoder
|
2022-03-11 19:35:25 +00:00
|
|
|
import prog8.code.target.cbm.AtasciiEncoding
|
|
|
|
import prog8.code.target.cbm.IsoEncoding
|
|
|
|
import prog8.code.target.cbm.PetsciiEncoding
|
2022-02-15 00:39:12 +00:00
|
|
|
import prog8tests.helpers.ErrorReporterForTests
|
|
|
|
import prog8tests.helpers.compileText
|
2021-06-01 19:21:33 +00:00
|
|
|
|
|
|
|
|
2022-01-19 00:08:24 +00:00
|
|
|
class TestStringEncodings: FunSpec({
|
2021-06-01 19:21:33 +00:00
|
|
|
|
2022-01-19 00:08:24 +00:00
|
|
|
context("petscii") {
|
|
|
|
test("testZero") {
|
2022-01-19 20:13:02 +00:00
|
|
|
PetsciiEncoding.encodePetscii("\u0000", true) shouldBe Ok(listOf<UByte>(0u))
|
|
|
|
PetsciiEncoding.encodePetscii("\u0000", false) shouldBe Ok(listOf<UByte>(0u))
|
|
|
|
PetsciiEncoding.decodePetscii(listOf(0u), true) shouldBe Ok("\u0000")
|
|
|
|
PetsciiEncoding.decodePetscii(listOf(0u), false) shouldBe Ok("\u0000")
|
2021-11-08 14:50:29 +00:00
|
|
|
}
|
|
|
|
|
2022-01-19 00:08:24 +00:00
|
|
|
test("testLowercase") {
|
2022-01-19 20:13:02 +00:00
|
|
|
PetsciiEncoding.encodePetscii("hello WORLD 123 @!£", true) shouldBe
|
2022-01-19 00:08:24 +00:00
|
|
|
Ok(listOf<UByte>(72u, 69u, 76u, 76u, 79u, 32u, 0xd7u, 0xcfu, 0xd2u, 0xccu, 0xc4u, 32u, 49u, 50u, 51u, 32u, 64u, 33u, 0x5cu))
|
2022-01-19 20:13:02 +00:00
|
|
|
PetsciiEncoding.encodePetscii("\uf11a", true) shouldBe Ok(listOf<UByte>(0x12u)) // reverse vid
|
|
|
|
PetsciiEncoding.encodePetscii("✓", true) shouldBe Ok(listOf<UByte>(0xfau))
|
2022-01-19 00:08:24 +00:00
|
|
|
withClue("expect lowercase error fallback") {
|
2022-01-19 20:13:02 +00:00
|
|
|
PetsciiEncoding.encodePetscii("π", true) shouldBe Ok(listOf<UByte>(255u))
|
|
|
|
PetsciiEncoding.encodePetscii("♥", true) shouldBe Ok(listOf<UByte>(0xd3u))
|
2022-01-19 00:08:24 +00:00
|
|
|
}
|
|
|
|
|
2022-01-19 20:13:02 +00:00
|
|
|
PetsciiEncoding.decodePetscii(listOf(72u, 0xd7u, 0x5cu, 0xfau, 0x12u), true) shouldBe Ok("hW£✓\uF11A")
|
2022-01-19 00:08:24 +00:00
|
|
|
}
|
2021-06-01 19:21:33 +00:00
|
|
|
|
2022-01-19 00:08:24 +00:00
|
|
|
test("testUppercase") {
|
2022-01-19 20:13:02 +00:00
|
|
|
PetsciiEncoding.encodePetscii("HELLO 123 @!£") shouldBe
|
2022-01-19 00:08:24 +00:00
|
|
|
Ok(listOf<UByte>(72u, 69u, 76u, 76u, 79u, 32u, 49u, 50u, 51u, 32u, 64u, 33u, 0x5cu))
|
2022-01-19 20:13:02 +00:00
|
|
|
PetsciiEncoding.encodePetscii("\uf11a") shouldBe Ok(listOf<UByte>(0x12u)) // reverse vid
|
|
|
|
PetsciiEncoding.encodePetscii("♥") shouldBe Ok(listOf<UByte>(0xd3u))
|
|
|
|
PetsciiEncoding.encodePetscii("π") shouldBe Ok(listOf<UByte>(0xffu))
|
2022-01-19 00:08:24 +00:00
|
|
|
withClue("expecting fallback") {
|
2022-01-19 20:13:02 +00:00
|
|
|
PetsciiEncoding.encodePetscii("✓") shouldBe Ok(listOf<UByte>(250u))
|
2022-01-19 00:08:24 +00:00
|
|
|
}
|
|
|
|
|
2022-01-19 20:13:02 +00:00
|
|
|
PetsciiEncoding.decodePetscii(listOf(72u, 0x5cu, 0xd3u, 0xffu)) shouldBe Ok("H£♥π")
|
2021-11-08 14:50:29 +00:00
|
|
|
}
|
|
|
|
|
2022-01-19 00:08:24 +00:00
|
|
|
test("testScreencodeLowercase") {
|
2022-01-19 20:13:02 +00:00
|
|
|
PetsciiEncoding.encodeScreencode("hello WORLD 123 @!£", true) shouldBe
|
2022-01-19 00:08:24 +00:00
|
|
|
Ok(listOf<UByte>(0x08u, 0x05u, 0x0cu, 0x0cu, 0x0fu, 0x20u, 0x57u, 0x4fu, 0x52u, 0x4cu, 0x44u, 0x20u, 0x31u, 0x32u, 0x33u, 0x20u, 0x00u, 0x21u, 0x1cu))
|
2022-01-19 20:13:02 +00:00
|
|
|
PetsciiEncoding.encodeScreencode("✓", true) shouldBe Ok(listOf<UByte>(0x7au))
|
2022-01-19 00:08:24 +00:00
|
|
|
withClue("expect fallback") {
|
2022-01-19 20:13:02 +00:00
|
|
|
PetsciiEncoding.encodeScreencode("♥", true) shouldBe Ok(listOf<UByte>(83u))
|
|
|
|
PetsciiEncoding.encodeScreencode("π", true) shouldBe Ok(listOf<UByte>(94u))
|
2022-01-19 00:08:24 +00:00
|
|
|
}
|
2021-06-01 19:21:33 +00:00
|
|
|
|
2022-01-19 20:13:02 +00:00
|
|
|
PetsciiEncoding.decodeScreencode(listOf(0x08u, 0x57u, 0x1cu, 0x7au), true) shouldBe Ok("hW£✓")
|
2021-11-08 14:50:29 +00:00
|
|
|
}
|
2021-06-01 19:21:33 +00:00
|
|
|
|
2022-01-19 00:08:24 +00:00
|
|
|
test("testScreencodeUppercase") {
|
2022-01-19 20:13:02 +00:00
|
|
|
PetsciiEncoding.encodeScreencode("WORLD 123 @!£") shouldBe
|
2022-01-19 00:08:24 +00:00
|
|
|
Ok(listOf<UByte>(0x17u, 0x0fu, 0x12u, 0x0cu, 0x04u, 0x20u, 0x31u, 0x32u, 0x33u, 0x20u, 0x00u, 0x21u, 0x1cu))
|
2022-01-19 20:13:02 +00:00
|
|
|
PetsciiEncoding.encodeScreencode("♥") shouldBe Ok(listOf<UByte>(0x53u))
|
|
|
|
PetsciiEncoding.encodeScreencode("π") shouldBe Ok(listOf<UByte>(0x5eu))
|
|
|
|
PetsciiEncoding.encodeScreencode("HELLO") shouldBe Ok(listOf<UByte>(8u, 5u, 12u, 12u, 15u))
|
2022-01-19 00:08:24 +00:00
|
|
|
withClue("expecting fallback") {
|
2022-01-19 20:13:02 +00:00
|
|
|
PetsciiEncoding.encodeScreencode("hello") shouldBe Ok(listOf<UByte>(8u, 5u, 12u, 12u, 15u))
|
|
|
|
PetsciiEncoding.encodeScreencode("✓") shouldBe Ok(listOf<UByte>(122u))
|
2022-01-19 00:08:24 +00:00
|
|
|
}
|
|
|
|
|
2022-01-19 20:13:02 +00:00
|
|
|
PetsciiEncoding.decodeScreencode(listOf(0x17u, 0x1cu, 0x53u, 0x5eu)) shouldBe Ok("W£♥π")
|
2022-01-19 00:08:24 +00:00
|
|
|
}
|
2021-06-01 19:21:33 +00:00
|
|
|
|
2022-01-19 00:08:24 +00:00
|
|
|
test("testErrorCases") {
|
2022-01-19 20:13:02 +00:00
|
|
|
PetsciiEncoding.encodePetscii("~", true).expectError { "shouldn't be able to encode tilde" }
|
|
|
|
PetsciiEncoding.encodePetscii("~", false).expectError { "shouldn't be able to encode tilde" }
|
|
|
|
PetsciiEncoding.encodeScreencode("~", true).expectError { "shouldn't be able to encode tilde" }
|
|
|
|
PetsciiEncoding.encodeScreencode("~", false).expectError { "shouldn't be able to encode tilde" }
|
2021-11-08 14:50:29 +00:00
|
|
|
}
|
|
|
|
|
2023-09-28 23:49:15 +00:00
|
|
|
test("testReturn") {
|
|
|
|
PetsciiEncoding.encodePetscii("\r", true) shouldBe Ok(listOf<UByte>(13u))
|
|
|
|
PetsciiEncoding.encodePetscii("\r", false) shouldBe Ok(listOf<UByte>(13u))
|
|
|
|
PetsciiEncoding.encodePetscii("\n", true) shouldBe Ok(listOf<UByte>(13u))
|
|
|
|
PetsciiEncoding.encodePetscii("\n", false) shouldBe Ok(listOf<UByte>(13u))
|
|
|
|
PetsciiEncoding.decodePetscii(listOf(13u), false) shouldBe Ok("\n")
|
|
|
|
PetsciiEncoding.decodePetscii(listOf(13u), true) shouldBe Ok("\n")
|
|
|
|
PetsciiEncoding.decodePetscii(listOf(0x8du), false) shouldBe Ok("\r")
|
|
|
|
PetsciiEncoding.decodePetscii(listOf(0x8du), true) shouldBe Ok("\r")
|
|
|
|
}
|
|
|
|
|
2022-01-19 00:08:24 +00:00
|
|
|
test("testSpecialReplacements") {
|
2022-01-19 20:13:02 +00:00
|
|
|
fun encodeP(c: Char, lower: Boolean) = PetsciiEncoding.encodePetscii(c.toString(), lower).getOrElse { throw it }.single()
|
|
|
|
fun encodeS(c: Char, lower: Boolean) = PetsciiEncoding.encodeScreencode(c.toString(), lower).getOrElse { throw it }.single()
|
2022-01-19 00:08:24 +00:00
|
|
|
|
2022-01-19 20:13:02 +00:00
|
|
|
PetsciiEncoding.encodePetscii("`", false).expectError { "shouldn't have translation for backtick" }
|
|
|
|
PetsciiEncoding.encodePetscii("`", true).expectError { "shouldn't have translation for backtick" }
|
|
|
|
PetsciiEncoding.encodePetscii("~", false).expectError { "shouldn't have translation for tilde" }
|
|
|
|
PetsciiEncoding.encodePetscii("~", true).expectError { "shouldn't have translation for tilde" }
|
2022-01-19 00:08:24 +00:00
|
|
|
|
|
|
|
encodeP('^', false) shouldBe 94u
|
|
|
|
encodeP('^', true) shouldBe 94u
|
|
|
|
encodeS('^', false) shouldBe 30u
|
|
|
|
encodeS('^', true) shouldBe 30u
|
|
|
|
encodeP('_', false) shouldBe 228u
|
|
|
|
encodeP('_', true) shouldBe 228u
|
|
|
|
encodeS('_', false) shouldBe 100u
|
|
|
|
encodeS('_', true) shouldBe 100u
|
|
|
|
encodeP('{', false) shouldBe 243u
|
|
|
|
encodeP('{', true) shouldBe 243u
|
|
|
|
encodeS('{', false) shouldBe 115u
|
|
|
|
encodeS('{', true) shouldBe 115u
|
|
|
|
encodeP('}', false) shouldBe 235u
|
|
|
|
encodeP('}', true) shouldBe 235u
|
|
|
|
encodeS('}', false) shouldBe 107u
|
|
|
|
encodeS('}', true) shouldBe 107u
|
|
|
|
encodeP('|', false) shouldBe 221u
|
|
|
|
encodeP('|', true) shouldBe 221u
|
|
|
|
encodeS('|', false) shouldBe 93u
|
|
|
|
encodeS('|', true) shouldBe 93u
|
|
|
|
encodeP('\\', false) shouldBe 205u
|
|
|
|
encodeP('\\', true) shouldBe 205u
|
|
|
|
encodeS('\\', false) shouldBe 77u
|
|
|
|
encodeS('\\', true) shouldBe 77u
|
2023-09-28 23:49:15 +00:00
|
|
|
encodeP('\r', true) shouldBe 13u
|
|
|
|
encodeP('\r', false) shouldBe 13u
|
|
|
|
encodeP('\n', true) shouldBe 13u
|
|
|
|
encodeP('\n', false) shouldBe 13u
|
2022-01-19 00:08:24 +00:00
|
|
|
}
|
2021-10-20 21:48:20 +00:00
|
|
|
|
2022-01-19 00:08:24 +00:00
|
|
|
test("testBoxDrawingCharsEncoding") {
|
2022-01-19 20:13:02 +00:00
|
|
|
fun encodeP(c: Char, lower: Boolean) = PetsciiEncoding.encodePetscii(c.toString(), lower).getOrElse { throw it }.single()
|
|
|
|
fun encodeS(c: Char, lower: Boolean) = PetsciiEncoding.encodeScreencode(c.toString(), lower).getOrElse { throw it }.single()
|
2022-01-19 00:08:24 +00:00
|
|
|
|
|
|
|
// pipe char
|
|
|
|
encodeP('|', false) shouldBe 221u
|
|
|
|
encodeP('|', true) shouldBe 221u
|
|
|
|
encodeS('|', false) shouldBe 93u
|
|
|
|
encodeS('|', true) shouldBe 93u
|
|
|
|
// ... same as '│', 0x7D -> BOX DRAWINGS LIGHT VERTICAL
|
|
|
|
encodeP('│', false) shouldBe 221u
|
|
|
|
encodeP('│', true) shouldBe 221u
|
|
|
|
encodeS('│', false) shouldBe 93u
|
|
|
|
encodeS('│', true) shouldBe 93u
|
|
|
|
|
|
|
|
// underscore
|
|
|
|
encodeP('_', false) shouldBe 228u
|
|
|
|
encodeP('_', true) shouldBe 228u
|
|
|
|
encodeS('_', false) shouldBe 100u
|
|
|
|
encodeS('_', true) shouldBe 100u
|
|
|
|
// ... same as '▁', 0xE4 LOWER ONE EIGHTH BLOCK
|
|
|
|
encodeP('▁', false) shouldBe 228u
|
|
|
|
encodeP('▁', true) shouldBe 228u
|
|
|
|
encodeS('▁', false) shouldBe 100u
|
|
|
|
encodeS('▁', true) shouldBe 100u
|
|
|
|
|
|
|
|
// ─ 0xC0 -> BOX DRAWINGS LIGHT HORIZONTAL
|
|
|
|
encodeP('─', false) shouldBe 192u
|
|
|
|
encodeP('─', true) shouldBe 192u
|
|
|
|
encodeS('─', false) shouldBe 64u
|
|
|
|
encodeS('─', true) shouldBe 64u
|
|
|
|
// │ 0x62 -> BOX DRAWINGS LIGHT VERTICAL
|
|
|
|
encodeP('│', false) shouldBe 221u
|
|
|
|
encodeP('│', true) shouldBe 221u
|
|
|
|
encodeS('│', false) shouldBe 93u
|
|
|
|
encodeS('│', true) shouldBe 93u
|
|
|
|
}
|
2021-10-30 13:15:11 +00:00
|
|
|
|
2022-01-19 00:08:24 +00:00
|
|
|
test("testBoxDrawingCharsDecoding") {
|
|
|
|
// ─ 0xC0 -> BOX DRAWINGS LIGHT HORIZONTAL
|
2022-01-19 20:13:02 +00:00
|
|
|
PetsciiEncoding.decodePetscii(listOf(195u), false).getOrElse { throw it }.single() shouldBe '\uf13b' //"BOX DRAWINGS LIGHT HORIZONTAL ONE EIGHTH UP (CUS)"
|
|
|
|
PetsciiEncoding.decodePetscii(listOf(195u), true).getOrElse { throw it }.single() shouldBe 'C'
|
|
|
|
PetsciiEncoding.decodePetscii(listOf(192u), false).getOrElse { throw it }.single() shouldBe '─'
|
|
|
|
PetsciiEncoding.decodePetscii(listOf(192u), true).getOrElse { throw it }.single() shouldBe '─'
|
|
|
|
PetsciiEncoding.decodeScreencode(listOf(67u), false).getOrElse { throw it }.single() shouldBe '\uf13b' //"BOX DRAWINGS LIGHT HORIZONTAL ONE EIGHTH UP (CUS)"
|
|
|
|
PetsciiEncoding.decodeScreencode(listOf(67u), true).getOrElse { throw it }.single() shouldBe 'C'
|
|
|
|
PetsciiEncoding.decodeScreencode(listOf(64u), false).getOrElse { throw it }.single() shouldBe '─'
|
|
|
|
PetsciiEncoding.decodeScreencode(listOf(64u), true).getOrElse { throw it }.single() shouldBe '─'
|
2022-01-19 00:08:24 +00:00
|
|
|
|
|
|
|
// │ 0x62 -> BOX DRAWINGS LIGHT VERTICAL
|
2022-01-19 20:13:02 +00:00
|
|
|
PetsciiEncoding.decodePetscii(listOf(125u), false).getOrElse { throw it }.single() shouldBe '│'
|
|
|
|
PetsciiEncoding.decodePetscii(listOf(125u), true).getOrElse { throw it }.single() shouldBe '│'
|
|
|
|
PetsciiEncoding.decodePetscii(listOf(221u), false).getOrElse { throw it }.single() shouldBe '│'
|
|
|
|
PetsciiEncoding.decodePetscii(listOf(221u), true).getOrElse { throw it }.single() shouldBe '│'
|
|
|
|
PetsciiEncoding.decodeScreencode(listOf(93u), false).getOrElse { throw it }.single() shouldBe '│'
|
|
|
|
PetsciiEncoding.decodeScreencode(listOf(93u), true).getOrElse { throw it }.single() shouldBe '│'
|
|
|
|
PetsciiEncoding.decodeScreencode(listOf(66u), false).getOrElse { throw it }.single() shouldBe '\uf13c' // "BOX DRAWINGS LIGHT VERTICAL ONE EIGHTH LEFT (CUS)"
|
|
|
|
PetsciiEncoding.decodeScreencode(listOf(66u), true).getOrElse { throw it }.single() shouldBe 'B'
|
2022-01-19 00:08:24 +00:00
|
|
|
}
|
2021-10-30 13:15:11 +00:00
|
|
|
}
|
|
|
|
|
2022-02-25 22:48:39 +00:00
|
|
|
context("atari") {
|
|
|
|
test("atascii encoding") {
|
|
|
|
AtasciiEncoding.encode("a") shouldBe Ok(listOf<UByte>(97u))
|
|
|
|
AtasciiEncoding.encode("A") shouldBe Ok(listOf<UByte>(65u))
|
|
|
|
AtasciiEncoding.encode("\n") shouldBe Ok(listOf<UByte>(155u))
|
|
|
|
}
|
|
|
|
|
|
|
|
test("atascii decoding") {
|
|
|
|
AtasciiEncoding.decode(listOf<UByte>(97u)) shouldBe Ok("a")
|
|
|
|
AtasciiEncoding.decode(listOf<UByte>(65u)) shouldBe Ok("A")
|
|
|
|
AtasciiEncoding.decode(listOf<UByte>(155u)) shouldBe Ok("\n")
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-01-19 00:08:24 +00:00
|
|
|
context("iso") {
|
|
|
|
test("iso accepts iso-characters") {
|
|
|
|
val result = IsoEncoding.encode("a_~ëç")
|
|
|
|
result.getOrElse { throw it }.map {it.toInt()} shouldBe listOf(97, 95, 126, 235, 231)
|
|
|
|
}
|
2021-10-30 13:15:11 +00:00
|
|
|
|
2022-01-19 00:08:24 +00:00
|
|
|
test("non-iso doesn't accept iso-characters") {
|
2022-01-19 20:13:02 +00:00
|
|
|
var result = PetsciiEncoding.encodePetscii("a_~ë")
|
2022-01-19 00:08:24 +00:00
|
|
|
result.expectError { "should not encode" }
|
2022-01-19 20:13:02 +00:00
|
|
|
result = PetsciiEncoding.encodeScreencode("a_~ë")
|
2022-01-19 00:08:24 +00:00
|
|
|
result.expectError { "should not encode" }
|
|
|
|
}
|
2021-10-30 13:15:11 +00:00
|
|
|
}
|
2022-02-15 00:39:12 +00:00
|
|
|
|
2022-03-25 17:26:23 +00:00
|
|
|
test("special pass-through") {
|
|
|
|
val passthroughEscaped= """\x00\x1b\x99\xff"""
|
2022-04-10 13:09:12 +00:00
|
|
|
val passthrough = passthroughEscaped.unescape()
|
2022-03-25 17:26:23 +00:00
|
|
|
passthrough.length shouldBe 4
|
|
|
|
passthrough[0] shouldBe '\u8000'
|
|
|
|
passthrough[1] shouldBe '\u801b'
|
|
|
|
passthrough[2] shouldBe '\u8099'
|
|
|
|
passthrough[3] shouldBe '\u80ff'
|
|
|
|
var encoded = Encoder.encodeString(passthrough, Encoding.PETSCII)
|
|
|
|
encoded shouldBe listOf<UByte>(0u, 0x1bu, 0x99u, 0xffu)
|
|
|
|
encoded = Encoder.encodeString(passthrough, Encoding.ATASCII)
|
|
|
|
encoded shouldBe listOf<UByte>(0u, 0x1bu, 0x99u, 0xffu)
|
|
|
|
encoded = Encoder.encodeString(passthrough, Encoding.SCREENCODES)
|
|
|
|
encoded shouldBe listOf<UByte>(0u, 0x1bu, 0x99u, 0xffu)
|
|
|
|
encoded = Encoder.encodeString(passthrough, Encoding.ISO)
|
|
|
|
encoded shouldBe listOf<UByte>(0u, 0x1bu, 0x99u, 0xffu)
|
|
|
|
}
|
|
|
|
|
2022-02-15 00:39:12 +00:00
|
|
|
test("invalid encoding immediately errors the parser") {
|
|
|
|
val source="""
|
|
|
|
main {
|
|
|
|
str string5 = unicorns:"wrong"
|
|
|
|
ubyte char5 = unicorns:'?'
|
|
|
|
|
|
|
|
sub start() {
|
|
|
|
}
|
|
|
|
}"""
|
|
|
|
val errors = ErrorReporterForTests()
|
2022-03-07 20:41:12 +00:00
|
|
|
compileText(C64Target(), false, source, errors, false) shouldBe null
|
2022-02-15 00:39:12 +00:00
|
|
|
errors.errors.size shouldBe 0
|
|
|
|
}
|
|
|
|
|
2023-12-02 20:10:51 +00:00
|
|
|
test("iso string encoding also on C64 compilationtarget") {
|
2022-02-15 00:39:12 +00:00
|
|
|
val source="""
|
|
|
|
main {
|
|
|
|
str string1 = "default"
|
|
|
|
str string2 = sc:"screencodes"
|
|
|
|
str string3 = iso:"iso"
|
|
|
|
str string4 = petscii:"petscii"
|
|
|
|
sub start() {
|
|
|
|
}
|
|
|
|
}"""
|
|
|
|
val errors = ErrorReporterForTests()
|
2023-12-02 20:10:51 +00:00
|
|
|
compileText(C64Target(), false, source, errors, writeAssembly = false) shouldNotBe null
|
|
|
|
errors.errors.size shouldBe 0
|
2022-02-15 00:39:12 +00:00
|
|
|
}
|
|
|
|
|
2023-12-02 20:10:51 +00:00
|
|
|
test("iso char encoding also on C64 compilationtarget") {
|
2022-02-15 00:39:12 +00:00
|
|
|
val source="""
|
|
|
|
main {
|
|
|
|
ubyte char1 = 'd'
|
|
|
|
ubyte char2 = sc:'s'
|
|
|
|
ubyte char3 = iso:'i'
|
|
|
|
ubyte char4 = petscii:'p'
|
|
|
|
sub start() {
|
|
|
|
}
|
|
|
|
}"""
|
|
|
|
val errors = ErrorReporterForTests()
|
2023-12-02 20:10:51 +00:00
|
|
|
compileText(C64Target(), false, source, errors, writeAssembly = false) shouldNotBe null
|
|
|
|
errors.errors.size shouldBe 0
|
2022-02-15 00:39:12 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
test("all encodings supported for Cx16 target") {
|
|
|
|
val source="""
|
|
|
|
main {
|
|
|
|
str string1 = "default"
|
|
|
|
str string2 = sc:"screencodes"
|
|
|
|
str string3 = iso:"iso"
|
|
|
|
str string4 = petscii:"petscii"
|
|
|
|
|
|
|
|
ubyte char1 = 'd'
|
|
|
|
ubyte char2 = sc:'s'
|
|
|
|
ubyte char3 = iso:'i'
|
|
|
|
ubyte char4 = petscii:'p'
|
|
|
|
|
|
|
|
sub start() {
|
|
|
|
}
|
|
|
|
}"""
|
2022-03-07 20:41:12 +00:00
|
|
|
compileText(Cx16Target(), false, source, writeAssembly = false) shouldNotBe null
|
2022-02-15 00:39:12 +00:00
|
|
|
}
|
2021-11-07 23:16:58 +00:00
|
|
|
})
|
2022-03-25 17:26:23 +00:00
|
|
|
|