diff --git a/src/Hermes-Tests-Classes/HETeSimpleClassWithBlocks.class.st b/src/Hermes-Tests-Classes/HETeSimpleClassWithBlocks.class.st index 3f0e6c2..1761a3d 100644 --- a/src/Hermes-Tests-Classes/HETeSimpleClassWithBlocks.class.st +++ b/src/Hermes-Tests-Classes/HETeSimpleClassWithBlocks.class.st @@ -17,6 +17,14 @@ Class { { #category : #'test methods' } HETeSimpleClassWithBlocks >> aMethodWithABlock [ + ^ [ + self. + 42 ] +] + +{ #category : #'test methods' } +HETeSimpleClassWithBlocks >> aMethodWithAContantBlock [ + ^ [ 42 ] ] @@ -25,9 +33,12 @@ HETeSimpleClassWithBlocks >> aMethodWithNestedBlocks [ passedTheEnsure := false. - ^ [ [ 42 ] on: Error - do: [ ^ self halt ] ] - ensure: [ passedTheEnsure := true ]. + ^ [ + [ + self. + 42 ] + on: Error + do: [ ^ self halt ] ] ensure: [ passedTheEnsure := true ] ] { #category : #'test methods' } diff --git a/src/Hermes-Tests/HEInstallerClassesWithBlocksTest.class.st b/src/Hermes-Tests/HEInstallerClassesWithBlocksTest.class.st index a3fb2d9..1097509 100644 --- a/src/Hermes-Tests/HEInstallerClassesWithBlocksTest.class.st +++ b/src/Hermes-Tests/HEInstallerClassesWithBlocksTest.class.st @@ -32,6 +32,24 @@ HEInstallerClassesWithBlocksTest >> testAMethodWithASingleBlockHasCorrectBinding ] +{ #category : #tests } +HEInstallerClassesWithBlocksTest >> testAMethodWithASingleConstantBlockHasCorrectBindingToTheHomeMethod [ + + | methodWithSimpleBlock block | + methodWithSimpleBlock := aClass >> #aMethodWithAContantBlock. + block := methodWithSimpleBlock literals at: 1. + + self flag: #pharo10. "This can be simplified once Pharo 11 will be the minimal version for Hermes. + In Pharo < 11, this will be a compiled block while in other cases il will be a constant block." + SystemVersion current major >= 11 + ifTrue: [ + self assert: block isBlock. + self assert: (block compiledBlock allLiterals at: 2) equals: methodWithSimpleBlock ] + ifFalse: [ + self assert: block isCompiledBlock. + self assert: (block allLiterals at: 2) equals: methodWithSimpleBlock ] +] + { #category : #tests } HEInstallerClassesWithBlocksTest >> testAMethodWithNestedBlocksHasCorrectBindingOfTheHomeBlockInTheNested [