Skip to content

Commit

Permalink
Add more details to assertion error, see: #323
Browse files Browse the repository at this point in the history
  • Loading branch information
marlitas committed Sep 22, 2023
1 parent 2a25be3 commit 030f1f6
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion js/common/model/EnergySkateParkModel.js
Original file line number Diff line number Diff line change
Expand Up @@ -584,7 +584,12 @@ class EnergySkateParkModel extends PhetioObject {
correctedState = correctedState.updatePosition( proposedPosition.x, proposedPosition.y );
correctedState = correctedState.updateUDVelocity( correctedState.parametricSpeed, newVelocity.x, newVelocity.y );

assert && assert( Utils.equalsEpsilon( correctedState.getTotalEnergy(), skaterState.getTotalEnergy(), 1E-8 ), 'substantial total energy change after corrections' );
if ( assert ) {
const skaterTotalEnergy = skaterState.getTotalEnergy();
const correctedTotalEnergy = correctedState.getTotalEnergy();
assert && assert( Utils.equalsEpsilon( correctedTotalEnergy, skaterTotalEnergy, 1E-8 ),
`substantial total energy change after corrections. skaterTotalEnergy: ${skaterTotalEnergy}, correctedTotalEnergy: ${correctedTotalEnergy}, delta: ${Math.abs( skaterTotalEnergy - correctedTotalEnergy )}` );
}

return correctedState;
}
Expand Down

0 comments on commit 030f1f6

Please sign in to comment.