@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,422 +1,206 @@
|
|
|
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 (EguaP)',
|
|
41
|
-
describe('interpretar()',
|
|
42
|
-
|
|
43
|
-
beforeEach(
|
|
3
|
+
const delegua_1 = require("../../fontes/delegua");
|
|
4
|
+
describe('Interpretador (EguaP)', () => {
|
|
5
|
+
describe('interpretar()', () => {
|
|
6
|
+
let delegua;
|
|
7
|
+
beforeEach(() => {
|
|
44
8
|
delegua = new delegua_1.Delegua('eguap');
|
|
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
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
switch (_a.label) {
|
|
248
|
-
case 0:
|
|
249
|
-
codigo = [
|
|
250
|
-
"se (1 > 2):",
|
|
251
|
-
" escreva('Nunca acontece'):",
|
|
252
|
-
"senão:",
|
|
253
|
-
" escreva('Um não é maior que dois')",
|
|
254
|
-
];
|
|
255
|
-
retornoLexador = delegua.lexador.mapear(codigo, -1);
|
|
256
|
-
retornoAvaliadorSintatico = delegua.avaliadorSintatico.analisar(retornoLexador);
|
|
257
|
-
return [4 /*yield*/, delegua.interpretador.interpretar(retornoAvaliadorSintatico.declaracoes)];
|
|
258
|
-
case 1:
|
|
259
|
-
retornoInterpretador = _a.sent();
|
|
260
|
-
expect(retornoInterpretador.erros).toHaveLength(0);
|
|
261
|
-
return [2 /*return*/];
|
|
262
|
-
}
|
|
263
|
-
});
|
|
264
|
-
}); });
|
|
87
|
+
describe('Condicionais', () => {
|
|
88
|
+
it('Condicionais - condição verdadeira', async () => {
|
|
89
|
+
const codigo = [
|
|
90
|
+
"se (1 < 2):",
|
|
91
|
+
" escreva('Um menor que dois'):",
|
|
92
|
+
"senao:",
|
|
93
|
+
" escreva('Nunca será executado')",
|
|
94
|
+
];
|
|
95
|
+
const retornoLexador = delegua.lexador.mapear(codigo, -1);
|
|
96
|
+
const retornoAvaliadorSintatico = delegua.avaliadorSintatico.analisar(retornoLexador);
|
|
97
|
+
const retornoInterpretador = await delegua.interpretador.interpretar(retornoAvaliadorSintatico.declaracoes);
|
|
98
|
+
expect(retornoInterpretador.erros).toHaveLength(0);
|
|
99
|
+
});
|
|
100
|
+
it('Condicionais - condição falsa', async () => {
|
|
101
|
+
const codigo = [
|
|
102
|
+
"se (1 > 2):",
|
|
103
|
+
" escreva('Nunca acontece'):",
|
|
104
|
+
"senão:",
|
|
105
|
+
" escreva('Um não é maior que dois')",
|
|
106
|
+
];
|
|
107
|
+
const retornoLexador = delegua.lexador.mapear(codigo, -1);
|
|
108
|
+
const retornoAvaliadorSintatico = delegua.avaliadorSintatico.analisar(retornoLexador);
|
|
109
|
+
const retornoInterpretador = await delegua.interpretador.interpretar(retornoAvaliadorSintatico.declaracoes);
|
|
110
|
+
expect(retornoInterpretador.erros).toHaveLength(0);
|
|
111
|
+
});
|
|
265
112
|
});
|
|
266
|
-
describe('Laços de repetição',
|
|
267
|
-
it.skip('Laços de repetição - enquanto',
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
return [4 /*yield*/, delegua.interpretador.interpretar(retornoAvaliadorSintatico.declaracoes)];
|
|
290
|
-
case 1:
|
|
291
|
-
retornoInterpretador = _a.sent();
|
|
292
|
-
expect(retornoInterpretador.erros).toHaveLength(0);
|
|
293
|
-
return [2 /*return*/];
|
|
294
|
-
}
|
|
295
|
-
});
|
|
296
|
-
}); });
|
|
297
|
-
it.skip('Laços de repetição - para', function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
298
|
-
var codigo, retornoLexador, retornoAvaliadorSintatico, retornoInterpretador;
|
|
299
|
-
return __generator(this, function (_a) {
|
|
300
|
-
switch (_a.label) {
|
|
301
|
-
case 0:
|
|
302
|
-
codigo = [
|
|
303
|
-
"para (var i = 0; i < 10; i = i + 1):",
|
|
304
|
-
" escreva(i)",
|
|
305
|
-
];
|
|
306
|
-
retornoLexador = delegua.lexador.mapear(codigo, -1);
|
|
307
|
-
retornoAvaliadorSintatico = delegua.avaliadorSintatico.analisar(retornoLexador);
|
|
308
|
-
return [4 /*yield*/, delegua.interpretador.interpretar(retornoAvaliadorSintatico.declaracoes)];
|
|
309
|
-
case 1:
|
|
310
|
-
retornoInterpretador = _a.sent();
|
|
311
|
-
expect(retornoInterpretador.erros).toHaveLength(0);
|
|
312
|
-
return [2 /*return*/];
|
|
313
|
-
}
|
|
314
|
-
});
|
|
315
|
-
}); });
|
|
113
|
+
describe('Laços de repetição', () => {
|
|
114
|
+
it.skip('Laços de repetição - enquanto', async () => {
|
|
115
|
+
const retornoLexador = delegua.lexador.mapear(["var a = 0;\nenquanto (a < 10) { a = a + 1; }"], -1);
|
|
116
|
+
const retornoAvaliadorSintatico = delegua.avaliadorSintatico.analisar(retornoLexador);
|
|
117
|
+
const retornoInterpretador = await delegua.interpretador.interpretar(retornoAvaliadorSintatico.declaracoes);
|
|
118
|
+
expect(retornoInterpretador.erros).toHaveLength(0);
|
|
119
|
+
});
|
|
120
|
+
it.skip('Laços de repetição - fazer ... enquanto', async () => {
|
|
121
|
+
const retornoLexador = delegua.lexador.mapear(["var a = 0;\nfazer { a = a + 1; } enquanto (a < 10)"], -1);
|
|
122
|
+
const retornoAvaliadorSintatico = delegua.avaliadorSintatico.analisar(retornoLexador);
|
|
123
|
+
const retornoInterpretador = await delegua.interpretador.interpretar(retornoAvaliadorSintatico.declaracoes);
|
|
124
|
+
expect(retornoInterpretador.erros).toHaveLength(0);
|
|
125
|
+
});
|
|
126
|
+
it.skip('Laços de repetição - para', async () => {
|
|
127
|
+
const codigo = [
|
|
128
|
+
"para (var i = 0; i < 10; i = i + 1):",
|
|
129
|
+
" escreva(i)",
|
|
130
|
+
];
|
|
131
|
+
const retornoLexador = delegua.lexador.mapear(codigo, -1);
|
|
132
|
+
const retornoAvaliadorSintatico = delegua.avaliadorSintatico.analisar(retornoLexador);
|
|
133
|
+
const retornoInterpretador = await delegua.interpretador.interpretar(retornoAvaliadorSintatico.declaracoes);
|
|
134
|
+
expect(retornoInterpretador.erros).toHaveLength(0);
|
|
135
|
+
});
|
|
316
136
|
});
|
|
317
|
-
describe('Classes',
|
|
318
|
-
it.skip('Trivial',
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
retornoAvaliadorSintatico = delegua.avaliadorSintatico.analisar(retornoLexador);
|
|
337
|
-
return [4 /*yield*/, delegua.interpretador.interpretar(retornoAvaliadorSintatico.declaracoes)];
|
|
338
|
-
case 1:
|
|
339
|
-
retornoInterpretador = _a.sent();
|
|
340
|
-
expect(retornoInterpretador.erros).toHaveLength(0);
|
|
341
|
-
return [2 /*return*/];
|
|
342
|
-
}
|
|
343
|
-
});
|
|
344
|
-
}); });
|
|
137
|
+
describe('Classes', () => {
|
|
138
|
+
it.skip('Trivial', async () => {
|
|
139
|
+
const codigo = [
|
|
140
|
+
"classe Animal:",
|
|
141
|
+
" correr():",
|
|
142
|
+
" escreva('Correndo Loucamente')",
|
|
143
|
+
"classe Cachorro herda Animal:",
|
|
144
|
+
" latir():",
|
|
145
|
+
" escreva('Au Au Au Au')",
|
|
146
|
+
"var nomeDoCachorro = Cachorro()",
|
|
147
|
+
"nomeDoCachorro.correr()",
|
|
148
|
+
"nomeDoCachorro.latir()",
|
|
149
|
+
"escreva('Classe: OK!')"
|
|
150
|
+
];
|
|
151
|
+
const retornoLexador = delegua.lexador.mapear(codigo, -1);
|
|
152
|
+
const retornoAvaliadorSintatico = delegua.avaliadorSintatico.analisar(retornoLexador);
|
|
153
|
+
const retornoInterpretador = await delegua.interpretador.interpretar(retornoAvaliadorSintatico.declaracoes);
|
|
154
|
+
expect(retornoInterpretador.erros).toHaveLength(0);
|
|
155
|
+
});
|
|
345
156
|
});
|
|
346
|
-
describe('Declaração e chamada de funções',
|
|
347
|
-
it('Fibonacci',
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
retornoAvaliadorSintatico = delegua.avaliadorSintatico.analisar(retornoLexador);
|
|
378
|
-
return [4 /*yield*/, delegua.interpretador.interpretar(retornoAvaliadorSintatico.declaracoes)];
|
|
379
|
-
case 1:
|
|
380
|
-
retornoInterpretador = _a.sent();
|
|
381
|
-
expect(retornoInterpretador.erros).toHaveLength(0);
|
|
382
|
-
return [2 /*return*/];
|
|
383
|
-
}
|
|
384
|
-
});
|
|
385
|
-
}); });
|
|
157
|
+
describe('Declaração e chamada de funções', () => {
|
|
158
|
+
it('Fibonacci', async () => {
|
|
159
|
+
const codigo = [
|
|
160
|
+
"função fibonacci(n):",
|
|
161
|
+
" se (n == 0):",
|
|
162
|
+
" retorna(0)",
|
|
163
|
+
" se (n == 1):",
|
|
164
|
+
" retorna(1)",
|
|
165
|
+
" var n1 = n - 1",
|
|
166
|
+
" var n2 = n - 2",
|
|
167
|
+
" var f1 = fibonacci(n1)",
|
|
168
|
+
" var f2 = fibonacci(n2)",
|
|
169
|
+
" retorna(f1 + f2)",
|
|
170
|
+
"var a = fibonacci(0)",
|
|
171
|
+
"escreva(a)",
|
|
172
|
+
"a = fibonacci(1)",
|
|
173
|
+
"escreva(a)",
|
|
174
|
+
"a = fibonacci(2)",
|
|
175
|
+
"escreva(a)",
|
|
176
|
+
"a = fibonacci(3)",
|
|
177
|
+
"escreva(a)",
|
|
178
|
+
"a = fibonacci(4)",
|
|
179
|
+
"escreva(a)",
|
|
180
|
+
"a = fibonacci(5)",
|
|
181
|
+
"escreva(a)"
|
|
182
|
+
];
|
|
183
|
+
const retornoLexador = delegua.lexador.mapear(codigo, -1);
|
|
184
|
+
const retornoAvaliadorSintatico = delegua.avaliadorSintatico.analisar(retornoLexador);
|
|
185
|
+
const retornoInterpretador = await delegua.interpretador.interpretar(retornoAvaliadorSintatico.declaracoes);
|
|
186
|
+
expect(retornoInterpretador.erros).toHaveLength(0);
|
|
187
|
+
});
|
|
386
188
|
});
|
|
387
189
|
});
|
|
388
|
-
describe('Cenários de falha',
|
|
389
|
-
describe('Acesso a variáveis e objetos',
|
|
390
|
-
it('Acesso a elementos de vetor',
|
|
391
|
-
var
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
}
|
|
403
|
-
});
|
|
404
|
-
}); });
|
|
405
|
-
it('Acesso a elementos de dicionário', function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
406
|
-
var retornoLexador, retornoAvaliadorSintatico, retornoInterpretador;
|
|
407
|
-
return __generator(this, function (_a) {
|
|
408
|
-
switch (_a.label) {
|
|
409
|
-
case 0:
|
|
410
|
-
retornoLexador = delegua.lexador.mapear(["var a = {'a': 1, 'b': 2};\nescreva(a['c']);"], -1);
|
|
411
|
-
retornoAvaliadorSintatico = delegua.avaliadorSintatico.analisar(retornoLexador);
|
|
412
|
-
return [4 /*yield*/, delegua.interpretador.interpretar(retornoAvaliadorSintatico.declaracoes)];
|
|
413
|
-
case 1:
|
|
414
|
-
retornoInterpretador = _a.sent();
|
|
415
|
-
expect(retornoInterpretador.erros.length).toBeGreaterThanOrEqual(0);
|
|
416
|
-
return [2 /*return*/];
|
|
417
|
-
}
|
|
418
|
-
});
|
|
419
|
-
}); });
|
|
190
|
+
describe('Cenários de falha', () => {
|
|
191
|
+
describe('Acesso a variáveis e objetos', () => {
|
|
192
|
+
it('Acesso a elementos de vetor', async () => {
|
|
193
|
+
const retornoLexador = delegua.lexador.mapear(["var a = [1, 2, 3];\nescreva(a[4]);"], -1);
|
|
194
|
+
const retornoAvaliadorSintatico = delegua.avaliadorSintatico.analisar(retornoLexador);
|
|
195
|
+
const retornoInterpretador = await delegua.interpretador.interpretar(retornoAvaliadorSintatico.declaracoes);
|
|
196
|
+
expect(retornoInterpretador.erros.length).toBeGreaterThan(0);
|
|
197
|
+
});
|
|
198
|
+
it('Acesso a elementos de dicionário', async () => {
|
|
199
|
+
const retornoLexador = delegua.lexador.mapear(["var a = {'a': 1, 'b': 2};\nescreva(a['c']);"], -1);
|
|
200
|
+
const retornoAvaliadorSintatico = delegua.avaliadorSintatico.analisar(retornoLexador);
|
|
201
|
+
const retornoInterpretador = await delegua.interpretador.interpretar(retornoAvaliadorSintatico.declaracoes);
|
|
202
|
+
expect(retornoInterpretador.erros.length).toBeGreaterThanOrEqual(0);
|
|
203
|
+
});
|
|
420
204
|
});
|
|
421
205
|
});
|
|
422
206
|
});
|