| 1 | use strict; use warnings; |
| 2 | use Test::More; |
| 3 | use Config; |
| 4 | # Stop f77-linking causing spurious undefined symbols (alpha) |
| 5 | $ENV{'PERL_DL_NONLAZY'}=0 if $Config{'osname'} eq "dec_osf"; |
| 6 | require PGPLOT; |
| 7 | |
| 8 | my $dev = $ENV{PGPLOT_DEV} || '/NULL'; |
| 9 | |
| 10 | $ENV{PGPLOT_XW_WIDTH}=0.3; |
| 11 | |
| 12 | PGPLOT::pgbegin(0,$dev,2,2); |
| 13 | |
| 14 | PGPLOT::pgsci(3); PGPLOT::pgscf(2); PGPLOT::pgsch(1.4); |
| 15 | |
| 16 | my $pi=3.141592654; |
| 17 | |
| 18 | # Anonymous subs! |
| 19 | |
| 20 | PGPLOT::pgfunx(sub{ sqrt($_[0]) }, 500, 0, 10, 0); |
| 21 | PGPLOT::pgfuny(sub{ sin(4*$_[0]) }, 360, 0, 2*$pi, 0); |
| 22 | |
| 23 | # Pass by name and pass by reference |
| 24 | |
| 25 | PGPLOT::pgfunt("funt_x", "funt_y", 360,0, 2*$pi, 0); |
| 26 | PGPLOT::pgfunt(\&funt_x2, \&funt_y2, 360,0, 2*$pi, 0); |
| 27 | |
| 28 | PGPLOT::pgend(); |
| 29 | |
| 30 | pass; |
| 31 | done_testing; |
| 32 | |
| 33 | sub funt_x { |
| 34 | my($t)=$_[0]; |
| 35 | return cos($t);; |
| 36 | } |
| 37 | |
| 38 | sub funt_y { |
| 39 | my($t)=$_[0]; |
| 40 | return sin($t); |
| 41 | } |
| 42 | |
| 43 | sub funt_x2 { |
| 44 | my($t)=$_[0]; |
| 45 | return cos(4*$t)*cos($t);; |
| 46 | } |
| 47 | |
| 48 | sub funt_y2 { |
| 49 | my($t)=$_[0]; |
| 50 | return cos(4*$t)*sin($t); |
| 51 | } |