comparison tests/mini/staticarrays.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/staticarrays.d@385a18242485
children
comparison
equal deleted inserted replaced
340:351c0077d0b3 341:1bb99290e03a
1 extern(C) int printf(char*, ...);
2
3 void numbers()
4 {
5 bool[8] bools;
6 char[8] chars;
7 byte[8] bytes;
8 short[8] shorts;
9 int[8] ints;
10 long[8] longs;
11 float[8] floats;
12 double[8] doubles;
13 real[8] reals;
14 {
15 bools[7] = true;
16 floats[7] = 3.14159265;
17 {
18 printf("bools[0] = %d, bools[7] = %d\n", bools[0], bools[7]);
19 printf("floats[0] = %f, floats[7] = %f\n", floats[0], floats[7]);
20 }
21 }
22 }
23
24 struct S
25 {
26 int i = 42;
27 void print()
28 {
29 printf("S.i = %d\n", i);
30 }
31 }
32
33 class C
34 {
35 int i;
36 this()
37 {
38 i = 3;
39 }
40 void print()
41 {
42 printf("C.i = %d\n", i);
43 }
44 }
45
46 void refs()
47 {
48 void*[5] voids;
49 S*[5] structs;
50 C[5] classes;
51
52 {
53 voids[0] = cast(void*)0xA;
54 printf("void* = %p\n", voids[0]);
55 }
56 {
57 structs[0] = new S;
58 structs[0].print();
59 delete structs[0];
60 }
61 {
62 classes[0] = new C;
63 classes[0].print();
64 delete classes[0];
65 }
66 }
67
68 void vals()
69 {
70 S[5] structs;
71 }
72
73 void main()
74 {
75 numbers();
76 refs();
77 vals();
78 }