6502-opcodes/firepower-core/src/test/scala/com/htmlism/firepower/core/FeatureSpec.scala

39 lines
1.4 KiB
Scala
Raw Normal View History

2022-12-04 23:36:11 +00:00
package com.htmlism.firepower.core
2022-08-03 04:16:11 +00:00
import org.scalatest.funsuite.AnyFunSuite
2023-10-03 20:15:10 +00:00
import org.scalatest.matchers.should.*
2022-08-03 04:16:11 +00:00
2023-10-03 20:15:10 +00:00
import com.htmlism.firepower.core.syntax.*
2022-08-03 04:16:11 +00:00
2022-10-20 21:08:11 +00:00
object ExampleRegister extends ZeroPageAddress(0x01, "example") with WriteOnlyByteAddress[ExampleRegister]
2022-10-03 05:52:37 +00:00
class ExampleRegister
2022-08-03 04:16:11 +00:00
class FeatureSpec extends AnyFunSuite with Matchers:
2023-06-13 18:01:45 +00:00
test("zero page address as write only supports writing"):
2022-10-03 05:52:37 +00:00
ExampleRegister
.writeConst(2)[Reg.A] shouldBe "LDA 2 STA 1 ; example = 2, via A"
2022-08-03 04:16:11 +00:00
2023-06-13 18:01:45 +00:00
test("zero page address as read/write supports writing"):
2022-10-03 05:52:37 +00:00
ExampleRegister
.writeConst(2)[Reg.A] shouldBe "LDA 2 STA 1 ; example = 2, via A"
2022-08-03 04:16:11 +00:00
2024-04-11 13:48:56 +00:00
test("writing to an address can use A registers for bouncing"):
2022-10-03 05:52:37 +00:00
ExampleRegister
.writeConst(2)[Reg.A] shouldBe "LDA 2 STA 1 ; example = 2, via A"
2022-08-03 04:16:11 +00:00
2024-04-11 13:48:56 +00:00
test("writing to an address can use X registers for bouncing"):
2022-10-03 05:52:37 +00:00
ExampleRegister
.writeConst(2)[Reg.X] shouldBe "LDX 2 STX 1 ; example = 2, via X"
2022-08-03 04:16:11 +00:00
2024-04-11 13:48:56 +00:00
test("writing to an address can use Y registers for bouncing"):
2022-10-03 05:52:37 +00:00
ExampleRegister
.writeConst(2)[Reg.Y] shouldBe "LDY 2 STY 1 ; example = 2, via Y"
2022-08-03 13:15:09 +00:00
ignore("the write payload is a typesafe enum") {}
2022-08-03 19:47:38 +00:00
// intializations must be constant
// cannot involve reading from a register, that is a side-effect
// can also support 16-bit initializations
ignore("initializations of the same value and register are aggReg.Ated") {}