1# encoding: utf-8
2"""
3Test lldb data formatter subsystem.
4"""
5
6
7import lldb
8from lldbsuite.test.decorators import *
9from lldbsuite.test.lldbtest import *
10from lldbsuite.test import lldbutil
11
12from ObjCDataFormatterTestCase import ObjCDataFormatterTestCase
13
14
15class ObjCDataFormatterNSError(ObjCDataFormatterTestCase):
16
17    def test_nserror_with_run_command(self):
18        """Test formatters for NSError."""
19        self.appkit_tester_impl(self.nserror_data_formatter_commands, True)
20
21    @skipUnlessDarwin
22    def test_nserror_with_run_command_no_const(self):
23        """Test formatters for NSError."""
24        self.appkit_tester_impl(self.nserror_data_formatter_commands, False)
25
26    def nserror_data_formatter_commands(self):
27        self.expect(
28            'frame variable nserror', substrs=['domain: @"Foobar" - code: 12'])
29
30        self.expect(
31            'frame variable nserrorptr',
32            substrs=['domain: @"Foobar" - code: 12'])
33
34        self.expect(
35            'frame variable nserror->_userInfo', substrs=['2 key/value pairs'])
36
37        self.expect(
38            'frame variable nserror->_userInfo --ptr-depth 1 -d run-target',
39            substrs=['@"a"', "1", '@"b"', "2"])
40