From b0bf845186674b60a2d657528c0880ce4d2e722c Mon Sep 17 00:00:00 2001 From: Jonathan Olson Date: Tue, 28 Feb 2017 12:15:58 -0700 Subject: [PATCH] Adding assertions for #273 --- js/make-a-ten/common/model/PaperNumber.js | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/js/make-a-ten/common/model/PaperNumber.js b/js/make-a-ten/common/model/PaperNumber.js index 4ea144c..011bfe9 100644 --- a/js/make-a-ten/common/model/PaperNumber.js +++ b/js/make-a-ten/common/model/PaperNumber.js @@ -76,12 +76,15 @@ define( function( require ) { step: function( dt ) { if ( !this.userControlledProperty.value ) { var currentPosition = this.positionProperty.value; + assert && assert( currentPosition.isFinite() ); + assert && assert( this.destination.isFinite() ); // perform any animation var distanceToDestination = currentPosition.distance( this.destination ); if ( distanceToDestination > dt * MakeATenConstants.ANIMATION_VELOCITY ) { // Move a step toward the destination. var stepVector = this.destination.minus( currentPosition ).setMagnitude( MakeATenConstants.ANIMATION_VELOCITY * dt ); + assert && assert( stepVector.isFinite() ); this.positionProperty.value = currentPosition.plus( stepVector ); } @@ -164,6 +167,8 @@ define( function( require ) { * immediately set the position to be the same as the destination. */ setDestination: function( destination, animate ) { + assert && assert( destination.isFinite() ); + this.destination = destination; if ( animate ) {