]> Cypherpunks.ru repositories - gostls13.git/blobdiff - test/map.go
cmd/compile/internal/inline: score call sites exposed by inlines
[gostls13.git] / test / map.go
index c5544e5297f873c0cf28bffb4e2282e5fffa3709..2c1cf8a14038259d1453a57e3d4e7a7d27da7ea6 100644 (file)
-// $G $F.go && $L $F.$A && ./$A.out
+// run
 
 // 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.
 
+// Test maps, almost exhaustively.
+// Complexity (linearity) test is in maplinear.go.
 
 package main
 
-import fmt "fmt"
+import (
+       "fmt"
+       "math"
+       "strconv"
+)
 
-const arraylen = 2; // BUG: shouldn't need this
+const count = 100
 
-func P(a *[]string) string {
-       s := "{";
+func P(a []string) string {
+       s := "{"
        for i := 0; i < len(a); i++ {
                if i > 0 {
                        s += ","
                }
-               s += `"` + a[i] + `"`;
+               s += `"` + a[i] + `"`
        }
-       s +="}";
-       return s;
+       s += "}"
+       return s
 }
 
 func main() {
-       F := fmt.New();
-
-       // BUG: should test a map literal when there's syntax
-
-       mib := new(map[int] bool);
-       mii := new(map[int] int);
-       mfi := new(map[float] int);
-       mif := new(map[int] float);
-       msi := new(map[string] int);
-       mis := new(map[int] string);
-       mss := new(map[string] string);
-       mspa := new(map[string] *[]string);
+       testbasic()
+       testfloat()
+       testnan()
+}
+
+func testbasic() {
+       // 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 {
+                       panic(fmt.Sprintf("mlit[%s] = %d\n", s, mlit[s]))
+               }
+       }
+
+       mib := make(map[int]bool)
+       mii := make(map[int]int)
+       mfi := make(map[float32]int)
+       mif := make(map[int]float32)
+       msi := make(map[string]int)
+       mis := make(map[int]string)
+       mss := make(map[string]string)
+       mspa := make(map[string][]string)
        // BUG need an interface map both ways too
 
        type T struct {
-               s string;
-               f float;
-       };
-       mipT := new(map[int] *T);
-       mpTi := new(map[*T] int);
-       //mit := new(map[int] T);       // should be able to do a value but:  fatal error: algtype: cant find type <T>{}
-       //mti := new(map[T] int);       // should be able to do a value but:  fatal error: algtype: cant find type <T>{}
+               i int64 // can't use string here; struct values are only compared at the top level
+               f float32
+       }
+       mipT := make(map[int]*T)
+       mpTi := make(map[*T]int)
+       mit := make(map[int]T)
+       //      mti := make(map[T] int)
 
-       type M map[int] int; 
-       mipM := new(map[int] *M);
+       type M map[int]int
+       mipM := make(map[int]M)
 
-       const count = 100; // BUG: should be bigger but maps do linear lookup
-       var apT [2*count]*T;
+       var apT [2 * count]*T
 
        for i := 0; i < count; i++ {
-               s := F.d(i).str();
-               f := float(i);
-               apT[i] = new(T);
-               apT[i].s = s;
-               apT[i].f = f;
-               apT[2*i] = new(T);      // need twice as many entries as we use, for the nonexistence check
-               apT[2*i].s = s;
-               apT[2*i].f = f;
-               // BUG t := T(s, f);
-               t := new(T); t.s = s; t.f = f;
-               // BUG m := M(i, i+1);
-               m := new(M); m[i] = i+1;
-               mib[i] = (i != 0);
-               mii[i] = 10*i;
-               mfi[float(i)] = 10*i;
-               mif[i] = 10.0*f;
-               mis[i] = s;
-               msi[F.d(i).str()] = i;
-               mss[F.d(i).str()] = F.d(10*i).str();
-               mss[F.d(i).str()] = F.d(10*i).str();
-               as := new([arraylen]string);
-                       as[0] = F.d(10*i).str();
-                       as[1] = F.d(10*i).str();
-               mspa[F.d(i).str()] = as;
-               mipT[i] = t;
-               mpTi[apT[i]] = i;
-               // BUG mti[t] = i;
-               mipM[i] = m;
+               s := strconv.Itoa(i)
+               s10 := strconv.Itoa(i * 10)
+               f := float32(i)
+               t := T{int64(i), f}
+               apT[i] = new(T)
+               apT[i].i = int64(i)
+               apT[i].f = f
+               apT[2*i] = new(T) // need twice as many entries as we use, for the nonexistence check
+               apT[2*i].i = int64(i)
+               apT[2*i].f = f
+               m := M{i: i + 1}
+               mib[i] = (i != 0)
+               mii[i] = 10 * i
+               mfi[float32(i)] = 10 * i
+               mif[i] = 10.0 * f
+               mis[i] = s
+               msi[s] = i
+               mss[s] = s10
+               mss[s] = s10
+               as := make([]string, 2)
+               as[0] = s10
+               as[1] = s10
+               mspa[s] = as
+               mipT[i] = apT[i]
+               mpTi[apT[i]] = i
+               mipM[i] = m
+               mit[i] = t
+               //      mti[t] = i
        }
 
        // test len
        if len(mib) != count {
-               F.s("len(mib) = ").d(len(mib)).putnl();
+               panic(fmt.Sprintf("len(mib) = %d\n", len(mib)))
        }
        if len(mii) != count {
-               F.s("len(mii) = ").d(len(mii)).putnl();
+               panic(fmt.Sprintf("len(mii) = %d\n", len(mii)))
        }
        if len(mfi) != count {
-               F.s("len(mfi) = ").d(len(mfi)).putnl();
+               panic(fmt.Sprintf("len(mfi) = %d\n", len(mfi)))
        }
        if len(mif) != count {
-               F.s("len(mif) = ").d(len(mif)).putnl();
+               panic(fmt.Sprintf("len(mif) = %d\n", len(mif)))
        }
        if len(msi) != count {
-               F.s("len(msi) = ").d(len(msi)).putnl();
+               panic(fmt.Sprintf("len(msi) = %d\n", len(msi)))
        }
        if len(mis) != count {
-               F.s("len(mis) = ").d(len(mis)).putnl();
+               panic(fmt.Sprintf("len(mis) = %d\n", len(mis)))
        }
        if len(mss) != count {
-               F.s("len(mss) = ").d(len(mss)).putnl();
+               panic(fmt.Sprintf("len(mss) = %d\n", len(mss)))
        }
        if len(mspa) != count {
-               F.s("len(mspa) = ").d(len(mspa)).putnl();
+               panic(fmt.Sprintf("len(mspa) = %d\n", len(mspa)))
        }
        if len(mipT) != count {
-               F.s("len(mipT) = ").d(len(mipT)).putnl();
+               panic(fmt.Sprintf("len(mipT) = %d\n", len(mipT)))
        }
        if len(mpTi) != count {
-               F.s("len(mpTi) = ").d(len(mpTi)).putnl();
+               panic(fmt.Sprintf("len(mpTi) = %d\n", len(mpTi)))
        }
-//     if len(mti) != count {
-//             F.s("len(mti) = ").d(len(mti)).putnl();
-//     }
+       //      if len(mti) != count {
+       //              panic(fmt.Sprintf("len(mti) = %d\n", len(mti)))
+       //      }
        if len(mipM) != count {
-               F.s("len(mipM) = ").d(len(mipM)).putnl();
+               panic(fmt.Sprintf("len(mipM) = %d\n", len(mipM)))
+       }
+       //      if len(mti) != count {
+       //              panic(fmt.Sprintf("len(mti) = %d\n", len(mti)))
+       //      }
+       if len(mit) != count {
+               panic(fmt.Sprintf("len(mit) = %d\n", len(mit)))
        }
-       
+
        // test construction directly
        for i := 0; i < count; i++ {
-               s := F.d(i).str();
-               f := float(i);
-               // BUG t := T(s, f);
-               var t T; t.s = s; t.f = f;
-               // BUG m := M(i, i+1);
+               s := strconv.Itoa(i)
+               s10 := strconv.Itoa(i * 10)
+               f := float32(i)
+               // BUG m := M(i, i+1)
                if mib[i] != (i != 0) {
-                       F.s("mib[").d(i).s("] = ").boolean(mib[i]).putnl();
+                       panic(fmt.Sprintf("mib[%d] = %t\n", i, mib[i]))
                }
-               if(mii[i] != 10*i) {
-                       F.s("mii[").d(i).s("] = ").d(mii[i]).putnl();
+               if mii[i] != 10*i {
+                       panic(fmt.Sprintf("mii[%d] = %d\n", i, mii[i]))
                }
-               if(mfi[f] != 10*i) {
-                       F.s("mfi[").d(i).s("] = ").d(mfi[f]).putnl();
+               if mfi[f] != 10*i {
+                       panic(fmt.Sprintf("mfi[%d] = %d\n", i, mfi[f]))
                }
-               if(mif[i] != 10.0*f) {
-                       F.s("mif[").d(i).s("] = ").g(mif[i]).putnl();
+               if mif[i] != 10.0*f {
+                       panic(fmt.Sprintf("mif[%d] = %g\n", i, mif[i]))
                }
-               if(mis[i] != s) {
-                       F.s("mis[").d(i).s("] = ").s(mis[i]).putnl();
+               if mis[i] != s {
+                       panic(fmt.Sprintf("mis[%d] = %s\n", i, mis[i]))
                }
-               if(msi[s] != i) {
-                       F.s("msi[").s(s).s("] = ").d(msi[s]).putnl();
+               if msi[s] != i {
+                       panic(fmt.Sprintf("msi[%s] = %d\n", s, msi[s]))
                }
-               if mss[s] != F.d(10*i).str() {
-                       F.s("mss[").s(s).s("] = ").s(mss[s]).putnl();
+               if mss[s] != s10 {
+                       panic(fmt.Sprintf("mss[%s] = %g\n", s, mss[s]))
                }
-               for j := 0; j < arraylen; j++ {
-                       if mspa[s][j] != F.d(10*i).str() {
-                               F.s("mspa[").s(s).s("][").d(j).s("] = ").s(mspa[s][j]).putnl();
+               for j := 0; j < len(mspa[s]); j++ {
+                       if mspa[s][j] != s10 {
+                               panic(fmt.Sprintf("mspa[%s][%d] = %s\n", s, j, mspa[s][j]))
                        }
                }
-               if(mipT[i].s != s || mipT[i].f != f) {
-                       F.s("mipT[").d(i).s("] = {").s(mipT[i].s).s(", ").g(mipT[i].f).s("}").putnl();
-               }
-               if(mpTi[apT[i]] != i) {
-                       F.s("mpTi[apT[").d(i).s("]] = ").d(mpTi[apT[i]]).putnl();
-               }
-//             if(mti[t] != i) {
-//                     F.s("mti[").s(s).s("] = ").s(mti[s]).putnl();
-//             }
-               if (mipM[i][i] != i + 1) {
-                       F.s("mipM[").d(i).s("][").d(i).s("] =").d(mipM[i][i]).putnl();
-               }
-       }
-
-       // test existence with zero check
-       // failed lookups yield the 'zero' of the type.
-       // a later loop uses the more reliable tuple check.
-       for i := 1; i < count; i++ {    // loop from 1 to avoid the real 'zeros'
-               s := F.d(i).str();
-               f := float(i);
-               // BUG t := T(s, f);
-               var t T; t.s = s; t.f = f;
-               // BUG m := M(i, i+1);
-               if mib[i] == false {
-                       F.s("existence: mib[").d(i).s("] == false").putnl();
-               }
-               if mii[i] == 0 {
-                       F.s("existence: mii[").d(i).s("] == 0").putnl();
-               }
-               if mfi[f] == 0 {
-                       F.s("existence: mfi[").g(f).s("] == 0").putnl();
-               }
-               if mif[i] == 0.0 {
-                       F.s("existence: mif[").d(i).s("] == 0.0").putnl();
-               }
-               if mis[i] == "" {
-                       F.s("existence: mis[").d(i).s("] == ``").putnl();
-               }
-               if msi[s] == 0 {
-                       F.s("existence: msi[").s(s).s("] == 0").putnl();
-               }
-               if mss[s] == `` {
-                       F.s("existence: mss[").s(s).s("] == ``").putnl();
-               }
-               if mspa[s] == nil {
-                       F.s("existence: mspa[").s(s).s("] == ``").putnl();
+               if mipT[i].i != int64(i) || mipT[i].f != f {
+                       panic(fmt.Sprintf("mipT[%d] = %v\n", i, mipT[i]))
                }
-               if mipT[i] == nil {
-                       F.s("existence: mipT[").d(i).s("] == nil").putnl();
+               if mpTi[apT[i]] != i {
+                       panic(fmt.Sprintf("mpTi[apT[%d]] = %d\n", i, mpTi[apT[i]]))
                }
-               if mpTi[apT[i]] == 0 {
-                       F.s("existence: mpTi[apT[").d(i).s("]] == 0").putnl();
+               //      if(mti[t] != i) {
+               //              panic(fmt.Sprintf("mti[%s] = %s\n", s, mti[t]))
+               //      }
+               if mipM[i][i] != i+1 {
+                       panic(fmt.Sprintf("mipM[%d][%d] = %d\n", i, i, mipM[i][i]))
                }
-//             if mti[t]  == 0 {
-//                     //emit stdout <- format("haskey mti[%s] false", string(t));
-//             }
-               if mipM[i] == nil {
-                       F.s("existence: mipM[").d(i).s("] == nil").putnl();
-               }
-       }
-
-       // test nonexistence with zero check
-       // failed lookups yield the 'zero' of the type.
-       // a later loop uses the more reliable tuple check.
-       for i := count; i < 2*count; i++ {
-               s := F.d(i).str();
-               f := float(i);
-               // BUG t := T(s, f);
-               var t T; t.s = s; t.f = f;
-               // BUG m := M(i, i+1);
-               if mib[i] != false {
-                       F.s("nonexistence: mib[").d(i).s("] != false").putnl();
-               }
-               if mii[i] != 0 {
-                       F.s("nonexistence: mii[").d(i).s("] != 0").putnl();
-               }
-               if mfi[f] != 0 {
-                       F.s("nonexistence: mfi[").g(f).s("] != 0").putnl();
-               }
-               if mif[i] != 0.0 {
-                       F.s("nonexistence: mif[").d(i).s("] != 0.0").putnl();
-               }
-               if mis[i] != `` {
-                       F.s("nonexistence: mis[").d(i).s("] != ``").putnl();
-               }
-               if msi[s] != 0 {
-                       F.s("nonexistence: msi[").s(s).s("] != 0").putnl();
-               }
-               if mss[s] != `` {
-                       F.s("nonexistence: mss[").s(s).s("] != ``").putnl();
-               }
-               if mspa[s] != nil {
-                       F.s("nonexistence: mspa[").s(s).s("] != ``").putnl();
-               }
-               if mipT[i] != nil {
-                       F.s("nonexistence: mipT[").d(i).s("] != nil").putnl();
-               }
-               if mpTi[apT[i]] != 0 {
-                       F.s("nonexistence: mpTi[apT[").d(i).s("]] != 0").putnl();
-               }
-//             if mti[t] != 0 {
-//                     // emit stdout <- format("haskey mti[%s] false", string(t));
-//
-               if mipM[i] != nil {
-                       F.s("nonexistence: mipM[").d(i).s("] != nil").putnl();
+               //      if(mti[t] != i) {
+               //              panic(fmt.Sprintf("mti[%v] = %d\n", t, mti[t]))
+               //      }
+               if mit[i].i != int64(i) || mit[i].f != f {
+                       panic(fmt.Sprintf("mit[%d] = {%d %g}\n", i, mit[i].i, mit[i].f))
                }
        }
 
        // test existence with tuple check
        // failed lookups yield a false value for the boolean.
        for i := 0; i < count; i++ {
-               s := F.d(i).str();
-               f := float(i);
-               // BUG t := T(s, f);
-               var t T; t.s = s; t.f = f;
-               // BUG m := M(i, i+1);
+               s := strconv.Itoa(i)
+               f := float32(i)
                {
-                       a, b := mib[i];
+                       _, b := mib[i]
                        if !b {
-                               F.s("tuple existence decl: mib[").d(i).s("]").putnl();
+                               panic(fmt.Sprintf("tuple existence decl: mib[%d]\n", i))
                        }
-                       a, b = mib[i];
+                       _, b = mib[i]
                        if !b {
-                               F.s("tuple existence assign: mib[").d(i).s("]").putnl();
+                               panic(fmt.Sprintf("tuple existence assign: mib[%d]\n", i))
                        }
                }
                {
-                       a, b := mii[i];
+                       _, b := mii[i]
                        if !b {
-                               F.s("tuple existence decl: mii[").d(i).s("]").putnl();
+                               panic(fmt.Sprintf("tuple existence decl: mii[%d]\n", i))
                        }
-                       a, b = mii[i];
+                       _, b = mii[i]
                        if !b {
-                               F.s("tuple existence assign: mii[").d(i).s("]").putnl();
+                               panic(fmt.Sprintf("tuple existence assign: mii[%d]\n", i))
                        }
                }
                {
-                       a, b := mfi[f];
+                       _, b := mfi[f]
                        if !b {
-                               F.s("tuple existence decl: mfi[").g(f).s("]").putnl();
+                               panic(fmt.Sprintf("tuple existence decl: mfi[%d]\n", i))
                        }
-                       a, b = mfi[f];
+                       _, b = mfi[f]
                        if !b {
-                               F.s("tuple existence assign: mfi[").g(f).s("]").putnl();
+                               panic(fmt.Sprintf("tuple existence assign: mfi[%d]\n", i))
                        }
                }
                {
-                       a, b := mif[i];
+                       _, b := mif[i]
                        if !b {
-                               F.s("tuple existence decl: mif[").d(i).s("]").putnl();
+                               panic(fmt.Sprintf("tuple existence decl: mif[%d]\n", i))
                        }
-                       a, b = mif[i];
+                       _, b = mif[i]
                        if !b {
-                               F.s("tuple existence assign: mif[").d(i).s("]").putnl();
+                               panic(fmt.Sprintf("tuple existence assign: mif[%d]\n", i))
                        }
                }
                {
-                       a, b := mis[i];
+                       _, b := mis[i]
                        if !b {
-                               F.s("tuple existence decl: mis[").d(i).s("]").putnl();
+                               panic(fmt.Sprintf("tuple existence decl: mis[%d]\n", i))
                        }
-                       a, b = mis[i];
+                       _, b = mis[i]
                        if !b {
-                               F.s("tuple existence assign: mis[").d(i).s("]").putnl();
+                               panic(fmt.Sprintf("tuple existence assign: mis[%d]\n", i))
                        }
                }
                {
-                       a, b := msi[s];
+                       _, b := msi[s]
                        if !b {
-                               F.s("tuple existence decl: msi[").s(s).s("]").putnl();
+                               panic(fmt.Sprintf("tuple existence decl: msi[%d]\n", i))
                        }
-                       a, b = msi[s];
+                       _, b = msi[s]
                        if !b {
-                               F.s("tuple existence assign: msi[").s(s).s("]").putnl();
+                               panic(fmt.Sprintf("tuple existence assign: msi[%d]\n", i))
                        }
                }
                {
-                       a, b := mss[s];
+                       _, b := mss[s]
                        if !b {
-                               F.s("tuple existence decl: mss[").s(s).s("]").putnl();
+                               panic(fmt.Sprintf("tuple existence decl: mss[%d]\n", i))
                        }
-                       a, b = mss[s];
+                       _, b = mss[s]
                        if !b {
-                               F.s("tuple existence assign: mss[").s(s).s("]").putnl();
+                               panic(fmt.Sprintf("tuple existence assign: mss[%d]\n", i))
                        }
                }
                {
-                       a, b := mspa[s];
+                       _, b := mspa[s]
                        if !b {
-                               F.s("tuple existence decl: mspa[").s(s).s("]").putnl();
+                               panic(fmt.Sprintf("tuple existence decl: mspa[%d]\n", i))
                        }
-                       a, b = mspa[s];
+                       _, b = mspa[s]
                        if !b {
-                               F.s("tuple existence assign: mspa[").s(s).s("]").putnl();
+                               panic(fmt.Sprintf("tuple existence assign: mspa[%d]\n", i))
                        }
                }
                {
-                       a, b := mipT[i];
+                       _, b := mipT[i]
                        if !b {
-                               F.s("tuple existence decl: mipT[").d(i).s("]").putnl();
+                               panic(fmt.Sprintf("tuple existence decl: mipT[%d]\n", i))
                        }
-                       a, b = mipT[i];
+                       _, b = mipT[i]
                        if !b {
-                               F.s("tuple existence assign: mipT[").d(i).s("]").putnl();
+                               panic(fmt.Sprintf("tuple existence assign: mipT[%d]\n", i))
                        }
                }
                {
-                       a, b := mpTi[apT[i]];
+                       _, b := mpTi[apT[i]]
                        if !b {
-                               F.s("tuple existence decl: mpTi[apT[").d(i).s("]]").putnl();
+                               panic(fmt.Sprintf("tuple existence decl: mpTi[apT[%d]]\n", i))
                        }
-                       a, b = mpTi[apT[i]];
+                       _, b = mpTi[apT[i]]
                        if !b {
-                               F.s("tuple existence assign: mpTi[apT[").d(i).s("]]").putnl();
+                               panic(fmt.Sprintf("tuple existence assign: mpTi[apT[%d]]\n", i))
                        }
                }
-//             a,b := mti[t]...
-//                     emit stdout <- format("haskey mti[%s] false", string(t));
                {
-                       a, b := mipM[i];
+                       _, b := mipM[i]
                        if !b {
-                               F.s("tuple existence decl: mipM[").d(i).s("]").putnl();
+                               panic(fmt.Sprintf("tuple existence decl: mipM[%d]\n", i))
                        }
-                       a, b = mipM[i];
+                       _, b = mipM[i]
                        if !b {
-                               F.s("tuple existence assign: mipM[").d(i).s("]").putnl();
+                               panic(fmt.Sprintf("tuple existence assign: mipM[%d]\n", i))
                        }
                }
+               {
+                       _, b := mit[i]
+                       if !b {
+                               panic(fmt.Sprintf("tuple existence decl: mit[%d]\n", i))
+                       }
+                       _, b = mit[i]
+                       if !b {
+                               panic(fmt.Sprintf("tuple existence assign: mit[%d]\n", i))
+                       }
+               }
+               //              {
+               //                      _, b := mti[t]
+               //                      if !b {
+               //                              panic(fmt.Sprintf("tuple existence decl: mti[%d]\n", i))
+               //                      }
+               //                      _, b = mti[t]
+               //                      if !b {
+               //                              panic(fmt.Sprintf("tuple existence assign: mti[%d]\n", i))
+               //                      }
+               //              }
        }
 
        // test nonexistence with tuple check
        // failed lookups yield a false value for the boolean.
        for i := count; i < 2*count; i++ {
-               s := F.d(i).str();
-               f := float(i);
-               // BUG t := T(s, f);
-               var t T; t.s = s; t.f = f;
-               // BUG m := M(i, i+1);
+               s := strconv.Itoa(i)
+               f := float32(i)
                {
-                       a, b := mib[i];
+                       _, b := mib[i]
                        if b {
-                               F.s("tuple nonexistence decl: mib[").d(i).s("]").putnl();
+                               panic(fmt.Sprintf("tuple nonexistence decl: mib[%d]", i))
                        }
-                       a, b = mib[i];
+                       _, b = mib[i]
                        if b {
-                               F.s("tuple nonexistence assign: mib[").d(i).s("]").putnl();
+                               panic(fmt.Sprintf("tuple nonexistence assign: mib[%d]", i))
                        }
                }
                {
-                       a, b := mii[i];
+                       _, b := mii[i]
                        if b {
-                               F.s("tuple nonexistence decl: mii[").d(i).s("]").putnl();
+                               panic(fmt.Sprintf("tuple nonexistence decl: mii[%d]", i))
                        }
-                       a, b = mii[i];
+                       _, b = mii[i]
                        if b {
-                               F.s("tuple nonexistence assign: mii[").d(i).s("]").putnl();
+                               panic(fmt.Sprintf("tuple nonexistence assign: mii[%d]", i))
                        }
                }
                {
-                       a, b := mfi[f];
+                       _, b := mfi[f]
                        if b {
-                               F.s("tuple nonexistence decl: mfi[").g(f).s("]").putnl();
+                               panic(fmt.Sprintf("tuple nonexistence decl: mfi[%d]", i))
                        }
-                       a, b = mfi[f];
+                       _, b = mfi[f]
                        if b {
-                               F.s("tuple nonexistence assign: mfi[").g(f).s("]").putnl();
+                               panic(fmt.Sprintf("tuple nonexistence assign: mfi[%d]", i))
                        }
                }
                {
-                       a, b := mif[i];
+                       _, b := mif[i]
                        if b {
-                               F.s("tuple nonexistence decl: mif[").d(i).s("]").putnl();
+                               panic(fmt.Sprintf("tuple nonexistence decl: mif[%d]", i))
                        }
-                       a, b = mif[i];
+                       _, b = mif[i]
                        if b {
-                               F.s("tuple nonexistence assign: mif[").d(i).s("]").putnl();
+                               panic(fmt.Sprintf("tuple nonexistence assign: mif[%d]", i))
                        }
                }
                {
-                       a, b := mis[i];
+                       _, b := mis[i]
                        if b {
-                               F.s("tuple nonexistence decl: mis[").d(i).s("]").putnl();
+                               panic(fmt.Sprintf("tuple nonexistence decl: mis[%d]", i))
                        }
-                       a, b = mis[i];
+                       _, b = mis[i]
                        if b {
-                               F.s("tuple nonexistence assign: mis[").d(i).s("]").putnl();
+                               panic(fmt.Sprintf("tuple nonexistence assign: mis[%d]", i))
                        }
                }
                {
-                       a, b := msi[s];
+                       _, b := msi[s]
                        if b {
-                               F.s("tuple nonexistence decl: msi[").s(s).s("]").putnl();
+                               panic(fmt.Sprintf("tuple nonexistence decl: msi[%d]", i))
                        }
-                       a, b = msi[s];
+                       _, b = msi[s]
                        if b {
-                               F.s("tuple nonexistence assign: msi[").s(s).s("]").putnl();
+                               panic(fmt.Sprintf("tuple nonexistence assign: msi[%d]", i))
                        }
                }
                {
-                       a, b := mss[s];
+                       _, b := mss[s]
                        if b {
-                               F.s("tuple nonexistence decl: mss[").s(s).s("]").putnl();
+                               panic(fmt.Sprintf("tuple nonexistence decl: mss[%d]", i))
                        }
-                       a, b = mss[s];
+                       _, b = mss[s]
                        if b {
-                               F.s("tuple nonexistence assign: mss[").s(s).s("]").putnl();
+                               panic(fmt.Sprintf("tuple nonexistence assign: mss[%d]", i))
                        }
                }
                {
-                       a, b := mspa[s];
+                       _, b := mspa[s]
                        if b {
-                               F.s("tuple nonexistence decl: mspa[").s(s).s("]").putnl();
+                               panic(fmt.Sprintf("tuple nonexistence decl: mspa[%d]", i))
                        }
-                       a, b = mspa[s];
+                       _, b = mspa[s]
                        if b {
-                               F.s("tuple nonexistence assign: mspa[").s(s).s("]").putnl();
+                               panic(fmt.Sprintf("tuple nonexistence assign: mspa[%d]", i))
                        }
                }
                {
-                       a, b := mipT[i];
+                       _, b := mipT[i]
                        if b {
-                               F.s("tuple nonexistence decl: mipT[").d(i).s("]").putnl();
+                               panic(fmt.Sprintf("tuple nonexistence decl: mipT[%d]", i))
                        }
-                       a, b = mipT[i];
+                       _, b = mipT[i]
                        if b {
-                               F.s("tuple nonexistence assign: mipT[").d(i).s("]").putnl();
+                               panic(fmt.Sprintf("tuple nonexistence assign: mipT[%d]", i))
                        }
                }
                {
-                       a, b := mpTi[apT[i]];
+                       _, b := mpTi[apT[i]]
                        if b {
-                               F.s("tuple nonexistence decl: mpTi[apt[").d(i).s("]]").putnl();
+                               panic(fmt.Sprintf("tuple nonexistence decl: mpTi[apt[%d]]", i))
                        }
-                       a, b = mpTi[apT[i]];
+                       _, b = mpTi[apT[i]]
                        if b {
-                               F.s("tuple nonexistence assign: mpTi[apT[").d(i).s("]]").putnl();
+                               panic(fmt.Sprintf("tuple nonexistence assign: mpTi[apT[%d]]", i))
                        }
                }
-//             a,b := mti[t]...
-//                     emit stdout <- format("haskey mti[%s] false", string(t));
                {
-                       a, b := mipM[i];
+                       _, b := mipM[i]
                        if b {
-                               F.s("tuple nonexistence decl: mipM[").d(i).s("]").putnl();
+                               panic(fmt.Sprintf("tuple nonexistence decl: mipM[%d]", i))
                        }
-                       a, b = mipM[i];
+                       _, b = mipM[i]
                        if b {
-                               F.s("tuple nonexistence assign: mipM[").d(i).s("]").putnl();
+                               panic(fmt.Sprintf("tuple nonexistence assign: mipM[%d]", i))
+                       }
+               }
+               //              {
+               //                      _, b := mti[t]
+               //                      if b {
+               //                              panic(fmt.Sprintf("tuple nonexistence decl: mti[%d]", i))
+               //                      }
+               //                      _, b = mti[t]
+               //                      if b {
+               //                              panic(fmt.Sprintf("tuple nonexistence assign: mti[%d]", i))
+               //                      }
+               //              }
+               {
+                       _, b := mit[i]
+                       if b {
+                               panic(fmt.Sprintf("tuple nonexistence decl: mit[%d]", i))
+                       }
+                       _, b = mit[i]
+                       if b {
+                               panic(fmt.Sprintf("tuple nonexistence assign: mit[%d]", i))
                        }
                }
        }
 
        // tests for structured map element updates
        for i := 0; i < count; i++ {
-               s := F.d(i).str();
-               mspa[s][i % 2] = "deleted";
-               if mspa[s][i % 2] != "deleted" {
-                       F.s("mspa[").d(i).s("][").d(i).s("%2] =").s(mspa[s][i % 2]).putnl();
+               s := strconv.Itoa(i)
+               mspa[s][i%2] = "deleted"
+               if mspa[s][i%2] != "deleted" {
+                       panic(fmt.Sprintf("update mspa[%s][%d] = %s\n", s, i%2, mspa[s][i%2]))
+
                }
-               mipT[i].s = string('a' + i % 26) + mipT[i].s[1:len(s)];
-               first := string('a' + i % 26);
-               if mipT[i].s != first + s[1:len(s)] {
-                       F.s("mit[").d(i).s("].s = ").s(mipT[i].s).putnl();
+
+               mipT[i].i += 1
+               if mipT[i].i != int64(i)+1 {
+                       panic(fmt.Sprintf("update mipT[%d].i = %d\n", i, mipT[i].i))
+
                }
-               mipT[i].f = float(i + 1);
-               if (mipT[i].f != float(i + 1)) {
-                       F.s("mipT[").d(i).s("].f = ").g(mipT[i].f).putnl();
+               mipT[i].f = float32(i + 1)
+               if mipT[i].f != float32(i+1) {
+                       panic(fmt.Sprintf("update mipT[%d].f = %g\n", i, mipT[i].f))
+
                }
-               mipM[i][i]++;
-               if mipM[i][i] != (i + 1) + 1 {
-                       F.s("mipM[").d(i).s("][").d(i).s("] = ").d(mipM[i][i]).putnl();
+
+               mipM[i][i]++
+               if mipM[i][i] != (i+1)+1 {
+                       panic(fmt.Sprintf("update mipM[%d][%d] = %d\n", i, i, mipM[i][i]))
+
                }
        }
+
+       // test range on nil map
+       var mnil map[string]int
+       for _, _ = range mnil {
+               panic("range mnil")
+       }
+}
+
+func testfloat() {
+       // Test floating point numbers in maps.
+       // Two map keys refer to the same entry if the keys are ==.
+       // The special cases, then, are that +0 == -0 and that NaN != NaN.
+
+       {
+               var (
+                       pz   = float32(0)
+                       nz   = math.Float32frombits(1 << 31)
+                       nana = float32(math.NaN())
+                       nanb = math.Float32frombits(math.Float32bits(nana) ^ 2)
+               )
+
+               m := map[float32]string{
+                       pz:   "+0",
+                       nana: "NaN",
+                       nanb: "NaN",
+               }
+               if m[pz] != "+0" {
+                       panic(fmt.Sprintln("float32 map cannot read back m[+0]:", m[pz]))
+               }
+               if m[nz] != "+0" {
+                       fmt.Sprintln("float32 map does not treat", pz, "and", nz, "as equal for read")
+                       panic(fmt.Sprintln("float32 map does not treat -0 and +0 as equal for read"))
+               }
+               m[nz] = "-0"
+               if m[pz] != "-0" {
+                       panic(fmt.Sprintln("float32 map does not treat -0 and +0 as equal for write"))
+               }
+               if _, ok := m[nana]; ok {
+                       panic(fmt.Sprintln("float32 map allows NaN lookup (a)"))
+               }
+               if _, ok := m[nanb]; ok {
+                       panic(fmt.Sprintln("float32 map allows NaN lookup (b)"))
+               }
+               if len(m) != 3 {
+                       panic(fmt.Sprintln("float32 map should have 3 entries:", m))
+               }
+               m[nana] = "NaN"
+               m[nanb] = "NaN"
+               if len(m) != 5 {
+                       panic(fmt.Sprintln("float32 map should have 5 entries:", m))
+               }
+       }
+
+       {
+               var (
+                       pz   = float64(0)
+                       nz   = math.Float64frombits(1 << 63)
+                       nana = float64(math.NaN())
+                       nanb = math.Float64frombits(math.Float64bits(nana) ^ 2)
+               )
+
+               m := map[float64]string{
+                       pz:   "+0",
+                       nana: "NaN",
+                       nanb: "NaN",
+               }
+               if m[nz] != "+0" {
+                       panic(fmt.Sprintln("float64 map does not treat -0 and +0 as equal for read"))
+               }
+               m[nz] = "-0"
+               if m[pz] != "-0" {
+                       panic(fmt.Sprintln("float64 map does not treat -0 and +0 as equal for write"))
+               }
+               if _, ok := m[nana]; ok {
+                       panic(fmt.Sprintln("float64 map allows NaN lookup (a)"))
+               }
+               if _, ok := m[nanb]; ok {
+                       panic(fmt.Sprintln("float64 map allows NaN lookup (b)"))
+               }
+               if len(m) != 3 {
+                       panic(fmt.Sprintln("float64 map should have 3 entries:", m))
+               }
+               m[nana] = "NaN"
+               m[nanb] = "NaN"
+               if len(m) != 5 {
+                       panic(fmt.Sprintln("float64 map should have 5 entries:", m))
+               }
+       }
+
+       {
+               var (
+                       pz   = complex64(0)
+                       nz   = complex(0, math.Float32frombits(1<<31))
+                       nana = complex(5, float32(math.NaN()))
+                       nanb = complex(5, math.Float32frombits(math.Float32bits(float32(math.NaN()))^2))
+               )
+
+               m := map[complex64]string{
+                       pz:   "+0",
+                       nana: "NaN",
+                       nanb: "NaN",
+               }
+               if m[nz] != "+0" {
+                       panic(fmt.Sprintln("complex64 map does not treat -0 and +0 as equal for read"))
+               }
+               m[nz] = "-0"
+               if m[pz] != "-0" {
+                       panic(fmt.Sprintln("complex64 map does not treat -0 and +0 as equal for write"))
+               }
+               if _, ok := m[nana]; ok {
+                       panic(fmt.Sprintln("complex64 map allows NaN lookup (a)"))
+               }
+               if _, ok := m[nanb]; ok {
+                       panic(fmt.Sprintln("complex64 map allows NaN lookup (b)"))
+               }
+               if len(m) != 3 {
+                       panic(fmt.Sprintln("complex64 map should have 3 entries:", m))
+               }
+               m[nana] = "NaN"
+               m[nanb] = "NaN"
+               if len(m) != 5 {
+                       panic(fmt.Sprintln("complex64 map should have 5 entries:", m))
+               }
+       }
+
+       {
+               var (
+                       pz   = complex128(0)
+                       nz   = complex(0, math.Float64frombits(1<<63))
+                       nana = complex(5, float64(math.NaN()))
+                       nanb = complex(5, math.Float64frombits(math.Float64bits(float64(math.NaN()))^2))
+               )
+
+               m := map[complex128]string{
+                       pz:   "+0",
+                       nana: "NaN",
+                       nanb: "NaN",
+               }
+               if m[nz] != "+0" {
+                       panic(fmt.Sprintln("complex128 map does not treat -0 and +0 as equal for read"))
+               }
+               m[nz] = "-0"
+               if m[pz] != "-0" {
+                       panic(fmt.Sprintln("complex128 map does not treat -0 and +0 as equal for write"))
+               }
+               if _, ok := m[nana]; ok {
+                       panic(fmt.Sprintln("complex128 map allows NaN lookup (a)"))
+               }
+               if _, ok := m[nanb]; ok {
+                       panic(fmt.Sprintln("complex128 map allows NaN lookup (b)"))
+               }
+               if len(m) != 3 {
+                       panic(fmt.Sprintln("complex128 map should have 3 entries:", m))
+               }
+               m[nana] = "NaN"
+               m[nanb] = "NaN"
+               if len(m) != 5 {
+                       panic(fmt.Sprintln("complex128 map should have 5 entries:", m))
+               }
+       }
+}
+
+func testnan() {
+       n := 500
+       m := map[float64]int{}
+       nan := math.NaN()
+       for i := 0; i < n; i++ {
+               m[nan] = 1
+       }
+       if len(m) != n {
+               panic("wrong size map after nan insertion")
+       }
+       iters := 0
+       for k, v := range m {
+               iters++
+               if !math.IsNaN(k) {
+                       panic("not NaN")
+               }
+               if v != 1 {
+                       panic("wrong value")
+               }
+       }
+       if iters != n {
+               panic("wrong number of nan range iters")
+       }
 }