Text::Markdown::Discount
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

38 lines
1.3 KiB

  1. # Before `make install' is performed this script should be runnable with
  2. # `make test'. After `make install' it should work as `perl Text-Markdown-XS.t'
  3. #########################
  4. # change 'tests => 1' to 'tests => last_test_to_print';
  5. use ExtUtils::testlib;
  6. use Test::More qw(no_plan);
  7. BEGIN { use_ok('Text::Markdown::Discount') };
  8. #########################
  9. use FindBin qw($Bin);
  10. use Text::Diff;
  11. opendir(DIR, "$Bin/../xt/MarkdownTest_1.0.3/Tests");
  12. foreach my $testfile (grep { /\.text$/ } readdir(DIR)) {
  13. my $testname = $testfile;
  14. $testname =~ s{(.+)\.text$}{$1}i;
  15. open (EXPECTED, "$Bin/../xt/MarkdownTest_1.0.3/Tests/$testname" . '.html') or die "NO html file for $testname";
  16. my $expected = do {undef $/; <EXPECTED>};
  17. my $actual = `$Bin/../xt/MarkdownXS.pl '$Bin/../xt/MarkdownTest_1.0.3/Tests/$testfile'` or die "failed run MarkdownXS.pl $testfile";
  18. $expected =~ s{'}{'\\''}g; # escape ' chars for shell
  19. $actual =~ s{'}{'\\''}g;
  20. $expected = `echo '$expected' | tidy --show-body-only 1 --quiet 1 --show-warnings 0`;
  21. $actual = `echo '$actual' | tidy --show-body-only 1 --quiet 1 --show-warnings 0`;
  22. if ($actual eq $expected) {
  23. pass($testname);
  24. } else {
  25. fail($testname);
  26. diag diff \$expected, \$actual;
  27. }
  28. }