def test_union(self):
schema = """
@0xbf5147cbbecf40c1;
struct P {
union {
x @0 :Int64;
y @1 :Void;
z @2 :Text;
}
}
"""
self.mod = self.compile(schema)
p = self.mod.P.new_x(1)
self.check(p, '(x = 1)')
#
p = self.mod.P.new_y()
self.check(p, '(y = void)')
#
p = self.mod.P.new_z(b'hello')
self.check(p, '(z = "hello")')
评论列表
文章目录