Add basic test

This commit is contained in:
Siddhangana 2024-12-24 13:13:16 +08:00
parent c01087cc3c
commit 9e12ce442f
2 changed files with 38 additions and 1 deletions

View File

@ -0,0 +1,37 @@
from min_artiq import *
from numpy import int32
@nac3
class NameManglingTest:
core: KernelInvariant[Core]
__var1: int32
__var2__: int32
__: int32
def __init__(self):
self.core = Core()
self.__var1 = 42
self.__var2__ = 10
self.__ = 99
@rpc
def get_var1(self) -> int32:
return self.__var1
@rpc
def get_var2(self) -> int32:
return self.__var2__
@rpc
def get_var3(self) -> int32:
return self.__
@kernel
def run(self):
assert self.get_var1() == 42
assert self.get_var2() == 10
assert self.get_var3() == 99
if __name__ == "__main__":
NameManglingTest().run()

View File

@ -1538,7 +1538,7 @@ impl SymbolResolver for Resolver {
ctx: &mut CodeGenContext<'ctx, '_>,
_: &mut dyn CodeGenerator,
) -> Option<ValueEnum<'ctx>> {
let (resolved_id, is_dunder) = if id.to_string().starts_with("__") && !id.to_string().ends_with("__") && !id.to_string().contains('.') {
let (resolved_id, _is_dunder) = if id.to_string().starts_with("__") && !id.to_string().ends_with("__") && !id.to_string().contains('.') {
let inner_resolver = &self.0;
if let Some(class_name) = inner_resolver.get_class_name(id, &ctx.top_level.definitions.read()) {