Skip to content

Commit

Permalink
Doctests for form_analysis/construct.py added
Browse files Browse the repository at this point in the history
  • Loading branch information
vanschelven committed Sep 14, 2017
1 parent 0bb64f2 commit a1b2497
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 0 deletions.
38 changes: 38 additions & 0 deletions doctests/form_analysis_construct.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
This isn't (by any means) a full test of construct.py
Rather, it's a construct that cuts through a number of Types (Form, FormList, SymbolList, Symbol)
to help me wrap my head around those in the context of a dynamically typed language.

>>> from hashstore import NoutHashStore
>>> from memoization import Stores, Memoization
>>>
>>> from dsn.s_expr.legato import NoteNout, NoteCapo, NoteNoutHash
>>>
>>> from dsn.s_expr.clef import BecomeNode, TextBecome
>>> from dsn.s_expr.utils import nouts_for_notes_da_capo
>>> from dsn.s_expr.test_utils import iinsert, rreplace
>>> from dsn.historiography.legato import HistoriographyNoteNoutHash, HistoriographyNoteNout, HistoriographyNoteCapo
>>> from dsn.form_analysis.into import construct_form_note
>>> from dsn.form_analysis.construct import construct_form
>>>
>>>
>>> m = Memoization()
>>> p = NoutHashStore(NoteNoutHash, NoteNout, NoteCapo)
>>> historiography_note_nout_store = NoutHashStore(HistoriographyNoteNoutHash, HistoriographyNoteNout, HistoriographyNoteCapo)
>>> stores = Stores(p, historiography_note_nout_store)
>>>
>>> for nh in nouts_for_notes_da_capo([
... BecomeNode(),
... iinsert(p, 0, [TextBecome("lambda")]),
... iinsert(p, 1, [BecomeNode(),
... iinsert(p, 0, [TextBecome("a")])
... ]),
... iinsert(p, 2, [TextBecome("a")]),
... ]):
... h = p.add(nh.nout)
...
>>>
>>> form_note, form_note_nout_hash = construct_form_note(m, stores, h)
>>> form = construct_form(m, stores, form_note_nout_hash)
>>>
>>> form.parameters.the_list[0].symbol
'a'
1 change: 1 addition & 0 deletions tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ def load_tests(loader, tests, ignore):
tests.addTests(doctest.DocFileSuite("doctests/h_utils.txt"))
tests.addTests(doctest.DocFileSuite("doctests/unambiguous_weaving.txt"))
tests.addTests(doctest.DocFileSuite("doctests/form_analysis_into.txt"))
tests.addTests(doctest.DocFileSuite("doctests/form_analysis_construct.txt"))

return tests

Expand Down

0 comments on commit a1b2497

Please sign in to comment.