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