<commit_before>var should = require("should");

describe('MethodHandler', function () {
	var MethodHandler = require('../../lib/MethodHandler');

	var beagle = new function () {
		this.bark = function () {
			return "woof!";
		}

		return this;
	};

	var nullCat;

	describe('#exists()', function () {
		it('should return true if the method exists', function () {
			(new MethodHandler()).exists('bark', beagle).should.equal(true);
		});

		it('should return false if the method does not exist', function () {
			(new MethodHandler()).exists('purr', beagle).should.equal(false);
		});

		it('should throw an error if there is no instance', function () {
			(function(){
				(new MethodHandler()).exists('bark', nullCat);
			}).should.throw("Cannot read property 'bark' of undefined");
		});
	});

	describe('#get()', function () {
		it('should throw an error if there is no instance', function () {
			(function(){
				(new MethodHandler()).get('bark', nullCat);
			}).should.throw("Cannot read property 'bark' of undefined");
		});

		it('should return undefined if the method does not exist', function () {
			var mi = (new MethodHandler()).get('meow', beagle);
			should.not.exist(mi);
		});

		it('should return the method if it exists', function () {
			(new MethodHandler()).get('bark', beagle).should.equal(beagle.bark);
		});
	});
});<commit_msg>Rewrote test for checking undefined methods<commit_after>var should = require("should");

describe('MethodHandler', function () {
	var MethodHandler = require('../../lib/MethodHandler');

	var beagle = new function () {
		this.bark = function () {
			return "woof!";
		}

		return this;
	};

	var nullCat;

	describe('#exists()', function () {
		it('should return true if the method exists', function () {
			(new MethodHandler()).exists('bark', beagle).should.equal(true);
		});

		it('should return false if the method does not exist', function () {
			(new MethodHandler()).exists('purr', beagle).should.equal(false);
		});

		it('should throw an error if there is no instance', function () {
			(function(){
				(new MethodHandler()).exists('bark', nullCat);
			}).should.throw("Cannot read property 'bark' of undefined");
		});
	});

	describe('#get()', function () {
		it('should throw an error if there is no instance', function () {
			(function(){
				(new MethodHandler()).get('bark', nullCat);
			}).should.throw("Cannot read property 'bark' of undefined");
		});

		it('should return undefined if the method does not exist', function () {
			var mi = (new MethodHandler()).get('meow', beagle)
			should(mi).be.type('undefined');
		});

		it('should return the method if it exists', function () {
			(new MethodHandler()).get('bark', beagle).should.equal(beagle.bark);
		});
	});
});
{'fraction_non_alphanumeric': 0.18377001455604075, 'fraction_numerical': 0.0, 'mean_word_length': 4.128731343283582, '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': '1277525', 'n_tokens_mistral': 910, 'n_tokens_neox': 802, 'n_words': 235}