@@ -435,11 +435,11 @@ def testLoad(self) -> None:
435435 self .assertEqual ("uast:Identifier" , path ["@type" ])
436436 self .assertEqual ("os" , path ["Name" ])
437437
438- # This test is intended to test that filter iterators work correctly
439- # once the context they come from has been DECREFed, i.e. chunks of
440- # code as the following one work correctly: python would decref the
441- # itetators, contexts, etc once we are out of while the loop, nodes
442- # should still be alive
438+ # The following testOrphan{x} methods verifies that iterators and nodes work
439+ # correctly once the context they come from has been DECREFed. Loading an
440+ # (external) node and filtering it after the context / iterators have been
441+ # DECREFed are also checked. As an example, the following code should work
442+ # in Python:
443443 #
444444 # its = []
445445 # for file in files:
@@ -472,22 +472,6 @@ def testOrphanFilter(self) -> None:
472472 typ = obj ["@type" ]
473473 self .assertEqual ("uast:RuntimeImport" , typ )
474474
475- # This test is intended to test that iterators work correctly once
476- # the context they come from has been DECREFed, i.e. chunks of code
477- # as the following one work correctly: python would decref the
478- # itetators, contexts, etc once we are out of while the loop, nodes
479- # should still be alive
480- #
481- # its = []
482- # for file in files:
483- # it = client.parse(file).iterate(TreeOrder.POST_ORDER)
484- # its.append(it)
485- #
486- # it = pick a it from its
487- # node = next(it)
488- #
489- # Instead of testing with a while, we can just delete ctx before doing
490- # something with the iterator
491475 def testOrphanIterator (self ) -> None :
492476 ctx = self ._parse_fixture ()
493477 it = ctx .iterate (TreeOrder .PRE_ORDER )
@@ -505,23 +489,6 @@ def testOrphanIterator(self) -> None:
505489 obj = next (it )
506490 self .assertIsInstance (obj , Node )
507491
508- # This test is intended to test that loading an external node can be done
509- # after the context, iterators, etc it comes from have been DECREFed, i.e.
510- # that chunks of code as the following one work correctly: python would
511- # DECREF the itetators, contexts, etc once we are out of while the loop,
512- # nodes should still be alive
513- #
514- # ext_refs = []
515- # for file in files:
516- # it = client.parse(file).iterate(TreeOrder.PRE_ORDER)
517- # node = next(it)
518- # ext_refs.append(node.node_ext)
519- #
520- # node = pick a node from ext_refs
521- # node.load()
522- #
523- # Instead of testing with a while, we can just delete ctx, it, etc before
524- # doing something with the node
525492 def testLoadOrphanNode (self ) -> None :
526493 ctx = self ._parse_fixture ()
527494 it = ctx .iterate (TreeOrder .PRE_ORDER )
@@ -542,24 +509,6 @@ def testLoadOrphanNode(self) -> None:
542509 typ = obj ["@type" ]
543510 self .assertEqual ("uast:RuntimeImport" , typ )
544511
545- # This test is intended to test that we can call filter over a node when
546- # the context, iterators, etc it has come from have been DECREFed, i.e.
547- # chunk of codes as the following one work correctly: python would DECREF
548- # the itetators, contexts, etc once we are out of while the loop, and we
549- # could still call the filter method
550- #
551- # nodes = []
552- # for file in files:
553- # node = client.parse(file)
554- # .iterate(TreeOrder.PRE_ORDER)
555- # .root
556- # nodes.append(node)
557- #
558- # node = pick a node from nodes
559- # node.filter("blablablah")
560- #
561- # Instead of testing with a while, we can just delete ctx before
562- # doing the filter with the node
563512 def testFilterOrphanNode (self ) -> None :
564513 ctx = self ._parse_fixture ()
565514 root = ctx .root
0 commit comments