Commit 6810f39e authored by Rob Pike's avatar Rob Pike

test update. also remove two duplicates

SVN=126336
parent c38391ad
......@@ -54,13 +54,11 @@ func (t *T) m10(a int, b float) int {
}
//BUG func f9(a int) (i int, f float) { // multiple returns not ready yet
// BUG funny return value
// var i float = 9;
// var f float = 9.0;
// return i, f;
// return
// }
func f9(a int) (i int, f float) {
i = 9;
f = 9.0;
return;
}
func main() {
......@@ -74,21 +72,15 @@ func main() {
assertequal(r5, 5, "5");
r6 := f6(1);
assertequal(r6, 6, "6");
var r7 int;
var s7 float;
//BUG r7, s7 = f7(1);
//BUG assertequal(r7, 7, "r7");
//BUG assertequal(int(s7), 7, "s7");
var r8 int;
var s8 float;
//BUG r8, s8 = f8(1);
//BUG assertequal(r8, 8, "r8");
//BUG assertequal(int(s8), 8, "s8");
var r9 int;
var s9 float;
//BUG r9, s9 = f9(1);
//BUG assertequal(r9, 9, "r9");
//BUG assertequal(int(s9), 9, "s9");
r7, s7 := f7(1);
assertequal(r7, 7, "r7");
assertequal(int(s7), 7, "s7");
r8, s8 := f8(1);
assertequal(r8, 8, "r8");
assertequal(int(s8), 8, "s8");
r9, s9 := f9(1);
assertequal(r9, 9, "r9");
assertequal(int(s9), 9, "s9");
var t *T = new(T);
t.x = 1;
t.y = 2;
......
......@@ -4,13 +4,15 @@
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
// does not compile and should not compile
package main
func f1(a int) (int, float) { // BUG multiple return values must have names
func f1(a int) (int, float) { // BUG (not caught by compiler): multiple return values must have names
return 7, 7.0;
}
func f2(a int) (a int, b float) { // BUG return value names must be different from parameter names
func f2(a int) (a int, b float) { // return value names must be different from parameter names
return 8, 8.0;
}
......@@ -49,6 +49,8 @@ BUG: known to fail incorrectly
=========== ./turing.go
Hello World!
=========== ./utf.go
=========== ken/for.go
=========== ken/interfun.go
......@@ -80,10 +82,6 @@ Hello World!
=========== ken/robiota.go
=========== ken/robliteral.go
=========== ken/robswitch.go
=========== ken/simparray.go
=========== ken/simpbool.go
......
// Copyright 2009 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
// $G $D/$F.go && $L $F.$A && ./$A.out
package main
var code int;
func assert(cond bool, msg string) {
if !cond {
print "assertion fail: " + msg + "\n";
code = 1;
//panic 1; this file has errors; print them all
}
}
func main() {
code = 0;
// bool
var t bool = true;
var f bool = false;
assert(t == !f, "bool");
// int8
var i00 int8 = 0;
var i01 int8 = 1;
var i02 int8 = -1;
var i03 int8 = 127;
var i04 int8 = -127;
var i05 int8 = -128;
var i06 int8 = +127;
assert(i01 == i00 + 1, "i01");
assert(i02 == -i01, "i02");
assert(i03 == -i04, "i03");
assert(-(i05+1) == i06, "i05");
// int16
var i10 int16 = 0;
var i11 int16 = 1;
var i12 int16 = -1;
var i13 int16 = 32767;
var i14 int16 = -32767;
var i15 int16 = -32768;
var i16 int16 = +32767;
assert(i11 == i10 + 1, "i11");
assert(i12 == -i11, "i12");
assert(i13 == -i14, "i13");
assert(-(i15+1) == i16, "i15");
// int32
var i20 int32 = 0;
var i21 int32 = 1;
var i22 int32 = -1;
var i23 int32 = 2147483647;
var i24 int32 = -2147483647;
var i25 int32 = -2147483648;
var i26 int32 = +2147483647;
assert(i21 == i20 + 1, "i21");
assert(i22 == -i21, "i22");
assert(i23 == -i24, "i23");
assert(-(i25+1) == i26, "i25");
assert(i23 == (1 << 31) - 1, "i23 size");
// int64
var i30 int64 = 0;
var i31 int64 = 1;
var i32 int64 = -1;
var i33 int64 = 9223372036854775807; // BUG? not sure these really work
var i34 int64 = -9223372036854775807;
var i35 int64 = -9223372036854775808;
var i36 int64 = +9223372036854775807;
assert(i31 == i30 + 1, "i31");
assert(i32 == -i31, "i32");
assert(i33 == -i34, "i33");
assert(-(i35+1) == i36, "i35");
assert(i33 == (1<<63) - 1, "i33 size");
// uint8
var u00 uint8 = 0;
var u01 uint8 = 1;
var u02 uint8 = 255;
var u03 uint8 = +255;
assert(u01 == u00 + 1, "u01");
assert(u02 == u03, "u02");
assert(u03 == (1<<8) - 1, "u03 size");
// uint16
var u10 uint16 = 0;
var u11 uint16 = 1;
var u12 uint16 = 65535;
var u13 uint16 = +65535;
assert(u11 == u10 + 1, "u11");
assert(u12 == u13, "u12");
// uint32
var u20 uint32 = 0;
var u21 uint32 = 1;
var u22 uint32 = 4294967295;
var u23 uint32 = +4294967295;
assert(u21 == u20 + 1, "u21");
assert(u22 == u23, "u22");
// uint64
var u30 uint64 = 0;
var u31 uint64 = 1;
var u32 uint64 = 18446744073709551615;
var u33 uint64 = +18446744073709551615;
// float
var f00 float = 3.14159;
var f01 float = -3.14159;
var f02 float = +3.14159;
var f03 float = 0.0;
var f04 float = .0;
var f05 float = 0.;
var f06 float = -0.0;
var f07 float = 1e10;
var f08 float = -1e10;
var f09 float = 1e-10;
var f10 float = 1e+10;
var f11 float = 1.e-10;
var f12 float = 1.e+10;
var f13 float = .1e-10;
var f14 float = .1e+10;
var f15 float = 1.1e-10;
var f16 float = 1.1e+10;
assert(f01 == -f00, "f01");
assert(f02 == -f01, "f02");
assert(f03 == f04, "f03");
assert(f04 == f05, "f04");
assert(f05 == f06, "f05");
assert(f07 == -f08, "f07");
assert(f09 == 1/f10, "f09");
assert(f11 == f09, "f11");
assert(f12 == f10, "f12");
assert(f13 == f09/10.0, "f13");
assert(f14 == f12/10.0, "f14");
assert(f15 == f16/1e20, "f15");
// character
var c0 uint8 = 'a';
var c1 uint8 = 'ä';
var c2 uint8 = '\a';
var c3 uint8 = '\b';
var c4 uint8 = '\f';
var c5 uint8 = '\n';
var c6 uint8 = '\r';
var c7 uint8 = '\t';
var c8 uint8 = '\v';
// var c9 uint8 = '本'; // correctly caught as error
var c9 uint16 = '本';
assert(c0 == 0x61, "c0");
assert(c1 == 0xe4, "c1");
assert(c2 == 0x07, "c2");
assert(c3 == 0x08, "c3");
assert(c4 == 0x0c, "c4");
assert(c5 == 0x0a, "c4");
assert(c6 == 0x0d, "c6");
assert(c7 == 0x09, "c7");
assert(c8 == 0x0b, "c8");
assert(c9 == 0x672c, "c9");
var c00 uint8 = '\000';
var c01 uint8 = '\007';
var c02 uint8 = '\177';
var c03 uint8 = '\377';
assert(c00 == 0, "c00");
assert(c01 == 7, "c01");
assert(c02 == 127, "c02");
assert(c03 == 255, "c03");
var cx0 uint8 = '\x00';
var cx1 uint8 = '\x0f';
var cx2 uint8 = '\xff';
assert(cx0 == 0, "cx0");
assert(cx1 == 15, "cx1");
assert(cx2 == 255, "cx2");
var cu0 uint16 = '\u1234';
var cu1 uint32 = '\U00101234';
assert(cu0 == 0x1234, "cu0");
assert(cu1 == 0x101234, "cu1");
// string
var s0 string = "";
var s1 string = "hellô";
assert(s1[0] == 'h', "s1-0");
assert(s1[4] == 0xc3, "s1-4");
assert(s1[5] == 0xb4, "s1-5");
var s2 string = "\a\b\f\n\r\t\v";
var s00 string = "\000";
var s01 string = "\007";
var s02 string = "\377";
assert(s00[0] == 0, "s00");
assert(s01[0] == 7, "s01");
assert(s02[0] == 255, "s02");
var x00 string = "\x00";
var x01 string = "\x0f";
var x02 string = "\xff";
assert(x00[0] == 0, "x00");
assert(x01[0] == 15, "x01");
assert(x02[0] == 255, "x02");
// these are all the same string
var sj0 string = "日本語";
var sj1 string = "\u65e5\u672c\u8a9e";
var sj2 string = "\U000065e5\U0000672c\U00008a9e";
var sj3 string = "\xe6\x97\xa5\xe6\x9c\xac\xe8\xaa\x9e";
assert(sj0 == sj1, "sj1");
assert(sj0 == sj2, "sj2");
assert(sj0 == sj3, "sj3");
sys.exit(code);
}
// Copyright 2009 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
// $G $D/$F.go && $L $F.$A && ./$A.out
package main
func assert(cond bool, msg string) {
if !cond {
print "assertion fail: " + msg + "\n";
panic 1;
}
}
func main() {
i5 := 5;
i7 := 7;
switch true {
case i5 < 5: assert(false, "<");
case i5 == 5: assert(true, "!");
case i5 > 5: assert(false, ">");
}
switch {
case i5 < 5: assert(false, "<");
case i5 == 5: assert(true, "!");
case i5 > 5: assert(false, ">");
}
switch x := 5; true {
case i5 < x: assert(false, "<");
case i5 == x: assert(true, "!");
case i5 > x: assert(false, ">");
}
switch x := 5; {
case i5 < x: assert(false, "<");
case i5 == x: assert(true, "!");
case i5 > x: assert(false, ">");
}
switch i5 {
case 0: assert(false, "0");
case 1: assert(false, "1");
case 2: assert(false, "2");
case 3: assert(false, "3");
case 4: assert(false, "4");
case 5: assert(true, "5");
case 6: assert(false, "6");
case 7: assert(false, "7");
case 8: assert(false, "8");
case 9: assert(false, "9");
default: assert(false, "default");
}
switch i5 {
case 0,1,2,3,4: assert(false, "4");
case 5: assert(true, "5");
case 6,7,8,9: assert(false, "9");
default: assert(false, "default");
}
switch i5 {
case 0:
case 1:
case 2:
case 3:
case 4: assert(false, "4");
case 5: assert(true, "5");
case 6:
case 7:
case 8:
case 9:
default: assert(i5 == 5, "good");
}
switch i5 {
case 0: dummy := 0; fallthrough;
case 1: dummy := 0; fallthrough;
case 2: dummy := 0; fallthrough;
case 3: dummy := 0; fallthrough;
case 4: dummy := 0; assert(false, "4");
case 5: dummy := 0; fallthrough;
case 6: dummy := 0; fallthrough;
case 7: dummy := 0; fallthrough;
case 8: dummy := 0; fallthrough;
case 9: dummy := 0; fallthrough;
default: dummy := 0; assert(i5 == 5, "good");
}
fired := 0; // BUG: should be able to use 'false'
switch i5 {
case 0: dummy := 0; fallthrough; // tests scoping of cases
case 1: dummy := 0; fallthrough;
case 2: dummy := 0; fallthrough;
case 3: dummy := 0; fallthrough;
case 4: dummy := 0; assert(false, "4");
case 5: dummy := 0; fallthrough;
case 6: dummy := 0; fallthrough;
case 7: dummy := 0; fallthrough;
case 8: dummy := 0; fallthrough;
case 9: dummy := 0; fallthrough;
default: dummy := 0; fired = fired + 1; assert(i5 == 5, "good");
}
assert(fired > 0, "fired");
count := 0;
switch i5 {
case 0: count = count + 1; fallthrough;
case 1: count = count + 1; fallthrough;
case 2: count = count + 1; fallthrough;
case 3: count = count + 1; fallthrough;
case 4: count = count + 1; assert(false, "4");
case 5: count = count + 1; fallthrough;
case 6: count = count + 1; fallthrough;
case 7: count = count + 1; fallthrough;
case 8: count = count + 1; fallthrough;
case 9: count = count + 1; fallthrough;
default: assert(i5 == count, "good");
}
assert(fired > 0, "fired");
fired = 0;
switch i := i5 + 2; i {
case i7: fired = 1;
default: assert(false, "fail");
}
assert(fired == 1, "var");
}
......@@ -63,7 +63,7 @@ func main() {
var i30 int64 = 0;
var i31 int64 = 1;
var i32 int64 = -1;
var i33 int64 = 9223372036854775807; // BUG? not sure these really work
var i33 int64 = 9223372036854775807;
var i34 int64 = -9223372036854775807;
var i35 int64 = -9223372036854775808;
var i36 int64 = +9223372036854775807;
......@@ -207,4 +207,7 @@ func main() {
var sj1 string = "\u65e5\u672c\u8a9e";
var sj2 string = "\U000065e5\U0000672c\U00008a9e";
var sj3 string = "\xe6\x97\xa5\xe6\x9c\xac\xe8\xaa\x9e";
assert(sj0 == sj1, "sj1");
assert(sj0 == sj2, "sj2");
assert(sj0 == sj3, "sj3");
}
......@@ -91,7 +91,7 @@ func main() {
default: dummy := 0; assert(i5 == 5, "good");
}
fired := 0; // BUG: should be able to use 'false'
fired := false;
switch i5 {
case 0: dummy := 0; fallthrough; // tests scoping of cases
case 1: dummy := 0; fallthrough;
......@@ -103,9 +103,9 @@ func main() {
case 7: dummy := 0; fallthrough;
case 8: dummy := 0; fallthrough;
case 9: dummy := 0; fallthrough;
default: dummy := 0; fired = fired + 1; assert(i5 == 5, "good");
default: dummy := 0; fired = !fired; assert(i5 == 5, "good");
}
assert(fired > 0, "fired");
assert(fired, "fired");
count := 0;
switch i5 {
......@@ -121,7 +121,7 @@ func main() {
case 9: count = count + 1; fallthrough;
default: assert(i5 == count, "good");
}
assert(fired > 0, "fired");
assert(fired, "fired");
switch hello {
case "wowie": assert(false, "wowie");
......@@ -130,10 +130,10 @@ func main() {
default: assert(false, "default");
}
fired = 0;
fired = false;
switch i := i5 + 2; i {
case i7: fired = 1;
case i7: fired = true;
default: assert(false, "fail");
}
assert(fired == 1, "var");
assert(fired, "var");
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment