2009-06-12 Bill Holmes <billholmes54@gmail.com>
[mono.git] / mono / tests / make_imt_test.sh
1 #! /bin/bash
2
3 LOW=2000
4 HIGH=2000
5
6 function create_iface () {
7         COUNT=$1
8         echo "public interface Iface_$COUNT {"
9         for i in `seq 1 $COUNT`;
10         do
11                 echo "  int Method_$i (int a, int b, int c, int d);"
12         done 
13         echo "}"
14         echo
15 }
16
17
18 function create_impl () {
19         COUNT=$1
20         echo "public class Impl_$COUNT : Iface_$COUNT {"
21         for i in `seq 1 $COUNT`;
22         do
23                 echo "  public virtual int Method_$i (int a, int b, int c, int d) { return a - b - c - d + ${i}; }"
24         done 
25         echo "}"
26         echo
27 }
28
29
30 function create_static_part () {
31         IFACE=$1
32         echo "  static Iface_$IFACE var_$IFACE = new Impl_$IFACE ();"
33         echo "  static int Test_$IFACE () {
34                 int res = 0;
35                 int r;
36         "
37
38         for i in `seq 1 $IFACE`;
39         do      
40                 echo "          if ((r = var_${IFACE}.Method_$i (10,5,3,2)) != ${i}) {
41                         Console.WriteLine(\"iface $IFACE method $i returned {0}\", r);
42                         res = 1;
43                 }"
44
45         done
46
47         echo "          return res;
48         }"
49 }
50
51
52 function test_iface () {
53         IFACE=$1
54         echo "          res |= Test_$IFACE ();"
55 }
56
57
58 ####Part that split the output
59
60 echo "using System;
61
62 "
63
64 for i in `seq $LOW $HIGH`;
65 do
66         create_iface $i
67         create_impl $i
68 done
69
70
71
72 echo "
73 public class Driver
74 {
75 "
76
77
78 for i in `seq $LOW $HIGH`;
79 do
80         create_static_part $i
81 done
82
83
84 echo "
85         public static int Main ()
86         {
87                 int res = 0;"
88
89
90 for i in `seq $LOW $HIGH`;
91 do
92         test_iface  $i
93 done
94
95
96 echo "          return res;
97         }
98 }"
99
100
101