[View]  [Edit]  [Lock]  [References]  [Attachments]  [History]  [Home]  [Changes]  [Search]  [Help] 

doNot-test[s8] Local variable bindings


This test verify that local variables are bound before instance variables.

Code

Object
	subclass: #TestLocalBinding
	instanceVariableNames: ' value '
	category: #Tests ! !
TestLocalBinding buildAccessors! !

! TestLocalBinding class methodsFor: #testing !
test

	^self new
		test1;
		test2;
		yourself! !

! TestLocalBinding methodsFor: #testing !
test1

	| value |
	value notNil ifTrue: [
		^self error: 'Failed test1. value must be nil on entry'
	].
	value := 10.
	self value = 10 ifTrue: [
		^self error: 'Failed test1. value instance must not be affected'
	].
	value = 10 ifFalse: [
		^self error: 'Failed test1. value must be 10'
	].! !

! TestLocalBinding methodsFor: #testing !
test2

	self value isNil ifTrue: [
		^self error: 'Failed test2. value must NOT be nil'
	].
	true ifTrue: [ |value|
		value := 10.
		self value = 10 ifTrue: [
			^self error: 'Failed test1. value instance must not be affected'
		].
		value = 10 ifFalse: [
			^self error: 'Failed test1. value must be 10'
		]
	].! !


Verification

TestLocalBinding test