1
0
mirror of https://github.com/golang/go synced 2024-11-21 20:34:40 -07:00

fix "declared and not used" in tests;

also template/template.go, missed last time.

R=r
DELTA=116  (61 added, 10 deleted, 45 changed)
OCL=34620
CL=34622
This commit is contained in:
Russ Cox 2009-09-14 21:03:53 -07:00
parent 59914723df
commit 1a3198907b
57 changed files with 128 additions and 77 deletions

View File

@ -397,12 +397,12 @@ func (t *Template) newVariable(name_formatter string) (v *variableElement) {
// Is it in user-supplied map? // Is it in user-supplied map?
if t.fmap != nil { if t.fmap != nil {
if fn, ok := t.fmap[formatter]; ok { if _, ok := t.fmap[formatter]; ok {
return return
} }
} }
// Is it in builtin map? // Is it in builtin map?
if fn, ok := builtins[formatter]; ok { if _, ok := builtins[formatter]; ok {
return return
} }
t.parseError("unknown formatter: %s", formatter); t.parseError("unknown formatter: %s", formatter);
@ -631,17 +631,17 @@ func (t *Template) writeVariable(v *variableElement, st *state) {
val := t.varValue(v.name, st).Interface(); val := t.varValue(v.name, st).Interface();
// is it in user-supplied map? // is it in user-supplied map?
if t.fmap != nil { if t.fmap != nil {
if fn, ok := t.fmap[v.formatter]; ok { if fn, ok := t.fmap[formatter]; ok {
fn(st.wr, val, v.formatter); fn(st.wr, val, formatter);
return; return;
} }
} }
// is it in builtin map? // is it in builtin map?
if fn, ok := builtins[v.formatter]; ok { if fn, ok := builtins[formatter]; ok {
fn(st.wr, val, v.formatter); fn(st.wr, val, formatter);
return; return;
} }
t.execError(st, v.linenum, "missing formatter %s for variable %s", v.formatter, v.name) t.execError(st, v.linenum, "missing formatter %s for variable %s", formatter, v.name)
} }
// Execute element i. Return next index to execute. // Execute element i. Return next index to execute.
@ -796,7 +796,7 @@ func validDelim(d []byte) bool {
if len(d) == 0 { if len(d) == 0 {
return false return false
} }
for i, c := range d { for _, c := range d {
if white(c) { if white(c) {
return false return false
} }

View File

@ -53,7 +53,6 @@ func main() {
} }
for i := 0; i < len(OUT); i++ { for i := 0; i < len(OUT); i++ {
t := min(xs);
for i := 0; i < n; i++ { for i := 0; i < n; i++ {
ins[i] <- x; ins[i] <- x;
} }

View File

@ -22,7 +22,6 @@ var a = []int{ 1, 2, 3 }
var NIL []int; var NIL []int;
func arraycmptest() { func arraycmptest() {
a1 := a;
if NIL != nil { if NIL != nil {
println("fail1:", NIL, "!= nil"); println("fail1:", NIL, "!= nil");
} }
@ -112,6 +111,7 @@ func interfacetest() {
i = e; i = e;
e1 := i.(E); e1 := i.(E);
// nothing to check; just verify it doesn't crash // nothing to check; just verify it doesn't crash
_ = e1;
} }
func main() { func main() {

View File

@ -26,6 +26,8 @@ func xxx() {
xx, ok = i.(int); xx, ok = i.(int);
a,b := multi(); a,b := multi();
_, _, _, _, _ = x, ok, xx, a, b;
} }
func f() map[int]int { func f() map[int]int {

View File

@ -46,7 +46,7 @@ func main() {
oai = []int{1,2,3}; oai = []int{1,2,3};
if len(oai) != 3 { panic("oai") } if len(oai) != 3 { panic("oai") }
at := [...]*T{&t, &t, &t}; at := [...]*T{&t, tp, &t};
if len(at) != 3 { panic("at") } if len(at) != 3 { panic("at") }
c := make(chan int); c := make(chan int);

View File

@ -30,8 +30,10 @@ func main() {
k := f1(); k := f1();
m, g, s := f3(); m, g, s := f3();
m, h, s := f3(); m, h, s := f3();
_, _, _, _, _, _, _, _, _ = i, f, s, j, k, m, g, s, h;
} }
if x() != "3" { if x() != "3" {
println("x() failed"); println("x() failed");
} }
_, _, _, _, _, _, _, _, _ = i, f, s, j, k, m, g, s, h;
} }

View File

@ -10,9 +10,9 @@ func main() {
i5 := 5; i5 := 5;
switch { // compiler crash fixable with 'switch true' switch { // compiler crash fixable with 'switch true'
case i5 < 5: dummy := 0; case i5 < 5: dummy := 0; _ = dummy;
case i5 == 5: dummy := 0; case i5 == 5: dummy := 0; _ = dummy;
case i5 > 5: dummy := 0; case i5 > 5: dummy := 0; _ = dummy;
} }
} }
/* /*

View File

@ -8,7 +8,7 @@ package main
func main() { func main() {
fired := false; fired := false; _ = fired;
} }
/* /*
bug9.go:5: defaultlit: unknown literal: LITERAL-B0 a(1) bug9.go:5: defaultlit: unknown literal: LITERAL-B0 a(1)

View File

@ -20,6 +20,7 @@ func main() {
t.x = 1; t.x = 1;
t.y = 2; t.y = 2;
r10 := t.m(1, 3.0); r10 := t.m(1, 3.0);
_ = r10;
} }
/* /*
bug11.go:16: fatal error: walktype: switch 1 unknown op CALLMETH l(16) <int32>INT32 bug11.go:16: fatal error: walktype: switch 1 unknown op CALLMETH l(16) <int32>INT32

View File

@ -10,6 +10,7 @@ package main
func main() { func main() {
var u30 uint64 = 0; var u30 uint64 = 0;
var u31 uint64 = 1; var u31 uint64 = 1;
_, _ = u30, u31;
var u32 uint64 = 18446744073709551615; var u32 uint64 = 18446744073709551615;
var u33 uint64 = +18446744073709551615; var u33 uint64 = +18446744073709551615;
if u32 != (1<<64)-1 { panic("u32\n"); } if u32 != (1<<64)-1 { panic("u32\n"); }

View File

@ -9,6 +9,7 @@ package main
func main() { func main() {
var cu0 uint16 = '\u1234'; var cu0 uint16 = '\u1234';
var cU1 uint32 = '\U00101234'; var cU1 uint32 = '\U00101234';
_, _ = cu0, cU1;
} }
/* /*
bug13.go:4: missing ' bug13.go:4: missing '

View File

@ -8,6 +8,7 @@ package main
func main() { func main() {
var s2 string = "\a\b\f\n\r\t\v"; // \r is miscompiled var s2 string = "\a\b\f\n\r\t\v"; // \r is miscompiled
_ = s2;
} }
/* /*
main.go.c: In function main_main: main.go.c: In function main_main:

View File

@ -22,6 +22,7 @@ func (i *TInt) TypeName() string {
func main() { func main() {
var t Type; var t Type;
t = nil; t = nil;
_ = t;
} }
/* /*

View File

@ -12,6 +12,7 @@ func main() {
i = '\\'; i = '\\';
var s string; var s string;
s = "\""; s = "\"";
_, _ = i, s;
} }
/* /*
bug.go:5: unknown escape sequence: ' bug.go:5: unknown escape sequence: '

View File

@ -23,6 +23,7 @@ prog := "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"+
"xxxxxxxx"+ "xxxxxxxx"+
"xxxxxxxxxxxxxxxxxxxxxxxxxxxxx" "xxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
; ;
_ = prog;
} }
/* Segmentation fault */ /* Segmentation fault */

View File

@ -8,4 +8,5 @@ package main
func main() { func main() {
var len int; // len should not be a keyword - this doesn't compile var len int; // len should not be a keyword - this doesn't compile
_ = len;
} }

View File

@ -17,5 +17,6 @@ func main() {
i = 0; i = 0;
type s2 int; type s2 int;
var k = func (a int) int { return a+1 }(3); var k = func (a int) int { return a+1 }(3);
_, _ = j, k;
ro: ro:
} }

View File

@ -16,6 +16,7 @@ func main() {
l1 := len(s); l1 := len(s);
var t T; var t T;
l2 := len(t.s); // BUG: cannot take len() of a string field l2 := len(t.s); // BUG: cannot take len() of a string field
_, _ = l1, l2;
} }
/* /*

View File

@ -9,6 +9,7 @@ package main
func main() { func main() {
var s string; var s string;
s = "0000000000000000000000000000000000000000000000000000000000"[0:7]; s = "0000000000000000000000000000000000000000000000000000000000"[0:7];
_ = s;
} }
/* /*

View File

@ -9,10 +9,12 @@ package main
func main(){ func main(){
c := make(chan int); c := make(chan int);
ok := false; ok := false;
i := 0; var i int;
i, ok = <-c; // works i, ok = <-c; // works
_, _ = i, ok;
ca := new([2]chan int); ca := new([2]chan int);
i, ok = <-(ca[0]); // fails: c.go:11: bad shape across assignment - cr=1 cl=2 i, ok = <-(ca[0]); // fails: c.go:11: bad shape across assignment - cr=1 cl=2
_, _ = i, ok;
} }

View File

@ -7,7 +7,7 @@
package main package main
func main() { func main() {
var i, j, k int; var i, k int;
outer: outer:
for k=0; k<2; k++ { for k=0; k<2; k++ {
print("outer loop top k ", k, "\n"); print("outer loop top k ", k, "\n");

View File

@ -19,4 +19,5 @@ type dch struct {
func dosplit(in *dch){ func dosplit(in *dch){
dat := <-in.dat; dat := <-in.dat;
_ = dat;
} }

View File

@ -13,4 +13,5 @@ func main() {
var x int; var x int;
var ok bool; var ok bool;
x, ok = t.m[0]; //bug075.go:11: bad shape across assignment - cr=1 cl=2 x, ok = t.m[0]; //bug075.go:11: bad shape across assignment - cr=1 cl=2
_, _ = x, ok;
} }

View File

@ -9,4 +9,5 @@ package main
func main() { func main() {
var exit int; var exit int;
exit: exit:
_ = exit;
} }

View File

@ -20,4 +20,5 @@ func main() {
c := make(chan string); c := make(chan string);
a := new(Service); a := new(Service);
go a.Serve(1234); go a.Serve(1234);
_ = c;
} }

View File

@ -10,6 +10,7 @@ const s string = "foo";
func main() { func main() {
i := len(s); // should be legal to take len() of a constant i := len(s); // should be legal to take len() of a constant
_ = i;
} }
/* /*

View File

@ -10,6 +10,7 @@ func main() {
a0 := P.V0(); // works a0 := P.V0(); // works
a1 := P.V1(); // works a1 := P.V1(); // works
a2, b2 := P.V2(); // doesn't work a2, b2 := P.V2(); // doesn't work
_, _, _, _ = a0, a1, a2, b2;
} }
/* /*

View File

@ -9,6 +9,7 @@ package main
func main() { func main() {
var a [1000] int64; // this alone works var a [1000] int64; // this alone works
var b [10000] int64; // this causes a runtime crash var b [10000] int64; // this causes a runtime crash
_, _ = a, b;
} }
/* /*

View File

@ -13,6 +13,7 @@ func f0() {
func f1() { func f1() {
x := 0; x := 0;
_ = x;
} }
@ -27,5 +28,5 @@ bug094.go:11: left side of := must be a name
bad top bad top
. LITERAL-I0 l(343) . LITERAL-I0 l(343)
bug094.go:11: fatal error: walktype: top=3 LITERAL bug094.go:11: fatal error: walktype: top=3 LITERAL
uetli:~/Source/go1/test/bugs gri$ uetli:~/Source/go1/test/bugs gri$
*/ */

View File

@ -11,6 +11,7 @@ type A []int;
func main() { func main() {
a := &A{0}; a := &A{0};
b := &A{0, 1}; b := &A{0, 1};
_, _ = a, b;
} }
/* /*

View File

@ -12,6 +12,7 @@ type M map[int] int;
func main() { func main() {
var a *A = &A{0}; var a *A = &A{0};
var m *M = &M{0 : 0}; // should be legal to use & here for consistency with other composite constructors (prev. line) var m *M = &M{0 : 0}; // should be legal to use & here for consistency with other composite constructors (prev. line)
_, _ = a, m;
} }
/* /*

View File

@ -7,5 +7,6 @@
package foo package foo
import "fmt" import "fmt"
func f() { func f() {
fmt := 1 fmt := 1;
_ = fmt;
} }

View File

@ -15,4 +15,5 @@ func main() {
t := new(T); t := new(T);
var i interface {}; var i interface {};
f, ok := i.(Foo); f, ok := i.(Foo);
_, _, _ = t, f, ok;
} }

View File

@ -29,7 +29,8 @@ func main() {
{ {
var x int; var x int;
var ok bool; var ok bool;
x, ok = f()["key"] x, ok = f()["key"];
_, _ = x, ok;
} }
} }

View File

@ -10,6 +10,7 @@ const c = 1;
func main() { func main() {
c := 0; c := 0;
_ = c;
} }
/* /*

View File

@ -9,7 +9,8 @@ package main
type t int type t int
func main() { func main() {
t := 0 t := 0;
_ = t;
} }
/* /*

View File

@ -17,6 +17,7 @@ func f0() string {
func f1() string { func f1() string {
const f = 3.141592; const f = 3.141592;
x := float64(float32(f)); // appears to change the precision of f x := float64(float32(f)); // appears to change the precision of f
_ = x;
return fmt.Sprintf("%v", float64(f)); return fmt.Sprintf("%v", float64(f));
} }

View File

@ -17,6 +17,7 @@ L:
L1: L1:
x := 1; x := 1;
_ = x;
for { for {
break L1; // ERROR "L1" break L1; // ERROR "L1"
continue L1; // ERROR "L1" continue L1; // ERROR "L1"

View File

@ -12,7 +12,6 @@ func main() {
// This bug doesn't arise with [...]int, or []interface{} or [3]interface{}. // This bug doesn't arise with [...]int, or []interface{} or [3]interface{}.
a := [...]interface{} { 1, 2, 3 }; a := [...]interface{} { 1, 2, 3 };
n := 1; n := 1;
bug := false;
for _, v := range a { for _, v := range a {
if v.(int) != n { if v.(int) != n {
println("BUG:", n, v.(int)); println("BUG:", n, v.(int));

View File

@ -6,11 +6,11 @@
package main package main
func f() { func f() {
v := [...]string{"a", "b"}; v := [...]string{"a", "b"};
_ = v;
} }
func main() { func main() {
f(); f();
} }

View File

@ -10,6 +10,7 @@ import "malloc"
func mk2() { func mk2() {
b := new([10000]byte); b := new([10000]byte);
_ = b;
// println(b, "stored at", &b); // println(b, "stored at", &b);
} }

View File

@ -9,5 +9,6 @@ package main
func main() { func main() {
for i := 0; i < 1000000; i++ { for i := 0; i < 1000000; i++ {
x := new([100]byte); x := new([100]byte);
_ = x;
} }
} }

View File

@ -171,6 +171,7 @@ func main() {
var x1 *Number = MakeNumber(1001); var x1 *Number = MakeNumber(1001);
var x2 *Number = MakeNumber(2002); var x2 *Number = MakeNumber(2002);
var x3 *Number = MakeNumber(3003); var x3 *Number = MakeNumber(3003);
_, _, _ = x1, x2, x3;
// this doesn't work I think... // this doesn't work I think...
//hmap.Lookup(x1, true); //hmap.Lookup(x1, true);

View File

@ -21,56 +21,57 @@ func main() {
count = 0; count = 0;
if true { if true {
count = count + 1; count = count + 1;
} }
assertequal(count, 1, "if true"); assertequal(count, 1, "if true");
count = 0; count = 0;
if false { if false {
count = count + 1; count = count + 1;
} }
assertequal(count, 0, "if false"); assertequal(count, 0, "if false");
count = 0; count = 0;
if one := 1; true { if one := 1; true {
count = count + one; count = count + one;
} }
assertequal(count, 1, "if true one"); assertequal(count, 1, "if true one");
count = 0; count = 0;
if one := 1; false { if one := 1; false {
count = count + 1; count = count + 1;
_ = one;
} }
assertequal(count, 0, "if false one"); assertequal(count, 0, "if false one");
count = 0; count = 0;
if { if {
count = count + 1; count = count + 1;
} }
assertequal(count, 1, "if empty"); assertequal(count, 1, "if empty");
count = 0; count = 0;
if one := 1; true { if one := 1; true {
count = count + one; count = count + one;
} }
assertequal(count, 1, "if empty one"); assertequal(count, 1, "if empty one");
count = 0; count = 0;
if i5 < i7 { if i5 < i7 {
count = count + 1; count = count + 1;
} }
assertequal(count, 1, "if cond"); assertequal(count, 1, "if cond");
count = 0; count = 0;
if true { if true {
count = count + 1; count = count + 1;
} else } else
count = count - 1; count = count - 1;
assertequal(count, 1, "if else true"); assertequal(count, 1, "if else true");
count = 0; count = 0;
if false { if false {
count = count + 1; count = count + 1;
} else } else
count = count - 1; count = count - 1;
assertequal(count, -1, "if else false"); assertequal(count, -1, "if else false");
@ -78,7 +79,9 @@ func main() {
count = 0; count = 0;
if t:=1; false { if t:=1; false {
count = count + 1; count = count + 1;
t := 7; _ = t;
t := 7;
_ = t;
} else } else
count = count - t; count = count - t;
assertequal(count, -1, "if else false var"); assertequal(count, -1, "if else false var");
@ -87,8 +90,10 @@ func main() {
t := 1; t := 1;
if false { if false {
count = count + 1; count = count + 1;
t := 7; t := 7;
_ = t;
} else } else
count = count - t; count = count - t;
_ = t;
assertequal(count, -1, "if else false var outside"); assertequal(count, -1, "if else false var outside");
} }

View File

@ -102,8 +102,7 @@ func main() {
hello(t.String()); hello(t.String());
// I2T2 false // I2T2 false
var u1 U; _, ok = s.(U);
u1, ok = s.(U);
false(ok); false(ok);
// I2I2 true // I2I2 true

View File

@ -18,6 +18,7 @@ func main() {
var e interface {}; var e interface {};
e = s; e = s;
i = e.(I); i = e.(I);
_ = i;
} }
// hide S down here to avoid static warning // hide S down here to avoid static warning

View File

@ -30,7 +30,6 @@ func AddInst(Inst) *Inst {
} }
func main() { func main() {
re := new(Regexp);
print("call addinst\n"); print("call addinst\n");
var x Inst = AddInst(new(Start)); // ERROR "illegal|incompatible|is not" var x Inst = AddInst(new(Start)); // ERROR "illegal|incompatible|is not"
print("return from addinst\n"); print("return from addinst\n");

View File

@ -27,17 +27,23 @@ func main() {
v = t; v = t;
p = t; // ERROR "is not|requires a pointer" p = t; // ERROR "is not|requires a pointer"
_, _= v, p;
v = &t; v = &t;
p = &t; p = &t;
_, _= v, p;
v = s; v = s;
p = s; // ERROR "is not|requires a pointer" p = s; // ERROR "is not|requires a pointer"
_, _= v, p;
v = &s; v = &s;
p = &s; p = &s;
_, _= v, p;
v = sp; v = sp;
p = sp; // no error! p = sp; // no error!
_, _= v, p;
v = &sp; v = &sp;
p = &sp; p = &sp;
_, _= v, p;
} }

View File

@ -149,7 +149,6 @@ func WhiteSpace(c int) bool
func NextToken() func NextToken()
{ {
var i, c int; var i, c int;
var backslash bool;
tokenbuf[0] = nilchar; // clear previous token tokenbuf[0] = nilchar; // clear previous token
c = Get(); c = Get();
@ -222,8 +221,7 @@ func ParseList() *Slist
func atom(i int) *Slist // BUG: uses tokenbuf; should take argument func atom(i int) *Slist // BUG: uses tokenbuf; should take argument
{ {
var h, length int; var slist *Slist;
var slist, tail *Slist;
slist = new(Slist); slist = new(Slist);
if token == '0' { if token == '0' {

View File

@ -21,56 +21,57 @@ func main() {
count = 0; count = 0;
if true { if true {
count = count + 1; count = count + 1;
} }
assertequal(count, 1, "if true"); assertequal(count, 1, "if true");
count = 0; count = 0;
if false { if false {
count = count + 1; count = count + 1;
} }
assertequal(count, 0, "if false"); assertequal(count, 0, "if false");
count = 0; count = 0;
if one := 1; true { if one := 1; true {
count = count + one; count = count + one;
} }
assertequal(count, 1, "if true one"); assertequal(count, 1, "if true one");
count = 0; count = 0;
if one := 1; false { if one := 1; false {
count = count + 1; _ = one;
count = count + 1;
} }
assertequal(count, 0, "if false one"); assertequal(count, 0, "if false one");
count = 0; count = 0;
if { if {
count = count + 1; count = count + 1;
} }
assertequal(count, 1, "if empty"); assertequal(count, 1, "if empty");
count = 0; count = 0;
if one := 1; { if one := 1; {
count = count + one; count = count + one;
} }
assertequal(count, 1, "if empty one"); assertequal(count, 1, "if empty one");
count = 0; count = 0;
if i5 < i7 { if i5 < i7 {
count = count + 1; count = count + 1;
} }
assertequal(count, 1, "if cond"); assertequal(count, 1, "if cond");
count = 0; count = 0;
if true { if true {
count = count + 1; count = count + 1;
} else } else
count = count - 1; count = count - 1;
assertequal(count, 1, "if else true"); assertequal(count, 1, "if else true");
count = 0; count = 0;
if false { if false {
count = count + 1; count = count + 1;
} else } else
count = count - 1; count = count - 1;
assertequal(count, -1, "if else false"); assertequal(count, -1, "if else false");
@ -78,7 +79,8 @@ func main() {
count = 0; count = 0;
if t:=1; false { if t:=1; false {
count = count + 1; count = count + 1;
t := 7; t := 7;
_ = t;
} else } else
count = count - t; count = count - t;
assertequal(count, -1, "if else false var"); assertequal(count, -1, "if else false var");
@ -87,7 +89,8 @@ func main() {
t := 1; t := 1;
if false { if false {
count = count + 1; count = count + 1;
t := 7; t := 7;
_ = t;
} else } else
count = count - t; count = count - t;
assertequal(count, -1, "if else false var outside"); assertequal(count, -1, "if else false var outside");

View File

@ -19,6 +19,7 @@ main()
var x int; var x int;
x = 25; x = 25;
y = 25; y = 25;
_ = x;
} }
x = x+y; x = x+y;
if(x != 40) { panic(x); } if(x != 40) { panic(x); }

View File

@ -108,6 +108,7 @@ func main() {
var u31 uint64 = 1; var u31 uint64 = 1;
var u32 uint64 = 18446744073709551615; var u32 uint64 = 18446744073709551615;
var u33 uint64 = +18446744073709551615; var u33 uint64 = +18446744073709551615;
_, _, _, _ = u30, u31, u32, u33;
// float // float
var f00 float = 3.14159; var f00 float = 3.14159;
@ -192,6 +193,7 @@ func main() {
assert(s1[4] == 0xc3, "s1-4"); assert(s1[4] == 0xc3, "s1-4");
assert(s1[5] == 0xb4, "s1-5"); assert(s1[5] == 0xb4, "s1-5");
var s2 string = "\a\b\f\n\r\t\v"; var s2 string = "\a\b\f\n\r\t\v";
_, _ = s0, s2;
var s00 string = "\000"; var s00 string = "\000";
var s01 string = "\007"; var s01 string = "\007";

View File

@ -33,7 +33,6 @@ func main() {
var ps *S1; var ps *S1;
var i I; var i I;
var pi *I1; var pi *I1;
var t T;
var pt *T1; var pt *T1;
if s.val() != 1 { panicln("s.val:", s.val()) } if s.val() != 1 { panicln("s.val:", s.val()) }

View File

@ -32,4 +32,6 @@ func main() {
i = nil; i = nil;
ta = make([]IN, 1); ta = make([]IN, 1);
ta[0] = nil; ta[0] = nil;
_, _, _, _, _, _, _, _ = i, f, s, m, c, t, in, ta;
} }

View File

@ -15,7 +15,6 @@ import (
func main() { func main() {
s := "\000\123\x00\xca\xFE\u0123\ubabe\U0000babe\U0010FFFFx"; s := "\000\123\x00\xca\xFE\u0123\ubabe\U0000babe\U0010FFFFx";
expect := []int{ 0, 0123, 0, 0xFFFD, 0xFFFD, 0x123, 0xbabe, 0xbabe, 0x10FFFF, 'x' }; expect := []int{ 0, 0123, 0, 0xFFFD, 0xFFFD, 0x123, 0xbabe, 0xbabe, 0x10FFFF, 'x' };
var rune, size int;
offset := 0; offset := 0;
var i, c int; var i, c int;
ok := true; ok := true;

View File

@ -73,37 +73,37 @@ func main() {
case 6: case 6:
case 7: case 7:
case 8: case 8:
case 9: case 9:
default: assert(i5 == 5, "good"); default: assert(i5 == 5, "good");
} }
switch i5 { switch i5 {
case 0: dummy := 0; fallthrough; case 0: dummy := 0; _ = dummy; fallthrough;
case 1: dummy := 0; fallthrough; case 1: dummy := 0; _ = dummy; fallthrough;
case 2: dummy := 0; fallthrough; case 2: dummy := 0; _ = dummy; fallthrough;
case 3: dummy := 0; fallthrough; case 3: dummy := 0; _ = dummy; fallthrough;
case 4: dummy := 0; assert(false, "4"); case 4: dummy := 0; _ = dummy; assert(false, "4");
case 5: dummy := 0; fallthrough; case 5: dummy := 0; _ = dummy; fallthrough;
case 6: dummy := 0; fallthrough; case 6: dummy := 0; _ = dummy; fallthrough;
case 7: dummy := 0; fallthrough; case 7: dummy := 0; _ = dummy; fallthrough;
case 8: dummy := 0; fallthrough; case 8: dummy := 0; _ = dummy; fallthrough;
case 9: dummy := 0; fallthrough; case 9: dummy := 0; _ = dummy; fallthrough;
default: dummy := 0; assert(i5 == 5, "good"); default: dummy := 0; _ = dummy; assert(i5 == 5, "good");
} }
fired := false; fired := false;
switch i5 { switch i5 {
case 0: dummy := 0; fallthrough; // tests scoping of cases case 0: dummy := 0; _ = dummy; fallthrough; // tests scoping of cases
case 1: dummy := 0; fallthrough; case 1: dummy := 0; _ = dummy; fallthrough;
case 2: dummy := 0; fallthrough; case 2: dummy := 0; _ = dummy; fallthrough;
case 3: dummy := 0; fallthrough; case 3: dummy := 0; _ = dummy; fallthrough;
case 4: dummy := 0; assert(false, "4"); case 4: dummy := 0; _ = dummy; assert(false, "4");
case 5: dummy := 0; fallthrough; case 5: dummy := 0; _ = dummy; fallthrough;
case 6: dummy := 0; fallthrough; case 6: dummy := 0; _ = dummy; fallthrough;
case 7: dummy := 0; fallthrough; case 7: dummy := 0; _ = dummy; fallthrough;
case 8: dummy := 0; fallthrough; case 8: dummy := 0; _ = dummy; fallthrough;
case 9: dummy := 0; fallthrough; case 9: dummy := 0; _ = dummy; fallthrough;
default: dummy := 0; fired = !fired; assert(i5 == 5, "good"); default: dummy := 0; _ = dummy; fired = !fired; assert(i5 == 5, "good");
} }
assert(fired, "fired"); assert(fired, "fired");

View File

@ -58,12 +58,14 @@ func control_structs() {
var p *Point = new(Point).Initialize(2, 3); var p *Point = new(Point).Initialize(2, 3);
i := p.Distance(); i := p.Distance();
var f float = 0.3; var f float = 0.3;
_ = f;
for {} for {}
for {}; for {};
for j := 0; j < i; j++ { for j := 0; j < i; j++ {
if i == 0 { if i == 0 {
} else i = 0; } else i = 0;
var x float; var x float;
_ = x;
} }
foo: // a label foo: // a label
var j int; var j int;