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. > 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. 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') HTH. 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 leo-editor+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/leo-editor/b481ec58-96ff-4da2-97d0-ac8f6a8d5cce%40googlegroups.com.