mirror of
https://github.com/vlang/v.git
synced 2023-08-10 21:13:21 +03:00
cgen: allow for const ( x = opt() ? )
This commit is contained in:
17
vlib/regex/simple_const_regex_test.v
Normal file
17
vlib/regex/simple_const_regex_test.v
Normal file
@@ -0,0 +1,17 @@
|
||||
import regex
|
||||
|
||||
const (
|
||||
a_or_b = regex.regex_opt('a|b') ?
|
||||
)
|
||||
|
||||
fn f(s string) bool {
|
||||
mut re := a_or_b
|
||||
start, _ := re.match_string(s)
|
||||
return start != -1
|
||||
}
|
||||
|
||||
fn test_const_regex_works() {
|
||||
assert f('a') == true
|
||||
assert f('b') == true
|
||||
assert f('c') == false
|
||||
}
|
||||
Reference in New Issue
Block a user