Jason Rhinelander | b3f3d79 | 2016-07-18 16:43:18 -0400 | [diff] [blame^] | 1 | #!/usr/bin/env python |
| 2 | from __future__ import print_function |
| 3 | import sys |
| 4 | sys.path.append('.') |
| 5 | |
| 6 | from example import ExampleVirt, runExampleVirt, runExampleVirtVirtual, runExampleVirtBool |
| 7 | |
| 8 | |
| 9 | class ExtendedExampleVirt(ExampleVirt): |
| 10 | def __init__(self, state): |
| 11 | super(ExtendedExampleVirt, self).__init__(state + 1) |
| 12 | self.data = "Hello world" |
| 13 | |
| 14 | def run(self, value): |
| 15 | print('ExtendedExampleVirt::run(%i), calling parent..' % value) |
| 16 | return super(ExtendedExampleVirt, self).run(value + 1) |
| 17 | |
| 18 | def run_bool(self): |
| 19 | print('ExtendedExampleVirt::run_bool()') |
| 20 | return False |
| 21 | |
| 22 | def pure_virtual(self): |
| 23 | print('ExtendedExampleVirt::pure_virtual(): %s' % self.data) |
| 24 | |
| 25 | |
| 26 | ex12 = ExampleVirt(10) |
| 27 | print(runExampleVirt(ex12, 20)) |
| 28 | try: |
| 29 | runExampleVirtVirtual(ex12) |
| 30 | except Exception as e: |
| 31 | print("Caught expected exception: " + str(e)) |
| 32 | |
| 33 | ex12p = ExtendedExampleVirt(10) |
| 34 | print(runExampleVirt(ex12p, 20)) |
| 35 | print(runExampleVirtBool(ex12p)) |
| 36 | runExampleVirtVirtual(ex12p) |