@designliquido/delegua 1.22.2 → 1.23.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.
- package/analisador-semantico/analisador-semantico.d.ts +2 -2
- package/analisador-semantico/analisador-semantico.d.ts.map +1 -1
- package/analisador-semantico/analisador-semantico.js +8 -6
- package/analisador-semantico/analisador-semantico.js.map +1 -1
- package/bibliotecas/testes/modulo-testes.d.ts.map +1 -1
- package/bibliotecas/testes/modulo-testes.js +132 -19
- package/bibliotecas/testes/modulo-testes.js.map +1 -1
- package/bibliotecas/testes/registro-testes.d.ts +18 -1
- package/bibliotecas/testes/registro-testes.d.ts.map +1 -1
- package/bibliotecas/testes/registro-testes.js +2 -0
- package/bibliotecas/testes/registro-testes.js.map +1 -1
- package/bin/package.json +1 -1
- package/interfaces/analisador-semantico-interface.d.ts +2 -1
- package/interfaces/analisador-semantico-interface.d.ts.map +1 -1
- package/interpretador/interpretador-base.d.ts.map +1 -1
- package/interpretador/interpretador-base.js +1 -1
- package/interpretador/interpretador-base.js.map +1 -1
- package/package.json +1 -1
- package/umd/delegua.js +143 -26
package/umd/delegua.js
CHANGED
|
@@ -520,13 +520,15 @@ class AnalisadorSemantico extends analisador_semantico_base_1.AnalisadorSemantic
|
|
|
520
520
|
this.funcoes = {};
|
|
521
521
|
this.classesDeclaradas = new Set();
|
|
522
522
|
this.classesRegistradas = new Map();
|
|
523
|
-
this.
|
|
523
|
+
this.classesExternasRegistradas = new Map();
|
|
524
524
|
this.classeAtualEmAnalise = null;
|
|
525
525
|
this.atual = 0;
|
|
526
526
|
this.diagnosticos = [];
|
|
527
527
|
}
|
|
528
|
-
|
|
529
|
-
|
|
528
|
+
registrarClassesExternas(classes) {
|
|
529
|
+
for (const classe of classes) {
|
|
530
|
+
this.classesExternasRegistradas.set(classe.simbolo.lexema, classe);
|
|
531
|
+
}
|
|
530
532
|
}
|
|
531
533
|
verificarTipoAtribuido(declaracao) {
|
|
532
534
|
if (declaracao.tipo) {
|
|
@@ -1692,7 +1694,7 @@ class AnalisadorSemantico extends analisador_semantico_base_1.AnalisadorSemantic
|
|
|
1692
1694
|
this.erro(superClasseVariavel.simbolo, `A classe '${declaracao.simbolo.lexema}' não pode herdar de si mesma.`);
|
|
1693
1695
|
}
|
|
1694
1696
|
else if (!this.classesDeclaradas.has(nomeSuperclasse) &&
|
|
1695
|
-
!this.
|
|
1697
|
+
!this.classesRegistradas.has(nomeSuperclasse)) {
|
|
1696
1698
|
this.erro(superClasseVariavel.simbolo, `Superclasse '${nomeSuperclasse}' não foi declarada.`);
|
|
1697
1699
|
}
|
|
1698
1700
|
}
|
|
@@ -1861,8 +1863,8 @@ class AnalisadorSemantico extends analisador_semantico_base_1.AnalisadorSemantic
|
|
|
1861
1863
|
}
|
|
1862
1864
|
async analisar(declaracoes) {
|
|
1863
1865
|
this.gerenciadorEscopos = new gerenciador_escopos_1.GerenciadorEscopos();
|
|
1864
|
-
this.classesDeclaradas = new Set();
|
|
1865
|
-
this.classesRegistradas = new Map();
|
|
1866
|
+
this.classesDeclaradas = new Set(this.classesExternasRegistradas.keys());
|
|
1867
|
+
this.classesRegistradas = new Map(this.classesExternasRegistradas);
|
|
1866
1868
|
this.classeAtualEmAnalise = null;
|
|
1867
1869
|
this.atual = 0;
|
|
1868
1870
|
this.diagnosticos = [];
|
|
@@ -13763,29 +13765,17 @@ function simboloAtual(interpretador) {
|
|
|
13763
13765
|
function construirModuloDeTestes(interpretador, registro) {
|
|
13764
13766
|
const modulo = new modulo_1.DeleguaModulo('testes');
|
|
13765
13767
|
modulo.componentes['afirmar'] = (0, modulo_afirmar_1.construirModuloAfirmar)();
|
|
13766
|
-
|
|
13767
|
-
const nome = interpretador.resolverValor(nomeRaw);
|
|
13768
|
-
const funcao = interpretador.resolverValor(funcaoRaw);
|
|
13769
|
-
const suiteAnterior = registro.suiteAtual;
|
|
13770
|
-
registro.suiteAtual = suiteAnterior ? `${suiteAnterior} > ${nome}` : nome;
|
|
13771
|
-
const emDeclaracaoTenteAnterior = interpretador.emDeclaracaoTente;
|
|
13772
|
-
interpretador.emDeclaracaoTente = true;
|
|
13773
|
-
try {
|
|
13774
|
-
await funcao.chamar(interpretador, [], null);
|
|
13775
|
-
}
|
|
13776
|
-
finally {
|
|
13777
|
-
registro.suiteAtual = suiteAnterior;
|
|
13778
|
-
interpretador.emDeclaracaoTente = emDeclaracaoTenteAnterior;
|
|
13779
|
-
}
|
|
13780
|
-
});
|
|
13781
|
-
modulo.componentes['teste'] = new funcao_padrao_1.FuncaoPadrao(2, async function (_visitante, nomeRaw, funcaoRaw) {
|
|
13782
|
-
const nome = interpretador.resolverValor(nomeRaw);
|
|
13783
|
-
const funcao = interpretador.resolverValor(funcaoRaw);
|
|
13768
|
+
async function executarTeste(nome, fn) {
|
|
13784
13769
|
const inicio = Date.now();
|
|
13785
13770
|
const emDeclaracaoTenteAnterior = interpretador.emDeclaracaoTente;
|
|
13786
13771
|
interpretador.emDeclaracaoTente = true;
|
|
13772
|
+
for (const escopo of registro.pilhaEscopos) {
|
|
13773
|
+
for (const h of escopo.antesDeCada) {
|
|
13774
|
+
await h.chamar(interpretador, [], null);
|
|
13775
|
+
}
|
|
13776
|
+
}
|
|
13787
13777
|
try {
|
|
13788
|
-
await
|
|
13778
|
+
await fn.chamar(interpretador, [], null);
|
|
13789
13779
|
registro.resultados.push({
|
|
13790
13780
|
nomeSuite: registro.suiteAtual,
|
|
13791
13781
|
nomeTeste: nome,
|
|
@@ -13803,9 +13793,134 @@ function construirModuloDeTestes(interpretador, registro) {
|
|
|
13803
13793
|
});
|
|
13804
13794
|
}
|
|
13805
13795
|
finally {
|
|
13796
|
+
for (const escopo of [...registro.pilhaEscopos].reverse()) {
|
|
13797
|
+
for (const h of escopo.depoisDeCada) {
|
|
13798
|
+
await h.chamar(interpretador, [], null);
|
|
13799
|
+
}
|
|
13800
|
+
}
|
|
13801
|
+
interpretador.emDeclaracaoTente = emDeclaracaoTenteAnterior;
|
|
13802
|
+
}
|
|
13803
|
+
}
|
|
13804
|
+
async function executarGrupo(nome, fn) {
|
|
13805
|
+
const suiteAnterior = registro.suiteAtual;
|
|
13806
|
+
registro.suiteAtual = suiteAnterior ? `${suiteAnterior} > ${nome}` : nome;
|
|
13807
|
+
const escopo = {
|
|
13808
|
+
antesDeCada: [],
|
|
13809
|
+
antesDeTodos: [],
|
|
13810
|
+
depoisDeCada: [],
|
|
13811
|
+
depoisDeTodos: [],
|
|
13812
|
+
itensColetados: [],
|
|
13813
|
+
temApenas: false,
|
|
13814
|
+
};
|
|
13815
|
+
registro.pilhaEscopos.push(escopo);
|
|
13816
|
+
const modoColetarAnterior = registro.modoColeta;
|
|
13817
|
+
registro.modoColeta = true;
|
|
13818
|
+
const emDeclaracaoTenteAnterior = interpretador.emDeclaracaoTente;
|
|
13819
|
+
interpretador.emDeclaracaoTente = true;
|
|
13820
|
+
try {
|
|
13821
|
+
await fn.chamar(interpretador, [], null);
|
|
13822
|
+
registro.modoColeta = modoColetarAnterior;
|
|
13823
|
+
for (const h of escopo.antesDeTodos) {
|
|
13824
|
+
await h.chamar(interpretador, [], null);
|
|
13825
|
+
}
|
|
13826
|
+
for (const item of escopo.itensColetados) {
|
|
13827
|
+
if (escopo.temApenas && !item.apenas)
|
|
13828
|
+
continue;
|
|
13829
|
+
if (item.pular) {
|
|
13830
|
+
if (item.tipo === 'teste') {
|
|
13831
|
+
registro.resultados.push({
|
|
13832
|
+
nomeSuite: registro.suiteAtual,
|
|
13833
|
+
nomeTeste: item.nome,
|
|
13834
|
+
status: 'pulado',
|
|
13835
|
+
tempoMs: 0,
|
|
13836
|
+
});
|
|
13837
|
+
}
|
|
13838
|
+
continue;
|
|
13839
|
+
}
|
|
13840
|
+
if (item.tipo === 'teste') {
|
|
13841
|
+
await executarTeste(item.nome, item.fn);
|
|
13842
|
+
}
|
|
13843
|
+
else {
|
|
13844
|
+
await executarGrupo(item.nome, item.fn);
|
|
13845
|
+
}
|
|
13846
|
+
}
|
|
13847
|
+
for (const h of escopo.depoisDeTodos) {
|
|
13848
|
+
await h.chamar(interpretador, [], null);
|
|
13849
|
+
}
|
|
13850
|
+
}
|
|
13851
|
+
finally {
|
|
13852
|
+
registro.pilhaEscopos.pop();
|
|
13853
|
+
registro.modoColeta = modoColetarAnterior;
|
|
13854
|
+
registro.suiteAtual = suiteAnterior;
|
|
13806
13855
|
interpretador.emDeclaracaoTente = emDeclaracaoTenteAnterior;
|
|
13807
13856
|
}
|
|
13857
|
+
}
|
|
13858
|
+
function coletarOuExecutar(tipo, nome, fn, pular, apenas) {
|
|
13859
|
+
if (registro.modoColeta && registro.pilhaEscopos.length > 0) {
|
|
13860
|
+
const escopoAtual = registro.pilhaEscopos[registro.pilhaEscopos.length - 1];
|
|
13861
|
+
if (apenas)
|
|
13862
|
+
escopoAtual.temApenas = true;
|
|
13863
|
+
escopoAtual.itensColetados.push({ tipo, nome, fn, pular, apenas });
|
|
13864
|
+
return Promise.resolve();
|
|
13865
|
+
}
|
|
13866
|
+
if (pular) {
|
|
13867
|
+
if (tipo === 'teste') {
|
|
13868
|
+
registro.resultados.push({
|
|
13869
|
+
nomeSuite: registro.suiteAtual,
|
|
13870
|
+
nomeTeste: nome,
|
|
13871
|
+
status: 'pulado',
|
|
13872
|
+
tempoMs: 0,
|
|
13873
|
+
});
|
|
13874
|
+
}
|
|
13875
|
+
return Promise.resolve();
|
|
13876
|
+
}
|
|
13877
|
+
return tipo === 'teste' ? executarTeste(nome, fn) : executarGrupo(nome, fn);
|
|
13878
|
+
}
|
|
13879
|
+
const grupoFn = new funcao_padrao_1.FuncaoPadrao(2, async function (_visitante, nomeRaw, funcaoRaw) {
|
|
13880
|
+
const nome = interpretador.resolverValor(nomeRaw);
|
|
13881
|
+
const fn = interpretador.resolverValor(funcaoRaw);
|
|
13882
|
+
return coletarOuExecutar('grupo', nome, fn, false, false);
|
|
13883
|
+
});
|
|
13884
|
+
grupoFn['pular'] = new funcao_padrao_1.FuncaoPadrao(2, async function (_visitante, nomeRaw, funcaoRaw) {
|
|
13885
|
+
const nome = interpretador.resolverValor(nomeRaw);
|
|
13886
|
+
const fn = interpretador.resolverValor(funcaoRaw);
|
|
13887
|
+
return coletarOuExecutar('grupo', nome, fn, true, false);
|
|
13888
|
+
});
|
|
13889
|
+
grupoFn['apenas'] = new funcao_padrao_1.FuncaoPadrao(2, async function (_visitante, nomeRaw, funcaoRaw) {
|
|
13890
|
+
const nome = interpretador.resolverValor(nomeRaw);
|
|
13891
|
+
const fn = interpretador.resolverValor(funcaoRaw);
|
|
13892
|
+
return coletarOuExecutar('grupo', nome, fn, false, true);
|
|
13808
13893
|
});
|
|
13894
|
+
modulo.componentes['grupo'] = grupoFn;
|
|
13895
|
+
const testeFn = new funcao_padrao_1.FuncaoPadrao(2, async function (_visitante, nomeRaw, funcaoRaw) {
|
|
13896
|
+
const nome = interpretador.resolverValor(nomeRaw);
|
|
13897
|
+
const fn = interpretador.resolverValor(funcaoRaw);
|
|
13898
|
+
return coletarOuExecutar('teste', nome, fn, false, false);
|
|
13899
|
+
});
|
|
13900
|
+
testeFn['pular'] = new funcao_padrao_1.FuncaoPadrao(2, async function (_visitante, nomeRaw, funcaoRaw) {
|
|
13901
|
+
const nome = interpretador.resolverValor(nomeRaw);
|
|
13902
|
+
const fn = interpretador.resolverValor(funcaoRaw);
|
|
13903
|
+
return coletarOuExecutar('teste', nome, fn, true, false);
|
|
13904
|
+
});
|
|
13905
|
+
testeFn['apenas'] = new funcao_padrao_1.FuncaoPadrao(2, async function (_visitante, nomeRaw, funcaoRaw) {
|
|
13906
|
+
const nome = interpretador.resolverValor(nomeRaw);
|
|
13907
|
+
const fn = interpretador.resolverValor(funcaoRaw);
|
|
13908
|
+
return coletarOuExecutar('teste', nome, fn, false, true);
|
|
13909
|
+
});
|
|
13910
|
+
modulo.componentes['teste'] = testeFn;
|
|
13911
|
+
function registrarHook(campo) {
|
|
13912
|
+
return new funcao_padrao_1.FuncaoPadrao(1, function (_visitante, funcaoRaw) {
|
|
13913
|
+
const fn = interpretador.resolverValor(funcaoRaw);
|
|
13914
|
+
if (registro.pilhaEscopos.length > 0) {
|
|
13915
|
+
registro.pilhaEscopos[registro.pilhaEscopos.length - 1][campo].push(fn);
|
|
13916
|
+
}
|
|
13917
|
+
return Promise.resolve(null);
|
|
13918
|
+
});
|
|
13919
|
+
}
|
|
13920
|
+
modulo.componentes['antesDeCada'] = registrarHook('antesDeCada');
|
|
13921
|
+
modulo.componentes['antesDeTodos'] = registrarHook('antesDeTodos');
|
|
13922
|
+
modulo.componentes['depoisDeCada'] = registrarHook('depoisDeCada');
|
|
13923
|
+
modulo.componentes['depoisDeTodos'] = registrarHook('depoisDeTodos');
|
|
13809
13924
|
modulo.componentes['lancarErro'] = new funcao_padrao_1.FuncaoPadrao(1, function (_visitante, mensagemRaw) {
|
|
13810
13925
|
const mensagem = interpretador.resolverValor(mensagemRaw);
|
|
13811
13926
|
return Promise.reject(new erro_de_assertiva_1.ErroDeAssertiva(simboloAtual(interpretador), String(mensagem)));
|
|
@@ -13821,6 +13936,8 @@ class RegistroTestes {
|
|
|
13821
13936
|
constructor() {
|
|
13822
13937
|
this.resultados = [];
|
|
13823
13938
|
this.suiteAtual = '';
|
|
13939
|
+
this.pilhaEscopos = [];
|
|
13940
|
+
this.modoColeta = false;
|
|
13824
13941
|
}
|
|
13825
13942
|
}
|
|
13826
13943
|
exports.RegistroTestes = RegistroTestes;
|
|
@@ -21914,7 +22031,7 @@ class InterpretadorBase {
|
|
|
21914
22031
|
*/
|
|
21915
22032
|
async visitarExpressaoAgrupamento(expressao) {
|
|
21916
22033
|
const avaliacaoAgrupamento = await this.avaliar(expressao.expressao);
|
|
21917
|
-
if (avaliacaoAgrupamento
|
|
22034
|
+
if (avaliacaoAgrupamento !== null && avaliacaoAgrupamento.declaracao) {
|
|
21918
22035
|
return avaliacaoAgrupamento.declaracao;
|
|
21919
22036
|
}
|
|
21920
22037
|
return avaliacaoAgrupamento;
|