[squeak-dev] The Inbox: Tools-ct.910.mcz

commits at source.squeak.org commits at source.squeak.org
Fri Oct 25 11:00:19 UTC 2019


A new version of Tools was added to project The Inbox:
http://source.squeak.org/inbox/Tools-ct.910.mcz

==================== Summary ====================

Name: Tools-ct.910
Author: ct
Time: 25 October 2019, 1:00:13.846396 pm
UUID: b10a85ef-63c1-524d-8943-93a23acac838
Ancestors: Tools-mt.909

Removes Blocks check from MethodFinder

Due to several implementators of #value(:)?(value:)* and #cull(:)?(cull:)* we have got nowadays, this is an unnecessary restriction. Furthermore, it impedes maintenance. For more information, read http://forum.world.st/MethodFinder-Blocks-td5105421.html

=============== Diff against Tools-mt.909 ===============

Item was changed:
  Object subclass: #MethodFinder
  	instanceVariableNames: 'data answers selector argMap thisData mapStage mapList expressions cachedClass cachedArgNum cachedSelectorLists'
+ 	classVariableNames: 'AddAndRemove Approved Dangerous'
- 	classVariableNames: 'AddAndRemove Approved Blocks Dangerous'
  	poolDictionaries: ''
  	category: 'Tools-MethodFinder'!
  
  !MethodFinder commentStamp: '<historical>' prior: 0!
  Find a method in the system from a set of examples.  Done by brute force, trying every possible selector.  Errors are skipped over using ( [3 + 'xyz'] ifError: [^ false] ).
  Submit an array of the form ((data1 data2) answer  (data1 data2) answer).
  
  	MethodFinder methodFor: #( (4 3) 7  (0 5) 5  (5 5) 10).
  
  answer:  'data1 + data2'
  
  More generally, use the brace notation to construct live examples.
  
  The program tries data1 as the receiver, and
  	tries all other permutations of the data for the receiver and args, and
  	tries leaving out one argument, and
  	uses all selectors data understands, and
  	uses all selectors in all od data's superclasses.
  
  Floating point values must be precise to 0.01 percent, or (X * 0.0001).
  
  If you get an error, you have probably discovered a selector that needs to be removed from the Approved list.  See MethodFinder.initialize.  Please email the Squeak Team.
  
  Only considers 0, 1, 2, and 3 argument messages.  The argument data may have 1 to 5 entries, but only a max of 4 used at a time.  For now, we only test messages that use given number of args or one fewer.  For example, this data (100 true 0.6) would test the receiver plus two args, and the receiver plus one arg, but not any other patterns.
  
  Three sets of selectors:  Approved, AddAndRemove, and Blocks selectors.  When testing a selector in AddAndRemove, deepCopy the receiver.  We do not handle selectors that modify an argument (printOn: etc.).  Blocks is a set of (selector argNumber) where that argument must be a block.
  
  For perform, the selector is tested.  It must be in the Approved list.
  
  do: is not on the Approved list.  It does not produce a result that can be tested.  Type 'do' into the upper pane of the Selector Finder to find messages list that.
  
  [Later, allow the user to supply a block that tests the answer, not just the literal answer.]
  	MethodFinder methodFor: { { true. [3]. [4]}. 3}. 
  Later allow this to work without the blocks around 3 and 4.!

Item was changed:
  ----- Method: MethodFinder class>>cleanUp: (in category 'class initialization') -----
  cleanUp: aggressive
  
  	Approved := nil.
+ 	AddAndRemove := nil.!
- 	AddAndRemove := nil.
- 	Blocks := nil.!

Item was changed:
  ----- Method: MethodFinder>>initialize (in category 'initialize') -----
(excessive size, no diff calculated)

Item was changed:
  ----- Method: MethodFinder>>initialize2 (in category 'initialize') -----
(excessive size, no diff calculated)

Item was changed:
  ----- Method: MethodFinder>>testPerfect: (in category 'search') -----
  testPerfect: aSelector
  	"Try this selector!! Return true if it answers every example perfectly.  Take the args in the order they are.  Do not permute them.  Survive errors.  later cache arg lists."
  
  | sz argList val rec activeSel perform |
  	"Transcript cr; show: aSelector.		debug"
  perform := aSelector beginsWith: 'perform:'.
  sz := argMap size.
  1 to: thisData size do: [:ii | "each example set of args"
  	argList := (thisData at: ii) copyFrom: 2 to: sz.
  	perform
  		ifFalse: [activeSel := aSelector]
  		ifTrue: [activeSel := argList first.	"what will be performed"
  			((Approved includes: activeSel) or: [AddAndRemove includes: activeSel])
  				ifFalse: [^ false].	"not approved"
  			aSelector == #perform:withArguments: 
  				ifTrue: [activeSel numArgs = (argList at: 2) basicSize "avoid error" 
  							ifFalse: [^ false]]
  				ifFalse: [activeSel numArgs = (aSelector numArgs - 1) 
  							ifFalse: [^ false]]].
- 	1 to: sz do: [:num | 
- 		(Blocks includes: (Array with: activeSel with: num)) ifTrue: [
- 			(argList at: num) isBlock ifFalse: [^ false]]].
  	rec := (AddAndRemove includes: activeSel) 
  			ifTrue: [(thisData at: ii) first isSymbol ifTrue: [^ false].
  						"vulnerable to modification"
  				(thisData at: ii) first copyTwoLevel] 	"protect from damage"
  			ifFalse: [(thisData at: ii) first].
  	val := [[rec perform: aSelector withArguments: argList]
  				on: Deprecation do: [ :ex | ex resume ]] 
  					ifError: [:aString :aReceiver | 
  							"self test3."
  							"self test2: (thisData at: ii)."
  							^ false].
  	"self test3."
  	"self test2: (thisData at: ii)."
  	((answers at: ii) closeTo: val) ifFalse: [^ false].
  	].
  ^ true!



More information about the Squeak-dev mailing list