Skip to content

Commit d23bd71

Browse files
authored
Add test for IIFE (#3349)
## **Description**
1 parent a738207 commit d23bd71

File tree

2 files changed

+15
-0
lines changed

2 files changed

+15
-0
lines changed
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
with entry {
2+
# Test: IIFE returning a function
3+
let adder = (def make_adder(x: int) {
4+
return lambda y: int: x + y;
5+
})(10);
6+
7+
print("Test - IIFE returning function, adder(5):", adder(5));
8+
}

jac/jaclang/compiler/passes/main/tests/test_checker_pass.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -412,6 +412,13 @@ def test_cyclic_symbol(self) -> None:
412412
TypeCheckPass(ir_in=mod, prog=program)
413413
self.assertEqual(len(program.errors_had), 0)
414414

415+
def test_get_type_of_iife_expression(self) -> None:
416+
path = self.fixture_abs_path("checker_iife_expression.jac")
417+
program = JacProgram()
418+
mod = program.compile(path)
419+
TypeCheckPass(ir_in=mod, prog=program)
420+
self.assertEqual(len(program.errors_had), 0)
421+
415422
def test_param_arg_match(self) -> None:
416423
program = JacProgram()
417424
path = self.fixture_abs_path("checker_generics.jac")

0 commit comments

Comments
 (0)