1"""Test that the Objective-C syntax for dictionary/array literals and indexing works"""
2
3
4import lldb
5from lldbsuite.test.decorators import *
6from lldbsuite.test.lldbtest import *
7from lldbsuite.test import lldbutil
8
9from ObjCNewSyntaxTest import ObjCNewSyntaxTest
10
11
12class ObjCNewSyntaxTestCaseLiteral(ObjCNewSyntaxTest):
13
14    @skipUnlessDarwin
15    @skipIf(macos_version=["<", "10.12"])
16    @expectedFailureAll(archs=["i[3-6]86"])
17    def test_char_literal(self):
18        self.runToBreakpoint()
19
20        self.expect("expr --object-description -- @'a'",
21                    VARIABLES_DISPLAYED_CORRECTLY, substrs=[str(ord('a'))])
22
23    @skipUnlessDarwin
24    @skipIf(macos_version=["<", "10.12"])
25    @expectedFailureAll(archs=["i[3-6]86"])
26    def test_integer_literals(self):
27        self.runToBreakpoint()
28
29        self.expect(
30            "expr --object-description -- @1",
31            VARIABLES_DISPLAYED_CORRECTLY,
32            substrs=["1"])
33
34        self.expect(
35            "expr --object-description -- @1l",
36            VARIABLES_DISPLAYED_CORRECTLY,
37            substrs=["1"])
38
39        self.expect(
40            "expr --object-description -- @1ul",
41            VARIABLES_DISPLAYED_CORRECTLY,
42            substrs=["1"])
43
44        self.expect(
45            "expr --object-description -- @1ll",
46            VARIABLES_DISPLAYED_CORRECTLY,
47            substrs=["1"])
48
49        self.expect(
50            "expr --object-description -- @1ull",
51            VARIABLES_DISPLAYED_CORRECTLY,
52            substrs=["1"])
53
54    @skipUnlessDarwin
55    @skipIf(macos_version=["<", "10.12"])
56    @expectedFailureAll(archs=["i[3-6]86"])
57    def test_float_literal(self):
58        self.runToBreakpoint()
59
60        self.expect("expr -- @123.45", VARIABLES_DISPLAYED_CORRECTLY,
61                    substrs=["NSNumber", "123.45"])
62
63    @skipUnlessDarwin
64    @skipIf(macos_version=["<", "10.12"])
65    @expectedFailureAll(archs=["i[3-6]86"])
66    def test_expressions_in_literals(self):
67        self.runToBreakpoint()
68
69        self.expect(
70            "expr --object-description -- @( 1 + 3 )",
71            VARIABLES_DISPLAYED_CORRECTLY,
72            substrs=["4"])
73        self.expect(
74            "expr -- @((char*)\"Hello world\" + 6)",
75            VARIABLES_DISPLAYED_CORRECTLY,
76            substrs=[
77                "NSString",
78                "world"])
79