def test_to_taxons(): labels = [ Label("if", [S(1, 1), S(1, 1), S(2, 5)]), Label("comparison_operator:Lt", [S(1, 1), S(3, 3), S(2, 2)]), ] assert t.to_taxons(labels) == [ ("flow/conditional", C({S(1, 1): 2, S(2, 5): 1})), ("test/inequality", C({S(2, 2): 1, S(3, 3): 1, S(1, 1): 1})), ]
def test_call(): programs = [ Program( path="algo1", labels=[ Label("if", [S(1, 1), S(1, 1), S(2, 5)]), Label("if_else", [S(1, 1), S(2, 5)]), Label("comparison_operator:Lt", [S(1, 1), S(3, 3), S(2, 2)]), ], taxa=[], addition={}, deletion={}, ), Program( path="algo2", labels=[ Label("member_call_method:difference_update", [S(1, 1), S(1, 1), S(2, 5)]), Label("literal:Set", [S(1, 1), S(2, 5)]), ], taxa=[], addition={}, deletion={}, ), ] result = {program.path: t.to_taxa(program.labels) for program in programs} print(result) assert result == { "algo1": [ ("condition/inequality", c({ S(2, 2): 1, S(3, 3): 1, S(1, 1): 1 })), ("flow/conditional", c({S(1, 1): 1})), ("flow/conditional/else", c({ S(1, 1): 1, S(2, 5): 1 })), ], "algo2": [ ("call/subroutine/builtin/casting/set", c({ S(1, 1): 1, S(2, 5): 1 })), ("type/non_sequence/set", c({ S(1, 1): 3, S(2, 5): 2 })), ], }