mirror of
https://github.com/cappuccino/cappuccino.git
synced 2026-12-01 18:58:22 +00:00
Fixed: comparing a CPNumber vs nil or CPNull didn't throw an exception.
In Objective-C, both `[@34 compare:nil]` and `[@34 compare:[CPNull null]]` throw invalid argument exceptions. This fix makes the same true in Objective-J. Refs #1959.
This commit is contained in:
1 parent
315e3fccf3
commit
0f53ceda30
2 files changed
+20
No files matched your search
@@ -20,6 +20,8 @@
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
|
||||
@import "CPException.j"
|
||||
@import "CPNull.j"
|
||||
@import "CPObject.j"
|
||||
@import "CPObjJRuntime.j"
|
||||
|
||||
@@ -314,6 +316,9 @@ FIXME: Do we need this?
|
||||
|
||||
- (CPComparisonResult)compare:(CPNumber)aNumber
|
||||
{
|
||||
if (aNumber === nil || aNumber['isa'] === CPNull)
|
||||
[CPException raise:CPInvalidArgumentException reason:"nil argument"];
|
||||
|
||||
if (self > aNumber)
|
||||
return CPOrderedDescending;
|
||||
else if (self < aNumber)
|
||||
|
||||
@@ -0,0 +1,15 @@
|
||||
@import <Foundation/CPNumber.j>
|
||||
|
||||
@implementation CPNumberTest : OJTestCase
|
||||
|
||||
- (void)testCompareWithNil
|
||||
{
|
||||
[self assertThrows:function () { [34 compare:nil] }];
|
||||
}
|
||||
|
||||
- (void)testCompareWithCPNull
|
||||
{
|
||||
[self assertThrows:function () { [34 compare:[CPNull null]] }];
|
||||
}
|
||||
|
||||
@end
|
||||
Reference in new issue
Block a user