Files
ldc/test/v2d.d
Tomas Lindquist Olsen 964f91b5a1 [svn r291] Fixed a bunch of the old Phobos tests to work with Tango.
Branch statements now emit a new block after it.
Fixed the _adSort runtime function had a bad signature.
Added a missing dot prefix on compiler generated string tables for string switch.
Fixed, PTRSIZE seems like it was wrong on 64bit, now it definitely gets set properly.
2008-06-16 16:01:19 +02:00

33 lines
551 B
D

extern(C) int printf(char*, ...);
struct V2D(T)
{
T x,y;
T dot(ref V2D v)
{
return x*v.x + y*v.y;
}
V2D opAdd(ref V2D v)
{
return V2D(x+v.x, y+v.y);
}
}
alias V2D!(float) V2Df;
void main()
{
printf("V2D test\n");
auto up = V2Df(0.0f, 1.0f);
auto right = V2Df(1.0f, 0.0f);
assert(up.dot(right) == 0.0f);
auto upright = up + right;
assert(upright.x == 1.0f && upright.y == 1.0f);
auto copy = upright;
copy.x++;
assert(copy.x > upright.x);
printf(" SUCCESS\n");
}