From 269bd1de089aad270f86115a45f20569f30b8917 Mon Sep 17 00:00:00 2001 From: Anton Sviridov Date: Wed, 10 Apr 2024 08:54:16 +0100 Subject: [PATCH] Adjust tests and implementation to satisfy coverage --- build.sbt | 1 - .../moped/internal/transformers/InputTransformer.scala | 8 ++------ tests/src/test/scala/tests/ConfigCommandSuite.scala | 6 ++++-- 3 files changed, 6 insertions(+), 9 deletions(-) diff --git a/build.sbt b/build.sbt index c834887..76b85a3 100644 --- a/build.sbt +++ b/build.sbt @@ -159,7 +159,6 @@ lazy val tests = project (publish / skip) := true, testFrameworks := List(new TestFramework("munit.Framework")), buildInfoPackage := "tests", - //scalacOptions ++= "-Ymacro-debug-verbose Yshow-trees-compact -Vprint".split(" ").toList, buildInfoKeys := Seq[BuildInfoKey]( "expectDirectory" -> (Test / sourceDirectory).value./("expect") diff --git a/moped/src/main/scala/moped/internal/transformers/InputTransformer.scala b/moped/src/main/scala/moped/internal/transformers/InputTransformer.scala index 00b77a9..dd4781e 100644 --- a/moped/src/main/scala/moped/internal/transformers/InputTransformer.scala +++ b/moped/src/main/scala/moped/internal/transformers/InputTransformer.scala @@ -40,7 +40,7 @@ final class InputTransformer[J](input: Input) extends CharParser[J] { } override def reject(j: Int): PartialFunction[Throwable, Nothing] = { - case e: IndexOutOfBoundsException => + case e: StringIndexOutOfBoundsException => val n = chars.length - 1 val pos = RangePosition(input, n, n) throw new DiagnosticException(Diagnostic.error("incomplete JSON", pos)) @@ -124,11 +124,7 @@ final class InputTransformer[J](input: Input) extends CharParser[J] { throw new StringIndexOutOfBoundsException(i) chars(i) } - def at(i: Int, j: Int): CharSequence = wrapped.subSequence(i, j) override def atEof(i: Int): Boolean = i >= chars.length - def close(): Unit = () + override def close(): Unit = () override def dropBufferUntil(i: Int): Unit = () - final def char(i: Int): Char = - chars(i) //upickle.core.Platform.charAt(chars, i) - // final def sliceString(i: Int, j: Int): CharSequence = chars.subsequence(i, j) } diff --git a/tests/src/test/scala/tests/ConfigCommandSuite.scala b/tests/src/test/scala/tests/ConfigCommandSuite.scala index 3947cff..796ff94 100644 --- a/tests/src/test/scala/tests/ConfigCommandSuite.scala +++ b/tests/src/test/scala/tests/ConfigCommandSuite.scala @@ -26,11 +26,13 @@ class ConfigCommandSuite extends BaseSuite { checkErrorOutput( "json-error", List("config"), - """|error: exhausted input + """|error: /workingDirectory/.tests.json:1 error: expected false + |filse + |^ |""".stripMargin, workingDirectoryLayout = """|/.tests.json - |{ + |filse |""".stripMargin )