Skip to content

Commit 8d06dc6

Browse files
committed
adding more tests for paragraph and header.
1 parent f1c6bcb commit 8d06dc6

File tree

2 files changed

+54
-24
lines changed

2 files changed

+54
-24
lines changed

src/Microdown-Rules/MicVocabularyChecker.class.st

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -14,20 +14,19 @@ MicVocabularyChecker >> checkProject: aFileReference [
1414

1515
| collector |
1616
collector := self fileCollectorForMainFileReference: aFileReference.
17-
1817
collector visitedFilesAsDOM do: [ :each | each accept: self ]
1918
]
2019

2120
{ #category : 'visiting - inline elements' }
2221
MicVocabularyChecker >> checkText: aMicText [
23-
24-
patternPairs do: [ :patternPair |
25-
(patternPair key match: aMicText bodyString)
26-
ifTrue: [
27-
results add: (MicUseofWrongVocabularyResult new
28-
micElement: aMicText;
29-
inFile: aMicText fromFile;
30-
patternPair: patternPair) ] ]
22+
23+
patternPairs do: [ :patternPair |
24+
"note that match: ignore upper/lower case differences."
25+
(patternPair key match: aMicText bodyString ) ifTrue: [
26+
results add: (MicUseofWrongVocabularyResult new
27+
micElement: aMicText;
28+
inFile: aMicText fromFile;
29+
patternPair: patternPair) ] ]
3130
]
3231

3332
{ #category : 'testing' }

src/Microdown-Rules/MicVocabularyCheckerTest.class.st

Lines changed: 46 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -14,26 +14,36 @@ Class {
1414
MicVocabularyCheckerTest >> generateFilesystemExample [
1515

1616
| file |
17-
file := fileSystem workingDirectory / 'example1WithMistake.md'.
17+
file := fileSystem workingDirectory / 'mistakeInParagraph.md'.
1818
file writeStreamDo: [ :stream |
1919
stream nextPutAll: '# Foo
20-
Pharo is cool
20+
Pharo is cool.
21+
22+
Spec uses a sub presenter. And there is a mistake in the previous sentence.
2123
22-
Spec uses a sub presenter
2324
```
2425
this is a code
2526
```
2627
' ].
2728

28-
file := fileSystem workingDirectory / 'example2WithMistake.md'.
29+
file := fileSystem workingDirectory / 'mistakeInHeader.md'.
2930
file writeStreamDo: [ :stream |
3031
stream nextPutAll: '## Bar
3132
Pharo is **cool**
3233
33-
sub-presenter is not correct.
34+
## sub-presenter is not correct.
3435
```
3536
this is a code 2
3637
```
38+
' ].
39+
40+
file := fileSystem workingDirectory / 'mistakeInUppercase.md'.
41+
file writeStreamDo: [ :stream |
42+
stream nextPutAll: '## Bar
43+
Pharo is **cool**
44+
45+
sub-Presenter is not correct. The checker should pay attention that the text may use a different case than the pattern.
46+
3747
' ]
3848
]
3949

@@ -44,14 +54,7 @@ MicVocabularyCheckerTest >> setUp [
4454
fileSystem := FileSystem memory.
4555
self generateFilesystemExample.
4656

47-
checker := MicVocabularyChecker new.
48-
49-
50-
]
51-
52-
{ #category : 'running' }
53-
MicVocabularyCheckerTest >> testCheckerExplain [
54-
57+
checker := MicVocabularyChecker new.
5558
checker pairs: {
5659
('sub-presenter' -> 'subpresenter').
5760
('sub presenter' -> 'subpresenter').
@@ -61,12 +64,40 @@ MicVocabularyCheckerTest >> testCheckerExplain [
6164
('back-end' -> 'backend').
6265
('back end' -> 'backend').
6366
('Pharo Image' -> 'Pharo image') }.
67+
]
68+
69+
{ #category : 'running' }
70+
MicVocabularyCheckerTest >> testCheckerFindsMistakeInHeader [
71+
72+
checker checkProject: fileSystem / 'mistakeInHeader.md'.
73+
self deny: checker isOkay.
74+
75+
self
76+
assert: checker results first explanation
77+
equals:
78+
'Text: sub-presenter is not correct. in file/mistakeInHeader.md contains a mistake: [sub-presenter] should not be used. We should use subpresenter'
79+
]
80+
81+
{ #category : 'running' }
82+
MicVocabularyCheckerTest >> testCheckerFindsMistakeInParagraph [
83+
84+
checker checkProject: fileSystem / 'mistakeInParagraph.md'.
85+
self deny: checker isOkay.
86+
87+
self
88+
assert: checker results first explanation
89+
equals:
90+
'Text: Spec uses a sub presenter. And there is a mistake in the previous sentence. in file/mistakeInParagraph.md contains a mistake: [sub presenter] should not be used. We should use subpresenter'
91+
]
92+
93+
{ #category : 'running' }
94+
MicVocabularyCheckerTest >> testCheckerFindsMistakeInUppercasedText [
6495

65-
checker checkProject: fileSystem / 'example1WithMistake.md'.
96+
checker checkProject: fileSystem / 'mistakeInUppercase.md'.
6697
self deny: checker isOkay.
6798

6899
self
69100
assert: checker results first explanation
70101
equals:
71-
'Text: Spec uses a sub presenter in file/example1WithMistake.md contains a mistake: [sub presenter] should not be used. We should use subpresenter'
102+
'Text: sub-Presenter is not correct. The checker should pay attention that the text may use a different case than the pattern. in file/mistakeInUppercase.md contains a mistake: [sub-presenter] should not be used. We should use subpresenter'
72103
]

0 commit comments

Comments
 (0)