Skip to content

Commit 532e8b8

Browse files
committed
Use infix function instead backticks.
1 parent 8fa3062 commit 532e8b8

6 files changed

Lines changed: 389 additions & 390 deletions

File tree

artifact/src/test/scala/BasicCombinatorsTest.scala

Lines changed: 30 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -12,61 +12,61 @@ trait BasicCombinatorTests {
1212
describe("parser \"abc\"") {
1313
val p = 'a' ~ 'b' ~ 'c'
1414

15-
p `shouldParse` "abc"
16-
p `shouldNotParse` "abcd"
15+
p shouldParse "abc"
16+
p shouldNotParse "abcd"
1717
}
1818

1919
describe("parser \"ab | ac\"") {
2020
val p = ('a' ~ 'b') | ('a' ~ 'c')
21-
p `shouldParse` "ab"
22-
p `shouldParse` "ac"
23-
p `shouldNotParse` "bc"
24-
p `shouldNotParse` "a"
25-
p `shouldNotParse` "abc"
21+
p shouldParse "ab"
22+
p shouldParse "ac"
23+
p shouldNotParse "bc"
24+
p shouldNotParse "a"
25+
p shouldNotParse "abc"
2626
}
2727

2828
describe("parser \"baaa | ba\"") {
2929
val p = ('b' ~ 'a' ~ 'a' ~ 'a') | 'b' ~ 'a'
30-
p `shouldParse` "baaa"
31-
p `shouldParse` "ba"
32-
((p ~ 'c' ~ 'o') | (p ~ 'c')) `shouldParse` "bac"
33-
((p ~ 'c' ~ 'o') | (p ~ 'c')) `shouldParse` "baco"
30+
p shouldParse "baaa"
31+
p shouldParse "ba"
32+
((p ~ 'c' ~ 'o') | (p ~ 'c')) shouldParse "bac"
33+
((p ~ 'c' ~ 'o') | (p ~ 'c')) shouldParse "baco"
3434
}
3535

3636
describe("parser \"(baaa | ba) aa\"") {
3737
val p = ("baaa" | "ba") ~ "aa"
38-
p `shouldParse` "baaaaa"
39-
p `shouldParse` "baaa"
38+
p shouldParse "baaaaa"
39+
p shouldParse "baaa"
4040
}
4141

4242
describe("parser \"succeed(a) b\"") {
4343
val p = succ('a') ~ 'b'
44-
p `shouldParse` "b"
45-
p `shouldNotParse` ""
44+
p shouldParse "b"
45+
p shouldNotParse ""
4646
}
4747

4848
describe("parser \"succeed(a) succeed(b)\"") {
4949
val p = succ('a') ~ succ('b')
50-
p `shouldParse` ""
50+
p shouldParse ""
5151
}
5252

5353
describe("parser \"succeed(a) | succeed(b)\"") {
5454
val p = succ('a') | succ('b')
55-
p `shouldParse` ""
55+
p shouldParse ""
5656
}
5757

5858
describe("parser \"(a a a | a a)+") {
5959
val p = 'a' ~ 'a' ~ 'a' | 'a' ~ 'a'
60-
describe("some(_)") { some(p) `shouldParse` "aaaa" }
61-
describe("_ ~ 'b'") { (p ~ 'b') `shouldParse` "aaab" }
60+
describe("some(_)") { some(p) shouldParse "aaaa" }
61+
describe("_ ~ 'b'") { (p ~ 'b') shouldParse "aaab" }
6262
describe("some(_) ~ 'b'") {
63-
(some(p) ~ 'b') `shouldParse` "aab"
64-
(some(p) ~ 'b') `shouldParse` "aaab"
65-
(some(p) ~ 'b') `shouldParse` "aaaaab"
63+
(some(p) ~ 'b') shouldParse "aab"
64+
(some(p) ~ 'b') shouldParse "aaab"
65+
(some(p) ~ 'b') shouldParse "aaaaab"
6666
}
6767
describe("some(_ ~ 'a') ~ 'b'") {
68-
(some(p ~ 'a') ~ 'b') `shouldParse` "aaaab"
69-
(some(p ~ 'a') ~ 'b') `shouldParse` "aaab"
68+
(some(p ~ 'a') ~ 'b') shouldParse "aaaab"
69+
(some(p ~ 'a') ~ 'b') shouldParse "aaab"
7070
}
7171
}
7272

@@ -75,12 +75,12 @@ trait BasicCombinatorTests {
7575

7676
val largeInput = List.fill(100)('a').mkString
7777

78-
p `shouldParse` "a"
79-
p `shouldParse` "aaaaaa"
80-
p `shouldParse` largeInput
81-
p `shouldNotParse` ""
82-
p `shouldNotParse` "b" + largeInput
83-
p `shouldNotParse` largeInput + "b"
78+
p shouldParse "a"
79+
p shouldParse "aaaaaa"
80+
p shouldParse largeInput
81+
p shouldNotParse ""
82+
p shouldNotParse "b" + largeInput
83+
p shouldNotParse largeInput + "b"
8484
}
8585

8686
}

artifact/src/test/scala/CustomMatchers.scala

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,18 +12,18 @@ trait CustomMatchers[+P <: Parsers](val parsers: P) extends Matchers {
1212
import parsers.{Elem, Parser, accepts, isSuccess, parse}
1313

1414
extension [T](p: => Parser[T]) {
15-
def shouldParse(s: Iterable[Elem], tags: Tag*) =
15+
infix def shouldParse(s: Iterable[Elem], tags: Tag*) =
1616
it(s"""should parse "$s" """, tags*) {
17-
accepts(p, s) `shouldBe` true
17+
accepts(p, s) shouldBe true
1818
}
19-
def shouldNotParse(s: Iterable[Elem], tags: Tag*) =
19+
infix def shouldNotParse(s: Iterable[Elem], tags: Tag*) =
2020
it(s"""should not parse "$s" """, tags*) {
21-
accepts(p, s) `shouldBe` false
21+
accepts(p, s) shouldBe false
2222
}
2323
// for unambiguous parses
24-
def shouldParseWith(s: Iterable[Elem], result: T) =
24+
infix def shouldParseWith(s: Iterable[Elem], result: T) =
2525
it(s"""should parse "$s" with correct result""") {
26-
parse(p, s) `shouldBe` List(result)
26+
parse(p, s) shouldBe List(result)
2727
}
2828
}
2929

0 commit comments

Comments
 (0)