From b0e40b3e36c3e6dc01f07bf51cf99103329d5988 Mon Sep 17 00:00:00 2001 From: Mark Canlas Date: Mon, 24 Aug 2020 16:27:02 -0400 Subject: [PATCH] add missing files --- .../mos6502/dsl/snake/AsciiValue.scala | 36 +++++++++++++++++++ .../htmlism/mos6502/dsl/snake/Direction.scala | 28 +++++++++++++++ 2 files changed, 64 insertions(+) create mode 100644 src/test/scala/com/htmlism/mos6502/dsl/snake/AsciiValue.scala create mode 100644 src/test/scala/com/htmlism/mos6502/dsl/snake/Direction.scala diff --git a/src/test/scala/com/htmlism/mos6502/dsl/snake/AsciiValue.scala b/src/test/scala/com/htmlism/mos6502/dsl/snake/AsciiValue.scala new file mode 100644 index 0000000..fd58e0f --- /dev/null +++ b/src/test/scala/com/htmlism/mos6502/dsl/snake/AsciiValue.scala @@ -0,0 +1,36 @@ +package com.htmlism.mos6502.dsl +package snake + +import cats.data.NonEmptyList + +object AsciiValue { + implicit val asciiValueMapping: Mapping[AsciiValue] = + new Mapping[AsciiValue] { + def comment: String = + "foo as a mapping" + + def all: NonEmptyList[AsciiValue] = + NonEmptyList.of(AsciiW, AsciiA, AsciiS, AsciiD) + + def value(x: AsciiValue): Int = + x match { + case AsciiW => 0x77 + case AsciiA => 0x61 + case AsciiS => 0x73 + case AsciiD => 0x64 + } + + def label(x: AsciiValue): String = + x.toString.toLowerCase + + def comment(x: AsciiValue): String = + x.toString + } +} + +sealed trait AsciiValue + +case object AsciiW extends AsciiValue +case object AsciiA extends AsciiValue +case object AsciiS extends AsciiValue +case object AsciiD extends AsciiValue diff --git a/src/test/scala/com/htmlism/mos6502/dsl/snake/Direction.scala b/src/test/scala/com/htmlism/mos6502/dsl/snake/Direction.scala new file mode 100644 index 0000000..330763b --- /dev/null +++ b/src/test/scala/com/htmlism/mos6502/dsl/snake/Direction.scala @@ -0,0 +1,28 @@ +package com.htmlism.mos6502.dsl +package snake + +import cats.data.NonEmptyList + +object Direction { + implicit val directionBitField: BitField[Direction] = + new BitField[Direction] { + def comment: String = + "foo as bit field" + + def all: NonEmptyList[Direction] = + NonEmptyList.of(Up, Down, Left, Right) + + def label(x: Direction): String = + "moving" + x.toString + + def comment(x: Direction): String = + x.toString + } +} + +sealed trait Direction + +case object Up extends Direction +case object Down extends Direction +case object Left extends Direction +case object Right extends Direction