-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest_final_codegen.arc
More file actions
62 lines (51 loc) · 1.22 KB
/
test_final_codegen.arc
File metadata and controls
62 lines (51 loc) · 1.22 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
62
// Comprehensive Arc codegen test with printf output
// This test exercises all working features of the Arc compiler
extern func puts(s: *i8);
func test_integer_calculations() {
let a = 15
let b = 7
let sum = a + b
let diff = a - b
let product = a * b
let quotient = a / b
// Function calls would be needed to actually print results
// For now, the calculations are performed but not displayed
}
func test_comparisons() {
let x = 20
let y = 15
let equal = x == y
let greater = x > y
let less = x < y
let greater_equal = x >= y
let less_equal = x <= y
}
func test_control_flow() {
let value = 25
if value > 20 {
let result = 1
} else {
let result = 0
}
// While loop test
mut counter = 0
while counter < 5 {
counter = counter + 1
}
}
func calculate(x: i32, y: i32) -> i32 {
let result = x * 2 + y
return result
}
func test_function_calls() {
let result1 = calculate(10, 5)
let result2 = calculate(3, 7)
let result3 = calculate(result1, result2)
}
func main() -> i32 {
test_integer_calculations()
test_comparisons()
test_control_flow()
test_function_calls()
return 0
}