diff options
Diffstat (limited to 'mcs/tests/gen-check.cs')
-rwxr-xr-x | mcs/tests/gen-check.cs | 78 |
1 files changed, 78 insertions, 0 deletions
diff --git a/mcs/tests/gen-check.cs b/mcs/tests/gen-check.cs new file mode 100755 index 00000000000..9077b141a74 --- /dev/null +++ b/mcs/tests/gen-check.cs @@ -0,0 +1,78 @@ +using System; + +class Stress { + + static string [] types = { + "int", "uint", + "short", "ushort", + "long", "ulong", + "sbyte", "byte", "char" + }; + + + static void w (string s) + { + Console.Write (s); + } + + static void wl (string s) + { + Console.WriteLine (s); + } + + static void generate_receptors () + { + foreach (string t in types){ + w ("\tstatic void receive_" + t + " (" + t + " a)\n\t{\n"); + w ("\t\tConsole.Write (\" \");\n"); + w ("\t\tConsole.WriteLine (a);\n"); + w ("\t}\n\n"); + } + + } + + static void call (string type, string name) + { + w ("\t\treceive_" + type + " (checked ((" + type + ") var ));\n"); + } + + static void generate_emision () + { + foreach (string type in types){ + w ("\tstatic void probe_" + type + "()\n\t{\n"); + if (type == "char") + w ("\t\t" + type + " var = (char) 0;"); + else + w ("\t\t" + type + " var = 0;"); + + wl (""); + + foreach (string t in types) + call (t, "var"); + + w ("\t}\n\n"); + } + } + + static void generate_main () + { + wl ("\tstatic void Main ()\n\t{"); + + foreach (string t in types){ + w ("\t\tprobe_" + t + " ();\n"); + } + wl ("\t}"); + } + + static void Main (string [] args) + { + wl ("using System;\nclass Test {\n"); + + generate_receptors (); + generate_emision (); + + generate_main (); + + wl ("}\n"); + } +} |