2019-08-18 18:21:48 +03:00
|
|
|
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
|
|
|
|
}
|
2019-08-18 22:50:38 +03:00
|
|
|
result := r.output.replace('>>> ', '').replace('>>>', '').replace('... ', '').all_after('Use Ctrl-C or `exit` to exit\n')
|
2019-08-18 18:21:48 +03:00
|
|
|
assert result == output
|
|
|
|
if result != output {
|
|
|
|
println(file)
|
|
|
|
println('Got : $result')
|
|
|
|
println('Expected : $output')
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|