OpenCores
URL https://opencores.org/ocsvn/openrisc/openrisc/trunk

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [gnu-dev/] [or1k-gcc/] [gcc/] [testsuite/] [go.test/] [test/] [defer.go] - Blame information for rev 700

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 700 jeremybenn
// $G $F.go && $L $F.$A && ./$A.out
2
 
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.
6
 
7
package main
8
 
9
import "fmt"
10
 
11
var result string
12
 
13
func addInt(i int) { result += fmt.Sprint(i) }
14
 
15
func test1helper() {
16
        for i := 0; i < 10; i++ {
17
                defer addInt(i)
18
        }
19
}
20
 
21
func test1() {
22
        result = ""
23
        test1helper()
24
        if result != "9876543210" {
25
                fmt.Printf("test1: bad defer result (should be 9876543210): %q\n", result)
26
        }
27
}
28
 
29
func addDotDotDot(v ...interface{}) { result += fmt.Sprint(v...) }
30
 
31
func test2helper() {
32
        for i := 0; i < 10; i++ {
33
                defer addDotDotDot(i)
34
        }
35
}
36
 
37
func test2() {
38
        result = ""
39
        test2helper()
40
        if result != "9876543210" {
41
                fmt.Printf("test2: bad defer result (should be 9876543210): %q\n", result)
42
        }
43
}
44
 
45
func main() {
46
        test1()
47
        test2()
48
}

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.