Esempio n. 1
0
    def test_should_find_used_method(self):
        handler = FunctionHandler()
        handler.add_declared("Str2int", Block("func Str2int(sint string) {"))

        code = Block('fmt.Println("test" + Str2int("5"))')
        handler.scan_used([code])

        self.assertTrue(
            "Str2int" in handler.get_params()
        )
Esempio n. 2
0
    def test_should_clear_old_assignment_when_clear(self):
        handler = FunctionHandler()
        handler.add_declared("Str2int", Block("func Str2int(sint string) {"))
        handler.assignment_manager.add_assigned("aaa", handler.handler_type)
        handler.assignment_manager.clear()

        code = Block('fmt.Println("test" + Str2int("5"))')
        handler.scan_used([code])

        self.assertTrue("Str2int" in handler.get_params())
        self.assertTrue("aaa" not in handler.get_params())
Esempio n. 3
0
    def test_success_add_block(self):
        handler = FunctionHandler()
        handler.get_declared().clear()
        handler.add(Block("func Str2int(sint string) {"))

        self.assertEqual(len(handler.get_declared()), 1)
Esempio n. 4
0
    def test_should_get_method_name(self):
        handler = FunctionHandler()
        handler.get_declared().clear()
        handler.add(Block("func Str2int(sint string) {"))

        self.assertTrue("Str2int" in handler.get_declared())