File tree 3 files changed +27
-1
lines changed 3 files changed +27
-1
lines changed Original file line number Diff line number Diff line change @@ -120,7 +120,7 @@ module Regexp =
120
120
let space = set [ ' ' ; '\t' ; '\r' ; '\n' ; '\v' ; '\f' ]
121
121
let all = set [ '\x20' .. '\x7E' ] + space
122
122
let digit = set [ '0' .. '9' ]
123
- let letter = set [ 'A' .. 'z' ]
123
+ let letter = set [ 'A' .. 'Z' ] + set [ 'a' .. ' z' ]
124
124
let word = letter + digit + set [ '_' ]
125
125
let w = ofSet word
126
126
let W = ofSet ( all - word)
Original file line number Diff line number Diff line change @@ -2,6 +2,8 @@ module Client.Tests
2
2
3
3
open Fable.Mocha
4
4
5
+ open Shared.Tests
6
+
5
7
6
8
let client = testList " Client" []
7
9
Original file line number Diff line number Diff line change @@ -117,6 +117,30 @@ module Regexp =
117
117
Expect.equal ( Regexp.maybe a) (!? a) " maybe should be an alias of (!?)"
118
118
Expect.equal ( Regexp.many a) (!+ a) " many should be an alias of (!+)"
119
119
Expect.equal ( Regexp.init 3 a) ( a ** 3 ) " init should be an alterantive for (**)"
120
+
121
+ testCase " Regex parsing" <| fun _ ->
122
+ let inline (= ?) actual expected = Expect.equal actual expected " should have been equal"
123
+ let parse str = str |> Regexp.tryParse |> Option.get
124
+ let fail str = Regexp.tryParse str =? None
125
+ let a = Regexp.singleton 'a'
126
+ let b = Regexp.singleton 'b'
127
+ let c = Regexp.singleton 'c'
128
+ parse " a|bb|cc" =? a + ( b * b) + ( c * c)
129
+ parse " a|b(b|c)c" =? a + ( b * ( b + c) * c)
130
+ parse " a|b(b|c)c*" =? a + ( b * ( b + c) * (!* c))
131
+ parse " (a|b(b|c)c)*" =? !* ( a + ( b * ( b + c) * c))
132
+ parse " " =? Regexp.empty
133
+ parse " ()" =? Regexp.empty
134
+ parse " (())" =? parse " ()"
135
+ parse " []" =? Regexp.none
136
+ parse " [A-Za-z_]" + Regexp.digit =? Regexp.word
137
+ parse " ." =? Regexp.dot
138
+ parse @" [!--\.]" =? Regexp.ofSet [ '!' .. '-' ] + Regexp.singleton '.'
139
+ parse @" \(\)" =? Regexp.ofSeq " ()"
140
+ fail " ("
141
+ fail " )"
142
+ fail " ())"
143
+ fail " {}"
120
144
]
121
145
122
146
You can’t perform that action at this time.
0 commit comments