diff options
author | Ayke van Laethem <[email protected]> | 2023-07-07 15:47:49 +0200 |
---|---|---|
committer | Ron Evans <[email protected]> | 2023-08-04 11:59:11 +0200 |
commit | f1e25a18d2584cda1d7b2d478e17a4358ee7daf0 (patch) | |
tree | 1cee732b73801015de741855ad047c71fcf3fa4a /testdata | |
parent | a2f886a67a645add0c2e42289e20f89fe402294d (diff) | |
download | tinygo-f1e25a18d2584cda1d7b2d478e17a4358ee7daf0.tar.gz tinygo-f1e25a18d2584cda1d7b2d478e17a4358ee7daf0.zip |
compiler: implement clear builtin for maps
Diffstat (limited to 'testdata')
-rw-r--r-- | testdata/go1.21.go | 11 | ||||
-rw-r--r-- | testdata/go1.21.txt | 2 |
2 files changed, 13 insertions, 0 deletions
diff --git a/testdata/go1.21.go b/testdata/go1.21.go index 184bb2d8a..603bd06e2 100644 --- a/testdata/go1.21.go +++ b/testdata/go1.21.go @@ -15,4 +15,15 @@ func main() { s := []int{1, 2, 3, 4, 5} clear(s[:3]) println("cleared s[:3]:", s[0], s[1], s[2], s[3], s[4]) + + // The clear builtin, for maps. + m := map[int]string{ + 1: "one", + 2: "two", + 3: "three", + } + clear(m) + println("cleared map:", m[1], m[2], m[3], len(m)) + m[4] = "four" + println("added to cleared map:", m[1], m[2], m[3], m[4], len(m)) } diff --git a/testdata/go1.21.txt b/testdata/go1.21.txt index 459631a30..3edfdb456 100644 --- a/testdata/go1.21.txt +++ b/testdata/go1.21.txt @@ -1,3 +1,5 @@ min/max: -3 5 min/max: -3.000000e+000 +5.000000e+000 cleared s[:3]: 0 0 0 4 5 +cleared map: 0 +added to cleared map: four 1 |