The Trunk: Tests-nice.146.mcz

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

The Trunk: Tests-nice.146.mcz

commits-2
Nicolas Cellier uploaded a new version of Tests to project The Trunk:
http://source.squeak.org/trunk/Tests-nice.146.mcz

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

Name: Tests-nice.146
Author: nice
Time: 22 February 2012, 11:13:55.416 pm
UUID: 8a2421e6-d98a-4acd-a225-22a152f00759
Ancestors: Tests-nice.145

Add a variant CompilerSyntaxErrorNotifyingTest for testing case of so called non interactive Compiler notification.
See class comment for the funny definition of "non interactive".

=============== Diff against Tests-nice.145 ===============

Item was added:
+ CompilerNotifyingTest subclass: #CompilerSyntaxErrorNotifyingTest
+ instanceVariableNames: ''
+ classVariableNames: ''
+ poolDictionaries: ''
+ category: 'Tests-Compiler'!
+
+ !CompilerSyntaxErrorNotifyingTest commentStamp: 'nice 2/22/2012 22:37' prior: 0!
+ A CompilerSyntaxErrorNotifyingTest is a specialization for testing correct handling of non interactive compiler notification.
+ Non interactive is a very relative notion in Smalltalk...
+ Here it means that user interaction will not happen directly in the TextEditor holding source code, but rather thru a SyntaxError window that will pop-up.
+ This test intercept the Notification before the pop-up is raised.
+ !

Item was added:
+ ----- Method: CompilerSyntaxErrorNotifyingTest class>>shouldInheritSelectors (in category 'testing') -----
+ shouldInheritSelectors
+ "This class can recycle all of super tests, it just has to refine internal Compiler evaluation machinery"
+ ^true!

Item was added:
+ ----- Method: CompilerSyntaxErrorNotifyingTest>>enumerateAllSelections (in category 'private') -----
+ enumerateAllSelections
+ "This method intercepts the SyntaxErrorNotification and prevent the SyntaxError morph to open.
+ The notification errorCode hold the source of evaluated sub-selection with inserted error message.
+ This can be compared to expected error notification."
+ | syntaxErrorProbe |
+ syntaxErrorProbe := Object new.
+ 1 to: self numberOfSelections do: [:n |
+ | result |
+ result := [self evaluateSelectionNumber: n] on: SyntaxErrorNotification do: [:exc |
+ | expectedSourceWithError expectedNotificationLocation |
+ expectedNotificationLocation := (expectedErrorPositions at: n) - (morph editor startIndex - 1).
+ expectedSourceWithError := morph editor selection
+ copyReplaceFrom: expectedNotificationLocation
+ to: expectedNotificationLocation - 1
+ with: (expectedErrors at: n) allButFirst.
+ self assert: expectedSourceWithError = exc errorCode asString.
+ exc return: syntaxErrorProbe].
+ self assert: result == syntaxErrorProbe].!

Item was added:
+ ----- Method: CompilerSyntaxErrorNotifyingTest>>evaluateSelection (in category 'private') -----
+ evaluateSelection
+ ^(nil class evaluatorClass new)
+ evaluate: morph editor selection readStream
+ "Note subtle difference versus  (morph editor selectionAsStream).
+ The later does not answer the same contents and would raise a SyntaxErrorNotification with wrong sub-selection"
+ in: nil
+ to: nil
+ notifying: nil
+ ifFail: [^failure]
+ logged: false!