[clang] Add tracking source deduction guide for the explicitly-written
[llvm-project.git] / lldb / test / API / lang / cpp / default-template-args / TestDefaultTemplateArgs.py
blob9dad2480e1350d460aa07b6b60242bae12edad6e
1 """
2 Test default template arguments.
3 """
5 import lldb
6 from lldbsuite.test.decorators import *
7 from lldbsuite.test.lldbtest import *
8 from lldbsuite.test import lldbutil
11 class TestDefaultTemplateArgs(TestBase):
12 @no_debug_info_test
13 def test(self):
14 self.build()
15 lldbutil.run_to_source_breakpoint(
16 self, "// break here", lldb.SBFileSpec("main.cpp")
19 # Declare a template with a template argument that has a default argument.
20 self.expect(
21 "expr --top-level -- template<typename T = int> struct $X { int v; };"
24 # The type we display to the user should omit the argument with the default
25 # value.
26 result = self.expect_expr("$X<> x; x", result_type="$X<>")
27 # The internal name should also always show all arguments (even if they
28 # have their default value).
29 self.assertEqual(result.GetTypeName(), "$X<int>")
31 # Test the template but this time specify a non-default value for the
32 # template argument.
33 # Both internal type name and the one we display to the user should
34 # show the non-default value in the type name.
35 result = self.expect_expr("$X<long> x; x", result_type="$X<long>")
36 self.assertEqual(result.GetTypeName(), "$X<long>")
38 # Test that the formatters are using the internal type names that
39 # always include all template arguments.
40 self.expect("type summary add '$X<int>' --summary-string 'summary1'")
41 self.expect_expr("$X<> x; x", result_summary="summary1")
42 self.expect("type summary add '$X<long>' --summary-string 'summary2'")
43 self.expect_expr("$X<long> x; x", result_summary="summary2")