diff options
| author | Julie Lala <jules@okfoc.us> | 2014-07-23 19:37:35 -0400 |
|---|---|---|
| committer | Julie Lala <jules@okfoc.us> | 2014-07-23 19:37:35 -0400 |
| commit | 81bd659b6ba25f28267a0b63e502807e7f5e1ac9 (patch) | |
| tree | b5bdeaf9a22747ab0010b317e151a9d7f3f004da | |
| parent | 5e0c67b5d70d90ea12b207e3c442378559f8f219 (diff) | |
peninsula test
| -rw-r--r-- | test/03-test-clipping.js | 37 |
1 files changed, 34 insertions, 3 deletions
diff --git a/test/03-test-clipping.js b/test/03-test-clipping.js index 4743eb0..037b5ff 100644 --- a/test/03-test-clipping.js +++ b/test/03-test-clipping.js @@ -7,9 +7,10 @@ var Clipper = require("../public/assets/javascripts/rectangles/engine/rooms/clip var FRONT = 0x1, BACK = 0x2, LEFT = 0x4, RIGHT = 0x8, FLOOR = 0x10, CEILING = 0x20 var ALL = FRONT | BACK | LEFT | RIGHT -var rect = new Rect( new vec(1,4), new vec(1,4) ) -var east = new Rect( new vec(2,5), new vec(1,4) ) -var corner = new Rect( new vec(3,5), new vec(3,5) ) +var rect = new Rect( new vec(1,5), new vec(1,5) ) +var east = new Rect( new vec(2,6), new vec(1,5) ) +var corner = new Rect( new vec(3,7), new vec(3,7) ) +var peninsula = new Rect( new vec(4,6), new vec(6,8) ) function report(a) { console.log( a.join("\n") ) @@ -80,5 +81,35 @@ describe('clipper', function(){ }) }) + // + + Rooms.list = {} + Rooms.regions = [] + Rooms.add_with_rect( rect ) + Rooms.add_with_rect( corner ) + Rooms.add_with_rect( peninsula ) + + describe('#cull_rects(rect, corner, peninsula)', function(){ + Rooms.clipper.reset_rects() + var regions = Rooms.clipper.clip_rects() + var culled = Rooms.clipper.cull_rects() + var culled_dupes = culled.filter(function(r){ return r.dupe }) + var culled_regions = culled.filter(function(r){ return ! r.dupe }) + + report(culled_dupes) + report([]) + report(culled_regions) + + it('clipper returns 16 rects', function(){ + assert.equal(16, regions.length) + }) + it('culling marks 2 duplicate', function(){ + assert.equal(2, culled_dupes.length) + }) + it('culling marks 14 non-duplicate', function(){ + assert.equal(14, culled_regions.length) + }) + }) + }) |
