Example #1
0
    def test_qualifiers(self):
        self.assertEqual(void_type().qualifiers, Qualifiers(0))

        t = void_type(Qualifiers.CONST | Qualifiers.VOLATILE)
        self.assertEqual(t.qualifiers, Qualifiers.CONST | Qualifiers.VOLATILE)
        self.assertEqual(
            repr(t), 'void_type(qualifiers=<Qualifiers.VOLATILE|CONST: 3>)')

        self.assertEqual(t.qualified(Qualifiers.ATOMIC),
                         void_type(Qualifiers.ATOMIC))
        self.assertEqual(t.unqualified(), void_type())
        self.assertEqual(t.qualified(Qualifiers(0)), t.unqualified())

        self.assertRaisesRegex(TypeError, 'expected Qualifiers or None',
                               void_type, 1.5)
Example #2
0
    def test_qualifiers(self):
        self.assertEqual(self.prog.void_type().qualifiers, Qualifiers(0))

        t = self.prog.void_type(qualifiers=Qualifiers.CONST
                                | Qualifiers.VOLATILE)
        self.assertEqual(t.qualifiers, Qualifiers.CONST | Qualifiers.VOLATILE)
        self.assertEqual(
            repr(t),
            "prog.void_type(qualifiers=<Qualifiers.VOLATILE|CONST: 3>)")

        self.assertIdentical(
            t.qualified(Qualifiers.ATOMIC),
            self.prog.void_type(qualifiers=Qualifiers.ATOMIC),
        )
        self.assertIdentical(t.unqualified(), self.prog.void_type())
        self.assertIdentical(t.qualified(Qualifiers(0)), t.unqualified())

        self.assertRaisesRegex(TypeError,
                               "expected Qualifiers",
                               self.prog.void_type,
                               qualifiers=1.5)