Debian Codegraph @

wrappers/perl/t/03_errors.t

raw
1 #!/usr/bin/perl -w
2
3 use strict;
4 use warnings;
5 use Test::More tests => 15;
6 use Cwd;
7
8 use Xray::Feff;
9
10
11 my $epsilon = 1e-3;
12
13 my $path = Xray::Feff::Path->new();
14 ok(ref($path) =~ m{Feff::Path}, "object created ".$path);
15
16 ### test make_scatterer errors
17
18 $path->Index(10);
19 my $ret = $path->atom(0, 0, -3.61, -1);
20 ok($ret == 1, "ipot negative");
21
22 $path->clear;
23 ok($path->Index == 9999, "clear path works");
24 ok($path->wrapper->_index == 9999, "clear path works, wrapper");
25
26 $ret = $path->atom(0, 0, -3.61, 9);
27 ok($ret == 2, "ipot too big");
28
29
30 $path->clear;
31
32 $ret = $path->atom(1.805, 0, 1.805, 1);
33 $ret = $path->atom(1.805, 0, 1.905, 1);
34 ok($ret == 4, "atoms too close");
35
36 $path->clear;
37 ok($path->nleg == 0, "nleg set correctly after clear");
38
39
40 ### test make_path errors
41 $path->phbin('../fortran/phase_orig.pad');
42 $ret = $path->atom(0, 0, 0, 1);
43 $ret = $path->atom(1.805, 0, 1.805, 1);
44 $ret = $path->path;
45 ok($ret < 64, "phbin alias works");
46 ok($ret == 1, "first atom is absorber");
47 $path->clear;
48
49 $path->phpad('../fortran/phase_orig.pad');
50 $ret = $path->atom(1.805, 0, 1.805, 1);
51 $ret = $path->atom(0, 0, 0, 1);
52 $ret = $path->path;
53 ok($ret == 2, "last atom is absorber");
54 $path->clear;
55
56 $path->phpad('../fortran/phase_orig.pad');
57 $ret = $path->atom(0, 0, 3.61, 1);
58 $ret = $path->atom(1.805, 0, 1.805, 1);
59 $path->degen(-12.0);
60 $ret = $path->path;
61 ok($ret == 4, "degeneracy negative");
62 $path->clear;
63
64 $path->phpad('../fortran/phase_orig.pad');
65 $ret = $path->atom(0, 0, 3.61, 1);
66 $ret = $path->atom(1.805, 0, 1.805, 1);
67 $path->Index(40000);
68 $ret = $path->path;
69 ok($ret == 8, "Index too big");
70 $path->clear;
71
72 $path->phpad('../fortran/phase_orig.pad');
73 $ret = $path->atom(0, 0, 3.61, 1);
74 $ret = $path->atom(1.805, 0, 1.805, 1);
75 $path->elpty(-0.5);
76 $ret = $path->path;
77 ok($ret == 16, "elpty negative");
78 $path->clear;
79
80 $path->phpad('../fortran/phase_orig.pad');
81 $ret = $path->atom(0, 0, 3.61, 1);
82 $ret = $path->atom(1.805, 0, 1.805, 1);
83 $path->iorder(-1);
84 $ret = $path->path;
85 ok($ret == 32, "iorder negative");
86 $path->clear;
87
88 $path->phpad('../fortran/phase_orig.padX');
89 $ret = $path->atom(0, 0, 3.61, 1);
90 $ret = $path->atom(1.805, 0, 1.805, 1);
91 $ret = $path->path;
92 ok($ret == 64, "phpad not readable");
93 $path->clear;
94
95
96 undef $path;