home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / perl560.zip / t / op / args.t < prev    next >
Text File  |  1999-09-19  |  1KB  |  55 lines

  1. #!./perl
  2.  
  3. print "1..8\n";
  4.  
  5. # test various operations on @_
  6.  
  7. my $ord = 0;
  8. sub new1 { bless \@_ }
  9. {
  10.     my $x = new1("x");
  11.     my $y = new1("y");
  12.     ++$ord;
  13.     print "# got [@$y], expected [y]\nnot " unless "@$y" eq "y";
  14.     print "ok $ord\n";
  15.     ++$ord;
  16.     print "# got [@$x], expected [x]\nnot " unless "@$x" eq "x";
  17.     print "ok $ord\n";
  18. }
  19.  
  20. sub new2 { splice @_, 0, 0, "a", "b", "c"; return \@_ }
  21. {
  22.     my $x = new2("x");
  23.     my $y = new2("y");
  24.     ++$ord;
  25.     print "# got [@$x], expected [a b c x]\nnot " unless "@$x" eq "a b c x";
  26.     print "ok $ord\n";
  27.     ++$ord;
  28.     print "# got [@$y], expected [a b c y]\nnot " unless "@$y" eq "a b c y";
  29.     print "ok $ord\n";
  30. }
  31.  
  32. sub new3 { goto &new1 }
  33. {
  34.     my $x = new3("x");
  35.     my $y = new3("y");
  36.     ++$ord;
  37.     print "# got [@$y], expected [y]\nnot " unless "@$y" eq "y";
  38.     print "ok $ord\n";
  39.     ++$ord;
  40.     print "# got [@$x], expected [x]\nnot " unless "@$x" eq "x";
  41.     print "ok $ord\n";
  42. }
  43.  
  44. sub new4 { goto &new2 }
  45. {
  46.     my $x = new4("x");
  47.     my $y = new4("y");
  48.     ++$ord;
  49.     print "# got [@$x], expected [a b c x]\nnot " unless "@$x" eq "a b c x";
  50.     print "ok $ord\n";
  51.     ++$ord;
  52.     print "# got [@$y], expected [a b c y]\nnot " unless "@$y" eq "a b c y";
  53.     print "ok $ord\n";
  54. }
  55.