Permalink
Browse files

Removed okay from jshintrc exceptions because it's not actually a rea…

…l QUnit command, improved location of variable declaration in the camera-rotate example, added/improved tests in space.test
  • Loading branch information...
dperit committed May 24, 2012
1 parent f412812 commit 3660a12ad3f330b7374043a8d5208cce9f8ef0a7
Showing with 68 additions and 14 deletions.
  1. +0 −1 .jshintrc
  2. +4 −3 examples/camera-rotate/camera-rotate.js
  3. +64 −10 src/core/space.test.js
View
@@ -23,7 +23,6 @@
"expect",
"notEqual",
"ok",
"okay",
"deepEqual",
// HTML5 browser APIs that jshint will learn about someday
@@ -89,9 +89,10 @@ document.addEventListener( "DOMContentLoaded", function( e ) {
]
));
for (var xCoord = -11; xCoord < 11; xCoord = xCoord + 2){
for (var yCoord = -11; yCoord < 11; yCoord = yCoord + 2){
for (var zCoord = -11; zCoord < 11; zCoord = zCoord + 2){
var xCoord, yCoord, zCoord;
for (xCoord = -11; xCoord < 11; xCoord = xCoord + 2){
for (yCoord = -11; yCoord < 11; yCoord = yCoord + 2){
for (zCoord = -11; zCoord < 11; zCoord = zCoord + 2){
space.add(new engine.simulation.Entity("cubex:" + xCoord + "y:" + yCoord + "z:" + zCoord,
[
new engine.core.Transform( [xCoord, yCoord, zCoord], [0, 0, 0], [ 0.1, 0.1, 0.1 ] ),
View
@@ -1,26 +1,80 @@
define(
[ "core/space", "core/clock" ],
function( Space, Clock ) {
[ "core/space", "core/clock", "core/entity" ],
function( Space, Clock, Entity ) {
return function() {
module( "Space", {
setup: function() {},
teardown: function() {}
});
test("Constructing a space", function(){
expect(-1);
// test construction without a clock;
var mySpace = new Space();
test("Constructing a space with new clock", function(){
expect(6);
var clock = new Clock();
var mySpace = new Space(clock);
okay(mySpace.id, "space has an id");
ok(mySpace.id, "space has an id");
equal(mySpace.size, 0, "space has no entities");
deepEqual(mySpace._entities, {}, "entity object is empty");
deepEqual(mySpace._nameIndex, {}, "nameIndex object is empty");
deepEqual(mySpace._tagIndex, {}, "tagIndex object is empty");
okay(mySpace.clock instanceof Clock);
// TD test signal is same as simulation with no args to constructor
ok(mySpace.clock instanceof Clock);
});
test("Constructing a space without a clock", function(){
expect(6);
// test construction without a clock;
var mySpace = new Space();
//TODO: Figure out why calling new Space without a parameter works at
// all in any case, and determine what should be done in the case when
//one isn't passed in, because it just breaks right now
ok(mySpace.clock instanceof Clock);
});
test("Add entities works normally", function(){
expect(8);
var clock = new Clock();
var mySpace = new Space(clock);
var entityDupe1 = new Entity("duplicate", [], ["uniqueTag1", "commonTag"]);
var entityDupe2 = new Entity("duplicate", [], ["uniqueTag2", "commonTag"]);
var uniqueNameEntity = new Entity("unique", [], ["commonTag"]);
var emptyEntity = new Entity();
mySpace.add(emptyEntity);
equal(mySpace.size, 1, "empty entity added properly");
mySpace.add(uniqueNameEntity);
equal(mySpace.findNamed("unique"), uniqueNameEntity, "single entity added properly");
mySpace.add(entityDupe1);
mySpace.add(entityDupe2);
equal(mySpace.findAllNamed("duplicate").length, 2,
"make sure that multiple colliding names are shoved into an array");
equal(mySpace.findNamed("duplicate").tags[0], "uniqueTag1",
"make sure that findNamed returns the first of duplicate names");
deepEqual(mySpace.findAllTagged("commonTag"), [uniqueNameEntity, entityDupe1, entityDupe2],
"find all tagged returns the correct items");
equal(mySpace.findTagged("uniqueTag1"), entityDupe1,
"find tagged returns the first of multiple entities with the same tag");
var parentEntity = new Entity("parent", [], []);
var childEntity = new Entity("child", [], [], parentEntity);
mySpace.add(parentEntity);
equal(mySpace.findNamed("child"), childEntity,
"space recursively adds child entities");
mySpace.remove(parentEntity);
equal(mySpace.findNamed("child"), null,
"space recursively removes child entities");
//Find entities with a given component type
});
};

0 comments on commit 3660a12

Please sign in to comment.