Mercurial > projects > ldc
annotate tests/mini/foreach8.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 | |
children | 30b42a283c8e |
rev | line source |
---|---|
lindquist@341 | 1 module tangotests.foreach1; |
lindquist@341 | 2 |
lindquist@341 | 3 extern(C) int printf(char*, ...); |
lindquist@341 | 4 |
lindquist@341 | 5 int main(){ |
lindquist@341 | 6 dchar[] array="\u2260"; |
lindquist@341 | 7 int test=0; |
lindquist@341 | 8 int count=0; |
lindquist@341 | 9 assert(count==0); |
lindquist@341 | 10 foreach(int index, char obj; array){ |
lindquist@341 | 11 printf("%d\n", obj); |
lindquist@341 | 12 test+=obj; |
lindquist@341 | 13 count++; |
lindquist@341 | 14 } |
lindquist@341 | 15 assert(count==3); |
lindquist@341 | 16 assert(test==0x20b); |
lindquist@341 | 17 return 0; |
lindquist@341 | 18 } |