aded @@ for keyword swapping

This commit is contained in:
2026-05-16 11:30:04 -05:00
parent 49aff518a4
commit e1176203f9
3 changed files with 78 additions and 30 deletions

View File

@@ -102,3 +102,35 @@ def test_shebang_override():
def test_shebang_default_when_absent():
assert _check_shebang("si x:\n pasar", "es") == "es"
# ---------------------------------------------------------------------------
# Postfix @@ syntax
# ---------------------------------------------------------------------------
def test_postfix_if():
out = es("x = 5\nx > 0 @@si:\n imprimir(x)")
assert "if" in out
assert "@@" not in out
def test_postfix_preserves_indentation():
src = (
"definir comprobar(x):\n"
" x > 0 @@si:\n"
" imprimir(x)\n"
" sino:\n"
" pasar\n"
)
out = es(src)
ast.parse(out) # fails if indentation is broken
def test_prefix_still_works_alongside_postfix():
src = (
"si x > 0:\n"
" imprimir(x)\n"
"y < 0 @@si:\n"
" imprimir(y)\n"
)
out = es(src)
assert out.count("if") == 2
assert "@@" not in out