From 79d731e291278953b6c41a409c144cb018022e09 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?St=C3=A9phaneDucasse?= Date: Fri, 2 Aug 2024 12:33:28 +0200 Subject: [PATCH] test for duplicated figures revisited. --- .../MicReferenceCheckerTest.class.st | 76 +++++++++++-------- 1 file changed, 46 insertions(+), 30 deletions(-) diff --git a/src/Microdown-BookTester-Tests/MicReferenceCheckerTest.class.st b/src/Microdown-BookTester-Tests/MicReferenceCheckerTest.class.st index 3ed6cab2..69f6d751 100644 --- a/src/Microdown-BookTester-Tests/MicReferenceCheckerTest.class.st +++ b/src/Microdown-BookTester-Tests/MicReferenceCheckerTest.class.st @@ -48,6 +48,32 @@ See *@Eq1@* ^ defAnCS0DoubleEq2DoubleEq1RefEq1 ] +{ #category : 'tests - reporting' } +MicReferenceCheckerTest >> defAncS0DoubleFig1Fig2RefAncS1 [ + + | doubleFig1 | + doubleFig1 := dir / 'defAncS0DoubleFig1Fig2RefAncS1.md'. + doubleFig1 writeStreamDo: [ :stream | + stream nextPutAll: '# Section +@ancS0 + +![a caption 1](figures/f.png anchor=fig1) + +![a caption 2](figures/f.png anchor=fig1) + +![a caption 2](figures/f.png anchor=fig1) + +![a caption 2](figures/f.png anchor=fig1) + +![a caption 3](figures/f.png anchor=fig2) + +See *@ancS1@* + +' ]. + doubleFig1 ensureCreateFile. + ^ doubleFig1 +] + { #category : 'helpers - anchors & references' } MicReferenceCheckerTest >> defEq1AndReferToEq1 [ @@ -337,6 +363,26 @@ MicReferenceCheckerTest >> testDuplicatedAnchorInDifferentFilesOfTheSameDir [ +] + +{ #category : 'tests - duplicated' } +MicReferenceCheckerTest >> testDuplicatedFigures [ + + | doubleFig1 checker dict dup1 | + doubleFig1 := self defAncS0DoubleFig1Fig2RefAncS1. + checker := MicReferenceChecker new. + self deny: (checker checkList: { doubleFig1 }). + self + assert: (checker results collect: [ :each | each anchorLabel ]) + equals: OrderedCollection <- #( 'fig1' 'fig1' 'fig1' 'ancS1' ). + + dict := checker results groupedBy: [ :each | each class ]. + + dup1 := (dict at: MicDuplicatedAnchorResult) first. + self assert: dup1 source equals: '/myDirectory/defAncS0DoubleFig1Fig2RefAncS1.md'. + self assert: dup1 anchorLabel equals: 'fig1'. + + ] { #category : 'tests - duplicated' } @@ -604,36 +650,6 @@ See *@ancS1@* equals: OrderedCollection <- #( 'ancS1' ) ] -{ #category : 'tests - reporting' } -MicReferenceCheckerTest >> testReportingDuplicatedFiguresInFile [ - - | file visitor | - file := (dir / 'file.txt') asFileReference. - file writeStreamDo: [ :stream | - stream nextPutAll: '# Section -@ancS0 - -![a caption 1](figures/f.png anchor=fig1) - -![a caption 2](figures/f.png anchor=fig1) - -![a caption 2](figures/f.png anchor=fig1) - -![a caption 2](figures/f.png anchor=fig1) - -![a caption 3](figures/f.png anchor=fig2) - -See *@ancS1@* - -' ]. - file ensureCreateFile. - visitor := MicReferenceChecker new. - self deny: (visitor checkList: { file }). - self - assert: (visitor results collect: [ :each | each anchorLabel ]) - equals: OrderedCollection <- #( 'fig1' 'fig1' 'fig1' 'ancS1') -] - { #category : 'tests - reporting' } MicReferenceCheckerTest >> testReportingDuplicatedSectionAnchorsInFile [