-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest_current_features.py
More file actions
executable file
·129 lines (107 loc) · 2.98 KB
/
test_current_features.py
File metadata and controls
executable file
·129 lines (107 loc) · 2.98 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
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
#!/usr/bin/env python3
"""
Test script to validate current Plan Language functionality
"""
import subprocess
import tempfile
import os
def test_plan(plan_code, description, should_succeed=True):
"""Test a piece of plan code"""
print(f"\n{'='*50}")
print(f"TEST: {description}")
print(f"CODE:\n{plan_code}")
print(f"{'='*50}")
# Write to temp file
with tempfile.NamedTemporaryFile(mode='w', suffix='.plan', delete=False) as f:
f.write(plan_code)
temp_file = f.name
try:
# Run the plan
result = subprocess.run(
['python3', 'plan_executor.py', temp_file],
capture_output=True,
text=True,
timeout=10
)
print(f"EXIT CODE: {result.returncode}")
if result.stdout:
print(f"OUTPUT:\n{result.stdout}")
if result.stderr:
print(f"ERROR:\n{result.stderr}")
success = result.returncode == 0
if success == should_succeed:
print("✅ PASS")
else:
print("❌ FAIL")
except subprocess.TimeoutExpired:
print("❌ TIMEOUT")
except Exception as e:
print(f"❌ EXCEPTION: {e}")
finally:
# Clean up temp file
os.unlink(temp_file)
def main():
print("🧪 Plan Language Feature Test Suite")
print("Current working directory:", os.getcwd())
# Test 1: Basic output
test_plan(
'writeln "Hello, World!"',
"Basic string output"
)
# Test 2: Numbers
test_plan(
'writeln 42\nwriteln 3.14',
"Number output"
)
# Test 3: Simple expressions
test_plan(
'writeln eval "2 + 3"',
"Expression evaluation"
)
# Test 4: Basic loop
test_plan(
'3 times { writeln "Loop iteration" }',
"Basic times loop"
)
# Test 5: Loop counter
test_plan(
'3 times { writeln times_count }',
"Loop counter access"
)
# Test 6: Basic if
test_plan(
'if true { writeln "True branch" }',
"Basic if statement"
)
# Test 7: If-else
test_plan(
'if false { writeln "False" } { writeln "True" }',
"If-else statement"
)
# Test 8: Function definition (should parse but not execute)
test_plan(
'def test#1\narg 1\nwriteln "After function"',
"Function definition parsing"
)
# Test 9: Function call (now working!)
test_plan(
'def add#2\narg 1 + arg 2\nwriteln add 5 3',
"Function call",
should_succeed=True
)
# Test 10: FizzBuzz excerpt (now working!)
test_plan(
'''def multiple#2
arg 1 % arg 2 == 0
def i#0
times_count 1
writeln multiple 6 2''',
"FizzBuzz functions",
should_succeed=True
)
print(f"\n{'='*60}")
print("TEST SUITE COMPLETE")
print("Check individual test results above")
print(f"{'='*60}")
if __name__ == "__main__":
main()