Support checked closed generic portable bindings
This commit is contained in:
@@ -0,0 +1,42 @@
|
||||
import assert from "node:assert/strict";
|
||||
import { compileCapabilityResourceSource, compileCapabilitySource } from "../src/capability-language/parser.js";
|
||||
import { compileExecutionPlan } from "../src/execution-world/plan.js";
|
||||
|
||||
/** Independently versioned generic interface and implementation, closed by a workspace. */
|
||||
export function portableGenericPlan() {
|
||||
const source = { repository: "https://example.test/portable-generics.git", commit: "a".repeat(40) };
|
||||
const iface = compileCapabilityResourceSource(
|
||||
`
|
||||
interface Echo<value T> id "echo-interface" revision "echo-interface@2" {
|
||||
operation echo id "echo-member" : T -> T {
|
||||
call id "echo-call" execution snapshot targets [browser, server];
|
||||
}
|
||||
}`,
|
||||
{ source },
|
||||
);
|
||||
assert.ok(iface.ok && iface.resource.kind === "interface", JSON.stringify(iface.diagnostics));
|
||||
const pkg = compileCapabilityResourceSource(
|
||||
`
|
||||
package Generic id "generic" revision "generic@3" {
|
||||
operation echo<value T> id "echo" : T -> T mode call
|
||||
execution snapshot targets [browser, server] receiver any;
|
||||
}`,
|
||||
{ source: { ...source, commit: "b".repeat(40) } },
|
||||
);
|
||||
assert.ok(pkg.ok && pkg.resource.kind === "package", JSON.stringify(pkg.diagnostics));
|
||||
const workspace = compileCapabilitySource(
|
||||
`
|
||||
workspace W id "w" revision "w@1" commit "${source.commit}" {
|
||||
import interface Echo; import package Generic; atom Thing id "thing";
|
||||
conform Thing as Echo<string> id "string-echo" { bind echo.call to package Generic.echo<string>; }
|
||||
conform Thing as Echo<list<int64>> id "list-echo" { bind echo.call to package Generic.echo<list<int64>>; }
|
||||
}`,
|
||||
"workspace.qx",
|
||||
{
|
||||
interfaces: new Map([["Echo", iface.resource.revision]]),
|
||||
packages: new Map([["Generic", pkg.resource.revision]]),
|
||||
},
|
||||
);
|
||||
assert.ok(workspace.ok, JSON.stringify(workspace.diagnostics));
|
||||
return compileExecutionPlan(workspace.workspace);
|
||||
}
|
||||
Reference in New Issue
Block a user