From 6bf4669c8f865eaedc28752247505a9853b47929 Mon Sep 17 00:00:00 2001 From: Torsten Bergmann Date: Tue, 24 Oct 2023 15:51:43 +0200 Subject: [PATCH] Fix over 2000 lint issues in tests --- .../DTDExternalEntityResolverTest.class.st | 55 +- ...DStaticExternalEntityResolverTest.class.st | 29 +- .../SAX2ElementHandlerParserTest.class.st | 43 +- src/XML-Parser-Tests/SAXHandlerTest.class.st | 100 +- src/XML-Parser-Tests/TestCase.extension.st | 44 +- .../XMLAbstractReadStreamTest.class.st | 147 +- .../XMLAbstractSetTest.class.st | 108 +- .../XMLAttributeDeclarationTest.class.st | 114 +- .../XMLAttributeDictionaryTest.class.st | 170 +- .../XMLAttributeListTest.class.st | 481 +++-- .../XMLAttributeSpecTest.class.st | 6 +- .../XMLAttributeTest.class.st | 170 +- .../XMLBasicElementClassMapperTest.class.st | 661 ++++--- src/XML-Parser-Tests/XMLCDataTest.class.st | 18 +- .../XMLCachingNodeListTest.class.st | 19 +- .../XMLClassFinderTest.class.st | 27 +- src/XML-Parser-Tests/XMLCommentTest.class.st | 31 +- .../XMLConfigurationTest.class.st | 191 +- .../XMLDOMConfigurationTest.class.st | 49 +- .../XMLDOMParserTest.class.st | 260 +-- .../XMLDecodingReadStreamAdapterTest.class.st | 10 +- .../XMLDoctypeDeclarationTest.class.st | 99 +- src/XML-Parser-Tests/XMLDocumentTest.class.st | 76 +- .../XMLElementDeclarationTest.class.st | 50 +- src/XML-Parser-Tests/XMLElementTest.class.st | 1275 ++++++------- .../XMLEncodingDetectorTest.class.st | 47 +- .../XMLExceptionTest.class.st | 242 ++- .../XMLExternalEntityTest.class.st | 156 +- .../XMLFileHandleTest.class.st | 10 +- .../XMLGeneralEntityDeclarationTest.class.st | 63 +- .../XMLHTTPMIMETypeTest.class.st | 57 +- .../XMLHTTPMessageTest.class.st | 419 ++--- .../XMLHTTPRequestTest.class.st | 93 +- .../XMLHTTPResponseTest.class.st | 42 +- .../XMLIntegerReaderTest.class.st | 154 +- .../XMLKeyValueCacheTest.class.st | 387 ++-- .../XMLNamespaceScopeTest.class.st | 527 +++--- ...NamespacedAttributeDictionaryTest.class.st | 98 +- .../XMLNestedStreamReaderTest.class.st | 233 +-- .../XMLNodeCanonicalPrintingTest.class.st | 171 +- .../XMLNodeFactoryTest.class.st | 188 +- src/XML-Parser-Tests/XMLNodeListTest.class.st | 118 +- src/XML-Parser-Tests/XMLNodeTest.class.st | 188 +- .../XMLNodeWithChildrenTest.class.st | 549 +++--- .../XMLNodeWithElementsTest.class.st | 1666 +++++++++-------- .../XMLNotationDeclarationTest.class.st | 68 +- .../XMLNullReadStreamTest.class.st | 3 +- .../XMLObservableListTest.class.st | 27 +- .../XMLOrderedListTest.class.st | 1073 ++++++----- src/XML-Parser-Tests/XMLPITest.class.st | 48 +- ...XMLParameterEntityDeclarationTest.class.st | 22 +- .../XMLParserExceptionTest.class.st | 14 +- src/XML-Parser-Tests/XMLParserTest.class.st | 997 +++++----- .../XMLPluggableElementFactoryTest.class.st | 179 +- .../XMLPluggableNodeFactoryTest.class.st | 192 +- .../XMLStreamConverterTest.class.st | 60 +- src/XML-Parser-Tests/XMLStringTest.class.st | 176 +- src/XML-Parser-Tests/XMLURITest.class.st | 285 +-- 58 files changed, 6421 insertions(+), 6364 deletions(-) diff --git a/src/XML-Parser-Tests/DTDExternalEntityResolverTest.class.st b/src/XML-Parser-Tests/DTDExternalEntityResolverTest.class.st index 03df2c34..7b29f733 100644 --- a/src/XML-Parser-Tests/DTDExternalEntityResolverTest.class.st +++ b/src/XML-Parser-Tests/DTDExternalEntityResolverTest.class.st @@ -38,6 +38,7 @@ DTDExternalEntityResolverTest >> resolverClass [ { #category : #tests } DTDExternalEntityResolverTest >> testCopy [ + | resolver copy | (resolver := self newResolver) externalSubsetReadLimit: 1000000; @@ -46,18 +47,23 @@ DTDExternalEntityResolverTest >> testCopy [ resolvesLocalFromNonLocal: true. copy := resolver copy. self - deny: copy == resolver; + deny: copy identicalTo: resolver; assert: copy externalSubsetReadLimit equals: 1000000; assert: copy maxExternalEntities equals: 10; assert: copy maxExternalEntitySize equals: 10000; assert: copy resolvesLocalFromNonLocal. self isTestingLimiting - ifTrue: [ self - assert: copy externalEntityResolver == resolver externalEntityResolver; - assert: copy externalEntityLimits == resolver externalEntityLimits ] - ifFalse: [ self - deny: copy externalEntityLimits == resolver externalEntityLimits ] + ifTrue: [ + self + assert: copy externalEntityResolver + identicalTo: resolver externalEntityResolver; + assert: copy externalEntityLimits + identicalTo: resolver externalEntityLimits ] + ifFalse: [ + self + deny: copy externalEntityLimits + identicalTo: resolver externalEntityLimits ] ] { #category : #tests } @@ -81,54 +87,63 @@ DTDExternalEntityResolverTest >> testDecoratorInterfaceCompatibility [ { #category : #tests } DTDExternalEntityResolverTest >> testExternalEntityLimits [ - | resolver newEntityLimits | + | resolver newEntityLimits | resolver := self newResolver. - self assert: resolver externalEntityLimits class == self entityLimitsClass. + self + assert: resolver externalEntityLimits class + identicalTo: self entityLimitsClass. newEntityLimits := self newEntityLimits. self - assert: (resolver externalEntityLimits: newEntityLimits) == resolver; - assert: resolver externalEntityLimits == newEntityLimits + assert: (resolver externalEntityLimits: newEntityLimits) + identicalTo: resolver; + assert: resolver externalEntityLimits identicalTo: newEntityLimits ] { #category : #tests } DTDExternalEntityResolverTest >> testExternalSubsetReadLimit [ + | resolver | resolver := self newResolver. self assert: resolver externalSubsetReadLimit equals: DTDExternalEntityLimits defaultExternalSubsetReadLimit. self - assert: (resolver externalSubsetReadLimit: 1000000) == resolver; + assert: (resolver externalSubsetReadLimit: 1000000) + identicalTo: resolver; assert: resolver externalSubsetReadLimit equals: 1000000; - assert: (resolver externalSubsetReadLimit: nil) == resolver; + assert: (resolver externalSubsetReadLimit: nil) + identicalTo: resolver; assert: resolver externalSubsetReadLimit isNil ] { #category : #tests } DTDExternalEntityResolverTest >> testMaxExternalEntities [ + | resolver | resolver := self newResolver. self assert: resolver maxExternalEntities > 0; - assert: (resolver maxExternalEntities: 10) == resolver; + assert: (resolver maxExternalEntities: 10) identicalTo: resolver; assert: resolver maxExternalEntities equals: 10; - assert: (resolver maxExternalEntities: nil) == resolver; + assert: (resolver maxExternalEntities: nil) identicalTo: resolver; assert: resolver maxExternalEntities isNil ] { #category : #tests } DTDExternalEntityResolverTest >> testMaxExternalEntitySize [ + | resolver | resolver := self newResolver. self assert: resolver maxExternalEntitySize equals: DTDExternalEntityLimits defaultMaxExternalEntitySize. self - assert: (resolver maxExternalEntitySize: 10000) == resolver; + assert: (resolver maxExternalEntitySize: 10000) + identicalTo: resolver; assert: resolver maxExternalEntitySize equals: 10000; - assert: (resolver maxExternalEntitySize: nil) == resolver; + assert: (resolver maxExternalEntitySize: nil) identicalTo: resolver; assert: resolver maxExternalEntitySize isNil ] @@ -158,14 +173,16 @@ DTDExternalEntityResolverTest >> testRemoveLimits [ { #category : #tests } DTDExternalEntityResolverTest >> testResolvesLocalFromNonLocal [ - | resolver | + | resolver | resolver := self newResolver. self deny: resolver resolvesLocalFromNonLocal; - assert: (resolver resolvesLocalFromNonLocal: false) == resolver; + assert: (resolver resolvesLocalFromNonLocal: false) + identicalTo: resolver; deny: resolver resolvesLocalFromNonLocal; - assert: (resolver resolvesLocalFromNonLocal: true) == resolver; + assert: (resolver resolvesLocalFromNonLocal: true) + identicalTo: resolver; assert: resolver resolvesLocalFromNonLocal ] diff --git a/src/XML-Parser-Tests/DTDStaticExternalEntityResolverTest.class.st b/src/XML-Parser-Tests/DTDStaticExternalEntityResolverTest.class.st index f62ad836..6fc62258 100644 --- a/src/XML-Parser-Tests/DTDStaticExternalEntityResolverTest.class.st +++ b/src/XML-Parser-Tests/DTDStaticExternalEntityResolverTest.class.st @@ -49,39 +49,39 @@ DTDStaticExternalEntityResolverTest >> resolverClass [ { #category : #tests } DTDStaticExternalEntityResolverTest >> testCopy [ + | resolver copy | super testCopy. - self isTestingLimiting - ifTrue: [ ^ self ]. + self isTestingLimiting ifTrue: [ ^ self ]. resolver := self newResolverWithEntities. copy := resolver copy. self - deny: copy == resolver; - deny: copy externalEntities == resolver externalEntities; + deny: copy identicalTo: resolver; + deny: copy externalEntities identicalTo: resolver externalEntities; assert: copy externalEntities equals: resolver externalEntities ] { #category : #tests } DTDStaticExternalEntityResolverTest >> testExternalEntities [ + | resolver replacementAssociation | - self isTestingLimiting - ifTrue: [ ^ self ]. + self isTestingLimiting ifTrue: [ ^ self ]. resolver := self newResolver. self - assert: resolver externalEntities class == Dictionary; + assert: resolver externalEntities class identicalTo: Dictionary; assert: resolver externalEntities isEmpty. resolver externalEntities: self entityAssociations. self assert: resolver externalEntities equals: self entityDictionary. replacementAssociation := 'new.ent' asXMLURI - -> self newEntityReplacement. + -> self newEntityReplacement. resolver externalEntities: (Array with: replacementAssociation). self assert: resolver externalEntities equals: (Dictionary with: replacementAssociation). - resolver := self resolverClass - externalEntities: self entityAssociations. + resolver := self resolverClass externalEntities: + self entityAssociations. self - assert: resolver class == self resolverClass; + assert: resolver class identicalTo: self resolverClass; assert: resolver externalEntities equals: self entityDictionary ] @@ -217,14 +217,13 @@ DTDStaticExternalEntityResolverTest >> testIncludesExternalEntityURI [ { #category : #tests } DTDStaticExternalEntityResolverTest >> testRemoveExternalEntities [ - | resolver | - self isTestingLimiting - ifTrue: [^ self]. + | resolver | + self isTestingLimiting ifTrue: [ ^ self ]. resolver := self newResolverWithEntities. self - assert: resolver removeExternalEntities == resolver; + assert: resolver removeExternalEntities identicalTo: resolver; deny: resolver hasExternalEntities ] diff --git a/src/XML-Parser-Tests/SAX2ElementHandlerParserTest.class.st b/src/XML-Parser-Tests/SAX2ElementHandlerParserTest.class.st index 011322d6..fbb7a096 100644 --- a/src/XML-Parser-Tests/SAX2ElementHandlerParserTest.class.st +++ b/src/XML-Parser-Tests/SAX2ElementHandlerParserTest.class.st @@ -90,33 +90,36 @@ SAX2ElementHandlerParserTest >> testParsingSamplePerson [ | person rootFactory personFactory contactsFactory factoryMapper | rootFactory := SAX2PluggableElementHandlerFactory new - handleElement: 'person' - withClass: SAX2HPersonElementHandler. + handleElement: 'person' + withClass: SAX2HPersonElementHandler. personFactory := SAX2PluggableElementHandlerFactory new - handleElement: 'name' withClass: SAX2HNameElementHandler; - handleElement: 'date-of-birth' - withClass: SAX2HDateOfBirthElementHandler; - handleElement: 'contacts' withClass: SAX2HContactsElementHandler; - handleElement: 'residence' withClass: SAX2HResidenceElementHandler. + handleElement: 'name' + withClass: SAX2HNameElementHandler; + handleElement: 'date-of-birth' + withClass: SAX2HDateOfBirthElementHandler; + handleElement: 'contacts' + withClass: SAX2HContactsElementHandler; + handleElement: 'residence' + withClass: SAX2HResidenceElementHandler. contactsFactory := SAX2PluggableElementHandlerFactory new - handleElement: 'email' - withClass: SAX2HEmailElementHandler. + handleElement: 'email' + withClass: SAX2HEmailElementHandler. factoryMapper := SAX2PluggableElementHandlerFactoryMapper new - mapElementHandlerClass: SAX2HPersonElementHandler - toFactory: personFactory; - mapElementHandlerClass: SAX2HContactsElementHandler - toFactory: contactsFactory. + mapElementHandlerClass: SAX2HPersonElementHandler + toFactory: personFactory; + mapElementHandlerClass: SAX2HContactsElementHandler + toFactory: contactsFactory. person := (SAX2ElementParser on: self samplePersonXML) - elementHandlerFactory: rootFactory; - elementHandlerFactoryMapper: factoryMapper; - parseDocument. + elementHandlerFactory: rootFactory; + elementHandlerFactoryMapper: factoryMapper; + parseDocument. self - assert: person class == SAX2SamplePerson; + assert: person class identicalTo: SAX2SamplePerson; assert: person name equals: 'Tim Bray'; assert: person dateOfBirth - equals: (Date year: 1955 month: 6 day: 21); + equals: (Date year: 1955 month: 6 day: 21); assert: person emailAddresses asArray - equals: #('tbray@textuality.com' 'tbray@tbray.org'); + equals: #( 'tbray@textuality.com' 'tbray@tbray.org' ); assert: person residence - equals: 'Vancouver, British Columbia, Canada' + equals: 'Vancouver, British Columbia, Canada' ] diff --git a/src/XML-Parser-Tests/SAXHandlerTest.class.st b/src/XML-Parser-Tests/SAXHandlerTest.class.st index 1b6f4d6a..20859e6f 100644 --- a/src/XML-Parser-Tests/SAXHandlerTest.class.st +++ b/src/XML-Parser-Tests/SAXHandlerTest.class.st @@ -567,28 +567,29 @@ SAXHandlerTest >> testIsInContent [ { #category : #tests } SAXHandlerTest >> testIsValidating [ - | parser | + | parser | parser := SAXHandler on: self prefixedXMLSource. self assert: parser isValidating; - assert: (parser isValidating: false) == parser; + assert: (parser isValidating: false) identicalTo: parser; deny: parser isValidating; - assert: (parser isValidating: true) == parser; - assert: parser isValidating. + assert: (parser isValidating: true) identicalTo: parser; + assert: parser isValidating ] { #category : #tests } SAXHandlerTest >> testMaxEntityReplacementDepth [ + | parser | parser := SAXHandler on: ''. self assert: parser maxEntityReplacementDepth equals: XMLParserLimits defaultMaxEntityReplacementDepth. self - assert: (parser maxEntityReplacementDepth: 20) == parser; + assert: (parser maxEntityReplacementDepth: 20) identicalTo: parser; assert: parser maxEntityReplacementDepth equals: 20; - assert: (parser maxEntityReplacementDepth: nil) == parser; + assert: (parser maxEntityReplacementDepth: nil) identicalTo: parser; assert: parser maxEntityReplacementDepth isNil ] @@ -601,15 +602,17 @@ SAXHandlerTest >> testNew [ { #category : #tests } SAXHandlerTest >> testOn [ + | parser oldConfiguraiton | parser := SAXHandler on: self prefixedXMLSource documentURI: 'oldURI'. oldConfiguraiton := parser configuration. parser parseDocument. self - assert: (parser on: self generalEntityXMLSource) == parser; + assert: (parser on: self generalEntityXMLSource) + identicalTo: parser; assert: parser input equals: self generalEntityXMLSource; - deny: parser documentURI = 'oldURI'; - deny: parser configuration == oldConfiguraiton + deny: parser documentURI equals: 'oldURI'; + deny: parser configuration identicalTo: oldConfiguraiton ] { #category : #tests } @@ -627,27 +630,27 @@ SAXHandlerTest >> testOptimizeForLargeDocuments [ { #category : #tests } SAXHandlerTest >> testPreservesUndeclaredEntityReferences [ - | parser | + | parser | parser := SAXHandler on: ''. self deny: parser preservesUndeclaredEntityReferences. "enabling should disable validation" self - assert: (parser preservesUndeclaredEntityReferences: true) == parser; + assert: (parser preservesUndeclaredEntityReferences: true) + identicalTo: parser; assert: parser preservesUndeclaredEntityReferences; deny: parser isValidating. - self - assert: (parser isValidating: true) == parser; + assert: (parser isValidating: true) identicalTo: parser; assert: parser isValidating; - deny: parser preservesUndeclaredEntityReferences. + deny: parser preservesUndeclaredEntityReferences ] { #category : #tests } SAXHandlerTest >> testProcessingInstructionData [ - | xml parser | + | xml parser | xml := ' ]> @@ -657,37 +660,26 @@ SAXHandlerTest >> testProcessingInstructionData [ '. - (parser := SAXRecordingHandler on: xml) - parseDocument. - self assert: - (parser wasSentSelectors: - #(startDocument - processingInstruction:data: - startDTD:publicID:systemID: - processingInstruction:data: - endDTD - processingInstruction:data: - startElement:attributes: - characters: - processingInstruction:data: - characters: - endElement: - processingInstruction:data: - endDocument)). + (parser := SAXRecordingHandler on: xml) parseDocument. + self assert: (parser wasSentSelectors: + #( startDocument #processingInstruction:data: + #startDTD:publicID:systemID: #processingInstruction:data: + endDTD #processingInstruction:data: + #startElement:attributes: characters: #processingInstruction:data: + characters: endElement: #processingInstruction:data: + endDocument )). (parser allSentMessagesNamed: #processingInstruction:data:) with: - #(#('before' 'DTD') - #('in' 'DTD') - #('before' 'element') - #('in' 'element') - #('after' 'element')) - do: [:message :arguments | - self assert: message arguments = arguments]. + #( #( 'before' 'DTD' ) #( 'in' 'DTD' ) #( 'before' 'element' ) + #( 'in' 'element' ) #( 'after' 'element' ) ) + do: [ :message :arguments | + self assert: message arguments equals: arguments ] ] { #category : #tests } SAXHandlerTest >> testRemoveLimits [ + | parser readLimit depthLimit | readLimit := 100. depthLimit := 5. @@ -698,55 +690,57 @@ SAXHandlerTest >> testRemoveLimits [ assert: parser documentReadLimit equals: readLimit; assert: parser maxEntityReplacementDepth equals: depthLimit. self - assert: parser removeLimits == parser; + assert: parser removeLimits identicalTo: parser; assert: parser documentReadLimit isNil; assert: parser maxEntityReplacementDepth isNil ] { #category : #tests } SAXHandlerTest >> testReplacesContentEntityReferences [ - | parser | + | parser | parser := SAXHandler on: self prefixedXMLSource. self assert: parser replacesContentEntityReferences; - assert: (parser replacesContentEntityReferences: false) == parser; + assert: (parser replacesContentEntityReferences: false) + identicalTo: parser; deny: parser replacesContentEntityReferences; - assert: (parser replacesContentEntityReferences: true) == parser; - assert: parser replacesContentEntityReferences. + assert: (parser replacesContentEntityReferences: true) + identicalTo: parser; + assert: parser replacesContentEntityReferences ] { #category : #tests } SAXHandlerTest >> testRequiresSchema [ - | parser | + | parser | (parser := SAXHandler on: '') isValidating: false. self deny: parser requiresSchema. "enabling should force validation" self - assert: (parser requiresSchema: true) == parser; + assert: (parser requiresSchema: true) identicalTo: parser; assert: parser requiresSchema; assert: parser isValidating. - self - assert: (parser isValidating: false) == parser; + assert: (parser isValidating: false) identicalTo: parser; deny: parser isValidating; - deny: parser requiresSchema. + deny: parser requiresSchema ] { #category : #tests } SAXHandlerTest >> testResolvesExternalEntities [ - | parser | + | parser | parser := SAXHandler on: self prefixedXMLSource. "should not resolve external entities by default for security" self deny: parser resolvesExternalEntities; - assert: (parser resolvesExternalEntities: true) == parser; + assert: (parser resolvesExternalEntities: true) identicalTo: parser; assert: parser resolvesExternalEntities; - assert: (parser resolvesExternalEntities: false) == parser; - deny: parser resolvesExternalEntities. + assert: (parser resolvesExternalEntities: false) + identicalTo: parser; + deny: parser resolvesExternalEntities ] { #category : #tests } diff --git a/src/XML-Parser-Tests/TestCase.extension.st b/src/XML-Parser-Tests/TestCase.extension.st index eceaabd9..c302edad 100644 --- a/src/XML-Parser-Tests/TestCase.extension.st +++ b/src/XML-Parser-Tests/TestCase.extension.st @@ -2,49 +2,53 @@ Extension { #name : #TestCase } { #category : #'*XML-Parser-Tests' } TestCase >> xmlShould: aBlock enumerate: aCollection [ - | enumerated | + | enumerated | enumerated := OrderedCollection new. - aBlock value: [:each | enumerated add: each]. - self assert: enumerated = aCollection asOrderedCollection + aBlock value: [ :each | enumerated add: each ]. + self assert: enumerated equals: aCollection asOrderedCollection ] { #category : #'*XML-Parser-Tests' } TestCase >> xmlShould: aBlock enumerate: aFirstCollection and: aSecondCollection [ - | firstEnumerated secondEnumerated | + | firstEnumerated secondEnumerated | firstEnumerated := OrderedCollection new. secondEnumerated := OrderedCollection new. - aBlock value: [:first :second | + aBlock value: [ :first :second | firstEnumerated addLast: first. - secondEnumerated addLast: second]. + secondEnumerated addLast: second ]. self - assert: firstEnumerated = aFirstCollection asOrderedCollection; - assert: secondEnumerated = aSecondCollection asOrderedCollection + assert: firstEnumerated + equals: aFirstCollection asOrderedCollection; + assert: secondEnumerated + equals: aSecondCollection asOrderedCollection ] { #category : #'*XML-Parser-Tests' } TestCase >> xmlShould: aBlock unorderedEnumerate: aCollection [ - | enumerated | + | enumerated | enumerated := OrderedCollection new. - aBlock value: [:each | enumerated add: each]. - self assert: enumerated sorted = aCollection asOrderedCollection sorted + aBlock value: [ :each | enumerated add: each ]. + self + assert: enumerated sorted + equals: aCollection asOrderedCollection sorted ] { #category : #'*XML-Parser-Tests' } TestCase >> xmlShould: aBlock unorderedEnumerate: aFirstCollection and: aSecondCollection [ - | firstEnumerated secondEnumerated | + | firstEnumerated secondEnumerated | firstEnumerated := OrderedCollection new. secondEnumerated := OrderedCollection new. - aBlock value: [:first :second | + aBlock value: [ :first :second | firstEnumerated addLast: first. - secondEnumerated addLast: second]. - self assert: - firstEnumerated sorted = - aFirstCollection asOrderedCollection sorted. - self assert: - secondEnumerated sorted = - aSecondCollection asOrderedCollection sorted + secondEnumerated addLast: second ]. + self + assert: firstEnumerated sorted + equals: aFirstCollection asOrderedCollection sorted. + self + assert: secondEnumerated sorted + equals: aSecondCollection asOrderedCollection sorted ] diff --git a/src/XML-Parser-Tests/XMLAbstractReadStreamTest.class.st b/src/XML-Parser-Tests/XMLAbstractReadStreamTest.class.st index 49f5eeda..02beb4af 100644 --- a/src/XML-Parser-Tests/XMLAbstractReadStreamTest.class.st +++ b/src/XML-Parser-Tests/XMLAbstractReadStreamTest.class.st @@ -55,27 +55,26 @@ XMLAbstractReadStreamTest >> testAtEnd [ { #category : #tests } XMLAbstractReadStreamTest >> testClose [ - | stream | + | stream | stream := self newStream. self - assert: stream close == stream; + assert: stream close identicalTo: stream; assert: stream atEnd ] { #category : #tests } XMLAbstractReadStreamTest >> testContents [ - | stream | + | stream | stream := self newStream. - self outputCollection do: [:each | - "use #= because wide chars aren't #== pre-Spur" + self outputCollection do: [ :each | "use #= because wide chars aren't #== pre-Spur" self - assert: stream peek = each; - assert: stream contents = self outputCollection; - assert: stream peek = each; - assert: stream next = each]. - self assert: stream contents = self outputCollection + assert: stream peek equals: each; + assert: stream contents equals: self outputCollection; + assert: stream peek equals: each; + assert: stream next equals: each ]. + self assert: stream contents equals: self outputCollection ] { #category : #tests } @@ -90,10 +89,12 @@ XMLAbstractReadStreamTest >> testIsStream [ { #category : #tests } XMLAbstractReadStreamTest >> testIsXMLBinaryOrExternalStream [ - | stream | + | stream | stream := self newStream. - self assert: stream isXMLBinaryOrExternalStream = stream isBinary + self + assert: stream isXMLBinaryOrExternalStream + equals: stream isBinary ] { #category : #tests } @@ -105,36 +106,34 @@ XMLAbstractReadStreamTest >> testNew [ { #category : #tests } XMLAbstractReadStreamTest >> testNext [ - | stream | + | stream | stream := self newStream. - self outputCollection do: [:each | - "use #= because wide chars aren't #== pre-Spur" - self assert: stream next = each]. + self outputCollection do: [ :each | "use #= because wide chars aren't #== pre-Spur" + self assert: stream next equals: each ]. self assert: stream next isNil. - 0 to: self outputCollection size do: [:i | + 0 to: self outputCollection size do: [ :i | stream := self newStream. - self assert: - (stream next: i) = - (self outputCollection copyFrom: 1 to: i)]. + self + assert: (stream next: i) + equals: (self outputCollection copyFrom: 1 to: i) ]. stream := self newStream. - self assert: - (stream next: self outputCollection size + 1) = - self outputCollection. + self + assert: (stream next: self outputCollection size + 1) + equals: self outputCollection. self assert: (stream next: 1) isEmpty ] { #category : #tests } XMLAbstractReadStreamTest >> testPeek [ - | stream | + | stream | stream := self newStream. - self outputCollection do: [:each | - "use #= because wide chars aren't #== pre-Spur" - self assert: stream peek = each. - stream next]. + self outputCollection do: [ :each | "use #= because wide chars aren't #== pre-Spur" + self assert: stream peek equals: each. + stream next ]. self assert: stream peek isNil ] @@ -157,74 +156,75 @@ XMLAbstractReadStreamTest >> testPeekFor [ { #category : #tests } XMLAbstractReadStreamTest >> testPosition [ - | stream startPosition endPosition position | + | stream startPosition endPosition position | stream := self newStream. startPosition := stream position. "1 or 0 depending on the stream on GS" - endPosition := - stream - upToEnd; - position. + endPosition := stream + upToEnd; + position. stream := self newStream. position := startPosition. - self outputCollection do: [:each | + self outputCollection do: [ :each | self - assert: stream position = position; - "use #= because wide chars aren't #== pre-Spur" - assert: stream peek = each; - assert: stream position = position; - assert: stream next = each; + assert: stream position equals: position; + assert: stream peek equals: each; + assert: stream position equals: position; + assert: stream next equals: each; assert: stream position > position. stream peek. self - assert: (stream position: position) == stream; - assert: stream peek = each; - assert: stream position = position; - assert: stream next = each; + assert: (stream position: position) identicalTo: stream; + assert: stream peek equals: each; + assert: stream position equals: position; + assert: stream next equals: each; assert: stream position > position. - position := stream position]. - self assert: position = endPosition + position := stream position ]. + self assert: position equals: endPosition ] { #category : #tests } XMLAbstractReadStreamTest >> testReset [ - | stream | + | stream | stream := self newStream. self - assert: stream upToEnd = self outputCollection; + assert: stream upToEnd equals: self outputCollection; assert: stream upToEnd isEmpty; - assert: stream reset == stream; - assert: stream upToEnd = self outputCollection; + assert: stream reset identicalTo: stream; + assert: stream upToEnd equals: self outputCollection; assert: stream upToEnd isEmpty ] { #category : #tests } XMLAbstractReadStreamTest >> testSkip [ - | stream | - 0 to: self outputCollection size do: [:i | + | stream | + 0 to: self outputCollection size do: [ :i | stream := self newStream. self - assert: (stream skip: i) == stream; - assert: stream upToEnd = (self outputCollection allButFirst: i)]. + assert: (stream skip: i) identicalTo: stream; + assert: stream upToEnd + equals: (self outputCollection allButFirst: i) ]. stream := self newStream. self - assert: (stream skip: self outputCollection size + 1) == stream; + assert: (stream skip: self outputCollection size + 1) + identicalTo: stream; assert: stream upToEnd isEmpty ] { #category : #tests } XMLAbstractReadStreamTest >> testSkipTo [ - | stream | - self outputCollection do: [:each | + | stream | + self outputCollection do: [ :each | stream := self newStream. self assert: (stream skipTo: each); - assert: stream upToEnd = (self outputCollection copyAfter: each)]. + assert: stream upToEnd + equals: (self outputCollection copyAfter: each) ]. stream := self newStream. self @@ -234,30 +234,35 @@ XMLAbstractReadStreamTest >> testSkipTo [ { #category : #tests } XMLAbstractReadStreamTest >> testUpTo [ - self outputCollection do: [:each | | stream | + + self outputCollection do: [ :each | + | stream | stream := self newStream. - self assert: - (stream upTo: each) = - (self outputCollection copyUpTo: each). - self assert: - stream upToEnd = - (self outputCollection copyAfter: each)]. - self assert: (self newStream upTo: #absent) = self outputCollection + self + assert: (stream upTo: each) + equals: (self outputCollection copyUpTo: each). + self + assert: stream upToEnd + equals: (self outputCollection copyAfter: each) ]. + self + assert: (self newStream upTo: #absent) + equals: self outputCollection ] { #category : #tests } XMLAbstractReadStreamTest >> testUpToEnd [ - | stream | - self outputCollection withIndexDo: [:each :i | + | stream | + self outputCollection withIndexDo: [ :each :i | stream := self newStream. stream skip: i. self - assert: stream upToEnd = (self outputCollection allButFirst: i); - assert: stream upToEnd = '']. + assert: stream upToEnd + equals: (self outputCollection allButFirst: i); + assert: stream upToEnd equals: '' ]. stream := self newStream. self - assert: stream upToEnd = self outputCollection; - assert: stream upToEnd = '' + assert: stream upToEnd equals: self outputCollection; + assert: stream upToEnd equals: '' ] diff --git a/src/XML-Parser-Tests/XMLAbstractSetTest.class.st b/src/XML-Parser-Tests/XMLAbstractSetTest.class.st index 52eae8f6..abd3da9f 100644 --- a/src/XML-Parser-Tests/XMLAbstractSetTest.class.st +++ b/src/XML-Parser-Tests/XMLAbstractSetTest.class.st @@ -24,18 +24,20 @@ XMLAbstractSetTest >> absentSetElement [ { #category : #asserting } XMLAbstractSetTest >> assertSet: aFirstSet equals: aSecondSet [ + self - assert: aFirstSet = aSecondSet; - assert: aSecondSet = aFirstSet + assert: aFirstSet equals: aSecondSet; + assert: aSecondSet equals: aFirstSet ] { #category : #asserting } XMLAbstractSetTest >> denySet: aFirstSet equals: aSecondSet [ + self - deny: aFirstSet = aSecondSet; - deny: aFirstSet == aSecondSet; - deny: aSecondSet = aFirstSet; - deny: aSecondSet == aFirstSet + deny: aFirstSet equals: aSecondSet; + deny: aFirstSet identicalTo: aSecondSet; + deny: aSecondSet equals: aFirstSet; + deny: aSecondSet identicalTo: aFirstSet ] { #category : #accessing } @@ -70,65 +72,69 @@ XMLAbstractSetTest >> setWithElements [ { #category : #tests } XMLAbstractSetTest >> testAdd [ - | set | + | set | set := self emptySet. - self setElements do: [:each | + self setElements do: [ :each | self - assert: (set add: each) == each; - assert: (set includes: each)]. + assert: (set add: each) identicalTo: each; + assert: (set includes: each) ]. self - assert: set = self setWithElements; - assert: (self setElements allSatisfy: [:each | (set add: each) == each]); - assert: set = self setWithElements + assert: set equals: self setWithElements; + assert: + (self setElements allSatisfy: [ :each | (set add: each) == each ]); + assert: set equals: self setWithElements ] { #category : #tests } XMLAbstractSetTest >> testConcatenation [ - | firstSet secondSet | + | firstSet secondSet | firstSet := self setWithElements. - self assert: (firstSet, self setWithElements) = self setWithElements. + self + assert: firstSet , self setWithElements + equals: self setWithElements. secondSet := self setWithDisjointElements. self - assert: (firstSet, secondSet) = (secondSet, firstSet); - deny: (firstSet, secondSet) = firstSet; - deny: (firstSet, secondSet) = secondSet; - assert: - (firstSet, secondSet) = - (self setClass newFrom: self setElements, self disjointSetElements) + assert: firstSet , secondSet equals: secondSet , firstSet; + deny: firstSet , secondSet equals: firstSet; + deny: firstSet , secondSet equals: secondSet; + assert: firstSet , secondSet + equals: + (self setClass newFrom: self setElements , self disjointSetElements) ] { #category : #tests } XMLAbstractSetTest >> testCopy [ - | set copy | + | set copy | set := self setWithElements. copy := set copy. self - assert: set = copy; - deny: set == copy. + assert: set equals: copy; + deny: set identicalTo: copy. set addAll: self disjointSetElements. - self deny: set = copy. + self deny: set equals: copy. copy addAll: self disjointSetElements. - self assert: set = copy + self assert: set equals: copy ] { #category : #tests } XMLAbstractSetTest >> testDo [ - | enumerated | + | enumerated | enumerated := OrderedCollection new. - self emptySet do: [:each | enumerated addLast: each]. - self assert: enumerated size = 0. + self emptySet do: [ :each | enumerated addLast: each ]. + self assert: enumerated size equals: 0. - self setWithElements do: [:each | enumerated addLast: each]. + self setWithElements do: [ :each | enumerated addLast: each ]. self - assert: enumerated size = self setElements size; - assert: (self setElements allSatisfy: [:each | enumerated includes: each]) + assert: enumerated size equals: self setElements size; + assert: + (self setElements allSatisfy: [ :each | enumerated includes: each ]) ] { #category : #tests } @@ -167,50 +173,48 @@ XMLAbstractSetTest >> testIncludes [ { #category : #tests } XMLAbstractSetTest >> testNewFrom [ - self assert: (self setClass newFrom: self setElements) = self setWithElements + + self + assert: (self setClass newFrom: self setElements) + equals: self setWithElements ] { #category : #tests } XMLAbstractSetTest >> testRemoveAll [ - | set | + | set | set := self setWithElements. self - assert: set removeAll == set; + assert: set removeAll identicalTo: set; assert: set isEmpty ] { #category : #tests } XMLAbstractSetTest >> testRemoveIfAbsent [ - | set | + | set | set := self setWithElements. - self setElements do: [:each | - self assert: - (set - remove: each - ifAbsent: [self fail]) == each. - self deny: (set includes: each). + self setElements do: [ :each | self - assert: - (set - remove: each - ifAbsent: [self absentSetElement]) == self absentSetElement. + assert: (set remove: each ifAbsent: [ self fail ]) + identicalTo: each. + self deny: (set includes: each). self - should: [set remove: each] - raise: Error]. + assert: (set remove: each ifAbsent: [ self absentSetElement ]) + identicalTo: self absentSetElement. + self should: [ set remove: each ] raise: Error ]. self assert: set isEmpty ] { #category : #tests } XMLAbstractSetTest >> testSize [ - | set size | + | set size | set := self emptySet. size := 0. - self assert: set size = size. - self setElements do: [:each | + self assert: set size equals: size. + self setElements do: [ :each | set add: each. size := size + 1. - self assert: set size = size] + self assert: set size equals: size ] ] diff --git a/src/XML-Parser-Tests/XMLAttributeDeclarationTest.class.st b/src/XML-Parser-Tests/XMLAttributeDeclarationTest.class.st index 63b20f89..18b50615 100644 --- a/src/XML-Parser-Tests/XMLAttributeDeclarationTest.class.st +++ b/src/XML-Parser-Tests/XMLAttributeDeclarationTest.class.st @@ -16,100 +16,104 @@ XMLAttributeDeclarationTest >> nodeClass [ { #category : #tests } XMLAttributeDeclarationTest >> testAttribute [ - | declaration | + | declaration | declaration := self newNode. self - assert: declaration attribute = ''; - assert: (declaration attribute: 'test') == declaration; - assert: declaration attribute = 'test' + assert: declaration attribute equals: ''; + assert: (declaration attribute: 'test') identicalTo: declaration; + assert: declaration attribute equals: 'test' ] { #category : #tests } XMLAttributeDeclarationTest >> testDefaultPragma [ - | declaration | + | declaration | declaration := self newNode. self - assert: declaration defaultPragma = ''; - assert: (declaration defaultPragma: 'REQUIRED') == declaration; - assert: declaration defaultPragma = 'REQUIRED' + assert: declaration defaultPragma equals: ''; + assert: (declaration defaultPragma: 'REQUIRED') + identicalTo: declaration; + assert: declaration defaultPragma equals: 'REQUIRED' ] { #category : #tests } XMLAttributeDeclarationTest >> testDefaultValue [ - | declaration | + | declaration | declaration := self newNode. self - assert: declaration defaultValue = ''; - assert: (declaration defaultValue: 'test') == declaration; - assert: declaration defaultValue = 'test' + assert: declaration defaultValue equals: ''; + assert: (declaration defaultValue: 'test') identicalTo: declaration; + assert: declaration defaultValue equals: 'test' ] { #category : #tests } XMLAttributeDeclarationTest >> testElement [ - | declaration | + | declaration | declaration := self newNode. self - assert: declaration element = ''; - assert: (declaration element: 'test') == declaration; - assert: declaration element = 'test' + assert: declaration element equals: ''; + assert: (declaration element: 'test') identicalTo: declaration; + assert: declaration element equals: 'test' ] { #category : #tests } XMLAttributeDeclarationTest >> testElementAttributeTypeDefaultPragmaDefaultValue [ - | declaration | - declaration := - self nodeClass - element: 'one' - attribute: 'two' - type: 'CDATA' - defaultPragma: '#IMPLIED' - defaultValue: 'default'. + | declaration | + declaration := self nodeClass + element: 'one' + attribute: 'two' + type: 'CDATA' + defaultPragma: '#IMPLIED' + defaultValue: 'default'. self - assert: declaration class == self nodeClass; - assert: declaration element = 'one'; - assert: declaration attribute = 'two'; - assert: declaration type = 'CDATA'; - assert: declaration defaultPragma = '#IMPLIED'; - assert: declaration defaultValue = 'default' + assert: declaration class identicalTo: self nodeClass; + assert: declaration element equals: 'one'; + assert: declaration attribute equals: 'two'; + assert: declaration type equals: 'CDATA'; + assert: declaration defaultPragma equals: '#IMPLIED'; + assert: declaration defaultValue equals: 'default' ] { #category : #tests } XMLAttributeDeclarationTest >> testType [ - | declaration | + | declaration | declaration := self newNode. self - assert: declaration type = ''; - assert: (declaration type: 'CDATA') == declaration; - assert: declaration type = 'CDATA' + assert: declaration type equals: ''; + assert: (declaration type: 'CDATA') identicalTo: declaration; + assert: declaration type equals: 'CDATA' ] { #category : #tests } XMLAttributeDeclarationTest >> testWriteXMLOn [ - self assert: - (self nodeClass - element: 'one' - attribute: 'two' - type: 'CDATA' - defaultPragma: '' - defaultValue: 'three') printString = ''. - self assert: - (self nodeClass - element: 'one' - attribute: 'two' - type: 'ENTITY' - defaultPragma: 'FIXED' - defaultValue: 'three') printString = ''. - self assert: - (self nodeClass - element: 'one' - attribute: 'two' - type: '(three|four)' - defaultPragma: '#IMPLIED' - defaultValue: 'four') printString = '' + + self + assert: (self nodeClass + element: 'one' + attribute: 'two' + type: 'CDATA' + defaultPragma: '' + defaultValue: 'three') printString + equals: ''. + self + assert: (self nodeClass + element: 'one' + attribute: 'two' + type: 'ENTITY' + defaultPragma: 'FIXED' + defaultValue: 'three') printString + equals: ''. + self + assert: (self nodeClass + element: 'one' + attribute: 'two' + type: '(three|four)' + defaultPragma: '#IMPLIED' + defaultValue: 'four') printString + equals: '' ] diff --git a/src/XML-Parser-Tests/XMLAttributeDictionaryTest.class.st b/src/XML-Parser-Tests/XMLAttributeDictionaryTest.class.st index 193a14bd..13ff9ce3 100644 --- a/src/XML-Parser-Tests/XMLAttributeDictionaryTest.class.st +++ b/src/XML-Parser-Tests/XMLAttributeDictionaryTest.class.st @@ -35,10 +35,12 @@ XMLAttributeDictionaryTest >> prefixedAttributeDictionary [ { #category : #tests } XMLAttributeDictionaryTest >> testAsXMLAttributeDictionary [ - | dictionary | + | dictionary | dictionary := self emptyDictionary. - self assert: dictionary asXMLAttributeDictionary == dictionary + self + assert: dictionary asXMLAttributeDictionary + identicalTo: dictionary ] { #category : #tests } @@ -367,94 +369,102 @@ XMLAttributeDictionaryTest >> testAtNameNamespaceURI [ { #category : #tests } XMLAttributeDictionaryTest >> testAtNameNamespaceURIIfAbsent [ - | dictionary | + | dictionary | dictionary := self prefixedAttributeDictionary. - self assert: - (dictionary - atName: 'id' - namespaceURI: XMLNamespaceScope xmlNamespaceURI - ifAbsent: [self absentValue]) equals: self absentValue. - self assert: - (dictionary - atName: 'id' - namespaceURI: 'defaultNS' - ifAbsent: [self absentValue]) equals: self absentValue. - self assert: - (dictionary - atName: 'id' - namespaceURI: '' - ifAbsent: [self fail]) equals: 'id'. - self assert: - (dictionary - atName: 'xml:id' - namespaceURI: XMLNamespaceScope xmlNamespaceURI - ifAbsent: [self absentValue]) equals: self absentValue. - self assert: - (dictionary - atName: 'xml:id' - namespaceURI: 'defaultNS' - ifAbsent: [self absentValue]) equals: self absentValue. - self assert: - (dictionary - atName: 'xml:id' - namespaceURI: '' - ifAbsent: [self fail]) equals: 'id'. - - self assert: - (dictionary - atName: 'name' - namespaceURI: 'prefixNS' - ifAbsent: [self absentValue]) equals: self absentValue. - self assert: - (dictionary - atName: 'prefix:name' - namespaceURI: 'prefixNS' - ifAbsent: [self absentValue]) equals: self absentValue. - self assert: + self + assert: (dictionary + atName: 'id' + namespaceURI: XMLNamespaceScope xmlNamespaceURI + ifAbsent: [ self absentValue ]) + equals: self absentValue. + self + assert: (dictionary + atName: 'id' + namespaceURI: 'defaultNS' + ifAbsent: [ self absentValue ]) + equals: self absentValue. + self + assert: + (dictionary atName: 'id' namespaceURI: '' ifAbsent: [ self fail ]) + equals: 'id'. + self + assert: (dictionary + atName: 'xml:id' + namespaceURI: XMLNamespaceScope xmlNamespaceURI + ifAbsent: [ self absentValue ]) + equals: self absentValue. + self + assert: (dictionary + atName: 'xml:id' + namespaceURI: 'defaultNS' + ifAbsent: [ self absentValue ]) + equals: self absentValue. + self + assert: (dictionary - atName: 'prefix:name' - namespaceURI: 'defaultNS' - ifAbsent: [self absentValue]) equals: self absentValue. + atName: 'xml:id' + namespaceURI: '' + ifAbsent: [ self fail ]) + equals: 'id'. - self assert: - (dictionary - atName: 'name' - namespaceURI: 'otherPrefixNS' - ifAbsent: [self absentValue]) equals: self absentValue. - self assert: - (dictionary - atName: 'otherPrefix:name' - namespaceURI: 'otherPrefixNS' - ifAbsent: [self absentValue]) equals: self absentValue. - self assert: - (dictionary - atName: 'otherPrefix:name' - namespaceURI: 'defaultNS' - ifAbsent: [self absentValue]) equals: self absentValue. + self + assert: (dictionary + atName: 'name' + namespaceURI: 'prefixNS' + ifAbsent: [ self absentValue ]) + equals: self absentValue. + self + assert: (dictionary + atName: 'prefix:name' + namespaceURI: 'prefixNS' + ifAbsent: [ self absentValue ]) + equals: self absentValue. + self + assert: (dictionary + atName: 'prefix:name' + namespaceURI: 'defaultNS' + ifAbsent: [ self absentValue ]) + equals: self absentValue. - self assert: - (dictionary - atName: 'name' - namespaceURI: '' - ifAbsent: [self fail]) = 'value'. - self assert: - (dictionary - atName: 'name' - namespaceURI: 'defaultNS' - ifAbsent: [self absentValue]) = self absentValue + self + assert: (dictionary + atName: 'name' + namespaceURI: 'otherPrefixNS' + ifAbsent: [ self absentValue ]) + equals: self absentValue. + self + assert: (dictionary + atName: 'otherPrefix:name' + namespaceURI: 'otherPrefixNS' + ifAbsent: [ self absentValue ]) + equals: self absentValue. + self + assert: (dictionary + atName: 'otherPrefix:name' + namespaceURI: 'defaultNS' + ifAbsent: [ self absentValue ]) + equals: self absentValue. + self + assert: + (dictionary atName: 'name' namespaceURI: '' ifAbsent: [ self fail ]) + equals: 'value'. + self + assert: (dictionary + atName: 'name' + namespaceURI: 'defaultNS' + ifAbsent: [ self absentValue ]) + equals: self absentValue ] { #category : #tests } XMLAttributeDictionaryTest >> testLazyDictionaryEmptyAttributeDictionary [ - self isTestingLazyDictionary - ifFalse: [^ self]. - self assert: - self emptyDictionary attributeDictionary == - self dictionaryClass emptyAttributeDictionary. - self assert: - self dictionaryClass emptyAttributeDictionary isEmpty + self isTestingLazyDictionary ifFalse: [ ^ self ]. + self + assert: self emptyDictionary attributeDictionary + identicalTo: self dictionaryClass emptyAttributeDictionary. + self assert: self dictionaryClass emptyAttributeDictionary isEmpty ] { #category : #tests } diff --git a/src/XML-Parser-Tests/XMLAttributeListTest.class.st b/src/XML-Parser-Tests/XMLAttributeListTest.class.st index 2736789a..146dfa48 100644 --- a/src/XML-Parser-Tests/XMLAttributeListTest.class.st +++ b/src/XML-Parser-Tests/XMLAttributeListTest.class.st @@ -122,46 +122,44 @@ XMLAttributeListTest >> sortBlock [ { #category : #tests } XMLAttributeListTest >> testAddAttributeAssociation [ - | list | + | list | list := self emptyList. - self listItems do: [:each | | attribute | + self listItems do: [ :each | + | attribute | attribute := list addAttributeAssociation: each name -> each value. self - assert: attribute class == self attributeClass; - assert: attribute name = each name; - assert: attribute value = each value; - assert: list last = attribute] + assert: attribute class identicalTo: self attributeClass; + assert: attribute name equals: each name; + assert: attribute value equals: each value; + assert: list last equals: attribute ] ] { #category : #tests } XMLAttributeListTest >> testAddAttributeNameValue [ - | list | + | list | list := self emptyList. - self listItems do: [:each | | attribute | - attribute := - list - addAttributeName: each name - value: each value. + self listItems do: [ :each | + | attribute | + attribute := list addAttributeName: each name value: each value. self - assert: attribute class == self attributeClass; - assert: attribute name = each name; - assert: attribute value = each value; - assert: list last = attribute] + assert: attribute class identicalTo: self attributeClass; + assert: attribute name equals: each name; + assert: attribute value equals: each value; + assert: list last equals: attribute ] ] { #category : #tests } XMLAttributeListTest >> testAsDictionary [ - | list dictionary | + | list dictionary | list := self listWithItems. dictionary := list asDictionary. self - assert: dictionary class == self attributesClass; - assert: - dictionary = - (self attributesClass newFrom: self attributeAssociations) + assert: dictionary class identicalTo: self attributesClass; + assert: dictionary + equals: (self attributesClass newFrom: self attributeAssociations) ] { #category : #tests } @@ -177,104 +175,91 @@ XMLAttributeListTest >> testAttributeAssociations [ { #category : #tests } XMLAttributeListTest >> testAttributeAt [ - | list | + | list | list := self emptyList. - 1 to: 2 do: [:i | - self listItems do: [:each | - self assert: - (list attributeAt: each name) = - (i > 1 - ifTrue: [each value] - ifFalse: ['']). + 1 to: 2 do: [ :i | + self listItems do: [ :each | + self assert: (list attributeAt: each name) equals: (i > 1 + ifTrue: [ each value ] + ifFalse: [ '' ]). list add: each. - self assert: (list attributeAt: each name) = each value]]. + self assert: (list attributeAt: each name) equals: each value ] ]. - self listItems do: [:each | - self assert: (list attributeAt: each name) = each value] + self listItems do: [ :each | + self assert: (list attributeAt: each name) equals: each value ] ] { #category : #tests } XMLAttributeListTest >> testAttributeAtIfAbsent [ - | list | + | list | list := self emptyList. - 1 to: 2 do: [:i | - self listItems do: [:each | - self assert: - (list - attributeAt: each name - ifAbsent: [ - i > 1 - ifTrue: [self fail] - ifFalse: [self absentListItem value]]) = - (i > 1 - ifTrue: [each value] - ifFalse: [self absentListItem value]). + 1 to: 2 do: [ :i | + self listItems do: [ :each | + self + assert: (list attributeAt: each name ifAbsent: [ + i > 1 + ifTrue: [ self fail ] + ifFalse: [ self absentListItem value ] ]) + equals: (i > 1 + ifTrue: [ each value ] + ifFalse: [ self absentListItem value ]). list add: each. - self assert: - (list - attributeAt: each name - ifAbsent: [self fail]) = each value]]. + self + assert: (list attributeAt: each name ifAbsent: [ self fail ]) + equals: each value ] ]. - self listItems do: [:each | - self assert: - (list - attributeAt: each name - ifAbsent: [self fail]) = each value] + self listItems do: [ :each | + self + assert: (list attributeAt: each name ifAbsent: [ self fail ]) + equals: each value ] ] { #category : #tests } XMLAttributeListTest >> testAttributeAtIfAbsentPut [ - | list | + | list | list := self emptyList. - 1 to: 2 do: [:i | - self listItems do: [:each | - self assert: - (list - attributeAt: each name - ifAbsentPut: [ - i > 1 - ifTrue: [self fail] - ifFalse: [each value]]) = each value. + 1 to: 2 do: [ :i | + self listItems do: [ :each | + self + assert: (list attributeAt: each name ifAbsentPut: [ + i > 1 + ifTrue: [ self fail ] + ifFalse: [ each value ] ]) + equals: each value. list add: each. - self assert: - (list - attributeAt: each name - ifAbsentPut: [self fail]) = each value]]. + self + assert: (list attributeAt: each name ifAbsentPut: [ self fail ]) + equals: each value ] ]. - self listItems do: [:each | - self assert: - (list - attributeAt: each name - ifAbsentPut: [self fail]) = each value] + self listItems do: [ :each | + self + assert: (list attributeAt: each name ifAbsentPut: [ self fail ]) + equals: each value ] ] { #category : #tests } XMLAttributeListTest >> testAttributeAtPut [ - | list | + | list | list := self emptyList. - 1 to: 2 do: [:i | - self listItems do: [:each | - self assert: - (list attributeAt: each name) = - (i > 1 - ifTrue: [each value] - ifFalse: ['']). - - self assert: - (list - attributeAt: each name - put: each value) = each value. - self assert: (list attributeAt: each name) = each value]]. + 1 to: 2 do: [ :i | + self listItems do: [ :each | + self assert: (list attributeAt: each name) equals: (i > 1 + ifTrue: [ each value ] + ifFalse: [ '' ]). + self + assert: (list attributeAt: each name put: each value) + equals: each value. + self assert: (list attributeAt: each name) equals: each value ] ]. - self listItems do: [:each | - self assert: (list attributeAt: each name) = each value] + self listItems do: [ :each | + self assert: (list attributeAt: each name) equals: each value ] ] { #category : #tests } @@ -324,167 +309,151 @@ XMLAttributeListTest >> testAttributeNamesDo [ { #category : #tests } XMLAttributeListTest >> testAttributeNodeAt [ - | list | + | list | list := self emptyList. - self listItems withIndexDo: [:attribute :i | | firstMatchingAttribute | - firstMatchingAttribute := - (self listItems copyFrom: 1 to: i - 1) - detect: [:each | each isNamed: attribute name] - ifNone: [nil]. - self assert: - (list attributeNodeAt: attribute name) = - (firstMatchingAttribute - ifNil: [self defaultValue]). - + self listItems withIndexDo: [ :attribute :i | + | firstMatchingAttribute | + firstMatchingAttribute := (self listItems copyFrom: 1 to: i - 1) + detect: [ :each | + each isNamed: attribute name ] + ifNone: [ nil ]. + self + assert: (list attributeNodeAt: attribute name) + equals: (firstMatchingAttribute ifNil: [ self defaultValue ]). + list add: attribute. - self assert: - (list attributeNodeAt: attribute name) = - (firstMatchingAttribute - ifNil: [attribute])]. + self + assert: (list attributeNodeAt: attribute name) + equals: (firstMatchingAttribute ifNil: [ attribute ]) ] ] { #category : #tests } XMLAttributeListTest >> testAttributeNodeAtIfAbsent [ - | list | + | list | list := self emptyList. - self listItems withIndexDo: [:attribute :i | | firstMatchingAttribute | - firstMatchingAttribute := - (self listItems copyFrom: 1 to: i - 1) - detect: [:each | each isNamed: attribute name] - ifNone: [nil]. - self assert: - (list - attributeNodeAt: attribute name - ifAbsent: [ - firstMatchingAttribute - ifNil: [self absentListItem]]) = - (firstMatchingAttribute - ifNil: [self absentListItem]). - + self listItems withIndexDo: [ :attribute :i | + | firstMatchingAttribute | + firstMatchingAttribute := (self listItems copyFrom: 1 to: i - 1) + detect: [ :each | + each isNamed: attribute name ] + ifNone: [ nil ]. + self + assert: (list + attributeNodeAt: attribute name + ifAbsent: [ + firstMatchingAttribute ifNil: [ self absentListItem ] ]) + equals: (firstMatchingAttribute ifNil: [ self absentListItem ]). + list add: attribute. - self assert: - (list - attributeNodeAt: attribute name - ifAbsent: [self fail]) = - (firstMatchingAttribute - ifNil: [attribute])]. + self + assert: + (list attributeNodeAt: attribute name ifAbsent: [ self fail ]) + equals: (firstMatchingAttribute ifNil: [ attribute ]) ] ] { #category : #tests } XMLAttributeListTest >> testAttributeValueAt [ - | list | + | list | list := self emptyList. - 1 to: 2 do: [:i | - self listItems do: [:each | - self assert: - (list attributeValueAt: each name) = - (i > 1 - ifTrue: [each value] - ifFalse: ['']). - + 1 to: 2 do: [ :i | + self listItems do: [ :each | + self assert: (list attributeValueAt: each name) equals: (i > 1 + ifTrue: [ each value ] + ifFalse: [ '' ]). + list add: each. - self assert: (list attributeValueAt: each name) = each value]]. + self assert: (list attributeValueAt: each name) equals: each value ] ]. - self listItems do: [:each | - self assert: (list attributeValueAt: each name) = each value]. + self listItems do: [ :each | + self assert: (list attributeValueAt: each name) equals: each value ] ] { #category : #tests } XMLAttributeListTest >> testAttributeValueAtIfAbsent [ - | list | + | list | list := self emptyList. - 1 to: 2 do: [:i | - self listItems do: [:each | - self assert: - (list - attributeValueAt: each name - ifAbsent: [ - i > 1 - ifTrue: [self fail] - ifFalse: [self absentListItem value]]) = - (i > 1 - ifTrue: [each value] - ifFalse: [self absentListItem value]). - + 1 to: 2 do: [ :i | + self listItems do: [ :each | + self + assert: (list attributeValueAt: each name ifAbsent: [ + i > 1 + ifTrue: [ self fail ] + ifFalse: [ self absentListItem value ] ]) + equals: (i > 1 + ifTrue: [ each value ] + ifFalse: [ self absentListItem value ]). + list add: each. - self assert: - (list - attributeValueAt: each name - ifAbsent: [self fail]) = each value]]. + self + assert: (list attributeValueAt: each name ifAbsent: [ self fail ]) + equals: each value ] ]. - self listItems do: [:each | - self assert: - (list - attributeValueAt: each name - ifAbsent: [self fail]) = each value]. + self listItems do: [ :each | + self + assert: (list attributeValueAt: each name ifAbsent: [ self fail ]) + equals: each value ] ] { #category : #tests } XMLAttributeListTest >> testAttributeValueAtIfAbsentPut [ - | list | + | list | list := self emptyList. - 1 to: 2 do: [:i | - self listItems do: [:each | - self assert: - (list - attributeValueAt: each name - ifAbsentPut: [ - i > 1 - ifTrue: [self fail] - ifFalse: [each value]]) = each value. - + 1 to: 2 do: [ :i | + self listItems do: [ :each | + self + assert: (list attributeValueAt: each name ifAbsentPut: [ + i > 1 + ifTrue: [ self fail ] + ifFalse: [ each value ] ]) + equals: each value. + list add: each. - self assert: - (list - attributeValueAt: each name - ifAbsentPut: [self fail]) = each value]]. + self + assert: + (list attributeValueAt: each name ifAbsentPut: [ self fail ]) + equals: each value ] ]. - self listItems do: [:each | - self assert: - (list - attributeValueAt: each name - ifAbsentPut: [self fail]) = each value]. + self listItems do: [ :each | + self + assert: + (list attributeValueAt: each name ifAbsentPut: [ self fail ]) + equals: each value ] ] { #category : #tests } XMLAttributeListTest >> testAttributeValueAtPut [ - | list | + | list | list := self emptyList. - 1 to: 2 do: [:i | - self listItems do: [:each | - self assert: - (list attributeValueAt: each name) = - (i > 1 - ifTrue: [each value] - ifFalse: ['']). - - self assert: - (list - attributeValueAt: each name - put: each value) = each value. - self assert: (list attributeValueAt: each name) = each value]]. + 1 to: 2 do: [ :i | + self listItems do: [ :each | + self assert: (list attributeValueAt: each name) equals: (i > 1 + ifTrue: [ each value ] + ifFalse: [ '' ]). + self + assert: (list attributeValueAt: each name put: each value) + equals: each value. + self assert: (list attributeValueAt: each name) equals: each value ] ]. - self listItems do: [:each | - self assert: (list attributeValueAt: each name) = each value]. + self listItems do: [ :each | + self assert: (list attributeValueAt: each name) equals: each value ] ] { #category : #tests } XMLAttributeListTest >> testAttributes [ - | list dictionary | + | list dictionary | list := self listWithItems. dictionary := list attributes. self - assert: dictionary class == self attributesClass; - assert: - dictionary = - (self attributesClass newFrom: self attributeAssociations). + assert: dictionary class identicalTo: self attributesClass; + assert: dictionary + equals: (self attributesClass newFrom: self attributeAssociations) ] { #category : #tests } @@ -501,21 +470,19 @@ XMLAttributeListTest >> testIncludesAttribute [ { #category : #tests } XMLAttributeListTest >> testIncludesAttributeNode [ - | list | + | list | list := self emptyList. - self listItems withIndexDo: [:attribute :i | | included | - included := - (self listItems - copyFrom: 1 - to: i - 1) anySatisfy: [:each | - each isNamed: attribute name]. - self assert: - (list includesAttributeNode: attribute name) = - included. + self listItems withIndexDo: [ :attribute :i | + | included | + included := (self listItems copyFrom: 1 to: i - 1) anySatisfy: [ + :each | each isNamed: attribute name ]. + self + assert: (list includesAttributeNode: attribute name) + equals: included. list add: attribute. - self assert: (list includesAttributeNode: attribute name)]. + self assert: (list includesAttributeNode: attribute name) ] ] { #category : #tests } @@ -542,79 +509,77 @@ XMLAttributeListTest >> testIncludesAttributeNodeNamespaceURI [ { #category : #tests } XMLAttributeListTest >> testRemoveAttribute [ - (Array - with: self listWithItems - with: self listWithItems reversed) - do: [:list | | copy | + + (Array with: self listWithItems with: self listWithItems reversed) + do: [ :list | + | copy | copy := list copy. - copy withIndexDo: [:each :i | + copy withIndexDo: [ :each :i | self - assert: (list removeAttribute: each name) = each value; + assert: (list removeAttribute: each name) equals: each value; deny: (list includes: each). - self - assertList: list - equals: (copy allButFirst: i). + self assertList: list equals: (copy allButFirst: i). - self - should: [list removeAttribute: each name] - raise: Error]]. + self should: [ list removeAttribute: each name ] raise: Error ] ] ] { #category : #tests } XMLAttributeListTest >> testRemoveAttributeIfAbsent [ - (Array - with: self listWithItems - with: self listWithItems reversed) - do: [:list | | copy | + + (Array with: self listWithItems with: self listWithItems reversed) + do: [ :list | + | copy | copy := list copy. - copy withIndexDo: [:each :i | - self assert: - (list - removeAttribute: each name - ifAbsent: [self fail]) = each value; + copy withIndexDo: [ :each :i | + self + assert: (list removeAttribute: each name ifAbsent: [ self fail ]) + equals: each value; deny: (list includes: each). + self assertList: list equals: (copy allButFirst: i). self - assertList: list - equals: (copy allButFirst: i). - - self assert: - (list - removeAttribute: each name - ifAbsent: [self absentListItem value]) = self absentListItem value]]. + assert: (list + removeAttribute: each name + ifAbsent: [ self absentListItem value ]) + equals: self absentListItem value ] ] ] { #category : #tests } XMLAttributeListTest >> testSetAttributes [ - | list associations | + | list associations | list := self emptyList. associations := self attributeAssociations. self - assert: (list setAttributes: associations) == list; - assert: list attributeAssociations asArray = associations asArray. + assert: (list setAttributes: associations) identicalTo: list; + assert: list attributeAssociations asArray + equals: associations asArray. - associations := - self changedListItems collect: [:each | each name -> each value]. + associations := self changedListItems collect: [ :each | + each name -> each value ]. self - assert: (list setAttributes: associations) == list; - assert: list attributeAssociations asArray = associations asArray. + assert: (list setAttributes: associations) identicalTo: list; + assert: list attributeAssociations asArray + equals: associations asArray ] { #category : #tests } XMLAttributeListTest >> testSetAttributesFromOrderPreservingDictionary [ - | element list dictionary | + | element list dictionary | element := XMLElement new. list := self listClass observer: element. - dictionary := OrderPreservingDictionary newFrom: self attributeAssociations. - self assert: - (list setAttributesFromOrderPreservingDictionary: dictionary) == list. - self assert: - list attributeAssociations asArray = - self attributeAssociations asArray. - list do: [:each | + dictionary := OrderPreservingDictionary newFrom: + self attributeAssociations. + self + assert: + (list setAttributesFromOrderPreservingDictionary: dictionary) + identicalTo: list. + self + assert: list attributeAssociations asArray + equals: self attributeAssociations asArray. + list do: [ :each | self - assert: each class == self attributeClass; - assert: each parent == element; - assert: each element == element] + assert: each class identicalTo: self attributeClass; + assert: each parent identicalTo: element; + assert: each element identicalTo: element ] ] diff --git a/src/XML-Parser-Tests/XMLAttributeSpecTest.class.st b/src/XML-Parser-Tests/XMLAttributeSpecTest.class.st index ec723490..c84dde37 100644 --- a/src/XML-Parser-Tests/XMLAttributeSpecTest.class.st +++ b/src/XML-Parser-Tests/XMLAttributeSpecTest.class.st @@ -21,8 +21,10 @@ XMLAttributeSpecTest >> newAttributeSpec [ { #category : #tests } XMLAttributeSpecTest >> testAsXMLAttributeSpec [ - | attributeSpec | + | attributeSpec | attributeSpec := self newAttributeSpec. - self assert: attributeSpec asXMLAttributeSpec == attributeSpec + self + assert: attributeSpec asXMLAttributeSpec + identicalTo: attributeSpec ] diff --git a/src/XML-Parser-Tests/XMLAttributeTest.class.st b/src/XML-Parser-Tests/XMLAttributeTest.class.st index bc1ac567..dbe920ac 100644 --- a/src/XML-Parser-Tests/XMLAttributeTest.class.st +++ b/src/XML-Parser-Tests/XMLAttributeTest.class.st @@ -27,44 +27,43 @@ XMLAttributeTest >> testCanonicallyEquals [ { #category : #tests } XMLAttributeTest >> testCopy [ - | node copy | - (node := self newNode) - element: self newElement. + | node copy | + (node := self newNode) element: self newElement. copy := node copy. self - deny: copy == node; + deny: copy identicalTo: node; assert: copy element isNil ] { #category : #tests } XMLAttributeTest >> testElement [ - | attribute element | + | attribute element | attribute := self newNode. self assert: attribute element isNil. element := self newElement. self - assert: (attribute element: element) == attribute; - assert: attribute element == element + assert: (attribute element: element) identicalTo: attribute; + assert: attribute element identicalTo: element ] { #category : #tests } XMLAttributeTest >> testExpandedName [ - | element attribute | + | element attribute | element := self newElement. attribute := self nodeClass name: 'one' value: 'two'. element attributeNodes add: attribute. - self assert: (attribute expandedName = 'one'). + self assert: attribute expandedName equals: 'one'. element defaultNamespace: 'defaultNS'. - self assert: (attribute expandedName = 'one'). + self assert: attribute expandedName equals: 'one'. element declarePrefix: 'prefix' uri: 'prefixNS'. attribute name: 'prefix:two'. - self assert: (attribute expandedName = 'Q{prefixNS}two') + self assert: attribute expandedName equals: 'Q{prefixNS}two' ] { #category : #tests } @@ -177,22 +176,22 @@ XMLAttributeTest >> testIsNamedAny [ { #category : #tests } XMLAttributeTest >> testLocalName [ - | attribute | + | attribute | attribute := self newNode. - self assert: attribute name = ''. + self assert: attribute name equals: ''. attribute name: 'one'. - self assert: attribute localName = 'one'. + self assert: attribute localName equals: 'one'. attribute name: 'two'. - self assert: attribute localName = 'two'. + self assert: attribute localName equals: 'two'. attribute name: 'prefix:three'. - self assert: attribute localName = 'three'. + self assert: attribute localName equals: 'three'. attribute name: 'four'. - self assert: attribute localName = 'four' + self assert: attribute localName equals: 'four' ] { #category : #tests } @@ -220,151 +219,152 @@ XMLAttributeTest >> testMatchesLanguage [ { #category : #tests } XMLAttributeTest >> testName [ - | attribute | + | attribute | "XMLAttribute class>>#name: is not tested here because it is soft-deprecated" - attribute := self newNode. self - assert: attribute name = ''; - assert: (attribute name: 'one') == attribute; - assert: attribute name = 'one'; - assert: (attribute name: 'prefix:two') == attribute; - assert: attribute name = 'prefix:two' + assert: attribute name equals: ''; + assert: (attribute name: 'one') identicalTo: attribute; + assert: attribute name equals: 'one'; + assert: (attribute name: 'prefix:two') identicalTo: attribute; + assert: attribute name equals: 'prefix:two' ] { #category : #tests } XMLAttributeTest >> testNameValue [ - | attribute | - attribute := - self nodeClass - name: 'one' - value: 'two'. + | attribute | + attribute := self nodeClass name: 'one' value: 'two'. self - assert: attribute class == self nodeClass; - assert: attribute name = 'one'; - assert: attribute value = 'two' + assert: attribute class identicalTo: self nodeClass; + assert: attribute name equals: 'one'; + assert: attribute value equals: 'two' ] { #category : #tests } XMLAttributeTest >> testNamed [ - | attribute | + | attribute | attribute := self nodeClass named: 'test'. self - assert: attribute class == self nodeClass; - assert: attribute name = 'test' + assert: attribute class identicalTo: self nodeClass; + assert: attribute name equals: 'test' ] { #category : #tests } XMLAttributeTest >> testNamespaceURI [ - | element attribute| + | element attribute | element := self newElement. attribute := self newNode. element attributeNodes add: attribute. - self assert: attribute namespaceURI = ''. + self assert: attribute namespaceURI equals: ''. element defaultNamespace: 'defaultNS'. - self assert: attribute namespaceURI = ''. + self assert: attribute namespaceURI equals: ''. element declarePrefix: 'prefix' uri: 'prefixNS'. attribute name: 'prefix:test'. - self assert: attribute namespaceURI = 'prefixNS'. + self assert: attribute namespaceURI equals: 'prefixNS'. attribute name: 'test'. - self assert: attribute namespaceURI = '' + self assert: attribute namespaceURI equals: '' ] { #category : #tests } XMLAttributeTest >> testPrefix [ - | attribute | + | attribute | attribute := self newNode. - self assert: attribute prefix = ''. + self assert: attribute prefix equals: ''. attribute name: 'one'. - self assert: attribute prefix = ''. + self assert: attribute prefix equals: ''. attribute name: 'prefix:two'. - self assert: attribute prefix = 'prefix'. + self assert: attribute prefix equals: 'prefix'. attribute name: 'three'. - self assert: attribute prefix = '' + self assert: attribute prefix equals: '' ] { #category : #tests } XMLAttributeTest >> testResolvePrefix [ - | element attribute| + | element attribute | element := self newElementWithAttributes. attribute := element attributeNodes first. - self namespaces keysAndValuesDo: [:prefix :uri | - "no default namespace for attributes" + self namespaces keysAndValuesDo: [ :prefix :uri | "no default namespace for attributes" prefix = '' - ifTrue: [self assert: (attribute resolvePrefix: prefix) = ''] - ifFalse: [self assert: (attribute resolvePrefix: prefix) = uri]]. - - self assert: - (attribute resolvePrefix: 'xml') = XMLNamespaceScope xmlNamespaceURI. - self assert: - (attribute resolvePrefix: 'xmlns') = XMLNamespaceScope xmlnsNamespaceURI + ifTrue: [ + self assert: (attribute resolvePrefix: prefix) equals: '' ] + ifFalse: [ + self assert: (attribute resolvePrefix: prefix) equals: uri ] ]. + self + assert: (attribute resolvePrefix: 'xml') + equals: XMLNamespaceScope xmlNamespaceURI. + self + assert: (attribute resolvePrefix: 'xmlns') + equals: XMLNamespaceScope xmlnsNamespaceURI ] { #category : #tests } XMLAttributeTest >> testResolvePrefixIfUnresolvable [ - | element attribute| + | element attribute | element := self newElementWithAttributes. attribute := element attributeNodes first. - self namespaces keysAndValuesDo: [:prefix :uri | + self namespaces keysAndValuesDo: [ :prefix :uri | prefix = '' - ifTrue: [ - "no default namespace for attributes" - self assert: + ifTrue: [ "no default namespace for attributes" + self + assert: (attribute - resolvePrefix: prefix - ifUnresolvable: ['unresolvable']) = 'unresolvable'] + resolvePrefix: prefix + ifUnresolvable: [ 'unresolvable' ]) + equals: 'unresolvable' ] ifFalse: [ - self assert: - (attribute - resolvePrefix: prefix - ifUnresolvable: [self fail]) = uri]]. - - self assert: - (attribute - resolvePrefix: 'xml' - ifUnresolvable: [self fail]) = XMLNamespaceScope xmlNamespaceURI. - self assert: - (attribute - resolvePrefix: 'xmlns' - ifUnresolvable: [self fail]) = XMLNamespaceScope xmlnsNamespaceURI + self + assert: + (attribute resolvePrefix: prefix ifUnresolvable: [ self fail ]) + equals: uri ] ]. + self + assert: + (attribute resolvePrefix: 'xml' ifUnresolvable: [ self fail ]) + equals: XMLNamespaceScope xmlNamespaceURI. + self + assert: + (attribute resolvePrefix: 'xmlns' ifUnresolvable: [ self fail ]) + equals: XMLNamespaceScope xmlnsNamespaceURI ] { #category : #tests } XMLAttributeTest >> testSortKey [ - self assert: (self newNode name: 'test') sortKey = 'test' + + self assert: (self newNode name: 'test') sortKey equals: 'test' ] { #category : #tests } XMLAttributeTest >> testValue [ - | attribute | + | attribute | attribute := self newNode. self - assert: attribute value = ''; - assert: (attribute value: 'test') == attribute; - assert: attribute value = 'test' + assert: attribute value equals: ''; + assert: (attribute value: 'test') identicalTo: attribute; + assert: attribute value equals: 'test' ] { #category : #tests } XMLAttributeTest >> testWriteXMLOn [ + self - assert: (self nodeClass name: 'name' value: '') printString = 'name=""'; - assert: (self nodeClass name: 'name' value: 'value') printString = 'name="value"'; + assert: (self nodeClass name: 'name' value: '') printString + equals: 'name=""'; + assert: (self nodeClass name: 'name' value: 'value') printString + equals: 'name="value"'; assert: - (self nodeClass - name: 'name' - value: self markupString) printString = ('name="', self escapedString, '"') + (self nodeClass name: 'name' value: self markupString) printString + equals: 'name="' , self escapedString , '"' ] diff --git a/src/XML-Parser-Tests/XMLBasicElementClassMapperTest.class.st b/src/XML-Parser-Tests/XMLBasicElementClassMapperTest.class.st index 69cd6362..cb11dce6 100644 --- a/src/XML-Parser-Tests/XMLBasicElementClassMapperTest.class.st +++ b/src/XML-Parser-Tests/XMLBasicElementClassMapperTest.class.st @@ -11,35 +11,39 @@ XMLBasicElementClassMapperTest >> mapperClass [ { #category : #tests } XMLBasicElementClassMapperTest >> testClassForElement [ - | mapper | + | mapper | mapper := self newMapper. self assert: (mapper classForElement: 'test') isNil; assert: (mapper classForElement: 'prefix:test') isNil. - mapper - mapElement: 'test' - toClass: self elementClass. + mapper mapElement: 'test' toClass: self elementClass. self - assert: (mapper classForElement: 'test') == self elementClass; - assert: (mapper classForElement: 'prefix:test') == self elementClass. + assert: (mapper classForElement: 'test') + identicalTo: self elementClass; + assert: (mapper classForElement: 'prefix:test') + identicalTo: self elementClass. mapper mapElement: 'test' attributeSpec: self attributes asXMLAttributeSpec toClass: self otherElementClass. self - assert: (mapper classForElement: 'test') == self elementClass; - assert: (mapper classForElement: 'prefix:test') == self elementClass. + assert: (mapper classForElement: 'test') + identicalTo: self elementClass; + assert: (mapper classForElement: 'prefix:test') + identicalTo: self elementClass. mapper mapElement: 'test' namespaceURI: 'testNS' toClass: self otherElementClass. self - assert: (mapper classForElement: 'test') == self elementClass; - assert: (mapper classForElement: 'prefix:test') == self elementClass. + assert: (mapper classForElement: 'test') + identicalTo: self elementClass; + assert: (mapper classForElement: 'prefix:test') + identicalTo: self elementClass. mapper mapElement: 'test' @@ -47,444 +51,419 @@ XMLBasicElementClassMapperTest >> testClassForElement [ attributeSpec: self attributes asXMLAttributeSpec toClass: self otherElementClass. self - assert: (mapper classForElement: 'test') == self elementClass; - assert: (mapper classForElement: 'prefix:test') == self elementClass. + assert: (mapper classForElement: 'test') + identicalTo: self elementClass; + assert: (mapper classForElement: 'prefix:test') + identicalTo: self elementClass. "QName mappings should take precedence over NCName mappings" - mapper - mapElement: 'prefix:test' - toClass: self otherElementClass. + mapper mapElement: 'prefix:test' toClass: self otherElementClass. self - assert: (mapper classForElement: 'test') == self elementClass; - assert: (mapper classForElement: 'prefix:test') == self otherElementClass + assert: (mapper classForElement: 'test') + identicalTo: self elementClass; + assert: (mapper classForElement: 'prefix:test') + identicalTo: self otherElementClass ] { #category : #tests } XMLBasicElementClassMapperTest >> testClassForElementAttributes [ - | mapper | + | mapper | mapper := self newMapper. self assert: - (mapper - classForElement: 'test' - attributes: self attributes) isNil. + (mapper classForElement: 'test' attributes: self attributes) isNil. self assert: - (mapper - classForElement: 'prefix:test' - attributes: self attributes) isNil. + (mapper classForElement: 'prefix:test' attributes: self attributes) + isNil. - mapper - mapElement: 'test' - toClass: self otherElementClass. - self assert: - (mapper - classForElement: 'test' - attributes: self attributes) == self otherElementClass. - (mapper - classForElement: 'prefix:test' - attributes: self attributes) == self otherElementClass. + mapper mapElement: 'test' toClass: self otherElementClass. + self + assert: (mapper classForElement: 'test' attributes: self attributes) + identicalTo: self otherElementClass. + (mapper classForElement: 'prefix:test' attributes: self attributes) + == self otherElementClass. mapper mapElement: 'test' attributeSpec: self attributes asXMLAttributeSpec toClass: self elementClass. - self assert: - (mapper - classForElement: 'test' - attributes: self attributes) == self elementClass. - self assert: - (mapper - classForElement: 'prefix:test' - attributes: self attributes) == self elementClass. + self + assert: (mapper classForElement: 'test' attributes: self attributes) + identicalTo: self elementClass. + self + assert: + (mapper classForElement: 'prefix:test' attributes: self attributes) + identicalTo: self elementClass. mapper mapElement: 'test' namespaceURI: 'testNS' toClass: self otherElementClass. - self assert: - (mapper - classForElement: 'test' - attributes: self attributes) == self elementClass. - self assert: - (mapper - classForElement: 'prefix:test' - attributes: self attributes) == self elementClass. + self + assert: (mapper classForElement: 'test' attributes: self attributes) + identicalTo: self elementClass. + self + assert: + (mapper classForElement: 'prefix:test' attributes: self attributes) + identicalTo: self elementClass. mapper mapElement: 'test' namespaceURI: 'testNS' attributeSpec: self attributes asXMLAttributeSpec toClass: self otherElementClass. - self assert: - (mapper - classForElement: 'test' - attributes: self attributes) == self elementClass. - self assert: - (mapper - classForElement: 'prefix:test' - attributes: self attributes) == self elementClass. - - "QName mappings should take precedence over NCName mappings" + self + assert: (mapper classForElement: 'test' attributes: self attributes) + identicalTo: self elementClass. + self + assert: + (mapper classForElement: 'prefix:test' attributes: self attributes) + identicalTo: self elementClass. mapper mapElement: 'prefix:test' attributeSpec: self attributes asXMLAttributeSpec toClass: self otherElementClass. - self assert: - (mapper - classForElement: 'test' - attributes: self attributes) == self elementClass. - self assert: - (mapper - classForElement: 'prefix:test' - attributes: self attributes) == self otherElementClass + self + assert: (mapper classForElement: 'test' attributes: self attributes) + identicalTo: self elementClass. + self + assert: + (mapper classForElement: 'prefix:test' attributes: self attributes) + identicalTo: self otherElementClass ] { #category : #tests } XMLBasicElementClassMapperTest >> testClassForElementAttributesIfNone [ - | mapper | + | mapper | mapper := self newMapper. - self assert: - (mapper - classForElement: 'test' - attributes: self attributes - ifNone: [#none]) == #none. - self assert: - (mapper - classForElement: 'prefix:test' - attributes: self attributes - ifNone: [#none]) == #none. + self + assert: (mapper + classForElement: 'test' + attributes: self attributes + ifNone: [ #none ]) + identicalTo: #none. + self + assert: (mapper + classForElement: 'prefix:test' + attributes: self attributes + ifNone: [ #none ]) + identicalTo: #none. - mapper - mapElement: 'test' - toClass: self otherElementClass. - self assert: - (mapper - classForElement: 'test' - attributes: self attributes - ifNone: [self fail]) == self otherElementClass. - self assert: - (mapper - classForElement: 'prefix:test' - attributes: self attributes - ifNone: [self fail]) == self otherElementClass. + mapper mapElement: 'test' toClass: self otherElementClass. + self + assert: (mapper + classForElement: 'test' + attributes: self attributes + ifNone: [ self fail ]) + identicalTo: self otherElementClass. + self + assert: (mapper + classForElement: 'prefix:test' + attributes: self attributes + ifNone: [ self fail ]) + identicalTo: self otherElementClass. mapper mapElement: 'test' attributeSpec: self attributes asXMLAttributeSpec toClass: self elementClass. - self assert: - (mapper - classForElement: 'test' - attributes: self attributes - ifNone: [self fail]) == self elementClass. - self assert: - (mapper - classForElement: 'prefix:test' - attributes: self attributes - ifNone: [self fail]) == self elementClass. + self + assert: (mapper + classForElement: 'test' + attributes: self attributes + ifNone: [ self fail ]) + identicalTo: self elementClass. + self + assert: (mapper + classForElement: 'prefix:test' + attributes: self attributes + ifNone: [ self fail ]) + identicalTo: self elementClass. mapper mapElement: 'test' namespaceURI: 'testNS' toClass: self otherElementClass. - self assert: - (mapper - classForElement: 'test' - attributes: self attributes - ifNone: [self fail]) == self elementClass. - self assert: - (mapper - classForElement: 'prefix:test' - attributes: self attributes - ifNone: [self fail]) == self elementClass. + self + assert: (mapper + classForElement: 'test' + attributes: self attributes + ifNone: [ self fail ]) + identicalTo: self elementClass. + self + assert: (mapper + classForElement: 'prefix:test' + attributes: self attributes + ifNone: [ self fail ]) + identicalTo: self elementClass. mapper mapElement: 'test' namespaceURI: 'testNS' attributeSpec: self attributes asXMLAttributeSpec toClass: self otherElementClass. - self assert: - (mapper - classForElement: 'test' - attributes: self attributes - ifNone: [self fail]) == self elementClass. - self assert: - (mapper - classForElement: 'prefix:test' - attributes: self attributes - ifNone: [self fail]) == self elementClass. - - "QName mappings should take precedence over NCName mappings" + self + assert: (mapper + classForElement: 'test' + attributes: self attributes + ifNone: [ self fail ]) + identicalTo: self elementClass. + self + assert: (mapper + classForElement: 'prefix:test' + attributes: self attributes + ifNone: [ self fail ]) + identicalTo: self elementClass. mapper mapElement: 'prefix:test' attributeSpec: self attributes asXMLAttributeSpec toClass: self otherElementClass. - self assert: - (mapper - classForElement: 'test' - attributes: self attributes - ifNone: [self fail]) == self elementClass. - self assert: - (mapper - classForElement: 'prefix:test' - attributes: self attributes - ifNone: [self fail]) == self otherElementClass + self + assert: (mapper + classForElement: 'test' + attributes: self attributes + ifNone: [ self fail ]) + identicalTo: self elementClass. + self + assert: (mapper + classForElement: 'prefix:test' + attributes: self attributes + ifNone: [ self fail ]) + identicalTo: self otherElementClass ] { #category : #tests } XMLBasicElementClassMapperTest >> testClassForElementIfNone [ - | mapper | + | mapper | mapper := self newMapper. - self assert: - (mapper - classForElement: 'test' - ifNone: [#none]) == #none. - self assert: - (mapper - classForElement: 'prefix:test' - ifNone: [#none]) == #none. + self + assert: (mapper classForElement: 'test' ifNone: [ #none ]) + identicalTo: #none. + self + assert: (mapper classForElement: 'prefix:test' ifNone: [ #none ]) + identicalTo: #none. - mapper - mapElement: 'test' - toClass: self elementClass. - self assert: - (mapper - classForElement: 'test' - ifNone: [self fail]) == self elementClass. - self assert: - (mapper - classForElement: 'prefix:test' - ifNone: [self fail]) == self elementClass. + mapper mapElement: 'test' toClass: self elementClass. + self + assert: (mapper classForElement: 'test' ifNone: [ self fail ]) + identicalTo: self elementClass. + self + assert: + (mapper classForElement: 'prefix:test' ifNone: [ self fail ]) + identicalTo: self elementClass. mapper mapElement: 'test' attributeSpec: self attributes asXMLAttributeSpec toClass: self otherElementClass. - self assert: - (mapper - classForElement: 'test' - ifNone: [self fail]) == self elementClass. - self assert: - (mapper - classForElement: 'prefix:test' - ifNone: [self fail]) == self elementClass. + self + assert: (mapper classForElement: 'test' ifNone: [ self fail ]) + identicalTo: self elementClass. + self + assert: + (mapper classForElement: 'prefix:test' ifNone: [ self fail ]) + identicalTo: self elementClass. mapper mapElement: 'test' namespaceURI: 'testNS' toClass: self otherElementClass. - self assert: - (mapper - classForElement: 'test' - ifNone: [self fail]) == self elementClass. - self assert: - (mapper - classForElement: 'prefix:test' - ifNone: [self fail]) == self elementClass. + self + assert: (mapper classForElement: 'test' ifNone: [ self fail ]) + identicalTo: self elementClass. + self + assert: + (mapper classForElement: 'prefix:test' ifNone: [ self fail ]) + identicalTo: self elementClass. mapper mapElement: 'test' namespaceURI: 'testNS' attributeSpec: self attributes asXMLAttributeSpec toClass: self otherElementClass. - self assert: - (mapper - classForElement: 'test' - ifNone: [self fail]) == self elementClass. - self assert: - (mapper - classForElement: 'prefix:test' - ifNone: [self fail]) == self elementClass. - - "QName mappings should take precedence over NCName mappings" - mapper - mapElement: 'prefix:test' - toClass: self otherElementClass. - self assert: - (mapper - classForElement: 'test' - ifNone: [self fail]) == self elementClass. - self assert: - (mapper - classForElement: 'prefix:test' - ifNone: [self fail]) == self otherElementClass + self + assert: (mapper classForElement: 'test' ifNone: [ self fail ]) + identicalTo: self elementClass. + self + assert: + (mapper classForElement: 'prefix:test' ifNone: [ self fail ]) + identicalTo: self elementClass. + mapper mapElement: 'prefix:test' toClass: self otherElementClass. + self + assert: (mapper classForElement: 'test' ifNone: [ self fail ]) + identicalTo: self elementClass. + self + assert: + (mapper classForElement: 'prefix:test' ifNone: [ self fail ]) + identicalTo: self otherElementClass ] { #category : #tests } XMLBasicElementClassMapperTest >> testClassForElementNamespaceURI [ - | mapper | + | mapper | mapper := self newMapper. self assert: - (mapper - classForElement: 'test' - namespaceURI: 'testNS') isNil. + (mapper classForElement: 'test' namespaceURI: 'testNS') isNil. self assert: - (mapper - classForElement: 'prefix:test' - namespaceURI: 'testNS') isNil. + (mapper classForElement: 'prefix:test' namespaceURI: 'testNS') isNil. - mapper - mapElement: 'test' - toClass: self otherElementClass. - self assert: - (mapper - classForElement: 'test' - namespaceURI: 'testNS') == self otherElementClass. - self assert: - (mapper - classForElement: 'prefix:test' - namespaceURI: 'testNS') == self otherElementClass. + mapper mapElement: 'test' toClass: self otherElementClass. + self + assert: (mapper classForElement: 'test' namespaceURI: 'testNS') + identicalTo: self otherElementClass. + self + assert: + (mapper classForElement: 'prefix:test' namespaceURI: 'testNS') + identicalTo: self otherElementClass. mapper mapElement: 'test' attributeSpec: self attributes asXMLAttributeSpec toClass: self otherElementClass. - self assert: - (mapper - classForElement: 'test' - namespaceURI: 'testNS') == self otherElementClass. - self assert: - (mapper - classForElement: 'prefix:test' - namespaceURI: 'testNS') == self otherElementClass. + self + assert: (mapper classForElement: 'test' namespaceURI: 'testNS') + identicalTo: self otherElementClass. + self + assert: + (mapper classForElement: 'prefix:test' namespaceURI: 'testNS') + identicalTo: self otherElementClass. mapper mapElement: 'test' namespaceURI: 'testNS' toClass: self elementClass. - self assert: - (mapper - classForElement: 'test' - namespaceURI: 'testNS') == self elementClass. - self assert: - (mapper - classForElement: 'prefix:test' - namespaceURI: 'testNS') == self elementClass. + self + assert: (mapper classForElement: 'test' namespaceURI: 'testNS') + identicalTo: self elementClass. + self + assert: + (mapper classForElement: 'prefix:test' namespaceURI: 'testNS') + identicalTo: self elementClass. mapper mapElement: 'test' namespaceURI: 'testNS' attributeSpec: self attributes asXMLAttributeSpec toClass: self otherElementClass. - self assert: - (mapper - classForElement: 'test' - namespaceURI: 'testNS') == self elementClass. - self assert: - (mapper - classForElement: 'prefix:test' - namespaceURI: 'testNS') == self elementClass. - - "QName mappings should take precedence over NCName mappings" + self + assert: (mapper classForElement: 'test' namespaceURI: 'testNS') + identicalTo: self elementClass. + self + assert: + (mapper classForElement: 'prefix:test' namespaceURI: 'testNS') + identicalTo: self elementClass. mapper mapElement: 'prefix:test' namespaceURI: 'testNS' toClass: self otherElementClass. - self assert: - (mapper - classForElement: 'test' - namespaceURI: 'testNS') == self elementClass. - self assert: - (mapper - classForElement: 'prefix:test' - namespaceURI: 'testNS') == self otherElementClass + self + assert: (mapper classForElement: 'test' namespaceURI: 'testNS') + identicalTo: self elementClass. + self + assert: + (mapper classForElement: 'prefix:test' namespaceURI: 'testNS') + identicalTo: self otherElementClass ] { #category : #tests } XMLBasicElementClassMapperTest >> testClassForElementNamespaceURIAttributes [ - | mapper | + | mapper | mapper := self newMapper. - self assert: - (mapper - classForElement: 'test' - namespaceURI: 'testNS' - attributes: self attributes) isNil. - self assert: - (mapper - classForElement: 'prefix:test' - namespaceURI: 'testNS' - attributes: self attributes) isNil. + self assert: (mapper + classForElement: 'test' + namespaceURI: 'testNS' + attributes: self attributes) isNil. + self assert: (mapper + classForElement: 'prefix:test' + namespaceURI: 'testNS' + attributes: self attributes) isNil. - mapper - mapElement: 'test' - toClass: self otherElementClass. - self assert: - (mapper - classForElement: 'test' - namespaceURI: 'testNS' - attributes: self attributes) == self otherElementClass. - self assert: - (mapper - classForElement: 'prefix:test' - namespaceURI: 'testNS' - attributes: self attributes) == self otherElementClass. + mapper mapElement: 'test' toClass: self otherElementClass. + self + assert: (mapper + classForElement: 'test' + namespaceURI: 'testNS' + attributes: self attributes) + identicalTo: self otherElementClass. + self + assert: (mapper + classForElement: 'prefix:test' + namespaceURI: 'testNS' + attributes: self attributes) + identicalTo: self otherElementClass. mapper mapElement: 'test' attributeSpec: self attributes asXMLAttributeSpec toClass: self otherElementClass. - self assert: - (mapper - classForElement: 'test' - namespaceURI: 'testNS' - attributes: self attributes) == self otherElementClass. - self assert: - (mapper - classForElement: 'prefix:test' - namespaceURI: 'testNS' - attributes: self attributes) == self otherElementClass. + self + assert: (mapper + classForElement: 'test' + namespaceURI: 'testNS' + attributes: self attributes) + identicalTo: self otherElementClass. + self + assert: (mapper + classForElement: 'prefix:test' + namespaceURI: 'testNS' + attributes: self attributes) + identicalTo: self otherElementClass. mapper mapElement: 'test' namespaceURI: 'testNS' toClass: self otherElementClass. - self assert: - (mapper - classForElement: 'test' - namespaceURI: 'testNS' - attributes: self attributes) == self otherElementClass. - self assert: - (mapper - classForElement: 'prefix:test' - namespaceURI: 'testNS' - attributes: self attributes) == self otherElementClass. + self + assert: (mapper + classForElement: 'test' + namespaceURI: 'testNS' + attributes: self attributes) + identicalTo: self otherElementClass. + self + assert: (mapper + classForElement: 'prefix:test' + namespaceURI: 'testNS' + attributes: self attributes) + identicalTo: self otherElementClass. mapper mapElement: 'test' namespaceURI: 'testNS' attributeSpec: self attributes asXMLAttributeSpec toClass: self elementClass. - self assert: - (mapper - classForElement: 'test' - namespaceURI: 'testNS' - attributes: self attributes) == self elementClass. - self assert: - (mapper - classForElement: 'prefix:test' - namespaceURI: 'testNS' - attributes: self attributes) == self elementClass. - - "QName mappings should take precedence over NCName mappings" + self + assert: (mapper + classForElement: 'test' + namespaceURI: 'testNS' + attributes: self attributes) + identicalTo: self elementClass. + self + assert: (mapper + classForElement: 'prefix:test' + namespaceURI: 'testNS' + attributes: self attributes) + identicalTo: self elementClass. mapper mapElement: 'prefix:test' namespaceURI: 'testNS' attributeSpec: self attributes asXMLAttributeSpec toClass: self otherElementClass. - self assert: - (mapper - classForElement: 'test' - namespaceURI: 'testNS' - attributes: self attributes) == self elementClass. - self assert: - (mapper - classForElement: 'prefix:test' - namespaceURI: 'testNS' - attributes: self attributes) == self otherElementClass + self + assert: (mapper + classForElement: 'test' + namespaceURI: 'testNS' + attributes: self attributes) + identicalTo: self elementClass. + self + assert: (mapper + classForElement: 'prefix:test' + namespaceURI: 'testNS' + attributes: self attributes) + identicalTo: self otherElementClass ] { #category : #tests } @@ -1025,44 +1004,44 @@ XMLBasicElementClassMapperTest >> testMapElementNamespaceURIAttributeSpecToClass { #category : #tests } XMLBasicElementClassMapperTest >> testMapElementNamespaceURIToClass [ - | mapper | + | mapper | mapper := self newMapper. - self assert: - (mapper - mapElement: 'test' - namespaceURI: 'testNS' - toClass: self elementClass) == mapper. - self assert: - (mapper - classForElement: 'test' - namespaceURI: 'testNS') == self elementClass. - - self assert: - (mapper - mapElement: 'test' - namespaceURI: 'testNS' - toClass: self otherElementClass) == mapper. - self assert: - (mapper - classForElement: 'test' - namespaceURI: 'testNS') == self otherElementClass + self + assert: (mapper + mapElement: 'test' + namespaceURI: 'testNS' + toClass: self elementClass) + identicalTo: mapper. + self + assert: (mapper classForElement: 'test' namespaceURI: 'testNS') + identicalTo: self elementClass. + self + assert: (mapper + mapElement: 'test' + namespaceURI: 'testNS' + toClass: self otherElementClass) + identicalTo: mapper. + self + assert: (mapper classForElement: 'test' namespaceURI: 'testNS') + identicalTo: self otherElementClass ] { #category : #tests } XMLBasicElementClassMapperTest >> testMapElementToClass [ - | mapper | + | mapper | mapper := self newMapper. - self assert: - (mapper - mapElement: 'test' - toClass: self elementClass) == mapper. - self assert: (mapper classForElement: 'test') == self elementClass. - - self assert: - (mapper - mapElement: 'test' - toClass: self otherElementClass) == mapper. - self assert: (mapper classForElement: 'test') == self otherElementClass + self + assert: (mapper mapElement: 'test' toClass: self elementClass) + identicalTo: mapper. + self + assert: (mapper classForElement: 'test') + identicalTo: self elementClass. + self + assert: (mapper mapElement: 'test' toClass: self otherElementClass) + identicalTo: mapper. + self + assert: (mapper classForElement: 'test') + identicalTo: self otherElementClass ] diff --git a/src/XML-Parser-Tests/XMLCDataTest.class.st b/src/XML-Parser-Tests/XMLCDataTest.class.st index eddb12bd..07fdc84a 100644 --- a/src/XML-Parser-Tests/XMLCDataTest.class.st +++ b/src/XML-Parser-Tests/XMLCDataTest.class.st @@ -11,24 +11,24 @@ XMLCDataTest >> nodeClass [ { #category : #tests } XMLCDataTest >> testAcceptNodeVisitor [ - | visitor cdata message | + | visitor cdata message | visitor := XMLRecordingNodeVisitor new. cdata := self newNode. self - assert: (cdata acceptNodeVisitor: visitor) == cdata; + assert: (cdata acceptNodeVisitor: visitor) identicalTo: cdata; assert: visitor messageRecorder hasMessages. message := visitor messageRecorder nextMessage. self - assert: message selector == #visitCData:; - assert: message arguments = (Array with: cdata); + assert: message selector identicalTo: #visitCData:; + assert: message arguments equals: (Array with: cdata); assert: visitor messageRecorder hasMessages. message := visitor messageRecorder nextMessage. self - assert: message selector == #visitStringNode:; - assert: message arguments = (Array with: cdata); + assert: message selector identicalTo: #visitStringNode:; + assert: message arguments equals: (Array with: cdata); deny: visitor messageRecorder hasMessages ] @@ -39,7 +39,9 @@ XMLCDataTest >> testIsCData [ { #category : #tests } XMLCDataTest >> testWriteXMLOn [ + self - assert: self newNode printString = ''; - assert: (self nodeClass string: self markupString) printString = ('') + assert: self newNode printString equals: ''; + assert: (self nodeClass string: self markupString) printString + equals: '' ] diff --git a/src/XML-Parser-Tests/XMLCachingNodeListTest.class.st b/src/XML-Parser-Tests/XMLCachingNodeListTest.class.st index 09a84f99..9551123f 100644 --- a/src/XML-Parser-Tests/XMLCachingNodeListTest.class.st +++ b/src/XML-Parser-Tests/XMLCachingNodeListTest.class.st @@ -16,30 +16,31 @@ XMLCachingNodeListTest >> listCopyClass [ { #category : #tests } XMLCachingNodeListTest >> testSort [ - | list cachedElements | + | list cachedElements | super testSort. list := self listWithItems. cachedElements := list elements. list sort: self reverseSortBlock. - self assert: list elements = (cachedElements sort: self reverseSortBlock) + self + assert: list elements + equals: (cachedElements sort: self reverseSortBlock) ] { #category : #tests } XMLCachingNodeListTest >> testSwapWith [ - | list cachedElements start end | + | list cachedElements start end | super testSwapWith. list := self listWithItems. cachedElements := list elements. start := 1. end := list size. - [start < end] - whileTrue: [ - list swap: start with: end. - start := start + 1. - end := end - 1]. - self assert: list elements = cachedElements reversed + [ start < end ] whileTrue: [ + list swap: start with: end. + start := start + 1. + end := end - 1 ]. + self assert: list elements equals: cachedElements reversed ] diff --git a/src/XML-Parser-Tests/XMLClassFinderTest.class.st b/src/XML-Parser-Tests/XMLClassFinderTest.class.st index e44dea12..4c18456b 100644 --- a/src/XML-Parser-Tests/XMLClassFinderTest.class.st +++ b/src/XML-Parser-Tests/XMLClassFinderTest.class.st @@ -26,22 +26,27 @@ XMLClassFinderTest >> presentClassName [ { #category : #tests } XMLClassFinderTest >> testClassNamed [ + + self + assert: (self classFinder classNamed: self presentClassName) + identicalTo: self presentClass. self assert: - (self classFinder classNamed: self presentClassName) == - self presentClass. - self assert: (self classFinder classNamed: self absentClassName) isNil + (self classFinder classNamed: self absentClassName) isNil ] { #category : #tests } XMLClassFinderTest >> testClassNamedIfAbsent [ - self assert: - (self classFinder - classNamed: self presentClassName - ifAbsent: [self fail]) == self presentClass. - self assert: - (self classFinder - classNamed: self absentClassName - ifAbsent: [#absent]) equals: #absent + + self + assert: (self classFinder + classNamed: self presentClassName + ifAbsent: [ self fail ]) + identicalTo: self presentClass. + self + assert: (self classFinder + classNamed: self absentClassName + ifAbsent: [ #absent ]) + equals: #absent ] { #category : #tests } diff --git a/src/XML-Parser-Tests/XMLCommentTest.class.st b/src/XML-Parser-Tests/XMLCommentTest.class.st index a71bbae3..1292a500 100644 --- a/src/XML-Parser-Tests/XMLCommentTest.class.st +++ b/src/XML-Parser-Tests/XMLCommentTest.class.st @@ -11,18 +11,18 @@ XMLCommentTest >> nodeClass [ { #category : #tests } XMLCommentTest >> testAcceptNodeVisitor [ - | visitor comment message | + | visitor comment message | visitor := XMLRecordingNodeVisitor new. comment := self newNode. self - assert: (comment acceptNodeVisitor: visitor) == comment; + assert: (comment acceptNodeVisitor: visitor) identicalTo: comment; assert: visitor messageRecorder hasMessages. message := visitor messageRecorder nextMessage. self - assert: message selector == #visitComment:; - assert: message arguments = (Array with: comment); + assert: message selector identicalTo: #visitComment:; + assert: message arguments equals: (Array with: comment); deny: visitor messageRecorder hasMessages ] @@ -44,33 +44,34 @@ XMLCommentTest >> testIsComment [ { #category : #tests } XMLCommentTest >> testSortKey [ - self assert: (self nodeClass string: 'test') sortKey = 'test' + + self assert: (self nodeClass string: 'test') sortKey equals: 'test' ] { #category : #tests } XMLCommentTest >> testString [ - | comment | + | comment | comment := self nodeClass string: self markupString. self - assert: comment class == self nodeClass; - assert: comment string = self markupString. + assert: comment class identicalTo: self nodeClass; + assert: comment string equals: self markupString. comment := self newNode. - self assert: comment string = ''. + self assert: comment string equals: ''. comment string: self markupString. - self assert: comment string = self markupString. + self assert: comment string equals: self markupString. comment string: ''. - self assert: comment string = '' + self assert: comment string equals: '' ] { #category : #tests } XMLCommentTest >> testWriteXMLOn [ + self - assert: self newNode printString = ''; - assert: - (self nodeClass string: self markupString) printString = - ('') + assert: self newNode printString equals: ''; + assert: (self nodeClass string: self markupString) printString + equals: '' ] diff --git a/src/XML-Parser-Tests/XMLConfigurationTest.class.st b/src/XML-Parser-Tests/XMLConfigurationTest.class.st index 510fe50d..95c2704e 100644 --- a/src/XML-Parser-Tests/XMLConfigurationTest.class.st +++ b/src/XML-Parser-Tests/XMLConfigurationTest.class.st @@ -36,8 +36,8 @@ XMLConfigurationTest >> parserHandlerClass [ { #category : #tests } XMLConfigurationTest >> testCopy [ - | configuration externalEntityResolver copy | + | configuration externalEntityResolver copy | externalEntityResolver := self externalEntityResolverClass new. (configuration := self newConfiguration) isValidating: false; @@ -45,220 +45,259 @@ XMLConfigurationTest >> testCopy [ decodesCharacters: false; parserHandlerClass: self otherParserHandlerClass; documentReadLimit: XMLParserLimits defaultDocumentReadLimit - 1; - maxEntityReplacementDepth: XMLParserLimits defaultMaxEntityReplacementDepth - 1; + maxEntityReplacementDepth: + XMLParserLimits defaultMaxEntityReplacementDepth - 1; preservesUndeclaredEntityReferences: true; replacesContentEntityReferences: false; resolvesExternalEntities: true; externalEntityResolver: externalEntityResolver. copy := configuration copy. self - deny: copy == configuration; + deny: copy identicalTo: configuration; assert: copy isValidating equals: configuration isValidating; assert: copy usesNamespaces equals: configuration usesNamespaces; - assert: copy decodesCharacters equals: configuration decodesCharacters; + assert: copy decodesCharacters + equals: configuration decodesCharacters; assert: copy requiresSchema equals: configuration requiresSchema; - assert: copy parserHandlerClass == configuration parserHandlerClass. - + assert: copy parserHandlerClass + identicalTo: configuration parserHandlerClass. self - deny: copy parserLimits == configuration parserLimits; - assert: copy documentReadLimit equals: configuration documentReadLimit; - assert: copy maxEntityReplacementDepth equals: configuration maxEntityReplacementDepth. - + deny: copy parserLimits identicalTo: configuration parserLimits; + assert: copy documentReadLimit + equals: configuration documentReadLimit; + assert: copy maxEntityReplacementDepth + equals: configuration maxEntityReplacementDepth. self - deny: copy entityConfiguration == configuration entityConfiguration; - assert: copy preservesUndeclaredEntityReferences equals: configuration preservesUndeclaredEntityReferences; - assert: copy replacesContentEntityReferences equals: configuration replacesContentEntityReferences; - assert: copy resolvesExternalEntities equals: configuration resolvesExternalEntities; - deny: copy externalEntityResolver == configuration externalEntityResolver; - assert: copy externalEntityResolver class == configuration externalEntityResolver class + deny: copy entityConfiguration + identicalTo: configuration entityConfiguration; + assert: copy preservesUndeclaredEntityReferences + equals: configuration preservesUndeclaredEntityReferences; + assert: copy replacesContentEntityReferences + equals: configuration replacesContentEntityReferences; + assert: copy resolvesExternalEntities + equals: configuration resolvesExternalEntities; + deny: copy externalEntityResolver + identicalTo: configuration externalEntityResolver; + assert: copy externalEntityResolver class + identicalTo: configuration externalEntityResolver class ] { #category : #tests } XMLConfigurationTest >> testDecodesCharacters [ - | configuration | + | configuration | configuration := self newConfiguration. self assert: configuration decodesCharacters; - assert: (configuration decodesCharacters: false) == configuration; + assert: (configuration decodesCharacters: false) + identicalTo: configuration; deny: configuration decodesCharacters; - assert: (configuration decodesCharacters: true) == configuration; + assert: (configuration decodesCharacters: true) + identicalTo: configuration; assert: configuration decodesCharacters ] { #category : #tests } XMLConfigurationTest >> testDocumentReadLimit [ - | configuration | + | configuration | configuration := self newConfiguration. self - assert: configuration documentReadLimit = XMLParserLimits defaultDocumentReadLimit; - assert: (configuration documentReadLimit: 100000) == configuration; - assert: configuration documentReadLimit = 100000; - assert: (configuration documentReadLimit: nil) == configuration; + assert: configuration documentReadLimit + equals: XMLParserLimits defaultDocumentReadLimit; + assert: (configuration documentReadLimit: 100000) + identicalTo: configuration; + assert: configuration documentReadLimit equals: 100000; + assert: (configuration documentReadLimit: nil) + identicalTo: configuration; assert: configuration documentReadLimit isNil ] { #category : #tests } XMLConfigurationTest >> testEntityConfiguration [ - | configuration newEntityConfiguration | + | configuration newEntityConfiguration | configuration := self newConfiguration. - self assert: configuration entityConfiguration class == DTDEntityConfiguration. + self + assert: configuration entityConfiguration class + identicalTo: DTDEntityConfiguration. newEntityConfiguration := DTDEntityConfiguration new. - self assert: - (configuration entityConfiguration: newEntityConfiguration) == - configuration. - self assert: configuration entityConfiguration == newEntityConfiguration + self + assert: (configuration entityConfiguration: newEntityConfiguration) + identicalTo: configuration. + self + assert: configuration entityConfiguration + identicalTo: newEntityConfiguration ] { #category : #tests } XMLConfigurationTest >> testExternalEntityResolver [ - | configuration oldResolver newResolver | + | configuration oldResolver newResolver | configuration := self newConfiguration. oldResolver := configuration externalEntityResolver. - self assert: oldResolver class == self externalEntityResolverClass. + self + assert: oldResolver class + identicalTo: self externalEntityResolverClass. newResolver := self externalEntityResolverClass new. self - assert: (configuration externalEntityResolver: newResolver) == configuration; - assert: configuration externalEntityResolver == newResolver + assert: (configuration externalEntityResolver: newResolver) + identicalTo: configuration; + assert: configuration externalEntityResolver + identicalTo: newResolver ] { #category : #tests } XMLConfigurationTest >> testIsValidating [ - | configuration | + | configuration | configuration := self newConfiguration. self assert: configuration isValidating; - assert: (configuration isValidating: false) == configuration; + assert: (configuration isValidating: false) + identicalTo: configuration; deny: configuration isValidating; - assert: (configuration isValidating: true) == configuration; + assert: (configuration isValidating: true) + identicalTo: configuration; assert: configuration isValidating ] { #category : #tests } XMLConfigurationTest >> testMaxEntityReplacementDepth [ - | configuration | + | configuration | configuration := self newConfiguration. - self assert: - configuration maxEntityReplacementDepth equals: - XMLParserLimits defaultMaxEntityReplacementDepth. self - assert: (configuration maxEntityReplacementDepth: 20) == configuration; + assert: configuration maxEntityReplacementDepth + equals: XMLParserLimits defaultMaxEntityReplacementDepth. + self + assert: (configuration maxEntityReplacementDepth: 20) + identicalTo: configuration; assert: configuration maxEntityReplacementDepth equals: 20; - assert: (configuration maxEntityReplacementDepth: nil) == configuration; + assert: (configuration maxEntityReplacementDepth: nil) + identicalTo: configuration; assert: configuration maxEntityReplacementDepth isNil ] { #category : #tests } XMLConfigurationTest >> testParserHandlerClass [ - | configuration | + | configuration | configuration := self newConfiguration. - self assert: configuration parserHandlerClass == self parserHandlerClass. - self assert: - (configuration parserHandlerClass: self otherParserHandlerClass) == - configuration. - self assert: configuration parserHandlerClass == self otherParserHandlerClass + self + assert: configuration parserHandlerClass + identicalTo: self parserHandlerClass. + self + assert: + (configuration parserHandlerClass: self otherParserHandlerClass) + identicalTo: configuration. + self + assert: configuration parserHandlerClass + identicalTo: self otherParserHandlerClass ] { #category : #tests } XMLConfigurationTest >> testParserLimits [ - | configuration newParserLimits | + | configuration newParserLimits | configuration := self newConfiguration. - self assert: configuration parserLimits class == XMLParserLimits. + self + assert: configuration parserLimits class + identicalTo: XMLParserLimits. newParserLimits := XMLParserLimits new. self - assert: (configuration parserLimits: newParserLimits) == configuration; - assert: configuration parserLimits == newParserLimits + assert: (configuration parserLimits: newParserLimits) + identicalTo: configuration; + assert: configuration parserLimits identicalTo: newParserLimits ] { #category : #tests } XMLConfigurationTest >> testPreservesUndeclaredEntityReferences [ - | configuration | + | configuration | configuration := self newConfiguration. self deny: configuration preservesUndeclaredEntityReferences. "enabling should disable validation" - self assert: - (configuration preservesUndeclaredEntityReferences: true) == - configuration. + self + assert: (configuration preservesUndeclaredEntityReferences: true) + identicalTo: configuration. self assert: configuration preservesUndeclaredEntityReferences; deny: configuration isValidating. - self - assert: (configuration isValidating: true) == configuration; + assert: (configuration isValidating: true) + identicalTo: configuration; assert: configuration isValidating; deny: configuration preservesUndeclaredEntityReferences ] { #category : #tests } XMLConfigurationTest >> testReplacesContentEntityReferences [ - | configuration | + | configuration | configuration := self newConfiguration. self assert: configuration replacesContentEntityReferences. - self assert: - (configuration replacesContentEntityReferences: false) == - configuration. + self + assert: (configuration replacesContentEntityReferences: false) + identicalTo: configuration. self deny: configuration replacesContentEntityReferences. - self assert: - (configuration replacesContentEntityReferences: true) == - configuration. + self + assert: (configuration replacesContentEntityReferences: true) + identicalTo: configuration. self assert: configuration replacesContentEntityReferences ] { #category : #tests } XMLConfigurationTest >> testRequiresSchema [ - | configuration | + | configuration | (configuration := self newConfiguration) isValidating: false. self deny: configuration requiresSchema. "enabling should force validation" self - assert: (configuration requiresSchema: true) == configuration; + assert: (configuration requiresSchema: true) + identicalTo: configuration; assert: configuration requiresSchema; assert: configuration isValidating. - self - assert: (configuration isValidating: false) == configuration; + assert: (configuration isValidating: false) + identicalTo: configuration; deny: configuration isValidating; deny: configuration requiresSchema ] { #category : #tests } XMLConfigurationTest >> testResolvesExternalEntities [ - | configuration | + | configuration | configuration := self newConfiguration. "should not resolve external entities by default for security" self deny: configuration resolvesExternalEntities; - assert: (configuration resolvesExternalEntities: true) == configuration; + assert: (configuration resolvesExternalEntities: true) + identicalTo: configuration; assert: configuration resolvesExternalEntities; - assert: (configuration resolvesExternalEntities: false) == configuration; + assert: (configuration resolvesExternalEntities: false) + identicalTo: configuration; deny: configuration resolvesExternalEntities ] { #category : #tests } XMLConfigurationTest >> testUsesNamespaces [ - | configuration | + | configuration | configuration := self newConfiguration. self assert: configuration usesNamespaces; - assert: (configuration usesNamespaces: false) == configuration; + assert: (configuration usesNamespaces: false) + identicalTo: configuration; deny: configuration usesNamespaces; - assert: (configuration usesNamespaces: true) == configuration; + assert: (configuration usesNamespaces: true) + identicalTo: configuration; assert: configuration usesNamespaces ] diff --git a/src/XML-Parser-Tests/XMLDOMConfigurationTest.class.st b/src/XML-Parser-Tests/XMLDOMConfigurationTest.class.st index a9ad4093..0f725647 100644 --- a/src/XML-Parser-Tests/XMLDOMConfigurationTest.class.st +++ b/src/XML-Parser-Tests/XMLDOMConfigurationTest.class.st @@ -21,8 +21,8 @@ XMLDOMConfigurationTest >> parserHandlerClass [ { #category : #tests } XMLDOMConfigurationTest >> testCopy [ - | configuration nodeFactory copy | + | configuration nodeFactory copy | super testCopy. nodeFactory := self nodeFactoryClass new. @@ -33,69 +33,80 @@ XMLDOMConfigurationTest >> testCopy [ nodeFactory: nodeFactory. copy := configuration copy. self - assert: copy preservesCDataNodes equals: configuration preservesCDataNodes; - assert: copy preservesCommentNodes equals: configuration preservesCommentNodes; - assert: copy preservesIgnorableWhitespace equals: configuration preservesIgnorableWhitespace; - deny: copy nodeFactory == configuration nodeFactory; - assert: copy nodeFactory class equals: configuration nodeFactory class + assert: copy preservesCDataNodes + equals: configuration preservesCDataNodes; + assert: copy preservesCommentNodes + equals: configuration preservesCommentNodes; + assert: copy preservesIgnorableWhitespace + equals: configuration preservesIgnorableWhitespace; + deny: copy nodeFactory identicalTo: configuration nodeFactory; + assert: copy nodeFactory class + equals: configuration nodeFactory class ] { #category : #tests } XMLDOMConfigurationTest >> testNodeFactory [ - | configuration oldNodeFactory newNodeFactory | + | configuration oldNodeFactory newNodeFactory | configuration := self newConfiguration. oldNodeFactory := configuration nodeFactory. - self assert: oldNodeFactory class == self nodeFactoryClass. + self assert: oldNodeFactory class identicalTo: self nodeFactoryClass. newNodeFactory := self nodeFactoryClass new. self - assert: (configuration nodeFactory: newNodeFactory) == configuration; - assert: configuration nodeFactory == newNodeFactory + assert: (configuration nodeFactory: newNodeFactory) + identicalTo: configuration; + assert: configuration nodeFactory identicalTo: newNodeFactory ] { #category : #tests } XMLDOMConfigurationTest >> testPreservesCDataNodes [ - | configuration | + | configuration | configuration := self newConfiguration. self deny: configuration preservesCDataNodes; - assert: (configuration preservesCDataNodes: true) == configuration; + assert: (configuration preservesCDataNodes: true) + identicalTo: configuration; assert: configuration preservesCDataNodes; - assert: (configuration preservesCDataNodes: false) == configuration; + assert: (configuration preservesCDataNodes: false) + identicalTo: configuration; deny: configuration preservesCDataNodes ] { #category : #tests } XMLDOMConfigurationTest >> testPreservesCommentNodes [ - | configuration | + | configuration | configuration := self newConfiguration. self deny: configuration preservesCommentNodes; - assert: (configuration preservesCommentNodes: true) == configuration; + assert: (configuration preservesCommentNodes: true) + identicalTo: configuration; assert: configuration preservesCommentNodes; - assert: (configuration preservesCommentNodes: false) == configuration; + assert: (configuration preservesCommentNodes: false) + identicalTo: configuration; deny: configuration preservesCommentNodes ] { #category : #tests } XMLDOMConfigurationTest >> testPreservesIgnorableWhitespace [ - | configuration | + | configuration | configuration := self newConfiguration. configuration isValidating: false. "should enable validation" self deny: configuration preservesIgnorableWhitespace; - assert: (configuration preservesIgnorableWhitespace: true) == configuration; + assert: (configuration preservesIgnorableWhitespace: true) + identicalTo: configuration; assert: configuration preservesIgnorableWhitespace; assert: configuration isValidating. "disabling validation should disable it" self - assert: (configuration isValidating: false) == configuration; + assert: (configuration isValidating: false) + identicalTo: configuration; deny: configuration preservesIgnorableWhitespace; deny: configuration isValidating ] diff --git a/src/XML-Parser-Tests/XMLDOMParserTest.class.st b/src/XML-Parser-Tests/XMLDOMParserTest.class.st index d9f7d362..09ef3ad4 100644 --- a/src/XML-Parser-Tests/XMLDOMParserTest.class.st +++ b/src/XML-Parser-Tests/XMLDOMParserTest.class.st @@ -54,16 +54,18 @@ XMLDOMParserTest >> testAllElementsNamespaceURIs [ { #category : #tests } XMLDOMParserTest >> testAttributeListClass [ - (Array - with: XMLAttributeList - with: XMLCachingAttributeList) - do: [:listClass | | document parser | - parser := XMLDOMParser on: self addressBookXML. - parser configuration attributeListClass: listClass. - document := parser parseDocument. - self assert: parser configuration attributeListClass == listClass. - document allElements do: [:each | - self assert: each attributeNodes class == listClass]] + + (Array with: XMLAttributeList with: XMLCachingAttributeList) do: [ + :listClass | + | document parser | + parser := XMLDOMParser on: self addressBookXML. + parser configuration attributeListClass: listClass. + document := parser parseDocument. + self + assert: parser configuration attributeListClass + identicalTo: listClass. + document allElements do: [ :each | + self assert: each attributeNodes class identicalTo: listClass ] ] ] { #category : #tests } @@ -105,14 +107,14 @@ XMLDOMParserTest >> testAttributeNamespacesDisabled [ { #category : #tests } XMLDOMParserTest >> testAttributeParent [ - (XMLDOMParser parse: self addressBookXML) allElementsDo: [:element | - element hasAttributes - ifTrue: [ - element attributeNodesDo: [:each | - self - assert: each hasParent; - assert: each parent == element; - assert: each element == element]]] + + (XMLDOMParser parse: self addressBookXML) allElementsDo: [ :element | + element hasAttributes ifTrue: [ + element attributeNodesDo: [ :each | + self + assert: each hasParent; + assert: each parent identicalTo: element; + assert: each element identicalTo: element ] ] ] ] { #category : #tests } @@ -222,17 +224,23 @@ XMLDOMParserTest >> testCDataSectionEntityReplacement [ { #category : #tests } XMLDOMParserTest >> testChangingNamespaces [ - | document people person | + | document people person | document := XMLDOMParser parse: self addressBookNamespacedXML. - people := document allElementsNamed: 'person' namespaceURI: 'defaultNS'. + people := document + allElementsNamed: 'person' + namespaceURI: 'defaultNS'. (person := people third) prefix: 'ps'. - self assert: person == (document findElementNamed: 'person' namespaceURI: 'personNS'). - self assert: - (people copyWithout: person) equals: - ((document findElementNamed: 'addressbook') nodesSelect: [:each | - each isElement and: [each namespaceURI = 'defaultNS']]) + self + assert: person + identicalTo: + (document findElementNamed: 'person' namespaceURI: 'personNS'). + self + assert: (people copyWithout: person) + equals: + ((document findElementNamed: 'addressbook') nodesSelect: [ :each | + each isElement and: [ each namespaceURI = 'defaultNS' ] ]) ] { #category : #tests } @@ -293,42 +301,42 @@ XMLDOMParserTest >> testDoctypeDeclaration [ { #category : #tests } XMLDOMParserTest >> testDocument [ - | parser document root | + | parser document root | parser := XMLDOMParser on: self addressBookXML. self assert: parser document isNil. document := parser parseDocument. - self assert: parser document == document. + self assert: parser document identicalTo: document. parser on: self addressBookXML. self assert: parser document isNil. - document allNodesDo: [:each | - self assert: each document == document]. + document allNodesDo: [ :each | + self assert: each document identicalTo: document ]. root := document root. root innerXML: self addressBookXML. - document allNodesDo: [:each | - self assert: each document == document]. + document allNodesDo: [ :each | + self assert: each document identicalTo: document ]. document removeNode: root. - root allNodesDo: [:each | - self assert: each document isNil] + root allNodesDo: [ :each | self assert: each document isNil ] ] { #category : #tests } XMLDOMParserTest >> testDocumentInternalSubset [ - | document doctypeDeclaration | - document := XMLDOMParser parse: self internalSubsetXMLWithDeclarations. + | document doctypeDeclaration | + document := XMLDOMParser parse: + self internalSubsetXMLWithDeclarations. doctypeDeclaration := document doctypeDeclaration. - doctypeDeclaration allNodesDo: [:each | - self assert: each document == document]. + doctypeDeclaration allNodesDo: [ :each | + self assert: each document identicalTo: document ]. document doctypeDeclaration: nil. - doctypeDeclaration allNodesDo: [:each | - self assert: each document isNil] + doctypeDeclaration allNodesDo: [ :each | + self assert: each document isNil ] ] { #category : #tests } @@ -406,21 +414,25 @@ XMLDOMParserTest >> testElementPrefixesNamespacesDisabled [ { #category : #tests } XMLDOMParserTest >> testFindElementNamespaceURI [ - | document people | + | document people | document := XMLDOMParser parse: self addressBookNamespacedXML. - people := document allElementsNamed: 'person' namespaceURI: 'defaultNS'. - self assert: - (document - findElementNamed: 'person' - namespaceURI: 'defaultNS' - with: [:each | (each attributeAt: 'employee-number') = 'A7987']) == people last. - self assert: - (document - findElementNamed: 'person' - namespaceURI: 'defaultNS' - with: [:each | (each attributeAt: 'family-name') = 'Brown']) == people second. + people := document + allElementsNamed: 'person' + namespaceURI: 'defaultNS'. + self + assert: (document + findElementNamed: 'person' + namespaceURI: 'defaultNS' + with: [ :each | (each attributeAt: 'employee-number') = 'A7987' ]) + identicalTo: people last. + self + assert: (document + findElementNamed: 'person' + namespaceURI: 'defaultNS' + with: [ :each | (each attributeAt: 'family-name') = 'Brown' ]) + identicalTo: people second ] { #category : #tests } @@ -762,24 +774,22 @@ XMLDOMParserTest >> testNamespacesDisabledAttributes [ { #category : #tests } XMLDOMParserTest >> testNamespacesDisabledReuse [ - | parser document oldRootScope newRootScope | + | parser document oldRootScope newRootScope | parser := XMLDOMParser on: self addressBookNamespacedXML. - document := - parser - usesNamespaces: true; - parseDocument. + document := parser + usesNamespaces: true; + parseDocument. oldRootScope := document root namespaceScope. self assert: oldRootScope hasNamespaces. - document := - parser - on: self addressBookNamespacedXML; - usesNamespaces: false; - parseDocument. + document := parser + on: self addressBookNamespacedXML; + usesNamespaces: false; + parseDocument. newRootScope := document root namespaceScope. self - deny: newRootScope = oldRootScope; + deny: newRootScope equals: oldRootScope; deny: newRootScope hasNamespaces. self @@ -787,17 +797,17 @@ XMLDOMParserTest >> testNamespacesDisabledReuse [ parser on: ''; usesNamespaces: true; - parseDocument] + parseDocument ] raise: XMLNamespaceException. self shouldnt: [ - document := - parser - on: ''; - usesNamespaces: false; - parseDocument] + document := parser + on: + ''; + usesNamespaces: false; + parseDocument ] raise: XMLNamespaceException. - self deny: document root hasNamespaces. + self deny: document root hasNamespaces ] { #category : #tests } @@ -841,58 +851,62 @@ XMLDOMParserTest >> testNamespacesResolvingDisabled [ { #category : #tests } XMLDOMParserTest >> testNodeDetecting [ - | document people | + | document people | document := XMLDOMParser parse: self addressBookXML. people := document root elementsAt: 'person'. - self assert: - ((document findElementNamed: 'addressbook') nodesDetect: [:each | - each isElement and: [(each attributeAt: 'family-name') = 'Brown']]) == people second. - self assert: - ((document findElementNamed: 'addressbook') - nodesDetect: [:each | each isElement and: [(each attributeAt: 'unknown') = 'Brown']] - ifNone: ['not found']) equals: 'not found'. + self + assert: + ((document findElementNamed: 'addressbook') nodesDetect: [ :each | + each isElement and: [ + (each attributeAt: 'family-name') = 'Brown' ] ]) + identicalTo: people second. + self + assert: ((document findElementNamed: 'addressbook') + nodesDetect: [ :each | + each isElement and: [ (each attributeAt: 'unknown') = 'Brown' ] ] + ifNone: [ 'not found' ]) + equals: 'not found' ] { #category : #tests } XMLDOMParserTest >> testNodeFactory [ - | parser oldNodeFactory newNodeFactory | + | parser oldNodeFactory newNodeFactory | parser := XMLDOMParser on: self addressBookXML. oldNodeFactory := parser nodeFactory. - self assert: oldNodeFactory class == self nodeFactoryClass. + self assert: oldNodeFactory class identicalTo: self nodeFactoryClass. newNodeFactory := self nodeFactoryClass new. self - assert: (parser nodeFactory: newNodeFactory) == parser; - assert: parser nodeFactory == newNodeFactory. + assert: (parser nodeFactory: newNodeFactory) identicalTo: parser; + assert: parser nodeFactory identicalTo: newNodeFactory ] { #category : #tests } XMLDOMParserTest >> testNodeListClass [ - (Array - with: XMLNodeList - with: XMLCachingNodeList) - do: [:listClass | | document parser | - parser := XMLDOMParser on: self addressBookXML. - parser configuration nodeListClass: listClass. - document := parser parseDocument. - self - assert: parser configuration nodeListClass == listClass; - assert: document nodes class == listClass. - document allElements do: [:each | - self assert: each nodes class == listClass]] + + (Array with: XMLNodeList with: XMLCachingNodeList) do: [ :listClass | + | document parser | + parser := XMLDOMParser on: self addressBookXML. + parser configuration nodeListClass: listClass. + document := parser parseDocument. + self + assert: parser configuration nodeListClass identicalTo: listClass; + assert: document nodes class identicalTo: listClass. + document allElements do: [ :each | + self assert: each nodes class identicalTo: listClass ] ] ] { #category : #tests } XMLDOMParserTest >> testNodeParent [ - (XMLDOMParser parse: self addressBookXML) allNodesDo: [:node | - node hasChildren - ifTrue: [ - node nodesDo: [:each | - self - assert: each hasParent; - assert: each parent == node]]] + + (XMLDOMParser parse: self addressBookXML) allNodesDo: [ :node | + node hasChildren ifTrue: [ + node nodesDo: [ :each | + self + assert: each hasParent; + assert: each parent identicalTo: node ] ] ] ] { #category : #tests } @@ -912,8 +926,8 @@ XMLDOMParserTest >> testNodeStack [ { #category : #tests } XMLDOMParserTest >> testOptimizeForLargeDocuments [ - | parser | + | parser | parser := XMLDOMParser on: ''. parser optimizeForLargeDocuments. @@ -921,7 +935,8 @@ XMLDOMParserTest >> testOptimizeForLargeDocuments [ deny: parser isValidating; deny: parser usesNamespaces; assert: parser documentReadLimit isNil; - assert: parser nodeFactory attributeListClass == XMLAttributeList. + assert: parser nodeFactory attributeListClass + identicalTo: XMLAttributeList ] { #category : #tests } @@ -1001,46 +1016,47 @@ XMLDOMParserTest >> testParsedElementNames [ { #category : #tests } XMLDOMParserTest >> testPreservesCDataNodes [ - | parser | + | parser | parser := XMLDOMParser on: self addressBookXML. self deny: parser preservesCDataNodes; - assert: (parser preservesCDataNodes: true) == parser; + assert: (parser preservesCDataNodes: true) identicalTo: parser; assert: parser preservesCDataNodes; - assert: (parser preservesCDataNodes: false) == parser; - deny: parser preservesCDataNodes. + assert: (parser preservesCDataNodes: false) identicalTo: parser; + deny: parser preservesCDataNodes ] { #category : #tests } XMLDOMParserTest >> testPreservesCommentNodes [ - | parser | + | parser | parser := XMLDOMParser on: self addressBookXML. self deny: parser preservesCommentNodes; - assert: (parser preservesCommentNodes: true) == parser; + assert: (parser preservesCommentNodes: true) identicalTo: parser; assert: parser preservesCommentNodes; - assert: (parser preservesCommentNodes: false) == parser; - deny: parser preservesCommentNodes. + assert: (parser preservesCommentNodes: false) identicalTo: parser; + deny: parser preservesCommentNodes ] { #category : #tests } XMLDOMParserTest >> testPreservesIgnorableWhitespace [ - | parser | + | parser | parser := XMLDOMParser on: self addressBookXML. parser isValidating: false. "should enable validation" self deny: parser preservesIgnorableWhitespace; - assert: (parser preservesIgnorableWhitespace: true) == parser; + assert: (parser preservesIgnorableWhitespace: true) + identicalTo: parser; assert: parser preservesIgnorableWhitespace; assert: parser isValidating. "disabling validation should disable it" self - assert: (parser isValidating: false) == parser; + assert: (parser isValidating: false) identicalTo: parser; deny: parser preservesIgnorableWhitespace; deny: parser isValidating ] @@ -1099,18 +1115,18 @@ XMLDOMParserTest >> testProcessingInstructionEntityReplacement [ { #category : #tests } XMLDOMParserTest >> testRootElement [ - | document root | + | document root | document := XMLDOMParser parse: self addressBookXML. - self assert: document class == XMLDocument. + self assert: document class identicalTo: XMLDocument. root := document root. - self assert: (root class == XMLElement). - - self assert: - (root allNodesDetect: [:each | - each isElement - and: [each isNamedAny: #('AddressBook' 'addressbook')]]) == root. - self assert: (root findElementNamed: 'addressbook') == root. + self assert: root class identicalTo: XMLElement. + self + assert: (root allNodesDetect: [ :each | + each isElement and: [ + each isNamedAny: #( 'AddressBook' 'addressbook' ) ] ]) + identicalTo: root. + self assert: (root findElementNamed: 'addressbook') identicalTo: root ] { #category : #tests } diff --git a/src/XML-Parser-Tests/XMLDecodingReadStreamAdapterTest.class.st b/src/XML-Parser-Tests/XMLDecodingReadStreamAdapterTest.class.st index 34f81106..fbfef22b 100644 --- a/src/XML-Parser-Tests/XMLDecodingReadStreamAdapterTest.class.st +++ b/src/XML-Parser-Tests/XMLDecodingReadStreamAdapterTest.class.st @@ -118,17 +118,19 @@ XMLDecodingReadStreamAdapterTest >> testNonDecodingOn [ { #category : #tests } XMLDecodingReadStreamAdapterTest >> testNonDecodingOnIfBinaryOrExternal [ - | basicInputCollection adapter stream | + | basicInputCollection adapter stream | basicInputCollection := self basicInputCollection. stream := self newStreamOn: (self binaryFrom: basicInputCollection). - adapter := self streamAdapterClass nonDecodingOnIfBinaryOrExternal: stream. + adapter := self streamAdapterClass nonDecodingOnIfBinaryOrExternal: + stream. self - assert: adapter class == self streamAdapterClass; + assert: adapter class identicalTo: self streamAdapterClass; assert: adapter hasNullStreamConverter. stream := self newStreamOn: (self stringFrom: basicInputCollection). - adapter := self streamAdapterClass nonDecodingOnIfBinaryOrExternal: stream. + adapter := self streamAdapterClass nonDecodingOnIfBinaryOrExternal: + stream. self assert: adapter isNil ] diff --git a/src/XML-Parser-Tests/XMLDoctypeDeclarationTest.class.st b/src/XML-Parser-Tests/XMLDoctypeDeclarationTest.class.st index a2462f02..6caa51f4 100644 --- a/src/XML-Parser-Tests/XMLDoctypeDeclarationTest.class.st +++ b/src/XML-Parser-Tests/XMLDoctypeDeclarationTest.class.st @@ -50,23 +50,25 @@ XMLDoctypeDeclarationTest >> selectListClass [ { #category : #tests } XMLDoctypeDeclarationTest >> testAllNodes [ - | nodeWithNodes allNodes | + | nodeWithNodes allNodes | nodeWithNodes := self newNodeWithNodes. allNodes := nodeWithNodes allNodes. self - assert: allNodes size = 9; - assert: allNodes first == nodeWithNodes; + assert: allNodes size equals: 9; + assert: allNodes first identicalTo: nodeWithNodes; assert: allNodes second isComment; - assert: allNodes second string = 'before'; - assert: allNodes third class == XMLGeneralEntityDeclaration; - assert: allNodes fourth class == XMLParameterEntityDeclaration; - assert: allNodes fifth class == XMLElementDeclaration; - assert: allNodes sixth class == XMLAttributeDeclaration; - assert: allNodes seventh class == XMLNotationDeclaration; + assert: allNodes second string equals: 'before'; + assert: allNodes third class + identicalTo: XMLGeneralEntityDeclaration; + assert: allNodes fourth class + identicalTo: XMLParameterEntityDeclaration; + assert: allNodes fifth class identicalTo: XMLElementDeclaration; + assert: allNodes sixth class identicalTo: XMLAttributeDeclaration; + assert: allNodes seventh class identicalTo: XMLNotationDeclaration; assert: allNodes eighth isPI; assert: allNodes ninth isComment; - assert: allNodes ninth string = 'after' + assert: allNodes ninth string equals: 'after' ] { #category : #tests } @@ -79,73 +81,80 @@ XMLDoctypeDeclarationTest >> testCanonicallyEquals [ { #category : #tests } XMLDoctypeDeclarationTest >> testPublicID [ - | doctype | + | doctype | doctype := self newNode. self - assert: doctype publicID = ''; - assert: (doctype publicID: 'test') == doctype; - assert: doctype publicID = 'test' + assert: doctype publicID equals: ''; + assert: (doctype publicID: 'test') identicalTo: doctype; + assert: doctype publicID equals: 'test' ] { #category : #tests } XMLDoctypeDeclarationTest >> testRoot [ - | doctype | + | doctype | doctype := self newNode. self - assert: doctype root = ''; - assert: (doctype root: 'test') == doctype; - assert: doctype root = 'test' + assert: doctype root equals: ''; + assert: (doctype root: 'test') identicalTo: doctype; + assert: doctype root equals: 'test' ] { #category : #tests } XMLDoctypeDeclarationTest >> testRootPublicIDSystemID [ - | doctype | - doctype := - self nodeClass - root: 'one' - publicID: 'two' - systemID: 'three'. + | doctype | + doctype := self nodeClass + root: 'one' + publicID: 'two' + systemID: 'three'. self - assert: doctype class == self nodeClass; - assert: doctype root = 'one'; - assert: doctype publicID = 'two'; - assert: doctype systemID = 'three' + assert: doctype class identicalTo: self nodeClass; + assert: doctype root equals: 'one'; + assert: doctype publicID equals: 'two'; + assert: doctype systemID equals: 'three' ] { #category : #tests } XMLDoctypeDeclarationTest >> testSystemID [ - | doctype | + | doctype | doctype := self newNode. self - assert: doctype systemID = ''; - assert: (doctype systemID: 'test') == doctype; - assert: doctype systemID = 'test' + assert: doctype systemID equals: ''; + assert: (doctype systemID: 'test') identicalTo: doctype; + assert: doctype systemID equals: 'test' ] { #category : #tests } XMLDoctypeDeclarationTest >> testWriteXMLOn [ - | doctype elementDeclaration | + | doctype elementDeclaration | doctype := self newNode. - self assert: doctype printString = ''. + self assert: doctype printString equals: ''. doctype root: 'one'. - self assert: doctype printString = ''. + self assert: doctype printString equals: ''. doctype publicID: 'two'. - self assert: doctype printString = ''. + self + assert: doctype printString + equals: ''. doctype systemID: 'three'. - self assert: doctype printString = ''. + self + assert: doctype printString + equals: ''. - elementDeclaration := XMLElementDeclaration element: 'four' contentModel: '(five|six)'. + elementDeclaration := XMLElementDeclaration + element: 'four' + contentModel: '(five|six)'. doctype addNode: elementDeclaration. - self assert: - doctype printString = - (''). - - self assert: - (self nodeClass root: 'one' publicID: '' systemID: 'two') printString = - '' + self + assert: doctype printString + equals: ''. + self + assert: + (self nodeClass root: 'one' publicID: '' systemID: 'two') + printString + equals: '' ] diff --git a/src/XML-Parser-Tests/XMLDocumentTest.class.st b/src/XML-Parser-Tests/XMLDocumentTest.class.st index 208962d9..fbfa84fb 100644 --- a/src/XML-Parser-Tests/XMLDocumentTest.class.st +++ b/src/XML-Parser-Tests/XMLDocumentTest.class.st @@ -23,24 +23,24 @@ XMLDocumentTest >> nodeClass [ { #category : #tests } XMLDocumentTest >> testAcceptNodeVisitor [ - | visitor document message | + | visitor document message | visitor := XMLRecordingNodeVisitor new. document := self newNode. self - assert: (document acceptNodeVisitor: visitor) == document; + assert: (document acceptNodeVisitor: visitor) identicalTo: document; assert: visitor messageRecorder hasMessages. message := visitor messageRecorder nextMessage. self - assert: message selector == #visitDocument:; - assert: message arguments = (Array with: document); + assert: message selector identicalTo: #visitDocument:; + assert: message arguments equals: (Array with: document); assert: visitor messageRecorder hasMessages. message := visitor messageRecorder nextMessage. self - assert: message selector == #visitNodeWithElements:; - assert: message arguments = (Array with: document); + assert: message selector identicalTo: #visitNodeWithElements:; + assert: message arguments equals: (Array with: document); deny: visitor messageRecorder hasMessages. super testAcceptNodeVisitor @@ -48,26 +48,29 @@ XMLDocumentTest >> testAcceptNodeVisitor [ { #category : #tests } XMLDocumentTest >> testDoctypeDeclaration [ - | document doctypeDeclaration newDocument | + | document doctypeDeclaration newDocument | document := self newNode. self assert: document doctypeDeclaration isNil. doctypeDeclaration := XMLDoctypeDeclaration new. self - assert: (document doctypeDeclaration: doctypeDeclaration) == document; - assert: document doctypeDeclaration == doctypeDeclaration; - assert: doctypeDeclaration parent == document. + assert: (document doctypeDeclaration: doctypeDeclaration) + identicalTo: document; + assert: document doctypeDeclaration identicalTo: doctypeDeclaration; + assert: doctypeDeclaration parent identicalTo: document. "adding a doctypeDeclaration from another doc should remove it from the other doc" newDocument := self newNode. self assert: - (newDocument doctypeDeclaration: document doctypeDeclaration) == - newDocument; - assert: newDocument doctypeDeclaration == doctypeDeclaration; - assert: newDocument doctypeDeclaration parent == newDocument; + (newDocument doctypeDeclaration: document doctypeDeclaration) + identicalTo: newDocument; + assert: newDocument doctypeDeclaration + identicalTo: doctypeDeclaration; + assert: newDocument doctypeDeclaration parent + identicalTo: newDocument; assert: document doctypeDeclaration isNil. newDocument doctypeDeclaration: nil. @@ -78,39 +81,40 @@ XMLDocumentTest >> testDoctypeDeclaration [ { #category : #tests } XMLDocumentTest >> testDoctypeDefinition [ - | document doctypeDefinition | + | document doctypeDefinition | document := self newNode. self assert: document doctypeDefinition isNil. doctypeDefinition := DTDDoctypeDefinition new. self - assert: (document doctypeDefinition: doctypeDefinition) == document; - assert: document doctypeDefinition == doctypeDefinition + assert: (document doctypeDefinition: doctypeDefinition) + identicalTo: document; + assert: document doctypeDefinition identicalTo: doctypeDefinition ] { #category : #tests } XMLDocumentTest >> testDocument [ - | document | + | document | super testDocument. document := self newNode. - self assert: document document == document. + self assert: document document identicalTo: document. document := self newNodeWithElements. - self assert: document document == document + self assert: document document identicalTo: document ] { #category : #tests } XMLDocumentTest >> testEncoding [ - | document | + | document | document := self newNode. self - assert: document encoding = ''; - assert: (document encoding: 'UTF-8') == document; - assert: document encoding = 'UTF-8' + assert: document encoding equals: ''; + assert: (document encoding: 'UTF-8') identicalTo: document; + assert: document encoding equals: 'UTF-8' ] { #category : #tests } @@ -175,49 +179,49 @@ XMLDocumentTest >> testIsDocument [ { #category : #tests } XMLDocumentTest >> testIsStandalone [ - | document | + | document | document := self newNode. self deny: document isStandalone; - assert: (document isStandalone: true) == document; + assert: (document isStandalone: true) identicalTo: document; assert: document isStandalone ] { #category : #tests } XMLDocumentTest >> testRoot [ - | document newRoot | + | document newRoot | newRoot := self newElementWithAttributes. document := self nodeClass root: newRoot. self - assert: document class == self nodeClass; - assert: document root == newRoot. + assert: document class identicalTo: self nodeClass; + assert: document root identicalTo: newRoot. self assert: self newNode root isNil. document := self newNodeWithElements. self - assert: document root == document nodes second; - assert: document nodes size = 3; + assert: document root identicalTo: document nodes second; + assert: document nodes size equals: 3; assert: document nodes first isComment; assert: (document nodes second isElementNamed: 'zero'); assert: document nodes third isComment. newRoot := self elementClass named: 'new-root'. self - assert: (document root: newRoot) == document; - assert: document root == newRoot; - assert: document nodes size = 3; + assert: (document root: newRoot) identicalTo: document; + assert: document root identicalTo: newRoot; + assert: document nodes size equals: 3; assert: document nodes first isComment; - assert: document nodes second == newRoot; + assert: document nodes second identicalTo: newRoot; assert: document nodes third isComment. document removeNodes. self assert: document root isNil. self - should: [document root: 'test' asXMLStringNode] + should: [ document root: 'test' asXMLStringNode ] raise: XMLDOMException ] diff --git a/src/XML-Parser-Tests/XMLElementDeclarationTest.class.st b/src/XML-Parser-Tests/XMLElementDeclarationTest.class.st index d056d4ea..30033f71 100644 --- a/src/XML-Parser-Tests/XMLElementDeclarationTest.class.st +++ b/src/XML-Parser-Tests/XMLElementDeclarationTest.class.st @@ -16,48 +16,50 @@ XMLElementDeclarationTest >> nodeClass [ { #category : #tests } XMLElementDeclarationTest >> testContentModel [ - | declaration | + | declaration | declaration := self newNode. self - assert: declaration contentModel = ''; - assert: (declaration contentModel: '(one|two)') == declaration; - assert: declaration contentModel = '(one|two)' + assert: declaration contentModel equals: ''; + assert: (declaration contentModel: '(one|two)') + identicalTo: declaration; + assert: declaration contentModel equals: '(one|two)' ] { #category : #tests } XMLElementDeclarationTest >> testElement [ - | declaration | + | declaration | declaration := self newNode. self - assert: declaration element = ''; - assert: (declaration element: 'test') == declaration; - assert: declaration element = 'test' + assert: declaration element equals: ''; + assert: (declaration element: 'test') identicalTo: declaration; + assert: declaration element equals: 'test' ] { #category : #tests } XMLElementDeclarationTest >> testElementContentModel [ - | declaration | - declaration := - self nodeClass - element: 'one' - contentModel: '(two|three)'. + | declaration | + declaration := self nodeClass + element: 'one' + contentModel: '(two|three)'. self - assert: declaration class == self nodeClass; - assert: declaration element = 'one'; - assert: declaration contentModel = '(two|three)' + assert: declaration class identicalTo: self nodeClass; + assert: declaration element equals: 'one'; + assert: declaration contentModel equals: '(two|three)' ] { #category : #assertions } XMLElementDeclarationTest >> testWriteXMLOn [ - self assert: - (self nodeClass - element: 'one' - contentModel: '(two | three)') printString = ''. - self assert: - (self nodeClass - element: 'one' - contentModel: 'EMPTY') printString = '' + + self + assert: + (self nodeClass element: 'one' contentModel: '(two | three)') + printString + equals: ''. + self + assert: + (self nodeClass element: 'one' contentModel: 'EMPTY') printString + equals: '' ] diff --git a/src/XML-Parser-Tests/XMLElementTest.class.st b/src/XML-Parser-Tests/XMLElementTest.class.st index cff899d8..0348640e 100644 --- a/src/XML-Parser-Tests/XMLElementTest.class.st +++ b/src/XML-Parser-Tests/XMLElementTest.class.st @@ -23,24 +23,24 @@ XMLElementTest >> nodeClass [ { #category : #tests } XMLElementTest >> testAcceptNodeVisitor [ - | visitor element message | + | visitor element message | visitor := XMLRecordingNodeVisitor new. element := self newNode. self - assert: (element acceptNodeVisitor: visitor) == element; + assert: (element acceptNodeVisitor: visitor) identicalTo: element; assert: visitor messageRecorder hasMessages. message := visitor messageRecorder nextMessage. self - assert: message selector == #visitElement:; - assert: message arguments = (Array with: element); + assert: message selector identicalTo: #visitElement:; + assert: message arguments equals: (Array with: element); assert: visitor messageRecorder hasMessages. message := visitor messageRecorder nextMessage. self - assert: message selector == #visitNodeWithElements:; - assert: message arguments = (Array with: element); + assert: message selector identicalTo: #visitNodeWithElements:; + assert: message arguments equals: (Array with: element); deny: visitor messageRecorder hasMessages. super testAcceptNodeVisitor @@ -48,45 +48,41 @@ XMLElementTest >> testAcceptNodeVisitor [ { #category : #tests } XMLElementTest >> testAddElementNamed [ - | element | + | element | super testAddElementNamed. element := self newNode. - element - declarePrefix: 'prefix' - uri: 'prefixNS'. + element declarePrefix: 'prefix' uri: 'prefixNS'. self - shouldnt: [element addElementNamed: 'prefix:test'] + shouldnt: [ element addElementNamed: 'prefix:test' ] raise: XMLNamespaceException. self - assert: element nodes size = 1; + assert: element nodes size equals: 1; assert: element firstNode isElement; - assert: element firstNode name = 'prefix:test'; - assert: element firstNode namespaceURI = 'prefixNS' + assert: element firstNode name equals: 'prefix:test'; + assert: element firstNode namespaceURI equals: 'prefixNS' ] { #category : #tests } XMLElementTest >> testAddElementNamedAttributes [ - | element | + | element | super testAddElementNamedAttributes. element := self newNode. - element - declarePrefix: 'prefix' - uri: 'prefixNS'. + element declarePrefix: 'prefix' uri: 'prefixNS'. self shouldnt: [ element addElementNamed: 'prefix:test' - attributes: self attributeAssociations] + attributes: self attributeAssociations ] raise: XMLNamespaceException. self - assert: element nodes size = 1; + assert: element nodes size equals: 1; assert: element firstNode isElement; - assert: element firstNode name = 'prefix:test'; - assert: element firstNode namespaceURI = 'prefixNS'; + assert: element firstNode name equals: 'prefix:test'; + assert: element firstNode namespaceURI equals: 'prefixNS'; assertElement: element firstNode hasAttributes: self attributes ] @@ -102,72 +98,71 @@ XMLElementTest >> testAttributeAssociations [ { #category : #tests } XMLElementTest >> testAttributeAt [ - | element | + | element | element := self newElementWithAttributes. - element attributeNodes do: [:each | - self assert: (element attributeAt: each name) = each value]. - self assert: (element attributeAt: 'absent') = '' + element attributeNodes do: [ :each | + self assert: (element attributeAt: each name) equals: each value ]. + self assert: (element attributeAt: 'absent') equals: '' ] { #category : #tests } XMLElementTest >> testAttributeAtIfAbsent [ - | element | + | element | element := self newElementWithAttributes. - element attributeNodes do: [:each | - self assert: - (element - attributeAt: each name - ifAbsent: [self fail]) = each value]. - self assert: - (element - attributeAt: 'absent' - ifAbsent: [#absent]) = #absent + element attributeNodes do: [ :each | + self + assert: (element attributeAt: each name ifAbsent: [ self fail ]) + equals: each value ]. + self + assert: (element attributeAt: 'absent' ifAbsent: [ #absent ]) + equals: #absent ] { #category : #tests } XMLElementTest >> testAttributeAtIfAbsentPut [ - | element | + | element | element := self newElementWithAttributes. - element attributeNodes do: [:each | - self assert: - (element - attributeAt: each name - ifAbsentPut: [self fail]) = each value]. - self assert: - (element - attributeAt: 'newName' - ifAbsentPut: ['newValue']) = 'newValue'. - self assert: (element attributeAt: 'newName') = 'newValue' + element attributeNodes do: [ :each | + self + assert: (element attributeAt: each name ifAbsentPut: [ self fail ]) + equals: each value ]. + self + assert: (element attributeAt: 'newName' ifAbsentPut: [ 'newValue' ]) + equals: 'newValue'. + self assert: (element attributeAt: 'newName') equals: 'newValue' ] { #category : #tests } XMLElementTest >> testAttributeAtPut [ - | element | + | element | element := self newElementWithAttributes. - element attributeNodes do: [:each | | newValue | - newValue := 'new', each value. + element attributeNodes do: [ :each | + | newValue | + newValue := 'new' , each value. self - assert: (element attributeAt: each name put: newValue) = newValue; - assert: (element attributeAt: each name) = newValue]. + assert: (element attributeAt: each name put: newValue) + equals: newValue; + assert: (element attributeAt: each name) equals: newValue ]. self - assert: (element attributeAt: 'newName' put: 'newValue') = 'newValue'; - assert: (element attributeAt: 'newName') = 'newValue' + assert: (element attributeAt: 'newName' put: 'newValue') + equals: 'newValue'; + assert: (element attributeAt: 'newName') equals: 'newValue' ] { #category : #tests } XMLElementTest >> testAttributeListCopying [ - | element attributeListCopy | + | element attributeListCopy | element := self newElementWithAttributes. attributeListCopy := element attributeNodes copy. self - assert: attributeListCopy = element attributeNodes; - deny: attributeListCopy == element attributeNodes; - assert: element attributeNodes observer == element; + assert: attributeListCopy equals: element attributeNodes; + deny: attributeListCopy identicalTo: element attributeNodes; + assert: element attributeNodes observer identicalTo: element; assert: attributeListCopy observer isNil ] @@ -217,120 +212,126 @@ XMLElementTest >> testAttributeNamesDo [ { #category : #tests } XMLElementTest >> testAttributeNodeAt [ - | element | + | element | element := self newElementWithAttributes. - element attributeNodes do: [:each | - self assert: (element attributeNodeAt: each name) = each]. - self assert: - (element attributeNodeAt: 'two') = element attributeNodes second. - self assert: - (element attributeNodeAt: 'absent') isNil + element attributeNodes do: [ :each | + self assert: (element attributeNodeAt: each name) equals: each ]. + self + assert: (element attributeNodeAt: 'two') + equals: element attributeNodes second. + self assert: (element attributeNodeAt: 'absent') isNil ] { #category : #tests } XMLElementTest >> testAttributeNodeAtIfAbsent [ - | element attributeLocalNames | + | element attributeLocalNames | element := self newElementWithAttributes. - element attributeNodes do: [:each | - self assert: - (element - attributeNodeAt: each name - ifAbsent: [self fail]) = each]. - attributeLocalNames := - (element attributeNodes collect: [:each | each localName]) asSet. - attributeLocalNames do: [:localName | - self assert: - (element - attributeNodeAt: localName - ifAbsent: [self fail]) = - (element attributeNodes detect: [:each | each localName = localName])]. - self assert: - (element - attributeNodeAt: 'absent' - ifAbsent: [#absent]) = #absent + element attributeNodes do: [ :each | + self + assert: + (element attributeNodeAt: each name ifAbsent: [ self fail ]) + equals: each ]. + attributeLocalNames := (element attributeNodes collect: [ :each | + each localName ]) asSet. + attributeLocalNames do: [ :localName | + self + assert: + (element attributeNodeAt: localName ifAbsent: [ self fail ]) + equals: + (element attributeNodes detect: [ :each | + each localName = localName ]) ]. + self + assert: (element attributeNodeAt: 'absent' ifAbsent: [ #absent ]) + equals: #absent ] { #category : #tests } XMLElementTest >> testAttributeNodeAtNamespaceURI [ - | element | + | element | element := self newElementWithAttributes. - self assert: - (element attributeNodeAt: 'prefix:two' namespaceURI: 'prefixNS') = - (element attributeNodes third). - self assert: - (element attributeNodeAt: 'two' namespaceURI: 'prefixNS') = - (element attributeNodes third). + self + assert: + (element attributeNodeAt: 'prefix:two' namespaceURI: 'prefixNS') + equals: element attributeNodes third. + self + assert: (element attributeNodeAt: 'two' namespaceURI: 'prefixNS') + equals: element attributeNodes third. self assert: (element attributeNodeAt: 'prefix:two' namespaceURI: 'absent') isNil ] { #category : #tests } XMLElementTest >> testAttributeNodeAtNamespaceURIIfAbsent [ - | element | + | element | element := self newElementWithAttributes. - self assert: - (element - attributeNodeAt: 'prefix:two' - namespaceURI: 'prefixNS' - ifAbsent: [self fail]) = - element attributeNodes third. - self assert: - (element - attributeNodeAt: 'two' - namespaceURI: 'prefixNS' - ifAbsent: [self fail]) = - element attributeNodes third. - self assert: - (element - attributeNodeAt: 'prefix:two' - namespaceURI: 'absent' - ifAbsent: [#absent]) = #absent + self + assert: (element + attributeNodeAt: 'prefix:two' + namespaceURI: 'prefixNS' + ifAbsent: [ self fail ]) + equals: element attributeNodes third. + self + assert: (element + attributeNodeAt: 'two' + namespaceURI: 'prefixNS' + ifAbsent: [ self fail ]) + equals: element attributeNodes third. + self + assert: (element + attributeNodeAt: 'prefix:two' + namespaceURI: 'absent' + ifAbsent: [ #absent ]) + equals: #absent ] { #category : #tests } XMLElementTest >> testAttributeNodes [ - | element attributeNodes | + | element attributeNodes | element := self newElementWithAttributes. attributeNodes := element attributeNodes. - self assert: attributeNodes class == self attributeListClass. - self assert: - (attributeNodes collect: [:each | each name -> each value]) asArray - = self attributeAssociations asArray + self + assert: attributeNodes class + identicalTo: self attributeListClass. + self + assert: + (attributeNodes collect: [ :each | each name -> each value ]) + asArray + equals: self attributeAssociations asArray ] { #category : #tests } XMLElementTest >> testAttributeNodesAdding [ - | element attributesAdded elementWithAttributes | + | element attributesAdded elementWithAttributes | element := self newElement. attributesAdded := element attributeNodes copyEmpty. elementWithAttributes := self newElementWithAttributes. "adding from another element should remove them from the previous element" - elementWithAttributes attributeNodes copy do: [:each | + elementWithAttributes attributeNodes copy do: [ :each | attributesAdded addLast: each. element attributeNodes addLast: each. self - assert: each element == element; - assert: each parent == element; - assert: element attributeNodes = attributesAdded; - deny: (elementWithAttributes attributeNodes includes: each)]. + assert: each element identicalTo: element; + assert: each parent identicalTo: element; + assert: element attributeNodes equals: attributesAdded; + deny: (elementWithAttributes attributeNodes includes: each) ]. "adding already present nodes should move them in-place" - element attributeNodes reversed do: [:each | + element attributeNodes reversed do: [ :each | attributesAdded remove: each; addLast: each. element attributeNodes addLast: each. self - assert: each element == element; - assert: each parent == element; - assert: element attributeNodes = attributesAdded] + assert: each element identicalTo: element; + assert: each parent identicalTo: element; + assert: element attributeNodes equals: attributesAdded ] ] { #category : #tests } @@ -406,8 +407,8 @@ XMLElementTest >> testAttributePrefixUndeclared [ { #category : #tests } XMLElementTest >> testAttributeRenaming [ - | elementWithAttributes attributeNodes attributeNode oldSize oldNames oldName | + | elementWithAttributes attributeNodes attributeNode oldSize oldNames oldName | elementWithAttributes := self newElementWithAttributes. attributeNodes := elementWithAttributes attributeNodes. @@ -417,163 +418,166 @@ XMLElementTest >> testAttributeRenaming [ oldName := attributeNode name. attributeNode name: 'newName'. self - assert: attributeNodes size = oldSize; - assert: attributeNodes first == attributeNode; - assert: elementWithAttributes attributeNames = (oldNames allButFirst copyWithFirst: 'newName'); + assert: attributeNodes size equals: oldSize; + assert: attributeNodes first identicalTo: attributeNode; + assert: elementWithAttributes attributeNames + equals: (oldNames allButFirst copyWithFirst: 'newName'); deny: (elementWithAttributes includesAttribute: oldName); - assert: (elementWithAttributes attributeNodeAt: 'newName') == attributeNode. + assert: (elementWithAttributes attributeNodeAt: 'newName') + identicalTo: attributeNode. oldNames := elementWithAttributes attributeNames. oldName := attributeNode name. attributeNode name: oldNames last. self - assert: attributeNodes size = (oldSize - 1); - assert: attributeNodes first == attributeNode; - assert: - elementWithAttributes attributeNames = - ((oldNames copyFrom: 2 to: oldNames size - 1) copyWithFirst: oldNames last); + assert: attributeNodes size equals: oldSize - 1; + assert: attributeNodes first identicalTo: attributeNode; + assert: elementWithAttributes attributeNames + equals: + ((oldNames copyFrom: 2 to: oldNames size - 1) copyWithFirst: + oldNames last); deny: (elementWithAttributes includesAttribute: oldName); - assert: (elementWithAttributes attributeNodeAt: attributeNode name) == attributeNode + assert: (elementWithAttributes attributeNodeAt: attributeNode name) + identicalTo: attributeNode ] { #category : #tests } XMLElementTest >> testAttributeSorting [ - | element | - element := - self nodeClass - name: 'sorted' - attributes: (Array with: 'c' -> '3' with: 'b' -> '2' with: 'a' -> '1'). - self assert: - (element attributeNodes sorted - collect: [:each | each name]) asArray = #('a' 'b' 'c'). - self assert: - ((element attributeNodes sorted: [:a :b | a name <= b name]) - collect: [:each | each name]) asArray = #('a' 'b' 'c'). - "sorted/sorted: should sort copies" - self assert: element attributeNames asArray = #('c' 'b' 'a'). + | element | + element := self nodeClass + name: 'sorted' + attributes: + (Array with: 'c' -> '3' with: 'b' -> '2' with: 'a' -> '1'). + self + assert: + (element attributeNodes sorted collect: [ :each | each name ]) + asArray + equals: #( 'a' 'b' 'c' ). + self + assert: + ((element attributeNodes sorted: [ :a :b | a name <= b name ]) + collect: [ :each | each name ]) asArray + equals: #( 'a' 'b' 'c' ). + self assert: element attributeNames asArray equals: #( 'c' 'b' 'a' ). element attributeNodes sort. - self assert: element attributeNames asArray = #('a' 'b' 'c'). - element attributeNodes sort: [:a :b | a name > b name]. - self assert: element attributeNames asArray = #('c' 'b' 'a') + self assert: element attributeNames asArray equals: #( 'a' 'b' 'c' ). + element attributeNodes sort: [ :a :b | a name > b name ]. + self assert: element attributeNames asArray equals: #( 'c' 'b' 'a' ) ] { #category : #tests } XMLElementTest >> testAttributes [ - | element attributeDictionary | + | element attributeDictionary | element := self newElementWithAttributes. attributeDictionary := element attributes. self - assert: attributeDictionary class == self attributesClass; - assert: attributeDictionary size = element attributeNodes size. - self assert: - (element attributeNodes allSatisfy: [:each | - (attributeDictionary at: each name) = each value]). + assert: attributeDictionary class identicalTo: self attributesClass; + assert: attributeDictionary size + equals: element attributeNodes size. + self assert: (element attributeNodes allSatisfy: [ :each | + (attributeDictionary at: each name) = each value ]) ] { #category : #tests } XMLElementTest >> testCanonicalPrinting [ - | element | - - element := - self nodeClass - name: 'test' - namespaces: (Array with: 'b' -> 'ns2' with: 'a' -> 'ns1' with: '' -> 'default') - attributes: (Array with: 'c' -> '3' with: 'b' -> '2' with: 'a' -> '1'). - self assert: - element printString = - ''. - self assert: - element canonicallyPrinted = - ''. + | element | + element := self nodeClass + name: 'test' + namespaces: + (Array + with: 'b' -> 'ns2' + with: 'a' -> 'ns1' + with: '' -> 'default') + attributes: + (Array with: 'c' -> '3' with: 'b' -> '2' with: 'a' -> '1'). + self + assert: element printString + equals: + ''. + self + assert: element canonicallyPrinted + equals: + '' ] { #category : #tests } XMLElementTest >> testDeclareNamespaces [ - | element | + | element | element := self newNode. - self assert: (element declareNamespaces: self namespaces) == element. - self namespaces keysAndValuesDo: [:prefix :uri | - self assert: (element isDeclaredPrefix: prefix uri: uri)]. + self + assert: (element declareNamespaces: self namespaces) + identicalTo: element. + self namespaces keysAndValuesDo: [ :prefix :uri | + self assert: (element isDeclaredPrefix: prefix uri: uri) ]. element := self newNode. - self assert: (element declareNamespaces: self namespaces associations) == element. - self namespaces keysAndValuesDo: [:prefix :uri | - self assert: (element isDeclaredPrefix: prefix uri: uri)]. + self + assert: (element declareNamespaces: self namespaces associations) + identicalTo: element. + self namespaces keysAndValuesDo: [ :prefix :uri | + self assert: (element isDeclaredPrefix: prefix uri: uri) ]. (element := self newNode) usesNamespaces: false. self - assert: (element declareNamespaces: #()) == element; - assert: element usesNamespaces. + assert: (element declareNamespaces: #( )) identicalTo: element; + assert: element usesNamespaces ] { #category : #tests } XMLElementTest >> testDeclarePrefixURI [ - | element elementsWithDeclaredPrefix | + | element elementsWithDeclaredPrefix | element := self newNodeWithElements. - self assert: - (element - declarePrefix: 'newPrefix' - uri: 'prefixNS') == element. - element allElementsDo: [:each | - self assert: - (each - isDeclaredPrefix: 'newPrefix' - uri: 'prefixNS')]. - self assert: - (element - declarePrefix: 'newPrefix' - uri: 'newPrefixNS') == element. - element allElementsDo: [:each | - self assert: - (each - isDeclaredPrefix: 'newPrefix' - uri: 'newPrefixNS')]. + self + assert: (element declarePrefix: 'newPrefix' uri: 'prefixNS') + identicalTo: element. + element allElementsDo: [ :each | + self assert: (each isDeclaredPrefix: 'newPrefix' uri: 'prefixNS') ]. + self + assert: (element declarePrefix: 'newPrefix' uri: 'newPrefixNS') + identicalTo: element. + element allElementsDo: [ :each | + self assert: (each isDeclaredPrefix: 'newPrefix' uri: 'newPrefixNS') ]. - elementsWithDeclaredPrefix := - element allElementsSelect: [:each | each prefix = 'prefix']. - self assert: - (element - declarePrefix: 'prefix' - uri: 'newPrefixNS') == element. - element allElementsDo: [:each | + elementsWithDeclaredPrefix := element allElementsSelect: [ :each | + each prefix = 'prefix' ]. + self + assert: (element declarePrefix: 'prefix' uri: 'newPrefixNS') + identicalTo: element. + element allElementsDo: [ :each | (elementsWithDeclaredPrefix includes: each) ifTrue: [ self assert: (each isDeclaredPrefix: 'prefix'); - deny: - (each - isDeclaredPrefix: 'prefix' - uri: 'newPrefixNS')] - ifFalse: [ - self assert: - (each - isDeclaredPrefix: 'prefix' - uri: 'newPrefixNS')]]. + deny: (each isDeclaredPrefix: 'prefix' uri: 'newPrefixNS') ] + ifFalse: [ + self assert: (each isDeclaredPrefix: 'prefix' uri: 'newPrefixNS') ] ]. self - should: [element declarePrefix: 'nonDefault' uri: ''] + should: [ element declarePrefix: 'nonDefault' uri: '' ] raise: XMLNamespaceException. "cannot rebind the xml prefix to a new NS" - self - should: [element declarePrefix: 'xml' uri: 'newNS'] + self + should: [ element declarePrefix: 'xml' uri: 'newNS' ] raise: XMLNamespaceException. "cannot rebind the xmlns prefix, even to the same NS" self - should: [element declarePrefix: 'xmlns' uri: XMLNamespaceScope xmlnsNamespaceURI] + should: [ + element + declarePrefix: 'xmlns' + uri: XMLNamespaceScope xmlnsNamespaceURI ] raise: XMLNamespaceException. (element := self newNode) usesNamespaces: false. - self assert: - (element - declarePrefix: 'prefix' - uri: 'prefixNS') == element. - self assert: element usesNamespaces. + self + assert: (element declarePrefix: 'prefix' uri: 'prefixNS') + identicalTo: element. + self assert: element usesNamespaces ] { #category : #tests } @@ -605,21 +609,19 @@ XMLElementTest >> testDeclarePrefixURIAttributes [ { #category : #tests } XMLElementTest >> testDeclaredPrefixes [ - | element prefixes | + | element prefixes | element := self newNode. prefixes := OrderedCollection new. - self namespaces keysAndValuesDo: [:prefix :uri | - element - declarePrefix: prefix - uri: uri. + self namespaces keysAndValuesDo: [ :prefix :uri | + element declarePrefix: prefix uri: uri. prefixes addLast: prefix. - self assert: element declaredPrefixes = prefixes asArray]. + self assert: element declaredPrefixes equals: prefixes asArray ]. (element := self newNode) usesNamespaces: false. self assert: element declaredPrefixes isEmpty; - deny: element usesNamespaces. + deny: element usesNamespaces ] { #category : #tests } @@ -704,71 +706,80 @@ XMLElementTest >> testDeclaresPrefixURI [ { #category : #tests } XMLElementTest >> testDefaultNamespace [ - | element elementsWithDefaultNamespace | + | element elementsWithDefaultNamespace | element := self newNodeWithElements. - elementsWithDefaultNamespace := - element allElementsSelect: [:each | - each defaultNamespace notEmpty]. - - self assert: (element defaultNamespace: 'newDefaultNS') == element. - element allElementsDo: [:each | + elementsWithDefaultNamespace := element allElementsSelect: [ :each | + each defaultNamespace notEmpty ]. + self + assert: (element defaultNamespace: 'newDefaultNS') + identicalTo: element. + element allElementsDo: [ :each | (elementsWithDefaultNamespace includes: each) - ifTrue: [self deny: (each defaultNamespace = 'newDefaultNS')] - ifFalse: [self assert: (each defaultNamespace = 'newDefaultNS')]]. - - self assert: (element defaultNamespace: '') == element. - element allElementsDo: [:each | + ifTrue: [ self deny: each defaultNamespace equals: 'newDefaultNS' ] + ifFalse: [ + self assert: each defaultNamespace equals: 'newDefaultNS' ] ]. + self assert: (element defaultNamespace: '') identicalTo: element. + element allElementsDo: [ :each | (elementsWithDefaultNamespace includes: each) - ifTrue: [self deny: each defaultNamespace = ''] - ifFalse: [self assert: each defaultNamespace = '']]. + ifTrue: [ self deny: each defaultNamespace equals: '' ] + ifFalse: [ self assert: each defaultNamespace equals: '' ] ]. (element := self newNode) usesNamespaces: false. self - assert: element defaultNamespace = ''; + assert: element defaultNamespace equals: ''; deny: element usesNamespaces; - assert: (element defaultNamespace: '') == element; - assert: element usesNamespaces. + assert: (element defaultNamespace: '') identicalTo: element; + assert: element usesNamespaces ] { #category : #tests } XMLElementTest >> testElementSorting [ - | element | + | element | (element := self nodeClass named: 'sorted') addElementNamed: 'c'; addElementNamed: 'b'; addElementNamed: 'a'. - - self assert: (element nodes sorted collect: [:each | each name]) asArray = #('a' 'b' 'c'). - self assert: - ((element nodes sorted: [:a :b | a name <= b name]) - collect: [:each | each name]) asArray = #('a' 'b' 'c'). - - self assert: (element nodesCollect: [:each | each name]) asArray = #('c' 'b' 'a'). + self + assert: + (element nodes sorted collect: [ :each | each name ]) asArray + equals: #( 'a' 'b' 'c' ). + self + assert: + ((element nodes sorted: [ :a :b | a name <= b name ]) collect: [ + :each | each name ]) asArray + equals: #( 'a' 'b' 'c' ). + self + assert: (element nodesCollect: [ :each | each name ]) asArray + equals: #( 'c' 'b' 'a' ). element nodes sort. - self assert: (element nodesCollect: [:each | each name]) asArray = #('a' 'b' 'c'). - element nodes sort: [:a :b | a name > b name]. - self assert: (element nodesCollect: [:each | each name]) asArray = #('c' 'b' 'a'). + self + assert: (element nodesCollect: [ :each | each name ]) asArray + equals: #( 'a' 'b' 'c' ). + element nodes sort: [ :a :b | a name > b name ]. + self + assert: (element nodesCollect: [ :each | each name ]) asArray + equals: #( 'c' 'b' 'a' ) ] { #category : #tests } XMLElementTest >> testExpandedName [ - | element | + | element | element := self nodeClass named: 'test'. - self assert: (element expandedName = 'test'). + self assert: element expandedName equals: 'test'. element defaultNamespace: 'defaultNS'. - self assert: (element expandedName = 'Q{defaultNS}test'). + self assert: element expandedName equals: 'Q{defaultNS}test'. element name: 'prefix:test' namespaceURI: 'prefixNS'. - self assert: (element expandedName = 'Q{prefixNS}test'). + self assert: element expandedName equals: 'Q{prefixNS}test'. element defaultNamespace: ''; name: 'test'. - self assert: (element expandedName = 'test'). + self assert: element expandedName equals: 'test' ] { #category : #tests } @@ -1083,179 +1094,153 @@ XMLElementTest >> testIsRoot [ { #category : #tests } XMLElementTest >> testLocalName [ - | element | + | element | element := self newNode. self - assert: element localName = ''; - assert: (element name: 'one') == element; - assert: element localName = 'one'; - assert: (element name: 'two') == element; - assert: element localName = 'two'. + assert: element localName equals: ''; + assert: (element name: 'one') identicalTo: element; + assert: element localName equals: 'one'; + assert: (element name: 'two') identicalTo: element; + assert: element localName equals: 'two'. - element - declarePrefix: 'prefix' - uri: 'prefixNS'. + element declarePrefix: 'prefix' uri: 'prefixNS'. self - assert: (element name: 'prefix:three') == element; - assert: element localName = 'three'; - assert: (element name: 'four') == element; - assert: element localName = 'four'. + assert: (element name: 'prefix:three') identicalTo: element; + assert: element localName equals: 'three'; + assert: (element name: 'four') identicalTo: element; + assert: element localName equals: 'four' ] { #category : #tests } XMLElementTest >> testName [ - | element | + | element | "XMLElement class>>#name: is not tested here because it is soft-deprecated" - element := self newNode. self - assert: element name = ''; - assert: (element name: 'one') == element; - assert: element name = 'one'; - assert: (element name: 'two') == element; - assert: element name = 'two'. + assert: element name equals: ''; + assert: (element name: 'one') identicalTo: element; + assert: element name equals: 'one'; + assert: (element name: 'two') identicalTo: element; + assert: element name equals: 'two'. self - should: [element name: 'unmapped:two'] + should: [ element name: 'unmapped:two' ] raise: XMLNamespaceException. element usesNamespaces: false. self - shouldnt: [element name: 'unmapped:three'] + shouldnt: [ element name: 'unmapped:three' ] raise: XMLNamespaceException. - self assert: element name = 'unmapped:three'. + self assert: element name equals: 'unmapped:three' ] { #category : #tests } XMLElementTest >> testNameAttributes [ - | attributes unprefixedAttributes element | + | attributes unprefixedAttributes element | attributes := self attributes. unprefixedAttributes := self unprefixedAttributes. - element := - self nodeClass - name: 'one' - attributes: self unprefixedAttributeAssociations. + element := self nodeClass + name: 'one' + attributes: self unprefixedAttributeAssociations. self - assert: element class == self nodeClass; - assert: element name = 'one'; + assert: element class identicalTo: self nodeClass; + assert: element name equals: 'one'; assertElement: element hasAttributes: unprefixedAttributes. "attributes: should accept any collection of associations" - element := - self nodeClass - name: 'two' - attributes: unprefixedAttributes associations. + element := self nodeClass + name: 'two' + attributes: unprefixedAttributes associations. self - assert: element name = 'two'; - assert: element class == self nodeClass; + assert: element name equals: 'two'; + assert: element class identicalTo: self nodeClass; assertElement: element hasAttributes: unprefixedAttributes. self should: [ self nodeClass name: 'undeclared:three' - attributes: unprefixedAttributes] + attributes: unprefixedAttributes ] raise: XMLNamespaceException. "prefixed attributes are not accepted" self - should: [ - self nodeClass - name: 'four' - attributes: attributes] - raise: XMLNamespaceException. + should: [ self nodeClass name: 'four' attributes: attributes ] + raise: XMLNamespaceException ] { #category : #tests } XMLElementTest >> testNameNamespaceURI [ - | element | - element := - self nodeClass - name: 'one' - namespaceURI: 'defaultNS'. + | element | + element := self nodeClass name: 'one' namespaceURI: 'defaultNS'. self - assert: element class == self nodeClass; - assert: element name = 'one'; - assert: element namespaceURI = 'defaultNS'. + assert: element class identicalTo: self nodeClass; + assert: element name equals: 'one'; + assert: element namespaceURI equals: 'defaultNS'. - element := - self nodeClass - name: 'prefix:two' - namespaceURI: 'prefixNS'. + element := self nodeClass name: 'prefix:two' namespaceURI: 'prefixNS'. self - assert: element class == self nodeClass; - assert: element name = 'prefix:two'; - assert: element namespaceURI = 'prefixNS'. + assert: element class identicalTo: self nodeClass; + assert: element name equals: 'prefix:two'; + assert: element namespaceURI equals: 'prefixNS'. self - should: [ - self nodeClass - name: 'prefix:three' - namespaceURI: ''] + should: [ self nodeClass name: 'prefix:three' namespaceURI: '' ] raise: XMLNamespaceException. element := self newNode. - self assert: - (element - name: 'one' - namespaceURI: 'defaultNS') == element. self - assert: element name = 'one'; - assert: element namespaceURI = 'defaultNS'. - - self assert: - (element - name: 'prefix:two' - namespaceURI: 'prefixNS') == element. + assert: (element name: 'one' namespaceURI: 'defaultNS') + identicalTo: element. self - assert: element name = 'prefix:two'; - assert: element namespaceURI = 'prefixNS'. + assert: element name equals: 'one'; + assert: element namespaceURI equals: 'defaultNS'. + self + assert: (element name: 'prefix:two' namespaceURI: 'prefixNS') + identicalTo: element. + self + assert: element name equals: 'prefix:two'; + assert: element namespaceURI equals: 'prefixNS'. self - should: [ - element - name: 'prefix:three' - namespaceURI: ''] + should: [ element name: 'prefix:three' namespaceURI: '' ] raise: XMLNamespaceException. (element := self newNode) usesNamespaces: false. - self assert: - (element - name: 'four' - namespaceURI: 'defaultNS') == element. self - assert: element name = 'four'; - assert: element namespaceURI = 'defaultNS'; - assert: element usesNamespaces. + assert: (element name: 'four' namespaceURI: 'defaultNS') + identicalTo: element. + self + assert: element name equals: 'four'; + assert: element namespaceURI equals: 'defaultNS'; + assert: element usesNamespaces ] { #category : #tests } XMLElementTest >> testNameNamespaceURIAttributes [ - | attributes unprefixedAttributes element | + | attributes unprefixedAttributes element | attributes := self attributes. unprefixedAttributes := self unprefixedAttributes. - element := - self nodeClass - name: 'one' - namespaceURI: 'defaultNS' - attributes: unprefixedAttributes. - self - assert: element class == self nodeClass; - assert: element name = 'one'; - assert: element namespaceURI = 'defaultNS'; + element := self nodeClass + name: 'one' + namespaceURI: 'defaultNS' + attributes: unprefixedAttributes. + self + assert: element class identicalTo: self nodeClass; + assert: element name equals: 'one'; + assert: element namespaceURI equals: 'defaultNS'; assertElement: element hasAttributes: unprefixedAttributes. - element := - self nodeClass - name: 'prefix:two' - namespaceURI: 'prefixNS' - attributes: attributes associations. + element := self nodeClass + name: 'prefix:two' + namespaceURI: 'prefixNS' + attributes: attributes associations. self - assert: element class == self nodeClass; - assert: element name = 'prefix:two'; - assert: element namespaceURI = 'prefixNS'; + assert: element class identicalTo: self nodeClass; + assert: element name equals: 'prefix:two'; + assert: element namespaceURI equals: 'prefixNS'; assertElement: element hasAttributes: attributes. "if the attributes have a prefix, then the element must have the @@ -1263,395 +1248,363 @@ XMLElementTest >> testNameNamespaceURIAttributes [ self should: [ self nodeClass - name: 'three' "no prefix" - namespaceURI: '' "no namespace" - attributes: attributes] + name: 'three' + namespaceURI: '' + attributes: attributes "no prefix" "no namespace" ] raise: XMLNamespaceException. self should: [ self nodeClass - name: 'four' "no prefix" + name: 'four' namespaceURI: 'prefixNS' - attributes: attributes] + attributes: attributes "no prefix" ] raise: XMLNamespaceException. self should: [ self nodeClass name: 'prefix:five' - namespaceURI: '' "no namespace" - attributes: unprefixedAttributes] - raise: XMLNamespaceException. + namespaceURI: '' + attributes: unprefixedAttributes "no namespace" ] + raise: XMLNamespaceException ] { #category : #tests } XMLElementTest >> testNameNamespaces [ + | element | - - element := - self nodeClass - name: 'one' - namespaces: self namespaces. + element := self nodeClass name: 'one' namespaces: self namespaces. self - assert: element class == self nodeClass; - assert: element name = 'one'; - assert: element namespaceURI = 'defaultNS'. - self namespaces keysAndValuesDo: [:prefix :uri | - self assert: (element isDeclaredPrefix: prefix uri: uri)]. + assert: element class identicalTo: self nodeClass; + assert: element name equals: 'one'; + assert: element namespaceURI equals: 'defaultNS'. + self namespaces keysAndValuesDo: [ :prefix :uri | + self assert: (element isDeclaredPrefix: prefix uri: uri) ]. "namespaces: should accept any collection of associations" - element := - self nodeClass - name: 'two' - namespaces: self namespaces associations. + element := self nodeClass + name: 'two' + namespaces: self namespaces associations. self - assert: element class == self nodeClass; - assert: element name = 'two'; - assert: element namespaceURI = 'defaultNS'. - self namespaces keysAndValuesDo: [:prefix :uri | - self assert: (element isDeclaredPrefix: prefix uri: uri)]. + assert: element class identicalTo: self nodeClass; + assert: element name equals: 'two'; + assert: element namespaceURI equals: 'defaultNS'. + self namespaces keysAndValuesDo: [ :prefix :uri | + self assert: (element isDeclaredPrefix: prefix uri: uri) ]. - element := - self nodeClass - name: 'prefix:three' - namespaces: self namespaces. + element := self nodeClass + name: 'prefix:three' + namespaces: self namespaces. self - assert: element class == self nodeClass; - assert: element name = 'prefix:three'; - assert: element namespaceURI = 'prefixNS'. - self namespaces keysAndValuesDo: [:prefix :uri | - self assert: (element isDeclaredPrefix: prefix uri: uri)]. + assert: element class identicalTo: self nodeClass; + assert: element name equals: 'prefix:three'; + assert: element namespaceURI equals: 'prefixNS'. + self namespaces keysAndValuesDo: [ :prefix :uri | + self assert: (element isDeclaredPrefix: prefix uri: uri) ]. self should: [ - self nodeClass - name: 'undeclared:three' - namespaces: self namespaces] - raise: XMLNamespaceException. + self nodeClass name: 'undeclared:three' namespaces: self namespaces ] + raise: XMLNamespaceException ] { #category : #tests } XMLElementTest >> testNameNamespacesAttributes [ + | element | + element := self nodeClass + name: 'one' + namespaces: self namespaces + attributes: self attributes. + self + assert: element class identicalTo: self nodeClass; + assert: element name equals: 'one'; + assert: element namespaceURI equals: 'defaultNS'; + assertElement: element hasAttributes: self attributes. + self namespaces keysAndValuesDo: [ :prefix :uri | + self assert: (element isDeclaredPrefix: prefix uri: uri) ]. - element := - self nodeClass - name: 'one' - namespaces: self namespaces - attributes: self attributes. + element := self nodeClass + name: 'two' + namespaces: self namespaces associations + attributes: self attributes associations. self - assert: element class == self nodeClass; - assert: element name = 'one'; - assert: element namespaceURI = 'defaultNS'; - assertElement: element hasAttributes: self attributes. - self namespaces keysAndValuesDo: [:prefix :uri | - self assert: (element isDeclaredPrefix: prefix uri: uri)]. - - element := - self nodeClass - name: 'two' - namespaces: self namespaces associations - attributes: self attributes associations. - self - assert: element class == self nodeClass; - assert: element name = 'two'; - assert: element namespaceURI = 'defaultNS'; + assert: element class identicalTo: self nodeClass; + assert: element name equals: 'two'; + assert: element namespaceURI equals: 'defaultNS'; assertElement: element hasAttributes: self attributes. - self namespaces keysAndValuesDo: [:prefix :uri | - self assert: (element isDeclaredPrefix: prefix uri: uri)]. + self namespaces keysAndValuesDo: [ :prefix :uri | + self assert: (element isDeclaredPrefix: prefix uri: uri) ]. self should: [ self nodeClass name: 'undeclared:three' namespaces: self namespaces - attributes: self attributes] + attributes: self attributes ] raise: XMLNamespaceException. self should: [ self nodeClass name: 'four' - namespaces: #() - attributes: self attributes] - raise: XMLNamespaceException. + namespaces: #( ) + attributes: self attributes ] + raise: XMLNamespaceException ] { #category : #tests } XMLElementTest >> testNamed [ - | element | + | element | element := self nodeClass named: 'test'. self - assert: element class == self nodeClass; - assert: element name = 'test'. + assert: element class identicalTo: self nodeClass; + assert: element name equals: 'test'. self - should: [self nodeClass named: 'undeclared:test'] - raise: XMLNamespaceException. + should: [ self nodeClass named: 'undeclared:test' ] + raise: XMLNamespaceException ] { #category : #tests } XMLElementTest >> testNamespaceURI [ - | element | + | element | element := self newNode. - self assert: element namespaceURI = ''. + self assert: element namespaceURI equals: ''. element defaultNamespace: 'defaultNS'. - self assert: element namespaceURI = 'defaultNS'. + self assert: element namespaceURI equals: 'defaultNS'. + + element name: 'prefix:test' namespaceURI: 'prefixNS'. + self assert: element namespaceURI equals: 'prefixNS'. - element - name: 'prefix:test' - namespaceURI: 'prefixNS'. - self assert: element namespaceURI = 'prefixNS'. - element defaultNamespace: ''; name: 'test'. - self assert: element namespaceURI = ''. + self assert: element namespaceURI equals: '' ] { #category : #tests } -XMLElementTest >> testNextElement [ - | root nextElement | +XMLElementTest >> testNextElement [ + | root nextElement | root := self newNodeWithElements firstElement. nextElement := nil. - root elements reverseDo: [:each | - self assert: each nextElement = nextElement. - nextElement := each]. + root elements reverseDo: [ :each | + self assert: each nextElement equals: nextElement. + nextElement := each ] ] { #category : #tests } XMLElementTest >> testPrefix [ - | element | + | element | element := self newNode. self - assert: element prefix = ''; - assert: (element name: 'one') == element; - assert: element prefix = ''. + assert: element prefix equals: ''; + assert: (element name: 'one') identicalTo: element; + assert: element prefix equals: ''. - element - declarePrefix: 'prefix' - uri: 'prefixNS'. + element declarePrefix: 'prefix' uri: 'prefixNS'. self - assert: (element prefix: 'prefix') == element; - assert: element name = 'prefix:one'; - assert: element prefix = 'prefix'; - assert: (element name: 'prefix:two') == element; - assert: element name = 'prefix:two'; - assert: element prefix = 'prefix'; - assert: (element prefix: '') == element; - assert: element name = 'two'; - assert: element prefix = ''. + assert: (element prefix: 'prefix') identicalTo: element; + assert: element name equals: 'prefix:one'; + assert: element prefix equals: 'prefix'; + assert: (element name: 'prefix:two') identicalTo: element; + assert: element name equals: 'prefix:two'; + assert: element prefix equals: 'prefix'; + assert: (element prefix: '') identicalTo: element; + assert: element name equals: 'two'; + assert: element prefix equals: ''. self - should: [element prefix: 'undeclared'] - raise: XMLNamespaceException. + should: [ element prefix: 'undeclared' ] + raise: XMLNamespaceException ] { #category : #tests } -XMLElementTest >> testPreviousElement [ - | root previousElement | +XMLElementTest >> testPreviousElement [ + | root previousElement | root := self newNodeWithElements firstElement. previousElement := nil. - root elements do: [:each | - self assert: each previousElement = previousElement. - previousElement := each]. + root elements do: [ :each | + self assert: each previousElement equals: previousElement. + previousElement := each ] ] { #category : #tests } XMLElementTest >> testPrintingDefaultNamespaces [ - | element | - element := - self nodeClass - name: 'element' - namespaceURI: 'default'. - element addNode: - ((self nodeClass - name: 'element' - namespaceURI: '') - addElementNamed: 'empty'; - yourself). - - self assert: - element printString = - ('', - '', - ''). + | element | + element := self nodeClass name: 'element' namespaceURI: 'default'. + element addNode: ((self nodeClass name: 'element' namespaceURI: '') + addElementNamed: 'empty'; + yourself). + self + assert: element printString + equals: + '' + , '' , '' ] { #category : #tests } XMLElementTest >> testPrintingNonRootNamespaces [ - | element | - element := - self nodeClass - name: 'element'. - element addNode: - (self nodeClass - name: 'used:empty' - namespaces: (Array with: '' -> 'defaultNS' with: 'used' -> 'usedNS')). - - self assert: - element printString = - ('', - '', - ''). + | element | + element := self nodeClass name: 'element'. + element addNode: (self nodeClass + name: 'used:empty' + namespaces: + (Array with: '' -> 'defaultNS' with: 'used' -> 'usedNS')). + self + assert: element printString + equals: + '' , '' + , '' ] { #category : #tests } XMLElementTest >> testPrintingRootNamespaces [ - | element | - element := - self nodeClass - name: 'used:element' - namespaces: (Array with: '' -> 'defaultNS' with: 'used' -> 'usedNS'). + | element | + element := self nodeClass + name: 'used:element' + namespaces: + (Array with: '' -> 'defaultNS' with: 'used' -> 'usedNS'). element addElementNamed: 'empty'. - - self assert: - element printString = - ('', - '', - ''). + self + assert: element printString + equals: + '' , '' + , '' ] { #category : #tests } XMLElementTest >> testRemoveAttribute [ - | element | + | element | element := self newElementWithAttributes. - element attributeNodes copy do: [:each | + element attributeNodes copy do: [ :each | self - assert: (element removeAttribute: each name) = each value; + assert: (element removeAttribute: each name) equals: each value; deny: (element includesAttribute: each name). - self - should: [element removeAttribute: each name] - raise: Error]. - self assert: element attributeNodes isEmpty. + self should: [ element removeAttribute: each name ] raise: Error ]. + self assert: element attributeNodes isEmpty ] { #category : #tests } XMLElementTest >> testRemoveAttributeIfAbsent [ - | element | + | element | element := self newElementWithAttributes. - element attributeNodes copy do: [:each | - self assert: - (element - removeAttribute: each name - ifAbsent: [self fail]) = each value. + element attributeNodes copy do: [ :each | + self + assert: + (element removeAttribute: each name ifAbsent: [ self fail ]) + equals: each value. self deny: (element includesAttribute: each name). - self assert: - (element - removeAttribute: each name - ifAbsent: [#absent]) = #absent]. - self assert: element attributeNodes isEmpty. + self + assert: (element removeAttribute: each name ifAbsent: [ #absent ]) + equals: #absent ]. + self assert: element attributeNodes isEmpty ] { #category : #tests } XMLElementTest >> testRemoveAttributeNode [ - | element | + | element | element := self newElementWithAttributes. - element attributeNodes copy do: [:each | + element attributeNodes copy do: [ :each | self - assert: (element removeAttributeNode: each) = each ; + assert: (element removeAttributeNode: each) equals: each; deny: (element attributeNodes includes: each). - self - should: [element removeAttribute: each] - raise: Error]. - self assert: element attributeNodes isEmpty. + self should: [ element removeAttribute: each ] raise: Error ]. + self assert: element attributeNodes isEmpty ] { #category : #tests } XMLElementTest >> testRemoveAttributeNodeIfAbsent [ - | element | + | element | element := self newElementWithAttributes. - element attributeNodes copy do: [:each | - self assert: - (element - removeAttributeNode: each - ifAbsent: [self fail]) = each. + element attributeNodes copy do: [ :each | + self + assert: (element removeAttributeNode: each ifAbsent: [ self fail ]) + equals: each. self deny: (element attributeNodes includes: each). - self assert: - (element - removeAttributeNode: each - ifAbsent: [#absent]) = #absent]. - self assert: element attributeNodes isEmpty. + self + assert: (element removeAttributeNode: each ifAbsent: [ #absent ]) + equals: #absent ]. + self assert: element attributeNodes isEmpty ] { #category : #tests } XMLElementTest >> testRemoveAttributes [ - | element | + | element | element := self newElementWithAttributes. self - assert: element removeAttributes == element; + assert: element removeAttributes identicalTo: element; assert: element attributeNodes isEmpty; - deny: element hasAttributes. + deny: element hasAttributes ] { #category : #tests } XMLElementTest >> testResolvePrefix [ - | element | + | element | element := self newNode. - self namespaces keysAndValuesDo: [:prefix :uri | - self assert: (element resolvePrefix: prefix) = ''. + self namespaces keysAndValuesDo: [ :prefix :uri | + self assert: (element resolvePrefix: prefix) equals: ''. element declarePrefix: prefix uri: uri. - self assert: (element resolvePrefix: prefix) = uri]. - - self assert: - (element resolvePrefix: 'xml') = XMLNamespaceScope xmlNamespaceURI. - self assert: - (element resolvePrefix: 'xmlns') = XMLNamespaceScope xmlnsNamespaceURI. + self assert: (element resolvePrefix: prefix) equals: uri ]. + self + assert: (element resolvePrefix: 'xml') + equals: XMLNamespaceScope xmlNamespaceURI. + self + assert: (element resolvePrefix: 'xmlns') + equals: XMLNamespaceScope xmlnsNamespaceURI. (element := self newNode) usesNamespaces: false. self - assert: (element resolvePrefix: 'xml') = ''; - assert: (element resolvePrefix: 'xmlns') = ''; - deny: element usesNamespaces. + assert: (element resolvePrefix: 'xml') equals: ''; + assert: (element resolvePrefix: 'xmlns') equals: ''; + deny: element usesNamespaces ] { #category : #tests } XMLElementTest >> testResolvePrefixIfUnresolvable [ - | element | + | element | element := self newNode. - self namespaces keysAndValuesDo: [:prefix :uri | - self assert: - (element - resolvePrefix: prefix - ifUnresolvable: ['unresolvable']) = 'unresolvable'. + self namespaces keysAndValuesDo: [ :prefix :uri | + self + assert: + (element resolvePrefix: prefix ifUnresolvable: [ 'unresolvable' ]) + equals: 'unresolvable'. element declarePrefix: prefix uri: uri. - self assert: - (element - resolvePrefix: prefix - ifUnresolvable: [self fail]) = uri]. - - self assert: - (element - resolvePrefix: 'xml' - ifUnresolvable: [self fail]) = XMLNamespaceScope xmlNamespaceURI. - self assert: - (element - resolvePrefix: 'xmlns' - ifUnresolvable: [self fail]) = XMLNamespaceScope xmlnsNamespaceURI. + self + assert: + (element resolvePrefix: prefix ifUnresolvable: [ self fail ]) + equals: uri ]. + self + assert: (element resolvePrefix: 'xml' ifUnresolvable: [ self fail ]) + equals: XMLNamespaceScope xmlNamespaceURI. + self + assert: + (element resolvePrefix: 'xmlns' ifUnresolvable: [ self fail ]) + equals: XMLNamespaceScope xmlnsNamespaceURI. (element := self newNode) usesNamespaces: false. - self assert: - (element - resolvePrefix: 'xml' - ifUnresolvable: ['unresolvable']) = 'unresolvable'. - self assert: - (element - resolvePrefix: 'xmlns' - ifUnresolvable: ['unresolvable']) = 'unresolvable'. - self deny: element usesNamespaces. + self + assert: + (element resolvePrefix: 'xml' ifUnresolvable: [ 'unresolvable' ]) + equals: 'unresolvable'. + self + assert: + (element resolvePrefix: 'xmlns' ifUnresolvable: [ 'unresolvable' ]) + equals: 'unresolvable'. + self deny: element usesNamespaces ] { #category : #tests } @@ -1690,77 +1643,77 @@ XMLElementTest >> testResolvePrefixesOfNamespaceURI [ { #category : #tests } XMLElementTest >> testSetAttributes [ - | element newAttributeAssociations | + | element newAttributeAssociations | element := self newElementWithAttributes. - newAttributeAssociations := - Array - with: 'newName' -> 'newValue' - with: 'newName2' -> 'newValue2'. + newAttributeAssociations := Array + with: 'newName' -> 'newValue' + with: 'newName2' -> 'newValue2'. element setAttributes: newAttributeAssociations. - - self assert: - (element attributeNodes collect: [:each | - each name -> each value]) asArray = - newAttributeAssociations. + self + assert: + (element attributeNodes collect: [ :each | each name -> each value ]) + asArray + equals: newAttributeAssociations ] { #category : #tests } XMLElementTest >> testSortKey [ - self assert: (self nodeClass named: 'test') sortKey = 'test' + + self assert: (self nodeClass named: 'test') sortKey equals: 'test' ] { #category : #tests } XMLElementTest >> testUndeclareDefaultNamespace [ - | element oldRootDefaultNamespace elementsWithCustomDefaultNamespace | + | element oldRootDefaultNamespace elementsWithCustomDefaultNamespace | element := self newNodeWithElements. oldRootDefaultNamespace := element defaultNamespace. - elementsWithCustomDefaultNamespace := - element descendantElementsSelect: [:each | - each defaultNamespace notEmpty - and: [each defaultNamespace ~= oldRootDefaultNamespace]]. + elementsWithCustomDefaultNamespace := element + descendantElementsSelect: [ + :each | + each defaultNamespace + notEmpty and: [ + each defaultNamespace + ~= oldRootDefaultNamespace ] ]. element defaultNamespace: 'newDefaultNS'; undeclareDefaultNamespace; - allElementsDo: [:each | + allElementsDo: [ :each | (elementsWithCustomDefaultNamespace includes: each) ifTrue: [ self assert: each defaultNamespace notEmpty; - deny: each defaultNamespace = oldRootDefaultNamespace; - deny: each defaultNamespace = 'newDefaultNS'] - ifFalse: [self assert: each defaultNamespace isEmpty]]. + deny: each defaultNamespace equals: oldRootDefaultNamespace; + deny: each defaultNamespace equals: 'newDefaultNS' ] + ifFalse: [ self assert: each defaultNamespace isEmpty ] ]. (element := self newNode) usesNamespaces: false. self - assert: element undeclareDefaultNamespace == element; - assert: element usesNamespaces. + assert: element undeclareDefaultNamespace identicalTo: element; + assert: element usesNamespaces ] { #category : #tests } XMLElementTest >> testUndeclarePrefix [ - | element | + | element | element := self newElementWithAttributes. - element - declarePrefix: 'unused' - uri: 'unusedNS'. + element declarePrefix: 'unused' uri: 'unusedNS'. element addElementNamed: 'prefixTwo:inner'. - self - assert: (element undeclarePrefix: '') == element; - assert: (element undeclarePrefix: 'unused') == element. - element allElementsDo: [:each | + assert: (element undeclarePrefix: '') identicalTo: element; + assert: (element undeclarePrefix: 'unused') identicalTo: element. + element allElementsDo: [ :each | self deny: (each isDeclaredPrefix: ''); deny: (each isDeclaredPrefix: 'unusused'); - assert: (each isDeclaredPrefix: 'prefixTwo')]. + assert: (each isDeclaredPrefix: 'prefixTwo') ]. "this prefix is used by the subelement so it can't be undeclared" self - should: [element undeclarePrefix: 'prefixTwo'] + should: [ element undeclarePrefix: 'prefixTwo' ] raise: XMLNamespaceException. (element := self newElementWithAttributes) @@ -1768,69 +1721,67 @@ XMLElementTest >> testUndeclarePrefix [ put: 'value'. "this prefix is used by an attribute so it can't be undeclared" self - should: [element undeclarePrefix: 'prefixTwo'] + should: [ element undeclarePrefix: 'prefixTwo' ] raise: XMLNamespaceException. (element := self newNode) usesNamespaces: false. self - assert: (element undeclarePrefix: '') == element; - assert: element usesNamespaces. + assert: (element undeclarePrefix: '') identicalTo: element; + assert: element usesNamespaces ] { #category : #tests } XMLElementTest >> testUndeclarePrefixes [ - | element innerElement | - element := - self nodeClass - name: 'outer' - namespaces: self namespaces - attributes: self unprefixedAttributes. + | element innerElement | + element := self nodeClass + name: 'outer' + namespaces: self namespaces + attributes: self unprefixedAttributes. (innerElement := element addElementNamed: 'prefixTwo:inner') declarePrefix: 'prefixTwo' uri: 'newNS'. - self - assert: (element undeclarePrefixes) == element; + assert: element undeclarePrefixes identicalTo: element; deny: element hasNamespaces; assert: innerElement hasNamespaces; - assert: innerElement declaredPrefixes asArray = #('prefixTwo'); - assert: (innerElement resolvePrefix: 'prefixTwo') = 'newNS'. + assert: innerElement declaredPrefixes asArray + equals: #( 'prefixTwo' ); + assert: (innerElement resolvePrefix: 'prefixTwo') equals: 'newNS'. self - should: [innerElement undeclarePrefixes] + should: [ innerElement undeclarePrefixes ] raise: XMLNamespaceException. (element := self newNode) usesNamespaces: false. self - assert: element undeclarePrefixes == element; - assert: element usesNamespaces. + assert: element undeclarePrefixes identicalTo: element; + assert: element usesNamespaces ] { #category : #tests } XMLElementTest >> testWriteXMLOn [ - | element attributes | + | element attributes | element := self nodeClass named: 'element'. - self assert: element printString = ''. - + self assert: element printString equals: ''. + element addString: 'test'. - self assert: element printString = 'test'. - - "attribute order should be preserved when printing" - attributes := - self attributesClass - with: 'b' -> 'one' - with: 'a' -> 'two' - with: 'c' -> 'three' - with: 'e' -> 'four' - with: 'd' -> 'five'. + self assert: element printString equals: 'test'. + attributes := self attributesClass + with: 'b' -> 'one' + with: 'a' -> 'two' + with: 'c' -> 'three' + with: 'e' -> 'four' + with: 'd' -> 'five'. element setAttributes: attributes. - self assert: - element printString = - 'test'. + self + assert: element printString + equals: + 'test'. element setAttributes: attributes associations reversed. - self assert: - element printString = - 'test'. + self + assert: element printString + equals: + 'test' ] diff --git a/src/XML-Parser-Tests/XMLEncodingDetectorTest.class.st b/src/XML-Parser-Tests/XMLEncodingDetectorTest.class.st index d6ef013e..3789c721 100644 --- a/src/XML-Parser-Tests/XMLEncodingDetectorTest.class.st +++ b/src/XML-Parser-Tests/XMLEncodingDetectorTest.class.st @@ -104,54 +104,49 @@ XMLEncodingDetectorTest >> newStreamOn: aString [ { #category : #tests } XMLEncodingDetectorTest >> testStreamConverterForEncoding [ - self explicitEncodedInputCollections do: [:each | - | stream startPosition streamConverter | + self explicitEncodedInputCollections do: [ :each | + | stream startPosition streamConverter | stream := self newStreamOn: each. startPosition := stream position. - streamConverter := - (self newExplicitEncodingDetectorOn: stream) - streamConverterForEncoding. + streamConverter := (self newExplicitEncodingDetectorOn: stream) + streamConverterForEncoding. self deny: streamConverter isNil; - assert: streamConverter class == self explicitStreamConverterClass; + assert: streamConverter class + identicalTo: self explicitStreamConverterClass; deny: streamConverter isImplicit; - assert: - stream position = - (startPosition + self inputCollectionByteOrderMark size)]. + assert: stream position + equals: startPosition + self inputCollectionByteOrderMark size ]. - self implicitEncodedInputCollections do: [:each | + self implicitEncodedInputCollections do: [ :each | | stream startPosition streamConverter | - stream := self newStreamOn: each. startPosition := stream position. - streamConverter := - (self newExplicitEncodingDetectorOn: stream) - streamConverterForEncoding. + streamConverter := (self newExplicitEncodingDetectorOn: stream) + streamConverterForEncoding. self assert: streamConverter isNil; - assert: stream position = startPosition. + assert: stream position equals: startPosition. stream := self newStreamOn: each. startPosition := stream position. - streamConverter := - (self newImplicitEncodingDetectorOn: stream) - streamConverterForEncoding. + streamConverter := (self newImplicitEncodingDetectorOn: stream) + streamConverterForEncoding. self deny: streamConverter isNil; - assert: streamConverter class == self implicitStreamConverterClass; + assert: streamConverter class + identicalTo: self implicitStreamConverterClass; assert: streamConverter isImplicit; - assert: stream position = startPosition]. + assert: stream position equals: startPosition ]. - self invalidImplicitEncodedInputCollections do: [:each | + self invalidImplicitEncodedInputCollections do: [ :each | | stream startPosition streamConverter | - stream := self newStreamOn: each. startPosition := stream position. - streamConverter := - (self newImplicitEncodingDetectorOn: stream) - streamConverterForEncoding. + streamConverter := (self newImplicitEncodingDetectorOn: stream) + streamConverterForEncoding. self assert: streamConverter isNil; - assert: stream position = startPosition] + assert: stream position equals: startPosition ] ] diff --git a/src/XML-Parser-Tests/XMLExceptionTest.class.st b/src/XML-Parser-Tests/XMLExceptionTest.class.st index 427af57a..55c4fcdf 100644 --- a/src/XML-Parser-Tests/XMLExceptionTest.class.st +++ b/src/XML-Parser-Tests/XMLExceptionTest.class.st @@ -50,196 +50,184 @@ XMLExceptionTest >> otherExceptionClass [ { #category : #tests } XMLExceptionTest >> testFormatMessageWith [ - | exception | + | exception | exception := self newException. - self assert: - (exception - formatMessage: '{1}' - with: 'one') == exception. + self + assert: (exception formatMessage: '{1}' with: 'one') + identicalTo: exception. self assert: exception messageText equals: 'one' ] { #category : #tests } XMLExceptionTest >> testFormatMessageWithArguments [ - | exception | + | exception | exception := self newException. - self assert: - (exception - formatMessage: '{1} {2} {3} {4}' - withArguments: #('one' 2 'three' 4)) == exception. + self + assert: (exception + formatMessage: '{1} {2} {3} {4}' + withArguments: #( 'one' 2 'three' 4 )) + identicalTo: exception. self assert: exception messageText equals: 'one 2 three 4' ] { #category : #tests } XMLExceptionTest >> testFormatMessageWithWith [ - | exception | + | exception | exception := self newException. - self assert: - (exception - formatMessage: '{1} {2}' - with: 'one' - with: 2) == exception. + self + assert: (exception formatMessage: '{1} {2}' with: 'one' with: 2) + identicalTo: exception. self assert: exception messageText equals: 'one 2' ] { #category : #tests } XMLExceptionTest >> testFormatMessageWithWithWith [ - | exception | + | exception | exception := self newException. - self assert: - (exception - formatMessage: '{1} {2} {3}' - with: 'one' - with: 2 - with: 'three') == exception. + self + assert: (exception + formatMessage: '{1} {2} {3}' + with: 'one' + with: 2 + with: 'three') + identicalTo: exception. self assert: exception messageText equals: 'one 2 three' ] { #category : #tests } XMLExceptionTest >> testFormatMessageWithWithWithWith [ - | exception | + | exception | exception := self newException. - self assert: - (exception - formatMessage: '{1} {2} {3} {4}' - with: 'one' - with: 2 - with: 'three' - with: 4) == exception. + self + assert: (exception + formatMessage: '{1} {2} {3} {4}' + with: 'one' + with: 2 + with: 'three' + with: 4) + identicalTo: exception. self assert: exception messageText equals: 'one 2 three 4' ] { #category : #tests } XMLExceptionTest >> testFormatSignalWith [ - (Array - with: self exceptionClass - with: self newException) - do: [:each | | raisedException | - [each - formatSignal: '{1}' - with: 1] - on: Error - do: [:exception | raisedException := exception]. - self - assert: raisedException notNil; - assert: raisedException class == self exceptionClass; - assert: raisedException messageText equals: '1'] + + (Array with: self exceptionClass with: self newException) do: [ :each | + | raisedException | + [ each formatSignal: '{1}' with: 1 ] + on: Error + do: [ :exception | raisedException := exception ]. + self + assert: raisedException notNil; + assert: raisedException class identicalTo: self exceptionClass; + assert: raisedException messageText equals: '1' ] ] { #category : #tests } XMLExceptionTest >> testFormatSignalWithArguments [ - (Array - with: self exceptionClass - with: self newException) - do: [:each | | raisedException | - [each - formatSignal: '{1} {2} {3} {4}' - withArguments: #(1 'two' 3 'four')] - on: Error - do: [:exception | raisedException := exception]. - self - assert: raisedException notNil; - assert: raisedException class == self exceptionClass; - assert: raisedException messageText equals: '1 two 3 four'] + + (Array with: self exceptionClass with: self newException) do: [ :each | + | raisedException | + [ + each + formatSignal: '{1} {2} {3} {4}' + withArguments: #( 1 'two' 3 'four' ) ] + on: Error + do: [ :exception | raisedException := exception ]. + self + assert: raisedException notNil; + assert: raisedException class identicalTo: self exceptionClass; + assert: raisedException messageText equals: '1 two 3 four' ] ] { #category : #tests } XMLExceptionTest >> testFormatSignalWithWith [ - (Array - with: self exceptionClass - with: self newException) - do: [:each | | raisedException | - [each - formatSignal: '{1} {2}' - with: 1 - with: 'two'] - on: Error - do: [:exception | raisedException := exception]. - self - assert: raisedException notNil; - assert: raisedException class == self exceptionClass; - assert: raisedException messageText equals: '1 two'] + + (Array with: self exceptionClass with: self newException) do: [ :each | + | raisedException | + [ each formatSignal: '{1} {2}' with: 1 with: 'two' ] + on: Error + do: [ :exception | raisedException := exception ]. + self + assert: raisedException notNil; + assert: raisedException class identicalTo: self exceptionClass; + assert: raisedException messageText equals: '1 two' ] ] { #category : #tests } XMLExceptionTest >> testFormatSignalWithWithWith [ - (Array - with: self exceptionClass - with: self newException) - do: [:each | | raisedException | - [each - formatSignal: '{1} {2} {3}' - with: 1 - with: 'two' - with: 3] - on: Error - do: [:exception | raisedException := exception]. - self - assert: raisedException notNil; - assert: raisedException class == self exceptionClass; - assert: raisedException messageText equals: '1 two 3'] + + (Array with: self exceptionClass with: self newException) do: [ :each | + | raisedException | + [ + each + formatSignal: '{1} {2} {3}' + with: 1 + with: 'two' + with: 3 ] + on: Error + do: [ :exception | raisedException := exception ]. + self + assert: raisedException notNil; + assert: raisedException class identicalTo: self exceptionClass; + assert: raisedException messageText equals: '1 two 3' ] ] { #category : #tests } XMLExceptionTest >> testFormatSignalWithWithWithWith [ - (Array - with: self exceptionClass - with: self newException) - do: [:each | | raisedException | - [each - formatSignal: '{1} {2} {3} {4}' - with: 1 - with: 'two' - with: 3 - with: 'four'] - on: Error - do: [:exception | raisedException := exception]. - self - assert: raisedException notNil; - assert: raisedException class == self exceptionClass; - assert: raisedException messageText equals: '1 two 3 four'] + + (Array with: self exceptionClass with: self newException) do: [ :each | + | raisedException | + [ + each + formatSignal: '{1} {2} {3} {4}' + with: 1 + with: 'two' + with: 3 + with: 'four' ] + on: Error + do: [ :exception | raisedException := exception ]. + self + assert: raisedException notNil; + assert: raisedException class identicalTo: self exceptionClass; + assert: raisedException messageText equals: '1 two 3 four' ] ] { #category : #tests } XMLExceptionTest >> testInheritMessageFrom [ - | exception otherException | + | exception otherException | exception := self newException. otherException := self newOtherExceptionWithErrorMessage. self - assert: (exception inheritMessageFrom: otherException) == exception; - assert: - exception messageText equals: - ('({1}) {2}' format: - (Array - with: self otherExceptionClass name - with: self errorMessage)) + assert: (exception inheritMessageFrom: otherException) + identicalTo: exception; + assert: exception messageText equals: ('({1}) {2}' format: + (Array + with: self otherExceptionClass name + with: self errorMessage)) ] { #category : #tests } XMLExceptionTest >> testSignalMessageFrom [ - | otherException | + | otherException | otherException := self newOtherExceptionWithErrorMessage. - (Array - with: self exceptionClass - with: self newException) - do: [:each | | raisedException | - [each signalMessageFrom: otherException] - on: Error - do: [:exception | raisedException := exception]. - self - assert: raisedException notNil; - assert: raisedException class == self exceptionClass; - assert: - raisedException messageText equals: - ('({1}) {2}' format: - (Array - with: self otherExceptionClass name - with: self errorMessage))] + (Array with: self exceptionClass with: self newException) do: [ :each | + | raisedException | + [ each signalMessageFrom: otherException ] + on: Error + do: [ :exception | raisedException := exception ]. + self + assert: raisedException notNil; + assert: raisedException class identicalTo: self exceptionClass; + assert: raisedException messageText equals: ('({1}) {2}' format: + (Array + with: self otherExceptionClass name + with: self errorMessage)) ] ] diff --git a/src/XML-Parser-Tests/XMLExternalEntityTest.class.st b/src/XML-Parser-Tests/XMLExternalEntityTest.class.st index 1b3d9e2e..4eca19fc 100644 --- a/src/XML-Parser-Tests/XMLExternalEntityTest.class.st +++ b/src/XML-Parser-Tests/XMLExternalEntityTest.class.st @@ -239,65 +239,53 @@ XMLExternalEntityTest >> testExternalSubsetReadLimit [ { #category : #tests } XMLExternalEntityTest >> testOnFileNamed [ - self - skipOrReturnWith: [^ self] - ifSkippable: #testOnFileNamed. - self tempFileManager newFileHandleDo: [:fileHandle | | parser | + self skipOrReturnWith: [ ^ self ] ifSkippable: #testOnFileNamed. + + self tempFileManager newFileHandleDo: [ :fileHandle | + | parser | self tempFileManager createFileWithContents: '' forHandle: fileHandle. self - shouldnt: [parser := SAXHandler onFileNamed: fileHandle path] + shouldnt: [ parser := SAXHandler onFileNamed: fileHandle path ] raise: XMLFileException. self - assert: parser documentURI = fileHandle path; - assert: parser documentURI asXMLURI isLocal] + assert: parser documentURI equals: fileHandle path; + assert: parser documentURI asXMLURI isLocal ] ] { #category : #tests } XMLExternalEntityTest >> testOnURL [ - | parser | - self - skipOrReturnWith: [^ self] - ifSkippable: #testOnURL. + | parser | + self skipOrReturnWith: [ ^ self ] ifSkippable: #testOnURL. self - shouldnt: [parser := SAXHandler onURL: self feedURL] + shouldnt: [ parser := SAXHandler onURL: self feedURL ] raise: XMLHTTPException. self - assert: parser documentURI = self feedURL; + assert: parser documentURI equals: self feedURL; deny: parser documentURI asXMLURI isLocal ] { #category : #tests } XMLExternalEntityTest >> testOnURLUpToLimit [ - | parser size | - self - skipOrReturnWith: [^ self] - ifSkippable: #testOnURLUpToLimit. + | parser size | + self skipOrReturnWith: [ ^ self ] ifSkippable: #testOnURLUpToLimit. - size := - (self feedURL asXMLURI - getUpToLimit: nil - decoding: false) size. + size := (self feedURL asXMLURI getUpToLimit: nil decoding: false) + size. self shouldnt: [ - parser := - SAXHandler - onURL: self feedURL - upToLimit: size] + parser := SAXHandler onURL: self feedURL upToLimit: size ] raise: XMLLimitException. - self assert: parser documentReadLimit = size. + self assert: parser documentReadLimit equals: size. self should: [ - (SAXHandler - onURL: self feedURL - upToLimit: size - 1) - parseDocument] + (SAXHandler onURL: self feedURL upToLimit: size - 1) parseDocument ] raise: XMLLimitException ] @@ -338,110 +326,114 @@ XMLExternalEntityTest >> testParsingDocBookExample [ { #category : #tests } XMLExternalEntityTest >> testParsingEncodedFile [ "This test creates/deletes a file so is skipped by default" + self - skipOrReturnWith: [^ self] + skipOrReturnWith: [ ^ self ] ifSkippable: #testParsingEncodedFile. - self tempFileManager newFileHandleDo: [:fileHandle | - self encodingNames do: [:encoding | | document documentFromFile | + self tempFileManager newFileHandleDo: [ :fileHandle | + self encodingNames do: [ :encoding | + | document documentFromFile | document := XMLDOMParser parse: self wideCharacterXML. - fileHandle writeStreamDo: [:stream | + fileHandle writeStreamDo: [ :stream | stream streamConverter: encoding asXMLStreamConverter; - nextPutAll: document printString]. + nextPutAll: document printString ]. self shouldnt: [ - documentFromFile := - XMLDOMParser parseFileNamed: fileHandle path] + documentFromFile := XMLDOMParser parseFileNamed: fileHandle path ] raise: XMLFileException. self - assert: documentFromFile encoding = ''; - assert: documentFromFile printString = document printString]] + assert: documentFromFile encoding equals: ''; + assert: documentFromFile printString equals: document printString ] ] ] { #category : #tests } XMLExternalEntityTest >> testParsingEncodedFileWithBOM [ "This test creates/deletes a file so is skipped by default" + self - skipOrReturnWith: [^ self] + skipOrReturnWith: [ ^ self ] ifSkippable: #testParsingEncodedFileWithBOM. - self tempFileManager newFileHandleDo: [:fileHandle | - self encodingNames do: [:encoding | | document documentFromFile | + self tempFileManager newFileHandleDo: [ :fileHandle | + self encodingNames do: [ :encoding | + | document documentFromFile | document := XMLDOMParser parse: self wideCharacterXML. - fileHandle writeStreamDo: [:stream | + fileHandle writeStreamDo: [ :stream | stream streamConverter: encoding asXMLStreamConverter; nextPutByteOrderMark; - nextPutAll: document printString]. + nextPutAll: document printString ]. self shouldnt: [ - documentFromFile := - XMLDOMParser parseFileNamed: fileHandle path] + documentFromFile := XMLDOMParser parseFileNamed: fileHandle path ] raise: XMLFileException. self - assert: documentFromFile encoding = ''; - assert: documentFromFile printString = document printString]] + assert: documentFromFile encoding equals: ''; + assert: documentFromFile printString equals: document printString ] ] ] { #category : #tests } XMLExternalEntityTest >> testParsingEncodedFileWithEncodingAttribute [ "This test creates/deletes a file so is skipped by default" + self - skipOrReturnWith: [^ self] + skipOrReturnWith: [ ^ self ] ifSkippable: #testParsingEncodedFileWithEncodingAttribute. - self tempFileManager newFileHandleDo: [:fileHandle | - self encodingNames do: [:encoding | | document documentFromFile | + self tempFileManager newFileHandleDo: [ :fileHandle | + self encodingNames do: [ :encoding | + | document documentFromFile | document := XMLDOMParser parse: self wideCharacterXML. document encoding: encoding. - fileHandle writeStreamDo: [:stream | + fileHandle writeStreamDo: [ :stream | stream streamConverter: encoding asXMLStreamConverter; - nextPutAll: document printString]. + nextPutAll: document printString ]. self shouldnt: [ - documentFromFile := - XMLDOMParser parseFileNamed: fileHandle path] + documentFromFile := XMLDOMParser parseFileNamed: fileHandle path ] raise: XMLFileException. self - assert: documentFromFile encoding = encoding; - assert: documentFromFile printString = document printString]] + assert: documentFromFile encoding equals: encoding; + assert: documentFromFile printString equals: document printString ] ] ] { #category : #tests } XMLExternalEntityTest >> testParsingEncodedFileWithEncodingAttributeAndBOM [ "This test creates/deletes a file so is skipped by default" + self - skipOrReturnWith: [^ self] + skipOrReturnWith: [ ^ self ] ifSkippable: #testParsingEncodedFileWithEncodingAttributeAndBOM. - self tempFileManager newFileHandleDo: [:fileHandle | - self encodingNames do: [:encoding | | document documentFromFile | + self tempFileManager newFileHandleDo: [ :fileHandle | + self encodingNames do: [ :encoding | + | document documentFromFile | document := XMLDOMParser parse: self wideCharacterXML. document encoding: encoding. - fileHandle writeStreamDo: [:stream | + fileHandle writeStreamDo: [ :stream | stream streamConverter: encoding asXMLStreamConverter; nextPutByteOrderMark; - nextPutAll: document printString]. + nextPutAll: document printString ]. self shouldnt: [ - documentFromFile := - XMLDOMParser parseFileNamed: fileHandle path] + documentFromFile := XMLDOMParser parseFileNamed: fileHandle path ] raise: XMLFileException. self - assert: documentFromFile encoding = encoding; - assert: documentFromFile printString = document printString]] + assert: documentFromFile encoding equals: encoding; + assert: documentFromFile printString equals: document printString ] ] ] { #category : #tests } XMLExternalEntityTest >> testParsingExternalEntities [ "This test uses HTTP so is skipped by default." - | entityCacheCopy | + | entityCacheCopy | self - skipOrReturnWith: [^ self] + skipOrReturnWith: [ ^ self ] ifSkippable: #testParsingExternalEntities. DTDCachingExternalEntityResolver clearEntityCache. @@ -461,20 +453,21 @@ XMLExternalEntityTest >> testParsingExternalEntities [ usingNamespaces: true validation: true externalEntities: true. - DTDCachingExternalEntityResolver entityCache keysAndValuesDo: [:key :value | - self assert: - (entityCacheCopy - at: key - ifAbsent: [self fail]) == value] + DTDCachingExternalEntityResolver entityCache keysAndValuesDo: [ + :key + :value | + self + assert: (entityCacheCopy at: key ifAbsent: [ self fail ]) + identicalTo: value ] ] { #category : #tests } XMLExternalEntityTest >> testParsingExternalEntitiesLimit [ "This test uses HTTP so is skipped by default." - | handler parser limitedResolver totalResolvedExternalEntities | + | handler parser limitedResolver totalResolvedExternalEntities | self - skipOrReturnWith: [^ self] + skipOrReturnWith: [ ^ self ] ifSkippable: #testParsingExternalEntitiesLimit. DTDCachingExternalEntityResolver clearEntityCache. @@ -485,7 +478,8 @@ XMLExternalEntityTest >> testParsingExternalEntitiesLimit [ (limitedResolver := parser driver externalEntityResolver) maxExternalEntities: nil. parser parseDocument. - totalResolvedExternalEntities := limitedResolver totalResolvedExternalEntities. + totalResolvedExternalEntities := limitedResolver + totalResolvedExternalEntities. self assert: totalResolvedExternalEntities > 0. "should report the same number of resolved entities each time, even if @@ -497,18 +491,16 @@ XMLExternalEntityTest >> testParsingExternalEntitiesLimit [ (limitedResolver := parser driver externalEntityResolver) maxExternalEntities: totalResolvedExternalEntities. parser parseDocument. - self assert: - limitedResolver totalResolvedExternalEntities = - totalResolvedExternalEntities. + self + assert: limitedResolver totalResolvedExternalEntities + equals: totalResolvedExternalEntities. (handler := SAXHandler on: self musicXMLDocument) resolvesExternalEntities: true. parser := handler parser. (limitedResolver := parser driver externalEntityResolver) maxExternalEntities: totalResolvedExternalEntities - 1. - self - should: [parser parseDocument] - raise: XMLLimitException + self should: [ parser parseDocument ] raise: XMLLimitException ] { #category : #tests } diff --git a/src/XML-Parser-Tests/XMLFileHandleTest.class.st b/src/XML-Parser-Tests/XMLFileHandleTest.class.st index 8b7b59c3..60beec96 100644 --- a/src/XML-Parser-Tests/XMLFileHandleTest.class.st +++ b/src/XML-Parser-Tests/XMLFileHandleTest.class.st @@ -33,16 +33,18 @@ XMLFileHandleTest class >> skippableTests [ { #category : #asserting } XMLFileHandleTest >> assertIsDecodedFileContents: aCollection [ + self assert: aCollection isString; - assert: aCollection = self decodedFileContents + assert: aCollection equals: self decodedFileContents ] { #category : #asserting } XMLFileHandleTest >> assertIsEncodedFileContentsWithBOM: aCollection [ - ^ self assert: - aCollection asByteArray = - self encodedFileContentsWithByteOrderMark asByteArray + + ^ self + assert: aCollection asByteArray + equals: self encodedFileContentsWithByteOrderMark asByteArray ] { #category : #accessing } diff --git a/src/XML-Parser-Tests/XMLGeneralEntityDeclarationTest.class.st b/src/XML-Parser-Tests/XMLGeneralEntityDeclarationTest.class.st index a433fe56..4e7d9541 100644 --- a/src/XML-Parser-Tests/XMLGeneralEntityDeclarationTest.class.st +++ b/src/XML-Parser-Tests/XMLGeneralEntityDeclarationTest.class.st @@ -23,45 +23,52 @@ XMLGeneralEntityDeclarationTest >> testIsUnparsed [ { #category : #tests } XMLGeneralEntityDeclarationTest >> testNData [ - | declaration | + | declaration | declaration := self newNode. self - assert: declaration ndata = ''; - assert: (declaration ndata: 'test') == declaration; - assert: declaration ndata = 'test' + assert: declaration ndata equals: ''; + assert: (declaration ndata: 'test') identicalTo: declaration; + assert: declaration ndata equals: 'test' ] { #category : #tests } XMLGeneralEntityDeclarationTest >> testNamePublicIDSystemIDNdata [ - | declaration | - declaration := - self nodeClass - name: 'one' - publicID: 'two' - systemID: 'three' - ndata: 'four'. + | declaration | + declaration := self nodeClass + name: 'one' + publicID: 'two' + systemID: 'three' + ndata: 'four'. self - assert: declaration class == self nodeClass; - assert: declaration name = 'one'; - assert: declaration publicID = 'two'; - assert: declaration systemID = 'three'; - assert: declaration ndata = 'four' + assert: declaration class identicalTo: self nodeClass; + assert: declaration name equals: 'one'; + assert: declaration publicID equals: 'two'; + assert: declaration systemID equals: 'three'; + assert: declaration ndata equals: 'four' ] { #category : #tests } XMLGeneralEntityDeclarationTest >> testWriteXMLOn [ - self assert: - (self nodeClass name: 'one' replacement: 'two') printString = - ''. - self assert: - (self nodeClass name: 'one' publicID: 'two' systemID: 'three') printString = - ''. - self assert: - (self nodeClass name: 'one' publicID: '' systemID: 'three') printString = - ''. - self assert: - (self nodeClass name: 'one' publicID: 'two' systemID: 'three' ndata: 'four') printString = - '' + + self + assert: (self nodeClass name: 'one' replacement: 'two') printString + equals: ''. + self + assert: + (self nodeClass name: 'one' publicID: 'two' systemID: 'three') + printString + equals: ''. + self + assert: (self nodeClass name: 'one' publicID: '' systemID: 'three') + printString + equals: ''. + self + assert: (self nodeClass + name: 'one' + publicID: 'two' + systemID: 'three' + ndata: 'four') printString + equals: '' ] diff --git a/src/XML-Parser-Tests/XMLHTTPMIMETypeTest.class.st b/src/XML-Parser-Tests/XMLHTTPMIMETypeTest.class.st index 1f00a76b..283eb31a 100644 --- a/src/XML-Parser-Tests/XMLHTTPMIMETypeTest.class.st +++ b/src/XML-Parser-Tests/XMLHTTPMIMETypeTest.class.st @@ -6,16 +6,18 @@ Class { { #category : #asserting } XMLHTTPMIMETypeTest >> assertMIMEType: aFirstMIMEType doesNotEqual: aSecondMIMEType [ + self - deny: aFirstMIMEType = aSecondMIMEType; - deny: aSecondMIMEType = aFirstMIMEType + deny: aFirstMIMEType equals: aSecondMIMEType; + deny: aSecondMIMEType equals: aFirstMIMEType ] { #category : #asserting } XMLHTTPMIMETypeTest >> assertMIMEType: aFirstMIMEType equals: aSecondMIMEType [ + self - assert: aFirstMIMEType = aSecondMIMEType; - assert: aSecondMIMEType = aFirstMIMEType + assert: aFirstMIMEType equals: aSecondMIMEType; + assert: aSecondMIMEType equals: aFirstMIMEType ] { #category : #tests } @@ -314,36 +316,19 @@ XMLHTTPMIMETypeTest >> testPrintOn [ { #category : #tests } XMLHTTPMIMETypeTest >> testSubType [ - #('/{1}' - ' / {1} ' - 'application/{1}' - ' application / {1} ' - '/{1};' - ' / {1} ; ' - '/{1};charset=utf8' - ' / {1} ; charset=utf8 ' - 'application/{1};charset=utf8' - ' application / {1} ; charset=utf8') - do: [:template | - #(#('xml') #('Xml') #('XML')) - do: [:values | - self assert: - (XMLHTTPMIMEType fromString: - (template format: values)) subType equals: 'xml']]. - #('' - ' ' - '/' - ' / ' - ';' - ' ; ' - 'application' - ' application ' - 'application/' - ' application / ' - ';charset=utf8' - ' ; charset=utf8 ' - 'application/;charset=utf8' - ' application / ; charset=utf8 ') - do: [:each | - self assert: (XMLHTTPMIMEType fromString: each) subType = ''] + + #( '/{1}' ' / {1} ' 'application/{1}' ' application / {1} ' + '/{1};' ' / {1} ; ' '/{1};charset=utf8' ' / {1} ; charset=utf8 ' + 'application/{1};charset=utf8' ' application / {1} ; charset=utf8' ) + do: [ :template | + #( #( 'xml' ) #( 'Xml' ) #( 'XML' ) ) do: [ :values | + self + assert: + (XMLHTTPMIMEType fromString: (template format: values)) subType + equals: 'xml' ] ]. + #( '' ' ' '/' ' / ' ';' ' ; ' 'application' ' application ' + 'application/' ' application / ' ';charset=utf8' ' ; charset=utf8 ' + 'application/;charset=utf8' ' application / ; charset=utf8 ' ) + do: [ :each | + self assert: (XMLHTTPMIMEType fromString: each) subType equals: '' ] ] diff --git a/src/XML-Parser-Tests/XMLHTTPMessageTest.class.st b/src/XML-Parser-Tests/XMLHTTPMessageTest.class.st index d330fa35..b44eac29 100644 --- a/src/XML-Parser-Tests/XMLHTTPMessageTest.class.st +++ b/src/XML-Parser-Tests/XMLHTTPMessageTest.class.st @@ -113,110 +113,108 @@ XMLHTTPMessageTest >> testAddHeader [ { #category : #tests } XMLHTTPMessageTest >> testContent [ - | message | - self isSupported - ifFalse: [^ self]. + | message | + self isSupported ifFalse: [ ^ self ]. message := self newMessage. self - assert: message content = ''; - assert: (message content: 'test') == message; - assert: message content = 'test' + assert: message content equals: ''; + assert: (message content: 'test') identicalTo: message; + assert: message content equals: 'test' ] { #category : #tests } XMLHTTPMessageTest >> testContentCharset [ - | message firstType secondType | - self isSupported - ifFalse: [^ self]. + | message firstType secondType | + self isSupported ifFalse: [ ^ self ]. message := self newMessage. - firstType := - XMLHTTPMIMEType - mainType: 'application' - subType: 'xml' - parameters: (OrderedCollection with: 'charset' -> 'utf8'). - secondType := - XMLHTTPMIMEType - mainType: 'text' - subType: 'html'. + firstType := XMLHTTPMIMEType + mainType: 'application' + subType: 'xml' + parameters: + (OrderedCollection with: 'charset' -> 'utf8'). + secondType := XMLHTTPMIMEType mainType: 'text' subType: 'html'. self assert: message contentType isNil; - assert: (message contentType: firstType) == message; - assert: message contentCharset = firstType charset; - assert: (message contentType: secondType) == message; - assert: message contentCharset = secondType charset; - assert: (message contentType: nil) == message; - assert: message contentCharset = XMLHTTPMIMEType defaultCharset. + assert: (message contentType: firstType) identicalTo: message; + assert: message contentCharset equals: firstType charset; + assert: (message contentType: secondType) identicalTo: message; + assert: message contentCharset equals: secondType charset; + assert: (message contentType: nil) identicalTo: message; + assert: message contentCharset + equals: XMLHTTPMIMEType defaultCharset. - message - headerAt: 'Content-Type' - put: firstType asString. - self assert: message contentCharset = firstType charset. + message headerAt: 'Content-Type' put: firstType asString. + self assert: message contentCharset equals: firstType charset. message removeHeaderAt: 'Content-Type'. - self assert: message contentCharset = XMLHTTPMIMEType defaultCharset + self + assert: message contentCharset + equals: XMLHTTPMIMEType defaultCharset ] { #category : #tests } XMLHTTPMessageTest >> testContentEncoding [ - | message defaultValue absentValue | - self isSupported - ifFalse: [^ self]. + | message defaultValue absentValue | + self isSupported ifFalse: [ ^ self ]. message := self newMessage. defaultValue := OrderedCollection new. absentValue := defaultValue. self - assert: message contentEncoding = defaultValue; - assert: (message contentEncoding: 'one') == message; - assert: message contentEncoding = #('one') asOrderedCollection; - assert: (message contentEncoding: ' one, identity, two') == message; - assert: message contentEncoding = #('one' 'two') asOrderedCollection; - assert: (message contentEncoding: #('one')) == message; - assert: message contentEncoding = #('one') asOrderedCollection; - assert: (message contentEncoding: #('one' 'identity' 'two')) == message; - assert: message contentEncoding = #('one' 'two') asOrderedCollection; - assert: (message contentEncoding: '') == message; - assert: message contentEncoding = absentValue; - assert: (message contentEncoding: #()) == message; - assert: message contentEncoding = absentValue. + assert: message contentEncoding equals: defaultValue; + assert: (message contentEncoding: 'one') identicalTo: message; + assert: message contentEncoding + equals: #( 'one' ) asOrderedCollection; + assert: (message contentEncoding: ' one, identity, two') + identicalTo: message; + assert: message contentEncoding + equals: #( 'one' 'two' ) asOrderedCollection; + assert: (message contentEncoding: #( 'one' )) identicalTo: message; + assert: message contentEncoding + equals: #( 'one' ) asOrderedCollection; + assert: (message contentEncoding: #( 'one' 'identity' 'two' )) + identicalTo: message; + assert: message contentEncoding + equals: #( 'one' 'two' ) asOrderedCollection; + assert: (message contentEncoding: '') identicalTo: message; + assert: message contentEncoding equals: absentValue; + assert: (message contentEncoding: #( )) identicalTo: message; + assert: message contentEncoding equals: absentValue. message headerAt: 'Content-Encoding' put: 'identity,one,identity,two,identity,three,identity'. - self assert: - message contentEncoding = - #('one' 'two' 'three') asOrderedCollection. + self + assert: message contentEncoding + equals: #( 'one' 'two' 'three' ) asOrderedCollection. message removeHeaderAt: 'Content-Encoding'. - self assert: message contentEncoding = absentValue + self assert: message contentEncoding equals: absentValue ] { #category : #tests } XMLHTTPMessageTest >> testContentLength [ - | message | - self isSupported - ifFalse: [^ self]. + | message | + self isSupported ifFalse: [ ^ self ]. message := self newMessage. self assert: message contentLength isNil; - assert: (message contentLength: 100) == message; - assert: message contentLength = 100; - assert: (message contentLength: nil) == message; + assert: (message contentLength: 100) identicalTo: message; + assert: message contentLength equals: 100; + assert: (message contentLength: nil) identicalTo: message; assert: message contentLength isNil; - assert: (message contentLength: nil) == message; + assert: (message contentLength: nil) identicalTo: message; assert: message contentLength isNil. - message - headerAt: 'Content-Length' - put: '200'. - self assert: message contentLength = 200. + message headerAt: 'Content-Length' put: '200'. + self assert: message contentLength equals: 200. message removeHeaderAt: 'Content-Length'. self assert: message contentLength isNil @@ -224,36 +222,27 @@ XMLHTTPMessageTest >> testContentLength [ { #category : #tests } XMLHTTPMessageTest >> testContentType [ - | message firstType secondType | - self isSupported - ifFalse: [^ self]. + | message firstType secondType | + self isSupported ifFalse: [ ^ self ]. message := self newMessage. - firstType := - XMLHTTPMIMEType - mainType: 'application' - subType: 'xml'. - secondType := - XMLHTTPMIMEType - mainType: 'text' - subType: 'html'. + firstType := XMLHTTPMIMEType mainType: 'application' subType: 'xml'. + secondType := XMLHTTPMIMEType mainType: 'text' subType: 'html'. self assert: message contentType isNil; - assert: (message contentType: firstType) == message; - assert: message contentType = firstType; - deny: message contentType = secondType; - assert: (message contentType: nil) == message; + assert: (message contentType: firstType) identicalTo: message; + assert: message contentType equals: firstType; + deny: message contentType equals: secondType; + assert: (message contentType: nil) identicalTo: message; assert: message contentType isNil; - assert: (message contentType: nil) == message; + assert: (message contentType: nil) identicalTo: message; assert: message contentType isNil. - message - headerAt: 'Content-Type' - put: secondType asString. + message headerAt: 'Content-Type' put: secondType asString. self - assert: message contentType = secondType; - deny: message contentType = firstType. + assert: message contentType equals: secondType; + deny: message contentType equals: firstType. message removeHeaderAt: 'Content-Type'. self assert: message contentType isNil @@ -275,13 +264,12 @@ XMLHTTPMessageTest >> testHasContent [ { #category : #tests } XMLHTTPMessageTest >> testHasHeaders [ - | message | - self isSupported - ifFalse: [^ self]. + | message | + self isSupported ifFalse: [ ^ self ]. message := self newMessage. - self assert: message hasHeaders = message headers notEmpty. + self assert: message hasHeaders equals: message headers notEmpty. message removeHeaders. self deny: message hasHeaders. @@ -292,130 +280,110 @@ XMLHTTPMessageTest >> testHasHeaders [ { #category : #tests } XMLHTTPMessageTest >> testHeaderAt [ - | message addedHeaderDictionary | - self isSupported - ifFalse: [^ self]. + | message addedHeaderDictionary | + self isSupported ifFalse: [ ^ self ]. message := self newMessage. addedHeaderDictionary := self headerDictionaryFrom: message headers. - self headers do: [:each | - self assert: - (message headerAt: each key) = - (addedHeaderDictionary - at: each key - ifAbsent: ['']). - - message - headerAt: each key - put: each value. + self headers do: [ :each | + self + assert: (message headerAt: each key) + equals: (addedHeaderDictionary at: each key ifAbsent: [ '' ]). + + message headerAt: each key put: each value. addedHeaderDictionary add: each. - self assert: (message headerAt: each key) = each value]. + self assert: (message headerAt: each key) equals: each value ]. - self headers do: [:each | - message addHeader: each]. - addedHeaderDictionary keysAndValuesDo: [:key :value | - self assert: (message headerAt: key) = value] + self headers do: [ :each | message addHeader: each ]. + addedHeaderDictionary keysAndValuesDo: [ :key :value | + self assert: (message headerAt: key) equals: value ] ] { #category : #tests } XMLHTTPMessageTest >> testHeaderAtIfAbsent [ - | message addedHeaderDictionary | - self isSupported - ifFalse: [^ self]. + | message addedHeaderDictionary | + self isSupported ifFalse: [ ^ self ]. message := self newMessage. addedHeaderDictionary := self headerDictionaryFrom: message headers. - self headers do: [:each | - self assert: - (message - headerAt: each key - ifAbsent: [#absent]) = - (addedHeaderDictionary - at: each key - ifAbsent: [#absent]). - - message - headerAt: each key - put: each value. + self headers do: [ :each | + self + assert: (message headerAt: each key ifAbsent: [ #absent ]) + equals: (addedHeaderDictionary at: each key ifAbsent: [ #absent ]). + + message headerAt: each key put: each value. addedHeaderDictionary add: each. - self assert: - (message - headerAt: each key - ifAbsent: [self fail]) = each value]. + self + assert: (message headerAt: each key ifAbsent: [ self fail ]) + equals: each value ]. - self headers do: [:each | - message addHeader: each]. - addedHeaderDictionary keysAndValuesDo: [:key :value | - self assert: - (message - headerAt: key - ifAbsent: [self fail]) = value] + self headers do: [ :each | message addHeader: each ]. + addedHeaderDictionary keysAndValuesDo: [ :key :value | + self + assert: (message headerAt: key ifAbsent: [ self fail ]) + equals: value ] ] { #category : #tests } XMLHTTPMessageTest >> testHeaderAtIfAbsentPut [ - | message addedHeaderDictionary | - self isSupported - ifFalse: [^ self]. + | message addedHeaderDictionary | + self isSupported ifFalse: [ ^ self ]. message := self newMessage. addedHeaderDictionary := self headerDictionaryFrom: message headers. - self headers do: [:each | - self assert: - (message - headerAt: each key - ifAbsentPut: [each value]) = - (addedHeaderDictionary - at: each key - ifAbsentPut: [each value]). - - self assert: - (message headerAt: each key) = - (addedHeaderDictionary at: each key). + self headers do: [ :each | + self + assert: (message headerAt: each key ifAbsentPut: [ each value ]) + equals: + (addedHeaderDictionary at: each key ifAbsentPut: [ each value ]). + self + assert: (message headerAt: each key) + equals: (addedHeaderDictionary at: each key). self assertMessage: message - hasHeaders: addedHeaderDictionary associations] + hasHeaders: addedHeaderDictionary associations ] ] { #category : #tests } XMLHTTPMessageTest >> testHeaderAtPut [ - | message addedHeaderDictionary | - self isSupported - ifFalse: [^ self]. + | message addedHeaderDictionary | + self isSupported ifFalse: [ ^ self ]. message := self newMessage. addedHeaderDictionary := self headerDictionaryFrom: message headers. - self headers do: [:each | - self assert: - (message - headerAt: each key - put: each value) = each value. + self headers do: [ :each | + self + assert: (message headerAt: each key put: each value) + equals: each value. addedHeaderDictionary add: each. - self assert: (message headerAt: each key) = each value. + self assert: (message headerAt: each key) equals: each value. self assertMessage: message - hasHeaders: addedHeaderDictionary associations] + hasHeaders: addedHeaderDictionary associations ] ] { #category : #tests } XMLHTTPMessageTest >> testHeaderKeys [ - | message addedHeaderKeys | - self isSupported - ifFalse: [^ self]. + | message addedHeaderKeys | + self isSupported ifFalse: [ ^ self ]. message := self newMessage. addedHeaderKeys := self headerKeysFrom: message headers. - self headers do: [:each | - self assert: message headerKeys sorted = addedHeaderKeys sorted. + self headers do: [ :each | + self + assert: message headerKeys sorted + equals: addedHeaderKeys sorted. message addHeader: each. addedHeaderKeys add: each key. - self assert: message headerKeys sorted = addedHeaderKeys sorted] + self + assert: message headerKeys sorted + equals: addedHeaderKeys sorted ] ] { #category : #tests } @@ -464,27 +432,22 @@ XMLHTTPMessageTest >> testHeaderKeysDo [ { #category : #tests } XMLHTTPMessageTest >> testHeaderValuesAt [ - | message addedHeaders | - self isSupported - ifFalse: [^ self]. + | message addedHeaders | + self isSupported ifFalse: [ ^ self ]. message := self newMessage. addedHeaders := message headers. - self headers do: [:each | - self assert: - (message headerValuesAt: each key) sorted = - (self - headerValuesAt: each key - from: addedHeaders) sorted. + self headers do: [ :each | + self + assert: (message headerValuesAt: each key) sorted + equals: (self headerValuesAt: each key from: addedHeaders) sorted. message addHeader: each. addedHeaders addLast: each. - self assert: - (message headerValuesAt: each key) sorted = - (self - headerValuesAt: each key - from: addedHeaders) sorted] + self + assert: (message headerValuesAt: each key) sorted + equals: (self headerValuesAt: each key from: addedHeaders) sorted ] ] { #category : #tests } @@ -558,110 +521,92 @@ XMLHTTPMessageTest >> testHeaderValuesAtDo [ { #category : #tests } XMLHTTPMessageTest >> testHeaders [ - | message addedHeaders | - self isSupported - ifFalse: [^ self]. + | message addedHeaders | + self isSupported ifFalse: [ ^ self ]. message := self newMessage. addedHeaders := message headers. self - assert: addedHeaders class == OrderedCollection; - assert: addedHeaders = message headers; - deny: addedHeaders == message headers. + assert: addedHeaders class identicalTo: OrderedCollection; + assert: addedHeaders equals: message headers; + deny: addedHeaders identicalTo: message headers ] { #category : #tests } XMLHTTPMessageTest >> testIncludesHeaderAt [ - | message addedHeaderKeys | - self isSupported - ifFalse: [^ self]. + | message addedHeaderKeys | + self isSupported ifFalse: [ ^ self ]. message := self newMessage. addedHeaderKeys := self headerKeysFrom: message headers. - self headers do: [:each | - self assert: - (message includesHeaderAt: each key) = - (addedHeaderKeys includes: each key). + self headers do: [ :each | + self + assert: (message includesHeaderAt: each key) + equals: (addedHeaderKeys includes: each key). message addHeader: each. addedHeaderKeys add: each key. - self assert: (message includesHeaderAt: each key)]. + self assert: (message includesHeaderAt: each key) ] ] { #category : #tests } XMLHTTPMessageTest >> testRemoveHeaderAt [ - | message addedHeaders addedHeaderKeys | - self isSupported - ifFalse: [^ self]. + | message addedHeaders addedHeaderKeys | + self isSupported ifFalse: [ ^ self ]. message := self newMessage. addedHeaders := message headers. - self headers do: [:each | + self headers do: [ :each | message addHeader: each. - addedHeaders addLast: each]. - addedHeaderKeys := (addedHeaders collect: [:each | each key]) asSet. - addedHeaderKeys do: [:each | - self assert: - (message removeHeaderAt: each) sorted = - (self - headerValuesAt: each - from: addedHeaders) sorted. + addedHeaders addLast: each ]. + addedHeaderKeys := (addedHeaders collect: [ :each | each key ]) asSet. + addedHeaderKeys do: [ :each | + self + assert: (message removeHeaderAt: each) sorted + equals: (self headerValuesAt: each from: addedHeaders) sorted. self - should: [message removeHeaderAt: each] - raise: XMLHTTPException]. + should: [ message removeHeaderAt: each ] + raise: XMLHTTPException ] ] { #category : #tests } XMLHTTPMessageTest >> testRemoveHeaderAtIfAbsent [ - | message addedHeaders addedHeaderKeys | - self isSupported - ifFalse: [^ self]. + | message addedHeaders addedHeaderKeys | + self isSupported ifFalse: [ ^ self ]. message := self newMessage. addedHeaders := message headers. - self headers do: [:each | + self headers do: [ :each | message addHeader: each. - addedHeaders addLast: each]. - addedHeaderKeys := (addedHeaders collect: [:each | each key]) asSet. - addedHeaderKeys do: [:each | - self assert: - (message - removeHeaderAt: each - ifAbsent: [self fail]) sorted = - (self - headerValuesAt: each - from: addedHeaders) sorted. - self assert: - (message - removeHeaderAt: each - ifAbsent: [#absent]) = #absent]. + addedHeaders addLast: each ]. + addedHeaderKeys := (addedHeaders collect: [ :each | each key ]) asSet. + addedHeaderKeys do: [ :each | + self + assert: + (message removeHeaderAt: each ifAbsent: [ self fail ]) sorted + equals: (self headerValuesAt: each from: addedHeaders) sorted. + self + assert: (message removeHeaderAt: each ifAbsent: [ #absent ]) + equals: #absent ] ] { #category : #tests } XMLHTTPMessageTest >> testRemoveHeaders [ - | message empty | - self isSupported - ifFalse: [^ self]. + | message empty | + self isSupported ifFalse: [ ^ self ]. message := self newMessage. empty := OrderedCollection new. - self assert: message removeHeaders == message. - self - assertMessage: message - hasHeaders: empty. + self assert: message removeHeaders identicalTo: message. + self assertMessage: message hasHeaders: empty. - self headers do: [:each | - message addHeader: each]. - self - assertMessage: message - hasHeaders: self headers. - self assert: message removeHeaders == message. - self - assertMessage: message - hasHeaders: empty. + self headers do: [ :each | message addHeader: each ]. + self assertMessage: message hasHeaders: self headers. + self assert: message removeHeaders identicalTo: message. + self assertMessage: message hasHeaders: empty ] diff --git a/src/XML-Parser-Tests/XMLHTTPRequestTest.class.st b/src/XML-Parser-Tests/XMLHTTPRequestTest.class.st index 57dc0143..ebb2aef2 100644 --- a/src/XML-Parser-Tests/XMLHTTPRequestTest.class.st +++ b/src/XML-Parser-Tests/XMLHTTPRequestTest.class.st @@ -31,104 +31,105 @@ XMLHTTPRequestTest >> newRequestWithURL [ { #category : #tests } XMLHTTPRequestTest >> testAcceptEncoding [ - | request defaultValue absentValue | - self isSupported - ifFalse: [^ self]. + | request defaultValue absentValue | + self isSupported ifFalse: [ ^ self ]. request := self newRequestWithURL. defaultValue := request defaultAcceptEncoding asOrderedCollection. absentValue := OrderedCollection new. self - assert: request acceptEncoding sorted = defaultValue sorted; - assert: (request acceptEncoding: 'one') == request; - assert: request acceptEncoding = #('one') asOrderedCollection; - assert: (request acceptEncoding: ' one, identity, two') == request; - assert: request acceptEncoding = #('one' 'two') asOrderedCollection; - assert: (request acceptEncoding: #('one')) == request; - assert: request acceptEncoding = #('one') asOrderedCollection; - assert: (request acceptEncoding: #('one' 'identity' 'two')) == request; - assert: request acceptEncoding = #('one' 'two') asOrderedCollection; - assert: (request acceptEncoding: '') == request; - assert: request acceptEncoding = absentValue; - assert: (request acceptEncoding: #()) == request; - assert: request acceptEncoding = absentValue. + assert: request acceptEncoding sorted equals: defaultValue sorted; + assert: (request acceptEncoding: 'one') identicalTo: request; + assert: request acceptEncoding + equals: #( 'one' ) asOrderedCollection; + assert: (request acceptEncoding: ' one, identity, two') + identicalTo: request; + assert: request acceptEncoding + equals: #( 'one' 'two' ) asOrderedCollection; + assert: (request acceptEncoding: #( 'one' )) identicalTo: request; + assert: request acceptEncoding + equals: #( 'one' ) asOrderedCollection; + assert: (request acceptEncoding: #( 'one' 'identity' 'two' )) + identicalTo: request; + assert: request acceptEncoding + equals: #( 'one' 'two' ) asOrderedCollection; + assert: (request acceptEncoding: '') identicalTo: request; + assert: request acceptEncoding equals: absentValue; + assert: (request acceptEncoding: #( )) identicalTo: request; + assert: request acceptEncoding equals: absentValue. request headerAt: 'Accept-Encoding' put: 'identity,one,identity,two,identity,three,identity'. - self assert: - request acceptEncoding = - #('one' 'two' 'three') asOrderedCollection. + self + assert: request acceptEncoding + equals: #( 'one' 'two' 'three' ) asOrderedCollection. request removeHeaderAt: 'Accept-Encoding'. - self assert: request acceptEncoding = absentValue + self assert: request acceptEncoding equals: absentValue ] { #category : #tests } XMLHTTPRequestTest >> testAsXMLHTTPRequest [ - | request | - self isSupported - ifFalse: [^ self]. + | request | + self isSupported ifFalse: [ ^ self ]. request := self newMessage. - self assert: request asXMLHTTPRequest == request + self assert: request asXMLHTTPRequest identicalTo: request ] { #category : #tests } XMLHTTPRequestTest >> testEnableCompression [ - | request | - self isSupported - ifFalse: [^ self]. + | request | + self isSupported ifFalse: [ ^ self ]. (request := self newRequestWithURL) acceptEncoding: ''. self - assert: request enableCompression == request; + assert: request enableCompression identicalTo: request; deny: request acceptEncoding isEmpty. - request acceptEncoding do: [:each | + request acceptEncoding do: [ :each | self assert: - (XMLHTTPDecompressingReadStreamAdapterFactory - classForCompression: each) notNil] + (XMLHTTPDecompressingReadStreamAdapterFactory classForCompression: + each) notNil ] ] { #category : #tests } XMLHTTPRequestTest >> testMethod [ - | request | - self isSupported - ifFalse: [^ self]. + | request | + self isSupported ifFalse: [ ^ self ]. request := self newMessage. self - assert: request method = 'GET'; + assert: request method equals: 'GET'; deny: request method isSymbol; - assert: (request method: 'POST') == request; - assert: request method = 'POST'; + assert: (request method: 'POST') identicalTo: request; + assert: request method equals: 'POST'; deny: request method isSymbol ] { #category : #tests } XMLHTTPRequestTest >> testTimeout [ - | request | - self isSupported - ifFalse: [^ self]. + | request | + self isSupported ifFalse: [ ^ self ]. request := self newMessage. self - assert: request timeout = self defaultTimeout; - assert: (request timeout: self defaultTimeout + 1) == request; - assert: request timeout = (self defaultTimeout + 1) + assert: request timeout equals: self defaultTimeout; + assert: (request timeout: self defaultTimeout + 1) + identicalTo: request; + assert: request timeout equals: self defaultTimeout + 1 ] { #category : #tests } XMLHTTPRequestTest >> testURL [ - self isSupported - ifFalse: [^ self]. - self assert: self newRequestWithURL url = self url + self isSupported ifFalse: [ ^ self ]. + self assert: self newRequestWithURL url equals: self url ] { #category : #accessing } diff --git a/src/XML-Parser-Tests/XMLHTTPResponseTest.class.st b/src/XML-Parser-Tests/XMLHTTPResponseTest.class.st index 1e21d360..80bded44 100644 --- a/src/XML-Parser-Tests/XMLHTTPResponseTest.class.st +++ b/src/XML-Parser-Tests/XMLHTTPResponseTest.class.st @@ -16,59 +16,55 @@ XMLHTTPResponseTest >> messageClass [ { #category : #tests } XMLHTTPResponseTest >> testProtocol [ - | response | - self isSupported - ifFalse: [^ self]. + | response | + self isSupported ifFalse: [ ^ self ]. response := self newMessage. self - assert: response protocol = 'HTTP/1.1'; - assert: (response protocol: 'HTTP/1.0') == response; - assert: response protocol = 'HTTP/1.0' + assert: response protocol equals: 'HTTP/1.1'; + assert: (response protocol: 'HTTP/1.0') identicalTo: response; + assert: response protocol equals: 'HTTP/1.0' ] { #category : #tests } XMLHTTPResponseTest >> testStatusCode [ - | response | - self isSupported - ifFalse: [^ self]. + | response | + self isSupported ifFalse: [ ^ self ]. response := self newMessage. self - assert: response statusCode = 200; - assert: (response statusCode: 404) == response; - assert: response statusCode = 404 + assert: response statusCode equals: 200; + assert: (response statusCode: 404) identicalTo: response; + assert: response statusCode equals: 404 ] { #category : #tests } XMLHTTPResponseTest >> testStatusDescription [ - | response | - self isSupported - ifFalse: [^ self]. + | response | + self isSupported ifFalse: [ ^ self ]. response := self newMessage. - self assert: response statusDescription = 'OK'. + self assert: response statusDescription equals: 'OK'. response statusCode: 404. - self assert: response statusDescription = 'Not Found' + self assert: response statusDescription equals: 'Not Found' ] { #category : #tests } XMLHTTPResponseTest >> testStatusLine [ - | response | - self isSupported - ifFalse: [^ self]. + | response | + self isSupported ifFalse: [ ^ self ]. response := self newMessage. - self assert: response statusLine = 'HTTP/1.1 200 OK'. + self assert: response statusLine equals: 'HTTP/1.1 200 OK'. response statusCode: 404. - self assert: response statusLine = 'HTTP/1.1 404 Not Found'. + self assert: response statusLine equals: 'HTTP/1.1 404 Not Found'. response protocol: 'HTTP/1.0'. - self assert: response statusLine = 'HTTP/1.0 404 Not Found' + self assert: response statusLine equals: 'HTTP/1.0 404 Not Found' ] diff --git a/src/XML-Parser-Tests/XMLIntegerReaderTest.class.st b/src/XML-Parser-Tests/XMLIntegerReaderTest.class.st index 0773a26a..7e964d1f 100644 --- a/src/XML-Parser-Tests/XMLIntegerReaderTest.class.st +++ b/src/XML-Parser-Tests/XMLIntegerReaderTest.class.st @@ -36,110 +36,123 @@ XMLIntegerReaderTest >> newStreamOn: aCollection [ { #category : #tests } XMLIntegerReaderTest >> testBaseMarker [ - 2 to: self maxBase do: [:base | | stream defaultBase | - defaultBase := (base - 1) max: 2. - stream := self newStreamOn: ((base printStringBase: base) copyWithFirst: $#). + + 2 to: self maxBase do: [ :base | + | stream defaultBase | + defaultBase := base - 1 max: 2. + stream := self newStreamOn: + ((base printStringBase: base) copyWithFirst: $#). self - assert: - (self integerReaderClass - readFrom: stream - withBase: base - andPrefixes: '@#$' - orBase: defaultBase) = base; + assert: (self integerReaderClass + readFrom: stream + withBase: base + andPrefixes: '@#$' + orBase: defaultBase) + equals: base; assert: stream atEnd. stream := self newStreamOn: (base printStringBase: defaultBase). self - assert: - (self integerReaderClass - readFrom: stream - withBase: base - andPrefixes: '@#$' - orBase: defaultBase) = base; - assert: stream atEnd] + assert: (self integerReaderClass + readFrom: stream + withBase: base + andPrefixes: '@#$' + orBase: defaultBase) + equals: base; + assert: stream atEnd ] ] { #category : #tests } XMLIntegerReaderTest >> testBases [ - 2 to: self maxBase do: [:base | | stream | - (0 to: base), (base + 1 to: base * 10 by: base) do: [:i | + + 2 to: self maxBase do: [ :base | + | stream | + (0 to: base) , (base + 1 to: base * 10 by: base) do: [ :i | stream := self newStreamOn: (i printStringBase: base). self - assert: (self integerReaderClass readFrom: stream withBase: base) = i; - assert: stream atEnd]]. + assert: (self integerReaderClass readFrom: stream withBase: base) + equals: i; + assert: stream atEnd ] ]. self should: [ self integerReaderClass readFrom: (self newStreamOn: '1') - withBase: 1] + withBase: 1 ] raise: Error. self should: [ self integerReaderClass readFrom: (self newStreamOn: '1') - withBase: self maxBase + 1] + withBase: self maxBase + 1 ] raise: Error ] { #category : #tests } XMLIntegerReaderTest >> testMaxIntegerValue [ - | maxValue | - (maxValue := self maxIntegerValue) - ifNil: [^ self]. - 2 to: self maxBase do: [:base | - self assert: - (self integerReaderClass - readFrom: (self newStreamOn: (maxValue printStringBase: base)) - withBase: base) = maxValue. - 1 to: base do: [:i | - self assert: - (self integerReaderClass - readFrom: (self newStreamOn: ((maxValue + i) printStringBase: base)) - withBase: base) = maxValue]] + | maxValue | + (maxValue := self maxIntegerValue) ifNil: [ ^ self ]. + 2 to: self maxBase do: [ :base | + self + assert: (self integerReaderClass + readFrom: (self newStreamOn: (maxValue printStringBase: base)) + withBase: base) + equals: maxValue. + 1 to: base do: [ :i | + self + assert: (self integerReaderClass + readFrom: + (self newStreamOn: (maxValue + i printStringBase: base)) + withBase: base) + equals: maxValue ] ] ] { #category : #tests } XMLIntegerReaderTest >> testNonDigit [ - 2 to: self maxBase do: [:base | | digitInterval letterInterval uppercaseLetterInterval | + + 2 to: self maxBase do: [ :base | + | digitInterval letterInterval uppercaseLetterInterval | base > 10 ifTrue: [ digitInterval := $0 asciiValue to: $9 asciiValue. letterInterval := $a asciiValue to: $a asciiValue + (base - 11). - uppercaseLetterInterval := $A asciiValue to: $A asciiValue + (base - 11)] + uppercaseLetterInterval := $A asciiValue to: + $A asciiValue + (base - 11) ] ifFalse: [ digitInterval := $0 asciiValue to: $0 asciiValue + base - 1. - letterInterval := #(). - uppercaseLetterInterval := #()]. - 0 to: 256 do: [:each | | char reader | + letterInterval := #( ). + uppercaseLetterInterval := #( ) ]. + 0 to: 256 do: [ :each | + | char reader | char := each asCharacter. - reader := self newIntegerReaderOn: (self newStreamOn: char asString). - ((digitInterval includes: each) - or: [(letterInterval includes: each) - or: [uppercaseLetterInterval includes: each]]) + reader := self newIntegerReaderOn: + (self newStreamOn: char asString). + ((digitInterval includes: each) or: [ + (letterInterval includes: each) or: [ + uppercaseLetterInterval includes: each ] ]) ifTrue: [ self assert: (reader nextIntegerWithBase: base) notNil; - assert: reader atEnd] + assert: reader atEnd ] ifFalse: [ self assert: (reader nextIntegerWithBase: base) isNil; deny: reader atEnd; - assert: reader next = char; - assert: reader atEnd]]] + assert: reader next equals: char; + assert: reader atEnd ] ] ] ] { #category : #tests } XMLIntegerReaderTest >> testPositioning [ - | reader string | + | reader string | string := 'test'. reader := self newIntegerReaderOn: (self newStreamOn: string). - string do: [:each | + string do: [ :each | self deny: reader atEnd; - assert: reader peek = each; - assert: reader next = each]. + assert: reader peek equals: each; + assert: reader next equals: each ]. self assert: reader atEnd; assert: reader peek isNil; @@ -148,33 +161,44 @@ XMLIntegerReaderTest >> testPositioning [ { #category : #tests } XMLIntegerReaderTest >> testPrintStream [ - | printStream reader | + | printStream reader | printStream := String new writeStream. - (reader := self newIntegerReaderOn: (self newStreamOn: '123xABChdefO11')) - printStream: printStream. + (reader := self newIntegerReaderOn: + (self newStreamOn: '123xABChdefO11')) printStream: + printStream. self - assert: (reader nextIntegerWithBase: 10) = 123; - assert: printStream contents = '123'; - assert: (reader nextIntegerWithBase: 16 andPrefixes: 'x' orBase: 10) = 2748; - assert: printStream contents = '123xABC'; - assert: (reader nextIntegerWithBase: 16 andPrefixes: 'h' orBase: 10) = 3567; - assert: printStream contents = '123xABChdef'. + assert: (reader nextIntegerWithBase: 10) equals: 123; + assert: printStream contents equals: '123'; + assert: (reader nextIntegerWithBase: 16 andPrefixes: 'x' orBase: 10) + equals: 2748; + assert: printStream contents equals: '123xABC'; + assert: (reader nextIntegerWithBase: 16 andPrefixes: 'h' orBase: 10) + equals: 3567; + assert: printStream contents equals: '123xABChdef'. reader printStream: nil. self - assert: (reader nextIntegerWithBase: 8 andPrefixes: 'oO' orBase: 10) = 9; - assert: printStream contents = '123xABChdef'; + assert: (reader nextIntegerWithBase: 8 andPrefixes: 'oO' orBase: 10) + equals: 9; + assert: printStream contents equals: '123xABChdef'; assert: reader atEnd ] { #category : #tests } XMLIntegerReaderTest >> testReadLimit [ - 2 to: self maxBase do: [:base | | stream | + + 2 to: self maxBase do: [ :base | + | stream | "101 regardless of base" stream := self newStreamOn: (base * base + 1 printStringBase: base). self - assert: (self integerReaderClass readFrom: stream withBase: base upToLimit: 2) = base; + assert: + (self integerReaderClass + readFrom: stream + withBase: base + upToLimit: 2) + equals: base; deny: stream atEnd; - assert: stream next == $1] + assert: stream next identicalTo: $1 ] ] diff --git a/src/XML-Parser-Tests/XMLKeyValueCacheTest.class.st b/src/XML-Parser-Tests/XMLKeyValueCacheTest.class.st index 040283ad..c58051ef 100644 --- a/src/XML-Parser-Tests/XMLKeyValueCacheTest.class.st +++ b/src/XML-Parser-Tests/XMLKeyValueCacheTest.class.st @@ -63,235 +63,201 @@ XMLKeyValueCacheTest >> newCacheWithEntries [ { #category : #asserting } XMLKeyValueCacheTest >> should: aBlock inAnyOrderEnumerate: aCollection [ - | enumerated | + | enumerated | enumerated := OrderedCollection new. - aBlock value: [:each | enumerated addLast: each]. + aBlock value: [ :each | enumerated addLast: each ]. self - assert: enumerated size = aCollection size; - assert: enumerated asSet = aCollection asSet + assert: enumerated size equals: aCollection size; + assert: enumerated asSet equals: aCollection asSet ] { #category : #asserting } XMLKeyValueCacheTest >> should: aBlock inAnyOrderEnumerateKeysAndValues: anAssociationCollection [ - | enumerated | + | enumerated | enumerated := OrderedCollection new. - aBlock value: [:first :second | - enumerated addLast: first -> second]. + aBlock value: [ :first :second | enumerated addLast: first -> second ]. self - assert: enumerated size = anAssociationCollection size; - assert: enumerated asSet = anAssociationCollection asSet + assert: enumerated size equals: anAssociationCollection size; + assert: enumerated asSet equals: anAssociationCollection asSet ] { #category : #tests } XMLKeyValueCacheTest >> testAt [ - | cache | + | cache | cache := self newCacheWithEntries. - self keysAndValuesDo: [:key :value | - self assert: (cache at: key) = value]. + self keysAndValuesDo: [ :key :value | + self assert: (cache at: key) equals: value ]. self assert: (cache at: 'absentKey') isNil ] { #category : #tests } XMLKeyValueCacheTest >> testAtIfAbsent [ - | cache | + | cache | cache := self newCacheWithEntries. - self keysAndValuesDo: [:key :value | - self assert: - (cache - at: key - ifAbsent: [self fail]) = value]. - self assert: - (cache - at: 'absentKey' - ifAbsent: ['absentValue']) = 'absentValue'. - - "the ifAbsent: block can modify the cache too, so make sure - it is cleared if needed to make room" - self assert: - (cache - at: 'absentKey' - ifAbsent: [ - cache - at: 'newKey' - put: 'newValue']) = 'newValue'. + self keysAndValuesDo: [ :key :value | + self assert: (cache at: key ifAbsent: [ self fail ]) equals: value ]. self - assert: cache size = 1; - assert: (cache at: 'newKey') = 'newValue' + assert: (cache at: 'absentKey' ifAbsent: [ 'absentValue' ]) + equals: 'absentValue'. + self + assert: (cache + at: 'absentKey' + ifAbsent: [ cache at: 'newKey' put: 'newValue' ]) + equals: 'newValue'. + self + assert: cache size equals: 1; + assert: (cache at: 'newKey') equals: 'newValue' ] { #category : #tests } XMLKeyValueCacheTest >> testAtIfAbsentPut [ - | cache | + | cache | cache := self newCacheWithEntries. - self keysAndValuesDo: [:key :value | - self assert: - (cache - at: key - ifAbsentPut: [self fail]) = value. + self keysAndValuesDo: [ :key :value | self - assert: (cache at: key) = value; - assert: cache size = self maxSize]. - self assert: - (cache - at: 'newKey' - ifAbsentPut: ['newValue']) = 'newValue'. + assert: (cache at: key ifAbsentPut: [ self fail ]) + equals: value. + self + assert: (cache at: key) equals: value; + assert: cache size equals: self maxSize ]. + self + assert: (cache at: 'newKey' ifAbsentPut: [ 'newValue' ]) + equals: 'newValue'. self - assert: (cache at: 'newKey') = 'newValue'; - assert: cache size = 1. + assert: (cache at: 'newKey') equals: 'newValue'; + assert: cache size equals: 1. "the ifAbsentPut: block can modify the cache too, so make sure it is cleared if needed to make room" cache := self newCacheWithEntries. - self assert: - (cache - at: 'newKey' - ifAbsentPut: [ - cache - at: 'newKeyTwo' - put: 'newValue']) = 'newValue'. self - assert: cache size = 2; - assert: (cache at: 'newKey') = 'newValue'; - assert: (cache at: 'newKeyTwo') = 'newValue' + assert: (cache + at: 'newKey' + ifAbsentPut: [ cache at: 'newKeyTwo' put: 'newValue' ]) + equals: 'newValue'. + self + assert: cache size equals: 2; + assert: (cache at: 'newKey') equals: 'newValue'; + assert: (cache at: 'newKeyTwo') equals: 'newValue' ] { #category : #tests } XMLKeyValueCacheTest >> testAtIfPresent [ - | cache | + | cache | cache := self newCacheWithEntries. - self keysAndValuesDo: [:key :value | - self assert: - (cache - at: key - ifPresent: [:each | #present -> each]) = (#present -> value). - "ensure cull: is used" - self assert: - (cache - at: key - ifPresent: [#present]) = #present]. - self assert: - (cache - at: 'absentKey' - ifPresent: [self fail]) isNil. + self keysAndValuesDo: [ :key :value | + self + assert: (cache at: key ifPresent: [ :each | #present -> each ]) + equals: #present -> value. + self + assert: (cache at: key ifPresent: [ #present ]) + equals: #present ]. + self assert: (cache at: 'absentKey' ifPresent: [ self fail ]) isNil. "the ifPresent: block can modify the cache too, so make sure it is cleared if needed to make room" - self assert: - (cache - at: 'absentKey' - ifAbsent: [ - cache - at: 'newKey' - put: 'newValue']) = 'newValue'. self - assert: cache size = 1; - assert: (cache at: 'newKey') = 'newValue' + assert: (cache + at: 'absentKey' + ifAbsent: [ cache at: 'newKey' put: 'newValue' ]) + equals: 'newValue'. + self + assert: cache size equals: 1; + assert: (cache at: 'newKey') equals: 'newValue' ] { #category : #tests } XMLKeyValueCacheTest >> testAtIfPresentPut [ - | cache | + | cache | cache := self newCacheWithEntries. - self keysAndValuesDo: [:key :value | - self assert: - (cache - at: key - ifPresent: [:each | each ~= value] - put: [self fail]) = value. - self assert: (cache at: key) = value. - - "ensure cull: is used" - self assert: + self keysAndValuesDo: [ :key :value | + self + assert: (cache - at: key - ifPresent: [false] - put: [self fail]) = value. - self assert: (cache at: key) = value. - - self assert: + at: key + ifPresent: [ :each | each ~= value ] + put: [ self fail ]) + equals: value. + self assert: (cache at: key) equals: value. + self + assert: (cache at: key ifPresent: [ false ] put: [ self fail ]) + equals: value. + self assert: (cache at: key) equals: value. + self + assert: (cache - at: key - ifPresent: [:each | each = value] - put: ['newValue']) = 'newValue'. - self assert: (cache at: key) = 'newValue']. + at: key + ifPresent: [ :each | each = value ] + put: [ 'newValue' ]) + equals: 'newValue'. + self assert: (cache at: key) equals: 'newValue' ]. self assert: - (cache - at: 'absentKey' - ifPresent: [self fail] - put: [self fail]) isNil. + (cache at: 'absentKey' ifPresent: [ self fail ] put: [ self fail ]) + isNil. self deny: (cache includesKey: 'absentKey'). "the ifPresent: block can modify the cache too, so make sure it is cleared if needed to make room" - self assert: - (cache - at: self keys first - ifPresent: [ - cache - at: 'newKey' - put: 'newValue'. - false] - put: [self fail]) = 'newValue'. - self - assert: cache size = 1; - assert: (cache at: 'newKey') = 'newValue'. + self + assert: (cache + at: self keys first + ifPresent: [ + cache at: 'newKey' put: 'newValue'. + false ] + put: [ self fail ]) + equals: 'newValue'. + self + assert: cache size equals: 1; + assert: (cache at: 'newKey') equals: 'newValue'. "the put: block can modify the cache too, so make sure it is cleared if needed to make room" cache := self cacheClass maxSize: 1. - cache - at: self keys first - put: self values first. - self assert: - (cache - at: self keys first - ifPresent: [true] - put: [ - cache - at: 'newKey' - put: 'newValue']) = 'newValue'. + cache at: self keys first put: self values first. + self + assert: (cache + at: self keys first + ifPresent: [ true ] + put: [ cache at: 'newKey' put: 'newValue' ]) + equals: 'newValue'. self - assert: cache size = 1; - assert: (cache at: self keys first) = 'newValue' + assert: cache size equals: 1; + assert: (cache at: self keys first) equals: 'newValue' ] { #category : #tests } XMLKeyValueCacheTest >> testAtPut [ - | cache | + | cache | cache := self cacheClass maxSize: self maxSize. - self associations withIndexDo: [:each :i | | key value | + self associations withIndexDo: [ :each :i | + | key value | key := each key. value := each value. - self assert: - (cache - at: key - put: value) = value. + self assert: (cache at: key put: value) equals: value. self - assert: (cache at: key) = value; - assert: cache size = i]. - self assert: - (cache - at: 'newKey' - put: 'newValue') = 'newValue'. + assert: (cache at: key) equals: value; + assert: cache size equals: i ]. + self assert: (cache at: 'newKey' put: 'newValue') equals: 'newValue'. self - assert: (cache at: 'newKey') = 'newValue'; - assert: cache size = 1 + assert: (cache at: 'newKey') equals: 'newValue'; + assert: cache size equals: 1 ] { #category : #tests } XMLKeyValueCacheTest >> testCapacity [ + self - assert: self newCache capacity = self defaultMaxSize; - assert: self newCacheWithEntries capacity = self maxSize + assert: self newCache capacity equals: self defaultMaxSize; + assert: self newCacheWithEntries capacity equals: self maxSize ] { #category : #tests } @@ -307,15 +273,15 @@ XMLKeyValueCacheTest >> testClear [ { #category : #tests } XMLKeyValueCacheTest >> testCopy [ - | cache copy | + | cache copy | cache := self newCacheWithEntries. copy := cache copy. self - deny: cache == copy; - assert: cache collection = copy collection; - deny: cache collection == copy collection; - deny: cache mutex == copy mutex + deny: cache identicalTo: copy; + assert: cache collection equals: copy collection; + deny: cache collection identicalTo: copy collection; + deny: cache mutex identicalTo: copy mutex ] { #category : #tests } @@ -337,9 +303,10 @@ XMLKeyValueCacheTest >> testIsEmpty [ { #category : #tests } XMLKeyValueCacheTest >> testKeys [ + self assert: self newCache keys isEmpty; - assert: self newCacheWithEntries keys asSet = self keys asSet + assert: self newCacheWithEntries keys asSet equals: self keys asSet ] { #category : #tests } @@ -366,27 +333,25 @@ XMLKeyValueCacheTest >> testKeysDo [ { #category : #tests } XMLKeyValueCacheTest >> testMaxSize [ - | cache | + | cache | cache := self newCache. self - assert: cache size = 0; - assert: cache maxSize = self defaultMaxSize. + assert: cache size equals: 0; + assert: cache maxSize equals: self defaultMaxSize. cache := self newCacheWithEntries. self - assert: cache size = self maxSize; - assert: cache maxSize = self maxSize. - + assert: cache size equals: self maxSize; + assert: cache maxSize equals: self maxSize. self - assert: (cache maxSize: self maxSize + 1) == cache; - assert: cache maxSize = (self maxSize + 1); - assert: cache size = self maxSize. - + assert: (cache maxSize: self maxSize + 1) identicalTo: cache; + assert: cache maxSize equals: self maxSize + 1; + assert: cache size equals: self maxSize. self - assert: (cache maxSize: 0) == cache; - assert: cache maxSize = 0; - assert: cache size = 0 + assert: (cache maxSize: 0) identicalTo: cache; + assert: cache maxSize equals: 0; + assert: cache size equals: 0 ] { #category : #tests } @@ -409,94 +374,86 @@ XMLKeyValueCacheTest >> testRemoveAll [ { #category : #tests } XMLKeyValueCacheTest >> testRemoveKey [ - | cache | + | cache | cache := self newCacheWithEntries. - self keysAndValuesDo: [:key :value | + self keysAndValuesDo: [ :key :value | self - assert: (cache removeKey: key) = value; + assert: (cache removeKey: key) equals: value; deny: (cache includesKey: key). "does not raise errors to support concurrent removal" - self assert: (cache removeKey: key) isNil]. - self assert: cache isEmpty. + self assert: (cache removeKey: key) isNil ]. + self assert: cache isEmpty ] { #category : #tests } XMLKeyValueCacheTest >> testRemoveKeyIfAbsent [ - | cache | + | cache | cache := self newCacheWithEntries. - self keysAndValuesDo: [:key :value | - self assert: - (cache - removeKey: key - ifAbsent: [self fail]) = value. + self keysAndValuesDo: [ :key :value | + self + assert: (cache removeKey: key ifAbsent: [ self fail ]) + equals: value. self deny: (cache includesKey: key). - self assert: - (cache - removeKey: key - ifAbsent: ['absentValue']) = 'absentValue']. + self + assert: (cache removeKey: key ifAbsent: [ 'absentValue' ]) + equals: 'absentValue' ]. self assert: cache isEmpty. cache := self newCacheWithEntries. - self assert: - (cache - removeKey: 'absentKey' - ifAbsent: [ - cache - at: 'newKey' - put: 'newValue']) = 'newValue'. self - assert: cache size = 1; - assert: (cache at: 'newKey') = 'newValue'. + assert: (cache + removeKey: 'absentKey' + ifAbsent: [ cache at: 'newKey' put: 'newValue' ]) + equals: 'newValue'. + self + assert: cache size equals: 1; + assert: (cache at: 'newKey') equals: 'newValue' ] { #category : #tests } XMLKeyValueCacheTest >> testRemoveKeyIfPresent [ - | cache | + | cache | cache := self newCacheWithEntries. - self keysAndValuesDo: [:key :value | - self assert: - (cache - removeKey: key - ifPresent: [:each | each ~= value]) = value. + self keysAndValuesDo: [ :key :value | + self + assert: (cache removeKey: key ifPresent: [ :each | each ~= value ]) + equals: value. self assert: (cache includesKey: key). "ensure cull: is used" - self assert: - (cache - removeKey: key - ifPresent: [false]) = value. + self + assert: (cache removeKey: key ifPresent: [ false ]) + equals: value. self assert: (cache includesKey: key). - - self assert: - (cache - removeKey: key - ifPresent: [:each | each = value]) = value. + self + assert: (cache removeKey: key ifPresent: [ :each | each = value ]) + equals: value. self deny: (cache includesKey: key). - self assert: - (cache - removeKey: key - ifPresent: [self fail]) isNil. - self deny: (cache includesKey: key)]. - self assert: cache isEmpty. + self assert: (cache removeKey: key ifPresent: [ self fail ]) isNil. + self deny: (cache includesKey: key) ]. + self assert: cache isEmpty ] { #category : #tests } XMLKeyValueCacheTest >> testSize [ + self - assert: self newCache size = 0; - assert: self newCacheWithEntries size = self maxSize + assert: self newCache size equals: 0; + assert: self newCacheWithEntries size equals: self maxSize ] { #category : #tests } XMLKeyValueCacheTest >> testValues [ + self assert: self newCache values isEmpty; - assert: self newCacheWithEntries values asSet = self values asSet + assert: self newCacheWithEntries values asSet + equals: self values asSet ] { #category : #tests } diff --git a/src/XML-Parser-Tests/XMLNamespaceScopeTest.class.st b/src/XML-Parser-Tests/XMLNamespaceScopeTest.class.st index d9f4fec9..02f9ecc6 100644 --- a/src/XML-Parser-Tests/XMLNamespaceScopeTest.class.st +++ b/src/XML-Parser-Tests/XMLNamespaceScopeTest.class.st @@ -32,15 +32,15 @@ XMLNamespaceScopeTest >> newNamespaceScopeWithNamespaces [ { #category : #tests } XMLNamespaceScopeTest >> testCopy [ - | scope oldPrefixMappings copy | + | scope oldPrefixMappings copy | scope := self newNamespaceScopeWithNamespaces. oldPrefixMappings := scope prefixMappings. copy := scope copy. self - deny: copy == scope; - assert: copy = scope; - assert: copy prefixMappings == oldPrefixMappings + deny: copy identicalTo: scope; + assert: copy equals: scope; + assert: copy prefixMappings identicalTo: oldPrefixMappings ] { #category : #tests } @@ -53,21 +53,25 @@ XMLNamespaceScopeTest >> testDefaultNamespace [ oldPrefixMappings := scope prefixMappings. scope defaultNamespace: 'test'. self - assert: scope defaultNamespace = 'test'; - assert: (scope prefixMappings at: '') = 'test'; - deny: scope prefixMappings = oldPrefixMappings. + assert: scope defaultNamespace equals: 'test'; + assert: (scope prefixMappings at: '') equals: 'test'; + deny: scope prefixMappings equals: oldPrefixMappings. scope unmapPrefix: ''. - self assert: scope defaultNamespace = '' + self assert: scope defaultNamespace equals: '' ] { #category : #tests } XMLNamespaceScopeTest >> testEquals [ + self - assert: self newNamespaceScope = self newNamespaceScope; - assert: self newNamespaceScopeWithNamespaces = self newNamespaceScopeWithNamespaces; - deny: self newNamespaceScope = self newNamespaceScopeWithNamespaces; - deny: self newNamespaceScopeWithNamespaces = self newNamespaceScope + assert: self newNamespaceScope equals: self newNamespaceScope; + assert: self newNamespaceScopeWithNamespaces + equals: self newNamespaceScopeWithNamespaces; + deny: self newNamespaceScope + equals: self newNamespaceScopeWithNamespaces; + deny: self newNamespaceScopeWithNamespaces + equals: self newNamespaceScope ] { #category : #tests } @@ -107,17 +111,18 @@ XMLNamespaceScopeTest >> testHash [ "We can only safely test that equal objects have the same hash; testing that different objects have different hashes would be unreliable because #hash is non-cryptographic and has collisions." - self assert: - self newNamespaceScope hash = - self newNamespaceScope hash. - self assert: - self newNamespaceScopeWithNamespaces hash = - self newNamespaceScopeWithNamespaces hash. - self assert: - self newNamespaceScope hash = - (self newNamespaceScopeWithNamespaces - unmapPrefixes; - hash) + + self + assert: self newNamespaceScope hash + equals: self newNamespaceScope hash. + self + assert: self newNamespaceScopeWithNamespaces hash + equals: self newNamespaceScopeWithNamespaces hash. + self + assert: self newNamespaceScope hash + equals: (self newNamespaceScopeWithNamespaces + unmapPrefixes; + hash) ] { #category : #tests } @@ -183,461 +188,408 @@ XMLNamespaceScopeTest >> testIncludesPrefixMappedTo [ { #category : #tests } XMLNamespaceScopeTest >> testInheritMappingsFrom [ - | outerScope innerScope | + | outerScope innerScope | outerScope := self newNamespaceScopeWithNamespaces. innerScope := self newNamespaceScope. innerScope inheritMappingsFrom: outerScope. - self assert: innerScope prefixMappings == outerScope prefixMappings. + self + assert: innerScope prefixMappings + identicalTo: outerScope prefixMappings. innerScope := self newNamespaceScopeWithNamespaces. innerScope inheritMappingsFrom: outerScope. self - assert: innerScope prefixMappings = outerScope prefixMappings; - deny: innerScope prefixMappings == outerScope prefixMappings + assert: innerScope prefixMappings equals: outerScope prefixMappings; + deny: innerScope prefixMappings + identicalTo: outerScope prefixMappings ] { #category : #tests } XMLNamespaceScopeTest >> testMapPrefixTo [ - | scope oldPrefixMappings | + | scope oldPrefixMappings | scope := self newNamespaceScope. - self namespaces keysAndValuesDo: [:prefix :uri | - "save to ensure prefixMappings is copied, even if unchanged" + self namespaces keysAndValuesDo: [ :prefix :uri | "save to ensure prefixMappings is copied, even if unchanged" oldPrefixMappings := scope prefixMappings. - scope - mapPrefix: prefix - to: uri. + scope mapPrefix: prefix to: uri. self - assert: (scope prefixMappings at: prefix) = uri; - deny: scope prefixMappings = oldPrefixMappings; - deny: scope prefixMappings == oldPrefixMappings. + assert: (scope prefixMappings at: prefix) equals: uri; + deny: scope prefixMappings equals: oldPrefixMappings; + deny: scope prefixMappings identicalTo: oldPrefixMappings. "save to ensure prefixMappings is copied, even if unchanged" oldPrefixMappings := scope prefixMappings. - scope - mapPrefix: prefix - to: uri. + scope mapPrefix: prefix to: uri. self - assert: (scope prefixMappings at: prefix) = uri; - assert: scope prefixMappings = oldPrefixMappings; - deny: scope prefixMappings == oldPrefixMappings]. - self assert: - scope prefixMappings associations asArray = - self namespaces associations asArray. + assert: (scope prefixMappings at: prefix) equals: uri; + assert: scope prefixMappings equals: oldPrefixMappings; + deny: scope prefixMappings identicalTo: oldPrefixMappings ]. + self + assert: scope prefixMappings associations asArray + equals: self namespaces associations asArray. - self namespaces keysDo: [:each | - "save to ensure prefixMappings is copied, even if unchanged" + self namespaces keysDo: [ :each | "save to ensure prefixMappings is copied, even if unchanged" oldPrefixMappings := scope prefixMappings. - scope - mapPrefix: each - to: 'newNS'. + scope mapPrefix: each to: 'newNS'. self - assert: (scope prefixMappings at: each) = 'newNS'; - deny: scope prefixMappings = oldPrefixMappings; - deny: scope prefixMappings == oldPrefixMappings]. + assert: (scope prefixMappings at: each) equals: 'newNS'; + deny: scope prefixMappings equals: oldPrefixMappings; + deny: scope prefixMappings identicalTo: oldPrefixMappings ]. "save to ensure prefixMappings is copied, even if unchanged" oldPrefixMappings := scope prefixMappings. - scope - mapPrefix: 'xml' - to: scope xmlNamespaceURI. + scope mapPrefix: 'xml' to: scope xmlNamespaceURI. self - assert: (scope prefixMappings at: 'xml') = scope xmlNamespaceURI; - deny: scope prefixMappings = oldPrefixMappings; - deny: scope prefixMappings == oldPrefixMappings. + assert: (scope prefixMappings at: 'xml') + equals: scope xmlNamespaceURI; + deny: scope prefixMappings equals: oldPrefixMappings; + deny: scope prefixMappings identicalTo: oldPrefixMappings. "cannot rebind xmlns prefix at all, even to the same URI" self - should: [ - scope - mapPrefix: 'xmlns' - to: scope xmlnsNamespaceURI] + should: [ scope mapPrefix: 'xmlns' to: scope xmlnsNamespaceURI ] raise: XMLNamespaceException. "cannot bind a new prefix to the xml, xmlns, or empty namespace URIs" (Array - with: scope xmlNamespaceURI - with: scope xmlnsNamespaceURI - with: '') do: [:each | + with: scope xmlNamespaceURI + with: scope xmlnsNamespaceURI + with: '') do: [ :each | self - should: [ - scope - mapPrefix: 'newPrefix' - to: each] - raise: XMLNamespaceException] + should: [ scope mapPrefix: 'newPrefix' to: each ] + raise: XMLNamespaceException ] ] { #category : #tests } XMLNamespaceScopeTest >> testMapPrefixesAndURIs [ - | outerScope innerScope namespaces | + | outerScope innerScope namespaces | namespaces := self namespaces. (outerScope := self newNamespaceScope) mapPrefixesAndURIs: namespaces. self - assert: outerScope prefixMappings = namespaces; - deny: outerScope prefixMappings == namespaces. + assert: outerScope prefixMappings equals: namespaces; + deny: outerScope prefixMappings identicalTo: namespaces. "copying shares dictionary until modified" innerScope := outerScope copy. self - assert: innerScope prefixMappings = outerScope prefixMappings; - assert: innerScope prefixMappings == outerScope prefixMappings. + assert: innerScope prefixMappings equals: outerScope prefixMappings; + assert: innerScope prefixMappings + identicalTo: outerScope prefixMappings. "modifying creates new dictionary" innerScope mapPrefixesAndURIs: namespaces. self - assert: innerScope prefixMappings = outerScope prefixMappings; - deny: innerScope prefixMappings == outerScope prefixMappings + assert: innerScope prefixMappings equals: outerScope prefixMappings; + deny: innerScope prefixMappings + identicalTo: outerScope prefixMappings ] { #category : #tests } XMLNamespaceScopeTest >> testMappedPrefixes [ - | scope prefixes | + | scope prefixes | scope := self newNamespaceScope. prefixes := OrderedCollection new. - self namespaces keysAndValuesDo: [:prefix :uri | - scope - mapPrefix: prefix - to: uri. + self namespaces keysAndValuesDo: [ :prefix :uri | + scope mapPrefix: prefix to: uri. prefixes addLast: prefix. - self assert: scope mappedPrefixes = prefixes asArray] + self assert: scope mappedPrefixes equals: prefixes asArray ] ] { #category : #tests } XMLNamespaceScopeTest >> testPrefixMappingAt [ - | scope | + | scope | scope := self newNamespaceScope. self - assert: (scope prefixMappingAt: 'xml') = ''; - assert: (scope prefixMappingAt: 'xmlns') = ''. + assert: (scope prefixMappingAt: 'xml') equals: ''; + assert: (scope prefixMappingAt: 'xmlns') equals: ''. "cannot map xmlns prefix, but can map xml" scope mapPrefix: 'xml' to: XMLNamespaceScope xmlNamespaceURI. - self assert: (scope prefixMappingAt: 'xml') = XMLNamespaceScope xmlNamespaceURI. + self + assert: (scope prefixMappingAt: 'xml') + equals: XMLNamespaceScope xmlNamespaceURI. - self namespaces keysAndValuesDo: [:prefix :uri | - self assert: (scope prefixMappingAt: prefix) = ''. + self namespaces keysAndValuesDo: [ :prefix :uri | + self assert: (scope prefixMappingAt: prefix) equals: ''. scope mapPrefix: prefix to: uri. - self assert: (scope prefixMappingAt: prefix) = uri] + self assert: (scope prefixMappingAt: prefix) equals: uri ] ] { #category : #tests } XMLNamespaceScopeTest >> testPrefixMappingAtIfAbsent [ - | scope | + | scope | scope := self newNamespaceScope. - self assert: - (scope - prefixMappingAt: 'xml' - ifAbsent: [#absent]) = #absent. - self assert: - (scope - prefixMappingAt: 'xmlns' - ifAbsent: [#absent]) = #absent. - - "cannot map xmlns prefix, but can map xml" + self + assert: (scope prefixMappingAt: 'xml' ifAbsent: [ #absent ]) + equals: #absent. + self + assert: (scope prefixMappingAt: 'xmlns' ifAbsent: [ #absent ]) + equals: #absent. scope mapPrefix: 'xml' to: XMLNamespaceScope xmlNamespaceURI. - self assert: - (scope - prefixMappingAt: 'xml' - ifAbsent: [self fail]) = XMLNamespaceScope xmlNamespaceURI. + self + assert: (scope prefixMappingAt: 'xml' ifAbsent: [ self fail ]) + equals: XMLNamespaceScope xmlNamespaceURI. - self namespaces keysAndValuesDo: [:prefix :uri | - self assert: - (scope - prefixMappingAt: prefix - ifAbsent: [#absent]) = #absent. + self namespaces keysAndValuesDo: [ :prefix :uri | + self + assert: (scope prefixMappingAt: prefix ifAbsent: [ #absent ]) + equals: #absent. scope mapPrefix: prefix to: uri. - self assert: - (scope - prefixMappingAt: prefix - ifAbsent: [self fail]) = uri] + self + assert: (scope prefixMappingAt: prefix ifAbsent: [ self fail ]) + equals: uri ] ] { #category : #tests } XMLNamespaceScopeTest >> testPrefixesAndURIsDo [ - | associations | + | associations | associations := OrderedCollection new. - self newNamespaceScope prefixesAndURIsDo: [:prefix :uri | - associations addLast: prefix -> uri]. + self newNamespaceScope prefixesAndURIsDo: [ :prefix :uri | + associations addLast: prefix -> uri ]. self assert: associations isEmpty. - self newNamespaceScopeWithNamespaces prefixesAndURIsDo: [:prefix :uri | - associations addLast: prefix -> uri]. - self assert: associations asArray = self namespaces associations asArray + self newNamespaceScopeWithNamespaces prefixesAndURIsDo: [ :prefix :uri | + associations addLast: prefix -> uri ]. + self + assert: associations asArray + equals: self namespaces associations asArray ] { #category : #tests } XMLNamespaceScopeTest >> testResolvePrefix [ - | scope | + | scope | scope := self newNamespaceScope. - self namespaces keysAndValuesDo: [:prefix :uri | - self assert: (scope resolvePrefix: prefix) = ''. + self namespaces keysAndValuesDo: [ :prefix :uri | + self assert: (scope resolvePrefix: prefix) equals: ''. scope mapPrefix: prefix to: uri. - self assert: (scope resolvePrefix: prefix) = uri]. - - self assert: - (scope resolvePrefix: 'xml') = scope xmlNamespaceURI. - self assert: - (scope resolvePrefix: 'xmlns') = scope xmlnsNamespaceURI + self assert: (scope resolvePrefix: prefix) equals: uri ]. + self + assert: (scope resolvePrefix: 'xml') + equals: scope xmlNamespaceURI. + self + assert: (scope resolvePrefix: 'xmlns') + equals: scope xmlnsNamespaceURI ] { #category : #tests } XMLNamespaceScopeTest >> testResolvePrefixIfUnresolvable [ - | scope | + | scope | scope := self newNamespaceScope. - self namespaces keysAndValuesDo: [:prefix :uri | - self assert: - (scope - resolvePrefix: prefix - ifUnresolvable: ['unresolvable']) = 'unresolvable'. + self namespaces keysAndValuesDo: [ :prefix :uri | + self + assert: + (scope resolvePrefix: prefix ifUnresolvable: [ 'unresolvable' ]) + equals: 'unresolvable'. scope mapPrefix: prefix to: uri. - self assert: - (scope - resolvePrefix: prefix - ifUnresolvable: [self fail]) = uri]. - - self assert: - (scope - resolvePrefix: 'xml' - ifUnresolvable: [self fail]) = scope xmlNamespaceURI. - self assert: - (scope - resolvePrefix: 'xmlns' - ifUnresolvable: [self fail]) = scope xmlnsNamespaceURI + self + assert: (scope resolvePrefix: prefix ifUnresolvable: [ self fail ]) + equals: uri ]. + self + assert: (scope resolvePrefix: 'xml' ifUnresolvable: [ self fail ]) + equals: scope xmlNamespaceURI. + self + assert: (scope resolvePrefix: 'xmlns' ifUnresolvable: [ self fail ]) + equals: scope xmlnsNamespaceURI ] { #category : #tests } XMLNamespaceScopeTest >> testResolvePrefixesOfNamespaceURI [ - | scope | + | scope | scope := self newNamespaceScope. - self namespaces keysAndValuesDo: [:prefix :uri | - self assert: - (scope resolvePrefixesOfNamespaceURI: uri) isEmpty. + self namespaces keysAndValuesDo: [ :prefix :uri | + self assert: (scope resolvePrefixesOfNamespaceURI: uri) isEmpty. - scope - mapPrefix: prefix - to: uri. - self assert: - (scope resolvePrefixesOfNamespaceURI: uri) = - (Set with: prefix). - - scope - mapPrefix: 'newPrefix' - to: uri. - self assert: - (scope resolvePrefixesOfNamespaceURI: uri) = - (Set with: prefix with: 'newPrefix')]. - - self assert: - (scope resolvePrefixesOfNamespaceURI: scope xmlNamespaceURI) = - (Set with: 'xml'). - self assert: - (scope resolvePrefixesOfNamespaceURI: scope xmlnsNamespaceURI) = - (Set with: 'xmlns'). + scope mapPrefix: prefix to: uri. + self + assert: (scope resolvePrefixesOfNamespaceURI: uri) + equals: (Set with: prefix). - "cannot map xmlns prefix at all, but can map xml to the same URI" - scope - mapPrefix: 'xml' - to: scope xmlNamespaceURI. - self assert: - (scope resolvePrefixesOfNamespaceURI: scope xmlNamespaceURI) = - (Set with: 'xml') + scope mapPrefix: 'newPrefix' to: uri. + self + assert: (scope resolvePrefixesOfNamespaceURI: uri) + equals: (Set with: prefix with: 'newPrefix') ]. + self + assert: (scope resolvePrefixesOfNamespaceURI: scope xmlNamespaceURI) + equals: (Set with: 'xml'). + self + assert: + (scope resolvePrefixesOfNamespaceURI: scope xmlnsNamespaceURI) + equals: (Set with: 'xmlns'). + scope mapPrefix: 'xml' to: scope xmlNamespaceURI. + self + assert: (scope resolvePrefixesOfNamespaceURI: scope xmlNamespaceURI) + equals: (Set with: 'xml') ] { #category : #tests } XMLNamespaceScopeTest >> testSize [ + self - assert: self newNamespaceScope size = 0; - assert: self newNamespaceScopeWithNamespaces size = self namespaces size + assert: self newNamespaceScope size equals: 0; + assert: self newNamespaceScopeWithNamespaces size + equals: self namespaces size ] { #category : #tests } XMLNamespaceScopeTest >> testUnmapPrefix [ - | scope | + | scope | scope := self newNamespaceScope. - self namespaces keysAndValuesDo: [:prefix :uri | | oldPrefixMappings | + self namespaces keysAndValuesDo: [ :prefix :uri | + | oldPrefixMappings | self - should: [scope unmapPrefix: prefix] + should: [ scope unmapPrefix: prefix ] raise: XMLNamespaceException. self deny: (scope includesPrefix: prefix). - scope - mapPrefix: prefix - to: uri. + scope mapPrefix: prefix to: uri. oldPrefixMappings := scope prefixMappings. self - assert: (scope unmapPrefix: prefix) = uri; + assert: (scope unmapPrefix: prefix) equals: uri; deny: (scope includesPrefix: prefix). "ensure prefixMappings is copied when removing" self assert: (oldPrefixMappings includesKey: prefix); - deny: scope prefixMappings = oldPrefixMappings; - deny: scope prefixMappings == oldPrefixMappings. + deny: scope prefixMappings equals: oldPrefixMappings; + deny: scope prefixMappings identicalTo: oldPrefixMappings. self - should: [scope unmapPrefix: prefix] - raise: XMLNamespaceException]. + should: [ scope unmapPrefix: prefix ] + raise: XMLNamespaceException ]. self assert: scope prefixMappings isEmpty ] { #category : #tests } XMLNamespaceScopeTest >> testUnmapPrefixIfAbsent [ - | scope | + | scope | scope := self newNamespaceScope. - self namespaces keysAndValuesDo: [:prefix :uri | | oldPrefixMappings | - self assert: - (scope - unmapPrefix: prefix - ifAbsent: [#absent]) = #absent. + self namespaces keysAndValuesDo: [ :prefix :uri | + | oldPrefixMappings | + self + assert: (scope unmapPrefix: prefix ifAbsent: [ #absent ]) + equals: #absent. self deny: (scope includesPrefix: prefix). - scope - mapPrefix: prefix - to: uri. + scope mapPrefix: prefix to: uri. oldPrefixMappings := scope prefixMappings. - self assert: - (scope - unmapPrefix: prefix - ifAbsent: [self fail]) = uri. + self + assert: (scope unmapPrefix: prefix ifAbsent: [ self fail ]) + equals: uri. self deny: (scope includesPrefix: prefix). "ensure prefixMappings is copied when removing" self assert: (oldPrefixMappings includesKey: prefix); - deny: scope prefixMappings = oldPrefixMappings; - deny: scope prefixMappings == oldPrefixMappings. - + deny: scope prefixMappings equals: oldPrefixMappings; + deny: scope prefixMappings identicalTo: oldPrefixMappings. self - assert: - (scope - unmapPrefix: prefix - ifAbsent: [#absent]) = #absent]. + assert: (scope unmapPrefix: prefix ifAbsent: [ #absent ]) + equals: #absent ]. self assert: scope prefixMappings isEmpty ] { #category : #tests } XMLNamespaceScopeTest >> testUnmapPrefixes [ - | scope oldPrefixMappings | + | scope oldPrefixMappings | scope := self newNamespaceScopeWithNamespaces. oldPrefixMappings := scope prefixMappings. self - assert: scope unmapPrefixes == scope; + assert: scope unmapPrefixes identicalTo: scope; deny: scope hasNamespaces. "ensure prefixMappings is copied when removing" self - assert: oldPrefixMappings = self namespaces; - deny: scope prefixMappings = oldPrefixMappings; - deny: scope prefixMappings == oldPrefixMappings + assert: oldPrefixMappings equals: self namespaces; + deny: scope prefixMappings equals: oldPrefixMappings; + deny: scope prefixMappings identicalTo: oldPrefixMappings ] { #category : #tests } XMLNamespaceScopeTest >> testValidateAndResolvePrefixOfAttribute [ - | scope | + | scope | scope := self newNamespaceScope. - self namespaces keysAndValuesDo: [:prefix :uri | | attribute | + self namespaces keysAndValuesDo: [ :prefix :uri | + | attribute | attribute := 'name' qualifyWithXMLPrefix: prefix. "unprefixed attributes have no namespace URI" prefix ifEmpty: [ - scope - mapPrefix: prefix - to: uri. - self assert: - (scope - validateAndResolvePrefix: prefix - ofAttribute: attribute) = ''] + scope mapPrefix: prefix to: uri. + self + assert: + (scope validateAndResolvePrefix: prefix ofAttribute: attribute) + equals: '' ] ifNotEmpty: [ self should: [ - scope - validateAndResolvePrefix: prefix - ofAttribute: attribute] + scope validateAndResolvePrefix: prefix ofAttribute: attribute ] raise: XMLNamespaceException. - scope - mapPrefix: prefix - to: uri. - self assert: - (scope - validateAndResolvePrefix: prefix - ofAttribute: attribute) = uri]]. - - self assert: - (scope - validateAndResolvePrefix: 'xml' - ofAttribute: ('name' qualifyWithXMLPrefix: 'xml')) = - scope xmlNamespaceURI. - "cannot use 'xmlns' as an attribute prefix, since it is reserved for - namespace declarations" + scope mapPrefix: prefix to: uri. + self + assert: + (scope validateAndResolvePrefix: prefix ofAttribute: attribute) + equals: uri ] ]. + self + assert: (scope + validateAndResolvePrefix: 'xml' + ofAttribute: ('name' qualifyWithXMLPrefix: 'xml')) + equals: scope xmlNamespaceURI. self should: [ scope validateAndResolvePrefix: 'xmlns' - ofAttribute: ('name' qualifyWithXMLPrefix: 'xmlns')] + ofAttribute: ('name' qualifyWithXMLPrefix: 'xmlns') ] raise: XMLNamespaceException. self - should: [ - scope - validateAndResolvePrefix: '' - ofAttribute: ':name'] - raise: XMLNamespaceException. + should: [ scope validateAndResolvePrefix: '' ofAttribute: ':name' ] + raise: XMLNamespaceException ] { #category : #tests } XMLNamespaceScopeTest >> testValidateAndResolvePrefixOfElement [ - | scope | + | scope | scope := self newNamespaceScope. - self namespaces keysAndValuesDo: [:prefix :uri | | element | + self namespaces keysAndValuesDo: [ :prefix :uri | + | element | element := 'name' qualifyWithXMLPrefix: prefix. - prefix - ifNotEmpty: [ - self - should: [ - scope - validateAndResolvePrefix: prefix - ofElement: element] - raise: XMLNamespaceException]. - scope - mapPrefix: prefix - to: uri. - self assert: - (scope - validateAndResolvePrefix: prefix - ofElement: element) = uri]. - - self assert: - (scope - validateAndResolvePrefix: 'xml' - ofElement: ('name' qualifyWithXMLPrefix: 'xml')) = - scope xmlNamespaceURI. - "cannot use 'xmlns' as an element prefix either" + prefix ifNotEmpty: [ + self + should: [ + scope validateAndResolvePrefix: prefix ofElement: element ] + raise: XMLNamespaceException ]. + scope mapPrefix: prefix to: uri. + self + assert: (scope validateAndResolvePrefix: prefix ofElement: element) + equals: uri ]. + self + assert: (scope + validateAndResolvePrefix: 'xml' + ofElement: ('name' qualifyWithXMLPrefix: 'xml')) + equals: scope xmlNamespaceURI. self should: [ scope validateAndResolvePrefix: 'xmlns' - ofElement: ('name' qualifyWithXMLPrefix: 'xmlns')] + ofElement: ('name' qualifyWithXMLPrefix: 'xmlns') ] raise: XMLNamespaceException. self - should: [ - scope - validateAndResolvePrefix: '' - ofElement: ':name'] - raise: XMLNamespaceException. + should: [ scope validateAndResolvePrefix: '' ofElement: ':name' ] + raise: XMLNamespaceException ] { #category : #tests } @@ -686,20 +638,21 @@ XMLNamespaceScopeTest >> testValidatePrefixesOfAttributes [ { #category : #tests } XMLNamespaceScopeTest >> testXMLNSNamespaceURI [ - | namespaceURI | + | namespaceURI | namespaceURI := 'http://www.w3.org/2000/xmlns/'. self - assert: self newNamespaceScope xmlnsNamespaceURI = namespaceURI; - assert: XMLNamespaceScope xmlnsNamespaceURI = namespaceURI. + assert: self newNamespaceScope xmlnsNamespaceURI + equals: namespaceURI; + assert: XMLNamespaceScope xmlnsNamespaceURI equals: namespaceURI ] { #category : #tests } XMLNamespaceScopeTest >> testXMLNamespaceURI [ - | namespaceURI | + | namespaceURI | namespaceURI := 'http://www.w3.org/XML/1998/namespace'. self - assert: self newNamespaceScope xmlNamespaceURI = namespaceURI; - assert: XMLNamespaceScope xmlNamespaceURI = namespaceURI. + assert: self newNamespaceScope xmlNamespaceURI equals: namespaceURI; + assert: XMLNamespaceScope xmlNamespaceURI equals: namespaceURI ] diff --git a/src/XML-Parser-Tests/XMLNamespacedAttributeDictionaryTest.class.st b/src/XML-Parser-Tests/XMLNamespacedAttributeDictionaryTest.class.st index 3a974174..77e04460 100644 --- a/src/XML-Parser-Tests/XMLNamespacedAttributeDictionaryTest.class.st +++ b/src/XML-Parser-Tests/XMLNamespacedAttributeDictionaryTest.class.st @@ -139,60 +139,54 @@ XMLNamespacedAttributeDictionaryTest >> testAssociationAtNameNamespaceURIIfAbsen { #category : #tests } XMLNamespacedAttributeDictionaryTest >> testAtNameNamespaceURI [ - | dictionary | + | dictionary | dictionary := self prefixedAttributeDictionary. - self assert: - (dictionary - atName: 'id' - namespaceURI: XMLNamespaceScope xmlNamespaceURI) equals: 'id'. - self assert: - (dictionary - atName: 'id' - namespaceURI: 'defaultNS') equals: ''. - self assert: - (dictionary - atName: 'xml:id' - namespaceURI: XMLNamespaceScope xmlNamespaceURI) equals: 'id'. - self assert: - (dictionary - atName: 'xml:id' - namespaceURI: 'defaultNS') equals: ''. + self + assert: (dictionary + atName: 'id' + namespaceURI: XMLNamespaceScope xmlNamespaceURI) + equals: 'id'. + self + assert: (dictionary atName: 'id' namespaceURI: 'defaultNS') + equals: ''. + self + assert: (dictionary + atName: 'xml:id' + namespaceURI: XMLNamespaceScope xmlNamespaceURI) + equals: 'id'. + self + assert: (dictionary atName: 'xml:id' namespaceURI: 'defaultNS') + equals: ''. - self assert: - (dictionary - atName: 'name' - namespaceURI: 'prefixNS') equals: 'prefixValue'. - self assert: - (dictionary - atName: 'prefix:name' - namespaceURI: 'prefixNS') = 'prefixValue'. - self assert: - (dictionary - atName: 'prefix:name' - namespaceURI: 'defaultNS') equals: ''. + self + assert: (dictionary atName: 'name' namespaceURI: 'prefixNS') + equals: 'prefixValue'. + self + assert: (dictionary atName: 'prefix:name' namespaceURI: 'prefixNS') + equals: 'prefixValue'. + self + assert: (dictionary atName: 'prefix:name' namespaceURI: 'defaultNS') + equals: ''. - self assert: - (dictionary - atName: 'name' - namespaceURI: 'otherPrefixNS') equals: 'otherPrefixValue'. - self assert: - (dictionary - atName: 'otherPrefix:name' - namespaceURI: 'otherPrefixNS') equals: 'otherPrefixValue'. - self assert: - (dictionary - atName: 'otherPrefix:name' - namespaceURI: 'defaultNS') equals: ''. + self + assert: (dictionary atName: 'name' namespaceURI: 'otherPrefixNS') + equals: 'otherPrefixValue'. + self + assert: + (dictionary atName: 'otherPrefix:name' namespaceURI: 'otherPrefixNS') + equals: 'otherPrefixValue'. + self + assert: + (dictionary atName: 'otherPrefix:name' namespaceURI: 'defaultNS') + equals: ''. - self assert: - (dictionary - atName: 'name' - namespaceURI: '') equals: 'value'. - self assert: - (dictionary - atName: 'name' - namespaceURI: 'defaultNS') equals: '' + self + assert: (dictionary atName: 'name' namespaceURI: '') + equals: 'value'. + self + assert: (dictionary atName: 'name' namespaceURI: 'defaultNS') + equals: '' ] { #category : #tests } @@ -267,12 +261,14 @@ XMLNamespacedAttributeDictionaryTest >> testAtNameNamespaceURIIfAbsent [ { #category : #tests } XMLNamespacedAttributeDictionaryTest >> testCopy [ - | dictionary copy | + | dictionary copy | super testCopy. dictionary := self prefixedAttributeDictionary. copy := dictionary copy. - self assert: dictionary namespaceScope == copy namespaceScope + self + assert: dictionary namespaceScope + identicalTo: copy namespaceScope ] { #category : #tests } diff --git a/src/XML-Parser-Tests/XMLNestedStreamReaderTest.class.st b/src/XML-Parser-Tests/XMLNestedStreamReaderTest.class.st index fac26659..aaedfac1 100644 --- a/src/XML-Parser-Tests/XMLNestedStreamReaderTest.class.st +++ b/src/XML-Parser-Tests/XMLNestedStreamReaderTest.class.st @@ -124,8 +124,8 @@ XMLNestedStreamReaderTest >> testAtEnd [ { #category : #tests } XMLNestedStreamReaderTest >> testCloseStreams [ - | stream streamReader pushedBackStream evaluated | + | stream streamReader pushedBackStream evaluated | stream := self newStreamOnSourceXML. streamReader := self newStreamReaderOn: stream. @@ -133,27 +133,24 @@ XMLNestedStreamReaderTest >> testCloseStreams [ evaluated := false. streamReader pushBackStream: pushedBackStream - whenPoppedDo: [evaluated := true] + whenPoppedDo: [ evaluated := true ] isExternal: true. self - assert: streamReader stream == pushedBackStream; + assert: streamReader stream identicalTo: pushedBackStream; assert: streamReader hasPushedBackStreams; deny: stream wasClosed; deny: pushedBackStream wasClosed. - self - assert: streamReader closeStreams == streamReader; + assert: streamReader closeStreams identicalTo: streamReader; assert: streamReader atEnd; - deny: streamReader stream == stream; - deny: streamReader stream == pushedBackStream; + deny: streamReader stream identicalTo: stream; + deny: streamReader stream identicalTo: pushedBackStream; deny: streamReader hasPushedBackStreams; assert: stream wasClosed; assert: pushedBackStream wasClosed; deny: evaluated. - self - shouldnt: [streamReader closeStreams] - raise: Error + self shouldnt: [ streamReader closeStreams ] raise: Error ] { #category : #tests } @@ -182,100 +179,108 @@ XMLNestedStreamReaderTest >> testIsStream [ { #category : #tests } XMLNestedStreamReaderTest >> testIsXMLBinaryOrExternalStream [ - | streamReader | + | streamReader | streamReader := self newStreamReaderOnSourceXML. - self assert: streamReader isXMLBinaryOrExternalStream = streamReader isBinary + self + assert: streamReader isXMLBinaryOrExternalStream + equals: streamReader isBinary ] { #category : #tests } XMLNestedStreamReaderTest >> testLineEndingNormalizationAcrossStreams [ - | streamReader | - streamReader := - self newStreamReaderOn: - (self newStreamOn: (String with: self lf)). + | streamReader | + streamReader := self newStreamReaderOn: + (self newStreamOn: (String with: self lf)). streamReader pushBackCharacter: self cr. streamReader pushBackStream: - (self newStreamOn: - (String with: self cr with: self lf)) + (self newStreamOn: (String with: self cr with: self lf)) whenPoppedDo: nil isExternal: true. self - assert: streamReader next = self normalizedLineEnding; + assert: streamReader next equals: self normalizedLineEnding; deny: streamReader atEnd; - assert: streamReader next = self cr; + assert: streamReader next equals: self cr; deny: streamReader atEnd; - assert: streamReader next = self normalizedLineEnding; + assert: streamReader next equals: self normalizedLineEnding; assert: streamReader atEnd ] { #category : #tests } XMLNestedStreamReaderTest >> testNext [ - | streamReader currentLineNumber currentColumnNumber currentPosition | + | streamReader currentLineNumber currentColumnNumber currentPosition | streamReader := self newStreamReaderOnSourceXML. currentLineNumber := 1. currentColumnNumber := currentPosition := 0. - self normalizedSourceXML do: [:each | - self assert: streamReader next = each. + self normalizedSourceXML do: [ :each | + self assert: streamReader next equals: each. each = self normalizedLineEnding ifTrue: [ currentLineNumber := currentLineNumber + 1. - currentColumnNumber := 0] - ifFalse: [currentColumnNumber := currentColumnNumber + 1]. + currentColumnNumber := 0 ] + ifFalse: [ currentColumnNumber := currentColumnNumber + 1 ]. currentPosition := currentPosition + 1. self - assert: streamReader currentLineNumber = currentLineNumber; - assert: streamReader currentColumnNumber = currentColumnNumber; - assert: streamReader currentPosition = currentPosition]. + assert: streamReader currentLineNumber equals: currentLineNumber; + assert: streamReader currentColumnNumber + equals: currentColumnNumber; + assert: streamReader currentPosition equals: currentPosition ]. self assert: streamReader next isNil. streamReader := self newStreamReaderOnSourceXML. self - assert: (streamReader next: self normalizedSourceXML size) = self normalizedSourceXML; - assert: streamReader currentLineNumber = currentLineNumber; - assert: streamReader currentColumnNumber = currentColumnNumber; - assert: streamReader currentPosition = currentPosition; - assert: (streamReader next: self normalizedSourceXML size) = '' + assert: (streamReader next: self normalizedSourceXML size) + equals: self normalizedSourceXML; + assert: streamReader currentLineNumber equals: currentLineNumber; + assert: streamReader currentColumnNumber + equals: currentColumnNumber; + assert: streamReader currentPosition equals: currentPosition; + assert: (streamReader next: self normalizedSourceXML size) + equals: '' ] { #category : #tests } XMLNestedStreamReaderTest >> testNormalizedLineEndingChar [ - | streamReader | + | streamReader | streamReader := self newStreamReaderOnSourceXML. self - assert: (streamReader normalizedLineEndingChar: $N) == streamReader; - assert: (streamReader normalizedLineEndingChar) == $N; - assert: streamReader upToEnd = (self sourceXMLNormalizedWith: $N) + assert: (streamReader normalizedLineEndingChar: $N) + identicalTo: streamReader; + assert: streamReader normalizedLineEndingChar identicalTo: $N; + assert: streamReader upToEnd + equals: (self sourceXMLNormalizedWith: $N) ] { #category : #tests } XMLNestedStreamReaderTest >> testPeek [ - | streamReader currentLineNumber currentColumnNumber currentPosition | + | streamReader currentLineNumber currentColumnNumber currentPosition | streamReader := self newStreamReaderOnSourceXML. currentLineNumber := 1. currentColumnNumber := currentPosition := 0. - self normalizedSourceXML do: [:each | + self normalizedSourceXML do: [ :each | self - assert: streamReader peek = each; - assert: streamReader currentLineNumber = currentLineNumber; - assert: streamReader currentColumnNumber = currentColumnNumber. + assert: streamReader peek equals: each; + assert: streamReader currentLineNumber equals: currentLineNumber; + assert: streamReader currentColumnNumber + equals: currentColumnNumber. streamReader next. each = self normalizedLineEnding ifTrue: [ currentLineNumber := currentLineNumber + 1. - currentColumnNumber := 0] - ifFalse: [currentColumnNumber := currentColumnNumber + 1]. + currentColumnNumber := 0 ] + ifFalse: [ currentColumnNumber := currentColumnNumber + 1 ]. currentPosition := currentPosition + 1. self - assert: streamReader currentLineNumber = currentLineNumber; - assert: streamReader currentColumnNumber = currentColumnNumber; - assert: streamReader currentPosition = currentPosition]. + assert: streamReader currentLineNumber equals: currentLineNumber; + assert: streamReader currentColumnNumber + equals: currentColumnNumber; + assert: streamReader currentPosition equals: currentPosition ]. self assert: streamReader peek isNil ] @@ -298,23 +303,24 @@ XMLNestedStreamReaderTest >> testPeekFor [ { #category : #tests } XMLNestedStreamReaderTest >> testPushBackStreamWhenPoppedDoIsExternal [ - | streamReader evaluated | + | streamReader evaluated | streamReader := self newStreamReaderOn: (self newStreamOn: ''). evaluated := false. - self assert: - (streamReader - pushBackStream: self newStreamReaderOnSourceXML - whenPoppedDo: [evaluated := true] - isExternal: true) == streamReader. - self normalizedSourceXML do: [:each | + self + assert: (streamReader + pushBackStream: self newStreamReaderOnSourceXML + whenPoppedDo: [ evaluated := true ] + isExternal: true) + identicalTo: streamReader. + self normalizedSourceXML do: [ :each | self - assert: streamReader peek = each; - assert: streamReader next = each; - deny: evaluated]. + assert: streamReader peek equals: each; + assert: streamReader next equals: each; + deny: evaluated ]. self assert: streamReader next isNil; - assert: evaluated. + assert: evaluated ] { #category : #tests } @@ -323,7 +329,6 @@ XMLNestedStreamReaderTest >> testPushBackStreamWhenPoppedDoIsExternalException [ the stream from being closed or getting popped" | stream streamReader evaluated | - stream := self newStreamOnSourceXML. streamReader := self newStreamReaderOnSourceXML. evaluated := false. @@ -331,59 +336,56 @@ XMLNestedStreamReaderTest >> testPushBackStreamWhenPoppedDoIsExternalException [ pushBackStream: stream whenPoppedDo: [ evaluated := true. - Error signal] + Error signal ] isExternal: true. self - assert: streamReader stream == stream; + assert: streamReader stream identicalTo: stream; deny: evaluated; deny: stream wasClosed. + self should: [ streamReader upToEnd ] raise: Error. self - should: [streamReader upToEnd] - raise: Error. - self - deny: streamReader stream == stream; + deny: streamReader stream identicalTo: stream; assert: evaluated; - assert: stream wasClosed. + assert: stream wasClosed ] { #category : #tests } XMLNestedStreamReaderTest >> testSkipSeparators [ - | streamReader stream currentLineNumber currentColumnNumber currentPosition | + | streamReader stream currentLineNumber currentColumnNumber currentPosition | streamReader := self newStreamReaderOnSourceXML. stream := self newStreamOn: self normalizedSourceXML. currentLineNumber := 1. currentColumnNumber := currentPosition := 0. - [stream atEnd] - whileFalse: [| totalSeparatorsSkipped | - totalSeparatorsSkipped := 0. - [self separators includes: stream peek] - whileTrue: [ - stream next = self normalizedLineEnding - ifTrue: [ - currentLineNumber := currentLineNumber + 1. - currentColumnNumber := 0] - ifFalse: [currentColumnNumber := currentColumnNumber + 1]. - currentPosition := currentPosition + 1. - totalSeparatorsSkipped := totalSeparatorsSkipped + 1]. - streamReader skipSeparators. - self - assert: streamReader currentLineNumber = currentLineNumber; - assert: streamReader currentColumnNumber = currentColumnNumber; - assert: streamReader currentPosition = currentPosition. - totalSeparatorsSkipped > 0 - ifFalse: [ - stream next. - streamReader next. - currentColumnNumber := currentColumnNumber + 1. - currentPosition := currentPosition + 1]]. + [ stream atEnd ] whileFalse: [ + | totalSeparatorsSkipped | + totalSeparatorsSkipped := 0. + [ self separators includes: stream peek ] whileTrue: [ + stream next = self normalizedLineEnding + ifTrue: [ + currentLineNumber := currentLineNumber + 1. + currentColumnNumber := 0 ] + ifFalse: [ currentColumnNumber := currentColumnNumber + 1 ]. + currentPosition := currentPosition + 1. + totalSeparatorsSkipped := totalSeparatorsSkipped + 1 ]. + streamReader skipSeparators. + self + assert: streamReader currentLineNumber equals: currentLineNumber; + assert: streamReader currentColumnNumber + equals: currentColumnNumber; + assert: streamReader currentPosition equals: currentPosition. + totalSeparatorsSkipped > 0 ifFalse: [ + stream next. + streamReader next. + currentColumnNumber := currentColumnNumber + 1. + currentPosition := currentPosition + 1 ] ] ] { #category : #tests } XMLNestedStreamReaderTest >> testStreamPushbackPortability [ - | streamReader output lastPeek lastNext | + | streamReader output lastPeek lastNext | streamReader := self newStreamReaderOn: (self newStreamOn: ''). streamReader pushBackStream: self newStreamOnSourceXML @@ -393,46 +395,49 @@ XMLNestedStreamReaderTest >> testStreamPushbackPortability [ self shouldnt: [ self normalizedSourceXML size timesRepeat: [ - output nextPut: - (streamReader - peek; - next)]. + output nextPut: (streamReader + peek; + next) ]. lastPeek := streamReader peek. - lastNext := streamReader next] + lastNext := streamReader next ] raise: Error. self - assert: output contents = self normalizedSourceXML; + assert: output contents equals: self normalizedSourceXML; assert: lastPeek isNil; assert: lastNext isNil; - assert: streamReader atEnd. + assert: streamReader atEnd ] { #category : #tests } XMLNestedStreamReaderTest >> testUpTo [ - self normalizedSourceXML do: [:each | | streamReader | + + self normalizedSourceXML do: [ :each | + | streamReader | streamReader := self newStreamReaderOnSourceXML. - self assert: - (streamReader upTo: each) = - (self normalizedSourceXML copyUpTo: each). - self assert: - streamReader upToEnd = - (self normalizedSourceXML copyAfter: each)]. - self assert: - (self newStreamReaderOnSourceXML upTo: self absentChar) = self normalizedSourceXML. + self + assert: (streamReader upTo: each) + equals: (self normalizedSourceXML copyUpTo: each). + self + assert: streamReader upToEnd + equals: (self normalizedSourceXML copyAfter: each) ]. + self + assert: (self newStreamReaderOnSourceXML upTo: self absentChar) + equals: self normalizedSourceXML ] { #category : #tests } XMLNestedStreamReaderTest >> testUpToEnd [ - | streamReader | - self normalizedSourceXML withIndexDo: [:each :i | + | streamReader | + self normalizedSourceXML withIndexDo: [ :each :i | streamReader := self newStreamReaderOnSourceXML. streamReader next: i. self - assert: streamReader upToEnd = (self normalizedSourceXML allButFirst: i); - assert: streamReader upToEnd = '']. + assert: streamReader upToEnd + equals: (self normalizedSourceXML allButFirst: i); + assert: streamReader upToEnd equals: '' ]. streamReader := self newStreamReaderOnSourceXML. self - assert: streamReader upToEnd = self normalizedSourceXML; - assert: streamReader upToEnd = ''. + assert: streamReader upToEnd equals: self normalizedSourceXML; + assert: streamReader upToEnd equals: '' ] diff --git a/src/XML-Parser-Tests/XMLNodeCanonicalPrintingTest.class.st b/src/XML-Parser-Tests/XMLNodeCanonicalPrintingTest.class.st index fab3d6df..85624ec3 100644 --- a/src/XML-Parser-Tests/XMLNodeCanonicalPrintingTest.class.st +++ b/src/XML-Parser-Tests/XMLNodeCanonicalPrintingTest.class.st @@ -11,8 +11,8 @@ XMLNodeCanonicalPrintingTest >> onCanonicalLineBreakJoin: aLineCollection [ { #category : #tests } XMLNodeCanonicalPrintingTest >> testCharacterReferences [ - | xml | + | xml | xml := ' @@ -26,28 +26,24 @@ XMLNodeCanonicalPrintingTest >> testCharacterReferences [ '. - - self assert: - ((XMLDOMParser on: xml) - isValidating: false; - parseDocument) canonicallyPrinted = - (self onCanonicalLineBreakJoin: - #('' - ' First line ' - 'Second line' - ' 2' - ' value>"0" && value<"10" ?"valid":"error"' - ' valid' - ' ' - ' ' - ' ' - '')) + self + assert: ((XMLDOMParser on: xml) + isValidating: false; + parseDocument) canonicallyPrinted + equals: (self onCanonicalLineBreakJoin: + #( '' ' First line ' 'Second line' + ' 2' ' value>"0" && value<"10" ?"valid":"error"' + ' valid' + ' ' + ' ' + ' ' + '' )) ] { #category : #tests } XMLNodeCanonicalPrintingTest >> testEntityReferences [ - | xml resolver | + | xml resolver | xml := ' @@ -64,35 +60,31 @@ XMLNodeCanonicalPrintingTest >> testEntityReferences [ (resolver := DTDStaticExternalEntityResolver new) externalEntityAtURI: 'world.txt' put: 'world'. - self assert: - ((XMLDOMParser on: xml) - externalEntityResolver: resolver copy; - resolvesExternalEntities: true; - isValidating: false; - parseDocument) canonicallyPrinted = - (self onCanonicalLineBreakJoin: - #('' - ' Hello, world!' - '')). - - self assert: - ((XMLDOMParser on: xml) - externalEntityResolver: resolver copy; - resolvesExternalEntities: true; - isValidating: false; - preservesCommentNodes: true; - parseDocument) canonicallyPrinted = - (self onCanonicalLineBreakJoin: - #('' - ' Hello, world!' - '' - '')) + self + assert: ((XMLDOMParser on: xml) + externalEntityResolver: resolver copy; + resolvesExternalEntities: true; + isValidating: false; + parseDocument) canonicallyPrinted + equals: (self onCanonicalLineBreakJoin: + #( '' ' Hello, world!' + '' )). + self + assert: ((XMLDOMParser on: xml) + externalEntityResolver: resolver copy; + resolvesExternalEntities: true; + isValidating: false; + preservesCommentNodes: true; + parseDocument) canonicallyPrinted + equals: (self onCanonicalLineBreakJoin: + #( '' ' Hello, world!' + '' '' )) ] { #category : #tests } XMLNodeCanonicalPrintingTest >> testPIsAndComments [ - | xml | + | xml | xml := ' > testPIsAndComments [ '. - - self assert: - (XMLDOMParser parse: xml) - canonicallyPrinted = - (self onCanonicalLineBreakJoin: - #('' - 'Hello, world!' - '')). - - self assert: - ((XMLDOMParser on: xml) - preservesCommentNodes: true; - parseDocument) canonicallyPrinted = - (self onCanonicalLineBreakJoin: - #('' - 'Hello, world!' - '' - '' - '')) + self + assert: (XMLDOMParser parse: xml) canonicallyPrinted + equals: (self onCanonicalLineBreakJoin: + #( '' 'Hello, world!' + '' )). + self + assert: ((XMLDOMParser on: xml) + preservesCommentNodes: true; + parseDocument) canonicallyPrinted + equals: (self onCanonicalLineBreakJoin: + #( '' 'Hello, world!' + '' '' + '' )) ] { #category : #tests } XMLNodeCanonicalPrintingTest >> testStartAndEndTags [ - | xml | + | xml | xml := ']> @@ -152,32 +138,24 @@ XMLNodeCanonicalPrintingTest >> testStartAndEndTags [ '. - - self assert: - ((XMLDOMParser on: xml) - isValidating: false; - parseDocument) canonicallyPrinted = - (self onCanonicalLineBreakJoin: - #('' - ' ' - ' ' - ' ' - ' ' - ' ' - ' ' - ' ' - ' ' - ' ' - ' ' - ' ' - ' ' - '')) + self + assert: ((XMLDOMParser on: xml) + isValidating: false; + parseDocument) canonicallyPrinted + equals: (self onCanonicalLineBreakJoin: + #( '' ' ' ' ' ' ' + ' ' + ' ' + ' ' + ' ' + ' ' ' ' + ' ' ' ' ' ' '' )) ] { #category : #tests } XMLNodeCanonicalPrintingTest >> testWhitespace [ - | xml | + | xml | xml := ' @@ -191,20 +169,11 @@ XMLNodeCanonicalPrintingTest >> testWhitespace [ '. - - self assert: - (XMLDOMParser parse: xml) - canonicallyPrinted = - (self onCanonicalLineBreakJoin: - #('' - ' ' - ' A B ' - ' ' - ' A' - ' ' - ' B' - ' A B ' - ' C' - ' ' - '')) + self + assert: (XMLDOMParser parse: xml) canonicallyPrinted + equals: (self onCanonicalLineBreakJoin: + #( '' ' ' ' A B ' + ' ' ' A' ' ' + ' B' ' A B ' + ' C' ' ' '' )) ] diff --git a/src/XML-Parser-Tests/XMLNodeFactoryTest.class.st b/src/XML-Parser-Tests/XMLNodeFactoryTest.class.st index f485031a..7e03153b 100644 --- a/src/XML-Parser-Tests/XMLNodeFactoryTest.class.st +++ b/src/XML-Parser-Tests/XMLNodeFactoryTest.class.st @@ -63,216 +63,244 @@ XMLNodeFactoryTest >> sampleUserXML [ { #category : #tests } XMLNodeFactoryTest >> testAsPluggableNodeFactory [ - | factory pluggableFactory | + | factory pluggableFactory | factory := self factoryClass new. pluggableFactory := factory asPluggableNodeFactory. - self assert: pluggableFactory class == self pluggableFactoryClass. + self + assert: pluggableFactory class + identicalTo: self pluggableFactoryClass. factory class == self pluggableFactoryClass - ifTrue: [self assert: pluggableFactory == factory] - ifFalse: [self deny: pluggableFactory == factory] + ifTrue: [ self assert: pluggableFactory identicalTo: factory ] + ifFalse: [ self deny: pluggableFactory identicalTo: factory ] ] { #category : #tests } XMLNodeFactoryTest >> testAttributeDeclarationClass [ - self assert: self newFactory attributeDeclarationClass == XMLAttributeDeclaration + + self + assert: self newFactory attributeDeclarationClass + identicalTo: XMLAttributeDeclaration ] { #category : #tests } XMLNodeFactoryTest >> testAttributeListClass [ - self assert: self newFactory attributeListClass == XMLCachingAttributeList + + self + assert: self newFactory attributeListClass + identicalTo: XMLCachingAttributeList ] { #category : #tests } XMLNodeFactoryTest >> testCDataClass [ - self assert: self newFactory cdataClass == XMLCData + + self assert: self newFactory cdataClass identicalTo: XMLCData ] { #category : #tests } XMLNodeFactoryTest >> testClassForElement [ - self assert: (self newFactory classForElement: 'test') == XMLElement + + self + assert: (self newFactory classForElement: 'test') + identicalTo: XMLElement ] { #category : #tests } XMLNodeFactoryTest >> testClassForElementNamespaceURI [ - self assert: - (self newFactory - classForElement: 'test' - namespaceURI: '') == XMLElement. - self assert: - (self newFactory - classForElement: 'test' - namespaceURI: 'testNS') == XMLElement + + self + assert: (self newFactory classForElement: 'test' namespaceURI: '') + identicalTo: XMLElement. + self + assert: + (self newFactory classForElement: 'test' namespaceURI: 'testNS') + identicalTo: XMLElement ] { #category : #tests } XMLNodeFactoryTest >> testCommentClass [ - self assert: self newFactory commentClass == XMLComment + + self assert: self newFactory commentClass identicalTo: XMLComment ] { #category : #tests } XMLNodeFactoryTest >> testDoctypeDeclarationClass [ - self assert: self newFactory doctypeDeclarationClass == XMLDoctypeDeclaration + + self + assert: self newFactory doctypeDeclarationClass + identicalTo: XMLDoctypeDeclaration ] { #category : #tests } XMLNodeFactoryTest >> testDocumentClass [ - self assert: self newFactory documentClass == XMLDocument + + self assert: self newFactory documentClass identicalTo: XMLDocument ] { #category : #tests } XMLNodeFactoryTest >> testElementClass [ - self assert: self newFactory elementClass == XMLElement + + self assert: self newFactory elementClass identicalTo: XMLElement ] { #category : #tests } XMLNodeFactoryTest >> testElementDeclarationClass [ - self assert: self newFactory elementDeclarationClass == XMLElementDeclaration + + self + assert: self newFactory elementDeclarationClass + identicalTo: XMLElementDeclaration ] { #category : #tests } XMLNodeFactoryTest >> testGeneralEntityDeclarationClass [ - self assert: - self newFactory generalEntityDeclarationClass == - XMLGeneralEntityDeclaration + + self + assert: self newFactory generalEntityDeclarationClass + identicalTo: XMLGeneralEntityDeclaration ] { #category : #tests } XMLNodeFactoryTest >> testNewCData [ - | cdata | + | cdata | cdata := self newFactory newCData: 'test'. self - assert: cdata class == XMLCData; - assert: cdata string = 'test' + assert: cdata class identicalTo: XMLCData; + assert: cdata string equals: 'test' ] { #category : #tests } XMLNodeFactoryTest >> testNewComment [ - | comment | + | comment | comment := self newFactory newComment: 'test'. self - assert: comment class == XMLComment; - assert: comment string = 'test' + assert: comment class identicalTo: XMLComment; + assert: comment string equals: 'test' ] { #category : #tests } XMLNodeFactoryTest >> testNewDocument [ - self assert: self newFactory newDocument class == XMLDocument + + self + assert: self newFactory newDocument class + identicalTo: XMLDocument ] { #category : #tests } XMLNodeFactoryTest >> testNewElement [ - self assert: self newFactory newElement class == XMLElement + + self assert: self newFactory newElement class identicalTo: XMLElement ] { #category : #tests } XMLNodeFactoryTest >> testNewElementNamed [ - | element | + | element | element := self newFactory newElementNamed: 'test'. self - assert: element class == XMLElement; - assert: element name = 'test' + assert: element class identicalTo: XMLElement; + assert: element name equals: 'test' ] { #category : #tests } XMLNodeFactoryTest >> testNewElementNamedAttributes [ - | element | - element := - self newFactory - newElementNamed: 'test' - attributes: self attributeAssociations. + | element | + element := self newFactory + newElementNamed: 'test' + attributes: self attributeAssociations. self - assert: element class == XMLElement; - assert: element name = 'test'; - assert: element attributes = self attributes + assert: element class identicalTo: XMLElement; + assert: element name equals: 'test'; + assert: element attributes equals: self attributes ] { #category : #tests } XMLNodeFactoryTest >> testNewElementNamedNamespaceURI [ - | element | - element := - self newFactory - newElementNamed: 'prefix:test' - namespaceURI: 'prefixNS'. + | element | + element := self newFactory + newElementNamed: 'prefix:test' + namespaceURI: 'prefixNS'. self - assert: element class == XMLElement; - assert: element name = 'prefix:test'; - assert: element namespaceURI = 'prefixNS' + assert: element class identicalTo: XMLElement; + assert: element name equals: 'prefix:test'; + assert: element namespaceURI equals: 'prefixNS' ] { #category : #tests } XMLNodeFactoryTest >> testNewElementNamedNamespaceURIAttributes [ - | element | - element := - self newFactory - newElementNamed: 'prefix:test' - namespaceURI: 'prefixNS' - attributes: self attributeAssociations. + | element | + element := self newFactory + newElementNamed: 'prefix:test' + namespaceURI: 'prefixNS' + attributes: self attributeAssociations. self - assert: element class == XMLElement; - assert: element name = 'prefix:test'; - assert: element namespaceURI = 'prefixNS'; - assert: element attributes = self attributes. + assert: element class identicalTo: XMLElement; + assert: element name equals: 'prefix:test'; + assert: element namespaceURI equals: 'prefixNS'; + assert: element attributes equals: self attributes ] { #category : #tests } XMLNodeFactoryTest >> testNewPI [ - self assert: self newFactory newPI class == XMLPI + + self assert: self newFactory newPI class identicalTo: XMLPI ] { #category : #tests } XMLNodeFactoryTest >> testNewPITargetData [ - | pi | - pi := - self newFactory - newPITarget: 'target' - data: 'data'. + | pi | + pi := self newFactory newPITarget: 'target' data: 'data'. self - assert: pi class == XMLPI; - assert: pi target = 'target'; - assert: pi data = 'data'. + assert: pi class identicalTo: XMLPI; + assert: pi target equals: 'target'; + assert: pi data equals: 'data' ] { #category : #tests } XMLNodeFactoryTest >> testNewStringNode [ - | cdata | + | cdata | cdata := self newFactory newStringNode: 'test'. self - assert: cdata class == XMLString; - assert: cdata string = 'test'. + assert: cdata class identicalTo: XMLString; + assert: cdata string equals: 'test' ] { #category : #tests } XMLNodeFactoryTest >> testNodeListClass [ - self assert: self newFactory nodeListClass == XMLNodeList + + self assert: self newFactory nodeListClass identicalTo: XMLNodeList ] { #category : #tests } XMLNodeFactoryTest >> testNotationDeclarationClass [ - self assert: self newFactory notationDeclarationClass == XMLNotationDeclaration + + self + assert: self newFactory notationDeclarationClass + identicalTo: XMLNotationDeclaration ] { #category : #tests } XMLNodeFactoryTest >> testPIClass [ - self assert: self newFactory piClass == XMLPI + + self assert: self newFactory piClass identicalTo: XMLPI ] { #category : #tests } XMLNodeFactoryTest >> testParameterEntityDeclarationClass [ - self assert: - self newFactory parameterEntityDeclarationClass == - XMLParameterEntityDeclaration + + self + assert: self newFactory parameterEntityDeclarationClass + identicalTo: XMLParameterEntityDeclaration ] { #category : #tests } XMLNodeFactoryTest >> testStringNodeClass [ - self assert: self newFactory stringNodeClass == XMLString + + self assert: self newFactory stringNodeClass identicalTo: XMLString ] diff --git a/src/XML-Parser-Tests/XMLNodeListTest.class.st b/src/XML-Parser-Tests/XMLNodeListTest.class.st index a3d589c9..3ccdfaed 100644 --- a/src/XML-Parser-Tests/XMLNodeListTest.class.st +++ b/src/XML-Parser-Tests/XMLNodeListTest.class.st @@ -132,79 +132,79 @@ XMLNodeListTest >> testContentNodesDo [ { #category : #tests } XMLNodeListTest >> testContentStringAt [ - | list | + | list | list := self listWithItems. - self listElements do: [:each | - self assert: - (list contentStringAt: each name) = each contentString] + self listElements do: [ :each | + self + assert: (list contentStringAt: each name) + equals: each contentString ] ] { #category : #tests } XMLNodeListTest >> testElementAfter [ - | list elementAfter | + | list elementAfter | list := self listWithItems. elementAfter := nil. - self listElements reverseDo: [:each | - self assert: (list elementAfter: each) = elementAfter. - elementAfter := each] + self listElements reverseDo: [ :each | + self assert: (list elementAfter: each) equals: elementAfter. + elementAfter := each ] ] { #category : #tests } XMLNodeListTest >> testElementAt [ - | list | + | list | list := self listWithItems. - self listElements do: [:each | | changedElement | - self assert: (list elementAt: each name) = each. + self listElements do: [ :each | + | changedElement | + self assert: (list elementAt: each name) equals: each. changedElement := self changedListItem: each. list addFirst: changedElement. - self assert: (list elementAt: each name) = changedElement. + self assert: (list elementAt: each name) equals: changedElement. list remove: each; remove: changedElement. - self assert: (list elementAt: each name) = self defaultValue] + self assert: (list elementAt: each name) equals: self defaultValue ] ] { #category : #tests } XMLNodeListTest >> testElementAtIfAbsent [ - | list | + | list | list := self listWithItems. - self listElements do: [:each | | changedElement | - self assert: - (list - elementAt: each name - ifAbsent: [self fail]) = each. + self listElements do: [ :each | + | changedElement | + self + assert: (list elementAt: each name ifAbsent: [ self fail ]) + equals: each. changedElement := self changedListItem: each. list addFirst: changedElement. - self assert: - (list - elementAt: each name - ifAbsent: [self fail]) = changedElement. + self + assert: (list elementAt: each name ifAbsent: [ self fail ]) + equals: changedElement. list remove: each; remove: changedElement. - self assert: - (list - elementAt: each name - ifAbsent: [self newListItem]) = self newListItem] + self + assert: (list elementAt: each name ifAbsent: [ self newListItem ]) + equals: self newListItem ] ] { #category : #tests } XMLNodeListTest >> testElementBefore [ - | list elementBefore | + | list elementBefore | list := self listWithItems. elementBefore := nil. - self listElements do: [:each | - self assert: (list elementBefore: each) = elementBefore. - elementBefore := each] + self listElements do: [ :each | + self assert: (list elementBefore: each) equals: elementBefore. + elementBefore := each ] ] { #category : #tests } @@ -231,27 +231,28 @@ XMLNodeListTest >> testElements [ { #category : #tests } XMLNodeListTest >> testElementsAt [ - self listElements do: [:element | | list elementsAt changedElement | + + self listElements do: [ :element | + | list elementsAt changedElement | list := self listWithItems. - elementsAt := - self listElements select: [:each | - each isNamed: element name]. - self assert: - (list elementsAt: element name) = - (self listClass newFrom: elementsAt). + elementsAt := self listElements select: [ :each | + each isNamed: element name ]. + self + assert: (list elementsAt: element name) + equals: (self listClass newFrom: elementsAt). changedElement := self changedListItem: element. list addFirst: changedElement. elementsAt := elementsAt copyWithFirst: changedElement. - self assert: - (list elementsAt: element name) = - (self listClass newFrom: elementsAt). + self + assert: (list elementsAt: element name) + equals: (self listClass newFrom: elementsAt). list remove: element. elementsAt := elementsAt copyWithout: element. - self assert: - (list elementsAt: element name) = - (self listClass newFrom: elementsAt)] + self + assert: (list elementsAt: element name) + equals: (self listClass newFrom: elementsAt) ] ] { #category : #tests } @@ -297,13 +298,13 @@ XMLNodeListTest >> testElementsSelect [ { #category : #tests } XMLNodeListTest >> testFirstElement [ - | list | + | list | list := self listWithItems. - self listElements do: [:each | - self assert: list firstElement = each. - list remove: each]. - self assert: list firstElement = self defaultValue. + self listElements do: [ :each | + self assert: list firstElement equals: each. + list remove: each ]. + self assert: list firstElement equals: self defaultValue ] { #category : #tests } @@ -350,23 +351,24 @@ XMLNodeListTest >> testHasStringNodes [ { #category : #tests } XMLNodeListTest >> testLastElement [ - | list | + | list | list := self listWithItems. - self listElements reverseDo: [:each | - self assert: list lastElement = each. - list remove: each]. - self assert: list lastElement = self defaultValue. + self listElements reverseDo: [ :each | + self assert: list lastElement equals: each. + list remove: each ]. + self assert: list lastElement equals: self defaultValue ] { #category : #tests } XMLNodeListTest >> testRawContentStringAt [ - | list | + | list | list := self listWithItems. - self listElements do: [:each | - self assert: - (list rawContentStringAt: each name) = each rawContentString]. + self listElements do: [ :each | + self + assert: (list rawContentStringAt: each name) + equals: each rawContentString ] ] { #category : #tests } diff --git a/src/XML-Parser-Tests/XMLNodeTest.class.st b/src/XML-Parser-Tests/XMLNodeTest.class.st index d9c3d113..f0f20132 100644 --- a/src/XML-Parser-Tests/XMLNodeTest.class.st +++ b/src/XML-Parser-Tests/XMLNodeTest.class.st @@ -14,29 +14,34 @@ XMLNodeTest class >> shouldInheritSelectors [ { #category : #assertions } XMLNodeTest >> assertElement: anElement hasAttributes: anAssociationCollection [ - | attributeNodes | - self assert: anElement attributeNodes size = anAssociationCollection size. + | attributeNodes | + self + assert: anElement attributeNodes size + equals: anAssociationCollection size. attributeNodes := anElement attributeNodes copy. - anAssociationCollection associationsDo: [:each | | attributeNode | + anAssociationCollection associationsDo: [ :each | + | attributeNode | attributeNode := attributeNodes removeFirst. self - assert: attributeNode name = each key; - assert: attributeNode value = each value] + assert: attributeNode name equals: each key; + assert: attributeNode value equals: each value ] ] { #category : #assertions } XMLNodeTest >> assertList: aList collects: aSecondList [ + self - assert: aList = aSecondList; - assert: aList class == self collectListClass + assert: aList equals: aSecondList; + assert: aList class identicalTo: self collectListClass ] { #category : #assertions } XMLNodeTest >> assertList: aList selects: aSecondList [ + self - assert: aList = aSecondList; - assert: aList class == self selectListClass + assert: aList equals: aSecondList; + assert: aList class identicalTo: self selectListClass ] { #category : #accessing } @@ -220,13 +225,13 @@ XMLNodeTest >> selectListClass [ { #category : #tests } XMLNodeTest >> testAcceptNodeVisitor [ - | visitor node | + | visitor node | visitor := XMLRecordingNodeVisitor new. node := self newNode. self - assert: (node acceptNodeVisitor: visitor) == node; - deny: visitor messageRecorder hasMessages. + assert: (node acceptNodeVisitor: visitor) identicalTo: node; + deny: visitor messageRecorder hasMessages ] { #category : #tests } @@ -276,19 +281,19 @@ XMLNodeTest >> testConfiguration [ { #category : #tests } XMLNodeTest >> testContentString [ - self assert: self newNode contentString = '' + + self assert: self newNode contentString equals: '' ] { #category : #tests } XMLNodeTest >> testCopy [ - | node copy | - (node := self newNode) - parent: self newNode. + | node copy | + (node := self newNode) parent: self newNode. copy := node copy. self - deny: copy == node; - deny: copy hasParent. + deny: copy identicalTo: node; + deny: copy hasParent ] { #category : #tests } @@ -298,10 +303,10 @@ XMLNodeTest >> testDocument [ { #category : #tests } XMLNodeTest >> testDocumentRoot [ - | node | + | node | node := self newNode. - self assert: node documentRoot == node. + self assert: node documentRoot identicalTo: node ] { #category : #tests } @@ -384,128 +389,119 @@ XMLNodeTest >> testIsStringNode [ { #category : #tests } XMLNodeTest >> testNewCData [ - | cdata | + | cdata | cdata := self newNode newCData: 'test'. self assert: cdata isCData; - assert: cdata string = 'test'. + assert: cdata string equals: 'test' ] { #category : #tests } XMLNodeTest >> testNewComment [ - | comment | + | comment | comment := self newNode newComment: 'test'. self assert: comment isComment; - assert: comment string = 'test'. + assert: comment string equals: 'test' ] { #category : #tests } XMLNodeTest >> testNewDocument [ - | node document | + | node document | node := self newNode. document := node newDocument. self assert: document isDocument. - node configuration - ifNotNil: [ - self - assert: document configuration == node configuration; - assert: document nodeFactory == node nodeFactory]. + node configuration ifNotNil: [ + self + assert: document configuration identicalTo: node configuration; + assert: document nodeFactory identicalTo: node nodeFactory ] ] { #category : #tests } XMLNodeTest >> testNewElement [ - | node element | + | node element | node := self newNode. element := node newElement. self assert: element isElement. - node configuration - ifNotNil: [ - self - assert: element configuration == node configuration; - assert: element nodeFactory == node nodeFactory]. + node configuration ifNotNil: [ + self + assert: element configuration identicalTo: node configuration; + assert: element nodeFactory identicalTo: node nodeFactory ] ] { #category : #tests } XMLNodeTest >> testNewElementNamed [ - | node element | + | node element | node := self newNode. element := node newElementNamed: 'test'. self assert: element isElement; - assert: element name = 'test'. - node configuration - ifNotNil: [ - self - assert: element configuration == node configuration; - assert: element nodeFactory == node nodeFactory]. + assert: element name equals: 'test'. + node configuration ifNotNil: [ + self + assert: element configuration identicalTo: node configuration; + assert: element nodeFactory identicalTo: node nodeFactory ] ] { #category : #tests } XMLNodeTest >> testNewElementNamedAttributes [ - | node element | + | node element | node := self newNode. - element := - node - newElementNamed: 'test' - attributes: self unprefixedAttributeAssociations. + element := node + newElementNamed: 'test' + attributes: self unprefixedAttributeAssociations. self assert: element isElement; - assert: element name = 'test'; + assert: element name equals: 'test'; assertElement: element hasAttributes: self unprefixedAttributes. - node configuration - ifNotNil: [ - self - assert: element configuration == node configuration; - assert: element nodeFactory == node nodeFactory]. + node configuration ifNotNil: [ + self + assert: element configuration identicalTo: node configuration; + assert: element nodeFactory identicalTo: node nodeFactory ] ] { #category : #tests } XMLNodeTest >> testNewElementNamedNamespaceURI [ - | node element | + | node element | node := self newNode. - element := - node - newElementNamed: 'prefix:test' - namespaceURI: 'prefixNS'. + element := node + newElementNamed: 'prefix:test' + namespaceURI: 'prefixNS'. self assert: element isElement; - assert: element name = 'prefix:test'; - assert: element namespaceURI = 'prefixNS'. - node configuration - ifNotNil: [ - self - assert: element configuration == node configuration; - assert: element nodeFactory == node nodeFactory]. + assert: element name equals: 'prefix:test'; + assert: element namespaceURI equals: 'prefixNS'. + node configuration ifNotNil: [ + self + assert: element configuration identicalTo: node configuration; + assert: element nodeFactory identicalTo: node nodeFactory ] ] { #category : #tests } XMLNodeTest >> testNewElementNamedNamespaceURIAttributes [ - | node element | + | node element | node := self newNode. - element := - node - newElementNamed: 'prefix:test' - namespaceURI: 'prefixNS' - attributes: self attributeAssociations. + element := node + newElementNamed: 'prefix:test' + namespaceURI: 'prefixNS' + attributes: self attributeAssociations. self assert: element isElement; - assert: element name = 'prefix:test'; - assert: element namespaceURI = 'prefixNS'; + assert: element name equals: 'prefix:test'; + assert: element namespaceURI equals: 'prefixNS'; assertElement: element hasAttributes: self attributes. - node configuration - ifNotNil: [ - self - assert: element configuration == node configuration; - assert: element nodeFactory == node nodeFactory]. + node configuration ifNotNil: [ + self + assert: element configuration identicalTo: node configuration; + assert: element nodeFactory identicalTo: node nodeFactory ] ] { #category : #tests } @@ -515,26 +511,23 @@ XMLNodeTest >> testNewPI [ { #category : #tests } XMLNodeTest >> testNewPITargetData [ - | pi | - pi := - self newNode - newPITarget: 'target' - data: 'data'. + | pi | + pi := self newNode newPITarget: 'target' data: 'data'. self assert: pi isPI; - assert: pi target = 'target'; - assert: pi data = 'data'. + assert: pi target equals: 'target'; + assert: pi data equals: 'data' ] { #category : #tests } XMLNodeTest >> testNewStringNode [ - | stringNode | + | stringNode | stringNode := self newNode newStringNode: 'test'. self assert: stringNode isStringNode; - assert: stringNode string = 'test'. + assert: stringNode string equals: 'test' ] { #category : #tests } @@ -544,20 +537,23 @@ XMLNodeTest >> testNextNode [ { #category : #tests } XMLNodeTest >> testNodeFactory [ - self assert: self newNode nodeFactory class == self nodeFactoryClass + + self + assert: self newNode nodeFactory class + identicalTo: self nodeFactoryClass ] { #category : #tests } XMLNodeTest >> testParent [ - | node parent | + | node parent | node := self newNode. self assert: node parent isNil. parent := self newNode. self - assert: (node parent: parent) == node; - assert: node parent == parent. + assert: (node parent: parent) identicalTo: node; + assert: node parent identicalTo: parent ] { #category : #tests } @@ -567,12 +563,16 @@ XMLNodeTest >> testPreviousNode [ { #category : #tests } XMLNodeTest >> testRawContentString [ - self assert: self newNode rawContentString = '' + + self assert: self newNode rawContentString equals: '' ] { #category : #tests } XMLNodeTest >> testSortKey [ - self assert: self newNode sortKey = self nodeClass name asString + + self + assert: self newNode sortKey + equals: self nodeClass name asString ] { #category : #tests } diff --git a/src/XML-Parser-Tests/XMLNodeWithChildrenTest.class.st b/src/XML-Parser-Tests/XMLNodeWithChildrenTest.class.st index e9c542ea..9e077b39 100644 --- a/src/XML-Parser-Tests/XMLNodeWithChildrenTest.class.st +++ b/src/XML-Parser-Tests/XMLNodeWithChildrenTest.class.st @@ -44,50 +44,50 @@ XMLNodeWithChildrenTest >> nodeListClass [ { #category : #tests } XMLNodeWithChildrenTest >> testAddComment [ - | nodeWithNodes comment | + | nodeWithNodes comment | nodeWithNodes := self newNode. comment := nodeWithNodes addComment: 'test'. self - assert: nodeWithNodes nodes size = 1; - assert: nodeWithNodes firstNode == comment; + assert: nodeWithNodes nodes size equals: 1; + assert: nodeWithNodes firstNode identicalTo: comment; assert: comment isComment; - assert: comment string = 'test' + assert: comment string equals: 'test' ] { #category : #tests } XMLNodeWithChildrenTest >> testAddNode [ - | node nodesAdded nodeWithNodes | + | node nodesAdded nodeWithNodes | node := self newNode. nodesAdded := node nodes copyEmpty. nodeWithNodes := self newNodeWithNodes. "adding nodes from another node should remove them from the previous node" - nodeWithNodes nodes copy do: [:each | + nodeWithNodes nodes copy do: [ :each | nodesAdded addLast: each. self - assert: (node addNode: each) == each; - assert: node nodes = nodesAdded; - assert: each parent == node; - deny: (nodeWithNodes nodes includes: each)]. + assert: (node addNode: each) identicalTo: each; + assert: node nodes equals: nodesAdded; + assert: each parent identicalTo: node; + deny: (nodeWithNodes nodes includes: each) ]. self deny: nodeWithNodes hasChildren. "adding already present nodes should move them in-place" - node nodes copy do: [:each | + node nodes copy do: [ :each | nodesAdded remove: each; addLast: each. self - assert: (node addNode: each) == each; - assert: node nodes = nodesAdded; - assert: each parent == node] + assert: (node addNode: each) identicalTo: each; + assert: node nodes equals: nodesAdded; + assert: each parent identicalTo: node ] ] { #category : #tests } XMLNodeWithChildrenTest >> testAddNodeAfter [ - | node nodesAdded nodeWithNodes nodeAfter | + | node nodesAdded nodeWithNodes nodeAfter | node := self newNode. nodesAdded := node nodes copyEmpty. nodeWithNodes := self newNodeWithNodes. @@ -96,33 +96,31 @@ XMLNodeWithChildrenTest >> testAddNodeAfter [ nodeAfter := nodeWithNodes firstNode. nodesAdded addLast: nodeAfter. node addNode: nodeAfter. - nodeWithNodes nodes reversed do: [:each | - nodesAdded - add: each - after: nodeAfter. + nodeWithNodes nodes reversed do: [ :each | + nodesAdded add: each after: nodeAfter. self - assert: (node addNode: each after: nodeAfter) == each; - assert: node nodes = nodesAdded; - assert: each parent == node; - deny: (nodeWithNodes nodes includes: each)]. + assert: (node addNode: each after: nodeAfter) identicalTo: each; + assert: node nodes equals: nodesAdded; + assert: each parent identicalTo: node; + deny: (nodeWithNodes nodes includes: each) ]. self deny: nodeWithNodes hasChildren. "adding already present nodes should move them in-place" nodeAfter := nodesAdded last. - node nodes allButLast reverseDo: [:each | + node nodes allButLast reverseDo: [ :each | nodesAdded remove: each; add: each after: nodeAfter. self - assert: (node addNode: each after: nodeAfter) == each; - assert: node nodes = nodesAdded; - assert: each parent == node] + assert: (node addNode: each after: nodeAfter) identicalTo: each; + assert: node nodes equals: nodesAdded; + assert: each parent identicalTo: node ] ] { #category : #tests } XMLNodeWithChildrenTest >> testAddNodeBefore [ - | node nodesAdded nodeWithNodes nodeBefore | + | node nodesAdded nodeWithNodes nodeBefore | node := self newNode. nodesAdded := node nodes copyEmpty. nodeWithNodes := self newNodeWithNodes. @@ -131,56 +129,54 @@ XMLNodeWithChildrenTest >> testAddNodeBefore [ nodeBefore := nodeWithNodes lastNode. nodesAdded addLast: nodeBefore. node addNode: nodeBefore. - nodeWithNodes nodes copy do: [:each | - nodesAdded - add: each - before: nodeBefore. + nodeWithNodes nodes copy do: [ :each | + nodesAdded add: each before: nodeBefore. self - assert: (node addNode: each before: nodeBefore) == each; - assert: node nodes = nodesAdded; - assert: each parent == node; - deny: (nodeWithNodes nodes includes: each)]. + assert: (node addNode: each before: nodeBefore) identicalTo: each; + assert: node nodes equals: nodesAdded; + assert: each parent identicalTo: node; + deny: (nodeWithNodes nodes includes: each) ]. self deny: nodeWithNodes hasChildren. "adding already present nodes should move them in-place" nodeBefore := nodesAdded first. - node nodes allButFirst reverseDo: [:each | + node nodes allButFirst reverseDo: [ :each | nodesAdded remove: each; add: each before: nodeBefore. self - assert: (node addNode: each before: nodeBefore) == each; - assert: node nodes = nodesAdded; - assert: each parent == node] + assert: (node addNode: each before: nodeBefore) identicalTo: each; + assert: node nodes equals: nodesAdded; + assert: each parent identicalTo: node ] ] { #category : #tests } XMLNodeWithChildrenTest >> testAddNodeFirst [ - | node nodesAdded nodeWithNodes | + | node nodesAdded nodeWithNodes | node := self newNode. nodesAdded := node nodes copyEmpty. nodeWithNodes := self newNodeWithNodes. "adding nodes from another node should remove them from the previous node" - nodeWithNodes nodes copy do: [:each | + nodeWithNodes nodes copy do: [ :each | nodesAdded addFirst: each. self - assert: (node addNodeFirst: each) == each; - assert: node nodes = nodesAdded; - assert: each parent == node; - deny: (nodeWithNodes nodes includes: each)]. + assert: (node addNodeFirst: each) identicalTo: each; + assert: node nodes equals: nodesAdded; + assert: each parent identicalTo: node; + deny: (nodeWithNodes nodes includes: each) ]. self deny: nodeWithNodes hasChildren. "adding already present nodes should move them in-place" - node nodes reversed do: [:each | + node nodes reversed do: [ :each | nodesAdded remove: each; addFirst: each. self - assert: (node addNodeFirst: each) == each; - assert: node nodes = nodesAdded; - assert: each parent == node] + assert: (node addNodeFirst: each) identicalTo: each; + assert: node nodes equals: nodesAdded; + assert: each parent identicalTo: node ] ] { #category : #tests } @@ -208,40 +204,37 @@ XMLNodeWithChildrenTest >> testAddNodes [ { #category : #tests } XMLNodeWithChildrenTest >> testAddPITargetData [ - | nodeWithNodes pi | + | nodeWithNodes pi | nodeWithNodes := self newNode. - pi := - nodeWithNodes - addPITarget: 'target' - data: 'data'. + pi := nodeWithNodes addPITarget: 'target' data: 'data'. self - assert: nodeWithNodes nodes size = 1; - assert: nodeWithNodes firstNode == pi; + assert: nodeWithNodes nodes size equals: 1; + assert: nodeWithNodes firstNode identicalTo: pi; assert: pi isPI; - assert: pi target = 'target'; - assert: pi data = 'data' + assert: pi target equals: 'target'; + assert: pi data equals: 'data' ] { #category : #tests } XMLNodeWithChildrenTest >> testAllNodes [ - | nodeWithNodes allNodes | + | nodeWithNodes allNodes | nodeWithNodes := self newNodeWithNodes. allNodes := nodeWithNodes allNodes. self - assert: allNodes size = 5; - assert: allNodes first == nodeWithNodes; + assert: allNodes size equals: 5; + assert: allNodes first identicalTo: nodeWithNodes; assert: allNodes second isComment; - assert: allNodes second string = 'one'; + assert: allNodes second string equals: 'one'; assert: allNodes third isPI; - assert: allNodes third target = 'two'; - assert: allNodes third data = 'three'; + assert: allNodes third target equals: 'two'; + assert: allNodes third data equals: 'three'; assert: allNodes fourth isComment; - assert: allNodes fourth string = 'four'; + assert: allNodes fourth string equals: 'four'; assert: allNodes fifth isPI; - assert: allNodes fifth target = 'five'; - assert: allNodes fifth data = 'six' + assert: allNodes fifth target equals: 'five'; + assert: allNodes fifth data equals: 'six' ] { #category : #tests } @@ -264,35 +257,37 @@ XMLNodeWithChildrenTest >> testAllNodesCollect [ { #category : #tests } XMLNodeWithChildrenTest >> testAllNodesDetect [ - | nodeWithNodes allNodes detectedNode | + | nodeWithNodes allNodes detectedNode | nodeWithNodes := self newNodeWithNodes. allNodes := nodeWithNodes allNodes. - detectedNode := nodeWithNodes allNodesDetect: [:each | each isPI]. + detectedNode := nodeWithNodes allNodesDetect: [ :each | each isPI ]. self assert: detectedNode notNil; assert: detectedNode isPI; - assert: detectedNode = (allNodes detect: [:each | each isPI]); - assert: (nodeWithNodes allNodesDetect: [:each | each isElementNamed: 'absent']) isNil + assert: detectedNode + equals: (allNodes detect: [ :each | each isPI ]); + assert: (nodeWithNodes allNodesDetect: [ :each | + each isElementNamed: 'absent' ]) isNil ] { #category : #tests } XMLNodeWithChildrenTest >> testAllNodesDetectIfNone [ - | nodeWithNodes allNodes detectedNode | + | nodeWithNodes allNodes detectedNode | nodeWithNodes := self newNodeWithNodes. allNodes := nodeWithNodes allNodes. - detectedNode := - nodeWithNodes - allNodesDetect: [:each | each isPI] - ifNone: [self fail]. + detectedNode := nodeWithNodes + allNodesDetect: [ :each | each isPI ] + ifNone: [ self fail ]. self assert: detectedNode isPI; - assert: detectedNode = (allNodes detect: [:each | each isPI] ifNone: [#absent]); - assert: - (nodeWithNodes - allNodesDetect: [:each | each isElementNamed: 'absent'] - ifNone: [#absent]) = #absent + assert: detectedNode + equals: (allNodes detect: [ :each | each isPI ] ifNone: [ #absent ]); + assert: (nodeWithNodes + allNodesDetect: [ :each | each isElementNamed: 'absent' ] + ifNone: [ #absent ]) + equals: #absent ] { #category : #tests } @@ -333,20 +328,19 @@ XMLNodeWithChildrenTest >> testAllNodesSelect [ { #category : #tests } XMLNodeWithChildrenTest >> testAncestorNodes [ - | nodeWithNodes ancestorStack | + | nodeWithNodes ancestorStack | super testAncestorNodes. nodeWithNodes := self newNodeWithNodes. ancestorStack := OrderedCollection new. - nodeWithNodes allNodesDo: [:each | - [ancestorStack isEmpty - or: [ancestorStack last == each parent]] - whileFalse: [ancestorStack removeLast]. - self assert: - each ancestorNodes asOrderedCollection = - ancestorStack reversed. - ancestorStack addLast: each] + nodeWithNodes allNodesDo: [ :each | + [ ancestorStack isEmpty or: [ ancestorStack last == each parent ] ] + whileFalse: [ ancestorStack removeLast ]. + self + assert: each ancestorNodes asOrderedCollection + equals: ancestorStack reversed. + ancestorStack addLast: each ] ] { #category : #tests } @@ -380,44 +374,45 @@ XMLNodeWithChildrenTest >> testCopy [ "this traverses the object graph of each node and compares it with its copy to make sure nodes and the inst vars that should be copied are copied. See #copiedClasses" - | nodeWithNodes nodeWithNodesCopy unvisitedPairs visitedPairs copiedClasses | + | nodeWithNodes nodeWithNodesCopy unvisitedPairs visitedPairs copiedClasses | super testCopy. nodeWithNodes := self newNodeWithNodes. "initialize the configuration (if it can have one)" - nodeWithNodes configuration - ifNotNil: [:config | config nodeFactory: XMLPluggableNodeFactory new]. + nodeWithNodes configuration ifNotNil: [ :config | + config nodeFactory: XMLPluggableNodeFactory new ]. nodeWithNodesCopy := nodeWithNodes copy. self - assert: nodeWithNodes printString = nodeWithNodesCopy printString; - assert: nodeWithNodes allNodes size = nodeWithNodesCopy allNodes size. + assert: nodeWithNodes printString + equals: nodeWithNodesCopy printString; + assert: nodeWithNodes allNodes size + equals: nodeWithNodesCopy allNodes size. unvisitedPairs := Set new. nodeWithNodes allNodes with: nodeWithNodesCopy allNodes - do: [:node :nodeCopy | unvisitedPairs add: node -> nodeCopy]. + do: [ :node :nodeCopy | unvisitedPairs add: node -> nodeCopy ]. visitedPairs := Set new. - copiedClasses := - self copiedClasses collect: [:each | - XMLClassFinder classNamed: each]. - [unvisitedPairs isEmpty] - whileFalse: [ | pair originalObject copyObject | - pair := unvisitedPairs remove: unvisitedPairs anyOne. - originalObject := pair key. - copyObject := pair value. - - self deny: originalObject == copyObject. - visitedPairs add: pair. - 1 - to: (originalObject class instSize min: copyObject class instSize) - do: [:i | | newPair | - newPair := (originalObject instVarAt: i) -> (copyObject instVarAt: i). - ((visitedPairs includes: newPair) - or: [copiedClasses noneSatisfy: [:each | newPair key isKindOf: each]]) - ifFalse: [unvisitedPairs add: newPair]]] + copiedClasses := self copiedClasses collect: [ :each | + XMLClassFinder classNamed: each ]. + [ unvisitedPairs isEmpty ] whileFalse: [ + | pair originalObject copyObject | + pair := unvisitedPairs remove: unvisitedPairs anyOne. + originalObject := pair key. + copyObject := pair value. + self deny: originalObject identicalTo: copyObject. + visitedPairs add: pair. + 1 to: (originalObject class instSize min: copyObject class instSize) + do: [ :i | + | newPair | + newPair := (originalObject instVarAt: i) + -> (copyObject instVarAt: i). + ((visitedPairs includes: newPair) or: [ + copiedClasses noneSatisfy: [ :each | newPair key isKindOf: each ] ]) + ifFalse: [ unvisitedPairs add: newPair ] ] ] ] { #category : #tests } @@ -458,35 +453,39 @@ XMLNodeWithChildrenTest >> testDescendantNodesCollect [ { #category : #tests } XMLNodeWithChildrenTest >> testDescendantNodesDetect [ - | nodeWithNodes descendantNodes detectedNode | + | nodeWithNodes descendantNodes detectedNode | nodeWithNodes := self newNodeWithNodes. descendantNodes := nodeWithNodes descendantNodes. - detectedNode := nodeWithNodes descendantNodesDetect: [:each | each isPI]. + detectedNode := nodeWithNodes descendantNodesDetect: [ :each | + each isPI ]. self assert: detectedNode notNil; assert: detectedNode isPI; - assert: detectedNode = (descendantNodes detect: [:each | each isPI]); - assert: (nodeWithNodes descendantNodesDetect: [:each | each isElementNamed: 'absent']) isNil + assert: detectedNode + equals: (descendantNodes detect: [ :each | each isPI ]); + assert: (nodeWithNodes descendantNodesDetect: [ :each | + each isElementNamed: 'absent' ]) isNil ] { #category : #tests } XMLNodeWithChildrenTest >> testDescendantNodesDetectIfNone [ - | nodeWithNodes descendantNodes detectedNode | + | nodeWithNodes descendantNodes detectedNode | nodeWithNodes := self newNodeWithNodes. descendantNodes := nodeWithNodes descendantNodes. - detectedNode := - nodeWithNodes - descendantNodesDetect: [:each | each isPI] - ifNone: [self fail]. + detectedNode := nodeWithNodes + descendantNodesDetect: [ :each | each isPI ] + ifNone: [ self fail ]. self assert: detectedNode isPI; - assert: detectedNode = (descendantNodes detect: [:each | each isPI] ifNone: [#absent]); - assert: - (nodeWithNodes - descendantNodesDetect: [:each | each isElementNamed: 'absent'] - ifNone: [#absent]) = #absent. + assert: detectedNode + equals: + (descendantNodes detect: [ :each | each isPI ] ifNone: [ #absent ]); + assert: (nodeWithNodes + descendantNodesDetect: [ :each | each isElementNamed: 'absent' ] + ifNone: [ #absent ]) + equals: #absent ] { #category : #tests } @@ -527,41 +526,40 @@ XMLNodeWithChildrenTest >> testDescendantNodesSelect [ { #category : #tests } XMLNodeWithChildrenTest >> testDocument [ - | nodeWithNodes document | + | nodeWithNodes document | nodeWithNodes := self newNodeWithNodes. document := nodeWithNodes document. - nodeWithNodes allNodesDo: [:each | - self assert: each document == document]. + nodeWithNodes allNodesDo: [ :each | + self assert: each document identicalTo: document ]. - document - ifNotNil: [ | root | - root := document root. - document removeNodes. - root allNodesDo: [:each | - self assert: each document isNil]]. + document ifNotNil: [ + | root | + root := document root. + document removeNodes. + root allNodesDo: [ :each | self assert: each document isNil ] ] ] { #category : #tests } XMLNodeWithChildrenTest >> testDocumentRoot [ - | nodeWithNodes | + | nodeWithNodes | super testDocumentRoot. nodeWithNodes := self newNodeWithNodes. - nodeWithNodes allNodesDo: [:each | - self assert: each documentRoot == nodeWithNodes]. + nodeWithNodes allNodesDo: [ :each | + self assert: each documentRoot identicalTo: nodeWithNodes ] ] { #category : #tests } XMLNodeWithChildrenTest >> testFirstNode [ - | nodeWithNodes | + | nodeWithNodes | nodeWithNodes := self newNodeWithNodes. - nodeWithNodes nodes copy do: [:each | - self assert: nodeWithNodes firstNode = each. - nodeWithNodes removeNode: each]. - self assert: nodeWithNodes firstNode isNil. + nodeWithNodes nodes copy do: [ :each | + self assert: nodeWithNodes firstNode equals: each. + nodeWithNodes removeNode: each ]. + self assert: nodeWithNodes firstNode isNil ] { #category : #tests } @@ -583,128 +581,134 @@ XMLNodeWithChildrenTest >> testIncludesNode [ { #category : #tests } XMLNodeWithChildrenTest >> testLastNode [ - | nodeWithNodes | + | nodeWithNodes | nodeWithNodes := self newNodeWithNodes. - nodeWithNodes nodes reversed do: [:each | - self assert: nodeWithNodes lastNode = each. - nodeWithNodes removeNode: each]. + nodeWithNodes nodes reversed do: [ :each | + self assert: nodeWithNodes lastNode equals: each. + nodeWithNodes removeNode: each ]. - self assert: nodeWithNodes lastNode isNil. + self assert: nodeWithNodes lastNode isNil ] { #category : #tests } XMLNodeWithChildrenTest >> testNextNode [ - | nodeWithNodes nextNode | + | nodeWithNodes nextNode | super testNextNode. nodeWithNodes := self newNodeWithNodes. nextNode := nil. - nodeWithNodes nodes reverseDo: [:each | - self assert: each nextNode = nextNode. - nextNode := each]. + nodeWithNodes nodes reverseDo: [ :each | + self assert: each nextNode equals: nextNode. + nextNode := each ] ] { #category : #tests } XMLNodeWithChildrenTest >> testNodeAfter [ - | nodeWithNodes nodeAfter | + | nodeWithNodes nodeAfter | nodeWithNodes := self newNodeWithNodes. nodeAfter := nil. - nodeWithNodes nodes reverseDo: [:each | - self assert: (nodeWithNodes nodeAfter: each) = nodeAfter. - nodeAfter := each]. - self assert: (nodeWithNodes nodeAfter: self newNode) isNil. + nodeWithNodes nodes reverseDo: [ :each | + self assert: (nodeWithNodes nodeAfter: each) equals: nodeAfter. + nodeAfter := each ]. + self assert: (nodeWithNodes nodeAfter: self newNode) isNil ] { #category : #tests } XMLNodeWithChildrenTest >> testNodeAt [ - | nodeWithNodes | + | nodeWithNodes | nodeWithNodes := self newNodeWithNodes. self assert: (nodeWithNodes nodeAt: 0) isNil. - 1 to: nodeWithNodes nodes size do: [:i | - self assert: (nodeWithNodes nodeAt: i) = (nodeWithNodes nodes at: i)]. - self assert: (nodeWithNodes nodeAt: nodeWithNodes nodes size + 1) isNil. + 1 to: nodeWithNodes nodes size do: [ :i | + self + assert: (nodeWithNodes nodeAt: i) + equals: (nodeWithNodes nodes at: i) ]. + self assert: + (nodeWithNodes nodeAt: nodeWithNodes nodes size + 1) isNil ] { #category : #tests } XMLNodeWithChildrenTest >> testNodeAtIfAbsent [ - | nodeWithNodes | + | nodeWithNodes | nodeWithNodes := self newNodeWithNodes. - 1 to: nodeWithNodes nodes size do: [:i | - self assert: - (nodeWithNodes - nodeAt: i - ifAbsent: [self fail]) = (nodeWithNodes nodes at: i)]. - self assert: - (nodeWithNodes - nodeAt: 0 - ifAbsent: [#absent]) = #absent. - self assert: - (nodeWithNodes - nodeAt: nodeWithNodes nodes size + 1 - ifAbsent: [#absent]) = #absent. + 1 to: nodeWithNodes nodes size do: [ :i | + self + assert: (nodeWithNodes nodeAt: i ifAbsent: [ self fail ]) + equals: (nodeWithNodes nodes at: i) ]. + self + assert: (nodeWithNodes nodeAt: 0 ifAbsent: [ #absent ]) + equals: #absent. + self + assert: (nodeWithNodes + nodeAt: nodeWithNodes nodes size + 1 + ifAbsent: [ #absent ]) + equals: #absent ] { #category : #tests } XMLNodeWithChildrenTest >> testNodeAtPut [ - | nodeWithNodes newNodeClass newNode | + | nodeWithNodes newNodeClass newNode | nodeWithNodes := self newNodeWithNodes. newNodeClass := nodeWithNodes firstNode class. self - should: [nodeWithNodes nodeAt: 0 put: newNodeClass new] + should: [ nodeWithNodes nodeAt: 0 put: newNodeClass new ] raise: Error. - 1 to: nodeWithNodes nodes size do: [:i | + 1 to: nodeWithNodes nodes size do: [ :i | newNode := newNodeClass new. self - assert: (nodeWithNodes nodeAt: i put: newNode) == newNode; - assert: (nodeWithNodes nodeAt: i) == newNode]. + assert: (nodeWithNodes nodeAt: i put: newNode) + identicalTo: newNode; + assert: (nodeWithNodes nodeAt: i) identicalTo: newNode ]. newNode := newNodeClass new. - self assert: - (nodeWithNodes - nodeAt: nodeWithNodes nodes size + 1 - put: newNode) == newNode. - self assert: (nodeWithNodes nodeAt: nodeWithNodes nodes size) == newNode. + self + assert: + (nodeWithNodes nodeAt: nodeWithNodes nodes size + 1 put: newNode) + identicalTo: newNode. + self + assert: (nodeWithNodes nodeAt: nodeWithNodes nodes size) + identicalTo: newNode. self should: [ nodeWithNodes nodeAt: nodeWithNodes nodes size + 2 - put: newNodeClass new] - raise: Error. + put: newNodeClass new ] + raise: Error ] { #category : #tests } XMLNodeWithChildrenTest >> testNodeBefore [ - | nodeWithNodes nodeBefore | + | nodeWithNodes nodeBefore | nodeWithNodes := self newNodeWithNodes. nodeBefore := nil. - nodeWithNodes nodes do: [:each | - self assert: (nodeWithNodes nodeBefore: each) = nodeBefore. - nodeBefore := each]. - self assert: (nodeWithNodes nodeBefore: self newNode) isNil. + nodeWithNodes nodes do: [ :each | + self assert: (nodeWithNodes nodeBefore: each) equals: nodeBefore. + nodeBefore := each ]. + self assert: (nodeWithNodes nodeBefore: self newNode) isNil ] { #category : #tests } XMLNodeWithChildrenTest >> testNodeListCopying [ - | nodeWithNodes nodeListCopy | + | nodeWithNodes nodeListCopy | nodeWithNodes := self newNodeWithNodes. nodeListCopy := nodeWithNodes nodes copy. self - assert: nodeListCopy = nodeWithNodes nodes; - deny: nodeListCopy == nodeWithNodes nodes; - assert: nodeWithNodes nodes observer == nodeWithNodes; - assert: nodeListCopy observer isNil. + assert: nodeListCopy equals: nodeWithNodes nodes; + deny: nodeListCopy identicalTo: nodeWithNodes nodes; + assert: nodeWithNodes nodes observer identicalTo: nodeWithNodes; + assert: nodeListCopy observer isNil ] { #category : #tests } XMLNodeWithChildrenTest >> testNodes [ - self assert: self newNode nodes class == self nodeListClass + + self assert: self newNode nodes class identicalTo: self nodeListClass ] { #category : #tests } @@ -719,30 +723,32 @@ XMLNodeWithChildrenTest >> testNodesCollect [ { #category : #tests } XMLNodeWithChildrenTest >> testNodesDetect [ - | node detectedNode | + | node detectedNode | node := self newNodeWithNodes. - detectedNode := node nodesDetect: [:each | each isComment]. + detectedNode := node nodesDetect: [ :each | each isComment ]. self assert: detectedNode notNil; - assert: detectedNode = (node nodes detect: [:each | each isComment]); - assert: (node nodesDetect: [:each | each isElementNamed: 'absent']) isNil. + assert: detectedNode + equals: (node nodes detect: [ :each | each isComment ]); + assert: + (node nodesDetect: [ :each | each isElementNamed: 'absent' ]) isNil ] { #category : #tests } XMLNodeWithChildrenTest >> testNodesDetectIfNone [ - | node | + | node | node := self newNodeWithNodes. - self assert: - (node - nodesDetect: [:each | each isComment] - ifNone: [self fail]) = - (node nodes detect: [:each | each isComment]). - self assert: - (node - nodesDetect: [:each | each isElementNamed: 'absent'] - ifNone: [#absent]) = #absent. + self + assert: + (node nodesDetect: [ :each | each isComment ] ifNone: [ self fail ]) + equals: (node nodes detect: [ :each | each isComment ]). + self + assert: (node + nodesDetect: [ :each | each isElementNamed: 'absent' ] + ifNone: [ #absent ]) + equals: #absent ] { #category : #tests } @@ -772,113 +778,112 @@ XMLNodeWithChildrenTest >> testNodesSelect [ { #category : #tests } XMLNodeWithChildrenTest >> testPreviousNode [ - | nodeWithNodes previousNode | + | nodeWithNodes previousNode | super testPreviousNode. nodeWithNodes := self newNodeWithNodes. previousNode := nil. - nodeWithNodes nodes do: [:each | - self assert: each previousNode = previousNode. - previousNode := each]. + nodeWithNodes nodes do: [ :each | + self assert: each previousNode equals: previousNode. + previousNode := each ] ] { #category : #tests } XMLNodeWithChildrenTest >> testRemoveNode [ - | nodeWithNodes | + | nodeWithNodes | nodeWithNodes := self newNodeWithNodes. - nodeWithNodes nodes copy do: [:each | + nodeWithNodes nodes copy do: [ :each | self assert: (nodeWithNodes includesNode: each); - assert: (nodeWithNodes removeNode: each) == each; - deny: (nodeWithNodes includesNode: each)]. + assert: (nodeWithNodes removeNode: each) identicalTo: each; + deny: (nodeWithNodes includesNode: each) ]. self deny: nodeWithNodes hasChildren. - self - should: [nodeWithNodes removeNode: self newNode] - raise: Error. + self should: [ nodeWithNodes removeNode: self newNode ] raise: Error ] { #category : #tests } XMLNodeWithChildrenTest >> testRemoveNodeIfAbsent [ - | nodeWithNodes | + | nodeWithNodes | nodeWithNodes := self newNodeWithNodes. - nodeWithNodes nodes copy do: [:each | + nodeWithNodes nodes copy do: [ :each | self assert: (nodeWithNodes includesNode: each). - self assert: - (nodeWithNodes - removeNode: each - ifAbsent: [self fail]) == each. - self deny: (nodeWithNodes includesNode: each)]. + self + assert: (nodeWithNodes removeNode: each ifAbsent: [ self fail ]) + identicalTo: each. + self deny: (nodeWithNodes includesNode: each) ]. self deny: nodeWithNodes hasChildren. - self assert: - (nodeWithNodes - removeNode: self newNode - ifAbsent: [#absent]) == #absent. + self + assert: + (nodeWithNodes removeNode: self newNode ifAbsent: [ #absent ]) + identicalTo: #absent ] { #category : #tests } XMLNodeWithChildrenTest >> testRemoveNodes [ - | nodeWithNodes | + | nodeWithNodes | nodeWithNodes := self newNodeWithNodes. self assert: nodeWithNodes hasChildren; - assert: nodeWithNodes removeNodes == nodeWithNodes; - deny: nodeWithNodes hasChildren. + assert: nodeWithNodes removeNodes identicalTo: nodeWithNodes; + deny: nodeWithNodes hasChildren ] { #category : #tests } XMLNodeWithChildrenTest >> testRemoveNodesAll [ - | nodeWithNodes | + | nodeWithNodes | nodeWithNodes := self newNodeWithNodes. - 1 to: nodeWithNodes nodes size do: [:i | | removed | - removed := (nodeWithNodes nodes copyFrom: 1 to: i). + 1 to: nodeWithNodes nodes size do: [ :i | + | removed | + removed := nodeWithNodes nodes copyFrom: 1 to: i. self - assert: (removed allSatisfy: [:each | nodeWithNodes includesNode: each]); - assert: (nodeWithNodes removeNodes: removed) == removed; - deny: (removed anySatisfy: [:each | nodeWithNodes includesNode: each]). - nodeWithNodes := self newNodeWithNodes]. + assert: + (removed allSatisfy: [ :each | nodeWithNodes includesNode: each ]); + assert: (nodeWithNodes removeNodes: removed) identicalTo: removed; + deny: + (removed anySatisfy: [ :each | nodeWithNodes includesNode: each ]). + nodeWithNodes := self newNodeWithNodes ] ] { #category : #tests } XMLNodeWithChildrenTest >> testReplaceNodeWith [ - | nodeWithNodes replacements nodes firstIndex secondIndex | + | nodeWithNodes replacements nodes firstIndex secondIndex | nodeWithNodes := self newNodeWithNodes. replacements := OrderedCollection new. - nodeWithNodes nodes copy do: [:each | - self assert: - (nodeWithNodes - replaceNode: each - with: (replacements add: self newNode)) == replacements last]. - self assert: nodeWithNodes nodes asOrderedCollection = replacements. + nodeWithNodes nodes copy do: [ :each | + self + assert: (nodeWithNodes + replaceNode: each + with: (replacements add: self newNode)) + identicalTo: replacements last ]. + self + assert: nodeWithNodes nodes asOrderedCollection + equals: replacements. nodeWithNodes := self newNodeWithNodes. nodes := nodeWithNodes nodes copy. - nodes do: [:each | - self assert: - (nodeWithNodes - replaceNode: each - with: each) == each]. - self assert: nodeWithNodes nodes = nodes. + nodes do: [ :each | + self + assert: (nodeWithNodes replaceNode: each with: each) + identicalTo: each ]. + self assert: nodeWithNodes nodes equals: nodes. firstIndex := 1. secondIndex := nodes size. - [firstIndex < secondIndex] - whileTrue: [ - nodeWithNodes - replaceNode: (nodes at: firstIndex) - with: (nodes at: secondIndex). - firstIndex := firstIndex + 1. - secondIndex := secondIndex - 1]. - self assert: nodeWithNodes nodes = nodes reversed. + [ firstIndex < secondIndex ] whileTrue: [ + nodeWithNodes + replaceNode: (nodes at: firstIndex) + with: (nodes at: secondIndex). + firstIndex := firstIndex + 1. + secondIndex := secondIndex - 1 ]. + self assert: nodeWithNodes nodes equals: nodes reversed. self should: [ - nodeWithNodes - replaceNode: nodes anyOne copy - with: self newNode] - raise: Error. + nodeWithNodes replaceNode: nodes anyOne copy with: self newNode ] + raise: Error ] diff --git a/src/XML-Parser-Tests/XMLNodeWithElementsTest.class.st b/src/XML-Parser-Tests/XMLNodeWithElementsTest.class.st index c63c50e7..24270144 100644 --- a/src/XML-Parser-Tests/XMLNodeWithElementsTest.class.st +++ b/src/XML-Parser-Tests/XMLNodeWithElementsTest.class.st @@ -38,13 +38,14 @@ XMLNodeWithElementsTest >> configurationClass [ { #category : #tests } XMLNodeWithElementsTest >> elementBefore [ - self newNodeWithElements allNodesDo: [:node | - node canHaveChildren - ifTrue: [| elementBefore | - elementBefore := nil. - node elements do: [:each | - self assert: (node elementBefore: each) == elementBefore. - elementBefore := each]]] + + self newNodeWithElements allNodesDo: [ :node | + node canHaveChildren ifTrue: [ + | elementBefore | + elementBefore := nil. + node elements do: [ :each | + self assert: (node elementBefore: each) identicalTo: elementBefore. + elementBefore := each ] ] ] ] { #category : #'instance creation' } @@ -91,140 +92,135 @@ XMLNodeWithElementsTest >> nodeClass [ { #category : #tests } XMLNodeWithElementsTest >> testAcceptNodeVisitor [ - | visitor nodeWithElements message | + | visitor nodeWithElements message | visitor := XMLRecordingNodeVisitor new. nodeWithElements := self newNodeWithElements. self - assert: (nodeWithElements acceptNodeVisitor: visitor) == nodeWithElements; + assert: (nodeWithElements acceptNodeVisitor: visitor) + identicalTo: nodeWithElements; assert: visitor messageRecorder hasMessages. "skip the messages for the nodeWithElements" - [visitor messageRecorder hasMessages - and: [ - visitor messageRecorder peekMessage arguments = - (Array with: nodeWithElements)]] - whileTrue: [visitor messageRecorder nextMessage]. - - nodeWithElements descendantNodesDo: [:node | | visitingSelectors | - visitingSelectors := - (#( - #(isElement #(visitElement: visitNodeWithElements:)) - #(isCData #(visitCData: #visitStringNode:)) - #(isStringNode #(#visitStringNode:)) - #(isComment #(visitComment:)) - #(isPI #(visitPI:))) - detect: [:each | node perform: each first] - ifNone: [#(nil #())]) second. + [ + visitor messageRecorder hasMessages and: [ + visitor messageRecorder peekMessage arguments + = (Array with: nodeWithElements) ] ] whileTrue: [ + visitor messageRecorder nextMessage ]. + + nodeWithElements descendantNodesDo: [ :node | + | visitingSelectors | + visitingSelectors := (#( #( isElement #( visitElement: visitNodeWithElements: ) ) + #( isCData #( visitCData: #visitStringNode: ) ) + #( isStringNode #( #visitStringNode: ) ) + #( isComment #( visitComment: ) ) + #( isPI #( visitPI: ) ) ) + detect: [ :each | node perform: each first ] + ifNone: [ #( nil #( ) ) ]) second. self assert: visitingSelectors notEmpty. - visitingSelectors do: [:selector | + visitingSelectors do: [ :selector | self assert: visitor messageRecorder hasMessages. message := visitor messageRecorder nextMessage. self - assert: message selector = selector; - assert: message arguments = (Array with: node)]]. + assert: message selector equals: selector; + assert: message arguments equals: (Array with: node) ] ]. self deny: visitor messageRecorder hasMessages ] { #category : #tests } XMLNodeWithElementsTest >> testAddCData [ - | nodeWithElements cdataNode | + | nodeWithElements cdataNode | nodeWithElements := self newNode. cdataNode := nodeWithElements addCData: 'test'. self assert: cdataNode isCData; - assert: cdataNode string = 'test'; - assert: nodeWithElements nodes size = 1; - assert: nodeWithElements firstNode == cdataNode + assert: cdataNode string equals: 'test'; + assert: nodeWithElements nodes size equals: 1; + assert: nodeWithElements firstNode identicalTo: cdataNode ] { #category : #tests } XMLNodeWithElementsTest >> testAddCDataNodeFactoryUse [ - | nodeWithElements firstCDataNode lastCDataNode | + | nodeWithElements firstCDataNode lastCDataNode | nodeWithElements := self newNode. firstCDataNode := nodeWithElements addCData: 'one'. nodeWithElements nodeFactory: - (XMLPluggableNodeFactory new - cdataClass: XMLFCData). + (XMLPluggableNodeFactory new cdataClass: XMLFCData). lastCDataNode := nodeWithElements addCData: 'two'. self - assert: nodeWithElements nodes size = 2; - assert: firstCDataNode class == XMLCData; - assert: firstCDataNode string = 'one'; - assert: lastCDataNode class == XMLFCData; - assert: lastCDataNode string = 'two' + assert: nodeWithElements nodes size equals: 2; + assert: firstCDataNode class identicalTo: XMLCData; + assert: firstCDataNode string equals: 'one'; + assert: lastCDataNode class identicalTo: XMLFCData; + assert: lastCDataNode string equals: 'two' ] { #category : #tests } XMLNodeWithElementsTest >> testAddComment [ - | nodeWithElements comment | + | nodeWithElements comment | super testAddComment. - (nodeWithElements := self newNode) - nodeFactory: - (XMLPluggableNodeFactory new - commentClass: XMLFComment). + (nodeWithElements := self newNode) nodeFactory: + (XMLPluggableNodeFactory new commentClass: XMLFComment). comment := nodeWithElements addComment: 'test'. self - assert: nodeWithElements nodes size = 1; - assert: nodeWithElements firstNode == comment; - assert: comment class == XMLFComment; - assert: comment string = 'test' + assert: nodeWithElements nodes size equals: 1; + assert: nodeWithElements firstNode identicalTo: comment; + assert: comment class identicalTo: XMLFComment; + assert: comment string equals: 'test' ] { #category : #tests } XMLNodeWithElementsTest >> testAddElementNamed [ - | nodeWithElements element | + | nodeWithElements element | nodeWithElements := self newNode. element := nodeWithElements addElementNamed: 'one'. self - assert: nodeWithElements nodes size = 1; + assert: nodeWithElements nodes size equals: 1; assert: element isElement; - assert: element name = 'one'. + assert: element name equals: 'one'. self - should: [nodeWithElements addElementNamed: 'undeclared:two'] + should: [ nodeWithElements addElementNamed: 'undeclared:two' ] raise: XMLNamespaceException. nodeWithElements := self newNode. nodeWithElements usesNamespaces: false. self - shouldnt: [nodeWithElements addElementNamed: 'undeclared:three'] + shouldnt: [ nodeWithElements addElementNamed: 'undeclared:three' ] raise: XMLNamespaceException ] { #category : #tests } XMLNodeWithElementsTest >> testAddElementNamedAttributes [ - | nodeWithElements element | + | nodeWithElements element | nodeWithElements := self newNode. - element := - nodeWithElements - addElementNamed: 'one' - attributes: self unprefixedAttributeAssociations. + element := nodeWithElements + addElementNamed: 'one' + attributes: self unprefixedAttributeAssociations. self - assert: nodeWithElements nodes size = 1; + assert: nodeWithElements nodes size equals: 1; assert: element isElement; - assert: element name = 'one'; + assert: element name equals: 'one'; assertElement: element hasAttributes: self unprefixedAttributes. self should: [ nodeWithElements addElementNamed: 'undeclared:two' - attributes: self unprefixedAttributeAssociations] + attributes: self unprefixedAttributeAssociations ] raise: XMLNamespaceException. self - should: [ - "attributes with undeclared prefixes should be caught too" + should: [ "attributes with undeclared prefixes should be caught too" nodeWithElements addElementNamed: 'three' - attributes: self attributeAssociations] + attributes: self attributeAssociations ] raise: XMLNamespaceException. nodeWithElements := self newNode. @@ -233,70 +229,65 @@ XMLNodeWithElementsTest >> testAddElementNamedAttributes [ shouldnt: [ nodeWithElements addElementNamed: 'undeclared:four' - attributes: self attributeAssociations] + attributes: self attributeAssociations ] raise: XMLNamespaceException ] { #category : #tests } XMLNodeWithElementsTest >> testAddElementNamedAttributesNodeFactoryUse [ - | nodeWithElements element | + | nodeWithElements element | nodeWithElements := self newNode. - nodeWithElements nodeFactory: - (XMLPluggableElementFactory new - handleElement: 'test' - attributes: self unprefixedAttributeAssociations - withClass: self otherElementClass). - element := - nodeWithElements - addElementNamed: 'test' - attributes: self unprefixedAttributeAssociations. - self - assert: nodeWithElements nodes size = 1; - assert: element class == self otherElementClass; - assert: element name = 'test'; + nodeWithElements nodeFactory: (XMLPluggableElementFactory new + handleElement: 'test' + attributes: self unprefixedAttributeAssociations + withClass: self otherElementClass). + element := nodeWithElements + addElementNamed: 'test' + attributes: self unprefixedAttributeAssociations. + self + assert: nodeWithElements nodes size equals: 1; + assert: element class identicalTo: self otherElementClass; + assert: element name equals: 'test'; assertElement: element hasAttributes: self unprefixedAttributes ] { #category : #tests } XMLNodeWithElementsTest >> testAddElementNamedNamespaceURI [ - | nodeWithElements element | + | nodeWithElements element | nodeWithElements := self newNode. - element := - nodeWithElements - addElementNamed: 'test' - namespaceURI: 'defaultNS'. + element := nodeWithElements + addElementNamed: 'test' + namespaceURI: 'defaultNS'. self - assert: nodeWithElements nodes size = 1; + assert: nodeWithElements nodes size equals: 1; assert: element isElement; - assert: element name = 'test'; - assert: element namespaceURI = 'defaultNS' + assert: element name equals: 'test'; + assert: element namespaceURI equals: 'defaultNS' ] { #category : #tests } XMLNodeWithElementsTest >> testAddElementNamedNamespaceURIAttributes [ - | nodeWithElements element | + | nodeWithElements element | nodeWithElements := self newNode. - element := - nodeWithElements - addElementNamed: 'prefix:one' - namespaceURI: 'prefixNS' - attributes: self attributeAssociations. + element := nodeWithElements + addElementNamed: 'prefix:one' + namespaceURI: 'prefixNS' + attributes: self attributeAssociations. self - assert: nodeWithElements nodes size = 1; + assert: nodeWithElements nodes size equals: 1; assert: element isElement; - assert: element name = 'prefix:one'; - assert: element namespaceURI = 'prefixNS'; + assert: element name equals: 'prefix:one'; + assert: element namespaceURI equals: 'prefixNS'; assertElement: element hasAttributes: self attributes. self - should: [ - "attributes with undeclared prefixes should be caught" + should: [ "attributes with undeclared prefixes should be caught" nodeWithElements addElementNamed: 'two' namespaceURI: 'defaultNS' - attributes: self attributeAssociations] + attributes: self attributeAssociations ] raise: XMLNamespaceException. "this forces namespace support" @@ -307,7 +298,7 @@ XMLNodeWithElementsTest >> testAddElementNamedNamespaceURIAttributes [ nodeWithElements addElementNamed: 'three' namespaceURI: '' - attributes: self unprefixedAttributeAssociations] + attributes: self unprefixedAttributeAssociations ] raise: XMLNamespaceException. nodeWithElements usesNamespaces: false. self @@ -315,124 +306,115 @@ XMLNodeWithElementsTest >> testAddElementNamedNamespaceURIAttributes [ nodeWithElements addElementNamed: 'four' namespaceURI: '' - attributes: self attributeAssociations] + attributes: self attributeAssociations ] raise: XMLNamespaceException ] { #category : #tests } XMLNodeWithElementsTest >> testAddElementNamedNamespaceURIAttributesNodeFactoryUse [ - | nodeWithElements element | + | nodeWithElements element | nodeWithElements := self newNode. - nodeWithElements nodeFactory: - (XMLPluggableElementFactory new - handleElement: 'prefix:test' - namespaceURI: 'prefixNS' - attributes: self attributeAssociations - withClass: self otherElementClass). - element := - nodeWithElements - addElementNamed: 'prefix:test' - namespaceURI: 'prefixNS' - attributes: self attributeAssociations. - self - assert: nodeWithElements nodes size = 1; - assert: element class == self otherElementClass; - assert: element name = 'prefix:test'; - assert: element namespaceURI = 'prefixNS'; + nodeWithElements nodeFactory: (XMLPluggableElementFactory new + handleElement: 'prefix:test' + namespaceURI: 'prefixNS' + attributes: self attributeAssociations + withClass: self otherElementClass). + element := nodeWithElements + addElementNamed: 'prefix:test' + namespaceURI: 'prefixNS' + attributes: self attributeAssociations. + self + assert: nodeWithElements nodes size equals: 1; + assert: element class identicalTo: self otherElementClass; + assert: element name equals: 'prefix:test'; + assert: element namespaceURI equals: 'prefixNS'; assertElement: element hasAttributes: self attributes ] { #category : #tests } XMLNodeWithElementsTest >> testAddElementNamedNamespaceURINodeFactoryUse [ - | nodeWithElements element | + | nodeWithElements element | nodeWithElements := self newNode. - nodeWithElements nodeFactory: - (XMLPluggableElementFactory new - handleElement: 'test' - namespaceURI: 'defaultNS' - withClass: self otherElementClass). - element := - nodeWithElements - addElementNamed: 'test' - namespaceURI: 'defaultNS'. + nodeWithElements nodeFactory: (XMLPluggableElementFactory new + handleElement: 'test' + namespaceURI: 'defaultNS' + withClass: self otherElementClass). + element := nodeWithElements + addElementNamed: 'test' + namespaceURI: 'defaultNS'. self - assert: nodeWithElements nodes size = 1; - assert: element class == self otherElementClass; - assert: element name = 'test'; - assert: element namespaceURI = 'defaultNS' + assert: nodeWithElements nodes size equals: 1; + assert: element class identicalTo: self otherElementClass; + assert: element name equals: 'test'; + assert: element namespaceURI equals: 'defaultNS' ] { #category : #tests } XMLNodeWithElementsTest >> testAddElementNamedNodeFactoryUse [ - | nodeWithElements element | + | nodeWithElements element | nodeWithElements := self newNode. - nodeWithElements nodeFactory: - (XMLPluggableElementFactory new - handleElement: 'test' - withClass: self otherElementClass). + nodeWithElements nodeFactory: (XMLPluggableElementFactory new + handleElement: 'test' + withClass: self otherElementClass). element := nodeWithElements addElementNamed: 'test'. self - assert: nodeWithElements nodes size = 1; - assert: element class == self otherElementClass; - assert: element name = 'test' + assert: nodeWithElements nodes size equals: 1; + assert: element class identicalTo: self otherElementClass; + assert: element name equals: 'test' ] { #category : #tests } XMLNodeWithElementsTest >> testAddPITargetData [ - | nodeWithElements pi | + | nodeWithElements pi | super testAddPITargetData. - (nodeWithElements := self newNode) - nodeFactory: - (XMLPluggableNodeFactory new - piClass: XMLFPI). - pi := - nodeWithElements - addPITarget: 'target' - data: 'data'. + (nodeWithElements := self newNode) nodeFactory: + (XMLPluggableNodeFactory new piClass: XMLFPI). + pi := nodeWithElements addPITarget: 'target' data: 'data'. self - assert: nodeWithElements nodes size = 1; - assert: nodeWithElements firstNode == pi; - assert: pi class == XMLFPI; - assert: pi target = 'target'; - assert: pi data = 'data' + assert: nodeWithElements nodes size equals: 1; + assert: nodeWithElements firstNode identicalTo: pi; + assert: pi class identicalTo: XMLFPI; + assert: pi target equals: 'target'; + assert: pi data equals: 'data' ] { #category : #tests } XMLNodeWithElementsTest >> testAddString [ - | nodeWithElements firstStringNode elementNode lastStringNode | + | nodeWithElements firstStringNode elementNode lastStringNode | nodeWithElements := self newNode. firstStringNode := nodeWithElements addString: 'one'. self assert: (firstStringNode isStringNode: 'one'); - assert: nodeWithElements nodes size = 1; - assert: nodeWithElements firstNode == firstStringNode. - + assert: nodeWithElements nodes size equals: 1; + assert: nodeWithElements firstNode identicalTo: firstStringNode. self - assert: (nodeWithElements addString: 'two') == firstStringNode; + assert: (nodeWithElements addString: 'two') + identicalTo: firstStringNode; assert: (firstStringNode isStringNode: 'onetwo'); - assert: nodeWithElements nodes size = 1; - assert: nodeWithElements nodes first == firstStringNode. + assert: nodeWithElements nodes size equals: 1; + assert: nodeWithElements nodes first identicalTo: firstStringNode. - elementNode := nodeWithElements addNode: (self elementClass named: 'three'). + elementNode := nodeWithElements addNode: + (self elementClass named: 'three'). self assert: (elementNode isElementNamed: 'three'); - assert: nodeWithElements nodes size = 2; - assert: nodeWithElements nodes first == firstStringNode; - assert: nodeWithElements nodes second == elementNode. + assert: nodeWithElements nodes size equals: 2; + assert: nodeWithElements nodes first identicalTo: firstStringNode; + assert: nodeWithElements nodes second identicalTo: elementNode. lastStringNode := nodeWithElements addString: 'four'. self assert: (lastStringNode isStringNode: 'four'); - assert: nodeWithElements nodes size = 3; - assert: nodeWithElements nodes first == firstStringNode; - assert: nodeWithElements nodes second == elementNode; - assert: nodeWithElements nodes third == lastStringNode + assert: nodeWithElements nodes size equals: 3; + assert: nodeWithElements nodes first identicalTo: firstStringNode; + assert: nodeWithElements nodes second identicalTo: elementNode; + assert: nodeWithElements nodes third identicalTo: lastStringNode ] { #category : #tests } @@ -484,26 +466,35 @@ XMLNodeWithElementsTest >> testAddStringNodeFactoryUse [ { #category : #tests } XMLNodeWithElementsTest >> testAllElements [ - | nodeWithElements allElements | + | nodeWithElements allElements | nodeWithElements := self newNodeWithElements. allElements := nodeWithElements allElements. - nodeWithElements isElement - ifTrue: [ - self assert: allElements first = nodeWithElements. - allElements removeFirst]. - self assert: - (allElements collect: [:each | each name]) asArray = - #('zero' 'one' 'two' 'three' 'four' 'prefix:four' 'prefix:five' 'four'). - self - assertList: allElements first allElements selects: (allElements copyFrom: 1 to: 8); - assertList: allElements second allElements selects: (allElements copyFrom: 2 to: 3); - assertList: allElements third allElements selects: (allElements copyFrom: 3 to: 3); - assertList: allElements fourth allElements selects: (allElements copyFrom: 4 to: 5); - assertList: allElements fifth allElements selects: (allElements copyFrom: 5 to: 5); - assertList: allElements sixth allElements selects: (allElements copyFrom: 6 to: 7); - assertList: allElements seventh allElements selects: (allElements copyFrom: 7 to: 7); - assertList: allElements eighth allElements selects: (allElements copyFrom: 8 to: 8) + nodeWithElements isElement ifTrue: [ + self assert: allElements first equals: nodeWithElements. + allElements removeFirst ]. + self + assert: (allElements collect: [ :each | each name ]) asArray + equals: + #( 'zero' 'one' 'two' 'three' 'four' 'prefix:four' 'prefix:five' + 'four' ). + self + assertList: allElements first allElements + selects: (allElements copyFrom: 1 to: 8); + assertList: allElements second allElements + selects: (allElements copyFrom: 2 to: 3); + assertList: allElements third allElements + selects: (allElements copyFrom: 3 to: 3); + assertList: allElements fourth allElements + selects: (allElements copyFrom: 4 to: 5); + assertList: allElements fifth allElements + selects: (allElements copyFrom: 5 to: 5); + assertList: allElements sixth allElements + selects: (allElements copyFrom: 6 to: 7); + assertList: allElements seventh allElements + selects: (allElements copyFrom: 7 to: 7); + assertList: allElements eighth allElements + selects: (allElements copyFrom: 8 to: 8) ] { #category : #tests } @@ -524,36 +515,43 @@ XMLNodeWithElementsTest >> testAllElementsCollect [ { #category : #tests } XMLNodeWithElementsTest >> testAllElementsDetect [ - | nodeWithElements allElements detectedElement | + | nodeWithElements allElements detectedElement | nodeWithElements := self newNodeWithElements. allElements := nodeWithElements allElements. - detectedElement := nodeWithElements allElementsDetect: [:each | each isNamed: 'prefix:four']. + detectedElement := nodeWithElements allElementsDetect: [ :each | + each isNamed: 'prefix:four' ]. self assert: detectedElement notNil; assert: (detectedElement isNamed: 'prefix:four'); - assert: detectedElement = (allElements detect: [:each | each isNamed: 'prefix:four']); - assert: (nodeWithElements allElementsDetect: [:each | each isNamed: 'absent']) isNil + assert: detectedElement + equals: + (allElements detect: [ :each | each isNamed: 'prefix:four' ]); + assert: + (nodeWithElements allElementsDetect: [ :each | + each isNamed: 'absent' ]) isNil ] { #category : #tests } XMLNodeWithElementsTest >> testAllElementsDetectIfNone [ - | nodeWithElements allElements detectedElement | + | nodeWithElements allElements detectedElement | nodeWithElements := self newNodeWithElements. allElements := nodeWithElements allElements. - detectedElement := - nodeWithElements - allElementsDetect: [:each | each isNamed: 'prefix:four'] - ifNone: [self fail]. + detectedElement := nodeWithElements + allElementsDetect: [ :each | + each isNamed: 'prefix:four' ] + ifNone: [ self fail ]. self assert: (detectedElement isNamed: 'prefix:four'). - self assert: - detectedElement = - (allElements detect: [:each | each isNamed: 'prefix:four']). - self assert: - (nodeWithElements - allElementsDetect: [:each | each isNamed: 'absent'] - ifNone: [#absent]) = #absent + self + assert: detectedElement + equals: + (allElements detect: [ :each | each isNamed: 'prefix:four' ]). + self + assert: (nodeWithElements + allElementsDetect: [ :each | each isNamed: 'absent' ] + ifNone: [ #absent ]) + equals: #absent ] { #category : #tests } @@ -574,16 +572,17 @@ XMLNodeWithElementsTest >> testAllElementsDo [ { #category : #tests } XMLNodeWithElementsTest >> testAllElementsNamed [ - | nodeWithElements allElements namedElements | + | nodeWithElements allElements namedElements | nodeWithElements := self newNodeWithElements. self assert: (nodeWithElements allElementsNamed: 'absent') isEmpty. allElements := nodeWithElements allElements. - namedElements := nodeWithElements allElementsNamed: 'four'. + namedElements := nodeWithElements allElementsNamed: 'four'. self - assert: namedElements size = 3; - assertList: namedElements selects: (allElements select: [:each | each isNamed: 'four']). + assert: namedElements size equals: 3; + assertList: namedElements + selects: (allElements select: [ :each | each isNamed: 'four' ]) ] { #category : #tests } @@ -604,20 +603,21 @@ XMLNodeWithElementsTest >> testAllElementsNamedDo [ { #category : #tests } XMLNodeWithElementsTest >> testAllElementsNamedNamespaceURI [ - | nodeWithElements allElements namedElements | + | nodeWithElements allElements namedElements | nodeWithElements := self newNodeWithElements. - self assert: (nodeWithElements allElementsNamed: 'four' namespaceURI: 'absent') isEmpty. + self assert: + (nodeWithElements allElementsNamed: 'four' namespaceURI: 'absent') + isEmpty. allElements := nodeWithElements allElements. - namedElements := nodeWithElements allElementsNamed: 'four' namespaceURI: 'testNS'. + namedElements := nodeWithElements + allElementsNamed: 'four' + namespaceURI: 'testNS'. self - assert: namedElements size = 2; - assertList: namedElements - selects: - (allElements select: [:each | - (each isNamed: 'four') - and: [each namespaceURI = 'testNS']]). + assert: namedElements size equals: 2; + assertList: namedElements selects: (allElements select: [ :each | + (each isNamed: 'four') and: [ each namespaceURI = 'testNS' ] ]) ] { #category : #tests } @@ -638,13 +638,13 @@ XMLNodeWithElementsTest >> testAllElementsSelect [ { #category : #tests } XMLNodeWithElementsTest >> testAllNodes [ - | nodeWithElements allNodes | + | nodeWithElements allNodes | nodeWithElements := self newNodeWithElements. allNodes := nodeWithElements allNodes. self - assert: allNodes size = 16; - assert: (allNodes at: 1) = nodeWithElements; + assert: allNodes size equals: 16; + assert: (allNodes at: 1) equals: nodeWithElements; assert: (allNodes at: 2) isComment; assert: ((allNodes at: 3) isElementNamed: 'zero'); assert: (allNodes at: 4) isComment; @@ -661,33 +661,39 @@ XMLNodeWithElementsTest >> testAllNodes [ assert: ((allNodes at: 15) isElementNamed: 'four'); assert: (allNodes at: 16) isComment. self - assertList: (allNodes at: 3) allNodes selects: (allNodes copyFrom: 3 to: 15); - assertList: (allNodes at: 5) allNodes selects: (allNodes copyFrom: 5 to: 8); - assertList: (allNodes at: 7) allNodes selects: (allNodes copyFrom: 7 to: 7); - assertList: (allNodes at: 10) allNodes selects: (allNodes copyFrom: 10 to: 12); - assertList: (allNodes at: 11) allNodes selects: (allNodes copyFrom: 11 to: 11); - assertList: (allNodes at: 13) allNodes selects: (allNodes copyFrom: 13 to: 14); - assertList: (allNodes at: 14) allNodes selects: (allNodes copyFrom: 14 to: 14); - assertList: (allNodes at: 15) allNodes selects: (allNodes copyFrom: 15 to: 15). + assertList: (allNodes at: 3) allNodes + selects: (allNodes copyFrom: 3 to: 15); + assertList: (allNodes at: 5) allNodes + selects: (allNodes copyFrom: 5 to: 8); + assertList: (allNodes at: 7) allNodes + selects: (allNodes copyFrom: 7 to: 7); + assertList: (allNodes at: 10) allNodes + selects: (allNodes copyFrom: 10 to: 12); + assertList: (allNodes at: 11) allNodes + selects: (allNodes copyFrom: 11 to: 11); + assertList: (allNodes at: 13) allNodes + selects: (allNodes copyFrom: 13 to: 14); + assertList: (allNodes at: 14) allNodes + selects: (allNodes copyFrom: 14 to: 14); + assertList: (allNodes at: 15) allNodes + selects: (allNodes copyFrom: 15 to: 15) ] { #category : #tests } XMLNodeWithElementsTest >> testAncestorElements [ - | nodeWithElements ancestorStack | + | nodeWithElements ancestorStack | super testAncestorElements. nodeWithElements := self newNodeWithElements. ancestorStack := OrderedCollection new. - nodeWithElements allNodesDo: [:each | - [ancestorStack isEmpty - or: [ancestorStack last = each parent]] - whileFalse: [ancestorStack removeLast]. - self assert: - each ancestorElements asOrderedCollection = - ancestorStack reversed. - each isElement - ifTrue: [ancestorStack addLast: each]]. + nodeWithElements allNodesDo: [ :each | + [ ancestorStack isEmpty or: [ ancestorStack last = each parent ] ] + whileFalse: [ ancestorStack removeLast ]. + self + assert: each ancestorElements asOrderedCollection + equals: ancestorStack reversed. + each isElement ifTrue: [ ancestorStack addLast: each ] ] ] { #category : #tests } @@ -705,24 +711,26 @@ XMLNodeWithElementsTest >> testAncestorElementsDo [ { #category : #tests } XMLNodeWithElementsTest >> testConfiguration [ - | nodeWithElements configuration newConfiguration | + | nodeWithElements configuration newConfiguration | nodeWithElements := self newNodeWithElements. configuration := nodeWithElements configuration. - self assert: configuration class == self configurationClass. - nodeWithElements allElementsDo: [:element | - self assert: element configuration == configuration. - element attributeNodes do: [:each | - self assert: each configuration == configuration]]. + self assert: configuration class identicalTo: self configurationClass. + nodeWithElements allElementsDo: [ :element | + self assert: element configuration identicalTo: configuration. + element attributeNodes do: [ :each | + self assert: each configuration identicalTo: configuration ] ]. "ensure descendants inherit the new config when it's set" newConfiguration := self configurationClass new. nodeWithElements configuration: newConfiguration. - self assert: nodeWithElements configuration == newConfiguration. - nodeWithElements allElementsDo: [:element | - self assert: element configuration == newConfiguration. - element attributeNodes do: [:each | - self assert: each configuration == newConfiguration]]. + self + assert: nodeWithElements configuration + identicalTo: newConfiguration. + nodeWithElements allElementsDo: [ :element | + self assert: element configuration identicalTo: newConfiguration. + element attributeNodes do: [ :each | + self assert: each configuration identicalTo: newConfiguration ] ] ] { #category : #tests } @@ -755,31 +763,43 @@ XMLNodeWithElementsTest >> testContentNodesDo [ { #category : #tests } XMLNodeWithElementsTest >> testContentStringAt [ - | root | + | root | root := self newNodeWithElements firstElement. - root elementsDo: [:each | - self assert: (root contentStringAt: each name) = each contentString]. + root elementsDo: [ :each | + self + assert: (root contentStringAt: each name) + equals: each contentString ] ] { #category : #tests } XMLNodeWithElementsTest >> testDescendantElements [ - | nodeWithElements descendantElements | + | nodeWithElements descendantElements | nodeWithElements := self newNodeWithElements. descendantElements := nodeWithElements descendantElements. - self assert: - (descendantElements collect: [:each | each name]) asArray = - #('zero' 'one' 'two' 'three' 'four' 'prefix:four' 'prefix:five' 'four'). self - assertList: descendantElements first descendantElements selects: (descendantElements copyFrom: 2 to: 8); - assertList: descendantElements second descendantElements selects: (descendantElements copyFrom: 3 to: 3); - assertList: descendantElements third descendantElements selects: descendantElements copyEmpty; - assertList: descendantElements fourth descendantElements selects: (descendantElements copyFrom: 5 to: 5); - assertList: descendantElements fifth descendantElements selects: descendantElements copyEmpty; - assertList: descendantElements sixth descendantElements selects: (descendantElements copyFrom: 7 to: 7); - assertList: descendantElements seventh descendantElements selects: descendantElements copyEmpty; - assertList: descendantElements eighth descendantElements selects: descendantElements copyEmpty. + assert: (descendantElements collect: [ :each | each name ]) asArray + equals: + #( 'zero' 'one' 'two' 'three' 'four' 'prefix:four' 'prefix:five' + 'four' ). + self + assertList: descendantElements first descendantElements + selects: (descendantElements copyFrom: 2 to: 8); + assertList: descendantElements second descendantElements + selects: (descendantElements copyFrom: 3 to: 3); + assertList: descendantElements third descendantElements + selects: descendantElements copyEmpty; + assertList: descendantElements fourth descendantElements + selects: (descendantElements copyFrom: 5 to: 5); + assertList: descendantElements fifth descendantElements + selects: descendantElements copyEmpty; + assertList: descendantElements sixth descendantElements + selects: (descendantElements copyFrom: 7 to: 7); + assertList: descendantElements seventh descendantElements + selects: descendantElements copyEmpty; + assertList: descendantElements eighth descendantElements + selects: descendantElements copyEmpty ] { #category : #tests } @@ -800,36 +820,42 @@ XMLNodeWithElementsTest >> testDescendantElementsCollect [ { #category : #tests } XMLNodeWithElementsTest >> testDescendantElementsDetect [ - | nodeWithElements descendantElements detectedElement | + | nodeWithElements descendantElements detectedElement | nodeWithElements := self newNodeWithElements. descendantElements := nodeWithElements descendantElements. - detectedElement := nodeWithElements descendantElementsDetect: [:each | each isNamed: 'prefix:four']. + detectedElement := nodeWithElements descendantElementsDetect: [ :each | + each isNamed: 'prefix:four' ]. self assert: detectedElement notNil; assert: (detectedElement isNamed: 'prefix:four'); - assert: detectedElement = (descendantElements detect: [:each | each isNamed: 'prefix:four']); - assert: (detectedElement descendantElementsDetect: [:each | each isNamed: 'prefix:four']) isNil. + assert: detectedElement + equals: + (descendantElements detect: [ :each | each isNamed: 'prefix:four' ]); + assert: (detectedElement descendantElementsDetect: [ :each | + each isNamed: 'prefix:four' ]) isNil ] { #category : #tests } XMLNodeWithElementsTest >> testDescendantElementsDetectIfNone [ - | nodeWithElements descendantElements detectedElement | + | nodeWithElements descendantElements detectedElement | nodeWithElements := self newNodeWithElements. descendantElements := nodeWithElements descendantElements. - detectedElement := - nodeWithElements - descendantElementsDetect: [:each | each isNamed: 'prefix:four'] - ifNone: [self fail]. + detectedElement := nodeWithElements + descendantElementsDetect: [ :each | + each isNamed: 'prefix:four' ] + ifNone: [ self fail ]. self assert: (detectedElement isNamed: 'prefix:four'). - self assert: - detectedElement = - (descendantElements detect: [:each | each isNamed: 'prefix:four']). - self assert: - (detectedElement - descendantElementsDetect: [:each | each isNamed: 'prefix:four'] - ifNone: [#absent]) = #absent. + self + assert: detectedElement + equals: + (descendantElements detect: [ :each | each isNamed: 'prefix:four' ]). + self + assert: (detectedElement + descendantElementsDetect: [ :each | each isNamed: 'prefix:four' ] + ifNone: [ #absent ]) + equals: #absent ] { #category : #tests } @@ -850,20 +876,22 @@ XMLNodeWithElementsTest >> testDescendantElementsDo [ { #category : #tests } XMLNodeWithElementsTest >> testDescendantElementsNamed [ - | nodeWithElements descendantElements namedElements | + | nodeWithElements descendantElements namedElements | nodeWithElements := self newNodeWithElements. - self assert: (nodeWithElements descendantElementsNamed: 'absent') isEmpty. + self assert: + (nodeWithElements descendantElementsNamed: 'absent') isEmpty. descendantElements := nodeWithElements descendantElements. - namedElements := nodeWithElements descendantElementsNamed: 'four'. - self assert: namedElements size = 3. + namedElements := nodeWithElements descendantElementsNamed: 'four'. + self assert: namedElements size equals: 3. self assertList: namedElements - selects: (descendantElements select: [:each | each isNamed: 'four']). + selects: + (descendantElements select: [ :each | each isNamed: 'four' ]). - namedElements do: [:each | - self assert: (each descendantElementsNamed: 'four') isEmpty] + namedElements do: [ :each | + self assert: (each descendantElementsNamed: 'four') isEmpty ] ] { #category : #tests } @@ -883,26 +911,22 @@ XMLNodeWithElementsTest >> testDescendantElementsNamedDo [ { #category : #tests } XMLNodeWithElementsTest >> testDescendantElementsNamedNamespaceURI [ - | nodeWithElements descendantElements namedElements | + | nodeWithElements descendantElements namedElements | nodeWithElements := self newNodeWithElements. - self assert: - (nodeWithElements - descendantElementsNamed: 'four' - namespaceURI: 'absent') isEmpty. + self assert: (nodeWithElements + descendantElementsNamed: 'four' + namespaceURI: 'absent') isEmpty. descendantElements := nodeWithElements descendantElements. - namedElements := - nodeWithElements - descendantElementsNamed: 'four' - namespaceURI: 'testNS'. + namedElements := nodeWithElements + descendantElementsNamed: 'four' + namespaceURI: 'testNS'. self - assert: namedElements size = 2; + assert: namedElements size equals: 2; assertList: namedElements - selects: - (descendantElements select: [:each | - (each isNamed: 'four') - and: [each namespaceURI = 'testNS']]). + selects: (descendantElements select: [ :each | + (each isNamed: 'four') and: [ each namespaceURI = 'testNS' ] ]) ] { #category : #tests } @@ -923,38 +947,38 @@ XMLNodeWithElementsTest >> testDescendantElementsSelect [ { #category : #tests } XMLNodeWithElementsTest >> testElementAfter [ - self newNodeWithElements allNodesDo: [:node | - node canHaveChildren - ifTrue: [| elementAfter | - elementAfter := nil. - node elements reverseDo: [:each | - self assert: (node elementAfter: each) = elementAfter. - elementAfter := each]]] + + self newNodeWithElements allNodesDo: [ :node | + node canHaveChildren ifTrue: [ + | elementAfter | + elementAfter := nil. + node elements reverseDo: [ :each | + self assert: (node elementAfter: each) equals: elementAfter. + elementAfter := each ] ] ] ] { #category : #tests } XMLNodeWithElementsTest >> testElementAt [ - self newNodeWithElements allNodesDo: [:node | - node canHaveChildren - ifTrue: [| elements localNames qualifiedNames | - elements := node elements. - localNames := (elements collect: [:each | each localName]) asSet. - qualifiedNames := - (elements - select: [:each | each hasPrefix] - thenCollect: [:each | each name]) asSet. - localNames do: [:localName | - self assert: - (node elementAt: localName) = - (elements detect: [:each | each localName = localName]). - self assert: (node elementAt: 'absent:', localName) isNil]. - qualifiedNames do: [:qualifiedName | - self assert: - (node elementAt: qualifiedName) = - (elements detect: [:each | - each hasPrefix - and: [each name = qualifiedName]])]. - self assert: (node elementAt: 'absent') isNil]] + + self newNodeWithElements allNodesDo: [ :node | + node canHaveChildren ifTrue: [ + | elements localNames qualifiedNames | + elements := node elements. + localNames := (elements collect: [ :each | each localName ]) asSet. + qualifiedNames := (elements + select: [ :each | each hasPrefix ] + thenCollect: [ :each | each name ]) asSet. + localNames do: [ :localName | + self + assert: (node elementAt: localName) + equals: (elements detect: [ :each | each localName = localName ]). + self assert: (node elementAt: 'absent:' , localName) isNil ]. + qualifiedNames do: [ :qualifiedName | + self + assert: (node elementAt: qualifiedName) + equals: (elements detect: [ :each | + each hasPrefix and: [ each name = qualifiedName ] ]) ]. + self assert: (node elementAt: 'absent') isNil ] ] ] { #category : #tests } @@ -984,138 +1008,127 @@ XMLNodeWithElementsTest >> testElementAtAddedInPlace [ { #category : #tests } XMLNodeWithElementsTest >> testElementAtIfAbsent [ - self newNodeWithElements allNodesDo: [:node | - node canHaveChildren - ifTrue: [| elements localNames qualifiedNames | - elements := node elements. - localNames := (elements collect: [:each | each localName]) asSet. - qualifiedNames := - (elements - select: [:each | each hasPrefix] - thenCollect: [:each | each name]) asSet. - localNames do: [:localName | - self assert: - (node - elementAt: localName - ifAbsent: [self fail]) = - (elements detect: [:each | each localName = localName]). - self assert: - (node - elementAt: 'absent:', localName - ifAbsent: [#absent]) = #absent]. - qualifiedNames do: [:qualifiedName | - self assert: - (node - elementAt: qualifiedName - ifAbsent: [self fail]) = - (elements detect: [:each | - each hasPrefix - and: [each name = qualifiedName]])]. - self assert: - (node - elementAt: 'absent' - ifAbsent: [#absent]) = #absent]] + + self newNodeWithElements allNodesDo: [ :node | + node canHaveChildren ifTrue: [ + | elements localNames qualifiedNames | + elements := node elements. + localNames := (elements collect: [ :each | each localName ]) asSet. + qualifiedNames := (elements + select: [ :each | each hasPrefix ] + thenCollect: [ :each | each name ]) asSet. + localNames do: [ :localName | + self + assert: (node elementAt: localName ifAbsent: [ self fail ]) + equals: (elements detect: [ :each | each localName = localName ]). + self + assert: + (node elementAt: 'absent:' , localName ifAbsent: [ #absent ]) + equals: #absent ]. + qualifiedNames do: [ :qualifiedName | + self + assert: (node elementAt: qualifiedName ifAbsent: [ self fail ]) + equals: (elements detect: [ :each | + each hasPrefix and: [ each name = qualifiedName ] ]) ]. + self + assert: (node elementAt: 'absent' ifAbsent: [ #absent ]) + equals: #absent ] ] ] { #category : #tests } XMLNodeWithElementsTest >> testElementAtNamespaceURI [ - self newNodeWithElements allNodesDo: [:node | - node canHaveChildren - ifTrue: [| elements localNames qualifiedNames namespaceURIs | - elements := node elements. - localNames := (elements collect: [:each | each localName]) asSet. - qualifiedNames := - (elements - select: [:each | each hasPrefix] - thenCollect: [:each | each name]) asSet. - namespaceURIs := (elements collect: [:each | each namespaceURI]) asSet. - localNames do: [:localName | - namespaceURIs do: [:uri | - self assert: - (node - elementAt: localName - namespaceURI: uri) = - (elements detect: [:each | - each localName = localName - and: [each namespaceURI = uri]])]. - self assert: - (node - elementAt: localName - namespaceURI: 'absentNS') isNil]. - qualifiedNames do: [:qualifiedName | - namespaceURIs do: [:uri | - self assert: - (node - elementAt: qualifiedName - namespaceURI: uri) = - (elements detect: [:each | - each hasPrefix - and: [each name = qualifiedName - and: [each namespaceURI = uri]]])]. - self assert: - (node - elementAt: qualifiedName - namespaceURI: 'absentNS') isNil]]] + + self newNodeWithElements allNodesDo: [ :node | + node canHaveChildren ifTrue: [ + | elements localNames qualifiedNames namespaceURIs | + elements := node elements. + localNames := (elements collect: [ :each | each localName ]) asSet. + qualifiedNames := (elements + select: [ :each | each hasPrefix ] + thenCollect: [ :each | each name ]) asSet. + namespaceURIs := (elements collect: [ :each | each namespaceURI ]) + asSet. + localNames do: [ :localName | + namespaceURIs do: [ :uri | + self + assert: (node elementAt: localName namespaceURI: uri) + equals: (elements detect: [ :each | + each localName = localName and: [ each namespaceURI = uri ] ]) ]. + self assert: + (node elementAt: localName namespaceURI: 'absentNS') isNil ]. + qualifiedNames do: [ :qualifiedName | + namespaceURIs do: [ :uri | + self + assert: (node elementAt: qualifiedName namespaceURI: uri) + equals: (elements detect: [ :each | + each hasPrefix and: [ + each name = qualifiedName and: [ each namespaceURI = uri ] ] ]) ]. + self assert: + (node elementAt: qualifiedName namespaceURI: 'absentNS') isNil ] ] ] ] { #category : #tests } XMLNodeWithElementsTest >> testElementAtNamespaceURIIfAbsent [ - self newNodeWithElements allNodesDo: [:node | - node canHaveChildren - ifTrue: [| elements localNames qualifiedNames namespaceURIs | - elements := node elements. - localNames := (elements collect: [:each | each localName]) asSet. - qualifiedNames := - (elements - select: [:each | each hasPrefix] - thenCollect: [:each | each name]) asSet. - namespaceURIs := (elements collect: [:each | each namespaceURI]) asSet. - localNames do: [:localName | - namespaceURIs do: [:uri | - self assert: - (node - elementAt: localName - namespaceURI: uri - ifAbsent: [#absent]) = - (elements - detect: [:each | - each localName = localName - and: [each namespaceURI = uri]] - ifNone: [#absent])]. - self assert: + + self newNodeWithElements allNodesDo: [ :node | + node canHaveChildren ifTrue: [ + | elements localNames qualifiedNames namespaceURIs | + elements := node elements. + localNames := (elements collect: [ :each | each localName ]) asSet. + qualifiedNames := (elements + select: [ :each | each hasPrefix ] + thenCollect: [ :each | each name ]) asSet. + namespaceURIs := (elements collect: [ :each | each namespaceURI ]) + asSet. + localNames do: [ :localName | + namespaceURIs do: [ :uri | + self + assert: (node - elementAt: localName - namespaceURI: 'absentNS' - ifAbsent: [#absent]) = #absent]. - qualifiedNames do: [:qualifiedName | - namespaceURIs do: [:uri | - self assert: - (node - elementAt: qualifiedName - namespaceURI: uri - ifAbsent: [#absent]) = - (elements - detect: [:each | - each hasPrefix - and: [each name = qualifiedName - and: [each namespaceURI = uri]]] - ifNone: [#absent])]. - self assert: + elementAt: localName + namespaceURI: uri + ifAbsent: [ #absent ]) + equals: (elements + detect: [ :each | + each localName = localName and: [ each namespaceURI = uri ] ] + ifNone: [ #absent ]) ]. + self + assert: (node + elementAt: localName + namespaceURI: 'absentNS' + ifAbsent: [ #absent ]) + equals: #absent ]. + qualifiedNames do: [ :qualifiedName | + namespaceURIs do: [ :uri | + self + assert: (node - elementAt: qualifiedName - namespaceURI: 'absentNS' - ifAbsent: [#absent]) = #absent]]] + elementAt: qualifiedName + namespaceURI: uri + ifAbsent: [ #absent ]) + equals: (elements + detect: [ :each | + each hasPrefix and: [ + each name = qualifiedName and: [ each namespaceURI = uri ] ] ] + ifNone: [ #absent ]) ]. + self + assert: (node + elementAt: qualifiedName + namespaceURI: 'absentNS' + ifAbsent: [ #absent ]) + equals: #absent ] ] ] ] { #category : #tests } XMLNodeWithElementsTest >> testElementBefore [ - self newNodeWithElements allNodesDo: [:node | - node canHaveChildren - ifTrue: [| elementBefore | - elementBefore := nil. - node elements do: [:each | - self assert: (node elementBefore: each) = elementBefore. - elementBefore := each]]] + + self newNodeWithElements allNodesDo: [ :node | + node canHaveChildren ifTrue: [ + | elementBefore | + elementBefore := nil. + node elements do: [ :each | + self assert: (node elementBefore: each) equals: elementBefore. + elementBefore := each ] ] ] ] { #category : #tests } @@ -1134,56 +1147,58 @@ XMLNodeWithElementsTest >> testElementNames [ { #category : #tests } XMLNodeWithElementsTest >> testElementRenamingToNext [ + self newNodeWithElements usesNamespaces: false; - allElementsDo: [:each | | parent oldName oldLocalName nextElement | - ((parent := each parent) notNil - and: [(nextElement := each nextElement) notNil]) - ifTrue: [ + allElementsDo: [ :each | + | parent oldName oldLocalName nextElement | + ((parent := each parent) notNil and: [ + (nextElement := each nextElement) notNil ]) ifTrue: [ oldName := each name. oldLocalName := each localName. - + each name: nextElement name. - each name = oldName - ifFalse: [ - self - deny: ((parent elementAt: oldName) = each); - deny: ((parent elementsAt: oldName) includes: each)]. - each localName = oldLocalName - ifFalse: [ + each name = oldName ifFalse: [ self - deny: ((parent elementAt: oldLocalName) = each); - deny: ((parent elementsAt: oldLocalName) includes: each)]. + deny: (parent elementAt: oldName) equals: each; + deny: ((parent elementsAt: oldName) includes: each) ]. + each localName = oldLocalName ifFalse: [ + self + deny: (parent elementAt: oldLocalName) equals: each; + deny: ((parent elementsAt: oldLocalName) includes: each) ]. self - assert: ((parent elementsAt: each name) after: each) = nextElement; - assert: ((parent elementsAt: each localName) after: each) = nextElement]]. + assert: ((parent elementsAt: each name) after: each) + equals: nextElement; + assert: ((parent elementsAt: each localName) after: each) + equals: nextElement ] ] ] { #category : #tests } XMLNodeWithElementsTest >> testElementRenamingToPrevious [ + self newNodeWithElements usesNamespaces: false; - allElementsDo: [:each | | parent oldName oldLocalName previousElement | - ((parent := each parent) notNil - and: [(previousElement := each previousElement) notNil]) - ifTrue: [ + allElementsDo: [ :each | + | parent oldName oldLocalName previousElement | + ((parent := each parent) notNil and: [ + (previousElement := each previousElement) notNil ]) ifTrue: [ oldName := each name. oldLocalName := each localName. - + each name: previousElement name. - each name = oldName - ifFalse: [ + each name = oldName ifFalse: [ self - deny: ((parent elementAt: oldName) = each); - deny: ((parent elementsAt: oldName) includes: each)]. - each localName = oldLocalName - ifFalse: [ - self - deny: ((parent elementAt: oldLocalName) = each); - deny: ((parent elementsAt: oldLocalName) includes: each)]. + deny: (parent elementAt: oldName) equals: each; + deny: ((parent elementsAt: oldName) includes: each) ]. + each localName = oldLocalName ifFalse: [ + self + deny: (parent elementAt: oldLocalName) equals: each; + deny: ((parent elementsAt: oldLocalName) includes: each) ]. self - assert: ((parent elementsAt: each name) before: each) = previousElement; - assert: ((parent elementsAt: each localName) before: each) = previousElement]]. + assert: ((parent elementsAt: each name) before: each) + equals: previousElement; + assert: ((parent elementsAt: each localName) before: each) + equals: previousElement ] ] ] { #category : #tests } @@ -1368,46 +1383,38 @@ XMLNodeWithElementsTest >> testElementsCollect [ { #category : #tests } XMLNodeWithElementsTest >> testElementsDetect [ - | root element | + | root element | root := self newNodeWithElements firstElement. - element := - root elementsDetect: [:each | - (each isNamed: 'four') - and: [each namespaceURI = 'testNS']]. + element := root elementsDetect: [ :each | + (each isNamed: 'four') and: [ + each namespaceURI = 'testNS' ] ]. self deny: element isNil. - self assert: - element = - (root elements detect: [:each | - (each isNamed: 'four') - and: [each namespaceURI = 'testNS']]). - self assert: - (root elementsDetect: [:each | - (each isNamed: 'four') - and: [each namespaceURI = 'absentNS']]) isNil. + self assert: element equals: (root elements detect: [ :each | + (each isNamed: 'four') and: [ each namespaceURI = 'testNS' ] ]). + self assert: (root elementsDetect: [ :each | + (each isNamed: 'four') and: [ each namespaceURI = 'absentNS' ] ]) + isNil ] { #category : #tests } XMLNodeWithElementsTest >> testElementsDetectIfNone [ - | root | + | root | root := self newNodeWithElements firstElement. - self assert: - (root - elementsDetect: [:each | - (each isNamed: 'four') - and: [each namespaceURI = 'testNS']] - ifNone: [self fail]) = - (root elements - detect: [:each | - (each isNamed: 'four') - and: [each namespaceURI = 'testNS']]). - self assert: - (root - elementsDetect: [:each | - (each isNamed: 'four') - and: [each namespaceURI = 'absentNS']] - ifNone: [#absent]) = #absent. + self + assert: (root + elementsDetect: [ :each | + (each isNamed: 'four') and: [ each namespaceURI = 'testNS' ] ] + ifNone: [ self fail ]) + equals: (root elements detect: [ :each | + (each isNamed: 'four') and: [ each namespaceURI = 'testNS' ] ]). + self + assert: (root + elementsDetect: [ :each | + (each isNamed: 'four') and: [ each namespaceURI = 'absentNS' ] ] + ifNone: [ #absent ]) + equals: #absent ] { #category : #tests } @@ -1440,92 +1447,106 @@ XMLNodeWithElementsTest >> testElementsSelect [ { #category : #tests } XMLNodeWithElementsTest >> testFindElementNamed [ - | nodeWithElements allElements foundElement | + | nodeWithElements allElements foundElement | nodeWithElements := self newNodeWithElements. allElements := nodeWithElements allElements. foundElement := nodeWithElements findElementNamed: 'four'. self assert: foundElement notNil; assert: (foundElement isNamed: 'four'); - assert: foundElement == (allElements detect: [:each | each isNamed: 'four']); - assert: (foundElement findElementNamed: 'four') == foundElement; - assert: (nodeWithElements findElementNamed: 'absent') isNil. + assert: foundElement + identicalTo: (allElements detect: [ :each | each isNamed: 'four' ]); + assert: (foundElement findElementNamed: 'four') + identicalTo: foundElement; + assert: (nodeWithElements findElementNamed: 'absent') isNil ] { #category : #tests } XMLNodeWithElementsTest >> testFindElementNamedNamespaceURI [ - | nodeWithElements allElements foundElement | + | nodeWithElements allElements foundElement | nodeWithElements := self newNodeWithElements. allElements := nodeWithElements allElements. - foundElement := nodeWithElements findElementNamed: 'four' namespaceURI: 'testNS'. + foundElement := nodeWithElements + findElementNamed: 'four' + namespaceURI: 'testNS'. self assert: foundElement notNil; assert: (foundElement isNamed: 'four'). - self assert: - foundElement == - (allElements detect: [:each | - (each isNamed: 'four') and: [each namespaceURI = 'testNS']]). self - assert: (foundElement findElementNamed: 'four' namespaceURI: 'testNS') == foundElement; - assert: (nodeWithElements findElementNamed: 'four' namespaceURI: 'absentNS') isNil. + assert: foundElement + identicalTo: (allElements detect: [ :each | + (each isNamed: 'four') and: [ each namespaceURI = 'testNS' ] ]). + self + assert: + (foundElement findElementNamed: 'four' namespaceURI: 'testNS') + identicalTo: foundElement; + assert: + (nodeWithElements findElementNamed: 'four' namespaceURI: 'absentNS') + isNil ] { #category : #tests } XMLNodeWithElementsTest >> testFindElementNamedNamespaceURIWith [ - | nodeWithElements allElements foundElement | + | nodeWithElements allElements foundElement | nodeWithElements := self newNodeWithElements. allElements := nodeWithElements allElements. - foundElement := - nodeWithElements - findElementNamed: 'four' - namespaceURI: 'testNS' - with: [:each | each hasChildren]. + foundElement := nodeWithElements + findElementNamed: 'four' + namespaceURI: 'testNS' + with: [ :each | each hasChildren ]. self assert: foundElement notNil; assert: (foundElement isNamed: 'prefix:four'). - self assert: - foundElement == - (allElements detect: [:each | - (each isNamed: 'four') - and: [(each namespaceURI = 'testNS') - and: [each hasChildren]]]). - self assert: - (foundElement - findElementNamed: 'four' - namespaceURI: 'testNS' - with: [:each | each hasChildren]) == foundElement. - self assert: - (nodeWithElements - findElementNamed: 'four' - namespaceURI: 'testNS' - with: [:each | false]) isNil. + self + assert: foundElement + identicalTo: (allElements detect: [ :each | + (each isNamed: 'four') and: [ + each namespaceURI = 'testNS' and: [ each hasChildren ] ] ]). + self + assert: (foundElement + findElementNamed: 'four' + namespaceURI: 'testNS' + with: [ :each | each hasChildren ]) + identicalTo: foundElement. + self assert: (nodeWithElements + findElementNamed: 'four' + namespaceURI: 'testNS' + with: [ :each | false ]) isNil ] { #category : #tests } XMLNodeWithElementsTest >> testFindElementNamedWith [ - | nodeWithElements allElements foundElement | + | nodeWithElements allElements foundElement | nodeWithElements := self newNodeWithElements. allElements := nodeWithElements allElements. - foundElement := nodeWithElements findElementNamed: 'four' with: [:each | each hasChildren]. + foundElement := nodeWithElements + findElementNamed: 'four' + with: [ :each | each hasChildren ]. self assert: foundElement notNil; assert: (foundElement isNamed: 'four'). - self assert: - foundElement == - (allElements detect: [:each | (each isNamed: 'four') and: [each hasChildren]]). self - assert: (foundElement findElementNamed: 'four' with: [:each | each hasChildren]) == foundElement; - assert: (nodeWithElements findElementNamed: 'four' with: [:each | false]) isNil. + assert: foundElement + identicalTo: (allElements detect: [ :each | + (each isNamed: 'four') and: [ each hasChildren ] ]). + self + assert: (foundElement + findElementNamed: 'four' + with: [ :each | each hasChildren ]) + identicalTo: foundElement; + assert: + (nodeWithElements findElementNamed: 'four' with: [ :each | false ]) + isNil ] { #category : #tests } XMLNodeWithElementsTest >> testFindElementWithID [ - | dtd content contentWithUndeclaredAttribute document idElement xmlIDElement | + | dtd content contentWithUndeclaredAttribute document idElement xmlIDElement | dtd := ' > testFindElementWithID [ '. - #(true false) do: [:isValidating | - document := - XMLDOMParser - parse: - dtd, - (isValidating - ifTrue: [content] - ifFalse: [contentWithUndeclaredAttribute]) - usingNamespaces: true - validation: isValidating. + #( true false ) do: [ :isValidating | + document := XMLDOMParser + parse: dtd , (isValidating + ifTrue: [ content ] + ifFalse: [ contentWithUndeclaredAttribute ]) + usingNamespaces: true + validation: isValidating. idElement := document findElementNamed: 'c'. xmlIDElement := document findElementNamed: 'd'. self - assert: (document findElementWithID: 'one') = idElement; - assert: (idElement findElementWithID: 'one') = idElement; + assert: (document findElementWithID: 'one') equals: idElement; + assert: (idElement findElementWithID: 'one') equals: idElement; assert: (idElement nextElement findElementWithID: 'one') isNil; - assert: (document findElementWithID: 'two') = xmlIDElement; - assert: (xmlIDElement findElementWithID: 'two') = xmlIDElement; + assert: (document findElementWithID: 'two') equals: xmlIDElement; + assert: (xmlIDElement findElementWithID: 'two') + equals: xmlIDElement; assert: (xmlIDElement nextElement findElementWithID: 'two') isNil; assert: (document findElementWithID: 'three') isNil. @@ -1586,42 +1605,43 @@ XMLNodeWithElementsTest >> testFindElementWithID [ assert: (document findElementWithID: 'one') isNil; assert: (idElement findElementWithID: 'one') isNil; assert: (document findElementWithID: 'two') isNil; - "xml:id is always an ID attribute, even without a DTD declaring it" - assert: (xmlIDElement findElementWithID: 'two') = xmlIDElement]. - - #(true false) do: [:isValidating | - document := - XMLDOMParser - parse: contentWithUndeclaredAttribute - usingNamespaces: true - validation: isValidating. + assert: (xmlIDElement findElementWithID: 'two') + equals: xmlIDElement ]. + + #( true false ) do: [ :isValidating | + document := XMLDOMParser + parse: contentWithUndeclaredAttribute + usingNamespaces: true + validation: isValidating. xmlIDElement := document findElementNamed: 'd'. self assert: (document findElementWithID: 'one') isNil; - "xml:id is always an ID attribute, even without a DTD declaring it" - assert: (document findElementWithID: 'two') = xmlIDElement; - assert: (xmlIDElement findElementWithID: 'two') = xmlIDElement]. + assert: (document findElementWithID: 'two') equals: xmlIDElement; + assert: (xmlIDElement findElementWithID: 'two') + equals: xmlIDElement ] ] { #category : #tests } XMLNodeWithElementsTest >> testFirstElement [ - | root | + | root | root := self newNodeWithElements nodeAt: 2. - root elements copy do: [:each | - self assert: root firstElement = each. - root removeNode: each]. - self assert: root firstElement isNil. + root elements copy do: [ :each | + self assert: root firstElement equals: each. + root removeNode: each ]. + self assert: root firstElement isNil ] { #category : #tests } XMLNodeWithElementsTest >> testHasContentNodes [ - | nodeWithElements | + | nodeWithElements | nodeWithElements := self newNodeWithElements. self assert: nodeWithElements hasContentNodes. - nodeWithElements allElementsDo: [:element | - self assert: element hasContentNodes = element contentNodes notEmpty]. + nodeWithElements allElementsDo: [ :element | + self + assert: element hasContentNodes + equals: element contentNodes notEmpty ] ] { #category : #tests } @@ -1634,12 +1654,14 @@ XMLNodeWithElementsTest >> testHasElements [ { #category : #tests } XMLNodeWithElementsTest >> testHasStringNodes [ - | nodeWithElements | + | nodeWithElements | nodeWithElements := self newNodeWithElements. self deny: nodeWithElements hasStringNodes. - nodeWithElements allElementsDo: [:element | - self assert: element hasStringNodes = element stringNodes notEmpty]. + nodeWithElements allElementsDo: [ :element | + self + assert: element hasStringNodes + equals: element stringNodes notEmpty ] ] { #category : #tests } @@ -1656,65 +1678,60 @@ XMLNodeWithElementsTest >> testIncludesElement [ { #category : #tests } XMLNodeWithElementsTest >> testInnerXML [ - | node element | + | node element | node := self newNode. - element := - node addNode: - (self elementClass - name: 'test' - namespaces: (Array with: 'prefix'-> 'ns')). + element := node addNode: (self elementClass + name: 'test' + namespaces: (Array with: 'prefix' -> 'ns')). element innerXML: ''. element firstNode innerXML: 'test'. self - assert: element nodes size = 1; + assert: element nodes size equals: 1; assert: (element firstNode isNamed: 'prefix:inner'); - assert: (element firstNode contentString = 'test'); - assert: - node innerXML = - 'test'; - assert: - element innerXML = - 'test'; - assert: element firstNode innerXML = 'test'. + assert: element firstNode contentString equals: 'test'; + assert: node innerXML + equals: + 'test'; + assert: element innerXML + equals: 'test'; + assert: element firstNode innerXML equals: 'test' ] { #category : #tests } XMLNodeWithElementsTest >> testInnerXMLIsInContent [ - | node parser | + | node parser | node := self newNodeWithElements. parser := XMLDOMParser on: ''. self deny: parser isInContent. node innerXMLParsedWith: parser. self - assert: node nodes size = 1; + assert: node nodes size equals: 1; assert: (node firstNode isElementNamed: 'content'); deny: node firstNode hasChildren; - assert: parser isInContent. + assert: parser isInContent ] { #category : #tests } XMLNodeWithElementsTest >> testInnerXMLPrettyPrinted [ - | nodeWithElements printString prettyPrintString prettyNodeWithElements | + | nodeWithElements printString prettyPrintString prettyNodeWithElements | nodeWithElements := self newNodeWithElements. "remove any whitespace formatting around elements (avoid descendantNodesDo: because we're removing)" - nodeWithElements descendantNodes do: [:each | - (each isStringNode - and: [each isWhitespace]) - ifTrue: [each parent removeNode: each]]. + nodeWithElements descendantNodes do: [ :each | + (each isStringNode and: [ each isWhitespace ]) ifTrue: [ + each parent removeNode: each ] ]. printString := nodeWithElements innerXML. prettyPrintString := nodeWithElements innerXMLPrettyPrinted. - self deny: printString = prettyPrintString. + self deny: printString equals: prettyPrintString. - prettyNodeWithElements := - (XMLDOMParser on: prettyPrintString) - preservesCommentNodes: true; - parseDocument. + prettyNodeWithElements := (XMLDOMParser on: prettyPrintString) + preservesCommentNodes: true; + parseDocument. self assertElements: prettyNodeWithElements descendantElements werePrettyPrintFormattedFrom: nodeWithElements descendantElements @@ -1722,18 +1739,24 @@ XMLNodeWithElementsTest >> testInnerXMLPrettyPrinted [ { #category : #tests } XMLNodeWithElementsTest >> testInnerXMLResetting [ - | nodeWithElements | + | nodeWithElements | nodeWithElements := self newNodeWithElements. self - should: [nodeWithElements firstElement innerXML: ''] + should: [ + nodeWithElements firstElement innerXML: '' ] raise: XMLWellFormednessException. - self assert: nodeWithElements printString = self newNodeWithNodes printString. + self + assert: nodeWithElements printString + equals: self newNodeWithNodes printString. self - should: [nodeWithElements firstElement innerXML: '&invalid;'] + should: [ + nodeWithElements firstElement innerXML: '&invalid;' ] raise: XMLWellFormednessException. - self assert: nodeWithElements printString = self newNodeWithNodes printString. + self + assert: nodeWithElements printString + equals: self newNodeWithNodes printString ] { #category : #tests } @@ -1743,361 +1766,355 @@ XMLNodeWithElementsTest >> testIsContentNode [ { #category : #tests } XMLNodeWithElementsTest >> testLastElement [ - | root | + | root | root := self newNodeWithElements nodeAt: 2. - root elements reversed do: [:each | - self assert: root lastElement = each. - root removeNode: each]. - self assert: root lastElement isNil. + root elements reversed do: [ :each | + self assert: root lastElement equals: each. + root removeNode: each ]. + self assert: root lastElement isNil ] { #category : #tests } XMLNodeWithElementsTest >> testNewCData [ - | nodeWithElements cdata | + | nodeWithElements cdata | super testNewCData. - (nodeWithElements := self newNode) - nodeFactory: - (XMLPluggableNodeFactory new - cdataClass: XMLFCData). + (nodeWithElements := self newNode) nodeFactory: + (XMLPluggableNodeFactory new cdataClass: XMLFCData). cdata := nodeWithElements newCData: 'test'. self - assert: cdata class == XMLFCData; - assert: cdata string = 'test'. + assert: cdata class identicalTo: XMLFCData; + assert: cdata string equals: 'test' ] { #category : #tests } XMLNodeWithElementsTest >> testNewComment [ - | nodeWithElements comment | + | nodeWithElements comment | super testNewComment. - (nodeWithElements := self newNode) - nodeFactory: - (XMLPluggableNodeFactory new - commentClass: XMLFComment). + (nodeWithElements := self newNode) nodeFactory: + (XMLPluggableNodeFactory new commentClass: XMLFComment). comment := nodeWithElements newComment: 'test'. self - assert: comment class == XMLFComment; - assert: comment string = 'test'. + assert: comment class identicalTo: XMLFComment; + assert: comment string equals: 'test' ] { #category : #tests } XMLNodeWithElementsTest >> testNewDocument [ - | nodeWithElements document | + | nodeWithElements document | super testNewDocument. - (nodeWithElements := self newNode) - nodeFactory: - (XMLPluggableNodeFactory new - documentClass: XMLFDocument). + (nodeWithElements := self newNode) nodeFactory: + (XMLPluggableNodeFactory new documentClass: XMLFDocument). document := nodeWithElements newDocument. self - assert: document class == XMLFDocument; - assert: document configuration == nodeWithElements configuration; - assert: document nodeFactory == nodeWithElements nodeFactory. + assert: document class identicalTo: XMLFDocument; + assert: document configuration + identicalTo: nodeWithElements configuration; + assert: document nodeFactory + identicalTo: nodeWithElements nodeFactory ] { #category : #tests } XMLNodeWithElementsTest >> testNewElement [ - | nodeWithElements element | + | nodeWithElements element | super testNewElement. - (nodeWithElements := self newNode) - nodeFactory: - (XMLPluggableNodeFactory new - elementClass: self otherElementClass). + (nodeWithElements := self newNode) nodeFactory: + (XMLPluggableNodeFactory new elementClass: self otherElementClass). element := nodeWithElements newElement. self - assert: element class == self otherElementClass; - assert: element configuration == nodeWithElements configuration; - assert: element nodeFactory == nodeWithElements nodeFactory. + assert: element class identicalTo: self otherElementClass; + assert: element configuration + identicalTo: nodeWithElements configuration; + assert: element nodeFactory + identicalTo: nodeWithElements nodeFactory ] { #category : #tests } XMLNodeWithElementsTest >> testNewElementNamed [ - | nodeWithElements element | + | nodeWithElements element | super testNewElementNamed. - (nodeWithElements := self newNode) - nodeFactory: - (XMLPluggableElementFactory new - handleElement: 'test' withClass: self otherElementClass). + (nodeWithElements := self newNode) nodeFactory: + (XMLPluggableElementFactory new + handleElement: 'test' + withClass: self otherElementClass). element := nodeWithElements newElementNamed: 'test'. self - assert: element class == self otherElementClass; - assert: element name = 'test'; - assert: element configuration == nodeWithElements configuration; - assert: element nodeFactory == nodeWithElements nodeFactory. + assert: element class identicalTo: self otherElementClass; + assert: element name equals: 'test'; + assert: element configuration + identicalTo: nodeWithElements configuration; + assert: element nodeFactory + identicalTo: nodeWithElements nodeFactory ] { #category : #tests } XMLNodeWithElementsTest >> testNewElementNamedAttributes [ - | nodeWithElements element | + | nodeWithElements element | super testNewElementNamedAttributes. - (nodeWithElements := self newNode) - nodeFactory: - (XMLPluggableElementFactory new - handleElement: 'test' - attributes: self unprefixedAttributeAssociations - withClass: self otherElementClass; - attributeListClass: self otherAttributeListClass). - element := - nodeWithElements - newElementNamed: 'test' - attributes: self unprefixedAttributeAssociations. - self - assert: element class == self otherElementClass; - assert: element name = 'test'; - assert: element attributeNodes class == self otherAttributeListClass; + (nodeWithElements := self newNode) nodeFactory: + (XMLPluggableElementFactory new + handleElement: 'test' + attributes: self unprefixedAttributeAssociations + withClass: self otherElementClass; + attributeListClass: self otherAttributeListClass). + element := nodeWithElements + newElementNamed: 'test' + attributes: self unprefixedAttributeAssociations. + self + assert: element class identicalTo: self otherElementClass; + assert: element name equals: 'test'; + assert: element attributeNodes class + identicalTo: self otherAttributeListClass; assertElement: element hasAttributes: self unprefixedAttributes; - assert: element configuration == nodeWithElements configuration; - assert: element nodeFactory == nodeWithElements nodeFactory. + assert: element configuration + identicalTo: nodeWithElements configuration; + assert: element nodeFactory + identicalTo: nodeWithElements nodeFactory ] { #category : #tests } XMLNodeWithElementsTest >> testNewElementNamedNamespaceURI [ - | nodeWithElements element | + | nodeWithElements element | super testNewElementNamedNamespaceURI. - (nodeWithElements := self newNode) - nodeFactory: - (XMLPluggableElementFactory new - handleElement: 'prefix:test' - namespaceURI: 'prefixNS' - withClass: self otherElementClass). - element := - nodeWithElements - newElementNamed: 'prefix:test' - namespaceURI: 'prefixNS'. + (nodeWithElements := self newNode) nodeFactory: + (XMLPluggableElementFactory new + handleElement: 'prefix:test' + namespaceURI: 'prefixNS' + withClass: self otherElementClass). + element := nodeWithElements + newElementNamed: 'prefix:test' + namespaceURI: 'prefixNS'. self - assert: element class == self otherElementClass; - assert: element name = 'prefix:test'; - assert: element namespaceURI = 'prefixNS'; - assert: element configuration == nodeWithElements configuration; - assert: element nodeFactory == nodeWithElements nodeFactory. + assert: element class identicalTo: self otherElementClass; + assert: element name equals: 'prefix:test'; + assert: element namespaceURI equals: 'prefixNS'; + assert: element configuration + identicalTo: nodeWithElements configuration; + assert: element nodeFactory + identicalTo: nodeWithElements nodeFactory ] { #category : #tests } XMLNodeWithElementsTest >> testNewElementNamedNamespaceURIAttributes [ - | nodeWithElements element | + | nodeWithElements element | super testNewElementNamedNamespaceURIAttributes. - (nodeWithElements := self newNode) - nodeFactory: - (XMLPluggableElementFactory new - handleElement: 'prefix:test' - namespaceURI: 'prefixNS' - attributes: self attributeAssociations - withClass: self otherElementClass; - attributeListClass: self otherAttributeListClass). - element := - nodeWithElements - newElementNamed: 'prefix:test' - namespaceURI: 'prefixNS' - attributes: self attributeAssociations. - self - assert: element class == self otherElementClass; - assert: element name = 'prefix:test'; - assert: element namespaceURI = 'prefixNS'; - assert: element attributeNodes class == self otherAttributeListClass; + (nodeWithElements := self newNode) nodeFactory: + (XMLPluggableElementFactory new + handleElement: 'prefix:test' + namespaceURI: 'prefixNS' + attributes: self attributeAssociations + withClass: self otherElementClass; + attributeListClass: self otherAttributeListClass). + element := nodeWithElements + newElementNamed: 'prefix:test' + namespaceURI: 'prefixNS' + attributes: self attributeAssociations. + self + assert: element class identicalTo: self otherElementClass; + assert: element name equals: 'prefix:test'; + assert: element namespaceURI equals: 'prefixNS'; + assert: element attributeNodes class + identicalTo: self otherAttributeListClass; assertElement: element hasAttributes: self attributes; - assert: element configuration == nodeWithElements configuration; - assert: element nodeFactory == nodeWithElements nodeFactory. + assert: element configuration + identicalTo: nodeWithElements configuration; + assert: element nodeFactory + identicalTo: nodeWithElements nodeFactory ] { #category : #tests } XMLNodeWithElementsTest >> testNewPI [ - | nodeWithElements | + | nodeWithElements | super testNewPI. - (nodeWithElements := self newNode) - nodeFactory: - (XMLPluggableNodeFactory new - piClass: XMLFPI). - self assert: nodeWithElements newPI class == XMLFPI. + (nodeWithElements := self newNode) nodeFactory: + (XMLPluggableNodeFactory new piClass: XMLFPI). + self assert: nodeWithElements newPI class identicalTo: XMLFPI ] { #category : #tests } XMLNodeWithElementsTest >> testNewPITargetData [ - | nodeWithElements pi | + | nodeWithElements pi | super testNewPITargetData. - (nodeWithElements := self newNode) - nodeFactory: - (XMLPluggableNodeFactory new - piClass: XMLFPI). - pi := - nodeWithElements - newPITarget: 'target' - data: 'data'. + (nodeWithElements := self newNode) nodeFactory: + (XMLPluggableNodeFactory new piClass: XMLFPI). + pi := nodeWithElements newPITarget: 'target' data: 'data'. self - assert: pi class == XMLFPI; - assert: pi target = 'target'; - assert: pi data = 'data'. + assert: pi class identicalTo: XMLFPI; + assert: pi target equals: 'target'; + assert: pi data equals: 'data' ] { #category : #tests } XMLNodeWithElementsTest >> testNewStringNode [ - | nodeWithElements stringNode | + | nodeWithElements stringNode | super testNewStringNode. - (nodeWithElements := self newNode) - nodeFactory: - (XMLPluggableNodeFactory new - stringNodeClass: XMLFString). + (nodeWithElements := self newNode) nodeFactory: + (XMLPluggableNodeFactory new stringNodeClass: XMLFString). stringNode := nodeWithElements newStringNode: 'test'. self - assert: stringNode class == XMLFString; - assert: stringNode string = 'test'. + assert: stringNode class identicalTo: XMLFString; + assert: stringNode string equals: 'test' ] { #category : #tests } XMLNodeWithElementsTest >> testNodeFactory [ - | nodeWithElements oldNodeFactory newNodeFactory | + | nodeWithElements oldNodeFactory newNodeFactory | nodeWithElements := self newNodeWithElements. oldNodeFactory := nodeWithElements nodeFactory. - self assert: oldNodeFactory class == self nodeFactoryClass. + self assert: oldNodeFactory class identicalTo: self nodeFactoryClass. newNodeFactory := self nodeFactoryClass new. self - assert: (nodeWithElements nodeFactory: newNodeFactory) == nodeWithElements; - assert: nodeWithElements nodeFactory == newNodeFactory. + assert: (nodeWithElements nodeFactory: newNodeFactory) + identicalTo: nodeWithElements; + assert: nodeWithElements nodeFactory identicalTo: newNodeFactory ] { #category : #tests } XMLNodeWithElementsTest >> testOuterXMLForNode [ - | nodeWithElements root nodes | + | nodeWithElements root nodes | nodeWithElements := self newNodeWithElements. root := nodeWithElements firstElement. nodes := root nodes copy. - nodes copy withIndexDo: [:each :i | | innerXML newNode | - innerXML := 'test'. + nodes copy withIndexDo: [ :each :i | + | innerXML newNode | + innerXML := 'test'. root outerXML: innerXML forNode: each. newNode := root nodeAt: i. self - assert: newNode printString = innerXML; - deny: root nodes = nodes. + assert: newNode printString equals: innerXML; + deny: root nodes equals: nodes. nodes at: i put: newNode. - self assert: root nodes = nodes]. + self assert: root nodes equals: nodes ]. - nodes copy do: [:each | + nodes copy do: [ :each | root outerXML: '' forNode: each. - self deny: root nodes = nodes. + self deny: root nodes equals: nodes. nodes remove: each. - self assert: root nodes = nodes]. + self assert: root nodes equals: nodes ] ] { #category : #tests } XMLNodeWithElementsTest >> testOuterXMLForNodeResetting [ - | nodeWithElements root | + | nodeWithElements root | nodeWithElements := self newNodeWithElements. root := nodeWithElements firstElement. self should: [ - root - outerXML: '' - forNode: root firstNode] + root outerXML: '' forNode: root firstNode ] raise: XMLWellFormednessException. - self assert: nodeWithElements printString = self newNodeWithNodes printString. + self + assert: nodeWithElements printString + equals: self newNodeWithNodes printString. self should: [ - root - outerXML: '&invalid;' - forNode: root firstNode] + root outerXML: '&invalid;' forNode: root firstNode ] raise: XMLWellFormednessException. - self assert: nodeWithElements printString = self newNodeWithNodes printString. + self + assert: nodeWithElements printString + equals: self newNodeWithNodes printString. self - should: [ - root - outerXML: '' - forNode: self nodeClass new] + should: [ root outerXML: '' forNode: self nodeClass new ] raise: XMLDOMException. - self assert: nodeWithElements printString = self newNodeWithNodes printString. + self + assert: nodeWithElements printString + equals: self newNodeWithNodes printString ] { #category : #tests } XMLNodeWithElementsTest >> testPrettyPrinted [ - | nodeWithElements printString prettyPrintString prettyNodeWithElements | + | nodeWithElements printString prettyPrintString prettyNodeWithElements | nodeWithElements := self newNodeWithElements. "remove any whitespace formatting around elements (avoid #allNodesDo: because we're removing)" - nodeWithElements allNodes do: [:each | - (each isStringNode - and: [each isWhitespace]) - ifTrue: [each parent removeNode: each]]. + nodeWithElements allNodes do: [ :each | + (each isStringNode and: [ each isWhitespace ]) ifTrue: [ + each parent removeNode: each ] ]. printString := nodeWithElements printString. prettyPrintString := nodeWithElements prettyPrinted. - self deny: printString = prettyPrintString. + self deny: printString equals: prettyPrintString. - prettyNodeWithElements := - (XMLDOMParser on: prettyPrintString) - preservesCommentNodes: true; - parseDocument. + prettyNodeWithElements := (XMLDOMParser on: prettyPrintString) + preservesCommentNodes: true; + parseDocument. self assertElements: prettyNodeWithElements allElements - werePrettyPrintFormattedFrom: nodeWithElements allElements. + werePrettyPrintFormattedFrom: nodeWithElements allElements ] { #category : #tests } XMLNodeWithElementsTest >> testPrintedWithoutSelfClosingTags [ - | nodeWithElements printString printStringWithoutSelfClosingTags | + | nodeWithElements printString printStringWithoutSelfClosingTags | nodeWithElements := self newNodeWithElements. printString := nodeWithElements printString. - printStringWithoutSelfClosingTags := nodeWithElements printedWithoutSelfClosingTags. - self deny: printString = printStringWithoutSelfClosingTags. + printStringWithoutSelfClosingTags := nodeWithElements + printedWithoutSelfClosingTags. + self deny: printString equals: printStringWithoutSelfClosingTags. - nodeWithElements allElementsDo: [:each | - each hasChildren - ifFalse: [ - printString := - printString - copyReplaceAll: '<', each name, '/>' - with: '<', each name, '>']]. - self assert: printString = printStringWithoutSelfClosingTags. + nodeWithElements allElementsDo: [ :each | + each hasChildren ifFalse: [ + printString := printString + copyReplaceAll: '<' , each name , '/>' + with: '<' , each name , '>' ] ]. + self assert: printString equals: printStringWithoutSelfClosingTags ] { #category : #tests } XMLNodeWithElementsTest >> testRawContentString [ - self assert: self newNodeWithElements rawContentString = 'testing onetesting twotesting three' + + self + assert: self newNodeWithElements rawContentString + equals: 'testing onetesting twotesting three' ] { #category : #tests } XMLNodeWithElementsTest >> testRawContentStringAt [ - | root | + | root | root := self newNodeWithElements firstElement. - root elementsDo: [:each | - self assert: (root rawContentStringAt: each name) = each rawContentString]. + root elementsDo: [ :each | + self + assert: (root rawContentStringAt: each name) + equals: each rawContentString ] ] { #category : #tests } XMLNodeWithElementsTest >> testRemoveAllFormattingNodes [ - | nodeWithElements nonFormattingStringNodes | + | nodeWithElements nonFormattingStringNodes | nodeWithElements := self newNode. - nodeWithElements innerXML: - ' + nodeWithElements innerXML: ' @@ -2114,18 +2131,17 @@ XMLNodeWithElementsTest >> testRemoveAllFormattingNodes [ four '. - nonFormattingStringNodes := - nodeWithElements allNodesSelect: [:node | - node isStringNode - and: [ - node ancestorElements anySatisfy: [:each | - each isNamed: 'non-formatting']]]. - - self - assert: nodeWithElements removeAllFormattingNodes == nodeWithElements; + nonFormattingStringNodes := nodeWithElements allNodesSelect: [ :node | + node isStringNode and: [ + node ancestorElements anySatisfy: [ + :each | + each isNamed: 'non-formatting' ] ] ]. + self + assert: nodeWithElements removeAllFormattingNodes + identicalTo: nodeWithElements; assert: - (nodeWithElements allNodesSelect: [ :each | each isStringNode]) = - nonFormattingStringNodes. + (nodeWithElements allNodesSelect: [ :each | each isStringNode ]) + equals: nonFormattingStringNodes ] { #category : #tests } @@ -2186,30 +2202,30 @@ XMLNodeWithElementsTest >> testStringsDo [ { #category : #tests } XMLNodeWithElementsTest >> testUsesNamespaces [ - | nodeWithElements | + | nodeWithElements | nodeWithElements := self newNodeWithElements. self assert: nodeWithElements usesNamespaces. - nodeWithElements allElementsDo: [:each | - self assert: each usesNamespaces]. - + nodeWithElements allElementsDo: [ :each | + self assert: each usesNamespaces ]. self - assert: (nodeWithElements usesNamespaces: false) == nodeWithElements; + assert: (nodeWithElements usesNamespaces: false) + identicalTo: nodeWithElements; deny: nodeWithElements usesNamespaces. - nodeWithElements allElementsDo: [:each | + nodeWithElements allElementsDo: [ :each | self deny: each usesNamespaces. self - shouldnt: [each prefix: 'undeclared'] - raise: XMLNamespaceException]. - + shouldnt: [ each prefix: 'undeclared' ] + raise: XMLNamespaceException ]. self - assert: (nodeWithElements usesNamespaces: true) == nodeWithElements; + assert: (nodeWithElements usesNamespaces: true) + identicalTo: nodeWithElements; assert: nodeWithElements usesNamespaces. - nodeWithElements allElementsDo: [:each | + nodeWithElements allElementsDo: [ :each | self assert: each usesNamespaces. self - should: [each prefix: 'undeclaredTwo'] - raise: XMLNamespaceException]. + should: [ each prefix: 'undeclaredTwo' ] + raise: XMLNamespaceException ] ] { #category : #tests } diff --git a/src/XML-Parser-Tests/XMLNotationDeclarationTest.class.st b/src/XML-Parser-Tests/XMLNotationDeclarationTest.class.st index cbe33d53..48c19fcd 100644 --- a/src/XML-Parser-Tests/XMLNotationDeclarationTest.class.st +++ b/src/XML-Parser-Tests/XMLNotationDeclarationTest.class.st @@ -16,62 +16,68 @@ XMLNotationDeclarationTest >> nodeClass [ { #category : #tests } XMLNotationDeclarationTest >> testName [ - | declaration | + | declaration | declaration := self newNode. self - assert: declaration name = ''; - assert: (declaration name: 'test') == declaration; - assert: declaration name = 'test' + assert: declaration name equals: ''; + assert: (declaration name: 'test') identicalTo: declaration; + assert: declaration name equals: 'test' ] { #category : #tests } XMLNotationDeclarationTest >> testNamePublicIDSystemID [ - | declaration | - declaration := - self nodeClass - name: 'one' - publicID: 'two' - systemID: 'three'. + | declaration | + declaration := self nodeClass + name: 'one' + publicID: 'two' + systemID: 'three'. self - assert: declaration class == self nodeClass; - assert: declaration name = 'one'; - assert: declaration publicID = 'two'; - assert: declaration systemID = 'three' + assert: declaration class identicalTo: self nodeClass; + assert: declaration name equals: 'one'; + assert: declaration publicID equals: 'two'; + assert: declaration systemID equals: 'three' ] { #category : #tests } XMLNotationDeclarationTest >> testPublicID [ - | declaration | + | declaration | declaration := self newNode. self - assert: declaration publicID = ''; - assert: (declaration publicID: 'test') == declaration; - assert: declaration publicID = 'test' + assert: declaration publicID equals: ''; + assert: (declaration publicID: 'test') identicalTo: declaration; + assert: declaration publicID equals: 'test' ] { #category : #tests } XMLNotationDeclarationTest >> testSystemID [ - | declaration | + | declaration | declaration := self newNode. self - assert: declaration systemID = ''; - assert: (declaration systemID: 'test') == declaration; - assert: declaration systemID = 'test' + assert: declaration systemID equals: ''; + assert: (declaration systemID: 'test') identicalTo: declaration; + assert: declaration systemID equals: 'test' ] { #category : #tests } XMLNotationDeclarationTest >> testWriteXMLOn [ - self assert: - (self nodeClass name: 'one' publicID: 'two' systemID: 'three') printString = - ''. - self assert: - (self nodeClass name: 'one' publicID: '' systemID: 'two') printString = - ''. - self assert: - (self nodeClass name: 'one' publicID: 'two' systemID: '') printString = - '' + + self + assert: + (self nodeClass name: 'one' publicID: 'two' systemID: 'three') + printString + equals: ''. + self + assert: + (self nodeClass name: 'one' publicID: '' systemID: 'two') + printString + equals: ''. + self + assert: + (self nodeClass name: 'one' publicID: 'two' systemID: '') + printString + equals: '' ] diff --git a/src/XML-Parser-Tests/XMLNullReadStreamTest.class.st b/src/XML-Parser-Tests/XMLNullReadStreamTest.class.st index e5bf1c6a..1dbafd46 100644 --- a/src/XML-Parser-Tests/XMLNullReadStreamTest.class.st +++ b/src/XML-Parser-Tests/XMLNullReadStreamTest.class.st @@ -21,5 +21,6 @@ XMLNullReadStreamTest >> streamClass [ { #category : #tests } XMLNullReadStreamTest >> testNew [ - self assert: self streamClass new class == self streamClass + + self assert: self streamClass new class identicalTo: self streamClass ] diff --git a/src/XML-Parser-Tests/XMLObservableListTest.class.st b/src/XML-Parser-Tests/XMLObservableListTest.class.st index 42841ff2..b6a9e588 100644 --- a/src/XML-Parser-Tests/XMLObservableListTest.class.st +++ b/src/XML-Parser-Tests/XMLObservableListTest.class.st @@ -77,14 +77,15 @@ XMLObservableListTest >> assertList: aList receivedNotificationOfReplacing: anOl { #category : #assertions } XMLObservableListTest >> assertNotification: aNotification for: anObject withList: aList hasType: aSelectorCollection [ + self assert: aNotification notNil; assert: (aSelectorCollection includes: aNotification selector). - self assert: - aNotification arguments = - ((Array with: anObject with: aList) - copyFrom: 1 - to: (aNotification selector asString occurrencesOf: $:)) + self + assert: aNotification arguments + equals: ((Array with: anObject with: aList) + copyFrom: 1 + to: (aNotification selector asString occurrencesOf: $:)) ] { #category : #assertions } @@ -423,23 +424,21 @@ XMLObservableListTest >> testRemoveFirstFew [ { #category : #tests } XMLObservableListTest >> testRemoveIfAbsent [ - | list | + | list | super testRemoveIfAbsent. list := self listWithItems. self should: [ - list - remove: self singleListItem - ifAbsent: [self absentListItem]] + list remove: self singleListItem ifAbsent: [ self absentListItem ] ] remove: self singleListItem fromAndNotify: list. - self assert: - (list - remove: self singleListItem - ifAbsent: [self absentListItem]) = self absentListItem. - self deny: list observer hasNotifications. + self + assert: + (list remove: self singleListItem ifAbsent: [ self absentListItem ]) + equals: self absentListItem. + self deny: list observer hasNotifications ] { #category : #tests } diff --git a/src/XML-Parser-Tests/XMLOrderedListTest.class.st b/src/XML-Parser-Tests/XMLOrderedListTest.class.st index 495deec1..38d68240 100644 --- a/src/XML-Parser-Tests/XMLOrderedListTest.class.st +++ b/src/XML-Parser-Tests/XMLOrderedListTest.class.st @@ -16,56 +16,63 @@ XMLOrderedListTest >> allowsDuplicates [ { #category : #assertions } XMLOrderedListTest >> assertList: aList collectedFrom: aSecondList equals: aThirdList [ + self - assert: aList = aThirdList; - assert: aList class = aSecondList species; - deny: aList == aSecondList; - deny: aList collection == aSecondList collection + assert: aList equals: aThirdList; + assert: aList class equals: aSecondList species; + deny: aList identicalTo: aSecondList; + deny: aList collection identicalTo: aSecondList collection ] { #category : #assertions } XMLOrderedListTest >> assertList: aList copiedFrom: aSecondList equals: aThirdList [ + self - assert: aList = aThirdList; - assert: aList class == self listCopyClass; - assert: aList collection class == aSecondList collection class; - deny: aList == aSecondList; - deny: aList collection == aSecondList collection + assert: aList equals: aThirdList; + assert: aList class identicalTo: self listCopyClass; + assert: aList collection class + identicalTo: aSecondList collection class; + deny: aList identicalTo: aSecondList; + deny: aList collection identicalTo: aSecondList collection ] { #category : #assertions } XMLOrderedListTest >> assertList: aFirstList equals: aSecondList [ + self - assert: aFirstList = aFirstList; - assert: aSecondList = aSecondList; - assert: aFirstList = aSecondList; - assert: aSecondList = aFirstList + assert: aFirstList equals: aFirstList; + assert: aSecondList equals: aSecondList; + assert: aFirstList equals: aSecondList; + assert: aSecondList equals: aFirstList ] { #category : #assertions } XMLOrderedListTest >> assertList: aList isCopyOf: aSecondList [ + self - assert: aList = aSecondList; - assert: aList class == self listCopyClass; - assert: aList collection class == aSecondList collection class; - assert: aList collection = aSecondList collection; - deny: aList == aSecondList; - deny: aList collection == aSecondList collection + assert: aList equals: aSecondList; + assert: aList class identicalTo: self listCopyClass; + assert: aList collection class + identicalTo: aSecondList collection class; + assert: aList collection equals: aSecondList collection; + deny: aList identicalTo: aSecondList; + deny: aList collection identicalTo: aSecondList collection ] { #category : #assertions } XMLOrderedListTest >> assertList: aList replacedItems: anOldItemCollection withItems: aNewItemCollection from: aStart to: aStop [ "items before aStart should not have been replaced" - 1 to: aStart - 1 do: [:i | - self assert: (aList at: i) = (anOldItemCollection at: i)]. + + 1 to: aStart - 1 do: [ :i | + self assert: (aList at: i) equals: (anOldItemCollection at: i) ]. "items within the range should be replaced" - aStart to: aStop do: [:i | - self assert: (aList at: i) = (aNewItemCollection at: i)]. + aStart to: aStop do: [ :i | + self assert: (aList at: i) equals: (aNewItemCollection at: i) ]. "items after aStop should not have been replaced" - aStop + 1 to: aList size do: [:i | - self assert: (aList at: i) = (anOldItemCollection at: i)] + aStop + 1 to: aList size do: [ :i | + self assert: (aList at: i) equals: (anOldItemCollection at: i) ] ] { #category : #accessing } @@ -114,9 +121,10 @@ XMLOrderedListTest >> defaultValue [ { #category : #assertions } XMLOrderedListTest >> denyList: aFirstList equals: aSecondList [ + self - deny: aFirstList = aSecondList; - deny: aSecondList = aFirstList + deny: aFirstList equals: aSecondList; + deny: aSecondList equals: aFirstList ] { #category : #accessing } @@ -206,187 +214,202 @@ XMLOrderedListTest >> sortBlock [ { #category : #tests } XMLOrderedListTest >> testAdd [ - | list | + | list | list := self emptyList. self - deny: list = self listWithItems; - assert: (self listItems allSatisfy: [:each | (list add: each) == each]); - assert: (list = self listWithItems). + deny: list equals: self listWithItems; + assert: + (self listItems allSatisfy: [ :each | (list add: each) == each ]); + assert: list equals: self listWithItems ] { #category : #tests } XMLOrderedListTest >> testAddAfter [ - | list | + | list | list := self listWithSingleItem. self - assert: - (self listItems allButFirst reversed - allSatisfy: [:each | (list add: each after: self singleListItem) = each]); - assert: list = self listWithItems; - should: [list add: self newListItem after: self absentListItem] raise: Error. + assert: (self listItems allButFirst reversed allSatisfy: [ :each | + (list add: each after: self singleListItem) = each ]); + assert: list equals: self listWithItems; + should: [ list add: self newListItem after: self absentListItem ] + raise: Error ] { #category : #tests } XMLOrderedListTest >> testAddAfterIndex [ - | list | + | list | list := self listWithSingleItem. self - assert: - (self listItems allButFirst reversed - allSatisfy: [:each | (list add: each afterIndex: 1) = each]); - assert: list = self listWithItems; - should: [list add: self newListItem afterIndex: self listItems size + 1] raise: Error; - should: [list add: self newListItem afterIndex: -1] raise: Error. + assert: (self listItems allButFirst reversed allSatisfy: [ :each | + (list add: each afterIndex: 1) = each ]); + assert: list equals: self listWithItems; + should: [ + list add: self newListItem afterIndex: self listItems size + 1 ] + raise: Error; + should: [ list add: self newListItem afterIndex: -1 ] raise: Error ] { #category : #tests } XMLOrderedListTest >> testAddAll [ - | list | + | list | list := self emptyList. self - deny: list = self listWithItems; - assert: (list addAll: self listItems) = self listItems; - assert: list = self listWithItems; - assert: (list addAll: self changedListItems) = self changedListItems; - assert: list = (self listClass newFrom: (self listItems, self changedListItems)). + deny: list equals: self listWithItems; + assert: (list addAll: self listItems) equals: self listItems; + assert: list equals: self listWithItems; + assert: (list addAll: self changedListItems) + equals: self changedListItems; + assert: list + equals: + (self listClass newFrom: self listItems , self changedListItems) ] { #category : #tests } XMLOrderedListTest >> testAddAllFirst [ - | list | + | list | list := self emptyList. self - assert: (list addAllFirst: self listItems) = self listItems; - assert: list = self listWithItems; - assert: (list addAllFirst: self changedListItems) = self changedListItems; - assert: list = (self listClass newFrom: self changedListItems, self listItems). + assert: (list addAllFirst: self listItems) equals: self listItems; + assert: list equals: self listWithItems; + assert: (list addAllFirst: self changedListItems) + equals: self changedListItems; + assert: list + equals: + (self listClass newFrom: self changedListItems , self listItems) ] { #category : #tests } XMLOrderedListTest >> testAddAllLast [ - | list | + | list | list := self emptyList. self - assert: (list addAllLast: self listItems) = self listItems; - assert: list = self listWithItems; - assert: (list addAllLast: self changedListItems) = self changedListItems; - assert: list = (self listClass newFrom: self listItems, self changedListItems). + assert: (list addAllLast: self listItems) equals: self listItems; + assert: list equals: self listWithItems; + assert: (list addAllLast: self changedListItems) + equals: self changedListItems; + assert: list + equals: + (self listClass newFrom: self listItems , self changedListItems) ] { #category : #tests } XMLOrderedListTest >> testAddBefore [ - | list last | + | list last | last := self listItems last. (list := self emptyList) add: last. self - assert: - (self listItems allButLast - allSatisfy: [:each | (list add: each before: last) = each]); - assert: list = self listWithItems; - should: [list add: self newListItem before: self absentListItem] raise: Error. + assert: (self listItems allButLast allSatisfy: [ :each | + (list add: each before: last) = each ]); + assert: list equals: self listWithItems; + should: [ list add: self newListItem before: self absentListItem ] + raise: Error ] { #category : #tests } XMLOrderedListTest >> testAddBeforeIndex [ - | list | + | list | (list := self emptyList) add: self listItems last. - self listItems allButLast withIndexDo: [:each :i | - self assert: (list add: each beforeIndex: i) = each]. + self listItems allButLast withIndexDo: [ :each :i | + self assert: (list add: each beforeIndex: i) equals: each ]. self - assert: list = self listWithItems; - should: [list add: self newListItem beforeIndex: self listItems size + 2] raise: Error; - should: [list add: self newListItem beforeIndex: 0] raise: Error. + assert: list equals: self listWithItems; + should: [ + list add: self newListItem beforeIndex: self listItems size + 2 ] + raise: Error; + should: [ list add: self newListItem beforeIndex: 0 ] raise: Error ] { #category : #tests } XMLOrderedListTest >> testAddFirst [ - | list | + | list | list := self emptyList. self - assert: (self listItems reversed allSatisfy: [:each | (list addFirst: each) = each]); - assert: list = self listWithItems. + assert: (self listItems reversed allSatisfy: [ :each | + (list addFirst: each) = each ]); + assert: list equals: self listWithItems. - self assert: (self listItems allSatisfy: [:each | (list addFirst: each) = each]). self assert: - list = - (self listClass newFrom: - (self allowsDuplicates - ifTrue: [self listItems reversed, self listItems] - ifFalse: [self listItems reversed])). + (self listItems allSatisfy: [ :each | (list addFirst: each) = each ]). + self + assert: list + equals: (self listClass newFrom: (self allowsDuplicates + ifTrue: [ self listItems reversed , self listItems ] + ifFalse: [ self listItems reversed ])) ] { #category : #tests } XMLOrderedListTest >> testAddLast [ - | list | + | list | list := self emptyList. self - assert: (self listItems allSatisfy: [:each | (list addLast: each) = each]); - assert: list = self listWithItems. + assert: + (self listItems allSatisfy: [ :each | (list addLast: each) = each ]); + assert: list equals: self listWithItems. - self assert: (self listItems allSatisfy: [:each | (list addLast: each) = each]). self assert: - list = - (self listClass newFrom: - (self allowsDuplicates - ifTrue: [self listItems, self listItems] - ifFalse: [self listItems])). + (self listItems allSatisfy: [ :each | (list addLast: each) = each ]). + self + assert: list + equals: (self listClass newFrom: (self allowsDuplicates + ifTrue: [ self listItems , self listItems ] + ifFalse: [ self listItems ])) ] { #category : #tests } XMLOrderedListTest >> testAfter [ - | list | + | list | list := self listWithItems. - 1 to: list size - 1 do: [:i | - self assert: - (list after: (self listItems at: i)) = - (self listItems at: i + 1)]. + 1 to: list size - 1 do: [ :i | + self + assert: (list after: (self listItems at: i)) + equals: (self listItems at: i + 1) ]. self - assert: (list after: self listItems last) = self defaultValue; - assert: (list after: self absentListItem) = self defaultValue. + assert: (list after: self listItems last) equals: self defaultValue; + assert: (list after: self absentListItem) equals: self defaultValue ] { #category : #tests } XMLOrderedListTest >> testAfterIfAbsent [ - | list | + | list | list := self listWithItems. - 1 to: list size - 1 do: [:i | - self assert: - (list - after: (self listItems at: i) - ifAbsent: [self fail]) = (self listItems at: i + 1)]. - self assert: - (list - after: self listItems last - ifAbsent: [self newListItem]) = self newListItem. - self assert: - (list - after: self absentListItem - ifAbsent: [self newListItem]) = self newListItem. + 1 to: list size - 1 do: [ :i | + self + assert: + (list after: (self listItems at: i) ifAbsent: [ self fail ]) + equals: (self listItems at: i + 1) ]. + self + assert: + (list after: self listItems last ifAbsent: [ self newListItem ]) + equals: self newListItem. + self + assert: + (list after: self absentListItem ifAbsent: [ self newListItem ]) + equals: self newListItem ] { #category : #tests } XMLOrderedListTest >> testAllButFirst [ - | list | - self assert: self emptyList allButFirst = self emptyList. + | list | + self assert: self emptyList allButFirst equals: self emptyList. list := self listWithItems. self assertList: list allButFirst copiedFrom: list - equals: (self listClass newFrom: self listItems allButFirst). + equals: (self listClass newFrom: self listItems allButFirst) ] { #category : #tests } @@ -401,10 +424,10 @@ XMLOrderedListTest >> testAllButFirstDo [ { #category : #tests } XMLOrderedListTest >> testAllButFirstFew [ - | list | + | list | list := self listWithItems. - 1 to: list size do: [:i | + 1 to: list size do: [ :i | self assertList: (list allButFirst: i) copiedFrom: list @@ -417,24 +440,21 @@ XMLOrderedListTest >> testAllButFirstFew [ assertList: (list allButFirst: i * -1) copiedFrom: list equals: list. - self assert: (self emptyList allButFirst: i) = self emptyList]. - self - assertList: (list allButFirst: 0) - copiedFrom: list - equals: list. + self assert: (self emptyList allButFirst: i) equals: self emptyList ]. + self assertList: (list allButFirst: 0) copiedFrom: list equals: list ] { #category : #tests } XMLOrderedListTest >> testAllButLast [ - | list | - self assert: self emptyList allButLast = self emptyList. + | list | + self assert: self emptyList allButLast equals: self emptyList. list := self listWithItems. self assertList: list allButLast copiedFrom: list - equals: (self listClass newFrom: self listItems allButLast). + equals: (self listClass newFrom: self listItems allButLast) ] { #category : #tests } @@ -449,10 +469,10 @@ XMLOrderedListTest >> testAllButLastDo [ { #category : #tests } XMLOrderedListTest >> testAllButLastFew [ - | list | + | list | list := self listWithItems. - 1 to: list size do: [:i | + 1 to: list size do: [ :i | self assertList: (list allButLast: i) copiedFrom: list @@ -465,158 +485,172 @@ XMLOrderedListTest >> testAllButLastFew [ assertList: (list allButLast: i * -1) copiedFrom: list equals: list. - self assert: (self emptyList allButLast: i) = self emptyList]. - self - assertList: (list allButLast: 0) - copiedFrom: list - equals: list. + self assert: (self emptyList allButLast: i) equals: self emptyList ]. + self assertList: (list allButLast: 0) copiedFrom: list equals: list ] { #category : #tests } XMLOrderedListTest >> testAnyOne [ + self - assert: self emptyList anyOne = self defaultValue; - assert: self listWithItems anyOne = self listItems first. + assert: self emptyList anyOne equals: self defaultValue; + assert: self listWithItems anyOne equals: self listItems first ] { #category : #tests } XMLOrderedListTest >> testAsArray [ + self - assert: self emptyList asArray = #(); - assert: self listWithItems asArray = self listItems asArray + assert: self emptyList asArray equals: #( ); + assert: self listWithItems asArray equals: self listItems asArray ] { #category : #tests } XMLOrderedListTest >> testAsOrderedCollection [ - | list | + | list | list := self listWithItems. self - assert: self emptyList asOrderedCollection = OrderedCollection new; - assert: list asOrderedCollection = self listItems asOrderedCollection; - deny: list asOrderedCollection == list collection. + assert: self emptyList asOrderedCollection + equals: OrderedCollection new; + assert: list asOrderedCollection + equals: self listItems asOrderedCollection; + deny: list asOrderedCollection identicalTo: list collection ] { #category : #tests } XMLOrderedListTest >> testAt [ - | list | + | list | list := self listWithItems. self - assert: ((1 to: list size) allSatisfy: [:i | (list at: i) = (self listItems at: i)]); - assert: (list at: 0) = self defaultValue; - assert: (list at: list size + 1) = self defaultValue. + assert: ((1 to: list size) allSatisfy: [ :i | + (list at: i) = (self listItems at: i) ]); + assert: (list at: 0) equals: self defaultValue; + assert: (list at: list size + 1) equals: self defaultValue ] { #category : #tests } XMLOrderedListTest >> testAtIfAbsent [ - | list | + | list | list := self listWithItems. - 1 to: list size do: [:i | - self assert: - (list - at: i - ifAbsent: [self fail]) = (self listItems at: i)]. + 1 to: list size do: [ :i | + self + assert: (list at: i ifAbsent: [ self fail ]) + equals: (self listItems at: i) ]. self - assert: (list at: 0 ifAbsent: [self newListItem]) = self newListItem; - assert: (list at: list size + 1 ifAbsent: [self newListItem]) = self newListItem. + assert: (list at: 0 ifAbsent: [ self newListItem ]) + equals: self newListItem; + assert: (list at: list size + 1 ifAbsent: [ self newListItem ]) + equals: self newListItem ] { #category : #tests } XMLOrderedListTest >> testAtLast [ - | list | + | list | list := self listWithItems. - 1 to: list size do: [:i | self assert: (list atLast: i) = (self listItems atLast: i)]. + 1 to: list size do: [ :i | + self assert: (list atLast: i) equals: (self listItems atLast: i) ]. self - assert: (list atLast: 0) = self defaultValue; - assert: (list atLast: list size + 1) = self defaultValue. + assert: (list atLast: 0) equals: self defaultValue; + assert: (list atLast: list size + 1) equals: self defaultValue ] { #category : #tests } XMLOrderedListTest >> testAtLastIfAbsent [ - | list | + | list | list := self listWithItems. - 1 to: list size do: [:i | - self assert: (list atLast: i ifAbsent: [self newListItem]) = (self listItems atLast: i)]. + 1 to: list size do: [ :i | + self + assert: (list atLast: i ifAbsent: [ self newListItem ]) + equals: (self listItems atLast: i) ]. self - assert: (list atLast: 0 ifAbsent: [self newListItem]) = self newListItem; - assert: (list atLast: list size + 1 ifAbsent: [self newListItem]) = self newListItem. + assert: (list atLast: 0 ifAbsent: [ self newListItem ]) + equals: self newListItem; + assert: (list atLast: list size + 1 ifAbsent: [ self newListItem ]) + equals: self newListItem ] { #category : #tests } XMLOrderedListTest >> testAtPut [ - | list | + | list | list := self listWithItems. - 1 to: list size do: [:i | | replacement | + 1 to: list size do: [ :i | + | replacement | replacement := list at: i. self - assert: (list at: i put: replacement) == replacement; - assert: (list at: i) == replacement]. - self assert: list = self listWithItems. - - self assert: (list at: list size + 1 put: self newListItem) = self newListItem. - self assert: - list = - (self listClass newFrom: (self listItems copyWith: self newListItem)). + assert: (list at: i put: replacement) identicalTo: replacement; + assert: (list at: i) identicalTo: replacement ]. + self assert: list equals: self listWithItems. + self + assert: (list at: list size + 1 put: self newListItem) + equals: self newListItem. + self + assert: list + equals: + (self listClass newFrom: (self listItems copyWith: self newListItem)). list := self listWithItems. - 1 to: list size do: [:i | | replacement | + 1 to: list size do: [ :i | + | replacement | replacement := self changedListItems at: i. self - assert: (list at: i put: replacement) == replacement; - assert: (list at: i) == replacement]. - self assert: list = (self listClass newFrom: self changedListItems). + assert: (list at: i put: replacement) identicalTo: replacement; + assert: (list at: i) identicalTo: replacement ]. + self + assert: list + equals: (self listClass newFrom: self changedListItems). list := self listWithItems. - self listItems do: [:each | - self assert: (list at: list size + 1 put: each) == each]. - self assert: - list = - (self allowsDuplicates - ifTrue: [self listClass newFrom: self listItems, self listItems] - ifFalse: [self listWithItems]). - self - should: [list at: 0 put: self newListItem] - raise: Error. - self - should: [list at: list size + 2 put: self newListItem] - raise: Error. + self listItems do: [ :each | + self assert: (list at: list size + 1 put: each) identicalTo: each ]. + self assert: list equals: (self allowsDuplicates + ifTrue: [ self listClass newFrom: self listItems , self listItems ] + ifFalse: [ self listWithItems ]). + self should: [ list at: 0 put: self newListItem ] raise: Error. + self + should: [ list at: list size + 2 put: self newListItem ] + raise: Error ] { #category : #tests } XMLOrderedListTest >> testBefore [ - | list | + | list | list := self listWithItems. - 2 to: list size do: [:i | - self assert: (list before: (self listItems at: i)) = (self listItems at: i - 1)]. + 2 to: list size do: [ :i | + self + assert: (list before: (self listItems at: i)) + equals: (self listItems at: i - 1) ]. self - assert: (list before: self listItems first) = self defaultValue; - assert: (list before: self absentListItem) = self defaultValue. + assert: (list before: self listItems first) + equals: self defaultValue; + assert: (list before: self absentListItem) + equals: self defaultValue ] { #category : #tests } XMLOrderedListTest >> testBeforeIfAbsent [ - | list | + | list | list := self listWithItems. - 2 to: list size do: [:i | - self assert: - (list - before: (self listItems at: i) - ifAbsent: [self fail]) = (self listItems at: i - 1)]. - self assert: - (list - before: self listItems first - ifAbsent: [self newListItem]) = self newListItem. - self assert: - (list - before: self absentListItem - ifAbsent: [self newListItem]) = self newListItem. + 2 to: list size do: [ :i | + self + assert: + (list before: (self listItems at: i) ifAbsent: [ self fail ]) + equals: (self listItems at: i - 1) ]. + self + assert: + (list before: self listItems first ifAbsent: [ self newListItem ]) + equals: self newListItem. + self + assert: + (list before: self absentListItem ifAbsent: [ self newListItem ]) + equals: self newListItem ] { #category : #tests } @@ -702,28 +736,31 @@ XMLOrderedListTest >> testCopy [ { #category : #tests } XMLOrderedListTest >> testCopyAfter [ - | list | + | list | list := self listWithItems. - list do: [:each | + list do: [ :each | self assertList: (list copyAfter: each) copiedFrom: list equals: (self listClass newFrom: (self listItems copyAfter: each)). - self assert: (self emptyList copyAfter: each) = self emptyList]. + self assert: (self emptyList copyAfter: each) equals: self emptyList ] ] { #category : #tests } XMLOrderedListTest >> testCopyAfterLast [ - | list | + | list | list := self listWithItems. - list do: [:each | + list do: [ :each | self assertList: (list copyAfterLast: each) copiedFrom: list - equals: (self listClass newFrom: (self listItems copyAfterLast: each)). - self assert: (self emptyList copyAfterLast: each) = self emptyList]. + equals: + (self listClass newFrom: (self listItems copyAfterLast: each)). + self + assert: (self emptyList copyAfterLast: each) + equals: self emptyList ] ] { #category : #tests } @@ -944,33 +981,41 @@ XMLOrderedListTest >> testCopyWithoutAll [ { #category : #tests } XMLOrderedListTest >> testDefaultValue [ - self assert: self emptyList defaultValue = self defaultValue + + self assert: self emptyList defaultValue equals: self defaultValue ] { #category : #tests } XMLOrderedListTest >> testDetect [ - | list | + | list | list := self listWithItems. - self listItems do: [:element | - self assert: (list detect: [:each | each = element]) = element]. - self assert: (list detect: [:each | each = self absentListItem]) = self defaultValue. + self listItems do: [ :element | + self + assert: (list detect: [ :each | each = element ]) + equals: element ]. + self + assert: (list detect: [ :each | each = self absentListItem ]) + equals: self defaultValue ] { #category : #tests } XMLOrderedListTest >> testDetectIfNone [ - | list | + | list | list := self listWithItems. - self listItems do: [:element | - self assert: + self listItems do: [ :element | + self + assert: (list - detect: [:each | each = element] - ifNone: [self newListItem]) = element]. - self assert: - (list - detect: [:each | each = self absentListItem] - ifNone: [self newListItem]) = self newListItem. + detect: [ :each | each = element ] + ifNone: [ self newListItem ]) + equals: element ]. + self + assert: (list + detect: [ :each | each = self absentListItem ] + ifNone: [ self newListItem ]) + equals: self newListItem ] { #category : #tests } @@ -982,22 +1027,23 @@ XMLOrderedListTest >> testDo [ { #category : #tests } XMLOrderedListTest >> testDoWithIndex [ - | list enumerated | + | list enumerated | list := self listWithItems. enumerated := OrderedCollection new. - list withIndexDo: [:each :i | enumerated addLast: each -> i]. - self assert: - enumerated = - (self listItems withIndexCollect: [:each : i | each -> i ]) - asOrderedCollection. + list withIndexDo: [ :each :i | enumerated addLast: each -> i ]. + self + assert: enumerated + equals: (self listItems withIndexCollect: [ :each :i | each -> i ]) + asOrderedCollection ] { #category : #tests } XMLOrderedListTest >> testEighth [ + self - assert: self emptyList eighth = self defaultValue; - assert: self listWithItems eighth = (self listItems at: 8). + assert: self emptyList eighth equals: self defaultValue; + assert: self listWithItems eighth equals: (self listItems at: 8) ] { #category : #tests } @@ -1076,16 +1122,18 @@ XMLOrderedListTest >> testEqualsSpecies [ { #category : #tests } XMLOrderedListTest >> testFifth [ + self - assert: self emptyList fifth = self defaultValue; - assert: self listWithItems fifth = (self listItems at: 5). + assert: self emptyList fifth equals: self defaultValue; + assert: self listWithItems fifth equals: (self listItems at: 5) ] { #category : #tests } XMLOrderedListTest >> testFirst [ + self - assert: self emptyList first = self defaultValue; - assert: self listWithItems first = (self listItems at: 1). + assert: self emptyList first equals: self defaultValue; + assert: self listWithItems first equals: (self listItems at: 1) ] { #category : #tests } @@ -1114,9 +1162,10 @@ XMLOrderedListTest >> testFirstFew [ { #category : #tests } XMLOrderedListTest >> testFourth [ + self - assert: self emptyList fourth = self defaultValue; - assert: self listWithItems fourth = (self listItems at: 4). + assert: self emptyList fourth equals: self defaultValue; + assert: self listWithItems fourth equals: (self listItems at: 4) ] { #category : #tests } @@ -1124,139 +1173,157 @@ XMLOrderedListTest >> testHash [ "We can only safely test that equal objects have the same hash; testing that different objects have different hashes would be unreliable because #hash is non-cryptographic and has collisions." + self - assert: self emptyList hash = self emptyList hash; - assert: self listWithSingleItem hash = self listWithSingleItem hash; - assert: self listWithItems hash = self listWithItems hash; - assert: - (self listWithItems - removeAll; - hash) = self emptyList hash. + assert: self emptyList hash equals: self emptyList hash; + assert: self listWithSingleItem hash + equals: self listWithSingleItem hash; + assert: self listWithItems hash equals: self listWithItems hash; + assert: (self listWithItems + removeAll; + hash) + equals: self emptyList hash ] { #category : #tests } XMLOrderedListTest >> testHashCustomCollection [ - self assert: - self emptyList hash = self customCollectionEmptyList hash. - self assert: - self listWithSingleItem hash = - self customCollectionListWithSingleItem hash. - self assert: - self listWithItems hash = - self customCollectionListWithItems hash. + + self + assert: self emptyList hash + equals: self customCollectionEmptyList hash. + self + assert: self listWithSingleItem hash + equals: self customCollectionListWithSingleItem hash. + self + assert: self listWithItems hash + equals: self customCollectionListWithItems hash ] { #category : #tests } XMLOrderedListTest >> testIdentityIndexOf [ - | list | + | list | list := self listWithItems. - 1 to: list size do: [:i | + 1 to: list size do: [ :i | self - assert: (list identityIndexOf: (list at: i)) = i; - assert: (list identityIndexOf: (list at: i) copy) isZero]. + assert: (list identityIndexOf: (list at: i)) equals: i; + assert: (list identityIndexOf: (list at: i) copy) isZero ] ] { #category : #tests } XMLOrderedListTest >> testIdentityIndexOfIfAbsent [ - | list | + | list | list := self listWithItems. - 1 to: list size do: [:i | + 1 to: list size do: [ :i | self - assert: (list identityIndexOf: (list at: i) ifAbsent: [-1]) = i; - assert: (list identityIndexOf: (list at: i) copy ifAbsent: [-1]) = -1]. + assert: (list identityIndexOf: (list at: i) ifAbsent: [ -1 ]) + equals: i; + assert: (list identityIndexOf: (list at: i) copy ifAbsent: [ -1 ]) + equals: -1 ] ] { #category : #tests } XMLOrderedListTest >> testIndexOf [ - | list | + | list | list := self listWithItems. - 1 to: list size do: [:i | + 1 to: list size do: [ :i | self - assert: (list indexOf: (list at: i)) = i; - assert: (list indexOf: (self listItems at: i)) = i]. - self assert: (list indexOf: self absentListItem) isZero. + assert: (list indexOf: (list at: i)) equals: i; + assert: (list indexOf: (self listItems at: i)) equals: i ]. + self assert: (list indexOf: self absentListItem) isZero ] { #category : #tests } XMLOrderedListTest >> testIndexOfIfAbsent [ - | list | + | list | list := self listWithItems. - 1 to: list size do: [:i | + 1 to: list size do: [ :i | self - assert: (list indexOf: (list at: i) ifAbsent: [-1]) = i; - assert: (list indexOf: (self listItems at: i) ifAbsent: [-1]) = i]. - self assert: (list indexOf: self absentListItem ifAbsent: [-1]) = -1. + assert: (list indexOf: (list at: i) ifAbsent: [ -1 ]) equals: i; + assert: (list indexOf: (self listItems at: i) ifAbsent: [ -1 ]) + equals: i ]. + self + assert: (list indexOf: self absentListItem ifAbsent: [ -1 ]) + equals: -1 ] { #category : #tests } XMLOrderedListTest >> testIndexOfStartingAt [ - | list | + | list | list := self listWithItems. - 1 to: list size do: [:i | + 1 to: list size do: [ :i | self - assert: (list indexOf: (list at: i) startingAt: i) = i; - assert: (list indexOf: (list at: i) startingAt: i + 1) isZero]. + assert: (list indexOf: (list at: i) startingAt: i) equals: i; + assert: (list indexOf: (list at: i) startingAt: i + 1) isZero ] ] { #category : #tests } XMLOrderedListTest >> testIndexOfStartingAtIfAbsent [ - | list | + | list | list := self listWithItems. - 1 to: list size do: [:i | + 1 to: list size do: [ :i | self - assert: (list indexOf: (list at: i) startingAt: i ifAbsent: [-1]) = i; - assert: (list indexOf: (list at: i) startingAt: i + 1 ifAbsent: [-1]) = -1]. + assert: (list indexOf: (list at: i) startingAt: i ifAbsent: [ -1 ]) + equals: i; + assert: + (list indexOf: (list at: i) startingAt: i + 1 ifAbsent: [ -1 ]) + equals: -1 ] ] { #category : #tests } XMLOrderedListTest >> testIndexOfSubCollectionStartingAt [ - | list | + | list | list := self listWithItems. - 1 to: self listItems size do: [:i | - i to: self listItems size do: [:j | - self assert: - (list - indexOfSubCollection: (self listItems copyFrom: i to: j) - startingAt: 1) = i. - self assert: - (list - indexOfSubCollection: (self listItems copyFrom: i to: j) - startingAt: i) = i. - self assert: - (list - indexOfSubCollection: (self listItems copyFrom: i to: j) - startingAt: i + 1) = 0]]. + 1 to: self listItems size do: [ :i | + i to: self listItems size do: [ :j | + self + assert: (list + indexOfSubCollection: (self listItems copyFrom: i to: j) + startingAt: 1) + equals: i. + self + assert: (list + indexOfSubCollection: (self listItems copyFrom: i to: j) + startingAt: i) + equals: i. + self + assert: (list + indexOfSubCollection: (self listItems copyFrom: i to: j) + startingAt: i + 1) + equals: 0 ] ] ] { #category : #tests } XMLOrderedListTest >> testIndexOfSubCollectionStartingAtIfAbsent [ - | list | + | list | list := self listWithItems. - 1 to: self listItems size do: [:i | - i to: self listItems size do: [:j | - self assert: - (list - indexOfSubCollection: (self listItems copyFrom: i to: j) - startingAt: 1 - ifAbsent: [-1]) = i. - self assert: - (list - indexOfSubCollection: (self listItems copyFrom: i to: j) - startingAt: i - ifAbsent: [-1]) = i. - self assert: - (list - indexOfSubCollection: (self listItems copyFrom: i to: j) - startingAt: i + 1 - ifAbsent: [-1]) = -1]]. + 1 to: self listItems size do: [ :i | + i to: self listItems size do: [ :j | + self + assert: (list + indexOfSubCollection: (self listItems copyFrom: i to: j) + startingAt: 1 + ifAbsent: [ -1 ]) + equals: i. + self + assert: (list + indexOfSubCollection: (self listItems copyFrom: i to: j) + startingAt: i + ifAbsent: [ -1 ]) + equals: i. + self + assert: (list + indexOfSubCollection: (self listItems copyFrom: i to: j) + startingAt: i + 1 + ifAbsent: [ -1 ]) + equals: -1 ] ] ] { #category : #tests } @@ -1269,9 +1336,10 @@ XMLOrderedListTest >> testIsEmpty [ { #category : #tests } XMLOrderedListTest >> testLast [ + self - assert: self emptyList last = self defaultValue; - assert: self listWithItems last = self listItems last. + assert: self emptyList last equals: self defaultValue; + assert: self listWithItems last equals: self listItems last ] { #category : #tests } @@ -1300,68 +1368,75 @@ XMLOrderedListTest >> testLastFew [ { #category : #tests } XMLOrderedListTest >> testLastIndexOf [ - | list | - list := self listClass newFrom: self listItems, self listItems. - list do: [:each | - self assert: - (list lastIndexOf: each) = - (self allowsDuplicates - ifTrue: [self listItems, self listItems lastIndexOf: each] - ifFalse: [self listItems lastIndexOf: each])]. - self assert: (list lastIndexOf: self newListItem) isZero. + | list | + list := self listClass newFrom: self listItems , self listItems. + list do: [ :each | + self + assert: (list lastIndexOf: each) + equals: (self allowsDuplicates + ifTrue: [ self listItems , self listItems lastIndexOf: each ] + ifFalse: [ self listItems lastIndexOf: each ]) ]. + self assert: (list lastIndexOf: self newListItem) isZero ] { #category : #tests } XMLOrderedListTest >> testLastIndexOfIfAbsent [ - | list | - list := self listClass newFrom: self listItems, self listItems. - list do: [:each | - self assert: - (list lastIndexOf: each ifAbsent: [-1]) = - (self allowsDuplicates - ifTrue: [self listItems, self listItems lastIndexOf: each] - ifFalse: [self listItems lastIndexOf: each])]. - self assert: (list lastIndexOf: self newListItem ifAbsent: [-1]) = -1. + | list | + list := self listClass newFrom: self listItems , self listItems. + list do: [ :each | + self + assert: (list lastIndexOf: each ifAbsent: [ -1 ]) + equals: (self allowsDuplicates + ifTrue: [ self listItems , self listItems lastIndexOf: each ] + ifFalse: [ self listItems lastIndexOf: each ]) ]. + self + assert: (list lastIndexOf: self newListItem ifAbsent: [ -1 ]) + equals: -1 ] { #category : #tests } XMLOrderedListTest >> testNew [ - | list | + | list | list := self listClass new: 20. - self assert: list = self emptyList. - self hasCapacity - ifTrue: [self assert: list capacity >= 20]. + self assert: list equals: self emptyList. + self hasCapacity ifTrue: [ self assert: list capacity >= 20 ] ] { #category : #tests } XMLOrderedListTest >> testNewFrom [ - self assert: (self listClass newFrom: self listItems) = self listWithItems + + self + assert: (self listClass newFrom: self listItems) + equals: self listWithItems ] { #category : #tests } XMLOrderedListTest >> testNewWithAll [ - | list | + | list | list := self listClass new: 10 withAll: self singleListItem. self allowsDuplicates - ifTrue: [self assert: list size = 10] - ifFalse: [self assert: list size = 1]. - self assert: (list allSatisfy: [:each | each = self singleListItem]). + ifTrue: [ self assert: list size equals: 10 ] + ifFalse: [ self assert: list size equals: 1 ]. + self assert: + (list allSatisfy: [ :each | each = self singleListItem ]) ] { #category : #tests } XMLOrderedListTest >> testNinth [ + self - assert: self emptyList ninth = self defaultValue; - assert: self listWithItems ninth = (self listItems at: 9). + assert: self emptyList ninth equals: self defaultValue; + assert: self listWithItems ninth equals: (self listItems at: 9) ] { #category : #tests } XMLOrderedListTest >> testOfSize [ - self assert: (self listClass ofSize: 10) size = 10 + + self assert: (self listClass ofSize: 10) size equals: 10 ] { #category : #tests } @@ -1386,21 +1461,21 @@ XMLOrderedListTest >> testPairsDo [ { #category : #tests } XMLOrderedListTest >> testReadStream [ - | list stream position | + | list stream position | list := self listWithItems. stream := list readStream. position := 0. self assert: stream isStream; - assert: stream position = 0. - self listItems do: [:each | + assert: stream position equals: 0. + self listItems do: [ :each | self deny: stream atEnd; - assert: stream next = each. + assert: stream next equals: each. position := position + 1. - self assert: stream position = position]. - self assert: stream atEnd. + self assert: stream position equals: position ]. + self assert: stream atEnd ] { #category : #tests } @@ -1434,108 +1509,118 @@ XMLOrderedListTest >> testRejectThenCollect [ { #category : #tests } XMLOrderedListTest >> testRemoveAll [ - | list | + | list | list := self listWithItems. self - assert: list removeAll == list; + assert: list removeAll identicalTo: list; assert: list isEmpty; - assert: list removeAll == list; - assert: list isEmpty. + assert: list removeAll identicalTo: list; + assert: list isEmpty ] { #category : #tests } XMLOrderedListTest >> testRemoveAt [ - self listItems withIndexDo: [:each :i | | list | + + self listItems withIndexDo: [ :each :i | + | list | list := self listWithItems. self - assert: (list removeAt: i) = each; - assert: (list = (self listClass newFrom: (self listItems copyWithout: each)))]. + assert: (list removeAt: i) equals: each; + assert: list + equals: + (self listClass newFrom: (self listItems copyWithout: each)) ]. self - should: [self listWithItems removeAt: 0] raise: Error; - should: [self listWithItems removeAt: self listItems size + 1] raise: Error. + should: [ self listWithItems removeAt: 0 ] raise: Error; + should: [ self listWithItems removeAt: self listItems size + 1 ] + raise: Error ] { #category : #tests } XMLOrderedListTest >> testRemoveFirst [ - | list | + | list | list := self listWithItems. - self listItems do: [:each | - self - assert: list removeFirst = each; - assert: list = (self listClass newFrom: (self listItems copyAfter: each))]. - self should: [list removeFirst] raise: Error. + self listItems do: [ :each | + self + assert: list removeFirst equals: each; + assert: list + equals: (self listClass newFrom: (self listItems copyAfter: each)) ]. + self should: [ list removeFirst ] raise: Error ] { #category : #tests } XMLOrderedListTest >> testRemoveFirstFew [ - 1 to: self listItems size do: [:i | | list removedElements | + + 1 to: self listItems size do: [ :i | + | list removedElements | list := self listWithItems. removedElements := list removeFirst: i. self - assert: removedElements asArray = (self listItemsFirst: i); - assert: list = (self listClass newFrom: (self listItems allButFirst: i)); + assert: removedElements asArray equals: (self listItemsFirst: i); + assert: list + equals: (self listClass newFrom: (self listItems allButFirst: i)); assert: (list removeFirst: 0) isEmpty; - should: [self emptyList removeFirst: i] raise: Error]. + should: [ self emptyList removeFirst: i ] raise: Error ] ] { #category : #tests } XMLOrderedListTest >> testRemoveIfAbsent [ - | list | + | list | list := self listWithItems. - self listItems do: [:each | - self assert: - (list - remove: each - ifAbsent: [self fail]) = each. + self listItems do: [ :each | + self + assert: (list remove: each ifAbsent: [ self fail ]) + equals: each. self deny: (list includes: each). - - self assert: - (list - remove: each - ifAbsent: [self absentListItem]) = self absentListItem]. + self + assert: (list remove: each ifAbsent: [ self absentListItem ]) + equals: self absentListItem ] ] { #category : #tests } XMLOrderedListTest >> testRemoveLast [ - | list | + | list | list := self listWithItems. - self listItems reverseDo: [:each | + self listItems reverseDo: [ :each | self - assert: list removeLast = each; - assert: list = (self listClass newFrom: (self listItems copyUpTo: each))]. - self should: [list removeLast] raise: Error. + assert: list removeLast equals: each; + assert: list + equals: (self listClass newFrom: (self listItems copyUpTo: each)) ]. + self should: [ list removeLast ] raise: Error ] { #category : #tests } XMLOrderedListTest >> testRemoveLastFew [ - | list removedElements | - 1 to: self listItems size do: [:i | + | list removedElements | + 1 to: self listItems size do: [ :i | list := self listWithItems. removedElements := list removeLast: i. self - assert: removedElements asArray = (self listItemsLast: i) asArray; - assert: list = (self listClass newFrom: (self listItems allButLast: i)); + assert: removedElements asArray + equals: (self listItemsLast: i) asArray; + assert: list + equals: (self listClass newFrom: (self listItems allButLast: i)); assert: (list removeLast: 0) isEmpty; - should: [self emptyList removeLast: i] raise: Error]. + should: [ self emptyList removeLast: i ] raise: Error ] ] { #category : #tests } XMLOrderedListTest >> testReplaceFromToWith [ - | list | - 1 to: self listItems size do: [:start | - start to: self listItems size do: [:stop | + | list | + 1 to: self listItems size do: [ :start | + start to: self listItems size do: [ :stop | list := self listWithItems. - self assert: - (list - replaceFrom: start - to: stop - with: (self changedListItems allButFirst: start - 1)) == list. + self + assert: (list + replaceFrom: start + to: stop + with: (self changedListItems allButFirst: start - 1)) + identicalTo: list. self assertList: list @@ -1548,31 +1633,29 @@ XMLOrderedListTest >> testReplaceFromToWith [ ifTrue: [ self should: [ - self emptyList - replaceFrom: start - to: stop - with: self listItems] - raise: Error] + self emptyList replaceFrom: start to: stop with: self listItems ] + raise: Error ] ifFalse: [ - self assert: - (self emptyList - replaceFrom: start - to: stop - with: self listItems) = - (self listClass newFrom: (self listItemsFirst: stop))]]] + self + assert: + (self emptyList replaceFrom: start to: stop with: self listItems) + equals: (self listClass newFrom: (self listItemsFirst: stop)) ] ] ] ] { #category : #tests } XMLOrderedListTest >> testReplaceFromToWithStartingAt [ - 1 to: self listItems size do: [:start | - start to: self listItems size do: [:stop | | list | + + 1 to: self listItems size do: [ :start | + start to: self listItems size do: [ :stop | + | list | list := self listWithItems. - self assert: - (list - replaceFrom: start - to: stop - with: self changedListItems - startingAt: start) == list. + self + assert: (list + replaceFrom: start + to: stop + with: self changedListItems + startingAt: start) + identicalTo: list. self assertList: list @@ -1589,16 +1672,16 @@ XMLOrderedListTest >> testReplaceFromToWithStartingAt [ replaceFrom: start to: stop with: self listItems - startingAt: start] - raise: Error] + startingAt: start ] + raise: Error ] ifFalse: [ - self assert: - (self emptyList - replaceFrom: start - to: stop - with: self listItems - startingAt: start) = - (self listClass newFrom: (self listItemsFirst: stop))]]] + self + assert: (self emptyList + replaceFrom: start + to: stop + with: self listItems + startingAt: start) + equals: (self listClass newFrom: (self listItemsFirst: stop)) ] ] ] ] { #category : #tests } @@ -1645,9 +1728,10 @@ XMLOrderedListTest >> testReversed [ { #category : #tests } XMLOrderedListTest >> testSecond [ + self - assert: self emptyList second = self defaultValue; - assert: self listWithItems second = (self listItems at: 2). + assert: self emptyList second equals: self defaultValue; + assert: self listWithItems second equals: (self listItems at: 2) ] { #category : #tests } @@ -1681,36 +1765,42 @@ XMLOrderedListTest >> testSelectThenCollect [ { #category : #tests } XMLOrderedListTest >> testSeventh [ + self - assert: self emptyList seventh = self defaultValue; - assert: self listWithItems seventh = (self listItems at: 7). + assert: self emptyList seventh equals: self defaultValue; + assert: self listWithItems seventh equals: (self listItems at: 7) ] { #category : #tests } XMLOrderedListTest >> testSixth [ + self - assert: self emptyList sixth = self defaultValue; - assert: self listWithItems sixth = (self listItems at: 6). + assert: self emptyList sixth equals: self defaultValue; + assert: self listWithItems sixth equals: (self listItems at: 6) ] { #category : #tests } XMLOrderedListTest >> testSize [ + self assert: self emptyList size isZero; - assert: self listWithSingleItem size = 1; - assert: self listWithItems size = self listItems size + assert: self listWithSingleItem size equals: 1; + assert: self listWithItems size equals: self listItems size ] { #category : #tests } XMLOrderedListTest >> testSort [ - | list | + | list | list := self listWithItems. self - assert: list sort == list; - assert: list = (self listClass newFrom: (self listItems copy sort: self sortBlock)); - assert: (list sort: self reverseSortBlock) == list; - assert: list = (self listClass newFrom: (self listItems copy sort: self reverseSortBlock)). + assert: list sort identicalTo: list; + assert: list + equals: + (self listClass newFrom: (self listItems copy sort: self sortBlock)); + assert: (list sort: self reverseSortBlock) identicalTo: list; + assert: list equals: (self listClass newFrom: + (self listItems copy sort: self reverseSortBlock)) ] { #category : #tests } @@ -1730,57 +1820,54 @@ XMLOrderedListTest >> testSorted [ { #category : #tests } XMLOrderedListTest >> testSpecies [ - self - assert: self emptyList species = self listSpecies + + self assert: self emptyList species equals: self listSpecies ] { #category : #tests } XMLOrderedListTest >> testSwapWith [ - | list start end | + | list start end | list := self listWithItems. start := 1. end := list size. - [start < end] - whileTrue: [ - list swap: start with: end. - start := start + 1. - end := end - 1]. - self assert: list = (self listClass newFrom: self listItems reversed). + [ start < end ] whileTrue: [ + list swap: start with: end. + start := start + 1. + end := end - 1 ]. + self + assert: list + equals: (self listClass newFrom: self listItems reversed). start := 1. end := list size. - [start < end] - whileTrue: [ - list swap: end with: start. - start := start + 1. - end := end - 1]. - self assert: list = self listWithItems. + [ start < end ] whileTrue: [ + list swap: end with: start. + start := start + 1. + end := end - 1 ]. + self assert: list equals: self listWithItems. - 1 to: list size do: [:i | list swap: i with: i]. - self assert: list = self listWithItems. + 1 to: list size do: [ :i | list swap: i with: i ]. + self assert: list equals: self listWithItems. + self should: [ list swap: 0 with: 1 ] raise: Error. + self should: [ list swap: 1 with: 0 ] raise: Error. self - should: [list swap: 0 with: 1] + should: [ list swap: list size + 1 with: list size ] raise: Error. self - should: [list swap: 1 with: 0] + should: [ list swap: list size with: list size + 1 ] raise: Error. - self - should: [list swap: list size + 1 with: list size] - raise: Error. - self - should: [list swap: list size with: list size + 1] - raise: Error. - self assert: list = self listWithItems. + self assert: list equals: self listWithItems ] { #category : #tests } XMLOrderedListTest >> testThird [ + self - assert: self emptyList third = self defaultValue; - assert: self listWithItems third = (self listItems at: 3). + assert: self emptyList third equals: self defaultValue; + assert: self listWithItems third equals: (self listItems at: 3) ] { #category : #tests } @@ -1805,23 +1892,27 @@ XMLOrderedListTest >> testWithCollect [ { #category : #tests } XMLOrderedListTest >> testWithDo [ - | list enumerated | + | list enumerated | list := self listWithItems. enumerated := OrderedCollection new. - list with: (1 to: list size + 1) do: [:each :i | enumerated addLast: each -> i]. - self assert: - enumerated = - (self listItems withIndexCollect: [:each : i | each -> i ]) + list + with: (1 to: list size + 1) + do: [ :each :i | enumerated addLast: each -> i ]. + self + assert: enumerated + equals: (self listItems withIndexCollect: [ :each :i | each -> i ]) asOrderedCollection. enumerated removeAll. - list with: (1 to: list size - 1) do: [:each :i | enumerated addLast: each -> i]. - self assert: - enumerated = - (self listItems allButLast - withIndexCollect: [:each : i | each -> i ]) - asOrderedCollection. + list + with: (1 to: list size - 1) + do: [ :each :i | enumerated addLast: each -> i ]. + self + assert: enumerated + equals: + (self listItems allButLast withIndexCollect: [ :each :i | + each -> i ]) asOrderedCollection ] { #category : #tests } @@ -1839,13 +1930,15 @@ XMLOrderedListTest >> testWithIndexCollect [ { #category : #tests } XMLOrderedListTest >> testWithIndexDo [ - | enumerated | + | enumerated | enumerated := OrderedCollection new. - self listWithItems withIndexDo: [:each :i | enumerated addLast: each -> i]. - self assert: - enumerated = - (self listItems withIndexCollect: [:each : i | each -> i ]) asOrderedCollection. + self listWithItems withIndexDo: [ :each :i | + enumerated addLast: each -> i ]. + self + assert: enumerated + equals: (self listItems withIndexCollect: [ :each :i | each -> i ]) + asOrderedCollection ] { #category : #tests } @@ -1857,8 +1950,10 @@ XMLOrderedListTest >> testWriteStream [ { #category : #tests } XMLOrderedListTest >> testXMLLastOrNil [ + self - assert: self emptyList xmlLastOrNil = self defaultValue; - assert: self listWithSingleItem xmlLastOrNil = self singleListItem; - assert: self listWithItems xmlLastOrNil = self listItems last + assert: self emptyList xmlLastOrNil equals: self defaultValue; + assert: self listWithSingleItem xmlLastOrNil + equals: self singleListItem; + assert: self listWithItems xmlLastOrNil equals: self listItems last ] diff --git a/src/XML-Parser-Tests/XMLPITest.class.st b/src/XML-Parser-Tests/XMLPITest.class.st index 80c48a4c..533f14d0 100644 --- a/src/XML-Parser-Tests/XMLPITest.class.st +++ b/src/XML-Parser-Tests/XMLPITest.class.st @@ -18,18 +18,18 @@ XMLPITest >> nodeClass [ { #category : #tests } XMLPITest >> testAcceptNodeVisitor [ - | visitor pi message | + | visitor pi message | visitor := XMLRecordingNodeVisitor new. pi := self newNode. self - assert: (pi acceptNodeVisitor: visitor) == pi; + assert: (pi acceptNodeVisitor: visitor) identicalTo: pi; assert: visitor messageRecorder hasMessages. message := visitor messageRecorder nextMessage. self - assert: message selector == #visitPI:; - assert: message arguments = (Array with: pi); + assert: message selector identicalTo: #visitPI:; + assert: message arguments equals: (Array with: pi); deny: visitor messageRecorder hasMessages ] @@ -46,13 +46,13 @@ XMLPITest >> testCanonicallyEquals [ { #category : #tests } XMLPITest >> testData [ - | pi | + | pi | pi := self newNode. self - assert: pi data = ''; - assert: (pi data: 'test') == pi; - assert: pi data = 'test' + assert: pi data equals: ''; + assert: (pi data: 'test') identicalTo: pi; + assert: pi data equals: 'test' ] { #category : #tests } @@ -76,41 +76,39 @@ XMLPITest >> testIsPI [ { #category : #tests } XMLPITest >> testSortKey [ - self assert: self newPIWithTargetAndData sortKey = 'target' + + self assert: self newPIWithTargetAndData sortKey equals: 'target' ] { #category : #tests } XMLPITest >> testTarget [ - | pi | + | pi | pi := self newNode. self - assert: pi target = ''; - assert: (pi target: 'test') == pi; - assert: pi target = 'test' + assert: pi target equals: ''; + assert: (pi target: 'test') identicalTo: pi; + assert: pi target equals: 'test' ] { #category : #tests } XMLPITest >> testTargetData [ - | pi | - pi := - self nodeClass - target: 'target' - data: 'data'. + | pi | + pi := self nodeClass target: 'target' data: 'data'. self - assert: pi class == self nodeClass; - assert: pi target = 'target'; - assert: pi data = 'data' + assert: pi class identicalTo: self nodeClass; + assert: pi target equals: 'target'; + assert: pi data equals: 'data' ] { #category : #tests } XMLPITest >> testWriteXMLOn [ - | pi | + | pi | pi := self newPIWithTargetAndData. - self assert: pi printString = ''. + self assert: pi printString equals: ''. - pi data: ' ', pi data. - self assert: pi printString = '' + pi data: ' ' , pi data. + self assert: pi printString equals: '' ] diff --git a/src/XML-Parser-Tests/XMLParameterEntityDeclarationTest.class.st b/src/XML-Parser-Tests/XMLParameterEntityDeclarationTest.class.st index 1499b521..a3313bd4 100644 --- a/src/XML-Parser-Tests/XMLParameterEntityDeclarationTest.class.st +++ b/src/XML-Parser-Tests/XMLParameterEntityDeclarationTest.class.st @@ -21,13 +21,17 @@ XMLParameterEntityDeclarationTest >> testIsParameter [ { #category : #tests } XMLParameterEntityDeclarationTest >> testWriteXMLOn [ - self assert: - (self nodeClass name: 'one' replacement: 'two') printString = - ''. - self assert: - (self nodeClass name: 'one' publicID: 'two' systemID: 'three') printString = - ''. - self assert: - (self nodeClass name: 'one' publicID: '' systemID: 'three') printString = - '' + + self + assert: (self nodeClass name: 'one' replacement: 'two') printString + equals: ''. + self + assert: + (self nodeClass name: 'one' publicID: 'two' systemID: 'three') + printString + equals: ''. + self + assert: (self nodeClass name: 'one' publicID: '' systemID: 'three') + printString + equals: '' ] diff --git a/src/XML-Parser-Tests/XMLParserExceptionTest.class.st b/src/XML-Parser-Tests/XMLParserExceptionTest.class.st index d5040e04..b43dc2fd 100644 --- a/src/XML-Parser-Tests/XMLParserExceptionTest.class.st +++ b/src/XML-Parser-Tests/XMLParserExceptionTest.class.st @@ -70,23 +70,24 @@ XMLParserExceptionTest >> lineNumber [ { #category : #tests } XMLParserExceptionTest >> testBaseURI [ - | exception | + | exception | exception := self newException. self assert: exception baseURI equals: ''; - assert: (exception baseURI: self baseURI) == exception; + assert: (exception baseURI: self baseURI) identicalTo: exception; assert: exception baseURI equals: self baseURI ] { #category : #tests } XMLParserExceptionTest >> testColumnNumber [ - | exception | + | exception | exception := self newException. self assert: exception columnNumber isNil; - assert: (exception columnNumber: self columnNumber) == exception; + assert: (exception columnNumber: self columnNumber) + identicalTo: exception; assert: exception columnNumber equals: self columnNumber ] @@ -134,12 +135,13 @@ XMLParserExceptionTest >> testHasLineNumber [ { #category : #tests } XMLParserExceptionTest >> testLineNumber [ - | exception | + | exception | exception := self newException. self assert: exception lineNumber isNil; - assert: (exception lineNumber: self lineNumber) == exception; + assert: (exception lineNumber: self lineNumber) + identicalTo: exception; assert: exception lineNumber equals: self lineNumber ] diff --git a/src/XML-Parser-Tests/XMLParserTest.class.st b/src/XML-Parser-Tests/XMLParserTest.class.st index a0561ba5..8562cc00 100644 --- a/src/XML-Parser-Tests/XMLParserTest.class.st +++ b/src/XML-Parser-Tests/XMLParserTest.class.st @@ -958,8 +958,8 @@ XMLParserTest >> testAttributeDeclarationWhitespace [ { #category : #tests } XMLParserTest >> testAttributeDefaultFixedValue [ - | dtd document root | + | dtd document root | dtd := ' @@ -971,58 +971,53 @@ XMLParserTest >> testAttributeDefaultFixedValue [ four ID #REQUIRED > ]>'. - #(true false) do: [:isValidating | - document := - (XMLDOMParser on: - dtd, - '') - isValidating: isValidating; - parseDocument. + #( true false ) do: [ :isValidating | + document := (XMLDOMParser on: + dtd , '') + isValidating: isValidating; + parseDocument. root := document root. self - assert: (root attributeAt: 'one') = 'fixedDefault'; - assert: (root attributeAt: 'two') = 'fixedDefaultTwo'; + assert: (root attributeAt: 'one') equals: 'fixedDefault'; + assert: (root attributeAt: 'two') equals: 'fixedDefaultTwo'; assert: (root includesAttribute: 'three'); - assert: (root attributeAt: 'three') = ''; - assert: (root attributeAt: 'four') = 'fixedDefaultTwo'. + assert: (root attributeAt: 'three') equals: ''; + assert: (root attributeAt: 'four') equals: 'fixedDefaultTwo'. "attributes with fixed defaults are set automatically if not present" - document := - (XMLDOMParser on: dtd, '') - isValidating: isValidating; - parseDocument. + document := (XMLDOMParser on: dtd , '') + isValidating: isValidating; + parseDocument. root := document root. self - assert: (root attributeAt: 'one') = 'fixedDefault'; - assert: (root attributeAt: 'two') = 'fixedDefaultTwo'; + assert: (root attributeAt: 'one') equals: 'fixedDefault'; + assert: (root attributeAt: 'two') equals: 'fixedDefaultTwo'; assert: (root includesAttribute: 'three'); - assert: (root attributeAt: 'three') = '']. + assert: (root attributeAt: 'three') equals: '' ]. "but if present cannot have non-default values" - #('one' 'two' 'three') - with: #('fixedDefault' 'fixedDefaultTwo' '') - do: [:name :fixedDefault | | xml | - xml := dtd, ''. + #( 'one' 'two' 'three' ) + with: #( 'fixedDefault' 'fixedDefaultTwo' '' ) + do: [ :name :fixedDefault | + | xml | + xml := dtd , ''. self - should: [SAXHandler parse: xml] + should: [ SAXHandler parse: xml ] raise: XMLValidationException. self shouldnt: [ - document := - (XMLDOMParser on: xml) - isValidating: false; - parseDocument] + document := (XMLDOMParser on: xml) + isValidating: false; + parseDocument ] raise: XMLValidationException. root := document root. self - assert: (root attributeAt: 'one') = 'fixedDefault'; - assert: (root attributeAt: 'two') = 'fixedDefaultTwo'; + assert: (root attributeAt: 'one') equals: 'fixedDefault'; + assert: (root attributeAt: 'two') equals: 'fixedDefaultTwo'; assert: (root includesAttribute: 'three'); - assert: (root attributeAt: 'three') = '']. + assert: (root attributeAt: 'three') equals: '' ] ] { #category : #tests } @@ -1030,165 +1025,168 @@ XMLParserTest >> testAttributeDefaultFixedValueEntityReference [ "tests that general entities referenced in attribute declaration #FIXED default values were declared before the declaration is parsed" - #(' + #( ' ' - "no ID test because they can't have default values, but IDREF/IDREFS can" - ' + ' - ' - ' + ' ' - ' - ' + ' ' ' - ' + ' ' - ' + ' ' - ' + ' ' - ' + ' ' - ' + ' - ') - do: [:each | | badSubset goodSubset badContent goodContent document| + ' ) do: [ :each | "no ID test because they can't have default values, but IDREF/IDREFS can" + | badSubset goodSubset badContent goodContent document | "the 'undeclared' entity declaration must come before the rest of the subset for it to be OK" - badSubset := each, ''. - goodSubset := '', each. - badContent := - ' + badSubset := each , ''. + goodSubset := '' , each. + badContent := ' '. - goodContent := - ' + goodContent := ' '. self should: [ - SAXHandler parse: '', goodContent] + SAXHandler parse: + '' , goodContent ] raise: XMLWellFormednessException. self should: [ - (SAXHandler on: '', goodContent) + (SAXHandler on: + '' , goodContent) externalEntityResolver: (DTDStaticExternalEntityResolver externalEntities: - (Array with: 'extern.dtd' -> badSubset)); + (Array with: 'extern.dtd' -> badSubset)); resolvesExternalEntities: true; - parseDocument] + parseDocument ] raise: XMLValidationException. self shouldnt: [ - document := - (XMLDOMParser on: - '', goodContent) - externalEntityResolver: - (DTDStaticExternalEntityResolver externalEntities: - (Array with: 'extern.dtd' -> badSubset)); - resolvesExternalEntities: true; - isValidating: false; - parseDocument] + document := (XMLDOMParser on: + '' , goodContent) + externalEntityResolver: + (DTDStaticExternalEntityResolver externalEntities: + (Array with: 'extern.dtd' -> badSubset)); + resolvesExternalEntities: true; + isValidating: false; + parseDocument ] raise: XMLValidationException. self - assert: ((document root elementAt: 'one') attributeAt: 'one') = ''; - assert: ((document root elementAt: 'two') attributeAt: 'two') = 'value'. + assert: ((document root elementAt: 'one') attributeAt: 'one') + equals: ''; + assert: ((document root elementAt: 'two') attributeAt: 'two') + equals: 'value'. self shouldnt: [ - document := - XMLDOMParser parse: - '', goodContent] + document := XMLDOMParser parse: + '' , goodContent ] raise: XMLValidationException. self - assert: ((document root elementAt: 'one') attributeAt: 'one') = 'value'; - assert: ((document root elementAt: 'two') attributeAt: 'two') = 'value'. + assert: ((document root elementAt: 'one') attributeAt: 'one') + equals: 'value'; + assert: ((document root elementAt: 'two') attributeAt: 'two') + equals: 'value'. self shouldnt: [ - document := - (XMLDOMParser on: - '', goodContent) - externalEntityResolver: - (DTDStaticExternalEntityResolver externalEntities: - (Array with: 'extern.dtd' -> goodSubset)); - resolvesExternalEntities: true; - parseDocument] + document := (XMLDOMParser on: + '' , goodContent) + externalEntityResolver: + (DTDStaticExternalEntityResolver externalEntities: + (Array with: 'extern.dtd' -> goodSubset)); + resolvesExternalEntities: true; + parseDocument ] raise: XMLValidationException. self - assert: ((document root elementAt: 'one') attributeAt: 'one') = 'value'; - assert: ((document root elementAt: 'two') attributeAt: 'two') = 'value'. + assert: ((document root elementAt: 'one') attributeAt: 'one') + equals: 'value'; + assert: ((document root elementAt: 'two') attributeAt: 'two') + equals: 'value'. "#FIXED default values cannot be changed" self - should: [SAXHandler parse: '', badContent] + should: [ + SAXHandler parse: + '' , badContent ] raise: XMLValidationException. self should: [ - (SAXHandler on: '', badContent) + (SAXHandler on: '' , badContent) externalEntityResolver: (DTDStaticExternalEntityResolver externalEntities: - (Array with: 'extern.dtd' -> goodSubset)); + (Array with: 'extern.dtd' -> goodSubset)); resolvesExternalEntities: true; - parseDocument] + parseDocument ] raise: XMLValidationException. "...unless validation is off" self shouldnt: [ - (SAXHandler on: '', badContent) + (SAXHandler on: + '' , badContent) isValidating: false; - parseDocument] + parseDocument ] raise: XMLValidationException. self shouldnt: [ - (SAXHandler on: '', badContent) + (SAXHandler on: '' , badContent) externalEntityResolver: (DTDStaticExternalEntityResolver externalEntities: - (Array with: 'extern.dtd' -> goodSubset)); + (Array with: 'extern.dtd' -> goodSubset)); resolvesExternalEntities: true; isValidating: false; - parseDocument] - raise: XMLValidationException]. + parseDocument ] + raise: XMLValidationException ] ] { #category : #tests } XMLParserTest >> testAttributeDefaultImplied [ - | dtd document root | + | dtd document root | dtd := ' @@ -1198,34 +1196,33 @@ XMLParserTest >> testAttributeDefaultImplied [ two CDATA #IMPLIED > ]>'. - document := - XMLDOMParser parse: - dtd, ''. + document := XMLDOMParser parse: + dtd , ''. root := document root. self - assert: (root attributeAt: 'one') = 'nonDefault'; - assert: (root attributeAt: 'two') = 'nonDefaultTwo'. + assert: (root attributeAt: 'one') equals: 'nonDefault'; + assert: (root attributeAt: 'two') equals: 'nonDefaultTwo'. - document := XMLDOMParser parse: dtd, ''. + document := XMLDOMParser parse: dtd , ''. root := document root. self assert: (root includesAttribute: 'one'); - assert: (root attributeAt: 'one') = ''; + assert: (root attributeAt: 'one') equals: ''; assert: (root includesAttribute: 'two'); - assert: (root attributeAt: 'two') = ''. + assert: (root attributeAt: 'two') equals: ''. "implied makes them optional" - document := XMLDOMParser parse: dtd, ''. + document := XMLDOMParser parse: dtd , ''. root := document root. self deny: (root includesAttribute: 'one'); - deny: (root includesAttribute: 'two'). + deny: (root includesAttribute: 'two') ] { #category : #tests } XMLParserTest >> testAttributeDefaultRequired [ - | dtd document root | + | dtd document root | dtd := ' @@ -1235,35 +1232,34 @@ XMLParserTest >> testAttributeDefaultRequired [ two CDATA #REQUIRED > ]>'. - document := - XMLDOMParser parse: - dtd, ''. + document := XMLDOMParser parse: + dtd , ''. root := document root. self - assert: (root attributeAt: 'one') = 'nonDefault'; - assert: (root attributeAt: 'two') = 'nonDefaultTwo'. + assert: (root attributeAt: 'one') equals: 'nonDefault'; + assert: (root attributeAt: 'two') equals: 'nonDefaultTwo'. "empty values still count as being present" - document := XMLDOMParser parse: dtd, ''. + document := XMLDOMParser parse: dtd , ''. root := document root. self assert: (root includesAttribute: 'one'); - assert: (root attributeAt: 'one') = ''; + assert: (root attributeAt: 'one') equals: ''; assert: (root includesAttribute: 'two'); - assert: (root attributeAt: 'two') = ''. + assert: (root attributeAt: 'two') equals: ''. "all required attributes must be present" - #('' - '') do: [:each | + #( '' '' ) do: [ + :each | self - should: [SAXHandler parse: dtd, each] - raise: XMLValidationException]. + should: [ SAXHandler parse: dtd , each ] + raise: XMLValidationException ] ] { #category : #tests } XMLParserTest >> testAttributeDefaultValue [ - | dtd | + | dtd | dtd := ' @@ -1274,40 +1270,38 @@ XMLParserTest >> testAttributeDefaultValue [ three NMTOKEN " defaultThree " > ]>'. - #(true false) do: [:isValidating | | document root | - document := - (XMLDOMParser on: - dtd, - '') - isValidating: isValidating; - parseDocument. + #( true false ) do: [ :isValidating | + | document root | + document := (XMLDOMParser on: + dtd , '') + isValidating: isValidating; + parseDocument. root := document root. self - assert: (root attributeAt: 'one') = 'nonDefault'; - assert: (root attributeAt: 'two') = 'nonDefaultTwo'; - assert: (root attributeAt: 'three') = 'nonDefaultThree'. + assert: (root attributeAt: 'one') equals: 'nonDefault'; + assert: (root attributeAt: 'two') equals: 'nonDefaultTwo'; + assert: (root attributeAt: 'three') equals: 'nonDefaultThree'. "empty but present attributes shouldn't get the default value" - document := XMLDOMParser parse: dtd, ''. + document := XMLDOMParser parse: dtd , ''. root := document root. - self - assert: (root includesAttribute: 'one'); - assert: (root attributeAt: 'one') = ''; - assert: (root includesAttribute: 'two'); - assert: (root attributeAt: 'two') = ''; - assert: (root attributeAt: 'three') = 'defaultThree'. + self + assert: (root includesAttribute: 'one'); + assert: (root attributeAt: 'one') equals: ''; + assert: (root includesAttribute: 'two'); + assert: (root attributeAt: 'two') equals: ''; + assert: (root attributeAt: 'three') equals: 'defaultThree'. "attributes with defaults are set automatically if not present" - document := XMLDOMParser parse: dtd, ''. + document := XMLDOMParser parse: dtd , ''. root := document root. self - assert: (root attributeAt: 'one') = 'default'; + assert: (root attributeAt: 'one') equals: 'default'; assert: (root includesAttribute: 'two'); - assert: (root attributeAt: 'two') = ''; - assert: (root attributeAt: 'three') = 'defaultThree']. + assert: (root attributeAt: 'two') equals: ''; + assert: (root attributeAt: 'three') equals: 'defaultThree' ] ] { #category : #tests } @@ -1379,118 +1373,116 @@ XMLParserTest >> testAttributeDefaultValueEntityReference [ "tests that general entities referenced in attribute declaration default values were declared before the declaration is parsed" - #(' + #( ' - ' - "no ID test because they can't have default values, but IDREF/IDREFS can" - ' + ' ' - ' - ' + ' ' - ' - ' + ' ' - ' - ' + ' ' - ' - ' + ' ' ' - ' + ' - ' - ' + ' ' - ' - ' + ' ' - ') - do: [:each | | badSubset goodSubset content document| + ' ) do: [ :each | "no ID test because they can't have default values, but IDREF/IDREFS can" + | badSubset goodSubset content document | "the 'undeclared' entity declaration must come before the rest of the subset for it to be OK" - badSubset := each, ''. - goodSubset := '', each. - content := - ' + badSubset := each , ''. + goodSubset := '' , each. + content := ' '. self - should: [SAXHandler parse: '', content] + should: [ + SAXHandler parse: '' , content ] raise: XMLWellFormednessException. self should: [ - (SAXHandler on: '', content) + (SAXHandler on: '' , content) externalEntityResolver: (DTDStaticExternalEntityResolver externalEntities: - (Array with: 'extern.dtd' -> badSubset)); + (Array with: 'extern.dtd' -> badSubset)); resolvesExternalEntities: true; - parseDocument] + parseDocument ] raise: XMLValidationException. self shouldnt: [ - document := - (XMLDOMParser on: '', content) - externalEntityResolver: - (DTDStaticExternalEntityResolver externalEntities: - (Array with: 'extern.dtd' -> badSubset)); - resolvesExternalEntities: true; - isValidating: false; - parseDocument] + document := (XMLDOMParser on: + '' , content) + externalEntityResolver: + (DTDStaticExternalEntityResolver externalEntities: + (Array with: 'extern.dtd' -> badSubset)); + resolvesExternalEntities: true; + isValidating: false; + parseDocument ] raise: XMLValidationException. self - assert: ((document root elementAt: 'one') attributeAt: 'one') = ''; - assert: ((document root elementAt: 'two') attributeAt: 'two') = 'value'. + assert: ((document root elementAt: 'one') attributeAt: 'one') + equals: ''; + assert: ((document root elementAt: 'two') attributeAt: 'two') + equals: 'value'. self shouldnt: [ - document := - XMLDOMParser parse: '', content] + document := XMLDOMParser parse: + '' , content ] raise: XMLValidationException. self - assert: ((document root elementAt: 'one') attributeAt: 'one') = 'value'; - assert: ((document root elementAt: 'two') attributeAt: 'two') = 'value'. + assert: ((document root elementAt: 'one') attributeAt: 'one') + equals: 'value'; + assert: ((document root elementAt: 'two') attributeAt: 'two') + equals: 'value'. self shouldnt: [ - document := - (XMLDOMParser on: '', content) - externalEntityResolver: - (DTDStaticExternalEntityResolver externalEntities: - (Array with: 'extern.dtd' -> goodSubset)); - resolvesExternalEntities: true; - parseDocument] + document := (XMLDOMParser on: + '' , content) + externalEntityResolver: + (DTDStaticExternalEntityResolver externalEntities: + (Array with: 'extern.dtd' -> goodSubset)); + resolvesExternalEntities: true; + parseDocument ] raise: XMLValidationException. self - assert: ((document root elementAt: 'one') attributeAt: 'one') = 'value'; - assert: ((document root elementAt: 'two') attributeAt: 'two') = 'value'] + assert: ((document root elementAt: 'one') attributeAt: 'one') + equals: 'value'; + assert: ((document root elementAt: 'two') attributeAt: 'two') + equals: 'value' ] ] { #category : #tests } @@ -1648,8 +1640,8 @@ XMLParserTest >> testAttributeDefaultValueNmtokens [ { #category : #tests } XMLParserTest >> testAttributeDefaultValueNonProcessing [ - | dtd document root | + | dtd document root | dtd := ' @@ -1658,20 +1650,19 @@ XMLParserTest >> testAttributeDefaultValueNonProcessing [ ]>'. - document := - (XMLDOMParser on: dtd, '') - isValidating: false; - parseDocument. + document := (XMLDOMParser on: dtd , '') + isValidating: false; + parseDocument. root := document root. self - assert: root attributeNodes size = 1; - assert: (root attributeAt: 'one') = 'default'. + assert: root attributeNodes size equals: 1; + assert: (root attributeAt: 'one') equals: 'default' ] { #category : #tests } XMLParserTest >> testAttributeDefaultValueNonProcessingStandalone [ - | dtd document root | + | dtd document root | dtd := ' @@ -1680,15 +1671,14 @@ XMLParserTest >> testAttributeDefaultValueNonProcessingStandalone [ ]>'. - document := - (XMLDOMParser on: dtd, '') - isValidating: false; - parseDocument. + document := (XMLDOMParser on: dtd , '') + isValidating: false; + parseDocument. root := document root. self - assert: root attributeNodes size = 2; - assert: (root attributeAt: 'one') = 'default'; - assert: (root attributeAt: 'two') = 'defaultTwo'. + assert: root attributeNodes size equals: 2; + assert: (root attributeAt: 'one') equals: 'default'; + assert: (root attributeAt: 'two') equals: 'defaultTwo' ] { #category : #tests } @@ -1814,21 +1804,20 @@ XMLParserTest >> testAttributeValueExternalEntityReference [ { #category : #tests } XMLParserTest >> testAttributeValueNormalization [ - | separators unnormalized normalized document | - separators := - String - with: Character space - with: Character tab - with: Character lf. - unnormalized := separators, 'nonspace', separators. + | separators unnormalized normalized document | + separators := String + with: Character space + with: Character tab + with: Character lf. + unnormalized := separators , 'nonspace' , separators. normalized := ' nonspace '. - document := - (XMLDOMParser parse: - '', unnormalized, ''). + document := XMLDOMParser parse: + '' , unnormalized + , ''. self - assert: (document root attributeAt: 'name') = normalized; - assert: (document root contentString) = unnormalized. + assert: (document root attributeAt: 'name') equals: normalized; + assert: document root contentString equals: unnormalized ] { #category : #tests } @@ -1846,10 +1835,9 @@ XMLParserTest >> testAttributeValueWithAngleBrackets [ { #category : #tests } XMLParserTest >> testAttributeXMLBase [ - | document | - document := - XMLDOMParser parse: ' + | document | + document := XMLDOMParser parse: ' test @@ -1858,30 +1846,32 @@ XMLParserTest >> testAttributeXMLBase [ '. - self assert: - (document allElementsCollect: [:each | each attributeAt: 'xml:base']) asArray = - #('a/b' 'a/c/d' '/e/f' 'a/c/d' ''). - - "resolution should not cause decoding/encoding" - document := - XMLDOMParser parse: ' + self + assert: + (document allElementsCollect: [ :each | + each attributeAt: 'xml:base' ]) asArray + equals: #( 'a/b' 'a/c/d' '/e/f' 'a/c/d' '' ). + document := XMLDOMParser parse: ' test '. - self assert: - (document allElementsCollect: [:each | each attributeAt: 'xml:base']) asArray = - #('[%61]/{%62}' '[%61]/{%63}/(%64)' '/!%65!/|%66|'). - - document := - XMLDOMParser - parse: - ' + self + assert: + (document allElementsCollect: [ :each | + each attributeAt: 'xml:base' ]) asArray + equals: #( '[%61]/{%62}' '[%61]/{%63}/(%64)' '/!%65!/|%66|' ). + + document := XMLDOMParser + parse: + ' ' - documentURI: 'doc.xml'. - self assert: (document root attributeAt: 'xml:base') = 'doc.xml'. + documentURI: 'doc.xml'. + self + assert: (document root attributeAt: 'xml:base') + equals: 'doc.xml' ] { #category : #tests } @@ -1961,25 +1951,24 @@ XMLParserTest >> testAttributeXMLIDValidation [ { #category : #tests } XMLParserTest >> testAttributeXMLReserved [ - | xml document element | + | xml document element | xml := ''. document := XMLDOMParser parse: xml usingNamespaces: true. element := document root. self - assert: element attributes size = 4; - assert: (element attributeAt: 'xml') = 'one'; - assert: (element attributeAt: 'xmll') = 'two'; - assert: (element attributeAt: 'xml:') = 'three'; - assert: (element attributeAt: 'xmlnss') = 'four'. + assert: element attributes size equals: 4; + assert: (element attributeAt: 'xml') equals: 'one'; + assert: (element attributeAt: 'xmll') equals: 'two'; + assert: (element attributeAt: 'xml:') equals: 'three'; + assert: (element attributeAt: 'xmlnss') equals: 'four' ] { #category : #tests } XMLParserTest >> testAttributeXMLReservedNamespaces [ - | xml xmlWithDuplicateID document element | - xml := - ''. + xmlWithDuplicateID := '' , xml , ''. self - should: [SAXHandler parse: xmlWithDuplicateID] - raise: XMLValidationException. + should: [ SAXHandler parse: xmlWithDuplicateID ] + raise: XMLValidationException ] { #category : #tests } @@ -3471,8 +3457,8 @@ XMLParserTest >> testEntityDeclarationWhitespace [ { #category : #tests } XMLParserTest >> testEntityExternalResolutionGeneral [ - | xml entities document | + | xml entities document | xml := ' @@ -3480,49 +3466,47 @@ XMLParserTest >> testEntityExternalResolutionGeneral [ ]> &extern;&extern2;&extern3;'. - entities := - Array - with: - '/base/extern.ent' -> - 'one' - with: - '/base/extern2.ent' -> - 'two' - with: '/base/extern3.ent' -> 'three'. - 1 to: entities size - 1 do: [:i | + entities := Array + with: + '/base/extern.ent' + -> 'one' + with: + '/base/extern2.ent' -> 'two' + with: '/base/extern3.ent' -> 'three'. + 1 to: entities size - 1 do: [ :i | self should: [ (SAXHandler on: xml) externalEntityResolver: (DTDStaticExternalEntityResolver externalEntities: - (entities copyFrom: 1 to: i)); + (entities copyFrom: 1 to: i)); resolvesExternalEntities: true; - parseDocument] - raise: XMLParserException]. + parseDocument ] + raise: XMLParserException ]. self should: [ (SAXHandler on: xml) externalEntityResolver: (DTDStaticExternalEntityResolver externalEntities: entities); resolvesExternalEntities: false; - parseDocument] + parseDocument ] raise: XMLParserException. self shouldnt: [ - document := - (XMLDOMParser on: xml) - externalEntityResolver: - (DTDStaticExternalEntityResolver externalEntities: entities); - resolvesExternalEntities: true; - parseDocument] + document := (XMLDOMParser on: xml) + externalEntityResolver: + (DTDStaticExternalEntityResolver externalEntities: + entities); + resolvesExternalEntities: true; + parseDocument ] raise: XMLParserException. - self assert: document root contentString = 'onetwothree'. + self assert: document root contentString equals: 'onetwothree' ] { #category : #tests } XMLParserTest >> testEntityExternalResolutionParameter [ - | xml entities document | + | xml entities document | xml := ' @@ -3531,40 +3515,37 @@ XMLParserTest >> testEntityExternalResolutionParameter [ %extern3; ]> &extern4;'. - entities := - Array - with: - '/base/extern.ent' -> - ' + entities := Array + with: + '/base/extern.ent' + -> ' ' - with: - '/base/sub/extern2.ent' -> - ' + with: + '/base/sub/extern2.ent' -> ' ' - with: - '/base/sub/extern3.ent' -> - ' + with: '/base/sub/extern3.ent' + -> ' ' - with: - '/base/sub/extern5.ent' -> - 'test'. - 1 to: entities size - 1 do: [:i | + with: + '/base/sub/extern5.ent' + -> 'test'. + 1 to: entities size - 1 do: [ :i | self should: [ (SAXHandler on: xml) externalEntityResolver: (DTDStaticExternalEntityResolver externalEntities: - (entities copyFrom: 1 to: i)); + (entities copyFrom: 1 to: i)); resolvesExternalEntities: true; - parseDocument] - raise: XMLParserException]. + parseDocument ] + raise: XMLParserException ]. self should: [ (SAXHandler on: xml) externalEntityResolver: (DTDStaticExternalEntityResolver externalEntities: entities); resolvesExternalEntities: false; - parseDocument] + parseDocument ] raise: XMLParserException. self shouldnt: [ @@ -3573,18 +3554,18 @@ XMLParserTest >> testEntityExternalResolutionParameter [ (DTDStaticExternalEntityResolver externalEntities: entities); resolvesExternalEntities: false; isValidating: false; - parseDocument] + parseDocument ] raise: XMLParserException. self shouldnt: [ - document := - (XMLDOMParser on: xml) - externalEntityResolver: - (DTDStaticExternalEntityResolver externalEntities: entities); - resolvesExternalEntities: true; - parseDocument] + document := (XMLDOMParser on: xml) + externalEntityResolver: + (DTDStaticExternalEntityResolver externalEntities: + entities); + resolvesExternalEntities: true; + parseDocument ] raise: XMLParserException. - self assert: document root contentString = 'test'. + self assert: document root contentString equals: 'test' ] { #category : #tests } @@ -3679,8 +3660,8 @@ XMLParserTest >> testEntityExternalSubsetResolution [ { #category : #tests } XMLParserTest >> testEntityLiteralContextNesting [ - | xml inner outer document | + | xml inner outer document | xml := ' "> @@ -3689,17 +3670,17 @@ XMLParserTest >> testEntityLiteralContextNesting [ ]> &outer;&inner;'. inner := ' '' inner '' '. - outer := ' '' " ', inner, ' '' " '. + outer := ' '' " ' , inner , ' '' " '. self - shouldnt: [document := XMLDOMParser parse: xml] + shouldnt: [ document := XMLDOMParser parse: xml ] raise: XMLWellFormednessException. self - assert: (document root attributeAt: 'one') = outer; - assert: (document root attributeAt: 'two') = inner; - assert: (document root attributeAt: 'three') = outer; - assert: (document root attributeAt: 'four') = inner; - assert: (document root contentString) = (outer, inner). + assert: (document root attributeAt: 'one') equals: outer; + assert: (document root attributeAt: 'two') equals: inner; + assert: (document root attributeAt: 'three') equals: outer; + assert: (document root attributeAt: 'four') equals: inner; + assert: document root contentString equals: outer , inner ] { #category : #tests } @@ -4500,29 +4481,32 @@ XMLParserTest >> testEntityReferenceInternalDeclarationExternallyDefined [ { #category : #tests } XMLParserTest >> testEntityReferencePredefined [ - | document references replacements | + | document references replacements | references := String new writeStream. replacements := String new writeStream. - XMLWellFormedParserTokenizer predefinedEntities keysAndValuesDo: [:name :char | + XMLWellFormedParserTokenizer predefinedEntities keysAndValuesDo: [ + :name + :char | references nextPut: $&; nextPutAll: name; nextPut: $;. - replacements nextPut: char]. + replacements nextPut: char ]. - document := - XMLDOMParser parse: - (']> {1} &nonRecursive; ' format: (Array with: references contents)). self - assert: (document root attributeAt: 'name') = replacements contents; - assert: (document root contentStringAt: 'one') = replacements contents; - assert: (document root contentStringAt: 'two') = '&nonRecursive;'. + assert: (document root attributeAt: 'name') + equals: replacements contents; + assert: (document root contentStringAt: 'one') + equals: replacements contents; + assert: (document root contentStringAt: 'two') + equals: '&nonRecursive;' ] { #category : #tests } @@ -4619,8 +4603,8 @@ XMLParserTest >> testEntityReferenceUndeclaredInEntityValue [ { #category : #tests } XMLParserTest >> testEntityReferenceUndeclaredPreserved [ - | xml parser document | + | xml parser document | xml := ' @@ -4631,12 +4615,13 @@ XMLParserTest >> testEntityReferenceUndeclaredPreserved [ isValidating: false; preservesUndeclaredEntityReferences: true. document := parser parseDocument. - self - assert: document doctypeDeclaration nodes size = 1; - assert: document doctypeDeclaration firstNode replacement = '&undeclaredOne;'; - assert: (document root attributeAt: 'name') = '"&undeclaredOne;"'; - assert: (document root contentString) = '<&undeclaredTwo;>'. + assert: document doctypeDeclaration nodes size equals: 1; + assert: document doctypeDeclaration firstNode replacement + equals: '&undeclaredOne;'; + assert: (document root attributeAt: 'name') + equals: '"&undeclaredOne;"'; + assert: document root contentString equals: '<&undeclaredTwo;>' ] { #category : #tests } @@ -4670,49 +4655,50 @@ XMLParserTest >> testEntityReferenceUnexpected [ { #category : #tests } XMLParserTest >> testEntityReferenceUnreplaced [ - | beforeSubset subset afterSubset xml document | + | beforeSubset subset afterSubset xml document | beforeSubset := ' "> + subset := '"> %first;'. afterSubset := ']>&second;'. - xml := beforeSubset, subset, afterSubset. - self assert: (XMLDOMParser parse: xml) root contentString = 'replacement'. - - document := - (XMLDOMParser on: xml) - replacesContentEntityReferences: false; - parseDocument. - self assert: document root contentString = '&second;'. + xml := beforeSubset , subset , afterSubset. + self + assert: (XMLDOMParser parse: xml) root contentString + equals: 'replacement'. + + document := (XMLDOMParser on: xml) + replacesContentEntityReferences: false; + parseDocument. + self assert: document root contentString equals: '&second;'. self should: [ - (SAXHandler on: (beforeSubset, '%first;]>')) + (SAXHandler on: beforeSubset , '%first;]>') replacesContentEntityReferences: false; - parseDocument] - raise: XMLValidationException. + parseDocument ] + raise: XMLValidationException ] { #category : #tests } XMLParserTest >> testEntityReferenceUnreplacedInContent [ - | xml document | + | xml document | xml := ' ]> <&declared;/>'. - document := - (XMLDOMParser on: xml) - replacesContentEntityReferences: false; - parseDocument. + document := (XMLDOMParser on: xml) + replacesContentEntityReferences: false; + parseDocument. self - assert: (document root attributeAt: 'two') = '"&declared;"'; - assert: document root contentString = '<&declared;/>'. + assert: (document root attributeAt: 'two') + equals: '"&declared;"'; + assert: document root contentString + equals: '<&declared;/>' ] { #category : #tests } XMLParserTest >> testEntityReferenceUnreplacedInContentUndeclared [ - | xml document | + | xml document | xml := ' @@ -4722,19 +4708,20 @@ XMLParserTest >> testEntityReferenceUnreplacedInContentUndeclared [ should: [ (SAXHandler on: xml) replacesContentEntityReferences: false; - parseDocument] + parseDocument ] raise: XMLValidationException. self shouldnt: [ - document := - (XMLDOMParser on: xml) - replacesContentEntityReferences: false; - isValidating: false; - parseDocument] + document := (XMLDOMParser on: xml) + replacesContentEntityReferences: false; + isValidating: false; + parseDocument ] raise: XMLValidationException. self - assert: (document root attributeAt: 'two') = '"&undeclared;"'; - assert: document root contentString = '<&undeclared;>'. + assert: (document root attributeAt: 'two') + equals: '"&undeclared;"'; + assert: document root contentString + equals: '<&undeclared;>' ] { #category : #tests } @@ -4794,8 +4781,8 @@ XMLParserTest >> testEntityReferenceUnterminatedInEntityValue [ { #category : #tests } XMLParserTest >> testEntityReplacement [ - | document | + | document | document := XMLDOMParser parse: ' "> @@ -4804,23 +4791,21 @@ XMLParserTest >> testEntityReplacement [ ]> - &name1; &name2; &name3; ', - '%name1Declaration;'. - self assert: - document root contentString = - ('replacement1 ', - 'replacement2 replacement1 ', - 'replacement3 replacement2 replacement1 ', - '%name1Declaration;'). - self assert: - (document root attributeAt: 'name') = - (('quoted "value"' copyWithFirst: $') copyWith: $'). + &name1; &name2; &name3; ' + , '%name1Declaration;'. + self + assert: document root contentString + equals: 'replacement1 ' , 'replacement2 replacement1 ' + , 'replacement3 replacement2 replacement1 ' , '%name1Declaration;'. + self + assert: (document root attributeAt: 'name') + equals: (('quoted "value"' copyWithFirst: $') copyWith: $') ] { #category : #tests } XMLParserTest >> testEntityReplacementEmpty [ - | xml document | + | xml document | xml := ' @@ -4830,14 +4815,14 @@ XMLParserTest >> testEntityReplacementEmpty [ &outer;&inner;'. self - shouldnt: [document := XMLDOMParser parse: xml] + shouldnt: [ document := XMLDOMParser parse: xml ] raise: XMLWellFormednessException. self - assert: (document root attributeAt: 'one') = ''; - assert: (document root attributeAt: 'two') = ''; - assert: (document root attributeAt: 'three') = ''; - assert: (document root attributeAt: 'four') = ''; - assert: document root contentString = ''. + assert: (document root attributeAt: 'one') equals: ''; + assert: (document root attributeAt: 'two') equals: ''; + assert: (document root attributeAt: 'three') equals: ''; + assert: (document root attributeAt: 'four') equals: ''; + assert: document root contentString equals: '' ] { #category : #tests } @@ -4887,8 +4872,8 @@ XMLParserTest >> testEntityReplacementSelfReferential [ { #category : #tests } XMLParserTest >> testEntityReplacementStandard [ "this test comes from the XML spec" - | dtd xml doc | + | dtd xml doc | dtd := ' @@ -4896,24 +4881,25 @@ XMLParserTest >> testEntityReplacementStandard [ xml := ' &book;'. - doc := - (XMLDOMParser on: xml) - externalEntityResolver: - (DTDStaticExternalEntityResolver externalEntities: - (Array with: 'extern.dtd' -> dtd)); - resolvesExternalEntities: true; - parseDocument. - self assert: - doc root contentString = - ('La Peste: Albert Camus, ', 16rA9 asCharacter asString, ' 1947 ', - 16rC9 asCharacter asString, 'ditions Gallimard. All rights reserved'). + doc := (XMLDOMParser on: xml) + externalEntityResolver: + (DTDStaticExternalEntityResolver externalEntities: + (Array with: 'extern.dtd' -> dtd)); + resolvesExternalEntities: true; + parseDocument. + self + assert: doc root contentString + equals: + 'La Peste: Albert Camus, ' , 16rA9 asCharacter asString , ' 1947 ' + , 16rC9 asCharacter asString + , 'ditions Gallimard. All rights reserved' ] { #category : #tests } XMLParserTest >> testEntityReplacementStandardLiteral [ "this test comes from the XML spec" - | dtd xml resolver doc | + | dtd xml resolver doc | dtd := ' '. @@ -4923,12 +4909,13 @@ XMLParserTest >> testEntityReplacementStandardLiteral [ (resolver := DTDStaticExternalEntityResolver new) externalEntityAtURI: 'extern.dtd' put: dtd. - doc := - (XMLDOMParser on: xml) - externalEntityResolver: resolver; - resolvesExternalEntities: true; - parseDocument. - self assert: (doc root attributeAt: 'attribute') = 'He said "Yes"'. + doc := (XMLDOMParser on: xml) + externalEntityResolver: resolver; + resolvesExternalEntities: true; + parseDocument. + self + assert: (doc root attributeAt: 'attribute') + equals: 'He said "Yes"'. dtd := ''. xml := ' @@ -4942,8 +4929,8 @@ XMLParserTest >> testEntityReplacementStandardLiteral [ (SAXHandler on: xml) externalEntityResolver: resolver; resolvesExternalEntities: true; - parseDocument] - raise: XMLWellFormednessException. + parseDocument ] + raise: XMLWellFormednessException ] { #category : #tests } @@ -4964,40 +4951,31 @@ XMLParserTest >> testEntityReplacementTerminatingInternalSubset [ { #category : #tests } XMLParserTest >> testEntityURIInheritance [ - | xml parser driver | + | xml parser driver | xml := '&second;'. - parser := - (SAXHandler - on: xml - documentURI: 'test.xml') parser. - (driver := parser driver) - doctypeDefinition parameterEntities - at: 'first' - put: - ((DTDExternalParameterParsedEntity name: 'first') - resolvedReplacement: - (DTDDecodedResolvedExternalParsedEntityReplacement contents: - '">'); - uri: 'test.ent'). - - self assert: driver baseURI = 'test.xml'. - - 3 timesRepeat: [parser parseToken]. - self assert: driver baseURI = 'test.ent'. - - 2 timesRepeat: [parser parseToken]. - self assert: driver baseURI = 'test.xml'. - - "internal entities (declared in the internal subset or in an external DTD) - can't change abase URI according to the xml:base spec" - 2 timesRepeat: [parser parseToken]. - self assert: driver baseURI = '/new/xml'. + parser := (SAXHandler on: xml documentURI: 'test.xml') parser. + (driver := parser driver) doctypeDefinition parameterEntities + at: 'first' + put: ((DTDExternalParameterParsedEntity name: 'first') + resolvedReplacement: + (DTDDecodedResolvedExternalParsedEntityReplacement contents: + '">'); + uri: 'test.ent'). + self assert: driver baseURI equals: 'test.xml'. + + 3 timesRepeat: [ parser parseToken ]. + self assert: driver baseURI equals: 'test.ent'. + + 2 timesRepeat: [ parser parseToken ]. + self assert: driver baseURI equals: 'test.xml'. + 2 timesRepeat: [ parser parseToken ]. + self assert: driver baseURI equals: '/new/xml'. - 3 timesRepeat: [parser parseToken]. + 3 timesRepeat: [ parser parseToken ]. self - assert: driver baseURI = 'test.xml'; - assert: parser atEnd. + assert: driver baseURI equals: 'test.xml'; + assert: parser atEnd ] { #category : #tests } @@ -5022,15 +5000,20 @@ XMLParserTest >> testIsInContent [ { #category : #tests } XMLParserTest >> testLineEndingsDoNotMatter [ - | source docFromSourceWithCRs docFromSourceWithLFs docFromSourceWithCRLFs | + | source docFromSourceWithCRs docFromSourceWithLFs docFromSourceWithCRLFs | source := '{1}one{1}two{1}'. - docFromSourceWithCRs := XMLDOMParser parse: (source format: (Array with: String cr)). - docFromSourceWithLFs := XMLDOMParser parse: (source format: (Array with: String lf)). - docFromSourceWithCRLFs := XMLDOMParser parse: (source format: (Array with: String crlf)). + docFromSourceWithCRs := XMLDOMParser parse: + (source format: (Array with: String cr)). + docFromSourceWithLFs := XMLDOMParser parse: + (source format: (Array with: String lf)). + docFromSourceWithCRLFs := XMLDOMParser parse: + (source format: (Array with: String crlf)). self - assert: (docFromSourceWithCRs root contentString) = (docFromSourceWithLFs root contentString); - assert: (docFromSourceWithLFs root contentString) = (docFromSourceWithCRLFs root contentString). + assert: docFromSourceWithCRs root contentString + equals: docFromSourceWithLFs root contentString; + assert: docFromSourceWithLFs root contentString + equals: docFromSourceWithCRLFs root contentString ] { #category : #tests } @@ -5997,8 +5980,8 @@ XMLParserTest >> testStandaloneExternalElementDeclarartionExternalSubset [ { #category : #tests } XMLParserTest >> testStandaloneExternalExternalEntity [ - | standalone notStandalone dtd resolver document | + | standalone notStandalone dtd resolver document | standalone := ''. notStandalone := ''. dtd := ' @@ -6008,56 +5991,53 @@ XMLParserTest >> testStandaloneExternalExternalEntity [ %extern; ]>'. - resolver := - DTDStaticExternalEntityResolver externalEntities: - (Array - with: 'extern.ent' -> '' - with: 'name.ent' -> 'value' - with: 'otherName.ent' -> 'otherValue'). + resolver := DTDStaticExternalEntityResolver externalEntities: (Array + with: + 'extern.ent' -> '' + with: 'name.ent' -> 'value' + with: 'otherName.ent' -> 'otherValue'). self should: [ - (SAXHandler on: standalone, dtd, '&name;') + (SAXHandler on: standalone , dtd , '&name;') externalEntityResolver: resolver copy; resolvesExternalEntities: true; - parseDocument] + parseDocument ] raise: XMLValidationException. self shouldnt: [ - document := - (XMLDOMParser on: standalone, dtd, '&name;') - externalEntityResolver: resolver copy; - resolvesExternalEntities: true; - isValidating: false; - parseDocument] + document := (XMLDOMParser on: + standalone , dtd , '&name;') + externalEntityResolver: resolver copy; + resolvesExternalEntities: true; + isValidating: false; + parseDocument ] raise: XMLParserException. - self assert: document contentString = 'value'. - "external entities only count as 'external markup declarations' in standalone - docs if they were defined in the external DTD subset or in a parameter entity" + self assert: document contentString equals: 'value'. self shouldnt: [ - document := - (XMLDOMParser on: standalone, dtd, '&otherName;') - externalEntityResolver: resolver copy; - resolvesExternalEntities: true; - parseDocument] + document := (XMLDOMParser on: + standalone , dtd , '&otherName;') + externalEntityResolver: resolver copy; + resolvesExternalEntities: true; + parseDocument ] raise: XMLValidationException. - self assert: document contentString = 'otherValue'. + self assert: document contentString equals: 'otherValue'. self shouldnt: [ - document := - (XMLDOMParser on: notStandalone, dtd, '&name;') - externalEntityResolver: resolver copy; - resolvesExternalEntities: true; - parseDocument] + document := (XMLDOMParser on: + notStandalone , dtd , '&name;') + externalEntityResolver: resolver copy; + resolvesExternalEntities: true; + parseDocument ] raise: XMLValidationException. - self assert: document contentString = 'value'. + self assert: document contentString equals: 'value' ] { #category : #tests } XMLParserTest >> testStandaloneExternalExternalEntityExternalSubset [ - | standalone notStandalone dtd subset resolver document | + | standalone notStandalone dtd subset resolver document | standalone := ''. notStandalone := ''. dtd := ' @@ -6068,52 +6048,49 @@ XMLParserTest >> testStandaloneExternalExternalEntityExternalSubset [ '. - resolver := - DTDStaticExternalEntityResolver externalEntities: - (Array - with: 'extern.dtd' -> subset - with: 'name.ent' -> 'value' - with: 'otherName.ent' -> 'otherValue'). + resolver := DTDStaticExternalEntityResolver externalEntities: (Array + with: 'extern.dtd' -> subset + with: 'name.ent' -> 'value' + with: 'otherName.ent' -> 'otherValue'). self should: [ - (SAXHandler on: standalone, dtd, '&name;') + (SAXHandler on: standalone , dtd , '&name;') externalEntityResolver: resolver copy; resolvesExternalEntities: true; - parseDocument] + parseDocument ] raise: XMLValidationException. self should: [ - (SAXHandler on: standalone, dtd, '&name;') + (SAXHandler on: standalone , dtd , '&name;') externalEntityResolver: resolver copy; resolvesExternalEntities: true; isValidating: false; - parseDocument] + parseDocument ] raise: XMLWellFormednessException. self shouldnt: [ - (SAXHandler on: standalone, dtd, '') + (SAXHandler on: standalone , dtd , '') externalEntityResolver: resolver copy; resolvesExternalEntities: true; - parseDocument] + parseDocument ] raise: XMLValidationException. self shouldnt: [ - document := - (XMLDOMParser on: notStandalone, dtd, '&name;') - externalEntityResolver: resolver copy; - resolvesExternalEntities: true; - parseDocument] + document := (XMLDOMParser on: + notStandalone , dtd , '&name;') + externalEntityResolver: resolver copy; + resolvesExternalEntities: true; + parseDocument ] raise: XMLValidationException. - self assert: document contentString = 'value'. + self assert: document contentString equals: 'value' ] { #category : #tests } XMLParserTest >> testStandaloneExternalExternalEntityRedundance [ - | standaloneXML resolver document | - standaloneXML := - ' + | standaloneXML resolver document | + standaloneXML := ' @@ -6122,20 +6099,18 @@ XMLParserTest >> testStandaloneExternalExternalEntityRedundance [ %extern; ]> &name;'. - resolver := - DTDStaticExternalEntityResolver externalEntities: - (Array - with: 'extern.ent' -> '' - with: 'name.ent' -> 'otherValue'). + resolver := DTDStaticExternalEntityResolver externalEntities: (Array + with: + 'extern.ent' -> '' + with: 'name.ent' -> 'otherValue'). self shouldnt: [ - document := - (XMLDOMParser on: standaloneXML) - externalEntityResolver: resolver copy; - resolvesExternalEntities: true; - parseDocument] + document := (XMLDOMParser on: standaloneXML) + externalEntityResolver: resolver copy; + resolvesExternalEntities: true; + parseDocument ] raise: XMLValidationException. - self assert: document contentString = 'value'. + self assert: document contentString equals: 'value' ] { #category : #tests } @@ -6173,7 +6148,7 @@ XMLParserTest >> testStandaloneExternalInternalEntity [ document := XMLDOMParser parse: notStandalone , dtd , '&name;' ] raise: XMLValidationException. - self assert: document contentString = 'value' + self assert: document contentString equals: 'value' ] { #category : #tests } diff --git a/src/XML-Parser-Tests/XMLPluggableElementFactoryTest.class.st b/src/XML-Parser-Tests/XMLPluggableElementFactoryTest.class.st index 3e46a010..d491584e 100644 --- a/src/XML-Parser-Tests/XMLPluggableElementFactoryTest.class.st +++ b/src/XML-Parser-Tests/XMLPluggableElementFactoryTest.class.st @@ -64,106 +64,110 @@ XMLPluggableElementFactoryTest >> tableElementClass [ { #category : #tests } XMLPluggableElementFactoryTest >> testAddElementNamed [ - | element userElement dataElement | + | element userElement dataElement | element := XMLElement name: 'root'. element defaultNamespace: 'dataNS'; declarePrefix: 'prefix' uri: 'prefixNS'. - element nodeFactory: - (XMLPluggableElementFactory new - handleElement: 'data' - namespaceURI: 'dataNS' - withClass: XMLFElement; - handleElement: 'user' - namespaceURI: 'prefixNS' - withClass: XMLFUserElement). + element nodeFactory: (XMLPluggableElementFactory new + handleElement: 'data' + namespaceURI: 'dataNS' + withClass: XMLFElement; + handleElement: 'user' + namespaceURI: 'prefixNS' + withClass: XMLFUserElement). userElement := element addElementNamed: 'prefix:user'. self - assert: userElement class == XMLFUserElement; + assert: userElement class identicalTo: XMLFUserElement; assert: (userElement isNamed: 'prefix:user'); - assert: userElement namespaceURI = 'prefixNS'. + assert: userElement namespaceURI equals: 'prefixNS'. dataElement := element addElementNamed: 'data'. self - assert: dataElement class == XMLFElement; + assert: dataElement class identicalTo: XMLFElement; assert: (dataElement isNamed: 'data'); - assert: dataElement namespaceURI = 'dataNS'. - - self assert: (element addElementNamed: 'default') class == XMLElement + assert: dataElement namespaceURI equals: 'dataNS'. + self + assert: (element addElementNamed: 'default') class + identicalTo: XMLElement ] { #category : #tests } XMLPluggableElementFactoryTest >> testClassForElement [ - | factory | + | factory | (factory := self newFactoryWithClasses) handleElement: 'user' withClass: self userElementClass. self - assert: (factory classForElement: 'user') == self userElementClass; - assert: (factory classForElement: 'prefix:user') == self userElementClass; - assert: (factory classForElement: 'absent') == self elementClass. + assert: (factory classForElement: 'user') + identicalTo: self userElementClass; + assert: (factory classForElement: 'prefix:user') + identicalTo: self userElementClass; + assert: (factory classForElement: 'absent') + identicalTo: self elementClass. factory handleElement: 'prefix:user' withClass: self usernameElementClass. self - assert: (factory classForElement: 'user') == self userElementClass; - assert: (factory classForElement: 'prefix:user') == self usernameElementClass; - assert: (factory classForElement: 'prefix:absent') == self elementClass + assert: (factory classForElement: 'user') + identicalTo: self userElementClass; + assert: (factory classForElement: 'prefix:user') + identicalTo: self usernameElementClass; + assert: (factory classForElement: 'prefix:absent') + identicalTo: self elementClass ] { #category : #tests } XMLPluggableElementFactoryTest >> testClassForElementNamespaceURI [ - | factory | + | factory | (factory := self newFactoryWithClasses) handleElement: 'user' namespaceURI: 'userNS' withClass: self userElementClass. - self assert: - (factory - classForElement: 'user' - namespaceURI: 'userNS') == self userElementClass. - self assert: - (factory - classForElement: 'prefix:user' - namespaceURI: 'userNS') == self userElementClass. - self assert: - (factory - classForElement: 'user' - namespaceURI: 'absentNS') == self elementClass. + self + assert: (factory classForElement: 'user' namespaceURI: 'userNS') + identicalTo: self userElementClass. + self + assert: + (factory classForElement: 'prefix:user' namespaceURI: 'userNS') + identicalTo: self userElementClass. + self + assert: (factory classForElement: 'user' namespaceURI: 'absentNS') + identicalTo: self elementClass. factory handleElement: 'prefix:user' namespaceURI: 'userNS' withClass: self usernameElementClass. - self assert: - (factory - classForElement: 'user' - namespaceURI: 'userNS') == self userElementClass. - self assert: - (factory - classForElement: 'prefix:user' - namespaceURI: 'userNS') == self usernameElementClass. - self assert: - (factory - classForElement: 'prefix:user' - namespaceURI: 'absentNS') == self elementClass + self + assert: (factory classForElement: 'user' namespaceURI: 'userNS') + identicalTo: self userElementClass. + self + assert: + (factory classForElement: 'prefix:user' namespaceURI: 'userNS') + identicalTo: self usernameElementClass. + self + assert: + (factory classForElement: 'prefix:user' namespaceURI: 'absentNS') + identicalTo: self elementClass ] { #category : #tests } XMLPluggableElementFactoryTest >> testCopy [ - | factory copy | + | factory copy | factory := self newFactoryWithClasses. factory handleElement: 'user' withClass: XMLFUserElement. copy := factory copy. self - deny: copy == factory; - deny: copy elementClassMapper == factory elementClassMapper + deny: copy identicalTo: factory; + deny: copy elementClassMapper + identicalTo: factory elementClassMapper ] { #category : #tests } @@ -185,16 +189,19 @@ XMLPluggableElementFactoryTest >> testElementClassAccessor [ { #category : #tests } XMLPluggableElementFactoryTest >> testElementClassMapper [ - | factory oldMapper newMapper | + | factory oldMapper newMapper | factory := self newFactoryWithClasses. oldMapper := factory elementClassMapper. - self assert: oldMapper class == self elementClassMapperClass. + self + assert: oldMapper class + identicalTo: self elementClassMapperClass. newMapper := self elementClassMapperClass new. self - assert: (factory elementClassMapper: newMapper) == factory; - assert: factory elementClassMapper == newMapper + assert: (factory elementClassMapper: newMapper) + identicalTo: factory; + assert: factory elementClassMapper identicalTo: newMapper ] { #category : #tests } @@ -284,44 +291,44 @@ XMLPluggableElementFactoryTest >> testElementsNameAndNamespaceMatching [ { #category : #tests } XMLPluggableElementFactoryTest >> testHandleElementsMatchingClass [ - | document | - - document := - (XMLDOMParser on: self sampleUsersXML) - nodeFactory: - (XMLPluggableElementFactory new - handleElementsMatchingClass: XMLFUserElement; - handleElementsMatchingClass: XMLFUsernameElement; - handleElementsMatchingClass: XMLFRealNameElement); - parseDocument. - document root elementsDo: [:element | - self - assert: (element class == XMLFUserElement); - assert: (element elements first class == XMLFUsernameElement); - assert: (element elements second class == XMLFRealNameElement)] + | document | + document := (XMLDOMParser on: self sampleUsersXML) + nodeFactory: (XMLPluggableElementFactory new + handleElementsMatchingClass: XMLFUserElement; + handleElementsMatchingClass: XMLFUsernameElement; + handleElementsMatchingClass: XMLFRealNameElement); + parseDocument. + + document root elementsDo: [ :element | + self + assert: element class identicalTo: XMLFUserElement; + assert: element elements first class + identicalTo: XMLFUsernameElement; + assert: element elements second class + identicalTo: XMLFRealNameElement ] ] { #category : #tests } XMLPluggableElementFactoryTest >> testHandleElementsMatchingClasses [ - | document | - document := - (XMLDOMParser on: self sampleUsersXML) - nodeFactory: - (XMLPluggableElementFactory new - handleElementsMatchingClasses: - (Array - with: XMLFUserElement - with: XMLFUsernameElement - with: XMLFRealNameElement)); - parseDocument. - - document root elementsDo: [:element | - self - assert: (element class == XMLFUserElement); - assert: (element elements first class == XMLFUsernameElement); - assert: (element elements second class == XMLFRealNameElement)] + | document | + document := (XMLDOMParser on: self sampleUsersXML) + nodeFactory: + (XMLPluggableElementFactory new + handleElementsMatchingClasses: (Array + with: XMLFUserElement + with: XMLFUsernameElement + with: XMLFRealNameElement)); + parseDocument. + + document root elementsDo: [ :element | + self + assert: element class identicalTo: XMLFUserElement; + assert: element elements first class + identicalTo: XMLFUsernameElement; + assert: element elements second class + identicalTo: XMLFRealNameElement ] ] { #category : #accessing } diff --git a/src/XML-Parser-Tests/XMLPluggableNodeFactoryTest.class.st b/src/XML-Parser-Tests/XMLPluggableNodeFactoryTest.class.st index d8c9429b..818879e1 100644 --- a/src/XML-Parser-Tests/XMLPluggableNodeFactoryTest.class.st +++ b/src/XML-Parser-Tests/XMLPluggableNodeFactoryTest.class.st @@ -67,222 +67,238 @@ XMLPluggableNodeFactoryTest >> stringNodeClass [ { #category : #tests } XMLPluggableNodeFactoryTest >> testAttributeListClass [ - | factory | + | factory | super testAttributeListClass. factory := self newFactoryWithClasses. self - assert: (factory attributeListClass: self attributeListClass) == factory; - assert: factory attributeListClass == self attributeListClass + assert: (factory attributeListClass: self attributeListClass) + identicalTo: factory; + assert: factory attributeListClass + identicalTo: self attributeListClass ] { #category : #tests } XMLPluggableNodeFactoryTest >> testCDataClass [ - super testCDataClass. - self assert: self newFactoryWithClasses cdataClass == self cdataClass + super testCDataClass. + self + assert: self newFactoryWithClasses cdataClass + identicalTo: self cdataClass ] { #category : #tests } XMLPluggableNodeFactoryTest >> testClassForElement [ - super testClassForElement. - self assert: (self newFactoryWithClasses classForElement: 'test') == self elementClass + super testClassForElement. + self + assert: (self newFactoryWithClasses classForElement: 'test') + identicalTo: self elementClass ] { #category : #tests } XMLPluggableNodeFactoryTest >> testClassForElementNamespaceURI [ - super testClassForElementNamespaceURI. - self assert: - (self newFactoryWithClasses - classForElement: 'test' - namespaceURI: '') == self elementClass. - self assert: - (self newFactoryWithClasses - classForElement: 'test' - namespaceURI: 'testNS') == self elementClass + super testClassForElementNamespaceURI. + self + assert: + (self newFactoryWithClasses classForElement: 'test' namespaceURI: '') + identicalTo: self elementClass. + self + assert: (self newFactoryWithClasses + classForElement: 'test' + namespaceURI: 'testNS') + identicalTo: self elementClass ] { #category : #tests } XMLPluggableNodeFactoryTest >> testCommentClass [ - super testCommentClass. - self assert: self newFactoryWithClasses commentClass == self commentClass + super testCommentClass. + self + assert: self newFactoryWithClasses commentClass + identicalTo: self commentClass ] { #category : #tests } XMLPluggableNodeFactoryTest >> testDocumentClass [ - super testDocumentClass. - self assert: self newFactoryWithClasses documentClass == self documentClass + super testDocumentClass. + self + assert: self newFactoryWithClasses documentClass + identicalTo: self documentClass ] { #category : #tests } XMLPluggableNodeFactoryTest >> testElementClass [ - super testElementClass. - self assert: self newFactoryWithClasses elementClass == self elementClass + super testElementClass. + self + assert: self newFactoryWithClasses elementClass + identicalTo: self elementClass ] { #category : #tests } XMLPluggableNodeFactoryTest >> testNewCData [ - | cdata | + | cdata | super testNewCData. cdata := self newFactoryWithClasses newCData: 'test'. self - assert: cdata class == self cdataClass; - assert: cdata string = 'test' + assert: cdata class identicalTo: self cdataClass; + assert: cdata string equals: 'test' ] { #category : #tests } XMLPluggableNodeFactoryTest >> testNewComment [ - | comment | + | comment | super testNewComment. comment := self newFactoryWithClasses newComment: 'test'. self - assert: comment class == self commentClass; - assert: comment string = 'test' + assert: comment class identicalTo: self commentClass; + assert: comment string equals: 'test' ] { #category : #tests } XMLPluggableNodeFactoryTest >> testNewDocument [ - super testNewDocument. - self assert: self newFactoryWithClasses newDocument class == self documentClass + super testNewDocument. + self + assert: self newFactoryWithClasses newDocument class + identicalTo: self documentClass ] { #category : #tests } XMLPluggableNodeFactoryTest >> testNewElement [ - super testNewElement. - self assert: self newFactoryWithClasses newElement class == self elementClass + super testNewElement. + self + assert: self newFactoryWithClasses newElement class + identicalTo: self elementClass ] { #category : #tests } XMLPluggableNodeFactoryTest >> testNewElementNamed [ - | element | + | element | super testNewElementNamed. element := self newFactoryWithClasses newElementNamed: 'test'. self - assert: element class == self elementClass; - assert: element name = 'test' + assert: element class identicalTo: self elementClass; + assert: element name equals: 'test' ] { #category : #tests } XMLPluggableNodeFactoryTest >> testNewElementNamedNamespaceURI [ - | element | + | element | super testNewElementNamedNamespaceURI. - element := - self newFactoryWithClasses - newElementNamed: 'prefix:test' - namespaceURI: 'prefixNS'. + element := self newFactoryWithClasses + newElementNamed: 'prefix:test' + namespaceURI: 'prefixNS'. self - assert: element class == self elementClass; - assert: element name = 'prefix:test'; - assert: element namespaceURI = 'prefixNS' + assert: element class identicalTo: self elementClass; + assert: element name equals: 'prefix:test'; + assert: element namespaceURI equals: 'prefixNS' ] { #category : #tests } XMLPluggableNodeFactoryTest >> testNewPI [ - super testNewPI. - self assert: self newFactoryWithClasses newPI class == self piClass + super testNewPI. + self + assert: self newFactoryWithClasses newPI class + identicalTo: self piClass ] { #category : #tests } XMLPluggableNodeFactoryTest >> testNewPITargetData [ - | pi | + | pi | super testNewPITargetData. - pi := - self newFactoryWithClasses - newPITarget: 'target' - data: 'data'. + pi := self newFactoryWithClasses newPITarget: 'target' data: 'data'. self - assert: pi class == self piClass; - assert: pi target = 'target'; - assert: pi data = 'data'. + assert: pi class identicalTo: self piClass; + assert: pi target equals: 'target'; + assert: pi data equals: 'data' ] { #category : #tests } XMLPluggableNodeFactoryTest >> testNewStringNode [ - | string | + | string | super testNewStringNode. string := self newFactoryWithClasses newStringNode: 'test'. self - assert: string class == self stringNodeClass; - assert: string string = 'test'. + assert: string class identicalTo: self stringNodeClass; + assert: string string equals: 'test' ] { #category : #tests } XMLPluggableNodeFactoryTest >> testNodeListClass [ - | factory | + | factory | super testNodeListClass. factory := self newFactoryWithClasses. self - assert: (factory nodeListClass: self nodeListClass) == factory; - assert: factory nodeListClass == self nodeListClass. + assert: (factory nodeListClass: self nodeListClass) + identicalTo: factory; + assert: factory nodeListClass identicalTo: self nodeListClass ] { #category : #tests } XMLPluggableNodeFactoryTest >> testPIClass [ - super testPIClass. - self assert: self newFactoryWithClasses piClass == self piClass. + super testPIClass. + self + assert: self newFactoryWithClasses piClass + identicalTo: self piClass ] { #category : #tests } XMLPluggableNodeFactoryTest >> testParsingSample [ - | document factory | + | document factory | factory := self newFactoryWithClasses. - document := - (XMLDOMParser on: self sampleUserXML) - nodeFactory: factory; - preservesCDataNodes: true; - preservesCommentNodes: true; - parseDocument. + document := (XMLDOMParser on: self sampleUserXML) + nodeFactory: factory; + preservesCDataNodes: true; + preservesCommentNodes: true; + parseDocument. self - assert: document class == self documentClass; - assert: document nodeFactory == factory. + assert: document class identicalTo: self documentClass; + assert: document nodeFactory identicalTo: factory. - document allElementsDo: [:each | + document allElementsDo: [ :each | self - assert: each class == self elementClass; - assert: each nodeFactory == factory]. - - document allNodesDo: [:each | - each isStringNode - ifTrue: [ - self assert: - each class == - (each isCData - ifTrue: [self cdataClass] - ifFalse: [self stringNodeClass])]. - each isComment - ifTrue: [self assert: each class == self commentClass]. - each isPI - ifTrue: [self assert: each class == self piClass]]. + assert: each class identicalTo: self elementClass; + assert: each nodeFactory identicalTo: factory ]. + + document allNodesDo: [ :each | + each isStringNode ifTrue: [ + self assert: each class identicalTo: (each isCData + ifTrue: [ self cdataClass ] + ifFalse: [ self stringNodeClass ]) ]. + each isComment ifTrue: [ + self assert: each class identicalTo: self commentClass ]. + each isPI ifTrue: [ + self assert: each class identicalTo: self piClass ] ] ] { #category : #tests } XMLPluggableNodeFactoryTest >> testStringNodeClass [ - super testStringNodeClass. - self assert: self newFactoryWithClasses stringNodeClass == self stringNodeClass. + super testStringNodeClass. + self + assert: self newFactoryWithClasses stringNodeClass + identicalTo: self stringNodeClass ] diff --git a/src/XML-Parser-Tests/XMLStreamConverterTest.class.st b/src/XML-Parser-Tests/XMLStreamConverterTest.class.st index 73efbc79..cfa4cde5 100644 --- a/src/XML-Parser-Tests/XMLStreamConverterTest.class.st +++ b/src/XML-Parser-Tests/XMLStreamConverterTest.class.st @@ -82,22 +82,24 @@ XMLStreamConverterTest >> streamConverterClass [ { #category : #tests } XMLStreamConverterTest >> testAbstractClass [ - | streamConverterClass | + | streamConverterClass | streamConverterClass := self streamConverterClass. - self assert: - streamConverterClass abstractClass == - (self isImplicit - ifTrue: [streamConverterClass superclass superclass] - ifFalse: [streamConverterClass superclass]) + self + assert: streamConverterClass abstractClass + identicalTo: (self isImplicit + ifTrue: [ streamConverterClass superclass superclass ] + ifFalse: [ streamConverterClass superclass ]) ] { #category : #tests } XMLStreamConverterTest >> testAsXMLStreamConverter [ - | streamConverter | + | streamConverter | streamConverter := self newStreamConverter. - self assert: streamConverter asXMLStreamConverter == streamConverter + self + assert: streamConverter asXMLStreamConverter + identicalTo: streamConverter ] { #category : #tests } @@ -110,33 +112,38 @@ XMLStreamConverterTest >> testCanConvertEncoding [ { #category : #tests } XMLStreamConverterTest >> testDefault [ - | streamConverter | + | streamConverter | streamConverter := self streamConverterClass default. self - assert: streamConverter class == self defaultClass; + assert: streamConverter class identicalTo: self defaultClass; assert: streamConverter isDefault; assert: streamConverter isImplicit ] { #category : #tests } XMLStreamConverterTest >> testDefaultClass [ - self assert: self streamConverterClass defaultClass == self defaultClass + + self + assert: self streamConverterClass defaultClass + identicalTo: self defaultClass ] { #category : #tests } XMLStreamConverterTest >> testDefaultEncoding [ - self assert: - self streamConverterClass defaultEncoding = - self defaultClass primaryEncodingName + + self + assert: self streamConverterClass defaultEncoding + equals: self defaultClass primaryEncodingName ] { #category : #tests } XMLStreamConverterTest >> testEncoding [ - self encodingNamesWithCaseInversions do: [:each | - self assert: - (XMLStreamConverter newForEncoding: each) encoding = - self primaryEncodingName] + + self encodingNamesWithCaseInversions do: [ :each | + self + assert: (XMLStreamConverter newForEncoding: each) encoding + equals: self primaryEncodingName ] ] { #category : #tests } @@ -190,19 +197,26 @@ XMLStreamConverterTest >> testNewForEncoding [ { #category : #tests } XMLStreamConverterTest >> testNull [ - self assert: self streamConverterClass null class == self nullClass + + self + assert: self streamConverterClass null class + identicalTo: self nullClass ] { #category : #tests } XMLStreamConverterTest >> testNullClass [ - self assert: self streamConverterClass nullClass == self nullClass + + self + assert: self streamConverterClass nullClass + identicalTo: self nullClass ] { #category : #tests } XMLStreamConverterTest >> testPrimaryEncodingName [ - self assert: - self streamConverterClass primaryEncodingName = - self primaryEncodingName + + self + assert: self streamConverterClass primaryEncodingName + equals: self primaryEncodingName ] { #category : #accessing } diff --git a/src/XML-Parser-Tests/XMLStringTest.class.st b/src/XML-Parser-Tests/XMLStringTest.class.st index 3c19c629..cc327e92 100644 --- a/src/XML-Parser-Tests/XMLStringTest.class.st +++ b/src/XML-Parser-Tests/XMLStringTest.class.st @@ -11,60 +11,62 @@ XMLStringTest >> nodeClass [ { #category : #tests } XMLStringTest >> testAcceptNodeVisitor [ - | visitor stringNode message | + | visitor stringNode message | visitor := XMLRecordingNodeVisitor new. stringNode := self newNode. self - assert: (stringNode acceptNodeVisitor: visitor) == stringNode; + assert: (stringNode acceptNodeVisitor: visitor) + identicalTo: stringNode; assert: visitor messageRecorder hasMessages. message := visitor messageRecorder nextMessage. self - assert: message selector == #visitStringNode:; - assert: message arguments = (Array with: stringNode); + assert: message selector identicalTo: #visitStringNode:; + assert: message arguments equals: (Array with: stringNode); deny: visitor messageRecorder hasMessages ] { #category : #tests } XMLStringTest >> testAppend [ - | stringNode | + | stringNode | stringNode := self newNode. stringNode append: 'one'. - self assert: stringNode string = 'one'. + self assert: stringNode string equals: 'one'. stringNode append: (self nodeClass string: 'two'). - self assert: stringNode string = 'onetwo'. + self assert: stringNode string equals: 'onetwo'. stringNode append: 'three'. - self assert: stringNode string = 'onetwothree' + self assert: stringNode string equals: 'onetwothree' ] { #category : #tests } XMLStringTest >> testAsString [ + self - assert: self newNode asString = ''; - assert: (self nodeClass string: 'test') asString = 'test' + assert: self newNode asString equals: ''; + assert: (self nodeClass string: 'test') asString equals: 'test' ] { #category : #tests } XMLStringTest >> testAsXMLEscapedString [ - | stringNode | + | stringNode | stringNode := self nodeClass string: self markupString. self - assert: stringNode string = self markupString; - deny: stringNode string = self escapedString; - assert: stringNode asXMLEscapedString = self escapedString + assert: stringNode string equals: self markupString; + deny: stringNode string equals: self escapedString; + assert: stringNode asXMLEscapedString equals: self escapedString ] { #category : #tests } XMLStringTest >> testAsXMLStringNode [ - | stringNode | + | stringNode | stringNode := self newNode. - self assert: stringNode asXMLStringNode == stringNode + self assert: stringNode asXMLStringNode identicalTo: stringNode ] { #category : #tests } @@ -94,25 +96,25 @@ XMLStringTest >> testCanonicallyEquals [ { #category : #tests } XMLStringTest >> testDeleteFromTo [ - | stringNode | + | stringNode | stringNode := self newNode. stringNode deleteFrom: 1 to: 0. - self assert: stringNode string = ''. + self assert: stringNode string equals: ''. stringNode append: 'onetwothree'. stringNode deleteFrom: 0 to: -1. stringNode deleteFrom: 12 to: 13. - self assert: stringNode string = 'onetwothree'. + self assert: stringNode string equals: 'onetwothree'. stringNode deleteFrom: 4 to: 6. - self assert: stringNode string = 'onethree'. + self assert: stringNode string equals: 'onethree'. stringNode deleteFrom: 4 to: 8. - self assert: stringNode string = 'one'. + self assert: stringNode string equals: 'one'. stringNode deleteFrom: 1 to: 3. - self assert: stringNode string = '' + self assert: stringNode string equals: '' ] { #category : #tests } @@ -167,24 +169,32 @@ XMLStringTest >> testIncludesSubstring [ { #category : #tests } XMLStringTest >> testIndexOfSubstring [ - | stringNode | + | stringNode | stringNode := self newNode. self assert: (stringNode indexOfSubstring: 'one') isZero; - assert: (stringNode indexOfSubstring: (self nodeClass string: 'one')) isZero. + assert: + (stringNode indexOfSubstring: (self nodeClass string: 'one')) + isZero. stringNode prepend: 'one'. self - assert: (stringNode indexOfSubstring: 'one') = 1; - assert: (stringNode indexOfSubstring: (self nodeClass string: 'one')) = 1. + assert: (stringNode indexOfSubstring: 'one') equals: 1; + assert: + (stringNode indexOfSubstring: (self nodeClass string: 'one')) + equals: 1. self assert: (stringNode indexOfSubstring: 'two') isZero; - assert: (stringNode indexOfSubstring: (self nodeClass string: 'two')) isZero. + assert: + (stringNode indexOfSubstring: (self nodeClass string: 'two')) + isZero. stringNode append: 'two'. self - assert: (stringNode indexOfSubstring: 'two') = 4; - assert: (stringNode indexOfSubstring: (self nodeClass string: 'two')) = 4 + assert: (stringNode indexOfSubstring: 'two') equals: 4; + assert: + (stringNode indexOfSubstring: (self nodeClass string: 'two')) + equals: 4 ] { #category : #tests } @@ -243,8 +253,8 @@ XMLStringTest >> testIsWhitespace [ { #category : #tests } XMLStringTest >> testMergeAdjacent [ - | element nodes | + | element nodes | (element := self newElement) addNode: (self nodeClass string: 'one'); addNode: (self nodeClass string: 'two'); @@ -258,23 +268,32 @@ XMLStringTest >> testMergeAdjacent [ element nodes second mergeAdjacent. nodes := element nodes. self - assert: nodes size = 6; - assert: (nodes first isStringNode and: [nodes first string = 'onetwothree']); + assert: nodes size equals: 6; + assert: + (nodes first isStringNode and: [ + nodes first string = 'onetwothree' ]); assert: nodes second isComment; - assert: (nodes third isStringNode and: [nodes third string = 'four']); - assert: (nodes fourth isStringNode and: [nodes fourth string = 'five']); + assert: + (nodes third isStringNode and: [ nodes third string = 'four' ]); + assert: + (nodes fourth isStringNode and: [ nodes fourth string = 'five' ]); assert: nodes fifth isComment; - assert: (nodes sixth isStringNode and: [nodes sixth string = 'six']). + assert: + (nodes sixth isStringNode and: [ nodes sixth string = 'six' ]). nodes fourth mergeAdjacent. nodes fifth mergeAdjacent. self - assert: nodes size = 5; - assert: (nodes first isStringNode and: [nodes first string = 'onetwothree']); + assert: nodes size equals: 5; + assert: + (nodes first isStringNode and: [ + nodes first string = 'onetwothree' ]); assert: nodes second isComment; - assert: (nodes third isStringNode and: [nodes third string = 'fourfive']); + assert: + (nodes third isStringNode and: [ nodes third string = 'fourfive' ]); assert: nodes fourth isComment; - assert: (nodes fifth isStringNode and: [nodes fifth string = 'six']) + assert: + (nodes fifth isStringNode and: [ nodes fifth string = 'six' ]) ] { #category : #tests } @@ -293,94 +312,102 @@ XMLStringTest >> testNotEmpty [ { #category : #tests } XMLStringTest >> testPrepend [ - | stringNode | + | stringNode | stringNode := self newNode. stringNode prepend: 'three'. - self assert: stringNode string = 'three'. + self assert: stringNode string equals: 'three'. stringNode prepend: (self nodeClass string: 'two'). - self assert: stringNode string = 'twothree'. + self assert: stringNode string equals: 'twothree'. stringNode prepend: 'one'. - self assert: stringNode string = 'onetwothree' + self assert: stringNode string equals: 'onetwothree' ] { #category : #tests } XMLStringTest >> testReplaceAllWith [ - | stringNode | + | stringNode | (stringNode := self newNode) replaceAll: 'old' with: 'new'. - self assert: stringNode string = ''. + self assert: stringNode string equals: ''. stringNode string: 'one old two old three old'. stringNode replaceAll: 'old' with: (self nodeClass string: 'new'). - self assert: stringNode string = 'one new two new three new'. + self assert: stringNode string equals: 'one new two new three new'. stringNode replaceAll: 'new' with: ''. - self assert: stringNode string = 'one two three ' + self assert: stringNode string equals: 'one two three ' ] { #category : #tests } XMLStringTest >> testReplaceFromToWith [ - | stringNode | + | stringNode | (stringNode := self newNode) replaceFrom: -1 to: -3 with: 'one'. - self assert: stringNode string = 'one'. + self assert: stringNode string equals: 'one'. stringNode replaceFrom: 1 to: 0 with: 'zero'. - self assert: stringNode string = 'zeroone'. + self assert: stringNode string equals: 'zeroone'. - stringNode replaceFrom: 9 to: 7 with: (self nodeClass string: 'fourthree'). - self assert: stringNode string = 'zeroonefourthree'. + stringNode + replaceFrom: 9 + to: 7 + with: (self nodeClass string: 'fourthree'). + self assert: stringNode string equals: 'zeroonefourthree'. stringNode replaceFrom: 8 to: 11 with: ' two '. - self assert: stringNode string = 'zeroone two three'. + self assert: stringNode string equals: 'zeroone two three'. stringNode replaceFrom: 0 to: 4 with: ''. - self assert: stringNode string = 'one two three'. + self assert: stringNode string equals: 'one two three'. - stringNode replaceFrom: 14 to: 13 with: (self nodeClass string: ' four'). - self assert: stringNode string = 'one two three four' + stringNode + replaceFrom: 14 + to: 13 + with: (self nodeClass string: ' four'). + self assert: stringNode string equals: 'one two three four' ] { #category : #tests } XMLStringTest >> testSize [ + self - assert: self newNode size = 0; - assert: (self nodeClass string: 'test') size = 4 + assert: self newNode size equals: 0; + assert: (self nodeClass string: 'test') size equals: 4 ] { #category : #tests } XMLStringTest >> testSortKey [ - self assert: (self nodeClass string: 'test') sortKey = 'test' + + self assert: (self nodeClass string: 'test') sortKey equals: 'test' ] { #category : #tests } XMLStringTest >> testSplitAt [ - | stringNode newStringNode element | + | stringNode newStringNode element | stringNode := self nodeClass string: 'onetwo'. newStringNode := stringNode splitAt: 0. self - deny: stringNode == newStringNode; - assert: stringNode string = ''; - assert: newStringNode string = 'onetwo'. + deny: stringNode identicalTo: newStringNode; + assert: stringNode string equals: ''; + assert: newStringNode string equals: 'onetwo'. stringNode := self nodeClass string: 'onetwo'. newStringNode := stringNode splitAt: 7. self - deny: stringNode == newStringNode; - assert: stringNode string = 'onetwo'; - assert: newStringNode string = ''. + deny: stringNode identicalTo: newStringNode; + assert: stringNode string equals: 'onetwo'; + assert: newStringNode string equals: ''. (element := self newElement) addNode: stringNode. newStringNode := stringNode splitAt: 4. self - deny: stringNode == newStringNode; - assert: stringNode string = 'one'; - assert: newStringNode string = 'two'; - assert: (element nodeAfter: stringNode) == newStringNode + deny: stringNode identicalTo: newStringNode; + assert: stringNode string equals: 'one'; + assert: newStringNode string equals: 'two'; + assert: (element nodeAfter: stringNode) identicalTo: newStringNode ] { #category : #tests } @@ -404,8 +431,9 @@ XMLStringTest >> testString [ { #category : #tests } XMLStringTest >> testWriteXMLOn [ - self assert: self newNode printString = ''. - self assert: - (self nodeClass string: self markupString) printString = - self escapedString. + + self assert: self newNode printString equals: ''. + self + assert: (self nodeClass string: self markupString) printString + equals: self escapedString ] diff --git a/src/XML-Parser-Tests/XMLURITest.class.st b/src/XML-Parser-Tests/XMLURITest.class.st index 4be67f20..df95e6ac 100644 --- a/src/XML-Parser-Tests/XMLURITest.class.st +++ b/src/XML-Parser-Tests/XMLURITest.class.st @@ -187,41 +187,38 @@ XMLURITest >> asciiCharacters [ { #category : #asserting } XMLURITest >> assertURI: aFirstURI atHostEquals: aSecondURI [ - self assert: aFirstURI host = aSecondURI host. - self - assertURI: aFirstURI - atPortEquals: aSecondURI + + self assert: aFirstURI host equals: aSecondURI host. + self assertURI: aFirstURI atPortEquals: aSecondURI ] { #category : #asserting } XMLURITest >> assertURI: aFirstURI atPathEquals: aSecondURI [ - self assert: aFirstURI pathSegments = aSecondURI pathSegments. - self - assertURI: aFirstURI - atQueryEquals: aSecondURI + + self assert: aFirstURI pathSegments equals: aSecondURI pathSegments. + self assertURI: aFirstURI atQueryEquals: aSecondURI ] { #category : #asserting } XMLURITest >> assertURI: aFirstURI atPortEquals: aSecondURI [ - self assert: aFirstURI port = aSecondURI port. - self - assertURI: aFirstURI - atPathEquals: aSecondURI + + self assert: aFirstURI port equals: aSecondURI port. + self assertURI: aFirstURI atPathEquals: aSecondURI ] { #category : #asserting } XMLURITest >> assertURI: aFirstURI atQueryEquals: aSecondURI [ + self - assert: aFirstURI query = aSecondURI query; - assert: aFirstURI fragment = aSecondURI fragment + assert: aFirstURI query equals: aSecondURI query; + assert: aFirstURI fragment equals: aSecondURI fragment ] { #category : #asserting } XMLURITest >> assertURI: aFirstURI atUserInfoEquals: aSecondURI [ - self assert: aFirstURI userInfo = aSecondURI userInfo. - self - assertURI: aFirstURI - atHostEquals: aSecondURI + + self assert: aFirstURI userInfo equals: aSecondURI userInfo. + self assertURI: aFirstURI atHostEquals: aSecondURI ] { #category : #accessing } @@ -430,25 +427,21 @@ XMLURITest >> testAsXMLFileHandle [ { #category : #tests } XMLURITest >> testAsXMLHTTPRequest [ - XMLHTTPRequest hasSupportedImplementation - ifFalse: [^ self]. - self allURIStringsDo: [:each | | uri request | + XMLHTTPRequest hasSupportedImplementation ifFalse: [ ^ self ]. + + self allURIStringsDo: [ :each | + | uri request | uri := each asXMLURI. - (uri isRelative - or: [uri isHTTP]) + (uri isRelative or: [ uri isHTTP ]) ifTrue: [ request := uri asXMLHTTPRequest. self - assert: request class == XMLHTTPRequest implementation; - assert: request url = uri printString] - ifFalse: [ - "do not assume HTTPS is supported even if HTTP is" - uri isHTTPS - ifFalse: [ - self - should: [uri asXMLHTTPRequest] - raise: XMLHTTPException]]]. + assert: request class identicalTo: XMLHTTPRequest implementation; + assert: request url equals: uri printString ] + ifFalse: [ "do not assume HTTPS is supported even if HTTP is" + uri isHTTPS ifFalse: [ + self should: [ uri asXMLHTTPRequest ] raise: XMLHTTPException ] ] ] ] { #category : #tests } @@ -2093,41 +2086,41 @@ XMLURITest >> testQueryValuesAtDo [ { #category : #tests } XMLURITest >> testQueryValuesAtIfAbsent [ - self allURIStringsDo: [:uriString | | uri valuesForKeys | + + self allURIStringsDo: [ :uriString | + | uri valuesForKeys | uri := uriString asXMLURI. valuesForKeys := Dictionary new. - uri query do: [:each | - (valuesForKeys - at: each key - ifAbsentPut: [OrderedCollection new]) - addLast: each value]. - valuesForKeys keysAndValuesDo: [:key :values | - self assert: - (uri - queryValuesAt: key - ifAbsent: [self fail]) = values]. - self assert: - (uri - queryValuesAt: 'absent' - ifAbsent: [#absent]) = #absent] + uri query do: [ :each | + (valuesForKeys at: each key ifAbsentPut: [ OrderedCollection new ]) + addLast: each value ]. + valuesForKeys keysAndValuesDo: [ :key :values | + self + assert: (uri queryValuesAt: key ifAbsent: [ self fail ]) + equals: values ]. + self + assert: (uri queryValuesAt: 'absent' ifAbsent: [ #absent ]) + equals: #absent ] ] { #category : #tests } XMLURITest >> testReadFrom [ - self allURIStringsDo: [:each | | stream uri | + + self allURIStringsDo: [ :each | + | stream uri | stream := each readStream. uri := XMLURI readFrom: stream. self - assert: uri class == XMLURI; + assert: uri class identicalTo: XMLURI; assert: uri uriString isNil; - assert: uri = each asXMLURI; + assert: uri equals: each asXMLURI; assert: stream atEnd. uri := XMLURI readFrom: each. self - assert: uri class == XMLURI; - assert: uri uriString = each; - assert: uri = each asXMLURI] + assert: uri class identicalTo: XMLURI; + assert: uri uriString equals: each; + assert: uri equals: each asXMLURI ] ] { #category : #tests } @@ -2157,35 +2150,37 @@ XMLURITest >> testScheme [ { #category : #tests } XMLURITest >> testSchemeAndHostCaseInsensitivity [ - self allURIStringsDo: [:each | | uri uppercaseURI | + + self allURIStringsDo: [ :each | + | uri uppercaseURI | uri := each asXMLURI. uppercaseURI := each asUppercase asXMLURI. self - assert: uri scheme = uppercaseURI scheme; - assert: uri hasAuthorityPrefix = uppercaseURI hasAuthorityPrefix. - uri hasUserInfo - ifTrue: [self deny: uri userInfo = uppercaseURI userInfo]. + assert: uri scheme equals: uppercaseURI scheme; + assert: uri hasAuthorityPrefix + equals: uppercaseURI hasAuthorityPrefix. + uri hasUserInfo ifTrue: [ + self deny: uri userInfo equals: uppercaseURI userInfo ]. self - assert: uri host = uppercaseURI host; - assert: uri port = uppercaseURI port. - (uri hasPath - and: [uri hasRootPath not]) - ifTrue: [self deny: uri pathSegments = uppercaseURI pathSegments]. - uri hasQuery - ifTrue: [self deny: uri query = uppercaseURI query]. - uri hasFragment - ifTrue: [self deny: uri fragment = uppercaseURI fragment]] + assert: uri host equals: uppercaseURI host; + assert: uri port equals: uppercaseURI port. + (uri hasPath and: [ uri hasRootPath not ]) ifTrue: [ + self deny: uri pathSegments equals: uppercaseURI pathSegments ]. + uri hasQuery ifTrue: [ + self deny: uri query equals: uppercaseURI query ]. + uri hasFragment ifTrue: [ + self deny: uri fragment equals: uppercaseURI fragment ] ] ] { #category : #tests } XMLURITest >> testSchemeCharacters [ - | scheme uri | - scheme := self alphaNumericCharacters, '+-.'. - uri := (scheme, '://', self host) asXMLURI. + | scheme uri | + scheme := self alphaNumericCharacters , '+-.'. + uri := (scheme , '://' , self host) asXMLURI. self - assert: uri scheme = scheme asLowercase; - assert: uri host = self host. + assert: uri scheme equals: scheme asLowercase; + assert: uri host equals: self host ] { #category : #tests } @@ -2193,95 +2188,117 @@ XMLURITest >> testStandardURICombining [ "Generated from RFC 3986, page 34-36" | baseURI | - baseURI := 'http://a/b/c/d;p?q' asXMLURI. self - assert: (baseURI / 'g:h' asXMLURI) = 'g:h' asXMLURI; - assert: (baseURI / 'g' asXMLURI) = 'http://a/b/c/g' asXMLURI; - assert: (baseURI / './g' asXMLURI) = 'http://a/b/c/g' asXMLURI; - assert: (baseURI / 'g/' asXMLURI) = 'http://a/b/c/g/' asXMLURI; - assert: (baseURI / '/g' asXMLURI) = 'http://a/g' asXMLURI; - assert: (baseURI / '//g' asXMLURI) = 'http://g' asXMLURI; - assert: (baseURI / '?y' asXMLURI) = 'http://a/b/c/d;p?y' asXMLURI; - assert: (baseURI / 'g?y' asXMLURI) = 'http://a/b/c/g?y' asXMLURI; - assert: (baseURI / '#s' asXMLURI) = 'http://a/b/c/d;p?q#s' asXMLURI; - assert: (baseURI / 'g#s' asXMLURI) = 'http://a/b/c/g#s' asXMLURI; - assert: (baseURI / 'g?y#s' asXMLURI) = 'http://a/b/c/g?y#s' asXMLURI; - assert: (baseURI / ';x' asXMLURI) = 'http://a/b/c/;x' asXMLURI; - assert: (baseURI / 'g;x' asXMLURI) = 'http://a/b/c/g;x' asXMLURI; - assert: (baseURI / 'g;x?y#s' asXMLURI) = 'http://a/b/c/g;x?y#s' asXMLURI; - assert: (baseURI / '' asXMLURI) = 'http://a/b/c/d;p?q' asXMLURI; - assert: (baseURI / '.' asXMLURI) = 'http://a/b/c/' asXMLURI; - assert: (baseURI / './' asXMLURI) = 'http://a/b/c/' asXMLURI; - assert: (baseURI / '..' asXMLURI) = 'http://a/b/' asXMLURI; - assert: (baseURI / '../' asXMLURI) = 'http://a/b/' asXMLURI; - assert: (baseURI / '../g' asXMLURI) = 'http://a/b/g' asXMLURI; - assert: (baseURI / '../..' asXMLURI) = 'http://a/' asXMLURI; - assert: (baseURI / '../../' asXMLURI) = 'http://a/' asXMLURI; - assert: (baseURI / '../../g' asXMLURI) = 'http://a/g' asXMLURI; - assert: (baseURI / '../../../g' asXMLURI) = 'http://a/g' asXMLURI; - assert: (baseURI / '../../../../g' asXMLURI) = 'http://a/g' asXMLURI; - assert: (baseURI / '/./g' asXMLURI) = 'http://a/g' asXMLURI; - assert: (baseURI / '/../g' asXMLURI) = 'http://a/g' asXMLURI; - assert: (baseURI / 'g.' asXMLURI) = 'http://a/b/c/g.' asXMLURI; - assert: (baseURI / '.g' asXMLURI) = 'http://a/b/c/.g' asXMLURI; - assert: (baseURI / 'g..' asXMLURI) = 'http://a/b/c/g..' asXMLURI; - assert: (baseURI / '..g' asXMLURI) = 'http://a/b/c/..g' asXMLURI; - assert: (baseURI / './../g' asXMLURI) = 'http://a/b/g' asXMLURI; - assert: (baseURI / './g/.' asXMLURI) = 'http://a/b/c/g/' asXMLURI; - assert: (baseURI / 'g/./h' asXMLURI) = 'http://a/b/c/g/h' asXMLURI; - assert: (baseURI / 'g/../h' asXMLURI) = 'http://a/b/c/h' asXMLURI; - assert: (baseURI / 'g;x=1/./y' asXMLURI) = 'http://a/b/c/g;x=1/y' asXMLURI; - assert: (baseURI / 'g;x=1/../y' asXMLURI) = 'http://a/b/c/y' asXMLURI; - assert: (baseURI / 'g?y/./x' asXMLURI) = 'http://a/b/c/g?y/./x' asXMLURI; - assert: (baseURI / 'g?y/../x' asXMLURI) = 'http://a/b/c/g?y/../x' asXMLURI; - assert: (baseURI / 'g#s/./x' asXMLURI) = 'http://a/b/c/g#s/./x' asXMLURI; - assert: (baseURI / 'g#s/../x' asXMLURI) = 'http://a/b/c/g#s/../x' asXMLURI; - assert: (baseURI / 'http:g' asXMLURI) = 'http:g' asXMLURI + assert: baseURI / 'g:h' asXMLURI equals: 'g:h' asXMLURI; + assert: baseURI / 'g' asXMLURI equals: 'http://a/b/c/g' asXMLURI; + assert: baseURI / './g' asXMLURI equals: 'http://a/b/c/g' asXMLURI; + assert: baseURI / 'g/' asXMLURI equals: 'http://a/b/c/g/' asXMLURI; + assert: baseURI / '/g' asXMLURI equals: 'http://a/g' asXMLURI; + assert: baseURI / '//g' asXMLURI equals: 'http://g' asXMLURI; + assert: baseURI / '?y' asXMLURI + equals: 'http://a/b/c/d;p?y' asXMLURI; + assert: baseURI / 'g?y' asXMLURI + equals: 'http://a/b/c/g?y' asXMLURI; + assert: baseURI / '#s' asXMLURI + equals: 'http://a/b/c/d;p?q#s' asXMLURI; + assert: baseURI / 'g#s' asXMLURI + equals: 'http://a/b/c/g#s' asXMLURI; + assert: baseURI / 'g?y#s' asXMLURI + equals: 'http://a/b/c/g?y#s' asXMLURI; + assert: baseURI / ';x' asXMLURI equals: 'http://a/b/c/;x' asXMLURI; + assert: baseURI / 'g;x' asXMLURI + equals: 'http://a/b/c/g;x' asXMLURI; + assert: baseURI / 'g;x?y#s' asXMLURI + equals: 'http://a/b/c/g;x?y#s' asXMLURI; + assert: baseURI / '' asXMLURI equals: 'http://a/b/c/d;p?q' asXMLURI; + assert: baseURI / '.' asXMLURI equals: 'http://a/b/c/' asXMLURI; + assert: baseURI / './' asXMLURI equals: 'http://a/b/c/' asXMLURI; + assert: baseURI / '..' asXMLURI equals: 'http://a/b/' asXMLURI; + assert: baseURI / '../' asXMLURI equals: 'http://a/b/' asXMLURI; + assert: baseURI / '../g' asXMLURI equals: 'http://a/b/g' asXMLURI; + assert: baseURI / '../..' asXMLURI equals: 'http://a/' asXMLURI; + assert: baseURI / '../../' asXMLURI equals: 'http://a/' asXMLURI; + assert: baseURI / '../../g' asXMLURI equals: 'http://a/g' asXMLURI; + assert: baseURI / '../../../g' asXMLURI + equals: 'http://a/g' asXMLURI; + assert: baseURI / '../../../../g' asXMLURI + equals: 'http://a/g' asXMLURI; + assert: baseURI / '/./g' asXMLURI equals: 'http://a/g' asXMLURI; + assert: baseURI / '/../g' asXMLURI equals: 'http://a/g' asXMLURI; + assert: baseURI / 'g.' asXMLURI equals: 'http://a/b/c/g.' asXMLURI; + assert: baseURI / '.g' asXMLURI equals: 'http://a/b/c/.g' asXMLURI; + assert: baseURI / 'g..' asXMLURI + equals: 'http://a/b/c/g..' asXMLURI; + assert: baseURI / '..g' asXMLURI + equals: 'http://a/b/c/..g' asXMLURI; + assert: baseURI / './../g' asXMLURI equals: 'http://a/b/g' asXMLURI; + assert: baseURI / './g/.' asXMLURI + equals: 'http://a/b/c/g/' asXMLURI; + assert: baseURI / 'g/./h' asXMLURI + equals: 'http://a/b/c/g/h' asXMLURI; + assert: baseURI / 'g/../h' asXMLURI + equals: 'http://a/b/c/h' asXMLURI; + assert: baseURI / 'g;x=1/./y' asXMLURI + equals: 'http://a/b/c/g;x=1/y' asXMLURI; + assert: baseURI / 'g;x=1/../y' asXMLURI + equals: 'http://a/b/c/y' asXMLURI; + assert: baseURI / 'g?y/./x' asXMLURI + equals: 'http://a/b/c/g?y/./x' asXMLURI; + assert: baseURI / 'g?y/../x' asXMLURI + equals: 'http://a/b/c/g?y/../x' asXMLURI; + assert: baseURI / 'g#s/./x' asXMLURI + equals: 'http://a/b/c/g#s/./x' asXMLURI; + assert: baseURI / 'g#s/../x' asXMLURI + equals: 'http://a/b/c/g#s/../x' asXMLURI; + assert: baseURI / 'http:g' asXMLURI equals: 'http:g' asXMLURI ] { #category : #tests } XMLURITest >> testUserInfo [ - self allURIStringsDo: [:each | | uri | + + self allURIStringsDo: [ :each | + | uri | uri := each asXMLURI. uri scheme = 'mailto' - ifTrue: [self assert: uri userInfo = 'userName'] - ifFalse: [self assert: uri userInfo = '']] + ifTrue: [ self assert: uri userInfo equals: 'userName' ] + ifFalse: [ self assert: uri userInfo equals: '' ] ] ] { #category : #tests } XMLURITest >> testUserInfoNonPercentEncodedCharacters [ - | userInfo uriString uri | - userInfo := self unreservedCharacters, self subDelimiterCharacters, ':'. - uriString := 'mailto:', userInfo, '@', self host. + | userInfo uriString uri | + userInfo := self unreservedCharacters , self subDelimiterCharacters + , ':'. + uriString := 'mailto:' , userInfo , '@' , self host. uri := uriString asXMLURI. self - assert: uri scheme = 'mailto'; - assert: uri userInfo = userInfo; - assert: uri host = self host. + assert: uri scheme equals: 'mailto'; + assert: uri userInfo equals: userInfo; + assert: uri host equals: self host. uri uriString: nil. - self assert: uri printString = uriString. + self assert: uri printString equals: uriString ] { #category : #tests } XMLURITest >> testUserInfoPercentEncodedCharacters [ - | prefix encoded decoded suffix encodedURIString uri | + | prefix encoded decoded suffix encodedURIString uri | prefix := 'mailto:'. - encoded := self percentEncodedASCIICharacters, '+'. - decoded := self asciiCharacters, '+'. - suffix := '@', self host. - encodedURIString := prefix, encoded, suffix. + encoded := self percentEncodedASCIICharacters , '+'. + decoded := self asciiCharacters , '+'. + suffix := '@' , self host. + encodedURIString := prefix , encoded , suffix. uri := encodedURIString asXMLURI. self - assert: uri scheme = 'mailto'; - assert: uri userInfo = decoded; - assert: uri rawUserInfo = encoded. + assert: uri scheme equals: 'mailto'; + assert: uri userInfo equals: decoded; + assert: uri rawUserInfo equals: encoded. uri uriString: nil. - self assert: uri printString = encodedURIString. + self assert: uri printString equals: encodedURIString ] { #category : #accessing }