1# encoding: utf-8
2"""
3Test lldb data formatter subsystem.
4"""
5
6from __future__ import print_function
7
8import lldb
9from lldbsuite.test.decorators import *
10from lldbsuite.test.lldbtest import *
11from lldbsuite.test import lldbutil
12
13from ObjCDataFormatterTestCase import ObjCDataFormatterTestCase
14
15
16class ObjCDataFormatterNSNumber(ObjCDataFormatterTestCase):
17
18    @skipUnlessDarwin
19    def test_nsnumber_with_run_command(self):
20        """Test formatters for  NS container classes."""
21        self.appkit_tester_impl(self.nscontainers_data_formatter_commands, True)
22
23    @skipUnlessDarwin
24    def test_nsnumber_with_run_command_no_const(self):
25        """Test formatters for  NS container classes."""
26        self.appkit_tester_impl(self.nscontainers_data_formatter_commands, False)
27
28    def nscontainers_data_formatter_commands(self):
29        self.expect(
30            'frame variable newArray nsDictionary newDictionary nscfDictionary cfDictionaryRef newMutableDictionary cfarray_ref mutable_array_ref',
31            substrs=[
32                '(NSArray *) newArray = ', '@"50 elements"',
33                '(NSDictionary *) nsDictionary = ', ' 2 key/value pairs',
34                '(NSDictionary *) newDictionary = ', ' 12 key/value pairs',
35                '(CFDictionaryRef) cfDictionaryRef = ', ' 2 key/value pairs',
36                '(NSDictionary *) newMutableDictionary = ', ' 21 key/value pairs',
37                '(CFArrayRef) cfarray_ref = ', '@"3 elements"',
38                '(CFMutableArrayRef) mutable_array_ref = ', '@"11 elements"'
39            ])
40
41        numbers = [ ("num1", "(int)5"),
42                    ("num2", "(float)3.140000"),
43                    ("num3", "(double)3.14"),
44                    ("num4", "(int128_t)18446744073709551614"),
45                    ("num5", "(char)65"),
46                    ("num6", "(long)255"),
47                    ("num7", "(long)2000000"),
48                    ("num8_Y", "YES"),
49                    ("num8_N", "NO"),
50                    ("num9", "(short)-31616"),
51                    ("num_at1", "(int)12"),
52                    ("num_at2", "(int)-12"),
53                    ("num_at3", "(double)12.5"),
54                    ("num_at4", "(double)-12.5"),
55                    ("num_at5", "(char)97"),
56                    ("num_at6", "(float)42.123"),
57                    ("num_at7", "(double)43.123"),
58                    ("num_at8", "(long)12345"),
59                    ("num_at9", "17375808098308635870"),
60                    ("num_at9b", "-1070935975400915746"),
61                    ("num_at10", "YES"),
62                    ("num_at11", "NO"),
63        ]
64
65        for var, res in numbers:
66            self.expect('frame variable ' + var, substrs=[res])
67
68