Almost-minimal filesystem based blog.
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.

62 lines
976 B

  1. #!/usr/bin/env perl
  2. use strict;
  3. use warnings;
  4. use lib 'lib';
  5. use Data::Dumper;
  6. use Test::More tests => 1;
  7. use App::WRT::Sort qw(sort_entries);
  8. my @unsorted = (
  9. 'abc',
  10. 'chapbook',
  11. 'c',
  12. 'c/frobnicate',
  13. 'frobnicate',
  14. '2012/1/2',
  15. '2019/6/21',
  16. '2019/6/2',
  17. '2014/3/1/a',
  18. '2014/3/1/frobnicate',
  19. '2014/3/1/b',
  20. '1999/12/1',
  21. 'a/index',
  22. 'a/ind',
  23. 'a',
  24. '2019/6/11',
  25. '2019/6/1',
  26. 'b',
  27. 'supercalifragilisticexpialidociousceteradisestamblishmentarianism'
  28. );
  29. my $sorted = [
  30. '1999/12/1',
  31. '2012/1/2',
  32. '2014/3/1/a',
  33. '2014/3/1/b',
  34. '2014/3/1/frobnicate',
  35. '2019/6/1',
  36. '2019/6/2',
  37. '2019/6/11',
  38. '2019/6/21',
  39. 'a',
  40. 'abc',
  41. 'a/ind',
  42. 'a/index',
  43. 'b',
  44. 'c',
  45. 'c/frobnicate',
  46. 'chapbook',
  47. 'frobnicate',
  48. 'supercalifragilisticexpialidociousceteradisestamblishmentarianism'
  49. ];
  50. my (@result) = sort_entries(@unsorted);
  51. unless (is_deeply($sorted, \@result, "sort_entries() works, more or less")) {
  52. for (@result) {
  53. diag($_);
  54. }
  55. }