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
18 changed files with 32 additions and 32 deletions

View File

@@ -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()

View File

@@ -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
}

View File

@@ -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]
}

View File

@@ -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' }

View File

@@ -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)]'

View File

@@ -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

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'),
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 == ''