Example #1
0
    def test_alfabeto_entrada(self):
        test1 = main.read_lines(
            '/home/fjorg/Projects/Maquina-de-Turing/tests/a.txt')

        self.assertEqual(test1['alfabeto_entrada'], ['X', 'a', 'b', 'c'])

        test2 = main.read_lines(
            '/home/fjorg/Projects/Maquina-de-Turing/tests/b.txt')

        self.assertEqual(test2['alfabeto_entrada'], ['a', 'b', 'c'])

        test3 = main.read_lines(
            '/home/fjorg/Projects/Maquina-de-Turing/tests/c.txt')

        self.assertEqual(test3['alfabeto_entrada'], ['0', '1', 'X'])

        test4 = main.read_lines(
            '/home/fjorg/Projects/Maquina-de-Turing/tests/d.txt')

        self.assertEqual(test4['alfabeto_entrada'], ['a', 'b'])

        test5 = main.read_lines(
            '/home/fjorg/Projects/Maquina-de-Turing/tests/e.txt')

        self.assertEqual(test5['alfabeto_entrada'], ['0', '1'])
Example #2
0
    def test_estados(self):
        test1 = main.read_lines(
            '/home/fjorg/Projects/Maquina-de-Turing/tests/a.txt')

        self.assertEqual(test1['estados'], ['0', '1', '2', '3', '6'])

        test2 = main.read_lines(
            '/home/fjorg/Projects/Maquina-de-Turing/tests/b.txt')

        self.assertEqual(test2['estados'], ['0', '1', '2', '3', '4'])

        test3 = main.read_lines(
            '/home/fjorg/Projects/Maquina-de-Turing/tests/c.txt')

        self.assertEqual(test3['estados'], ['0', '1', '2', '3', '4', '5', '6'])

        test4 = main.read_lines(
            '/home/fjorg/Projects/Maquina-de-Turing/tests/d.txt')

        self.assertEqual(test4['estados'], ['0', '1', '2', '3'])

        test5 = main.read_lines(
            '/home/fjorg/Projects/Maquina-de-Turing/tests/e.txt')

        self.assertEqual(test5['estados'], ['0', '1'])
                    song += ' '
            if instr_idx + 1 < len(song_line):
                song += ' '
    return song


# ========== MAIN SCRIPT================
mycwd = os.getcwd()
os.chdir("..")

print('===== TRANSPOSITION TOOL IN THE CHROMATIC SCALE =====')
first_line = input('Type or copy-paste notes, or enter file name (in ' + os.path.normpath(SONG_DIR_IN) + '/): ').strip()

fp = load_file(SONG_DIR_IN, first_line)  # loads file or asks for next line

song_lines = read_lines(fp, first_line)

try:
    note_shift = int(input('Transposition ? (-12 ; +12): ').strip())
except ValueError:
    note_shift = 0

skyparser = SongParser()
skyparser.set_delimiters(ICON_DELIMITER, PAUSE, QUAVER_DELIMITER, COMMENT_DELIMITER, REPEAT_INDICATOR)
possible_modes = skyparser.get_possible_modes(song_lines)

if len(possible_modes) > 1:
    print('\nSeveral possible notations detected.')
    song_notation = ask_for_mode(possible_modes)
elif len(possible_modes) == 0:
    print('\nCould not detect your note format. Maybe your song contains typo errors?')
Example #4
0
    def test_estados_finais(self):
        test1 = main.read_lines(
            '/home/fjorg/Projects/Maquina-de-Turing/tests/a.txt')

        self.assertEqual(test1['estados_finais'], ['6'])
Example #5
0
    def test_estado_inicial(self):
        test1 = main.read_lines(
            '/home/fjorg/Projects/Maquina-de-Turing/tests/a.txt')

        self.assertEqual(test1['estado_inicial'], '0')
Example #6
0
    def test_espaco_branco(self):
        test1 = main.read_lines(
            '/home/fjorg/Projects/Maquina-de-Turing/tests/a.txt')

        self.assertEqual(test1['simbolo_espaco'], 'B')
Example #7
0
    def test_transicoes(self):
        test1 = main.read_lines(
            '/home/fjorg/Projects/Maquina-de-Turing/tests/a.txt')

        self.assertEqual(len(test1['transicoes']), 13)
        self.assertEqual(test1['transicoes'][0]['estado_atual'], '0')
        self.assertEqual(test1['transicoes'][0]['estado_destino'], '0')
        self.assertEqual(len(test1['transicoes'][0]['fitas']), 1)
        self.assertEqual(test1['transicoes'][0]['fitas'][0]['simbolo_atual'],
                         'X')
        self.assertEqual(test1['transicoes'][0]['fitas'][0]['novo_simbolo'],
                         'X')
        self.assertEqual(test1['transicoes'][0]['fitas'][0]['movimento'], 'R')

        self.assertEqual(test1['transicoes'][1]['estado_atual'], '0')
        self.assertEqual(test1['transicoes'][1]['estado_destino'], '1')
        self.assertEqual(len(test1['transicoes'][1]['fitas']), 1)
        self.assertEqual(test1['transicoes'][1]['fitas'][0]['simbolo_atual'],
                         'a')
        self.assertEqual(test1['transicoes'][1]['fitas'][0]['novo_simbolo'],
                         'X')
        self.assertEqual(test1['transicoes'][1]['fitas'][0]['movimento'], 'R')

        test2 = main.read_lines(
            '/home/fjorg/Projects/Maquina-de-Turing/tests/b.txt')

        self.assertEqual(len(test2['transicoes']), 8)
        self.assertEqual(test2['transicoes'][0]['estado_atual'], '0')
        self.assertEqual(test2['transicoes'][0]['estado_destino'], '0')
        self.assertEqual(len(test2['transicoes'][0]['fitas']), 3)

        self.assertEqual(test2['transicoes'][0]['fitas'][0]['simbolo_atual'],
                         'a')
        self.assertEqual(test2['transicoes'][0]['fitas'][0]['novo_simbolo'],
                         'a')
        self.assertEqual(test2['transicoes'][0]['fitas'][0]['movimento'], 'R')
        self.assertEqual(test2['transicoes'][0]['fitas'][1]['simbolo_atual'],
                         'B')
        self.assertEqual(test2['transicoes'][0]['fitas'][1]['novo_simbolo'],
                         'a')
        self.assertEqual(test2['transicoes'][0]['fitas'][1]['movimento'], 'R')
        self.assertEqual(test2['transicoes'][0]['fitas'][2]['simbolo_atual'],
                         'B')
        self.assertEqual(test2['transicoes'][0]['fitas'][2]['novo_simbolo'],
                         'B')
        self.assertEqual(test2['transicoes'][0]['fitas'][2]['movimento'], 'S')

        self.assertEqual(test2['transicoes'][1]['estado_atual'], '0')
        self.assertEqual(test2['transicoes'][1]['estado_destino'], '1')
        self.assertEqual(len(test2['transicoes'][1]['fitas']), 3)

        self.assertEqual(test2['transicoes'][1]['fitas'][0]['simbolo_atual'],
                         'B')
        self.assertEqual(test2['transicoes'][1]['fitas'][0]['novo_simbolo'],
                         'B')
        self.assertEqual(test2['transicoes'][1]['fitas'][0]['movimento'], 'S')
        self.assertEqual(test2['transicoes'][1]['fitas'][1]['simbolo_atual'],
                         'B')
        self.assertEqual(test2['transicoes'][1]['fitas'][1]['novo_simbolo'],
                         'B')
        self.assertEqual(test2['transicoes'][1]['fitas'][1]['movimento'], 'L')
        self.assertEqual(test2['transicoes'][1]['fitas'][2]['simbolo_atual'],
                         'B')
        self.assertEqual(test2['transicoes'][1]['fitas'][2]['novo_simbolo'],
                         'B')
        self.assertEqual(test2['transicoes'][1]['fitas'][2]['movimento'], 'S')
Example #8
0
    def test_qt_fitas(self):
        test1 = main.read_lines(
            '/home/fjorg/Projects/Maquina-de-Turing/tests/a.txt')

        self.assertEqual(test1['qt_fitas'], 1)