| 
									
										
										
										
											2008-08-11 13:32:13 -07:00
										 |  |  | // $G $F.go && $L $F.$A && ./$A.out | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | // Copyright 2009 The Go Authors. All rights reserved. | 
					
						
							|  |  |  | // Use of this source code is governed by a BSD-style | 
					
						
							|  |  |  | // license that can be found in the LICENSE file. | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | package main | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2008-12-20 16:07:43 -08:00
										 |  |  | import ( | 
					
						
							|  |  |  | 	"fmt"; | 
					
						
							|  |  |  | 	"strconv"; | 
					
						
							|  |  |  | ) | 
					
						
							| 
									
										
										
										
											2008-08-11 13:32:13 -07:00
										 |  |  | 
 | 
					
						
							|  |  |  | const arraylen = 2; // BUG: shouldn't need this | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2008-12-18 22:37:22 -08:00
										 |  |  | func P(a []string) string { | 
					
						
							| 
									
										
										
										
											2008-08-11 13:32:13 -07:00
										 |  |  | 	s := "{"; | 
					
						
							|  |  |  | 	for i := 0; i < len(a); i++ { | 
					
						
							|  |  |  | 		if i > 0 { | 
					
						
							|  |  |  | 			s += "," | 
					
						
							|  |  |  | 		} | 
					
						
							|  |  |  | 		s += `"` + a[i] + `"`; | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 	s +="}"; | 
					
						
							|  |  |  | 	return s; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | func main() { | 
					
						
							| 
									
										
										
										
											2008-12-20 16:07:43 -08:00
										 |  |  | 	// Test a map literal. | 
					
						
							|  |  |  | 	mlit := map[string] int { "0":0, "1":1, "2":2, "3":3, "4":4 }; | 
					
						
							|  |  |  | 	for i := 0; i < len(mlit); i++ { | 
					
						
							|  |  |  | 		s := string([]byte{byte(i)+'0'}); | 
					
						
							|  |  |  | 		if mlit[s] != i { | 
					
						
							|  |  |  | 			fmt.printf("mlit[%s] = %d\n", s, mlit[s]) | 
					
						
							|  |  |  | 		} | 
					
						
							|  |  |  | 	} | 
					
						
							| 
									
										
										
										
											2008-08-11 13:32:13 -07:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-01-06 15:19:02 -08:00
										 |  |  | 	mib := make(map[int] bool); | 
					
						
							|  |  |  | 	mii := make(map[int] int); | 
					
						
							|  |  |  | 	mfi := make(map[float] int); | 
					
						
							|  |  |  | 	mif := make(map[int] float); | 
					
						
							|  |  |  | 	msi := make(map[string] int); | 
					
						
							|  |  |  | 	mis := make(map[int] string); | 
					
						
							|  |  |  | 	mss := make(map[string] string); | 
					
						
							|  |  |  | 	mspa := make(map[string] []string); | 
					
						
							| 
									
										
										
										
											2008-08-11 13:32:13 -07:00
										 |  |  | 	// BUG need an interface map both ways too | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	type T struct { | 
					
						
							| 
									
										
										
										
											2008-12-20 16:07:43 -08:00
										 |  |  | 		i int64;	// can't use string here; struct values are only compared at the top level | 
					
						
							| 
									
										
										
										
											2008-08-11 13:32:13 -07:00
										 |  |  | 		f float; | 
					
						
							|  |  |  | 	}; | 
					
						
							| 
									
										
										
										
											2009-01-06 15:19:02 -08:00
										 |  |  | 	mipT := make(map[int] *T); | 
					
						
							|  |  |  | 	mpTi := make(map[*T] int); | 
					
						
							|  |  |  | 	mit := make(map[int] T); | 
					
						
							|  |  |  | 	mti := make(map[T] int); | 
					
						
							| 
									
										
										
										
											2008-08-11 13:32:13 -07:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2008-12-19 03:05:37 -08:00
										 |  |  | 	type M map[int] int; | 
					
						
							| 
									
										
										
										
											2009-01-06 15:19:02 -08:00
										 |  |  | 	mipM := make(map[int] M); | 
					
						
							| 
									
										
										
										
											2008-08-11 13:32:13 -07:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2008-12-20 16:07:43 -08:00
										 |  |  | 	const count = 1000; | 
					
						
							| 
									
										
										
										
											2008-08-11 13:32:13 -07:00
										 |  |  | 	var apT [2*count]*T; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	for i := 0; i < count; i++ { | 
					
						
							| 
									
										
										
										
											2008-12-20 16:07:43 -08:00
										 |  |  | 		s := strconv.itoa(i); | 
					
						
							|  |  |  | 		s10 := strconv.itoa(i*10); | 
					
						
							| 
									
										
										
										
											2008-08-11 13:32:13 -07:00
										 |  |  | 		f := float(i); | 
					
						
							| 
									
										
										
										
											2008-12-20 16:07:43 -08:00
										 |  |  | 		t := T{int64(i),f}; | 
					
						
							| 
									
										
										
										
											2009-01-06 15:19:02 -08:00
										 |  |  | 		apT[i] = new(T); | 
					
						
							| 
									
										
										
										
											2008-12-20 16:07:43 -08:00
										 |  |  | 		apT[i].i = int64(i); | 
					
						
							| 
									
										
										
										
											2008-08-11 13:32:13 -07:00
										 |  |  | 		apT[i].f = f; | 
					
						
							| 
									
										
										
										
											2009-01-06 15:19:02 -08:00
										 |  |  | 		apT[2*i] = new(T);	// need twice as many entries as we use, for the nonexistence check | 
					
						
							| 
									
										
										
										
											2008-12-20 16:07:43 -08:00
										 |  |  | 		apT[2*i].i = int64(i); | 
					
						
							| 
									
										
										
										
											2008-08-11 13:32:13 -07:00
										 |  |  | 		apT[2*i].f = f; | 
					
						
							| 
									
										
										
										
											2009-01-06 15:19:02 -08:00
										 |  |  | 		m := M{i: i+1}; | 
					
						
							| 
									
										
										
										
											2008-08-11 13:32:13 -07:00
										 |  |  | 		mib[i] = (i != 0); | 
					
						
							|  |  |  | 		mii[i] = 10*i; | 
					
						
							|  |  |  | 		mfi[float(i)] = 10*i; | 
					
						
							|  |  |  | 		mif[i] = 10.0*f; | 
					
						
							|  |  |  | 		mis[i] = s; | 
					
						
							| 
									
										
										
										
											2008-12-20 16:07:43 -08:00
										 |  |  | 		msi[s] = i; | 
					
						
							|  |  |  | 		mss[s] = s10; | 
					
						
							|  |  |  | 		mss[s] = s10; | 
					
						
							| 
									
										
										
										
											2009-01-06 15:19:02 -08:00
										 |  |  | 		as := make([]string, arraylen); | 
					
						
							| 
									
										
										
										
											2008-12-20 16:07:43 -08:00
										 |  |  | 			as[0] = s10; | 
					
						
							|  |  |  | 			as[1] = s10; | 
					
						
							|  |  |  | 		mspa[s] = as; | 
					
						
							|  |  |  | 		mipT[i] = apT[i]; | 
					
						
							| 
									
										
										
										
											2008-08-11 13:32:13 -07:00
										 |  |  | 		mpTi[apT[i]] = i; | 
					
						
							|  |  |  | 		mipM[i] = m; | 
					
						
							| 
									
										
										
										
											2008-12-20 16:07:43 -08:00
										 |  |  | 		mit[i] = t; | 
					
						
							|  |  |  | 		mti[t] = i; | 
					
						
							| 
									
										
										
										
											2008-08-11 13:32:13 -07:00
										 |  |  | 	} | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	// test len | 
					
						
							|  |  |  | 	if len(mib) != count { | 
					
						
							| 
									
										
										
										
											2008-12-20 16:07:43 -08:00
										 |  |  | 		fmt.printf("len(mib) = %d\n", len(mib)); | 
					
						
							| 
									
										
										
										
											2008-08-11 13:32:13 -07:00
										 |  |  | 	} | 
					
						
							|  |  |  | 	if len(mii) != count { | 
					
						
							| 
									
										
										
										
											2008-12-20 16:07:43 -08:00
										 |  |  | 		fmt.printf("len(mii) = %d\n", len(mii)); | 
					
						
							| 
									
										
										
										
											2008-08-11 13:32:13 -07:00
										 |  |  | 	} | 
					
						
							|  |  |  | 	if len(mfi) != count { | 
					
						
							| 
									
										
										
										
											2008-12-20 16:07:43 -08:00
										 |  |  | 		fmt.printf("len(mfi) = %d\n", len(mfi)); | 
					
						
							| 
									
										
										
										
											2008-08-11 13:32:13 -07:00
										 |  |  | 	} | 
					
						
							|  |  |  | 	if len(mif) != count { | 
					
						
							| 
									
										
										
										
											2008-12-20 16:07:43 -08:00
										 |  |  | 		fmt.printf("len(mif) = %d\n", len(mif)); | 
					
						
							| 
									
										
										
										
											2008-08-11 13:32:13 -07:00
										 |  |  | 	} | 
					
						
							|  |  |  | 	if len(msi) != count { | 
					
						
							| 
									
										
										
										
											2008-12-20 16:07:43 -08:00
										 |  |  | 		fmt.printf("len(msi) = %d\n", len(msi)); | 
					
						
							| 
									
										
										
										
											2008-08-11 13:32:13 -07:00
										 |  |  | 	} | 
					
						
							|  |  |  | 	if len(mis) != count { | 
					
						
							| 
									
										
										
										
											2008-12-20 16:07:43 -08:00
										 |  |  | 		fmt.printf("len(mis) = %d\n", len(mis)); | 
					
						
							| 
									
										
										
										
											2008-08-11 13:32:13 -07:00
										 |  |  | 	} | 
					
						
							|  |  |  | 	if len(mss) != count { | 
					
						
							| 
									
										
										
										
											2008-12-20 16:07:43 -08:00
										 |  |  | 		fmt.printf("len(mss) = %d\n", len(mss)); | 
					
						
							| 
									
										
										
										
											2008-08-11 13:32:13 -07:00
										 |  |  | 	} | 
					
						
							|  |  |  | 	if len(mspa) != count { | 
					
						
							| 
									
										
										
										
											2008-12-20 16:07:43 -08:00
										 |  |  | 		fmt.printf("len(mspa) = %d\n", len(mspa)); | 
					
						
							| 
									
										
										
										
											2008-08-11 13:32:13 -07:00
										 |  |  | 	} | 
					
						
							|  |  |  | 	if len(mipT) != count { | 
					
						
							| 
									
										
										
										
											2008-12-20 16:07:43 -08:00
										 |  |  | 		fmt.printf("len(mipT) = %d\n", len(mipT)); | 
					
						
							| 
									
										
										
										
											2008-08-11 13:32:13 -07:00
										 |  |  | 	} | 
					
						
							|  |  |  | 	if len(mpTi) != count { | 
					
						
							| 
									
										
										
										
											2008-12-20 16:07:43 -08:00
										 |  |  | 		fmt.printf("len(mpTi) = %d\n", len(mpTi)); | 
					
						
							| 
									
										
										
										
											2008-08-11 13:32:13 -07:00
										 |  |  | 	} | 
					
						
							| 
									
										
										
										
											2009-01-06 15:19:02 -08:00
										 |  |  | 	if len(mti) != count { | 
					
						
							|  |  |  | 		fmt.printf("len(mti) = %d\n", len(mti)); | 
					
						
							|  |  |  | 	} | 
					
						
							| 
									
										
										
										
											2008-08-11 13:32:13 -07:00
										 |  |  | 	if len(mipM) != count { | 
					
						
							| 
									
										
										
										
											2008-12-20 16:07:43 -08:00
										 |  |  | 		fmt.printf("len(mipM) = %d\n", len(mipM)); | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 	if len(mti) != count { | 
					
						
							|  |  |  | 		fmt.printf("len(mti) = %d\n", len(mti)); | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 	if len(mit) != count { | 
					
						
							|  |  |  | 		fmt.printf("len(mit) = %d\n", len(mit)); | 
					
						
							| 
									
										
										
										
											2008-08-11 13:32:13 -07:00
										 |  |  | 	} | 
					
						
							| 
									
										
										
										
											2008-12-19 03:05:37 -08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2008-08-11 13:32:13 -07:00
										 |  |  | 	// test construction directly | 
					
						
							|  |  |  | 	for i := 0; i < count; i++ { | 
					
						
							| 
									
										
										
										
											2008-12-20 16:07:43 -08:00
										 |  |  | 		s := strconv.itoa(i); | 
					
						
							|  |  |  | 		s10 := strconv.itoa(i*10); | 
					
						
							| 
									
										
										
										
											2008-08-11 13:32:13 -07:00
										 |  |  | 		f := float(i); | 
					
						
							| 
									
										
										
										
											2008-12-20 16:07:43 -08:00
										 |  |  | 		t := T{int64(i), f}; | 
					
						
							| 
									
										
										
										
											2008-08-11 13:32:13 -07:00
										 |  |  | 		// BUG m := M(i, i+1); | 
					
						
							|  |  |  | 		if mib[i] != (i != 0) { | 
					
						
							| 
									
										
										
										
											2008-12-20 16:07:43 -08:00
										 |  |  | 			fmt.printf("mib[%d] = %t\n", i, mib[i]); | 
					
						
							| 
									
										
										
										
											2008-08-11 13:32:13 -07:00
										 |  |  | 		} | 
					
						
							|  |  |  | 		if(mii[i] != 10*i) { | 
					
						
							| 
									
										
										
										
											2008-12-20 16:07:43 -08:00
										 |  |  | 			fmt.printf("mii[%d] = %d\n", i, mii[i]); | 
					
						
							| 
									
										
										
										
											2008-08-11 13:32:13 -07:00
										 |  |  | 		} | 
					
						
							|  |  |  | 		if(mfi[f] != 10*i) { | 
					
						
							| 
									
										
										
										
											2008-12-20 16:07:43 -08:00
										 |  |  | 			fmt.printf("mfi[%d] = %d\n", i, mfi[f]); | 
					
						
							| 
									
										
										
										
											2008-08-11 13:32:13 -07:00
										 |  |  | 		} | 
					
						
							|  |  |  | 		if(mif[i] != 10.0*f) { | 
					
						
							| 
									
										
										
										
											2008-12-20 16:07:43 -08:00
										 |  |  | 			fmt.printf("mif[%d] = %g\n", i, mif[i]); | 
					
						
							| 
									
										
										
										
											2008-08-11 13:32:13 -07:00
										 |  |  | 		} | 
					
						
							|  |  |  | 		if(mis[i] != s) { | 
					
						
							| 
									
										
										
										
											2008-12-20 16:07:43 -08:00
										 |  |  | 			fmt.printf("mis[%d] = %s\n", i, mis[i]); | 
					
						
							| 
									
										
										
										
											2008-08-11 13:32:13 -07:00
										 |  |  | 		} | 
					
						
							|  |  |  | 		if(msi[s] != i) { | 
					
						
							| 
									
										
										
										
											2008-12-20 16:07:43 -08:00
										 |  |  | 			fmt.printf("msi[%s] = %d\n", s, msi[s]); | 
					
						
							| 
									
										
										
										
											2008-08-11 13:32:13 -07:00
										 |  |  | 		} | 
					
						
							| 
									
										
										
										
											2008-12-20 16:07:43 -08:00
										 |  |  | 		if mss[s] != s10 { | 
					
						
							|  |  |  | 			fmt.printf("mss[%s] = %g\n", s, mss[s]); | 
					
						
							| 
									
										
										
										
											2008-08-11 13:32:13 -07:00
										 |  |  | 		} | 
					
						
							|  |  |  | 		for j := 0; j < arraylen; j++ { | 
					
						
							| 
									
										
										
										
											2008-12-20 16:07:43 -08:00
										 |  |  | 			if mspa[s][j] != s10 { | 
					
						
							|  |  |  | 				fmt.printf("mspa[%s][%d] = %s\n", s, j, mspa[s][j]); | 
					
						
							| 
									
										
										
										
											2008-08-11 13:32:13 -07:00
										 |  |  | 			} | 
					
						
							|  |  |  | 		} | 
					
						
							| 
									
										
										
										
											2008-12-20 16:07:43 -08:00
										 |  |  | 		if(mipT[i].i != int64(i) || mipT[i].f != f) { | 
					
						
							|  |  |  | 			fmt.printf("mipT[%d] = %v\n", i, mipT[i]); | 
					
						
							| 
									
										
										
										
											2008-08-11 13:32:13 -07:00
										 |  |  | 		} | 
					
						
							|  |  |  | 		if(mpTi[apT[i]] != i) { | 
					
						
							| 
									
										
										
										
											2008-12-20 16:07:43 -08:00
										 |  |  | 			fmt.printf("mpTi[apT[%d]] = %d\n", i, mpTi[apT[i]]); | 
					
						
							| 
									
										
										
										
											2008-08-11 13:32:13 -07:00
										 |  |  | 		} | 
					
						
							| 
									
										
										
										
											2009-01-06 15:19:02 -08:00
										 |  |  | 		if(mti[t] != i) { | 
					
						
							|  |  |  | 			fmt.printf("mti[%s] = %s\n", s, mti[t]); | 
					
						
							|  |  |  | 		} | 
					
						
							| 
									
										
										
										
											2008-08-11 13:32:13 -07:00
										 |  |  | 		if (mipM[i][i] != i + 1) { | 
					
						
							| 
									
										
										
										
											2008-12-20 16:07:43 -08:00
										 |  |  | 			fmt.printf("mipM[%d][%d] = %d\n", i, i, mipM[i][i]); | 
					
						
							|  |  |  | 		} | 
					
						
							|  |  |  | 		if(mti[t] != i) { | 
					
						
							|  |  |  | 			fmt.printf("mti[%v] = %d\n", t, mti[t]); | 
					
						
							|  |  |  | 		} | 
					
						
							|  |  |  | 		if(mit[i].i != int64(i) || mit[i].f != f) { | 
					
						
							|  |  |  | 			fmt.printf("mit[%d] = {%d %g}\n", i, mit[i].i, mit[i].f); | 
					
						
							| 
									
										
										
										
											2008-08-11 13:32:13 -07:00
										 |  |  | 		} | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	// test existence with tuple check | 
					
						
							|  |  |  | 	// failed lookups yield a false value for the boolean. | 
					
						
							|  |  |  | 	for i := 0; i < count; i++ { | 
					
						
							| 
									
										
										
										
											2008-12-20 16:07:43 -08:00
										 |  |  | 		s := strconv.itoa(i); | 
					
						
							| 
									
										
										
										
											2008-08-11 13:32:13 -07:00
										 |  |  | 		f := float(i); | 
					
						
							| 
									
										
										
										
											2008-12-20 16:07:43 -08:00
										 |  |  | 		t := T{int64(i), f}; | 
					
						
							| 
									
										
										
										
											2008-08-11 13:32:13 -07:00
										 |  |  | 		{ | 
					
						
							|  |  |  | 			a, b := mib[i]; | 
					
						
							|  |  |  | 			if !b { | 
					
						
							| 
									
										
										
										
											2008-12-20 16:07:43 -08:00
										 |  |  | 				fmt.printf("tuple existence decl: mib[%d]\n", i); | 
					
						
							| 
									
										
										
										
											2008-08-11 13:32:13 -07:00
										 |  |  | 			} | 
					
						
							|  |  |  | 			a, b = mib[i]; | 
					
						
							|  |  |  | 			if !b { | 
					
						
							| 
									
										
										
										
											2008-12-20 16:07:43 -08:00
										 |  |  | 				fmt.printf("tuple existence assign: mib[%d]\n", i); | 
					
						
							| 
									
										
										
										
											2008-08-11 13:32:13 -07:00
										 |  |  | 			} | 
					
						
							|  |  |  | 		} | 
					
						
							|  |  |  | 		{ | 
					
						
							|  |  |  | 			a, b := mii[i]; | 
					
						
							|  |  |  | 			if !b { | 
					
						
							| 
									
										
										
										
											2008-12-20 16:07:43 -08:00
										 |  |  | 				fmt.printf("tuple existence decl: mii[%d]\n", i); | 
					
						
							| 
									
										
										
										
											2008-08-11 13:32:13 -07:00
										 |  |  | 			} | 
					
						
							|  |  |  | 			a, b = mii[i]; | 
					
						
							|  |  |  | 			if !b { | 
					
						
							| 
									
										
										
										
											2008-12-20 16:07:43 -08:00
										 |  |  | 				fmt.printf("tuple existence assign: mii[%d]\n", i); | 
					
						
							| 
									
										
										
										
											2008-08-11 13:32:13 -07:00
										 |  |  | 			} | 
					
						
							|  |  |  | 		} | 
					
						
							|  |  |  | 		{ | 
					
						
							|  |  |  | 			a, b := mfi[f]; | 
					
						
							|  |  |  | 			if !b { | 
					
						
							| 
									
										
										
										
											2008-12-20 16:07:43 -08:00
										 |  |  | 				fmt.printf("tuple existence decl: mfi[%d]\n", i); | 
					
						
							| 
									
										
										
										
											2008-08-11 13:32:13 -07:00
										 |  |  | 			} | 
					
						
							|  |  |  | 			a, b = mfi[f]; | 
					
						
							|  |  |  | 			if !b { | 
					
						
							| 
									
										
										
										
											2008-12-20 16:07:43 -08:00
										 |  |  | 				fmt.printf("tuple existence assign: mfi[%d]\n", i); | 
					
						
							| 
									
										
										
										
											2008-08-11 13:32:13 -07:00
										 |  |  | 			} | 
					
						
							|  |  |  | 		} | 
					
						
							|  |  |  | 		{ | 
					
						
							|  |  |  | 			a, b := mif[i]; | 
					
						
							|  |  |  | 			if !b { | 
					
						
							| 
									
										
										
										
											2008-12-20 16:07:43 -08:00
										 |  |  | 				fmt.printf("tuple existence decl: mif[%d]\n", i); | 
					
						
							| 
									
										
										
										
											2008-08-11 13:32:13 -07:00
										 |  |  | 			} | 
					
						
							|  |  |  | 			a, b = mif[i]; | 
					
						
							|  |  |  | 			if !b { | 
					
						
							| 
									
										
										
										
											2008-12-20 16:07:43 -08:00
										 |  |  | 				fmt.printf("tuple existence assign: mif[%d]\n", i); | 
					
						
							| 
									
										
										
										
											2008-08-11 13:32:13 -07:00
										 |  |  | 			} | 
					
						
							|  |  |  | 		} | 
					
						
							|  |  |  | 		{ | 
					
						
							|  |  |  | 			a, b := mis[i]; | 
					
						
							|  |  |  | 			if !b { | 
					
						
							| 
									
										
										
										
											2008-12-20 16:07:43 -08:00
										 |  |  | 				fmt.printf("tuple existence decl: mis[%d]\n", i); | 
					
						
							| 
									
										
										
										
											2008-08-11 13:32:13 -07:00
										 |  |  | 			} | 
					
						
							|  |  |  | 			a, b = mis[i]; | 
					
						
							|  |  |  | 			if !b { | 
					
						
							| 
									
										
										
										
											2008-12-20 16:07:43 -08:00
										 |  |  | 				fmt.printf("tuple existence assign: mis[%d]\n", i); | 
					
						
							| 
									
										
										
										
											2008-08-11 13:32:13 -07:00
										 |  |  | 			} | 
					
						
							|  |  |  | 		} | 
					
						
							|  |  |  | 		{ | 
					
						
							|  |  |  | 			a, b := msi[s]; | 
					
						
							|  |  |  | 			if !b { | 
					
						
							| 
									
										
										
										
											2008-12-20 16:07:43 -08:00
										 |  |  | 				fmt.printf("tuple existence decl: msi[%d]\n", i); | 
					
						
							| 
									
										
										
										
											2008-08-11 13:32:13 -07:00
										 |  |  | 			} | 
					
						
							|  |  |  | 			a, b = msi[s]; | 
					
						
							|  |  |  | 			if !b { | 
					
						
							| 
									
										
										
										
											2008-12-20 16:07:43 -08:00
										 |  |  | 				fmt.printf("tuple existence assign: msi[%d]\n", i); | 
					
						
							| 
									
										
										
										
											2008-08-11 13:32:13 -07:00
										 |  |  | 			} | 
					
						
							|  |  |  | 		} | 
					
						
							|  |  |  | 		{ | 
					
						
							|  |  |  | 			a, b := mss[s]; | 
					
						
							|  |  |  | 			if !b { | 
					
						
							| 
									
										
										
										
											2008-12-20 16:07:43 -08:00
										 |  |  | 				fmt.printf("tuple existence decl: mss[%d]\n", i); | 
					
						
							| 
									
										
										
										
											2008-08-11 13:32:13 -07:00
										 |  |  | 			} | 
					
						
							|  |  |  | 			a, b = mss[s]; | 
					
						
							|  |  |  | 			if !b { | 
					
						
							| 
									
										
										
										
											2008-12-20 16:07:43 -08:00
										 |  |  | 				fmt.printf("tuple existence assign: mss[%d]\n", i); | 
					
						
							| 
									
										
										
										
											2008-08-11 13:32:13 -07:00
										 |  |  | 			} | 
					
						
							|  |  |  | 		} | 
					
						
							|  |  |  | 		{ | 
					
						
							|  |  |  | 			a, b := mspa[s]; | 
					
						
							|  |  |  | 			if !b { | 
					
						
							| 
									
										
										
										
											2008-12-20 16:07:43 -08:00
										 |  |  | 				fmt.printf("tuple existence decl: mspa[%d]\n", i); | 
					
						
							| 
									
										
										
										
											2008-08-11 13:32:13 -07:00
										 |  |  | 			} | 
					
						
							|  |  |  | 			a, b = mspa[s]; | 
					
						
							|  |  |  | 			if !b { | 
					
						
							| 
									
										
										
										
											2008-12-20 16:07:43 -08:00
										 |  |  | 				fmt.printf("tuple existence assign: mspa[%d]\n", i); | 
					
						
							| 
									
										
										
										
											2008-08-11 13:32:13 -07:00
										 |  |  | 			} | 
					
						
							|  |  |  | 		} | 
					
						
							|  |  |  | 		{ | 
					
						
							|  |  |  | 			a, b := mipT[i]; | 
					
						
							|  |  |  | 			if !b { | 
					
						
							| 
									
										
										
										
											2008-12-20 16:07:43 -08:00
										 |  |  | 				fmt.printf("tuple existence decl: mipT[%d]\n", i); | 
					
						
							| 
									
										
										
										
											2008-08-11 13:32:13 -07:00
										 |  |  | 			} | 
					
						
							|  |  |  | 			a, b = mipT[i]; | 
					
						
							|  |  |  | 			if !b { | 
					
						
							| 
									
										
										
										
											2008-12-20 16:07:43 -08:00
										 |  |  | 				fmt.printf("tuple existence assign: mipT[%d]\n", i); | 
					
						
							| 
									
										
										
										
											2008-08-11 13:32:13 -07:00
										 |  |  | 			} | 
					
						
							|  |  |  | 		} | 
					
						
							|  |  |  | 		{ | 
					
						
							|  |  |  | 			a, b := mpTi[apT[i]]; | 
					
						
							|  |  |  | 			if !b { | 
					
						
							| 
									
										
										
										
											2008-12-20 16:07:43 -08:00
										 |  |  | 				fmt.printf("tuple existence decl: mpTi[apT[%d]]\n", i); | 
					
						
							| 
									
										
										
										
											2008-08-11 13:32:13 -07:00
										 |  |  | 			} | 
					
						
							|  |  |  | 			a, b = mpTi[apT[i]]; | 
					
						
							|  |  |  | 			if !b { | 
					
						
							| 
									
										
										
										
											2008-12-20 16:07:43 -08:00
										 |  |  | 				fmt.printf("tuple existence assign: mpTi[apT[%d]]\n", i); | 
					
						
							| 
									
										
										
										
											2008-08-11 13:32:13 -07:00
										 |  |  | 			} | 
					
						
							|  |  |  | 		} | 
					
						
							|  |  |  | 		{ | 
					
						
							|  |  |  | 			a, b := mipM[i]; | 
					
						
							|  |  |  | 			if !b { | 
					
						
							| 
									
										
										
										
											2008-12-20 16:07:43 -08:00
										 |  |  | 				fmt.printf("tuple existence decl: mipM[%d]\n", i); | 
					
						
							| 
									
										
										
										
											2008-08-11 13:32:13 -07:00
										 |  |  | 			} | 
					
						
							|  |  |  | 			a, b = mipM[i]; | 
					
						
							|  |  |  | 			if !b { | 
					
						
							| 
									
										
										
										
											2008-12-20 16:07:43 -08:00
										 |  |  | 				fmt.printf("tuple existence assign: mipM[%d]\n", i); | 
					
						
							|  |  |  | 			} | 
					
						
							|  |  |  | 		} | 
					
						
							|  |  |  | 		{ | 
					
						
							|  |  |  | 			a, b := mit[i]; | 
					
						
							|  |  |  | 			if !b { | 
					
						
							|  |  |  | 				fmt.printf("tuple existence decl: mit[%d]\n", i); | 
					
						
							|  |  |  | 			} | 
					
						
							|  |  |  | 			a, b = mit[i]; | 
					
						
							|  |  |  | 			if !b { | 
					
						
							|  |  |  | 				fmt.printf("tuple existence assign: mit[%d]\n", i); | 
					
						
							|  |  |  | 			} | 
					
						
							|  |  |  | 		} | 
					
						
							|  |  |  | 		{ | 
					
						
							|  |  |  | 			a, b := mti[t]; | 
					
						
							|  |  |  | 			if !b { | 
					
						
							|  |  |  | 				fmt.printf("tuple existence decl: mti[%d]\n", i); | 
					
						
							|  |  |  | 			} | 
					
						
							|  |  |  | 			a, b = mti[t]; | 
					
						
							|  |  |  | 			if !b { | 
					
						
							|  |  |  | 				fmt.printf("tuple existence assign: mti[%d]\n", i); | 
					
						
							| 
									
										
										
										
											2008-08-11 13:32:13 -07:00
										 |  |  | 			} | 
					
						
							|  |  |  | 		} | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	// test nonexistence with tuple check | 
					
						
							|  |  |  | 	// failed lookups yield a false value for the boolean. | 
					
						
							|  |  |  | 	for i := count; i < 2*count; i++ { | 
					
						
							| 
									
										
										
										
											2008-12-20 16:07:43 -08:00
										 |  |  | 		s := strconv.itoa(i); | 
					
						
							| 
									
										
										
										
											2008-08-11 13:32:13 -07:00
										 |  |  | 		f := float(i); | 
					
						
							| 
									
										
										
										
											2008-12-20 16:07:43 -08:00
										 |  |  | 		t := T{int64(i),f}; | 
					
						
							| 
									
										
										
										
											2008-08-11 13:32:13 -07:00
										 |  |  | 		{ | 
					
						
							|  |  |  | 			a, b := mib[i]; | 
					
						
							|  |  |  | 			if b { | 
					
						
							| 
									
										
										
										
											2008-12-20 16:07:43 -08:00
										 |  |  | 				fmt.printf("tuple nonexistence decl: mib[%d]", i); | 
					
						
							| 
									
										
										
										
											2008-08-11 13:32:13 -07:00
										 |  |  | 			} | 
					
						
							|  |  |  | 			a, b = mib[i]; | 
					
						
							|  |  |  | 			if b { | 
					
						
							| 
									
										
										
										
											2008-12-20 16:07:43 -08:00
										 |  |  | 				fmt.printf("tuple nonexistence assign: mib[%d]", i); | 
					
						
							| 
									
										
										
										
											2008-08-11 13:32:13 -07:00
										 |  |  | 			} | 
					
						
							|  |  |  | 		} | 
					
						
							|  |  |  | 		{ | 
					
						
							|  |  |  | 			a, b := mii[i]; | 
					
						
							|  |  |  | 			if b { | 
					
						
							| 
									
										
										
										
											2008-12-20 16:07:43 -08:00
										 |  |  | 				fmt.printf("tuple nonexistence decl: mii[%d]", i); | 
					
						
							| 
									
										
										
										
											2008-08-11 13:32:13 -07:00
										 |  |  | 			} | 
					
						
							|  |  |  | 			a, b = mii[i]; | 
					
						
							|  |  |  | 			if b { | 
					
						
							| 
									
										
										
										
											2008-12-20 16:07:43 -08:00
										 |  |  | 				fmt.printf("tuple nonexistence assign: mii[%d]", i); | 
					
						
							| 
									
										
										
										
											2008-08-11 13:32:13 -07:00
										 |  |  | 			} | 
					
						
							|  |  |  | 		} | 
					
						
							|  |  |  | 		{ | 
					
						
							|  |  |  | 			a, b := mfi[f]; | 
					
						
							|  |  |  | 			if b { | 
					
						
							| 
									
										
										
										
											2008-12-20 16:07:43 -08:00
										 |  |  | 				fmt.printf("tuple nonexistence decl: mfi[%d]", i); | 
					
						
							| 
									
										
										
										
											2008-08-11 13:32:13 -07:00
										 |  |  | 			} | 
					
						
							|  |  |  | 			a, b = mfi[f]; | 
					
						
							|  |  |  | 			if b { | 
					
						
							| 
									
										
										
										
											2008-12-20 16:07:43 -08:00
										 |  |  | 				fmt.printf("tuple nonexistence assign: mfi[%d]", i); | 
					
						
							| 
									
										
										
										
											2008-08-11 13:32:13 -07:00
										 |  |  | 			} | 
					
						
							|  |  |  | 		} | 
					
						
							|  |  |  | 		{ | 
					
						
							|  |  |  | 			a, b := mif[i]; | 
					
						
							|  |  |  | 			if b { | 
					
						
							| 
									
										
										
										
											2008-12-20 16:07:43 -08:00
										 |  |  | 				fmt.printf("tuple nonexistence decl: mif[%d]", i); | 
					
						
							| 
									
										
										
										
											2008-08-11 13:32:13 -07:00
										 |  |  | 			} | 
					
						
							|  |  |  | 			a, b = mif[i]; | 
					
						
							|  |  |  | 			if b { | 
					
						
							| 
									
										
										
										
											2008-12-20 16:07:43 -08:00
										 |  |  | 				fmt.printf("tuple nonexistence assign: mif[%d]", i); | 
					
						
							| 
									
										
										
										
											2008-08-11 13:32:13 -07:00
										 |  |  | 			} | 
					
						
							|  |  |  | 		} | 
					
						
							|  |  |  | 		{ | 
					
						
							|  |  |  | 			a, b := mis[i]; | 
					
						
							|  |  |  | 			if b { | 
					
						
							| 
									
										
										
										
											2008-12-20 16:07:43 -08:00
										 |  |  | 				fmt.printf("tuple nonexistence decl: mis[%d]", i); | 
					
						
							| 
									
										
										
										
											2008-08-11 13:32:13 -07:00
										 |  |  | 			} | 
					
						
							|  |  |  | 			a, b = mis[i]; | 
					
						
							|  |  |  | 			if b { | 
					
						
							| 
									
										
										
										
											2008-12-20 16:07:43 -08:00
										 |  |  | 				fmt.printf("tuple nonexistence assign: mis[%d]", i); | 
					
						
							| 
									
										
										
										
											2008-08-11 13:32:13 -07:00
										 |  |  | 			} | 
					
						
							|  |  |  | 		} | 
					
						
							|  |  |  | 		{ | 
					
						
							|  |  |  | 			a, b := msi[s]; | 
					
						
							|  |  |  | 			if b { | 
					
						
							| 
									
										
										
										
											2008-12-20 16:07:43 -08:00
										 |  |  | 				fmt.printf("tuple nonexistence decl: msi[%d]", i); | 
					
						
							| 
									
										
										
										
											2008-08-11 13:32:13 -07:00
										 |  |  | 			} | 
					
						
							|  |  |  | 			a, b = msi[s]; | 
					
						
							|  |  |  | 			if b { | 
					
						
							| 
									
										
										
										
											2008-12-20 16:07:43 -08:00
										 |  |  | 				fmt.printf("tuple nonexistence assign: msi[%d]", i); | 
					
						
							| 
									
										
										
										
											2008-08-11 13:32:13 -07:00
										 |  |  | 			} | 
					
						
							|  |  |  | 		} | 
					
						
							|  |  |  | 		{ | 
					
						
							|  |  |  | 			a, b := mss[s]; | 
					
						
							|  |  |  | 			if b { | 
					
						
							| 
									
										
										
										
											2008-12-20 16:07:43 -08:00
										 |  |  | 				fmt.printf("tuple nonexistence decl: mss[%d]", i); | 
					
						
							| 
									
										
										
										
											2008-08-11 13:32:13 -07:00
										 |  |  | 			} | 
					
						
							|  |  |  | 			a, b = mss[s]; | 
					
						
							|  |  |  | 			if b { | 
					
						
							| 
									
										
										
										
											2008-12-20 16:07:43 -08:00
										 |  |  | 				fmt.printf("tuple nonexistence assign: mss[%d]", i); | 
					
						
							| 
									
										
										
										
											2008-08-11 13:32:13 -07:00
										 |  |  | 			} | 
					
						
							|  |  |  | 		} | 
					
						
							|  |  |  | 		{ | 
					
						
							|  |  |  | 			a, b := mspa[s]; | 
					
						
							|  |  |  | 			if b { | 
					
						
							| 
									
										
										
										
											2008-12-20 16:07:43 -08:00
										 |  |  | 				fmt.printf("tuple nonexistence decl: mspa[%d]", i); | 
					
						
							| 
									
										
										
										
											2008-08-11 13:32:13 -07:00
										 |  |  | 			} | 
					
						
							|  |  |  | 			a, b = mspa[s]; | 
					
						
							|  |  |  | 			if b { | 
					
						
							| 
									
										
										
										
											2008-12-20 16:07:43 -08:00
										 |  |  | 				fmt.printf("tuple nonexistence assign: mspa[%d]", i); | 
					
						
							| 
									
										
										
										
											2008-08-11 13:32:13 -07:00
										 |  |  | 			} | 
					
						
							|  |  |  | 		} | 
					
						
							|  |  |  | 		{ | 
					
						
							|  |  |  | 			a, b := mipT[i]; | 
					
						
							|  |  |  | 			if b { | 
					
						
							| 
									
										
										
										
											2008-12-20 16:07:43 -08:00
										 |  |  | 				fmt.printf("tuple nonexistence decl: mipT[%d]", i); | 
					
						
							| 
									
										
										
										
											2008-08-11 13:32:13 -07:00
										 |  |  | 			} | 
					
						
							|  |  |  | 			a, b = mipT[i]; | 
					
						
							|  |  |  | 			if b { | 
					
						
							| 
									
										
										
										
											2008-12-20 16:07:43 -08:00
										 |  |  | 				fmt.printf("tuple nonexistence assign: mipT[%d]", i); | 
					
						
							| 
									
										
										
										
											2008-08-11 13:32:13 -07:00
										 |  |  | 			} | 
					
						
							|  |  |  | 		} | 
					
						
							|  |  |  | 		{ | 
					
						
							|  |  |  | 			a, b := mpTi[apT[i]]; | 
					
						
							|  |  |  | 			if b { | 
					
						
							| 
									
										
										
										
											2008-12-20 16:07:43 -08:00
										 |  |  | 				fmt.printf("tuple nonexistence decl: mpTi[apt[%d]]", i); | 
					
						
							| 
									
										
										
										
											2008-08-11 13:32:13 -07:00
										 |  |  | 			} | 
					
						
							|  |  |  | 			a, b = mpTi[apT[i]]; | 
					
						
							|  |  |  | 			if b { | 
					
						
							| 
									
										
										
										
											2008-12-20 16:07:43 -08:00
										 |  |  | 				fmt.printf("tuple nonexistence assign: mpTi[apT[%d]]", i); | 
					
						
							| 
									
										
										
										
											2008-08-11 13:32:13 -07:00
										 |  |  | 			} | 
					
						
							|  |  |  | 		} | 
					
						
							|  |  |  | 		{ | 
					
						
							|  |  |  | 			a, b := mipM[i]; | 
					
						
							|  |  |  | 			if b { | 
					
						
							| 
									
										
										
										
											2008-12-20 16:07:43 -08:00
										 |  |  | 				fmt.printf("tuple nonexistence decl: mipM[%d]", i); | 
					
						
							| 
									
										
										
										
											2008-08-11 13:32:13 -07:00
										 |  |  | 			} | 
					
						
							|  |  |  | 			a, b = mipM[i]; | 
					
						
							|  |  |  | 			if b { | 
					
						
							| 
									
										
										
										
											2008-12-20 16:07:43 -08:00
										 |  |  | 				fmt.printf("tuple nonexistence assign: mipM[%d]", i); | 
					
						
							|  |  |  | 			} | 
					
						
							|  |  |  | 		} | 
					
						
							|  |  |  | 		{ | 
					
						
							|  |  |  | 			a, b := mti[t]; | 
					
						
							|  |  |  | 			if b { | 
					
						
							|  |  |  | 				fmt.printf("tuple nonexistence decl: mti[%d]", i); | 
					
						
							|  |  |  | 			} | 
					
						
							|  |  |  | 			a, b = mti[t]; | 
					
						
							|  |  |  | 			if b { | 
					
						
							|  |  |  | 				fmt.printf("tuple nonexistence assign: mti[%d]", i); | 
					
						
							|  |  |  | 			} | 
					
						
							|  |  |  | 		} | 
					
						
							|  |  |  | 		{ | 
					
						
							|  |  |  | 			a, b := mit[i]; | 
					
						
							|  |  |  | 			if b { | 
					
						
							|  |  |  | 				fmt.printf("tuple nonexistence decl: mit[%d]", i); | 
					
						
							|  |  |  | 			} | 
					
						
							|  |  |  | 			a, b = mit[i]; | 
					
						
							|  |  |  | 			if b { | 
					
						
							|  |  |  | 				fmt.printf("tuple nonexistence assign: mit[%d]", i); | 
					
						
							| 
									
										
										
										
											2008-08-11 13:32:13 -07:00
										 |  |  | 			} | 
					
						
							|  |  |  | 		} | 
					
						
							|  |  |  | 	} | 
					
						
							| 
									
										
										
										
											2008-12-19 03:05:37 -08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2008-08-11 13:32:13 -07:00
										 |  |  | 
 | 
					
						
							|  |  |  | 	// tests for structured map element updates | 
					
						
							|  |  |  | 	for i := 0; i < count; i++ { | 
					
						
							| 
									
										
										
										
											2008-12-20 16:07:43 -08:00
										 |  |  | 		s := strconv.itoa(i); | 
					
						
							| 
									
										
										
										
											2008-08-11 13:32:13 -07:00
										 |  |  | 		mspa[s][i % 2] = "deleted"; | 
					
						
							|  |  |  | 		if mspa[s][i % 2] != "deleted" { | 
					
						
							| 
									
										
										
										
											2008-12-20 16:07:43 -08:00
										 |  |  | 			fmt.printf("update mspa[%s][%d] = %s\n", s, i %2, mspa[s][i % 2]); | 
					
						
							| 
									
										
										
										
											2008-08-11 13:32:13 -07:00
										 |  |  | 		} | 
					
						
							| 
									
										
										
										
											2008-12-20 16:07:43 -08:00
										 |  |  | 
 | 
					
						
							|  |  |  | 		mipT[i].i += 1; | 
					
						
							|  |  |  | 		if mipT[i].i != int64(i)+1 { | 
					
						
							|  |  |  | 			fmt.printf("update mipT[%d].i = %d\n", i, mipT[i].i); | 
					
						
							| 
									
										
										
										
											2008-08-11 13:32:13 -07:00
										 |  |  | 		} | 
					
						
							|  |  |  | 		mipT[i].f = float(i + 1); | 
					
						
							|  |  |  | 		if (mipT[i].f != float(i + 1)) { | 
					
						
							| 
									
										
										
										
											2008-12-20 16:07:43 -08:00
										 |  |  | 			fmt.printf("update mipT[%d].f = %g\n", i, mipT[i].f); | 
					
						
							| 
									
										
										
										
											2008-08-11 13:32:13 -07:00
										 |  |  | 		} | 
					
						
							| 
									
										
										
										
											2008-12-20 16:07:43 -08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2008-08-11 13:32:13 -07:00
										 |  |  | 		mipM[i][i]++; | 
					
						
							|  |  |  | 		if mipM[i][i] != (i + 1) + 1 { | 
					
						
							| 
									
										
										
										
											2008-12-20 16:07:43 -08:00
										 |  |  | 			fmt.printf("update mipM[%d][%d] = %i\n", i, i, mipM[i][i]); | 
					
						
							| 
									
										
										
										
											2008-08-11 13:32:13 -07:00
										 |  |  | 		} | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | } |