Permalink
Browse files

node: asserting with global vars is dumb.

  • Loading branch information...
1 parent bafd87b commit f260a4868f7375b91ba0077e8975e8cb21919b5c @lamberta committed Jun 13, 2011
Showing with 31 additions and 77 deletions.
  1. +6 −29 build/doodle-debug.js
  2. +19 −19 build/doodle.js
  3. +6 −29 src/node.js
View
@@ -9657,8 +9657,8 @@ doodle.Emitter.isEmitter = function (obj) {
/*DEBUG*/
window.debug_len = children.length;
type_check(index1,'number', index2,'number', {label:'Node.swapChildrenAt', params:['index1', 'index2'], id:this.id});
- range_check(index1 >= -window.debug_len, index1 < window.debug_len, {label:'Node.setChildIndex', params:['*index1*', 'index2'], id:this.id, message:"Index out of range."});
- range_check(index2 >= -window.debug_len, index2 < window.debug_len, {label:'Node.setChildIndex', params:['index1', '*index2*'], id:this.id, message:"Index out of range."});
+ range_check(index1 >= -children.length, index1 < children.length, {label:'Node.setChildIndex', params:['*index1*', 'index2'], id:this.id, message:"Index out of range."});
+ range_check(index2 >= -children.length, index2 < children.length, {label:'Node.setChildIndex', params:['index1', '*index2*'], id:this.id, message:"Index out of range."});
//asserts
console.assert(doodle.Node.isNode(children[index1]), "Child is a Node.", children[index1]);
console.assert(doodle.Node.isNode(children[index2]), "Child is a Node.", children[index2]);
@@ -9695,17 +9695,10 @@ doodle.Emitter.isEmitter = function (obj) {
value: function (node1, node2) {
var children = this.children;
/*DEBUG*/
- window.debug_len = children.length;
type_check(node1, 'Node', node2, 'Node', {label:'Node.swapChildren', id:this.id, params:['node1', 'node2'], inherits:true});
reference_check(node1.parent === this, node2.parent === this, {label:'Node.swapChildren', params:['child1','child2'], id:this.id, message:"Can not swap a Node that is not a child."});
/*END_DEBUG*/
-
this.swapChildrenAt(children.indexOf(node1), children.indexOf(node2));
-
- /*DEBUG*/
- console.assert(window.debug_len === children.length, "Children array length is still the same.");
- delete window.debug_len;
- /*END_DEBUG*/
}
},
@@ -9726,18 +9719,10 @@ doodle.Emitter.isEmitter = function (obj) {
/*DEBUG*/
type_check(node, 'Node', {label:'Node.swapDepths', params:'node', id:this.id, inherits:true});
reference_check(parent !== null, node.parent === parent, {label:'Node.swapDepths', params:'*node*', id:this.id, message:"Can not swap positions with a Node that has a different parent."});
- //asserts
console.assert(doodle.Node.isNode(parent), "parent is a Node", parent);
- window.debug_len = parent.children.length;
/*END_DEBUG*/
-
children = parent.children;
parent.swapChildrenAt(children.indexOf(this), children.indexOf(node));
-
- /*DEBUG*/
- console.assert(window.debug_len === children.length, "Children array length is still the same.");
- delete window.debug_len;
- /*END_DEBUG*/
}
},
@@ -9753,22 +9738,14 @@ doodle.Emitter.isEmitter = function (obj) {
writable: false,
configurable: false,
value: function (index) {
- var parent = this.parent;
/*DEBUG*/
type_check(index, 'number', {label:'Node.swapDepthAt', params:'index', id:this.id});
- reference_check(parent !== null, {label:'Node.swapDepthAt', params:'*index*', id:this.id, message:"Node does not have a parent."});
+ reference_check(this.parent !== null, {label:'Node.swapDepthAt', params:'*index*', id:this.id, message:"Node does not have a parent."});
- console.assert(doodle.Node.isNode(parent), "Node has parent Node.");
- window.debug_len = parent.children.length;
- range_check(index >= -window.debug_len, index < window.debug_len, {label:'Node.swapDepthAt', params:'*index1*', id:this.id, message:"Index out of range."});
- /*END_DEBUG*/
-
- parent.swapChildrenAt(parent.children.indexOf(this), index);
-
- /*DEBUG*/
- console.assert(window.debug_len === parent.children.length, "Children array length is still the same length.");
- delete window.debug_len;
+ console.assert(doodle.Node.isNode(this.parent), "Node has parent Node.");
+ range_check(index >= -this.parent.children.length, index < this.parent.children.length, {label:'Node.swapDepthAt', params:'*index1*', id:this.id, message:"Index out of range."});
/*END_DEBUG*/
+ this.parent.swapChildrenAt(this.parent.children.indexOf(this), index);
}
},
Oops, something went wrong.

0 comments on commit f260a48

Please sign in to comment.