def test_rev_const_merge_types_in_list(self): rev_const_type = CompositeType({ ("get", 0): GetterMicroOpType(0, StringType()), ("set", 0): SetterMicroOpType(0, StringType()), ("get", 1): GetterMicroOpType(1, IntegerType()), ("set", 1): SetterMicroOpType(1, IntegerType()), ("get", 2): GetterMicroOpType(2, AnyType()), ("set", 2): SetterMicroOpType(2, AnyType()), ("insert-start", ): InsertStartMicroOpType(StringType(), False) }, name="test") normal_broad_type = CompositeType({ ("get", 0): GetterMicroOpType(0, StringType()), ("set", 0): SetterMicroOpType(0, StringType()), ("get", 1): GetterMicroOpType(1, IntegerType()), ("set", 1): SetterMicroOpType(1, IntegerType()), ("get", 2): GetterMicroOpType(2, AnyType()), ("set", 2): SetterMicroOpType(2, AnyType()), }, name="test") self.assertFalse(rev_const_type.is_self_consistent(DUMMY_REASONER)) rev_const_type = prepare_lhs_type(rev_const_type, None) self.assertTrue(rev_const_type.is_self_consistent(DUMMY_REASONER)) self.assertTrue(normal_broad_type.is_copyable_from(rev_const_type, DUMMY_REASONER))
def test_rev_const_assigned_to_narrow_type(self): rev_const_type = CompositeType({ ("get", "foo"): GetterMicroOpType("foo", StringType()), ("set", "foo"): SetterMicroOpType("foo", AnyType()) }, name="test") normal_broad_type = CompositeType({ ("get", "foo"): GetterMicroOpType("foo", StringType()), ("set", "foo"): SetterMicroOpType("foo", StringType()) }, name="test") self.assertTrue(normal_broad_type.is_copyable_from(rev_const_type, DUMMY_REASONER))
def test_rev_const_flatten_tuple(self): rev_const_type = CompositeType({ ("get", 0): GetterMicroOpType(0, StringType()), ("set", 0): SetterMicroOpType(0, AnyType()) }, name="test") normal_broad_type = CompositeType({ ("get", 0): GetterMicroOpType(0, StringType()), ("set", 0): SetterMicroOpType(0, StringType()) }, name="test") rev_const_type = prepare_lhs_type(rev_const_type, None) self.assertTrue(isinstance(rev_const_type.get_micro_op_type(("set", 0)).value_type, StringType)) self.assertTrue(normal_broad_type.is_copyable_from(rev_const_type, DUMMY_REASONER))
def test_rev_const_wildcard(self): rev_const_type = CompositeType({ ("get-wildcard", ): GetterWildcardMicroOpType(StringType(), StringType(), True), ("set-wildcard", ): SetterWildcardMicroOpType(StringType(), AnyType(), False, False) }, name="test") normal_broad_type = CompositeType({ ("get", "foo"): GetterWildcardMicroOpType(StringType(), StringType(), True), ("set", "foo"): SetterWildcardMicroOpType(StringType(), StringType(), False, False) }, name="test") rev_const_type = prepare_lhs_type(rev_const_type, None) self.assertTrue(isinstance(rev_const_type.get_micro_op_type(("set-wildcard",)).value_type, StringType)) self.assertTrue(normal_broad_type.is_copyable_from(rev_const_type, DUMMY_REASONER))