1# coding=utf8
2"""
3Test that the expression parser returns proper Unicode strings.
4"""
5
6
7
8import lldb
9from lldbsuite.test.decorators import *
10from lldbsuite.test.lldbtest import *
11from lldbsuite.test import lldbutil
12
13# this test case fails because of rdar://12991846
14# the expression parser does not deal correctly with Unicode expressions
15# e.g.
16#(lldb) expr L"Hello"
17#(const wchar_t [6]) $0 = {
18#  [0] = \0\0\0\0
19#  [1] = \0\0\0\0
20#  [2] = \0\0\0\0
21#  [3] = \0\0\0\0
22#  [4] = H\0\0\0
23#  [5] = e\0\0\0
24#}
25
26
27class UnicodeLiteralsTestCase(TestBase):
28
29    def test_expr1(self):
30        """Test that the expression parser returns proper Unicode strings."""
31        self.rdar12991846(expr=1)
32
33    def test_expr2(self):
34        """Test that the expression parser returns proper Unicode strings."""
35        self.rdar12991846(expr=2)
36
37    def test_expr3(self):
38        """Test that the expression parser returns proper Unicode strings."""
39        self.rdar12991846(expr=3)
40
41    def rdar12991846(self, expr=None):
42        """Test that the expression parser returns proper Unicode strings."""
43        if self.getArchitecture() in ['i386']:
44            self.skipTest(
45                "Skipping because this test is known to crash on i386")
46
47        self.build()
48        lldbutil.run_to_source_breakpoint(self, "// Set break point at this line", lldb.SBFileSpec("main.cpp"))
49
50        if expr == 1:
51            self.expect('expression L"hello"', substrs=['hello'])
52
53        if expr == 2:
54            self.expect('expression u"hello"', substrs=['hello'])
55
56        if expr == 3:
57            self.expect('expression U"hello"', substrs=['hello'])
58