test(speckl): lock in List<T> in interface record fields (cycle 73)
This commit is contained in:
parent
04fa9844f4
commit
5ae89e943c
1 changed files with 33 additions and 0 deletions
|
|
@ -884,4 +884,37 @@ speck Second {
|
|||
}
|
||||
});
|
||||
});
|
||||
|
||||
// Cycle 73: List<T> fields in interface records must be preserved in the AST.
|
||||
// Previously the generator emitted empty type for these fields because
|
||||
// it called speckTypeToProto(f.type.name) which returns '' when .name is
|
||||
// undefined (List/Map/Set nodes use .elementType/.keyType/.valueType,
|
||||
// not .name). The generator was fixed, but this test locks in the parser
|
||||
// behavior so a regression is caught early.
|
||||
describe('List<T> in interface record fields (cycle 73)', () => {
|
||||
it('should parse List<T> fields in interface records', () => {
|
||||
const content = `speck One {
|
||||
interface Container {
|
||||
items: List<Ticket>,
|
||||
names: List<String>
|
||||
}
|
||||
interface Ticket {
|
||||
id: String
|
||||
}
|
||||
}`;
|
||||
const ast = parseSpeckContent(content);
|
||||
const iface = ast.specks[0].members.find(m => m.name === 'Container');
|
||||
expect(iface).toBeDefined();
|
||||
if (iface?.type === 'interface') {
|
||||
expect(iface.fields).toBeDefined();
|
||||
expect(iface.fields.length).toBe(2);
|
||||
expect(iface.fields[0].name).toBe('items');
|
||||
expect(iface.fields[0].type.type).toBe('list');
|
||||
expect(iface.fields[0].type.elementType?.name).toBe('Ticket');
|
||||
expect(iface.fields[1].name).toBe('names');
|
||||
expect(iface.fields[1].type.type).toBe('list');
|
||||
expect(iface.fields[1].type.elementType?.name).toBe('String');
|
||||
}
|
||||
});
|
||||
});
|
||||
});
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue