199451b44SJordan Rupprecht# encoding: utf-8 299451b44SJordan Rupprecht""" 399451b44SJordan RupprechtTest lldb date formatter subsystem. 499451b44SJordan Rupprecht""" 599451b44SJordan Rupprecht 699451b44SJordan Rupprecht 799451b44SJordan Rupprechtimport lldb 899451b44SJordan Rupprechtfrom lldbsuite.test.decorators import * 999451b44SJordan Rupprechtfrom lldbsuite.test.lldbtest import * 1099451b44SJordan Rupprechtfrom lldbsuite.test import lldbutil 1199451b44SJordan Rupprecht 1299451b44SJordan Rupprechtfrom ObjCDataFormatterTestCase import ObjCDataFormatterTestCase 1399451b44SJordan Rupprecht 1499451b44SJordan Rupprechtimport datetime 1599451b44SJordan Rupprecht 1699451b44SJordan Rupprechtclass ObjCDataFormatterNSDate(ObjCDataFormatterTestCase): 1799451b44SJordan Rupprecht 1899451b44SJordan Rupprecht def test_nsdate_with_run_command(self): 1999451b44SJordan Rupprecht """Test formatters for NSDate.""" 20*9d5e95d0SJonas Devlieghere self.appkit_tester_impl(self.nsdate_data_formatter_commands, False) 2199451b44SJordan Rupprecht 2299451b44SJordan Rupprecht def nsdate_data_formatter_commands(self): 2399451b44SJordan Rupprecht self.expect( 2499451b44SJordan Rupprecht 'frame variable date1 date2', 2599451b44SJordan Rupprecht patterns=[ 2699451b44SJordan Rupprecht '(1985-04-10|1985-04-11)', 2799451b44SJordan Rupprecht '(2011-01-01|2010-12-31)']) 2899451b44SJordan Rupprecht 2999451b44SJordan Rupprecht # this test might fail if we hit the breakpoint late on December 31st of some given year 3099451b44SJordan Rupprecht # and midnight comes between hitting the breakpoint and running this line of code 3199451b44SJordan Rupprecht # hopefully the output will be revealing enough in that case :-) 3299451b44SJordan Rupprecht now_year = '%s-' % str(datetime.datetime.now().year) 3399451b44SJordan Rupprecht 3499451b44SJordan Rupprecht self.expect('frame variable date3', substrs=[now_year]) 3599451b44SJordan Rupprecht self.expect('frame variable date4', substrs=['1970']) 3699451b44SJordan Rupprecht self.expect('frame variable date5', substrs=[now_year]) 3799451b44SJordan Rupprecht 3899451b44SJordan Rupprecht self.expect('frame variable date1_abs date2_abs', 3999451b44SJordan Rupprecht substrs=['1985-04', '2011-01']) 4099451b44SJordan Rupprecht 4199451b44SJordan Rupprecht self.expect('frame variable date3_abs', substrs=[now_year]) 4299451b44SJordan Rupprecht self.expect('frame variable date4_abs', substrs=['1970']) 4399451b44SJordan Rupprecht self.expect('frame variable date5_abs', substrs=[now_year]) 4499451b44SJordan Rupprecht 455814255eSRaphael Isemann # Check that LLDB always follow's NSDate's rounding behavior (which 465814255eSRaphael Isemann # is always rounding down). 475814255eSRaphael Isemann self.expect_expr("date_1970_minus_06", result_summary="1969-12-31 23:59:59 UTC") 485814255eSRaphael Isemann self.expect_expr("date_1970_minus_05", result_summary="1969-12-31 23:59:59 UTC") 495814255eSRaphael Isemann self.expect_expr("date_1970_minus_04", result_summary="1969-12-31 23:59:59 UTC") 505814255eSRaphael Isemann self.expect_expr("date_1970_plus_06", result_summary="1970-01-01 00:00:00 UTC") 515814255eSRaphael Isemann self.expect_expr("date_1970_plus_05", result_summary="1970-01-01 00:00:00 UTC") 525814255eSRaphael Isemann self.expect_expr("date_1970_plus_04", result_summary="1970-01-01 00:00:00 UTC") 535814255eSRaphael Isemann 5499451b44SJordan Rupprecht self.expect('frame variable cupertino home europe', 5599451b44SJordan Rupprecht substrs=['@"America/Los_Angeles"', 5699451b44SJordan Rupprecht '@"Europe/Rome"', 5799451b44SJordan Rupprecht '@"Europe/Paris"']) 5899451b44SJordan Rupprecht 5999451b44SJordan Rupprecht self.expect('frame variable cupertino_ns home_ns europe_ns', 6099451b44SJordan Rupprecht substrs=['@"America/Los_Angeles"', 6199451b44SJordan Rupprecht '@"Europe/Rome"', 6299451b44SJordan Rupprecht '@"Europe/Paris"']) 6399451b44SJordan Rupprecht 6499451b44SJordan Rupprecht self.expect( 6599451b44SJordan Rupprecht 'frame variable mut_bv', 6699451b44SJordan Rupprecht substrs=[ 6799451b44SJordan Rupprecht '(CFMutableBitVectorRef) mut_bv = ', 6899451b44SJordan Rupprecht '1110 0110 1011 0000 1101 1010 1000 1111 0011 0101 1101 0001 00']) 69001c78deSRaphael Isemann 70001c78deSRaphael Isemann self.expect_expr("distant_past", result_summary="0001-01-01 00:00:00 UTC") 71001c78deSRaphael Isemann self.expect_expr("distant_future", result_summary="4001-01-01 00:00:00 UTC") 72