Skip to content

Commit

Permalink
Add 'partial' property to functionchart type info.
Browse files Browse the repository at this point in the history
  • Loading branch information
Bill Budge authored and Bill Budge committed Mar 11, 2024
1 parent fe50f8a commit 6a6e615
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 11 deletions.
9 changes: 3 additions & 6 deletions examples/functioncharts/functioncharts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1606,11 +1606,6 @@ export class FunctionchartContext extends EventBase<Change, ChangeEvents>
// });
// }

// Evaluate context.
// if (subgraphInfo.inWires) {

// }

// Sort pins in increasing y-order. This lets users arrange the pins of the
// new type in an intuitive way.
function compareYs(p1: PinInfo, p2: PinInfo) {
Expand Down Expand Up @@ -1702,7 +1697,9 @@ export class FunctionchartContext extends EventBase<Change, ChangeEvents>
if (name)
typeString += '(' + name + ')';

return { typeString, passThroughs };
const partial = !!(subgraphInfo.inWires.size > 0);

return { typeString, passThroughs, partial };
}

// Update the derived 'type' property. Delete any wires that are no longer compatible with
Expand Down
8 changes: 4 additions & 4 deletions out/examples/functioncharts/functioncharts.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions out/test/functioncharts.test.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

27 changes: 26 additions & 1 deletion test/functioncharts.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -652,7 +652,7 @@ describe('FunctionchartContext', () => {
expect(context.selectedNonWires().length).toBe(1);
expect(context.selectedNonWires()[0]).toBe(functionchart1);
});
test('getFunctionchartTypeInfo', () => {
test('getFunctionchartTypeInfo-passthroughs,closed', () => {
const context = new FC.FunctionchartContext(),
functionchart = context.root,
elem1 = addElement(functionchart, 'cond'),
Expand All @@ -667,6 +667,31 @@ describe('FunctionchartContext', () => {
expect(typeInfo.typeString).toBe('[v**v*,*]');
expect(typeInfo.passThroughs.length).toBe(1);
arrayEquals(typeInfo.passThroughs[0], [1, 2, 4, 5]);
expect(typeInfo.partial).toBe(false);
});
test('getFunctionchartTypeInfo-open', () => {
const context = new FC.FunctionchartContext(),
functionchart = context.root,
functionchart1 = addFunctionchart(functionchart),
elem = addElement(functionchart1, 'binop'),
input1 = addPseudoelement(functionchart1, 'input'),
output = addPseudoelement(functionchart1, 'output');
let typeInfo = context.getFunctionchartTypeInfo(functionchart1);
// No inputs or outputs.
expect(typeInfo.typeString).toBe('[*,*]');
expect(typeInfo.passThroughs.length).toBe(0);
const wire1 = addWire(functionchart1, input1, 0, elem, 0),
wire2 = addWire(functionchart1, elem, 0, output, 0);
typeInfo = context.getFunctionchartTypeInfo(functionchart1);
expect(typeInfo.typeString).toBe('[v,v]');
expect(typeInfo.passThroughs.length).toBe(0);
expect(typeInfo.partial).toBe(false);
const input2 = addPseudoelement(functionchart, 'input'),
wire3 = addWire(functionchart1, input2, 0, elem, 1);
typeInfo = context.getFunctionchartTypeInfo(functionchart1);
expect(typeInfo.typeString).toBe('[v,v]');
expect(typeInfo.passThroughs.length).toBe(0);
expect(typeInfo.partial).toBe(true);
});
const recursiveFuncionchart = {
"type": "functionchart",
Expand Down

0 comments on commit 6a6e615

Please sign in to comment.