@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,458 +1,215 @@
|
|
|
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('Biblioteca Global',
|
|
41
|
-
|
|
42
|
-
beforeEach(
|
|
3
|
+
const delegua_1 = require("../fontes/delegua");
|
|
4
|
+
describe('Biblioteca Global', () => {
|
|
5
|
+
let delegua;
|
|
6
|
+
beforeEach(() => {
|
|
43
7
|
delegua = new delegua_1.Delegua('delegua');
|
|
44
8
|
});
|
|
45
|
-
describe('aleatorio()',
|
|
46
|
-
it('Trivial',
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
retornoAvaliadorSintatico = delegua.avaliadorSintatico.analisar(retornoLexador);
|
|
53
|
-
return [4 /*yield*/, delegua.interpretador.interpretar(retornoAvaliadorSintatico.declaracoes)];
|
|
54
|
-
case 1:
|
|
55
|
-
retornoInterpretador = _a.sent();
|
|
56
|
-
expect(retornoInterpretador.erros).toHaveLength(0);
|
|
57
|
-
return [2 /*return*/];
|
|
58
|
-
}
|
|
59
|
-
});
|
|
60
|
-
}); });
|
|
9
|
+
describe('aleatorio()', () => {
|
|
10
|
+
it('Trivial', async () => {
|
|
11
|
+
const retornoLexador = delegua.lexador.mapear(["escreva(aleatorio())"], -1);
|
|
12
|
+
const retornoAvaliadorSintatico = delegua.avaliadorSintatico.analisar(retornoLexador);
|
|
13
|
+
const retornoInterpretador = await delegua.interpretador.interpretar(retornoAvaliadorSintatico.declaracoes);
|
|
14
|
+
expect(retornoInterpretador.erros).toHaveLength(0);
|
|
15
|
+
});
|
|
61
16
|
});
|
|
62
|
-
describe('aleatorioEntre()',
|
|
63
|
-
it('Sucesso',
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
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
|
-
}); });
|
|
17
|
+
describe('aleatorioEntre()', () => {
|
|
18
|
+
it('Sucesso', async () => {
|
|
19
|
+
const retornoLexador = delegua.lexador.mapear(["escreva(aleatorioEntre(1, 5))"], -1);
|
|
20
|
+
const retornoAvaliadorSintatico = delegua.avaliadorSintatico.analisar(retornoLexador);
|
|
21
|
+
const retornoInterpretador = await delegua.interpretador.interpretar(retornoAvaliadorSintatico.declaracoes);
|
|
22
|
+
expect(retornoInterpretador.erros).toHaveLength(0);
|
|
23
|
+
});
|
|
78
24
|
});
|
|
79
|
-
describe('inteiro()',
|
|
80
|
-
it('Sucesso',
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
switch (_a.label) {
|
|
99
|
-
case 0:
|
|
100
|
-
retornoLexador = delegua.lexador.mapear(["escreva(inteiro(nulo))"], -1);
|
|
101
|
-
retornoAvaliadorSintatico = delegua.avaliadorSintatico.analisar(retornoLexador);
|
|
102
|
-
return [4 /*yield*/, delegua.interpretador.interpretar(retornoAvaliadorSintatico.declaracoes)];
|
|
103
|
-
case 1:
|
|
104
|
-
retornoInterpretador = _a.sent();
|
|
105
|
-
expect(retornoInterpretador.erros).toHaveLength(0);
|
|
106
|
-
return [2 /*return*/];
|
|
107
|
-
}
|
|
108
|
-
});
|
|
109
|
-
}); });
|
|
110
|
-
it('Falha - Não inteiro', 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(["escreva(inteiro('Oi'))"], -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.length).toBeGreaterThan(0);
|
|
121
|
-
return [2 /*return*/];
|
|
122
|
-
}
|
|
123
|
-
});
|
|
124
|
-
}); });
|
|
25
|
+
describe('inteiro()', () => {
|
|
26
|
+
it('Sucesso', async () => {
|
|
27
|
+
const retornoLexador = delegua.lexador.mapear(["escreva(inteiro(1 + 1))"], -1);
|
|
28
|
+
const retornoAvaliadorSintatico = delegua.avaliadorSintatico.analisar(retornoLexador);
|
|
29
|
+
const retornoInterpretador = await delegua.interpretador.interpretar(retornoAvaliadorSintatico.declaracoes);
|
|
30
|
+
expect(retornoInterpretador.erros).toHaveLength(0);
|
|
31
|
+
});
|
|
32
|
+
it('Sucesso - Nulo', async () => {
|
|
33
|
+
const retornoLexador = delegua.lexador.mapear(["escreva(inteiro(nulo))"], -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('Falha - Não inteiro', async () => {
|
|
39
|
+
const retornoLexador = delegua.lexador.mapear(["escreva(inteiro('Oi'))"], -1);
|
|
40
|
+
const retornoAvaliadorSintatico = delegua.avaliadorSintatico.analisar(retornoLexador);
|
|
41
|
+
const retornoInterpretador = await delegua.interpretador.interpretar(retornoAvaliadorSintatico.declaracoes);
|
|
42
|
+
expect(retornoInterpretador.erros.length).toBeGreaterThan(0);
|
|
43
|
+
});
|
|
125
44
|
});
|
|
126
|
-
describe('mapear()',
|
|
127
|
-
it('Sucesso',
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
var codigo, retornoLexador, retornoAvaliadorSintatico, retornoInterpretador;
|
|
148
|
-
return __generator(this, function (_a) {
|
|
149
|
-
switch (_a.label) {
|
|
150
|
-
case 0:
|
|
151
|
-
codigo = [
|
|
152
|
-
"var f = 'Sou uma função'",
|
|
153
|
-
"escreva(mapear([1, 2, 3], f))"
|
|
154
|
-
];
|
|
155
|
-
retornoLexador = delegua.lexador.mapear(codigo, -1);
|
|
156
|
-
retornoAvaliadorSintatico = delegua.avaliadorSintatico.analisar(retornoLexador);
|
|
157
|
-
return [4 /*yield*/, delegua.interpretador.interpretar(retornoAvaliadorSintatico.declaracoes)];
|
|
158
|
-
case 1:
|
|
159
|
-
retornoInterpretador = _a.sent();
|
|
160
|
-
expect(retornoInterpretador.erros.length).toBeGreaterThan(0);
|
|
161
|
-
return [2 /*return*/];
|
|
162
|
-
}
|
|
163
|
-
});
|
|
164
|
-
}); });
|
|
45
|
+
describe('mapear()', () => {
|
|
46
|
+
it('Sucesso', async () => {
|
|
47
|
+
const codigo = [
|
|
48
|
+
"var f = funcao(x) { retorna(x ** x) }",
|
|
49
|
+
"escreva(mapear([1, 2, 3], f))"
|
|
50
|
+
];
|
|
51
|
+
const retornoLexador = delegua.lexador.mapear(codigo, -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('Falha - Funçao de mapeamento inválida', async () => {
|
|
57
|
+
const codigo = [
|
|
58
|
+
"var f = 'Sou uma função'",
|
|
59
|
+
"escreva(mapear([1, 2, 3], f))"
|
|
60
|
+
];
|
|
61
|
+
const retornoLexador = delegua.lexador.mapear(codigo, -1);
|
|
62
|
+
const retornoAvaliadorSintatico = delegua.avaliadorSintatico.analisar(retornoLexador);
|
|
63
|
+
const retornoInterpretador = await delegua.interpretador.interpretar(retornoAvaliadorSintatico.declaracoes);
|
|
64
|
+
expect(retornoInterpretador.erros.length).toBeGreaterThan(0);
|
|
65
|
+
});
|
|
165
66
|
});
|
|
166
|
-
describe('todosEmCondicao()',
|
|
167
|
-
it('Sucesso',
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
var codigo, retornoLexador, retornoAvaliadorSintatico, retornoInterpretador;
|
|
188
|
-
return __generator(this, function (_a) {
|
|
189
|
-
switch (_a.label) {
|
|
190
|
-
case 0:
|
|
191
|
-
codigo = [
|
|
192
|
-
"var f = 'Sou uma função'",
|
|
193
|
-
"escreva(todosEmCondicao([1, 2, 3, 4, 5, 6], f))"
|
|
194
|
-
];
|
|
195
|
-
retornoLexador = delegua.lexador.mapear(codigo, -1);
|
|
196
|
-
retornoAvaliadorSintatico = delegua.avaliadorSintatico.analisar(retornoLexador);
|
|
197
|
-
return [4 /*yield*/, delegua.interpretador.interpretar(retornoAvaliadorSintatico.declaracoes)];
|
|
198
|
-
case 1:
|
|
199
|
-
retornoInterpretador = _a.sent();
|
|
200
|
-
expect(retornoInterpretador.erros.length).toBeGreaterThan(0);
|
|
201
|
-
return [2 /*return*/];
|
|
202
|
-
}
|
|
203
|
-
});
|
|
204
|
-
}); });
|
|
67
|
+
describe('todosEmCondicao()', () => {
|
|
68
|
+
it('Sucesso', async () => {
|
|
69
|
+
const codigo = [
|
|
70
|
+
"var f = funcao(x) { retorna(x < 10) }",
|
|
71
|
+
"escreva(todosEmCondicao([1, 2, 3, 4, 5, 6], f))"
|
|
72
|
+
];
|
|
73
|
+
const retornoLexador = delegua.lexador.mapear(codigo, -1);
|
|
74
|
+
const retornoAvaliadorSintatico = delegua.avaliadorSintatico.analisar(retornoLexador);
|
|
75
|
+
const retornoInterpretador = await delegua.interpretador.interpretar(retornoAvaliadorSintatico.declaracoes);
|
|
76
|
+
expect(retornoInterpretador.erros).toHaveLength(0);
|
|
77
|
+
});
|
|
78
|
+
it('Falha - Funçao de mapeamento inválida', async () => {
|
|
79
|
+
const codigo = [
|
|
80
|
+
"var f = 'Sou uma função'",
|
|
81
|
+
"escreva(todosEmCondicao([1, 2, 3, 4, 5, 6], f))"
|
|
82
|
+
];
|
|
83
|
+
const retornoLexador = delegua.lexador.mapear(codigo, -1);
|
|
84
|
+
const retornoAvaliadorSintatico = delegua.avaliadorSintatico.analisar(retornoLexador);
|
|
85
|
+
const retornoInterpretador = await delegua.interpretador.interpretar(retornoAvaliadorSintatico.declaracoes);
|
|
86
|
+
expect(retornoInterpretador.erros.length).toBeGreaterThan(0);
|
|
87
|
+
});
|
|
205
88
|
});
|
|
206
|
-
describe('filtrarPor()',
|
|
207
|
-
it('Sucesso',
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
var codigo, retornoLexador, retornoAvaliadorSintatico, retornoInterpretador;
|
|
228
|
-
return __generator(this, function (_a) {
|
|
229
|
-
switch (_a.label) {
|
|
230
|
-
case 0:
|
|
231
|
-
codigo = [
|
|
232
|
-
"var f = 'Sou uma função'",
|
|
233
|
-
"escreva(filtrarPor([1, 2, 3, 4, 5, 6], f))"
|
|
234
|
-
];
|
|
235
|
-
retornoLexador = delegua.lexador.mapear(codigo, -1);
|
|
236
|
-
retornoAvaliadorSintatico = delegua.avaliadorSintatico.analisar(retornoLexador);
|
|
237
|
-
return [4 /*yield*/, delegua.interpretador.interpretar(retornoAvaliadorSintatico.declaracoes)];
|
|
238
|
-
case 1:
|
|
239
|
-
retornoInterpretador = _a.sent();
|
|
240
|
-
expect(retornoInterpretador.erros.length).toBeGreaterThan(0);
|
|
241
|
-
return [2 /*return*/];
|
|
242
|
-
}
|
|
243
|
-
});
|
|
244
|
-
}); });
|
|
89
|
+
describe('filtrarPor()', () => {
|
|
90
|
+
it('Sucesso', async () => {
|
|
91
|
+
const codigo = [
|
|
92
|
+
"var f = funcao(x) { se(x > 4) { retorna(x) } }",
|
|
93
|
+
"escreva(filtrarPor([1, 2, 3, 4, 5, 6], f))"
|
|
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('Falha - Funçao de mapeamento inválida', async () => {
|
|
101
|
+
const codigo = [
|
|
102
|
+
"var f = 'Sou uma função'",
|
|
103
|
+
"escreva(filtrarPor([1, 2, 3, 4, 5, 6], f))"
|
|
104
|
+
];
|
|
105
|
+
const retornoLexador = delegua.lexador.mapear(codigo, -1);
|
|
106
|
+
const retornoAvaliadorSintatico = delegua.avaliadorSintatico.analisar(retornoLexador);
|
|
107
|
+
const retornoInterpretador = await delegua.interpretador.interpretar(retornoAvaliadorSintatico.declaracoes);
|
|
108
|
+
expect(retornoInterpretador.erros.length).toBeGreaterThan(0);
|
|
109
|
+
});
|
|
245
110
|
});
|
|
246
|
-
describe('primeiroEmCondicao()',
|
|
247
|
-
it('Sucesso',
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
var codigo, retornoLexador, retornoAvaliadorSintatico, retornoInterpretador;
|
|
268
|
-
return __generator(this, function (_a) {
|
|
269
|
-
switch (_a.label) {
|
|
270
|
-
case 0:
|
|
271
|
-
codigo = [
|
|
272
|
-
"var f = 'Sou uma função'",
|
|
273
|
-
"escreva(primeiroEmCondicao([1, 2, 3, 4, 5, 6], f))"
|
|
274
|
-
];
|
|
275
|
-
retornoLexador = delegua.lexador.mapear(codigo, -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.length).toBeGreaterThan(0);
|
|
281
|
-
return [2 /*return*/];
|
|
282
|
-
}
|
|
283
|
-
});
|
|
284
|
-
}); });
|
|
111
|
+
describe('primeiroEmCondicao()', () => {
|
|
112
|
+
it('Sucesso', async () => {
|
|
113
|
+
const codigo = [
|
|
114
|
+
"var f = funcao(x) { se(x > 4) { retorna(x) } }",
|
|
115
|
+
"escreva(primeiroEmCondicao([1, 2, 3, 4, 5, 6], f))"
|
|
116
|
+
];
|
|
117
|
+
const retornoLexador = delegua.lexador.mapear(codigo, -1);
|
|
118
|
+
const retornoAvaliadorSintatico = delegua.avaliadorSintatico.analisar(retornoLexador);
|
|
119
|
+
const retornoInterpretador = await delegua.interpretador.interpretar(retornoAvaliadorSintatico.declaracoes);
|
|
120
|
+
expect(retornoInterpretador.erros).toHaveLength(0);
|
|
121
|
+
});
|
|
122
|
+
it('Falha - Funçao de mapeamento inválida', async () => {
|
|
123
|
+
const codigo = [
|
|
124
|
+
"var f = 'Sou uma função'",
|
|
125
|
+
"escreva(primeiroEmCondicao([1, 2, 3, 4, 5, 6], f))"
|
|
126
|
+
];
|
|
127
|
+
const retornoLexador = delegua.lexador.mapear(codigo, -1);
|
|
128
|
+
const retornoAvaliadorSintatico = delegua.avaliadorSintatico.analisar(retornoLexador);
|
|
129
|
+
const retornoInterpretador = await delegua.interpretador.interpretar(retornoAvaliadorSintatico.declaracoes);
|
|
130
|
+
expect(retornoInterpretador.erros.length).toBeGreaterThan(0);
|
|
131
|
+
});
|
|
285
132
|
});
|
|
286
|
-
describe('paraCada()',
|
|
287
|
-
it.skip('Sucesso',
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
var codigo, retornoLexador, retornoAvaliadorSintatico, retornoInterpretador;
|
|
308
|
-
return __generator(this, function (_a) {
|
|
309
|
-
switch (_a.label) {
|
|
310
|
-
case 0:
|
|
311
|
-
codigo = [
|
|
312
|
-
"var f = 'Sou uma função'",
|
|
313
|
-
"escreva(paraCada([1, 2, 3, 4, 5, 6], f))"
|
|
314
|
-
];
|
|
315
|
-
retornoLexador = delegua.lexador.mapear(codigo, -1);
|
|
316
|
-
retornoAvaliadorSintatico = delegua.avaliadorSintatico.analisar(retornoLexador);
|
|
317
|
-
return [4 /*yield*/, delegua.interpretador.interpretar(retornoAvaliadorSintatico.declaracoes)];
|
|
318
|
-
case 1:
|
|
319
|
-
retornoInterpretador = _a.sent();
|
|
320
|
-
expect(retornoInterpretador.erros.length).toBeGreaterThan(0);
|
|
321
|
-
return [2 /*return*/];
|
|
322
|
-
}
|
|
323
|
-
});
|
|
324
|
-
}); });
|
|
133
|
+
describe('paraCada()', () => {
|
|
134
|
+
it.skip('Sucesso', async () => {
|
|
135
|
+
const codigo = [
|
|
136
|
+
"var f = funcao(valor) { se(valor >= 7) { escreva(valor) } }",
|
|
137
|
+
"escreva(paraCada([1, 2, 3, 4, 5, 6, 7, 8, 9, 10], f)"
|
|
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
|
+
});
|
|
144
|
+
it('Falha - Funçao de mapeamento inválida', async () => {
|
|
145
|
+
const codigo = [
|
|
146
|
+
"var f = 'Sou uma função'",
|
|
147
|
+
"escreva(paraCada([1, 2, 3, 4, 5, 6], f))"
|
|
148
|
+
];
|
|
149
|
+
const retornoLexador = delegua.lexador.mapear(codigo, -1);
|
|
150
|
+
const retornoAvaliadorSintatico = delegua.avaliadorSintatico.analisar(retornoLexador);
|
|
151
|
+
const retornoInterpretador = await delegua.interpretador.interpretar(retornoAvaliadorSintatico.declaracoes);
|
|
152
|
+
expect(retornoInterpretador.erros.length).toBeGreaterThan(0);
|
|
153
|
+
});
|
|
325
154
|
});
|
|
326
|
-
describe('ordenar()',
|
|
327
|
-
it('Sucesso',
|
|
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
|
-
}); });
|
|
155
|
+
describe('ordenar()', () => {
|
|
156
|
+
it('Sucesso', async () => {
|
|
157
|
+
const codigo = [
|
|
158
|
+
"ordenar([5, 12, 10, 1, 4, 25, 33, 9, 7, 6, 2])"
|
|
159
|
+
];
|
|
160
|
+
const retornoLexador = delegua.lexador.mapear(codigo, -1);
|
|
161
|
+
const retornoAvaliadorSintatico = delegua.avaliadorSintatico.analisar(retornoLexador);
|
|
162
|
+
const retornoInterpretador = await delegua.interpretador.interpretar(retornoAvaliadorSintatico.declaracoes);
|
|
163
|
+
expect(retornoInterpretador.erros).toHaveLength(0);
|
|
164
|
+
});
|
|
345
165
|
});
|
|
346
|
-
describe('real()',
|
|
347
|
-
it('Sucesso',
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
switch (_a.label) {
|
|
366
|
-
case 0:
|
|
367
|
-
retornoLexador = delegua.lexador.mapear(["escreva(real('Oi'))"], -1);
|
|
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.length).toBeGreaterThan(0);
|
|
373
|
-
return [2 /*return*/];
|
|
374
|
-
}
|
|
375
|
-
});
|
|
376
|
-
}); });
|
|
377
|
-
it.skip('Falha - Nulo', function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
378
|
-
var retornoLexador, retornoAvaliadorSintatico, retornoInterpretador;
|
|
379
|
-
return __generator(this, function (_a) {
|
|
380
|
-
switch (_a.label) {
|
|
381
|
-
case 0:
|
|
382
|
-
retornoLexador = delegua.lexador.mapear(["escreva(real(nulo))"], -1);
|
|
383
|
-
retornoAvaliadorSintatico = delegua.avaliadorSintatico.analisar(retornoLexador);
|
|
384
|
-
return [4 /*yield*/, delegua.interpretador.interpretar(retornoAvaliadorSintatico.declaracoes)];
|
|
385
|
-
case 1:
|
|
386
|
-
retornoInterpretador = _a.sent();
|
|
387
|
-
expect(retornoInterpretador.erros.length).toBeGreaterThan(0);
|
|
388
|
-
return [2 /*return*/];
|
|
389
|
-
}
|
|
390
|
-
});
|
|
391
|
-
}); });
|
|
166
|
+
describe('real()', () => {
|
|
167
|
+
it('Sucesso', async () => {
|
|
168
|
+
const retornoLexador = delegua.lexador.mapear(["escreva(real(3.14))"], -1);
|
|
169
|
+
const retornoAvaliadorSintatico = delegua.avaliadorSintatico.analisar(retornoLexador);
|
|
170
|
+
const retornoInterpretador = await delegua.interpretador.interpretar(retornoAvaliadorSintatico.declaracoes);
|
|
171
|
+
expect(retornoInterpretador.erros).toHaveLength(0);
|
|
172
|
+
});
|
|
173
|
+
it('Falha - Não inteiro', async () => {
|
|
174
|
+
const retornoLexador = delegua.lexador.mapear(["escreva(real('Oi'))"], -1);
|
|
175
|
+
const retornoAvaliadorSintatico = delegua.avaliadorSintatico.analisar(retornoLexador);
|
|
176
|
+
const retornoInterpretador = await delegua.interpretador.interpretar(retornoAvaliadorSintatico.declaracoes);
|
|
177
|
+
expect(retornoInterpretador.erros.length).toBeGreaterThan(0);
|
|
178
|
+
});
|
|
179
|
+
it.skip('Falha - Nulo', async () => {
|
|
180
|
+
const retornoLexador = delegua.lexador.mapear(["escreva(real(nulo))"], -1);
|
|
181
|
+
const retornoAvaliadorSintatico = delegua.avaliadorSintatico.analisar(retornoLexador);
|
|
182
|
+
const retornoInterpretador = await delegua.interpretador.interpretar(retornoAvaliadorSintatico.declaracoes);
|
|
183
|
+
expect(retornoInterpretador.erros.length).toBeGreaterThan(0);
|
|
184
|
+
});
|
|
392
185
|
});
|
|
393
|
-
describe('tamanho()',
|
|
394
|
-
it('Sucesso',
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
switch (_a.label) {
|
|
413
|
-
case 0:
|
|
414
|
-
retornoLexador = delegua.lexador.mapear(["escreva(tamanho(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.length).toBeGreaterThan(0);
|
|
420
|
-
return [2 /*return*/];
|
|
421
|
-
}
|
|
422
|
-
});
|
|
423
|
-
}); });
|
|
424
|
-
it('Falha - Nulo', function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
425
|
-
var retornoLexador, retornoAvaliadorSintatico, retornoInterpretador;
|
|
426
|
-
return __generator(this, function (_a) {
|
|
427
|
-
switch (_a.label) {
|
|
428
|
-
case 0:
|
|
429
|
-
retornoLexador = delegua.lexador.mapear(["escreva(tamanho(nulo))"], -1);
|
|
430
|
-
retornoAvaliadorSintatico = delegua.avaliadorSintatico.analisar(retornoLexador);
|
|
431
|
-
return [4 /*yield*/, delegua.interpretador.interpretar(retornoAvaliadorSintatico.declaracoes)];
|
|
432
|
-
case 1:
|
|
433
|
-
retornoInterpretador = _a.sent();
|
|
434
|
-
expect(retornoInterpretador.erros.length).toBeGreaterThan(0);
|
|
435
|
-
return [2 /*return*/];
|
|
436
|
-
}
|
|
437
|
-
});
|
|
438
|
-
}); });
|
|
186
|
+
describe('tamanho()', () => {
|
|
187
|
+
it('Sucesso', async () => {
|
|
188
|
+
const retornoLexador = delegua.lexador.mapear(["escreva(tamanho([1, 2, 3]))"], -1);
|
|
189
|
+
const retornoAvaliadorSintatico = delegua.avaliadorSintatico.analisar(retornoLexador);
|
|
190
|
+
const retornoInterpretador = await delegua.interpretador.interpretar(retornoAvaliadorSintatico.declaracoes);
|
|
191
|
+
expect(retornoInterpretador.erros).toHaveLength(0);
|
|
192
|
+
});
|
|
193
|
+
it('Falha - Argumento não é lista', async () => {
|
|
194
|
+
const retornoLexador = delegua.lexador.mapear(["escreva(tamanho(1))"], -1);
|
|
195
|
+
const retornoAvaliadorSintatico = delegua.avaliadorSintatico.analisar(retornoLexador);
|
|
196
|
+
const retornoInterpretador = await delegua.interpretador.interpretar(retornoAvaliadorSintatico.declaracoes);
|
|
197
|
+
expect(retornoInterpretador.erros.length).toBeGreaterThan(0);
|
|
198
|
+
});
|
|
199
|
+
it('Falha - Nulo', async () => {
|
|
200
|
+
const retornoLexador = delegua.lexador.mapear(["escreva(tamanho(nulo))"], -1);
|
|
201
|
+
const retornoAvaliadorSintatico = delegua.avaliadorSintatico.analisar(retornoLexador);
|
|
202
|
+
const retornoInterpretador = await delegua.interpretador.interpretar(retornoAvaliadorSintatico.declaracoes);
|
|
203
|
+
expect(retornoInterpretador.erros.length).toBeGreaterThan(0);
|
|
204
|
+
});
|
|
439
205
|
});
|
|
440
|
-
describe('texto()',
|
|
441
|
-
it('Trivial',
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
retornoAvaliadorSintatico = delegua.avaliadorSintatico.analisar(retornoLexador);
|
|
448
|
-
return [4 /*yield*/, delegua.interpretador.interpretar(retornoAvaliadorSintatico.declaracoes)];
|
|
449
|
-
case 1:
|
|
450
|
-
retornoInterpretador = _a.sent();
|
|
451
|
-
expect(retornoInterpretador.erros).toHaveLength(0);
|
|
452
|
-
return [2 /*return*/];
|
|
453
|
-
}
|
|
454
|
-
});
|
|
455
|
-
}); });
|
|
206
|
+
describe('texto()', () => {
|
|
207
|
+
it('Trivial', async () => {
|
|
208
|
+
const retornoLexador = delegua.lexador.mapear(["escreva(texto(123))"], -1);
|
|
209
|
+
const retornoAvaliadorSintatico = delegua.avaliadorSintatico.analisar(retornoLexador);
|
|
210
|
+
const retornoInterpretador = await delegua.interpretador.interpretar(retornoAvaliadorSintatico.declaracoes);
|
|
211
|
+
expect(retornoInterpretador.erros).toHaveLength(0);
|
|
212
|
+
});
|
|
456
213
|
});
|
|
457
214
|
});
|
|
458
215
|
//# sourceMappingURL=biblioteca-global.test.js.map
|