brintos

brintos / llvm-project-archived public Read only

0
0
Text · 1.7 KiB · 9dad248 Raw
44 lines · python
1"""2Test default template arguments.3"""4 5import lldb6from lldbsuite.test.decorators import *7from lldbsuite.test.lldbtest import *8from lldbsuite.test import lldbutil9 10 11class TestDefaultTemplateArgs(TestBase):12    @no_debug_info_test13    def test(self):14        self.build()15        lldbutil.run_to_source_breakpoint(16            self, "// break here", lldb.SBFileSpec("main.cpp")17        )18 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; };"22        )23 24        # The type we display to the user should omit the argument with the default25        # value.26        result = self.expect_expr("$X<> x; x", result_type="$X<>")27        # The internal name should also always show all arguments (even if they28        # have their default value).29        self.assertEqual(result.GetTypeName(), "$X<int>")30 31        # Test the template but this time specify a non-default value for the32        # template argument.33        # Both internal type name and the one we display to the user should34        # 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>")37 38        # Test that the formatters are using the internal type names that39        # 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")44