Commit f2030938 authored by Ian Lance Taylor's avatar Ian Lance Taylor

test: change several tests to not print

This will make these tests more meaningful for gccgo, which
runs tests in parallel and has no equivalent to golden.out.

Remove ken/simpprint.go since it duplicates helloworld.go.

R=golang-dev, r
CC=golang-dev
https://golang.org/cl/5536058
parent 39bb4bd4
......@@ -6,6 +6,8 @@
package main
import "fmt"
type Element interface {
}
......@@ -43,7 +45,7 @@ func main() {
i4 := new(I)
i4.val = 44444
v := New()
print("hi\n")
r := "hi\n"
v.Insert(i4)
v.Insert(i3)
v.Insert(i2)
......@@ -52,10 +54,25 @@ func main() {
for i := 0; i < v.nelem; i++ {
var x *I
x = v.At(i).(*I)
print(i, " ", x.val, "\n") // prints correct list
r += fmt.Sprintln(i, x.val) // prints correct list
}
for i := 0; i < v.nelem; i++ {
print(i, " ", v.At(i).(*I).val, "\n")
r += fmt.Sprintln(i, v.At(i).(*I).val)
}
expect := `hi
0 44444
1 3333
2 222
3 11
4 0
0 44444
1 3333
2 222
3 11
4 0
`
if r != expect {
panic(r)
}
}
......
......@@ -6,11 +6,14 @@
package main
import "fmt"
func main() {
var i, k int
var r string
outer:
for k = 0; k < 2; k++ {
print("outer loop top k ", k, "\n")
r += fmt.Sprintln("outer loop top k", k)
if k != 0 {
panic("k not zero")
} // inner loop breaks this one every time
......@@ -18,12 +21,20 @@ outer:
if i != 0 {
panic("i not zero")
} // loop breaks every time
print("inner loop top i ", i, "\n")
r += fmt.Sprintln("inner loop top i", i)
if true {
print("do break\n")
r += "do break\n"
break outer
}
}
}
print("broke\n")
r += "broke\n"
expect := `outer loop top k 0
inner loop top i 0
do break
broke
`
if r != expect {
panic(r)
}
}
......@@ -11,18 +11,6 @@ printing: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
=========== ./helloworld.go
hello, world
=========== ./peano.go
0! = 1
1! = 1
2! = 2
3! = 6
4! = 24
5! = 120
6! = 720
7! = 5040
8! = 40320
9! = 362880
=========== ./printbig.go
-9223372036854775808
9223372036854775807
......@@ -30,9 +18,6 @@ hello, world
=========== ./sigchld.go
survived SIGCHLD
=========== ./turing.go
Hello World!
== ken/
=========== ken/cplx0.go
......@@ -45,14 +30,6 @@ Hello World!
(+1.292308e+000-1.384615e-001i)
(+1.292308e+000-1.384615e-001i)
=========== ken/cplx4.go
c = (-5.000000-6.000000i)
c = (5.000000+6.000000i)
c = (5.000000+6.000000i)
c = (5.000000+6.000000i)
c = (5+6i)
c = (13+7i)
=========== ken/cplx5.go
(+5.000000e+000-5.000000e+000i)
(+5.000000e+000-5.000000e+000i)
......@@ -65,21 +42,6 @@ c = (13+7i)
=========== ken/intervar.go
print 1 bio 2 file 3 -- abc
=========== ken/label.go
100
=========== ken/rob1.go
9876543210
=========== ken/rob2.go
(defn foo (add 12 34))
=========== ken/simpprint.go
hello world
=========== ken/simpswitch.go
0out01out12out2aout34out4fiveout56out6aout78out89out9
=========== ken/string.go
abcxyz-abcxyz-abcxyz-abcxyz-abcxyz-abcxyz-abcxyz
......@@ -93,28 +55,9 @@ abcxyz-abcxyz-abcxyz-abcxyz-abcxyz-abcxyz-abcxyz
== fixedbugs/
=========== fixedbugs/bug027.go
hi
0 44444
1 3333
2 222
3 11
4 0
0 44444
1 3333
2 222
3 11
4 0
=========== fixedbugs/bug067.go
ok
=========== fixedbugs/bug070.go
outer loop top k 0
inner loop top i 0
do break
broke
=========== fixedbugs/bug328.go
0x0
......
......@@ -15,30 +15,44 @@ const (
C1 = R + I // ADD(5,6)
)
func doprint(c complex128) { fmt.Printf("c = %f\n", c) }
func want(s, w string) {
if s != w {
panic(s + " != " + w)
}
}
func doprint(c complex128, w string) {
s := fmt.Sprintf("%f", c)
want(s, w)
}
func main() {
// constants
fmt.Printf("c = %f\n", -C1)
doprint(C1)
s := fmt.Sprintf("%f", -C1)
want(s, "(-5.000000-6.000000i)")
doprint(C1, "(5.000000+6.000000i)")
// variables
c1 := C1
fmt.Printf("c = %f\n", c1)
doprint(c1)
s = fmt.Sprintf("%f", c1)
want(s, "(5.000000+6.000000i)")
doprint(c1, "(5.000000+6.000000i)")
// 128
c2 := complex128(C1)
fmt.Printf("c = %G\n", c2)
s = fmt.Sprintf("%G", c2)
want(s, "(5+6i)")
// real, imag, complex
c3 := complex(real(c2)+3, imag(c2)-5) + c2
fmt.Printf("c = %G\n", c3)
s = fmt.Sprintf("%G", c3)
want(s, "(13+7i)")
// compiler used to crash on nested divide
c4 := complex(real(c3/2), imag(c3/2))
if c4 != c3/2 {
fmt.Printf("BUG: c3 = %G != c4 = %G\n", c3, c4)
panic(0)
}
}
......@@ -25,8 +25,6 @@ loop:
if i < 100 {
goto loop
}
print(i)
print("\n")
return
gogoloop:
......
......@@ -7,7 +7,7 @@
package main
type Item interface {
Print()
Print() string
}
type ListItem struct {
......@@ -30,12 +30,14 @@ func (list *List) Insert(i Item) {
list.head = item
}
func (list *List) Print() {
func (list *List) Print() string {
r := ""
i := list.head
for i != nil {
i.item.Print()
r += i.item.Print()
i = i.next
}
return r
}
// Something to put in a list
......@@ -48,8 +50,8 @@ func (this *Integer) Init(i int) *Integer {
return this
}
func (this *Integer) Print() {
print(this.val)
func (this *Integer) Print() string {
return string(this.val + '0')
}
func main() {
......@@ -61,6 +63,8 @@ func main() {
list.Insert(integer)
}
list.Print()
print("\n")
r := list.Print()
if r != "9876543210" {
panic(r)
}
}
......@@ -6,6 +6,8 @@
package main
import "fmt"
const nilchar = 0
type Atom struct {
......@@ -80,40 +82,44 @@ func main() {
if list == nil {
break
}
list.Print()
r := list.Print()
list.Free()
if r != "(defn foo (add 12 34))" {
panic(r)
}
break
}
}
func (slist *Slist) PrintOne(doparen bool) {
func (slist *Slist) PrintOne(doparen bool) string {
if slist == nil {
return
return ""
}
var r string
if slist.isatom {
if slist.isstring {
print(slist.String())
r = slist.String()
} else {
print(slist.Integer())
r = fmt.Sprintf("%v", slist.Integer())
}
} else {
if doparen {
print("(")
r += "("
}
slist.Car().PrintOne(true)
r += slist.Car().PrintOne(true)
if slist.Cdr() != nil {
print(" ")
slist.Cdr().PrintOne(false)
r += " "
r += slist.Cdr().PrintOne(false)
}
if doparen {
print(")")
r += ")"
}
}
return r
}
func (slist *Slist) Print() {
slist.PrintOne(true)
print("\n")
func (slist *Slist) Print() string {
return slist.PrintOne(true)
}
func Get() int {
......
// $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");
}
......@@ -7,17 +7,20 @@
package main
func main() {
r := ""
a := 3
for i := 0; i < 10; i = i + 1 {
switch i {
case 5:
print("five")
r += "five"
case a, 7:
print("a")
r += "a"
default:
print(i)
r += string(i + '0')
}
print("out", i)
r += "out" + string(i+'0')
}
if r != "0out01out12out2aout34out4fiveout56out6aout78out89out9" {
panic(r)
}
print("\n")
}
......@@ -107,8 +107,16 @@ func init() {
// -------------------------------------
// Factorial
var results = [...]int{
1, 1, 2, 6, 24, 120, 720, 5040, 40320, 362880, 3628800,
39916800, 479001600,
}
func main() {
for i := 0; i <= 9; i++ {
print(i, "! = ", count(fact(gen(i))), "\n")
if f := count(fact(gen(i))); f != results[i] {
println("FAIL:", i, "!:", f, "!=", results[i])
panic(0)
}
}
}
......@@ -25,6 +25,7 @@ func scan(dir int) {
}
func main() {
r := ""
for {
switch prog[pc] {
case '>':
......@@ -36,7 +37,7 @@ func main() {
case '-':
a[p]--
case '.':
print(string(a[p]))
r += string(a[p])
case '[':
if a[p] == 0 {
scan(1)
......@@ -46,6 +47,9 @@ func main() {
scan(-1)
}
default:
if r != "Hello World!\n" {
panic(r)
}
return
}
pc++
......
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