aboutsummaryrefslogtreecommitdiffhomepage
path: root/testdata
diff options
context:
space:
mode:
authorAyke van Laethem <[email protected]>2018-10-20 17:54:16 +0200
committerAyke van Laethem <[email protected]>2018-10-20 17:54:16 +0200
commit7c2a6169b0ad59909b87dbac405e7e0e23979363 (patch)
tree28c8707f95c696ad50d74f7a6d2e73f4fa6810ce /testdata
parentda89464a63a7c181e928a68f4ac392bd841a00b2 (diff)
downloadtinygo-7c2a6169b0ad59909b87dbac405e7e0e23979363.tar.gz
tinygo-7c2a6169b0ad59909b87dbac405e7e0e23979363.zip
compiler: support comma-ok in map lookup
Diffstat (limited to 'testdata')
-rw-r--r--testdata/map.go6
-rw-r--r--testdata/map.txt2
2 files changed, 8 insertions, 0 deletions
diff --git a/testdata/map.go b/testdata/map.go
index fe070625e..9c704cfcf 100644
--- a/testdata/map.go
+++ b/testdata/map.go
@@ -24,6 +24,8 @@ func main() {
readMap(testmap2, "ten")
delete(testmap2, "six")
readMap(testmap2, "seven")
+ lookup(testmap2, "eight")
+ lookup(testmap2, "nokey")
}
func readMap(m map[string]int, key string) {
@@ -33,3 +35,7 @@ func readMap(m map[string]int, key string) {
println(" ", k, "=", v)
}
}
+func lookup(m map[string]int, key string) {
+ value, ok := m[key]
+ println("lookup with comma-ok:", key, value, ok)
+}
diff --git a/testdata/map.txt b/testdata/map.txt
index 4f96c74f1..d076a595a 100644
--- a/testdata/map.txt
+++ b/testdata/map.txt
@@ -46,3 +46,5 @@ map read: seven = 7
ten = 10
eleven = 11
twelve = 12
+lookup with comma-ok: eight 8 true
+lookup with comma-ok: nokey 0 false