Переглянути джерело

Fix a bug when the generated output is a different type than the one expected by the expected output

Lucas Mendonça 4 роки тому
батько
коміт
64e5dbf340
1 змінених файлів з 6 додано та 0 видалено
  1. 6 0
      js/assessment/output_matching/output_matching.js

+ 6 - 0
js/assessment/output_matching/output_matching.js

@@ -81,10 +81,16 @@ export class OutputMatching {
 
   outputMatch (g_output, e_output) {
     if(OutputMatching.NUM_REGEX.test(e_output)) {
+      if(!OutputMatching.NUM_REGEX.test(g_output)) {
+        return OutputResult.createNumberResult(e_output, g_output, 0);
+      }
       const g_num = new Decimal(g_output);
       const e_num = new Decimal(e_output);
       return this.checkNumbers(g_num, e_num);
     } else if (OutputMatching.BOOLEAN_REGEX.test(e_output)) {
+      if (!OutputMatching.BOOLEAN_REGEX.test(g_output)) {
+        return OutputResult.createBoolResult(e_output, g_output, 0);
+      }
       const g_bool = TypeParser.toBool(g_output);
       const e_bool = TypeParser.toBool(e_output);
       return this.checkBoolean(g_bool, e_bool);