code
stringlengths
10
1.34M
language
stringclasses
1 value
// $G $D/$F.go && $L $F.$A && ./$A.out >tmp.go && // $G tmp.go && $L tmp.$A && ./$A.out || echo BUG: 64bit // rm -f tmp.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. // Generate test of 64-bit arithmeti...
Go
// $G $D/$F.go && $L $F.$A && ./$A.out // 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. package main import "fmt" func main() { n := bool + byte + float + float32 + float64 + int + int8 + ...
Go
// $G $D/$F.go && $L $F.$A && ./$A.out // 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. package main const ( // example from the spec n1 = +5; n2 = -5; d1 = +3; d2 = -3; q1 = +1; q2 = -1; q3 = -1; ...
Go
// $G $D/$F.go && $L $F.$A && ./$A.out // 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. package main func main() { var x,y int; x,y = simple(10,20,30); if x+y != 65 { panic(x+y); } } func simple(ia,ib,i...
Go
// $G $D/$F.go && $L $F.$A && ./$A.out // 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. package main const nilchar = 0; type Atom struct { str string; integer int; next *Slist; /* in hash bucket */ }...
Go
// $G $D/$F.go && $L $F.$A && ./$A.out // 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. package main import "rand" const Count = 1e5 func i64rand() int64 { for { a := int64(rand.Uint32()); a = (a<<32)...
Go
// $G $D/$F.go && $L $F.$A && ./$A.out // 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. package main var bx []byte var by []byte; var fx []float var fy []float; var lb,hb int var t int func main() { // wi...
Go
// $G $D/$F.go && $L $F.$A && ./$A.out // 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. package main func setpd(a []int) { // print("setpd a=", a, " len=", len(a), " cap=", cap(a), "\n"); for i:=0; i<len(a)...
Go
// $G $D/$F.go && $L $F.$A && ./$A.out // 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. package main var b[10] float32; func main() { var a[10] float32; for i:=int16(5); i<10; i=i+1 { a[i] = float32(i)...
Go
// $G $D/$F.go && $L $F.$A && ./$A.out // 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. package main var bx [10]byte var by []byte; var fx [10]float var fy []float; var lb,hb int var t int func main() { lb...
Go
// $G $D/$F.go && $L $F.$A && ./$A.out // 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. package main var x,y int; func main() { x = 15; y = 20; { var x int; x = 25; y = 25; _ = x; } x = x+y; ...
Go
// $G $D/$F.go && $L $F.$A && ./$A.out // 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. package main func main() { var t,i int; for i=0; i<100; i=i+1 { t = t+i; } if t != 50*99 { panic(t); } }
Go
// $G $D/$F.go && $L $F.$A && ./$A.out // 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. package main const size = 16; var a [size]byte; var p []byte; var m map[int]byte; func f(k int) byte { return byte(k...
Go
// $G $D/$F.go && $L $F.$A && ./$A.out // 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. package main var ians [18]int; var uans [18]uint; var pass string; func testi(i int, t1,t2,t3 int) { n := ((t1*3) + t...
Go
// $G $D/$F.go && $L $F.$A && ./$A.out // 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. package main func assertequal(is, shouldbe int, msg string) { if is != shouldbe { print("assertion fail" + msg + "\n...
Go
// $G $D/$F.go && $L $F.$A && ./$A.out // 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. package main import "rand" const Count = 1e5 func i64rand() int64 { for { a := int64(rand.Uint32()); a = (a<<32)...
Go
// $G $D/$F.go && $L $F.$A && ./$A.out // 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. package main func main() { print("hello world\n"); }
Go
// $G $D/$F.go && $L $F.$A && ./$A.out // 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. package main func main() { a := 3; for i:=0; i<10; i=i+1 { switch(i) { case 5: print("five"); case a,7: p...
Go
// $G $D/$F.go && $L $F.$A && ./$A.out // 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. package main type x2 struct { a,b,c int; d int; }; var g1 x2; var g2 struct { a,b,c int; d x2; }; func main() { var ...
Go
// $G $D/$F.go && $L $F.$A && ./$A.out // 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. package main func assertequal(is, shouldbe int, msg string) { if is != shouldbe { print("assertion fail" + msg + "\n...
Go
// $G $D/$F.go && $L $F.$A && ./$A.out // 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. package main type I interface { test1() int; test2() int; test3() int; test4() int; test5() int; test6() int; t...
Go
// $G $D/$F.go && $L $F.$A && ./$A.out // 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. package main import "runtime" const N = 1000; // sent messages const M = 10; // receiving goroutines const W = 2; /...
Go
// $G $D/$F.go && $L $F.$A && ./$A.out // 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. package main import "os" import "runtime" var randx int; func nrand(n int) int { randx += 10007; if randx >= 100000...
Go
// $G $D/$F.go && $L $F.$A && ./$A.out // 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. package main func main() { var x int; x = fun(10,20,30); if x != 60 { panic(x); } } func fun(ia,ib,ic int)int { ...
Go
// $G $D/$F.go && $L $F.$A && ./$A.out // 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. package main func main() { i := 0; if false { goto gogoloop; } if false { goto gogoloop; } if false { goto...
Go
// $G $D/$F.go && $L $F.$A && ./$A.out // 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. package main type s struct { a bool; b bool; } func main() { var a,b bool; a = true; b = false; if !a { panic(...
Go
// $G $D/$F.go && $L $F.$A && ./$A.out // 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. package main type Item interface { Print(); } type ListItem struct { item Item; next *ListItem; } type List ...
Go
// $G $D/$F.go && $L $F.$A && ./$A.out // 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. package main type x2 struct { a,b,c int; d int; }; var g1 x2; var g2 struct { a,b,c int; d x2; }; func main() { var ...
Go
// $G $D/$F.go && $L $F.$A && ./$A.out // 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. package main type M map[int]int type S struct{ a,b,c int }; type SS struct{ aa,bb,cc S }; type SA struct{ a,b,c [3]int ...
Go
// $G $D/$F.go && $L $F.$A && ./$A.out // 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. package main type S struct { a,b int; } type I1 interface { f ()int; } type I2 interface { g() int; f() int; } f...
Go
// $G $D/$F.go && $L $F.$A && ./$A.out // 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. package main func main() { x := func(a int)int { x := func(a int)int { x := func(a int)int { return a+5; ...
Go
// $G $D/$F.go && $L $F.$A && ./$A.out // 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. package main type myint int; type mystring string; type I0 interface {}; func f() { var ia, ib I0; var i myint; v...
Go
// $G $D/$F.go && $L $F.$A && ./$A.out // 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. package main type vlong int64; type short int16; func main() { s1 := vlong(0); for i:=short(0); i<10; i=i+1 { s1 =...
Go
// $G $D/$F.go && $L $F.$A && ./$A.out // 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. package main type C struct { a int; x func(p *C)int; } func (this *C) f()int { return this.a; } func main() { va...
Go
// $G $D/$F.go && $L $F.$A && ./$A.out // 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. package main func main() { var c string; a := `abc`; b := `xyz`; /* print a literal */ print(`abc`); /* print...
Go
// $G $D/$F.go && $L $F.$A && ./$A.out // 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. package main type Iputs interface { puts (s string); } // --------- type Print struct { whoami int; put Iputs; } ...
Go
// $G $D/$F.go && $L $F.$A && ./$A.out // 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. package main func assertequal(is, shouldbe int, msg string) { if is != shouldbe { print("assertion fail" + msg + "\n...
Go
// $G $F.go && $L $F.$A && ./$A.out // 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. package main var a,b,c,d,e,f,g,h,i int; func printit() { println(a,b,c,d,e,f,g,h,i); } func testit(permuteok bool) bool...
Go
// $G $D/$F.go && $L $F.$A && ./$A.out // 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. package main func main() { c := make(chan int, 10); if len(c) != 0 || cap(c) != 10 { panicln("chan len/cap ", len(c...
Go
// errchk $G -e $D/$F.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. package main type S struct { A, B, C, X, Y, Z int; } type T struct { S; } var x = 1 var a1 = S { 0, X: 1 }; // ERROR "mixture|und...
Go
// $G $D/$F.go && $L $F.$A && ./$A.out // 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. package main const ( ci8 = -1<<7; ci16 = -1<<15 + 100; ci32 = -1<<31 + 100000; ci64 = -1<<63 + 10000000001; cu8 ...
Go
// $G $D/$F.go && $L $F.$A && ./$A.out // 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. package main import "syscall" func main() { syscall.Syscall(syscall.SYS_KILL, uintptr(syscall.Getpid()), syscall.SIGC...
Go
// $G $D/$F.go && $L $F.$A && ./$A.out || echo BUG indirect // 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. package main var m0 map[string]int var m1 *map[string]int var m2 *map[string]int = &m0 var m3 map[...
Go
// errchk $G $D/$F.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. package main func out_escapes() (x int, p *int) { p = &x; // ERROR "address of out parameter" return; } func out_escapes_2() (x int, ...
Go
// $G $F.go && $L $F.$A && ./$A.out // 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. package main import "fmt" var result string func addInt(i int) { result += fmt.Sprint(i) } func test1helper() { for i...
Go
// $G $D/$F.go && $L $F.$A && ./$A.out // 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. package main import "fmt" const ( a = iota; b; c; d; e; ) var x = []int{1,2,3} func f(x int, len *byte) { *len...
Go
// $G $F.go && $L $F.$A && ./$A.out // 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. package main const ( c0 = 0; cm1 = -1; chuge = 1 << 100; chuge_1 = chuge - 1; c1 = chuge >> 100; c3div2 = 3/2; c1e3...
Go
// $G $F.go && $L $F.$A && ./$A.out // 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. package main func assert(cond bool, msg string) { if !cond { print("assertion fail: ", msg, "\n"); panic(1); } } co...
Go
// $G $D/$F.go && $L $F.$A && ./$A.out // 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. // Try to tickle stack splitting bugs by doing // go, defer, and closure calls at different stack depths. package main ...
Go
// $G $F.go && $L $F.$A && ./$A.out // 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. package main func pow10(pow int) float64 { if pow < 0 { return 1/pow10(-pow); } if pow > 0 { return pow10(pow-1)*10; } ...
Go
// errchk $G $F.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. // does not compile and should not compile package main func f1(a int) (int, float) { // BUG (not caught by compiler): multiple return va...
Go
// errchk $G -e $D/$F.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. package _ // ERROR "invalid package name _" func main() { _(); // ERROR "cannot use _ as value" x := _+1; // ERROR "cannot use _ as...
Go
// errchk $G $D/$F.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. package main var a = []int { "a" }; // ERROR "conver|incompatible|cannot" var b = int { 1 }; // ERROR "compos" func f() int func main...
Go
// $G $F.go && $L $F.$A && ./$A.out // 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. package main import ( "fmt"; "strconv"; ) const count = 100; func P(a []string) string { s := "{"; for i := 0; i < l...
Go
// $G $F.go && $L $F.$A && ./$A.out // 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. // Correct short declarations and redeclarations. package main func f1() int { return 1 } func f2() (float, int) { return...
Go
// $G $D/$F.go && $L $F.$A && ./$A.out // 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. // make a lot of goroutines, threaded together. // tear them down cleanly. package main import ( "os"; "strconv"; ) ...
Go
// $G $D/$F.go && $L $F.$A && ./$A.out // 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. // Verify that unbuffered channels act as pure fifos. package main import "os" const N = 10 func AsynchFifo() { ch ...
Go
// $G $D/$F.go && $L $F.$A && ./$A.out // 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. // Power series package // A power series is a channel, along which flow rational // coefficients. A denominator of zer...
Go
// $G $D/$F.go && $L $F.$A && ./$A.out // 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. // Verify channel operations that test for blocking // Use several sizes and types of operands package main import "ru...
Go
// $G $D/$F.go && $L $F.$A && ./$A.out // 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. // This version generates up to 100 and checks the results. // With a channel, of course. package main // Send the seq...
Go
// $G $D/$F.go && $L $F.$A && ./$A.out // 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. package main var counter uint var shift uint func GetValue() uint { counter++; return 1 << shift } func Send(a, b c...
Go
// errchk $G -e $D/$F.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. package main var ( cr <-chan int; cs chan<- int; c chan int; ) func main() { cr = c; // ok cs = c; // ok c = cr; // ERROR "...
Go
// $G $D/$F.go && $L $F.$A && ./$A.out // 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. // Power series package // A power series is a channel, along which flow rational // coefficients. A denominator of zer...
Go
// $G $F.go && $L $F.$A && ./$A.out // 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. package main func assertequal(is, shouldbe int, msg string) { if is != shouldbe { print("assertion fail", msg, "\n"); ...
Go
// $G $F.go && $L $F.$A && ./$A.out // 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. package main type T struct { i int; f float; s string; next *T } type R struct { num int } func itor(a int) *R { r := n...
Go
// $G $D/$F.go && $L $F.$A && ./$A.out // 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. // trivial malloc test package main import ( "flag"; "fmt"; "malloc"; ) var chatty = flag.Bool("v", false, "chatty...
Go
// $G $D/$F.go && $L $F.$A && ./$A.out || echo BUG wrong result // 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. package main func main() { var x int = 1; if x != 1 { panic("found ", x, ", expected 1\n"); ...
Go
// $G $D/$F.go && $L $F.$A && ! ./$A.out // 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. package main func main() { var b []int; var ib interface{} = b; var m = make(map[interface{}] int); m[ib] = 1; }
Go
// $G $F.go && $L $F.$A && ./$A.out // 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. package main import "os" const ( Bool = iota; Int; Float; String; Struct; Chan; Array; Map; Func; Last; ) type...
Go
// $G $F.go && $L $F.$A && ./$A.out // 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. package main func main() { print("hello, world\n"); }
Go
// $G $D/$F.go && $L $F.$A && ./$A.out // 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. package main import "fmt" type T int func (t T) String() string { return fmt.Sprintf("T%d", t); } const ( A T = 1<<...
Go
// errchk $G $D/$F.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. package main type T struct {a int} type P *T type P1 *T func (p P) val() int { return 1 } // ERROR "receiver" func (p *P1) val() int {...
Go
// $G $D/$F.go && $L $F.$A && ./$A.out // 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. // Test that basic operations on named types are valid // and preserve the type. package main type Array [10]byte typ...
Go
// $G $F.go && $L $F.$A && ./$A.out // 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. package main var a = []int { 1,2, } var b = [5]int { 1,2,3 } var c = []int { 1 } var d = [...]int { 1,2,3 } func main() {...
Go
// errchk $G $D/$F.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. package main var notmain func() func main() { var x = &main; // ERROR "address of|invalid" main = notmain; // ERROR "assign to|inval...
Go
// errchk $G $F.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. package main type t1 int; type t2 int; type t3 int; func f1(*t2, x t3); // ERROR "named" func f2(t1, *t2, x t3); // ERROR "named" func f3(...
Go
// $G $D/$F.go && $L $F.$A && ./$A.out // 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. // This used to crash because the scheduler // tried to kick off a new scheduling thread for f // when time.Nanoseconds ...
Go
// $G $F.go && $L $F.$A && ./$A.out // 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. package main type T struct { i int } type IN interface { } func main() { var i *int; var f *float; var s *string; v...
Go
// $G $F.go && $L $F.$A && ./$A.out arg1 arg2 // 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. package main import "os" func main() { if len(os.Args) != 3 { panic("argc") } if os.Args[1] != "arg1" { ...
Go
// $G $F.go && $L $F.$A && ./$A.out // 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. package main // ---------------------------------------------------------------------------- // Helper functions func ASS...
Go
// $G $D/$F.go && $L $F.$A && ./$A.out // 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. // Random malloc test. package main import ( "flag"; "malloc"; "rand"; "unsafe"; ) var chatty = flag.Bool("v", fa...
Go
// $G $D/$F.go && $L $F.$A && ./$A.out // 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. // Repeated malloc test. package main import ( "flag"; "malloc" ) var chatty = flag.Bool("v", false, "chatty"); va...
Go
// $G $F.go && $L $F.$A && ./$A.out // 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. package main type T chan uint64; func M(f uint64) (in, out T) { in = make(T, 100); out = make(T, 100); go func(in, out...
Go
// $G $F.go && $L $F.$A && ./$A.out // 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. package main import "os" func main() { i := 0; switch x := 5; { case i < x: os.Exit(0); case i == x: case i > ...
Go
// $G $D/$F.go && $L $F.$A && ./$A.out // 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. package main import "fmt" type T int func (t T) String() string { return fmt.Sprintf("T%d", t); } const ( A T = 1<<...
Go
// $G $F.go && $L $F.$A && ./$A.out // 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. package main var a,b,c,d,e,f,g,h,i int; func printit() { println(a,b,c,d,e,f,g,h,i); } func testit(permuteok bool) bool...
Go
// $G $D/$F.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. // check that when import gives multiple names // to a type, they're still all the same type package main import _os_ "os" import "os" import ...
Go
// errchk $G $D/$F.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. package main const ( A int = 1; B byte; // ERROR "type without expr|expected .=." )
Go
// $G $D/$F.go && $L $F.$A && ./$A.out // 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. package main type T struct { a float64; b int64; c string; d byte; } var a = []int{ 1, 2, 3 } var NIL []int; func...
Go
// $G $F.go && $L $F.$A && ./$A.out arg1 arg2 // 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. package main import "os" func main() { if len(os.Args) != 3 { panic("argc") } if os.Args[1] != "arg1" { ...
Go
// $G $F.go && $L $F.$A && ./$A.out // 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. package main func assert(cond bool, msg string) { if !cond { print("assertion fail: ", msg, "\n"); panic(1); } } fu...
Go
// $G $F.go && $L $F.$A && ./$A.out // 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. package main type T struct { i int } type IN interface { } func main() { var i *int; var f *float; var s *string; v...
Go
// $G $D/$F.go && $L $F.$A && ./$A.out || echo BUG: compos // 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. package main type T struct { int; } func f() *T { return &T{1} } func main() { x := f(); y :...
Go
// errchk $G -e $F.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. // Incorrect short declarations and redeclarations. package main func f1() int { return 1 } func f2() (float, int) { return 1, 2 } func...
Go
// $G $D/$F.go && $L $F.$A && ./$A.out // 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. // trivial malloc test package main import ( "flag"; "fmt"; "malloc"; ) var chatty = flag.Bool("v", false, "chatty...
Go
// $G $D/$F.go && $L $F.$A && ./$A.out // 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. // This used to crash because the scheduler // tried to kick off a new scheduling thread for f // when time.Nanoseconds ...
Go
// $G $D/$F.go && $L $F.$A && ! ./$A.out // 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. package main func use(bool) { } func main() { var a []int; var ia interface{} = a; use(ia == ia); }
Go
// errchk $G $F.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. // does not compile and should not compile package main func f1(a int) (int, float) { // BUG (not caught by compiler): multiple return va...
Go
// $G $D/$F.go && $L $F.$A && ./$A.out // 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. package main import "fmt" import "reflect" type S struct { A, B, C, X, Y, Z int; } type T struct { S; } var a1 = S...
Go
// $G $D/$F.go && $L $F.$A && ./$A.out // 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. package main import "fmt" func main() { n := bool + byte + float + float32 + float64 + int + int8 + ...
Go