diff options
author | Rémy Oudompheng <oudomphe@phare.normalesup.org> | 2012-10-10 22:35:27 +0200 |
---|---|---|
committer | Rémy Oudompheng <oudomphe@phare.normalesup.org> | 2012-10-10 22:35:27 +0200 |
commit | dda1b560ec03e3c5da82bef67322f6f4d16cd7eb (patch) | |
tree | 06ad0b32d3edb70d8c93021e717406bcbdfc3f90 /test/ddd2.dir | |
parent | c12dab2aa606fda6b8ff54082de775bf7737c866 (diff) | |
download | go-dda1b560ec03e3c5da82bef67322f6f4d16cd7eb.tar.gz go-dda1b560ec03e3c5da82bef67322f6f4d16cd7eb.zip |
test: convert tests to run.go whenever possible.
The other tests either need a complex procedure
or are architecture- or OS-dependent.
Update #4139.
R=golang-dev, daniel.morsing, iant
CC=golang-dev
https://golang.org/cl/6618062
Diffstat (limited to 'test/ddd2.dir')
-rw-r--r-- | test/ddd2.dir/ddd2.go | 16 | ||||
-rw-r--r-- | test/ddd2.dir/ddd3.go | 28 |
2 files changed, 44 insertions, 0 deletions
diff --git a/test/ddd2.dir/ddd2.go b/test/ddd2.dir/ddd2.go new file mode 100644 index 0000000000..c9a2675926 --- /dev/null +++ b/test/ddd2.dir/ddd2.go @@ -0,0 +1,16 @@ +// 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. + +// This file is compiled and then imported by ddd3.go. + +package ddd + +func Sum(args ...int) int { + s := 0 + for _, v := range args { + s += v + } + return s +} + diff --git a/test/ddd2.dir/ddd3.go b/test/ddd2.dir/ddd3.go new file mode 100644 index 0000000000..5486fe8a04 --- /dev/null +++ b/test/ddd2.dir/ddd3.go @@ -0,0 +1,28 @@ +// 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. + +// Test that variadic functions work across package boundaries. + +package main + +import "./ddd2" + +func main() { + if x := ddd.Sum(1, 2, 3); x != 6 { + println("ddd.Sum 6", x) + panic("fail") + } + if x := ddd.Sum(); x != 0 { + println("ddd.Sum 0", x) + panic("fail") + } + if x := ddd.Sum(10); x != 10 { + println("ddd.Sum 10", x) + panic("fail") + } + if x := ddd.Sum(1, 8); x != 9 { + println("ddd.Sum 9", x) + panic("fail") + } +} |