Skip to content
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)
}
}