Mercurial > projects > dstress
comparison run/mini/foreach10.d @ 1628:c6ef09dfba4d
add mini test set from ldc project
author | Moritz Warning <moritzwarning@web.de> |
---|---|
date | Mon, 10 Jan 2011 19:47:18 +0100 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
1627:e1b954780837 | 1628:c6ef09dfba4d |
---|---|
1 module foreach10; | |
2 | |
3 extern(C) int printf(char*, ...); | |
4 | |
5 void main() { | |
6 char* last = null; | |
7 printf("The addresses should increment:\n"); | |
8 foreach (ref c; "bar") { | |
9 auto a = { | |
10 printf("%x '%c'\n", c, c); | |
11 return &c; | |
12 }; | |
13 auto nw = a(); | |
14 printf("ptr = %p\n", nw); | |
15 if (last != null) | |
16 assert(nw == last+1); | |
17 last = nw; | |
18 } | |
19 } |