diff options
author | Michael Stapelberg <stapelberg@debian.org> | 2013-03-04 21:27:36 +0100 |
---|---|---|
committer | Michael Stapelberg <michael@stapelberg.de> | 2013-03-04 21:27:36 +0100 |
commit | 04b08da9af0c450d645ab7389d1467308cfc2db8 (patch) | |
tree | db247935fa4f2f94408edc3acd5d0d4f997aa0d8 /test/index.go | |
parent | 917c5fb8ec48e22459d77e3849e6d388f93d3260 (diff) | |
download | golang-upstream/1.1_hg20130304.tar.gz |
Imported Upstream version 1.1~hg20130304upstream/1.1_hg20130304
Diffstat (limited to 'test/index.go')
-rw-r--r-- | test/index.go | 30 |
1 files changed, 14 insertions, 16 deletions
diff --git a/test/index.go b/test/index.go index f9e2413c1..daab45f7a 100644 --- a/test/index.go +++ b/test/index.go @@ -1,23 +1,19 @@ -// $G $D/$F.go && $L $F.$A && -// ./$A.out -pass 0 >tmp.go && $G tmp.go && $L -o $A.out1 tmp.$A && ./$A.out1 && -// ./$A.out -pass 1 >tmp.go && errchk $G -e tmp.go && -// ./$A.out -pass 2 >tmp.go && errchk $G -e tmp.go -// rm -f tmp.go $A.out1 +// skip // Copyright 2010 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 index and slice bounds checks. -// The output is compiled and run. +// The actual tests are index0.go, index1.go, index2.go. package main import ( "bufio" - "flag" "fmt" "os" + "unsafe" ) const prolog = ` @@ -151,14 +147,13 @@ func bug() { func main() { ` -// Passes: +// pass variable set in index[012].go // 0 - dynamic checks // 1 - static checks of invalid constants (cannot assign to types) // 2 - static checks of array bounds -var pass = flag.Int("pass", 0, "which test (0,1,2)") func testExpr(b *bufio.Writer, expr string) { - if *pass == 0 { + if pass == 0 { fmt.Fprintf(b, "\ttest(func(){use(%s)}, %q)\n", expr, expr) } else { fmt.Fprintf(b, "\tuse(%s) // ERROR \"index|overflow\"\n", expr) @@ -168,12 +163,10 @@ func testExpr(b *bufio.Writer, expr string) { func main() { b := bufio.NewWriter(os.Stdout) - flag.Parse() - - if *pass == 0 { - fmt.Fprint(b, "// $G $D/$F.go && $L $F.$A && ./$A.out\n\n") + if pass == 0 { + fmt.Fprint(b, "// run\n\n") } else { - fmt.Fprint(b, "// errchk $G -e $D/$F.go\n\n") + fmt.Fprint(b, "// errorcheck\n\n") } fmt.Fprint(b, prolog) @@ -221,6 +214,11 @@ func main() { // the next pass from running. // So run it as a separate check. thisPass = 1 + } else if a == "s" && n == "" && (i == "i64big" || i == "i64bigger") && unsafe.Sizeof(int(0)) > 4 { + // If int is 64 bits, these huge + // numbers do fit in an int, so they + // are not rejected at compile time. + thisPass = 0 } else { thisPass = 2 } @@ -232,7 +230,7 @@ func main() { } // Only print the test case if it is appropriate for this pass. - if thisPass == *pass { + if thisPass == pass { pae := p+a+e+big cni := c+n+i |