test: Add detailed METAR decode statistics to test function
Co-authored-by: aider (gemini/gemini-2.5-pro) <aider@aider.chat>
This commit is contained in:
+26
-1
@@ -536,18 +536,43 @@
|
||||
function testAllMetars() {
|
||||
console.log(`--- Starting test of ${metars.length} METARs ---`);
|
||||
let failed = 0;
|
||||
let withUnknowns = 0;
|
||||
const originalConsoleLog = console.log;
|
||||
|
||||
metars.forEach(metarString => {
|
||||
const tempLogs = [];
|
||||
console.log = (...args) => {
|
||||
tempLogs.push(args.join(' '));
|
||||
};
|
||||
|
||||
try {
|
||||
const sections = generateMetarSections(metarString);
|
||||
if (sections.length === 0 && metarString.length > 0) {
|
||||
throw new Error("Parser produced no sections");
|
||||
}
|
||||
|
||||
const hasUnknowns = tempLogs.some(msg => msg.includes('Unknown') || msg.includes('Other remark'));
|
||||
if (hasUnknowns) {
|
||||
withUnknowns++;
|
||||
originalConsoleLog(`METAR with decoding issues: ${metarString}`);
|
||||
tempLogs.forEach(msg => originalConsoleLog(` -> ${msg}`));
|
||||
}
|
||||
|
||||
} catch (e) {
|
||||
console.error("Failed to parse:", metarString, e);
|
||||
failed++;
|
||||
}
|
||||
});
|
||||
console.log(`--- Test finished, ${failed} failures ---`);
|
||||
|
||||
console.log = originalConsoleLog;
|
||||
const total = metars.length;
|
||||
const clean = total - failed - withUnknowns;
|
||||
|
||||
console.log(`--- Test finished ---`);
|
||||
console.log(`Total METARs: ${total}`);
|
||||
console.log(`Clean decodes: ${clean} (${(clean/total*100).toFixed(1)}%)`);
|
||||
console.log(`Decodes with issues: ${withUnknowns} (${(withUnknowns/total*100).toFixed(1)}%)`);
|
||||
console.log(`Failed to parse: ${failed} (${(failed/total*100).toFixed(1)}%)`);
|
||||
}
|
||||
|
||||
testAllBtn.addEventListener('click', testAllMetars);
|
||||
|
||||
Reference in New Issue
Block a user