Skip to content

Commit

Permalink
Registry pass test change to fail if any registry.pikle file is gener…
Browse files Browse the repository at this point in the history
…ated
  • Loading branch information
Jayanaka-98 committed Oct 30, 2024
1 parent 76e6803 commit 889db8e
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 17 deletions.
12 changes: 2 additions & 10 deletions jac/jaclang/compiler/passes/main/tests/test_registry_pass.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
class RegistryPassTests(TestCase):
"""Test pass module."""

# Need change
def setUp(self) -> None:
"""Set up test."""
return super().setUp()
Expand All @@ -18,7 +19,7 @@ def test_registry_pass(self) -> None:
"""Basic test for pass."""
state = jac_file_to_pass(self.fixture_abs_path("registry.jac"), RegistryPass)
self.assertFalse(state.errors_had)
self.assertTrue(
self.assertFalse(
os.path.exists(
os.path.join(
os.path.dirname(self.fixture_abs_path("registry.jac")),
Expand All @@ -27,13 +28,4 @@ def test_registry_pass(self) -> None:
)
)
)
self.assertTrue(
os.path.exists(
os.path.join(
os.path.dirname(self.fixture_abs_path("registry.jac")),
"__jac_gen__",
"fstrings.registry.pkl",
)
)
)
self.assertIn("109", str(state.ir.to_dict()))
13 changes: 6 additions & 7 deletions jac/jaclang/tests/fixtures/registry.jac
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,12 @@ Personality {
EXTROVERT: 'Person who is outgoing and socially confident'
}

glob personality_examples: 'Personality Information of Famous People': dict[str, Personality|None] = {
glob personality_examples: 'Personality Information of Famous People': dict[str, Personality | None] = {
'Albert Einstein': Personality.INTROVERT,
'Barack Obama': Personality.EXTROVERT
};

glob person_value : list[tuple[dict[str, Personality], int]] =(-90);
glob person_value: list[tuple[dict[str, Personality], int]] = (-90);

can 'GenAI ability'
genai_ability(x: 'Something': str) -> 'Something Else': str by llm();
Expand All @@ -34,9 +34,9 @@ normal_ability(x: 'Something': str) -> 'Something Else': str {
}

can foo() {
person_value=22;
person_value = 22;
can bar() {
person_value=33;
person_value = 33;
}
}
with entry {
Expand All @@ -45,12 +45,11 @@ with entry {
einstein = Person('Albert Einstein', einstein_age);
}

import from jaclang.runtimelib.machine {JacMachine}
import from jaclang.compiler.semtable {SemRegistry, SemScope, SemInfo}
import from jaclang.runtimelib.machine { JacMachine }

with entry {
registry = JacMachine.get().jac_program.SemIR;
# print (registry);

print(len(registry.registry));
print(len(list(registry.registry.items())[0][1]));
print(list(registry.registry.items())[3][0].scope);
Expand Down

0 comments on commit 889db8e

Please sign in to comment.