From e55975594bf8ec418f35fc3cef312b6e8d07267d Mon Sep 17 00:00:00 2001 From: Philippus Date: Wed, 27 Jun 2018 23:10:26 +0200 Subject: [PATCH 1/2] Add test showing scala/bug#3212 is fixed --- .../scala/util/parsing/combinator/t3212.scala | 27 +++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 shared/src/test/scala/scala/util/parsing/combinator/t3212.scala diff --git a/shared/src/test/scala/scala/util/parsing/combinator/t3212.scala b/shared/src/test/scala/scala/util/parsing/combinator/t3212.scala new file mode 100644 index 00000000..79122aa7 --- /dev/null +++ b/shared/src/test/scala/scala/util/parsing/combinator/t3212.scala @@ -0,0 +1,27 @@ +package scala.util.parsing.combinator + +import org.junit.Test +import org.junit.Assert.assertEquals + +class t3212 extends RegexParsers { + + sealed trait BuySell + case object BUY extends BuySell + case object SELL extends BuySell + + def buy_sell: Parser[BuySell] = + "to" ~> "buy" ^^^ BUY | + "to" ~> "sell" ^^^ SELL | + failure("buy or sell expected") + + @Test + def test: Unit = { + val parseResult = parse[BuySell](phrase(buy_sell), "bought") + + val expected = """[1.1] failure: buy or sell expected + +bought +^""" + assertEquals(expected, parseResult.toString) + } +} From 9094ff282dbc5b95011bf9a3c6e24d964b0d7271 Mon Sep 17 00:00:00 2001 From: Philippus Date: Tue, 10 Jul 2018 22:24:56 +0200 Subject: [PATCH 2/2] Fix indentation --- .../scala/scala/util/parsing/combinator/t3212.scala | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/shared/src/test/scala/scala/util/parsing/combinator/t3212.scala b/shared/src/test/scala/scala/util/parsing/combinator/t3212.scala index 79122aa7..b48f811e 100644 --- a/shared/src/test/scala/scala/util/parsing/combinator/t3212.scala +++ b/shared/src/test/scala/scala/util/parsing/combinator/t3212.scala @@ -5,12 +5,12 @@ import org.junit.Assert.assertEquals class t3212 extends RegexParsers { - sealed trait BuySell - case object BUY extends BuySell - case object SELL extends BuySell + sealed trait BuySell + case object BUY extends BuySell + case object SELL extends BuySell - def buy_sell: Parser[BuySell] = - "to" ~> "buy" ^^^ BUY | + def buy_sell: Parser[BuySell] = + "to" ~> "buy" ^^^ BUY | "to" ~> "sell" ^^^ SELL | failure("buy or sell expected")