# Path: omelette/compiler/code.py
# class Code(object):
#     """Class representing the code divided into objects."""
# 
#     def __init__(self, code=""):
#         self.__objects = [_CodeObject(-1, "")]
#         self.__lexer = Lexer()
# 
#         lines = code.split("\n") if code else []
# 
#         for number, line in enumerate(lines):
#             self.insert_line(number, line)
# 
#     def objects(self, condition=None):
#         return filter(condition, self.__objects)
# 
#     def __is_header(self, line):
#         try:
#             header = self.__lexer["header"] + StringEnd()
#             header.parseString(line)
#             return True
#         except ParseException:
#             return False
# 
#     def __shift(self, position, offset):
#         for object in self.objects(_after(position)):
#             object.position += offset
# 
#     def insert_line(self, number, line):
#         self.__shift(number, 1)
# 
#         if self.__is_header(line):
#             object = _CodeObject(number, line)
# 
#             previous = self.objects(_before(number))[-1]
#             previous.transfer_lines(object, number)
# 
#             self.__objects.append(object)
#             self.__objects.sort()
#         else:
#             object = self.objects(_before(number))[-1]
#             object.insert_line(number, line)
# 
#     def update_line(self, number, line):
#         object = self.objects(_before(number))[-1]
#         updated_line = object.lines[number - object.position]
# 
#         if self.__is_header(line) == self.__is_header(updated_line):
#             object.update_line(number, line)
#         else:
#             self.remove_line(number)
#             self.insert_line(number, line)
# 
#     def remove_line(self, number):
#         object = self.objects(_before(number))[-1]
#         object.remove_line(number)
# 
#         if object.position == number:
#             previous = self.objects(_before(number))[-2]
#             object.transfer_lines(previous, number)
# 
#             self.__objects.remove(object)
# 
#         self.__shift(number, -1)


import unittest
from omelette.compiler.code import Code
        result = self.instance.objects()

        self.assertEquals(result[2].lines[0], line)
        self.assertEquals(result[1].modified, True)
        self.assertEquals(result[2].modified, True)

    def test_remove_line(self):
        self.instance.remove_line(1)
        result = self.instance.objects()

        self.assertEquals(result[1].lines[1], self.lines[2])
        self.assertEquals(result[2].position, 2)
        self.assertEquals(result[1].modified, True)

    def test_remove_header(self):
        self.instance.remove_line(3)
        result = self.instance.objects()

        self.assertEquals(len(result), 2)
        self.assertEquals(result[1].lines[3], self.lines[4])
        self.assertEquals(result[1].lines[4], self.lines[5])
        self.assertEquals(result[1].modified, True)

    def test_is_empty(self):
        empty = Code("\n\n\n")

        result = empty.objects().pop()
        self.assertTrue(result.is_empty())

    def test_is_not_empty(self):

# Path: omelette/compiler/code.py
# class Code(object):
#     """Class representing the code divided into objects."""
# 
#     def __init__(self, code=""):
#         self.__objects = [_CodeObject(-1, "")]
#         self.__lexer = Lexer()
# 
#         lines = code.split("\n") if code else []
# 
#         for number, line in enumerate(lines):
#             self.insert_line(number, line)
# 
#     def objects(self, condition=None):
#         return filter(condition, self.__objects)
# 
#     def __is_header(self, line):
#         try:
#             header = self.__lexer["header"] + StringEnd()
#             header.parseString(line)
#             return True
#         except ParseException:
#             return False
# 
#     def __shift(self, position, offset):
#         for object in self.objects(_after(position)):
#             object.position += offset
# 
#     def insert_line(self, number, line):
#         self.__shift(number, 1)
# 
#         if self.__is_header(line):
#             object = _CodeObject(number, line)
# 
#             previous = self.objects(_before(number))[-1]
#             previous.transfer_lines(object, number)
# 
#             self.__objects.append(object)
#             self.__objects.sort()
#         else:
#             object = self.objects(_before(number))[-1]
#             object.insert_line(number, line)
# 
#     def update_line(self, number, line):
#         object = self.objects(_before(number))[-1]
#         updated_line = object.lines[number - object.position]
# 
#         if self.__is_header(line) == self.__is_header(updated_line):
#             object.update_line(number, line)
#         else:
#             self.remove_line(number)
#             self.insert_line(number, line)
# 
#     def remove_line(self, number):
#         object = self.objects(_before(number))[-1]
#         object.remove_line(number)
# 
#         if object.position == number:
#             previous = self.objects(_before(number))[-2]
#             object.transfer_lines(previous, number)
# 
#             self.__objects.remove(object)
# 
#         self.__shift(number, -1)


# Path: omelette/compiler/test/test_code.py
import unittest
from omelette.compiler.code import Code

        result = self.instance.objects()

        self.assertEquals(result[2].lines[0], line)
        self.assertEquals(result[1].modified, True)
        self.assertEquals(result[2].modified, True)

    def test_remove_line(self):
        self.instance.remove_line(1)
        result = self.instance.objects()

        self.assertEquals(result[1].lines[1], self.lines[2])
        self.assertEquals(result[2].position, 2)
        self.assertEquals(result[1].modified, True)

    def test_remove_header(self):
        self.instance.remove_line(3)
        result = self.instance.objects()

        self.assertEquals(len(result), 2)
        self.assertEquals(result[1].lines[3], self.lines[4])
        self.assertEquals(result[1].lines[4], self.lines[5])
        self.assertEquals(result[1].modified, True)

    def test_is_empty(self):
        empty = Code("\n\n\n")

        result = empty.objects().pop()
        self.assertTrue(result.is_empty())

    def test_is_not_empty(self):

        not_empty = Code("\n    target: School\n")