Skip to content

Commit

Permalink
feat(Program): runArguments implemented
Browse files Browse the repository at this point in the history
  • Loading branch information
Sheyne committed Feb 27, 2017
1 parent 25fb4b0 commit aae2464
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/program.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,9 @@ function pickReturnType(argTypes: Type[], signatures: [Type[], Type][], stateTyp

export class Program {
constructor(private program: PluginProgram, private plugin: Plugin) {
this.runArguments = this.plugin.typeEnvironment.startTypes.map(
t => t[0].slice(1)
);
};

validate(): string[] {
Expand Down
2 changes: 2 additions & 0 deletions test/test-interpreters.ts
Original file line number Diff line number Diff line change
Expand Up @@ -692,6 +692,8 @@ describe("various interpreters", () => {
const prog = new Program(pluginProg, nfa);
const stringType = nfa.typeEnvironment.getStringType();

assert.deepEqual([["string"]], prog.runArguments.map(t => t.map(t2 => t2.name)));

let results;
results = prog.run([new CoreValue(stringType, "11")]);
assert.equal(3, results.states.length, "correct number of states");
Expand Down
11 changes: 11 additions & 0 deletions test/test-plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,15 @@ describe("plugin", () => {
const pluginProgram = new context.global["plugin-stub"].Program({ elements: [] });

program = new Program(pluginProgram, plugin);

assert.deepEqual([
["any", "any"],
["number", "number"],
["number", "string"],
["string", "string"],
["string", "string"],
], program.runArguments.map(t => t.map(t2 => t2.name)));

// const anyType = plugin.typeEnvironment.getType(plugin.typeEnvironment.checker.getAnyType());
stringType = plugin.typeEnvironment.getType(plugin.typeEnvironment.checker.getStringType());
numberType = plugin.typeEnvironment.getType(plugin.typeEnvironment.checker.getNumberType());
Expand Down Expand Up @@ -90,6 +99,8 @@ describe("plugin", () => {
const pluginProgram = new context.global["plugin-stub"].Program({ elements: [] });

program = new Program(pluginProgram, plugin);
assert.deepEqual([["any", "any"]], program.runArguments.map(t => t.map(t2 => t2.name)));

// const anyType = plugin.typeEnvironment.getType(plugin.typeEnvironment.checker.getAnyType());
stringType = plugin.typeEnvironment.getType(plugin.typeEnvironment.checker.getStringType());
numberType = plugin.typeEnvironment.getType(plugin.typeEnvironment.checker.getNumberType());
Expand Down

0 comments on commit aae2464

Please sign in to comment.