Merge pull request #5714 from alexischr/update_bockbuild
[mono.git] / mcs / tests / gen-check.cs
1 using System;
2
3 class Stress {
4         
5         static string [] types = {
6                 "int",   "uint",
7                 "short", "ushort",
8                 "long",  "ulong",
9                 "sbyte", "byte", "char"
10                 };
11         
12
13         static void w (string s)
14         {
15                 Console.Write (s);
16         }
17
18         static void wl (string s)
19         {
20                 Console.WriteLine (s);
21         }
22         
23         static void generate_receptors ()
24         {
25                 foreach (string t in types){
26                         w ("\tstatic void receive_" + t + " (" + t + " a)\n\t{\n");
27                         w ("\t\tConsole.Write (\"        \");\n");
28                         w ("\t\tConsole.WriteLine (a);\n");
29                         w ("\t}\n\n");
30                 }
31                 
32         }
33
34         static void call (string type, string name)
35         {
36                 w ("\t\treceive_" + type + " (checked ((" + type + ") var ));\n");
37         }
38
39         static void generate_emision ()
40         {
41                 foreach (string type in types){
42                         w ("\tstatic void probe_" + type + "()\n\t{\n");
43                         if (type == "char")
44                                 w ("\t\t" + type + " var = (char) 0;");
45                         else
46                                 w ("\t\t" + type + " var = 0;");                                        
47                                 
48                         wl ("");
49
50                         foreach (string t in types)
51                                 call (t, "var");
52                         
53                         w ("\t}\n\n");
54                 }
55         }
56         
57         static void generate_main ()
58         {
59                 wl ("\tpublic static void Main ()\n\t{");
60
61                 foreach (string t in types){
62                         w ("\t\tprobe_" + t + " ();\n");
63                 }
64                 wl ("\t}");
65         }
66
67         public static void Main (string [] args)
68         {
69                 wl ("using System;\nclass Test {\n");
70
71                 generate_receptors ();
72                 generate_emision ();
73
74                 generate_main ();
75                                
76                 wl ("}\n");
77         }
78 }