On Sunday 21 March 2010 21:58:57 Nicolas Petton wrote:
> Grease is not ready to use yet. Currently many tests fail, as I just
> imported code without really porting it, but I should have some time
> next week to work on that :)
Awesome, I cloned your repository and use that as an oppurtunity to improve my
Smalltalk knowledge. The below is an application of capitalized that makes us
pass some more tests, I will attempt to make GST pass the GRStringTests this
week.
The patch is still work in progress, e.g. the GRStringTests >>
testCapitalizedUmlauts will require us to either change the default encoding
to latin1, or play with some tricks like converting the String to a
UnicodeString in case the first charachter looks like a UTF-8 symbol.
regards
holger
diff --git a/Core/Extensions.st b/Core/Extensions.st
index 18dae68..45586cc 100644
--- a/Core/Extensions.st
+++ b/Core/Extensions.st
@@ -20,6 +20,22 @@ String extend [
^self startsWith: aString
]
+ capitalized [
+ <category: '*Grease-GST-Core'>
+ | capitalized |
+
+ " fast case "
+ self isEmpty
+ ifTrue: [self copy.].
+
+ " detect the encoding "
+ capitalized := self copy.
+
+ capitalized isEmpty
+ ifFalse: [capitalized at: 1 put: ((capitalized at: 1) asUppercase).].
+ ^ capitalized
+ ]
+
excerpt: aString [
<category: '*Grease-Core'>
"Answer an excerpt of the receiver that matches the first occurence of aString. If aString isn't found, nil is answered."
@@ -263,3 +279,10 @@ UndefinedObject extend [
<category: '*Grease-Core'>
]
]
+
+Symbol extend [
+ capitalized [
+ <category: '*Grease-GST-Core'>
+ ^ self asString capitalized asSymbol
+ ]
+]
_______________________________________________
help-smalltalk mailing list
[email protected]
http://lists.gnu.org/mailman/listinfo/help-smalltalk