Run DCE after a LoopFlatten test to reduce spurious output [nfc]
[llvm-project.git] / lldb / test / API / lang / cpp / char1632_t / TestChar1632T.py
blobe1cbe0509ae047609bf589e185cff3932cb238c9
1 # coding=utf8
2 """
3 Test that the C++11 support for char16_t and char32_t works correctly.
4 """
7 import lldb
8 from lldbsuite.test.decorators import *
9 from lldbsuite.test.lldbtest import *
10 from lldbsuite.test import lldbutil
13 class Char1632TestCase(TestBase):
14 def setUp(self):
15 # Call super's setUp().
16 TestBase.setUp(self)
17 # Find the line number to break for main.cpp.
18 self.source = "main.cpp"
19 self.lines = [
20 line_number(self.source, "// breakpoint1"),
21 line_number(self.source, "// breakpoint2"),
24 @expectedFailureAll(
25 compiler="icc",
26 bugnumber="ICC (13.1) does not emit the DW_TAG_base_type for char16_t and char32_t.",
28 def test(self):
29 """Test that the C++11 support for char16_t and char32_t works correctly."""
30 self.build()
31 exe = self.getBuildArtifact("a.out")
33 # Create a target by the debugger.
34 target = self.dbg.CreateTarget(exe)
35 self.assertTrue(target, VALID_TARGET)
37 # Set breakpoints
38 for line in self.lines:
39 lldbutil.run_break_set_by_file_and_line(self, "main.cpp", line)
41 # Now launch the process, and do not stop at entry point and stop at
42 # breakpoint1
43 process = target.LaunchSimple(None, None, self.get_process_working_directory())
45 if not process:
46 self.fail("SBTarget.Launch() failed")
48 if self.TraceOn():
49 self.runCmd("frame variable")
51 # Check that we correctly report the const types
52 self.expect(
53 "frame variable cs16 cs32",
54 substrs=[
55 "(const char16_t *) cs16 = ",
56 'u"hello world ྒྙྐ"',
57 "(const char32_t *) cs32 = ",
58 'U"hello world ྒྙྐ"',
62 # Check that we correctly report the non-const types
63 self.expect(
64 "frame variable s16 s32",
65 substrs=[
66 "(char16_t *) s16 = ",
67 'u"ﺸﺵۻ"',
68 "(char32_t *) s32 = ",
69 'U"ЕЙРГЖО"',
73 # Check that we correctly report the array types
74 self.expect(
75 "frame variable as16 as32",
76 patterns=[
77 "\(char16_t\[[0-9]+\]\) as16 = ",
78 "\(char32_t\[[0-9]+\]\) as32 = ",
80 substrs=['u"ﺸﺵۻ"', 'U"ЕЙРГЖО"'],
83 self.runCmd("next") # step to after the string is nullified
85 # check that we don't crash on NULL
86 self.expect("frame variable s32", substrs=["(char32_t *) s32 = 0x00000000"])
88 # continue and hit breakpoint2
89 self.runCmd("continue")
91 # check that the new strings show
92 self.expect(
93 "frame variable s16 s32",
94 substrs=[
95 "(char16_t *) s16 = 0x",
96 '"色ハ匂ヘト散リヌルヲ"',
97 "(char32_t *) s32 = ",
98 '"෴"',
102 # check the same as above for arrays
103 self.expect(
104 "frame variable as16 as32",
105 patterns=[
106 "\(char16_t\[[0-9]+\]\) as16 = ",
107 "\(char32_t\[[0-9]+\]\) as32 = ",
109 substrs=['"色ハ匂ヘト散リヌルヲ"', '"෴"'],
112 # check that zero values are properly handles
113 self.expect_expr("cs16_zero", result_summary="U+0000 u'\\0'")
114 self.expect_expr("cs32_zero", result_summary="U+0x00000000 U'\\0'")
116 # Check that we can run expressions that return charN_t
117 self.expect_expr("u'a'", result_type="char16_t", result_summary="U+0061 u'a'")
118 self.expect_expr(
119 "U'a'", result_type="char32_t", result_summary="U+0x00000061 U'a'"