File tree Expand file tree Collapse file tree 2 files changed +9
-7
lines changed
Expand file tree Collapse file tree 2 files changed +9
-7
lines changed Original file line number Diff line number Diff line change @@ -21,17 +21,17 @@ object TournamentClock:
2121
2222 object parse :
2323
24- private val cleanRegex = " (move|minutes|minute|min|m|seconds|second|sec|s|'|\" |/ )" .r
24+ private val cleanRegex = " (/ move|minutes|minute|min|m|seconds|second|sec|s|'|\" )" .r
2525
2626 private def make (a : Int , b : Int ) =
2727 val limit = LimitSeconds (if a > 180 then a else a * 60 )
2828 TournamentClock (limit, IncrementSeconds (b))
2929
3030 def apply (str : String ): Option [TournamentClock ] =
3131 cleanRegex
32- .replaceAllIn(str.toLowerCase, " " )
33- .replace( " " , " " )
34- .split( '+' ) match
35- case Array (a) => a.toIntOption.map(make(_, 0 ))
36- case Array (a, b) => (a.toIntOption, b.toIntOption).mapN(make)
37- case _ => none
32+ .replaceAllIn(str.toLowerCase.replace( " " , " " ) , " " )
33+ .split( '+' )
34+ .match
35+ case Array (a) => a.toIntOption.map(make(_, 0 ))
36+ case Array (a, b) => (a.toIntOption, b.toIntOption).mapN(make)
37+ case _ => none
Original file line number Diff line number Diff line change @@ -43,5 +43,7 @@ class TournamentClockTest extends ChessTest:
4343 assertEquals(parse(" 180" ), someClock(180 , 0 ))
4444 assertEquals(parse(" 240" ), someClock(4 , 0 ))
4545
46+ assertEquals(parse(" 120 min / 40 moves + 30 min" ), None )
47+
4648 // we're not there yet
4749 // assertEquals(parse("90 min / 40 moves + 30 min + 30 sec / move"), ???)
You can’t perform that action at this time.
0 commit comments