File: 08parse_hyperbolic.t

package info (click to toggle)
libmath-symbolic-perl 0.613-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 1,268 kB
  • sloc: perl: 12,638; makefile: 9
file content (48 lines) | stat: -rw-r--r-- 1,008 bytes parent folder | download | duplicates (6)
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
42
43
44
45
46
47
48
#!perl
use strict;
use warnings;

use Test::More tests => 4;

BEGIN {
	use_ok('Math::Symbolic');
}

if ($ENV{TEST_YAPP_PARSER}) {
	require Math::Symbolic::Parser::Yapp;
	$Math::Symbolic::Parser = Math::Symbolic::Parser::Yapp->new();
}

use Math::Symbolic::ExportConstants qw/:all/;

my $tree;
my $str;
undef $@;
eval <<'HERE';
$tree = Math::Symbolic->parse_from_string('sinh(2)');
HERE
$str = $tree->to_string();
$str =~ s/\s+//g;
ok( ( !$@ and $str eq 'sinh(2)' ), "Parsing hyperbolic sine" );

undef $@;
eval <<'HERE';
$tree = Math::Symbolic->parse_from_string('cosh(2)');
HERE
$str = $tree->to_string();
$str =~ s/\s+//g;
ok( ( !$@ and $str eq 'cosh(2)' ), 'Parsing hyperbolic cosine' );

undef $@;
eval <<'HERE';
$tree = Math::Symbolic->parse_from_string(
		'tan(log(cosh(2),sin(2*1*3+1*3)*sinh(0)))'
	);
HERE
$str = $tree->to_string();
$str =~ s/\s+//g;
ok(
    ( !$@ and $str eq 'tan(log(cosh(2),(sin(((2*1)*3)+(1*3)))*(sinh(0))))' ),
    'Parsing more complicated string involving sinh/cosh/tan.'
);