<commit_before>var layer = require('../index.js');
var should = require('should');

var testData, proxy, context;

var testProxy = function(fn) {
  var r = fn('no modifications', 'no modifications');
  r[0].should.equal('modified by proxy');
  r[1].should.equal('no modifications');
  testData.should.equal('proxyactual');
}

describe('layer', function() {

  beforeEach(function() {
    testData = '';
    proxy = function(arg_a, arg_b) {
      testData += 'proxy';
      arg_a.should.equal('no modifications');
      arg_b.should.equal('no modifications');
      arg_a = 'modified by proxy';
      return [arg_a, arg_b];
    }
    context = {
      actual: function(arg_a, arg_b) {
        testData += 'actual';
        return [arg_a, arg_b];
      },
      replaceTest: function(x, y) {
        throw new Error('it didn\'t replace');
      }
    }
  })

  describe('set', function() {

    it('proxy', function() {
      layer.set(context, context.actual, proxy);
      testProxy(context.actual);
      context.actual.skip.should.be.a('function');
      should.exist(context.actual.skip._context);
    });

    it('errors when can\'t set', function() {
      var noerr = true;
      var nonproxy = undefined;
      try {
        layer.set(null, nonproxy, function() {});
      } catch(e) {
        noerr = false;
      }
      if (noerr) throw new Error('expected an error');
    });

    it('no arguments uses call instead of apply');

    it('maintains scope of the original function');

    it('async proxy');

    it('multiple (async/sync) proxies');

  });


  describe('unset', function() {

    it('proxy', function() {
      // double check proxy is set
      layer.set(context, context.actual, proxy);
      testProxy(context.actual);

      layer.unset(context.actual);
      var r = context.actual('no modifications', 'no modifications');
      r[0].should.equal('no modifications');
      r[1].should.equal('no modifications');
      testData.should.equal('proxyactualactual');<commit_msg>test: no arguments uses call instead of apply<commit_after>var layer = require('../index.js');
var should = require('should');

var testData, proxy, context;

var testProxy = function(fn) {
  var r = fn('no modifications', 'no modifications');
  r[0].should.equal('modified by proxy');
  r[1].should.equal('no modifications');
  testData.should.equal('proxyactual');
}

describe('layer', function() {

  beforeEach(function() {
    testData = '';
    proxy = function(arg_a, arg_b) {
      testData += 'proxy';
      arg_a.should.equal('no modifications');
      arg_b.should.equal('no modifications');
      arg_a = 'modified by proxy';
      return [arg_a, arg_b];
    }
    context = {
      actual: function(arg_a, arg_b) {
        testData += 'actual';
        return [arg_a, arg_b];
      },
      replaceTest: function(x, y) {
        throw new Error('it didn\'t replace');
      }
    }
  })

  describe('set', function() {

    beforeEach(function() {
      testData = '';
    });

    it('proxy', function() {
      layer.set(context, context.actual, proxy);
      testProxy(context.actual);
      context.actual.skip.should.be.a('function');
      should.exist(context.actual.skip._context);
    });

    it('errors when can\'t set', function() {
      var noerr = true;
      var nonproxy = undefined;
      try {
        layer.set(null, nonproxy, function() {});
      } catch(e) {
        noerr = false;
      }
      if (noerr) throw new Error('expected an error');
    });

    it('no arguments uses call instead of apply', function() {
      context.noargs = function() {
        // since arguments is {} then call was used over apply
        arguments.should.eql({});
        testData += 'actual';
      }
      layer.set(context, context.noargs, function() { testData = 'proxy'; });
      context.noargs();
      testData.should.be.equal('proxyactual');
    });

    it('maintains scope of the original function');

    it('async proxy');

    it('multiple (async/sync) proxies');

  });


  describe('unset', function() {

    it('proxy', function() {
      // double check proxy is set
      layer.set(context, context.actual, proxy);
      testProxy(context.actual);

      layer.unset(context.actual);
      var r = context.actual('no modifications', 'no modifications');
      r[0].should.equal('no modifications');
      r[1].should.equal('no modifications');
      testData.should.equal('proxyactualactual');
{'fraction_non_alphanumeric': 0.15998197386210006, 'fraction_numerical': 0.0018026137899954935, 'mean_word_length': 2.8103004291845495, 'pattern_counts': {'":': 0, '<': 3, '<?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': '6835286', 'n_tokens_mistral': 1349, 'n_tokens_neox': 1315, 'n_words': 310}