mirror of
https://github.com/vlang/v.git
synced 2023-08-10 21:13:21 +03:00
repl: functions and conditional blocks support
This commit is contained in:

committed by
Alexander Medvednikov

parent
ecc8059a9e
commit
e1d2c83ff6
18
compiler/tests/repl/conditional_blocks.repl
Normal file
18
compiler/tests/repl/conditional_blocks.repl
Normal file
@ -0,0 +1,18 @@
|
||||
if true {
|
||||
println('foo')
|
||||
}
|
||||
for i := 0; i < 4; i++ {
|
||||
println(i)
|
||||
}
|
||||
if false {
|
||||
println('foo')
|
||||
} else {
|
||||
println('bar')
|
||||
}
|
||||
===output===
|
||||
foo
|
||||
0
|
||||
1
|
||||
2
|
||||
3
|
||||
bar
|
11
compiler/tests/repl/function.repl
Normal file
11
compiler/tests/repl/function.repl
Normal file
@ -0,0 +1,11 @@
|
||||
fn test() {
|
||||
println('foo')
|
||||
}
|
||||
test()
|
||||
fn test2(a int) {
|
||||
println(a)
|
||||
}
|
||||
test2(42)
|
||||
===output===
|
||||
foo
|
||||
42
|
@ -14,7 +14,7 @@ fn test_repl() {
|
||||
assert false
|
||||
break
|
||||
}
|
||||
result := r.output.replace('>>> ', '').replace('>>>', '').all_after('Use Ctrl-C or `exit` to exit\n')
|
||||
result := r.output.replace('>>> ', '').replace('>>>', '').replace('... ', '').all_after('Use Ctrl-C or `exit` to exit\n')
|
||||
assert result == output
|
||||
if result != output {
|
||||
println(file)
|
||||
|
Reference in New Issue
Block a user