Skip to content

Commit

Permalink
assertion tests added to OpenRangeTests.js, author annotations update…
Browse files Browse the repository at this point in the history
…d, see #73
  • Loading branch information
mbarlow12 committed Jan 7, 2019
1 parent d4e9b3e commit 3e9001c
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
1 change: 1 addition & 0 deletions js/OpenRange.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ define( function( require ) {
this.openMax = options.openMax;

// if the interval is open, ensure that the min is strictly less than the max
assert && assert( this.openMin || this.openMax, 'use Range type if min and max are inclusive' );
assert && ( ( this.openMin || this.openMax ) ? assert( min < max ) : assert( min <= max ) );
}

Expand Down
15 changes: 7 additions & 8 deletions js/OpenRangeTests.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,7 @@
/**
* Bounds2 tests
*
* @author Jonathan Olson (PhET Interactive Simulations)
* @author Sam Reid (PhET Interactive Simulations)
* @author Michael Barlow (PhET Interactive Simulations)
*/

define( function( require ) {
Expand Down Expand Up @@ -55,10 +54,10 @@ define( function( require ) {
assert.ok( openRange.containsRange( new Range( 1.000000001, 2 ) ), '(1, 10) contains [1.000000001, 2]' );
} );

// QUnit.test( 'assertion failures', function( assert ) {
// debugger;
// assert.throws( new OpenRange( 1, 1, minHalfOpenOptions ), 'min open range with min === max throws an error' );
// assert.throws( new OpenRange( 1, 1, maxHalfOpenOptions ), 'max open range with min === max throws an error' );
// assert.throws( new OpenRange( 1, 1 ), 'full open range with min === max throws an error' );
// } );
QUnit.test( 'assertion failures', function( assert ) {
assert.throws( () => new OpenRange( 1, 10, { openMin: false, openMax: false } ), 'include both min and max throws an error' );
assert.throws( () => new OpenRange( 1, 1, minHalfOpenOptions ), 'min open range with min === max throws an error' );
assert.throws( () => new OpenRange( 1, 1, maxHalfOpenOptions ), 'max open range with min === max throws an error' );
assert.throws( () => new OpenRange( 1, 1 ), 'full open range with min === max throws an error' );
} );
} );

0 comments on commit 3e9001c

Please sign in to comment.