| | 208 | |
| | 209 | /** |
| | 210 | * @ticket 22692 |
| | 211 | */ |
| | 212 | function test_spaces_around_quotes() { |
| | 213 | $nbsp = "\xC2\xA0"; |
| | 214 | $pi = "\xCE\xA0"; |
| | 215 | |
| | 216 | // This should never happen, even if the desired output changes some day. |
| | 217 | |
| | 218 | $problem_input = "$nbsp\"A"; |
| | 219 | $problem_output = "$nbsp”A"; |
| | 220 | |
| | 221 | $this->assertNotEquals( $problem_output, wptexturize( $problem_input ) ); |
| | 222 | |
| | 223 | // These are desirable outputs for the current design. |
| | 224 | |
| | 225 | $input = array(); |
| | 226 | $output = array(); |
| | 227 | |
| | 228 | $input[] = "stop. $nbsp\"A quote after 2 spaces.\""; |
| | 229 | $output[] = "stop. $nbsp“A quote after 2 spaces.”"; |
| | 230 | |
| | 231 | $input[] = "stop.$nbsp$nbsp\"A quote after 2 spaces.\""; |
| | 232 | $output[] = "stop.$nbsp$nbsp“A quote after 2 spaces.”"; |
| | 233 | |
| | 234 | $input[] = "stop. $nbsp'A quote after 2 spaces.'"; |
| | 235 | $output[] = "stop. $nbsp‘A quote after 2 spaces.’"; |
| | 236 | |
| | 237 | $input[] = "stop.$nbsp$nbsp'A quote after 2 spaces.'"; |
| | 238 | $output[] = "stop.$nbsp$nbsp‘A quote after 2 spaces.’"; |
| | 239 | |
| | 240 | $input[] = "stop. \"A quote after 2 spaces.\""; |
| | 241 | $output[] = "stop. “A quote after 2 spaces.”"; |
| | 242 | |
| | 243 | $input[] = "stop. \"A quote after 2 spaces.\""; |
| | 244 | $output[] = "stop. “A quote after 2 spaces.”"; |
| | 245 | |
| | 246 | $input[] = "stop. 'A quote after 2 spaces.'"; |
| | 247 | $output[] = "stop. ‘A quote after 2 spaces.’"; |
| | 248 | |
| | 249 | $input[] = "stop. 'A quote after 2 spaces.'"; |
| | 250 | $output[] = "stop. ‘A quote after 2 spaces.’"; |
| | 251 | |
| | 252 | $input[] = "Contraction: $pi's"; |
| | 253 | $output[] = "Contraction: $pi’s"; |
| | 254 | |
| | 255 | foreach($input as $key => $in) { |
| | 256 | $this->assertEquals( $output[$key], wptexturize( $in ) ); |
| | 257 | } |
| | 258 | } |
| | 259 | |
| | 260 | /** |
| | 261 | * Check all baseline patterns. If anything ever changes in wptexturize(), these tests may fail. |
| | 262 | * |
| | 263 | * @ticket 22692 |
| | 264 | */ |
| | 265 | function test_apos_before_digits() { |
| | 266 | $input = array(); |
| | 267 | $output = array(); |
| | 268 | |
| | 269 | // Apostrophe before a number always becomes ’ (apos); |
| | 270 | |
| | 271 | $input[] = "word '99 word"; |
| | 272 | $output[] = "word ’99 word"; |
| | 273 | |
| | 274 | $input[] = "word'99 word"; |
| | 275 | $output[] = "word’99 word"; |
| | 276 | |
| | 277 | $input[] = "word '99word"; |
| | 278 | $output[] = "word ’99word"; |
| | 279 | |
| | 280 | $input[] = "word'99word"; |
| | 281 | $output[] = "word’99word"; |
| | 282 | |
| | 283 | $input[] = "word '99’s word"; // Appears as a separate but logically superfluous pattern in 3.8. |
| | 284 | $output[] = "word ’99’s word"; |
| | 285 | |
| | 286 | $input[] = "word '99's word"; // Due to the logic error, second apos becomes a prime. See ticket #22823 |
| | 287 | $output[] = "word ’99′s word"; |
| | 288 | |
| | 289 | $input[] = "word '99'samsonite"; |
| | 290 | $output[] = "word ’99′samsonite"; |
| | 291 | |
| | 292 | $input[] = "according to our source, '33% of all students scored less than 50' on the test."; // Apostrophes and primes have priority over quotes |
| | 293 | $output[] = "according to our source, ’33% of all students scored less than 50′ on the test."; |
| | 294 | |
| | 295 | $input[] = "word '99' word"; // See ticket #8775 |
| | 296 | $output[] = "word ’99′ word"; |
| | 297 | |
| | 298 | foreach($input as $key => $in) { |
| | 299 | $this->assertEquals( $output[$key], wptexturize( $in ) ); |
| | 300 | } |
| | 301 | } |
| | 302 | |
| | 303 | /** |
| | 304 | * Check all baseline patterns. If anything ever changes in wptexturize(), these tests may fail. |
| | 305 | * |
| | 306 | * @ticket 22692 |
| | 307 | */ |
| | 308 | function test_opening_single_quote() { |
| | 309 | $input = array(); |
| | 310 | $output = array(); |
| | 311 | |
| | 312 | // Apostrophe after a space or ([{<" becomes ‘ (opening_single_quote) |
| | 313 | |
| | 314 | $input[] = "word 'word word"; |
| | 315 | $output[] = "word ‘word word"; |
| | 316 | |
| | 317 | $input[] = "word ('word word"; |
| | 318 | $output[] = "word (‘word word"; |
| | 319 | |
| | 320 | $input[] = "word ['word word"; |
| | 321 | $output[] = "word [‘word word"; |
| | 322 | |
| | 323 | $input[] = "word <'word word"; // Invalid HTML input? |
| | 324 | $output[] = "word <‘word word"; |
| | 325 | |
| | 326 | $input[] = "word <'word word"; // Valid HTML input triggers the apos in a word pattern |
| | 327 | $output[] = "word <’word word"; |
| | 328 | |
| | 329 | $input[] = "word {'word word"; |
| | 330 | $output[] = "word {‘word word"; |
| | 331 | |
| | 332 | $input[] = "word \"'word word"; |
| | 333 | $output[] = "word “‘word word"; // Two opening quotes |
| | 334 | |
| | 335 | $input[] = "'word word"; |
| | 336 | $output[] = "‘word word"; |
| | 337 | |
| | 338 | $input[] = "word('word word"; |
| | 339 | $output[] = "word(‘word word"; |
| | 340 | |
| | 341 | $input[] = "word['word word"; |
| | 342 | $output[] = "word[‘word word"; |
| | 343 | |
| | 344 | $input[] = "word<'word word"; |
| | 345 | $output[] = "word<‘word word"; |
| | 346 | |
| | 347 | $input[] = "word<'word word"; |
| | 348 | $output[] = "word<’word word"; |
| | 349 | |
| | 350 | $input[] = "word{'word word"; |
| | 351 | $output[] = "word{‘word word"; |
| | 352 | |
| | 353 | $input[] = "word\"'word word"; |
| | 354 | $output[] = "word”‘word word"; // Closing quote, then opening quote |
| | 355 | |
| | 356 | $input[] = "word ' word word"; |
| | 357 | $output[] = "word ‘ word word"; |
| | 358 | |
| | 359 | $input[] = "word (' word word"; |
| | 360 | $output[] = "word (‘ word word"; |
| | 361 | |
| | 362 | $input[] = "word [' word word"; |
| | 363 | $output[] = "word [‘ word word"; |
| | 364 | |
| | 365 | $input[] = "word <' word word"; // Invalid HTML input? |
| | 366 | $output[] = "word <‘ word word"; |
| | 367 | |
| | 368 | $input[] = "word <' word word"; // Valid HTML input triggers the closing single quote here |
| | 369 | $output[] = "word <’ word word"; |
| | 370 | |
| | 371 | $input[] = "word {' word word"; |
| | 372 | $output[] = "word {‘ word word"; |
| | 373 | |
| | 374 | $input[] = "word \"' word word"; |
| | 375 | $output[] = "word “‘ word word"; // Two opening quotes |
| | 376 | |
| | 377 | $input[] = "' word word"; |
| | 378 | $output[] = "‘ word word"; |
| | 379 | |
| | 380 | $input[] = "word(' word word"; |
| | 381 | $output[] = "word(‘ word word"; |
| | 382 | |
| | 383 | $input[] = "word[' word word"; |
| | 384 | $output[] = "word[‘ word word"; |
| | 385 | |
| | 386 | $input[] = "word<' word word"; |
| | 387 | $output[] = "word<‘ word word"; |
| | 388 | |
| | 389 | $input[] = "word<' word word"; |
| | 390 | $output[] = "word<’ word word"; |
| | 391 | |
| | 392 | $input[] = "word{' word word"; |
| | 393 | $output[] = "word{‘ word word"; |
| | 394 | |
| | 395 | $input[] = "word\"' word word"; |
| | 396 | $output[] = "word”‘ word word"; // Closing quote, then opening quote |
| | 397 | |
| | 398 | foreach($input as $key => $in) { |
| | 399 | $this->assertEquals( $output[$key], wptexturize( $in ) ); |
| | 400 | } |
| | 401 | } |
| | 402 | |
| | 403 | /** |
| | 404 | * Check all baseline patterns. If anything ever changes in wptexturize(), these tests may fail. |
| | 405 | * |
| | 406 | * @ticket 22692 |
| | 407 | */ |
| | 408 | function test_double_prime() { |
| | 409 | $input = array(); |
| | 410 | $output = array(); |
| | 411 | |
| | 412 | // Double quote after a number becomes ″ (double_prime) |
| | 413 | |
| | 414 | $input[] = 'word 99" word'; |
| | 415 | $output[] = 'word 99″ word'; |
| | 416 | |
| | 417 | $input[] = 'word 99"word'; |
| | 418 | $output[] = 'word 99″word'; |
| | 419 | |
| | 420 | $input[] = 'word99" word'; |
| | 421 | $output[] = 'word99″ word'; |
| | 422 | |
| | 423 | $input[] = 'word99"word'; |
| | 424 | $output[] = 'word99″word'; |
| | 425 | |
| | 426 | foreach($input as $key => $in) { |
| | 427 | $this->assertEquals( $output[$key], wptexturize( $in ) ); |
| | 428 | } |
| | 429 | } |
| | 430 | |
| | 431 | /** |
| | 432 | * Check all baseline patterns. If anything ever changes in wptexturize(), these tests may fail. |
| | 433 | * |
| | 434 | * @ticket 22692 |
| | 435 | */ |
| | 436 | function test_single_prime() { |
| | 437 | $input = array(); |
| | 438 | $output = array(); |
| | 439 | |
| | 440 | // Apostrophe after a number becomes ′ (prime) |
| | 441 | |
| | 442 | $input[] = "word 99' word"; |
| | 443 | $output[] = "word 99′ word"; |
| | 444 | |
| | 445 | $input[] = "word 99'word"; |
| | 446 | $output[] = "word 99′word"; |
| | 447 | |
| | 448 | $input[] = "word99' word"; |
| | 449 | $output[] = "word99′ word"; |
| | 450 | |
| | 451 | $input[] = "word99'word"; |
| | 452 | $output[] = "word99′word"; |
| | 453 | |
| | 454 | foreach($input as $key => $in) { |
| | 455 | $this->assertEquals( $output[$key], wptexturize( $in ) ); |
| | 456 | } |
| | 457 | } |
| | 458 | |
| | 459 | /** |
| | 460 | * Check all baseline patterns. If anything ever changes in wptexturize(), these tests may fail. |
| | 461 | * |
| | 462 | * @ticket 22692 |
| | 463 | */ |
| | 464 | function test_contractions() { |
| | 465 | $input = array(); |
| | 466 | $output = array(); |
| | 467 | |
| | 468 | // Apostrophe "in a word" becomes ’ (apos) |
| | 469 | |
| | 470 | $input[] = "word word's word"; |
| | 471 | $output[] = "word word’s word"; |
| | 472 | |
| | 473 | $input[] = "word word'. word"; // Quotes with outside punctuation could end with apostrophes instead of closing quotes (may affect i18n) |
| | 474 | $output[] = "word word’. word"; |
| | 475 | |
| | 476 | $input[] = "word ]'. word"; |
| | 477 | $output[] = "word ]’. word"; |
| | 478 | |
| | 479 | $input[] = "word )'. word"; |
| | 480 | $output[] = "word )’. word"; |
| | 481 | |
| | 482 | $input[] = "word }'. word"; |
| | 483 | $output[] = "word }’. word"; |
| | 484 | |
| | 485 | $input[] = "word >'. word"; // Not tested |
| | 486 | $output[] = "word >’. word"; |
| | 487 | |
| | 488 | $input[] = "word >'. word"; |
| | 489 | $output[] = "word >’. word"; |
| | 490 | |
| | 491 | foreach($input as $key => $in) { |
| | 492 | $this->assertEquals( $output[$key], wptexturize( $in ) ); |
| | 493 | } |
| | 494 | } |
| | 495 | |
| | 496 | /** |
| | 497 | * Check all baseline patterns. If anything ever changes in wptexturize(), these tests may fail. |
| | 498 | * |
| | 499 | * @ticket 22692 |
| | 500 | */ |
| | 501 | function test_opening_quote() { |
| | 502 | $input = array(); |
| | 503 | $output = array(); |
| | 504 | |
| | 505 | // Double quote after a space or ([{< becomes “ (opening_quote) if not followed by spaces |
| | 506 | |
| | 507 | $input[] = 'word "word word'; |
| | 508 | $output[] = 'word “word word'; |
| | 509 | |
| | 510 | $input[] = 'word ("word word'; |
| | 511 | $output[] = 'word (“word word'; |
| | 512 | |
| | 513 | $input[] = 'word ["word word'; |
| | 514 | $output[] = 'word [“word word'; |
| | 515 | |
| | 516 | $input[] = 'word <"word word'; // Invalid HTML input? |
| | 517 | $output[] = 'word <“word word'; |
| | 518 | |
| | 519 | $input[] = 'word <"word word'; // Valid HTML input triggers the closing quote pattern |
| | 520 | $output[] = 'word <”word word'; |
| | 521 | |
| | 522 | $input[] = 'word {"word word'; |
| | 523 | $output[] = 'word {“word word'; |
| | 524 | |
| | 525 | $input[] = '"word word'; |
| | 526 | $output[] = '“word word'; |
| | 527 | |
| | 528 | $input[] = 'word("word word'; |
| | 529 | $output[] = 'word(“word word'; |
| | 530 | |
| | 531 | $input[] = 'word["word word'; |
| | 532 | $output[] = 'word[“word word'; |
| | 533 | |
| | 534 | $input[] = 'word<"word word'; // Invalid HTML input? |
| | 535 | $output[] = 'word<“word word'; |
| | 536 | |
| | 537 | $input[] = 'word<"word word'; // Valid HTML input triggers the closing quote pattern |
| | 538 | $output[] = 'word<”word word'; |
| | 539 | |
| | 540 | $input[] = 'word{"word word'; |
| | 541 | $output[] = 'word{“word word'; |
| | 542 | |
| | 543 | $input[] = 'word "99 word'; |
| | 544 | $output[] = 'word “99 word'; |
| | 545 | |
| | 546 | foreach($input as $key => $in) { |
| | 547 | $this->assertEquals( $output[$key], wptexturize( $in ) ); |
| | 548 | } |
| | 549 | } |
| | 550 | |
| | 551 | /** |
| | 552 | * Check all baseline patterns. If anything ever changes in wptexturize(), these tests may fail. |
| | 553 | * |
| | 554 | * @ticket 22692 |
| | 555 | */ |
| | 556 | function test_closing_quote() { |
| | 557 | $input = array(); |
| | 558 | $output = array(); |
| | 559 | |
| | 560 | // Double quote becomes ” (closing_quote) unless it is already converted to double_prime or opening_quote. |
| | 561 | |
| | 562 | $input[] = 'word word" word'; |
| | 563 | $output[] = 'word word” word'; |
| | 564 | |
| | 565 | $input[] = 'word word") word'; |
| | 566 | $output[] = 'word word”) word'; |
| | 567 | |
| | 568 | $input[] = 'word word"] word'; |
| | 569 | $output[] = 'word word”] word'; |
| | 570 | |
| | 571 | $input[] = 'word word"} word'; |
| | 572 | $output[] = 'word word”} word'; |
| | 573 | |
| | 574 | $input[] = 'word word"> word'; // Invalid HTML input? |
| | 575 | $output[] = 'word word”> word'; |
| | 576 | |
| | 577 | $input[] = 'word word"> word'; // Valid HTML should work |
| | 578 | $output[] = 'word word”> word'; |
| | 579 | |
| | 580 | $input[] = 'word word"'; |
| | 581 | $output[] = 'word word”'; |
| | 582 | |
| | 583 | $input[] = 'word word"word'; |
| | 584 | $output[] = 'word word”word'; |
| | 585 | |
| | 586 | $input[] = 'word"word"word'; |
| | 587 | $output[] = 'word”word”word'; |
| | 588 | |
| | 589 | $input[] = 'test sentence".'; |
| | 590 | $output[] = 'test sentence”.'; |
| | 591 | |
| | 592 | $input[] = 'test sentence."'; |
| | 593 | $output[] = 'test sentence.”'; |
| | 594 | |
| | 595 | $input[] = 'test sentence". word'; |
| | 596 | $output[] = 'test sentence”. word'; |
| | 597 | |
| | 598 | $input[] = 'test sentence." word'; |
| | 599 | $output[] = 'test sentence.” word'; |
| | 600 | |
| | 601 | foreach($input as $key => $in) { |
| | 602 | $this->assertEquals( $output[$key], wptexturize( $in ) ); |
| | 603 | } |
| | 604 | } |
| | 605 | |
| | 606 | /** |
| | 607 | * Check all baseline patterns. If anything ever changes in wptexturize(), these tests may fail. |
| | 608 | * |
| | 609 | * @ticket 22692 |
| | 610 | */ |
| | 611 | function test_closing_single_quote() { |
| | 612 | $input = array(); |
| | 613 | $output = array(); |
| | 614 | |
| | 615 | // Single quote followed by a space or a period becomes ’ (closing_single_quote) |
| | 616 | |
| | 617 | $input[] = "word word' word"; |
| | 618 | $output[] = "word word’ word"; |
| | 619 | |
| | 620 | $input[] = "word word'. word"; |
| | 621 | $output[] = "word word’. word"; |
| | 622 | |
| | 623 | $input[] = "word word'.word"; |
| | 624 | $output[] = "word word’.word"; |
| | 625 | |
| | 626 | $input[] = "word word'"; |
| | 627 | $output[] = "word word’"; |
| | 628 | |
| | 629 | $input[] = "test sentence'."; |
| | 630 | $output[] = "test sentence’."; |
| | 631 | |
| | 632 | $input[] = "test sentence.'"; |
| | 633 | $output[] = "test sentence.’"; |
| | 634 | |
| | 635 | $input[] = "test sentence'. word"; |
| | 636 | $output[] = "test sentence’. word"; |
| | 637 | |
| | 638 | $input[] = "test sentence.' word"; |
| | 639 | $output[] = "test sentence.’ word"; |
| | 640 | |
| | 641 | foreach($input as $key => $in) { |
| | 642 | $this->assertEquals( $output[$key], wptexturize( $in ) ); |
| | 643 | } |
| | 644 | } |
| | 645 | |
| | 646 | /** |
| | 647 | * Check all baseline patterns. If anything ever changes in wptexturize(), these tests may fail. |
| | 648 | * |
| | 649 | * @ticket 22692 |
| | 650 | */ |
| | 651 | function test_multiplication() { |
| | 652 | $input = array(); |
| | 653 | $output = array(); |
| | 654 | |
| | 655 | // 9x9 becomes 9×9 |
| | 656 | |
| | 657 | $input[] = "9x9"; |
| | 658 | $output[] = "9×9"; |
| | 659 | |
| | 660 | $input[] = "12x34"; |
| | 661 | $output[] = "12×34"; |
| | 662 | |
| | 663 | $input[] = "9 x 9"; |
| | 664 | $output[] = "9 x 9"; |
| | 665 | |
| | 666 | foreach($input as $key => $in) { |
| | 667 | $this->assertEquals( $output[$key], wptexturize( $in ) ); |
| | 668 | } |
| | 669 | } |
| | 670 | |
| | 671 | /** |
| | 672 | * Check all baseline patterns. If anything ever changes in wptexturize(), these tests may fail. |
| | 673 | * |
| | 674 | * @ticket 22692 |
| | 675 | */ |
| | 676 | function test_ampersand() { |
| | 677 | $input = array(); |
| | 678 | $output = array(); |
| | 679 | |
| | 680 | // & always becomes & unless it is followed by # or ; |
| | 681 | |
| | 682 | $input[] = "word & word"; |
| | 683 | $output[] = "word & word"; |
| | 684 | |
| | 685 | $input[] = "word&word"; |
| | 686 | $output[] = "word&word"; |
| | 687 | |
| | 688 | $input[] = "word word"; |
| | 689 | $output[] = "word word"; |
| | 690 | |
| | 691 | $input[] = "word & word"; |
| | 692 | $output[] = "word & word"; |
| | 693 | |
| | 694 | $input[] = "word &# word"; |
| | 695 | $output[] = "word &# word"; // invalid output? |
| | 696 | |
| | 697 | $input[] = "word &44; word"; |
| | 698 | $output[] = "word &44; word"; |
| | 699 | |
| | 700 | foreach($input as $key => $in) { |
| | 701 | $this->assertEquals( $output[$key], wptexturize( $in ) ); |
| | 702 | } |
| | 703 | } |
| | 704 | |
| | 705 | /** |
| | 706 | * Check all baseline patterns. If anything ever changes in wptexturize(), these tests may fail. |
| | 707 | * |
| | 708 | * @ticket 22692 |
| | 709 | */ |
| | 710 | function test_cockney() { |
| | 711 | $input = array(); |
| | 712 | $output = array(); |
| | 713 | |
| | 714 | // "cockney" phrases begin with apos instead of opening_single_quote. |
| | 715 | |
| | 716 | $input[] = "word 'tain't word"; |
| | 717 | $output[] = "word ’tain’t word"; |
| | 718 | |
| | 719 | $input[] = "word 'twere word"; |
| | 720 | $output[] = "word ’twere word"; |
| | 721 | |
| | 722 | $input[] = "word 'twas word"; |
| | 723 | $output[] = "word ’twas word"; |
| | 724 | |
| | 725 | $input[] = "word 'tis word"; |
| | 726 | $output[] = "word ’tis word"; |
| | 727 | |
| | 728 | $input[] = "word 'twill word"; |
| | 729 | $output[] = "word ’twill word"; |
| | 730 | |
| | 731 | $input[] = "word 'til word"; |
| | 732 | $output[] = "word ’til word"; |
| | 733 | |
| | 734 | $input[] = "word 'bout word"; |
| | 735 | $output[] = "word ’bout word"; |
| | 736 | |
| | 737 | $input[] = "word 'nuff word"; |
| | 738 | $output[] = "word ’nuff word"; |
| | 739 | |
| | 740 | $input[] = "word 'round word"; |
| | 741 | $output[] = "word ’round word"; |
| | 742 | |
| | 743 | $input[] = "word 'cause word"; |
| | 744 | $output[] = "word ’cause word"; |
| | 745 | |
| | 746 | $input[] = "word 'em word"; |
| | 747 | $output[] = "word ‘em word"; |
| | 748 | |
| | 749 | foreach($input as $key => $in) { |
| | 750 | $this->assertEquals( $output[$key], wptexturize( $in ) ); |
| | 751 | } |
| | 752 | } |
| | 753 | |
| | 754 | /** |
| | 755 | * Check all baseline patterns. If anything ever changes in wptexturize(), these tests may fail. |
| | 756 | * |
| | 757 | * @ticket 22692 |
| | 758 | */ |
| | 759 | function test_smart_dashes() { |
| | 760 | $input = array(); |
| | 761 | $output = array(); |
| | 762 | |
| | 763 | // Smart dashes, etc |
| | 764 | |
| | 765 | $input[] = "word --- word"; |
| | 766 | $output[] = "word — word"; |
| | 767 | |
| | 768 | $input[] = "word---word"; |
| | 769 | $output[] = "word—word"; |
| | 770 | |
| | 771 | $input[] = "word -- word"; |
| | 772 | $output[] = "word — word"; |
| | 773 | |
| | 774 | $input[] = "word--word"; |
| | 775 | $output[] = "word–word"; |
| | 776 | |
| | 777 | $input[] = "word - word"; |
| | 778 | $output[] = "word – word"; |
| | 779 | |
| | 780 | $input[] = "word-word"; |
| | 781 | $output[] = "word-word"; |
| | 782 | |
| | 783 | $input[] = "word xn– word"; |
| | 784 | $output[] = "word xn-- word"; |
| | 785 | |
| | 786 | $input[] = "wordxn–word"; |
| | 787 | $output[] = "wordxn--word"; |
| | 788 | |
| | 789 | foreach($input as $key => $in) { |
| | 790 | $this->assertEquals( $output[$key], wptexturize( $in ) ); |
| | 791 | } |
| | 792 | } |
| | 793 | |
| | 794 | /** |
| | 795 | * Check all baseline patterns. If anything ever changes in wptexturize(), these tests may fail. |
| | 796 | * |
| | 797 | * @ticket 22692 |
| | 798 | */ |
| | 799 | function test_misc_static_replacements() { |
| | 800 | $input = array(); |
| | 801 | $output = array(); |
| | 802 | |
| | 803 | $input[] = "word ... word"; |
| | 804 | $output[] = "word … word"; |
| | 805 | |
| | 806 | $input[] = "word...word"; |
| | 807 | $output[] = "word…word"; |
| | 808 | |
| | 809 | $input[] = "word `` word"; |
| | 810 | $output[] = "word “ word"; |
| | 811 | |
| | 812 | $input[] = "word``word"; |
| | 813 | $output[] = "word“word"; |
| | 814 | |
| | 815 | $input[] = "word '' word"; |
| | 816 | $output[] = "word ” word"; |
| | 817 | |
| | 818 | $input[] = "word''word"; |
| | 819 | $output[] = "word”word"; |
| | 820 | |
| | 821 | $input[] = "word (tm) word"; |
| | 822 | $output[] = "word ™ word"; |
| | 823 | |
| | 824 | $input[] = "word (tm)word"; |
| | 825 | $output[] = "word ™word"; |
| | 826 | |
| | 827 | $input[] = "word(tm) word"; |
| | 828 | $output[] = "word(tm) word"; |
| | 829 | |
| | 830 | $input[] = "word(tm)word"; |
| | 831 | $output[] = "word(tm)word"; |
| | 832 | |
| | 833 | foreach($input as $key => $in) { |
| | 834 | $this->assertEquals( $output[$key], wptexturize( $in ) ); |
| | 835 | } |
| | 836 | } |
| | 837 | |
| | 838 | |
| | 839 | /** |
| | 840 | * All of these tests fail against 3.8 but were not yet listed above. |
| | 841 | * |
| | 842 | * @ticket 22692 |
| | 843 | */ |
| | 844 | function test_more_bugs() { |
| | 845 | $input = array(); |
| | 846 | $output = array(); |
| | 847 | |
| | 848 | // Tests derived from, and contrary to, the baseline patterns above, where output seemed unusual |
| | 849 | |
| | 850 | $input[] = "according to our source, '33% of all students scored less than 50' on the test."; |
| | 851 | $output[] = "according to our source, ‘33% of all students scored less than 50’ on the test."; |
| | 852 | |
| | 853 | $input[] = 'according to our source, "33% of all students scored less than 50" on the test.'; |
| | 854 | $output[] = 'according to our source, “33% of all students scored less than 50” on the test.'; |
| | 855 | |
| | 856 | $input[] = "word <'test quote'&rt; word"; |
| | 857 | $output[] = "word <‘test quote’&rt; word"; |
| | 858 | |
| | 859 | $input[] = 'word <"test quote"&rt; word'; |
| | 860 | $output[] = 'word <“test quote”&rt; word'; |
| | 861 | |
| | 862 | $input[] = "word 'em word"; |
| | 863 | $output[] = "word ’em word"; |
| | 864 | |
| | 865 | $input[] = "word xn– word"; |
| | 866 | $output[] = "word xn– word"; |
| | 867 | |
| | 868 | $input[] = "wordxn–word"; |
| | 869 | $output[] = "wordxn–word"; |
| | 870 | |
| | 871 | foreach($input as $key => $in) { |
| | 872 | $this->assertEquals( $output[$key], wptexturize( $in ) ); |
| | 873 | } |
| | 874 | } |
| | 875 | |
| | 876 | /** |
| | 877 | * Multiplication pattern in 3.8 will break HTML that contains matching server names or directories. |
| | 878 | * |
| | 879 | * @ticket 4116 |
| | 880 | */ |
| | 881 | function test_multiplication_in_urls() { |
| | 882 | $input = array(); |
| | 883 | $output = array(); |
| | 884 | |
| | 885 | $input[] = "www.4x3.com"; |
| | 886 | $output[] = "www.4x3.com"; |
| | 887 | |
| | 888 | $input[] = "4x3.domain.com"; |
| | 889 | $output[] = "4x3.domain.com"; |
| | 890 | |
| | 891 | $input[] = "<a href='http://www.24x7.com/'>http://www.24x7.com/</a>"; |
| | 892 | $output[] = "<a href='http://www.24x7.com/'>http://www.24x7.com/</a>"; |
| | 893 | |
| | 894 | $input[] = "<a href='http://www.domain.com/24x7/'>http://www.domain.com/24x7/</a>"; |
| | 895 | $output[] = "<a href='http://www.domain.com/24x7/'>http://www.domain.com/24x7/</a>"; |
| | 896 | |
| | 897 | foreach($input as $key => $in) { |
| | 898 | $this->assertEquals( $output[$key], wptexturize( $in ) ); |
| | 899 | } |
| | 900 | } |
| | 901 | |
| | 902 | /** |
| | 903 | * Shortcodes and smart quotes might conflict. Some of these appear to be fixed already. |
| | 904 | * |
| | 905 | * @ticket 6969 |
| | 906 | */ |
| | 907 | function test_quotes_in_shortcodes() { |
| | 908 | $input = array(); |
| | 909 | $output = array(); |
| | 910 | |
| | 911 | $input[] = '[caption]<img src="http://localhost/Great_Wave.jpg" alt="Great Wave" title="Great Wave" width="300" height="205" /> The Great Wave[/caption]'; |
| | 912 | $output[] = '[caption]<img src="http://localhost/Great_Wave.jpg" alt="Great Wave" title="Great Wave" width="300" height="205" /> The Great Wave[/caption]'; |
| | 913 | |
| | 914 | $input[] = '[code lang="php"]$foo = \'bar\';[/code]'; |
| | 915 | $output[] = '[code lang="php"]$foo = \'bar\';[/code]'; |
| | 916 | |
| | 917 | $input[] = '[foobar]This is how you "quote" things.[/foobar]'; |
| | 918 | $output[] = '[foobar]This is how you "quote" things.[/foobar]'; |
| | 919 | |
| | 920 | $input[] = "<pre>\n[[php foo=\"bar\"]\necho \"foo\" . 'bar';\n[/php]]\n</pre>"; |
| | 921 | $output[] = "<pre>\n[[php foo=\"bar\"]\necho \"foo\" . 'bar';\n[/php]]\n</pre>"; |
| | 922 | |
| | 923 | $input[] = "foo[shortcode]\n\"bar\"\n[/shortcode]foo"; |
| | 924 | $output[] = "foo[shortcode]\n\"bar\"\n[/shortcode]foo"; |
| | 925 | |
| | 926 | foreach($input as $key => $in) { |
| | 927 | $this->assertEquals( $output[$key], wptexturize( $in ) ); |
| | 928 | } |
| | 929 | } |
| | 930 | |
| | 931 | /** |
| | 932 | * User requested smart quotes not break when surrounded by dashes. |
| | 933 | * |
| | 934 | * @ticket 20342 |
| | 935 | */ |
| | 936 | function test_dashes_around_quotes() { |
| | 937 | $input = array(); |
| | 938 | $output = array(); |
| | 939 | |
| | 940 | // These may fail in 3.8 |
| | 941 | |
| | 942 | $input[] = 'word---"quote"'; |
| | 943 | $output[] = 'word—“quote”'; |
| | 944 | |
| | 945 | $input[] = 'word--"quote"'; |
| | 946 | $output[] = 'word–“quote”'; |
| | 947 | |
| | 948 | $input[] = 'word-"quote"'; |
| | 949 | $output[] = 'word-“quote”'; |
| | 950 | |
| | 951 | // These should pass already |
| | 952 | |
| | 953 | $input[] = '"quote"---word'; |
| | 954 | $output[] = '“quote”—word'; |
| | 955 | |
| | 956 | $input[] = '"quote"--word'; |
| | 957 | $output[] = '“quote”–word'; |
| | 958 | |
| | 959 | $input[] = '"quote"-word'; |
| | 960 | $output[] = '“quote”-word'; |
| | 961 | |
| | 962 | foreach($input as $key => $in) { |
| | 963 | $this->assertEquals( $output[$key], wptexturize( $in ) ); |
| | 964 | } |
| | 965 | } |
| | 966 | |
| | 967 | /** |
| | 968 | * Numbers after apostrophes are ambiguous due to the ambiguity of single quotes. |
| | 969 | * |
| | 970 | * @ticket 26850 |
| | 971 | */ |
| | 972 | function test_quotes_starting_with_digits() { |
| | 973 | $input = array(); |
| | 974 | $output = array(); |
| | 975 | |
| | 976 | $input[] = "in '4 years, 3 months,' Obama cut the deficit"; |
| | 977 | $output[] = "in ‘4 years, 3 months,’ Obama cut the deficit"; |
| | 978 | |
| | 979 | $input[] = "in '40 years, 3 months,' Obama cut the deficit"; |
| | 980 | $output[] = "in ‘40 years, 3 months,’ Obama cut the deficit"; |
| | 981 | |
| | 982 | $input[] = "in '400 years, 3 months,' Obama cut the deficit"; |
| | 983 | $output[] = "in ‘400 years, 3 months,’ Obama cut the deficit"; |
| | 984 | |
| | 985 | foreach($input as $key => $in) { |
| | 986 | $this->assertEquals( $output[$key], wptexturize( $in ) ); |
| | 987 | } |
| | 988 | } |