diff options
Diffstat (limited to 'v_windows/v/vlib/v/tests/map_alias_key_test.v')
-rw-r--r-- | v_windows/v/vlib/v/tests/map_alias_key_test.v | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/v_windows/v/vlib/v/tests/map_alias_key_test.v b/v_windows/v/vlib/v/tests/map_alias_key_test.v new file mode 100644 index 0000000..a9865c7 --- /dev/null +++ b/v_windows/v/vlib/v/tests/map_alias_key_test.v @@ -0,0 +1,34 @@ +type Type = int +type RType = rune + +fn test_map_key_alias() { + mut m_int := { + 12: '12' + 2: '2' + } + m_int[14] = '14' + m_int[Type(15)] = '15' + assert m_int.str() == "{12: '12', 2: '2', 14: '14', 15: '15'}" + //// /// ///// // + mut m_rune := { + `a`: '12' + `l`: '14' + } + m_rune[`g`] = '12' + m_rune[RType(`$`)] = '16' + assert m_rune.str() == "{`a`: '12', `l`: '14', `g`: '12', `$`: '16'}" +} + +fn test_map_alias_key_init() { + m_int := { + Type(12): '12' + Type(2): '2' + } + assert m_int.str() == "{12: '12', 2: '2'}" + //// // ///// // + m_rune := { + RType(`a`): '12' + RType(`l`): '14' + } + assert m_rune.str() == "{`a`: '12', `l`: '14'}" +} |