Skip to content

Commit dbc0cdb

Browse files
committed
test(egua): cover try catch failure
Signed-off-by: afadesigns <afadesign.official@gmail.com>
1 parent f23ebe4 commit dbc0cdb

2 files changed

Lines changed: 26 additions & 2 deletions

File tree

exemplos/dialetos/egua-classico/testes.egua

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ função startTest(){
1616
escreva("|");
1717
escreva(tCasoEscolha());
1818
escreva("|");
19-
//escreva(tTentePegue());
19+
escreva(tTentePegue());
2020
escreva("|");
2121
escreva(tClasse());
2222
}

testes/nucleo-execucao.test.ts

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,4 +54,28 @@ describe('Núcleo de execução', () => {
5454
expect(retornoSaida.length).toBeGreaterThan(0);
5555
expect(retornoSaida).toBe('correndo');
5656
});
57-
});
57+
58+
it('Dialeto Égua executa bloco `pegue` quando comparação inválida ocorre', async () => {
59+
const consoleSpy = jest.spyOn(console, 'log').mockImplementation(() => undefined);
60+
try {
61+
const nucleoExecucao = new NucleoExecucao('0.1');
62+
nucleoExecucao.configurarDialeto('egua');
63+
64+
await nucleoExecucao.executarCodigoComoArgumento(`
65+
tente {
66+
1 > "1";
67+
escreva("Tente - Pegue: ERRO!");
68+
} pegue {
69+
escreva("Tente - Pegue: OK!");
70+
}`);
71+
72+
const saidas = consoleSpy.mock.calls.map(([mensagem]) =>
73+
typeof mensagem === 'string' ? mensagem.trim() : ''
74+
);
75+
expect(saidas).toContain('Tente - Pegue: OK!');
76+
expect(saidas).not.toContain('Tente - Pegue: ERRO!');
77+
} finally {
78+
consoleSpy.mockRestore();
79+
}
80+
});
81+
});

0 commit comments

Comments
 (0)