Skip to content

Commit 1393deb

Browse files
committed
Fix Integer printing and decimalDigitLength
1 parent 9faaa55 commit 1393deb

6 files changed

Lines changed: 56 additions & 3 deletions

File tree

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
*neo-json-gemstone-core
22
decimalDigitLength
33
"Alias needed for Zinc"
4-
^ self digitLength
4+
^ self numberOfDigitsInBase: 10

filetree/Neo-JSON-GemStone-Core.package/SmallInteger.extension/instance/numberOfDigitsInBase..st

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,5 @@ numberOfDigitsInBase: b
33
"Return how many digits are necessary to print this number in base b.
44
Mostly same as super but an optimized version for base 10 case"
55

6-
b = 10 ifFalse: [^super numberOfDigitsInBase: b].
76
self < 0 ifTrue: [^self negated numberOfDigitsInBase: b].
8-
^self decimalDigitLength
7+
^super numberOfDigitsInBase: b
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
NeoJSONIntegerExtensionTests tests Integer-related extensions
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
public
2+
testDecimalDigitLength
3+
4+
self
5+
assert: 9 decimalDigitLength
6+
equals: 1.
7+
self
8+
assert: 9999999 decimalDigitLength
9+
equals: 7
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
public
2+
testPrintOnBaseLengthPadded
3+
4+
| int length printer |
5+
printer := [String streamContents: [:stream | int printOn: stream base: 10 length: length padded: true]].
6+
7+
int := 9.
8+
length := 1.
9+
self
10+
assert: printer value
11+
equals: '9'.
12+
length := 4.
13+
self
14+
assert: printer value
15+
equals: '0009'.
16+
17+
int := -9.
18+
length := 1.
19+
self
20+
assert: printer value
21+
equals: '-9'.
22+
length := 3.
23+
self
24+
assert: printer value
25+
equals: '-09'.
26+
27+
int := 9999999.
28+
length := 8.
29+
self
30+
assert: printer value
31+
equals: '09999999'
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
{
2+
"category" : "Neo-JSON-GemStone-Tests",
3+
"classinstvars" : [
4+
],
5+
"classvars" : [
6+
],
7+
"commentStamp" : "",
8+
"instvars" : [],
9+
"name" : "NeoJSONIntegerExtensionTests",
10+
"pools" : [
11+
],
12+
"super" : "TestCase",
13+
"type" : "normal" }

0 commit comments

Comments
 (0)