mirror of
https://github.com/vlang/v.git
synced 2025-09-10 16:00:31 -04:00
parent
96eada1835
commit
a67bfebe95
@ -435,6 +435,10 @@ fn run_repl(workdir string, vrepl_prefix string) int {
|
|||||||
if s.output.len > r.last_output.len {
|
if s.output.len > r.last_output.len {
|
||||||
cur_line_output := s.output[r.last_output.len..]
|
cur_line_output := s.output[r.last_output.len..]
|
||||||
print_output(cur_line_output)
|
print_output(cur_line_output)
|
||||||
|
if s.exit_code == 0 {
|
||||||
|
r.last_output = s.output.clone()
|
||||||
|
r.lines << r.line
|
||||||
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
mut temp_line := r.line
|
mut temp_line := r.line
|
||||||
@ -442,9 +446,7 @@ fn run_repl(workdir string, vrepl_prefix string) int {
|
|||||||
filter_line := r.line.replace(r.line.find_between("'", "'"), '').replace(r.line.find_between('"',
|
filter_line := r.line.replace(r.line.find_between("'", "'"), '').replace(r.line.find_between('"',
|
||||||
'"'), '')
|
'"'), '')
|
||||||
mut is_statement := false
|
mut is_statement := false
|
||||||
if func_call {
|
if filter_line.count('=') % 2 == 1
|
||||||
is_statement = true
|
|
||||||
} else if filter_line.count('=') % 2 == 1
|
|
||||||
&& (filter_line.count('!=') + filter_line.count('>=') + filter_line.count('<=')) == 0 {
|
&& (filter_line.count('!=') + filter_line.count('>=') + filter_line.count('<=')) == 0 {
|
||||||
is_statement = true
|
is_statement = true
|
||||||
} else {
|
} else {
|
||||||
@ -467,6 +469,10 @@ fn run_repl(workdir string, vrepl_prefix string) int {
|
|||||||
if s.output.len > r.last_output.len {
|
if s.output.len > r.last_output.len {
|
||||||
cur_line_output := s.output[r.last_output.len..]
|
cur_line_output := s.output[r.last_output.len..]
|
||||||
print_output(cur_line_output)
|
print_output(cur_line_output)
|
||||||
|
if s.exit_code == 0 {
|
||||||
|
r.last_output = s.output.clone()
|
||||||
|
r.lines << temp_line
|
||||||
|
}
|
||||||
}
|
}
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
@ -478,6 +484,8 @@ fn run_repl(workdir string, vrepl_prefix string) int {
|
|||||||
}
|
}
|
||||||
} else if temp_line.starts_with('#include ') {
|
} else if temp_line.starts_with('#include ') {
|
||||||
temp_source_code = '${temp_line}\n' + r.current_source_code(false, false)
|
temp_source_code = '${temp_line}\n' + r.current_source_code(false, false)
|
||||||
|
} else if temp_line.starts_with('fn') {
|
||||||
|
temp_source_code = r.current_source_code(false, false)
|
||||||
} else {
|
} else {
|
||||||
temp_source_code = r.current_source_code(true, false) + '\n${temp_line}\n'
|
temp_source_code = r.current_source_code(true, false) + '\n${temp_line}\n'
|
||||||
}
|
}
|
||||||
@ -490,6 +498,8 @@ fn run_repl(workdir string, vrepl_prefix string) int {
|
|||||||
r.parse_import(r.line)
|
r.parse_import(r.line)
|
||||||
} else if r.line.starts_with('#include ') {
|
} else if r.line.starts_with('#include ') {
|
||||||
r.includes << r.line
|
r.includes << r.line
|
||||||
|
} else if r.line.starts_with('fn ') {
|
||||||
|
r.functions << r.line
|
||||||
} else {
|
} else {
|
||||||
r.lines << r.line
|
r.lines << r.line
|
||||||
}
|
}
|
||||||
|
@ -1,3 +1,3 @@
|
|||||||
print($tmpl('./tmpl/hello.txt'))
|
$tmpl('./tmpl/hello.txt')
|
||||||
===output===
|
===output===
|
||||||
hello
|
hello
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
println(math.sinf(50.0))
|
math.sinf(50.0)
|
||||||
println(1+math.sinf(50.0))
|
println(1+math.sinf(50.0))
|
||||||
fn test() { println('foo') } fn test2(a int) { println(a) }
|
fn test() { println('foo') } fn test2(a int) { println(a) }
|
||||||
test()
|
test()
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
import encoding.hex as z
|
import encoding.hex as z
|
||||||
print(z.decode('AB09CD')!.hex())
|
z.decode('AB09CD')!.hex()
|
||||||
===output===
|
===output===
|
||||||
ab09cd
|
ab09cd
|
||||||
|
@ -4,4 +4,5 @@ values.pop()
|
|||||||
values
|
values
|
||||||
===output===
|
===output===
|
||||||
[1, 2, 3]
|
[1, 2, 3]
|
||||||
|
3
|
||||||
[1, 2]
|
[1, 2]
|
8
vlib/v/slow_tests/repl/method_call2.repl
Normal file
8
vlib/v/slow_tests/repl/method_call2.repl
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
mut values := [1, 2, 3]
|
||||||
|
values
|
||||||
|
println(values.pop())
|
||||||
|
values
|
||||||
|
===output===
|
||||||
|
[1, 2, 3]
|
||||||
|
3
|
||||||
|
[1, 2]
|
Loading…
x
Reference in New Issue
Block a user