aboutsummaryrefslogtreecommitdiffhomepage
path: root/testdata
diff options
context:
space:
mode:
authorAyke van Laethem <[email protected]>2023-07-07 15:15:49 +0200
committerRon Evans <[email protected]>2023-08-04 11:59:11 +0200
commita2f886a67a645add0c2e42289e20f89fe402294d (patch)
tree0d8e48a86eda24290e683c623a0fee3494916c26 /testdata
parentf791c821ff5d393c875fe41889b94c19cf5f508d (diff)
downloadtinygo-a2f886a67a645add0c2e42289e20f89fe402294d.tar.gz
tinygo-a2f886a67a645add0c2e42289e20f89fe402294d.zip
compiler: implement clear builtin for slices
Diffstat (limited to 'testdata')
-rw-r--r--testdata/go1.21.go6
-rw-r--r--testdata/go1.21.txt1
2 files changed, 7 insertions, 0 deletions
diff --git a/testdata/go1.21.go b/testdata/go1.21.go
index 885e588da..184bb2d8a 100644
--- a/testdata/go1.21.go
+++ b/testdata/go1.21.go
@@ -1,6 +1,7 @@
package main
func main() {
+ // The new min/max builtins.
ia := 1
ib := 5
ic := -3
@@ -9,4 +10,9 @@ func main() {
fc := -3.0
println("min/max:", min(ia, ib, ic), max(ia, ib, ic))
println("min/max:", min(fa, fb, fc), max(fa, fb, fc))
+
+ // The clear builtin, for slices.
+ s := []int{1, 2, 3, 4, 5}
+ clear(s[:3])
+ println("cleared s[:3]:", s[0], s[1], s[2], s[3], s[4])
}
diff --git a/testdata/go1.21.txt b/testdata/go1.21.txt
index ad81dcfe9..459631a30 100644
--- a/testdata/go1.21.txt
+++ b/testdata/go1.21.txt
@@ -1,2 +1,3 @@
min/max: -3 5
min/max: -3.000000e+000 +5.000000e+000
+cleared s[:3]: 0 0 0 4 5