1
0
mirror of https://github.com/vlang/v.git synced 2023-08-10 21:13:21 +03:00

term.ui, vweb, v: update deprecated functions (#18726)

This commit is contained in:
Turiiya 2023-07-02 08:38:33 +02:00 committed by GitHub
parent 5d4c2cd832
commit a27f2ddcc3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
18 changed files with 32 additions and 32 deletions

View File

@ -92,5 +92,5 @@ fn main() {
event_fn: event event_fn: event
hide_cursor: true hide_cursor: true
) )
app.tui.run()? app.tui.run()!
} }

View File

@ -42,5 +42,5 @@ fn main() {
use_alternate_buffer: false use_alternate_buffer: false
) )
println('V term.ui event viewer (press `esc` to exit)\n\n') println('V term.ui event viewer (press `esc` to exit)\n\n')
app.tui.run()? app.tui.run()!
} }

View File

@ -493,5 +493,5 @@ fn main() {
hide_cursor: true hide_cursor: true
frame_rate: 60 frame_rate: 60
) )
app.tui.run()? app.tui.run()!
} }

View File

@ -91,5 +91,5 @@ fn main() {
hide_cursor: true hide_cursor: true
frame_rate: 60 frame_rate: 60
) )
app.tui.run()? app.tui.run()!
} }

View File

@ -125,7 +125,7 @@ fn main() {
app.mouse_pos.x = 40 app.mouse_pos.x = 40
app.mouse_pos.y = 15 app.mouse_pos.y = 15
app.ui.clear() app.ui.clear()
app.ui.run()? app.ui.run()!
} }
fn frame(mut app App) { fn frame(mut app App) {

View File

@ -646,5 +646,5 @@ fn main() {
event_fn: event event_fn: event
capture_events: true capture_events: true
) )
a.tui.run()? a.tui.run()!
} }

View File

@ -468,5 +468,5 @@ fn main() {
hide_cursor: true hide_cursor: true
frame_rate: 10 frame_rate: 10
) )
app.termui.run()? app.termui.run()!
} }

View File

@ -39,7 +39,7 @@ fn main() {
frame_fn: frame frame_fn: frame
hide_cursor: true hide_cursor: true
) )
app.tui.run()? app.tui.run()!
} }
``` ```

View File

@ -44,7 +44,7 @@ fn load_title() {
} }
// run sets up and starts the terminal. // run sets up and starts the terminal.
pub fn (mut ctx Context) run() ? { pub fn (mut ctx Context) run() ! {
if ctx.cfg.use_x11 { if ctx.cfg.use_x11 {
ctx.fail('error: x11 backend not implemented yet') ctx.fail('error: x11 backend not implemented yet')
exit(1) exit(1)

View File

@ -101,7 +101,7 @@ pub fn init(cfg Config) &Context {
} }
// run starts the windows console or restarts if it was paused. // 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 frame_time := 1_000_000 / ctx.cfg.frame_rate
mut init_called := false mut init_called := false
mut sw := time.new_stopwatch(auto_start: false) mut sw := time.new_stopwatch(auto_start: false)

View File

@ -8,9 +8,9 @@ fn test_interpret() {
mut bench := benchmark.new_benchmark() mut bench := benchmark.new_benchmark()
vexe := os.getenv('VEXE') vexe := os.getenv('VEXE')
vroot := os.dir(vexe) vroot := os.dir(vexe)
os.chdir(vroot)? os.chdir(vroot)!
dir := os.join_path(vroot, 'vlib/v/eval/testdata') dir := os.join_path(vroot, 'vlib/v/eval/testdata')
files := os.ls(dir)? files := os.ls(dir)!
// //
tests := files.filter(it.ends_with('.vv')) tests := files.filter(it.ends_with('.vv'))
if tests.len == 0 { if tests.len == 0 {
@ -35,7 +35,7 @@ fn test_interpret() {
eprintln(res.output) eprintln(res.output)
continue 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) expected = normalise_line_endings(expected)
mut found := normalise_line_endings(res.output) mut found := normalise_line_endings(res.output)
found = found.trim_space() found = found.trim_space()

View File

@ -40,7 +40,7 @@ fn test_running_programs_compiled_with_the_js_backend() {
os.chdir(vroot) or {} os.chdir(vroot) or {}
test_dir := 'vlib/v/gen/js/tests/testdata' test_dir := 'vlib/v/gen/js/tests/testdata'
main_files := get_main_files_in_dir(test_dir) 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 assert fails == 0
} }

View File

@ -1,10 +1,10 @@
import rand import rand
pub fn sample[T](arr []T, k int) ?[]T { pub fn sample[T](arr []T, k int) ![]T {
mut result := arr.clone() mut result := arr.clone()
rand.seed([u32(1), 2]) // set seed to produce same results in order 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] return result[0..k]
} }

View File

@ -1,5 +1,5 @@
fn test_match_aliases() { fn test_match_aliases() {
a := byte(97) a := u8(97)
ret := match a { ret := match a {
`0`...`9`, `a`...`f` { 'OK' } `0`...`9`, `a`...`f` { 'OK' }
else { 'NOT OK' } else { 'NOT OK' }

View File

@ -23,7 +23,7 @@ enum State {
parse_operator parse_operator
} }
fn tokenise(args string) ?[]Value { fn tokenise(args string) ![]Value {
mut rv := []Value{} mut rv := []Value{}
mut state := State.expecting mut state := State.expecting
@ -34,7 +34,7 @@ fn tokenise(args string) ?[]Value {
match i { match i {
`0`...`9` { `0`...`9` {
state = .parse_num state = .parse_num
cur_value = int(i.str().parse_uint(10, 8)?) cur_value = int(i.str().parse_uint(10, 8)!)
} }
`+`, `-`, `*`, `/` { `+`, `-`, `*`, `/` {
state = .parse_operator state = .parse_operator
@ -67,7 +67,7 @@ fn tokenise(args string) ?[]Value {
.parse_num { .parse_num {
match i { match i {
`0`...`9` { `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 state = .parse_operator
@ -94,7 +94,7 @@ fn tokenise(args string) ?[]Value {
`0`...`9` { `0`...`9` {
state = .parse_num state = .parse_num
rv << cur_value rv << cur_value
cur_value = int(i.str().parse_uint(10, 8)?) cur_value = int(i.str().parse_uint(10, 8)!)
} }
` ` { ` ` {
state = .expecting state = .expecting
@ -111,11 +111,11 @@ fn tokenise(args string) ?[]Value {
return rv return rv
} }
fn parse_args(argv []string) ?Expression { fn parse_args(argv []string) !Expression {
rv := Expression{ rv := Expression{
val: 1 val: 1
} }
tokens := tokenise(argv.join(' '))? tokens := tokenise(argv.join(' '))!
println(tokens) println(tokens)
assert '${tokens}' == '[Value(1), Value(add), Value(subtract), Value(multiply), Value(divide)]' assert '${tokens}' == '[Value(1), Value(add), Value(subtract), Value(multiply), Value(divide)]'

View File

@ -16,11 +16,11 @@ fn test_sorting_shared_arrays() {
alarms := Alarms{} alarms := Alarms{}
utc := time.utc() utc := time.utc()
alarms.add(utc) alarms.add(utc)
alarms.add(time.parse_iso8601('2022-03-01')?) alarms.add(time.parse_iso8601('2022-03-01')!)
alarms.add(time.parse_iso8601('3001-03-01')?) alarms.add(time.parse_iso8601('3001-03-01')!)
alarms.add(time.parse_iso8601('2002-03-01')?) alarms.add(time.parse_iso8601('2002-03-01')!)
alarms.add(time.parse_iso8601('3002-03-01')?) alarms.add(time.parse_iso8601('3002-03-01')!)
alarms.add(time.parse_iso8601('2021-03-01')?) alarms.add(time.parse_iso8601('2021-03-01')!)
println(alarms) println(alarms)
lock alarms.times { lock alarms.times {
assert alarms.times.len == 6 assert alarms.times.len == 6

View File

@ -15,7 +15,7 @@ fn test_ok() {
}" }"
for s in [ok_source, ok_source.replace(apos, quote), ok_source.replace('\n', '\r\n'), 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 ')] { 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.name == 'V'
assert content.description == 'The V programming language.' assert content.description == 'The V programming language.'
assert content.version == '0.7.7' assert content.version == '0.7.7'
@ -24,7 +24,7 @@ fn test_ok() {
assert content.dependencies == [] assert content.dependencies == []
assert content.unknown == {} assert content.unknown == {}
} }
e := vmod.decode('Module{}')? e := vmod.decode('Module{}')!
assert e.name == '' assert e.name == ''
assert e.description == '' assert e.description == ''
assert e.version == '' assert e.version == ''

View File

@ -268,7 +268,7 @@ fn test_token_with_app() {
res := http.get('http://${localserver}/') or { panic(err) } res := http.get('http://${localserver}/') or { panic(err) }
mut doc := html.parse(res.body) 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 inputs.len == 1
assert csrf_config.token_name == inputs[0].attributes['name'] assert csrf_config.token_name == inputs[0].attributes['name']
} }
@ -277,7 +277,7 @@ fn test_token_with_middleware() {
res := http.get('http://${localserver}/middleware_index') or { panic(err) } res := http.get('http://${localserver}/middleware_index') or { panic(err) }
mut doc := html.parse(res.body) 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 inputs.len == 1
assert csrf_config.token_name == inputs[0].attributes['name'] assert csrf_config.token_name == inputs[0].attributes['name']
} }