# Path: omelette/compiler/uml.py
# class Operation(_Field):
#     """Class representing UML Operation."""
# 
#     def __init__(self, visibility, name, is_static=False, parameters=[],
#             type=None):
#         """
#         Create Operation with given visibility ("+", "-", "#" or "~") and name.
# 
#         Parameters are list of tuples: name, type.
# 
#         Keyword arguments:
#         is_static -- (default: False)
#         parameters -- list of operation parameters (default: empty list)
#         type -- type of value returned by the operation as a String (default: None)
#         """
# 
#         self.is_static = is_static
#         self.visibility = visibility
#         self.name = name
#         self.parameters = parameters
#         self.type = type
# 
#     def __str__(self):
#         return (self.visibility + " " + self.name + "(" +
#                 self.__formatted_params() + ")" +
#                 _try_to_format(" : %s", self.type))
# 
#     def __formatted_params(self):
#         """
#         Returns formatted list of operation's parameters.
# 
#         eg: "arg1 : type1, arg2 : type2, arg3"
#         """
# 
#         format = lambda(n, t) : n + _try_to_format(" : %s", t)
#         formatted = map(format, self.parameters)
#         return ", ".join(formatted)
# 
#     def __format_parameter(self, parameter):
#         """
#         Used in __formatted_params, returns "arg1 : type" if param's type is
#         not None, otherwise just "arg1".
#         """
# 
#         (name, type) = parameter
#         return name + ((" : " + type) if type else "")
# 
# class Attribute(_Field):
#     """Class representing UML Attribute."""
# 
#     def __init__(self, visibility, name, is_static=False, type=None,
#             default_value=None):
#         """
#         Create Attribute with given visibility ("+", "-", "#" or "~") and name.
# 
#         Keyword arguments:
#         is_static -- (default: False)
#         type -- type of value returned by the operation as a String (default: None)
#         default_value -- (default : None).
#         """
# 
#         self.is_static = is_static
#         self.visibility = visibility
#         self.name = name
#         self.type = type
#         self.default_value = default_value
# 
#     def __str__(self):
#         return (self.visibility + " " + self.name +
#                 _try_to_format(" : %s", self.type) +
#                 _try_to_format(" = %s", self.default_value))


import unittest
from omelette.compiler.uml import Operation, Attribute
        self.assertEquals(o.is_static, 0)

    def test_operation_minimal(self):
        o = Operation("#", "ASD")
        self.assertEquals(str(o), "# ASD()")
        self.assertFalse(o.is_static)

    def test_operation_no_params(self):
        o = Operation("+", "asd", is_static=1)
        self.assertEqual(o.is_static, 1)

    def test_operation_no_types(self):
        o = Operation("+", "asd", 0, [("a", "int"), ("b", None)], "int")
        self.assertEquals(str(o), "+ asd(a : int, b) : int")

    def test_operation_no_return_type(self):
        o = Operation("+", "asd", 0, [("a", "int"), ("b", None)], None)
        self.assertEquals(str(o), "+ asd(a : int, b)")

    def test_attribute(self):
        a = Attribute("+", "asd", 1, "int", "42")
        self.assertEquals(str(a), "+ asd : int = 42")
        self.assertTrue(a.is_static)

    def test_attribute_minimal(self):
        a = Attribute("#", "ASD")
        self.assertEquals(str(a), "# ASD")
        self.assertFalse(a.is_static)

    def test_attribute_no_type(self):

# Path: omelette/compiler/uml.py
# class Operation(_Field):
#     """Class representing UML Operation."""
# 
#     def __init__(self, visibility, name, is_static=False, parameters=[],
#             type=None):
#         """
#         Create Operation with given visibility ("+", "-", "#" or "~") and name.
# 
#         Parameters are list of tuples: name, type.
# 
#         Keyword arguments:
#         is_static -- (default: False)
#         parameters -- list of operation parameters (default: empty list)
#         type -- type of value returned by the operation as a String (default: None)
#         """
# 
#         self.is_static = is_static
#         self.visibility = visibility
#         self.name = name
#         self.parameters = parameters
#         self.type = type
# 
#     def __str__(self):
#         return (self.visibility + " " + self.name + "(" +
#                 self.__formatted_params() + ")" +
#                 _try_to_format(" : %s", self.type))
# 
#     def __formatted_params(self):
#         """
#         Returns formatted list of operation's parameters.
# 
#         eg: "arg1 : type1, arg2 : type2, arg3"
#         """
# 
#         format = lambda(n, t) : n + _try_to_format(" : %s", t)
#         formatted = map(format, self.parameters)
#         return ", ".join(formatted)
# 
#     def __format_parameter(self, parameter):
#         """
#         Used in __formatted_params, returns "arg1 : type" if param's type is
#         not None, otherwise just "arg1".
#         """
# 
#         (name, type) = parameter
#         return name + ((" : " + type) if type else "")
# 
# class Attribute(_Field):
#     """Class representing UML Attribute."""
# 
#     def __init__(self, visibility, name, is_static=False, type=None,
#             default_value=None):
#         """
#         Create Attribute with given visibility ("+", "-", "#" or "~") and name.
# 
#         Keyword arguments:
#         is_static -- (default: False)
#         type -- type of value returned by the operation as a String (default: None)
#         default_value -- (default : None).
#         """
# 
#         self.is_static = is_static
#         self.visibility = visibility
#         self.name = name
#         self.type = type
#         self.default_value = default_value
# 
#     def __str__(self):
#         return (self.visibility + " " + self.name +
#                 _try_to_format(" : %s", self.type) +
#                 _try_to_format(" = %s", self.default_value))


# Path: omelette/compiler/test/test_field.py
import unittest
from omelette.compiler.uml import Operation, Attribute

        self.assertEquals(o.is_static, 0)

    def test_operation_minimal(self):
        o = Operation("#", "ASD")
        self.assertEquals(str(o), "# ASD()")
        self.assertFalse(o.is_static)

    def test_operation_no_params(self):
        o = Operation("+", "asd", is_static=1)
        self.assertEqual(o.is_static, 1)

    def test_operation_no_types(self):
        o = Operation("+", "asd", 0, [("a", "int"), ("b", None)], "int")
        self.assertEquals(str(o), "+ asd(a : int, b) : int")

    def test_operation_no_return_type(self):
        o = Operation("+", "asd", 0, [("a", "int"), ("b", None)], None)
        self.assertEquals(str(o), "+ asd(a : int, b)")

    def test_attribute(self):
        a = Attribute("+", "asd", 1, "int", "42")
        self.assertEquals(str(a), "+ asd : int = 42")
        self.assertTrue(a.is_static)

    def test_attribute_minimal(self):
        a = Attribute("#", "ASD")
        self.assertEquals(str(a), "# ASD")
        self.assertFalse(a.is_static)

    def test_attribute_no_type(self):

        a = Attribute("+", "asd", 1, None, "42")