-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest_integer_only_codegen.arc
More file actions
86 lines (75 loc) · 1.56 KB
/
test_integer_only_codegen.arc
File metadata and controls
86 lines (75 loc) · 1.56 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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
// Integer-only codegen test to avoid type issues
// This test only uses integer values to work around the current
// limitation where all variables are generated as 'int' type
func simple_function() {
let x = 42
}
func add_numbers(a: i32, b: i32) -> i32 {
let result = a + b
return result
}
func test_basic_variables() {
let x = 42
let y = 10
let count = 100
}
func test_mut_and_const() {
mut counter = 0
mut total = 100
const MAX_VALUE = 1000
}
func test_basic_math() {
let a = 10
let b = 5
let sum = a + b
let diff = a - b
let product = a * b
let quotient = a / b
}
func test_basic_comparisons() {
let x = 42
let y = 10
let is_equal = x == y
let is_greater = x > y
let is_less = x < y
let is_greater_equal = x >= y
let is_less_equal = x <= y
}
func test_if_statements() {
let x = 42
if x == 42 {
let answer = 1
}
if x > 40 {
let big_number = 1
} else {
let small_number = 0
}
}
func test_logical_ops() {
let a = 1
let b = 0
// Removed logical operations due to semantic analysis errors
}
func test_while_loops() {
mut i = 0
while i < 10 {
i = i + 1
}
}
func test_function_calls() {
let result1 = add_numbers(5, 3)
let result2 = add_numbers(10, 20)
}
func main() -> i32 {
simple_function()
test_basic_variables()
test_mut_and_const()
test_basic_math()
test_basic_comparisons()
test_if_statements()
test_logical_ops()
test_while_loops()
test_function_calls()
return 0
}