<commit_before>describe('core.lane', function () {

	it('should be accessible', function () {
		var lanefac = norne.obj.get('core.lane');
		expect(lanefac).toBeDefined();
	});


	it('checks the constructors parameters', function () {
		function catcher () {
			norne.obj.create('core.lane');
		}

		expect(catcher).toThrow();
	});


	it('should let me add points', function () {
		var lane, point, stub;

		lane = norne.obj.create('core.lane', 0);
		point = { x: 50, y: 100};
		stub = {
			evt: function (p) {
				expect(p.x).toEqual(point.x);
				expect(p.y).toEqual(point.y);
			}
		};

		spyOn(stub, 'evt');
		expect(lane.addPoint).toBeDefined();
		lane.on('addPoint', stub.evt);

		lane.addPoint(50, 100);
		expect(stub.evt).toHaveBeenCalled();
	});


	it('returns the correct width', function () {
		var lane = norne.obj.create('core.lane', 0),
			max = 100;

		lane.addPoint(10, 0);
		lane.addPoint(max, 0);
		lane.addPoint(20, 0);

		expect(lane.width()).toEqual(max);
	});

});
<commit_msg>Implemented .addPoint and .getPoints. Needed to fix the binary search implementation. Added documentation.<commit_after>describe('core.lane', function () {

	it('should be accessible', function () {
		var lanefac = norne.obj.get('core.lane');
		expect(lanefac).toBeDefined();
	});


	it('checks the constructors parameters', function () {
		function catcher () {
			norne.obj.create('core.lane');
		}

		expect(catcher).toThrow();
	});


	it('should let me add points', function () {
		var lane, point, stub;

		lane = norne.obj.create('core.lane', 0);
		point = { x: 50, y: 100};
		stub = {
			evt: function (p) {
				expect(p.x).toEqual(point.x);
				expect(p.y).toEqual(point.y);
			}
		};

		spyOn(stub, 'evt');
		expect(lane.addPoint).toBeDefined();
		lane.on('addPoint', stub.evt);

		lane.addPoint(50, 100);
		expect(stub.evt).toHaveBeenCalled();
	});


	it('returns the correct width', function () {
		var lane = norne.obj.create('core.lane', 0),
			max = 100;

		lane.addPoint(10, 0);
		lane.addPoint(max, 0);
		lane.addPoint(20, 0);

		expect(lane.width()).toEqual(max);
	});


	it('lets me retrieve points (sorted) from a certain range', function () {
		var lane, p_true, p_false, p_union, p_diff, points;

		// should be inside the range
		p_true = [
			{x: 30, y: 0}, {x: -50, y: 0}, {x: 100, y: 0}, {x: 60, y: 0}
		];

		// should be outside the range
		p_false = [
			{x: 2000, y: 0}, {x: 101, y: 0}, {x: -80, y: 0}
		];

		// all elements sorted
		p_union = _(_.union(p_true, p_false)).sortBy(function (p) {
			return p.x;
		});

		// just elements in range, sorted
		p_diff = _(p_union).difference(p_false);

		lane = norne.obj.create('core.lane', 0);
		_(_.union(p_false, p_true)).each(function (p) {
			lane.addPoint(p.x, p.y);
		});

		// without parameters, all points must be returned
		points = lane.getPoints();
		_(p_union).each(function (p, i) {
			expect(points[i].x).toEqual(p.x);
			expect(points[i].y).toEqual(p.y);
		});

		// now with params, p[x-1] until p[y+1] must be returned
		points = lane.getPoints(0, 60);
		_(p_diff).each(function (p, i) {
			expect(points[i].x).toEqual(p.x);
			expect(points[i].y).toEqual(p.y);
		});

	});


	it('should retrieve correct points in extreme cases', function () {
		// TODO test for cases like one point added at 0,0
		// or the range is outside defined points etc.
	});

});

{'fraction_non_alphanumeric': 0.1911589008363202, 'fraction_numerical': 0.022998805256869773, 'mean_word_length': 3.447543160690571, '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': '734314', 'n_tokens_mistral': 1441, 'n_tokens_neox': 1248, 'n_words': 288}