aded @@ for keyword swapping
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user