Skip to content

Commit

Permalink
Fix CommentParserTest
Browse files Browse the repository at this point in the history
  • Loading branch information
lenguyenthanh committed Apr 12, 2024
1 parent 3cd4f66 commit 0927db1
Showing 1 changed file with 16 additions and 13 deletions.
29 changes: 16 additions & 13 deletions modules/study/src/test/CommentParserTest.scala
Original file line number Diff line number Diff line change
Expand Up @@ -78,47 +78,50 @@ class CommentParserTest extends lila.common.LilaTest:
assertEquals(C("Hello there [%clk 10:40:33.556] something else").clock, Some(Centis(3843356)))

test("parse shapes: empty"):
assertEquals(C(""), C.ParsedComment(Shapes(Nil), None, ""))
assertEquals(C(""), C.ParsedComment(Shapes(Nil), None, None, ""))

test("parse shapes: without"):
assertEquals(C("Hello there"), C.ParsedComment(Shapes(Nil), None, "Hello there"))
assertEquals(C("Hello there"), C.ParsedComment(Shapes(Nil), None, None, "Hello there"))

test("parse shapes: at start"):
assertMatch(C("[%csl Gb4,Yd5,Rf6] Hello there")) { case C.ParsedComment(shapes, None, "Hello there") =>
shapes.value.size == 3
assertMatch(C("[%csl Gb4,Yd5,Rf6] Hello there")) {
case C.ParsedComment(shapes, None, None, "Hello there") =>
shapes.value.size == 3
}

test("parse shapes: at end"):
assertMatch(C("Hello there [%csl Gb4,Yd5,Rf6]")) { case C.ParsedComment(shapes, None, "Hello there") =>
shapes.value.size == 3
assertMatch(C("Hello there [%csl Gb4,Yd5,Rf6]")) {
case C.ParsedComment(shapes, None, None, "Hello there") =>
shapes.value.size == 3
}

test("parse shapes: multiple"):
assertMatch(C("Hello there [%csl Gb4,Yd5,Rf6][%cal Ge2e4,Ye2d4,Re2g4]")) {
case C.ParsedComment(shapes, None, "Hello there") => shapes.value.size == 6
case C.ParsedComment(shapes, None, None, "Hello there") => shapes.value.size == 6
}

test("parse shapes: new lines"):
assertMatch(C("Hello there [%csl\nGb4,Yd5,Rf6]")) { case C.ParsedComment(shapes, None, "Hello there") =>
shapes.value.size == 3
assertMatch(C("Hello there [%csl\nGb4,Yd5,Rf6]")) {
case C.ParsedComment(shapes, None, None, "Hello there") =>
shapes.value.size == 3
}

test("parse shapes: multiple, one new line"):
assertMatch(C("Hello there [%csl\nGb4,Yd5,Rf6][%cal Ge2e4,Ye2d4,Re2g4]")) {
case C.ParsedComment(shapes, None, "Hello there") => shapes.value.size == 6
case C.ParsedComment(shapes, None, None, "Hello there") => shapes.value.size == 6
}
assertMatch(C("Hello there [%csl Gb4,Yd5,Rf6][%cal\nGe2e4,Ye2d4,Re2g4]")) {
case C.ParsedComment(shapes, None, "Hello there") => shapes.value.size == 6
case C.ParsedComment(shapes, None, None, "Hello there") => shapes.value.size == 6
}

test("parse shapes: multiple mess"):
assertMatch(C("Hello there [%csl \n\n Gb4,Yd5,Rf6][%cal\nGe2e4,Ye2d4,Re2g4]")) {
case C.ParsedComment(shapes, None, "Hello there") => shapes.value.size == 6
case C.ParsedComment(shapes, None, None, "Hello there") => shapes.value.size == 6
}

test("multiple shapes + clock"):
assertMatch(C("Hello there [%clk 10:40:33][%csl \n\n Gb4,Yd5,Rf6][%cal\nGe2e4,Ye2d4,Re2g4]")) {
case C.ParsedComment(shapes, clock, "Hello there") =>
case C.ParsedComment(shapes, clock, None, "Hello there") =>
shapes.value.size == 6 &&
clock == Some(Centis(3843300))
}

0 comments on commit 0927db1

Please sign in to comment.