mirror of https://github.com/go-python/gopy.git
tests: fix exit code
This commit is contained in:
parent
179d004305
commit
fbb477f2ae
|
@ -11,3 +11,5 @@ print ("Python list:", a)
|
|||
print ("Go array: ", b)
|
||||
print ("arrays.IntSum from Python list:", arrays.IntSum(a))
|
||||
print ("arrays.IntSum from Go array:", arrays.IntSum(b))
|
||||
|
||||
print("OK")
|
||||
|
|
|
@ -10,3 +10,5 @@ import cgo
|
|||
print("cgo.doc: %s" % repr(cgo.__doc__).lstrip('u'))
|
||||
print("cgo.Hi()= %s" % repr(cgo.Hi()).lstrip('u'))
|
||||
print("cgo.Hello(you)= %s" % repr(cgo.Hello("you")).lstrip('u'))
|
||||
|
||||
print("OK")
|
||||
|
|
|
@ -21,3 +21,4 @@ print("k2 = %s" % consts.GetKind2())
|
|||
#print("k3 = %s" % consts.GetKind3())
|
||||
#print("k4 = %s" % consts.GetKind4())
|
||||
|
||||
print("OK")
|
||||
|
|
|
@ -9,3 +9,4 @@ import empty as pkg
|
|||
|
||||
print("doc(pkg):\n%s" % repr(pkg.__doc__).lstrip('u'))
|
||||
|
||||
print("OK")
|
||||
|
|
|
@ -27,3 +27,4 @@ print("s2.F1 = funcs.GetF1()...")
|
|||
s2.F1 = funcs.GetF1()
|
||||
print("s2.F1() = %s" % s2.F1())
|
||||
|
||||
print("OK")
|
||||
|
|
|
@ -9,3 +9,5 @@ import gostrings
|
|||
|
||||
print("S1 = %s" % (gostrings.GetS1(),))
|
||||
print("GetString() = %s" % (gostrings.GetString(),))
|
||||
|
||||
print("OK")
|
||||
|
|
|
@ -256,3 +256,6 @@ try:
|
|||
print("mem(slice):",len(memoryview(s)))
|
||||
except Exception as err:
|
||||
print("mem(slice): caught:",err)
|
||||
pass
|
||||
|
||||
print("OK")
|
||||
|
|
|
@ -18,3 +18,4 @@ t.F()
|
|||
print("iface.CallIface(t)")
|
||||
iface.CallIface(t)
|
||||
|
||||
print("OK")
|
||||
|
|
|
@ -12,3 +12,5 @@ print('l.SomeListOfStrings: {}'.format(l.SomeListOfStrings))
|
|||
print('l.SomeListOfInts: {}'.format(l.SomeListOfInts))
|
||||
print('l.SomeListOfFloats: {}'.format(l.SomeListOfFloats))
|
||||
print('l.SomeListOfBools: {}'.format(l.SomeListOfBools))
|
||||
|
||||
print("OK")
|
||||
|
|
|
@ -13,3 +13,5 @@ print('maps.Keys from Go map:', maps.Keys(a))
|
|||
print('maps.Values from Go map:', maps.Values(a))
|
||||
print('maps.Keys from Python dictionary:', maps.Keys(b))
|
||||
print('maps.Values from Python dictionary:', maps.Values(b))
|
||||
|
||||
print("OK")
|
||||
|
|
|
@ -125,3 +125,5 @@ print("s = %s" % (s,))
|
|||
print("s = named.Slice(xrange(10))")
|
||||
s = named.Slice(xrange(10))
|
||||
print("s = %s" % (s,))
|
||||
|
||||
print("OK")
|
||||
|
|
|
@ -14,3 +14,5 @@ print("s.Value = %s" % (s.Value,))
|
|||
|
||||
print("pointers.Inc(s)")
|
||||
print("s.Value = %s" % (s.Value,))
|
||||
|
||||
print("OK")
|
||||
|
|
|
@ -16,3 +16,5 @@ def div(a, b):
|
|||
|
||||
div(5,0)
|
||||
div(5,2)
|
||||
|
||||
print("OK")
|
||||
|
|
|
@ -9,3 +9,5 @@ import rename
|
|||
|
||||
print(rename.say_hi())
|
||||
print(rename.MyStruct().say_something())
|
||||
|
||||
print("OK")
|
||||
|
|
|
@ -45,4 +45,4 @@ print("s += [10,20]")
|
|||
s += [10,20]
|
||||
print("s = %s" % (s,))
|
||||
|
||||
|
||||
print("OK")
|
||||
|
|
|
@ -22,3 +22,5 @@ a = 3+4j
|
|||
b = 2+5j
|
||||
print("pkg.Comp64Add(%s, %s) = %s" % (a, b, pkg.Comp128Add(a, b)))
|
||||
print("pkg.Comp128Add(%s, %s) = %s" % (a, b, pkg.Comp128Add(a, b)))
|
||||
|
||||
print("OK")
|
||||
|
|
|
@ -16,3 +16,5 @@ print(i)
|
|||
s = sliceptr.StrVector()
|
||||
sliceptr.Convert(i, s)
|
||||
print(s)
|
||||
|
||||
print("OK")
|
||||
|
|
|
@ -23,3 +23,5 @@ si16 = slices.SliceInt16([-2,-3])
|
|||
si32 = slices.SliceInt32([-3,-4])
|
||||
si64 = slices.SliceInt64([-4,-5])
|
||||
print ("signed slice elements:", si8[0], si16[0], si32[0], si64[0])
|
||||
|
||||
print("OK")
|
||||
|
|
|
@ -71,3 +71,5 @@ try:
|
|||
except Exception as err:
|
||||
print("caught error: %s" % (err,))
|
||||
pass
|
||||
|
||||
print("OK")
|
||||
|
|
|
@ -36,3 +36,4 @@ binary_stdout.write(b"encoding.GetString() -> ")
|
|||
binary_stdout.write(gostring_ret.encode("UTF-8"))
|
||||
binary_stdout.write(b"\n")
|
||||
|
||||
print("OK")
|
||||
|
|
|
@ -51,3 +51,5 @@ print("k2 = %s" % vars.GetKind2())
|
|||
print("vars.GetDoc() = %s" % repr(vars.GetDoc()).lstrip('u'))
|
||||
print("doc of vars.GetDoc = %s" % repr(vars.GetDoc.__doc__).lstrip('u'))
|
||||
print("doc of vars.SetDoc = %s" % repr(vars.SetDoc.__doc__).lstrip('u'))
|
||||
|
||||
print("OK")
|
||||
|
|
21
main_test.go
21
main_test.go
|
@ -217,6 +217,7 @@ slice[2]: caught: slice index out of range
|
|||
slice: []int{1, 42}
|
||||
len(slice): 2
|
||||
mem(slice): 2
|
||||
OK
|
||||
`),
|
||||
})
|
||||
|
||||
|
@ -350,6 +351,7 @@ slice[2]: caught: slice index out of range
|
|||
slice: []int{1, 42}
|
||||
len(slice): 2
|
||||
mem(slice): caught: cannot make memory view because object does not have the buffer interface
|
||||
OK
|
||||
`),
|
||||
})
|
||||
}
|
||||
|
@ -374,6 +376,7 @@ s2 = funcs.S2()...
|
|||
s2.F1 = funcs.GetF1()...
|
||||
calling F1
|
||||
s2.F1() = None
|
||||
OK
|
||||
`),
|
||||
})
|
||||
}
|
||||
|
@ -394,6 +397,7 @@ pkg.Bool(True)= True
|
|||
pkg.Bool(False)= False
|
||||
pkg.Comp64Add((3+4j), (2+5j)) = (5+9j)
|
||||
pkg.Comp128Add((3+4j), (2+5j)) = (5+9j)
|
||||
OK
|
||||
`),
|
||||
})
|
||||
}
|
||||
|
@ -407,6 +411,7 @@ func TestBindEmpty(t *testing.T) {
|
|||
want: []byte(`empty.init()... [CALLED]
|
||||
doc(pkg):
|
||||
'Package empty does not expose anything.\nWe may want to wrap and import it just for its side-effects.\n'
|
||||
OK
|
||||
`),
|
||||
})
|
||||
}
|
||||
|
@ -425,6 +430,7 @@ pointers.Inc(s)
|
|||
==> go: s.Value==2
|
||||
<== go: s.Value==3
|
||||
s.Value = 3
|
||||
OK
|
||||
`),
|
||||
})
|
||||
}
|
||||
|
@ -496,6 +502,7 @@ s = named.Slice(range(10))
|
|||
s = named.Slice{0, 1, 2, 3, 4, 5, 6, 7, 8, 9}
|
||||
s = named.Slice(xrange(10))
|
||||
s = named.Slice{0, 1, 2, 3, 4, 5, 6, 7, 8, 9}
|
||||
OK
|
||||
`),
|
||||
})
|
||||
}
|
||||
|
@ -525,6 +532,7 @@ s2child = S2Child{S2: structs.S2{Public:42, private:0}, local: 123}
|
|||
s2child.Public = 42
|
||||
s2child.local = 123
|
||||
caught error: 'S2Child' object has no attribute 'private'
|
||||
OK
|
||||
`),
|
||||
})
|
||||
}
|
||||
|
@ -544,6 +552,7 @@ c6 = 42
|
|||
c7 = 666.666
|
||||
k1 = 1
|
||||
k2 = 2
|
||||
OK
|
||||
`),
|
||||
})
|
||||
}
|
||||
|
@ -583,6 +592,7 @@ k2 = 456
|
|||
vars.GetDoc() = 'A variable with some documentation'
|
||||
doc of vars.GetDoc = 'returns vars.Doc\n\nDoc is a top-level string with some documentation attached.\n'
|
||||
doc of vars.SetDoc = 'sets vars.Doc\n\nDoc is a top-level string with some documentation attached.\n'
|
||||
OK
|
||||
`),
|
||||
})
|
||||
}
|
||||
|
@ -610,6 +620,7 @@ s += [1,2]
|
|||
s = seqs.Slice{1, 2}
|
||||
s += [10,20]
|
||||
s = seqs.Slice{1, 2, 10, 20}
|
||||
OK
|
||||
`),
|
||||
})
|
||||
}
|
||||
|
@ -635,6 +646,7 @@ func TestBindCgoPackage(t *testing.T) {
|
|||
want: []byte(`cgo.doc: 'Package cgo tests bindings of CGo-based packages.\n'
|
||||
cgo.Hi()= 'hi from go\n'
|
||||
cgo.Hello(you)= 'hello you from go\n'
|
||||
OK
|
||||
`),
|
||||
})
|
||||
}
|
||||
|
@ -647,6 +659,7 @@ func TestPyErrors(t *testing.T) {
|
|||
lang: features[path],
|
||||
want: []byte(`Divide by zero.
|
||||
pyerrors.Div(5, 2) = 2
|
||||
OK
|
||||
`),
|
||||
})
|
||||
}
|
||||
|
@ -661,6 +674,7 @@ func TestBuiltinArrays(t *testing.T) {
|
|||
Go array: [4]int{1, 2, 3, 4}
|
||||
arrays.IntSum from Python list: 10
|
||||
arrays.IntSum from Go array: 10
|
||||
OK
|
||||
`),
|
||||
})
|
||||
}
|
||||
|
@ -677,6 +691,7 @@ slices.IntSum from Python list: 10
|
|||
slices.IntSum from Go slice: 10
|
||||
unsigned slice elements: 1 2 3 4
|
||||
signed slice elements: -1 -2 -3 -4
|
||||
OK
|
||||
`),
|
||||
})
|
||||
}
|
||||
|
@ -693,6 +708,7 @@ maps.Keys from Go map: []int{1, 2}
|
|||
maps.Values from Go map: []float64{3, 5}
|
||||
maps.Keys from Python dictionary: []int{1, 2}
|
||||
maps.Values from Python dictionary: []float64{3, 5}
|
||||
OK
|
||||
`),
|
||||
})
|
||||
}
|
||||
|
@ -705,6 +721,7 @@ func TestBindStrings(t *testing.T) {
|
|||
lang: features[path],
|
||||
want: []byte(`S1 = S1
|
||||
GetString() = MyString
|
||||
OK
|
||||
`),
|
||||
})
|
||||
}
|
||||
|
@ -717,6 +734,7 @@ func TestBindRename(t *testing.T) {
|
|||
lang: features[path],
|
||||
want: []byte(`hi
|
||||
something
|
||||
OK
|
||||
`),
|
||||
})
|
||||
}
|
||||
|
@ -735,6 +753,7 @@ l.SomeListOfStrings: []string{"some", "list", "of", "strings"}
|
|||
l.SomeListOfInts: []int64{6, 2, 9, 1}
|
||||
l.SomeListOfFloats: []float64{6.6, 2.2, 9.9, 1.1}
|
||||
l.SomeListOfBools: []bool{true, false, true, false}
|
||||
OK
|
||||
`),
|
||||
})
|
||||
}
|
||||
|
@ -748,6 +767,7 @@ func TestSlicePtr(t *testing.T) {
|
|||
want: []byte(`sliceptr.IntVector{1, 2, 3}
|
||||
sliceptr.IntVector{1, 2, 3, 4}
|
||||
sliceptr.StrVector{"1", "2", "3", "4"}
|
||||
OK
|
||||
`),
|
||||
})
|
||||
}
|
||||
|
@ -761,6 +781,7 @@ func TestUnicode(t *testing.T) {
|
|||
want: []byte(`encoding.HandleString(bytestr) -> Python byte string
|
||||
encoding.HandleString(unicodestr) -> Python Unicode string 🐱
|
||||
encoding.GetString() -> Go Unicode string 🐱
|
||||
OK
|
||||
`),
|
||||
})
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue