Files
Josh Goldberg 9a9a98a608 (v0.5.2) Bumped gulp-shenanigans to 0.5.20
Also changed constants and equations to be public readonly members, and
equations to no longer take constants and equations in.

Fixes #1.
2016-11-30 00:11:53 -06:00

37 lines
1019 B
TypeScript

import { IConstants, IEquation, IEquations, IMathDecidr, IMathDecidrSettings } from "../../src/IMathDecidr";
import { MathDecidr } from "../../src/MathDecidr";
export interface IMockConstants extends IConstants {
gravity: number;
}
export interface IMockEquations extends IEquations {
fallingForce: IEquation;
}
export interface IMockMathDecidr extends IMathDecidr {
readonly constants: IMockConstants;
readonly equations: IMockEquations;
}
export const mockConstants: IMockConstants = {
gravity: 9.81
};
export const mockEquations: IMockEquations = {
fallingForce: function (this: IMockMathDecidr, mass: number): number {
return mass * this.constants.gravity;
}
};
/**
* @param settings Settings for the
* @returns A new MathDecidr instance.
*/
export function mockMathDecidr(settings?: IMathDecidrSettings): IMockMathDecidr {
return new MathDecidr(settings || {
constants: mockConstants,
equations: mockEquations
}) as any as IMockMathDecidr;
}