1 #!/usr/local/bin/rune -x -d
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) {
30 main(int ac, char **av)
36 stdout->show("count 0-9:");
37 for (i = 0; i < 10; ++i) {
43 test = 23; # runs int->test cast
44 stdout->show("test expect 11:", test.a, "and 46:", test.b);
45 stdout->show("test expect 57:", (int)test);
46 test = (23); # runs int->test cast
47 stdout->show("test expect 11:", test.a, "and 46:", test.b);
48 stdout->show("test expect 57:", (int)test);
49 test = (a:23); # does not run int->test cast
50 stdout->show("test expect 23:", test.a, "and 0:", test.b);
51 stdout->show("test expect 23:", (int)test);
53 stdout->show("nocast expect 23:", nocast.a, "and 0:", nocast.b);
60 stdout->show("test expect 1: ", (double)b8);
61 stdout->show("test expect 5: ", (int32_t)d);
64 # These casts depend on a feature in the Rune resolver
65 # which modifies the type of constants to match operators.
68 int8_t b8 = b8 + 1; # autocast int32_t -> int8_t
69 int8_t b9 = b9 + 127; # autocast int32_t -> int8_t
70 int32_t b10 = b10 + 0x7FFFFFFF;
71 # this should have a resolver failure if we uncomment it
72 # int32_t b11 = b11 + 0x08FFFFFFFL;
73 stdout->show("test b8 1: ", b8);
74 stdout->show("test 98 127: ", b9);
77 float b8 = b8 + 1.0; # autocast double -> float
78 double b10 = b10 + 1.2;
79 # this should have a resolver failure if we uncomment it
80 #float b9 = b9 + 1.1; # autocast double -> float
81 stdout->show("test b8 1.0: ", b8);
82 stdout->show("test b10 1.2: ", b10);