tinygo/testdata/map.txt
Ayke van Laethem 0d34f933eb compiler,runtime: implement maps for arbitrary keys
This implementation simply casts types without special support to an
interface, to make the implementation simpler and possibly reducing the
code size too. It will likely be slower than the canonical Go
implementation though (which builds special compare and hash functions
at compile time).
2020-01-27 08:27:14 +01:00

73 строки
1 КиБ
Text

map length: 2
map read: answer = 42
answer = 42
foo = 3
map length: 1
map read: data = 3
data = 3
map length: 12
map read: three = 3
one = 1
two = 2
three = 3
four = 4
five = 5
six = 6
seven = 7
eight = 8
nine = 9
ten = 10
eleven = 11
twelve = 12
map length: 12
map read: ten = 10
one = 1
two = 2
three = 3
four = 4
five = 5
six = 6
seven = 7
eight = 8
nine = 9
ten = 10
eleven = 11
twelve = 12
map length: 11
map read: seven = 7
one = 1
two = 2
three = 3
four = 4
five = 5
seven = 7
eight = 8
nine = 9
ten = 10
eleven = 11
twelve = 12
lookup with comma-ok: eight 8 true
lookup with comma-ok: nokey 0 false
false true 2
true false 0
4
42
4321
5555
itfMap[3]: 0
itfMap[3.14]: 3
itfMap[8]: 8
itfMap[uint8(8)]: 80
itfMap["eight"]: 800
itfMap[[2]int{5, 2}]: 52
itfMap[true]: 1
itfMap[8]: 0
floatMap[42]: 84
floatMap[43]: 0
floatMap[42]: 0
structMap[{"tau", 6.28}]: 5
structMap[{"Tau", 6.28}]: 0
structMap[{"tau", 3.14}]: 0
structMap[{"tau", 6.28}]: 0
tested preallocated map
tested growing of a map