From 69a7baeaaa38699582208811f0f6e3e2fbe1b9f6 Mon Sep 17 00:00:00 2001 From: Som Snytt Date: Sat, 12 Feb 2022 12:17:40 -0800 Subject: [PATCH 1/2] Version bumps --- build.sbt | 16 +++++++++------- .../src/main/scala/atto/parser/Combinator.scala | 2 +- project/build.properties | 2 +- project/plugins.sbt | 4 ++-- 4 files changed, 13 insertions(+), 11 deletions(-) diff --git a/build.sbt b/build.sbt index 02c434e..d7773ab 100644 --- a/build.sbt +++ b/build.sbt @@ -1,12 +1,13 @@ import sbtcrossproject.{ crossProject, CrossType } -lazy val catsVersion = "2.6.1" -lazy val fs2CoreVersion = "2.5.6" +lazy val catsVersion = "2.7.0" +lazy val fs2CoreVersion = "2.5.10" lazy val scalacheckVersion = "1.15.4" -lazy val scala212 = "2.12.16" -lazy val scala213 = "2.13.6" -lazy val scala30 = "3.0.2" +lazy val scala212 = "2.12.20" +lazy val scala213 = "2.13.16" +lazy val scala30 = "3.3.6" +lazy val scala31 = "3.7.0" lazy val commonSettings = Seq( organization := "org.tpolecat", @@ -19,7 +20,8 @@ lazy val commonSettings = Seq( ("BSD New", url("http://opensource.org/licenses/BSD-3-Clause")) ), scalaVersion := scala213, - crossScalaVersions := Seq(scala212, scala213, scala30), + crossScalaVersions := Seq(scala212, scala213, scala30, scala31), + scalacOptions += "-Wconf:msg=infix|vararg|deprecated:s", // dottydoc really doesn't work at all right now Compile / doc / sources := { @@ -70,7 +72,7 @@ lazy val refined = .settings(commonSettings) .settings( name := "atto-refined", - libraryDependencies += "eu.timepit" %%% "refined" % "0.9.26", + libraryDependencies += "eu.timepit" %%% "refined" % "0.11.3", ) lazy val tests = diff --git a/modules/core/src/main/scala/atto/parser/Combinator.scala b/modules/core/src/main/scala/atto/parser/Combinator.scala index f6618a3..1082a11 100644 --- a/modules/core/src/main/scala/atto/parser/Combinator.scala +++ b/modules/core/src/main/scala/atto/parser/Combinator.scala @@ -56,7 +56,7 @@ trait Combinator0 { private def prompt[R](st0: State, kf: State => TResult[R], ks: State => TResult[R]): Result[R] = Partial[R](s => - if (s.isEmpty) Eval.defer(kf(st0 copy (complete = true))) + if (s.isEmpty) Eval.defer(kf(st0.copy(complete = true))) else Eval.defer(ks(st0.copy(input = st0.input + s, complete = false))) ) diff --git a/project/build.properties b/project/build.properties index 88dc997..cc68b53 100644 --- a/project/build.properties +++ b/project/build.properties @@ -1 +1 @@ -sbt.version=1.5.8 \ No newline at end of file +sbt.version=1.10.11 diff --git a/project/plugins.sbt b/project/plugins.sbt index 02b6718..2663b5b 100644 --- a/project/plugins.sbt +++ b/project/plugins.sbt @@ -1,9 +1,9 @@ addSbtPlugin("com.lightbend.paradox" % "sbt-paradox" % "0.9.2") addSbtPlugin("com.typesafe.sbt" % "sbt-site" % "1.4.1") addSbtPlugin("com.typesafe.sbt" % "sbt-ghpages" % "0.6.3") -addSbtPlugin("com.github.sbt" % "sbt-ci-release" % "1.5.10") +addSbtPlugin("com.github.sbt" % "sbt-ci-release" % "1.5.10") addSbtPlugin("com.timushev.sbt" % "sbt-updates" % "0.5.3") addSbtPlugin("io.github.davidgregory084" % "sbt-tpolecat" % "0.1.20") addSbtPlugin("org.portable-scala" % "sbt-scalajs-crossproject" % "1.0.0") -addSbtPlugin("org.scala-js" % "sbt-scalajs" % "1.5.1") +addSbtPlugin("org.scala-js" % "sbt-scalajs" % "1.19.0") addSbtPlugin("org.scoverage" % "sbt-scoverage" % "1.6.1") From 1a924ec559b26c60d5caada2f0ea1aff35752cfa Mon Sep 17 00:00:00 2001 From: Som Snytt Date: Sat, 12 Feb 2022 22:32:30 -0800 Subject: [PATCH 2/2] Improve horizontal whitespace The character class includes various chars. The previous test was unlikely to fail, as it checked only arbitrary chars, most of which are obviously not whitespace even to the most broken implementation. Note that it's not helpful to display an arbitrary horizontal whitespace char after a failed test, though I imagine it was a minimized input. --- .../core/src/main/scala/atto/parser/Character.scala | 4 ++-- .../tests/src/test/scala/atto/CharacterTest.scala | 12 +++++++++--- modules/tests/src/test/scala/atto/Generators.scala | 5 +++-- 3 files changed, 14 insertions(+), 7 deletions(-) diff --git a/modules/core/src/main/scala/atto/parser/Character.scala b/modules/core/src/main/scala/atto/parser/Character.scala index 8ab0730..869d99c 100644 --- a/modules/core/src/main/scala/atto/parser/Character.scala +++ b/modules/core/src/main/scala/atto/parser/Character.scala @@ -5,7 +5,7 @@ import cats.implicits._ import java.lang.String import atto.syntax.parser._ import scala.{ Char, Boolean, Option, Unit } -import scala.Predef.{ charWrapper, augmentString } +import scala.Predef.{ charWrapper, intWrapper, augmentString } /** Parsers for various kinds of characters. */ trait Character { @@ -102,5 +102,5 @@ trait Character { /** Whitespace that is not a line break */ def horizontalWhitespace: Parser[Char] = - oneOf(" \t") named "horizontalWhitespace" + oneOf(s" \t\u00A0\u1680\u180e${(0x2000 to 0x200a).map(_.toChar).mkString}\u202f\u205f\u3000").named("horizontalWhitespace") } diff --git a/modules/tests/src/test/scala/atto/CharacterTest.scala b/modules/tests/src/test/scala/atto/CharacterTest.scala index 0d4ff45..ee73d64 100644 --- a/modules/tests/src/test/scala/atto/CharacterTest.scala +++ b/modules/tests/src/test/scala/atto/CharacterTest.scala @@ -94,8 +94,14 @@ object CharacterTest extends Properties("Character") { (if (predicate(c)) Some(()) else None) } - property("horizontalWhitespace") = forAll { (c: Char) => - horizontalWhitespace.parseOnly(c.toString).option === - (if (c == ' ' || c == '\t') Some(c) else None) + property("horizontalWhitespace") = forAll(Gen.oneOf(Generators.horizontalWhitespace, Arbitrary.arbitrary[Char])) { (c: Char) => + //println(f"CHK(${c.toInt}%04x) TEST(${CharClass.horizontalWhitespace.unapplySeq(c).flatMap(_.headOption)}) PARSE(${horizontalWhitespace.parseOnly(c.toString).option})") + horizontalWhitespace.parseOnly(c.toString).option === CharClass.horizontalWhitespace.unapplySeq(c).flatMap(_.headOption) } } + +private object CharClass { + val horizontalWhitespace = raw"(\h)".r // " \t\xA0\u1680\u180e\u2000-\u200a\u202f\u205f\u3000" + val horizontalWhitespaceChars = + " \u0009\u00A0\u1680\u180e\u202f\u205f\u3000".toVector ++ ('\u2000' to '\u200a').toVector +} diff --git a/modules/tests/src/test/scala/atto/Generators.scala b/modules/tests/src/test/scala/atto/Generators.scala index 2dd75ad..b8f84ea 100644 --- a/modules/tests/src/test/scala/atto/Generators.scala +++ b/modules/tests/src/test/scala/atto/Generators.scala @@ -3,6 +3,7 @@ package atto import org.scalacheck.Gen object Generators { - val whitespace: Gen[Char] = - Gen.oneOf('\n', ' ', '\t') + val whitespace: Gen[Char] = Gen.oneOf('\n', ' ', '\t') + + val horizontalWhitespace = Gen.oneOf(CharClass.horizontalWhitespaceChars) }