24-imports.ha (2254B)
1 use rt::{compile, exited, EXIT_SUCCESS}; 2 use testmod; 3 4 fn _enum() void = { 5 assert(testmod::other::EIGHT == 8); 6 assert(testmod::char_enum::ONE == 1); 7 }; 8 9 fn accept() void = { 10 assert(compile(" 11 use testmod; 12 export fn main() void = static assert(testmod::val == 42); 13 ") as exited == EXIT_SUCCESS); 14 assert(compile(" 15 use testmod; 16 use alias = testmod; 17 export fn main() void = static assert(testmod::val == alias::val); 18 ") as exited == EXIT_SUCCESS); 19 assert(compile(" 20 use testmod; 21 use testmod::{val, val2}; 22 export fn main() void = static assert( 23 testmod::val == val && testmod::val2 == val2 24 ); 25 ") as exited == EXIT_SUCCESS); 26 assert(compile(" 27 use testmod; 28 use testmod::*; 29 export fn main() void = static assert( 30 testmod::val == val && testmod::val2 == val2 31 ); 32 ") as exited == EXIT_SUCCESS); 33 assert(compile(" 34 use testmod; 35 use testmod::{alias = val, val2}; 36 export fn main() void = static assert( 37 testmod::val == alias && testmod::val2 == val2 38 ); 39 ") as exited == EXIT_SUCCESS); 40 assert(compile(" 41 use testmod; 42 use modalias = testmod::{valalias = val, val2}; 43 export fn main() void = static assert( 44 testmod::val == modalias::valalias && testmod::val2 == modalias::val2 45 ); 46 ") as exited == EXIT_SUCCESS); 47 }; 48 49 fn reject() void = { 50 assert(compile(" 51 use wrong; 52 export fn main() void = { testmod::val }; 53 ") as exited != EXIT_SUCCESS); 54 assert(compile(" 55 use testmod::{val}; 56 export fn main() void = static assert( 57 testmod::val == 42 58 ); 59 ") as exited != EXIT_SUCCESS); 60 assert(compile(" 61 use testmod::{val}; 62 export fn main() void = static assert( 63 val2 == 90 64 ); 65 ") as exited != EXIT_SUCCESS); 66 assert(compile(" 67 use testmod; 68 use test = testmod::*; 69 export fn main() void = void; 70 ") as exited != EXIT_SUCCESS); 71 assert(compile(" 72 use testmod; 73 use testmod*; 74 export fn main() void = void; 75 ") as exited != EXIT_SUCCESS); 76 assert(compile(" 77 use testmod::{alias = val, val2}; 78 export fn main() void = static assert(val == 42); 79 ") as exited != EXIT_SUCCESS); 80 assert(compile(" 81 use modalias = testmod::{valalias = val, val2}; 82 export fn main() void = static assert(valalias == 42); 83 ") as exited != EXIT_SUCCESS); 84 }; 85 86 87 export fn main() void = { 88 _enum(); 89 accept(); 90 reject(); 91 };