PageRenderTime 22ms CodeModel.GetById 1ms app.highlight 15ms RepoModel.GetById 2ms 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
 1#!/usr/bin/perl
 2
 3use strict;
 4
 5my $modsize = 399; #adjust it so you can have a smaller or bigger hugemod 
 6
 7my $runme = shift @ARGV;
 8
 9open HEADER, ">hugemod.h" or die "error";
10open TEST, ">$runme" or die "error";
11open I1, ">hugemod_a.i" or die "error";
12open I2, ">hugemod_b.i" or die "error";
13
14print TEST "import hugemod_a\n";
15print TEST "import hugemod_b\n";
16
17print I1 "\%module hugemod_a;\n";
18print I1 "\%include \"hugemod.h\";\n";
19print I1 "\%{ #include \"hugemod.h\" \%}\n";
20
21print I2 "\%module hugemod_b;\n";
22print I2 "\%import \"hugemod.h\";\n";
23print I2 "\%{ #include \"hugemod.h\" \%}\n";
24print I2 "\%inline \%{\n";
25
26my $i;
27
28for ($i = 0; $i < $modsize; $i++) {
29  my $t = $i * 4;
30  print HEADER "class type$i { public: int a; };\n";
31  print I2 "class dtype$i : public type$i { public: int b; };\n";
32  
33  print TEST "c = hugemod_a.type$i()\n";
34  print TEST "c.a = $t\n";
35  print TEST "if c.a != $t:\n";
36  print TEST "    raise RuntimeError\n";
37
38  print TEST "c = hugemod_b.dtype$i()\n";
39  print TEST "c.a = $t\n";
40  print TEST "if c.a != $t:\n";
41  print TEST "    raise RuntimeError\n";
42  
43  $t = -$t;
44  
45  print TEST "c.b = $t\n";
46  print TEST "if c.b != $t:\n";
47  print TEST "    raise RuntimeError\n\n";
48}
49
50print I2 "\%}\n";
51
52close HEADER;
53close TEST;
54close I1;
55close I2;