forked from M-Labs/artiq
1
0
Fork 0

coredevice: Add test for recent kernel RPC fixes

This covers all three (de)serialisation fixes.
This commit is contained in:
David Nadlinger 2019-03-31 03:56:11 +01:00 committed by Sebastien Bourdeauducq
parent ff1eb4858a
commit 3e49da3d39
1 changed files with 23 additions and 2 deletions

View File

@ -61,6 +61,9 @@ class RoundtripTest(ExperimentCase):
def test_list_tuple(self): def test_list_tuple(self):
self.assertRoundtrip(([1, 2], [3, 4])) self.assertRoundtrip(([1, 2], [3, 4]))
def test_list_mixed_tuple(self):
self.assertRoundtrip([(0x12345678, [("foo", [0.0, 1.0], [0, 1])])])
class _DefaultArg(EnvExperiment): class _DefaultArg(EnvExperiment):
def build(self): def build(self):
@ -344,7 +347,25 @@ class _ListTuple(EnvExperiment):
[numpy.int32(base_b + i) for i in range(n)] [numpy.int32(base_b + i) for i in range(n)]
class _NestedTupleList(EnvExperiment):
def build(self):
self.setattr_device("core")
self.data = [(0x12345678, [("foo", [0.0, 1.0], [2, 3])]),
(0x76543210, [("bar", [4.0, 5.0], [6, 7])])]
def get_data(self) -> TList(TTuple(
[TInt32, TList(TTuple([TStr, TList(TFloat), TList(TInt32)]))])):
return self.data
@kernel
def run(self):
a = self.get_data()
if a != self.data:
raise ValueError
class ListTupleTest(ExperimentCase): class ListTupleTest(ExperimentCase):
def test_list_tuple(self): def test_list_tuple(self):
exp = self.create(_ListTuple) self.create(_ListTuple).run()
exp.run()
def test_nested_tuple_list(self):
self.create(_NestedTupleList).run()