1b39c5158Smillert#!perl -w 2b39c5158Smillert 3b39c5158Smillertuse strict; 46fb12b70Safresh1use warnings; 5b39c5158Smillertuse lib 't/lib'; 6b39c5158Smillert 7b39c5158Smillertuse Test::More; 8b39c5158Smillert 9b39c5158Smillertuse TAP::Parser::YAMLish::Reader; 10b39c5158Smillert 11b39c5158Smillertmy @SCHEDULE; 12b39c5158Smillert 13b39c5158SmillertBEGIN { 14b39c5158Smillert @SCHEDULE = ( 15b39c5158Smillert { name => 'Hello World', 16b39c5158Smillert in => [ 17b39c5158Smillert '--- Hello, World', 18b39c5158Smillert '...', 19b39c5158Smillert ], 20b39c5158Smillert out => "Hello, World", 21b39c5158Smillert }, 22b39c5158Smillert { name => 'Hello World 2', 23b39c5158Smillert in => [ 24b39c5158Smillert '--- \'Hello, \'\'World\'', 25b39c5158Smillert '...', 26b39c5158Smillert ], 27b39c5158Smillert out => "Hello, 'World", 28b39c5158Smillert }, 29b39c5158Smillert { name => 'Hello World 3', 30b39c5158Smillert in => [ 31b39c5158Smillert '--- "Hello, World"', 32b39c5158Smillert '...', 33b39c5158Smillert ], 34b39c5158Smillert out => "Hello, World", 35b39c5158Smillert }, 36b39c5158Smillert { name => 'Hello World 4', 37b39c5158Smillert in => [ 38b39c5158Smillert '--- "Hello, World"', 39b39c5158Smillert '...', 40b39c5158Smillert ], 41b39c5158Smillert out => "Hello, World", 42b39c5158Smillert }, 43b39c5158Smillert { name => 'Hello World 4', 44b39c5158Smillert in => [ 45b39c5158Smillert '--- >', 46b39c5158Smillert ' Hello,', 47b39c5158Smillert ' World', 48b39c5158Smillert '...', 49b39c5158Smillert ], 50b39c5158Smillert out => "Hello, World\n", 51b39c5158Smillert }, 52b39c5158Smillert { name => 'Hello World Block', 53b39c5158Smillert in => [ 54b39c5158Smillert '--- |', 55b39c5158Smillert ' Hello,', 56b39c5158Smillert ' World', 57b39c5158Smillert '...', 58b39c5158Smillert ], 59b39c5158Smillert out => "Hello,\n World\n", 60b39c5158Smillert }, 61b39c5158Smillert { name => 'Hello World 5', 62b39c5158Smillert in => [ 63b39c5158Smillert '--- >', 64b39c5158Smillert ' Hello,', 65b39c5158Smillert ' World', 66b39c5158Smillert '...', 67b39c5158Smillert ], 68b39c5158Smillert error => qr{Missing\s+'[.][.][.]'}, 69b39c5158Smillert }, 70b39c5158Smillert { name => 'Simple array', 71b39c5158Smillert in => [ 72b39c5158Smillert '---', 73b39c5158Smillert '- 1', 74b39c5158Smillert '- 2', 75b39c5158Smillert '- 3', 76b39c5158Smillert '...', 77b39c5158Smillert ], 78b39c5158Smillert out => [ '1', '2', '3' ], 79b39c5158Smillert }, 80b39c5158Smillert { name => 'Mixed array', 81b39c5158Smillert in => [ 82b39c5158Smillert '---', 83b39c5158Smillert '- 1', 84b39c5158Smillert '- \'two\'', 85b39c5158Smillert '- "three\n"', 86b39c5158Smillert '...', 87b39c5158Smillert ], 88b39c5158Smillert out => [ '1', 'two', "three\n" ], 89b39c5158Smillert }, 90b39c5158Smillert { name => 'Hash in array', 91b39c5158Smillert in => [ 92b39c5158Smillert '---', 93b39c5158Smillert '- 1', 94b39c5158Smillert '- two: 2', 95b39c5158Smillert '- 3', 96b39c5158Smillert '...', 97b39c5158Smillert ], 98b39c5158Smillert out => [ '1', { two => '2' }, '3' ], 99b39c5158Smillert }, 100b39c5158Smillert { name => 'Hash in array 2', 101b39c5158Smillert in => [ 102b39c5158Smillert '---', 103b39c5158Smillert '- 1', 104b39c5158Smillert '- two: 2', 105b39c5158Smillert ' three: 3', 106b39c5158Smillert '- 4', 107b39c5158Smillert '...', 108b39c5158Smillert ], 109b39c5158Smillert out => [ '1', { two => '2', three => '3' }, '4' ], 110b39c5158Smillert }, 111b39c5158Smillert { name => 'Nested array', 112b39c5158Smillert in => [ 113b39c5158Smillert '---', 114b39c5158Smillert '- one', 115b39c5158Smillert '-', 116b39c5158Smillert ' - two', 117b39c5158Smillert ' -', 118b39c5158Smillert ' - three', 119b39c5158Smillert ' - four', 120b39c5158Smillert '- five', 121b39c5158Smillert '...', 122b39c5158Smillert ], 123b39c5158Smillert out => [ 'one', [ 'two', ['three'], 'four' ], 'five' ], 124b39c5158Smillert }, 125b39c5158Smillert { name => 'Nested hash', 126b39c5158Smillert in => [ 127b39c5158Smillert '---', 128b39c5158Smillert 'one:', 129b39c5158Smillert ' five: 5', 130b39c5158Smillert ' two:', 131b39c5158Smillert ' four: 4', 132b39c5158Smillert ' three: 3', 133b39c5158Smillert 'six: 6', 134b39c5158Smillert '...', 135b39c5158Smillert ], 136b39c5158Smillert out => { 137b39c5158Smillert one => { two => { three => '3', four => '4' }, five => '5' }, 138b39c5158Smillert six => '6' 139b39c5158Smillert }, 140b39c5158Smillert }, 141*eac174f2Safresh1 { name => 'Edge cases for hash start vs. undefined scalar 1', 142*eac174f2Safresh1 in => [ 143*eac174f2Safresh1 '---', 144*eac174f2Safresh1 'one:', 145*eac174f2Safresh1 ' five: 5', 146*eac174f2Safresh1 ' two:', 147*eac174f2Safresh1 ' four: 4', 148*eac174f2Safresh1 ' three: 3', 149*eac174f2Safresh1 'six: 6', 150*eac174f2Safresh1 '...', 151*eac174f2Safresh1 ], 152*eac174f2Safresh1 out => { 153*eac174f2Safresh1 one => { two => undef, three => '3', four => '4', five => '5' }, 154*eac174f2Safresh1 six => '6' 155*eac174f2Safresh1 }, 156*eac174f2Safresh1 }, 157*eac174f2Safresh1 { name => 'Edge cases for hash start vs. undefined scalar 2', 158*eac174f2Safresh1 in => [ 159*eac174f2Safresh1 '---', 160*eac174f2Safresh1 'one:', 161*eac174f2Safresh1 ' five: 5', 162*eac174f2Safresh1 ' two: ~', 163*eac174f2Safresh1 ' four: 4', 164*eac174f2Safresh1 ' three: 3', 165*eac174f2Safresh1 'six: 6', 166*eac174f2Safresh1 '...', 167*eac174f2Safresh1 ], 168*eac174f2Safresh1 out => { 169*eac174f2Safresh1 one => { two => undef, three => '3', four => '4', five => '5' }, 170*eac174f2Safresh1 six => '6' 171*eac174f2Safresh1 }, 172*eac174f2Safresh1 }, 173*eac174f2Safresh1 { name => 'Edge cases for hash start vs. undefined scalar 3', 174*eac174f2Safresh1 in => [ 175*eac174f2Safresh1 '---', 176*eac174f2Safresh1 'two:', 177*eac174f2Safresh1 'four: 4', 178*eac174f2Safresh1 'three: 3', 179*eac174f2Safresh1 '...', 180*eac174f2Safresh1 ], 181*eac174f2Safresh1 out => { 182*eac174f2Safresh1 two => undef, three => '3', four => '4', 183*eac174f2Safresh1 }, 184*eac174f2Safresh1 }, 185*eac174f2Safresh1 { name => 'Edge cases for hash start vs. undefined scalar 4', 186*eac174f2Safresh1 in => [ 187*eac174f2Safresh1 '---', 188*eac174f2Safresh1 'two:', 189*eac174f2Safresh1 ' four: 4', 190*eac174f2Safresh1 ' three: 3', 191*eac174f2Safresh1 '...', 192*eac174f2Safresh1 ], 193*eac174f2Safresh1 out => { 194*eac174f2Safresh1 two => { three => '3', four => '4' }, 195*eac174f2Safresh1 }, 196*eac174f2Safresh1 }, 197*eac174f2Safresh1 { name => 'Edge cases for hash start vs. undefined scalar 5', 198*eac174f2Safresh1 in => [ 199*eac174f2Safresh1 '---', 200*eac174f2Safresh1 'two:', 201*eac174f2Safresh1 '- four: 4', 202*eac174f2Safresh1 '- three: 3', 203*eac174f2Safresh1 '...', 204*eac174f2Safresh1 ], 205*eac174f2Safresh1 out => { 206*eac174f2Safresh1 two => [ { four => '4' }, { three => '3' } ], 207*eac174f2Safresh1 }, 208*eac174f2Safresh1 }, 209b39c5158Smillert { name => 'Space after colon', 210b39c5158Smillert in => [ '---', 'spog: ', ' - 1', ' - 2', '...' ], 211b39c5158Smillert out => { spog => [ 1, 2 ] }, 212b39c5158Smillert }, 213b39c5158Smillert { name => 'Original YAML::Tiny test', 214b39c5158Smillert in => [ 215b39c5158Smillert '---', 216b39c5158Smillert 'invoice: 34843', 217b39c5158Smillert 'date : 2001-01-23', 218b39c5158Smillert 'bill-to:', 219b39c5158Smillert ' given : Chris', 220b39c5158Smillert ' family : Dumars', 221b39c5158Smillert ' address:', 222b39c5158Smillert ' lines: |', 223b39c5158Smillert ' 458 Walkman Dr.', 224b39c5158Smillert ' Suite #292', 225b39c5158Smillert ' city : Royal Oak', 226b39c5158Smillert ' state : MI', 227b39c5158Smillert ' postal : 48046', 228b39c5158Smillert 'product:', 229b39c5158Smillert ' - sku : BL394D', 230b39c5158Smillert ' quantity : 4', 231b39c5158Smillert ' description : Basketball', 232b39c5158Smillert ' price : 450.00', 233b39c5158Smillert ' - sku : BL4438H', 234b39c5158Smillert ' quantity : 1', 235b39c5158Smillert ' description : Super Hoop', 236b39c5158Smillert ' price : 2392.00', 237b39c5158Smillert 'tax : 251.42', 238b39c5158Smillert 'total: 4443.52', 239b39c5158Smillert 'comments: >', 240b39c5158Smillert ' Late afternoon is best.', 241b39c5158Smillert ' Backup contact is Nancy', 242b39c5158Smillert ' Billsmer @ 338-4338', 243b39c5158Smillert '...', 244b39c5158Smillert ], 245b39c5158Smillert out => { 246b39c5158Smillert 'bill-to' => { 247b39c5158Smillert 'given' => 'Chris', 248b39c5158Smillert 'address' => { 249b39c5158Smillert 'city' => 'Royal Oak', 250b39c5158Smillert 'postal' => '48046', 251b39c5158Smillert 'lines' => "458 Walkman Dr.\nSuite #292\n", 252b39c5158Smillert 'state' => 'MI' 253b39c5158Smillert }, 254b39c5158Smillert 'family' => 'Dumars' 255b39c5158Smillert }, 256b39c5158Smillert 'invoice' => '34843', 257b39c5158Smillert 'date' => '2001-01-23', 258b39c5158Smillert 'tax' => '251.42', 259b39c5158Smillert 'product' => [ 260b39c5158Smillert { 'sku' => 'BL394D', 261b39c5158Smillert 'quantity' => '4', 262b39c5158Smillert 'price' => '450.00', 263b39c5158Smillert 'description' => 'Basketball' 264b39c5158Smillert }, 265b39c5158Smillert { 'sku' => 'BL4438H', 266b39c5158Smillert 'quantity' => '1', 267b39c5158Smillert 'price' => '2392.00', 268b39c5158Smillert 'description' => 'Super Hoop' 269b39c5158Smillert } 270b39c5158Smillert ], 271b39c5158Smillert 'comments' => 272b39c5158Smillert "Late afternoon is best. Backup contact is Nancy Billsmer @ 338-4338\n", 273b39c5158Smillert 'total' => '4443.52' 274b39c5158Smillert } 275b39c5158Smillert }, 276b39c5158Smillert 277b39c5158Smillert # Tests harvested from YAML::Tiny 278b39c5158Smillert { in => ['...'], 279b39c5158Smillert name => 'Regression: empty', 280b39c5158Smillert error => qr{document\s+header\s+not\s+found} 281b39c5158Smillert }, 282b39c5158Smillert { in => [ 283b39c5158Smillert '# comment', 284b39c5158Smillert '...' 285b39c5158Smillert ], 286b39c5158Smillert name => 'Regression: only_comment', 287b39c5158Smillert error => qr{document\s+header\s+not\s+found} 288b39c5158Smillert }, 289b39c5158Smillert { out => undef, 290b39c5158Smillert in => [ 291b39c5158Smillert '---', 292b39c5158Smillert '...' 293b39c5158Smillert ], 294b39c5158Smillert name => 'Regression: only_header', 295b39c5158Smillert error => qr{Premature\s+end}i, 296b39c5158Smillert }, 297b39c5158Smillert { out => undef, 298b39c5158Smillert in => [ 299b39c5158Smillert '---', 300b39c5158Smillert '---', 301b39c5158Smillert '...' 302b39c5158Smillert ], 303b39c5158Smillert name => 'Regression: two_header', 304b39c5158Smillert error => qr{Unexpected\s+start}i, 305b39c5158Smillert }, 306b39c5158Smillert { out => undef, 307b39c5158Smillert in => [ 308b39c5158Smillert '--- ~', 309b39c5158Smillert '...' 310b39c5158Smillert ], 311b39c5158Smillert name => 'Regression: one_undef' 312b39c5158Smillert }, 313b39c5158Smillert { out => undef, 314b39c5158Smillert in => [ 315b39c5158Smillert '--- ~', 316b39c5158Smillert '...' 317b39c5158Smillert ], 318b39c5158Smillert name => 'Regression: one_undef2' 319b39c5158Smillert }, 320b39c5158Smillert { in => [ 321b39c5158Smillert '--- ~', 322b39c5158Smillert '---', 323b39c5158Smillert '...' 324b39c5158Smillert ], 325b39c5158Smillert name => 'Regression: two_undef', 326b39c5158Smillert error => qr{Missing\s+'[.][.][.]'}, 327b39c5158Smillert }, 328b39c5158Smillert { out => 'foo', 329b39c5158Smillert in => [ 330b39c5158Smillert '--- foo', 331b39c5158Smillert '...' 332b39c5158Smillert ], 333b39c5158Smillert name => 'Regression: one_scalar', 334b39c5158Smillert }, 335b39c5158Smillert { out => 'foo', 336b39c5158Smillert in => [ 337b39c5158Smillert '--- foo', 338b39c5158Smillert '...' 339b39c5158Smillert ], 340b39c5158Smillert name => 'Regression: one_scalar2', 341b39c5158Smillert }, 342b39c5158Smillert { in => [ 343b39c5158Smillert '--- foo', 344b39c5158Smillert '--- bar', 345b39c5158Smillert '...' 346b39c5158Smillert ], 347b39c5158Smillert name => 'Regression: two_scalar', 348b39c5158Smillert error => qr{Missing\s+'[.][.][.]'}, 349b39c5158Smillert }, 350b39c5158Smillert { out => ['foo'], 351b39c5158Smillert in => [ 352b39c5158Smillert '---', 353b39c5158Smillert '- foo', 354b39c5158Smillert '...' 355b39c5158Smillert ], 356b39c5158Smillert name => 'Regression: one_list1' 357b39c5158Smillert }, 358b39c5158Smillert { out => [ 359b39c5158Smillert 'foo', 360b39c5158Smillert 'bar' 361b39c5158Smillert ], 362b39c5158Smillert in => [ 363b39c5158Smillert '---', 364b39c5158Smillert '- foo', 365b39c5158Smillert '- bar', 366b39c5158Smillert '...' 367b39c5158Smillert ], 368b39c5158Smillert name => 'Regression: one_list2' 369b39c5158Smillert }, 370b39c5158Smillert { out => [ 371b39c5158Smillert undef, 372b39c5158Smillert 'bar' 373b39c5158Smillert ], 374b39c5158Smillert in => [ 375b39c5158Smillert '---', 376b39c5158Smillert '- ~', 377b39c5158Smillert '- bar', 378b39c5158Smillert '...' 379b39c5158Smillert ], 380b39c5158Smillert name => 'Regression: one_listundef' 381b39c5158Smillert }, 382b39c5158Smillert { out => { 'foo' => 'bar' }, 383b39c5158Smillert in => [ 384b39c5158Smillert '---', 385b39c5158Smillert 'foo: bar', 386b39c5158Smillert '...' 387b39c5158Smillert ], 388b39c5158Smillert name => 'Regression: one_hash1' 389b39c5158Smillert }, 390b39c5158Smillert { out => { 391b39c5158Smillert 'foo' => 'bar', 392b39c5158Smillert 'this' => undef 393b39c5158Smillert }, 394b39c5158Smillert in => [ 395b39c5158Smillert '---', 396b39c5158Smillert 'foo: bar', 397b39c5158Smillert 'this: ~', 398b39c5158Smillert '...' 399b39c5158Smillert ], 400b39c5158Smillert name => 'Regression: one_hash2' 401b39c5158Smillert }, 402b39c5158Smillert { out => { 403b39c5158Smillert 'foo' => [ 404b39c5158Smillert 'bar', 405b39c5158Smillert undef, 406b39c5158Smillert 'baz' 407b39c5158Smillert ] 408b39c5158Smillert }, 409b39c5158Smillert in => [ 410b39c5158Smillert '---', 411b39c5158Smillert 'foo:', 412b39c5158Smillert ' - bar', 413b39c5158Smillert ' - ~', 414b39c5158Smillert ' - baz', 415b39c5158Smillert '...' 416b39c5158Smillert ], 417b39c5158Smillert name => 'Regression: array_in_hash' 418b39c5158Smillert }, 419b39c5158Smillert { out => { 420b39c5158Smillert 'bar' => { 'foo' => 'bar' }, 421b39c5158Smillert 'foo' => undef 422b39c5158Smillert }, 423b39c5158Smillert in => [ 424b39c5158Smillert '---', 425b39c5158Smillert 'foo: ~', 426b39c5158Smillert 'bar:', 427b39c5158Smillert ' foo: bar', 428b39c5158Smillert '...' 429b39c5158Smillert ], 430b39c5158Smillert name => 'Regression: hash_in_hash' 431b39c5158Smillert }, 432b39c5158Smillert { out => [ 433b39c5158Smillert { 'foo' => undef, 434b39c5158Smillert 'this' => 'that' 435b39c5158Smillert }, 436b39c5158Smillert 'foo', undef, 437b39c5158Smillert { 'foo' => 'bar', 438b39c5158Smillert 'this' => 'that' 439b39c5158Smillert } 440b39c5158Smillert ], 441b39c5158Smillert in => [ 442b39c5158Smillert '---', 443b39c5158Smillert '-', 444b39c5158Smillert ' foo: ~', 445b39c5158Smillert ' this: that', 446b39c5158Smillert '- foo', 447b39c5158Smillert '- ~', 448b39c5158Smillert '-', 449b39c5158Smillert ' foo: bar', 450b39c5158Smillert ' this: that', 451b39c5158Smillert '...' 452b39c5158Smillert ], 453b39c5158Smillert name => 'Regression: hash_in_array' 454b39c5158Smillert }, 455b39c5158Smillert { out => ['foo'], 456b39c5158Smillert in => [ 457b39c5158Smillert '---', 458b39c5158Smillert '- \'foo\'', 459b39c5158Smillert '...' 460b39c5158Smillert ], 461b39c5158Smillert name => 'Regression: single_quote1' 462b39c5158Smillert }, 463b39c5158Smillert { out => [' '], 464b39c5158Smillert in => [ 465b39c5158Smillert '---', 466b39c5158Smillert '- \' \'', 467b39c5158Smillert '...' 468b39c5158Smillert ], 469b39c5158Smillert name => 'Regression: single_spaces' 470b39c5158Smillert }, 471b39c5158Smillert { out => [''], 472b39c5158Smillert in => [ 473b39c5158Smillert '---', 474b39c5158Smillert '- \'\'', 475b39c5158Smillert '...' 476b39c5158Smillert ], 477b39c5158Smillert name => 'Regression: single_null' 478b39c5158Smillert }, 479b39c5158Smillert { out => ' ', 480b39c5158Smillert in => [ 481b39c5158Smillert '--- " "', 482b39c5158Smillert '...' 483b39c5158Smillert ], 484b39c5158Smillert name => 'Regression: only_spaces' 485b39c5158Smillert }, 486b8851fccSafresh1 { out => ['first','second'], 487b8851fccSafresh1 in => [ 488b8851fccSafresh1 '--- ', 489b8851fccSafresh1 '- first ', 490b8851fccSafresh1 '- second ', 491b8851fccSafresh1 '...' 492b8851fccSafresh1 ], 493b8851fccSafresh1 name => "Space after header for array", 494b8851fccSafresh1 }, 495b8851fccSafresh1 { out => {'key' => [{'value' => {'key2' => 'value2'}}]}, 496b8851fccSafresh1 in => [ 497b8851fccSafresh1 '--- ', 498b8851fccSafresh1 'key: ', 499b8851fccSafresh1 '- value: ', 500b8851fccSafresh1 ' key2: value2 ', 501b8851fccSafresh1 '... ' 502b8851fccSafresh1 ], 503b8851fccSafresh1 name => "Space after header for hash", 504b8851fccSafresh1 }, 505b39c5158Smillert { out => [ 506b39c5158Smillert undef, 507b39c5158Smillert { 'foo' => 'bar', 508b39c5158Smillert 'this' => 'that' 509b39c5158Smillert }, 510b39c5158Smillert 'baz' 511b39c5158Smillert ], 512b39c5158Smillert in => [ 513b39c5158Smillert '---', 514b39c5158Smillert '- ~', 515b39c5158Smillert '- foo: bar', 516b39c5158Smillert ' this: that', 517b39c5158Smillert '- baz', 518b39c5158Smillert '...' 519b39c5158Smillert ], 520b39c5158Smillert name => 'Regression: inline_nested_hash' 521b39c5158Smillert }, 522*eac174f2Safresh1 { name => "Unprintables", # This is an ASCII centric test 523b39c5158Smillert in => [ 524b39c5158Smillert "---", 525b39c5158Smillert "- \"\\z\\x01\\x02\\x03\\x04\\x05\\x06\\a\\x08\\t\\n\\v\\f\\r\\x0e\\x0f\"", 526b39c5158Smillert "- \"\\x10\\x11\\x12\\x13\\x14\\x15\\x16\\x17\\x18\\x19\\x1a\\e\\x1c\\x1d\\x1e\\x1f\"", 527b39c5158Smillert "- \" !\\\"#\$%&'()*+,-./\"", 528b39c5158Smillert "- 0123456789:;<=>?", 529b39c5158Smillert "- '\@ABCDEFGHIJKLMNO'", 530b39c5158Smillert "- 'PQRSTUVWXYZ[\\]^_'", 531b39c5158Smillert "- '`abcdefghijklmno'", 532b39c5158Smillert "- 'pqrstuvwxyz{|}~\177'", 533b39c5158Smillert "- \200\201\202\203\204\205\206\207\210\211\212\213\214\215\216\217", 534b39c5158Smillert "- \220\221\222\223\224\225\226\227\230\231\232\233\234\235\236\237", 535b39c5158Smillert "- \240\241\242\243\244\245\246\247\250\251\252\253\254\255\256\257", 536b39c5158Smillert "- \260\261\262\263\264\265\266\267\270\271\272\273\274\275\276\277", 537b39c5158Smillert "- \300\301\302\303\304\305\306\307\310\311\312\313\314\315\316\317", 538b39c5158Smillert "- \320\321\322\323\324\325\326\327\330\331\332\333\334\335\336\337", 539b39c5158Smillert "- \340\341\342\343\344\345\346\347\350\351\352\353\354\355\356\357", 540b39c5158Smillert "- \360\361\362\363\364\365\366\367\370\371\372\373\374\375\376\377", 541b39c5158Smillert "..." 542b39c5158Smillert ], 543b39c5158Smillert out => [ 544b39c5158Smillert "\0\1\2\3\4\5\6\a\b\t\n\13\f\r\16\17", 545b39c5158Smillert "\20\21\22\23\24\25\26\27\30\31\32\e\34\35\36\37", 546b39c5158Smillert " !\"#\$%&'()*+,-./", 547b39c5158Smillert "0123456789:;<=>?", 548b39c5158Smillert "\@ABCDEFGHIJKLMNO", 549b39c5158Smillert "PQRSTUVWXYZ[\\]^_", 550b39c5158Smillert "`abcdefghijklmno", 551b39c5158Smillert "pqrstuvwxyz{|}~\177", 552b39c5158Smillert "\200\201\202\203\204\205\206\207\210\211\212\213\214\215\216\217", 553b39c5158Smillert "\220\221\222\223\224\225\226\227\230\231\232\233\234\235\236\237", 554b39c5158Smillert "\240\241\242\243\244\245\246\247\250\251\252\253\254\255\256\257", 555b39c5158Smillert "\260\261\262\263\264\265\266\267\270\271\272\273\274\275\276\277", 556b39c5158Smillert "\300\301\302\303\304\305\306\307\310\311\312\313\314\315\316\317", 557b39c5158Smillert "\320\321\322\323\324\325\326\327\330\331\332\333\334\335\336\337", 558b39c5158Smillert "\340\341\342\343\344\345\346\347\350\351\352\353\354\355\356\357", 559b39c5158Smillert "\360\361\362\363\364\365\366\367\370\371\372\373\374\375\376\377" 560b39c5158Smillert ], 561b39c5158Smillert }, 562b39c5158Smillert { name => 'Quoted hash keys', 563b39c5158Smillert in => [ 564b39c5158Smillert '---', 565b39c5158Smillert ' "quoted": Magic!', 566b39c5158Smillert ' "\n\t": newline, tab', 567b39c5158Smillert '...', 568b39c5158Smillert ], 569b39c5158Smillert out => { 570b39c5158Smillert quoted => 'Magic!', 571b39c5158Smillert "\n\t" => 'newline, tab', 572b39c5158Smillert }, 573b39c5158Smillert }, 574b39c5158Smillert { name => 'Empty', 575b39c5158Smillert in => [], 576b39c5158Smillert out => undef, 577b39c5158Smillert }, 578b39c5158Smillert ); 579b39c5158Smillert 580b39c5158Smillert plan tests => @SCHEDULE * 5; 581b39c5158Smillert} 582b39c5158Smillert 583b39c5158Smillertsub iter { 584b39c5158Smillert my $ar = shift; 585b39c5158Smillert return sub { 586b39c5158Smillert return shift @$ar; 587b39c5158Smillert }; 588b39c5158Smillert} 589b39c5158Smillert 590b39c5158Smillertfor my $test (@SCHEDULE) { 591b39c5158Smillert my $name = $test->{name}; 592b39c5158Smillert ok my $yaml = TAP::Parser::YAMLish::Reader->new, "$name: Created"; 593b39c5158Smillert isa_ok $yaml, 'TAP::Parser::YAMLish::Reader'; 594b39c5158Smillert 595b39c5158Smillert my $source = join( "\n", @{ $test->{in} } ) . "\n"; 596b39c5158Smillert 597b39c5158Smillert my $iter = iter( $test->{in} ); 598b39c5158Smillert my $got = eval { $yaml->read($iter) }; 599b39c5158Smillert 600b39c5158Smillert my $raw = $yaml->get_raw; 601b39c5158Smillert 602b39c5158Smillert if ( my $err = $test->{error} ) { 603b39c5158Smillert unless ( like $@, $err, "$name: Error message" ) { 604b39c5158Smillert diag "Error: $@\n"; 605b39c5158Smillert } 606b39c5158Smillert ok !$got, "$name: No result"; 607b39c5158Smillert pass; 608b39c5158Smillert } 609b39c5158Smillert else { 610b39c5158Smillert my $want = $test->{out}; 611b39c5158Smillert unless ( ok !$@, "$name: No error" ) { 612b39c5158Smillert diag "Error: $@\n"; 613b39c5158Smillert } 614b39c5158Smillert is_deeply $got, $want, "$name: Result matches"; 615b39c5158Smillert is $raw, $source, "$name: Captured source matches"; 616b39c5158Smillert } 617b39c5158Smillert} 618