PageRenderTime 196ms CodeModel.GetById 29ms RepoModel.GetById 0ms app.codeStats 0ms

/trunk/Examples/test-suite/python/hugemod.pl

#
Perl | 55 lines | 39 code | 15 blank | 1 comment | 4 complexity | 17848b1c354141b9afcc64fbc3df38b5 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. my $modsize = 399; #adjust it so you can have a smaller or bigger hugemod
  4. my $runme = shift @ARGV;
  5. open HEADER, ">hugemod.h" or die "error";
  6. open TEST, ">$runme" or die "error";
  7. open I1, ">hugemod_a.i" or die "error";
  8. open I2, ">hugemod_b.i" or die "error";
  9. print TEST "import hugemod_a\n";
  10. print TEST "import hugemod_b\n";
  11. print I1 "\%module hugemod_a;\n";
  12. print I1 "\%include \"hugemod.h\";\n";
  13. print I1 "\%{ #include \"hugemod.h\" \%}\n";
  14. print I2 "\%module hugemod_b;\n";
  15. print I2 "\%import \"hugemod.h\";\n";
  16. print I2 "\%{ #include \"hugemod.h\" \%}\n";
  17. print I2 "\%inline \%{\n";
  18. my $i;
  19. for ($i = 0; $i < $modsize; $i++) {
  20. my $t = $i * 4;
  21. print HEADER "class type$i { public: int a; };\n";
  22. print I2 "class dtype$i : public type$i { public: int b; };\n";
  23. print TEST "c = hugemod_a.type$i()\n";
  24. print TEST "c.a = $t\n";
  25. print TEST "if c.a != $t:\n";
  26. print TEST " raise RuntimeError\n";
  27. print TEST "c = hugemod_b.dtype$i()\n";
  28. print TEST "c.a = $t\n";
  29. print TEST "if c.a != $t:\n";
  30. print TEST " raise RuntimeError\n";
  31. $t = -$t;
  32. print TEST "c.b = $t\n";
  33. print TEST "if c.b != $t:\n";
  34. print TEST " raise RuntimeError\n\n";
  35. }
  36. print I2 "\%}\n";
  37. close HEADER;
  38. close TEST;
  39. close I1;
  40. close I2;