annotate tests/mini/cond.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/cond.d@d9d5d59873d8
children
rev   line source
lindquist@270 1 extern(C) int printf(char*, ...);
lindquist@270 2
lindquist@1 3 version=AndAnd;
lindquist@1 4 version=OrOr;
lindquist@1 5
lindquist@1 6 version(AndAnd)
lindquist@1 7 void andand1()
lindquist@1 8 {
lindquist@1 9 int a,b;
lindquist@1 10 a = 4;
lindquist@1 11 b = 5;
lindquist@1 12 assert(a == 4);
lindquist@1 13 assert(b == 5);
lindquist@1 14 assert(a+b == 9);
lindquist@1 15 assert(a == 4 && b == 5);
lindquist@1 16 assert(a != 3 && b == 5);
lindquist@1 17 assert(a > 2);
lindquist@1 18 assert(a < 54);
lindquist@1 19 assert(a < b);
lindquist@1 20 assert(a > b-2);
lindquist@1 21
lindquist@1 22 int apb = a+b;
lindquist@1 23 int amb = a*b;
lindquist@1 24 assert(apb < amb && apb > a);
lindquist@1 25 }
lindquist@1 26
lindquist@1 27 version(OrOr)
lindquist@1 28 void oror1()
lindquist@1 29 {
lindquist@1 30 int a,b;
lindquist@1 31 a = 10;
lindquist@1 32 b = 1000;
lindquist@1 33 assert(a);
lindquist@1 34 assert(b);
lindquist@1 35 assert(a || b);
lindquist@1 36 assert(a > b || a < b);
lindquist@1 37 }
lindquist@1 38
lindquist@1 39 void main()
lindquist@1 40 {
lindquist@1 41 printf("Conditionals test\n");
lindquist@1 42 version(AndAnd) andand1();
lindquist@1 43 version(OrOr) oror1();
lindquist@1 44 printf(" SUCCESS\n");
lindquist@1 45 }