1 #!/usr/local/bin/rune -x
8 alias stdio.File *stdout = stdio.stdout;
14 public cast Test myfunc(int x) {
15 Test v = ( x / 2, x * 2 );
19 public cast int myfunc2(Test x) {
25 main(int ac, char **av)
30 stdout->show("count 0-9:");
31 for (i = 0; i < 10; ++i) {
38 stdout->show("test expect 11:", test.a, "and 46:", test.b);
39 stdout->show("test expect 46:", (int)test);
46 stdout->show("test expect 1: ", (double)b8);
47 stdout->show("test expect 5: ", (int32_t)d);
50 # These casts depend on a feature in the Rune resolver
51 # which modifies the type of constants to match operators.
54 int8_t b8 = b8 + 1; # autocast int32_t -> int8_t
55 int8_t b9 = b9 + 127; # autocast int32_t -> int8_t
56 int32_t b10 = b10 + 0x7FFFFFFF;
57 # this should have a resolver failure if we uncomment it
58 # int32_t b11 = b11 + 0x08FFFFFFFL;
59 stdout->show("test b8 1: ", b8);
60 stdout->show("test 98 127: ", b9);
63 float b8 = b8 + 1.0; # autocast double -> float
64 double b10 = b10 + 1.2;
65 # this should have a resolver failure if we uncomment it
66 #float b9 = b9 + 1.1; # autocast double -> float
67 stdout->show("test b8 1.0: ", b8);
68 stdout->show("test b10 1.2: ", b10);