aboutsummaryrefslogtreecommitdiff
path: root/v_windows/v/old/vlib/v/tests/generic_fn_infer_struct_test.v
blob: 3985e1ea675e784d13623934705788337d07b30f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
struct Node<T> {
	data T
}

fn foo<T>(n Node<T>) string {
	return '$n'
}

fn test_generics_fn_infer_struct() {
	ret1 := foo(Node<int>{})
	println(ret1)
	assert ret1.contains('Node<int>{')
	assert ret1.contains('data: 0')

	ret2 := foo(Node<byte>{})
	println(ret2)
	assert ret2.contains('Node<byte>{')
	assert ret2.contains('data: 0')
}