forked from M-Labs/nac3
Add basic test
This commit is contained in:
parent
c01087cc3c
commit
9e12ce442f
37
nac3artiq/demo/mangling_test.py
Normal file
37
nac3artiq/demo/mangling_test.py
Normal 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()
|
@ -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()) {
|
||||
|
Loading…
Reference in New Issue
Block a user