summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorJulie Lala <jules@okfoc.us>2014-07-23 15:15:21 -0400
committerJulie Lala <jules@okfoc.us>2014-07-23 15:27:42 -0400
commitc3d855b3f0b6af000c0d359da6a2b774bcd0a5d5 (patch)
tree7ab85a3a83fbffefd86c494e262f2a25edbcded8 /test
parent8a8b78b3f6a4ce930263099fe14b0fe86d11597f (diff)
handling coplanar walls correctly
Diffstat (limited to 'test')
-rw-r--r--test/01-test-vec2.js7
-rw-r--r--test/02-test-rect.js65
2 files changed, 57 insertions, 15 deletions
diff --git a/test/01-test-vec2.js b/test/01-test-vec2.js
index 054d37b..b38f052 100644
--- a/test/01-test-vec2.js
+++ b/test/01-test-vec2.js
@@ -38,6 +38,13 @@ describe('vec2', function(){
assert.equal(false, vec.contains( -5 ));
assert.equal(false, vec.contains( 15 ));
})
+ it('containsCenter itself', function(){
+ assert.equal(true, vec.containsCenter( 5 ));
+ })
+ it('does not containsCenter its endpoints', function(){
+ assert.equal(false, vec.containsCenter( 0 ));
+ assert.equal(false, vec.containsCenter( 10 ));
+ })
it('intersects when only startpoint matches', function(){
assert.equal(true, vec.intersects( new vec2(-5, 0) ));
})
diff --git a/test/02-test-rect.js b/test/02-test-rect.js
index 0ae59f7..55f1ec9 100644
--- a/test/02-test-rect.js
+++ b/test/02-test-rect.js
@@ -60,17 +60,15 @@ describe('rect', function(){
return prev | curr.sides
}, 0)
}
+ /*
+ console.log(s0.map(function(r){ return r.toString() }))
+ console.log(s1.map(function(r){ return r.toString() }))
+ */
describe('#split(rect, east)', function(){
var s0 = rect.split(east)
var s1 = east.split(rect)
- console.log("\n")
- console.log(rect+"")
- console.log(east+"")
- console.log(s0.map(function(r){ return r.toString() }))
- console.log(s1.map(function(r){ return r.toString() }))
-
it('splits on all 4 sides', function(){
assert.equal(ALL, sides(s0) | sides(s1))
})
@@ -99,6 +97,7 @@ describe('rect', function(){
describe('#split(rect, east_edge)', function(){
var s0 = rect.split(east_edge)
var s1 = east_edge.split(rect)
+
it('has no degenerate vectors', function(){
s0.forEach(function(r){
assert.notEqual(0, r.x.magnitude())
@@ -113,17 +112,17 @@ describe('rect', function(){
assert.equal(ALL, sides(s0) | sides(s1))
})
it('rect is front/back/left', function(){
- assert.equal(FRONT | BACK | LEFT, sides(s0))
+ assert.equal(ALL, sides(s0))
})
it('east is front/back/right', function(){
assert.equal(FRONT | BACK | RIGHT, sides(s1))
})
})
- return
describe('#split(rect, south)', function(){
var s0 = rect.split(south)
var s1 = south.split(rect)
+
it('splits on all 4 sides', function(){
assert.equal(ALL, sides(s0) | sides(s1))
})
@@ -135,18 +134,54 @@ describe('rect', function(){
})
})
+ describe('#split(rect, south_in)', function(){
+ var s0 = rect.split(south_in)
+ var s1 = south_in.split(rect)
+ it('splits on all 4 sides', function(){
+ assert.equal(ALL, sides(s0) | sides(s1))
+ })
+ it('rect is has all sides', function(){
+ assert.equal(ALL, sides(s0))
+ })
+ it('south_in only has left/right', function(){
+ assert.equal(LEFT | RIGHT, sides(s1))
+ })
+ })
+
+ describe('#split(rect, south_edge)', function(){
+ var s0 = rect.split(south_edge)
+ var s1 = south_edge.split(rect)
+
+ it('has no degenerate vectors', function(){
+ s0.forEach(function(r){
+ assert.notEqual(0, r.x.magnitude())
+ assert.notEqual(0, r.y.magnitude())
+ })
+ s1.forEach(function(r){
+ assert.notEqual(0, r.x.magnitude())
+ assert.notEqual(0, r.y.magnitude())
+ })
+ })
+ it('splits on all 4 sides', function(){
+ assert.equal(ALL, sides(s0) | sides(s1))
+ })
+ it('rect has all sides', function(){
+ assert.equal(ALL, sides(s0))
+ })
+ it('south is back/left/right', function(){
+ assert.equal(BACK | LEFT | RIGHT, sides(s1))
+ })
+ })
+
describe('#split(rect, corner)', function(){
var s0 = rect.split(corner)
var s1 = corner.split(rect)
- it('splits on all 4 sides', function(){
- // assert.equal(ALL, sides(s0) | sides(s1))
- })
- it('rect is front/left/right', function(){
- // assert.equal(FRONT | LEFT | RIGHT, sides(s0))
+ it('rect splits on all 4 sides', function(){
+ assert.equal(ALL, sides(s0))
})
- it('corner is back/left/right', function(){
-// assert.equal(BACK| LEFT | RIGHT, sides(s1))
+ it('corner splits on all 4 sides', function(){
+ assert.equal(ALL, sides(s1))
})
})