[Pkg] The Trunk: Tests-eem.376.mcz

commits at source.squeak.org commits at source.squeak.org
Thu Apr 6 23:06:45 UTC 2017

Eliot Miranda uploaded a new version of Tests to project The Trunk:

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

Name: Tests-eem.376
Author: eem
Time: 6 April 2017, 4:06:35.872493 pm
UUID: cf795993-c2d9-4443-b1ae-ac421928a96a
Ancestors: Tests-eem.375

Make the decompilation tests use the same bytecode set for recompilation as the original method.
Make the testMaxLiterals test use the preferred bytecode set's literal limit.

=============== Diff against Tests-eem.375 ===============

Item was changed:
  ----- Method: CompilerTest>>testMaxLiterals (in category 'limits') -----
  	"Document the maximum number of literals in a compiled method"
  	| maxLiterals stringThatCanBeCompiled stringWithOneTooManyLiterals |
  	"Why 6?  It's rather implementation dependent.  But the {... construct is compiled as
  		(Array braceStream: size)
  			nextPut: expr;
  	 where nextPut: is a special selector.  So one each for Array binding, #braceStream, #braceArray and the size,
  	 one for the selector and one for the methodClass makes 6."
+ 	maxLiterals := CompiledCode preferredBytecodeSetEncoderClass new maxNumLiterals - 6.
- 	maxLiterals := thisContext method encoderClass new maxNumLiterals - 6.
  	stringThatCanBeCompiled := '{ ', (String streamContents: [:strm |
  					1 to: maxLiterals do: [:e | strm nextPutAll: '''', e asString, '''', ' . ']]), '}'.
  	stringWithOneTooManyLiterals := '{ ', (String streamContents: [:strm |
  					1 to: maxLiterals + 1 do: [:e | strm nextPutAll: '''', e asString, '''', ' . ']]), '}'.
  	self assert: ((1 to: maxLiterals) collect: #printString) equals: (Compiler evaluate: stringThatCanBeCompiled).
  	"If the following test fails, it means that the limit has been raised or eliminated,
  	and this test should be updated to reflect the improvement."
  	self should: [Compiler evaluate: stringWithOneTooManyLiterals] raise: Error.

Item was changed:
  ----- Method: DecompilerTests>>checkDecompileMethod: (in category 'utilities') -----
  checkDecompileMethod: oldMethod
  	| cls selector oldMethodNode methodNode newMethod oldCodeString newCodeString |
  	cls := oldMethod methodClass.
  	selector := oldMethod selector.
  	oldMethodNode := (cls decompilerClass new withTempNames: oldMethod methodNode schematicTempNamesString)
  							decompile: selector
  							in: cls
  							method: oldMethod methodForDecompile.
  	[oldMethodNode properties includesKey: #warning] whileTrue:
  		[oldMethodNode properties removeKey: #warning].
  	oldCodeString := oldMethodNode decompileString.
+ 	methodNode := [| compiler |
+ 					  compiler := cls newCompiler.
+ 					  compiler parser encoderClass: oldMethod encoderClass.
+ 					  compiler
- 	methodNode := [cls newCompiler
  						compile: oldCodeString
  						in: cls
  						notifying: nil
  						ifFail: []]
  						on: SyntaxErrorNotification
  						do: [:ex|
  							ex errorMessage = 'Cannot store into' ifTrue:
  								[ex return: #badStore].
  							ex pass].
  	"Ignore cannot store into block arg errors; they're not our issue."
  	methodNode ~~ #badStore ifTrue:
  		[newMethod := methodNode generate.
  		 newCodeString := ((cls decompilerClass new withTempNames: methodNode schematicTempNamesString)
  								decompile: selector
  								in: cls
  								method: newMethod methodForDecompile) decompileString.
  		 "(StringHolder new textContents:
  			(TextDiffBuilder buildDisplayPatchFrom: oldCodeString to: newCodeString))
  				openLabel: 'Decompilation Differences for ', cls name,'>>',selector"
  		 "(StringHolder new textContents:
  			(TextDiffBuilder buildDisplayPatchFrom: oldMethod abstractSymbolic to: newMethod abstractSymbolic))
  				openLabel: 'Bytecode Differences for ', cls name,'>>',selector"
  		 self assert: (oldCodeString = newCodeString
  					or: [(Scanner new scanTokens: oldCodeString) = (Scanner new scanTokens: newCodeString)])
  			description: cls name asString, ' ', selector asString
  			resumable: true]!

More information about the Packages mailing list