When I awoke this morning I knew it was time to start work again on the code generator. Sitting in meditation would have no chance of being helpful.
But as I was making coffee I realized that a table of the expected results is the long-sought missing piece of the puzzle. I wasn't sure what form that table would take. Happily, a few minutes of experimentation showed that a slight modification of the MORE representation of an outline would likely do the trick.
As usual, lines starting with '-' denote nodes, with the indentation of those lines denoting outline level. All other lines denote the unindented body text. But headlines must also denote the type of expected node. For example: org:Declarations denotes a node whose headline is "Declarations" and whose vnode_info "kind" is "org". At present, the valid types are outer, org, class, def. I might add 'method'.
The line "# Expect:" separates the input lines from the MORE representation of the output nodes.
Here are the first three cases I created. They are just Leo nodes:
Node 1: (headline: docstring, vars, body follows):
"""A docstring"""
switch = 1
# Expect:
- outer:root
@others
- org:Declarations
"""A docstring"""
switch = 1
Node 2: docstring, vars, outer def
"""A docstring"""
switch = 1
def d1:
pass
# Expect:
- outer:root
- org:Declarations
"""A docstring"""
switch = 1
- def:function: d1
def d1:
pass
Node 3: docstring, vars, class
"""A docstring"""
switch = 1
class Class1:
def method1(self):
pass
# Expect:
- outer:root
- Declarations
"""A docstring"""
switch = 1
- class:class Class1
class Class1:
@others
- def: method1:
def method1(self):
pass
I think you get the idea. I expect to create dozens of such nodes.
Now, for the first time, there is an organizable table (a Leo outline) of cases. Clearly, this table corresponds to unit tests. Even better, a simple Leo script could create the corresponding unit tests!
I think this qualifies as a conceptual and operational breakthrough.
Edward