test20 613 B

123456789101112131415161718192021222324252627282930313233343536
  1. #!/usr/bin/perl
  2. #
  3. use strict;
  4. use warnings;
  5. use lib "..";
  6. use Tpl;
  7. my $pwd = `pwd`;
  8. chomp $pwd;
  9. my $tmp1 = "$pwd/$0_1.out";
  10. my $tmp2 = "$pwd/$0_2.out";
  11. my $tmp3 = "$pwd/$0_3.out";
  12. my ($c,@i);
  13. my $tpl = Tpl->tpl_map("A(S(ci#))",\$c,\@i,10);
  14. # make element 1
  15. $c = 97;
  16. @i = (0,1,2,3,4,5,6,7,8,9);
  17. $tpl->tpl_pack(1);
  18. # make element 2
  19. $c = 98;
  20. @i = (1,2,3,4,5,6,7,8,9,10);
  21. $tpl->tpl_pack(1);
  22. $tpl->tpl_dump($tmp1);
  23. `../tplxml $tmp1 > $tmp2`; # convert tpl to xml
  24. `../tplxml $tmp2 > $tmp3`; # convert xml back to tpl
  25. `diff $tmp1 $tmp3`;
  26. print "tpl files ", ($? ? "differ" : "identical"), "\n";