[squeak-dev] The Trunk: KernelTests-laza.87.mcz

commits at source.squeak.org commits at source.squeak.org
Sun Aug 30 23:24:50 UTC 2009


Alexander Lazarević uploaded a new version of KernelTests to project The Trunk:
http://source.squeak.org/trunk/KernelTests-laza.87.mcz

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

Name: KernelTests-laza.87
Author: laza
Time: 31 August 2009, 1:24:44 am
UUID: 7bbafac0-f203-f94c-95de-ce3b9a575c4a
Ancestors: KernelTests-laza.86

Remove obsolete BlockContext tests

=============== Diff against KernelTests-laza.86 ===============

Item was removed:
- ----- Method: BlockContextTest>>testSupplyAnswerUsingTraditionalMatchOfQuestion (in category 'tests') -----
- testSupplyAnswerUsingTraditionalMatchOfQuestion
- 
- 	self should: [true = ([self confirm: 'You like Smalltalk?'] 
- 		valueSupplyingAnswer: #('*Smalltalk#' true))]!

Item was removed:
- ----- Method: BlockContextTest>>testDecompile (in category 'tests - printing') -----
- testDecompile
- 	self assert: ([3 + 4] decompile printString = '{[3 + 4]}').!

Item was removed:
- ----- Method: BlockContextTest>>testSupplyAnswerUsingRegexMatchOfQuestion (in category 'tests') -----
- testSupplyAnswerUsingRegexMatchOfQuestion
- 
- 	(String includesSelector: #matchesRegex:) ifFalse: [^ self].
- 	
- 	self should: [true = ([self confirm: 'You like Smalltalk?'] 
- 		valueSupplyingAnswer: #('.*Smalltalk\?' true))]!

Item was removed:
- ----- Method: BlockContextTest>>testSetUp (in category 'tests') -----
- testSetUp
- 	"Note: In addition to verifying that the setUp worked the way it was expected to, testSetUp is used to illustrate the meaning of the simple access methods, methods that are not normally otherwise 'tested'"
- 	self deny: aBlockContext isClosure.
- 	self deny: aBlockContext isMethodContext.
- 	self deny: aBlockContext isPseudoContext.
- 	self deny: aBlockContext isDead.
- 	self assert: aBlockContext home = contextOfaBlockContext.
- 	self assert: aBlockContext blockHome = contextOfaBlockContext.
- 	self assert: aBlockContext receiver = self.
- 	self assert: (aBlockContext method isKindOf: CompiledMethod).
- 	self assert: aBlockContext methodNode selector = 'setUp'.
- 	self assert: (aBlockContext methodNodeFormattedAndDecorated: true) selector = 'setUp'.!

Item was removed:
- ----- Method: BlockContextTest>>testCopyStack (in category 'tests') -----
- testCopyStack
- 	self assert: aBlockContext copyStack printString = aBlockContext printString.!

Item was removed:
- ----- Method: BlockContextTest>>testValueWithPossibleArgument (in category 'tests - evaluating') -----
- testValueWithPossibleArgument
- 	| block  blockWithArg blockWith2Arg |
- 
- 	block := [1].
- 	blockWithArg  := [:arg | arg].
- 	blockWith2Arg := [:arg1 :arg2 | {arg1. arg2}].
- 
- 	self assert: (block valueWithPossibleArgument: 1) = 1.
- 	
- 	self assert: (blockWithArg valueWithPossibleArgument: 1) = 1.
- 	
- 	self assert: (blockWith2Arg valueWithPossibleArgument: 1) = {1 . nil}.
- 	
- 
- 	!

Item was removed:
- ----- Method: BlockContextTest>>testNew (in category 'tests') -----
- testNew
- 	self	should: [ContextPart new: 5] raise: Error.
- 	[ContextPart new: 5]
- 		ifError: [:error :receiver | error = 'Error: Contexts must only be created with newForMethod:'].
- 	[ContextPart new]
- 		ifError: [:error :receiver | error = 'Error: Contexts must only be created with newForMethod:'].	
- 	[ContextPart basicNew]
- 		ifError: [:error :receiver | error = 'Error: Contexts must only be created with newForMethod:'].				
- 
- !

Item was removed:
- ----- Method: BlockContextTest>>testOneArgument (in category 'tests') -----
- testOneArgument
- 	| c |
- 	c := OrderedCollection new.
- 	c add: 'hello'.
- 	[c
- 		do: [1 + 2]]
- 		ifError: [:err :rcvr | self deny: err = 'This block requires 0 arguments.'].
- 	[c
- 		do: [:arg1 :arg2 | 1 + 2]]
- 		ifError: [:err :rcvr | self deny: err = 'This block requires 2 arguments.'] !

Item was removed:
- ----- Method: BlockContextTest>>testSupplyAnswerThroughNestedBlocks (in category 'tests') -----
- testSupplyAnswerThroughNestedBlocks
- 
- 	self should: [true = ([[self confirm: 'You like Smalltalk?'] 
- 		valueSupplyingAnswer: #('Blub' false)] valueSupplyingAnswer: #('Smalltalk' true))]!

Item was removed:
- ----- Method: BlockContextTest>>testSupplyAnswerOfFillInTheBlank (in category 'testing') -----
- testSupplyAnswerOfFillInTheBlank
- 
- 	self should: ['blue' = ([UIManager default request: 'Your favorite color?'] 
- 		valueSupplyingAnswer: #('Your favorite color?' 'blue'))]!

Item was removed:
- ----- Method: BlockContextTest>>testTallyInstructions (in category 'tests') -----
- testTallyInstructions
- 	self assert: (ContextPart tallyInstructions: aBlockContext) size = 15.!

Item was removed:
- ----- Method: BlockContextTest>>testRunSimulated (in category 'tests') -----
- testRunSimulated
- 	self assert: (ContextPart runSimulated: aBlockContext) class = Rectangle.!

Item was removed:
- ----- Method: BlockContextTest>>testSupplyAnswerOfFillInTheBlankUsingDefaultAnswer (in category 'testing') -----
- testSupplyAnswerOfFillInTheBlankUsingDefaultAnswer
- 
- 	self should: ['red' = ([UIManager default  request: 'Your favorite color?' initialAnswer: 'red'] 
- 		valueSupplyingAnswer: #('Your favorite color?' #default))]!

Item was removed:
- ----- Method: BlockContextTest>>testSupplySameAnswerToAllQuestions (in category 'tests') -----
- testSupplySameAnswerToAllQuestions
- 
- 	self should: [true = ([self confirm: 'You like Smalltalk?'] valueSupplyingAnswer: true)].
- 	
- 	self should: [#(true true) = ([{self confirm: 'One'. self confirm: 'Two'}] valueSupplyingAnswer: true)].!

Item was removed:
- ----- Method: BlockContextTest>>testSuppressInformUsingStringMatchOptions (in category 'tests') -----
- testSuppressInformUsingStringMatchOptions
- 
- 	self should: [([nil inform: 'Should not see this message or this test failed!!'] valueSuppressingMessages: #('Should not see this message or this test failed!!')) isNil].
- 	
- 	self should: [([nil inform: 'Should not see this message or this test failed!!'] valueSuppressingMessages: #('not see this message')) isNil].
- 	
- 	self should: [([nil inform: 'Should not see this message or this test failed!!'] valueSuppressingMessages: #('*message*failed#')) isNil].
- !

Item was removed:
- TestCase subclass: #BlockContextTest
- 	instanceVariableNames: 'aBlockContext contextOfaBlockContext'
- 	classVariableNames: ''
- 	poolDictionaries: ''
- 	category: 'KernelTests-Methods'!
- 
- !BlockContextTest commentStamp: 'jrp 10/17/2004 12:22' prior: 0!
- I am an SUnit Test of BlockContext and its supertype ContextPart.  See also MethodContextTest.
- 
- My fixtures are:
- aBlockContext     - just some trivial block, i.e., [100 at 100 corner: 200 at 200].
- 
- NOTES ABOUT AUTOMATING USER INPUTS
- 
- When executing non-interactive programs you will inevitably run into programs (like SqueakMap or Monticello installation packages -- and other programs, to be fair) that require user input during their execution and these sort of problems shoot the whole non-interactiveness of your enclosing program.
- 
- BlockContext helper methods have been made available and tests of these helpers are provided in this class to demonstrate that it can intercept PopUpMenu and FillInTheBlankMorph requests for user interaction.  Of course, PopUpMenu and FillInTheBlankMorph were modified to first signal a ProvideAnswerNotification and if someone handles that (e.g. the enclosing block) then the user interaction will be circumvented and the provided answer of the enclosing block will be used.  The basic syntax looks like:
- 
- 	[self confirm: 'Install spyware?'] valueSupplyingAnswer: #('Install spyware?' false)
- 
- There a few variants on this theme making it easy to provide a literal list of answers for the block so that you can handle a bunch of questions in a block with appropriate answers.
- 
- Additionally, it is possible to suppress Object>>inform: modal dialog boxes as these get in the way of automating anything.  After applying this changeset you should be able to tryout the following code snippets to see the variants on this theme that are available.
- 
- Examples:
- 
- So you don't need any introduction here -- this one works like usual.
- [self inform: 'hello'. #done] value.
- 
- Now let's suppress all inform: messages.
- [self inform: 'hello'; inform: 'there'. #done] valueSuppressingAllMessages.
- 
- Here we can just suppress a single inform: message.
- [self inform: 'hi'; inform: 'there'. #done] valueSuppressingMessages: #('there')
- 
- Here you see how you can suppress a list of messages.
- [self inform: 'hi'; inform: 'there'; inform: 'bill'. #done] valueSuppressingMessages: #('hi' 'there')
- 
- Enough about inform:, let's look at confirm:. As you see this one works as expected.
- [self confirm: 'You like Squeak?'] value
- 
- Let's supply answers to one of the questions -- check out the return value.
- [{self confirm: 'You like Smalltalk?'. self confirm: 'You like Squeak?'}]
- 	valueSupplyingAnswer: #('You like Smalltalk?' true)
- 
- Here we supply answers using only substrings of the questions (for simplicity).
- [{self confirm: 'You like Squeak?'. self confirm: 'You like MVC?'}]
- 	valueSupplyingAnswers: #( ('Squeak' true) ('MVC' false) )
- 
- This time let's answer all questions exactly the same way.
- [{self confirm: 'You like Squeak?'. self confirm: 'You like Morphic?'}]
- 	valueSupplyingAnswer: true
- 	
- And, of course, we can answer FillInTheBlank questions in the same manner.
- [FillInTheBlank request: 'What day is it?']
- 	valueSupplyingAnswer: 'the first day of the rest of your life'
- 	
- We can also return whatever the initialAnswer of the FillInTheBlank was by using the #default answer.
- [FillInTheBlank request: 'What day is it?' initialAnswer: DateAndTime now dayOfWeekName]
- 	valueSupplyingAnswer: #default
- 	
- Finally, you can also do regex matches on any of the question text (or inform text) (should you have VB-Regex enhancements in your image).
- [FillInTheBlank request: 'What day is it?']
- 	valueSupplyingAnswers: { {'What day.*\?'. DateAndTime now dayOfWeekName} }!

Item was removed:
- ----- Method: BlockContextTest>>testSuppressInform (in category 'tests') -----
- testSuppressInform
- 
- 	self should: [[nil inform: 'Should not see this message or this test failed!!'] valueSuppressingAllMessages isNil]!

Item was removed:
- ----- Method: BlockContextTest>>setUp (in category 'setup') -----
- setUp
- 	super setUp.
- 	aBlockContext := [100 at 100 corner: 200 at 200].
- 	contextOfaBlockContext := thisContext.!

Item was removed:
- ----- Method: BlockContextTest>>testTallyMethods (in category 'tests') -----
- testTallyMethods
- 	self assert: (ContextPart tallyMethods: aBlockContext) size = 3.!

Item was removed:
- ----- Method: BlockContextTest>>testValueWithPossibleArgs (in category 'tests - evaluating') -----
- testValueWithPossibleArgs
- 	| block  blockWithArg blockWith2Arg |
- 
- 	block := [1].
- 	blockWithArg  := [:arg | arg].
- 	blockWith2Arg := [:arg1 :arg2 | {arg1. arg2}].
- 
- 	self assert: (block valueWithPossibleArgs: #()) = 1.
- 	self assert: (block valueWithPossibleArgs: #(1)) = 1.
- 	
- 	self assert: (blockWithArg valueWithPossibleArgs: #()) = nil.
- 	self assert: (blockWithArg valueWithPossibleArgs: #(1)) = 1.
- 	self assert: (blockWithArg valueWithPossibleArgs: #(1 2)) = 1.
- 
- 	self assert: (blockWith2Arg valueWithPossibleArgs: #()) = {nil .nil}.
- 	self assert: (blockWith2Arg valueWithPossibleArgs: #(1)) =  {1 . nil}.
- 	self assert: (blockWith2Arg valueWithPossibleArgs: #(1 2)) =  #(1 2).
- 	self assert: (blockWith2Arg valueWithPossibleArgs: #(1 2 3)) = #(1 2).
- 		
- 
- 	!

Item was removed:
- ----- Method: BlockContextTest>>testValueWithExitContinue (in category 'tests - evaluating') -----
- testValueWithExitContinue
- 
- 	| val last |	
- 	val := 0. 
- 
- 	1 to: 10 do: [ :i |
- 		[ :continue |
- 			i = 4 ifTrue: [continue value].
- 			val := val + 1.
- 			last := i
- 		] valueWithExit.
- 	].
- 
- 	self assert: val = 9.
- 	self assert: last = 10.	!

Item was removed:
- ----- Method: BlockContextTest>>testSupplySeveralAnswersToSeveralQuestions (in category 'tests') -----
- testSupplySeveralAnswersToSeveralQuestions
- 
- 	self should: [#(false true) = ([{self confirm: 'One'. self confirm: 'Two'}] 
- 		valueSupplyingAnswers: #( ('One' false) ('Two' true) ))].
- 	
- 	self should: [#(true false) = ([{self confirm: 'One'. self confirm: 'Two'}] 
- 		valueSupplyingAnswers: #( ('One' true) ('Two' false) ))]!

Item was removed:
- ----- Method: BlockContextTest>>testTrace (in category 'tests') -----
- testTrace
- 	self assert: (ContextPart trace: aBlockContext) class = Rectangle.!

Item was removed:
- ----- Method: BlockContextTest>>testValueWithExitBreak (in category 'tests - evaluating') -----
- testValueWithExitBreak
- 
- 	| val |	
- 
- 	[ :break |
- 	    1 to: 10 do: [ :i |
- 			val := i.
- 			i = 4 ifTrue: [break value].
- 		] 
- 	] valueWithExit.
- 
- 	self assert: val = 4.!

Item was removed:
- ----- Method: BlockContextTest>>testSupplyAnswerUsingOnlySubstringOfQuestion (in category 'tests') -----
- testSupplyAnswerUsingOnlySubstringOfQuestion
- 
- 	self should: [false = ([self confirm: 'You like Smalltalk?'] 
- 		valueSupplyingAnswer: #('like' false))]!

Item was removed:
- ----- Method: BlockContextTest>>testSupplySpecificAnswerToQuestion (in category 'tests') -----
- testSupplySpecificAnswerToQuestion
- 
- 	self should: [false = ([self confirm: 'You like Smalltalk?'] 
- 		valueSupplyingAnswer: #('You like Smalltalk?' false))]!

Item was removed:
- ----- Method: BlockContextTest>>testFindContextSuchThat (in category 'tests') -----
- testFindContextSuchThat
- 	self assert: (aBlockContext findContextSuchThat: [:each| true]) printString = aBlockContext printString.
- 	self assert: (aBlockContext hasContext: aBlockContext).  !

Item was removed:
- ----- Method: BlockContextTest>>testNoArguments (in category 'tests') -----
- testNoArguments
- 	[10
- 		timesRepeat: [:arg | 1 + 2]]
- 		ifError: [:err :rcvr | self deny: err = 'This block requires 1 arguments.'].
- 	[10
- 		timesRepeat: [:arg1 :arg2 | 1 + 2]]
- 		ifError: [:err :rcvr | self deny: err = 'This block requires 2 arguments.'] !

Item was removed:
- ----- Method: BlockContextTest>>testBlockIsBottomContext (in category 'tests') -----
- testBlockIsBottomContext
- 	self	should: [aBlockContext client ] raise: Error. "block's sender is nil, a block has no client"
- 	self assert: aBlockContext bottomContext = aBlockContext.
- 	self assert: aBlockContext secondFromBottom isNil.!

Item was removed:
- ----- Method: BlockContextTest>>testValueWithArguments (in category 'tests - evaluating') -----
- testValueWithArguments
- 	self
- 		should: [aBlockContext
- 				valueWithArguments: #(1 )]
- 		raise: Error.
- 	self
- 		shouldnt: [aBlockContext
- 				valueWithArguments: #()]
- 		raise: Error.
- 	[aBlockContext
- 		valueWithArguments: #(1 )]
- 		ifError: [:err :rcvr | self assert: err = 'Error: This block accepts 0 arguments, but was called with 1.'].
- 	[[:i | 3 + 4]
- 		valueWithArguments: #(1 2)]
- 		ifError: [:err :rcvr | self assert: err = 'Error: This block accepts 1 argument, but was called with 2.']!




More information about the Squeak-dev mailing list