-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathOperators.pi
More file actions
40 lines (34 loc) · 835 Bytes
/
Operators.pi
File metadata and controls
40 lines (34 loc) · 835 Bytes
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
// Test file for Pi language operators
// First clear any leftover stack items
clear
// Test basic arithmetic operators
1 2 + 3 == assert
5 2 - 3 == assert
3 4 * 12 == assert
10 2 div 5 == assert
// mod not available in Pi yet
// 10 3 mod 1 == assert
// Test comparison operators
5 5 == assert
5 6 == not assert
// These operators might not be implemented yet
// 5 6 < assert
// 6 5 > assert
// 5 5 <= assert
// 5 5 >= assert
// Use != operator if available, otherwise just invert ==
5 6 == not assert
// Test logical operators
true true and assert
true false or assert
false not assert
// Test stack operations
1 2 3
depth 3 == assert
clear
depth 0 == assert
// Test more complex expressions
1 2 + 3 * 4 div // Should be (1+2)*3/4 = 9/4 = 2.25, but integer division gives 2
2 == assert
// Make sure we clean up at the end
clear