예제 #1
0
def length_operation_working():
    """Проверка работы операции нахождения длины объекта"""
    real_string_segment_size = minimal_data_length["string_segment"]
    minimal_data_length["string_segment"] = 4
    real_list_segment_size = minimal_data_length["list_segment"]
    minimal_data_length["list_segment"] = 4
    setting.initialisation("program.yovc")
    str_num = add.string_segment()
    put.string_segment(str_num, "char_list",
                       "Эта строка не влезет в маленький сегмент")
    list_num = add.list_segment()
    put.list_segment(list_num, "link_list", [i for i in range(40)])
    view.tape()
    print(get.string_segment(str_num))
    view.string_segment(str_num)
    print(get.list_segment(list_num))
    view.list_segment(list_num)
    objects.Length(["link", str_num])
    kind, length_link = pull.memory_stack()
    draw.entity_link(length_link)
    objects.Length(["link", list_num])
    kind, length_link = pull.memory_stack()
    draw.entity_link(length_link)
    string_num = make.string_segment("a")
    objects.Find(["link", string_num])
    name_num = pull.memory_stack()
    objects.Equate(name_num, ["link", list_num])
    objects.Length(name_num)
    kind, length_link = pull.memory_stack()
    draw.entity_link(length_link)
    minimal_data_length["string_segment"] = real_string_segment_size
    minimal_data_length["list_segment"] = real_list_segment_size
예제 #2
0
def math_operations_working():
    """Проверка работы математических операций"""
    setting.initialisation("program.yovc")
    number_1 = 97
    number_2 = -65
    num_1 = append.data_segment("number", number_1)
    num_2 = append.data_segment("number", number_2)
    print(f"Negative: - {number_1}")
    math.Negative(["link", num_1])
    draw.memory_stack_link()
    print(f"Add: {number_1} + {number_2}")
    math.Add(["link", num_1], ["link", num_2])
    draw.memory_stack_link()
    print(f"Increment: {number_1}++")
    math.Increment(["link", num_1])
    draw.memory_stack_link()
    print(f"Decrement: {number_1}--")
    math.Decrement(["link", num_1])
    draw.memory_stack_link()
    print(f"Subtract: {number_1} - {number_2}")
    math.Subtract(["link", num_1], ["link", num_2])
    draw.memory_stack_link()
    print(f"Multiply: {number_1} * {number_2}")
    math.Multiply(["link", num_1], ["link", num_2])
    draw.memory_stack_link()
    print(f"Divide: {number_1} / {number_2}")
    math.Divide(["link", num_1], ["link", num_2])
    draw.memory_stack_link()
    print(f"Modulo: {number_1} % {number_2}")
    math.Modulo(["link", num_1], ["link", num_2])
    draw.memory_stack_link()
예제 #3
0
def console_operations_working():
    """Проверка работы оперций ввода и вывода"""
    setting.initialisation("program.yovc")
    console.Input()
    link_type, link_value = pull.memory_stack()
    console.Output(["link", link_value])
    view.tape()
예제 #4
0
def subobject_operation_working():
    """Проверка работы операции нахождения элемента по индексу"""
    real_string_segment_size = minimal_data_length["string_segment"]
    minimal_data_length["string_segment"] = 4
    real_list_segment_size = minimal_data_length["list_segment"]
    minimal_data_length["list_segment"] = 4
    setting.initialisation("program.yovc")
    str_num = add.string_segment()
    put.string_segment(str_num, "char_list",
                       "Эта строка не влезет в маленький сегмент")
    list_num = add.list_segment()
    put.list_segment(list_num, "link_list", [i for i in range(40)])
    view.tape()
    print(get.string_segment(str_num))
    view.string_segment(str_num)
    print(get.list_segment(list_num))
    view.list_segment(list_num)
    index = append.data_segment("number", 25)
    objects.Sub_object(["link", str_num], ["link", index])
    kind, element_link = pull.memory_stack()
    display.entity(element_link)
    objects.Sub_object(["link", list_num], ["link", index])
    kind, element_link = pull.memory_stack()
    display.entity(element_link)
    minimal_data_length["string_segment"] = real_string_segment_size
    minimal_data_length["list_segment"] = real_list_segment_size
예제 #5
0
def equate_operation_working():
    """Проверка работы команды приравнивания"""
    setting.initialisation("program.yovc")
    objects.Create(["chars", "Крутой язык"])
    str_num = make.string_segment("Ё")
    objects.Find(["link", str_num])
    name_num = pull.memory_stack()
    value_num = pull.memory_stack()
    objects.Equate(name_num, value_num)
    namespace_num = find.attribute(seg_links["system"], "target_namespace")
    view.namespace_items(namespace_num)
    console.Output(name_num)

    list_num = make.list_segment([0, 1, 2, 3, 4, 5])
    index_num = make.entity("number", 3)
    objects.Sub_object(["link", list_num], ["link", index_num])
    elem_num = pull.memory_stack()
    objects.Create(["array", [6, 7, 8]])
    value_num = pull.memory_stack()
    objects.Equate(elem_num, value_num)
    console.Output(elem_num)

    objects.Sub_object(["link", list_num], ["link", index_num])
    str_num = make.string_segment("array")
    objects.Find(["link", str_num])
    name_num = pull.memory_stack()
    elem_num = pull.memory_stack()
    objects.Equate(name_num, elem_num)
    view.namespace_items(namespace_num)
    console.Output(name_num)
예제 #6
0
def list_and_string_segments_making():
    """Проверка на создание сегментов строки и списка с данными"""
    setting.initialisation("program.yovc")
    str_num = make.string_segment("Эта строка должна влезть")
    list_num = make.list_segment([i for i in range(40)])
    view.tape()
    view.string_segment(str_num)
    view.list_segment(list_num)
예제 #7
0
def negative_command_working():
    """Проверка работы команды Negative"""
    setting.initialisation("program.yovc")
    number = -255
    print("number", number)
    num = append.data_segment("number", number)
    math.Negative(num)
    kind, number = link.memory_stack_get()
    print(kind, number)
예제 #8
0
def list_segment_putting():
    """Проверка на заполнение сегмента списка"""
    real_list_segment_size = minimal_data_length["list_segment"]
    minimal_data_length["list_segment"] = 4
    setting.initialisation("program.yovc")
    num = add.list_segment()
    put.list_segment(num, "link_list", [i for i in range(40)])
    view.tape()
    print(get.list_segment(num))
    view.list_segment(num)
    minimal_data_length["list_segment"] = real_list_segment_size
예제 #9
0
def namespace_putting():
    """Проверка на заполнение пространства имён"""
    real_namespace_size = minimal_data_length["namespace"]
    minimal_data_length["namespace"] = 4
    setting.initialisation("program.yovc")
    prog_num = find.attribute(seg_links["system"], "main_program")
    num = add.namespace(prog_num)
    put.namespace(num, "link_list", [i for i in range(40)])
    view.tape()
    print(get.namespace(num))
    view.namespace(num)
    minimal_data_length["namespace"] = real_namespace_size
예제 #10
0
def string_segment_putting():
    """Проверка на заполнение сегмента строки"""
    real_string_segment_size = minimal_data_length["string_segment"]
    minimal_data_length["string_segment"] = 4
    setting.initialisation("program.yovc")
    num = add.string_segment()
    put.string_segment(num, "char_list",
                       "Эта строка не влезет в маленький сегмент")
    view.tape()
    print(get.string_segment(num))
    view.string_segment(num)
    minimal_data_length["string_segment"] = real_string_segment_size
예제 #11
0
def data_segment_putting():
    """Проверка на заполнение сегмента данных"""
    real_data_segment_size = minimal_data_length["data_segment"]
    minimal_data_length["data_segment"] = 4
    setting.initialisation("program.yovc")
    num = find.attribute(seg_links["system"], "first_data_segment")
    put.data_segment(num, "chars", "Эта строка не влезет в маленький сегмент")
    put.data_segment(num, "dictionary_item", [15, 20, 25])
    put.data_segment(num, "number", 255)
    view.tape()
    view.data_segment()
    minimal_data_length["data_segment"] = real_data_segment_size
예제 #12
0
def create_operation_working():
    """Проверка работы команды создания"""
    setting.initialisation("program.yovc")
    objects.Create(["none", 0])
    draw.memory_stack_link()
    objects.Create(["logic", True])
    draw.memory_stack_link()
    objects.Create(["number", 365])
    draw.memory_stack_link()
    objects.Create(["chars", "super_string"])
    draw.memory_stack_link()
    objects.Create(["array", [1, 2, 3, 4, 5]])
    draw.memory_stack_link()
    view.tape()
예제 #13
0
def comparison_operations_working():
    """Проверка работы операций сравнения"""
    setting.initialisation("program.yovc")
    value_1 = 53
    value_2 = 4
    num_1 = append.data_segment("number", value_1)
    num_2 = append.data_segment("number", value_2)
    print(f"Equal: {value_1} == {value_2}")
    comparison.Equal(["link", num_1], ["link", num_2])
    draw.memory_stack_link()
    print(f"Great: {value_1} > {value_2}")
    comparison.Great(["link", num_1], ["link", num_2])
    draw.memory_stack_link()
    print(f"Less: {value_1} < {value_2}")
    comparison.Less(["link", num_1], ["link", num_2])
    draw.memory_stack_link()
예제 #14
0
def memory_stack_operations_working():
    """Проверка работы операций стека памяти"""
    setting.initialisation("program.yovc")
    value = 248
    stack.Push(["number", value])
    display.entity(438)
    stack.Pop(["link", 438])
    display.entity(438)
    print()
    number_1 = 97
    number_2 = -65
    num_1 = append.data_segment("number", number_1)
    num_2 = append.data_segment("number", number_2)
    math.Add(["link", num_1], ["link", num_2])
    display.entity(440)
    stack.Pop(["link", 440])
    display.entity(440)
예제 #15
0
def jumps_operations_working():
    """Проверка работы операций переходов"""
    setting.initialisation("program.yovc")
    show.attribute(seg_links["system"], "target_cell")
    jumps.Jump(["link", 12])
    print("Jump:")
    show.attribute(seg_links["system"], "target_cell")
    true_num = append.data_segment("logic", True)
    false_num = append.data_segment("logic", False)
    print("Jump_if true:")
    jumps.Jump_if(["link", 16], ["link", true_num])
    show.attribute(seg_links["system"], "target_cell")
    print("Jump_if false:")
    jumps.Jump_if(["link", 25], ["link", false_num])
    show.attribute(seg_links["system"], "target_cell")
    print("End:")
    jumps.End()
    show.attribute(seg_links["system"], "target_cell")
예제 #16
0
def segment_extending():
    """Проверка на расширение сегментов"""
    segment_nums = setting.initialisation("program.yovc")
    list_num = add.list_segment()
    namespace_num = find.attribute(seg_links["system"], "target_namespace")
    data_num = find.attribute(seg_links["system"], "first_data_segment")
    extend.data_segment(data_num)
    extend.namespace(namespace_num)
    extend.list_segment(list_num)
    view.tape()
예제 #17
0
def logic_operations_working():
    """Проверка работы логических операций"""
    setting.initialisation("program.yovc")
    value_1 = True
    value_2 = False
    num_1 = append.data_segment("logic", value_1)
    num_2 = append.data_segment("logic", value_2)
    print(f"Not: not {value_1}")
    logic.Not(["link", num_1])
    draw.memory_stack_link()
    print(f"And: {value_1} and {value_2}")
    logic.And(["link", num_1], ["link", num_2])
    draw.memory_stack_link()
    print(f"Or: {value_1} or {value_2}")
    logic.Or(["link", num_1], ["link", num_2])
    draw.memory_stack_link()
    print(f"Xor: {value_1} xor {value_2}")
    logic.Xor(["link", num_1], ["link", num_2])
    draw.memory_stack_link()
예제 #18
0
def stack_taking_putting():
    """Проверка на заполнение и опустошение стека"""
    real_memory_stack_size = minimal_data_length["memory_stack"]
    minimal_data_length["memory_stack"] = 8
    setting.initialisation("program.yovc")
    num = find.attribute(seg_links["system"], "memory_stack")
    data = [5, 10, 15, 20, 25]
    print("Заполнение:")
    for i in range(len(data)):
        try:
            put.stack(num, "link", data[i])
            show.segment_body(num)
        except LowerCommandError as error:
            print(error)
    print("Извлечение:")
    for i in range(len(data)):
        try:
            obj_type, obj_value = take.stack(num)
            show.segment_body(num)
        except LowerCommandError as error:
            print(error)
    show.segment_body(num)
    minimal_data_length["memory_stack"] = real_memory_stack_size
예제 #19
0
def find_operation_working():
    """Проверка работы команды поиска"""
    real_namespace_size = minimal_data_length["namespace"]
    minimal_data_length["namespace"] = 2
    setting.initialisation("program.yovc")
    prog_num = find.attribute(seg_links["system"], "main_program")
    name_num = find.attribute(prog_num, "namespace")
    view.namespace_items(name_num)
    str_num = make.string_segment("J")
    objects.Find(["link", str_num])
    value_link = pull.memory_stack()
    draw.link_on_link(value_link)
    view.namespace_items(name_num)
    item.write_namespace_name(name_num, ["string_segment", "Yo"],
                              value=["number", 1])
    str_num = make.string_segment("Yo")
    view.tape()
    view.data_segment()
    objects.Find(["link", str_num])
    view.namespace_items(name_num)
    value_link = pull.memory_stack()
    draw.link_on_link(value_link)
    minimal_data_length["namespace"] = real_namespace_size
예제 #20
0
def list_segment_writing():
    """Проверка на запись сегмента списка"""
    setting.initialisation("program.yovc")
    add.list_segment()
    view.tape()