Skip to content

Commit

Permalink
Test that class creation does not create packages
Browse files Browse the repository at this point in the history
  • Loading branch information
theseion committed Nov 18, 2023
1 parent 668ca0c commit b2888b9
Show file tree
Hide file tree
Showing 5 changed files with 42 additions and 10 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
helpers
fullySerialize: aClass
self serializer fullySerializeBehavior: aClass.
self serialize: aClass
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
helpers
materializeSilently: aBoolean

| materialized |
materialized := self materialized.
self classFactory registerBehavior: materialized.
aBoolean ifTrue: [ self classFactory createdSilently add: materialized ].
^ materialized
Original file line number Diff line number Diff line change
@@ -1,12 +1,7 @@
tests
helpers
resultOfSerializeRemoveAndMaterialize: aClass

| materialized wasSilent |
self serializer fullySerializeBehavior: aClass.
self serialize: aClass.
| wasSilent |
self fullySerialize: aClass.
wasSilent := self classFactory createdSilently includes: aClass.
self classFactory delete: aClass.
materialized := self materialized.
self classFactory registerBehavior: materialized.
wasSilent ifTrue: [ self classFactory createdSilently add: materialized ].
^ materialized
^ self materializeSilently: wasSilent
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
tests
helpers
resultOfSerializeRemoveAndMaterializeAll: objects

| classesOrTraits materialized silent |
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
tests
testDoesNotCreatePackage
"Tests materialization of a package not defined in the image."

| undefinedPackage aClassOrTrait materializedClassOrTrait package packageTag wasSilent |
undefinedPackage := self packageOrganizer undefinedPackage.
aClassOrTrait := self newClassOrTrait.
package := aClassOrTrait package.
packageTag := aClassOrTrait packageTag.

self deny: package identicalTo: undefinedPackage.

self fullySerialize: aClassOrTrait.
wasSilent := self classFactory createdSilently includes: aClassOrTrait.
self classFactory delete: aClassOrTrait.

package removeFromSystem.
self deny: (self packageOrganizer hasPackage: package).

materializedClassOrTrait := self materializeSilently: wasSilent.

self deny: package identicalTo: materializedClassOrTrait package.
self assert: materializedClassOrTrait package identicalTo: undefinedPackage.
self deny: packageTag name equals: materializedClassOrTrait packageTag name.
self assert: materializedClassOrTrait packageTag identicalTo: undefinedPackage undefinedTag

0 comments on commit b2888b9

Please sign in to comment.