bind: test top-level vars+consts

This commit is contained in:
Sebastien Binet 2015-07-31 16:54:24 +02:00
parent ac4e49ddfb
commit 64de09f092
3 changed files with 39 additions and 0 deletions

View File

@ -9,6 +9,16 @@ import (
"fmt"
)
const (
Version = "0.1" // Version of this package
Universe = 42 // Universe is the fundamental constant of everything
)
var (
Debug = false // Debug switches between debug and prod
Anon = Person{Age: 1, Name: "<nobody>"} // Anon is a default anonymous person
)
// Hi prints hi from Go
func Hi() {
fmt.Printf("hi from go\n")

View File

@ -3,6 +3,24 @@ import hi
print "--- doc(hi)..."
print hi.__doc__
print "--- hi.GetUniverse():", hi.GetUniverse()
print "--- hi.GetVersion():", hi.GetVersion()
print "--- hi.GetDebug():",hi.GetDebug()
print "--- hi.SetDebug(true)"
hi.SetDebug(True)
print "--- hi.GetDebug():",hi.GetDebug()
print "--- hi.SetDebug(false)"
hi.SetDebug(False)
print "--- hi.GetDebug():",hi.GetDebug()
print "--- hi.GetAnon():",hi.GetAnon()
anon = hi.NewPerson('you',24)
print "--- new anon:",anon
print "--- hi.SetAnon(hi.NewPerson('you', 24))..."
hi.SetAnon(anon)
print "--- hi.GetAnon():",hi.GetAnon()
print "--- doc(hi.Hi)..."
print hi.Hi.__doc__

View File

@ -59,6 +59,17 @@ worked for 4 hours
--- doc(hi)...
package hi exposes a few Go functions to be wrapped and used from Python.
--- hi.GetUniverse(): 42
--- hi.GetVersion(): 0.1
--- hi.GetDebug(): False
--- hi.SetDebug(true)
--- hi.GetDebug(): True
--- hi.SetDebug(false)
--- hi.GetDebug(): False
--- hi.GetAnon(): hi.Person{Name="<nobody>", Age=1}
--- new anon: hi.Person{Name="you", Age=24}
--- hi.SetAnon(hi.NewPerson('you', 24))...
--- hi.GetAnon(): hi.Person{Name="you", Age=24}
--- doc(hi.Hi)...
Hi()