[mono/tests] Fix out of tree build.
[mono-project.git] / mcs / tests / gen-cast-test.cs
blobf8df506b1114b1ec46d8566943ad37bab3f553a3
1 using System;
3 class Stress {
5 static string mode = "unchecked";
7 static string [] types = {
8 "int", "uint",
9 "short", "ushort",
10 "long", "ulong",
11 "sbyte", "byte", "char"
15 static void w (string s)
17 Console.Write (s);
20 static void wl (string s)
22 Console.WriteLine (s);
25 static void generate_receptors ()
27 foreach (string t in types){
28 w ("\tstatic void receive_" + t + " (" + t + " a)\n\t{\n");
29 w ("\t\tConsole.Write (\" \");\n");
30 w ("\t\tConsole.WriteLine (a);\n");
31 w ("\t}\n\n");
36 static void var (string type, string name, string init)
38 w ("\t\t" + type + " " + name + " = (" + type + ") " + init + ";\n");
41 static void call (string type, string name)
43 w ("\t\treceive_" + type + " (" + mode + "((" + type + ") " + name + "));\n");
46 static void generate_emision ()
48 foreach (string type in types){
49 w ("\tstatic void probe_" + type + "()\n\t{\n");
50 var (type, "zero", "0");
51 var (type, "min", type + ".MinValue");
52 var (type, "max", type + ".MaxValue");
53 wl ("");
55 wl ("\t\tConsole.WriteLine (\"Testing: " + type + "\");\n");
56 foreach (string t in types){
57 wl ("\t\tConsole.WriteLine (\" arg: " + t + " (" + type + ")\");\n");
58 call (t, "zero");
59 call (t, "min");
60 call (t, "max");
63 w ("\t}\n\n");
67 static void generate_main ()
69 wl ("\tpublic static void Main ()\n\t{");
71 foreach (string t in types){
72 w ("\t\tprobe_" + t + " ();\n");
74 wl ("\t}");
77 public static void Main (string [] args)
79 foreach (string arg in args){
80 if (arg == "-h" || arg == "--help"){
81 Console.WriteLine ("-h, --help Shows help");
82 Console.WriteLine ("-c, --checked Generate checked contexts");
83 return;
85 if (arg == "--checked" || arg == "-c"){
86 mode = "checked";
87 continue;
90 wl ("using System;\nclass Test {\n");
92 generate_receptors ();
93 generate_emision ();
95 generate_main ();
97 wl ("}\n");