199451b44SJordan Rupprechtimport lldb 299451b44SJordan Rupprechtfrom lldbsuite.test.decorators import * 399451b44SJordan Rupprechtfrom lldbsuite.test.lldbtest import * 499451b44SJordan Rupprechtfrom lldbsuite.test import lldbutil 599451b44SJordan Rupprecht 699451b44SJordan Rupprecht 7*2238dcc3SJonas Devlieghereclass TestCase(TestBase): 899451b44SJordan Rupprecht def common_setup(self): 999451b44SJordan Rupprecht self.build() 10*2238dcc3SJonas Devlieghere lldbutil.run_to_source_breakpoint( 11*2238dcc3SJonas Devlieghere self, "// break here", lldb.SBFileSpec("main.cpp") 12*2238dcc3SJonas Devlieghere ) 1399451b44SJordan Rupprecht 1499451b44SJordan Rupprecht def test_call_on_base(self): 1599451b44SJordan Rupprecht self.common_setup() 1699451b44SJordan Rupprecht self.expect_expr("base_with_dtor.foo()", result_type="int", result_value="1") 1799451b44SJordan Rupprecht self.expect_expr("base_without_dtor.foo()", result_type="int", result_value="2") 1899451b44SJordan Rupprecht 1999451b44SJordan Rupprecht def test_call_on_derived(self): 2099451b44SJordan Rupprecht self.common_setup() 2199451b44SJordan Rupprecht self.expect_expr("derived_with_dtor.foo()", result_type="int", result_value="3") 22*2238dcc3SJonas Devlieghere self.expect_expr( 23*2238dcc3SJonas Devlieghere "derived_without_dtor.foo()", result_type="int", result_value="4" 24*2238dcc3SJonas Devlieghere ) 25*2238dcc3SJonas Devlieghere self.expect_expr( 26*2238dcc3SJonas Devlieghere "derived_with_base_dtor.foo()", result_type="int", result_value="5" 27*2238dcc3SJonas Devlieghere ) 28*2238dcc3SJonas Devlieghere self.expect_expr( 29*2238dcc3SJonas Devlieghere "derived_with_dtor_but_no_base_dtor.foo()", 30*2238dcc3SJonas Devlieghere result_type="int", 31*2238dcc3SJonas Devlieghere result_value="6", 32*2238dcc3SJonas Devlieghere ) 3399451b44SJordan Rupprecht 3499451b44SJordan Rupprecht def test_call_on_derived_as_base(self): 3599451b44SJordan Rupprecht self.common_setup() 36*2238dcc3SJonas Devlieghere self.expect_expr( 37*2238dcc3SJonas Devlieghere "derived_with_dtor_as_base.foo()", result_type="int", result_value="3" 38*2238dcc3SJonas Devlieghere ) 39*2238dcc3SJonas Devlieghere self.expect_expr( 40*2238dcc3SJonas Devlieghere "derived_without_as_base.foo()", result_type="int", result_value="4" 41*2238dcc3SJonas Devlieghere ) 42*2238dcc3SJonas Devlieghere self.expect_expr( 43*2238dcc3SJonas Devlieghere "derived_with_base_dtor_as_base.foo()", result_type="int", result_value="5" 44*2238dcc3SJonas Devlieghere ) 45*2238dcc3SJonas Devlieghere self.expect_expr( 46*2238dcc3SJonas Devlieghere "derived_with_dtor_but_no_base_dtor_as_base.foo()", 47*2238dcc3SJonas Devlieghere result_type="int", 48*2238dcc3SJonas Devlieghere result_value="6", 49*2238dcc3SJonas Devlieghere ) 5099451b44SJordan Rupprecht 5199451b44SJordan Rupprecht def test_call_overloaded(self): 5299451b44SJordan Rupprecht self.common_setup() 53*2238dcc3SJonas Devlieghere self.expect( 54*2238dcc3SJonas Devlieghere "expr derived_with_overload.foo()", 55*2238dcc3SJonas Devlieghere error=True, 56*2238dcc3SJonas Devlieghere substrs=["too few arguments to function call, expected 1, have 0"], 57*2238dcc3SJonas Devlieghere ) 58*2238dcc3SJonas Devlieghere self.expect_expr( 59*2238dcc3SJonas Devlieghere "derived_with_overload.foo(1)", result_type="int", result_value="7" 60*2238dcc3SJonas Devlieghere ) 61*2238dcc3SJonas Devlieghere self.expect_expr( 62*2238dcc3SJonas Devlieghere "derived_with_overload_and_using.foo(1)", 63*2238dcc3SJonas Devlieghere result_type="int", 64*2238dcc3SJonas Devlieghere result_value="8", 65*2238dcc3SJonas Devlieghere ) 6699451b44SJordan Rupprecht # FIXME: It seems the using declaration doesn't import the overload from the base class. 67*2238dcc3SJonas Devlieghere self.expect( 68*2238dcc3SJonas Devlieghere "expr derived_with_overload_and_using.foo()", 69*2238dcc3SJonas Devlieghere error=True, 70*2238dcc3SJonas Devlieghere substrs=["too few arguments to function call, expected 1, have 0"], 71*2238dcc3SJonas Devlieghere ) 72