Skip to content

Commit

Permalink
Fix #109
Browse files Browse the repository at this point in the history
  • Loading branch information
ytsejam78 committed Aug 12, 2024
1 parent 7193725 commit 43141db
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 1 deletion.
25 changes: 25 additions & 0 deletions source/Sagan-Core-Tests/RepositoryBasedTest.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -257,6 +257,31 @@ RepositoryBasedTest >> testFindAllMatchingLimitedToSortedByAscending [

]

{ #category : 'tests - querying' }
RepositoryBasedTest >> testFindAllMatchingLimitedToSortedByAscendingLimitGreaterThanNumberOfMatchingElements [

| results |
self extraterrestrials
store: self silvesterStallone;
store: self silvesterMcCoy;
store: self johnTravolta;
store: self johnLock.

results := self extraterrestrials
findAllMatching: [ :extraterrestrial :criteria |
criteria does: extraterrestrial lastName asUppercase includeSubstring: 'L' ]
limitedTo: 4
sortedByAscending: #lastName.

self
assert: results size equals: 3;
assert: ( results anySatisfy: [ :result | result lastName = 'Lock' ] );
deny: ( results anySatisfy: [ :result | result lastName = 'McCoy' ] );
assert: ( results anySatisfy: [ :result | result lastName = 'Stallone' ] );
assert: ( results anySatisfy: [ :result | result lastName = 'Travolta' ] )

]

{ #category : 'tests - querying' }
RepositoryBasedTest >> testFindAllMatchingSortedBy [

Expand Down
2 changes: 1 addition & 1 deletion source/Sagan-Core/InMemoryRepository.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ InMemoryRepository >> findAllMatching: aCriteriaOrBlock [
InMemoryRepository >> findAllMatching: aCriteriaOrBlock limitedTo: aMaxNumberOfResults sortedByAscending: aVariableName [

^ ( ( self contentsSortedByAscending: aVariableName ) select:
( self asMatchingCriteria: aCriteriaOrBlock ) ) copyFirst: aMaxNumberOfResults
( self asMatchingCriteria: aCriteriaOrBlock ) ) copyNoMoreThanFirst: aMaxNumberOfResults
]

{ #category : 'querying' }
Expand Down

0 comments on commit 43141db

Please sign in to comment.