Skip to content

Commit

Permalink
Adding a test for the expr types
Browse files Browse the repository at this point in the history
  • Loading branch information
mgtm98 committed Oct 2, 2024
1 parent 135688b commit a363718
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 0 deletions.
8 changes: 8 additions & 0 deletions jac/jaclang/tests/fixtures/expr_type.jac
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
with entry {
a = 4;
b = 7;
c = a + b;
d = a + b + c;

h = float(a);
}
17 changes: 17 additions & 0 deletions jac/jaclang/tests/test_cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -217,6 +217,23 @@ def test_builtins_loading(self) -> None:
r"13\:12 \- 13\:18.*Name - append - .*SymbolPath: builtins_test.builtins.list.append",
)

def test_expr_types(self) -> None:
"""Testing for print AstTool."""
captured_output = io.StringIO()
sys.stdout = captured_output

cli.tool("ir", ["ast", f"{self.fixture_abs_path('expr_type.jac')}"])

sys.stdout = sys.__stdout__
stdout_value = captured_output.getvalue()

self.assertRegex(
stdout_value, r"4\:9 \- 4\:14.*BinaryExpr \- Type\: builtins.int"
)
self.assertRegex(
stdout_value, r"7\:9 \- 7\:17.*FuncCall \- Type\: builtins.float"
)

def test_ast_dotgen(self) -> None:
"""Testing for print AstTool."""
captured_output = io.StringIO()
Expand Down

0 comments on commit a363718

Please sign in to comment.