Skip to content

Commit

Permalink
610 all pharo tests pass even though i didnt solve the exercise (#611)
Browse files Browse the repository at this point in the history
* Handle removing of class from system, so that test can fail after removing it.
- fixes #610

* Replaced deprecated method in P11.

* Moved removing of class to compatibility package for P11.
  • Loading branch information
Bajger authored Feb 22, 2024
1 parent 1d52806 commit aa1cc00
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 1 deletion.
5 changes: 5 additions & 0 deletions dev/src/BaselineOfExercism/BaselineOfExercism.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,11 @@ BaselineOfExercism >> baseline: spec [
group: 'testRunnerTests' with: #('ExercismTestRunnerTests'), self class exerciseGoldenTestPackageNames;
group: 'v3' with: #('ExercismV3')
].
spec for: #'pharo11.x' do: [
"ExercismTools methods will add methods from compatibility package for Pharo 11"
spec package: 'ExercismTests' with: [ spec includes: #('ExercismPharo110') ].
spec package: 'ExercismPharo110'
].
spec for: #'pharo12.x' do: [
"ExercismTools methods will be overwritten by compatibility package for Pharo 12"
spec package: 'ExercismTests' with: [ spec includes: #('ExercismPharo120') ].
Expand Down
24 changes: 24 additions & 0 deletions dev/src/ExercismPharo110/Class.extension.st
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
Extension { #name : #Class }

{ #category : #'*ExercismPharo110' }
Class >> removeFromSystem: logged [
"Forget the receiver from the Smalltalk global dictionary. Any existing instances will refer to an obsolete version of the receiver.
Keep the class name and category for triggering the system change message. If we wait to long, then we get obsolete information which is not what we want.
Tell class to deactivate and unload itself-- two separate events in the module system"
| myCategory |
self release.
self unload.

self superclass ifNotNil:
["If we have no superclass there's nothing to be remembered"
self superclass addObsoleteSubclass: self].

"we add the class to Undeclared so that if references still exist, they will be automatically fixed
if this class is loaded again. We do not check if references exist as it is too slow"
self binding value: nil.
Undeclared declare: self name asSymbol from: Smalltalk globals.
myCategory := self category.
self environment forgetClass: self logged: logged.
self obsolete.
logged ifTrue: [SystemAnnouncer uniqueInstance classRemoved: self fromCategory: myCategory]
]
1 change: 1 addition & 0 deletions dev/src/ExercismPharo110/package.st
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Package { #name : #ExercismPharo110 }
2 changes: 1 addition & 1 deletion dev/src/ExercismTestRunner/ExercismTest.extension.st
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ ExercismTest >> resultDebugInfo [
[
aContext isNil or: [
aContext receiver == self and: [
aContext methodSelector == #runCase ] ] ] whileFalse: [
aContext selector == #runCase ] ] ] whileFalse: [
[
writeStream
nextPutAll: aContext printString;
Expand Down

0 comments on commit aa1cc00

Please sign in to comment.