/
make-imt-test.cs
53 lines (43 loc) · 1.8 KB
/
make-imt-test.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
using System;
public class Tests
{
public static void Main (String[] args) {
int low = 2000;
int high = 2000;
Console.WriteLine ("using System;");
Console.WriteLine ();
for (int count = low; count <= high; ++count) {
Console.WriteLine ("public interface Iface_" + count + " {");
for (int i = 0; i <= count; ++i)
Console.WriteLine (" int Method_" + i + " (int a, int b, int c, int d);");
Console.WriteLine ("}");
Console.WriteLine ("public class Impl_" + count + " : Iface_" + count + " {");
for (int i = 0; i <= count; ++i)
Console.WriteLine (" public virtual int Method_" + i + " (int a, int b, int c, int d) { return a - b - c -d + " + i + "; }");
Console.WriteLine ("}");
}
Console.WriteLine ("public class Driver");
Console.WriteLine ("{");
for (int iface = low; iface <= high; ++iface) {
Console.WriteLine (" static Iface_" + iface + " var_" + iface + " = new Impl_" + iface + " ();");
Console.WriteLine (" static int Test_" + iface + " () {");
Console.WriteLine (" int res = 0;");
Console.WriteLine (" int r;");
for (int i = 0; i < iface; ++i) {
Console.WriteLine (String.Format (" if ((r = var_{0}.Method_{1} (10,5,3,2)) != {1}) {{", iface, i));
Console.WriteLine (String.Format (" Console.WriteLine(\"iface {0} method {1} returned {{0}}\", r);", iface, i));
Console.WriteLine (" res = 1;");
Console.WriteLine ("}");
}
Console.WriteLine ("return res;");
Console.WriteLine ("}");
}
Console.WriteLine (" public static int Main () {");
Console.WriteLine (" int res = 0;");
for (int iface = low; iface <= high; ++iface)
Console.WriteLine (String.Format (" res |= Test_{0} ();", iface));
Console.WriteLine (" return res;");
Console.WriteLine (" }");
Console.WriteLine ("}");
}
}