File: test.pl

package info (click to toggle)
libmath-calculus-expression-perl 0.2.2.ds-4
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, forky, sid, trixie
  • size: 160 kB
  • sloc: perl: 1,221; sh: 51; makefile: 2
file content (28 lines) | stat: -rw-r--r-- 667 bytes parent folder | download | duplicates (4)
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
# Before `make install' is performed this script should be runnable with
# `make test'. After `make install' it should work as `perl test.pl'

use Test;
BEGIN { plan tests => 8 };

use Math::Calculus::Expression;
ok(1);

my $exp = Math::Calculus::Expression->new;
ok(ref $exp);

ok($exp->setExpression('2*x + a'));

ok($exp->getExpression eq '2*x + a');

ok($exp->evaluate(x => 20, a => 2) == 42);

my $exp2 = $exp->clone;
ok($exp->sameRepresentation($exp2));

$exp->setExpression('2*3*x');
$exp->simplify;
ok($exp->getExpression eq '6*x');

$exp->setExpression('x^(2+1) + 6*5*x');
$exp->simplify;
ok($exp->getExpression eq 'x^3 + 30*x');