v2 / vlib / v / tests / options / option_generic_param_test.v
14 lines · 11 sloc · 251 bytes · 95e1b7c14c92bf08a7655b63c7647eb6bd5d811a
Raw
1import json
2import x.json2
3
4type Elem = int | ?int
5
6const empty = ?int(none)
7const array = [Elem(1), Elem(empty), 3]
8
9fn test_main() {
10 dump(array)
11 e := json.encode(array)
12 assert dump(e) == '[1,{},3]'
13 assert dump(json2.encode(array)) == '[1,,3]'
14}
15