[squeak-dev] The Trunk: CollectionsTests-topa.244.mcz

commits at source.squeak.org commits at source.squeak.org
Wed Jul 8 13:43:42 UTC 2015


Tobias Pape uploaded a new version of CollectionsTests to project The Trunk:
http://source.squeak.org/trunk/CollectionsTests-topa.244.mcz

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

Name: CollectionsTests-topa.244
Author: topa
Time: 8 July 2015, 3:43:29.531 pm
UUID: 71277a1a-3f59-462a-b2f7-14b612c17a84
Ancestors: CollectionsTests-mt.243

Do the primitive/non-primitive test in a way that works without directly modifying a compiled method header word.

=============== Diff against CollectionsTests-mt.243 ===============

Item was changed:
  ----- Method: StringTest>>testFindSubstringInStartingAtMatchTable (in category 'tests - finding') -----
  testFindSubstringInStartingAtMatchTable
  
  	| str tbl cm |
  	str := 'hello '.
  	tbl := String classPool at: #CaseSensitiveOrder.
  	self assert: (str findSubstring: ' ' in: str startingAt: 1 matchTable: tbl) = 6.
  	self assert: (str findSubstring: 'q' in: str startingAt: 1 matchTable: tbl) = 0.
  	self assert: (str findSubstring: 'q' in: str startingAt: -1 matchTable: tbl) = 0.
  	self assert: (str findSubstring: ' ' in: str startingAt: -1 matchTable: tbl) = 6.
  
+ 	
  	"The next test ensures that the fallback code works just as well"
+ 	cm := (ByteString >> #findSubstring:in:startingAt:matchTable:) in: [:origMethod |
+ 		"Adapted from CompiledMethod>>#newFrom: "
+ 		| inst header|
+ 		header := origMethod header bitAnd: 16r1FF bitInvert.
+ 		"CompiledMethod newFrom: CompiledMethod class >> #newFrom:"
+ 		inst := CompiledMethod 
+ 			newMethod: origMethod basicSize - origMethod initialPC + 1
+ 			header: header.
+ 		1 to: origMethod numLiterals do: [:index| inst literalAt: index put: (origMethod literalAt: index)].
+ 		origMethod initialPC to: origMethod size do: [:index | inst at: index put: (origMethod at: index)].
+ 		inst postCopy].
- 	cm := (CompiledMethod newFrom: (ByteString >> #findSubstring:in:startingAt:matchTable:)).
- 	cm objectAt: 1 put: (cm header bitAnd: 16r1FF bitInvert).
  	self assert: (cm valueWithReceiver: str arguments: {' '. str. 1. tbl}) = 6.
  	self assert: (cm valueWithReceiver: str arguments: {'q'. str. 1. tbl}) = 0.
  	self assert: (cm valueWithReceiver: str arguments: {'q'. str. -1. tbl}) = 0.
  	self assert: (cm valueWithReceiver: str arguments: {' '. str. -1. tbl}) = 6.
  !



More information about the Squeak-dev mailing list