Mercurial > projects > ldc
annotate test/v2d.d @ 131:5825d48b27d1 trunk
[svn r135] * Merged DMD 1.025 *
* Fixed a minor linking order mishap *
* Added an command line option -annotate *
* Fixed some problems with running optimizations *
* Added std.stdio and dependencies to lphobos (still not 100% working, but compiles and links) *
* Fixed problems with passing aggregate types to variadic functions *
* Added initial code towards full GC support, currently based on malloc and friends, not all the runtime calls the GC yet for memory *
* Fixed problems with resolving nested function context pointers for some heavily nested cases *
* Redid function argument passing + other minor code cleanups, still lots to do on this end... *
author | lindquist |
---|---|
date | Fri, 04 Jan 2008 01:38:42 +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 } |