We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
2 parents 7650a5d + 9094ff2 commit 02183d8Copy full SHA for 02183d8
shared/src/test/scala/scala/util/parsing/combinator/t3212.scala
@@ -0,0 +1,27 @@
1
+package scala.util.parsing.combinator
2
+
3
+import org.junit.Test
4
+import org.junit.Assert.assertEquals
5
6
+class t3212 extends RegexParsers {
7
8
+ sealed trait BuySell
9
+ case object BUY extends BuySell
10
+ case object SELL extends BuySell
11
12
+ def buy_sell: Parser[BuySell] =
13
+ "to" ~> "buy" ^^^ BUY |
14
+ "to" ~> "sell" ^^^ SELL |
15
+ failure("buy or sell expected")
16
17
+ @Test
18
+ def test: Unit = {
19
+ val parseResult = parse[BuySell](phrase(buy_sell), "bought")
20
21
+ val expected = """[1.1] failure: buy or sell expected
22
23
+bought
24
+^"""
25
+ assertEquals(expected, parseResult.toString)
26
+ }
27
+}
0 commit comments