# this works as a bash include
#
#PRIO 1.1
#COMM Math::Geomet2dPoint
#COMM - check behaviour of reference->string conversion
#COMM - run method string()
#COMM - check overload of data structure conversion (@{},%{})
#COMM   requires &DataPrint for data display
#COMM - output object via &DataPrint
#
function homogaddr {
  perl -n -e 's/(ARRAY|HASH)\(0x\w{5,8}\)/$1(0x123ABC)/; print' "$@"
}
perl -e '
  use lib shift();  # give include precedence to code directory, perl -I would not work!
  use strict;
  use MainLib::Data;
  use Math::Geomet2dPoint;
  my $pPt = Math::Geomet2dPoint->new(0.3,1.5);
  printf "point ref: %s\n", ref($pPt)||q("");
  my $pPt2=$pPt;
  printf "point ref assignment: %s\n",
    (sprintf(q(%s),$pPt) eq sprintf(q(%s),$pPt2)) ? q(OK):q(ERROR);
  printf "point address: %s\n", $pPt||q("");
  printf "point copy, basic function / unequal to source: %s/%s\n",
    $pPt->clone()=~m/ARRAY\(0x[a-z0-9]{5,8}\)$/?q(OK):q(ERROR),
    (sprintf(q(%s),$pPt->clone()) ne sprintf(q(%s),$pPt)) ? q(OK):q(ERROR);
  printf "point copy, method alias: %s\n",
    $pPt->copy()=~m/ARRAY\(0x[a-z0-9]{5,8}\)$/?q(OK):q(ERROR);
  printf "point as string: %s\n", $pPt->string();
  printf "point as string, custom label: %s\n", $pPt->string(-label=>q(vector));
  printf "point as string, fully customised: %s\n",
    $pPt->string(-fmt=>q(vector2D(%.2f,%.2f)));
  printf "point as an ARRAY:\n"; &DataPrint ([ @$pPt ],-space=>2,-NoAddr=>1);
  printf "point as a HASH:\n"; &DataPrint({ %$pPt },-space=>2,-NoAddr=>1);
  printf "point via \&DataPrint:\n"; &DataPrint([ $pPt ],-space=>2,-NoAddr=>1);
  ' -- "$dircode"  \
| homogaddr
