소스 검색

Implement output test interface new line char

Improve numeric regex to recognize negative number and scientific notation
Lucas Mendonça 4 년 전
부모
커밋
5ec0e1cead
2개의 변경된 파일9개의 추가작업 그리고 3개의 파일을 삭제
  1. 2 2
      js/assessment/output_matching/output_matching.js
  2. 7 1
      js/util/outputTest.js

+ 2 - 2
js/assessment/output_matching/output_matching.js

@@ -13,11 +13,11 @@ const LocalizedStrings = LocalizedStringsService.getInstance();
 export class OutputMatching {
 
   static get NUM_REGEX () {
-    return /^[0-9]+(\.[0-9]+)?$/;
+    return /^[+-]?([0-9]+([.][0-9]*)?(e[+-]?[0-9]+)?)$/;
   } 
 
   static get NUM_IN_STRING_REGEX () {
-    return /[0-9]+(\.[0-9]+)?/g;
+    return /[+-]?([0-9]+([.][0-9]*)?(e[+-]?[0-9]+)?)/g;
   }
 
   static get BOOLEAN_REGEX () {

+ 7 - 1
js/util/outputTest.js

@@ -8,6 +8,12 @@ export class OutputTest extends Output {
   }
 
   sendOutput (text) {
-    this.list.push(text);
+    const output = ''+text;
+    output.split("\n").forEach(t => {
+      t = t.replace(/\t/g,'  ');
+      t = t.replace(/\s/g," ");
+      this.list.push(t);
+    },this);
+    
   }
 }