@devquest/cli 1.0.9 → 1.1.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.
|
@@ -44,16 +44,24 @@ async function testStage1(cwd) {
|
|
|
44
44
|
}
|
|
45
45
|
const output = result.stdout;
|
|
46
46
|
console.log(chalk_1.default.gray(`Saída do usuário:\n${output}`));
|
|
47
|
-
// Validação
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
47
|
+
// Validação rigorosa: O Estágio 1 espera que o usuário imprima uma lista de tokens em JSON
|
|
48
|
+
try {
|
|
49
|
+
const tokens = JSON.parse(output.trim());
|
|
50
|
+
const hasConst = tokens.some((t) => t.type === 'KEYWORD' && t.value === 'const');
|
|
51
|
+
const hasIdentifier = tokens.some((t) => t.type === 'IDENTIFIER' && t.value === 'x');
|
|
52
|
+
const hasLiteral = tokens.some((t) => t.type === 'LITERAL' && t.value === '10');
|
|
53
|
+
if (hasConst && hasIdentifier && hasLiteral) {
|
|
54
|
+
console.log(chalk_1.default.green(`✅ Scanner identificou os tokens (const, x, 10) corretamente no formato JSON.`));
|
|
55
|
+
return true;
|
|
56
|
+
}
|
|
57
|
+
else {
|
|
58
|
+
console.log(chalk_1.default.red(`❌ Scanner produziu JSON, mas os tokens esperados (const, x, 10) não foram encontrados ou estão no formato errado.`));
|
|
59
|
+
return false;
|
|
60
|
+
}
|
|
54
61
|
}
|
|
55
|
-
|
|
56
|
-
console.log(chalk_1.default.red(`❌ Scanner
|
|
62
|
+
catch (e) {
|
|
63
|
+
console.log(chalk_1.default.red(`❌ Erro de Formato: O Estágio 1 exige que o Scanner imprima a lista de tokens em formato JSON válido.`));
|
|
64
|
+
console.log(chalk_1.default.yellow(`Exemplo esperado: [{"type": "KEYWORD", "value": "const"}, ...]`));
|
|
57
65
|
return false;
|
|
58
66
|
}
|
|
59
67
|
}
|