6502-opcodes/src/test/scala/com/htmlism/mos6502/dsl/Easy6502Spec.scala

50 lines
1.1 KiB
Scala
Raw Normal View History

2020-08-15 05:27:13 +00:00
package com.htmlism.mos6502.dsl
import cats.implicits._
2020-08-15 06:04:21 +00:00
import org.scalatest.flatspec._
import org.scalatest.matchers._
2020-08-15 05:27:13 +00:00
class Easy6502Spec extends AnyFlatSpec with should.Matchers {
"the three pixel demo" should "have the right instructions" in {
val doc =
withAssemblyContext { implicit ctx =>
val scr =
IndexedAddressCollection[Color](0x0200, "screen")
scr.write(0, Color.White)
scr.write(1, Color.Green)
scr.write(2, Color.Orange)
}
doc.triplets shouldEqual List(
("LDA", "#$01".some, "write White to screen (0)".some),
("STA", "$0200".some, "".some),
("LDA", "#$05".some, "write Green to screen (1)".some),
("STA", "$0201".some, "".some),
("LDA", "#$08".some, "write Orange to screen (2)".some),
("STA", "$0202".some, "".some)
)
doc.printOut()
}
2020-08-16 04:16:10 +00:00
"define style dsl" should "compile" in {
val doc =
asmDoc { implicit ctx =>
enum[Color]
}
println(doc)
}
2020-08-15 05:27:13 +00:00
def withAssemblyContext(f: AssemblyContext => Unit): AssemblyContext = {
val ctx: AssemblyContext =
new AssemblyContext
f(ctx)
ctx
}
}