2026-09-20 19:42:24 -07:00
|
|
|
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 {
|
2026-09-28 20:29:21 -07:00
|
|
|
call id "echo-call" execution snapshot;
|
2026-09-20 19:42:24 -07:00
|
|
|
}
|
|
|
|
|
}`,
|
|
|
|
|
{ source },
|
|
|
|
|
);
|
|
|
|
|
assert.ok(iface.ok && iface.resource.kind === "interface", JSON.stringify(iface.diagnostics));
|
|
|
|
|
const pkg = compileCapabilityResourceSource(
|
2026-09-28 20:29:21 -07:00
|
|
|
`symbol JavaScript id "target:org.quixos.execution.javascript@1";
|
|
|
|
|
|
2026-09-20 19:42:24 -07:00
|
|
|
package Generic id "generic" revision "generic@3" {
|
|
|
|
|
operation echo<value T> id "echo" : T -> T mode call
|
2026-09-28 20:29:21 -07:00
|
|
|
execution snapshot targets [JavaScript, server] receiver any;
|
2026-09-20 19:42:24 -07:00
|
|
|
}`,
|
|
|
|
|
{ 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);
|
|
|
|
|
}
|