>
> First of all, Leo's add-comments and delete-comments commands probably do
> what you want.
They don't behave the way I would like. I had already been through their
code (it helped me in writing my own commenting functions). There's nothing
objectively wrong with Leo's commenting system - it's just not the way I
want it.
But there may be an easier way. See the FAQ entry: How can I use dev nodes
> to develop and test Leo's own code?
>
> The "dev script" *is *the unit test during development.
>
I honestly couldn't follow that FAQ entry - perhaps images would help. The
first step is:
Create a *dev node* as a test harness.
>
And then followed by:
Using a plain outline node would be less convenient because you won’t be
> able to execute it so easily.
>
What is a dev node? Is that defined somewhere? My best guess from the docs
is that what you mean is @test, @command or @button (i.e. any of these
qualify as a dev node).
In any case, I think the FAQ entry is quite a bit ahead of where I am, and
will help me when I become more proficient. My issue right now is much
simpler. Let's forget comments and use a simple example. Suppose I have a
node whose contents are:
from operator import mul
def factorial(number):
if number < 0:
raise ValueError
if number == 0:
return 1
return reduce(mul, range(number+1), 1)
It's a simple function. Imagine this is a helper function that will be used
by some other function that interacts with Leo. It is not saved to any file
(beyond the .leo file, of course). I would like to create a unit test for
this. What is the best way?
On Thu, Oct 11, 2018 at 4:12 AM Edward K. Ream <[email protected]> wrote:
> On Sat, Oct 6, 2018 at 8:10 AM <[email protected]> wrote:
>
> I recently tried writing my own logic for commenting and uncommenting
>> lines.
>>
>
> First of all, Leo's add-comments and delete-comments commands probably do
> what you want. There are unit tests in unitTest.leo. See the node Active
> Unit Tests-->@file activeUnitTests.txt-->Organized by
> file-->leoCommands-->add/delete comments
>
> These unit tests use c.addComments() to do the work. So by extension, one
> way would be to define your new commands using @g.command and then your
> @test node would use use the new command.
>
> But there may be an easier way. See the FAQ entry: How can I use dev
> nodes to develop and test Leo's own code?
>
> The "dev script" *is *the unit test during development.
>
> Later, you could add proper @test nodes somewhere. They would access your
> new code, perhaps using c.k.simulateCommand('new-command')
>
> HTH. Feel free to ask more questions.
>
> Edward
>
> --
> You received this message because you are subscribed to the Google Groups
> "leo-editor" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to [email protected].
> To post to this group, send email to [email protected].
> Visit this group at https://groups.google.com/group/leo-editor.
> For more options, visit https://groups.google.com/d/optout.
>
--
You received this message because you are subscribed to the Google Groups
"leo-editor" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/leo-editor.
For more options, visit https://groups.google.com/d/optout.