You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

57 lines
1.3 KiB

  1. #!/usr/bin/env python
  2. from __future__ import print_function
  3. import sys
  4. sys.path.append('.')
  5. from example.issues import print_cchar, print_char
  6. from example.issues import DispatchIssue, dispatch_issue_go
  7. from example.issues import Placeholder, return_vec_of_reference_wrapper
  8. from example.issues import iterator_passthrough
  9. from example.issues import ElementList, ElementA, print_element
  10. from example.issues import expect_float, expect_int
  11. import gc
  12. print_cchar("const char *")
  13. print_char('c')
  14. class PyClass1(DispatchIssue):
  15. def dispatch(self):
  16. print("Yay..")
  17. class PyClass2(DispatchIssue):
  18. def dispatch(self):
  19. try:
  20. super(PyClass2, self).dispatch()
  21. except Exception as e:
  22. print("Failed as expected: " + str(e))
  23. p = PyClass1()
  24. dispatch_issue_go(p)
  25. b = PyClass2()
  26. dispatch_issue_go(b)
  27. print(return_vec_of_reference_wrapper(Placeholder(4)))
  28. print(list(iterator_passthrough(iter([3, 5, 7, 9, 11, 13, 15]))))
  29. el = ElementList()
  30. for i in range(10):
  31. el.add(ElementA(i))
  32. gc.collect()
  33. for i, v in enumerate(el.get()):
  34. print("%i==%i, " % (i, v.value()), end='')
  35. print()
  36. try:
  37. print_element(None)
  38. except Exception as e:
  39. print("Failed as expected: " + str(e))
  40. try:
  41. print(expect_int(5.2))
  42. except Exception as e:
  43. print("Failed as expected: " + str(e))
  44. print(expect_float(12))