blob: b7e3cd369cd7b6a3a044c47290be019277593908 [file] [log] [blame]
Wenzel Jakob57082212015-09-04 23:42:12 +02001#!/usr/bin/env python
2from __future__ import print_function
Wenzel Jakob38bd7112015-07-05 20:05:44 +02003import sys
4sys.path.append('.')
5
6from example import Pet
7from example import Dog
8from example import dog_bark
9from example import pet_print
10
11polly = Pet('Polly', 'parrot')
12molly = Dog('Molly')
13print(polly.name() + " is a " + polly.species())
14pet_print(polly)
15print(molly.name() + " is a " + molly.species())
16pet_print(molly)
17dog_bark(molly)
18try:
19 dog_bark(polly)
20except Exception as e:
21 print('The following error is expected: ' + str(e))
22
23from example import test_callback1
24from example import test_callback2
25from example import test_callback3
Wenzel Jakob281aa0e2015-07-30 15:29:00 +020026from example import test_callback4
Wenzel Jakob19208fe2015-10-13 17:37:25 +020027from example import test_cleanup
Wenzel Jakob38bd7112015-07-05 20:05:44 +020028
29def func1():
30 print('Callback function 1 called!')
31
Wenzel Jakob7b8e0322015-08-28 17:49:15 +020032def func2(a, b, c, d):
33 print('Callback function 2 called : ' + str(a) + ", " + str(b) + ", " + str(c) + ", "+ str(d))
Wenzel Jakoba2f6fde2015-10-01 16:46:03 +020034 return d
Wenzel Jakob38bd7112015-07-05 20:05:44 +020035
36print(test_callback1(func1))
37print(test_callback2(func2))
38
Wenzel Jakoba2f6fde2015-10-01 16:46:03 +020039test_callback3(lambda i: i + 1)
40f = test_callback4()
Wenzel Jakob281aa0e2015-07-30 15:29:00 +020041print("func(43) = %i" % f(43))
Wenzel Jakob19208fe2015-10-13 17:37:25 +020042
43test_cleanup()