annotate tests/mini/assign.d @ 341:1bb99290e03a trunk

[svn r362] Started merging the old 'test' dir as well as the newer 'tangotests' dir into 'tests/mini' and 'tests/minicomplex'.
author lindquist
date Sun, 13 Jul 2008 02:51:19 +0200
parents test/assign.d@c53b6e3fe49a
children
rev   line source
lindquist@1 1 module assign;
lindquist@1 2
lindquist@1 3 // this is taken from std.intrinsic from gdc
lindquist@1 4
lindquist@1 5 int mybtc(uint *p, uint bitnum)
lindquist@1 6 {
lindquist@1 7 uint * q = p + (bitnum / (uint.sizeof*8));
lindquist@1 8 uint mask = 1 << (bitnum & ((uint.sizeof*8) - 1));
lindquist@1 9 int result = *q & mask;
lindquist@1 10 *q ^= mask;
lindquist@1 11 return result ? -1 : 0;
lindquist@1 12 }
lindquist@1 13
lindquist@1 14 void main()
lindquist@1 15 {
lindquist@1 16 uint i = 0xFFFF_FFFF;
lindquist@1 17 int r = mybtc(&i, 31);
lindquist@1 18 assert(r);
lindquist@1 19 assert(i == 0x7FFF_FFFF);
lindquist@1 20 r = mybtc(&i, 31);
lindquist@1 21 assert(!r);
lindquist@1 22 assert(i == 0xFFFF_FFFF);
lindquist@1 23 }