Skip to content

Commit

Permalink
Merge pull request #53 from pie-framework/fix/PD-1494
Browse files Browse the repository at this point in the history
fix(leading-zeros): math validation problem with a leading zero, when the response and the correct answer also have matching trailing zeros
  • Loading branch information
CarlaCostea authored Mar 8, 2022
2 parents df5b493 + fdef445 commit 9677416
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 4 deletions.
2 changes: 1 addition & 1 deletion src/conversion/latex-to-ast.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1146,7 +1146,7 @@ export class LatexToAst {
if (parsedNumber !== number.toString()) {
const p = number.toString();
// @ts-ignore
const sub = result
const sub = parsedNumber
// @ts-ignore
.substring(p.length)
.split("")
Expand Down
18 changes: 18 additions & 0 deletions src/fixtures/latex-equal/literal/literal.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
export default {

mode: "literal",
tests: [
{
Expand All @@ -13,6 +14,23 @@ export default {
ne: ["12.001"],
opts: { literal: { allowTrailingZeros: true } },
},
{
target: "0.500",
eq: [".500000"],
opts: { literal: { allowTrailingZeros: true } },
ne: [".5001"],
},
{
target: "0.500",
ne: [".500000"],
opts: { literal: { allowTrailingZeros: false } },
},
{
target: "0.500",
eq: [".500"],
opts: { literal: { allowTrailingZeros: true } },
ne: [".5001"],
},
{
target: "12.00",
eq: ["12.00"],
Expand Down
4 changes: 1 addition & 3 deletions src/latex-equal.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,9 @@ export const latexEqual = (a: Latex, b: Latex, opts: Opts) => {
}

const al = lta.convert(a);
console.log(al, "al")


const bl = lta.convert(b);
console.log(bl, "bl")

if (differenceIsTooGreat(al, bl)) {
return false;
}
Expand Down

0 comments on commit 9677416

Please sign in to comment.