Fix bug with MI Parsing if there is a list with empty strings

A JavaScript string is a falsy value - but an empty string is valid in these positions - so need to explicitly check for undefined instead of just falsy.
This commit is contained in:
Marcel Ball 2018-01-24 16:00:04 -04:00
commit cdee9d6420
2 changed files with 6 additions and 1 deletions

View file

@ -213,7 +213,7 @@ export function parseMI(output: string): MINode {
let values = [];
values.push(value);
let remaining = output;
while (value = parseCommaValue())
while ((value = parseCommaValue()) !== undefined)
values.push(value);
output = output.substr(1); // ]
return values;

View file

@ -173,4 +173,9 @@ suite("MI Parse", () => {
assert.equal(MINode.valueOf(obj[1], "@frame.fullname"), undefined);
assert.equal(MINode.valueOf(obj[1], "@frame.line"), undefined);
});
test("empty string values", () => {
let parsed = parseMI(`15^done,register-names=["r0","pc","","xpsr","","control"]`);
let result = parsed.result('register-names');
assert.deepEqual(result, ["r0", "pc", "", "xpsr", "", "control"]);
});
});