Skip to content

Commit

Permalink
Rename IntFormat -> LiteralInt.
Browse files Browse the repository at this point in the history
  • Loading branch information
nedtwigg committed Dec 19, 2023
1 parent 9b0853a commit c9aa23f
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ interface LiteralFormat<T : Any> {
fun parse(str: String, language: Language): T
}

object IntFormat : LiteralFormat<Int> {
object LiteralInt : LiteralFormat<Int> {
override fun encode(value: Int, language: Language): String {
// TODO: 1000000 is hard to read, 1_000_000 is much much better
return value.toString()
Expand All @@ -38,7 +38,7 @@ object IntFormat : LiteralFormat<Int> {
}
}

object StrFormat : LiteralFormat<String> {
object LiteralString : LiteralFormat<String> {
override fun encode(value: String, language: Language): String {
if (!value.contains("\n")) {
// TODO: replace \t, maybe others...
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ package com.diffplug.selfie
import io.kotest.matchers.shouldBe
import kotlin.test.Test

class IntFormatTest {
class LiteralIntTest {
@Test
fun encode() {
encode(0, "0")
Expand All @@ -33,7 +33,7 @@ class IntFormatTest {
encode(-1_000_000, "-1000000")
}
private fun encode(value: Int, expected: String) {
val actual = IntFormat().encode(value)
val actual = LiteralInt.encode(value, Language.JAVA)
actual shouldBe expected
}

Expand All @@ -50,7 +50,7 @@ class IntFormatTest {
decode("-9_9_9", -999)
}
private fun decode(value: String, expected: Int) {
val actual = IntFormat().parse(value)
val actual = LiteralInt.parse(value, Language.JAVA)
actual shouldBe expected
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ object Selfie {
}
private fun toBeDidntMatch(expected: Int?): Int {
if (RW.isWrite) {
Router.writeInline(recordCall(), LiteralValue(expected, actual, IntFormat))
Router.writeInline(recordCall(), LiteralValue(expected, actual, LiteralInt))
return actual
} else {
if (expected == null) {
Expand Down

0 comments on commit c9aa23f

Please sign in to comment.