annotate 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
rev   line source
lindquist@98 1 module arrays11;
lindquist@98 2
lindquist@98 3 void ints()
lindquist@98 4 {
lindquist@98 5 int[] a = [1,2,3,4,5,6];
lindquist@98 6 {assert(a == a);}
lindquist@98 7
lindquist@98 8 int[] b = [4,5,6,7,8,9];
lindquist@98 9 {assert(a != b);}
lindquist@98 10 {assert(a[3..$] == b[0..3]);}
lindquist@98 11 }
lindquist@98 12
lindquist@98 13 void floats()
lindquist@98 14 {
lindquist@98 15 float[] a = [1.0f, 2.0f, 3.0f, 4.0f];
lindquist@98 16 {assert(a == a);}
lindquist@98 17
lindquist@98 18 float[] b = [2.0f, 3.0f, 5.0f];
lindquist@98 19 {assert(a != b);}
lindquist@98 20 {assert(a[1..3] == b[0..2]);}
lindquist@98 21 }
lindquist@98 22
lindquist@98 23 struct S
lindquist@98 24 {
lindquist@98 25 int i;
lindquist@98 26 int j;
lindquist@98 27
lindquist@98 28 int opEquals(S s)
lindquist@98 29 {
lindquist@98 30 return (i == s.i) && (j == s.j);
lindquist@98 31 }
lindquist@98 32 }
lindquist@98 33
lindquist@98 34 void structs()
lindquist@98 35 {
lindquist@98 36 S[] a = [S(0,0), S(1,0), S(2,0), S(3,0)];
lindquist@98 37 {assert(a == a);}
lindquist@98 38 S[] b = [S(0,1), S(1,0), S(2,0), S(3,1)];
lindquist@98 39 {assert(a != b);}
lindquist@98 40 {assert(a[1..3] == b[1..3]);}
lindquist@98 41
lindquist@98 42 S[2] c = [S(2,0), S(3,1)];
lindquist@98 43 {assert(c == b[2..$]);}
lindquist@98 44 }
lindquist@98 45
lindquist@98 46 void main()
lindquist@98 47 {
lindquist@98 48 ints();
lindquist@98 49 floats();
lindquist@98 50 structs();
lindquist@98 51 }