def test_code(self):
    self.round_trip({'code': Code('function x() { return 1; }')})
    code = Code('return z', z=2)
    res = json_util.dumps(code)
    self.assertEqual(code, json_util.loads(res))
    self.assertEqual('{"$code": "return z", "$scope": {"z": 2}}', res)
    no_scope = Code('function() {}')
    self.assertEqual('{"$code": "function() {}"}', json_util.dumps(no_scope))
def test_code(self):
    self.round_trip({'code': Code('function x() { return 1; }')})
    code = Code('return z', z=2)
    res = json_util.dumps(code)
    self.assertEqual(code, json_util.loads(res))
    self.assertEqual('{"$code": "return z", "$scope": {"z": 2}}', res)
    no_scope = Code('function() {}')
    self.assertEqual('{"$code": "function() {}"}', json_util.dumps(no_scope))