Mercurial > projects > ldc
annotate test/v2d.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 | c53b6e3fe49a |
children | d9d5d59873d8 |
rev | line source |
---|---|
1 | 1 struct V2D(T) |
2 { | |
3 T x,y; | |
4 | |
5 T dot(ref V2D v) | |
6 { | |
7 return x*v.x + y*v.y; | |
8 } | |
9 | |
10 V2D opAdd(ref V2D v) | |
11 { | |
12 return V2D(x+v.x, y+v.y); | |
13 } | |
14 } | |
15 | |
16 alias V2D!(float) V2Df; | |
17 | |
18 void main() | |
19 { | |
20 printf("V2D test\n"); | |
21 auto up = V2Df(0.0f, 1.0f); | |
22 auto right = V2Df(1.0f, 0.0f); | |
23 assert(up.dot(right) == 0.0f); | |
24 auto upright = up + right; | |
25 assert(upright.x == 1.0f && upright.y == 1.0f); | |
26 auto copy = upright; | |
27 copy.x++; | |
28 assert(copy.x > upright.x); | |
29 printf(" SUCCESS\n"); | |
30 } |