@designliquido/delegua 0.9.2 → 0.9.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/bin/delegua +1 -1
- package/bin/delegua.cmd +1 -1
- package/bin/package.json +3 -3
- package/coverage/lcov-report/sorter.js +4 -4
- package/coverage/lcov-report/sorter.js.map +1 -1
- package/execucao.d.ts +1 -0
- package/execucao.js +29 -0
- package/execucao.js.map +1 -0
- package/fontes/avaliador-sintatico/avaliador-sintatico-base.d.ts +1 -1
- package/fontes/avaliador-sintatico/avaliador-sintatico-base.js +108 -105
- package/fontes/avaliador-sintatico/avaliador-sintatico-base.js.map +1 -1
- package/fontes/avaliador-sintatico/avaliador-sintatico.d.ts +1 -1
- package/fontes/avaliador-sintatico/avaliador-sintatico.js +244 -256
- package/fontes/avaliador-sintatico/avaliador-sintatico.js.map +1 -1
- package/fontes/avaliador-sintatico/dialetos/avaliador-sintatico-birl.d.ts +20 -0
- package/fontes/avaliador-sintatico/dialetos/avaliador-sintatico-birl.js +68 -0
- package/fontes/avaliador-sintatico/dialetos/avaliador-sintatico-birl.js.map +1 -0
- package/fontes/avaliador-sintatico/dialetos/avaliador-sintatico-egua-classico.d.ts +1 -1
- package/fontes/avaliador-sintatico/dialetos/avaliador-sintatico-egua-classico.js +227 -236
- package/fontes/avaliador-sintatico/dialetos/avaliador-sintatico-egua-classico.js.map +1 -1
- package/fontes/avaliador-sintatico/dialetos/avaliador-sintatico-eguap.d.ts +1 -1
- package/fontes/avaliador-sintatico/dialetos/avaliador-sintatico-eguap.js +247 -257
- package/fontes/avaliador-sintatico/dialetos/avaliador-sintatico-eguap.js.map +1 -1
- package/fontes/avaliador-sintatico/dialetos/avaliador-sintatico-visualg.d.ts +3 -0
- package/fontes/avaliador-sintatico/dialetos/avaliador-sintatico-visualg.js +192 -131
- package/fontes/avaliador-sintatico/dialetos/avaliador-sintatico-visualg.js.map +1 -1
- package/fontes/avaliador-sintatico/erro-avaliador-sintatico.js +6 -24
- package/fontes/avaliador-sintatico/erro-avaliador-sintatico.js.map +1 -1
- package/fontes/bibliotecas/biblioteca-global.js +206 -367
- package/fontes/bibliotecas/biblioteca-global.js.map +1 -1
- package/fontes/bibliotecas/importar-biblioteca.js +28 -29
- package/fontes/bibliotecas/importar-biblioteca.js.map +1 -1
- package/fontes/bibliotecas/primitivas-texto.js +9 -22
- package/fontes/bibliotecas/primitivas-texto.js.map +1 -1
- package/fontes/bibliotecas/primitivas-vetor.js +12 -14
- package/fontes/bibliotecas/primitivas-vetor.js.map +1 -1
- package/fontes/construtos/acesso-indice-variavel.js +6 -50
- package/fontes/construtos/acesso-indice-variavel.js.map +1 -1
- package/fontes/construtos/acesso-metodo.js +6 -50
- package/fontes/construtos/acesso-metodo.js.map +1 -1
- package/fontes/construtos/agrupamento.js +6 -50
- package/fontes/construtos/agrupamento.js.map +1 -1
- package/fontes/construtos/atribuicao-sobrescrita.js +6 -50
- package/fontes/construtos/atribuicao-sobrescrita.js.map +1 -1
- package/fontes/construtos/atribuir.js +6 -50
- package/fontes/construtos/atribuir.js.map +1 -1
- package/fontes/construtos/binario.js +6 -50
- package/fontes/construtos/binario.js.map +1 -1
- package/fontes/construtos/chamada.js +6 -50
- package/fontes/construtos/chamada.js.map +1 -1
- package/fontes/construtos/definir-valor.js +6 -50
- package/fontes/construtos/definir-valor.js.map +1 -1
- package/fontes/construtos/dicionario.js +6 -50
- package/fontes/construtos/dicionario.js.map +1 -1
- package/fontes/construtos/funcao.d.ts +2 -2
- package/fontes/construtos/funcao.js +6 -47
- package/fontes/construtos/funcao.js.map +1 -1
- package/fontes/construtos/isto.js +6 -47
- package/fontes/construtos/isto.js.map +1 -1
- package/fontes/construtos/literal.js +6 -47
- package/fontes/construtos/literal.js.map +1 -1
- package/fontes/construtos/logico.js +6 -50
- package/fontes/construtos/logico.js.map +1 -1
- package/fontes/construtos/super.js +6 -47
- package/fontes/construtos/super.js.map +1 -1
- package/fontes/construtos/unario.js +6 -50
- package/fontes/construtos/unario.js.map +1 -1
- package/fontes/construtos/variavel.js +6 -47
- package/fontes/construtos/variavel.js.map +1 -1
- package/fontes/construtos/vetor.js +6 -50
- package/fontes/construtos/vetor.js.map +1 -1
- package/fontes/declaracoes/bloco.js +9 -70
- package/fontes/declaracoes/bloco.js.map +1 -1
- package/fontes/declaracoes/classe.js +11 -72
- package/fontes/declaracoes/classe.js.map +1 -1
- package/fontes/declaracoes/continua.js +8 -65
- package/fontes/declaracoes/continua.js.map +1 -1
- package/fontes/declaracoes/declaracao.js +6 -47
- package/fontes/declaracoes/declaracao.js.map +1 -1
- package/fontes/declaracoes/enquanto.js +10 -71
- package/fontes/declaracoes/enquanto.js.map +1 -1
- package/fontes/declaracoes/escolha.js +11 -72
- package/fontes/declaracoes/escolha.js.map +1 -1
- package/fontes/declaracoes/escreva.js +9 -70
- package/fontes/declaracoes/escreva.js.map +1 -1
- package/fontes/declaracoes/expressao.js +9 -70
- package/fontes/declaracoes/expressao.js.map +1 -1
- package/fontes/declaracoes/fazer.js +10 -71
- package/fontes/declaracoes/fazer.js.map +1 -1
- package/fontes/declaracoes/funcao.js +10 -68
- package/fontes/declaracoes/funcao.js.map +1 -1
- package/fontes/declaracoes/importar.js +10 -71
- package/fontes/declaracoes/importar.js.map +1 -1
- package/fontes/declaracoes/leia.js +9 -70
- package/fontes/declaracoes/leia.js.map +1 -1
- package/fontes/declaracoes/para.js +12 -73
- package/fontes/declaracoes/para.js.map +1 -1
- package/fontes/declaracoes/retorna.js +10 -71
- package/fontes/declaracoes/retorna.js.map +1 -1
- package/fontes/declaracoes/se.js +12 -73
- package/fontes/declaracoes/se.js.map +1 -1
- package/fontes/declaracoes/sustar.js +8 -65
- package/fontes/declaracoes/sustar.js.map +1 -1
- package/fontes/declaracoes/tente.js +12 -73
- package/fontes/declaracoes/tente.js.map +1 -1
- package/fontes/declaracoes/var.js +10 -71
- package/fontes/declaracoes/var.js.map +1 -1
- package/fontes/delegua.js +125 -206
- package/fontes/delegua.js.map +1 -1
- package/fontes/depuracao/cyrb53.js +3 -4
- package/fontes/depuracao/cyrb53.js.map +1 -1
- package/fontes/depuracao/servidor-depuracao.js +125 -209
- package/fontes/depuracao/servidor-depuracao.js.map +1 -1
- package/fontes/espaco-variaveis.js +3 -4
- package/fontes/espaco-variaveis.js.map +1 -1
- package/fontes/estruturas/chamavel.js +6 -9
- package/fontes/estruturas/chamavel.js.map +1 -1
- package/fontes/estruturas/classe-padrao.js +17 -35
- package/fontes/estruturas/classe-padrao.js.map +1 -1
- package/fontes/estruturas/delegua-classe.d.ts +2 -2
- package/fontes/estruturas/delegua-classe.js +21 -39
- package/fontes/estruturas/delegua-classe.js.map +1 -1
- package/fontes/estruturas/delegua-funcao.js +48 -114
- package/fontes/estruturas/delegua-funcao.js.map +1 -1
- package/fontes/estruturas/funcao-padrao.js +13 -75
- package/fontes/estruturas/funcao-padrao.js.map +1 -1
- package/fontes/estruturas/metodo-primitiva.js +11 -39
- package/fontes/estruturas/metodo-primitiva.js.map +1 -1
- package/fontes/estruturas/modulo.js +6 -7
- package/fontes/estruturas/modulo.js.map +1 -1
- package/fontes/estruturas/objeto-delegua-classe.d.ts +3 -3
- package/fontes/estruturas/objeto-delegua-classe.js +12 -13
- package/fontes/estruturas/objeto-delegua-classe.js.map +1 -1
- package/fontes/estruturas/objeto-padrao.js +9 -11
- package/fontes/estruturas/objeto-padrao.js.map +1 -1
- package/fontes/excecoes/erro-em-tempo-de-execucao.js +8 -26
- package/fontes/excecoes/erro-em-tempo-de-execucao.js.map +1 -1
- package/fontes/importador/importador.js +21 -22
- package/fontes/importador/importador.js.map +1 -1
- package/fontes/interfaces/avaliador-sintatico-interface.d.ts +1 -1
- package/fontes/interfaces/parametro-interface.d.ts +1 -1
- package/fontes/interpretador/dialetos/egua-classico.js +592 -1019
- package/fontes/interpretador/dialetos/egua-classico.js.map +1 -1
- package/fontes/interpretador/inferenciador.js +1 -1
- package/fontes/interpretador/inferenciador.js.map +1 -1
- package/fontes/interpretador/interpretador-com-depuracao.js +186 -336
- package/fontes/interpretador/interpretador-com-depuracao.js.map +1 -1
- package/fontes/interpretador/interpretador.js +706 -1175
- package/fontes/interpretador/interpretador.js.map +1 -1
- package/fontes/interpretador/pilha-escopos-execucao.js +52 -57
- package/fontes/interpretador/pilha-escopos-execucao.js.map +1 -1
- package/fontes/lexador/dialetos/lexador-birl.d.ts +6 -19
- package/fontes/lexador/dialetos/lexador-birl.js +157 -49
- package/fontes/lexador/dialetos/lexador-birl.js.map +1 -1
- package/fontes/lexador/dialetos/lexador-egua-classico.js +43 -46
- package/fontes/lexador/dialetos/lexador-egua-classico.js.map +1 -1
- package/fontes/lexador/dialetos/lexador-eguap.js +59 -63
- package/fontes/lexador/dialetos/lexador-eguap.js.map +1 -1
- package/fontes/lexador/dialetos/lexador-visualg.js +45 -54
- package/fontes/lexador/dialetos/lexador-visualg.js.map +1 -1
- package/fontes/lexador/dialetos/palavras-reservadas/birl.d.ts +14 -1
- package/fontes/lexador/dialetos/palavras-reservadas/birl.js +18 -1
- package/fontes/lexador/dialetos/palavras-reservadas/birl.js.map +1 -1
- package/fontes/lexador/dialetos/palavras-reservadas/egua-classico.js +1 -1
- package/fontes/lexador/dialetos/palavras-reservadas/egua-classico.js.map +1 -1
- package/fontes/lexador/dialetos/palavras-reservadas/visualg.d.ts +24 -0
- package/fontes/lexador/dialetos/palavras-reservadas/visualg.js +25 -1
- package/fontes/lexador/dialetos/palavras-reservadas/visualg.js.map +1 -1
- package/fontes/lexador/lexador-base-linha-unica.d.ts +1 -1
- package/fontes/lexador/lexador-base-linha-unica.js +28 -29
- package/fontes/lexador/lexador-base-linha-unica.js.map +1 -1
- package/fontes/lexador/lexador.js +53 -57
- package/fontes/lexador/lexador.js.map +1 -1
- package/fontes/lexador/palavras-reservadas.js +1 -1
- package/fontes/lexador/palavras-reservadas.js.map +1 -1
- package/fontes/lexador/simbolo.js +5 -6
- package/fontes/lexador/simbolo.js.map +1 -1
- package/fontes/quebras/index.js +11 -42
- package/fontes/quebras/index.js.map +1 -1
- package/fontes/resolvedor/dialetos/egua-classico.js +143 -144
- package/fontes/resolvedor/dialetos/egua-classico.js.map +1 -1
- package/fontes/resolvedor/erro-resolvedor.js +6 -24
- package/fontes/resolvedor/erro-resolvedor.js.map +1 -1
- package/fontes/resolvedor/pilha-escopos.js +11 -12
- package/fontes/resolvedor/pilha-escopos.js.map +1 -1
- package/fontes/tipos-de-simbolos/birl.d.ts +7 -0
- package/fontes/tipos-de-simbolos/birl.js +20 -12
- package/fontes/tipos-de-simbolos/birl.js.map +1 -1
- package/fontes/tipos-de-simbolos/comum.d.ts +2 -0
- package/fontes/tipos-de-simbolos/comum.js +2 -0
- package/fontes/tipos-de-simbolos/comum.js.map +1 -1
- package/fontes/tipos-de-simbolos/visualg.d.ts +9 -0
- package/fontes/tipos-de-simbolos/visualg.js +9 -0
- package/fontes/tipos-de-simbolos/visualg.js.map +1 -1
- package/index.d.ts +5 -1
- package/index.js +18 -25
- package/index.js.map +1 -1
- package/jest.config.js +9 -47
- package/jest.config.js.map +1 -1
- package/package.json +3 -3
- package/testes/__mocks__/estatistica.js +1 -1
- package/testes/__mocks__/estatistica.js.map +1 -1
- package/testes/__mocks__/fisica.js +1 -1
- package/testes/__mocks__/fisica.js.map +1 -1
- package/testes/__mocks__/matematica.js +1 -1
- package/testes/__mocks__/matematica.js.map +1 -1
- package/testes/avaliador-sintatico.test.js +27 -27
- package/testes/avaliador-sintatico.test.js.map +1 -1
- package/testes/biblioteca-global.test.js +197 -440
- package/testes/biblioteca-global.test.js.map +1 -1
- package/testes/birl/avaliador-sintatico.test.d.ts +1 -0
- package/testes/birl/avaliador-sintatico.test.js +18 -0
- package/testes/birl/avaliador-sintatico.test.js.map +1 -0
- package/testes/birl/lexador.test.d.ts +1 -0
- package/testes/birl/lexador.test.js +31 -0
- package/testes/birl/lexador.test.js.map +1 -0
- package/testes/delegua.test.js +7 -7
- package/testes/delegua.test.js.map +1 -1
- package/testes/egua-classico/avaliador-sintatico.test.js +14 -14
- package/testes/egua-classico/avaliador-sintatico.test.js.map +1 -1
- package/testes/egua-classico/delegua.test.js +5 -5
- package/testes/egua-classico/delegua.test.js.map +1 -1
- package/testes/egua-classico/interpretador.test.js +180 -396
- package/testes/egua-classico/interpretador.test.js.map +1 -1
- package/testes/egua-classico/lexador.test.js +23 -23
- package/testes/egua-classico/lexador.test.js.map +1 -1
- package/testes/egua-classico/resolvedor.test.js +12 -12
- package/testes/egua-classico/resolvedor.test.js.map +1 -1
- package/testes/eguap/avaliador-sintatico.test.js +11 -11
- package/testes/eguap/avaliador-sintatico.test.js.map +1 -1
- package/testes/eguap/interpretador.test.js +189 -405
- package/testes/eguap/interpretador.test.js.map +1 -1
- package/testes/eguap/lexador.test.js +18 -18
- package/testes/eguap/lexador.test.js.map +1 -1
- package/testes/interpretador.test.js +431 -908
- package/testes/interpretador.test.js.map +1 -1
- package/testes/lexador.test.js +42 -42
- package/testes/lexador.test.js.map +1 -1
- package/testes/visualg/avaliador-sintatico.test.js +23 -23
- package/testes/visualg/avaliador-sintatico.test.js.map +1 -1
- package/testes/visualg/interpretador.test.js +16 -61
- package/testes/visualg/interpretador.test.js.map +1 -1
- package/testes/visualg/lexador.test.js +15 -15
- package/testes/visualg/lexador.test.js.map +1 -1
|
@@ -1,946 +1,469 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
-
});
|
|
10
|
-
};
|
|
11
|
-
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
12
|
-
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
13
|
-
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
14
|
-
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
15
|
-
function step(op) {
|
|
16
|
-
if (f) throw new TypeError("Generator is already executing.");
|
|
17
|
-
while (_) try {
|
|
18
|
-
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
19
|
-
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
20
|
-
switch (op[0]) {
|
|
21
|
-
case 0: case 1: t = op; break;
|
|
22
|
-
case 4: _.label++; return { value: op[1], done: false };
|
|
23
|
-
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
24
|
-
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
25
|
-
default:
|
|
26
|
-
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
27
|
-
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
28
|
-
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
29
|
-
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
30
|
-
if (t[2]) _.ops.pop();
|
|
31
|
-
_.trys.pop(); continue;
|
|
32
|
-
}
|
|
33
|
-
op = body.call(thisArg, _);
|
|
34
|
-
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
35
|
-
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
36
|
-
}
|
|
37
|
-
};
|
|
38
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
39
|
-
|
|
40
|
-
describe('Interpretador',
|
|
41
|
-
describe('interpretar()',
|
|
42
|
-
|
|
43
|
-
beforeEach(
|
|
3
|
+
const delegua_1 = require("../fontes/delegua");
|
|
4
|
+
describe('Interpretador', () => {
|
|
5
|
+
describe('interpretar()', () => {
|
|
6
|
+
let delegua;
|
|
7
|
+
beforeEach(() => {
|
|
44
8
|
delegua = new delegua_1.Delegua('delegua');
|
|
45
9
|
});
|
|
46
|
-
describe('Cenários de sucesso',
|
|
47
|
-
describe('Atribuições',
|
|
48
|
-
it('Trivial',
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
});
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
switch (_a.label) {
|
|
82
|
-
case 0:
|
|
83
|
-
retornoLexador = delegua.lexador.mapear(["var a = {'a': 1, 'b': 2}"], -1);
|
|
84
|
-
retornoAvaliadorSintatico = delegua.avaliadorSintatico.analisar(retornoLexador);
|
|
85
|
-
return [4 /*yield*/, delegua.interpretador.interpretar(retornoAvaliadorSintatico.declaracoes)];
|
|
86
|
-
case 1:
|
|
87
|
-
retornoInterpretador = _a.sent();
|
|
88
|
-
expect(retornoInterpretador.erros).toHaveLength(0);
|
|
89
|
-
return [2 /*return*/];
|
|
90
|
-
}
|
|
91
|
-
});
|
|
92
|
-
}); });
|
|
93
|
-
it('Concatenação', function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
94
|
-
var retornoLexador, retornoAvaliadorSintatico, retornoInterpretador;
|
|
95
|
-
return __generator(this, function (_a) {
|
|
96
|
-
switch (_a.label) {
|
|
97
|
-
case 0:
|
|
98
|
-
retornoLexador = delegua.lexador.mapear(["var a = 1 + '1'"], -1);
|
|
99
|
-
retornoAvaliadorSintatico = delegua.avaliadorSintatico.analisar(retornoLexador);
|
|
100
|
-
return [4 /*yield*/, delegua.interpretador.interpretar(retornoAvaliadorSintatico.declaracoes)];
|
|
101
|
-
case 1:
|
|
102
|
-
retornoInterpretador = _a.sent();
|
|
103
|
-
expect(retornoInterpretador.erros).toHaveLength(0);
|
|
104
|
-
return [2 /*return*/];
|
|
105
|
-
}
|
|
106
|
-
});
|
|
107
|
-
}); });
|
|
108
|
-
it('Interpolação de Texto', function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
109
|
-
var retornoLexador, retornoAvaliadorSintatico, retornoInterpretador;
|
|
110
|
-
return __generator(this, function (_a) {
|
|
111
|
-
switch (_a.label) {
|
|
112
|
-
case 0:
|
|
113
|
-
retornoLexador = delegua.lexador.mapear([
|
|
114
|
-
"var comidaFavorita = 'strogonoff'",
|
|
115
|
-
'escreva("Minha comida favorita é ${comidaFavorita}")'
|
|
116
|
-
], -1);
|
|
117
|
-
retornoAvaliadorSintatico = delegua.avaliadorSintatico.analisar(retornoLexador);
|
|
118
|
-
return [4 /*yield*/, delegua.interpretador.interpretar(retornoAvaliadorSintatico.declaracoes)];
|
|
119
|
-
case 1:
|
|
120
|
-
retornoInterpretador = _a.sent();
|
|
121
|
-
expect(retornoInterpretador.erros).toHaveLength(0);
|
|
122
|
-
return [2 /*return*/];
|
|
123
|
-
}
|
|
124
|
-
});
|
|
125
|
-
}); });
|
|
10
|
+
describe('Cenários de sucesso', () => {
|
|
11
|
+
describe('Atribuições', () => {
|
|
12
|
+
it('Trivial', async () => {
|
|
13
|
+
const retornoLexador = delegua.lexador.mapear(["var a = 1"], -1);
|
|
14
|
+
const retornoAvaliadorSintatico = delegua.avaliadorSintatico.analisar(retornoLexador);
|
|
15
|
+
const retornoInterpretador = await delegua.interpretador.interpretar(retornoAvaliadorSintatico.declaracoes);
|
|
16
|
+
expect(retornoInterpretador.erros).toHaveLength(0);
|
|
17
|
+
});
|
|
18
|
+
it('Vetor', async () => {
|
|
19
|
+
const retornoLexador = delegua.lexador.mapear(["var a = [1, 2, 3]"], -1);
|
|
20
|
+
const retornoAvaliadorSintatico = delegua.avaliadorSintatico.analisar(retornoLexador);
|
|
21
|
+
const retornoInterpretador = await delegua.interpretador.interpretar(retornoAvaliadorSintatico.declaracoes);
|
|
22
|
+
expect(retornoInterpretador.erros).toHaveLength(0);
|
|
23
|
+
});
|
|
24
|
+
it('Dicionário', async () => {
|
|
25
|
+
const retornoLexador = delegua.lexador.mapear(["var a = {'a': 1, 'b': 2}"], -1);
|
|
26
|
+
const retornoAvaliadorSintatico = delegua.avaliadorSintatico.analisar(retornoLexador);
|
|
27
|
+
const retornoInterpretador = await delegua.interpretador.interpretar(retornoAvaliadorSintatico.declaracoes);
|
|
28
|
+
expect(retornoInterpretador.erros).toHaveLength(0);
|
|
29
|
+
});
|
|
30
|
+
it('Concatenação', async () => {
|
|
31
|
+
const retornoLexador = delegua.lexador.mapear(["var a = 1 + '1'"], -1);
|
|
32
|
+
const retornoAvaliadorSintatico = delegua.avaliadorSintatico.analisar(retornoLexador);
|
|
33
|
+
const retornoInterpretador = await delegua.interpretador.interpretar(retornoAvaliadorSintatico.declaracoes);
|
|
34
|
+
expect(retornoInterpretador.erros).toHaveLength(0);
|
|
35
|
+
});
|
|
36
|
+
it('Interpolação de Texto', async () => {
|
|
37
|
+
const retornoLexador = delegua.lexador.mapear([
|
|
38
|
+
"var comidaFavorita = 'strogonoff'",
|
|
39
|
+
'escreva("Minha comida favorita é ${comidaFavorita}")'
|
|
40
|
+
], -1);
|
|
41
|
+
const retornoAvaliadorSintatico = delegua.avaliadorSintatico.analisar(retornoLexador);
|
|
42
|
+
const retornoInterpretador = await delegua.interpretador.interpretar(retornoAvaliadorSintatico.declaracoes);
|
|
43
|
+
expect(retornoInterpretador.erros).toHaveLength(0);
|
|
44
|
+
});
|
|
126
45
|
});
|
|
127
|
-
describe('Acesso a variáveis e objetos',
|
|
128
|
-
it('Acesso a elementos de vetor',
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
});
|
|
146
|
-
it('Acesso a elementos de dicionário', function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
147
|
-
var retornoLexador, retornoAvaliadorSintatico, retornoInterpretador;
|
|
148
|
-
return __generator(this, function (_a) {
|
|
149
|
-
switch (_a.label) {
|
|
150
|
-
case 0:
|
|
151
|
-
retornoLexador = delegua.lexador.mapear([
|
|
152
|
-
"var a = {'a': 1, 'b': 2}",
|
|
153
|
-
"escreva(a['b'])"
|
|
154
|
-
], -1);
|
|
155
|
-
retornoAvaliadorSintatico = delegua.avaliadorSintatico.analisar(retornoLexador);
|
|
156
|
-
return [4 /*yield*/, delegua.interpretador.interpretar(retornoAvaliadorSintatico.declaracoes)];
|
|
157
|
-
case 1:
|
|
158
|
-
retornoInterpretador = _a.sent();
|
|
159
|
-
expect(retornoInterpretador.erros).toHaveLength(0);
|
|
160
|
-
return [2 /*return*/];
|
|
161
|
-
}
|
|
162
|
-
});
|
|
163
|
-
}); });
|
|
46
|
+
describe('Acesso a variáveis e objetos', () => {
|
|
47
|
+
it('Acesso a elementos de vetor', async () => {
|
|
48
|
+
const retornoLexador = delegua.lexador.mapear([
|
|
49
|
+
"var a = [1, 2, 3]",
|
|
50
|
+
"escreva(a[1])"
|
|
51
|
+
], -1);
|
|
52
|
+
const retornoAvaliadorSintatico = delegua.avaliadorSintatico.analisar(retornoLexador);
|
|
53
|
+
const retornoInterpretador = await delegua.interpretador.interpretar(retornoAvaliadorSintatico.declaracoes);
|
|
54
|
+
expect(retornoInterpretador.erros).toHaveLength(0);
|
|
55
|
+
});
|
|
56
|
+
it('Acesso a elementos de dicionário', async () => {
|
|
57
|
+
const retornoLexador = delegua.lexador.mapear([
|
|
58
|
+
"var a = {'a': 1, 'b': 2}",
|
|
59
|
+
"escreva(a['b'])"
|
|
60
|
+
], -1);
|
|
61
|
+
const retornoAvaliadorSintatico = delegua.avaliadorSintatico.analisar(retornoLexador);
|
|
62
|
+
const retornoInterpretador = await delegua.interpretador.interpretar(retornoAvaliadorSintatico.declaracoes);
|
|
63
|
+
expect(retornoInterpretador.erros).toHaveLength(0);
|
|
64
|
+
});
|
|
164
65
|
});
|
|
165
|
-
describe('escreva()',
|
|
166
|
-
it('Olá Mundo (escreva() e literal)',
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
});
|
|
196
|
-
it('nulo igual a nulo', function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
197
|
-
var retornoLexador, retornoAvaliadorSintatico, retornoInterpretador;
|
|
198
|
-
return __generator(this, function (_a) {
|
|
199
|
-
switch (_a.label) {
|
|
200
|
-
case 0:
|
|
201
|
-
retornoLexador = delegua.lexador.mapear(["escreva(nulo == nulo)"], -1);
|
|
202
|
-
retornoAvaliadorSintatico = delegua.avaliadorSintatico.analisar(retornoLexador);
|
|
203
|
-
return [4 /*yield*/, delegua.interpretador.interpretar(retornoAvaliadorSintatico.declaracoes)];
|
|
204
|
-
case 1:
|
|
205
|
-
retornoInterpretador = _a.sent();
|
|
206
|
-
expect(retornoInterpretador.erros).toHaveLength(0);
|
|
207
|
-
return [2 /*return*/];
|
|
208
|
-
}
|
|
209
|
-
});
|
|
210
|
-
}); });
|
|
211
|
-
it('verdadeiro', function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
212
|
-
var retornoLexador, retornoAvaliadorSintatico, retornoInterpretador;
|
|
213
|
-
return __generator(this, function (_a) {
|
|
214
|
-
switch (_a.label) {
|
|
215
|
-
case 0:
|
|
216
|
-
retornoLexador = delegua.lexador.mapear(["escreva(verdadeiro)"], -1);
|
|
217
|
-
retornoAvaliadorSintatico = delegua.avaliadorSintatico.analisar(retornoLexador);
|
|
218
|
-
return [4 /*yield*/, delegua.interpretador.interpretar(retornoAvaliadorSintatico.declaracoes)];
|
|
219
|
-
case 1:
|
|
220
|
-
retornoInterpretador = _a.sent();
|
|
221
|
-
expect(retornoInterpretador.erros).toHaveLength(0);
|
|
222
|
-
return [2 /*return*/];
|
|
223
|
-
}
|
|
224
|
-
});
|
|
225
|
-
}); });
|
|
226
|
-
it('falso', function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
227
|
-
var retornoLexador, retornoAvaliadorSintatico, retornoInterpretador;
|
|
228
|
-
return __generator(this, function (_a) {
|
|
229
|
-
switch (_a.label) {
|
|
230
|
-
case 0:
|
|
231
|
-
retornoLexador = delegua.lexador.mapear(["escreva(falso)"], -1);
|
|
232
|
-
retornoAvaliadorSintatico = delegua.avaliadorSintatico.analisar(retornoLexador);
|
|
233
|
-
return [4 /*yield*/, delegua.interpretador.interpretar(retornoAvaliadorSintatico.declaracoes)];
|
|
234
|
-
case 1:
|
|
235
|
-
retornoInterpretador = _a.sent();
|
|
236
|
-
expect(retornoInterpretador.erros).toHaveLength(0);
|
|
237
|
-
return [2 /*return*/];
|
|
238
|
-
}
|
|
239
|
-
});
|
|
240
|
-
}); });
|
|
66
|
+
describe('escreva()', () => {
|
|
67
|
+
it('Olá Mundo (escreva() e literal)', async () => {
|
|
68
|
+
const retornoLexador = delegua.lexador.mapear(["escreva('Olá mundo')"], -1);
|
|
69
|
+
const retornoAvaliadorSintatico = delegua.avaliadorSintatico.analisar(retornoLexador);
|
|
70
|
+
const retornoInterpretador = await delegua.interpretador.interpretar(retornoAvaliadorSintatico.declaracoes);
|
|
71
|
+
expect(retornoInterpretador.erros).toHaveLength(0);
|
|
72
|
+
});
|
|
73
|
+
it('nulo', async () => {
|
|
74
|
+
const retornoLexador = delegua.lexador.mapear(["escreva(nulo)"], -1);
|
|
75
|
+
const retornoAvaliadorSintatico = delegua.avaliadorSintatico.analisar(retornoLexador);
|
|
76
|
+
const retornoInterpretador = await delegua.interpretador.interpretar(retornoAvaliadorSintatico.declaracoes);
|
|
77
|
+
expect(retornoInterpretador.erros).toHaveLength(0);
|
|
78
|
+
});
|
|
79
|
+
it('nulo igual a nulo', async () => {
|
|
80
|
+
const retornoLexador = delegua.lexador.mapear(["escreva(nulo == nulo)"], -1);
|
|
81
|
+
const retornoAvaliadorSintatico = delegua.avaliadorSintatico.analisar(retornoLexador);
|
|
82
|
+
const retornoInterpretador = await delegua.interpretador.interpretar(retornoAvaliadorSintatico.declaracoes);
|
|
83
|
+
expect(retornoInterpretador.erros).toHaveLength(0);
|
|
84
|
+
});
|
|
85
|
+
it('verdadeiro', async () => {
|
|
86
|
+
const retornoLexador = delegua.lexador.mapear(["escreva(verdadeiro)"], -1);
|
|
87
|
+
const retornoAvaliadorSintatico = delegua.avaliadorSintatico.analisar(retornoLexador);
|
|
88
|
+
const retornoInterpretador = await delegua.interpretador.interpretar(retornoAvaliadorSintatico.declaracoes);
|
|
89
|
+
expect(retornoInterpretador.erros).toHaveLength(0);
|
|
90
|
+
});
|
|
91
|
+
it('falso', async () => {
|
|
92
|
+
const retornoLexador = delegua.lexador.mapear(["escreva(falso)"], -1);
|
|
93
|
+
const retornoAvaliadorSintatico = delegua.avaliadorSintatico.analisar(retornoLexador);
|
|
94
|
+
const retornoInterpretador = await delegua.interpretador.interpretar(retornoAvaliadorSintatico.declaracoes);
|
|
95
|
+
expect(retornoInterpretador.erros).toHaveLength(0);
|
|
96
|
+
});
|
|
241
97
|
});
|
|
242
|
-
describe('Importar',
|
|
243
|
-
it('Importar biblioteca externa',
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
retornoInterpretador = _a.sent();
|
|
253
|
-
expect(retornoInterpretador.erros).toHaveLength(0);
|
|
254
|
-
return [2 /*return*/];
|
|
255
|
-
}
|
|
256
|
-
});
|
|
257
|
-
}); });
|
|
258
|
-
describe('Importar bibliotecas delegua', function () {
|
|
259
|
-
describe('testa importação da biblioteca de estatística', function () {
|
|
260
|
-
beforeEach(function () {
|
|
98
|
+
describe('Importar', () => {
|
|
99
|
+
it('Importar biblioteca externa', async () => {
|
|
100
|
+
const retornoLexador = delegua.lexador.mapear(["var commander = importar('commander')"], -1);
|
|
101
|
+
const retornoAvaliadorSintatico = delegua.avaliadorSintatico.analisar(retornoLexador);
|
|
102
|
+
const retornoInterpretador = await delegua.interpretador.interpretar(retornoAvaliadorSintatico.declaracoes);
|
|
103
|
+
expect(retornoInterpretador.erros).toHaveLength(0);
|
|
104
|
+
});
|
|
105
|
+
describe('Importar bibliotecas delegua', () => {
|
|
106
|
+
describe('testa importação da biblioteca de estatística', () => {
|
|
107
|
+
beforeEach(() => {
|
|
261
108
|
jest.mock('./__mocks__/estatistica.ts');
|
|
262
109
|
});
|
|
263
|
-
afterAll(
|
|
110
|
+
afterAll(() => {
|
|
264
111
|
jest.unmock("./__mocks__/estatistica.ts");
|
|
265
112
|
});
|
|
266
|
-
it('estatística',
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
}
|
|
279
|
-
});
|
|
280
|
-
}); });
|
|
281
|
-
it('estatistica', function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
282
|
-
var retornoLexador, retornoAvaliadorSintatico, retornoInterpretador;
|
|
283
|
-
return __generator(this, function (_a) {
|
|
284
|
-
switch (_a.label) {
|
|
285
|
-
case 0:
|
|
286
|
-
retornoLexador = delegua.lexador.mapear(["var estatistica = importar('estatistica')"], -1);
|
|
287
|
-
retornoAvaliadorSintatico = delegua.avaliadorSintatico.analisar(retornoLexador);
|
|
288
|
-
return [4 /*yield*/, delegua.interpretador.interpretar(retornoAvaliadorSintatico.declaracoes)];
|
|
289
|
-
case 1:
|
|
290
|
-
retornoInterpretador = _a.sent();
|
|
291
|
-
expect(retornoInterpretador.erros).toHaveLength(0);
|
|
292
|
-
return [2 /*return*/];
|
|
293
|
-
}
|
|
294
|
-
});
|
|
295
|
-
}); });
|
|
113
|
+
it('estatística', async () => {
|
|
114
|
+
const retornoLexador = delegua.lexador.mapear(["var estatística = importar('estatística')"], -1);
|
|
115
|
+
const retornoAvaliadorSintatico = delegua.avaliadorSintatico.analisar(retornoLexador);
|
|
116
|
+
const retornoInterpretador = await delegua.interpretador.interpretar(retornoAvaliadorSintatico.declaracoes);
|
|
117
|
+
expect(retornoInterpretador.erros).toHaveLength(0);
|
|
118
|
+
});
|
|
119
|
+
it('estatistica', async () => {
|
|
120
|
+
const retornoLexador = delegua.lexador.mapear(["var estatistica = importar('estatistica')"], -1);
|
|
121
|
+
const retornoAvaliadorSintatico = delegua.avaliadorSintatico.analisar(retornoLexador);
|
|
122
|
+
const retornoInterpretador = await delegua.interpretador.interpretar(retornoAvaliadorSintatico.declaracoes);
|
|
123
|
+
expect(retornoInterpretador.erros).toHaveLength(0);
|
|
124
|
+
});
|
|
296
125
|
});
|
|
297
|
-
describe('testa importação da biblioteca de física',
|
|
298
|
-
beforeEach(
|
|
126
|
+
describe('testa importação da biblioteca de física', () => {
|
|
127
|
+
beforeEach(() => {
|
|
299
128
|
jest.mock('./__mocks__/fisica.ts');
|
|
300
129
|
});
|
|
301
|
-
afterEach(
|
|
130
|
+
afterEach(() => {
|
|
302
131
|
jest.unmock("./__mocks__/fisica.ts");
|
|
303
132
|
});
|
|
304
|
-
it('física',
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
}
|
|
317
|
-
});
|
|
318
|
-
}); });
|
|
319
|
-
it('fisica', function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
320
|
-
var retornoLexador, retornoAvaliadorSintatico, retornoInterpretador;
|
|
321
|
-
return __generator(this, function (_a) {
|
|
322
|
-
switch (_a.label) {
|
|
323
|
-
case 0:
|
|
324
|
-
retornoLexador = delegua.lexador.mapear(["var fisica = importar('fisica')"], -1);
|
|
325
|
-
retornoAvaliadorSintatico = delegua.avaliadorSintatico.analisar(retornoLexador);
|
|
326
|
-
return [4 /*yield*/, delegua.interpretador.interpretar(retornoAvaliadorSintatico.declaracoes)];
|
|
327
|
-
case 1:
|
|
328
|
-
retornoInterpretador = _a.sent();
|
|
329
|
-
expect(retornoInterpretador.erros).toHaveLength(0);
|
|
330
|
-
return [2 /*return*/];
|
|
331
|
-
}
|
|
332
|
-
});
|
|
333
|
-
}); });
|
|
133
|
+
it('física', async () => {
|
|
134
|
+
const retornoLexador = delegua.lexador.mapear(["var física = importar('física')"], -1);
|
|
135
|
+
const retornoAvaliadorSintatico = delegua.avaliadorSintatico.analisar(retornoLexador);
|
|
136
|
+
const retornoInterpretador = await delegua.interpretador.interpretar(retornoAvaliadorSintatico.declaracoes);
|
|
137
|
+
expect(retornoInterpretador.erros).toHaveLength(0);
|
|
138
|
+
});
|
|
139
|
+
it('fisica', async () => {
|
|
140
|
+
const retornoLexador = delegua.lexador.mapear(["var fisica = importar('fisica')"], -1);
|
|
141
|
+
const retornoAvaliadorSintatico = delegua.avaliadorSintatico.analisar(retornoLexador);
|
|
142
|
+
const retornoInterpretador = await delegua.interpretador.interpretar(retornoAvaliadorSintatico.declaracoes);
|
|
143
|
+
expect(retornoInterpretador.erros).toHaveLength(0);
|
|
144
|
+
});
|
|
334
145
|
});
|
|
335
|
-
describe('testa importação da biblioteca de matemática',
|
|
336
|
-
beforeEach(
|
|
146
|
+
describe('testa importação da biblioteca de matemática', () => {
|
|
147
|
+
beforeEach(() => {
|
|
337
148
|
jest.mock('./__mocks__/matematica.ts');
|
|
338
149
|
});
|
|
339
|
-
afterAll(
|
|
150
|
+
afterAll(() => {
|
|
340
151
|
jest.unmock("./__mocks__/matematica.ts");
|
|
341
152
|
});
|
|
342
|
-
it('matemática com acento',
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
}
|
|
355
|
-
});
|
|
356
|
-
}); });
|
|
357
|
-
it('matematica sem acento', function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
358
|
-
var retornoLexador, retornoAvaliadorSintatico, retornoInterpretador;
|
|
359
|
-
return __generator(this, function (_a) {
|
|
360
|
-
switch (_a.label) {
|
|
361
|
-
case 0:
|
|
362
|
-
retornoLexador = delegua.lexador.mapear(["var matematica = importar('matematica')"], -1);
|
|
363
|
-
retornoAvaliadorSintatico = delegua.avaliadorSintatico.analisar(retornoLexador);
|
|
364
|
-
return [4 /*yield*/, delegua.interpretador.interpretar(retornoAvaliadorSintatico.declaracoes)];
|
|
365
|
-
case 1:
|
|
366
|
-
retornoInterpretador = _a.sent();
|
|
367
|
-
expect(retornoInterpretador.erros).toHaveLength(0);
|
|
368
|
-
return [2 /*return*/];
|
|
369
|
-
}
|
|
370
|
-
});
|
|
371
|
-
}); });
|
|
153
|
+
it('matemática com acento', async () => {
|
|
154
|
+
const retornoLexador = delegua.lexador.mapear(["var matemática = importar('matemática')"], -1);
|
|
155
|
+
const retornoAvaliadorSintatico = delegua.avaliadorSintatico.analisar(retornoLexador);
|
|
156
|
+
const retornoInterpretador = await delegua.interpretador.interpretar(retornoAvaliadorSintatico.declaracoes);
|
|
157
|
+
expect(retornoInterpretador.erros).toHaveLength(0);
|
|
158
|
+
});
|
|
159
|
+
it('matematica sem acento', async () => {
|
|
160
|
+
const retornoLexador = delegua.lexador.mapear(["var matematica = importar('matematica')"], -1);
|
|
161
|
+
const retornoAvaliadorSintatico = delegua.avaliadorSintatico.analisar(retornoLexador);
|
|
162
|
+
const retornoInterpretador = await delegua.interpretador.interpretar(retornoAvaliadorSintatico.declaracoes);
|
|
163
|
+
expect(retornoInterpretador.erros).toHaveLength(0);
|
|
164
|
+
});
|
|
372
165
|
});
|
|
373
166
|
});
|
|
374
167
|
});
|
|
375
|
-
describe('Delegua com parametro de performance',
|
|
376
|
-
it('performance',
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
retornoAvaliadorSintatico = deleguaPerformance.avaliadorSintatico.analisar(retornoLexador);
|
|
384
|
-
return [4 /*yield*/, deleguaPerformance.interpretador.interpretar(retornoAvaliadorSintatico.declaracoes)];
|
|
385
|
-
case 1:
|
|
386
|
-
retornoInterpretador = _a.sent();
|
|
387
|
-
expect(retornoInterpretador.erros).toHaveLength(0);
|
|
388
|
-
return [2 /*return*/];
|
|
389
|
-
}
|
|
390
|
-
});
|
|
391
|
-
}); });
|
|
168
|
+
describe('Delegua com parametro de performance', () => {
|
|
169
|
+
it('performance', async () => {
|
|
170
|
+
const deleguaPerformance = new delegua_1.Delegua('delegua', true);
|
|
171
|
+
const retornoLexador = deleguaPerformance.lexador.mapear(["escreva(1 + 1)"], -1);
|
|
172
|
+
const retornoAvaliadorSintatico = deleguaPerformance.avaliadorSintatico.analisar(retornoLexador);
|
|
173
|
+
const retornoInterpretador = await deleguaPerformance.interpretador.interpretar(retornoAvaliadorSintatico.declaracoes);
|
|
174
|
+
expect(retornoInterpretador.erros).toHaveLength(0);
|
|
175
|
+
});
|
|
392
176
|
});
|
|
393
|
-
describe('Operações matemáticas',
|
|
394
|
-
it('Operações matemáticas - Trivial',
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
}
|
|
407
|
-
});
|
|
408
|
-
}); });
|
|
409
|
-
it('Operações matemáticas - Subtração', function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
410
|
-
var retornoLexador, retornoAvaliadorSintatico, retornoInterpretador;
|
|
411
|
-
return __generator(this, function (_a) {
|
|
412
|
-
switch (_a.label) {
|
|
413
|
-
case 0:
|
|
414
|
-
retornoLexador = delegua.lexador.mapear(["-1"], -1);
|
|
415
|
-
retornoAvaliadorSintatico = delegua.avaliadorSintatico.analisar(retornoLexador);
|
|
416
|
-
return [4 /*yield*/, delegua.interpretador.interpretar(retornoAvaliadorSintatico.declaracoes)];
|
|
417
|
-
case 1:
|
|
418
|
-
retornoInterpretador = _a.sent();
|
|
419
|
-
expect(retornoInterpretador.erros).toHaveLength(0);
|
|
420
|
-
return [2 /*return*/];
|
|
421
|
-
}
|
|
422
|
-
});
|
|
423
|
-
}); });
|
|
177
|
+
describe('Operações matemáticas', () => {
|
|
178
|
+
it('Operações matemáticas - Trivial', async () => {
|
|
179
|
+
const retornoLexador = delegua.lexador.mapear(["escreva(5 + 4 * 3 - 2 ** 1 / 6 % 10)"], -1);
|
|
180
|
+
const retornoAvaliadorSintatico = delegua.avaliadorSintatico.analisar(retornoLexador);
|
|
181
|
+
const retornoInterpretador = await delegua.interpretador.interpretar(retornoAvaliadorSintatico.declaracoes);
|
|
182
|
+
expect(retornoInterpretador.erros).toHaveLength(0);
|
|
183
|
+
});
|
|
184
|
+
it('Operações matemáticas - Subtração', async () => {
|
|
185
|
+
const retornoLexador = delegua.lexador.mapear(["-1"], -1);
|
|
186
|
+
const retornoAvaliadorSintatico = delegua.avaliadorSintatico.analisar(retornoLexador);
|
|
187
|
+
const retornoInterpretador = await delegua.interpretador.interpretar(retornoAvaliadorSintatico.declaracoes);
|
|
188
|
+
expect(retornoInterpretador.erros).toHaveLength(0);
|
|
189
|
+
});
|
|
424
190
|
});
|
|
425
|
-
describe('Operações lógicas',
|
|
426
|
-
it('Operações lógicas - ou',
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
});
|
|
456
|
-
it('Operações lógicas -
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
});
|
|
486
|
-
it('Operações lógicas - bit a bit não', function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
487
|
-
var retornoLexador, retornoAvaliadorSintatico, retornoInterpretador;
|
|
488
|
-
return __generator(this, function (_a) {
|
|
489
|
-
switch (_a.label) {
|
|
490
|
-
case 0:
|
|
491
|
-
retornoLexador = delegua.lexador.mapear(["~1"], -1);
|
|
492
|
-
retornoAvaliadorSintatico = delegua.avaliadorSintatico.analisar(retornoLexador);
|
|
493
|
-
return [4 /*yield*/, delegua.interpretador.interpretar(retornoAvaliadorSintatico.declaracoes)];
|
|
494
|
-
case 1:
|
|
495
|
-
retornoInterpretador = _a.sent();
|
|
496
|
-
expect(retornoInterpretador.erros).toHaveLength(0);
|
|
497
|
-
return [2 /*return*/];
|
|
498
|
-
}
|
|
499
|
-
});
|
|
500
|
-
}); });
|
|
501
|
-
it('Operações lógicas - menor menor', function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
502
|
-
var retornoLexador, retornoAvaliadorSintatico, retornoInterpretador;
|
|
503
|
-
return __generator(this, function (_a) {
|
|
504
|
-
switch (_a.label) {
|
|
505
|
-
case 0:
|
|
506
|
-
retornoLexador = delegua.lexador.mapear(["1 << 2"], -1);
|
|
507
|
-
retornoAvaliadorSintatico = delegua.avaliadorSintatico.analisar(retornoLexador);
|
|
508
|
-
return [4 /*yield*/, delegua.interpretador.interpretar(retornoAvaliadorSintatico.declaracoes)];
|
|
509
|
-
case 1:
|
|
510
|
-
retornoInterpretador = _a.sent();
|
|
511
|
-
expect(retornoInterpretador.erros).toHaveLength(0);
|
|
512
|
-
return [2 /*return*/];
|
|
513
|
-
}
|
|
514
|
-
});
|
|
515
|
-
}); });
|
|
516
|
-
it('Operações lógicas - maior maior', function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
517
|
-
var retornoLexador, retornoAvaliadorSintatico, retornoInterpretador;
|
|
518
|
-
return __generator(this, function (_a) {
|
|
519
|
-
switch (_a.label) {
|
|
520
|
-
case 0:
|
|
521
|
-
retornoLexador = delegua.lexador.mapear(["2 >> 1"], -1);
|
|
522
|
-
retornoAvaliadorSintatico = delegua.avaliadorSintatico.analisar(retornoLexador);
|
|
523
|
-
return [4 /*yield*/, delegua.interpretador.interpretar(retornoAvaliadorSintatico.declaracoes)];
|
|
524
|
-
case 1:
|
|
525
|
-
retornoInterpretador = _a.sent();
|
|
526
|
-
expect(retornoInterpretador.erros).toHaveLength(0);
|
|
527
|
-
return [2 /*return*/];
|
|
528
|
-
}
|
|
529
|
-
});
|
|
530
|
-
}); });
|
|
531
|
-
it('Operações lógicas - bit ou', function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
532
|
-
var retornoLexador, retornoAvaliadorSintatico, retornoInterpretador;
|
|
533
|
-
return __generator(this, function (_a) {
|
|
534
|
-
switch (_a.label) {
|
|
535
|
-
case 0:
|
|
536
|
-
retornoLexador = delegua.lexador.mapear(["1 | 2"], -1);
|
|
537
|
-
retornoAvaliadorSintatico = delegua.avaliadorSintatico.analisar(retornoLexador);
|
|
538
|
-
return [4 /*yield*/, delegua.interpretador.interpretar(retornoAvaliadorSintatico.declaracoes)];
|
|
539
|
-
case 1:
|
|
540
|
-
retornoInterpretador = _a.sent();
|
|
541
|
-
expect(retornoInterpretador.erros).toHaveLength(0);
|
|
542
|
-
return [2 /*return*/];
|
|
543
|
-
}
|
|
544
|
-
});
|
|
545
|
-
}); });
|
|
546
|
-
it('Operações lógicas - bit e', function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
547
|
-
var retornoLexador, retornoAvaliadorSintatico, retornoInterpretador;
|
|
548
|
-
return __generator(this, function (_a) {
|
|
549
|
-
switch (_a.label) {
|
|
550
|
-
case 0:
|
|
551
|
-
retornoLexador = delegua.lexador.mapear(["1 & 1"], -1);
|
|
552
|
-
retornoAvaliadorSintatico = delegua.avaliadorSintatico.analisar(retornoLexador);
|
|
553
|
-
return [4 /*yield*/, delegua.interpretador.interpretar(retornoAvaliadorSintatico.declaracoes)];
|
|
554
|
-
case 1:
|
|
555
|
-
retornoInterpretador = _a.sent();
|
|
556
|
-
expect(retornoInterpretador.erros).toHaveLength(0);
|
|
557
|
-
return [2 /*return*/];
|
|
558
|
-
}
|
|
559
|
-
});
|
|
560
|
-
}); });
|
|
561
|
-
it('Operações lógicas - bit xor', function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
562
|
-
var retornoLexador, retornoAvaliadorSintatico, retornoInterpretador;
|
|
563
|
-
return __generator(this, function (_a) {
|
|
564
|
-
switch (_a.label) {
|
|
565
|
-
case 0:
|
|
566
|
-
retornoLexador = delegua.lexador.mapear(["1 ^ 2"], -1);
|
|
567
|
-
retornoAvaliadorSintatico = delegua.avaliadorSintatico.analisar(retornoLexador);
|
|
568
|
-
return [4 /*yield*/, delegua.interpretador.interpretar(retornoAvaliadorSintatico.declaracoes)];
|
|
569
|
-
case 1:
|
|
570
|
-
retornoInterpretador = _a.sent();
|
|
571
|
-
expect(retornoInterpretador.erros).toHaveLength(0);
|
|
572
|
-
return [2 /*return*/];
|
|
573
|
-
}
|
|
574
|
-
});
|
|
575
|
-
}); });
|
|
191
|
+
describe('Operações lógicas', () => {
|
|
192
|
+
it('Operações lógicas - ou', async () => {
|
|
193
|
+
const retornoLexador = delegua.lexador.mapear(["escreva(verdadeiro ou falso)"], -1);
|
|
194
|
+
const retornoAvaliadorSintatico = delegua.avaliadorSintatico.analisar(retornoLexador);
|
|
195
|
+
const retornoInterpretador = await delegua.interpretador.interpretar(retornoAvaliadorSintatico.declaracoes);
|
|
196
|
+
expect(retornoInterpretador.erros).toHaveLength(0);
|
|
197
|
+
});
|
|
198
|
+
it('Operações lógicas - e', async () => {
|
|
199
|
+
const retornoLexador = delegua.lexador.mapear(["escreva(verdadeiro e falso)"], -1);
|
|
200
|
+
const retornoAvaliadorSintatico = delegua.avaliadorSintatico.analisar(retornoLexador);
|
|
201
|
+
const retornoInterpretador = await delegua.interpretador.interpretar(retornoAvaliadorSintatico.declaracoes);
|
|
202
|
+
expect(retornoInterpretador.erros).toHaveLength(0);
|
|
203
|
+
});
|
|
204
|
+
it('Operações lógicas - negação', async () => {
|
|
205
|
+
const retornoLexador = delegua.lexador.mapear(["!verdadeiro"], -1);
|
|
206
|
+
const retornoAvaliadorSintatico = delegua.avaliadorSintatico.analisar(retornoLexador);
|
|
207
|
+
const retornoInterpretador = await delegua.interpretador.interpretar(retornoAvaliadorSintatico.declaracoes);
|
|
208
|
+
expect(retornoInterpretador.erros).toHaveLength(0);
|
|
209
|
+
});
|
|
210
|
+
it('Operações lógicas - em', async () => {
|
|
211
|
+
const retornoLexador = delegua.lexador.mapear(["escreva(2 em [1, 2, 3])"], -1);
|
|
212
|
+
const retornoAvaliadorSintatico = delegua.avaliadorSintatico.analisar(retornoLexador);
|
|
213
|
+
const retornoInterpretador = await delegua.interpretador.interpretar(retornoAvaliadorSintatico.declaracoes);
|
|
214
|
+
expect(retornoInterpretador.erros).toHaveLength(0);
|
|
215
|
+
});
|
|
216
|
+
it('Operações lógicas - bit a bit não', async () => {
|
|
217
|
+
const retornoLexador = delegua.lexador.mapear(["~1"], -1);
|
|
218
|
+
const retornoAvaliadorSintatico = delegua.avaliadorSintatico.analisar(retornoLexador);
|
|
219
|
+
const retornoInterpretador = await delegua.interpretador.interpretar(retornoAvaliadorSintatico.declaracoes);
|
|
220
|
+
expect(retornoInterpretador.erros).toHaveLength(0);
|
|
221
|
+
});
|
|
222
|
+
it('Operações lógicas - menor menor', async () => {
|
|
223
|
+
const retornoLexador = delegua.lexador.mapear(["1 << 2"], -1);
|
|
224
|
+
const retornoAvaliadorSintatico = delegua.avaliadorSintatico.analisar(retornoLexador);
|
|
225
|
+
const retornoInterpretador = await delegua.interpretador.interpretar(retornoAvaliadorSintatico.declaracoes);
|
|
226
|
+
expect(retornoInterpretador.erros).toHaveLength(0);
|
|
227
|
+
});
|
|
228
|
+
it('Operações lógicas - maior maior', async () => {
|
|
229
|
+
const retornoLexador = delegua.lexador.mapear(["2 >> 1"], -1);
|
|
230
|
+
const retornoAvaliadorSintatico = delegua.avaliadorSintatico.analisar(retornoLexador);
|
|
231
|
+
const retornoInterpretador = await delegua.interpretador.interpretar(retornoAvaliadorSintatico.declaracoes);
|
|
232
|
+
expect(retornoInterpretador.erros).toHaveLength(0);
|
|
233
|
+
});
|
|
234
|
+
it('Operações lógicas - bit ou', async () => {
|
|
235
|
+
const retornoLexador = delegua.lexador.mapear(["1 | 2"], -1);
|
|
236
|
+
const retornoAvaliadorSintatico = delegua.avaliadorSintatico.analisar(retornoLexador);
|
|
237
|
+
const retornoInterpretador = await delegua.interpretador.interpretar(retornoAvaliadorSintatico.declaracoes);
|
|
238
|
+
expect(retornoInterpretador.erros).toHaveLength(0);
|
|
239
|
+
});
|
|
240
|
+
it('Operações lógicas - bit e', async () => {
|
|
241
|
+
const retornoLexador = delegua.lexador.mapear(["1 & 1"], -1);
|
|
242
|
+
const retornoAvaliadorSintatico = delegua.avaliadorSintatico.analisar(retornoLexador);
|
|
243
|
+
const retornoInterpretador = await delegua.interpretador.interpretar(retornoAvaliadorSintatico.declaracoes);
|
|
244
|
+
expect(retornoInterpretador.erros).toHaveLength(0);
|
|
245
|
+
});
|
|
246
|
+
it('Operações lógicas - bit xor', async () => {
|
|
247
|
+
const retornoLexador = delegua.lexador.mapear(["1 ^ 2"], -1);
|
|
248
|
+
const retornoAvaliadorSintatico = delegua.avaliadorSintatico.analisar(retornoLexador);
|
|
249
|
+
const retornoInterpretador = await delegua.interpretador.interpretar(retornoAvaliadorSintatico.declaracoes);
|
|
250
|
+
expect(retornoInterpretador.erros).toHaveLength(0);
|
|
251
|
+
});
|
|
576
252
|
});
|
|
577
|
-
describe('Escolha - Caso',
|
|
578
|
-
it('Escolha',
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
retornoAvaliadorSintatico = delegua.avaliadorSintatico.analisar(retornoLexador);
|
|
595
|
-
return [4 /*yield*/, delegua.interpretador.interpretar(retornoAvaliadorSintatico.declaracoes)];
|
|
596
|
-
case 1:
|
|
597
|
-
retornoInterpretador = _a.sent();
|
|
598
|
-
expect(retornoInterpretador.erros).toHaveLength(0);
|
|
599
|
-
return [2 /*return*/];
|
|
600
|
-
}
|
|
601
|
-
});
|
|
602
|
-
}); });
|
|
253
|
+
describe('Escolha - Caso', () => {
|
|
254
|
+
it('Escolha', async () => {
|
|
255
|
+
const codigo = [
|
|
256
|
+
"escolha (1) {",
|
|
257
|
+
"caso 1:",
|
|
258
|
+
"escreva('correspondente à opção 1');",
|
|
259
|
+
"caso 2:",
|
|
260
|
+
"escreva('correspondente à opção 2');",
|
|
261
|
+
"padrao:",
|
|
262
|
+
"escreva('Sem opção correspondente');",
|
|
263
|
+
"}"
|
|
264
|
+
];
|
|
265
|
+
const retornoLexador = delegua.lexador.mapear(codigo, -1);
|
|
266
|
+
const retornoAvaliadorSintatico = delegua.avaliadorSintatico.analisar(retornoLexador);
|
|
267
|
+
const retornoInterpretador = await delegua.interpretador.interpretar(retornoAvaliadorSintatico.declaracoes);
|
|
268
|
+
expect(retornoInterpretador.erros).toHaveLength(0);
|
|
269
|
+
});
|
|
603
270
|
});
|
|
604
|
-
describe('Tente - Pegue - Finalmente',
|
|
605
|
-
it('Tente',
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
});
|
|
657
|
-
}); });
|
|
658
|
-
it('Pegue', function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
659
|
-
var codigo, retornoLexador, retornoAvaliadorSintatico, retornoInterpretador;
|
|
660
|
-
return __generator(this, function (_a) {
|
|
661
|
-
switch (_a.label) {
|
|
662
|
-
case 0:
|
|
663
|
-
codigo = [
|
|
664
|
-
"tente {",
|
|
665
|
-
"1 > '1';",
|
|
666
|
-
"escreva('sucesso');",
|
|
667
|
-
"} pegue {",
|
|
668
|
-
"escreva('captura');",
|
|
669
|
-
"} finalmente {",
|
|
670
|
-
"escreva('pronto');",
|
|
671
|
-
"}"
|
|
672
|
-
];
|
|
673
|
-
retornoLexador = delegua.lexador.mapear(codigo, -1);
|
|
674
|
-
retornoAvaliadorSintatico = delegua.avaliadorSintatico.analisar(retornoLexador);
|
|
675
|
-
return [4 /*yield*/, delegua.interpretador.interpretar(retornoAvaliadorSintatico.declaracoes)];
|
|
676
|
-
case 1:
|
|
677
|
-
retornoInterpretador = _a.sent();
|
|
678
|
-
expect(retornoInterpretador.erros).toHaveLength(0);
|
|
679
|
-
return [2 /*return*/];
|
|
680
|
-
}
|
|
681
|
-
});
|
|
682
|
-
}); });
|
|
271
|
+
describe('Tente - Pegue - Finalmente', () => {
|
|
272
|
+
it('Tente', async () => {
|
|
273
|
+
const codigo = [
|
|
274
|
+
"tente {",
|
|
275
|
+
"escreva('sucesso');",
|
|
276
|
+
"} pegue {",
|
|
277
|
+
"escreva('pegue');",
|
|
278
|
+
"} finalmente {",
|
|
279
|
+
"escreva('pronto');",
|
|
280
|
+
"}"
|
|
281
|
+
];
|
|
282
|
+
const retornoLexador = delegua.lexador.mapear(codigo, -1);
|
|
283
|
+
const retornoAvaliadorSintatico = delegua.avaliadorSintatico.analisar(retornoLexador);
|
|
284
|
+
const retornoInterpretador = await delegua.interpretador.interpretar(retornoAvaliadorSintatico.declaracoes);
|
|
285
|
+
expect(retornoInterpretador.erros).toHaveLength(0);
|
|
286
|
+
});
|
|
287
|
+
it.skip('Tente com senão', async () => {
|
|
288
|
+
const codigo = [
|
|
289
|
+
"tente {",
|
|
290
|
+
"se 1 != 1 {",
|
|
291
|
+
"escreva('sucesso');",
|
|
292
|
+
"}",
|
|
293
|
+
"senao {",
|
|
294
|
+
"escreva('é diferente');",
|
|
295
|
+
"}",
|
|
296
|
+
"} pegue {",
|
|
297
|
+
"escreva('pegue');",
|
|
298
|
+
"} finalmente {",
|
|
299
|
+
"escreva('pronto');",
|
|
300
|
+
"}"
|
|
301
|
+
];
|
|
302
|
+
const retornoLexador = delegua.lexador.mapear(codigo, -1);
|
|
303
|
+
const retornoAvaliadorSintatico = delegua.avaliadorSintatico.analisar(retornoLexador);
|
|
304
|
+
const retornoInterpretador = await delegua.interpretador.interpretar(retornoAvaliadorSintatico.declaracoes);
|
|
305
|
+
expect(retornoInterpretador.erros).toHaveLength(0);
|
|
306
|
+
});
|
|
307
|
+
it('Pegue', async () => {
|
|
308
|
+
const codigo = [
|
|
309
|
+
"tente {",
|
|
310
|
+
"1 > '1';",
|
|
311
|
+
"escreva('sucesso');",
|
|
312
|
+
"} pegue {",
|
|
313
|
+
"escreva('captura');",
|
|
314
|
+
"} finalmente {",
|
|
315
|
+
"escreva('pronto');",
|
|
316
|
+
"}"
|
|
317
|
+
];
|
|
318
|
+
const retornoLexador = delegua.lexador.mapear(codigo, -1);
|
|
319
|
+
const retornoAvaliadorSintatico = delegua.avaliadorSintatico.analisar(retornoLexador);
|
|
320
|
+
const retornoInterpretador = await delegua.interpretador.interpretar(retornoAvaliadorSintatico.declaracoes);
|
|
321
|
+
expect(retornoInterpretador.erros).toHaveLength(0);
|
|
322
|
+
});
|
|
683
323
|
}),
|
|
684
|
-
describe('Condicionais',
|
|
685
|
-
it('Condicionais - condição verdadeira',
|
|
686
|
-
|
|
687
|
-
|
|
688
|
-
|
|
689
|
-
|
|
690
|
-
|
|
691
|
-
|
|
692
|
-
|
|
693
|
-
|
|
694
|
-
|
|
695
|
-
|
|
696
|
-
|
|
697
|
-
|
|
698
|
-
});
|
|
699
|
-
|
|
700
|
-
|
|
701
|
-
|
|
702
|
-
|
|
703
|
-
|
|
704
|
-
|
|
705
|
-
|
|
706
|
-
|
|
707
|
-
|
|
708
|
-
|
|
709
|
-
|
|
710
|
-
|
|
711
|
-
|
|
712
|
-
|
|
713
|
-
|
|
714
|
-
}); });
|
|
715
|
-
it('Condicionais - condição menor igual', function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
716
|
-
var retornoLexador, retornoAvaliadorSintatico, retornoInterpretador;
|
|
717
|
-
return __generator(this, function (_a) {
|
|
718
|
-
switch (_a.label) {
|
|
719
|
-
case 0:
|
|
720
|
-
retornoLexador = delegua.lexador.mapear(["se (1 <= 2) { escreva('Um é menor e igual a dois') } senão { escreva('Nunca será executado') }"], -1);
|
|
721
|
-
retornoAvaliadorSintatico = delegua.avaliadorSintatico.analisar(retornoLexador);
|
|
722
|
-
return [4 /*yield*/, delegua.interpretador.interpretar(retornoAvaliadorSintatico.declaracoes)];
|
|
723
|
-
case 1:
|
|
724
|
-
retornoInterpretador = _a.sent();
|
|
725
|
-
expect(retornoInterpretador.erros).toHaveLength(0);
|
|
726
|
-
return [2 /*return*/];
|
|
727
|
-
}
|
|
728
|
-
});
|
|
729
|
-
}); });
|
|
730
|
-
it('Condicionais - condição maior igual', function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
731
|
-
var retornoLexador, retornoAvaliadorSintatico, retornoInterpretador;
|
|
732
|
-
return __generator(this, function (_a) {
|
|
733
|
-
switch (_a.label) {
|
|
734
|
-
case 0:
|
|
735
|
-
retornoLexador = delegua.lexador.mapear(["se (2 >= 1) { escreva('Dois é maior ou igual a um') } senão { escreva('Nunca será executado') }"], -1);
|
|
736
|
-
retornoAvaliadorSintatico = delegua.avaliadorSintatico.analisar(retornoLexador);
|
|
737
|
-
return [4 /*yield*/, delegua.interpretador.interpretar(retornoAvaliadorSintatico.declaracoes)];
|
|
738
|
-
case 1:
|
|
739
|
-
retornoInterpretador = _a.sent();
|
|
740
|
-
expect(retornoInterpretador.erros).toHaveLength(0);
|
|
741
|
-
return [2 /*return*/];
|
|
742
|
-
}
|
|
743
|
-
});
|
|
744
|
-
}); });
|
|
745
|
-
it('Condicionais - condição diferente', function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
746
|
-
var retornoLexador, retornoAvaliadorSintatico, retornoInterpretador;
|
|
747
|
-
return __generator(this, function (_a) {
|
|
748
|
-
switch (_a.label) {
|
|
749
|
-
case 0:
|
|
750
|
-
retornoLexador = delegua.lexador.mapear(["se (2 != 1) { escreva('Dois é diferente de um') } senão { escreva('Nunca será executado') }"], -1);
|
|
751
|
-
retornoAvaliadorSintatico = delegua.avaliadorSintatico.analisar(retornoLexador);
|
|
752
|
-
return [4 /*yield*/, delegua.interpretador.interpretar(retornoAvaliadorSintatico.declaracoes)];
|
|
753
|
-
case 1:
|
|
754
|
-
retornoInterpretador = _a.sent();
|
|
755
|
-
expect(retornoInterpretador.erros).toHaveLength(0);
|
|
756
|
-
return [2 /*return*/];
|
|
757
|
-
}
|
|
758
|
-
});
|
|
759
|
-
}); });
|
|
760
|
-
});
|
|
761
|
-
describe('Laços de repetição', function () {
|
|
762
|
-
it('Laços de repetição - enquanto', function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
763
|
-
var retornoLexador, retornoAvaliadorSintatico, retornoInterpretador;
|
|
764
|
-
return __generator(this, function (_a) {
|
|
765
|
-
switch (_a.label) {
|
|
766
|
-
case 0:
|
|
767
|
-
retornoLexador = delegua.lexador.mapear(["var a = 0;\nenquanto (a < 10) { a = a + 1 }"], -1);
|
|
768
|
-
retornoAvaliadorSintatico = delegua.avaliadorSintatico.analisar(retornoLexador);
|
|
769
|
-
return [4 /*yield*/, delegua.interpretador.interpretar(retornoAvaliadorSintatico.declaracoes)];
|
|
770
|
-
case 1:
|
|
771
|
-
retornoInterpretador = _a.sent();
|
|
772
|
-
expect(retornoInterpretador.erros).toHaveLength(0);
|
|
773
|
-
return [2 /*return*/];
|
|
774
|
-
}
|
|
324
|
+
describe('Condicionais', () => {
|
|
325
|
+
it('Condicionais - condição verdadeira', async () => {
|
|
326
|
+
const retornoLexador = delegua.lexador.mapear(["se (1 < 2) { escreva('Um menor que dois') } senão { escreva('Nunca será executado') }"], -1);
|
|
327
|
+
const retornoAvaliadorSintatico = delegua.avaliadorSintatico.analisar(retornoLexador);
|
|
328
|
+
const retornoInterpretador = await delegua.interpretador.interpretar(retornoAvaliadorSintatico.declaracoes);
|
|
329
|
+
expect(retornoInterpretador.erros).toHaveLength(0);
|
|
330
|
+
});
|
|
331
|
+
it('Condicionais - condição falsa', async () => {
|
|
332
|
+
const retornoLexador = delegua.lexador.mapear(["se (1 > 2) { escreva('Nunca acontece') } senão { escreva('Um não é maior que dois') }"], -1);
|
|
333
|
+
const retornoAvaliadorSintatico = delegua.avaliadorSintatico.analisar(retornoLexador);
|
|
334
|
+
const retornoInterpretador = await delegua.interpretador.interpretar(retornoAvaliadorSintatico.declaracoes);
|
|
335
|
+
expect(retornoInterpretador.erros).toHaveLength(0);
|
|
336
|
+
});
|
|
337
|
+
it('Condicionais - condição menor igual', async () => {
|
|
338
|
+
const retornoLexador = delegua.lexador.mapear(["se (1 <= 2) { escreva('Um é menor e igual a dois') } senão { escreva('Nunca será executado') }"], -1);
|
|
339
|
+
const retornoAvaliadorSintatico = delegua.avaliadorSintatico.analisar(retornoLexador);
|
|
340
|
+
const retornoInterpretador = await delegua.interpretador.interpretar(retornoAvaliadorSintatico.declaracoes);
|
|
341
|
+
expect(retornoInterpretador.erros).toHaveLength(0);
|
|
342
|
+
});
|
|
343
|
+
it('Condicionais - condição maior igual', async () => {
|
|
344
|
+
const retornoLexador = delegua.lexador.mapear(["se (2 >= 1) { escreva('Dois é maior ou igual a um') } senão { escreva('Nunca será executado') }"], -1);
|
|
345
|
+
const retornoAvaliadorSintatico = delegua.avaliadorSintatico.analisar(retornoLexador);
|
|
346
|
+
const retornoInterpretador = await delegua.interpretador.interpretar(retornoAvaliadorSintatico.declaracoes);
|
|
347
|
+
expect(retornoInterpretador.erros).toHaveLength(0);
|
|
348
|
+
});
|
|
349
|
+
it('Condicionais - condição diferente', async () => {
|
|
350
|
+
const retornoLexador = delegua.lexador.mapear(["se (2 != 1) { escreva('Dois é diferente de um') } senão { escreva('Nunca será executado') }"], -1);
|
|
351
|
+
const retornoAvaliadorSintatico = delegua.avaliadorSintatico.analisar(retornoLexador);
|
|
352
|
+
const retornoInterpretador = await delegua.interpretador.interpretar(retornoAvaliadorSintatico.declaracoes);
|
|
353
|
+
expect(retornoInterpretador.erros).toHaveLength(0);
|
|
775
354
|
});
|
|
776
|
-
});
|
|
777
|
-
|
|
778
|
-
|
|
779
|
-
|
|
780
|
-
|
|
781
|
-
|
|
782
|
-
|
|
783
|
-
|
|
784
|
-
|
|
785
|
-
|
|
786
|
-
|
|
787
|
-
|
|
788
|
-
|
|
789
|
-
|
|
790
|
-
|
|
791
|
-
|
|
792
|
-
|
|
793
|
-
|
|
794
|
-
|
|
795
|
-
|
|
796
|
-
|
|
797
|
-
|
|
798
|
-
|
|
799
|
-
case 0:
|
|
800
|
-
retornoLexador = delegua.lexador.mapear(["para (var i = 0; i < 10; i = i + 1) { escreva(i) }"], -1);
|
|
801
|
-
retornoAvaliadorSintatico = delegua.avaliadorSintatico.analisar(retornoLexador);
|
|
802
|
-
return [4 /*yield*/, delegua.interpretador.interpretar(retornoAvaliadorSintatico.declaracoes)];
|
|
803
|
-
case 1:
|
|
804
|
-
retornoInterpretador = _a.sent();
|
|
805
|
-
expect(retornoInterpretador.erros).toHaveLength(0);
|
|
806
|
-
return [2 /*return*/];
|
|
807
|
-
}
|
|
808
|
-
});
|
|
809
|
-
}); });
|
|
355
|
+
});
|
|
356
|
+
describe('Laços de repetição', () => {
|
|
357
|
+
it('Laços de repetição - enquanto', async () => {
|
|
358
|
+
const retornoLexador = delegua.lexador.mapear(["var a = 0;\nenquanto (a < 10) { a = a + 1 }"], -1);
|
|
359
|
+
const retornoAvaliadorSintatico = delegua.avaliadorSintatico.analisar(retornoLexador);
|
|
360
|
+
const retornoInterpretador = await delegua.interpretador.interpretar(retornoAvaliadorSintatico.declaracoes);
|
|
361
|
+
expect(retornoInterpretador.erros).toHaveLength(0);
|
|
362
|
+
});
|
|
363
|
+
it('Laços de repetição - fazer ... enquanto', async () => {
|
|
364
|
+
const retornoLexador = delegua.lexador.mapear([
|
|
365
|
+
"var a = 0",
|
|
366
|
+
"fazer { a = a + 1 } enquanto (a < 10)"
|
|
367
|
+
], -1);
|
|
368
|
+
const retornoAvaliadorSintatico = delegua.avaliadorSintatico.analisar(retornoLexador);
|
|
369
|
+
const retornoInterpretador = await delegua.interpretador.interpretar(retornoAvaliadorSintatico.declaracoes);
|
|
370
|
+
expect(retornoInterpretador.erros).toHaveLength(0);
|
|
371
|
+
});
|
|
372
|
+
it('Laços de repetição - para', async () => {
|
|
373
|
+
const retornoLexador = delegua.lexador.mapear(["para (var i = 0; i < 10; i = i + 1) { escreva(i) }"], -1);
|
|
374
|
+
const retornoAvaliadorSintatico = delegua.avaliadorSintatico.analisar(retornoLexador);
|
|
375
|
+
const retornoInterpretador = await delegua.interpretador.interpretar(retornoAvaliadorSintatico.declaracoes);
|
|
376
|
+
expect(retornoInterpretador.erros).toHaveLength(0);
|
|
377
|
+
});
|
|
810
378
|
});
|
|
811
|
-
describe('Classes',
|
|
812
|
-
it('Trivial',
|
|
813
|
-
|
|
814
|
-
|
|
815
|
-
|
|
816
|
-
|
|
817
|
-
|
|
818
|
-
|
|
819
|
-
|
|
820
|
-
|
|
821
|
-
|
|
822
|
-
|
|
823
|
-
|
|
824
|
-
|
|
825
|
-
|
|
826
|
-
|
|
827
|
-
|
|
828
|
-
|
|
829
|
-
|
|
830
|
-
|
|
831
|
-
|
|
832
|
-
|
|
833
|
-
|
|
834
|
-
retornoAvaliadorSintatico = delegua.avaliadorSintatico.analisar(retornoLexador);
|
|
835
|
-
return [4 /*yield*/, delegua.interpretador.interpretar(retornoAvaliadorSintatico.declaracoes)];
|
|
836
|
-
case 1:
|
|
837
|
-
retornoInterpretador = _a.sent();
|
|
838
|
-
expect(retornoInterpretador.erros).toHaveLength(0);
|
|
839
|
-
return [2 /*return*/];
|
|
840
|
-
}
|
|
841
|
-
});
|
|
842
|
-
}); });
|
|
379
|
+
describe('Classes', () => {
|
|
380
|
+
it('Trivial', async () => {
|
|
381
|
+
const codigo = [
|
|
382
|
+
"classe Animal {",
|
|
383
|
+
" correr() {",
|
|
384
|
+
" escreva('Correndo Loucamente')",
|
|
385
|
+
" }",
|
|
386
|
+
"}",
|
|
387
|
+
"classe Cachorro herda Animal {",
|
|
388
|
+
" latir() {",
|
|
389
|
+
" escreva('Au Au Au Au')",
|
|
390
|
+
" }",
|
|
391
|
+
"}",
|
|
392
|
+
"var nomeDoCachorro = Cachorro()",
|
|
393
|
+
"nomeDoCachorro.correr()",
|
|
394
|
+
"nomeDoCachorro.latir()",
|
|
395
|
+
"escreva('Classe: OK!')"
|
|
396
|
+
];
|
|
397
|
+
const retornoLexador = delegua.lexador.mapear(codigo, -1);
|
|
398
|
+
const retornoAvaliadorSintatico = delegua.avaliadorSintatico.analisar(retornoLexador);
|
|
399
|
+
const retornoInterpretador = await delegua.interpretador.interpretar(retornoAvaliadorSintatico.declaracoes);
|
|
400
|
+
expect(retornoInterpretador.erros).toHaveLength(0);
|
|
401
|
+
});
|
|
843
402
|
});
|
|
844
|
-
describe('Declaração e chamada de funções',
|
|
845
|
-
it('Fibonacci',
|
|
846
|
-
|
|
847
|
-
|
|
848
|
-
|
|
849
|
-
|
|
850
|
-
|
|
851
|
-
|
|
852
|
-
|
|
853
|
-
|
|
854
|
-
|
|
855
|
-
|
|
856
|
-
|
|
857
|
-
|
|
858
|
-
|
|
859
|
-
|
|
860
|
-
|
|
861
|
-
|
|
862
|
-
|
|
863
|
-
|
|
864
|
-
|
|
865
|
-
|
|
866
|
-
|
|
867
|
-
|
|
868
|
-
|
|
869
|
-
|
|
870
|
-
|
|
871
|
-
|
|
872
|
-
|
|
873
|
-
|
|
874
|
-
|
|
875
|
-
|
|
876
|
-
|
|
877
|
-
|
|
878
|
-
retornoAvaliadorSintatico = delegua.avaliadorSintatico.analisar(retornoLexador);
|
|
879
|
-
return [4 /*yield*/, delegua.interpretador.interpretar(retornoAvaliadorSintatico.declaracoes)];
|
|
880
|
-
case 1:
|
|
881
|
-
retornoInterpretador = _a.sent();
|
|
882
|
-
expect(retornoInterpretador.erros).toHaveLength(0);
|
|
883
|
-
return [2 /*return*/];
|
|
884
|
-
}
|
|
885
|
-
});
|
|
886
|
-
}); });
|
|
403
|
+
describe('Declaração e chamada de funções', () => {
|
|
404
|
+
it('Fibonacci', async () => {
|
|
405
|
+
const codigo = [
|
|
406
|
+
"função fibonacci(n) {",
|
|
407
|
+
" se (n == 0) {",
|
|
408
|
+
" retorna(0);",
|
|
409
|
+
" }",
|
|
410
|
+
" se (n == 1) {",
|
|
411
|
+
" retorna(1);",
|
|
412
|
+
" }",
|
|
413
|
+
" var n1 = n - 1;",
|
|
414
|
+
" var n2 = n - 2;",
|
|
415
|
+
" var f1 = fibonacci(n1);",
|
|
416
|
+
" var f2 = fibonacci(n2);",
|
|
417
|
+
" retorna(f1 + f2);",
|
|
418
|
+
"}",
|
|
419
|
+
"var a = fibonacci(0);",
|
|
420
|
+
"escreva(a);",
|
|
421
|
+
"a = fibonacci(1);",
|
|
422
|
+
"escreva(a);",
|
|
423
|
+
"a = fibonacci(2);",
|
|
424
|
+
"escreva(a);",
|
|
425
|
+
"a = fibonacci(3);",
|
|
426
|
+
"escreva(a);",
|
|
427
|
+
"a = fibonacci(4);",
|
|
428
|
+
"escreva(a);",
|
|
429
|
+
"a = fibonacci(5);",
|
|
430
|
+
"escreva(a);"
|
|
431
|
+
];
|
|
432
|
+
const retornoLexador = delegua.lexador.mapear(codigo, -1);
|
|
433
|
+
const retornoAvaliadorSintatico = delegua.avaliadorSintatico.analisar(retornoLexador);
|
|
434
|
+
const retornoInterpretador = await delegua.interpretador.interpretar(retornoAvaliadorSintatico.declaracoes);
|
|
435
|
+
expect(retornoInterpretador.erros).toHaveLength(0);
|
|
436
|
+
});
|
|
887
437
|
});
|
|
888
438
|
});
|
|
889
|
-
describe('Cenários de falha',
|
|
890
|
-
describe('Acesso a variáveis e objetos',
|
|
891
|
-
it('Acesso a elementos de vetor',
|
|
892
|
-
|
|
893
|
-
|
|
894
|
-
|
|
895
|
-
|
|
896
|
-
|
|
897
|
-
|
|
898
|
-
|
|
899
|
-
|
|
900
|
-
|
|
901
|
-
|
|
902
|
-
|
|
903
|
-
|
|
904
|
-
|
|
905
|
-
|
|
906
|
-
|
|
907
|
-
|
|
908
|
-
});
|
|
909
|
-
it('Acesso a elementos de dicionário', function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
910
|
-
var retornoLexador, retornoAvaliadorSintatico, retornoInterpretador;
|
|
911
|
-
return __generator(this, function (_a) {
|
|
912
|
-
switch (_a.label) {
|
|
913
|
-
case 0:
|
|
914
|
-
retornoLexador = delegua.lexador.mapear([
|
|
915
|
-
"var a = {'a': 1, 'b': 2};",
|
|
916
|
-
"escreva(a['c']);"
|
|
917
|
-
], -1);
|
|
918
|
-
retornoAvaliadorSintatico = delegua.avaliadorSintatico.analisar(retornoLexador);
|
|
919
|
-
return [4 /*yield*/, delegua.interpretador.interpretar(retornoAvaliadorSintatico.declaracoes)];
|
|
920
|
-
case 1:
|
|
921
|
-
retornoInterpretador = _a.sent();
|
|
922
|
-
expect(retornoInterpretador.erros.length).toBeGreaterThanOrEqual(0);
|
|
923
|
-
return [2 /*return*/];
|
|
924
|
-
}
|
|
925
|
-
});
|
|
926
|
-
}); });
|
|
439
|
+
describe('Cenários de falha', () => {
|
|
440
|
+
describe('Acesso a variáveis e objetos', () => {
|
|
441
|
+
it('Acesso a elementos de vetor', async () => {
|
|
442
|
+
const retornoLexador = delegua.lexador.mapear([
|
|
443
|
+
"var a = [1, 2, 3];",
|
|
444
|
+
"escreva(a[4]);"
|
|
445
|
+
], -1);
|
|
446
|
+
const retornoAvaliadorSintatico = delegua.avaliadorSintatico.analisar(retornoLexador);
|
|
447
|
+
const retornoInterpretador = await delegua.interpretador.interpretar(retornoAvaliadorSintatico.declaracoes);
|
|
448
|
+
expect(retornoInterpretador.erros.length).toBeGreaterThan(0);
|
|
449
|
+
});
|
|
450
|
+
it('Acesso a elementos de dicionário', async () => {
|
|
451
|
+
const retornoLexador = delegua.lexador.mapear([
|
|
452
|
+
"var a = {'a': 1, 'b': 2};",
|
|
453
|
+
"escreva(a['c']);"
|
|
454
|
+
], -1);
|
|
455
|
+
const retornoAvaliadorSintatico = delegua.avaliadorSintatico.analisar(retornoLexador);
|
|
456
|
+
const retornoInterpretador = await delegua.interpretador.interpretar(retornoAvaliadorSintatico.declaracoes);
|
|
457
|
+
expect(retornoInterpretador.erros.length).toBeGreaterThanOrEqual(0);
|
|
458
|
+
});
|
|
927
459
|
});
|
|
928
|
-
describe('Importar',
|
|
929
|
-
it('Importar biblioteca externa que não existe',
|
|
930
|
-
|
|
931
|
-
|
|
932
|
-
|
|
933
|
-
|
|
934
|
-
|
|
935
|
-
retornoAvaliadorSintatico = delegua.avaliadorSintatico.analisar(retornoLexador);
|
|
936
|
-
return [4 /*yield*/, delegua.interpretador.interpretar(retornoAvaliadorSintatico.declaracoes)];
|
|
937
|
-
case 1:
|
|
938
|
-
retornoInterpretador = _a.sent();
|
|
939
|
-
expect(retornoInterpretador.erros.length).toBeGreaterThan(0);
|
|
940
|
-
return [2 /*return*/];
|
|
941
|
-
}
|
|
942
|
-
});
|
|
943
|
-
}); });
|
|
460
|
+
describe('Importar', () => {
|
|
461
|
+
it('Importar biblioteca externa que não existe', async () => {
|
|
462
|
+
const retornoLexador = delegua.lexador.mapear(["var naoexiste = importar('naoexiste')"], -1);
|
|
463
|
+
const retornoAvaliadorSintatico = delegua.avaliadorSintatico.analisar(retornoLexador);
|
|
464
|
+
const retornoInterpretador = await delegua.interpretador.interpretar(retornoAvaliadorSintatico.declaracoes);
|
|
465
|
+
expect(retornoInterpretador.erros.length).toBeGreaterThan(0);
|
|
466
|
+
});
|
|
944
467
|
});
|
|
945
468
|
});
|
|
946
469
|
});
|