mirror of https://github.com/go-python/gopy.git
bind: test docstrings of named types' methods
Change-Id: Ib625a14a09f9ce83bc814b9b8c0d431bddbce639
This commit is contained in:
parent
e891e740c2
commit
4db01df52d
|
@ -2,10 +2,12 @@
|
|||
// Use of this source code is governed by a BSD-style
|
||||
// license that can be found in the LICENSE file.
|
||||
|
||||
// package named tests various aspects of named types.
|
||||
package named
|
||||
|
||||
type Float float32
|
||||
|
||||
// Value returns a float32 value
|
||||
func (f Float) Value() float32 { return float32(f) }
|
||||
|
||||
type X float32
|
||||
|
@ -13,13 +15,21 @@ type XX X
|
|||
type XXX XX
|
||||
type XXXX XXX
|
||||
|
||||
func (x X) Value() float32 { return float32(x) }
|
||||
func (x XX) Value() float32 { return float32(x) }
|
||||
func (x XXX) Value() float32 { return float32(x) }
|
||||
// Value returns a float32 value
|
||||
func (x X) Value() float32 { return float32(x) }
|
||||
|
||||
// Value returns a float32 value
|
||||
func (x XX) Value() float32 { return float32(x) }
|
||||
|
||||
// Value returns a float32 value
|
||||
func (x XXX) Value() float32 { return float32(x) }
|
||||
|
||||
// Value returns a float32 value
|
||||
func (x XXXX) Value() float32 { return float32(x) }
|
||||
|
||||
type Str string
|
||||
|
||||
// Value returns a string value
|
||||
func (s Str) Value() string { return string(s) }
|
||||
|
||||
type Slice []float64
|
||||
|
|
|
@ -7,6 +7,11 @@ from __future__ import print_function
|
|||
|
||||
import named
|
||||
|
||||
### test docs
|
||||
print("doc(named): %r" % (named.__doc__,))
|
||||
print("doc(named.Float): %r" % (named.Float.__doc__,))
|
||||
print("doc(named.Float.Value): %r" % (named.Float.Value.__doc__,))
|
||||
|
||||
print("v = named.Float()")
|
||||
v = named.Float()
|
||||
print("v = %s" % (v,))
|
||||
|
|
|
@ -280,7 +280,10 @@ func TestBindNamed(t *testing.T) {
|
|||
t.Parallel()
|
||||
testPkg(t, pkg{
|
||||
path: "_examples/named",
|
||||
want: []byte(`v = named.Float()
|
||||
want: []byte(`doc(named): 'package named tests various aspects of named types.\n'
|
||||
doc(named.Float): ''
|
||||
doc(named.Float.Value): 'Value() float\n\nValue returns a float32 value\n'
|
||||
v = named.Float()
|
||||
v = 0
|
||||
v.Value() = 0.0
|
||||
x = named.X()
|
||||
|
|
Loading…
Reference in New Issue