forked from M-Labs/nac3
[artiq] cleanup module functionality tests
This commit is contained in:
parent
2d275949b8
commit
f817d3347b
26
nac3artiq/demo/module.py
Normal file
26
nac3artiq/demo/module.py
Normal file
@ -0,0 +1,26 @@
|
|||||||
|
from min_artiq import *
|
||||||
|
from numpy import int32
|
||||||
|
|
||||||
|
# Global Variable Definition
|
||||||
|
X: Kernel[int32] = 1
|
||||||
|
|
||||||
|
# TopLevelFunction Defintion
|
||||||
|
@kernel
|
||||||
|
def display_X():
|
||||||
|
print_int32(X)
|
||||||
|
|
||||||
|
# TopLevel Class Definition
|
||||||
|
@nac3
|
||||||
|
class A:
|
||||||
|
@kernel
|
||||||
|
def __init__(self):
|
||||||
|
self.set_x(1)
|
||||||
|
|
||||||
|
@kernel
|
||||||
|
def set_x(self, new_val: int32):
|
||||||
|
global X
|
||||||
|
X = new_val
|
||||||
|
|
||||||
|
@kernel
|
||||||
|
def get_X(self) -> int32:
|
||||||
|
return X
|
@ -1,7 +1,5 @@
|
|||||||
from min_artiq import *
|
from min_artiq import *
|
||||||
import tests.string_attribute_issue337 as issue337
|
import module as module_definition
|
||||||
import tests.support_class_attr_issue102 as issue102
|
|
||||||
import tests.global_variables as global_variables
|
|
||||||
|
|
||||||
@nac3
|
@nac3
|
||||||
class TestModuleSupport:
|
class TestModuleSupport:
|
||||||
@ -13,17 +11,16 @@ class TestModuleSupport:
|
|||||||
@kernel
|
@kernel
|
||||||
def run(self):
|
def run(self):
|
||||||
# Accessing classes
|
# Accessing classes
|
||||||
issue337.Demo().run()
|
obj = module_definition.A()
|
||||||
obj = issue102.Demo()
|
obj.get_X()
|
||||||
obj.attr3 = 3
|
obj.set_x(2)
|
||||||
|
|
||||||
# Calling functions
|
# Calling functions
|
||||||
global_variables.inc_X()
|
module_definition.display_X()
|
||||||
global_variables.display_X()
|
|
||||||
|
|
||||||
# Updating global variables
|
# Updating global variables
|
||||||
global_variables.X = 9
|
module_definition.X = 9
|
||||||
global_variables.display_X()
|
module_definition.display_X()
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
TestModuleSupport().run()
|
TestModuleSupport().run()
|
@ -1,14 +0,0 @@
|
|||||||
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
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user