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

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [gnu-dev/] [or1k-gcc/] [gcc/] [testsuite/] [go.go-torture/] [execute/] [switch-1.go] - Blame information for rev 698

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 698 jeremybenn
package main
2
 
3
func f1(i int) bool {
4
  switch j := i; j {
5
  case 3: fallthrough
6
  case 1: return true
7
  case 2: return false
8
  default: return false
9
  case 4: return true
10
  }
11
}
12
 
13
func f2(i int) int {
14
  switch {
15
    case i < 0: return -1
16
    case i > 0: return 1
17
    default: return 0
18
    case i != 0: return 1000
19
  }
20
  panic(0)
21
}
22
 
23
func f3(i int) int {
24
 lab:
25
  switch i {
26
    case 1: break
27
    case 2: return 2
28
    case 3, 4:
29
      switch i {
30
        case 3: break lab
31
        case 4: break
32
      }
33
      return 4
34
  }
35
  return 1
36
}
37
 
38
func main() {
39
  if !f1(1) {
40
    panic(1);
41
  }
42
  if f1(2) {
43
    panic(2);
44
  }
45
  if !f1(3) {
46
    panic(3);
47
  }
48
  if !f1(4) {
49
    panic(4);
50
  }
51
  if f1(5) {
52
    panic(5);
53
  }
54
 
55
  if f2(-100) != -1 {
56
    panic(6);
57
  }
58
  if f2(1000) != 1 {
59
    panic(7);
60
  }
61
  if f2(0) != 0 {
62
    panic(8);
63
  }
64
 
65
  if f3(1) != 1 || f3(2) != 2 || f3(3) != 1 || f3(4) != 4 {
66
    panic(9);
67
  }
68
}

powered by: WebSVN 2.1.0

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