Mercurial > projects > ldc
annotate test/bug9.d @ 108:288fe1029e1f trunk
[svn r112] Fixed 'case 1,2,3:' style case statements.
Fixed a bunch of bugs with return/break/continue in loops.
Fixed support for the DMDFE hidden implicit return value variable. This can be needed for some foreach statements where the loop body is converted to a nested delegate, but also possibly returns from the function.
Added std.math to phobos.
Added AA runtime support code, done ground work for implementing AAs.
Several other bugfixes.
author | lindquist |
---|---|
date | Tue, 20 Nov 2007 05:29:20 +0100 |
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 |