-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Adição de testes unitários para lexador e formatador JSON.
- Loading branch information
1 parent
e277d74
commit 8d3da11
Showing
6 changed files
with
855 additions
and
1,816 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
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}'); | ||
}); | ||
}); |
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,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"); | ||
}); | ||
}); |
Oops, something went wrong.