Skip to content

Commit

Permalink
vrepl: fix output of the fn call
Browse files Browse the repository at this point in the history
  • Loading branch information
yuyi98 committed Jul 4, 2024
1 parent 0c2d72f commit 0dd0311
Show file tree
Hide file tree
Showing 6 changed files with 17 additions and 6 deletions.
8 changes: 5 additions & 3 deletions cmd/tools/vrepl.v
Original file line number Diff line number Diff line change
Expand Up @@ -435,16 +435,16 @@ fn run_repl(workdir string, vrepl_prefix string) int {
if s.output.len > r.last_output.len {
cur_line_output := s.output[r.last_output.len..]
print_output(cur_line_output)
r.last_output = s.output.clone()
r.lines << r.line
}
} else {
mut temp_line := r.line
func_call, fntype := r.function_call(r.line)
filter_line := r.line.replace(r.line.find_between("'", "'"), '').replace(r.line.find_between('"',
'"'), '')
mut is_statement := false
if func_call {
is_statement = true
} else if filter_line.count('=') % 2 == 1
if filter_line.count('=') % 2 == 1
&& (filter_line.count('!=') + filter_line.count('>=') + filter_line.count('<=')) == 0 {
is_statement = true
} else {
Expand All @@ -467,6 +467,8 @@ fn run_repl(workdir string, vrepl_prefix string) int {
if s.output.len > r.last_output.len {
cur_line_output := s.output[r.last_output.len..]
print_output(cur_line_output)
r.last_output = s.output.clone()
r.lines << temp_line
}
continue
}
Expand Down
2 changes: 1 addition & 1 deletion vlib/v/slow_tests/repl/comptime_tmpl.repl
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
print($tmpl('./tmpl/hello.txt'))
$tmpl('./tmpl/hello.txt')
===output===
hello
2 changes: 1 addition & 1 deletion vlib/v/slow_tests/repl/fn_calls.repl
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
println(math.sinf(50.0))
math.sinf(50.0)
println(1+math.sinf(50.0))
fn test() { println('foo') } fn test2(a int) { println(a) }
test()
Expand Down
2 changes: 1 addition & 1 deletion vlib/v/slow_tests/repl/import_alias.repl
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import encoding.hex as z
print(z.decode('AB09CD')!.hex())
z.decode('AB09CD')!.hex()
===output===
ab09cd
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,5 @@ values.pop()
values
===output===
[1, 2, 3]
3
[1, 2]
8 changes: 8 additions & 0 deletions vlib/v/slow_tests/repl/method_call2.repl
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
mut values := [1, 2, 3]
values
println(values.pop())
values
===output===
[1, 2, 3]
3
[1, 2]

0 comments on commit 0dd0311

Please sign in to comment.