File tree Expand file tree Collapse file tree 2 files changed +10
-6
lines changed
Expand file tree Collapse file tree 2 files changed +10
-6
lines changed Original file line number Diff line number Diff line change 11{
22 "name" : " code-executor" ,
3- "version" : " 0.2.3 " ,
3+ "version" : " 0.2.4 " ,
44 "description" : " A CLI/library to execute code against test cases in various languages and obtain relevant results." ,
55 "main" : " dist/src/index.js" ,
66 "keywords" : [
Original file line number Diff line number Diff line change 11export default function matchLines ( expected : string , obtained : string ) : 'Pass' | 'Fail' {
22 function splitAndTrim ( code : string ) {
3- return code . split ( '\n' ) . map ( ( sentence ) => sentence . trim ( ) ) ;
3+ 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 }
You can’t perform that action at this time.
0 commit comments