Skip to content

Commit 08ea860

Browse files
committed
fix: Bug in matchLines
1 parent 7236766 commit 08ea860

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

src/utils/matchLines.ts

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,16 @@ export default function matchLines(expected: string, obtained: string): 'Pass' |
33
return code.split('\n').map((sentence) => sentence.trimEnd());
44
}
55

6-
const expectedArray = splitAndTrim(expected);
7-
const obtainedArray = splitAndTrim(obtained);
6+
const expectedArray = splitAndTrim(expected.trim());
7+
const obtainedArray = splitAndTrim(obtained.trim());
88

9-
const minLength = Math.min(expectedArray.length, obtainedArray.length);
9+
if (expectedArray.length !== obtainedArray.length) {
10+
return 'Fail';
11+
}
12+
13+
const { length } = expectedArray;
1014

11-
for (let i = 0; i < minLength; i += 1) {
15+
for (let i = 0; i < length; i += 1) {
1216
if (expectedArray[i] !== obtainedArray[i]) {
1317
return 'Fail';
1418
}

0 commit comments

Comments
 (0)