On Thu, Jan 9, 2020 at 5:10 AM Edward K. Ream <edream...@gmail.com> wrote:

> On Wed, Jan 8, 2020 at 5:55 AM Brian Theado <brian.the...@gmail.com>
> wrote:
>
> > I often read unit tests in source code projects in the hope of finding
> simple, concrete usage examples. These examples not only serve to test the
> code, but also also documentation on how to use it.
>
> > But from that I don't see what the outputs are. It doesn't show me what
> a TOG object can do and what it is for.
>
> For an overview, see the Theory of Operation in LeoDocs.leo.
>

Thanks, I did read those docs and didn't find what I was looking for. Maybe
after I understand better, I can provide some concrete, constructive
feedback on those docs.


> > Is there some code you can add which make it easy to see how things
> work?
>
> Good question.  The dozen or so tests in the TestFstringify class assert
> that a small example produces the desired result.
>

Yes, those are nice. Concrete inputs and concrete outputs in the test.
Exactly what I was hoping for in a least few of the TOG tests.


> To see the two-way links produced by the TOG class, just call
> dump_tree(tree) at the end of *any* test. For example, in
> TestTOG.test_ClassDef2, replace:
>
> self.make_data(contents)
>
> by:
>
> contents, tokens, tree = self.make_data(contents)
> dump_tree(tree)
>
> The output will be:
>
> Tree...
>
> parent           lines      node                               tokens
> ======           =====      ====                               ======
>                  6..7       0.Module:                          newline.33(
> 6:0)
>   0.Module                    1.Expr:
>   1.Expr         1              2.Str: s='ds 1'                string.1("""ds
> 1""")
>   0.Module       1..2         3.ClassDef:                      newline.2(1
> :11) name.3(class) name.5(TestClass) op.6=:
>   3.ClassDef                    4.Expr:
>   4.Expr         2..3             5.Str: s='ds 2'              newline.7(2
> :17) string.9("""ds 2""")
>   3.ClassDef     3..4           6.FunctionDef:                 newline.10(
> 3:15) name.12(def) name.14(long_name) op.23=:
>   6.FunctionDef  4                7.arguments:                 op.20==
>   7.arguments    4                  8.arg:                     name.16(a)
>   7.arguments    4                  9.arg:                     name.19(b)
>   7.arguments    4                  10.Num: n=2                number.21(2
> )
>   6.FunctionDef                   11.Expr:
>  11.Expr         4..5               12.Str: s='ds 3'           newline.24(
> 4:27) string.26("""ds 3""")
>   6.FunctionDef                   13.Expr:
>  13.Expr                            14.Call:
>  14.Call         5..6                 15.Name: id='print'      newline.27(
> 5:19) name.29(print)
>  14.Call         6                    16.Str: s='done'         string.31(
> 'done')
>
>
This looks useful, thanks. I'll take a look.

-- 
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 leo-editor+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/leo-editor/CAO5X8Cwu%3DvcOx_Oz3YSd%3DeFvqU30um5jTxFN4VCmHBKiRTr%3DKA%40mail.gmail.com.

Reply via email to