Portability fixes in PPPredicateTest>>charactersDo: / parsedCharacterSet:
* It is my understanding that charactersDo: should iterate over all signle byte
characters. If so, the method suffer from off-by-one error, it should generate
characters with code points 0..255. 256 is actually a two-byte character.
Method changed accordingly.
* Use Character>>asString instead of `String>>with:` which is safer
w.r.t. multi-byte characters. Under Smalltalk/X, String may contain only
signle byte characters.
--- a/tests/PPPredicateTest.st Mon Nov 03 11:33:28 2014 +0000
+++ b/tests/PPPredicateTest.st Mon Nov 03 12:46:42 2014 +0000
@@ -11,7 +11,9 @@
!PPPredicateTest methodsFor:'private'!
charactersDo: aBlock
- 1 to: 256 do: [ :index | aBlock value: (Character codePoint: index) ]
+ 0 to: 255 do: [ :index | aBlock value: (Character codePoint: index) ]
+
+ "Modified: / 03-11-2014 / 09:11:31 / Jan Vrany <jan.vrany@fit.cvut.cz>"
! !
!PPPredicateTest methodsFor:'testing'!
@@ -322,12 +324,14 @@
!
parsedCharacterSet: aParser
- | result |
- result := String new writeStream.
- self charactersDo: [ :char |
- (aParser matches: (String with: char))
- ifTrue: [ result nextPut: char ] ].
- ^ result contents
+ | result |
+ result := String new writeStream.
+ self charactersDo: [ :char |
+ (aParser matches: char asString)
+ ifTrue: [ result nextPut: char ] ].
+ ^ result contents
+
+ "Modified: / 03-11-2014 / 09:16:33 / Jan Vrany <jan.vrany@fit.cvut.cz>"
! !
!PPPredicateTest class methodsFor:'documentation'!