comparison run/mini/staticarrays.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 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 }