Skip to content

Commit

Permalink
- Atualização periódica de pacotes;
Browse files Browse the repository at this point in the history
- Adição de testes unitários para lexador e formatador JSON.
  • Loading branch information
leonelsanchesdasilva committed Nov 29, 2024
1 parent e277d74 commit 8d3da11
Show file tree
Hide file tree
Showing 6 changed files with 855 additions and 1,816 deletions.
2 changes: 1 addition & 1 deletion fontes/lexador/lexador-json.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ export class LexadorJson {
* @returns {boolean} checkResult - Check result
* @private
*/
private _allTokensAnalyzed(input: any, foundToken: any) {
private _allTokensAnalyzed(input: any, foundToken: any): boolean {
const safeInput = input || {};

const inputLength = safeInput.length;
Expand Down
4 changes: 2 additions & 2 deletions fontes/nucleo-execucao.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import * as caminho from "path";
import * as readline from "readline";

import chalk from "chalk";
import colorizeJson from "json-colorizer";
import { colorize } from "json-colorizer";

import {
AvaliadorSintaticoInterface,
Expand Down Expand Up @@ -486,7 +486,7 @@ export class NucleoExecucao
const resultadoLexacao = lexadorJson.getTokens(resultado[0]);
const resultadoFormatacao =
formatadorJson.formatar(resultadoLexacao);
isto.funcaoDeRetorno(colorizeJson(resultadoFormatacao));
isto.funcaoDeRetorno(colorize(resultadoFormatacao));
}

interfaceLeitura.prompt();
Expand Down
28 changes: 14 additions & 14 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,15 @@
"testes:servidor-depuracao": "yarn ts-node ./fontes/depuracao/servidor-depuracao.ts"
},
"dependencies": {
"@designliquido/birl": "^0.1.8",
"@designliquido/delegua": "^0.37.0",
"@designliquido/mapler": "^0.1.9",
"@designliquido/portugol-studio": "^0.4.5",
"@designliquido/potigol": "^0.1.10",
"@designliquido/birl": "^0.1.9",
"@designliquido/delegua": "^0.37.2",
"@designliquido/mapler": "^0.1.10",
"@designliquido/portugol-studio": "^0.4.6",
"@designliquido/potigol": "^0.1.11",
"@designliquido/visualg": "^0.3.6",
"chalk": "4.1.2",
"commander": "^9.4.1",
"json-colorizer": "^2.2.2"
"commander": "^12.1.0",
"json-colorizer": "^3.0.1"
},
"devDependencies": {
"@designliquido/delegua-estatistica": "^0.0.6",
Expand All @@ -29,17 +29,17 @@
"@designliquido/delegua-json": "^0.0.1",
"@designliquido/delegua-matematica": "^0.2.0",
"@designliquido/delegua-tempo": "^0.0.2",
"@types/estree": "^1.0.5",
"@types/jest": "^29.5.13",
"@types/node": "^22.7.6",
"@types/estree": "^1.0.6",
"@types/jest": "^29.5.14",
"@types/node": "^22.10.1",
"copyfiles": "^2.4.1",
"jest": "^29.7.0",
"jest-mock-process": "^2.0.0",
"release-it": "^15.6.0",
"rimraf": "^4.1.2",
"ts-jest": "^29.0.5",
"release-it": "^17.10.0",
"rimraf": "^6.0.1",
"ts-jest": "^29.2.5",
"ts-node": "^10.9.2",
"tsconfig-paths": "^4.2.0",
"typescript": "^5.6.3"
"typescript": "^5.7.2"
}
}
14 changes: 14 additions & 0 deletions testes/formatadores/formatador-json.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import { FormatadorJson } from "../../fontes/formatadores";
import { LexadorJson } from "../../fontes/lexador/lexador-json";

describe('Formatador JSON', () => {
it('Trivial', () => {
const lexadorJson = new LexadorJson();
const formatadorJson = new FormatadorJson();

const resultadoLexador: {type: string, value: string}[] = lexadorJson.getTokens('{"1": 2, "tres": "quatro"}');
const resultado = formatadorJson.formatar(resultadoLexador);

expect(resultado).toBe('{\n "1": 2,\n "tres": "quatro"\n}');
});
});
21 changes: 21 additions & 0 deletions testes/lexadores/lexador-json.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import { LexadorJson } from "../../fontes/lexador/lexador-json";

describe('Lexador JSON', () => {
it('Trivial', () => {
const lexadorJson = new LexadorJson();
const resultado: {type: string, value: string}[] = lexadorJson.getTokens('{"1": 2, "tres": "quatro"}');
expect(resultado).toHaveLength(12);
expect(resultado[0].type).toBe("OPEN_BRACE");
expect(resultado[1].type).toBe("STRING_KEY");
expect(resultado[2].type).toBe("COLON");
expect(resultado[3].type).toBe("WHITESPACE");
expect(resultado[4].type).toBe("NUMBER_LITERAL");
expect(resultado[5].type).toBe("COMMA");
expect(resultado[6].type).toBe("WHITESPACE");
expect(resultado[7].type).toBe("STRING_KEY");
expect(resultado[8].type).toBe("COLON");
expect(resultado[9].type).toBe("WHITESPACE");
expect(resultado[10].type).toBe("STRING_LITERAL");
expect(resultado[11].type).toBe("CLOSE_BRACE");
});
});
Loading

0 comments on commit 8d3da11

Please sign in to comment.