1#!/usr/bin/perl -w 2use strict; 3use Test::More; 4use Finance::Quote; 5 6if ( not $ENV{"ONLINE_TEST"} ) { 7 plan skip_all => 'Set $ENV{ONLINE_TEST} to run this test'; 8} 9 10my $q = Finance::Quote->new(); 11my $year = (localtime())[5] + 1900; 12my $lastyear = $year - 1; 13 14my @symbols = qw/MSFT AMZN AAPL GOOGL GOOG FB CSCO INTC PEP BRK-A SEB NVR BKNG IBKR/; 15 16plan tests => 11*(1+$#symbols)+2; 17 18my %quotes = $q->fool(@symbols, "BOGUS"); 19ok(%quotes); 20 21foreach my $symbol (@symbols) { 22 ok($quotes{$symbol, "symbol"} eq $symbol, "$symbol defined"); 23 ok($quotes{$symbol, "success"}, "$symbol success"); 24 ok($quotes{$symbol, "day_range"} =~ m/^[0-9.]+\s*-\s*[0-9.]+$/, "$symbol returned day_range"); 25 ok($quotes{$symbol, "open"} > 0, "$symbol returned open"); 26 ok($quotes{$symbol, "volume"} >= 0, "$symbol returned volume"); 27 ok($quotes{$symbol, "close"} > 0, "$symbol returned close"); 28 ok($quotes{$symbol, "year_range"} =~ m/^[0-9.]+\s*-\s*[0-9.]+$/, "$symbol returned year_range"); 29 ok($quotes{$symbol, "last"} > 0, "$symbol returned last"); 30 ok($quotes{$symbol, "currency"} eq 'USD', "$symbol returned currency"); 31 ok(substr($quotes{$symbol, "isodate"}, 0, 4) == $year 32 || substr($quotes{$symbol, "isodate"}, 0, 4) == $lastyear); 33 ok(substr($quotes{$symbol, "date"}, 6, 4) == $year 34 ||substr($quotes{$symbol, "date"}, 6, 4) == $lastyear); 35} 36 37ok(!$quotes{"BOGUS", "success"}); 38 39