-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest_smart_split_nesting.py
More file actions
48 lines (40 loc) · 1.73 KB
/
test_smart_split_nesting.py
File metadata and controls
48 lines (40 loc) · 1.73 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
#!/usr/bin/env python3
from trekbasicpy.basic_utils import smart_split
def test_smart_split_nesting():
"""Test smart_split with nested parentheses"""
print("Testing smart_split with nested parentheses...")
print("=" * 60)
# Test case from user: DIM X( MAX(MAX(Z,A), A ))
test1 = "X( MAX(MAX(Z,A), A )), Y(3), Z(A+B)"
result1 = smart_split(test1, enquote="(", dequote=")", split_char=",")
print(f"Test 1: {test1}")
print(f"Result: {result1}")
print(f"Expected: ['X( MAX(MAX(Z,A), A ))', ' Y(3)', ' Z(A+B)'] (3 parts)")
print(f"Actual length: {len(result1)}")
print()
# Test case with simple parentheses (should still work)
test2 = "A(3,4), B(5,6), C(7)"
result2 = smart_split(test2, enquote="(", dequote=")", split_char=",")
print(f"Test 2: {test2}")
print(f"Result: {result2}")
print(f"Expected: ['A(3,4)', ' B(5,6)', ' C(7)'] (3 parts)")
print(f"Actual length: {len(result2)}")
print()
# Test case with string quotes (should work as before)
test3 = 'PRINT"Hello, World": PRINT"Goodbye"'
result3 = smart_split(test3, enquote='"', dequote='"', split_char=":")
print(f"Test 3: {test3}")
print(f"Result: {result3}")
print(f"Expected: ['PRINT\"Hello, World\"', ' PRINT\"Goodbye\"'] (2 parts)")
print(f"Actual length: {len(result3)}")
print()
# Test case with deeply nested parentheses
test4 = "A(B(C(D,E),F),G), H(I)"
result4 = smart_split(test4, enquote="(", dequote=")", split_char=",")
print(f"Test 4: {test4}")
print(f"Result: {result4}")
print(f"Expected: ['A(B(C(D,E),F),G)', ' H(I)'] (2 parts)")
print(f"Actual length: {len(result4)}")
print()
if __name__ == "__main__":
test_smart_split_nesting()