<commit_before><!DOCTYPE HTML>
<html>
	<head>
		<title>Tile</title>
		<script type="text/javascript" src="../lib/jquery/jquery-1.4.2.min.js"></script>
		<script type="text/javascript" src="qunit.js"></script>
		<script type="text/javascript" src="fakes.js"></script>
		<script type="text/javascript" src="../src/mob.js"></script>
		<script type="text/javascript" src="../src/pickup.js"></script>
		<script type="text/javascript" src="../src/tile.js"></script>
		<link rel="stylesheet" href="qunit.css" type="text/css" media="screen" title="no title" charset="utf-8">
		<script>
			$(document).ready(function() {
				
				var checkexists = function(thing, message) {
					ok(typeof(thing) != 'undefined', message);
				};
				
				module('basics');
				
				test('ctor', function() {
					equals(typeof tile, 'function', 'tile exists');
					var t = tile();
					equals(typeof t.draw, 'function', 'draw exists');
				});
				
				module('statics');
				
				test('tilesize', function() {
					checkexists(tile.tilesize, 'tile.tilesize exists');
				});
				
				test('totilepos', function() {
					checkexists(tile.totilepos, 'tile.convertpos exists');
					var pos = tile.totilepos(0, 0);
					equals(pos.x, 0, 'converted (0,0) x position correctly');
					equals(pos.y, 0, 'converted (0,0) y position correctly');
					pos = tile.totilepos(32, 0);
					equals(pos.x, 1, 'converted (32,0) x position correctly');
					equals(pos.y, 0, 'converted (32,0) y position correctly');
					pos = tile.totilepos(32, 1);
					equals(pos.x, 1, 'converted (32,1) x position correctly');
					equals(pos.y, 0, 'converted (32,1) y position correctly');
					pos = tile.totilepos(-1, -1);
					equals(pos.x, -1, 'converted (-1, -1) x position correctly');
					equals(pos.y, -1, 'converted (-1, -1) y position correctly');
				});
				
				test('getrect', function() {
					ok(typeof(tile.getrect) === 'function', 'getrect is a function');
					var rect = tile.getrect(0, 0);
					equals(rect.x1, 0, 'x1');
					equals(rect.y1, 0, 'y1');
					equals(rect.x2, tile.tilesize - 1, 'x2');
					equals(rect.y2, tile.tilesize - 1, 'y2');
					rect = tile.getrect(1, 1);
					equals(rect.x1, tile.tilesize, 'x1');
					equals(rect.y1, tile.tilesize, 'y1');
					equals(rect.x2, tile.tilesize * 2 - 1, 'x2');
					equals(rect.y2, tile.tilesize * 2 - 1, 'y2');
				});
				
				module('tiles', {
					setup: function() {
						this.fakegame = new FakeGame();
						this.fakectx =  new FakeCtx();
					}
				});
				
				test('Air', function() {
					checkexists(tile.air, 'Air exists');
					ok(!tile.air.diggable, 'Air is not diggable');
				});

				test('Dirt', function() {
					checkexists(tile.dirt, 'Dirt exists');
					var dirt = tile.dirt();
					ok(typeof(dirt.draw) == 'function', 'dirt draw exists');
					ok(dirt.diggable, 'dirt is diggable');
					dirt.draw(this.fakectx);
					equals(this.fakectx.drawImageArgs.length, 1, 'drawImage called');
					var args = this.fakectx.drawImageArgs[0];
					equals(args.drx, 0, 'drawImage x');
					equals(args.dry, 0, 'drawImage y');
					equals(this.fakectx.fillRectArgs.length, 1, 'fill called');
					args = this.fakectx.fillRectArgs[0];
					equals(args.frx, 0, 'fillRect x');
					equals(args.fry, 30, 'fillRect y');
					equals(args.frw, tile.tilesize, 'fillRect width');
					equals(args.frh, 3, 'fillRect height');
				});
				
				test('DirtWithGrass', function() {
					checkexists(tile.dirtwithgrass, 'DirtWithGrass exists');
					var dirt = tile.dirtwithgrass({game: this.fakegame});
					ok(typeof(dirt.draw) === 'function', 'draw exists');
					ok(dirt.diggable, 'DirtWithGrass is diggable');
					dirt.draw(this.fakectx);
					equals(this.fakectx.fillRectArgs.length, 1, 'fill called once');
				});

				test('drawdamage', function() {
					equals(typeof(tile.drawdamage), 'function', 'drawdamage exists');
					tile.drawdamage(this.fakectx, 1);
					equals(this.fakectx.drawImageArgs.length, 0, 'drawImage not called');
					tile.drawdamage(this.fakectx, 0.9);
					equals(this.fakectx.drawImageArgs.length, 1, 'drawImage called');
					var args = this.fakectx.drawImageArgs[0];
					equals(args.drx, 0, 'x is 0');
					equals(args.dry, 0, 'y is 0');
					equals(args.img.src.substr(-11), 'cracks1.png', 'cracks1');
					tile.drawdamage(this.fakectx, 0.6);
					equals(this.fakectx.drawImageArgs.length, 2, 'drawImage called');
					var args = this.fakectx.drawImageArgs[1];
					equals(args.img.src.substr(-11), 'cracks2.png', 'cracks2');
					tile.drawdamage(this.fakectx, 0.3);
					equals(this.fakectx.drawImageArgs.length, 3, 'drawImage called');
					var args = this.fakectx.drawImageArgs[2];
					equals(args.img.src.substr(-11), 'cracks3.png', 'cracks3');
				});
				
				test('tile tick', function() {
					var d = tile.dirt();<commit_msg>fixed a last failing test<commit_after><!DOCTYPE HTML>
<html>
	<head>
		<title>Tile</title>
		<script type="text/javascript" src="../lib/jquery/jquery-1.4.2.min.js"></script>
		<script type="text/javascript" src="qunit.js"></script>
		<script type="text/javascript" src="fakes.js"></script>
		<script type="text/javascript" src="../src/mob.js"></script>
		<script type="text/javascript" src="../src/pickup.js"></script>
		<script type="text/javascript" src="../src/tile.js"></script>
		<link rel="stylesheet" href="qunit.css" type="text/css" media="screen" title="no title" charset="utf-8">
		<script>
			$(document).ready(function() {
				
				var checkexists = function(thing, message) {
					ok(typeof(thing) != 'undefined', message);
				};
				
				module('basics');
				
				test('ctor', function() {
					equals(typeof tile, 'function', 'tile exists');
					var t = tile();
					equals(typeof t.draw, 'function', 'draw exists');
				});
				
				module('statics');
				
				test('tilesize', function() {
					checkexists(tile.tilesize, 'tile.tilesize exists');
				});
				
				test('totilepos', function() {
					checkexists(tile.totilepos, 'tile.convertpos exists');
					var pos = tile.totilepos(0, 0);
					equals(pos.x, 0, 'converted (0,0) x position correctly');
					equals(pos.y, 0, 'converted (0,0) y position correctly');
					pos = tile.totilepos(32, 0);
					equals(pos.x, 1, 'converted (32,0) x position correctly');
					equals(pos.y, 0, 'converted (32,0) y position correctly');
					pos = tile.totilepos(32, 1);
					equals(pos.x, 1, 'converted (32,1) x position correctly');
					equals(pos.y, 0, 'converted (32,1) y position correctly');
					pos = tile.totilepos(-1, -1);
					equals(pos.x, -1, 'converted (-1, -1) x position correctly');
					equals(pos.y, -1, 'converted (-1, -1) y position correctly');
				});
				
				test('getrect', function() {
					ok(typeof(tile.getrect) === 'function', 'getrect is a function');
					var rect = tile.getrect(0, 0);
					equals(rect.x1, 0, 'x1');
					equals(rect.y1, 0, 'y1');
					equals(rect.x2, tile.tilesize - 1, 'x2');
					equals(rect.y2, tile.tilesize - 1, 'y2');
					rect = tile.getrect(1, 1);
					equals(rect.x1, tile.tilesize, 'x1');
					equals(rect.y1, tile.tilesize, 'y1');
					equals(rect.x2, tile.tilesize * 2 - 1, 'x2');
					equals(rect.y2, tile.tilesize * 2 - 1, 'y2');
				});
				
				module('tiles', {
					setup: function() {
						this.fakegame = new FakeGame();
						this.fakectx =  new FakeCtx();
					}
				});
				
				test('Air', function() {
					checkexists(tile.air, 'Air exists');
					ok(!tile.air.diggable, 'Air is not diggable');
				});

				test('Dirt', function() {
					checkexists(tile.dirt, 'Dirt exists');
					var dirt = tile.dirt({game: this.fakegame});
					ok(typeof(dirt.draw) == 'function', 'dirt draw exists');
					ok(dirt.diggable, 'dirt is diggable');
					dirt.draw(this.fakectx);
					equals(this.fakectx.drawImageArgs.length, 1, 'drawImage called');
					var args = this.fakectx.drawImageArgs[0];
					equals(args.drx, 0, 'drawImage x');
					equals(args.dry, 0, 'drawImage y');
					equals(this.fakectx.fillRectArgs.length, 1, 'fill called');
					args = this.fakectx.fillRectArgs[0];
					equals(args.frx, 0, 'fillRect x');
					equals(args.fry, 30, 'fillRect y');
					equals(args.frw, tile.tilesize, 'fillRect width');
					equals(args.frh, 3, 'fillRect height');
				});
				
				test('DirtWithGrass', function() {
					checkexists(tile.dirtwithgrass, 'DirtWithGrass exists');
					var dirt = tile.dirtwithgrass({game: this.fakegame});
					ok(typeof(dirt.draw) === 'function', 'draw exists');
					ok(dirt.diggable, 'DirtWithGrass is diggable');
					dirt.draw(this.fakectx);
					equals(this.fakectx.fillRectArgs.length, 1, 'fill called once');
				});

				test('drawdamage', function() {
					equals(typeof(tile.drawdamage), 'function', 'drawdamage exists');
					tile.drawdamage(this.fakectx, 1);
					equals(this.fakectx.drawImageArgs.length, 0, 'drawImage not called');
					tile.drawdamage(this.fakectx, 0.9);
					equals(this.fakectx.drawImageArgs.length, 1, 'drawImage called');
					var args = this.fakectx.drawImageArgs[0];
					equals(args.drx, 0, 'x is 0');
					equals(args.dry, 0, 'y is 0');
					equals(args.img.src.substr(-11), 'cracks1.png', 'cracks1');
					tile.drawdamage(this.fakectx, 0.6);
					equals(this.fakectx.drawImageArgs.length, 2, 'drawImage called');
					var args = this.fakectx.drawImageArgs[1];
					equals(args.img.src.substr(-11), 'cracks2.png', 'cracks2');
					tile.drawdamage(this.fakectx, 0.3);
					equals(this.fakectx.drawImageArgs.length, 3, 'drawImage called');
					var args = this.fakectx.drawImageArgs[2];
					equals(args.img.src.substr(-11), 'cracks3.png', 'cracks3');
				});
				
				test('tile tick', function() {
					var d = tile.dirt({game: this.fakegame});
{'fraction_non_alphanumeric': 0.18685192866030692, 'fraction_numerical': 0.023019493985897966, 'mean_word_length': 3.3038821954484603, 'pattern_counts': {'":': 0, '<': 41, '<?xml version=': 0, '>': 41, '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': '7179020', 'n_tokens_mistral': 4375, 'n_tokens_neox': 3416, 'n_words': 695}