chore: 增加scripts目录

This commit is contained in:
2025-12-28 08:13:13 +08:00
parent bc89550a28
commit f6d9f5255e
23 changed files with 4817 additions and 2638 deletions

View File

@@ -0,0 +1,43 @@
#!/usr/bin/env node
// 测试语法错误检测功能
const { hasSyntaxErrors } = require('./optimized-processor.js');
// 测试代码
const testCases = [
{
name: 'Normal code',
code: 'function test() { console.log("hello"); return "world"; }',
shouldError: false
},
{
name: 'Runtime.js syntax error',
code: 'p[s][0]', // 缺少分号的情况
shouldError: true
},
{
name: 'Bracket mismatch',
code: 'function test() { return [1, 2, 3; }', // 缺少右括号
shouldError: true
},
{
name: 'Valid bracket code',
code: 'function test() { return [1, 2, 3]; }',
shouldError: false
}
];
console.log('🧪 Testing Syntax Error Detection');
console.log('==================================');
testCases.forEach((testCase, index) => {
console.log(`\n${index + 1}. ${testCase.name}`);
console.log(` Code: ${testCase.code}`);
const hasError = hasSyntaxErrors(testCase.code);
console.log(` Expected: ${testCase.shouldError ? 'Error' : 'No Error'}`);
console.log(` Detected: ${hasError ? 'Error' : 'No Error'}`);
console.log(` Result: ${hasError === testCase.shouldError ? '✅ Pass' : '❌ Fail'}`);
});
console.log('\n🎉 Syntax error detection test completed!');