[Pkg] The Trunk: MultilingualTests-pre.25.mcz

commits at source.squeak.org commits at source.squeak.org
Tue Jun 20 11:49:04 UTC 2017


Patrick Rein uploaded a new version of MultilingualTests to project The Trunk:
http://source.squeak.org/trunk/MultilingualTests-pre.25.mcz

==================== Summary ====================

Name: MultilingualTests-pre.25
Author: pre
Time: 20 June 2017, 7:48:48.189902 am
UUID: c40a038c-6884-994b-a1aa-c7cdcddf2805
Ancestors: MultilingualTests-pre.24

Reverts accidentially removed code and merges it with the new version.

=============== Diff against MultilingualTests-pre.24 ===============

Item was changed:
  ----- Method: MultiByteFileStreamTest>>testByteTextConverter (in category 'testing') -----
  testByteTextConverter
+ 
+ 	| byteCharacters converterClasses |
+ 	byteCharacters := Character allByteCharacters.
- 	| strings converterClasses |
- 	strings := {
- 		String newFrom: ((0 to: 255) collect: [:e | e asCharacter]).
- 	}.
- 	
  	converterClasses := ByteTextConverter allSubclasses 
+ 		copyWithoutAll: {ISO8859TextConverter . WinCPTextConverter . MacOSCPTextConverter}. 
+ 	converterClasses do: [ :converterClass |
+ 		| converter stream encoded decoded encoded2 |
+ 		converter := converterClass new.
+ 		stream := byteCharacters readStream.
+ 		"Find bytes that can be decoded by this converter."
+ 		encoded := byteCharacters select: [ :e | (converter nextFromStream: stream) notNil ].
+ 		"Decode those bytes."
+ 		stream := encoded readStream.
+ 		decoded := encoded collect: [ :e | converter nextFromStream: stream ].
+ 		self assert: stream atEnd.
+ 		"Re-encode the decoded bytes using #nextPutAll:toStream:, and check if they match the original bytes."
+ 		encoded2 := String streamContents: [ :writeStream |
+ 			converter nextPutAll: decoded toStream: writeStream ].
+ 		encoded with: encoded2 do: [ :original :reencoded |
+ 			self 
+ 				assert: original charCode = reencoded charCode
+ 				description: [ '{1} could not decode or re-encode {2} using #nextPutAll:toStream:. Instead, it yielded {3}.'
+ 					format: {
+ 						converterClass name.
+ 						original charCode.
+ 						reencoded charCode } ] ].
+ 		"Re-encode the decoded bytes using #nextPut:toStream:, and check if they match the original bytes."
+ 		encoded2 := String streamContents: [ :writeStream |
+ 			decoded do: [:e | converter nextPut: e toStream: writeStream ] ].
+ 		encoded with: encoded2 do: [ :original :reencoded |
+ 			self 
+ 				assert: original charCode = reencoded charCode
+ 				description: [ '{1} could not decode or re-encode {2} using #nextPut:toStream:. Instead, it yielded {3}.'
+ 					format: {
+ 						converterClass name.
+ 						original charCode.
+ 						reencoded charCode } ] ] ]!
- 		copyWithoutAll: {ISO8859TextConverter . WinCPTextConverter . MacOSCPTextConverter}.
- 	converterClasses do: [:converterClass | 
- 		strings do: [:string | | converter stream encoded decoded encoded2 |
- 			converter := converterClass new.
- 			stream := string readStream.
- 			encoded := string select: [:e | (converter nextFromStream: stream) notNil].
- 			stream := encoded readStream.
- 			decoded := encoded collect: [:e | converter nextFromStream: stream].
- 			self assert: stream atEnd.
- 			stream := String new writeStream.
- 			converter nextPutAll: decoded toStream: stream.
- 			encoded2 := stream contents.
- 			self assert: (encoded2 collect: [:e | e charCode] as: Array) = (encoded collect: [:e | e charCode] as: Array).
- 			stream := String new writeStream.
- 			decoded do: [:e | converter nextPut: e toStream: stream].
- 			encoded2 := stream contents.
- 			self assert: (encoded2 collect: [:e | e charCode] as: Array) = (encoded collect: [:e | e charCode] as: Array)]]!

Item was changed:
  ----- Method: MultiByteFileStreamTest>>testLineEndConversion (in category 'testing') -----
  testLineEndConversion
  
  	| failures | 
  	fileName := 'foolinendconversion.txt'.
  	failures := OrderedCollection new.
  	TextConverter allSubclassesDo: [ :textConverterClass |
  		textConverterClass encodingNames ifNotEmpty: [
  			#(cr lf crlf) do: [ :lineEndConvention |
  				self
  					testLineEndConvention: lineEndConvention
  					withConverter: textConverterClass
  					ifFail: [ :expectedResult :result |
  						failures add: {
  							textConverterClass.
  							lineEndConvention.
  							expectedResult.
  							result } ] ] ] ].
+ 	self assert: failures isEmpty.
+ 	"The code below is here to help you see why those cases fail"
+ 	failures do: [ :failure |
+ 		self
+ 			testLineEndConvention: failure second
+ 			withConverter: failure first
+ 			ifFail: [ :expectedResult :result | self halt ] ].!
- 	self assert: failures isEmpty!



More information about the Packages mailing list