Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mono/mono.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMiguel de Icaza <miguel@gnome.org>2001-09-27 17:39:40 +0400
committerMiguel de Icaza <miguel@gnome.org>2001-09-27 17:39:40 +0400
commit80438b4f08413d65135a74dc5d34494ee893563a (patch)
tree5fb2eb0204d9af4c23252f3e3bc80af1a960e4b2 /mcs/tests/gen-cast-test.cs
parent281ba72b2b761b0ac6991ad9a39145032971bbde (diff)
Add more tests to compare our cast code
svn path=/trunk/mcs/; revision=1002
Diffstat (limited to 'mcs/tests/gen-cast-test.cs')
-rwxr-xr-xmcs/tests/gen-cast-test.cs86
1 files changed, 86 insertions, 0 deletions
diff --git a/mcs/tests/gen-cast-test.cs b/mcs/tests/gen-cast-test.cs
new file mode 100755
index 00000000000..a7525928861
--- /dev/null
+++ b/mcs/tests/gen-cast-test.cs
@@ -0,0 +1,86 @@
+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 var (string type, string name, string init)
+ {
+ w ("\t\t" + type + " " + name + " = (" + type + ") " + init + ";\n");
+ }
+
+ static void call (string type, string name)
+ {
+ w ("\t\treceive_" + type + " (unchecked ((" + type + ") " + name + "));\n");
+ }
+
+ static void generate_emision ()
+ {
+ foreach (string type in types){
+ w ("\tstatic void probe_" + type + "()\n\t{\n");
+ var (type, "zero", "0");
+ var (type, "min", type + ".MinValue");
+ var (type, "max", type + ".MaxValue");
+ wl ("");
+
+ wl ("\t\tConsole.WriteLine (\"Testing: " + type + "\");\n");
+ foreach (string t in types){
+ wl ("\t\tConsole.WriteLine (\" arg: " + t + "\");\n");
+ call (t, "zero");
+ call (t, "min");
+ call (t, "max");
+ }
+
+ 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 ()
+ {
+ wl ("using System;\nclass Test {\n");
+
+ generate_receptors ();
+ generate_emision ();
+
+ generate_main ();
+
+ wl ("}\n");
+ }
+}