Question

I want to send code from my workspace to a method. This means create the class and then the method without ever leaving the workspace or using the Browser. Is this possible and if yes how ?

Can I do the same for creating tests ?

Was it helpful?

Solution

Try this in a workspace:

|myClass myTest|

myClass := Object subclass: #MyClass
    instanceVariableNames: ''
    classVariableNames: ''
    poolDictionaries: ''
    category: 'GeneratedInAWorkspace'.

myClass compile: 'foo ^ 10'.

myTest := TestCase subclass: #MyClassTest
    instanceVariableNames: ''
    classVariableNames: ''
    poolDictionaries: ''
    category: 'GeneratedInAWorkspace'.

myTest compile: 'testFoo self assert: (Smalltalk at: #MyClass) new foo = 10'.
myTest run: #testFoo "prints: 1 run, 1 passes, 0 skipped, 0 expected failures, 0 failures, 0 errors, 0 unexpected passes"
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top