mirror of
https://github.com/cappuccino/cappuccino.git
synced 2026-11-09 16:38:45 +00:00
enable '.003' or '-.003' style number in CPDecimalMakeWithString function and add new test cases
This commit is contained in:
1 parent
729d2493cd
commit
9f1a8fa7a2
2 files changed
+6
-1
No files matched your search
@@ -115,7 +115,8 @@ function CPDecimalMakeWithString(string, locale)
|
||||
|
||||
// Note: this doesn't accept .01 for example, should it?
|
||||
// If yes simply add '?' after integer part group, i.e. ([+\-]?)((?:0|[1-9]\d*)?)
|
||||
var matches = string.match(/^([+\-]?)((?:0|[1-9]\d*))(?:\.(\d*))?(?:[eE]([+\-]?)(\d+))?$/);
|
||||
// Note: now it accept .01 style.
|
||||
var matches = string.match(/^([+\-]?)((?:0|[1-9]\d*)?)(?:\.(\d*))?(?:[eE]([+\-]?)(\d+))?$/);
|
||||
if (!matches)
|
||||
return CPDecimalMakeNaN();
|
||||
|
||||
|
||||
@@ -522,6 +522,10 @@
|
||||
[self assert:"123456789123456789123456789000000000000000" equals:[dcmn stringValue] message:"stringValue: - large number"];
|
||||
dcmn = [CPDecimalNumber decimalNumberWithString:@"82346.2341144"];
|
||||
[self assert:"82346.2341144" equals:[dcmn descriptionWithLocale:nil] message:"descriptionWithLocale: - large number"];
|
||||
dcmn = [CPDecimalNumber decimalNumberWithString:@".125"];
|
||||
[self assert:"0.125" equals:[dcmn descriptionWithLocale:nil] message:"stringValue: - no integral part number"];
|
||||
dcmn = [CPDecimalNumber decimalNumberWithString:@"-.003"];
|
||||
[self assert:"-0.003" equals:[dcmn descriptionWithLocale:nil] message:"stringValue: - no integral part negative number"];
|
||||
}
|
||||
|
||||
- (void)testEncoding
|
||||
|
||||
Reference in new issue
Block a user