The Trunk: MultilingualTests-pre.27.mcz

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

The Trunk: MultilingualTests-pre.27.mcz

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

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

Name: MultilingualTests-pre.27
Author: pre
Time: 31 August 2017, 6:19:18.949747 pm
UUID: e3fa7680-679e-0a4f-b16d-5d8b3f205eda
Ancestors: MultilingualTests-pre.26

Minor changes to the tests for MultiByteFileStream checking for correct latin1 conversion for the fixed size UTF encodings and working on the LineEndConvention test to read in through MultiByteFileStream.

=============== Diff against MultilingualTests-pre.26 ===============

Item was changed:
  ----- Method: MultiByteFileStreamTest>>testLineEndConvention:withConverter:ifFail: (in category 'helpers') -----
  testLineEndConvention: lineEndConvention withConverter: textConverterClass ifFail: failBlock
 
  | expectedResult result |
  [
  MultiByteFileStream forceNewFileNamed: fileName do: [ :file |
  file
  converter: textConverterClass new;
  lineEndConvention: lineEndConvention;
  cr;
  nextPut: Character cr;
  nextPutAll: String cr;
  nextPutAll: String cr asWideString ].
+ result := MultiByteFileStream oldFileNamed: fileName do: [ :file |
+ file
+ converter: textConverterClass new;
+ contents ].
- result := StandardFileStream oldFileNamed: fileName do: [ :file |
- file contents ].
  expectedResult := String streamContents: [ :stream |
  4 timesRepeat: [ stream perform: lineEndConvention ] ].
  result = expectedResult ifFalse: [
  failBlock value: expectedResult asByteArray value: result asByteArray ] ]
  on: Error
  do: [ :err | failBlock value: err messageText value: err messageText ]!

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 ] ].!

Item was added:
+ ----- Method: MultiByteFileStreamTest>>testNextPutAllUtfsStartingAt (in category 'testing') -----
+ testNextPutAllUtfsStartingAt
+
+ | result |
+ fileName := 'foonextputallstartingat.txt'.
+ {'utf-16' . #[0 64 216 0 220 0 216 0 220 1 216 0 220 2] .
+   'utf-32'. #[0 0 0 64 0 1 0 0 0 1 0 1 0 1 0 2]}
+ pairsDo: [:encodingName :encodingResult |
+ MultiByteFileStream forceNewFileNamed: fileName do: [ :file | | string |
+ file converter: (TextConverter newForEncoding: encodingName).
+ string := self unicodeString.
+ file
+ next: 2 putAll: string startingAt: 1;
+ next: 1 putAll: string startingAt: 3;
+ next: 1 putAll: string startingAt: 4 ].
+ result := StandardFileStream readOnlyFileNamed: fileName do: [ :file |
+ file binary; contents ].
+
+ "See for example: https://unicode-table.com/de/10000/ --pre"
+ self assert: encodingResult equals: result]
+
+
+ !

Item was added:
+ ----- Method: MultiByteFileStreamTest>>unicodeString (in category 'fixtures') -----
+ unicodeString
+
+ ^ String newFrom: (#(64 65536 65537 65538) collect: [:n | Character codePoint: n])!