64 lines · python
1"""2Test that we can call C++ template fucntions.3"""4import lldb5from lldbsuite.test.decorators import *6from lldbsuite.test.lldbtest import *7from lldbsuite.test import lldbutil8 9 10class TemplateFunctionsTestCase(TestBase):11 def do_test_template_function(self, add_cast):12 self.build()13 lldbutil.run_to_source_breakpoint(14 self, "// break here", lldb.SBFileSpec("main.cpp", False)15 )16 17 if add_cast:18 self.expect_expr("(int) foo(42)", result_type="int", result_value="42")19 else:20 self.expect(21 "expr b1 <=> b2",22 error=True,23 substrs=[24 "warning:",25 "'<=>' is a single token in C++20; add a space to avoid a change in behavior",26 ],27 )28 29 self.expect_expr("foo(42)", result_type="int", result_value="42")30 31 # overload with template case32 self.expect_expr("h(10)", result_type="int", result_value="10")33 34 # ADL lookup case35 self.expect_expr("f(A::C{})", result_type="int", result_value="4")36 37 # ADL lookup but no overload38 self.expect_expr("g(A::C{})", result_type="int", result_value="4")39 40 # variadic function cases41 self.expect_expr("var(1)", result_type="int", result_value="10")42 self.expect_expr("var(1, 2)", result_type="int", result_value="10")43 44 # Overloaded templated operator case45 self.expect_expr("b1 > b2", result_type="bool", result_value="true")46 self.expect_expr("b1 >> b2", result_type="bool", result_value="true")47 self.expect_expr("b1 << b2", result_type="bool", result_value="true")48 self.expect_expr("b1 == b2", result_type="bool", result_value="true")49 50 # Overloaded operator case51 self.expect_expr("d1 > d2", result_type="bool", result_value="true")52 self.expect_expr("d1 >> d2", result_type="bool", result_value="true")53 self.expect_expr("d1 << d2", result_type="bool", result_value="true")54 self.expect_expr("d1 == d2", result_type="bool", result_value="true")55 56 @skipIfWindows57 def test_template_function_with_cast(self):58 self.do_test_template_function(True)59 60 @skipIfWindows61 @expectedFailureAll(debug_info=["dwarf", "gmodules", "dwo"])62 def test_template_function_without_cast(self):63 self.do_test_template_function(False)64