@designliquido/delegua 0.8.1 → 0.9.0

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