Skip to content

Commit

Permalink
Minor changes. Added support for refuse:.
Browse files Browse the repository at this point in the history
  • Loading branch information
gcotelli committed Feb 1, 2017
1 parent c921572 commit 5831de1
Show file tree
Hide file tree
Showing 26 changed files with 83 additions and 33 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ testConditionalChecking
rowCount := -15.

checkerBuilder
checking: [ :asserter | asserter enforce: [ rowCount notNil ] because: [ self fail ] onSuccess: [ :successAsserter | successAsserter enforce: [ rowCount positive ] because: [ explanation ] ] ].
checking: [ :asserter | asserter refuse: [ rowCount isNil ] because: [ self fail ] onSuccess: [ :successAsserter | successAsserter enforce: [ rowCount positive ] because: [ explanation ] ] ].

self
should: [ checkerBuilder buildAndCheck ]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ testSeveralConditionsButOnlyOneFailed
asserter
enforce: [ 4 > 3 ] because: [ self fail ];
enforce: [ 1 > 2 ] because: mathFailureExplanation;
enforce: [ #() isEmpty ] because: [ self fail ] ].
refuse: [ #() notEmpty ] because: [ self fail ] ].
self
should: [ checkerBuilder buildAndCheck ]
raise: AssertionFailed
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
{
"instance" : {
"testWithoutFailures" : "GabrielOmarCotelli 1/26/2017 19:50",
"testConditionalChecking" : "GabrielOmarCotelli 1/26/2017 19:50",
"testConditionalChecking" : "GabrielOmarCotelli 2/1/2017 15:10",
"testSeveralConditionsButOnlyOneFailedConfiguringErrorToRaise" : "GabrielOmarCotelli 1/31/2017 21:06",
"testFailFastConfiguringErrorToRaise" : "GabrielOmarCotelli 1/31/2017 21:06",
"testConditionalCheckingWhenFirstConditionFails" : "GabrielOmarCotelli 1/26/2017 19:50",
"testSeveralConditionsButOnlyOneFailed" : "GabrielOmarCotelli 1/26/2017 19:50",
"testSeveralConditionsButOnlyOneFailed" : "GabrielOmarCotelli 2/1/2017 15:10",
"testSingleConditionFailure" : "GabrielOmarCotelli 1/26/2017 19:50",
"testFailFastPassingSomeConditions" : "GabrielOmarCotelli 1/26/2017 19:50",
"testFailFastInConditional" : "GabrielOmarCotelli 1/26/2017 19:50",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,5 @@ testEnforceOneFactFailingRaisingError
| explanation |

explanation := 'A false statement'.
"For single fact checking any exception can be configured to be raised"
"For single fact checking any exception can be configured to be raised, but it's not the case when using multiple fact checking"
self should: [ AssertionChecker enforce: [ false ] because: explanation raising: Error ] raise: Error withExceptionDo: [ :exception | self assert: exception messageText equals: explanation ]
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
tests
testRefuseOneFactFailing

| explanation |

explanation := 'A false statement'.
self should: [ AssertionChecker refuse: [ true ] because: explanation ] raise: AssertionFailed withExceptionDo: [ :exception | self assert: exception messageText equals: explanation ]
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
tests
testRefuseOneFactNotFailing

self
shouldnt: [ AssertionChecker refuse: [ false ] because: [ self fail ] ] raise: AssertionFailed;
shouldnt: [ AssertionChecker refuse: [ false ] because: [ self fail ] raising: InstanceCreationFailed ] raise: InstanceCreationFailed
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
{
"instance" : {
"testEnforceOneFactFailingRaisingNonDefaultException" : "GabrielOmarCotelli 1/31/2017 20:19",
"testEnforceOneFactFailing" : "GabrielOmarCotelli 1/31/2017 20:16",
"testEnforceOneFactNotFailing" : "GabrielOmarCotelli 1/31/2017 20:57",
"testEnforceOneFactFailingRaisingError" : "GabrielOmarCotelli 1/31/2017 21:08"
"testRefuseOneFactFailing" : "GabrielOmarCotelli 2/1/2017 14:49",
"testEnforceOneFactFailing" : "GabrielOmarCotelli 1/31/2017 20:16",
"testRefuseOneFactNotFailing" : "GabrielOmarCotelli 2/1/2017 15:08",
"testEnforceOneFactFailingRaisingError" : "GabrielOmarCotelli 2/1/2017 14:22",
"testEnforceOneFactFailingRaisingNonDefaultException" : "GabrielOmarCotelli 1/31/2017 20:19"
},
"class" : { }
}
2 changes: 1 addition & 1 deletion source/Buoy-Tests.package/monticello.meta/version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
(name 'Buoy-Tests-GabrielOmarCotelli.4' message 'Add test cases' id 'eebeab3b-1eda-4b0c-955e-450bc100b05a' date '31 January 2017' time '9:13:55.838186 pm' author 'GabrielOmarCotelli' ancestors ((name 'Buoy-Tests-GabrielOmarCotelli.3' message 'Add Holders ' id '21414a7c-6b1d-134d-a01a-dad169c438de' date '27 January 2017' time '6:47:13.88642 pm' author 'GabrielOmarCotelli' ancestors ((name 'Buoy-Tests-GabrielOmarCotelli.2' message 'Renamed a method' id '4db25a31-cdbf-4d66-8e72-877e298b1b47' date '26 January 2017' time '7:51:46.200684 pm' author 'GabrielOmarCotelli' ancestors ((name 'Buoy-Tests-GabrielOmarCotelli.1' message 'Renamed packages' id '714b9a68-e0b3-4b48-be06-7b3f27f4ce47' date '26 January 2017' time '7:29:43.673983 pm' author 'GabrielOmarCotelli' ancestors () stepChildren ())) stepChildren ())) stepChildren ())) stepChildren ())
(name 'Buoy-Tests-GabrielOmarCotelli.5' message 'Minor changes. Added support for refuse:.' id '76d04fb8-d53c-2348-b0b9-e090961b922e' date '1 February 2017' time '3:16:33.360533 pm' author 'GabrielOmarCotelli' ancestors ((name 'Buoy-Tests-GabrielOmarCotelli.4' message 'Add test cases' id 'eebeab3b-1eda-4b0c-955e-450bc100b05a' date '31 January 2017' time '9:13:55.838186 pm' author 'GabrielOmarCotelli' ancestors ((name 'Buoy-Tests-GabrielOmarCotelli.3' message 'Add Holders ' id '21414a7c-6b1d-134d-a01a-dad169c438de' date '27 January 2017' time '6:47:13.88642 pm' author 'GabrielOmarCotelli' ancestors ((name 'Buoy-Tests-GabrielOmarCotelli.2' message 'Renamed a method' id '4db25a31-cdbf-4d66-8e72-877e298b1b47' date '26 January 2017' time '7:51:46.200684 pm' author 'GabrielOmarCotelli' ancestors ((name 'Buoy-Tests-GabrielOmarCotelli.1' message 'Renamed packages' id '714b9a68-e0b3-4b48-be06-7b3f27f4ce47' date '26 January 2017' time '7:29:43.673983 pm' author 'GabrielOmarCotelli' ancestors () stepChildren ())) stepChildren ())) stepChildren ())) stepChildren ())) stepChildren ())
4 changes: 4 additions & 0 deletions source/Buoy.package/Asserter.class/instance/asReverseFact..st
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
private
asReverseFact: aFact

^ [ aFact value not ]
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
configuring
refuse: aFact because: aStringOrBlock

self enforce: (self asReverseFact: aFact) because: aStringOrBlock
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
configuring
refuse: aFact because: anExplanationStringOrBlock onSuccess: aSuccessAction

self enforce: (self asReverseFact: aFact) because: anExplanationStringOrBlock onSuccess: aSuccessAction
7 changes: 5 additions & 2 deletions source/Buoy.package/Asserter.class/methodProperties.json
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
{
"instance" : {
"asReverseFact:" : "GabrielOmarCotelli 2/1/2017 14:44",
"enforce:because:" : "GabrielOmarCotelli 1/26/2017 19:50",
"enforce:because:onSuccess:" : "GabrielOmarCotelli 1/26/2017 19:50",
"initialize" : "GabrielOmarCotelli 1/25/2017 21:42",
"checkApplying:" : "GabrielOmarCotelli 1/25/2017 21:43",
"value:applying:" : "GabrielOmarCotelli 1/24/2017 21:46"
"initialize" : "GabrielOmarCotelli 1/25/2017 21:42",
"value:applying:" : "GabrielOmarCotelli 1/24/2017 21:46",
"refuse:because:onSuccess:" : "GabrielOmarCotelli 2/1/2017 14:44",
"refuse:because:" : "GabrielOmarCotelli 2/1/2017 14:44"
},
"class" : { }
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
private
checkApplyingFailFastPolicyTo: asserter raising: errorToSignal

^ (self applying: (RaiseOnFirstAssertionFailurePolicy raising: errorToSignal) to: asserter) check
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
checking
enforce: aFact because: aStringOrBlockExplanation

^ self enforce: aFact because: aStringOrBlockExplanation raising: AssertionFailed
^ self enforce: aFact because: aStringOrBlockExplanation raising: AssertionFailurePolicy defaultErrorToSignal
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
checking
enforce: aFact because: aStringOrBlockExplanation raising: errorClass
enforce: aFact because: aStringOrBlockExplanation raising: errorToSignal

^ (self
applying: (RaiseOnFirstAssertionFailurePolicy raising: errorClass)
to:
(Asserter new
enforce: aFact because: aStringOrBlockExplanation;
yourself)) check
| asserter |

asserter := Asserter new.
asserter enforce: aFact because: aStringOrBlockExplanation.

^ self checkApplyingFailFastPolicyTo: asserter raising: errorToSignal
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
checking
refuse: aFact because: aStringOrBlockExplanation

^ self refuse: aFact because: aStringOrBlockExplanation raising: AssertionFailurePolicy defaultErrorToSignal
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
checking
refuse: aFact because: aStringOrBlockExplanation raising: errorToSignal

| asserter |

asserter := Asserter new.
asserter refuse: aFact because: aStringOrBlockExplanation.

^ self checkApplyingFailFastPolicyTo: asserter raising: errorToSignal
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,11 @@
"check" : "GabrielOmarCotelli 1/25/2017 21:50"
},
"class" : {
"enforce:because:" : "GabrielOmarCotelli 2/1/2017 14:09",
"checkApplyingFailFastPolicyTo:raising:" : "GabrielOmarCotelli 2/1/2017 14:48",
"enforce:because:raising:" : "GabrielOmarCotelli 2/1/2017 14:48",
"refuse:because:raising:" : "GabrielOmarCotelli 2/1/2017 14:47",
"applying:to:" : "GabrielOmarCotelli 1/25/2017 21:51",
"enforce:because:" : "GabrielOmarCotelli 1/31/2017 20:55",
"enforce:because:raising:" : "GabrielOmarCotelli 1/31/2017 20:55"
"refuse:because:" : "GabrielOmarCotelli 2/1/2017 14:45"
}
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
checking
build

^ AssertionChecker applying: (failurePolicyFactory raising: errorClass) to: asserter
^ AssertionChecker applying: (failurePolicyFactory raising: errorToSignal) to: asserter
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@ initialize

super initialize.
asserter := Asserter new.
errorClass := AssertionFailurePolicy defaultError.
self raising: AssertionFailurePolicy defaultErrorToSignal.
failurePolicyFactory := CollectingAssertionFailuresPolicy
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
configuring
raising: anErrorClass
raising: anErrorToSignal

errorClass := anErrorClass
errorToSignal := anErrorToSignal
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
{
"instance" : {
"build" : "GabrielOmarCotelli 1/31/2017 21:04",
"build" : "GabrielOmarCotelli 2/1/2017 14:11",
"checking:" : "GabrielOmarCotelli 1/23/2017 17:14",
"initialize" : "GabrielOmarCotelli 1/31/2017 21:04",
"raising:" : "GabrielOmarCotelli 1/31/2017 21:05",
"initialize" : "GabrielOmarCotelli 2/1/2017 14:11",
"raising:" : "GabrielOmarCotelli 2/1/2017 14:11",
"buildAndCheck" : "GabrielOmarCotelli 1/25/2017 21:52",
"failFast" : "GabrielOmarCotelli 1/24/2017 21:29"
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
"instvars" : [
"asserter",
"failurePolicyFactory",
"errorClass"
"errorToSignal"
],
"name" : "AssertionCheckerBuilder",
"type" : "normal"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Accessing
defaultError
defaultErrorToSignal

^ AssertionFailed
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"assertionFailedBecause:" : "GabrielOmarCotelli 1/24/2017 21:27"
},
"class" : {
"raising:" : "GabrielOmarCotelli 1/31/2017 21:02",
"defaultError" : "GabrielOmarCotelli 1/31/2017 21:01"
"defaultErrorToSignal" : "GabrielOmarCotelli 2/1/2017 14:09",
"raising:" : "GabrielOmarCotelli 1/31/2017 21:02"
}
}
2 changes: 1 addition & 1 deletion source/Buoy.package/monticello.meta/version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
(name 'Buoy-GabrielOmarCotelli.4' message 'Add support for configuring the error to raise' id 'c7f8a941-2bd9-4516-b799-422568b01d9b' date '31 January 2017' time '9:12:59.929828 pm' author 'GabrielOmarCotelli' ancestors ((name 'Buoy-GabrielOmarCotelli.3' message 'Add Holders ' id '6abb119b-9bdf-9f4d-9ed6-03e57b808e6f' date '27 January 2017' time '6:46:17.43442 pm' author 'GabrielOmarCotelli' ancestors ((name 'Buoy-GabrielOmarCotelli.2' message 'Renamed a method' id '9695bddd-07f6-4941-9102-6391e123ed81' date '26 January 2017' time '7:51:52.401108 pm' author 'GabrielOmarCotelli' ancestors ((name 'Buoy-GabrielOmarCotelli.1' message 'Renamed packages' id 'cd4412b9-c2d6-4833-aa07-73bfa4f0bd14' date '26 January 2017' time '7:29:12.845086 pm' author 'GabrielOmarCotelli' ancestors () stepChildren ())) stepChildren ())) stepChildren ())) stepChildren ())
(name 'Buoy-GabrielOmarCotelli.5' message 'Minor changes. Added support for refuse:.' id '90f1c3f8-f68d-384b-bde2-76191df27929' date '1 February 2017' time '3:15:21.893533 pm' author 'GabrielOmarCotelli' ancestors ((name 'Buoy-GabrielOmarCotelli.4' message 'Add support for configuring the error to raise' id 'c7f8a941-2bd9-4516-b799-422568b01d9b' date '31 January 2017' time '9:12:59.929828 pm' author 'GabrielOmarCotelli' ancestors ((name 'Buoy-GabrielOmarCotelli.3' message 'Add Holders ' id '6abb119b-9bdf-9f4d-9ed6-03e57b808e6f' date '27 January 2017' time '6:46:17.43442 pm' author 'GabrielOmarCotelli' ancestors ((name 'Buoy-GabrielOmarCotelli.2' message 'Renamed a method' id '9695bddd-07f6-4941-9102-6391e123ed81' date '26 January 2017' time '7:51:52.401108 pm' author 'GabrielOmarCotelli' ancestors ((name 'Buoy-GabrielOmarCotelli.1' message 'Renamed packages' id 'cd4412b9-c2d6-4833-aa07-73bfa4f0bd14' date '26 January 2017' time '7:29:12.845086 pm' author 'GabrielOmarCotelli' ancestors () stepChildren ())) stepChildren ())) stepChildren ())) stepChildren ())) stepChildren ())

0 comments on commit 5831de1

Please sign in to comment.