From f108dd2bb0807ee1a902d97bdb9570637b84ca7f Mon Sep 17 00:00:00 2001 From: Michael Scharp Date: Mon, 24 Mar 2014 09:23:16 -0600 Subject: [PATCH 1/2] Update min.as An array that contained an element with a value of 0 was returning an incorrect value as the minimum. Added check to see if the result is a number. --- asx/src/asx/array/min.as | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/asx/src/asx/array/min.as b/asx/src/asx/array/min.as index e382c33..d171ab6 100644 --- a/asx/src/asx/array/min.as +++ b/asx/src/asx/array/min.as @@ -26,7 +26,7 @@ package asx.array { for each (item in iterable) { - if (!result) + if (!result && !(result is Number)) { result = item; } @@ -39,4 +39,4 @@ package asx.array return result; } -} \ No newline at end of file +} From fb3adc770e7d65ae448175fb6ede32fbd2ca525a Mon Sep 17 00:00:00 2001 From: Michael Scharp Date: Mon, 24 Mar 2014 09:26:52 -0600 Subject: [PATCH 2/2] Update MinTest.as Updated tests. --- asx_test/src/asx/array/MinTest.as | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/asx_test/src/asx/array/MinTest.as b/asx_test/src/asx/array/MinTest.as index 32ce7fa..616ea2c 100644 --- a/asx_test/src/asx/array/MinTest.as +++ b/asx_test/src/asx/array/MinTest.as @@ -9,8 +9,8 @@ package asx.array [Test] public function min_withArray_returnsTheMinimumItem():void { - assertThat(min([1, 101, 11, 10, 100]), equalTo(1)); - assertThat(min(['1', '101', '11', '10', '100']), equalTo('1')); + assertThat(min([1, 101, 11, 10, 0, 100]), equalTo(0)); + assertThat(min(['1', '101', '11', '10', '0', '100']), equalTo('0')); } [Test] @@ -24,4 +24,4 @@ package asx.array assertThat(min(items, 'value'), hasProperty('value', 1)); } } -} \ No newline at end of file +}