-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmodule_system_test.arc
More file actions
61 lines (47 loc) · 1.32 KB
/
module_system_test.arc
File metadata and controls
61 lines (47 loc) · 1.32 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
// Comprehensive module system test
use math;
use string_utils::{length, concat};
use math::{add, PI};
// External function declaration
extern func printf(format: *i8, ...) -> i32;
func test_module_imports() {
// Test simple module import
let result = math::add(5, 3);
printf("math::add(5, 3) = %d\n", result);
// Test specific imports
let sum = add(10, 20);
printf("add(10, 20) = %d\n", sum);
// Test constant import
printf("PI = %f\n", PI);
// Test string utilities
let str = "Hello";
let len = length(str);
printf("length('%s') = %d\n", str, len);
}
// Inline module definition
pub mod utils {
pub func helper() -> i32 {
return 42;
}
pub const MAX_SIZE = 1024;
// Nested module
pub mod inner {
pub func nested_func() -> i32 {
return 100;
}
}
}
func test_inline_modules() {
let value = utils::helper();
printf("utils::helper() = %d\n", value);
printf("utils::MAX_SIZE = %d\n", utils::MAX_SIZE);
let nested = utils::inner::nested_func();
printf("utils::inner::nested_func() = %d\n", nested);
}
func main() -> i32 {
printf("=== Module System Test ===\n");
test_module_imports();
test_inline_modules();
printf("=== Test Complete ===\n");
return 0;
}