1import unittest
2
3from mypyc.ir.rtypes import (
4    RTuple, object_rprimitive, int_rprimitive, bool_rprimitive, list_rprimitive,
5    RInstance, RUnion,
6)
7from mypyc.ir.class_ir import ClassIR
8
9
10class TestTupleNames(unittest.TestCase):
11    def setUp(self) -> None:
12        self.inst_a = RInstance(ClassIR('A', '__main__'))
13        self.inst_b = RInstance(ClassIR('B', '__main__'))
14
15    def test_names(self) -> None:
16        assert RTuple([int_rprimitive, int_rprimitive]).unique_id == "T2II"
17        assert RTuple([list_rprimitive, object_rprimitive, self.inst_a]).unique_id == "T3OOO"
18        assert RTuple([list_rprimitive, object_rprimitive, self.inst_b]).unique_id == "T3OOO"
19        assert RTuple([]).unique_id == "T0"
20        assert RTuple([RTuple([]),
21                       RTuple([int_rprimitive, int_rprimitive])]).unique_id == "T2T0T2II"
22        assert RTuple([bool_rprimitive,
23                       RUnion([bool_rprimitive, int_rprimitive])]).unique_id == "T2CO"
24