File tree 2 files changed +10
-6
lines changed
2 files changed +10
-6
lines changed Original file line number Diff line number Diff line change 1
1
{
2
2
"name" : " code-executor" ,
3
- "version" : " 0.2.3 " ,
3
+ "version" : " 0.2.4 " ,
4
4
"description" : " A CLI/library to execute code against test cases in various languages and obtain relevant results." ,
5
5
"main" : " dist/src/index.js" ,
6
6
"keywords" : [
Original file line number Diff line number Diff line change 1
1
export default function matchLines ( expected : string , obtained : string ) : 'Pass' | 'Fail' {
2
2
function splitAndTrim ( code : string ) {
3
- return code . split ( '\n' ) . map ( ( sentence ) => sentence . trim ( ) ) ;
3
+ return code . split ( '\n' ) . map ( ( sentence ) => sentence . trimEnd ( ) ) ;
4
4
}
5
5
6
- const expectedArray = splitAndTrim ( expected ) ;
7
- const obtainedArray = splitAndTrim ( obtained ) ;
6
+ const expectedArray = splitAndTrim ( expected . trim ( ) ) ;
7
+ const obtainedArray = splitAndTrim ( obtained . trim ( ) ) ;
8
8
9
- const minLength = Math . min ( expectedArray . length , obtainedArray . length ) ;
9
+ if ( expectedArray . length !== obtainedArray . length ) {
10
+ return 'Fail' ;
11
+ }
12
+
13
+ const { length } = expectedArray ;
10
14
11
- for ( let i = 0 ; i < minLength ; i += 1 ) {
15
+ for ( let i = 0 ; i < length ; i += 1 ) {
12
16
if ( expectedArray [ i ] !== obtainedArray [ i ] ) {
13
17
return 'Fail' ;
14
18
}
You can’t perform that action at this time.
0 commit comments