add testing frameworks

This commit is contained in:
Mark Canlas 2020-08-15 00:49:07 -04:00
parent 69286c8a86
commit 59c8c06a26
6 changed files with 49 additions and 41 deletions

View File

@ -3,7 +3,8 @@ lazy val root =
.in(file("."))
.settings(
initialCommands in console := "import com.htmlism._",
libraryDependencies += "org.scalatest" %% "scalatest" % "3.2.1" % "test",
scalafmtOnCompile := true
)
.withCats
.withTesting
.withTestingBeta

View File

@ -13,6 +13,14 @@ object ProjectPlugin extends AutoPlugin {
def withCats: Project =
p
.settings(libraryDependencies += "org.typelevel" %% "cats-core" % "2.2.0-RC2")
def withTesting: Project =
p.settings(libraryDependencies += "org.scalatest" %% "scalatest" % "3.2.1" % "test")
def withTestingBeta: Project =
p.settings(
libraryDependencies += "com.disneystreaming" %% "weaver-framework" % "0.4.2" % Test,
testFrameworks += new TestFramework("weaver.framework.TestFramework"))
}
}
}

View File

@ -26,7 +26,7 @@ object MatchOpcodes {
0x96 -> (STX -> ZeroPageY),
0xB6 -> (LDX -> ZeroPageY),
0xBE -> (LDX -> AbsoluteY),
0xBE -> (LDX -> AbsoluteY)
)
def injectedOpcodesRelative: Map[Int, (Instruction, AddressingMode)] =
@ -38,7 +38,7 @@ object MatchOpcodes {
0x90 -> BCC,
0xB0 -> BCS,
0xD0 -> BNE,
0xF0 -> BEQ,
0xF0 -> BEQ
).view.mapValues(x => x -> Relative).toMap
def injectedOpcodesImplied: Map[Int, (Instruction, AddressingMode)] =

View File

@ -4,44 +4,43 @@ sealed trait Color
object Color {
implicit val ev: Operand[Color] =
Operand
.operandInt
Operand.operandInt
.contra(toByte, _.toString)
def toByte(x: Color): Int =
x match {
case Black => 0x0
case White => 0x1
case Red => 0x2
case Cyan => 0x3
case Purple => 0x4
case Green => 0x5
case Blue => 0x6
case Yellow => 0x7
case Orange => 0x8
case Brown => 0x9
case LightRed => 0xA
case DarkGrey => 0xB
case Grey => 0xC
case Black => 0x0
case White => 0x1
case Red => 0x2
case Cyan => 0x3
case Purple => 0x4
case Green => 0x5
case Blue => 0x6
case Yellow => 0x7
case Orange => 0x8
case Brown => 0x9
case LightRed => 0xA
case DarkGrey => 0xB
case Grey => 0xC
case LightGreen => 0xD
case LightBlue => 0xE
case LightGrey => 0xF
case LightBlue => 0xE
case LightGrey => 0xF
}
case object Black extends Color
case object White extends Color
case object Red extends Color
case object Cyan extends Color
case object Purple extends Color
case object Green extends Color
case object Blue extends Color
case object Yellow extends Color
case object Orange extends Color
case object Brown extends Color
case object LightRed extends Color
case object DarkGrey extends Color
case object Grey extends Color
case object Black extends Color
case object White extends Color
case object Red extends Color
case object Cyan extends Color
case object Purple extends Color
case object Green extends Color
case object Blue extends Color
case object Yellow extends Color
case object Orange extends Color
case object Brown extends Color
case object LightRed extends Color
case object DarkGrey extends Color
case object Grey extends Color
case object LightGreen extends Color
case object LightBlue extends Color
case object LightGrey extends Color
case object LightBlue extends Color
case object LightGrey extends Color
}

View File

@ -67,7 +67,6 @@ object DslDemo extends App {
}
}
object registers {
sealed trait Register
@ -130,15 +129,14 @@ class AssemblyContext {
def push(instruction: Instruction, s: String): Unit =
xs.append(UnaryInstruction(instruction, s.some))
def push[A : Operand](instruction: Instruction, x: A): Unit =
def push[A: Operand](instruction: Instruction, x: A): Unit =
xs.append(InstructionWithOperand(instruction, x, None))
def push[A : Operand](instruction: Instruction, x: A, s: String): Unit =
def push[A: Operand](instruction: Instruction, x: A, s: String): Unit =
xs.append(InstructionWithOperand(instruction, x: A, s.some))
def printOut(): Unit = {
xs
.map(_.toAsm)
xs.map(_.toAsm)
.foreach(println)
}
}

View File

@ -20,7 +20,9 @@ case class UnaryInstruction(instruction: Instruction, comment: Option[String]) e
}
}
case class InstructionWithOperand[A](instruction: Instruction, operand: A, comment: Option[String])(implicit ev: Operand[A]) extends Statement {
case class InstructionWithOperand[A](instruction: Instruction, operand: A, comment: Option[String])(
implicit ev: Operand[A]
) extends Statement {
def toAsm: String = {
val left =
instruction.toString