Skip to content

Add test showing scala/bug#3212 is fixed #159

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jul 17, 2018
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 27 additions & 0 deletions shared/src/test/scala/scala/util/parsing/combinator/t3212.scala
Original file line number Diff line number Diff line change
@@ -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)
}
}