def test_eq_two_recursive_should_succeed(self):
     a1 = Classifier('A')
     a1.properties = [Property(Type(a1), 'a')]
     a2 = Classifier('A')
     a2.properties = [Property(Type(a2), 'a')]
     assert_that(a1, equal_to(a2))
     assert_that(a1.equiv_pattern(a2))
 def test_str_should_succeed(self):
     assert_that(str(Property()), starts_with('anonymous_'))
     assert_that(str(Property('x', Type(Class('A')), owner=Class('B'))),
                 equal_to('B::x: A'))
 def test_eq_with_property_should_succeed(self):
     assert_that(
         Classifier('A', properties=[Property(Type(Classifier('B')), 'b')]),
         equal_to(Classifier('A', properties=[
             Property(Type(Classifier('B')), 'b')])))
 def command_sender_type(self):
     return Type(self.command_sender())
コード例 #5
0
 def test_str_should_succeed(self):
     assert_that(str(Parameter()), starts_with('anonymous_'))
     assert_that(str(Parameter('x', Type(Class('A')))), equal_to('x: A'))
 def cheese_type(self):
     return Type(self.cheese())
 def burger_type(self):
     return Type(self.burger())
class Burgers(object):
    INT_TYPE = Type(PrimitiveType('int'))

    @staticmethod
    def _price():
        return Operation('price',
                         Burgers.INT_TYPE,
                         Visibility.PUBLIC,
                         is_static=False)

    @cached_method
    def cutlet_price(self):
        return self._price()

    @cached_method
    def cutlet(self):
        return Class('Cutlet', operations=[self.cutlet_price()])

    @cached_method
    def cutlet_type(self):
        return Type(self.cutlet())

    @cached_method
    def cheese_price(self):
        return self._price()

    @cached_method
    def cheese(self):
        return Class('Cheese', operations=[self.cheese_price()])

    @cached_method
    def cheese_type(self):
        return Type(self.cheese())

    @cached_method
    def burger_price(self):
        return self._price()

    @cached_method
    def burger(self):
        return Interface('Burger', operations=[self.burger_price()])

    @cached_method
    def burger_type(self):
        return Type(self.burger())

    @cached_method
    def hamburger_cutlet(self):
        return Property('cutlet',
                        self.cutlet_type(),
                        Visibility.PUBLIC,
                        is_static=False)

    @cached_method
    def hamburger_price(self):
        return self._price()

    @cached_method
    def hamburger(self):
        return Class('Hamburger',
                     properties=[self.hamburger_cutlet()],
                     operations=[self.hamburger_price()])

    @cached_method
    def cheeseburger_cutlet(self):
        return Property('cutlet',
                        self.cutlet_type(),
                        Visibility.PUBLIC,
                        is_static=False)

    @cached_method
    def cheeseburger_cheese(self):
        return Property('cheese',
                        self.cheese_type(),
                        Visibility.PUBLIC,
                        is_static=False)

    @cached_method
    def cheeseburger_price(self):
        return self._price()

    @cached_method
    def cheeseburger(self):
        return Class('Cheeseburger',
                     properties=[
                         self.cheeseburger_cutlet(),
                         self.cheeseburger_cheese(),
                     ],
                     operations=[self.cheeseburger_price()])

    @cached_method
    def burger_with_burger(self):
        return Property('burger',
                        self.burger_type(),
                        Visibility.PUBLIC,
                        is_static=False)

    @cached_method
    def burger_with_price(self):
        return self._price()

    @cached_method
    def burger_with(self):
        return Class('BurgerWith',
                     properties=[self.burger_with_burger()],
                     operations=[self.burger_with_price()])

    @cached_method
    def create(self):
        self.cutlet().generals = [self.burger_with()]
        self.cheese().generals = [self.burger_with()]
        self.cheeseburger().generals = [self.burger()]
        self.hamburger().generals = [self.burger()]
        self.burger_with().generals = [self.burger()]
        self.burger_with_price().invocations = [self.burger_price()]
        return Model([
            self.burger(),
            self.burger_with(),
            self.hamburger(),
            self.cheeseburger(),
            self.cutlet(),
            self.cheese(),
        ])
 def cutlet_type(self):
     return Type(self.cutlet())
 def test_dump_and_load_yaml_should_succeed(self):
     obj = Type()
     data = "!Type {}\n"
     assert_that(yaml.dump(obj, default_flow_style=False), equal_to(data))
     assert_that(yaml.load(data), equal_to(obj))
コード例 #11
0
 def test_str_should_succeed(self):
     assert_that(str(Operation()),
                 starts_with('anonymous_') and ends_with('()'))
     assert_that(str(Operation('f', Type(Class('A')), owner=Class('B'))),
                 equal_to('B::f(): A'))
 def test_make_with_wrong_range_should_throw_exception(self):
     assert_that(calling(lambda: Type(lower=1, upper=0)),
                 raises(MultRangeError))
 def test_make_with_wrong_upper_should_throw_exception(self):
     assert_that(calling(lambda: Type(upper='')),
                 raises(MultUpperTypeError))
     assert_that(calling(lambda: Type(upper=-1)), raises(NegativeMultUpper))
 def test_str_should_succeed(self):
     assert_that(str(Type(Class())),
                 starts_with('type of class anonymous_'))
     assert_that(str(Type(Class('A'))), equal_to('type of class A'))
 def test_eq_should_succeed(self):
     assert_that(Type(Class()), not equal_to(Type(Class())))
     assert_that(Type(Class('A')), equal_to(Type(Class('A'))))
 def test_equivalent_pattern_range_should_succeed(self):
     assert_that(Type(Class()).equiv_pattern_range(Type(Class())))