mirror of
https://github.com/vlang/v.git
synced 2023-08-10 21:13:21 +03:00
tests: v implementation of repl tests
This commit is contained in:

committed by
Alexander Medvednikov

parent
aae063b9ad
commit
14f13ff55a
25
compiler/tests/repl/repl_test.v
Normal file
25
compiler/tests/repl/repl_test.v
Normal file
@ -0,0 +1,25 @@
|
||||
import os
|
||||
|
||||
fn test_repl() {
|
||||
test_files := os.walk_ext('.', '.repl')
|
||||
|
||||
for file in test_files {
|
||||
content := os.read_file(file) or {
|
||||
assert false
|
||||
break
|
||||
}
|
||||
input := content.all_before('===output===\n').replace('$', '\\$')
|
||||
output := content.all_after('===output===\n')
|
||||
r := os.exec('echo "$input" | ./v') or {
|
||||
assert false
|
||||
break
|
||||
}
|
||||
result := r.output.replace('>>> ', '').replace('>>>', '').all_after('Use Ctrl-C or `exit` to exit\n')
|
||||
assert result == output
|
||||
if result != output {
|
||||
println(file)
|
||||
println('Got : $result')
|
||||
println('Expected : $output')
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user