Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[RBRefactoring]RBBrowserEnvironment implementorsOf: doesn't handle well when anding envs #4874

Open
VincentBlondeau opened this issue Oct 10, 2019 · 3 comments

Comments

@VincentBlondeau
Copy link
Contributor

@VincentBlondeau VincentBlondeau commented Oct 10, 2019

env := RBBrowserEnvironment new.
col1 := ((env implementorsOf: #do:)
& (env implementorsOf: #size)
forClasses: Object allSubclasses) classes.

env := RBBrowserEnvironment new.
do :=((env implementorsOf: #do:) forClasses: Object allSubclasses) classes.
size := ((env implementorsOf: #size) forClasses: Object allSubclasses) classes.
col2 := size intersection: do.

self assert: col1 = col2.

@VincentBlondeau

This comment has been minimized.

Copy link
Contributor Author

@VincentBlondeau VincentBlondeau commented Oct 10, 2019

More explanation:
This code get in the Smalltalk environment the subclasses of Object and filter the ones that implement #do: and #size.

If you do the same request separately, i.e. 1 filter for the #do: and another one for the #size and then take the intersection, you expect to have the same results. Which is not the case.

@VincentBlondeau

This comment has been minimized.

Copy link
Contributor Author

@VincentBlondeau VincentBlondeau commented Oct 10, 2019

Ref #3010

@VincentBlondeau

This comment has been minimized.

Copy link
Contributor Author

@VincentBlondeau VincentBlondeau commented Oct 10, 2019

Test to be integrated to check the fix:

RBBrowserEnvironmentTest >> #testAndEnvironmentWithImplementors
	| originalEnvironment objectPrintStringEnvironment andEnvironment |
	originalEnvironment := universalEnvironment implementorsOf: #printOn:.
	objectPrintStringEnvironment := universalEnvironment forClass: Object
				selectors: #(#fullPrintString).
	andEnvironment := objectPrintStringEnvironment & originalEnvironment.
	self universalTestFor: andEnvironment.
	self assert: andEnvironment numberSelectors = 1.
	self assert: andEnvironment classNames asArray = #(#Object).
	self assert: (andEnvironment protocolsFor: Object) size = 1.
	self assert: (objectPrintStringEnvironment & objectPrintStringEnvironment) packages = objectPrintStringEnvironment packages.
	andEnvironment := originalEnvironment 
				& (universalEnvironment referencesTo: #printString).
	self assert: andEnvironment numberSelectors 
				= (originalEnvironment referencesTo: #printString) numberSelectors.
	self assert: andEnvironment classNames asSortedCollection 
				= (originalEnvironment referencesTo: #printString) classNames 
						asSortedCollection

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
1 participant
You can’t perform that action at this time.