Set the decision and its input
Toy layoutL1 maps K1/K2/K3 to A/B;L2 maps the same labels to A-B. Reporting L2 while always applying L1 produces the wrong symbol. Physical key labels alone do not select the code interpretation.
| Case | Input JSON |
|---|---|
| Base test | {"layout":"L2","keys":["K1","K2","K3"]} |
Run the supplied comparison
The programme executes the supplied mappings only. It makes no claim about an operating system, scanner firmware or locale driver; catalogue admission needs its own code convention.
| Path | Output JSON |
|---|---|
| Faulty path | {"layout":"L2","code":"A/B"} |
| Required path | {"layout":"L2","code":"A-B"} |
import assert from 'node:assert/strict';
const run=function run(i,corrected=true){
const layouts={L1:{K1:'A',K2:'/',K3:'B'},L2:{K1:'A',K2:'-',K3:'B'}};
if(!Object.hasOwn(layouts,i.layout)||i.keys.some(k=>!Object.hasOwn(layouts[i.layout],k)))return {held:true};
return {layout:i.layout,code:i.keys.map(k=>layouts[corrected?i.layout:'L1'][k]).join('')};
};
const cases=[{"input":{"layout":"L2","keys":["K1","K2","K3"]},"corrected":false,"expected":{"layout":"L2","code":"A/B"}},{"input":{"layout":"L2","keys":["K1","K2","K3"]},"corrected":true,"expected":{"layout":"L2","code":"A-B"}},{"input":{"layout":"L1","keys":["K1","K2","K3"]},"corrected":true,"expected":{"layout":"L1","code":"A/B"}},{"input":{"layout":null,"keys":["K1"]},"corrected":true,"expected":{"held":true}}];
for(const test of cases){const actual=await run(test.input,test.corrected);assert.deepEqual(actual,test.expected);console.log(actual);}
Choose from the boundary evidence
L1 legitimately produces A/B. An unknown layout or unmapped key is held.
- Read the selected layout
- Map the complete key sequence
- Review the resulting code
Do not infer a real device layout from this toy mapping.
| Condition | Input JSON | Expected output JSON |
|---|---|---|
| declared first layout | {"layout":"L1","keys":["K1","K2","K3"]} | {"layout":"L1","code":"A/B"} |
| layout not supplied | {"layout":null,"keys":["K1"]} | {"held":true} |
What belongs to the baseL2 result?
Show the worked answer
A-B, with layoutL2 retained. A/B belongs to L1 despite identical physical key labels.