-
Notifications
You must be signed in to change notification settings - Fork 201
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
compiler.embedding: add tests for quote serialization.
whitequark
committed
Aug 28, 2015
1 parent
37811f6
commit cbd903a
Showing
2 changed files
with
52 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
from artiq.language import * | ||
from artiq.test.hardware_testbench import ExperimentCase | ||
|
||
class Roundtrip(EnvExperiment): | ||
def build(self): | ||
self.attr_device("core") | ||
|
||
@kernel | ||
def roundtrip(self, obj, fn): | ||
fn(obj) | ||
|
||
class RoundtripTest(ExperimentCase): | ||
def assertRoundtrip(self, obj): | ||
exp = self.create(Roundtrip) | ||
def callback(objcopy) -> TNone: | ||
self.assertEqual(obj, objcopy) | ||
exp.roundtrip(obj, callback) | ||
|
||
def test_None(self): | ||
self.assertRoundtrip(None) | ||
|
||
def test_bool(self): | ||
self.assertRoundtrip(True) | ||
self.assertRoundtrip(False) | ||
|
||
def test_int(self): | ||
self.assertRoundtrip(42) | ||
self.assertRoundtrip(int(42, width=64)) | ||
|
||
def test_float(self): | ||
self.assertRoundtrip(42.0) | ||
|
||
def test_str(self): | ||
self.assertRoundtrip("foo") | ||
|
||
def test_list(self): | ||
self.assertRoundtrip([10]) | ||
|
||
def test_object(self): | ||
obj = object() | ||
self.assertRoundtrip(obj) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters