From a363718f93aef12c21a511c3ee6939d7a6bc7f06 Mon Sep 17 00:00:00 2001 From: mgtm98 Date: Wed, 2 Oct 2024 12:24:37 +0300 Subject: [PATCH] Adding a test for the expr types --- jac/jaclang/tests/fixtures/expr_type.jac | 8 ++++++++ jac/jaclang/tests/test_cli.py | 17 +++++++++++++++++ 2 files changed, 25 insertions(+) create mode 100644 jac/jaclang/tests/fixtures/expr_type.jac diff --git a/jac/jaclang/tests/fixtures/expr_type.jac b/jac/jaclang/tests/fixtures/expr_type.jac new file mode 100644 index 000000000..af9af9aa2 --- /dev/null +++ b/jac/jaclang/tests/fixtures/expr_type.jac @@ -0,0 +1,8 @@ +with entry { + a = 4; + b = 7; + c = a + b; + d = a + b + c; + + h = float(a); +} \ No newline at end of file diff --git a/jac/jaclang/tests/test_cli.py b/jac/jaclang/tests/test_cli.py index 91c779a34..669ff2e48 100644 --- a/jac/jaclang/tests/test_cli.py +++ b/jac/jaclang/tests/test_cli.py @@ -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()