[squeak-dev] The Trunk: CollectionsTests-ul.180.mcz
commits at source.squeak.org
commits at source.squeak.org
Thu Feb 10 21:55:56 UTC 2011
Levente Uzonyi uploaded a new version of CollectionsTests to project The Trunk:
http://source.squeak.org/trunk/CollectionsTests-ul.180.mcz
==================== Summary ====================
Name: CollectionsTests-ul.180
Author: ul
Time: 10 February 2011, 10:55:05.91 pm
UUID: 67f43872-7dfe-5b4c-bcac-e9a1727254b0
Ancestors: CollectionsTests-ul.179
- unified the categorization of StringTest's methods
- added a test for #expandMacrosWithArguments:
=============== Diff against CollectionsTests-ul.179 ===============
Item was changed:
+ ----- Method: StringTest>>testComparing (in category 'tests - comparing') -----
- ----- Method: StringTest>>testComparing (in category 'test-comparing') -----
testComparing
self assert: 'foo' < 'foo:'.
self assert: 'foo' < 'fooBar'.
self assert: 'foo' <= 'foo:'.
self assert: 'foo' <= 'fooBar'.
self assert: 'foo:' > 'foo'.
self assert: 'fooBar' > 'foo'.
self assert: 'foo:' >= 'foo'.
self assert: 'fooBar' >= 'foo'!
Item was changed:
+ ----- Method: StringTest>>testEncodeForHTTP (in category 'tests - converting') -----
- ----- Method: StringTest>>testEncodeForHTTP (in category 'testing - converting') -----
testEncodeForHTTP
self assert: 'aa aa éé aa aa' encodeForHTTP = 'aa%20aa%20%C3%A9%C3%A9%20aa%20aa'!
Item was changed:
+ ----- Method: StringTest>>testEquality (in category 'tests - comparing') -----
- ----- Method: StringTest>>testEquality (in category 'as yet unclassified') -----
testEquality
self assert: 'abc' = 'abc' asWideString.
self assert: 'abc' asWideString = 'abc'.
self assert: (#[ 97 0 0 0 ] asString ~= 'a000' asWideString).
self assert: ('a000' asWideString ~= #[ 97 0 0 0 ] asString).
self assert: ('abc' sameAs: 'aBc' asWideString).
self assert: ('aBc' asWideString sameAs: 'abc').
self assert: (#[ 97 0 0 0 ] asString
sameAs: 'Abcd' asWideString) not.
self assert: ('a000' asWideString sameAs:
#[ 97 0 0 0 ] asString) not.!
Item was added:
+ ----- Method: StringTest>>testExpandMacrosWithArguments (in category 'tests - formatting') -----
+ testExpandMacrosWithArguments
+
+ | patterns |
+ patterns := {
+ "Input - Expected output"
+ #('' '').
+ #('foo' 'foo').
+ { '<N>'. String cr }.
+ { '<T>'. String tab }.
+ { '<n>'. String cr }.
+ { '<t>'. String tab }.
+ #('%>' '>').
+ #('%<' '<').
+ #('%%' '%').
+ #('%a' 'a').
+ #('%A' 'A').
+ #('<1S>' 'foo').
+ #('<1s>' 'foo').
+ #('<10S>' '10').
+ #('<10s>' '10').
+ #('<2P>' '1').
+ #('<3p>' 'true').
+ #('<10P>' '''10''').
+ #('<11p>' '11').
+ #('<3?ab:cde>' 'ab').
+ #('<4?ab:cde>' 'cde') }.
+ "Test all possible 3 long sequences of the above patterns. Since the patterns include
+ the empty string, all 1 and 2 long sequences will be tested too."
+ patterns do: [ :first |
+ patterns do: [ :second |
+ patterns do: [ :third |
+ | result |
+ result := first first, second first, third first expandMacrosWithArguments: #('foo' 1 true false 5 6 7 8 9 '10' 11).
+ self assert: first second, second second, third second equals: result ] ] ].
+ "Test some malformed inputs too."
+ #('%' '<' '<N' '<T' '<1T' '<>' '<N><' '<1st' '<A' '<1Phello>' '<1?abcd>' '<?a:b>') do: [ :each |
+ self should: [ each expandMacrosWithArguments: #() ] raise: Error ]!
Item was changed:
+ ----- Method: StringTest>>testFindLastOccurenceOfStringStartingAt (in category 'tests - accessing') -----
- ----- Method: StringTest>>testFindLastOccurenceOfStringStartingAt (in category 'testing') -----
testFindLastOccurenceOfStringStartingAt
self assert: ('Smalltalk' findLastOccurrenceOfString: 'al' startingAt: 2) = 7.
self assert: ('aaa' findLastOccurrenceOfString: 'aa' startingAt: 1) = 2.
self assert: ('Smalltalk' asWideString findLastOccurrenceOfString: 'al' startingAt: 2) = 7.
self assert: ('Smalltalk' asWideString findLastOccurrenceOfString: 'al' asWideString startingAt: 2) = 7.
self assert: (('Smalltalk' copyWith: 835 asCharacter) findLastOccurrenceOfString: 'al' asWideString startingAt: 2) = 7.!
Item was changed:
+ ----- Method: StringTest>>testFindTokensEscapedBy01 (in category 'tests - tokenizing') -----
- ----- Method: StringTest>>testFindTokensEscapedBy01 (in category 'testing - tokenizing') -----
testFindTokensEscapedBy01
| tokens |
string := 'this, is, "a, test"'.
tokens := string findTokens: ',' escapedBy: '"'.
self assert: tokens size = 3!
Item was changed:
+ ----- Method: StringTest>>testFindTokensEscapedBy02 (in category 'tests - tokenizing') -----
- ----- Method: StringTest>>testFindTokensEscapedBy02 (in category 'testing - tokenizing') -----
testFindTokensEscapedBy02
| tokens |
string := ''.
tokens := string findTokens: ',' escapedBy: '"'.
self assert: tokens isEmpty!
Item was changed:
+ ----- Method: StringTest>>testFindTokensEscapedBy03 (in category 'tests - tokenizing') -----
- ----- Method: StringTest>>testFindTokensEscapedBy03 (in category 'testing - tokenizing') -----
testFindTokensEscapedBy03
| tokens |
string := 'this, is, a, test'.
tokens := string findTokens: ',' escapedBy: '"'.
self assert: tokens size = 4!
Item was changed:
+ ----- Method: StringTest>>testFindTokensEscapedBy04 (in category 'tests - tokenizing') -----
- ----- Method: StringTest>>testFindTokensEscapedBy04 (in category 'testing - tokenizing') -----
testFindTokensEscapedBy04
| tokens |
string := 'this, is, a"," test'.
tokens := string findTokens: ',' escapedBy: '"'.
self assert: tokens size = 3.
self assert: tokens third = ' a, test'!
Item was changed:
+ ----- Method: StringTest>>testFindTokensEscapedBy05 (in category 'tests - tokenizing') -----
- ----- Method: StringTest>>testFindTokensEscapedBy05 (in category 'testing - tokenizing') -----
testFindTokensEscapedBy05
| tokens |
string := 'this, /is, a"," test/'.
tokens := string findTokens: ',#' escapedBy: '"/'.
self assert: tokens size = 2.
self assert: tokens first = 'this'.
self assert: tokens second = ' is, a"," test'.!
Item was changed:
+ ----- Method: StringTest>>testFindTokensEscapedBy06 (in category 'tests - tokenizing') -----
- ----- Method: StringTest>>testFindTokensEscapedBy06 (in category 'testing - tokenizing') -----
testFindTokensEscapedBy06
| tokens |
string := 'this, is, "a, test'.
tokens := string findTokens: ',' escapedBy: '"'.
self assert: tokens size = 3.
self assert: tokens third = ' a, test'!
Item was changed:
+ ----- Method: StringTest>>testFindTokensEscapedBy07 (in category 'tests - tokenizing') -----
- ----- Method: StringTest>>testFindTokensEscapedBy07 (in category 'testing - tokenizing') -----
testFindTokensEscapedBy07
| tokens |
string := 'a:b::c'.
tokens := string findTokens: ':' escapedBy: '"'.
self assert: tokens size = 4.
self assert: tokens first = 'a'.
self assert: tokens second = 'b'.
self assert: tokens third = ''.
self assert: tokens fourth = 'c'!
Item was changed:
+ ----- Method: StringTest>>testFindTokensEscapedBy08 (in category 'tests - tokenizing') -----
- ----- Method: StringTest>>testFindTokensEscapedBy08 (in category 'testing - tokenizing') -----
testFindTokensEscapedBy08
| tokens |
string := 'this, is, ##a, test'.
tokens := string findTokens: ',' escapedBy: '#'.
self assert: tokens size = 4.
self assert: tokens third = ' a'.
self assert: tokens fourth = ' test'!
Item was changed:
+ ----- Method: StringTest>>testFindTokensEscapedBy09 (in category 'tests - tokenizing') -----
- ----- Method: StringTest>>testFindTokensEscapedBy09 (in category 'testing - tokenizing') -----
testFindTokensEscapedBy09
| tokens |
string := 'this, is, ###a, test#'.
tokens := string findTokens: ',' escapedBy: '#'.
self assert: tokens size = 3.
self assert: tokens third = ' #a, test'!
Item was changed:
+ ----- Method: StringTest>>testFindTokensEscapedBy10 (in category 'tests - tokenizing') -----
- ----- Method: StringTest>>testFindTokensEscapedBy10 (in category 'testing - tokenizing') -----
testFindTokensEscapedBy10
| tokens |
string := 'this, is, ###a, test'.
tokens := string findTokens: ',' escapedBy: '#'.
self assert: tokens size = 3.
self assert: tokens third = ' #a, test'!
Item was changed:
+ ----- Method: StringTest>>testFindTokensEscapedBy11 (in category 'tests - tokenizing') -----
- ----- Method: StringTest>>testFindTokensEscapedBy11 (in category 'testing - tokenizing') -----
testFindTokensEscapedBy11
| tokens |
string := 'this, is, """a, test"'.
tokens := string findTokens: ',' escapedBy: '"'.
self assert: tokens size = 3.
self assert: tokens third = ' "a, test'!
Item was changed:
+ ----- Method: StringTest>>testFindTokensEscapedBy12 (in category 'tests - tokenizing') -----
- ----- Method: StringTest>>testFindTokensEscapedBy12 (in category 'testing - tokenizing') -----
testFindTokensEscapedBy12
| tokens |
string := 'one, two# three; four. five'.
tokens := string findTokens: ',#;.' escapedBy: '"'.
self assert: tokens size = 5.
self assert: tokens third = ' three'!
Item was changed:
+ ----- Method: StringTest>>testFindTokensEscapedBy13 (in category 'tests - tokenizing') -----
- ----- Method: StringTest>>testFindTokensEscapedBy13 (in category 'testing - tokenizing') -----
testFindTokensEscapedBy13
| tokens |
string := 'one, two# three; four. five'.
tokens := string findTokens: ',#;.' escapedBy: nil.
self assert: tokens size = 5.
self assert: tokens third = ' three'!
Item was changed:
+ ----- Method: StringTest>>testFindTokensEscapedBy14 (in category 'tests - tokenizing') -----
- ----- Method: StringTest>>testFindTokensEscapedBy14 (in category 'testing - tokenizing') -----
testFindTokensEscapedBy14
| tokens |
string := 'one, "two# three"; &four. five&'.
tokens := string findTokens: ',#;.' escapedBy: '"&'.
self assert: tokens size = 3.
self assert: tokens second = ' two# three'.
self assert: tokens third = ' four. five'!
Item was changed:
+ ----- Method: StringTest>>testFindTokensEscapedBy15 (in category 'tests - tokenizing') -----
- ----- Method: StringTest>>testFindTokensEscapedBy15 (in category 'testing - tokenizing') -----
testFindTokensEscapedBy15
| tokens |
string := 'one, "two# three"; &four. five&'.
tokens := string findTokens: nil escapedBy: '"&'.
self assert: tokens size = 1.
self assert: tokens first = 'one, two# three; four. five'!
Item was changed:
+ ----- Method: StringTest>>testFindTokensEscapedBy16 (in category 'tests - tokenizing') -----
- ----- Method: StringTest>>testFindTokensEscapedBy16 (in category 'testing - tokenizing') -----
testFindTokensEscapedBy16
| tokens |
string := 'one, "two# three"; &four. five&'.
tokens := string findTokens: nil escapedBy: nil.
self assert: tokens size = 1.
self assert: tokens first = string!
Item was changed:
+ ----- Method: StringTest>>testFindTokensEscapedBy21 (in category 'tests - tokenizing') -----
- ----- Method: StringTest>>testFindTokensEscapedBy21 (in category 'testing - tokenizing') -----
testFindTokensEscapedBy21
| tokens |
string := 'this, is, "a, test"'.
tokens := string findTokens: $, escapedBy: $".
self assert: tokens size = 3!
Item was changed:
+ ----- Method: StringTest>>testFindTokensEscapedBy22 (in category 'tests - tokenizing') -----
- ----- Method: StringTest>>testFindTokensEscapedBy22 (in category 'testing - tokenizing') -----
testFindTokensEscapedBy22
| tokens |
string := ''.
tokens := string findTokens: $, escapedBy: $".
self assert: tokens size = 0!
Item was changed:
+ ----- Method: StringTest>>testFindTokensEscapedBy23 (in category 'tests - tokenizing') -----
- ----- Method: StringTest>>testFindTokensEscapedBy23 (in category 'testing - tokenizing') -----
testFindTokensEscapedBy23
| tokens |
string := 'this, is, a, test'.
tokens := string findTokens: $, escapedBy: $".
self assert: tokens size = 4!
Item was changed:
+ ----- Method: StringTest>>testFindTokensEscapedBy24 (in category 'tests - tokenizing') -----
- ----- Method: StringTest>>testFindTokensEscapedBy24 (in category 'testing - tokenizing') -----
testFindTokensEscapedBy24
| tokens |
string := 'this, is, a"," test'.
tokens := string findTokens: $, escapedBy: $".
self assert: tokens size = 3.
self assert: tokens third = ' a, test'!
Item was changed:
+ ----- Method: StringTest>>testFindTokensEscapedBy25 (in category 'tests - tokenizing') -----
- ----- Method: StringTest>>testFindTokensEscapedBy25 (in category 'testing - tokenizing') -----
testFindTokensEscapedBy25
| tokens |
string := 'this, /is, a"," test/'.
tokens := string findTokens: $, escapedBy: $/.
self assert: tokens size = 2.
self assert: tokens first = 'this'.
self assert: tokens second = ' is, a"," test'.!
Item was changed:
+ ----- Method: StringTest>>testFindTokensEscapedBy26 (in category 'tests - tokenizing') -----
- ----- Method: StringTest>>testFindTokensEscapedBy26 (in category 'testing - tokenizing') -----
testFindTokensEscapedBy26
| tokens |
string := 'this, is, "a, test'.
tokens := string findTokens: $, escapedBy: $".
self assert: tokens size = 3.
self assert: tokens third = ' a, test'!
Item was changed:
+ ----- Method: StringTest>>testFormat (in category 'tests - formatting') -----
- ----- Method: StringTest>>testFormat (in category 'testing - formatting') -----
testFormat
{
[ '\{ \} \\ foo {1} bar {2}' format: { 12. 'string' } ] -> '{ } \ foo 12 bar string'.
[ '\{ \} \\ foo {2} bar {1}' format: { 'string'. 12 } ] -> '{ } \ foo 12 bar string'.
[ '\{1}' format: {} ] -> '{1}'.
[ '\{1}{1}' format: { $a } ] -> '{1}a'.
} do: [ :each |
self assert: each key value = each value ]!
Item was changed:
+ ----- Method: StringTest>>testLineCorrespondingToIndex (in category 'tests - lines') -----
- ----- Method: StringTest>>testLineCorrespondingToIndex (in category 'testing - lines') -----
testLineCorrespondingToIndex
| sampleCRString sampleLFString sampleCRLFString anIndex |
sampleCRString := 'Fred', String cr , 'the' , String cr , 'Bear'.
sampleLFString := 'Fred', String lf , 'the' , String lf , 'Bear'.
sampleCRLFString := 'Fred', String crlf , 'the' , String crlf , 'Bear'.
anIndex := sampleCRString indexOf: $h.
self assert: (sampleCRString lineCorrespondingToIndex: anIndex) = 'the'.
anIndex := sampleLFString indexOf: $h.
self assert: (sampleLFString lineCorrespondingToIndex: anIndex) = 'the'.
anIndex := sampleCRLFString indexOf: $h.
self assert: (sampleCRLFString lineCorrespondingToIndex: anIndex) = 'the'.
anIndex := sampleCRString indexOf: $B.
self assert: (sampleCRString lineCorrespondingToIndex: anIndex) = 'Bear'.
anIndex := sampleLFString indexOf: $B.
self assert: (sampleLFString lineCorrespondingToIndex: anIndex) = 'Bear'.
anIndex := sampleCRLFString indexOf: $B.
self assert: (sampleCRLFString lineCorrespondingToIndex: anIndex) = 'Bear'.
anIndex := sampleCRString indexOf: $d.
self assert: (sampleCRString lineCorrespondingToIndex: anIndex) = 'Fred'.
anIndex := sampleLFString indexOf: $d.
self assert: (sampleLFString lineCorrespondingToIndex: anIndex) = 'Fred'.
anIndex := sampleCRLFString indexOf: $d.
self assert: (sampleCRLFString lineCorrespondingToIndex: anIndex) = 'Fred'.!
Item was changed:
+ ----- Method: StringTest>>testLineCount (in category 'tests - lines') -----
- ----- Method: StringTest>>testLineCount (in category 'testing - lines') -----
testLineCount
| sampleCRString sampleLFString sampleCRLFString |
sampleCRString := 'Fred', String cr , 'the' , String cr , 'Bear'.
sampleLFString := 'Fred', String lf , 'the' , String lf , 'Bear'.
sampleCRLFString := 'Fred', String crlf , 'the' , String crlf , 'Bear'.
self assert: sampleCRString lineCount = 3.
self assert: sampleLFString lineCount = 3.
self assert: sampleCRLFString lineCount = 3.!
Item was changed:
+ ----- Method: StringTest>>testLineNumber (in category 'tests - lines') -----
- ----- Method: StringTest>>testLineNumber (in category 'testing - lines') -----
testLineNumber
| sampleCRString sampleLFString sampleCRLFString |
sampleCRString := 'Fred', String cr , 'the' , String cr , 'Bear'.
sampleLFString := 'Fred', String lf , 'the' , String lf , 'Bear'.
sampleCRLFString := 'Fred', String crlf , 'the' , String crlf , 'Bear'.
self assert: (sampleCRString lineNumber: 2) = 'the'.
self assert: (sampleLFString lineNumber: 2) = 'the'.
self assert: (sampleCRLFString lineNumber: 2) = 'the'.!
Item was changed:
+ ----- Method: StringTest>>testLinesDo (in category 'tests - lines') -----
- ----- Method: StringTest>>testLinesDo (in category 'testing - lines') -----
testLinesDo
| sampleCRString sampleLFString sampleCRLFString lines |
sampleCRString := 'Fred', String cr , 'the' , String cr , 'Bear'.
sampleLFString := 'Fred', String lf , 'the' , String lf , 'Bear'.
sampleCRLFString := 'Fred', String crlf , 'the' , String crlf , 'Bear'.
lines := OrderedCollection new.
sampleCRString linesDo: [:aLine |
self deny: (aLine includes: Character cr).
self deny: (aLine includes: Character lf).
lines add: aLine].
self assert: lines asArray = #('Fred' 'the' 'Bear').
lines := OrderedCollection new.
sampleLFString linesDo: [:aLine |
self deny: (aLine includes: Character cr).
self deny: (aLine includes: Character lf).
lines add: aLine].
self assert: lines asArray = #('Fred' 'the' 'Bear').
lines := OrderedCollection new.
sampleCRLFString linesDo: [:aLine |
self deny: (aLine includes: Character cr).
self deny: (aLine includes: Character lf).
lines add: aLine].
self assert: lines asArray = #('Fred' 'the' 'Bear').
!
Item was changed:
+ ----- Method: StringTest>>testMatch (in category 'tests - comparing') -----
- ----- Method: StringTest>>testMatch (in category 'test-comparing') -----
testMatch
#('**' 'f**' 'f**o' 'f*' '*f*' 'f#*' 'f##' '*oo' '#oo' '*o*' '#o#' '#o*' '*o#' 'fo*' 'fo#' '*foo*' '###' '*#' 'f*#' 'f*#o')
do: [ :each | self assert: (each match: 'foo') ].
#('bar' 'foo#' '#foo' '*foo#' '#foo*' '*bar*') do: [ :each |
self deny: (each match: 'foo') ]!
Item was changed:
+ ----- Method: StringTest>>testPercentEncodingJa (in category 'tests - converting') -----
- ----- Method: StringTest>>testPercentEncodingJa (in category 'testing - converting') -----
testPercentEncodingJa
| leading hiraA hiraO hiraAO encodedHiraA encodedHiraO encodedHiraAO |
"Make Japanese String from unicode. see http://www.unicode.org/charts/PDF/U3040.pdf"
leading := JapaneseEnvironment leadingChar.
hiraA := (Character leadingChar: leading code: 16r3042) asString. "HIRAGANA LETTER A"
hiraO := (Character leadingChar: leading code: 16r304A) asString. "HIRAGANA LETTER O"
hiraAO := hiraA, hiraO.
"Percent Encoded Japanese String"
encodedHiraA := hiraA encodeForHTTP.
self assert: encodedHiraA = '%E3%81%82'.
encodedHiraO := hiraO encodeForHTTP.
self assert: encodedHiraO = '%E3%81%8A'.
encodedHiraAO := hiraAO encodeForHTTP.
self assert: encodedHiraAO = '%E3%81%82%E3%81%8A'.
"without percent encoded string"
self assert: '' unescapePercents = ''.
self assert: 'abc' unescapePercents = 'abc'. "latin1 character"
self assert: hiraAO unescapePercents = hiraAO. "multibyte character"
"encoded latin1 string"
self assert: '%61' unescapePercents = 'a'.
self assert: '%61%62%63' unescapePercents = 'abc'.
"encoded multibyte string"
Locale currentPlatform: (Locale isoLanguage: 'ja') during: [
self assert: encodedHiraA unescapePercents = hiraA.
self assert: encodedHiraAO unescapePercents = hiraAO].
"mixed string"
Locale currentPlatform: (Locale isoLanguage: 'ja') during: [
self assert: (encodedHiraAO,'a') unescapePercents = (hiraAO, 'a').
self assert: ('a', encodedHiraA) unescapePercents = ('a', hiraA).
self assert: ('a', encodedHiraA, 'b') unescapePercents = ('a', hiraA, 'b').
self assert: ('a', encodedHiraA, 'b', encodedHiraO) unescapePercents = ('a', hiraA, 'b', hiraO).
self assert: (encodedHiraA, encodedHiraO, 'b', encodedHiraA) unescapePercents = (hiraA, hiraO, 'b', hiraA)].
"for Seaside"
Locale currentPlatform: (Locale isoLanguage: 'ja') during: [
self assert: (encodedHiraA, '+', encodedHiraO) unescapePercents = (hiraA, ' ', hiraO)].
!
Item was changed:
+ ----- Method: StringTest>>testSpace (in category 'tests - instance creation') -----
- ----- Method: StringTest>>testSpace (in category 'testing - instance creation') -----
testSpace
"self debug: #testSpace"
string := String new.
self assert: string size = 0. "instead of #isEmpty to be consistent with the following test"
string := String space.
self assert: string size = 1.
self assert: string = ' '!
Item was changed:
+ ----- Method: StringTest>>testWithBlanksTrimmed (in category 'tests - converting') -----
- ----- Method: StringTest>>testWithBlanksTrimmed (in category 'testing - converting') -----
testWithBlanksTrimmed
| s |
self assert: ' abc d ' withBlanksTrimmed = 'abc d'.
self assert: 'abc d ' withBlanksTrimmed = 'abc d'.
self assert: ' abc d' withBlanksTrimmed = 'abc d'.
self assert: (((0 to: 255) collect: [ :each | each asCharacter ] thenSelect: [ :each | each isSeparator ]) as: String) withBlanksTrimmed = ''.
s := 'abcd'.
self assert: s withBlanksTrimmed = s.
self assert: s withBlanksTrimmed ~~ s.!
Item was changed:
+ ----- Method: StringTest>>testWithInternetLineEndings (in category 'tests - internet') -----
- ----- Method: StringTest>>testWithInternetLineEndings (in category 'testing - internet') -----
testWithInternetLineEndings
{
'abc' -> 'abc'.
'abc', String cr -> ('abc', String crlf).
'abc', String lf -> ('abc', String crlf).
'abc', String crlf -> ('abc', String crlf).
String cr, 'abc' -> (String crlf, 'abc').
String lf, 'abc' -> (String crlf, 'abc').
String crlf, 'abc' -> (String crlf, 'abc').
'abc', String cr, String cr, 'abc' -> ('abc', String crlf, String crlf, 'abc').
'abc', String lf, String lf, 'abc' -> ('abc', String crlf, String crlf, 'abc').
'abc', String crlf, String crlf, 'abc' -> ('abc', String crlf, String crlf, 'abc').
String cr, 'abc', String cr, String crlf, 'abc', String lf -> (String crlf, 'abc', String crlf, String crlf, 'abc', String crlf).
String lf, 'abc', String lf, String crlf, 'abc', String cr -> (String crlf, 'abc', String crlf, String crlf, 'abc', String crlf).
} do: [ :each |
self assert: each key withInternetLineEndings = each value ]!
Item was changed:
+ ----- Method: StringTest>>testWithSqueakLineEndings (in category 'tests - internet') -----
- ----- Method: StringTest>>testWithSqueakLineEndings (in category 'testing - internet') -----
testWithSqueakLineEndings
{
'abc' -> 'abc'.
'abc', String cr -> ('abc', String cr).
'abc', String lf -> ('abc', String cr).
'abc', String crlf -> ('abc', String cr).
String cr, 'abc' -> (String cr, 'abc').
String lf, 'abc' -> (String cr, 'abc').
String crlf, 'abc' -> (String cr, 'abc').
'abc', String cr, String cr, 'abc' -> ('abc', String cr, String cr, 'abc').
'abc', String lf, String lf, 'abc' -> ('abc', String cr, String cr, 'abc').
'abc', String crlf, String crlf, 'abc' -> ('abc', String cr, String cr, 'abc').
String cr, 'abc', String cr, String crlf, 'abc', String lf -> (String cr, 'abc', String cr, String cr, 'abc', String cr).
String lf, 'abc', String lf, String crlf, 'abc', String cr -> (String cr, 'abc', String cr, String cr, 'abc', String cr).
} do: [ :each |
self assert: each key withSqueakLineEndings = each value ]!
Item was changed:
+ ----- Method: StringTest>>testWithUnixLineEndings (in category 'tests - internet') -----
- ----- Method: StringTest>>testWithUnixLineEndings (in category 'testing - internet') -----
testWithUnixLineEndings
{
'abc' -> 'abc'.
'abc', String cr -> ('abc', String lf).
'abc', String lf -> ('abc', String lf).
'abc', String crlf -> ('abc', String lf).
String cr, 'abc' -> (String lf, 'abc').
String lf, 'abc' -> (String lf, 'abc').
String crlf, 'abc' -> (String lf, 'abc').
'abc', String cr, String cr, 'abc' -> ('abc', String lf, String lf, 'abc').
'abc', String lf, String lf, 'abc' -> ('abc', String lf, String lf, 'abc').
'abc', String crlf, String crlf, 'abc' -> ('abc', String lf, String lf, 'abc').
String cr, 'abc', String cr, String crlf, 'abc', String lf -> (String lf, 'abc', String lf, String lf, 'abc', String lf).
String lf, 'abc', String lf, String crlf, 'abc', String cr -> (String lf, 'abc', String lf, String lf, 'abc', String lf).
} do: [ :each |
self assert: each key withUnixLineEndings = each value ]!
Item was changed:
+ ----- Method: StringTest>>testWithoutQuoting (in category 'tests - internet') -----
- ----- Method: StringTest>>testWithoutQuoting (in category 'testing - internet') -----
testWithoutQuoting
#(
'"foo"' 'foo'
'''foo''' 'foo'
'"foo''' '"foo'''
'''foo"' '''foo"'
'"foo' '"foo'
'foo"' 'foo"'
'foo' 'foo') pairsDo: [ :before :after |
self assert: before withoutQuoting = after ]!
Item was changed:
+ ----- Method: StringTest>>testWthNoLineLongerThan (in category 'tests - lines') -----
- ----- Method: StringTest>>testWthNoLineLongerThan (in category 'testing - lines') -----
testWthNoLineLongerThan
| phrases |
phrases := {
'Fred the bear went down to the brook to read his book in silence'.
'Fred the bear went down' , String cr , ' to the brook to ' , String cr , 'read his book in silence'.
'Fred the bear went down' , String lf , ' to the brook to ' , String lf , 'read his book in silence'.
'Fred the bear went down' , String crlf , ' to the brook to ' , String crlf , 'read his book in silence'.
}.
#(5 7 9) do: [:length |
phrases do: [:phrase |
| split |
split := phrase withNoLineLongerThan: length.
self
assert: (split copyWithoutAll: CharacterSet separators) = (phrase copyWithoutAll: CharacterSet separators)
description: 'no information should be lost'.
split linesDo: [:line |
self assert: line size <= length description: 'lines should not be longer than prescribed'].
phrase lineCount = 1 ifTrue: [| lastLineSize |
lastLineSize := length.
split linesDo: [:line |
line isEmpty ifFalse: [| firstWordSize |
firstWordSize := line indexOfAnyOf: CharacterSet separators startingAt: 1 ifAbsent: [line size + 1].
self assert: (lastLineSize + firstWordSize) > length description: 'split was too short'.
lastLineSize := line size]]]]]!
More information about the Squeak-dev
mailing list
|