-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Permitindo atribuição de valores String aos modificadores (#162)
* Debug do tratamento atual de valores string * Ajustando Lexador para mapear lexema de valor string devidamente * Adaptando lógica de modificadores que aceitam valores string * Testes unitários - atribuindo valores string aos modificadores * Testes unitários - caso de falha
- Loading branch information
1 parent
209f897
commit cbf55d9
Showing
11 changed files
with
165 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
export const ValorString: Array<string> = [ | ||
'citações', | ||
'citacoes', | ||
'configurações-variação-fonte', | ||
'configuracoes-variacao-fonte', | ||
'ênfase-texto', | ||
'enfase-texto', | ||
'estilo-ênfase-texto', | ||
'estilo-enfase-texto', | ||
'substituir-idioma-fonte', | ||
'vazamento-texto', | ||
]; | ||
|
||
export const ValorStringAcentuado: Array<string> = [ | ||
'citações', | ||
'configurações-variação-fonte', | ||
'ênfase-texto', | ||
'estilo-ênfase-texto', | ||
'substituir-idioma-fonte', | ||
'vazamento-texto', | ||
]; | ||
|
||
/* | ||
VALORES STRING - Exemplos | ||
"x" | ||
"<" | ||
'foo' | ||
"\25B2" | ||
"«" "»" "‹" "›" | ||
'xxxxx' | ||
*/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,90 @@ | ||
import { AvaliadorSintatico } from "../../fontes/avaliador-sintatico"; | ||
import { Importador } from "../../fontes/importador"; | ||
import { AvaliadorSintaticoInterface, ImportadorInterface, LexadorInterface } from "../../fontes/interfaces"; | ||
import { Lexador } from "../../fontes/lexador"; | ||
import { SeletorModificador } from "../../fontes/modificadores/superclasse"; | ||
import tiposDeSimbolos from "../../fontes/tipos-de-simbolos/foles"; | ||
import { Serializador } from "../../fontes/serializadores"; | ||
import { ValorString, ValorStringAcentuado } from "../listas/valor-string"; | ||
|
||
describe('Testando Seletores com VALORES STRING', () => { | ||
describe('Testes Unitários', () => { | ||
let lexador: LexadorInterface; | ||
let importador: ImportadorInterface; | ||
let avaliadorSintatico: AvaliadorSintaticoInterface; | ||
let tradutor: Serializador; | ||
|
||
beforeEach(() => { | ||
lexador = new Lexador(); | ||
importador = new Importador(lexador); | ||
avaliadorSintatico = new AvaliadorSintatico(importador); | ||
tradutor = new Serializador(); | ||
}); | ||
|
||
it('Caso de sucesso - Lexador, Avaliador e Tradutor', () => { | ||
for (let index = 0; index < Object.keys(ValorString).length; index += 1) { | ||
|
||
const valoresString = [ | ||
"'x'", | ||
'"«" "»" "‹" "›"', | ||
"'foo'", | ||
"'/25B2'", | ||
]; | ||
|
||
for (let valIndex = 0; valIndex < valoresString.length; valIndex += 1) { | ||
// Lexador | ||
const resultadoLexador = lexador.mapear([ | ||
"corpo {", | ||
`${ValorString[index]}: ${valoresString[valIndex]};`, | ||
"}" | ||
]); | ||
|
||
if (valIndex !== 1) { | ||
expect(resultadoLexador.simbolos).toHaveLength(7); | ||
} else { | ||
expect(resultadoLexador.simbolos).toHaveLength(10); | ||
} | ||
|
||
if (valIndex < 1) { | ||
expect(resultadoLexador.simbolos).toEqual( | ||
expect.arrayContaining([ | ||
expect.objectContaining({ tipo: tiposDeSimbolos.TEXTO }), | ||
]) | ||
); | ||
} else { | ||
expect(resultadoLexador.simbolos).toEqual( | ||
expect.arrayContaining([ | ||
expect.objectContaining({ tipo: tiposDeSimbolos.IDENTIFICADOR }), | ||
]) | ||
); | ||
} | ||
|
||
// Avaliador Sintático | ||
const resultadoAvaliadorSintatico = avaliadorSintatico.analisar(resultadoLexador.simbolos); | ||
expect(resultadoAvaliadorSintatico[0].modificadores[0].nomeFoles).toContain(ValorString[index]); | ||
expect(resultadoAvaliadorSintatico[0].modificadores[0].valor).toContain(valoresString[valIndex]); | ||
|
||
// Tradutor | ||
const resultadoTradutor = tradutor.serializar(resultadoAvaliadorSintatico); | ||
expect(resultadoTradutor).toContain(valoresString[valIndex]); | ||
} | ||
} | ||
}); | ||
|
||
it('Caso de falha - Avaliador sintático deve retornar erro ', () => { | ||
for (let index = 0; index < Object.keys(ValorStringAcentuado).length; index += 1) { | ||
// Lexador | ||
const resultadoLexador = lexador.mapear([ | ||
"corpo {", | ||
`${ValorStringAcentuado[index]}: x;`, | ||
"}" | ||
]); | ||
|
||
// Avaliador Sintático não deve aceitar o valor string sem aspas | ||
expect(() => { | ||
avaliadorSintatico.analisar(resultadoLexador.simbolos); | ||
}).toThrowError(`Propriedade '${ValorStringAcentuado[index]}' com valor x inválido`); | ||
} | ||
}); | ||
}); | ||
}); |