Mercurial > projects > dstress
comparison run/mini/arrays7.d @ 1628:c6ef09dfba4d
add mini test set from ldc project
author | Moritz Warning <moritzwarning@web.de> |
---|---|
date | Mon, 10 Jan 2011 19:47:18 +0100 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
1627:e1b954780837 | 1628:c6ef09dfba4d |
---|---|
1 module arrays7; | |
2 | |
3 extern(C) int printf(char*, ...); | |
4 | |
5 struct S | |
6 { | |
7 int i; | |
8 float f; | |
9 long l; | |
10 | |
11 void print() | |
12 { | |
13 printf("%d %f %lx\n", i, f, l); | |
14 } | |
15 } | |
16 | |
17 void main() | |
18 { | |
19 S[] arr; | |
20 S s; | |
21 assert(arr.length == 0); | |
22 arr ~= s; | |
23 assert(arr.length == 1); | |
24 arr ~= S(1,2.64,0xFFFF_FFFF_FFFF); | |
25 assert(arr.length == 2); | |
26 arr[0].print(); | |
27 arr[1].print(); | |
28 assert(arr[1].i == 1); | |
29 assert(arr[1].f > 2.63 && arr[1].f < 2.65); | |
30 assert(arr[1].l == 0xFFFF_FFFF_FFFF); | |
31 } |