mirror of
https://github.com/vlang/v.git
synced 2025-09-13 09:25:45 -04:00
parent
59909cde89
commit
72f45e4434
@ -2762,7 +2762,8 @@ fn (mut p Parser) name_expr() ast.Expr {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
// Raw string (`s := r'hello \n ')
|
// Raw string (`s := r'hello \n ')
|
||||||
if p.peek_tok.kind == .string && !p.inside_str_interp && p.peek_token(2).kind != .colon {
|
if p.peek_tok.kind == .string && p.tok.line_nr == p.peek_tok.line_nr && !p.inside_str_interp
|
||||||
|
&& p.peek_token(2).kind != .colon {
|
||||||
if p.tok.kind == .name && p.tok.lit in ['r', 'c', 'js'] {
|
if p.tok.kind == .name && p.tok.lit in ['r', 'c', 'js'] {
|
||||||
return p.string_expr()
|
return p.string_expr()
|
||||||
} else {
|
} else {
|
||||||
|
28
vlib/v/tests/if_elseif_else_test.v
Normal file
28
vlib/v/tests/if_elseif_else_test.v
Normal file
@ -0,0 +1,28 @@
|
|||||||
|
module main
|
||||||
|
|
||||||
|
fn if_expt(this int) (string, int) {
|
||||||
|
inc := 1
|
||||||
|
mut count := 0
|
||||||
|
thing := if this in [0, 1, 2] {
|
||||||
|
count += 1
|
||||||
|
'0..2'
|
||||||
|
} else if this in [3, 4, 5] {
|
||||||
|
count += inc
|
||||||
|
'3..5'
|
||||||
|
} else {
|
||||||
|
'not 0..5'
|
||||||
|
}
|
||||||
|
return thing, count
|
||||||
|
}
|
||||||
|
|
||||||
|
fn test_main() {
|
||||||
|
a, b := if_expt(1)
|
||||||
|
assert a == '0..2'
|
||||||
|
assert b == 1
|
||||||
|
c, d := if_expt(4)
|
||||||
|
assert c == '3..5'
|
||||||
|
assert d == 1
|
||||||
|
e, f := if_expt(7)
|
||||||
|
assert e == 'not 0..5'
|
||||||
|
assert f == 0
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user