@@ -65,13 +65,20 @@ test_type_inference_on_literals_for_various_types :: proc(t: ^testing.T) {
6565 testing.expect_value (t, len (group_slice_u8 ({})), 0 )
6666 testing.expect_value (t, group_slice_u8 (nil ) == nil , true )
6767
68- proc_dynamic_array :: proc (a: [dynamic ]u8 ) -> [dynamic ]u8 { return a }
68+ proc_dynamic_array :: proc (t: ^testing.T, array: [dynamic ]u8 , expected_len: int ) {
69+ if expected_len < 0 {
70+ testing.expect_value (t, array == nil , true )
71+ } else {
72+ testing.expect_value (t, len (array), expected_len)
73+ }
74+ delete (array)
75+ }
6976 group_dynamic_array :: proc {proc_nil, proc_dynamic_array}
70- testing. expect_value (t, len ( group_dynamic_array ( [dynamic ]u8 {1 , 2 , 3 })) , 3 )
71- testing. expect_value (t, len ( group_dynamic_array ( {1 , 2 , 3 })) , 3 )
72- testing. expect_value (t, len ( group_dynamic_array ( {0 =1 , 1 =2 , 2 =3 })) , 3 )
73- testing. expect_value (t, len ( group_dynamic_array ({})) , 0 )
74- testing. expect_value (t, group_dynamic_array ( nil ) == nil , true )
77+ group_dynamic_array (t, [dynamic ]u8 {1 , 2 , 3 }, 3 )
78+ group_dynamic_array (t, {1 , 2 , 3 }, 3 )
79+ group_dynamic_array (t, {0 =1 , 1 =2 , 2 =3 }, 3 )
80+ group_dynamic_array (t, {} , 0 )
81+ group_dynamic_array (t, nil , - 1 )
7582
7683 Enum :: enum {A, B, C}
7784 proc_enum :: proc (a: Enum) -> Enum { return a }
@@ -111,12 +118,19 @@ test_type_inference_on_literals_for_various_types :: proc(t: ^testing.T) {
111118 testing.expect_value (t, group_union (int (9 )).(int ), 9 )
112119 testing.expect_value (t, group_union ({}), nil )
113120
114- proc_map :: proc (a: map [u8 ]u8 ) -> map [u8 ]u8 { return a }
121+ proc_map :: proc (t: ^testing.T, map_: map [u8 ]u8 , expected_len: int ) {
122+ if expected_len < 0 {
123+ testing.expect_value (t, map_ == nil , true )
124+ } else {
125+ testing.expect_value (t, len (map_), expected_len)
126+ }
127+ delete (map_)
128+ }
115129 group_map :: proc {proc_nil, proc_map}
116- testing. expect_value (t, len ( group_map ( map [u8 ]u8 {1 =1 , 2 =2 })) , 2 )
117- testing. expect_value (t, len ( group_map ( {1 =1 , 2 =2 })) , 2 )
118- testing. expect_value (t, len ( group_map ({})) , 0 )
119- testing. expect_value (t, group_map ( nil ) == nil , true )
130+ group_map (t, map [u8 ]u8 {1 =1 , 2 =2 }, 2 )
131+ group_map (t, {1 =1 , 2 =2 }, 2 )
132+ group_map (t, {} , 0 )
133+ group_map (t, nil , - 1 )
120134
121135 Bit_Field :: bit_field u16 {a: u8 |4 , b: u8 |4 , c: u8 |4 }
122136 proc_bit_field :: proc (a: Bit_Field) -> Bit_Field { return a }
0 commit comments