1
0
mirror of https://github.com/golang/go synced 2024-11-14 08:20:21 -07:00
go/doc/progs/run
Russ Cox 28eba4877b fix "declared and not used" errors in non-test code.
R=r
DELTA=112  (6 added, 57 deleted, 49 changed)
OCL=34610
CL=34610
2009-09-14 17:20:29 -07:00

79 lines
1.8 KiB
Bash
Executable File

#!/bin/bash
# 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.
. $GOROOT/src/Make.$GOARCH
if [ -z "$O" ]; then
echo 'missing $O - maybe no Make.$GOARCH?' 1>&2
exit 1
fi
rm -f *.$O
for i in \
file.go \
helloworld.go \
helloworld3.go \
echo.go \
cat.go \
cat_rot13.go \
sum.go \
sort.go \
sortmain.go \
print.go \
print_string.go \
sieve.go \
sieve1.go \
server1.go \
; do
BASE=$(basename $i .go)
$GC $i
done
function testit {
$LD $1.$O
x=$(echo $(./$O.out $2 2>&1)) # extra echo canonicalizes
if [ "$x" != "$3" ]
then
echo $1 failed: '"'$x'"' is not '"'$3'"'
fi
}
function testitpipe {
$LD $1.$O
x=$(echo $(./$O.out | $2 2>&1)) # extra echo canonicalizes
if [ "$x" != "$3" ]
then
echo $1 failed: '"'$x'"' is not '"'$3'"'
fi
}
testit helloworld "" "Hello, world; or Καλημέρα κόσμε; or こんにちは 世界"
testit helloworld3 "" "hello, world can't open file; err=no such file or directory"
testit echo "hello, world" "hello, world"
testit sum "" "6"
alphabet=abcdefghijklmnopqrstuvwxyz
rot13=nopqrstuvwxyzabcdefghijklm
echo $alphabet | testit cat "" $alphabet
echo $alphabet | testit cat_rot13 "--rot13" $rot13
echo $rot13 | testit cat_rot13 "--rot13" $alphabet
testit sortmain "" "Sunday Monday Tuesday Wednesday Thursday Friday Saturday"
testit print "" "18446744073709551615 -1 18446744073709551615 {77 Sunset Strip} [1 2 3 4] 18446744073709551615 {77 Sunset Strip} [1 2 3 4] 18446744073709551615 {77 Sunset Strip} [1 2 3 4]"
testit print_string "" "77 Sunset Strip"
testitpipe sieve "sed 10q" "2 3 5 7 11 13 17 19 23 29"
testitpipe sieve "sed 10q" "2 3 5 7 11 13 17 19 23 29"
# server hangs; don't run it, just compile it
$GC server.go
testit server1 "" ""
rm -f $O.out *.$O