@designliquido/delegua 0.9.3 → 0.9.5
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/README.md +25 -3
- package/bin/delegua +1 -1
- package/bin/delegua.cmd +1 -1
- package/bin/package.json +7 -5
- 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.js +108 -105
- package/fontes/avaliador-sintatico/avaliador-sintatico-base.js.map +1 -1
- package/fontes/avaliador-sintatico/avaliador-sintatico.js +226 -232
- package/fontes/avaliador-sintatico/avaliador-sintatico.js.map +1 -1
- package/fontes/avaliador-sintatico/dialetos/avaliador-sintatico-birl.js +35 -55
- package/fontes/avaliador-sintatico/dialetos/avaliador-sintatico-birl.js.map +1 -1
- package/fontes/avaliador-sintatico/dialetos/avaliador-sintatico-egua-classico.js +211 -216
- package/fontes/avaliador-sintatico/dialetos/avaliador-sintatico-egua-classico.js.map +1 -1
- package/fontes/avaliador-sintatico/dialetos/avaliador-sintatico-eguap.js +231 -237
- 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 +188 -121
- 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 +117 -200
- 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/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 +1 -0
- package/fontes/lexador/dialetos/lexador-birl.js +55 -64
- 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.js +1 -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.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 +1 -0
- package/fontes/tipos-de-simbolos/birl.js +1 -0
- 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 +4 -0
- package/index.js +4 -26
- package/index.js.map +1 -1
- package/jest.config.js +9 -47
- package/jest.config.js.map +1 -1
- package/package.json +7 -5
- 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.js +8 -8
- package/testes/birl/avaliador-sintatico.test.js.map +1 -1
- package/testes/birl/lexador.test.js +10 -10
- package/testes/birl/lexador.test.js.map +1 -1
- 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,413 +1,197 @@
|
|
|
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 (Égua Clássico)',
|
|
41
|
-
describe('interpretar()',
|
|
42
|
-
|
|
43
|
-
beforeEach(
|
|
3
|
+
const delegua_1 = require("../../fontes/delegua");
|
|
4
|
+
describe('Interpretador (Égua Clássico)', () => {
|
|
5
|
+
describe('interpretar()', () => {
|
|
6
|
+
let delegua;
|
|
7
|
+
beforeEach(() => {
|
|
44
8
|
delegua = new delegua_1.Delegua('egua');
|
|
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
|
-
switch (_a.label) {
|
|
67
|
-
case 0:
|
|
68
|
-
retornoLexador = delegua.lexador.mapear(["var a = [1, 2, 3];"], -1);
|
|
69
|
-
retornoAvaliadorSintatico = delegua.avaliadorSintatico.analisar(retornoLexador);
|
|
70
|
-
return [4 /*yield*/, delegua.interpretador.interpretar(retornoAvaliadorSintatico.declaracoes)];
|
|
71
|
-
case 1:
|
|
72
|
-
retornoInterpretador = _a.sent();
|
|
73
|
-
expect(retornoInterpretador.erros).toHaveLength(0);
|
|
74
|
-
return [2 /*return*/];
|
|
75
|
-
}
|
|
76
|
-
});
|
|
77
|
-
}); });
|
|
78
|
-
it('Dicionário', function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
79
|
-
var retornoLexador, retornoAvaliadorSintatico, retornoInterpretador;
|
|
80
|
-
return __generator(this, function (_a) {
|
|
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
|
-
}); });
|
|
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
|
+
});
|
|
93
30
|
});
|
|
94
|
-
describe('Acesso a variáveis e objetos',
|
|
95
|
-
it('Acesso a elementos de vetor',
|
|
96
|
-
var
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
}
|
|
108
|
-
});
|
|
109
|
-
}); });
|
|
110
|
-
it('Acesso a elementos de dicionário', function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
111
|
-
var retornoLexador, retornoAvaliadorSintatico, retornoInterpretador;
|
|
112
|
-
return __generator(this, function (_a) {
|
|
113
|
-
switch (_a.label) {
|
|
114
|
-
case 0:
|
|
115
|
-
retornoLexador = delegua.lexador.mapear(["var a = {'a': 1, 'b': 2};\nescreva(a['b']);"], -1);
|
|
116
|
-
retornoAvaliadorSintatico = delegua.avaliadorSintatico.analisar(retornoLexador);
|
|
117
|
-
return [4 /*yield*/, delegua.interpretador.interpretar(retornoAvaliadorSintatico.declaracoes)];
|
|
118
|
-
case 1:
|
|
119
|
-
retornoInterpretador = _a.sent();
|
|
120
|
-
expect(retornoInterpretador.erros).toHaveLength(0);
|
|
121
|
-
return [2 /*return*/];
|
|
122
|
-
}
|
|
123
|
-
});
|
|
124
|
-
}); });
|
|
31
|
+
describe('Acesso a variáveis e objetos', () => {
|
|
32
|
+
it('Acesso a elementos de vetor', async () => {
|
|
33
|
+
const retornoLexador = delegua.lexador.mapear(["var a = [1, 2, 3];\nescreva(a[1]);"], -1);
|
|
34
|
+
const retornoAvaliadorSintatico = delegua.avaliadorSintatico.analisar(retornoLexador);
|
|
35
|
+
const retornoInterpretador = await delegua.interpretador.interpretar(retornoAvaliadorSintatico.declaracoes);
|
|
36
|
+
expect(retornoInterpretador.erros).toHaveLength(0);
|
|
37
|
+
});
|
|
38
|
+
it('Acesso a elementos de dicionário', async () => {
|
|
39
|
+
const retornoLexador = delegua.lexador.mapear(["var a = {'a': 1, 'b': 2};\nescreva(a['b']);"], -1);
|
|
40
|
+
const retornoAvaliadorSintatico = delegua.avaliadorSintatico.analisar(retornoLexador);
|
|
41
|
+
const retornoInterpretador = await delegua.interpretador.interpretar(retornoAvaliadorSintatico.declaracoes);
|
|
42
|
+
expect(retornoInterpretador.erros).toHaveLength(0);
|
|
43
|
+
});
|
|
125
44
|
});
|
|
126
|
-
describe('escreva()',
|
|
127
|
-
it('Olá Mundo (escreva() e literal)',
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
}
|
|
140
|
-
});
|
|
141
|
-
}); });
|
|
142
|
-
it('nulo', function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
143
|
-
var retornoLexador, retornoAvaliadorSintatico, retornoInterpretador;
|
|
144
|
-
return __generator(this, function (_a) {
|
|
145
|
-
switch (_a.label) {
|
|
146
|
-
case 0:
|
|
147
|
-
retornoLexador = delegua.lexador.mapear(["escreva(nulo);"], -1);
|
|
148
|
-
retornoAvaliadorSintatico = delegua.avaliadorSintatico.analisar(retornoLexador);
|
|
149
|
-
return [4 /*yield*/, delegua.interpretador.interpretar(retornoAvaliadorSintatico.declaracoes)];
|
|
150
|
-
case 1:
|
|
151
|
-
retornoInterpretador = _a.sent();
|
|
152
|
-
expect(retornoInterpretador.erros).toHaveLength(0);
|
|
153
|
-
return [2 /*return*/];
|
|
154
|
-
}
|
|
155
|
-
});
|
|
156
|
-
}); });
|
|
45
|
+
describe('escreva()', () => {
|
|
46
|
+
it('Olá Mundo (escreva() e literal)', async () => {
|
|
47
|
+
const retornoLexador = delegua.lexador.mapear(["escreva('Olá mundo');"], -1);
|
|
48
|
+
const retornoAvaliadorSintatico = delegua.avaliadorSintatico.analisar(retornoLexador);
|
|
49
|
+
const retornoInterpretador = await delegua.interpretador.interpretar(retornoAvaliadorSintatico.declaracoes);
|
|
50
|
+
expect(retornoInterpretador.erros).toHaveLength(0);
|
|
51
|
+
});
|
|
52
|
+
it('nulo', async () => {
|
|
53
|
+
const retornoLexador = delegua.lexador.mapear(["escreva(nulo);"], -1);
|
|
54
|
+
const retornoAvaliadorSintatico = delegua.avaliadorSintatico.analisar(retornoLexador);
|
|
55
|
+
const retornoInterpretador = await delegua.interpretador.interpretar(retornoAvaliadorSintatico.declaracoes);
|
|
56
|
+
expect(retornoInterpretador.erros).toHaveLength(0);
|
|
57
|
+
});
|
|
157
58
|
});
|
|
158
|
-
describe('Operações matemáticas',
|
|
159
|
-
it('Operações matemáticas - Trivial',
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
retornoAvaliadorSintatico = delegua.avaliadorSintatico.analisar(retornoLexador);
|
|
166
|
-
return [4 /*yield*/, delegua.interpretador.interpretar(retornoAvaliadorSintatico.declaracoes)];
|
|
167
|
-
case 1:
|
|
168
|
-
retornoInterpretador = _a.sent();
|
|
169
|
-
expect(retornoInterpretador.erros).toHaveLength(0);
|
|
170
|
-
return [2 /*return*/];
|
|
171
|
-
}
|
|
172
|
-
});
|
|
173
|
-
}); });
|
|
59
|
+
describe('Operações matemáticas', () => {
|
|
60
|
+
it('Operações matemáticas - Trivial', async () => {
|
|
61
|
+
const retornoLexador = delegua.lexador.mapear(["escreva(5 + 4 * 3 - 2 ** 1 / 6 % 10);"], -1);
|
|
62
|
+
const retornoAvaliadorSintatico = delegua.avaliadorSintatico.analisar(retornoLexador);
|
|
63
|
+
const retornoInterpretador = await delegua.interpretador.interpretar(retornoAvaliadorSintatico.declaracoes);
|
|
64
|
+
expect(retornoInterpretador.erros).toHaveLength(0);
|
|
65
|
+
});
|
|
174
66
|
});
|
|
175
|
-
describe('Operações lógicas',
|
|
176
|
-
it('Operações lógicas - ou',
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
switch (_a.label) {
|
|
195
|
-
case 0:
|
|
196
|
-
retornoLexador = delegua.lexador.mapear(["escreva(verdadeiro e falso);"], -1);
|
|
197
|
-
retornoAvaliadorSintatico = delegua.avaliadorSintatico.analisar(retornoLexador);
|
|
198
|
-
return [4 /*yield*/, delegua.interpretador.interpretar(retornoAvaliadorSintatico.declaracoes)];
|
|
199
|
-
case 1:
|
|
200
|
-
retornoInterpretador = _a.sent();
|
|
201
|
-
expect(retornoInterpretador.erros).toHaveLength(0);
|
|
202
|
-
return [2 /*return*/];
|
|
203
|
-
}
|
|
204
|
-
});
|
|
205
|
-
}); });
|
|
206
|
-
it('Operações lógicas - em', function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
207
|
-
var retornoLexador, retornoAvaliadorSintatico, retornoInterpretador;
|
|
208
|
-
return __generator(this, function (_a) {
|
|
209
|
-
switch (_a.label) {
|
|
210
|
-
case 0:
|
|
211
|
-
retornoLexador = delegua.lexador.mapear(["escreva(2 em [1, 2, 3]);"], -1);
|
|
212
|
-
retornoAvaliadorSintatico = delegua.avaliadorSintatico.analisar(retornoLexador);
|
|
213
|
-
return [4 /*yield*/, delegua.interpretador.interpretar(retornoAvaliadorSintatico.declaracoes)];
|
|
214
|
-
case 1:
|
|
215
|
-
retornoInterpretador = _a.sent();
|
|
216
|
-
expect(retornoInterpretador.erros).toHaveLength(0);
|
|
217
|
-
return [2 /*return*/];
|
|
218
|
-
}
|
|
219
|
-
});
|
|
220
|
-
}); });
|
|
67
|
+
describe('Operações lógicas', () => {
|
|
68
|
+
it('Operações lógicas - ou', async () => {
|
|
69
|
+
const retornoLexador = delegua.lexador.mapear(["escreva(verdadeiro ou falso);"], -1);
|
|
70
|
+
const retornoAvaliadorSintatico = delegua.avaliadorSintatico.analisar(retornoLexador);
|
|
71
|
+
const retornoInterpretador = await delegua.interpretador.interpretar(retornoAvaliadorSintatico.declaracoes);
|
|
72
|
+
expect(retornoInterpretador.erros).toHaveLength(0);
|
|
73
|
+
});
|
|
74
|
+
it('Operações lógicas - e', async () => {
|
|
75
|
+
const retornoLexador = delegua.lexador.mapear(["escreva(verdadeiro e falso);"], -1);
|
|
76
|
+
const retornoAvaliadorSintatico = delegua.avaliadorSintatico.analisar(retornoLexador);
|
|
77
|
+
const retornoInterpretador = await delegua.interpretador.interpretar(retornoAvaliadorSintatico.declaracoes);
|
|
78
|
+
expect(retornoInterpretador.erros).toHaveLength(0);
|
|
79
|
+
});
|
|
80
|
+
it('Operações lógicas - em', async () => {
|
|
81
|
+
const retornoLexador = delegua.lexador.mapear(["escreva(2 em [1, 2, 3]);"], -1);
|
|
82
|
+
const retornoAvaliadorSintatico = delegua.avaliadorSintatico.analisar(retornoLexador);
|
|
83
|
+
const retornoInterpretador = await delegua.interpretador.interpretar(retornoAvaliadorSintatico.declaracoes);
|
|
84
|
+
expect(retornoInterpretador.erros).toHaveLength(0);
|
|
85
|
+
});
|
|
221
86
|
});
|
|
222
|
-
describe('Condicionais',
|
|
223
|
-
it('Condicionais - condição verdadeira',
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
}
|
|
236
|
-
});
|
|
237
|
-
}); });
|
|
238
|
-
it('Condicionais - condição falsa', function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
239
|
-
var retornoLexador, retornoAvaliadorSintatico, retornoInterpretador;
|
|
240
|
-
return __generator(this, function (_a) {
|
|
241
|
-
switch (_a.label) {
|
|
242
|
-
case 0:
|
|
243
|
-
retornoLexador = delegua.lexador.mapear(["se (1 > 2) { escreva('Nunca acontece'); } senão { escreva('Um não é maior que dois'); }"], -1);
|
|
244
|
-
retornoAvaliadorSintatico = delegua.avaliadorSintatico.analisar(retornoLexador);
|
|
245
|
-
return [4 /*yield*/, delegua.interpretador.interpretar(retornoAvaliadorSintatico.declaracoes)];
|
|
246
|
-
case 1:
|
|
247
|
-
retornoInterpretador = _a.sent();
|
|
248
|
-
expect(retornoInterpretador.erros).toHaveLength(0);
|
|
249
|
-
return [2 /*return*/];
|
|
250
|
-
}
|
|
251
|
-
});
|
|
252
|
-
}); });
|
|
87
|
+
describe('Condicionais', () => {
|
|
88
|
+
it('Condicionais - condição verdadeira', async () => {
|
|
89
|
+
const retornoLexador = delegua.lexador.mapear(["se (1 < 2) { escreva('Um menor que dois'); } senão { escreva('Nunca será executado'); }"], -1);
|
|
90
|
+
const retornoAvaliadorSintatico = delegua.avaliadorSintatico.analisar(retornoLexador);
|
|
91
|
+
const retornoInterpretador = await delegua.interpretador.interpretar(retornoAvaliadorSintatico.declaracoes);
|
|
92
|
+
expect(retornoInterpretador.erros).toHaveLength(0);
|
|
93
|
+
});
|
|
94
|
+
it('Condicionais - condição falsa', async () => {
|
|
95
|
+
const retornoLexador = delegua.lexador.mapear(["se (1 > 2) { escreva('Nunca acontece'); } senão { escreva('Um não é maior que dois'); }"], -1);
|
|
96
|
+
const retornoAvaliadorSintatico = delegua.avaliadorSintatico.analisar(retornoLexador);
|
|
97
|
+
const retornoInterpretador = await delegua.interpretador.interpretar(retornoAvaliadorSintatico.declaracoes);
|
|
98
|
+
expect(retornoInterpretador.erros).toHaveLength(0);
|
|
99
|
+
});
|
|
253
100
|
});
|
|
254
|
-
describe('Laços de repetição',
|
|
255
|
-
it('Laços de repetição - enquanto',
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
});
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
switch (_a.label) {
|
|
274
|
-
case 0:
|
|
275
|
-
retornoLexador = delegua.lexador.mapear(["var a = 0;\nfazer { a = a + 1; } enquanto (a < 10)"], -1);
|
|
276
|
-
retornoAvaliadorSintatico = delegua.avaliadorSintatico.analisar(retornoLexador);
|
|
277
|
-
return [4 /*yield*/, delegua.interpretador.interpretar(retornoAvaliadorSintatico.declaracoes)];
|
|
278
|
-
case 1:
|
|
279
|
-
retornoInterpretador = _a.sent();
|
|
280
|
-
expect(retornoInterpretador.erros).toHaveLength(0);
|
|
281
|
-
return [2 /*return*/];
|
|
282
|
-
}
|
|
283
|
-
});
|
|
284
|
-
}); });
|
|
285
|
-
it('Laços de repetição - para', function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
286
|
-
var retornoLexador, retornoAvaliadorSintatico, retornoInterpretador;
|
|
287
|
-
return __generator(this, function (_a) {
|
|
288
|
-
switch (_a.label) {
|
|
289
|
-
case 0:
|
|
290
|
-
retornoLexador = delegua.lexador.mapear(["para (var i = 0; i < 10; i = i + 1) { escreva(i); }"], -1);
|
|
291
|
-
retornoAvaliadorSintatico = delegua.avaliadorSintatico.analisar(retornoLexador);
|
|
292
|
-
return [4 /*yield*/, delegua.interpretador.interpretar(retornoAvaliadorSintatico.declaracoes)];
|
|
293
|
-
case 1:
|
|
294
|
-
retornoInterpretador = _a.sent();
|
|
295
|
-
expect(retornoInterpretador.erros).toHaveLength(0);
|
|
296
|
-
return [2 /*return*/];
|
|
297
|
-
}
|
|
298
|
-
});
|
|
299
|
-
}); });
|
|
101
|
+
describe('Laços de repetição', () => {
|
|
102
|
+
it('Laços de repetição - enquanto', async () => {
|
|
103
|
+
const retornoLexador = delegua.lexador.mapear(["var a = 0;\nenquanto (a < 10) { a = a + 1; }"], -1);
|
|
104
|
+
const retornoAvaliadorSintatico = delegua.avaliadorSintatico.analisar(retornoLexador);
|
|
105
|
+
const retornoInterpretador = await delegua.interpretador.interpretar(retornoAvaliadorSintatico.declaracoes);
|
|
106
|
+
expect(retornoInterpretador.erros).toHaveLength(0);
|
|
107
|
+
});
|
|
108
|
+
it('Laços de repetição - fazer ... enquanto', async () => {
|
|
109
|
+
const retornoLexador = delegua.lexador.mapear(["var a = 0;\nfazer { a = a + 1; } enquanto (a < 10)"], -1);
|
|
110
|
+
const retornoAvaliadorSintatico = delegua.avaliadorSintatico.analisar(retornoLexador);
|
|
111
|
+
const retornoInterpretador = await delegua.interpretador.interpretar(retornoAvaliadorSintatico.declaracoes);
|
|
112
|
+
expect(retornoInterpretador.erros).toHaveLength(0);
|
|
113
|
+
});
|
|
114
|
+
it('Laços de repetição - para', async () => {
|
|
115
|
+
const retornoLexador = delegua.lexador.mapear(["para (var i = 0; i < 10; i = i + 1) { escreva(i); }"], -1);
|
|
116
|
+
const retornoAvaliadorSintatico = delegua.avaliadorSintatico.analisar(retornoLexador);
|
|
117
|
+
const retornoInterpretador = await delegua.interpretador.interpretar(retornoAvaliadorSintatico.declaracoes);
|
|
118
|
+
expect(retornoInterpretador.erros).toHaveLength(0);
|
|
119
|
+
});
|
|
300
120
|
});
|
|
301
|
-
describe('Classes',
|
|
302
|
-
it('Trivial',
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
retornoAvaliadorSintatico = delegua.avaliadorSintatico.analisar(retornoLexador);
|
|
325
|
-
return [4 /*yield*/, delegua.interpretador.interpretar(retornoAvaliadorSintatico.declaracoes)];
|
|
326
|
-
case 1:
|
|
327
|
-
retornoInterpretador = _a.sent();
|
|
328
|
-
expect(retornoInterpretador.erros).toHaveLength(0);
|
|
329
|
-
return [2 /*return*/];
|
|
330
|
-
}
|
|
331
|
-
});
|
|
332
|
-
}); });
|
|
121
|
+
describe('Classes', () => {
|
|
122
|
+
it('Trivial', async () => {
|
|
123
|
+
const codigo = [
|
|
124
|
+
"classe Animal {",
|
|
125
|
+
" correr() {",
|
|
126
|
+
" escreva('Correndo Loucamente');",
|
|
127
|
+
" }",
|
|
128
|
+
"}",
|
|
129
|
+
"classe Cachorro herda Animal {",
|
|
130
|
+
" latir() {",
|
|
131
|
+
" escreva('Au Au Au Au');",
|
|
132
|
+
" }",
|
|
133
|
+
"}",
|
|
134
|
+
"var nomeDoCachorro = Cachorro();",
|
|
135
|
+
"nomeDoCachorro.correr();",
|
|
136
|
+
"nomeDoCachorro.latir();",
|
|
137
|
+
"escreva('Classe: OK!');"
|
|
138
|
+
];
|
|
139
|
+
const retornoLexador = delegua.lexador.mapear(codigo, -1);
|
|
140
|
+
const retornoAvaliadorSintatico = delegua.avaliadorSintatico.analisar(retornoLexador);
|
|
141
|
+
const retornoInterpretador = await delegua.interpretador.interpretar(retornoAvaliadorSintatico.declaracoes);
|
|
142
|
+
expect(retornoInterpretador.erros).toHaveLength(0);
|
|
143
|
+
});
|
|
333
144
|
});
|
|
334
|
-
describe('Declaração e chamada de funções',
|
|
335
|
-
it('Fibonacci',
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
retornoAvaliadorSintatico = delegua.avaliadorSintatico.analisar(retornoLexador);
|
|
369
|
-
return [4 /*yield*/, delegua.interpretador.interpretar(retornoAvaliadorSintatico.declaracoes)];
|
|
370
|
-
case 1:
|
|
371
|
-
retornoInterpretador = _a.sent();
|
|
372
|
-
expect(retornoInterpretador.erros).toHaveLength(0);
|
|
373
|
-
return [2 /*return*/];
|
|
374
|
-
}
|
|
375
|
-
});
|
|
376
|
-
}); });
|
|
145
|
+
describe('Declaração e chamada de funções', () => {
|
|
146
|
+
it('Fibonacci', async () => {
|
|
147
|
+
const codigo = [
|
|
148
|
+
"função fibonacci(n) {",
|
|
149
|
+
" se (n == 0) {",
|
|
150
|
+
" retorna(0);",
|
|
151
|
+
" }",
|
|
152
|
+
" se (n == 1) {",
|
|
153
|
+
" retorna(1);",
|
|
154
|
+
" }",
|
|
155
|
+
" var n1 = n - 1;",
|
|
156
|
+
" var n2 = n - 2;",
|
|
157
|
+
" var f1 = fibonacci(n1);",
|
|
158
|
+
" var f2 = fibonacci(n2);",
|
|
159
|
+
" retorna(f1 + f2);",
|
|
160
|
+
"}",
|
|
161
|
+
"var a = fibonacci(0);",
|
|
162
|
+
"escreva(a);",
|
|
163
|
+
"a = fibonacci(1);",
|
|
164
|
+
"escreva(a);",
|
|
165
|
+
"a = fibonacci(2);",
|
|
166
|
+
"escreva(a);",
|
|
167
|
+
"a = fibonacci(3);",
|
|
168
|
+
"escreva(a);",
|
|
169
|
+
"a = fibonacci(4);",
|
|
170
|
+
"escreva(a);",
|
|
171
|
+
"a = fibonacci(5);",
|
|
172
|
+
"escreva(a);"
|
|
173
|
+
];
|
|
174
|
+
const retornoLexador = delegua.lexador.mapear(codigo, -1);
|
|
175
|
+
const retornoAvaliadorSintatico = delegua.avaliadorSintatico.analisar(retornoLexador);
|
|
176
|
+
const retornoInterpretador = await delegua.interpretador.interpretar(retornoAvaliadorSintatico.declaracoes);
|
|
177
|
+
expect(retornoInterpretador.erros).toHaveLength(0);
|
|
178
|
+
});
|
|
377
179
|
});
|
|
378
180
|
});
|
|
379
|
-
describe('Cenários de falha',
|
|
380
|
-
describe('Acesso a variáveis e objetos',
|
|
381
|
-
it('Acesso a elementos de vetor',
|
|
382
|
-
var
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
}
|
|
394
|
-
});
|
|
395
|
-
}); });
|
|
396
|
-
it('Acesso a elementos de dicionário', function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
397
|
-
var retornoLexador, retornoAvaliadorSintatico, retornoInterpretador;
|
|
398
|
-
return __generator(this, function (_a) {
|
|
399
|
-
switch (_a.label) {
|
|
400
|
-
case 0:
|
|
401
|
-
retornoLexador = delegua.lexador.mapear(["var a = {'a': 1, 'b': 2};\nescreva(a['c']);"], -1);
|
|
402
|
-
retornoAvaliadorSintatico = delegua.avaliadorSintatico.analisar(retornoLexador);
|
|
403
|
-
return [4 /*yield*/, delegua.interpretador.interpretar(retornoAvaliadorSintatico.declaracoes)];
|
|
404
|
-
case 1:
|
|
405
|
-
retornoInterpretador = _a.sent();
|
|
406
|
-
expect(retornoInterpretador.erros.length).toBeGreaterThanOrEqual(0);
|
|
407
|
-
return [2 /*return*/];
|
|
408
|
-
}
|
|
409
|
-
});
|
|
410
|
-
}); });
|
|
181
|
+
describe('Cenários de falha', () => {
|
|
182
|
+
describe('Acesso a variáveis e objetos', () => {
|
|
183
|
+
it('Acesso a elementos de vetor', async () => {
|
|
184
|
+
const retornoLexador = delegua.lexador.mapear(["var a = [1, 2, 3];\nescreva(a[4]);"], -1);
|
|
185
|
+
const retornoAvaliadorSintatico = delegua.avaliadorSintatico.analisar(retornoLexador);
|
|
186
|
+
const retornoInterpretador = await delegua.interpretador.interpretar(retornoAvaliadorSintatico.declaracoes);
|
|
187
|
+
expect(retornoInterpretador.erros.length).toBeGreaterThan(0);
|
|
188
|
+
});
|
|
189
|
+
it('Acesso a elementos de dicionário', async () => {
|
|
190
|
+
const retornoLexador = delegua.lexador.mapear(["var a = {'a': 1, 'b': 2};\nescreva(a['c']);"], -1);
|
|
191
|
+
const retornoAvaliadorSintatico = delegua.avaliadorSintatico.analisar(retornoLexador);
|
|
192
|
+
const retornoInterpretador = await delegua.interpretador.interpretar(retornoAvaliadorSintatico.declaracoes);
|
|
193
|
+
expect(retornoInterpretador.erros.length).toBeGreaterThanOrEqual(0);
|
|
194
|
+
});
|
|
411
195
|
});
|
|
412
196
|
});
|
|
413
197
|
});
|