- We need to invalidate the selection area when we replace the
[mono-project.git] / mono / tests / array.cs
blobb0e9d47ff1e778425504e95dfd9e0c8307341fd6
1 using System;
2 using System.Runtime.InteropServices;
4 public class Test {
6 static void puts (string s)
8 Console.WriteLine (s);
11 public static int jagged ()
13 int[][] j2 = new int [3][];
15 // does not work
16 // j2 [0] = new int[] {1, 2, 3};
17 // j2 [1] = new int[] {1, 2, 3, 4, 5, 6};
18 // j2 [2] = new int[] {1, 2, 3, 4, 5, 6, 7, 8, 9};
20 j2 [0] = new int[3];
21 j2 [1] = new int[6];
22 j2 [2] = new int[9];
24 for (int i = 0; i < j2.Length; i++)
25 for (int j = 0; j < (i+1)*3; j++)
26 j2 [i][j] = j;
28 for (int i = 0; i < j2.Length; i++)
29 for (int j = 0; j < (i+1)*3; j++)
30 if (j2 [i][j] != j)
31 return 1;
32 return 0;
35 public static int stest ()
37 string[] sa = new string[32];
39 sa [0] = "This";
40 sa [2] = "is";
41 sa [10] = "a";
42 sa [20] = "stupid";
43 sa [21] = "Test";
45 for (int i = 0; i < sa.Length; i++){
46 if (sa [i] != null)
47 puts (sa [i]);
50 return 0;
53 public static int atest2 ()
55 int[,] ia = new int[32,32];
57 for (int i = 0; i <ia.GetLength (0); i++)
58 ia [i,i] = i*i;
60 for (int i = 0; i <ia.GetLength (0); i++)
61 if (ia [i,i] != i*i)
62 return 1;
64 for (int i = 0; i <ia.GetLength (0); i++)
65 ia.SetValue (i*i*i, i, i);
67 for (int i = 0; i <ia.GetLength (0); i++)
68 if ((int)ia.GetValue (i, i) != i*i*i)
69 return 1;
71 return 0;
74 public static int atest ()
76 int[] ia = new int[32];
78 for (int i = 0; i <ia.Length; i++)
79 ia [i] = i*i;
81 for (int i = 0; i <ia.Length; i++)
82 if (ia [i] != i*i)
83 return 1;
85 if (ia.Rank != 1)
86 return 2;
88 if (ia.GetValue (2) == null)
89 return 3;
91 for (int i = 0; i <ia.Length; i++)
92 ia.SetValue (i*i*i, i);
94 for (int i = 0; i <ia.Length; i++)
95 if ((int)ia.GetValue (i) != i*i*i){
96 puts ("Crap: " + i + " " + (int) ia.GetValue (i) );
98 return 4;
101 return 0;
105 public static int Main () {
106 puts ("a");
107 if (atest () != 0)
108 return atest ();
109 puts ("b");
110 if (atest2 () != 0)
111 return 1;
112 puts ("c");
113 if (atest2 () != 0)
114 return 1;
115 puts ("d");
116 if (stest () != 0)
117 return 1;
118 puts ("e");
119 if (jagged () != 0)
120 return 1;
123 return 0;