-
Notifications
You must be signed in to change notification settings - Fork 659
/
Copy pathArrayTest.cs
204 lines (183 loc) · 6.22 KB
/
ArrayTest.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
using ILRuntimeTest;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace TestCases
{
public class ArrayTest
{
public int val = 123;
public static void ArrayTest01()
{
var a = new int[0][]; //Assets/ILRuntime/Generated/System_Int32_Binding_Array.cs(26,78): error CS0178: Invalid rank specifier, expecting `,' or `]'
var b = new int[0][][]; //Assets/ILRuntime/Generated/System_Int32[]_Binding_Array.cs
}
public static void ArrayTest02()
{
int[] aa = new int[] { 1, 2, 3, 4, 5 };
uint index = 2;
int i = 10;
aa[index] = 20;
i = aa[index];
Console.WriteLine("i {0}", i);
}
public static void ArrayTest03()
{
double[] propValueArr = new double[] { 0.5, 0.5 };
Console.WriteLine("{0} ", propValueArr[0]);
//ArrayTest03Sub(propValueArr, 1, new ArrayTest03Cls(), 14);
}
public static void ArrayTestLong()
{
double[] propValueArr = new double[2];
propValueArr[0] = 0.5;
propValueArr[1] = 0.5;
Console.WriteLine("{0} ", propValueArr[0]);
}
class ArrayTest03Cls
{
public float[] levelParam = new float[] { 0.5f, 0.5f };
}
static void ArrayTest03Sub(double[] propValurArr, int i, ArrayTest03Cls conf, int skillLevel)
{
propValurArr[i] += conf.levelParam[i] * (skillLevel - 1);
Console.WriteLine("{0} buff0 {1} {2} {3} {4} {5} {6}", 61901, skillLevel, 0, 0, propValurArr[i], conf.levelParam[i], conf.levelParam[i] * (skillLevel - 1));
}
public static void ArrayTest04()
{
var t = typeof(ArrayTest);
var arr = Array.CreateInstance(t, 10);
for (int i = 0; i < 10; i++)
{
arr.SetValue(Activator.CreateInstance(t), i);
}
Console.WriteLine(arr.Length);
ArrayTest[] arr2 = arr as ArrayTest[];
for (int i = 0; i < 10; i++)
{
Console.WriteLine(arr2[i].val);
}
}
public static void ArrayTest05()
{
ILRuntimeTest.TestFramework.TestVector3[] arr = new ILRuntimeTest.TestFramework.TestVector3[] { ILRuntimeTest.TestFramework.TestVector3.One, ILRuntimeTest.TestFramework.TestVector3.One2 };
Console.WriteLine(arr[0].ToString());
}
public static void ArrayTest06()
{
int[,,] pos = new int[,,] { { { 1, 2, 3 }, { 3, 4, 5 } }, { { 1, 3, 3 }, { 2, 3, 4 } } };
Console.WriteLine(pos[0, 1, 1]);
}
[ILRuntimeTest(IsToDo = true)]
public static void ArrayTest07()
{
int[,] a = new int[2, 3];
a[0, 0] = 1; //ios il2cpp ipad test: invocation exception
a[0, 0].ToString(); //unityeditor crash on windows pc test
}
public static void ArrayTest08()
{
GenericArrayTest<ArrayTest> cls = new ArrayTest.GenericArrayTest<ArrayTest>();
cls.Init();
Console.WriteLine(cls.arr.Length);
if (cls.arr.Length != 10)
throw new Exception();
}
public static void ArrayBindTest()
{
ILRuntimeTest.TestFramework.TestClass4 cls = new ILRuntimeTest.TestFramework.TestClass4();
cls.TestArrayOut(out var arr);
Console.WriteLine(arr.Length);
}
static int[] sa = new int[] { 1, 2, 3, 4, 5 };
public static void ArrayTest09()
{
uint index = 2;
int i = sa[index];
Console.WriteLine(i);
}
public static void ArrayTest10()
{
int[] aa = new int[] { 1, 2, 3, 4, 5 };
int index = 2;
int i = aa[index];
Console.WriteLine(i);
}
public static void ArrayTest11()
{
ushort[] aa = new ushort[] { 1, 2, 65535, 4, 5 };
uint index = 2;
ushort i = aa[index];
Console.WriteLine(i);
}
public static void ArrayTest12()
{
long[] aa = new long[3] { -1, 54 , 43742424878678 };
uint index = 2;
long i = aa[index];
Console.WriteLine(i);
}
public static void ArrayTest13()
{
byte[] aa = new byte[] { 7, 16, 32 };
uint index = 2;
byte i = aa[index];
Console.WriteLine(i);
}
public static void ArrayTest14()
{
char[] aa = new char[] {'a', 'b', 'c', 'd'}; //data is error ; ldtoken
uint index = 2;
char i = aa[index]; //元数据
Console.WriteLine(i);
}
public static void ArrayTest15()
{
float[] aa = new float[] { 1.5f, float.MaxValue, 10.0f, 0.54587122115f };
uint index = 3;
float i = aa[index];
Console.WriteLine(i);
}
public static void ArrayTest16()
{
double[] aa = new double[] { 1.5f, float.MaxValue, 10.0f, 0.54587122115f };
uint index = 3;
double i = aa[index];
Console.WriteLine(i);
}
class GenericArrayTest<T>
{
public T[][] arr;
public void Init()
{
arr = new T[10][];
for(int i = 0; i < 10; i++)
{
arr[i] = new T[20];
}
}
}
public static void ArrayTest17() //error
{
TestGenericDelegate<bool>[] array = new TestGenericDelegate<bool>[] { Callback1, Callback2, Callback3 };
foreach (var item in array)
{
item?.Invoke(true);
}
}
public delegate void TestGenericDelegate<T>(T t);
static void Callback1(bool b)
{
Console.WriteLine("Callback1");
}
static void Callback2(bool b)
{
Console.WriteLine("Callback2");
}
static void Callback3(bool b)
{
Console.WriteLine("Callback3");
}
}
}