<commit_before>/**
 * This file is part of the NovaeCalc project.
 *
 * It is permitted to use, redistribute and/or modify this software
 * under the terms of the MIT License
 *
 * @author <NAME> <<EMAIL>>
 * @copyright (c) 2015 <NAME>, @felixmaier
 *
 * You may not change or remove these lines
 *
 */
(function() { "use strict"

  /**
   * Function to compare mathematical results of ENGEL
   * and the javascript interpreter
   */
  var interpret = function() {

    /** Default variable name */
    var varName = "A1";

    var engelResult = 0;
    var jsResult = 0;
    var failures = 0;

    var array = [
      /** Float numbers */
      "= (2.5 + 2.0)",
      "= (-2.5 + 2.0) + 2.25",
      /** Plus */
      "= 2 + 2",
      /** Minus */
      "= 2 - 2",
      /** Mult */
      "= 2 * 2",
      /** Division */
      "= 10 / 2",
      /** Operator predecence */
      "= 5 + 5 * 2",
      /** Negative numbers */
      "= -20",
      /** Parenthesis */
      "= -(2 * 2) + 10",
      "= -( (2*2) + -(5+2) )",
      "= -( (-5*5) + (7*7) + -(-9) )",
      "= -( -(2*2) + 5 )"
    ];

    for (var ii = 0; ii < array.length; ++ii) {

      engelResult = ENGEL.interpret(varName + array[ii]).VAR[varName].value.value;
      jsResult = parseFloat(window.eval(array[ii].slice(2)));

      if (engelResult !== jsResult) {
        failures++;
        console.log("#### Results doesn't match! => " + (array[ii].slice(2)) + " ####");
        console.log( "ENGEL:", engelResult);
        console.log( "JS:   ", jsResult);
      }

    }

    if (!failures) console.log("All tests passed successfully!");

  };

  Import.scripts = [
    /** Interpreter */
    "../core/interpreter/main.js",
    "../core/interpreter/stack.js",
    "../core/interpreter/lexer.js",
    "../core/interpreter/parser/main.js",
    "../core/interpreter/parser/expression.js",<commit_msg>Optimize interpreter test<commit_after>/**
 * This file is part of the NovaeCalc project.
 *
 * It is permitted to use, redistribute and/or modify this software
 * under the terms of the MIT License
 *
 * @author <NAME> <<EMAIL>>
 * @copyright (c) 2015 <NAME>, @felixmaier
 *
 * You may not change or remove these lines
 *
 */
(function() { "use strict"

  /**
   * Function to compare mathematical results of ENGEL
   * and the javascript interpreter
   */
  var interpret = function() {

    /** Default variable name */
    var varName = "A1 =";

    var engelResult = 0;
    var jsResult = 0;
    var failures = 0;

    var array = [
      /** Float numbers */
      "(2.5 + 2.0)",
      "(-2.5 + 2.0) + 2.25",
      /** Plus */
      "2 + 2",
      /** Minus */
      "2 - 2",
      /** Mult */
      "2 * 2",
      /** Division */
      "10 / 2",
      /** Operator predecence */
      "5 + 5 * 2",
      /** Negative numbers */
      "-20",
      /** Parenthesis */
      "-(2 * 2) + 10",
      "-( (2*2) + -(5+2) )",
      "-( (-5*5) + (7*7) + -(-9) )",
      "-( -(2*2) + 5 )"
    ];

    for (var ii = 0; ii < array.length; ++ii) {

      engelResult = ENGEL.interpret(varName + array[ii]).VAR[varName.slice(0, 2)].value.value;
      jsResult = parseFloat(window.eval(array[ii]));

      if (engelResult !== jsResult) {
        failures++;
        console.log("#### Results doesn't match! => " + (array[ii]) + " ####");
        console.log( "ENGEL:", engelResult);
        console.log( "JS:   ", jsResult);
      }

    }

    if (!failures) console.log("All tests passed successfully!");

  };

  Import.scripts = [
    /** Interpreter */
    "../core/interpreter/main.js",
    "../core/interpreter/stack.js",
    "../core/interpreter/lexer.js",
    "../core/interpreter/parser/main.js",
    "../core/interpreter/parser/expression.js",
{'fraction_non_alphanumeric': 0.19929881337648328, 'fraction_numerical': 0.028047464940668825, 'mean_word_length': 2.005672609400324, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 13, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '563554', 'n_tokens_mistral': 1334, 'n_tokens_neox': 1252, 'n_words': 310}