From 554fd8c5195424bdbcabf5de30fdc183aba391bd Mon Sep 17 00:00:00 2001 From: upstream source tree Date: Sun, 15 Mar 2015 20:14:05 -0400 Subject: obtained gcc-4.6.4.tar.bz2 from upstream website; verified gcc-4.6.4.tar.bz2.sig; imported gcc-4.6.4 source tree from verified upstream tarball. downloading a git-generated archive based on the 'upstream' tag should provide you with a source tree that is binary identical to the one extracted from the above tarball. if you have obtained the source via the command 'git clone', however, do note that line-endings of files in your working directory might differ from line-endings of the respective files in the upstream repository. --- gcc/testsuite/go.test/test/method.go | 111 +++++++++++++++++++++++++++++++++++ 1 file changed, 111 insertions(+) create mode 100644 gcc/testsuite/go.test/test/method.go (limited to 'gcc/testsuite/go.test/test/method.go') diff --git a/gcc/testsuite/go.test/test/method.go b/gcc/testsuite/go.test/test/method.go new file mode 100644 index 000000000..c751c1f1b --- /dev/null +++ b/gcc/testsuite/go.test/test/method.go @@ -0,0 +1,111 @@ +// $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 + +type S string +type S1 string +type I int +type I1 int +type T struct { + x int +} +type T1 T + +func (s S) val() int { return 1 } +func (s *S1) val() int { return 2 } +func (i I) val() int { return 3 } +func (i *I1) val() int { return 4 } +//func (t T) val() int { return 7 } +func (t *T1) val() int { return 8 } + +type Val interface { + val() int +} + +func val(v Val) int { return v.val() } + +func main() { + var s S + var ps *S1 + var i I + var pi *I1 + var pt *T1 + + if s.val() != 1 { + println("s.val:", s.val()) + panic("fail") + } + if S.val(s) != 1 { + println("S.val(s):", S.val(s)) + panic("fail") + } + if (*S).val(&s) != 1 { + println("(*S).val(s):", (*S).val(&s)) + panic("fail") + } + if ps.val() != 2 { + println("ps.val:", ps.val()) + panic("fail") + } + if (*S1).val(ps) != 2 { + println("(*S1).val(ps):", (*S1).val(ps)) + panic("fail") + } + if i.val() != 3 { + println("i.val:", i.val()) + panic("fail") + } + if I.val(i) != 3 { + println("I.val(i):", I.val(i)) + panic("fail") + } + if (*I).val(&i) != 3 { + println("(*I).val(&i):", (*I).val(&i)) + panic("fail") + } + if pi.val() != 4 { + println("pi.val:", pi.val()) + panic("fail") + } + if (*I1).val(pi) != 4 { + println("(*I1).val(pi):", (*I1).val(pi)) + panic("fail") + } + // if t.val() != 7 { prinln("t.val:", t.val()); panic("fail") } + if pt.val() != 8 { + println("pt.val:", pt.val()) + panic("fail") + } + if (*T1).val(pt) != 8 { + println("(*T1).val(pt):", (*T1).val(pt)) + panic("fail") + } + + if val(s) != 1 { + println("s.val:", val(s)) + panic("fail") + } + if val(ps) != 2 { + println("ps.val:", val(ps)) + panic("fail") + } + if val(i) != 3 { + println("i.val:", val(i)) + panic("fail") + } + if val(pi) != 4 { + println("pi.val:", val(pi)) + panic("fail") + } + // if val(t) != 7 { println("t.val:", val(t)); panic("fail") } + if val(pt) != 8 { + println("pt.val:", val(pt)) + panic("fail") + } + + // if Val.val(i) != 3 { println("Val.val(i):", Val.val(i)); panic("fail") } +} -- cgit v1.2.3