~ubuntu-branches/ubuntu/vivid/golang/vivid

« back to all changes in this revision

Viewing changes to test/cmp.go

  • Committer: Package Import Robot
  • Author(s): James Page
  • Date: 2013-08-20 14:06:23 UTC
  • mfrom: (14.1.23 saucy-proposed)
  • Revision ID: package-import@ubuntu.com-20130820140623-b414jfxi3m0qkmrq
Tags: 2:1.1.2-2ubuntu1
* Merge from Debian unstable (LP: #1211749, #1202027). Remaining changes:
  - 016-armhf-elf-header.patch: Use correct ELF header for armhf binaries.
  - d/control,control.cross: Update Breaks/Replaces for Ubuntu
    versions to ensure smooth upgrades, regenerate control file.

Show diffs side-by-side

added added

removed removed

Lines of Context:
8
8
 
9
9
package main
10
10
 
11
 
import "unsafe"
 
11
import (
 
12
        "os"
 
13
        "unsafe"
 
14
)
12
15
 
13
16
var global bool
 
17
 
14
18
func use(b bool) { global = b }
15
19
 
16
20
func stringptr(s string) uintptr { return *(*uintptr)(unsafe.Pointer(&s)) }
38
42
        var c string = "hello"
39
43
        var d string = "hel" // try to get different pointer
40
44
        d = d + "lo"
41
 
        if stringptr(c) == stringptr(d) {
42
 
                panic("compiler too smart -- got same string")
 
45
 
 
46
        // exp/ssa/interp can't handle unsafe.Pointer.
 
47
        if os.Getenv("GOSSAINTERP") != "" {
 
48
                if stringptr(c) == stringptr(d) {
 
49
                        panic("compiler too smart -- got same string")
 
50
                }
43
51
        }
44
52
 
45
53
        var e = make(chan int)
283
291
                isfalse(ix != z)
284
292
                isfalse(iz != x)
285
293
        }
286
 
        
 
294
 
287
295
        // structs with _ fields
288
296
        {
289
297
                var x = struct {
296
304
                        x: 1, y: 2, z: 3,
297
305
                }
298
306
                var ix interface{} = x
299
 
                
 
307
 
300
308
                istrue(x == x)
301
309
                istrue(x == ix)
302
310
                istrue(ix == x)