]> Cypherpunks.ru repositories - gostls13.git/blob - test/method.go
fix "declared and not used" in tests;
[gostls13.git] / test / method.go
1 // $G $D/$F.go && $L $F.$A && ./$A.out
2
3 // Copyright 2009 The Go Authors. All rights reserved.
4 // Use of this source code is governed by a BSD-style
5 // license that can be found in the LICENSE file.
6
7 package main
8
9 type S string
10 type S1 string
11 type I int
12 type I1 int
13 type T struct { x int }
14 type T1 T
15
16 func (s S) val() int { return 1 }
17 func (s *S1) val() int { return 2 }
18 func (i I) val() int { return 3 }
19 func (i *I1) val() int { return 4 }
20 //func (t T) val() int { return 7 }
21 func (t *T1) val() int { return 8 }
22
23 type Val interface {
24         val() int
25 }
26
27 func val(v Val) int {
28         return v.val()
29 }
30
31 func main() {
32         var s S;
33         var ps *S1;
34         var i I;
35         var pi *I1;
36         var pt *T1;
37
38         if s.val() != 1 { panicln("s.val:", s.val()) }
39         if ps.val() != 2 { panicln("ps.val:", ps.val()) }
40         if i.val() != 3 { panicln("i.val:", i.val()) }
41         if pi.val() != 4 { panicln("pi.val:", pi.val()) }
42 //      if t.val() != 7 { panicln("t.val:", t.val()) }
43         if pt.val() != 8 { panicln("pt.val:", pt.val()) }
44
45         if val(s) != 1 { panicln("s.val:", val(s)) }
46         if val(ps) != 2 { panicln("ps.val:", val(ps)) }
47         if val(i) != 3 { panicln("i.val:", val(i)) }
48         if val(pi) != 4 { panicln("pi.val:", val(pi)) }
49 //      if val(t) != 7 { panicln("t.val:", val(t)) }
50         if val(pt) != 8 { panicln("pt.val:", val(pt)) }
51
52 }