Skip to content

Commit

Permalink
make class package work across all Pharo versions for generating test…
Browse files Browse the repository at this point in the history
… classes
  • Loading branch information
jbrichau committed Feb 4, 2024
1 parent edd9b01 commit 203d08e
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 23 deletions.
Original file line number Diff line number Diff line change
@@ -1,20 +1,4 @@
accessing-code
defineSubClassOf: aSuperSymbol

| class |
class := SystemVersion current major >= 12
ifTrue: [
factory make: [ :aBuilder |
aBuilder
superclass: (Smalltalk at: aSuperSymbol);
package: self category ] ]
ifFalse: [
factory
newSubclassOf: (Smalltalk at: aSuperSymbol)
instanceVariableNames: ''
classVariableNames: 'classVarsString'
category: self category ].
environment
addClass: class;
addClass: class classSide.
^ class
^ self defineSubClassOf: aSuperSymbol inPackage: self category
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
accessing-code
defineSubClassOf: aSuperSymbol inPackage: packageName

| class |
class := SystemVersion current major >= 12
ifTrue: [
factory make: [ :aBuilder |
aBuilder
superclass: (Smalltalk at: aSuperSymbol);
package: packageName ] ]
ifFalse: [
factory
newSubclassOf: (Smalltalk at: aSuperSymbol)
instanceVariableNames: ''
classVariableNames: 'classVarsString'
category: packageName ].
environment
addClass: class;
addClass: class classSide.
^ class
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,7 @@ tests-block
testReferencesNotPortableClass

| class |
class := self defineSubClassOf: #GRObject.
class package: 'SomeCategory' tag: ''.
class := self defineSubClassOf: #GRObject inPackage: 'SomeCategory'.
self compile: 'invalid ^ Semaphore new' in: class.
self compile: 'valid ^ GRObject new' in: class.
self
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,7 @@ tests-block
testSubclassesNotPortableClass

| class |
class := self defineSubClassOf: #Mutex.
class package: 'SomeCategory' tag: ''.
class := self defineSubClassOf: #Mutex inPackage: 'SomeCategory'.
self
assertRule: GRSubclassesNotPortableClassRule
matches: { class }
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,7 @@ tests-block
testUsesNotPortableClass

| class |
class := self defineSubClassOf: #GRObject.
class package: 'SomeCategory' tag: ''.
class := self defineSubClassOf: #GRObject inPackage: 'SomeCategory'.
self compile: 'invalid ^ Semaphore new' in: class.
self compile: 'valid ^ GRObject new' in: class.
self
Expand Down

0 comments on commit 203d08e

Please sign in to comment.