| 
					
				 | 
			
			
				@@ -37,30 +37,59 @@ export class OutputMatching { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				   } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				   eval () { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-    const outerThis = this; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    const refThis = this; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     const input = new InputAssessment(this.input_list); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     const gen_output = new OutputTest(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-    program.registerInput(input); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-    program.registerOutput(gen_output); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    this.program.registerInput(input); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    this.program.registerOutput(gen_output); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     const start_time = Date.now(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     return this.program.interpretAST().then( sto => { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-       
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+      const final_time = Date.now() - start_time; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+      if(input.isInputAvailable()) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        return {status:"failed", grade:0, error_msg: refThis.getErrorMessage('test_case_few_reads', this.name+1), 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+          store:sto, time: final_time}; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+      } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+      const result = gen_output.list.map((g_out, i) => { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        if(i >= this.expected_output.length) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+          return new OutputResult.OutputMatchResult(null, g_out, 0, this.getPotentialOutputType(g_out)); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        return this.outputMatch(g_out, this.expected_output[i]); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+      }, this); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+      if(this.expected_output.length > gen_output.list.length) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        for(let i = gen_output.list.length; i < this.expected_output.length; ++i) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+          const e_out = this.expected_output[i]; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+          result.push(new OutputResult.OutputMatchResult(e_out, null, 0, this.getPotentialOutputType(e_out))); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+      } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+      const grade = result.reduce((prev, val) => prev + val.grade, 0) / result.length; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+      return {status: "ok", grade: grade, error_msg: "", store: sto, time: final_time, results: result}; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     }).catch(error => { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				- 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+      return {status:"failed", grade:0, error_msg: refThis.getErrorMessage('test_case_failed_exception', this.name + 1, error.message), 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        store:null, time: null}; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     }); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				   } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+  getPotentialOutputType (output) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    if(OutputMatching.NUM_REGEX.test(output)) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+      return "number"; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    } else if (OutputMatching.BOOLEAN_REGEX.test(output)) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+      return "bool"; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    } else { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+      return "string"; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+  } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				   outputMatch (g_output, e_output) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     if(OutputMatching.NUM_REGEX.test(e_output)) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				       const g_num = new Decimal(g_output); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				       const e_num = new Decimal(e_output); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-      this.checkNumbers(g_num, e_num); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+      return this.checkNumbers(g_num, e_num); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     } else if (OutputMatching.BOOLEAN_REGEX.test(e_output)) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				       const g_bool = TypeParser.toBool(g_output); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				       const e_bool = TypeParser.toBool(e_output); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-      this.checkBoolean(g_bool, e_bool); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+      return this.checkBoolean(g_bool, e_bool); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     } else { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-      this.checkStrings(g_output, e_output); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+      return this.checkStrings(g_output, e_output); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				   } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -130,4 +159,7 @@ export class OutputMatching { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     return OutputResult.createStringResult(e_ouput, g_output, finalGrade); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				   } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+  getErrorMessage (errorID, ...args) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    return LocalizedStrings.getError(errorID, args); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+  } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 } 
			 |