The Trunk: MultilingualTests-ul.32.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-ul.32.mcz

commits-2
Levente Uzonyi uploaded a new version of MultilingualTests to project The Trunk:
http://source.squeak.org/trunk/MultilingualTests-ul.32.mcz

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

Name: MultilingualTests-ul.32
Author: ul
Time: 2 July 2018, 11:33:14.701094 pm
UUID: 37d57291-187e-4317-83c4-ec3cef2b5a92
Ancestors: MultilingualTests-dtl.31

MultiByteFileStreamTest:
- use the existing mechanism (assign to the instance variable fileName) to prevent files being left behind
- use *fileNamed:do: instead of *fileNamed: to ensure the files are closed right after use

=============== Diff against MultilingualTests-dtl.31 ===============

Item was changed:
  ----- Method: MultiByteFileStreamTest>>testUpToAllAscii (in category 'testing') -----
  testUpToAllAscii
  "This test case is inspired by Mantis #4665."
  "Compare to testUpToAllUtf."
 
+ | resultA resultB |
+ fileName :='testUpToAll.in'.
+ FileDirectory default forceNewFileNamed: fileName do: [ :out |
+ out nextPutAll: 'A<'. "Encodes to byte sequence 413C" ].
- | in out fn resultA resultB |
- fn :='testUpToAll.in'.
- out := FileDirectory default forceNewFileNamed: fn.
- out nextPutAll: 'A<'. "Encodes to byte sequence 413C"
- out close.
 
+ resultA := FileDirectory default readOnlyFileNamed: fileName do: [ :in |
+ in upToAll: '<' ].
- in := FileDirectory default readOnlyFileNamed: fn.
- resultA := in upToAll: '<'.
- in close.
 
+ resultB := FileDirectory default readOnlyFileNamed: fileName do: [ :in |
+ in upTo: $< ].
- in := FileDirectory default readOnlyFileNamed: fn.
- resultB := in upTo: $<.
- in close.
 
  self assert: resultA = resultB
  !

Item was changed:
  ----- Method: MultiByteFileStreamTest>>testUpToAllNonZeroLength (in category 'testing') -----
  testUpToAllNonZeroLength
  "Ensures that upToAll: correctly skips over the nonzero-length separator."
+
+ fileName :='testUpToAll.in'.
+ FileDirectory default forceNewFileNamed: fileName do: [ :out |
+ out nextPutAll: 231 asCharacter asString, 'a<b<<c' ].
- | in out fn |
- fn :='testUpToAll.in'.
- out := FileDirectory default forceNewFileNamed: fn.
- out nextPutAll: 231 asCharacter asString, 'a<b<<c'.
- out close.
 
+ FileDirectory default readOnlyFileNamed: fileName do: [ :in |
+ self assert: in next = 231 asCharacter.
+ self assert: (in upToAll: '<<') = 'a<b'.
+ self assert: in next = $c ]!
- in := FileDirectory default readOnlyFileNamed: fn.
- self assert: in next = 231 asCharacter.
- self assert: (in upToAll: '<<') = 'a<b'.
- self assert: in next = $c.!

Item was changed:
  ----- Method: MultiByteFileStreamTest>>testUpToAllUtf (in category 'testing') -----
  testUpToAllUtf
  "This test case is adapted from Mantis #4665."
  "MultiByteFileStream was relying on PositionableStream>>#match: to discover the position immediately following the delimiter collection. It would then use #next: to retrieve a number of *characters* computed as the difference in stream positions. However, stream positions are measured in *bytes*, not characters, so this would lead to misalignment when the skipped text included UTF-8 encoded characters."
 
+ | resultA resultB |
+ fileName :='testUpToAll.in'.
+ FileDirectory default forceNewFileNamed: fileName do: [ :out |
+ out nextPutAll: 231 asCharacter asString, '<'. "Encodes to byte sequence C3A73C" ].
- | in out fn resultA resultB |
- fn :='testUpToAll.in'.
- out := FileDirectory default forceNewFileNamed: fn.
- out nextPutAll: 231 asCharacter asString, '<'. "Encodes to byte sequence C3A73C"
- out close.
 
+ resultA := FileDirectory default readOnlyFileNamed: fileName do: [ :in |
+ in upToAll: '<' ].
- in := FileDirectory default readOnlyFileNamed: fn.
- resultA := in upToAll: '<'.
- in close.
 
+ resultB := FileDirectory default readOnlyFileNamed: fileName do: [ :in |
+ in upTo: $< ].
- in := FileDirectory default readOnlyFileNamed: fn.
- resultB := in upTo: $<.
- in close.
 
  self assert: resultA = resultB
  !

Item was changed:
  ----- Method: MultiByteFileStreamTest>>testUpToAllZeroLength (in category 'testing') -----
  testUpToAllZeroLength
  "Ensures that upToAll: behaves correctly with a zero-length separator."
+
+ fileName :='testUpToAll.in'.
+ FileDirectory default forceNewFileNamed: fileName do: [ :out |
+ out nextPutAll: 231 asCharacter asString, 'a<b<<c' ].
- | in out fn |
- fn :='testUpToAll.in'.
- out := FileDirectory default forceNewFileNamed: fn.
- out nextPutAll: 231 asCharacter asString, 'a<b<<c'.
- out close.
 
+ FileDirectory default readOnlyFileNamed: fileName do: [ :in |
+ self assert: in next = 231 asCharacter.
+ self assert: (in upToAll: '') = ''.
+ self assert: in next = $a ]!
- in := FileDirectory default readOnlyFileNamed: fn.
- self assert: in next = 231 asCharacter.
- self assert: (in upToAll: '') = ''.
- self assert: in next = $a.!