2009-03-20 Zoltan Varga <vargaz@gmail.com>
[mono.git] / mono / tests / array.cs
old mode 100755 (executable)
new mode 100644 (file)
index 0eadfd5..b0e9d47
@@ -3,10 +3,13 @@ using System.Runtime.InteropServices;
 
 public class Test {
 
-       [DllImport("cygwin1.dll", EntryPoint="puts", CharSet=CharSet.Ansi)]
-       public static extern int puts (string name);
+       static void puts (string s)
+       {
+               Console.WriteLine (s);
+       }
 
-       public static int jagged () {
+       public static int jagged ()
+       {
                int[][] j2 = new int [3][];
 
                // does not work 
@@ -29,7 +32,8 @@ public class Test {
                return 0;
        }
 
-       public static int stest () {
+       public static int stest ()
+       {
                string[] sa = new string[32];
 
                sa [0] = "This";
@@ -38,14 +42,16 @@ public class Test {
                sa [20] = "stupid";
                sa [21] = "Test";
 
-               for (int i = 0; i < sa.Length; i++)
+               for (int i = 0; i < sa.Length; i++){
                        if (sa [i] != null)
                                puts (sa [i]);
+               }
                
                return 0;
        }
        
-       public static int atest2 () {
+       public static int atest2 ()
+       {
                int[,] ia = new int[32,32];
 
                for (int i = 0; i <ia.GetLength (0); i++)
@@ -55,36 +61,64 @@ public class Test {
                        if (ia [i,i] != i*i)
                                return 1;
 
+               for (int i = 0; i <ia.GetLength (0); i++)
+                       ia.SetValue (i*i*i, i, i);
+
+               for (int i = 0; i <ia.GetLength (0); i++)
+                       if ((int)ia.GetValue (i, i) != i*i*i)
+                               return 1;
+
                return 0;
        }
        
-       public static int Main () {
+       public static int atest ()
+       {
                int[] ia = new int[32];
 
                for (int i = 0; i <ia.Length; i++)
                        ia [i] = i*i;
-
+               
                for (int i = 0; i <ia.Length; i++)
                        if (ia [i] != i*i)
                                return 1;
                
                if (ia.Rank != 1)
-                       return 1;
+                       return 2;
+
+               if (ia.GetValue (2) == null)
+                       return 3;
+
+               for (int i = 0; i <ia.Length; i++)
+                       ia.SetValue (i*i*i, i);
+
+               for (int i = 0; i <ia.Length; i++)
+                       if ((int)ia.GetValue (i) != i*i*i){
+                               puts ("Crap: " + i + " " + (int) ia.GetValue (i) );
+
+                               return 4;
+                       }
                
+               return 0;
+       }
+       
+
+       public static int Main () {
+               puts ("a");
+               if (atest () != 0)
+                       return atest ();
+               puts ("b");     
                if (atest2 () != 0)
                        return 1;
+               puts ("c");
                if (atest2 () != 0)
                        return 1;
-               
+               puts ("d");     
                if (stest () != 0)
                        return 1;
-               
+               puts ("e");     
                if (jagged () != 0)
                        return 1;
                
-
-               if (ia.GetValue (2) == null)
-                       return 1;
                
                return 0;
        }