1# encoding: utf-8
2"""
3Test lldb date 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
14import datetime
15
16class ObjCDataFormatterNSDate(ObjCDataFormatterTestCase):
17
18    @skipUnlessDarwin
19    def test_nsdate_with_run_command(self):
20        """Test formatters for  NSDate."""
21        self.appkit_tester_impl(self.nsdate_data_formatter_commands)
22
23    def nsdate_data_formatter_commands(self):
24        self.expect(
25            'frame variable date1 date2',
26            patterns=[
27                '(1985-04-10|1985-04-11)',
28                '(2011-01-01|2010-12-31)'])
29
30        # this test might fail if we hit the breakpoint late on December 31st of some given year
31        # and midnight comes between hitting the breakpoint and running this line of code
32        # hopefully the output will be revealing enough in that case :-)
33        now_year = '%s-' % str(datetime.datetime.now().year)
34
35        self.expect('frame variable date3', substrs=[now_year])
36        self.expect('frame variable date4', substrs=['1970'])
37        self.expect('frame variable date5', substrs=[now_year])
38
39        self.expect('frame variable date1_abs date2_abs',
40                    substrs=['1985-04', '2011-01'])
41
42        self.expect('frame variable date3_abs', substrs=[now_year])
43        self.expect('frame variable date4_abs', substrs=['1970'])
44        self.expect('frame variable date5_abs', substrs=[now_year])
45
46        self.expect('frame variable cupertino home europe',
47                    substrs=['@"America/Los_Angeles"',
48                             '@"Europe/Rome"',
49                             '@"Europe/Paris"'])
50
51        self.expect('frame variable cupertino_ns home_ns europe_ns',
52                    substrs=['@"America/Los_Angeles"',
53                             '@"Europe/Rome"',
54                             '@"Europe/Paris"'])
55
56        self.expect(
57            'frame variable mut_bv',
58            substrs=[
59                '(CFMutableBitVectorRef) mut_bv = ',
60                '1110 0110 1011 0000 1101 1010 1000 1111 0011 0101 1101 0001 00'])
61