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

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

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

Name: MultilingualTests-ul.8
Author: ul
Time: 14 February 2010, 1:29:59.813 pm
UUID: ab7af94e-e564-4749-8651-410343614bd4
Ancestors: MultilingualTests-nice.7

- make sure we don't leave files on the disk
- use #xxxFileNamed:do: when possible
- use #lf and #crlf with streams

=============== Diff against MultilingualTests-nice.7 ===============

Item was changed:
  ----- Method: MultiByteFileStreamTest>>testLineEnding (in category 'testing') -----
  testLineEnding
-
- | foo fileName |
-
- fileName := 'foolinend.txt'.
-
- foo := MultiByteFileStream forceNewFileNamed: fileName.
- [foo wantsLineEndConversion: false.
- foo nextPutAll: 'line 1'; cr; nextPutAll: 'line 2'; nextPutAll: String crlf; nextPutAll: 'line 3'; nextPut: Character lf; nextPutAll: 'line 4'] ensure: [foo close].
 
+ fileName := 'foolinend.txt'.
+ MultiByteFileStream forceNewFileNamed: fileName do: [ :file |
+ file
+ wantsLineEndConversion: false;
+ nextPutAll: 'line 1'; cr;
+ nextPutAll: 'line 2'; crlf;
+ nextPutAll: 'line 3'; lf;
+ nextPutAll: 'line 4' ].
  {
  {#cr.  'line 1' , String cr , 'line 2' , String cr , 'line 3' , String cr , 'line 4'}.
  {#lf.  'line 1' , String cr , 'line 2' , String cr , 'line 3' , String cr , 'line 4'}.
  {#crlf.  'line 1' , String cr , 'line 2' , String cr , 'line 3' , String cr , 'line 4'}.
  {nil.  'line 1' , String cr , 'line 2' , String crlf , 'line 3' , String lf , 'line 4'}
  } do: [:lineEndingResult |
+ MultiByteFileStream oldFileNamed: fileName do: [ :file |
+ file lineEndConvention: lineEndingResult first.
+ self assert: file upToEnd = lineEndingResult last ] ]!
- foo := MultiByteFileStream oldFileNamed: fileName.
- [foo lineEndConvention: lineEndingResult first.
- self assert: (foo upToEnd) = lineEndingResult last] ensure: [foo close]].
-
- FileDirectory default deleteFileNamed: fileName!

Item was changed:
  TestCase subclass: #MultiByteFileStreamTest
+ instanceVariableNames: 'fileName'
- instanceVariableNames: ''
  classVariableNames: ''
  poolDictionaries: ''
  category: 'MultilingualTests-TextConversion'!

Item was added:
+ ----- Method: MultiByteFileStreamTest>>tearDown (in category 'as yet unclassified') -----
+ tearDown
+
+ fileName ifNotNil: [
+ FileDirectory default deleteFileNamed: fileName ]!

Item was changed:
  ----- Method: MultiByteFileStreamTest>>testBinaryUpTo (in category 'testing') -----
  testBinaryUpTo
  "This is a non regression test for bug http://bugs.squeak.org/view.php?id=6933"
 
- | foo fileName |
-
  fileName := 'foobug6933'.
+ MultiByteFileStream forceNewFileNamed: fileName do: [ :file |
+ file
+ binary;
+ nextPutAll: #[ 1 2 3 4 ] ].
+ MultiByteFileStream oldFileNamed: fileName do: [ :file |
+ file binary.
+ self assert: (file upTo: 3) = #[ 1 2 ] ]!
-
- foo := MultiByteFileStream forceNewFileNamed: fileName.
- [foo binary.
- foo nextPutAll: #[ 1 2 3 4 ]] ensure: [foo close].
-
- foo := MultiByteFileStream oldFileNamed: fileName.
- [foo binary.
- self assert: (foo upTo: 3) = #[ 1 2 ]] ensure: [foo close].
-
- FileDirectory default deleteFileNamed: fileName!

Item was changed:
  ----- Method: MultiByteFileStreamTest>>testAsciiBackChunk (in category 'testing') -----
  testAsciiBackChunk
 
- | foo fileName |
-
  fileName := 'foobackchunk.txt'.
+ MultiByteFileStream forceNewFileNamed: fileName do: [ :file |
+ file
+ lineEndConvention: #cr;
+ converter: UTF8TextConverter new;
+ cr; nextChunkPut: 'test1' printString;
+ cr; nextChunkPut: 'test2' printString.
+ self
+ assert: file backChunk = (String cr , 'test2' printString);
+ assert: file backChunk = (String cr , 'test1' printString) ]!
-
- foo := MultiByteFileStream forceNewFileNamed: fileName.
- [foo lineEndConvention: #cr; converter: UTF8TextConverter new.
- foo cr; nextChunkPut: 'test1' printString.
- foo cr; nextChunkPut: 'test2' printString.
- self assert: foo backChunk = (String cr , 'test2' printString).
- self assert: foo backChunk = (String cr , 'test1' printString).] ensure: [foo close].
-
- FileDirectory default deleteFileNamed: fileName!

Item was changed:
  ----- Method: MultiByteFileStreamTest>>testNextLine (in category 'testing') -----
  testNextLine
-
- | foo fileName |
-
- fileName := 'foolinend.txt'.
-
- foo := MultiByteFileStream forceNewFileNamed: fileName.
- [foo wantsLineEndConversion: false.
- foo nextPutAll: 'line 1'; cr; nextPutAll: 'line 2'; nextPutAll: String crlf; nextPutAll: 'line 3'; nextPut: Character lf; nextPutAll: 'line 4'] ensure: [foo close].
 
+ fileName := 'foobackchunk.txt'.
+ MultiByteFileStream forceNewFileNamed: fileName do: [ :file |
+ file
+ wantsLineEndConversion: false;
+ nextPutAll: 'line 1'; cr;
+ nextPutAll: 'line 2'; crlf;
+ nextPutAll: 'line 3'; lf;
+ nextPutAll: 'line 4' ].
  #(cr lf crlf nil) do: [:lineEnding |
+ MultiByteFileStream oldFileNamed: fileName do: [ :file |
+ file lineEndConvention: lineEnding.
+ self
+ assert: file nextLine = 'line 1';
+ assert: file nextLine = 'line 2';
+ assert: file nextLine = 'line 3';
+ assert: file nextLine = 'line 4';
+ assert: file nextLine = nil ] ]!
- foo := MultiByteFileStream oldFileNamed: fileName.
- [foo lineEndConvention: lineEnding.
- self assert: (foo nextLine) = ('line 1').
- self assert: (foo nextLine) = ('line 2').
- self assert: (foo nextLine) = ('line 3').
- self assert: (foo nextLine) = ('line 4').
- self assert: (foo nextLine) = nil] ensure: [foo close]].
-
- FileDirectory default deleteFileNamed: fileName!

Item was changed:
  ----- Method: MultiByteFileStreamTest>>testNonAsciiBackChunk (in category 'testing') -----
  testNonAsciiBackChunk
  "Note: this is an expected failure: MultiByteFileStream is not equipped to read back non ASCII String... (no comment)
  As a consequence, never use non ASCII in method category nor in your initials. That would make a few tools blind..."
 
+ fileName :=  'foobackchunk.txt'.
+ MultiByteFileStream forceNewFileNamed: fileName do: [ :file |
+ file
+ lineEndConvention: #cr;
+ converter: UTF8TextConverter new;
+ cr; nextChunkPut: 'testé' printString;
+ cr; nextChunkPut: 'test' printString.
+ self assert: file backChunk = (String cr , 'test' printString).
+ self assert: file backChunk = (String cr , 'testé' printString) ]!
- | foo fileName |
-
- fileName := 'foobackchunk.txt'.
-
- foo := MultiByteFileStream forceNewFileNamed: fileName.
- [foo lineEndConvention: #cr; converter: UTF8TextConverter new.
- foo cr; nextChunkPut: 'testé' printString.
- foo cr; nextChunkPut: 'test' printString.
- self assert: foo backChunk = (String cr , 'test' printString).
- self assert: foo backChunk = (String cr , 'testé' printString).] ensure: [foo close].
-
- FileDirectory default deleteFileNamed: fileName!