39 lines
1.5 KiB
JavaScript
39 lines
1.5 KiB
JavaScript
// Quick inline test - can be run with copy-paste in browser console
|
|
|
|
// Test cases
|
|
const tests = [
|
|
{ code: 'DC2.W+++', expect: 'Planets', desc: 'Width +++' },
|
|
{ code: 'DC2.W~', expect: 'Variable', desc: 'Width ~' },
|
|
{ code: 'DC2.Tc+++[SE]', expect: 'assembly', desc: 'Technology with specialist' },
|
|
{ code: 'DC2.T+', expect: 'Over-weight', desc: 'Weight +' },
|
|
{ code: 'DC2.Skm', expect: 'metal', desc: 'Skin Type metal' },
|
|
{ code: 'DC2.Df-', expect: 'Irritant', desc: 'Dragon Friend -' },
|
|
{ code: 'DC2.L', expect: 'Normal', desc: 'Length normal' },
|
|
{ code: 'DC2.Ac+++!', expect: 'T1', desc: 'Activity +++!' },
|
|
{ code: 'DC2.A+++!', expect: 'Eternal', desc: 'Age +++!' },
|
|
{ code: 'DC2.$', expect: 'hoard', desc: 'Money $' },
|
|
{ code: 'DC2.O/', expect: 'fault', desc: 'Offspring /' },
|
|
];
|
|
|
|
console.log('=== Running Inline Tests ===\n');
|
|
|
|
tests.forEach(test => {
|
|
try {
|
|
const parsed = parseDragonCode(test.code);
|
|
const decoded = decodeDragonCode(parsed);
|
|
|
|
let actual = 'NOT FOUND';
|
|
for (const section of Object.values(decoded)) {
|
|
if (section && section.length > 0) {
|
|
actual = section[0].value;
|
|
break;
|
|
}
|
|
}
|
|
|
|
const passed = actual.toLowerCase().includes(test.expect.toLowerCase());
|
|
console.log(`${passed ? '✓' : '✗'} ${test.desc}: ${actual}`);
|
|
} catch (error) {
|
|
console.log(`✗ ${test.desc}: ERROR - ${error.message}`);
|
|
}
|
|
});
|