Skip to content

Commit

Permalink
Added test file and updated symbols to not include
Browse files Browse the repository at this point in the history
  • Loading branch information
rishadbaniya committed May 18, 2021
1 parent 2abef98 commit 7e19e61
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 5 deletions.
5 changes: 3 additions & 2 deletions release/oneDegreeEquationStandardizer.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
// Step 1 => Its the latex building of just showing the user question
// Step 2 => Its the latex building of separating the like variables and the constants in left and right respectively
// Step 3 => Its the latex building of adding and subtracting the like variables and the constants
export const makeItStandard = (rawEquation) => {
const makeItStandard = (rawEquation) => {
let step1 = new ThreeVariableEquation(rawEquation);
let step1Latex = step1.buidlatexFromRawInput();
let step2 = _equationVarAndConstSeparator(step1);
Expand All @@ -19,7 +19,7 @@ export const makeItStandard = (rawEquation) => {
};
const isRawEquationValid = (rawEq) => {
const INVALID_EQUATION = "INVALID_EQUATION";
let toNotInclude = ["++", "--", "==", "+=", "-=", "*", "/"];
let toNotInclude = ["++", "--", "==", "+=", "-=", "-+", "+-", "*", "/"];
if (!rawEq.includes("=")) {
throw INVALID_EQUATION;
}
Expand Down Expand Up @@ -191,3 +191,4 @@ const _likeVariableAndConstantAdder = (equation) => {
equation.leftSideCoeffVarAndConstantTree.CoeffAndVar[0] = equation.leftSideCoeffVarAndConstantTree.CoeffAndVar[0].replace(/[+]/, "");
return equation;
};
export default makeItStandard;
2 changes: 1 addition & 1 deletion release/oneDegreeEquationStandardizer.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 3 additions & 2 deletions src/oneDegreeEquationStandardizer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ type makeItStandardType = {
leftVars : string[],
rightConstant : string[]
}
export const makeItStandard = (rawEquation: string) : makeItStandardType => {
const makeItStandard = (rawEquation: string) : makeItStandardType => {
let step1: ThreeVariableEquation = new ThreeVariableEquation(rawEquation);
let step1Latex = step1.buidlatexFromRawInput();
let step2: ThreeVariableEquation = _equationVarAndConstSeparator(step1);
Expand All @@ -32,7 +32,7 @@ type CoeffVarAndConstantTree = {

const isRawEquationValid = (rawEq : string)=>{
const INVALID_EQUATION = "INVALID_EQUATION";
let toNotInclude = ["++","--","==","+=","-=","*","/"];
let toNotInclude = ["++","--","==","+=","-=","-+","+-","*","/"];
if(!rawEq.includes("=")){
throw INVALID_EQUATION
}else{
Expand Down Expand Up @@ -259,3 +259,4 @@ const _likeVariableAndConstantAdder = (
return equation;
};

export default makeItStandard;
9 changes: 9 additions & 0 deletions test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
// Use "deno run test.js" to run the test


import makeItStandard from './release/oneDegreeEquationStandardizer.min.js';
// Won't throw error
console.log(makeItStandard("2x+3y+20=20"))

// WIll throw error
console.log(makeItStandard("2x+3y+20+=20"))

0 comments on commit 7e19e61

Please sign in to comment.