3 // Copyright 2009 The Go Authors. All rights reserved.
4 // Use of this source code is governed by a BSD-style
5 // license that can be found in the LICENSE file.
7 // Test the internal "algorithms" for objects larger than a word: hashing, equality etc.
18 var a
= []int{1, 2, 3}
23 println("fail1:", NIL
, "!= nil")
27 println("fail2: nil !=", NIL
)
30 if a
== nil ||
nil == a
{
31 println("fail3:", a
, "== nil")
36 func SameArray(a
, b
[]int) bool {
37 if len(a
) != len(b
) ||
cap(a
) != cap(b
) {
40 if len(a
) > 0 && &a
[0] != &b
[0] {
46 var t
= T
{1.5, 123, "hello", 255}
47 var mt
= make(map[int]T
)
48 var ma
= make(map[int][]int)
53 if t1
.a
!= t
.a || t1
.b
!= t
.b || t1
.c
!= t
.c || t1
.d
!= t
.d
{
54 println("fail: map val struct", t1
.a
, t1
.b
, t1
.c
, t1
.d
)
60 if !SameArray(a
, a1
) {
61 println("fail: map val array", a
, a1
)
67 var ca
= make(chan []int)
78 if t1
.a
!= t
.a || t1
.b
!= t
.b || t1
.c
!= t
.c || t1
.d
!= t
.d
{
79 println("fail: map val struct", t1
.a
, t1
.b
, t1
.c
, t1
.d
)
84 if !SameArray(a
, a1
) {
85 println("fail: map val array", a
, a1
)
94 func interfacetest() {
99 if !SameArray(a
, a1
) {
100 println("interface <-> []int", a
, a1
)
107 if !SameArray(a
, a1
) {
108 println("interface <-> *[]int", a
, a1
)
114 if t1
.a
!= t
.a || t1
.b
!= t
.b || t1
.c
!= t
.c || t1
.d
!= t
.d
{
115 println("interface <-> struct", t1
.a
, t1
.b
, t1
.c
, t1
.d
)
121 // nothing to check; just verify it doesn't crash