allow functions to call other functions #53

This commit is contained in:
undergroundwires
2021-01-16 13:26:41 +01:00
parent f1abd7682f
commit 7661575573
38 changed files with 1507 additions and 645 deletions

View File

@@ -1,10 +1,31 @@
import { FunctionData } from 'js-yaml-loader!*';
import { FunctionData, ScriptFunctionCallData } from 'js-yaml-loader!*';
export class FunctionDataStub implements FunctionData {
public static createWithCode() {
return new FunctionDataStub()
.withCode('stub-code')
.withRevertCode('stub-revert-code');
}
public static createWithCall(call?: ScriptFunctionCallData) {
let instance = new FunctionDataStub();
if (call) {
instance = instance.withCall(call);
} else {
instance = instance.withMockCall();
}
return instance;
}
public static createWithoutCallOrCodes() {
return new FunctionDataStub();
}
public name = 'function data stub';
public code = 'function data stub code';
public revertCode = 'function data stub revertCode';
public code: string;
public revertCode: string;
public parameters?: readonly string[];
public call?: ScriptFunctionCallData;
private constructor() { }
public withName(name: string) {
this.name = name;
@@ -22,4 +43,12 @@ export class FunctionDataStub implements FunctionData {
this.revertCode = revertCode;
return this;
}
public withCall(call: ScriptFunctionCallData) {
this.call = call;
return this;
}
public withMockCall() {
this.call = { function: 'func' };
return this;
}
}