Skip to content

Commit

Permalink
term.ui, vweb, v: update deprecated functions (#18726)
Browse files Browse the repository at this point in the history
  • Loading branch information
ttytm committed Jul 2, 2023
1 parent 5d4c2cd commit a27f2dd
Show file tree
Hide file tree
Showing 18 changed files with 32 additions and 32 deletions.
2 changes: 1 addition & 1 deletion examples/term.ui/cursor_chaser.v
Original file line number Diff line number Diff line change
Expand Up @@ -92,5 +92,5 @@ fn main() {
event_fn: event
hide_cursor: true
)
app.tui.run()?
app.tui.run()!
}
2 changes: 1 addition & 1 deletion examples/term.ui/event_viewer.v
Original file line number Diff line number Diff line change
Expand Up @@ -42,5 +42,5 @@ fn main() {
use_alternate_buffer: false
)
println('V term.ui event viewer (press `esc` to exit)\n\n')
app.tui.run()?
app.tui.run()!
}
2 changes: 1 addition & 1 deletion examples/term.ui/pong.v
Original file line number Diff line number Diff line change
Expand Up @@ -493,5 +493,5 @@ fn main() {
hide_cursor: true
frame_rate: 60
)
app.tui.run()?
app.tui.run()!
}
2 changes: 1 addition & 1 deletion examples/term.ui/rectangles.v
Original file line number Diff line number Diff line change
Expand Up @@ -91,5 +91,5 @@ fn main() {
hide_cursor: true
frame_rate: 60
)
app.tui.run()?
app.tui.run()!
}
2 changes: 1 addition & 1 deletion examples/term.ui/term_drawing.v
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ fn main() {
app.mouse_pos.x = 40
app.mouse_pos.y = 15
app.ui.clear()
app.ui.run()?
app.ui.run()!
}

fn frame(mut app App) {
Expand Down
2 changes: 1 addition & 1 deletion examples/term.ui/text_editor.v
Original file line number Diff line number Diff line change
Expand Up @@ -646,5 +646,5 @@ fn main() {
event_fn: event
capture_events: true
)
a.tui.run()?
a.tui.run()!
}
2 changes: 1 addition & 1 deletion examples/term.ui/vyper.v
Original file line number Diff line number Diff line change
Expand Up @@ -468,5 +468,5 @@ fn main() {
hide_cursor: true
frame_rate: 10
)
app.termui.run()?
app.termui.run()!
}
2 changes: 1 addition & 1 deletion vlib/term/ui/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ fn main() {
frame_fn: frame
hide_cursor: true
)
app.tui.run()?
app.tui.run()!
}
```

Expand Down
2 changes: 1 addition & 1 deletion vlib/term/ui/input_nix.c.v
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ fn load_title() {
}

// run sets up and starts the terminal.
pub fn (mut ctx Context) run() ? {
pub fn (mut ctx Context) run() ! {
if ctx.cfg.use_x11 {
ctx.fail('error: x11 backend not implemented yet')
exit(1)
Expand Down
2 changes: 1 addition & 1 deletion vlib/term/ui/input_windows.c.v
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ pub fn init(cfg Config) &Context {
}

// run starts the windows console or restarts if it was paused.
pub fn (mut ctx Context) run() ? {
pub fn (mut ctx Context) run() ! {
frame_time := 1_000_000 / ctx.cfg.frame_rate
mut init_called := false
mut sw := time.new_stopwatch(auto_start: false)
Expand Down
6 changes: 3 additions & 3 deletions vlib/v/eval/interpret_test.v
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@ fn test_interpret() {
mut bench := benchmark.new_benchmark()
vexe := os.getenv('VEXE')
vroot := os.dir(vexe)
os.chdir(vroot)?
os.chdir(vroot)!
dir := os.join_path(vroot, 'vlib/v/eval/testdata')
files := os.ls(dir)?
files := os.ls(dir)!
//
tests := files.filter(it.ends_with('.vv'))
if tests.len == 0 {
Expand All @@ -35,7 +35,7 @@ fn test_interpret() {
eprintln(res.output)
continue
}
mut expected := os.read_file('${dir}/${test_name_without_postfix}.out')?
mut expected := os.read_file('${dir}/${test_name_without_postfix}.out')!
expected = normalise_line_endings(expected)
mut found := normalise_line_endings(res.output)
found = found.trim_space()
Expand Down
2 changes: 1 addition & 1 deletion vlib/v/gen/js/program_test.v
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ fn test_running_programs_compiled_with_the_js_backend() {
os.chdir(vroot) or {}
test_dir := 'vlib/v/gen/js/tests/testdata'
main_files := get_main_files_in_dir(test_dir)
fails := check_path(test_dir, main_files)?
fails := check_path(test_dir, main_files)!
assert fails == 0
}

Expand Down
4 changes: 2 additions & 2 deletions vlib/v/tests/generics_with_nested_external_generics_fn_test.v
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import rand

pub fn sample[T](arr []T, k int) ?[]T {
pub fn sample[T](arr []T, k int) ![]T {
mut result := arr.clone()

rand.seed([u32(1), 2]) // set seed to produce same results in order
rand.shuffle[T](mut result)?
rand.shuffle[T](mut result)!

return result[0..k]
}
Expand Down
2 changes: 1 addition & 1 deletion vlib/v/tests/match_aliases_test.v
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
fn test_match_aliases() {
a := byte(97)
a := u8(97)
ret := match a {
`0`...`9`, `a`...`f` { 'OK' }
else { 'NOT OK' }
Expand Down
12 changes: 6 additions & 6 deletions vlib/v/tests/match_expr_with_assign_sumtype_test.v
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ enum State {
parse_operator
}

fn tokenise(args string) ?[]Value {
fn tokenise(args string) ![]Value {
mut rv := []Value{}

mut state := State.expecting
Expand All @@ -34,7 +34,7 @@ fn tokenise(args string) ?[]Value {
match i {
`0`...`9` {
state = .parse_num
cur_value = int(i.str().parse_uint(10, 8)?)
cur_value = int(i.str().parse_uint(10, 8)!)
}
`+`, `-`, `*`, `/` {
state = .parse_operator
Expand Down Expand Up @@ -67,7 +67,7 @@ fn tokenise(args string) ?[]Value {
.parse_num {
match i {
`0`...`9` {
cur_value = 10 + int(i.str().parse_uint(10, 8)?)
cur_value = 10 + int(i.str().parse_uint(10, 8)!)
}
`+`, `-`, `*`, `/` {
state = .parse_operator
Expand All @@ -94,7 +94,7 @@ fn tokenise(args string) ?[]Value {
`0`...`9` {
state = .parse_num
rv << cur_value
cur_value = int(i.str().parse_uint(10, 8)?)
cur_value = int(i.str().parse_uint(10, 8)!)
}
` ` {
state = .expecting
Expand All @@ -111,11 +111,11 @@ fn tokenise(args string) ?[]Value {
return rv
}

fn parse_args(argv []string) ?Expression {
fn parse_args(argv []string) !Expression {
rv := Expression{
val: 1
}
tokens := tokenise(argv.join(' '))?
tokens := tokenise(argv.join(' '))!

println(tokens)
assert '${tokens}' == '[Value(1), Value(add), Value(subtract), Value(multiply), Value(divide)]'
Expand Down
10 changes: 5 additions & 5 deletions vlib/v/tests/shared_array_sort_test.v
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,11 @@ fn test_sorting_shared_arrays() {
alarms := Alarms{}
utc := time.utc()
alarms.add(utc)
alarms.add(time.parse_iso8601('2022-03-01')?)
alarms.add(time.parse_iso8601('3001-03-01')?)
alarms.add(time.parse_iso8601('2002-03-01')?)
alarms.add(time.parse_iso8601('3002-03-01')?)
alarms.add(time.parse_iso8601('2021-03-01')?)
alarms.add(time.parse_iso8601('2022-03-01')!)
alarms.add(time.parse_iso8601('3001-03-01')!)
alarms.add(time.parse_iso8601('2002-03-01')!)
alarms.add(time.parse_iso8601('3002-03-01')!)
alarms.add(time.parse_iso8601('2021-03-01')!)
println(alarms)
lock alarms.times {
assert alarms.times.len == 6
Expand Down
4 changes: 2 additions & 2 deletions vlib/v/vmod/parser_test.v
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ fn test_ok() {
}"
for s in [ok_source, ok_source.replace(apos, quote), ok_source.replace('\n', '\r\n'),
ok_source.replace('\n', '\r\n '), ok_source.replace('\n', '\n ')] {
content := vmod.decode(s)?
content := vmod.decode(s)!
assert content.name == 'V'
assert content.description == 'The V programming language.'
assert content.version == '0.7.7'
Expand All @@ -24,7 +24,7 @@ fn test_ok() {
assert content.dependencies == []
assert content.unknown == {}
}
e := vmod.decode('Module{}')?
e := vmod.decode('Module{}')!
assert e.name == ''
assert e.description == ''
assert e.version == ''
Expand Down
4 changes: 2 additions & 2 deletions vlib/vweb/csrf/csrf_test.v
Original file line number Diff line number Diff line change
Expand Up @@ -268,7 +268,7 @@ fn test_token_with_app() {
res := http.get('http://${localserver}/') or { panic(err) }

mut doc := html.parse(res.body)
inputs := doc.get_tag_by_attribute_value('type', 'hidden')
inputs := doc.get_tags_by_attribute_value('type', 'hidden')
assert inputs.len == 1
assert csrf_config.token_name == inputs[0].attributes['name']
}
Expand All @@ -277,7 +277,7 @@ fn test_token_with_middleware() {
res := http.get('http://${localserver}/middleware_index') or { panic(err) }

mut doc := html.parse(res.body)
inputs := doc.get_tag_by_attribute_value('type', 'hidden')
inputs := doc.get_tags_by_attribute_value('type', 'hidden')
assert inputs.len == 1
assert csrf_config.token_name == inputs[0].attributes['name']
}
Expand Down

0 comments on commit a27f2dd

Please sign in to comment.