v2 / vlib / v / tests / consts / const_map_init_order_test.v
26 lines · 24 sloc · 424 bytes · 667a07c289da92359f8830ae98c12700b2cf3476
Raw
1const bit = f64(1)
2const nibble = bit * 4
3const bytes = bit * 8
4const kb = bytes * 1000
5const mb = kb * 1000
6
7const units_map = {
8 bit: 'bit'
9 nibble: 'nibble'
10 bytes: 'byte'
11 kb: 'kB'
12 mb: 'MB'
13}
14
15fn test_const_map_init_order() {
16 println(units_map.len)
17 println(units_map)
18 assert units_map.len == 5
19 assert units_map == {
20 1.0: 'bit'
21 4.0: 'nibble'
22 8.0: 'byte'
23 8000.0: 'kB'
24 8.e+06: 'MB'
25 }
26}
27