2009-11-18 10:11:17 -07:00
#!/usr/bin/env bash
2008-09-17 13:14:52 -06:00
# 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.
2010-03-30 11:34:57 -06:00
set -e
2010-12-13 13:50:57 -07:00
eval $(gomake --no-print-directory -f ../../src/Make.inc go-env)
2009-06-05 11:59:55 -06:00
if [ -z "$O" ]; then
echo 'missing $O - maybe no Make.$GOARCH?' 1>&2
exit 1
fi
rm -f *.$O
2008-09-17 13:14:52 -06:00
2011-12-11 19:15:29 -07:00
defer_panic_recover="
defer.go
defer2.go
"
effective_go="
eff_bytesize.go
eff_qr.go
eff_sequence.go
"
2011-12-12 15:44:06 -07:00
error_handling="
error.go
error2.go
error3.go
error4.go
"
2008-09-17 13:14:52 -06:00
for i in \
2011-12-11 19:15:29 -07:00
$defer_panic_recover \
$effective_go \
2011-12-12 15:44:06 -07:00
$error_handling \
2012-01-05 15:21:43 -07:00
slices.go \
2011-12-11 19:15:29 -07:00
go1.go \
2008-09-17 13:14:52 -06:00
; do
2010-08-30 13:40:56 -06:00
$GC $i
2008-09-17 13:14:52 -06:00
done
2011-10-14 13:37:07 -06:00
# Write to temporary file to avoid mingw bash bug.
2012-01-12 15:45:32 -07:00
TMPFILE="/tmp/gotest3.$USER"
2011-10-14 13:37:07 -06:00
2008-09-17 13:14:52 -06:00
function testit {
2010-08-30 13:40:56 -06:00
$LD $1.$O
2011-10-14 13:37:07 -06:00
./$O.out $2 2>&1 >"$TMPFILE" || true
x=$(echo $(cat "$TMPFILE")) # extra echo canonicalizes
2008-09-17 13:14:52 -06:00
if [ "$x" != "$3" ]
then
echo $1 failed: '"'$x'"' is not '"'$3'"'
fi
}
2012-01-04 22:43:02 -07:00
testit defer "" "0 3210 2"
testit defer2 "" "Calling g. Printing in g 0 Printing in g 1 Printing in g 2 Printing in g 3 Panicking! Defer in g 3 Defer in g 2 Defer in g 1 Defer in g 0 Recovered in f 4 Returned normally from f."
2008-09-17 13:14:52 -06:00
2011-08-22 06:46:59 -06:00
testit eff_bytesize "" "1.00YB 9.09TB"
testit eff_sequence "" "[-1 2 6 16 44]"
2011-12-21 13:06:20 -07:00
testit go1 "" "Christmas is a holiday: true"
2011-12-07 17:11:17 -07:00
2011-10-14 13:37:07 -06:00
rm -f $O.out $O.out.exe *.$O "$TMPFILE"