Domanda

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 ?

È stato utile?

Soluzione

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"
Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top