tr
This commit is contained in:
38
test_parse.py
Normal file
38
test_parse.py
Normal file
@@ -0,0 +1,38 @@
|
||||
#!/usr/bin/env python
|
||||
import sys
|
||||
sys.path.insert(0, 'src')
|
||||
|
||||
# Test parsing logic
|
||||
test_cases = [
|
||||
('2,11,20', [2, 11, 20]),
|
||||
('1 5 10', [1, 5, 10]),
|
||||
('3, 7, 14', [3, 7, 14]),
|
||||
]
|
||||
|
||||
for test_input, expected in test_cases:
|
||||
# Simulate the parsing logic
|
||||
parts = ['display-cards'] + test_input.split()
|
||||
nums = []
|
||||
tokens = []
|
||||
for tok in parts[1:]:
|
||||
if ',' in tok:
|
||||
tokens.extend(tok.split(','))
|
||||
else:
|
||||
tokens.append(tok)
|
||||
|
||||
for tok in tokens:
|
||||
tok = tok.strip()
|
||||
if tok:
|
||||
try:
|
||||
nums.append(int(tok))
|
||||
except ValueError:
|
||||
nums.append(-1)
|
||||
|
||||
status = '✓' if nums == expected else '✗'
|
||||
print(f'{status} Input: "{test_input}" -> {nums} (expected {expected})')
|
||||
|
||||
# Test with actual cards
|
||||
from tarot.tarot_api import Tarot
|
||||
print("\n✓ Parsing logic works! Now test in REPL with:")
|
||||
print(" display-cards 2,11,20")
|
||||
print(" display-cards 1 5 10")
|
||||
Reference in New Issue
Block a user