'From Cuis 2.6 of 10 August 2010 [latest update: #540] on 27 August 2010 at 11:27:28 am'!

!ClosureCompilerTest methodsFor: 'tests' stamp: 'jmv 8/27/2010 10:10'!
testBlockDoitDecompilation
	"Tests that decompile of a doit block with remote vars executes correcly"
	"Tests that decompilation of a Block, when 'method' of block is equivalent to that compiled by a DoIt, preserves the temp names "
	
	| blockSourceStream methodNode compiledMethod block decompiledBlock method |
	blockSourceStream := '|x y| [:a :b | x _ a. y _ b. x + y]' readStream.
	methodNode := nil class evaluatorClass new 
						from: blockSourceStream class: nil class context: nil notifying: nil;
						translate: blockSourceStream noPattern: true ifFail: [nil].
	method _ methodNode generate: #(0 0 0 0).
	compiledMethod _ method copyWithTempsFromMethodNode: methodNode.
	block := nil withArgs: #() executeMethod: compiledMethod.
	
	self shouldnt: [decompiledBlock := block decompile] raise: Error.
	self assert: 
'{[ :a :b |
	x _ a.
	y _ b.
	x + y. ]}' equals: decompiledBlock printString
! !

