[artiq] add tests for module support

This commit is contained in:
abdul124 2025-01-16 12:42:13 +08:00
parent 14e80dfab7
commit 879b063968
4 changed files with 46 additions and 12 deletions

View File

@ -0,0 +1,29 @@
from min_artiq import *
import tests.string_attribute_issue337 as issue337
import tests.support_class_attr_issue102 as issue102
import tests.global_variables as global_variables
@nac3
class TestModuleSupport:
core: KernelInvariant[Core]
def __init__(self):
self.core = Core()
@kernel
def run(self):
# Accessing classes
issue337.Demo().run()
obj = issue102.Demo()
obj.attr3 = 3
# Calling functions
global_variables.inc_X()
global_variables.display_X()
# Updating global variables
global_variables.X = 9
global_variables.display_X()
if __name__ == "__main__":
TestModuleSupport().run()

View File

@ -0,0 +1,14 @@
from min_artiq import *
from numpy import int32
X: Kernel[int32] = 1
@rpc
def display_X():
print_int32(X)
@kernel
def inc_X():
global X
X += 1

View File

@ -1,16 +1,13 @@
from min_artiq import *
from numpy import int32
@nac3
class Demo:
core: KernelInvariant[Core]
attr1: KernelInvariant[str]
attr2: KernelInvariant[int32]
attr1: Kernel[str]
attr2: Kernel[int32]
@kernel
def __init__(self):
self.core = Core()
self.attr2 = 32
self.attr1 = "SAMPLE"
@ -19,6 +16,3 @@ class Demo:
print_int32(self.attr2)
self.attr1
if __name__ == "__main__":
Demo().run()

View File

@ -1,7 +1,6 @@
from min_artiq import *
from numpy import int32
@nac3
class Demo:
attr1: KernelInvariant[int32] = 2
@ -12,7 +11,6 @@ class Demo:
def __init__(self):
self.attr3 = 8
@nac3
class NAC3Devices:
core: KernelInvariant[Core]
@ -35,6 +33,5 @@ class NAC3Devices:
NAC3Devices.attr4 # Attributes accessible for classes without __init__
if __name__ == "__main__":
NAC3Devices().run()