diff --git a/vlib/strconv/atoi_test.v b/vlib/strconv/atoi_test.v index 947213999b..318934c57a 100644 --- a/vlib/strconv/atoi_test.v +++ b/vlib/strconv/atoi_test.v @@ -17,11 +17,13 @@ fn test_atoi() { assert false } if x := strconv.atoi('str') { + println(x) assert false } else { assert true } if x := strconv.atoi('') { + println(x) assert false } else { assert true diff --git a/vlib/sync/atomic2/atomic.v b/vlib/sync/atomic2/atomic.v index 9d047bc30a..e2758342d9 100644 --- a/vlib/sync/atomic2/atomic.v +++ b/vlib/sync/atomic2/atomic.v @@ -1,7 +1,5 @@ module atomic2 -import sync - /* Implements the atomic operations. For now TCC does not support the atomic versions on nix so it uses locks to simulate the same behavor. diff --git a/vlib/sync/channel_select_5_test.v b/vlib/sync/channel_select_5_test.v index d3aa0d4709..fbe2392ce7 100644 --- a/vlib/sync/channel_select_5_test.v +++ b/vlib/sync/channel_select_5_test.v @@ -35,7 +35,6 @@ fn test_select() { go do_send_int2(chi) go do_send_int3(chi) mut sum := i64(0) - mut rl := i64(0) mut sl := i64(0) for _ in 0 .. 60000 + recch.cap { select { diff --git a/vlib/v/tests/differently_named_structs_test.v b/vlib/v/tests/differently_named_structs_test.v index 5e67f28f6f..f8c798b5f6 100644 --- a/vlib/v/tests/differently_named_structs_test.v +++ b/vlib/v/tests/differently_named_structs_test.v @@ -1,16 +1,30 @@ +struct DB { + name string +} -struct DB { name string } -struct DxB { name string } -struct DeclExprA { name string } -struct AStructWithAVeryLongName { name string } +struct DxB { + name string +} + +struct DeclExprA { + name string +} + +struct AStructWithAVeryLongName { + name string +} fn test_struct_names_can_be_used_for_creating_them() { a := DB{} + println(a) assert true b := DxB{} + println(b) assert true c := DeclExprA{} + println(c) assert true d := AStructWithAVeryLongName{} + println(d) assert true } diff --git a/vlib/v/tests/match_test.v b/vlib/v/tests/match_test.v index 6d1d5530b4..59edad535d 100644 --- a/vlib/v/tests/match_test.v +++ b/vlib/v/tests/match_test.v @@ -11,19 +11,20 @@ pub fn (c Color) str() string { fn test_match_integers() { mut a := 3 mut b := 0 - match a - 2 { - println('two') - } - 3 { - println('three') - b = 3 - } - 4 { - println('four') - } - else { - println('???') + match a { + 2 { + println('two') + } + 3 { + println('three') + b = 3 + } + 4 { + println('four') + } + else { + println('???') + } } assert b == 3 assert match 2 { @@ -37,6 +38,7 @@ fn test_match_integers() { else { 5 } } == 5 assert match 1 { + 2 { 0 } else { 5 } } == 5 a = 0 @@ -68,6 +70,7 @@ fn test_match_integers() { assert a == 6 a = 0 match 1 { + 0 {} else { a = -2 } } assert a == -2 @@ -225,9 +228,15 @@ fn test_match_sumtype_multiple_types() { } fn test_sub_expression() { - b := false && match 1 {0 {true} else {true}} + b := false && match 1 { + 0 { true } + else { true } + } assert !b - c := true || match 1 {0 {false} else {false}} + c := true || match 1 { + 0 { false } + else { false } + } assert c } @@ -270,6 +279,9 @@ fn test_sumtype_with_array() { } fn test_match_expression_add() { - a := match true { true {1} false {2} } + 3 + a := match true { + true { 1 } + false { 2 } + } + 3 assert a == 4 } diff --git a/vlib/v/tests/typeof_simple_types_test.v b/vlib/v/tests/typeof_simple_types_test.v index 07b0cd53ca..1c0cc6e659 100644 --- a/vlib/v/tests/typeof_simple_types_test.v +++ b/vlib/v/tests/typeof_simple_types_test.v @@ -14,35 +14,35 @@ type MySumType = Abc | Xyz type AnotherSumType = XxYyZz | int -type SuperSumType = MySumType | AnotherSumType | string +type SuperSumType = AnotherSumType | MySumType | string fn test_typeof_for_builtin_int_types() { - assert typeof(i8(1)) == 'i8' - assert typeof(i16(1)) == 'i16' - assert typeof(int(1)) == 'int' - // assert typeof(1) == 'int_literal' - assert typeof(i64(1)) == 'i64' - assert typeof(byte(1)) == 'byte' - assert typeof(u16(1)) == 'u16' - assert typeof(u32(1)) == 'u32' - assert typeof(u64(1)) == 'u64' + assert typeof(i8(1)).name == 'i8' + assert typeof(i16(1)).name == 'i16' + assert typeof(int(1)).name == 'int' + // assert typeof(1).name == 'int_literal' + assert typeof(i64(1)).name == 'i64' + assert typeof(byte(1)).name == 'byte' + assert typeof(u16(1)).name == 'u16' + assert typeof(u32(1)).name == 'u32' + assert typeof(u64(1)).name == 'u64' } fn test_typeof_for_builtin_float_types() { - assert typeof(f32(1.0)) == 'f32' - assert typeof(f64(1.0)) == 'f64' - // assert typeof(1.0) == 'float_literal' + assert typeof(f32(1.0)).name == 'f32' + assert typeof(f64(1.0)).name == 'f64' + // assert typeof(1.0).name == 'float_literal' } fn test_typeof_for_builtin_string_type() { - assert typeof('abc') == 'string' - assert typeof('/v/nv/vlib/v/tests/typeof_simple_types_test.v') == 'string' - assert typeof('22') == 'string' + assert typeof('abc').name == 'string' + assert typeof('/v/nv/vlib/v/tests/typeof_simple_types_test.v').name == 'string' + assert typeof('22').name == 'string' } fn test_typeof_for_structs() { - assert typeof(Abc{}) == 'Abc' - assert typeof(Xyz{}) == 'Xyz' + assert typeof(Abc{}).name == 'Abc' + assert typeof(Xyz{}).name == 'Xyz' } // diff --git a/vlib/x/json2/json2_test.v b/vlib/x/json2/json2_test.v index 9bdc5d176f..1d10aa21f2 100644 --- a/vlib/x/json2/json2_test.v +++ b/vlib/x/json2/json2_test.v @@ -86,7 +86,7 @@ fn test_character_unescape() { assert lines['newline'].str() == 'new\nline' assert lines['tab'].str() == '\ttab' assert lines['backslash'].str() == 'back\\slash' - assert lines['quotes'].str() == '\"quotes\"' + assert lines['quotes'].str() == '"quotes"' assert lines['slash'].str() == '/dev/null' } @@ -169,6 +169,7 @@ fn test_parse_user() { assert false User2{} } + println(u2) u := json2.decode(s) or { assert false User{} @@ -249,14 +250,15 @@ fn test_struct_in_struct() { fn test_encode_map() { expected := '{"one":1,"two":2,"three":3,"four":4}' numbers := { - 'one': json2.Any(1) - 'two': json2.Any(2) + 'one': json2.Any(1) + 'two': json2.Any(2) 'three': json2.Any(3) - 'four': json2.Any(4) + 'four': json2.Any(4) } out := numbers.str() assert out == expected } + /* fn test_parse_map() { expected := {