Skip to content

Commit

Permalink
Merge pull request #656 from hernanmd/NewFinder
Browse files Browse the repository at this point in the history
New Finder
  • Loading branch information
Ducasse authored Jan 18, 2024
2 parents 435667d + 3fb7839 commit 6805e51
Show file tree
Hide file tree
Showing 56 changed files with 4,739 additions and 2 deletions.
14 changes: 12 additions & 2 deletions src/BaselineOfNewTools/BaselineOfNewTools.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,11 @@ BaselineOfNewTools >> baseline: spec [
package: 'NewTools-Scopes-Tests';
package: 'NewTools-Scopes-Resources-A-Tests';
package: 'NewTools-Scopes-Resources-B-Tests';
package: 'NewTools-Scopes-Resources-C-Tests'.
package: 'NewTools-Scopes-Resources-C-Tests';
package: 'NewTools-Scopes-Tests';
"Finder"
package: 'NewTools-Finder';
package: 'NewTools-Finder-Tests' with: [ spec requires: #('NewTools-Finder') ].

spec
group: 'Core' with: #( 'NewTools-Core' 'NewTools-Morphic' );
Expand Down Expand Up @@ -147,6 +151,11 @@ BaselineOfNewTools >> baseline: spec [
'NewTools-Scopes-Resources-B-Tests'
'NewTools-Scopes-Resources-C-Tests'
'NewTools-Scopes-Tests');
"Finder"
group: #Finder with: #(
'NewTools-Finder'
'NewTools-Finder-Tests');

group: 'default' with: #(
'Playground'
'Inspector'
Expand All @@ -158,7 +167,8 @@ BaselineOfNewTools >> baseline: spec [
'Spotter'
'RewriterTools'
'ScopesEditor'
'FileBrowser') ]
'FileBrowser'
'Finder') ]
]

{ #category : 'external projects' }
Expand Down
105 changes: 105 additions & 0 deletions src/NewTools-Finder-Tests/StFinderClassTest.class.st
Original file line number Diff line number Diff line change
@@ -0,0 +1,105 @@
Class {
#name : 'StFinderClassTest',
#superclass : 'StFinderTest',
#category : 'NewTools-Finder-Tests-Core',
#package : 'NewTools-Finder-Tests',
#tag : 'Core'
}

{ #category : 'running' }
StFinderClassTest >> setUp [

super setUp.
presenterModel currentSearch: StFinderClassSearch new

]

{ #category : 'tests' }
StFinderClassTest >> testSearchForExactCaseInsensitiveStringMissing [

self openInstance.
self setExactAndCaseInsensitive.
self doSearch: 'stfindermock'.

self assertEmpty: presenter resultTree roots.

]

{ #category : 'tests' }
StFinderClassTest >> testSearchForExactCaseInsensitiveStringSucess [

| results |

self openInstance.
self setExactAndCaseInsensitive.
self doSearch: 'stfindermockc'.

results := presenter resultTree roots.
self
assertCollection: (results collect: [ : r | r content name ])
hasSameElements: #(#StFinderMockC).
]

{ #category : 'tests' }
StFinderClassTest >> testSearchForExactCaseSensitiveStringMissing [

self openInstance.
self setExactAndCaseSensitive.
self doSearch: 'StFinderMock'.

self assertEmpty: presenter resultTree roots.

]

{ #category : 'tests' }
StFinderClassTest >> testSearchForExactCaseSensitiveStringSucess [

| results |

self openInstance.
self setExactAndCaseSensitive.
self doSearch: 'StFinderMockC'.

results := presenter resultTree roots.
self
assert: results size
equals: 1.
]

{ #category : 'tests' }
StFinderClassTest >> testSearchForRegexpStartWithCaseInsensitive [

| results |

self openInstance.
self setRegexAndCaseInsensitive.
self doSearch: '^StFinderMock'.
results := presenter resultTree roots.

self
assertCollection: (results collect: [ : r | r content name ])
hasSameElements: #(#StFinderMockC #StFinderMocka #StFinderMockB).
]

{ #category : 'tests' }
StFinderClassTest >> testSearchForRegexpStartWithCaseSensitive [

| results |

self openInstance.
self setRegexAndCaseSensitive.
self doSearch: '^StFinderMockC'.
results := presenter resultTree roots.
self
assert: results size
equals: 1.
]

{ #category : 'tests' }
StFinderClassTest >> testSubstringSearchNonExistingClass [

self openInstance.
self doSearch: 'NonExistingClass'.

self assertEmpty: presenter resultTree roots
]
68 changes: 68 additions & 0 deletions src/NewTools-Finder-Tests/StFinderExampleTest.class.st
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
Class {
#name : 'StFinderExampleTest',
#superclass : 'StFinderTest',
#category : 'NewTools-Finder-Tests-Core',
#package : 'NewTools-Finder-Tests',
#tag : 'Core'
}

{ #category : 'running' }
StFinderExampleTest >> setUp [

super setUp.
presenterModel currentSearch: StFinderExampleSearch new.
self openInstance.

]

{ #category : 'running' }
StFinderExampleTest >> testConcatenationSearch [

| results |

self doSearch: '''a''. ''b''. ''ab'''.

results := presenter resultTree roots.
self assert: results size equals: 2.
]

{ #category : 'running' }
StFinderExampleTest >> testFactorialSearch [

| results firstResult secondResult |

self doSearch: '3 . 6'.

results := presenter resultTree roots.
firstResult := results contents first.
secondResult := results contents second.

self assert: firstResult content selector equals: #slowFactorial.
self assert: secondResult content selector equals: #factorial.

]

{ #category : 'running' }
StFinderExampleTest >> testIndexOfSearch [

| results |

self doSearch: '{2. 4. 5. 1}. 5. 3'.

results := presenter resultTree roots.

self assert: (results contents anySatisfy: [ : r | r content selector = #indexOf: ])

]

{ #category : 'running' }
StFinderExampleTest >> testNegatedSearch [

| results singleResult |

self doSearch: '2 . -2'.

results := presenter resultTree roots.
singleResult := results contents anyOne.
self assert: singleResult content selector equals: #negated.
]
7 changes: 7 additions & 0 deletions src/NewTools-Finder-Tests/StFinderMockB.class.st
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
Class {
#name : 'StFinderMockB',
#superclass : 'Object',
#category : 'NewTools-Finder-Tests-Mocks',
#package : 'NewTools-Finder-Tests',
#tag : 'Mocks'
}
30 changes: 30 additions & 0 deletions src/NewTools-Finder-Tests/StFinderMockC.class.st
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
"
Class to hold sample selectors to find.
"
Class {
#name : 'StFinderMockC',
#superclass : 'Object',
#category : 'NewTools-Finder-Tests-Mocks',
#package : 'NewTools-Finder-Tests',
#tag : 'Mocks'
}

{ #category : 'accessing' }
StFinderMockC >> aBCSelectorSearchForRegexpStartWithCase [
"mock example"
]

{ #category : 'accessing' }
StFinderMockC >> abcSelectorSearchForRegexpStartWithoutCase [
"mock example"
]

{ #category : 'accessing' }
StFinderMockC >> selectorSearchForRegexpWithCaseEndsWithAbc [
"mock example"
]

{ #category : 'accessing' }
StFinderMockC >> selectorSearchForRegexpWithoutCaseEndsWithabc [
"mock example"
]
7 changes: 7 additions & 0 deletions src/NewTools-Finder-Tests/StFinderMocka.class.st
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
Class {
#name : 'StFinderMocka',
#superclass : 'Object',
#category : 'NewTools-Finder-Tests-Mocks',
#package : 'NewTools-Finder-Tests',
#tag : 'Mocks'
}
105 changes: 105 additions & 0 deletions src/NewTools-Finder-Tests/StFinderPackageTest.class.st
Original file line number Diff line number Diff line change
@@ -0,0 +1,105 @@
Class {
#name : 'StFinderPackageTest',
#superclass : 'StFinderTest',
#category : 'NewTools-Finder-Tests-Core',
#package : 'NewTools-Finder-Tests',
#tag : 'Core'
}

{ #category : 'running' }
StFinderPackageTest >> setUp [

super setUp.
presenterModel currentSearch: StFinderPackageSearch new

]

{ #category : 'tests' }
StFinderPackageTest >> testSearchForExactCaseInsensitiveStringMissing [

self openInstance.
self setExactAndCaseInsensitive.
self doSearch: 'newtools-finder'.

self assertEmpty: presenter resultTree roots.

]

{ #category : 'tests' }
StFinderPackageTest >> testSearchForExactCaseInsensitiveStringSucess [

| results |

self openInstance.
self setExactAndCaseInsensitive.
self doSearch: 'newtools-finder-tests'.

results := presenter resultTree roots.
self
assertCollection: (results collect: [ : r | r content name ])
hasSameElements: #('NewTools-Finder-Tests').
]

{ #category : 'tests' }
StFinderPackageTest >> testSearchForExactCaseSensitiveStringMissing [

self openInstance.
self setExactAndCaseSensitive.
self doSearch: 'NewTools-Finder'.

self assertEmpty: presenter resultTree roots.

]

{ #category : 'tests' }
StFinderPackageTest >> testSearchForExactCaseSensitiveStringSucess [

| results |

self openInstance.
self setExactAndCaseSensitive.
self doSearch: 'NewTools-Finder-Tests'.

results := presenter resultTree roots.
self
assert: results size
equals: 1.
]

{ #category : 'tests' }
StFinderPackageTest >> testSearchForRegexpStartWithCaseInsensitive [

| results |

self openInstance.
self setRegexAndCaseInsensitive.
self doSearch: '^newTools-finder'.
results := presenter resultTree roots.

self
assertCollection: (results collect: [ : r | r content name ])
hasSameElements: #(#'NewTools-Finder-Tests').
]

{ #category : 'tests' }
StFinderPackageTest >> testSearchForRegexpStartWithCaseSensitive [

| results |

self openInstance.
self setRegexAndCaseSensitive.
self doSearch: '^NewTools-Finder'.
results := presenter resultTree roots.
self
assert: results size
equals: 1.
]

{ #category : 'tests' }
StFinderPackageTest >> testSubstringSearchNonExistingPackage [

self openInstance.

self doSearch: 'NonExistingPackage'.
self assertEmpty: presenter resultTree roots
]
Loading

0 comments on commit 6805e51

Please sign in to comment.