From 3e9001c01a707f46a1600a55a6f0209be759da3f Mon Sep 17 00:00:00 2001 From: Michael Barlow Date: Mon, 7 Jan 2019 13:59:14 -0700 Subject: [PATCH] assertion tests added to OpenRangeTests.js, author annotations updated, see #73 --- js/OpenRange.js | 1 + js/OpenRangeTests.js | 15 +++++++-------- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/js/OpenRange.js b/js/OpenRange.js index 8bdbb27..5af05fd 100644 --- a/js/OpenRange.js +++ b/js/OpenRange.js @@ -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 ) ); } diff --git a/js/OpenRangeTests.js b/js/OpenRangeTests.js index beb1db7..85ef54c 100644 --- a/js/OpenRangeTests.js +++ b/js/OpenRangeTests.js @@ -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 ) { @@ -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' ); + } ); } ); \ No newline at end of file