PageRenderTime 41ms CodeModel.GetById 17ms RepoModel.GetById 0ms app.codeStats 0ms

/trunk/Examples/test-suite/perl5/minherit_runme.pl

#
Perl | 72 lines | 49 code | 20 blank | 3 comment | 0 complexity | 7141f18e9e6eaf603d4d5494500a845e MD5 | raw file
Possible License(s): LGPL-2.1, Cube, GPL-3.0, 0BSD, GPL-2.0
  1. #!/usr/bin/perl
  2. use strict;
  3. use warnings;
  4. use Test::More tests => 38;
  5. BEGIN { use_ok('minherit') }
  6. require_ok('minherit');
  7. # adapted from ../python/minherit_runme.py
  8. my $a = minherit::Foo->new();
  9. my $b = minherit::Bar->new();
  10. my $c = minherit::FooBar->new();
  11. my $d = minherit::Spam->new();
  12. is($a->xget(), 1);
  13. is($b->yget(), 2);
  14. is($c->xget(), 1);
  15. is($c->yget(), 2);
  16. is($c->zget(), 3);
  17. is($d->xget(), 1);
  18. is($d->yget(), 2);
  19. is($d->zget(), 3);
  20. is($d->wget(), 4);
  21. is(minherit::xget($a), 1);
  22. is(minherit::yget($b), 2);
  23. is(minherit::xget($c), 1);
  24. is(minherit::yget($c), 2);
  25. is(minherit::zget($c), 3);
  26. is(minherit::xget($d), 1);
  27. is(minherit::yget($d), 2);
  28. is(minherit::zget($d), 3);
  29. is(minherit::wget($d), 4);
  30. # Cleanse all of the pointers and see what happens
  31. my $aa = minherit::toFooPtr($a);
  32. my $bb = minherit::toBarPtr($b);
  33. my $cc = minherit::toFooBarPtr($c);
  34. my $dd = minherit::toSpamPtr($d);
  35. is($aa->xget, 1);
  36. is($bb->yget(), 2);
  37. is($cc->xget(), 1);
  38. is($cc->yget(), 2);
  39. is($cc->zget(), 3);
  40. is($dd->xget(), 1);
  41. is($dd->yget(), 2);
  42. is($dd->zget(), 3);
  43. is($dd->wget(), 4);
  44. is(minherit::xget($aa), 1);
  45. is(minherit::yget($bb), 2);
  46. is(minherit::xget($cc), 1);
  47. is(minherit::yget($cc), 2);
  48. is(minherit::zget($cc), 3);
  49. is(minherit::xget($dd), 1);
  50. is(minherit::yget($dd), 2);
  51. is(minherit::zget($dd), 3);
  52. is(minherit::wget($dd), 4);