]> git.ipfire.org Git - thirdparty/gcc.git/blob - gcc/testsuite/go.go-torture/execute/map-1.go
Add Go frontend, libgo library, and Go testsuite.
[thirdparty/gcc.git] / gcc / testsuite / go.go-torture / execute / map-1.go
1 package main
2
3 func main() {
4 v := make(map[int] int);
5 v[0] = 0;
6 v[1000000] = 1;
7 if v[0] != 0 {
8 panic(1)
9 }
10 val, present := v[0];
11 if !present || val != 0 {
12 panic(2)
13 }
14 val = 5;
15 val, present = v[1];
16 if present || val != 0 {
17 panic(3);
18 }
19 if v[2] != 0 {
20 panic(4)
21 }
22 val, present = v[2];
23 if present {
24 panic(5)
25 }
26 if len(v) != 2 {
27 panic(6)
28 }
29 v[0] = 0, false;
30 if len(v) != 1 {
31 panic(7)
32 }
33
34 w := make(map[string] string);
35 if len(w) != 0 {
36 panic(8)
37 }
38 w["Hello"] = "world";
39 w["Goodbye"] = "sweet prince";
40 if w["Hello"] != "world" {
41 panic(9)
42 }
43 if w["Hej"] != "" {
44 panic(10)
45 }
46 }