File: 20_dividends.t

package info (click to toggle)
libfinance-quotehist-perl 1.19-1
  • links: PTS
  • area: main
  • in suites: wheezy
  • size: 428 kB
  • sloc: perl: 1,940; makefile: 4
file content (41 lines) | stat: -rw-r--r-- 1,015 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
use strict;

my $tcount;
BEGIN { $tcount = 6 }
use Test::More tests => $tcount;

use FindBin;
use lib $FindBin::RealBin;

use testload;

SKIP: {
  skip("dividend (no connect)", $tcount) unless network_ok();
  for my $src (sources()) {
    SKIP: {
      my($m, $sym, $start, $end, $dat) = basis($src, 'dividend');
      next unless $m;
      skip("(dev only) dividend $src test", 2)
        unless DEV_TESTS || $src eq GOLDEN_CHILD;
      eval "use $m";
      my %parms = ( class => $m );
      dividend_cmp(
        $sym, $start, $end,
        "direct dividend ($src)",
        $dat, %parms
      );
    }
  }
}

sub dividend_cmp {
  @_ >= 5 or die "Problem with args\n";
  my($symbol, $start_date, $end_date, $label, $dat, %parms) = @_;
  my $q = new_quotehist($symbol, $start_date, $end_date, %parms);
  my @rows = $q->dividends;
  cmp_ok(scalar @rows, '==', scalar @$dat, "$label (rows)");
  for my $i (0 .. $#rows) {
    $rows[$i] = join(':', @{$rows[$i]});
  }
  is_deeply(\@rows, $dat, "$label (content)");
}