-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Doctests for form_analysis/construct.py added
- Loading branch information
1 parent
0bb64f2
commit a1b2497
Showing
2 changed files
with
39 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters