Skip to content

Commit 02183d8

Browse files
authored
Merge pull request scala#159 from Philippus/issue-3212
Add test showing scala/bug#3212 is fixed
2 parents 7650a5d + 9094ff2 commit 02183d8

File tree

1 file changed

+27
-0
lines changed
  • shared/src/test/scala/scala/util/parsing/combinator

1 file changed

+27
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -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

Comments
 (0)