-
Notifications
You must be signed in to change notification settings - Fork 22
/
test_pretty_print.py
63 lines (55 loc) · 1.06 KB
/
test_pretty_print.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
import magma as m
def test_pretty_print_tuple():
t = m.Tuple(a=m.Bit, b=m.Bit, c=m.Bit)
assert m.util.pretty_str(t) == """\
Tuple(
a = Bit,
b = Bit,
c = Bit
)\
"""
def test_pretty_print_tuple_recursive():
t = m.Tuple(a=m.Bit, b=m.Bit, c=m.Bit)
u = m.Tuple(x=t, y=t)
assert m.util.pretty_str(u) == """\
Tuple(
x = Tuple(
a = Bit,
b = Bit,
c = Bit
),
y = Tuple(
a = Bit,
b = Bit,
c = Bit
)
)\
"""
def test_pretty_print_array_of_tuple():
t = m.Tuple(a=m.Bit, b=m.Bit, c=m.Bit)
u = m.Array[3, t]
assert m.util.pretty_str(u) == """\
Array[3, Tuple(
a = Bit,
b = Bit,
c = Bit
)]\
"""
def test_pretty_print_array_of_nested_tuple():
t = m.Tuple(a=m.Bits[5], b=m.UInt[3], c=m.SInt[4])
u = m.Tuple(x=t, y=t)
v = m.Array[3, u]
assert m.util.pretty_str(v) == """\
Array[3, Tuple(
x = Tuple(
a = Bits[5],
b = UInt[3],
c = SInt[4]
),
y = Tuple(
a = Bits[5],
b = UInt[3],
c = SInt[4]
)
)]\
"""