<commit_before>(function() {

  // The global context
  var globalContext = typeof global !== 'undefined' ? global : this;
  var nativeState;

  function restoreNative(methodName, target, storedMethod) {
    if (target[methodName] !== storedMethod) {
      if (!storedMethod) {
        delete target[methodName];
      } else {
        target[methodName] = storedMethod;
      }
    }
  }

  function assertNamespaces(namespaces, assert, checkStatic, checkInstance) {
    for (var i = 0; i < namespaces.length; i++) {
      assertNamespace(namespaces[i], assert, checkStatic, checkInstance);
    }
  }

  function assertNamespace(namespace, assert, checkStatic, checkInstance) {
    var sugarNamespace = Sugar[namespace],
        nativeClass = globalContext[namespace],
        count = 0, mappedCount = 0;

    function methodIsMapped(method, name) {
      return (method.instance && method.instance === nativeClass.prototype[name]) || method === nativeClass[name];
    }

    function checkMethod() {
      return (!!method.instance && checkInstance) || (method.static && checkStatic);
    }

    testIterateOverObject(sugarNamespace, function(name, method) {
      if (!checkMethod(method)) {
        return;
      }
      count++;
      if (methodIsMapped(method, name)) {
        mappedCount++;
      }
    });
    if (assert === false) {
      equal(mappedCount, 0, namespace + ' methods not mapped.');
    } else {
      equal(mappedCount, count, 'All methods mapped to ' + namespace + '.');
    }
  }

  function isSugarMethod(method) {
    return typeof method === 'function' && (method.static || !!method.instance);
  }

  assertAllMethodsMappedToNative = function(namespaces) {
    assertNamespaces(namespaces, true, true, true);
  }

  assertNoMethodsMappedToNative = function(namespaces) {
    assertNamespaces(namespaces, false, true, true);
  }

  assertStaticMethodsMappedToNative = function(namespaces) {
    assertNamespaces(namespaces, true, true, false);
  }

  assertStaticMethodsNotMappedToNative = function(namespaces) {
    assertNamespaces(namespaces, false, true, false);
  }

  assertInstanceMethodsMappedToNative = function(namespaces) {
    assertNamespaces(namespaces, true, false, true);
  }

  assertInstanceMethodsNotMappedToNative = function(namespaces) {
    assertNamespaces(namespaces, false, false, true);
  }

  storeNativeState = function() {
    nativeState = {};
    testIterateOverObject(Sugar, function(name, ns) {
      var state = nativeState[name] = {};
      nativeState[name + 'Active'] = ns.active;
      var nativeClass = globalContext[name];
      testIterateOverObject(ns, function(methodName, method) {
        if (!isSugarMethod(method)) {
          // Only store Sugar defined methods.
          return;
        }
        // Store both static and instance methods as both
        // are possible, such as in the case of Object.keys.
        state[methodName] = {
          static: nativeClass[methodName],
          instance: nativeClass.prototype[methodName]
        }
      });
    });
  }

  restoreNativeState = function() {
    testIterateOverObject(Sugar, function(name, ns) {
      var nativeClass = globalContext[name];
      ns.active = nativeState[name + 'Active'];
      testIterateOverObject(ns, function(methodName, method) {
        if (!isSugarMethod(method)) {<commit_msg>resetting "objectInstance" flag in core helper instead of core tests setup method (makes this more robust)<commit_after>(function() {

  // The global context
  var globalContext = typeof global !== 'undefined' ? global : this;
  var nativeState;

  function restoreNative(methodName, target, storedMethod) {
    if (target[methodName] !== storedMethod) {
      if (!storedMethod) {
        delete target[methodName];
      } else {
        target[methodName] = storedMethod;
      }
    }
  }

  function assertNamespaces(namespaces, assert, checkStatic, checkInstance) {
    for (var i = 0; i < namespaces.length; i++) {
      assertNamespace(namespaces[i], assert, checkStatic, checkInstance);
    }
  }

  function assertNamespace(namespace, assert, checkStatic, checkInstance) {
    var sugarNamespace = Sugar[namespace],
        nativeClass = globalContext[namespace],
        count = 0, mappedCount = 0;

    function methodIsMapped(method, name) {
      return (method.instance && method.instance === nativeClass.prototype[name]) || method === nativeClass[name];
    }

    function checkMethod() {
      return (!!method.instance && checkInstance) || (method.static && checkStatic);
    }

    testIterateOverObject(sugarNamespace, function(name, method) {
      if (!checkMethod(method)) {
        return;
      }
      count++;
      if (methodIsMapped(method, name)) {
        mappedCount++;
      }
    });
    if (assert === false) {
      equal(mappedCount, 0, namespace + ' methods not mapped.');
    } else {
      equal(mappedCount, count, 'All methods mapped to ' + namespace + '.');
    }
  }

  function isSugarMethod(method) {
    return typeof method === 'function' && (method.static || !!method.instance);
  }

  assertAllMethodsMappedToNative = function(namespaces) {
    assertNamespaces(namespaces, true, true, true);
  }

  assertNoMethodsMappedToNative = function(namespaces) {
    assertNamespaces(namespaces, false, true, true);
  }

  assertStaticMethodsMappedToNative = function(namespaces) {
    assertNamespaces(namespaces, true, true, false);
  }

  assertStaticMethodsNotMappedToNative = function(namespaces) {
    assertNamespaces(namespaces, false, true, false);
  }

  assertInstanceMethodsMappedToNative = function(namespaces) {
    assertNamespaces(namespaces, true, false, true);
  }

  assertInstanceMethodsNotMappedToNative = function(namespaces) {
    assertNamespaces(namespaces, false, false, true);
  }

  storeNativeState = function() {
    nativeState = {};
    testIterateOverObject(Sugar, function(name, ns) {
      var state = nativeState[name] = {};
      nativeState[name + 'Active'] = ns.active;
      var nativeClass = globalContext[name];
      testIterateOverObject(ns, function(methodName, method) {
        if (!isSugarMethod(method)) {
          // Only store Sugar defined methods.
          return;
        }
        // Store both static and instance methods as both
        // are possible, such as in the case of Object.keys.
        state[methodName] = {
          static: nativeClass[methodName],
          instance: nativeClass.prototype[methodName]
        }
      });
    });
  }

  restoreNativeState = function() {
    // "objectInstance" preserves state for future
    // method definitions, so reset that flag here.
    Sugar.Object.extend({
      methods: [],
      objectInstance: false
    });
    testIterateOverObject(Sugar, function(name, ns) {
      var nativeClass = globalContext[name];
      ns.active = nativeState[name + 'Active'];
      testIterateOverObject(ns, function(methodName, method) {
        if (!isSugarMethod(method)) {
{'fraction_non_alphanumeric': 0.11661640097659055, 'fraction_numerical': 0.0011489300588826655, 'mean_word_length': 3.269773145309626, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 3, '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': '6785006', 'n_tokens_mistral': 1963, 'n_tokens_neox': 1926, 'n_words': 449}