Changeset 9758 for trunk/PS-IPP-Metadata-Config/t/05_time.t
- Timestamp:
- Oct 26, 2006, 4:15:45 PM (20 years ago)
- File:
-
- 1 edited
-
trunk/PS-IPP-Metadata-Config/t/05_time.t (modified) (9 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/PS-IPP-Metadata-Config/t/05_time.t
r8940 r9758 3 3 # Copyright (C) 2005 Joshua Hoblitt 4 4 # 5 # $Id: 05_time.t,v 1. 3 2006-09-25 21:49:42jhoblitt Exp $5 # $Id: 05_time.t,v 1.4 2006-10-27 02:15:45 jhoblitt Exp $ 6 6 7 7 use strict; … … 12 12 #$::RD_TRACE = 1; 13 13 14 use Test::More tests => 1 0;14 use Test::More tests => 17; 15 15 use PS::IPP::Metadata::Config; 16 16 … … 19 19 { 20 20 my $example =<<END; 21 mytime MULTI 22 mytime UTC NULL 23 mytime UT1 NULL 24 mytime TAI NULL 25 mytime TT NULL 26 END 27 28 my $config = $config_parser->parse( $example ); 29 ok( defined( $config ), "NULL times parsed"); 30 31 my $tree = [ 32 { 33 name => 'mytime', 34 class => 'time', 35 type => 'UTC', 36 value => undef, 37 }, 38 { 39 name => 'mytime', 40 class => 'time', 41 type => 'UT1', 42 value => undef, 43 }, 44 { 45 name => 'mytime', 46 class => 'time', 47 type => 'TAI', 48 value => undef, 49 }, 50 { 51 name => 'mytime', 52 class => 'time', 53 type => 'TT', 54 value => undef, 55 }, 56 ]; 57 58 is_deeply( $config, $tree, "NULL times structure" ); 59 } 60 61 { 62 my $example =<<END; 63 mytime MULTI 64 mytime UTC NULL # comment 65 mytime UT1 NULL # comment 66 mytime TAI NULL # comment 67 mytime TT NULL # comment 68 END 69 70 my $config = $config_parser->parse( $example ); 71 ok( defined( $config ), "NULL times with comments parsed"); 72 73 my $tree = [ 74 { 75 name => 'mytime', 76 class => 'time', 77 type => 'UTC', 78 value => undef, 79 comment => 'comment', 80 }, 81 { 82 name => 'mytime', 83 class => 'time', 84 type => 'UT1', 85 value => undef, 86 comment => 'comment', 87 }, 88 { 89 name => 'mytime', 90 class => 'time', 91 type => 'TAI', 92 value => undef, 93 comment => 'comment', 94 }, 95 { 96 name => 'mytime', 97 class => 'time', 98 type => 'TT', 99 value => undef, 100 comment => 'comment', 101 }, 102 ]; 103 104 is_deeply( $config, $tree, "NULL times with comments structure" ); 105 } 106 107 { 108 my $example =<<END; 109 recently MULTI 110 recently UTC 2005-03-18T16:05:00 111 recently UT1 2005-03-18T16:05:00 112 recently TAI 2005-03-18T16:05:00 113 recently TT 2005-03-18T16:05:00 114 END 115 116 my $config = $config_parser->parse( $example ); 117 ok( defined( $config ), "basic ISO8601 parsed"); 118 119 my $tree = [ 120 { 121 name => 'recently', 122 class => 'time', 123 type => 'UTC', 124 value => DateTime::Format::ISO8601->parse_datetime("2005-03-18T16:05:00Z"), 125 }, 126 { 127 name => 'recently', 128 class => 'time', 129 type => 'UT1', 130 value => DateTime::Format::ISO8601->parse_datetime("2005-03-18T16:05:00Z"), 131 }, 132 { 133 name => 'recently', 134 class => 'time', 135 type => 'TAI', 136 value => DateTime::Format::ISO8601->parse_datetime("2005-03-18T16:05:00Z"), 137 }, 138 { 139 name => 'recently', 140 class => 'time', 141 type => 'TT', 142 value => DateTime::Format::ISO8601->parse_datetime("2005-03-18T16:05:00Z"), 143 }, 144 ]; 145 146 is_deeply( $config, $tree, "basic ISO8601 structure" ); 147 } 148 149 { 150 my $example =<<END; 151 recently MULTI 21 152 recently UTC 2005-03-18T16:05:00Z 22 153 recently UT1 2005-03-18T16:05:00Z … … 24 155 recently TT 2005-03-18T16:05:00Z 25 156 END 26 my $config = $config_parser->parse( $example ); 27 ok( defined( $config ), "basic IS8601"); 28 } 29 30 { 31 my $example =<<END; 157 158 my $config = $config_parser->parse( $example ); 159 ok( defined( $config ), "basic ISO8601 w/Z parsed"); 160 161 my $tree = [ 162 { 163 name => 'recently', 164 class => 'time', 165 type => 'UTC', 166 value => DateTime::Format::ISO8601->parse_datetime("2005-03-18T16:05:00Z"), 167 }, 168 { 169 name => 'recently', 170 class => 'time', 171 type => 'UT1', 172 value => DateTime::Format::ISO8601->parse_datetime("2005-03-18T16:05:00Z"), 173 }, 174 { 175 name => 'recently', 176 class => 'time', 177 type => 'TAI', 178 value => DateTime::Format::ISO8601->parse_datetime("2005-03-18T16:05:00Z"), 179 }, 180 { 181 name => 'recently', 182 class => 'time', 183 type => 'TT', 184 value => DateTime::Format::ISO8601->parse_datetime("2005-03-18T16:05:00Z"), 185 }, 186 ]; 187 188 is_deeply( $config, $tree, "basic ISO8601 w/Z structure" ); 189 } 190 191 { 192 my $example =<<END; 193 recently MULTI 32 194 recently UTC 2005-03-18T16:05:00.000001Z 33 195 recently UT1 2005-03-18T16:05:00.000001Z … … 36 198 END 37 199 my $config = $config_parser->parse( $example ); 38 ok( defined( $config ), "basic IS8601 with fractional seconds"); 39 } 40 41 { 42 my $example =<<END; 200 ok( defined( $config ), "basic IS8601 with fractional seconds parsed"); 201 } 202 203 { 204 my $example =<<END; 205 recently MULTI 43 206 recently UTC 2005-03-18T16:05:00Z # foo 44 207 recently UT1 2005-03-18T16:05:00Z # bar … … 47 210 END 48 211 my $config = $config_parser->parse( $example ); 49 ok( defined( $config ), "ISO8601 with comments"); 50 } 51 52 { 53 my $example =<<END; 212 ok( defined( $config ), "ISO8601 with comments parsed"); 213 } 214 215 { 216 my $example =<<END; 217 recently MULTI 54 218 recently UTC 2005-03-18T16:05:00.000001Z # foo 55 219 recently UT1 2005-03-18T16:05:00.000001Z # bar … … 58 222 END 59 223 my $config = $config_parser->parse( $example ); 60 ok( defined( $config ), "ISO8601 with comments and fractional seconds"); 61 } 62 63 { 64 my $example =<<END; 224 ok( defined( $config ), "ISO8601 with comments and fractional seconds parsed"); 225 } 226 227 diag("epoch time format maybe deprecated"); 228 229 { 230 my $example =<<END; 231 recently MULTI 65 232 recently UTC 123456, 5000, 1 66 233 recently UT1 123456, 5000 … … 69 236 END 70 237 my $config = $config_parser->parse( $example ); 71 ok( defined( $config ), "basic epoch time"); 72 } 73 74 { 75 my $example =<<END; 238 ok( defined( $config ), "basic epoch time parsed"); 239 } 240 241 { 242 my $example =<<END; 243 recently MULTI 76 244 recently UTC 123456, 5000, 1 # foo 77 245 recently UT1 123456, 5000 # bar … … 80 248 END 81 249 my $config = $config_parser->parse( $example ); 82 ok( defined( $config ), "epoch time with comments ");83 } 84 85 { 86 my $example =<<END; 87 broken UTC 2005-03-18 T16:05:0088 END 89 my $config = $config_parser->parse( $example ); 90 ok( !defined( $config ), "bad format"); 91 } 92 93 { 94 my $example =<<END; 95 broken UT1 2005-03-18 T16:05:0096 END 97 my $config = $config_parser->parse( $example ); 98 ok( !defined( $config ), "bad format"); 99 } 100 101 { 102 my $example =<<END; 103 broken TAI 2005-03-18 T16:05:00104 END 105 my $config = $config_parser->parse( $example ); 106 ok( !defined( $config ), "bad format"); 107 } 108 109 { 110 my $example =<<END; 111 broken TT 2005-03-18 T16:05:00112 END 113 my $config = $config_parser->parse( $example ); 114 ok( !defined( $config ), "bad format"); 115 } 250 ok( defined( $config ), "epoch time with comments parsed"); 251 } 252 253 { 254 my $example =<<END; 255 broken UTC 2005-03-18 16:05:00 256 END 257 my $config = $config_parser->parse( $example ); 258 ok( !defined( $config ), "bad format"); 259 } 260 261 { 262 my $example =<<END; 263 broken UT1 2005-03-18 16:05:00 264 END 265 my $config = $config_parser->parse( $example ); 266 ok( !defined( $config ), "bad format"); 267 } 268 269 { 270 my $example =<<END; 271 broken TAI 2005-03-18 16:05:00 272 END 273 my $config = $config_parser->parse( $example ); 274 ok( !defined( $config ), "bad format"); 275 } 276 277 { 278 my $example =<<END; 279 broken TT 2005-03-18 16:05:00 280 END 281 my $config = $config_parser->parse( $example ); 282 ok( !defined( $config ), "bad format"); 283 }
Note:
See TracChangeset
for help on using the changeset viewer.
