#!/usr/bin/perl -w # # This file is part of Lingua-AtD # # This software is copyright (c) 2011 by David L. Day. # # This is free software; you can redistribute it and/or modify it under # the same terms as the Perl 5 programming language system itself. # use Test::More; use Test::Exception; plan tests => 11; my $xml_good = ' spell hyphenate 1 spell misused words 4 spell raw 28 stats sentences 351 stats words 4683 stats bias language 1 style complex phrases 7 style hidden verbs 1 style passive voice 7 '; my $xml_exception = ' This is a description of what went wrong '; use_ok('Lingua::AtD::Scores'); my $atd_results = Lingua::AtD::Scores->new( { xml => $xml_good } ); isa_ok( $atd_results, 'Lingua::AtD::Scores' ); is( $atd_results->get_xml, $xml_good, ' get_xml() [good]' ); is( $atd_results->has_server_exception, 0, ' has_service_exception() [good]' ); is( $atd_results->get_server_exception, undef, ' get_service_exception() [good]' ); is( $atd_results->has_metrics, 1, ' has_metrics() [good]' ); is( $atd_results->get_metrics, 9, ' get_metrics() [good]' ); throws_ok( sub { Lingua::AtD::Scores->new( { xml => $xml_exception } ) }, 'Lingua::AtD::ServiceException', 'Service Exception thrown' ); my $atd_exception = Exception::Class->caught('Lingua::AtD::ServiceException'); isa_ok( $atd_exception, 'Lingua::AtD::ServiceException' ); is( $atd_exception->description, 'Indicates the AtD service returned an error message.', 'description() [exception]' ); is( $atd_exception->service_message, 'This is a description of what went wrong', 'service_message() [exception]' ); done_testing;