v2 / vlib / v / tests / interfaces / array_init_with_interface_test.v
16 lines · 12 sloc · 308 bytes · 83ad0092a56c07f01598c8c3a0170b2ab95b7971
Raw
1interface IValue {}
2
3struct Null {}
4
5struct MyInt {
6 val int
7}
8
9fn test_array_init_with_interface_implicit_cast() {
10 // Test that array init with interface element type allows implicit cast
11 a := []IValue{len: 3, init: Null{}}
12 assert a.len == 3
13
14 b := []IValue{len: 2, init: MyInt{42}}
15 assert b.len == 2
16}
17