[Pharo-users] What is the status of SUnit in Pharo?
Hi guys - what’s the status of SUnit in Pharo, are fixes supposed to be applied upstream to some master SUnit project or do we propose fixes/improvements locally? For example the method: should: aBlock raise: anExceptionalEvent whoseDescriptionIncludes: substring description: aString ^self assert: (self executeShould: aBlock inScopeOf: anExceptionalEvent withDescriptionContaining: substring) description: aString The #executeShould:…. Is implemented in the subclass TestCase and not TestAsserter (is that a local pharo thing to do with Traits?) - the code critic shows an error - and it seems the Calypso doesn’t have an option to call these things out anymore? But equally poking more - while I REALLY LOVE the fact that assert:equals: give me a useful diff browser on a failure - I REALLY HATE that there are many other examples where I don’t get the same useful UI - e.g. #should:raise:whoseDescriptionIncludes:description: is awful Given our community mostly invented unit testing - why is it so poorly fleshed out to do the right thing? Along the same lines - when trying to write descriptive tests, why can’t I easily assert the existence of a substring in something and get an equally useful message? I recall mentioning this a few years ago and don’t remember why I got shot down - but honestly, this stops us writing helpful tests and keeps us in the stone ages? Can we modernise this state of affairs so things are like the amazing diff browser (which I’m assuming is some sort of hack? Is the debug window pulling apart a TestResult to do this - am interested in how it does this, as I couldn’t figure it out?) Tim
[Pharo-users] [Spec] Min script browser
Hi, I am experimenting Spec to write a DrGeo user scripts browser (in DrGeo scripts are classes). The layout and widgetery is so far ok (see screenshot). Nevertheless I have issue to keep synchronized the compiled methods in the Spec list, a recompiled method when the user edit its code and save it, then the source code in the code widget. Indeed when the user press save to keep the code it is compiled fine but the Spec list still hold what I guess is another instance of the compiled method. My attempt to manage this situation makes my code to look like shit. How will you manage this to keep up to date and synchronized the script information in the different Spec widgets? Thanks Hilaire -- Dr. Geo http://drgeo.eu 'From Pharo8.0.0 of 20 February 2020 [Build information: Pharo-8.0.0+build.1129.sha.278304fdce17a1b7cc3ede1006275ffbc7baf20a (64 Bit)] on 30 March 2020 at 4:07:31.728507 pm'! SpPresenter subclass: #DrGScriptBrowser2 instanceVariableNames: 'scripts methods source saveBtn' classVariableNames: '' package: 'DrGeoII-UI-Window'! !DrGScriptBrowser2 commentStamp: 'HilaireFernandes 3/28/2020 12:59' prior: 0! A DrGeo script browser written with Spec2.! !DrGScriptBrowser2 methodsFor: 'action-button-actions' stamp: 'HilaireFernandes 3/30/2020 15:54'! saveCode | compiledMethod selectedMethodItem | selectedMethodItem := methods selectedPage activePresenter selection. compiledMethod := selectedMethodItem selectedItem. methods selectedPage activePresenter inspect. (compiledMethod notNil and: [ source pendingText ~= source text ]) ifTrue: [ compiledMethod methodClass compile: source pendingText. methods selectedPage activePresenter selection selectedItem compiledMethod selector == #scriptName ifTrue: [ "Update the script name in Scripts list" " scripts selection inspect" scripts updateList ]. self inform: ('Method "{1}" saved' translated format: {compiledMethod selector}) ]! ! !DrGScriptBrowser2 methodsFor: 'initialization' stamp: 'HilaireFernandes 3/30/2020 09:57'! newButtons saveBtn := self newButton label: 'Save' translated; icon: (self iconNamed: #smallSave); yourself! ! !DrGScriptBrowser2 methodsFor: 'initialization' stamp: 'HilaireFernandes 3/30/2020 15:38'! instanceMethodsTab ^ SpNotebookPage title: 'Methods' translated provider: [ self newList display: [:aMethod | aMethod selector ]; whenSelectionChangedDo: [ :selection | | method | method := selection selectedItem. source text: method sourceCode; behavior: method methodClass]; yourself]! ! !DrGScriptBrowser2 methodsFor: 'initialization' stamp: 'HilaireFernandes 3/28/2020 15:31'! newScriptCode source := self instantiate: SpLabelledContainer. source label: 'Source' translated; content: SpCodePresenter! ! !DrGScriptBrowser2 methodsFor: 'initialization' stamp: 'HilaireFernandes 3/30/2020 15:39'! connectPresenters scripts whenSelectedItemChanged: [ :class | source clearContent; behavior: nil. class ifNotNil: [ (methods pageAt: 1) whenRetrievedDo: [ :list | list items: class methods]. (methods pageAt: 2) whenRetrievedDo: [ :list | list items: class class methods]. methods resetAllPageContents.]]. saveBtn action: [ self saveCode ]. source acceptBlock: [ :text | text inspect ]! ! !DrGScriptBrowser2 methodsFor: 'initialization' stamp: 'HilaireFernandes 3/29/2020 13:15'! classMethodsTab ^ SpNotebookPage title: 'Script data' translated provider: [ self newList display: [:aMethod | aMethod selector ]; whenSelectionChangedDo: [ :selection | source text: selection selectedItem sourceCode. source behavior: selection selectedItem methodClass]; yourself]! ! !DrGScriptBrowser2 methodsFor: 'initialization' stamp: 'HilaireFernandes 3/28/2020 15:31'! newScriptsList scripts := self instantiate: SpLabelledList. scripts label: 'Scripts' translated; items: DrGeoUserScript allSubclasses; display: [ :aClass | aClass scriptName ]! ! !DrGScriptBrowser2 methodsFor: 'initialization' stamp: 'HilaireFernandes 3/28/2020 15:10'! newMethodsList methods := self newNotebook. methods addPage: self instanceMethodsTab; addPage: self classMethodsTab! ! !DrGScriptBrowser2 methodsFor: