tests: fix some tests, that failed due to the stricter immutable checks
parent
86862d6a94
commit
ae8f7cf569
|
@ -7,6 +7,7 @@ module csv
|
||||||
import strings
|
import strings
|
||||||
|
|
||||||
struct Writer {
|
struct Writer {
|
||||||
|
mut:
|
||||||
sb strings.Builder
|
sb strings.Builder
|
||||||
pub mut:
|
pub mut:
|
||||||
use_crlf bool
|
use_crlf bool
|
||||||
|
|
|
@ -28,7 +28,6 @@ pub struct EventBus {
|
||||||
pub mut:
|
pub mut:
|
||||||
registry &Registry
|
registry &Registry
|
||||||
publisher &Publisher
|
publisher &Publisher
|
||||||
pub:
|
|
||||||
subscriber &Subscriber
|
subscriber &Subscriber
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -15,12 +15,12 @@ pub struct Client {
|
||||||
retry int
|
retry int
|
||||||
eb &eventbus.EventBus
|
eb &eventbus.EventBus
|
||||||
is_ssl bool
|
is_ssl bool
|
||||||
lock &sync.Mutex = sync.new_mutex()
|
|
||||||
write_lock &sync.Mutex = sync.new_mutex()
|
|
||||||
// subprotocol_len int
|
// subprotocol_len int
|
||||||
// cwebsocket_subprotocol *subprotocol;
|
// cwebsocket_subprotocol *subprotocol;
|
||||||
// cwebsocket_subprotocol *subprotocols[];
|
// cwebsocket_subprotocol *subprotocols[];
|
||||||
mut:
|
mut:
|
||||||
|
lock &sync.Mutex = sync.new_mutex()
|
||||||
|
write_lock &sync.Mutex = sync.new_mutex()
|
||||||
state State
|
state State
|
||||||
socket net.Socket
|
socket net.Socket
|
||||||
flags []Flag
|
flags []Flag
|
||||||
|
|
|
@ -4,7 +4,7 @@ import time
|
||||||
// time than you have specified. To avoid false positives from CI test
|
// time than you have specified. To avoid false positives from CI test
|
||||||
// failures, some of the asserts will be run only if you pass `-d stopwatch`
|
// failures, some of the asserts will be run only if you pass `-d stopwatch`
|
||||||
fn test_stopwatch_works_as_intended() {
|
fn test_stopwatch_works_as_intended() {
|
||||||
sw := time.new_stopwatch({})
|
mut sw := time.new_stopwatch({})
|
||||||
// sample code that you want to measure:
|
// sample code that you want to measure:
|
||||||
println('Hello world')
|
println('Hello world')
|
||||||
time.sleep_ms(1)
|
time.sleep_ms(1)
|
||||||
|
@ -15,7 +15,7 @@ fn test_stopwatch_works_as_intended() {
|
||||||
|
|
||||||
fn test_stopwatch_time_between_pause_and_start_should_be_skipped_in_elapsed() {
|
fn test_stopwatch_time_between_pause_and_start_should_be_skipped_in_elapsed() {
|
||||||
println('Testing pause function')
|
println('Testing pause function')
|
||||||
sw := time.new_stopwatch({})
|
mut sw := time.new_stopwatch({})
|
||||||
time.sleep_ms(10) // A
|
time.sleep_ms(10) // A
|
||||||
eprintln('Elapsed after 10ms nap: ${sw.elapsed().milliseconds()}ms')
|
eprintln('Elapsed after 10ms nap: ${sw.elapsed().milliseconds()}ms')
|
||||||
assert sw.elapsed().milliseconds() >= 10
|
assert sw.elapsed().milliseconds() >= 10
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
vlib/v/checker/tests/const_field_add_err.v:6:2: error: cannot assign to constant `a`
|
vlib/v/checker/tests/const_field_add_err.v:6:2: error: cannot modify constant `a`
|
||||||
4 |
|
4 |
|
||||||
5 | fn main() {
|
5 | fn main() {
|
||||||
6 | a += 1
|
6 | a += 1
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
vlib/v/checker/tests/const_field_dec_err.v:6:2: error: cannot assign to constant `a`
|
vlib/v/checker/tests/const_field_dec_err.v:6:2: error: cannot modify constant `a`
|
||||||
4 |
|
4 |
|
||||||
5 | fn main() {
|
5 | fn main() {
|
||||||
6 | a--
|
6 | a--
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
vlib/v/checker/tests/const_field_inc_err.v:6:2: error: cannot assign to constant `a`
|
vlib/v/checker/tests/const_field_inc_err.v:6:2: error: cannot modify constant `a`
|
||||||
4 |
|
4 |
|
||||||
5 | fn main() {
|
5 | fn main() {
|
||||||
6 | a++
|
6 | a++
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
vlib/v/checker/tests/const_field_sub_err.v:6:2: error: cannot assign to constant `a`
|
vlib/v/checker/tests/const_field_sub_err.v:6:2: error: cannot modify constant `a`
|
||||||
4 |
|
4 |
|
||||||
5 | fn main() {
|
5 | fn main() {
|
||||||
6 | a -= 1
|
6 | a -= 1
|
||||||
|
|
|
@ -16,10 +16,10 @@ const (
|
||||||
|
|
||||||
pub struct Fmt {
|
pub struct Fmt {
|
||||||
pub:
|
pub:
|
||||||
out strings.Builder
|
|
||||||
out_imports strings.Builder
|
|
||||||
table &table.Table
|
table &table.Table
|
||||||
pub mut:
|
pub mut:
|
||||||
|
out_imports strings.Builder
|
||||||
|
out strings.Builder
|
||||||
indent int
|
indent int
|
||||||
empty_line bool
|
empty_line bool
|
||||||
line_len int
|
line_len int
|
||||||
|
|
|
@ -89,7 +89,7 @@ fn test_scan() {
|
||||||
assert t == 2
|
assert t == 2
|
||||||
})
|
})
|
||||||
|
|
||||||
tfn := TestFn{}
|
mut tfn := TestFn{}
|
||||||
tfn.tst_1()
|
tfn.tst_1()
|
||||||
tfn.tst_2(fn(i int){
|
tfn.tst_2(fn(i int){
|
||||||
t := i + 1
|
t := i + 1
|
||||||
|
@ -102,7 +102,7 @@ fn test_scan() {
|
||||||
// Test @STRUCT
|
// Test @STRUCT
|
||||||
assert @STRUCT == ''
|
assert @STRUCT == ''
|
||||||
|
|
||||||
ts := TestStruct { test: "test" }
|
mut ts := TestStruct { test: "test" }
|
||||||
ts.test_struct()
|
ts.test_struct()
|
||||||
r1 := ts.test_struct_w_return()
|
r1 := ts.test_struct_w_return()
|
||||||
r2 := ts.test_struct_w_high_order(fn(i int)string{
|
r2 := ts.test_struct_w_high_order(fn(i int)string{
|
||||||
|
|
|
@ -46,7 +46,7 @@ import os
|
||||||
import live
|
import live
|
||||||
|
|
||||||
fn append_to_file(fname, s string) {
|
fn append_to_file(fname, s string) {
|
||||||
f := os.open_append(fname) or {
|
mut f := os.open_append(fname) or {
|
||||||
println('>>>> could not open file \$fname for appending, err: \$err ')
|
println('>>>> could not open file \$fname for appending, err: \$err ')
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue