-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #57 from ba-st/equality_checker
Equality checker
- Loading branch information
Showing
15 changed files
with
376 additions
and
185 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
49 changes: 49 additions & 0 deletions
49
source/Buoy-Comparison-Tests/ObjectUsingComparisonAffordances.class.st
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
" | ||
I'm an example used for testing purposes | ||
" | ||
Class { | ||
#name : #ObjectUsingComparisonAffordances, | ||
#superclass : #Object, | ||
#instVars : [ | ||
'first', | ||
'second' | ||
], | ||
#category : #'Buoy-Comparison-Tests' | ||
} | ||
|
||
{ #category : #'instance creation' } | ||
ObjectUsingComparisonAffordances class >> with: anInteger and: anInteger2 [ | ||
|
||
^ self new initializeWith: anInteger and: anInteger2 | ||
] | ||
|
||
{ #category : #comparing } | ||
ObjectUsingComparisonAffordances >> = anObject [ | ||
|
||
^ self equalityChecker | ||
compareAll: #(#first #second); | ||
checkAgainst: anObject | ||
] | ||
|
||
{ #category : #accessing } | ||
ObjectUsingComparisonAffordances >> first [ | ||
^ first | ||
] | ||
|
||
{ #category : #comparing } | ||
ObjectUsingComparisonAffordances >> hash [ | ||
|
||
^ self equalityHashCombinator combineHashOf: first with: second | ||
] | ||
|
||
{ #category : #initialization } | ||
ObjectUsingComparisonAffordances >> initializeWith: anInteger and: anInteger2 [ | ||
|
||
first := anInteger. | ||
second := anInteger2 | ||
] | ||
|
||
{ #category : #accessing } | ||
ObjectUsingComparisonAffordances >> second [ | ||
^ second | ||
] |
28 changes: 0 additions & 28 deletions
28
source/Buoy-Comparison-Tests/ObjectUsingEqualityHashCombinator.class.st
This file was deleted.
Oops, something went wrong.
82 changes: 82 additions & 0 deletions
82
source/Buoy-Comparison-Tests/PropertyBasedEqualityCheckerTest.class.st
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,82 @@ | ||
" | ||
An #PropertyBasedEqualityCheckerTest is a test class for testing the behavior of #PropertyBasedEqualityChecker | ||
" | ||
Class { | ||
#name : #PropertyBasedEqualityCheckerTest, | ||
#superclass : #TestCase, | ||
#category : #'Buoy-Comparison-Tests' | ||
} | ||
|
||
{ #category : #tests } | ||
PropertyBasedEqualityCheckerTest >> testCheckingIdenticalObjects [ | ||
|
||
| checker | | ||
|
||
checker := self equalityChecker. | ||
checker compareWith: [ :a :b | self fail ]. | ||
|
||
self assert: ( checker checkAgainst: self ) | ||
] | ||
|
||
{ #category : #tests } | ||
PropertyBasedEqualityCheckerTest >> testPropertyBlockComparison [ | ||
|
||
| checker | | ||
|
||
checker := #(1 2 3 4) equalityChecker. | ||
checker compare: [ :collection | collection last even ]. | ||
|
||
self | ||
assert: ( checker checkAgainst: #(2) ); | ||
assert: ( checker checkAgainst: #(1 2 3 4) ); | ||
deny: ( checker checkAgainst: #(3) ); | ||
deny: ( checker checkAgainst: #(1 2 3 3) ). | ||
|
||
checker := #(1 2 3 3) equalityChecker. | ||
checker compare: [ :collection | collection last even ]. | ||
|
||
self | ||
assert: ( checker checkAgainst: #(1) ); | ||
assert: ( checker checkAgainst: #(1 2 3 3) ); | ||
deny: ( checker checkAgainst: #(2) ); | ||
deny: ( checker checkAgainst: #(1 2 3 4) ) | ||
] | ||
|
||
{ #category : #tests } | ||
PropertyBasedEqualityCheckerTest >> testPropertyComparison [ | ||
|
||
| checker | | ||
|
||
checker := #(1 2 3 4) equalityChecker. | ||
checker compare: #first. | ||
|
||
self | ||
assert: ( checker checkAgainst: #(1 1 1 1) ); | ||
deny: ( checker checkAgainst: #(2 2 3 4) ) | ||
] | ||
|
||
{ #category : #tests } | ||
PropertyBasedEqualityCheckerTest >> testSeveralPropertiesComparison [ | ||
|
||
| checker | | ||
|
||
checker := #(1 2 3 4) equalityChecker. | ||
checker compareAll: #(#first #second). | ||
|
||
self | ||
assert: ( checker checkAgainst: #(1 2 1 2) ); | ||
deny: ( checker checkAgainst: #(1 1 3 4) ); | ||
deny: ( checker checkAgainst: #(2 2 3 4) ) | ||
] | ||
|
||
{ #category : #tests } | ||
PropertyBasedEqualityCheckerTest >> testTypeComparison [ | ||
|
||
| checker | | ||
|
||
checker := self equalityChecker. | ||
|
||
self | ||
assert: ( checker checkAgainst: self class new ); | ||
deny: ( checker checkAgainst: self class superclass new ) | ||
] |
26 changes: 26 additions & 0 deletions
26
source/Buoy-Comparison-Tests/SequenceableCollectionEqualityCheckerTest.class.st
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
" | ||
A SequenceableCollectionEqualityCheckerTest is a test class for testing the behavior of SequenceableCollectionEqualityChecker | ||
" | ||
Class { | ||
#name : #SequenceableCollectionEqualityCheckerTest, | ||
#superclass : #TestCase, | ||
#category : #'Buoy-Comparison-Tests' | ||
} | ||
|
||
{ #category : #tests } | ||
SequenceableCollectionEqualityCheckerTest >> testCheckAgainst [ | ||
|
||
| checker base | | ||
|
||
base := #(1 2 3 4). | ||
checker := SequenceableCollectionEqualityChecker new. | ||
|
||
self | ||
assert: ( checker check: base against: #(1 2 3 4) ); | ||
assert: ( checker check: base against: #(1 2 3 4) asOrderedCollection ); | ||
deny: ( checker check: base against: #(1 2 3) ); | ||
deny: ( checker check: base against: #(0 2 3 4) ); | ||
deny: ( checker check: base against: #(1 0 3 4) ); | ||
deny: ( checker check: base against: #(1 2 0 4) ); | ||
deny: ( checker check: base against: #(1 2 3 0) ) | ||
] |
79 changes: 0 additions & 79 deletions
79
source/Buoy-Comparison-Tests/StandardComparatorTest.class.st
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.