mirror of
https://github.com/boostorg/python.git
synced 2026-01-20 16:52:15 +00:00
forward.hpp
pointer_holder.hpp
value_holder.hpp
test/long.[py/cpp]
pointee.hpp, - begin making borland work.
cv_category.hpp,
referent_storage.hpp
instance.hpp
self.hpp - removed flotsam
signature.hpp - use vector instead of list
destroy.hpp - removed needless complication
make_keyword_range_fn.hpp - support for simpler init using vectors
class_converters.hpp - workaround for pro7
inheritance.hpp - simplified; took out pro7 workarounds; factored out
inheritance_query.hpp to reduce recompilation
dependencies
make_ptr_instance.hpp - add missing typename
registry.cpp - add a little invariant checking for metrowerks
class.cpp - stopped relying on class_id typedef
test/data_members.cpp - added a few more tests to make sure things compile at least.
test/destroy_test.cpp - removed cheating has_trivial_destructor tests
test/enum.cpp - added some pro7 workarounds
test/virtual_functions.[py/cpp] - added _some_ tests for callbacks which return by reference.
[SVN r18489]
106 lines
1.5 KiB
Python
106 lines
1.5 KiB
Python
'''
|
|
>>> from virtual_functions_ext import *
|
|
|
|
>>> class C1(concrete):
|
|
... def f(self, y):
|
|
... return concrete.f(self, Y(-y.value()))
|
|
|
|
>>> class C2(concrete):
|
|
... pass
|
|
|
|
>>> class A1(abstract):
|
|
... def f(self, y):
|
|
... return y.value() * 2
|
|
... def g(self, y):
|
|
... return self
|
|
|
|
>>> class A2(abstract):
|
|
... pass
|
|
|
|
|
|
>>> y1 = Y(16)
|
|
>>> y2 = Y(17)
|
|
|
|
|
|
|
|
#
|
|
# Test abstract with f,g overridden
|
|
#
|
|
>>> a1 = A1(42)
|
|
>>> a1.value()
|
|
42
|
|
|
|
# Call f,g indirectly from C++
|
|
>>> a1.call_f(y1)
|
|
32
|
|
>>> assert type(a1.call_g(y1)) is abstract
|
|
|
|
# Call f directly from Python
|
|
>>> a1.f(y2)
|
|
34
|
|
|
|
#
|
|
# Test abstract with f not overridden
|
|
#
|
|
>>> a2 = A2(42)
|
|
>>> a2.value()
|
|
42
|
|
|
|
# Call f indirectly from C++
|
|
>>> try: a2.call_f(y1)
|
|
... except AttributeError: pass
|
|
... else: print 'no exception'
|
|
|
|
# Call f directly from Python
|
|
>>> try: a2.call_f(y2)
|
|
... except AttributeError: pass
|
|
... else: print 'no exception'
|
|
|
|
############# Concrete Tests ############
|
|
|
|
#
|
|
# Test concrete with f overridden
|
|
#
|
|
>>> c1 = C1(42)
|
|
>>> c1.value()
|
|
42
|
|
|
|
# Call f indirectly from C++
|
|
>>> c1.call_f(y1)
|
|
-16
|
|
|
|
# Call f directly from Python
|
|
>>> c1.f(y2)
|
|
-17
|
|
|
|
#
|
|
# Test concrete with f not overridden
|
|
#
|
|
>>> c2 = C2(42)
|
|
>>> c2.value()
|
|
42
|
|
|
|
# Call f indirectly from C++
|
|
>>> c2.call_f(y1)
|
|
16
|
|
|
|
# Call f directly from Python
|
|
>>> c2.f(y2)
|
|
17
|
|
|
|
|
|
'''
|
|
|
|
def run(args = None):
|
|
import sys
|
|
import doctest
|
|
|
|
if args is not None:
|
|
sys.argv = args
|
|
return doctest.testmod(sys.modules.get(__name__))
|
|
|
|
if __name__ == '__main__':
|
|
print "running..."
|
|
import sys
|
|
sys.exit(run()[0])
|