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

« back to all changes in this revision

Viewing changes to test/fixedbugs/bug473.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:
 
1
// run
 
2
 
 
3
// Copyright 2013 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.
 
6
 
 
7
// Used to be miscompiled by gccgo, due to a bug in handling
 
8
// initialization ordering.
 
9
 
 
10
package main
 
11
 
 
12
func F(a ...interface{}) interface{} {
 
13
        s := 0
 
14
        for _, v := range a {
 
15
                s += v.(int)
 
16
        }
 
17
        return s
 
18
}
 
19
 
 
20
var V1 = F(V10, V4, V3, V11)
 
21
 
 
22
var V2 = F(V1)
 
23
 
 
24
var V3 = F(1)
 
25
 
 
26
var V4 = F(2)
 
27
 
 
28
var V5 = F(3)
 
29
 
 
30
var V6 = F(4)
 
31
 
 
32
var V7 = F(5)
 
33
 
 
34
var V8 = F(V14, V7, V3, V6, V5)
 
35
 
 
36
var V9 = F(V4, F(V12))
 
37
 
 
38
var V10 = F(V4, V9)
 
39
 
 
40
var V11 = F(6)
 
41
 
 
42
var V12 = F(V5, V3, V8)
 
43
 
 
44
var V13 = F(7)
 
45
 
 
46
var V14 = F(8)
 
47
 
 
48
func expect(name string, a interface{}, b int) {
 
49
        if a.(int) != b {
 
50
                panic(name)
 
51
        }
 
52
}
 
53
 
 
54
func main() {
 
55
        expect("V1", V1, 38)
 
56
        expect("V2", V2, 38)
 
57
        expect("V3", V3, 1)
 
58
        expect("V4", V4, 2)
 
59
        expect("V5", V5, 3)
 
60
        expect("V6", V6, 4)
 
61
        expect("V7", V7, 5)
 
62
        expect("V8", V8, 21)
 
63
        expect("V9", V9, 27)
 
64
        expect("V10", V10, 29)
 
65
        expect("V11", V11, 6)
 
66
        expect("V12", V12, 25)
 
67
        expect("V13", V13, 7)
 
68
        expect("V14", V14, 8)
 
69
}