def test_make_interface_extends_two_interfaces_should_succeed(self): tree = self.parse(''' interface InterfaceA {} interface InterfaceB {} interface InterfaceC extends InterfaceA, InterfaceB {} ''') classifiers, errors = make_classifiers(tree) assert_that(errors, empty()) make_generalizations(tree, classifiers) assert_that( classifiers['InterfaceC'].generals, equal_to([ Interface('InterfaceA'), Interface('InterfaceB'), ]))
def component(self): return Interface('Component', operations=[ Operation('operation', self.VOID, Visibility.PUBLIC, is_static=False) ])
def test_make_several_class_should_succeed(self): tree = self.parse(''' class C1 {} class C2 {} interface I1 {} interface I2 {} ''') classifiers, errors = make_classifiers(tree) assert_that( classifiers, equal_to({ 'C1': Class('C1'), 'C2': Class('C2'), 'I1': Interface('I1'), 'I2': Interface('I2'), })) assert_that(errors, empty())
def test_make_class_extends_and_implements_should_succeed(self): tree = self.parse(''' interface InterfaceA {} interface InterfaceB {} class General {} class Realization extends General implements InterfaceA, InterfaceB {} ''') classifiers, errors = make_classifiers(tree) assert_that(errors, empty()) make_generalizations(tree, classifiers) assert_that( classifiers['Realization'].generals, equal_to([ Class('General'), Interface('InterfaceA'), Interface('InterfaceB'), ]))
def decorator(self): return Interface('Decorator', properties=[ self.decorator_component(), ], operations=[ Operation('operation', self.VOID, Visibility.PUBLIC, is_static=False), ])
def test_declaration_of_two_same_interfaces_should_return_error(self): tree = self.parse(''' interface Interface {} interface Interface {} ''') classifiers, errors = make_classifiers(tree) assert_that(classifiers, equal_to({'Interface': Interface('Interface')})) assert_that( errors, equal_to([ ClassifierRedeclaration(InterfaceDeclaration('Interface', [])) ]))
def adapter(self): return Interface('Adapter', operations=[self.adapter_operation()])
def interface(self): return Interface('Interface', operations=[self.interface_operation()])
def test_make_one_interface_should_succeed(self): tree = self.parse('interface I {}') classifiers, errors = make_classifiers(tree) assert_that(classifiers, equal_to({'I': Interface('I')})) assert_that(errors, empty())
def component(self): return Interface('Component', operations=[self.component_operation()])
def abstract_factory(self): return Interface('AbstractFactory', operations=[self.abstract_factory_create()])
def make_interface(declaration): return Interface(declaration.name)
def visitor(self): return Interface('Visitor', operations=[self.visitor_visit()])
def element(self): return Interface('Element', operations=[self.element_accept()])
def handler(self): return Interface('Handler', operations=[self.handler_handle_request()])
def implementor(self): return Interface('Implementor', operations=[self.implementor_operation_impl()])
def abstract_product(self): return Interface('AbstractProduct')
def make_interface(class_info): return Interface(class_info.pretty_this())
def test_make_should_succeed(self): declaration = InterfaceDeclaration(name='Interface', body=None) interface = make_interface(declaration) assert_that(interface, equal_to(Interface('Interface')))