Rune - Fix array passing, optimize constant array indices
[rune.git] / tests / loop100m.d
1 #!/usr/local/bin/rune -x
2 #
3 #       Demonstrate a loop.
4
5 library import "sys";
6
7 # The interpreter should be able to optimize out the call to fubar().
8 #
9 # Test it by replacing fubar(loops) with 100000000 and seeing if
10 # it takes the same amount of time.
11 #
12 pure
13 long
14 fubar(long value)
15 {
16         return (value);
17 }
18
19 # The interpreter should be able to optimize out constant values from
20 # variables.
21 #
22 # Test it by replacing fubar(loops) with loops or (loops) and seeing
23 # if it takes the same amount of time.
24 #
25 const long loops = 100000000;
26
27 int
28 main(int ac, char **av)
29 {
30         long i;
31
32         for (i = 0; i < fubar(loops); ++i)
33                 ;
34 #       for (i = 0; i < 100000000L; ++i)
35 #               ;
36 }