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:
parent
5d4c2cd832
commit
a27f2ddcc3
@ -92,5 +92,5 @@ fn main() {
|
||||
event_fn: event
|
||||
hide_cursor: true
|
||||
)
|
||||
app.tui.run()?
|
||||
app.tui.run()!
|
||||
}
|
||||
|
@ -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()!
|
||||
}
|
||||
|
@ -493,5 +493,5 @@ fn main() {
|
||||
hide_cursor: true
|
||||
frame_rate: 60
|
||||
)
|
||||
app.tui.run()?
|
||||
app.tui.run()!
|
||||
}
|
||||
|
@ -91,5 +91,5 @@ fn main() {
|
||||
hide_cursor: true
|
||||
frame_rate: 60
|
||||
)
|
||||
app.tui.run()?
|
||||
app.tui.run()!
|
||||
}
|
||||
|
@ -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) {
|
||||
|
@ -646,5 +646,5 @@ fn main() {
|
||||
event_fn: event
|
||||
capture_events: true
|
||||
)
|
||||
a.tui.run()?
|
||||
a.tui.run()!
|
||||
}
|
||||
|
@ -468,5 +468,5 @@ fn main() {
|
||||
hide_cursor: true
|
||||
frame_rate: 10
|
||||
)
|
||||
app.termui.run()?
|
||||
app.termui.run()!
|
||||
}
|
||||
|
@ -39,7 +39,7 @@ fn main() {
|
||||
frame_fn: frame
|
||||
hide_cursor: true
|
||||
)
|
||||
app.tui.run()?
|
||||
app.tui.run()!
|
||||
}
|
||||
```
|
||||
|
||||
|
@ -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)
|
||||
|
@ -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)
|
||||
|
@ -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 {
|
||||
@ -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()
|
||||
|
@ -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
|
||||
}
|
||||
|
||||
|
@ -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]
|
||||
}
|
||||
|
@ -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' }
|
||||
|
@ -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
|
||||
@ -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
|
||||
@ -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
|
||||
@ -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
|
||||
@ -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)]'
|
||||
|
@ -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
|
||||
|
@ -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'
|
||||
@ -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 == ''
|
||||
|
@ -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']
|
||||
}
|
||||
@ -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']
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user