Ejemplo n.º 1
0
 def test_bound_function_nested_repr(self):
   f = self._make_pytd_function(params=())
   callself1 = self._vm.program.NewVariable(
       [abstract.BaseValue("test1", self._vm)], [], self._vm.root_node)
   bound1 = abstract.BoundFunction(callself1, f)
   callself2 = self._vm.program.NewVariable(
       [abstract.BaseValue("test2", self._vm)], [], self._vm.root_node)
   bound2 = abstract.BoundFunction(callself2, bound1)
   # `bound2` is BoundFunction(test2, BoundFunction(test1, f))
   six.assertCountEqual(self, bound2.repr_names(), ["test2.f"])
Ejemplo n.º 2
0
 def test_bound_function_repr_replace_parent(self):
   f = self._make_pytd_function(params=(), name="foo.f")
   callself = self._vm.program.NewVariable(
       [abstract.AtomicAbstractValue("test", self._vm)],
       [], self._vm.root_cfg_node)
   bound = abstract.BoundFunction(callself, f)
   six.assertCountEqual(self, bound.repr_names(), ["test.f"])
Ejemplo n.º 3
0
 def test_bound_function_callself_repr(self):
   f = self._make_pytd_function(params=())
   callself = self._vm.program.NewVariable(
       [abstract.BaseValue("test", self._vm)], [], self._vm.root_node)
   bound = abstract.BoundFunction(callself, f)
   callself_repr = lambda v: v.name + "foo"
   six.assertCountEqual(self, bound.repr_names(callself_repr), ["testfoo.f"])
Ejemplo n.º 4
0
 def test_bound_function_repr(self):
   f = self._make_pytd_function(params=())
   callself = self._vm.program.NewVariable(
       [abstract.AtomicAbstractValue(name, self._vm)
        for name in ("test1", "test2")], [], self._vm.root_cfg_node)
   bound = abstract.BoundFunction(callself, f)
   six.assertCountEqual(self, bound.repr_names(), ["test1.f", "test2.f"])
   six.assertRegex(self, repr(bound), r"test(1|2)\.f")
Ejemplo n.º 5
0
 def test_bound_function_repr_no_callself(self):
   f = self._make_pytd_function(params=())
   callself = self._vm.program.NewVariable()
   bound = abstract.BoundFunction(callself, f)
   six.assertCountEqual(self, bound.repr_names(), ["<class>.f"])