Files
gnucash/lib/Finance-Quote-1.05/t/asx.t
Dave Peticolas f387ae896c Ben Stanley's patch updating the version of Finance::Quote in lib/.
git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@3851 57a11ea4-9604-0410-9ed3-97b8803252fd
2001-03-29 07:43:37 +00:00

41 lines
1005 B
Perl
Executable File

#!/usr/bin/perl -w
use strict;
use Test;
BEGIN {plan tests => 11};
use Finance::Quote;
# Test ASX functions.
my $q = Finance::Quote->new();
$q->timeout(120); # ASX is broken regularly, so timeouts are good.
my %quotes = $q->asx("CML","BHP");
ok(%quotes);
# Check the last values are defined. These are the most used and most
# reliable indicators of success.
ok($quotes{"CML","last"} > 0);
ok($quotes{"CML","success"});
ok($quotes{"BHP","last"} > 0);
ok($quotes{"BHP","success"});
# Exercise the fetch function a little.
%quotes = $q->fetch("asx","ITE");
ok(%quotes);
ok($quotes{"ITE","last"} > 0);
ok($quotes{"ITE","success"} > 0);
# Check that we're getting currency information.
ok($quotes{"ITE", "currency"} eq "AUD");
# Check we're not getting bogus percentage signs.
$quotes{"ITE","p_change"} ||= ""; # Avoid warning if undefined.
ok($quotes{"ITE","p_change"} !~ /%/);
# Check that looking up a bogus stock returns failure:
%quotes = $q->asx("BOG");
ok(! $quotes{"BOG","success"});