If you develop code using Leo, please read at least the executive summary. 
It might change your life. It certainly has changed mine.

*Executive Summary*

1. A *preamble *in each @test node makes it easy to run unit tests locally, 
without reloading Leo!

2. A local test;; abbreviation could create new @test nodes, with *customized 
*preambles.

3. A new reload-abbreviation command (#340 
<https://github.com/leo-editor/leo-editor/issues/340>) will allow you to 
change the preamble without reloading Leo.

This is huge: for the first time *ever*, test-driven development will be 
easy and natural in Leo.
 
*Details*

I developed these ideas while working on the new importers.  Experience 
shows that I almost *never* get regex's right at first.  Creating a unit 
test for each regex saved time almost instantly, *despite some initial 
setup costs*.

The setup cost is that local unit tests must start with a *custom preamble*:

g.cls()
if c.isChanged(): c.save()
import imp
import leo.plugins.importers.otl as otl
imp.reload(otl)
x = otl.Otl_Importer(c.importCommands, atAuto=False)

With this preamble, I can run the tests after changing the otl plugin 
without reloading leoPlugins.leo.  This was the beginning of the 
avalanche...

Here is typical code that follows the preamble:

pattern = x.otl_pattern
print(pattern)
table = (
    'body line',
    '\tline 1',
    '  \tlevel 2',
)
for line in table:
    m = pattern.match(line)
    print('%20r ==> (%r)(%r)' % (
        line, m and m.group(1), m and m.group(2)))

Using this @test node, I can modify the regex and see the results *instantly. 
*This saved about 20+ seconds per coding iteration, a *gigantic* win. 

I*t is impossible to overstate the importance of this new work flow!*

It has changed my life. It also got me thinking about a further 
improvement, namely creating custom preambles for new tests more easily.

Issue #340 <https://github.com/leo-editor/leo-editor/issues/340> proposes a 
new reload-abbreviations command. This will allow me to change the preamble 
without reloading Leo.  The ultimate work flow will be:

- Modify the *local* test;; abbreviation so that it supports the code under 
test.
- Run reload-abbreviations.
- Create new tests with test;;

This will make true test-driven development feasible, for the first time 
ever in Leo.

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.

Reply via email to