1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/js/src/jit-test/tests/ion/bug991457.js Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,64 @@ 1.4 +function test() { 1.5 + this.init(); 1.6 + for (var i=0; i<10; i++) { 1.7 + delete this.blocks[10][9]; 1.8 + this.collapse_blocks(); 1.9 + } 1.10 + this.look_for_holes(); 1.11 +} 1.12 +test.prototype.init = function() { 1.13 + this.blocks = new Array(20); 1.14 + for (var x=0; x<this.blocks.length; x++) { 1.15 + this.blocks[x] = new Array(10); 1.16 + for (var y=0; y<this.blocks[x].length; y++) { 1.17 + this.blocks[x][y] = {}; 1.18 + } 1.19 + } 1.20 +} 1.21 +test.prototype.move_block = function(x,y,x1,y1) { 1.22 + this.blocks[x][y] = this.blocks[x1][y1]; 1.23 + if (this.blocks[x][y]) 1.24 + delete this.blocks[x1][y1]; 1.25 +} 1.26 +test.prototype.collapse_blocks = function() { 1.27 + var didSomething=0; 1.28 + do { 1.29 + didSomething=0; 1.30 + for (var x=0; x<this.blocks.length; x++) 1.31 + for (var y=1; y<this.blocks[x].length; y++) { 1.32 + if (!this.blocks[x][y] && this.blocks[x][y-1]) { 1.33 + this.move_block(x,y,x,y-1); 1.34 + didSomething=1; 1.35 + } 1.36 + } 1.37 + } while (didSomething); 1.38 + 1.39 + do { 1.40 + didSomething = 0; 1.41 + for (var x=0; x<this.blocks.length-1; x++) { 1.42 + if (!this.blocks[x][9] && this.blocks[x+1][9]) { 1.43 + for (var y=0; y<this.blocks[x].length; y++) 1.44 + this.move_block(x,y,x+1,y); 1.45 + didSomething = 1; 1.46 + } 1.47 + } 1.48 + } while (didSomething); 1.49 +} 1.50 +test.prototype.look_for_holes = function() { 1.51 + var was_empty = false; 1.52 + var n_empty = 0; 1.53 + for (var x=0; x<this.blocks.length; x++) { 1.54 + var empty = true; 1.55 + for (var y=0; y<this.blocks[x].length; y++) { 1.56 + if (this.blocks[x][y]) { 1.57 + empty = false; 1.58 + n_empty++; 1.59 + } 1.60 + } 1.61 + if (was_empty) 1.62 + assertEq(empty, true); 1.63 + was_empty = empty; 1.64 + } 1.65 + assertEq(n_empty, 190); 1.66 +} 1.67 +new test();