Mercurial > projects > ldc
annotate test/bug9.d @ 203:e881c9b1c738 trunk
[svn r219] Fixed: the tango/lib/gc/basic garbage collector now compiles and links into an executable (change in tango/lib/llvmdc-posix.mak), closes #5 .
Changed: removed the crappy realloc based dynamic memory runtime and started moving over to DMD style runtime support, part of moving to real GC.
Fixed: dynamic arrays now use GC runtime for allocating memory.
Fixed: new expression now use GC for allocating memory.
Changed: revamped the dynamic array support routines related to dynamic memory.
Fixed: assertions no longer create exsessive allocas.
Changed: misc. minor cleanups.
author | lindquist |
---|---|
date | Tue, 13 May 2008 14:42:09 +0200 |
parents | 8b0e809563df |
children | d9d5d59873d8 |
rev | line source |
---|---|
40 | 1 module bug9; |
2 struct rgb | |
3 { | |
4 ubyte[3] values; | |
5 rgb average(rgb other) | |
6 { | |
7 rgb res; | |
8 foreach (id, ref v; res.values) v=(values[id]+other.values[id])/2; | |
9 return res; | |
10 } | |
11 void print() | |
12 { | |
13 printf("[%d,%d,%d]\n", values[0], values[1], values[2]); | |
14 } | |
15 } | |
16 | |
17 void main() | |
18 { | |
19 rgb a,b; | |
20 a.values[0] = 10; | |
21 a.values[1] = 20; | |
22 a.values[2] = 30; | |
23 b.values[0] = 30; | |
24 b.values[1] = 20; | |
25 b.values[2] = 10; | |
26 rgb avg = a.average(b); | |
27 avg.print(); | |
28 assert(avg.values[0] == 20); | |
29 assert(avg.values[1] == 20); | |
30 assert(avg.values[2] == 20); | |
31 } | |
32 |