Rune - Change limport mechanic
[rune.git] / tests / read.d
1 #!/usr/local/bin/rune -x
2 #
3 # Simple reading.  Test the Rune feature which allows the casting of
4 # pointers to (void *) as long as the target object does not contain
5 # any pointers or lvalues.
6 #
7
8 import "sys";
9 import <stdio>;
10
11 class MyBuf {
12         char buf[512];
13         char x[4];
14
15         # resolver should fail if the structure contains a pointer.
16         #
17         #char *y;
18 }
19
20 int
21 main(int ac, char **av)
22 {
23         MyBuf buf;
24         size_t r;
25         Fs fs;
26
27         fs.open("/usr/share/dict/words", 0, 0);
28
29         for (;;) {
30                 r = fs.read(&buf, sizeof(buf));
31                 stdio.stdout->fwrite(&buf, r);
32                 if (r <= (size_t)0)
33                         break;
34         }
35         return(0);
36 }