-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
39a3426
commit 8a1f66d
Showing
3 changed files
with
46 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
import json | ||
import os | ||
import sys | ||
from importlib.machinery import SourceFileLoader | ||
from importlib.util import module_from_spec | ||
from importlib.util import spec_from_file_location | ||
from textwrap import dedent | ||
|
||
import pytest | ||
|
||
sys.path.insert(0, os.path.abspath(os.path.join(os.path.dirname(os.path.abspath(__file__)), '../'))) | ||
from ahk_ast import parser | ||
from ahk_ast.model import * | ||
from ahk_ast.tokenizer import tokenize | ||
|
||
tests_path = os.path.abspath(os.path.join(os.path.dirname(os.path.abspath(__file__)), 'examples')) | ||
|
||
|
||
@pytest.mark.parametrize('op', argvalues=[('+',), ('-',), ('*',), ('/',), ('//',), ('**',)]) | ||
def test_math_binop(op): | ||
op = op[0] | ||
script = dedent( | ||
f"""\ | ||
a := 1 {op} 1 | ||
""" | ||
) | ||
expected = Program( | ||
Assignment( | ||
location=Identifier(name='a'), | ||
value=BinOp(left=Integer(value=1), right=Integer(value=1), op=op), | ||
) | ||
) | ||
model = parser.parse(script) | ||
assert model == expected |