comparison tests/mini/arrays11.d @ 341:1bb99290e03a trunk

[svn r362] Started merging the old 'test' dir as well as the newer 'tangotests' dir into 'tests/mini' and 'tests/minicomplex'.
author lindquist
date Sun, 13 Jul 2008 02:51:19 +0200
parents test/arrays11.d@6789050b5ad1
children
comparison
equal deleted inserted replaced
340:351c0077d0b3 341:1bb99290e03a
1 module arrays11;
2
3 void ints()
4 {
5 int[] a = [1,2,3,4,5,6];
6 {assert(a == a);}
7
8 int[] b = [4,5,6,7,8,9];
9 {assert(a != b);}
10 {assert(a[3..$] == b[0..3]);}
11 }
12
13 void floats()
14 {
15 float[] a = [1.0f, 2.0f, 3.0f, 4.0f];
16 {assert(a == a);}
17
18 float[] b = [2.0f, 3.0f, 5.0f];
19 {assert(a != b);}
20 {assert(a[1..3] == b[0..2]);}
21 }
22
23 struct S
24 {
25 int i;
26 int j;
27
28 int opEquals(S s)
29 {
30 return (i == s.i) && (j == s.j);
31 }
32 }
33
34 void structs()
35 {
36 S[] a = [S(0,0), S(1,0), S(2,0), S(3,0)];
37 {assert(a == a);}
38 S[] b = [S(0,1), S(1,0), S(2,0), S(3,1)];
39 {assert(a != b);}
40 {assert(a[1..3] == b[1..3]);}
41
42 S[2] c = [S(2,0), S(3,1)];
43 {assert(c == b[2..$]);}
44 }
45
46 void main()
47 {
48 ints();
49 floats();
50 structs();
51 }