~ubuntu-branches/ubuntu/lucid/pdl/lucid

« back to all changes in this revision

Viewing changes to Basic/Test/tests.pd

  • Committer: Bazaar Package Importer
  • Author(s): Ben Gertzfield
  • Date: 2002-04-08 18:47:16 UTC
  • Revision ID: james.westby@ubuntu.com-20020408184716-0hf64dc96kin3htp
Tags: upstream-2.3.2
ImportĀ upstreamĀ versionĀ 2.3.2

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
pp_addpm({At=>Top},<<'EOPM');
 
2
 
 
3
=head1 NAME
 
4
 
 
5
PDL::Tests - tests for some PP features
 
6
 
 
7
=head1 SYNOPSIS
 
8
 
 
9
  use PDL::Tests;
 
10
 
 
11
  <test code>
 
12
 
 
13
=head1 DESCRIPTION
 
14
 
 
15
This module provides some PP defined test functions that are
 
16
supposed to test some features/bugs of PDL::PP.
 
17
 
 
18
Strictly speaking this module shouldn't be installed with a
 
19
'make install' but I haven't yet worked out how to do it.
 
20
 
 
21
=cut
 
22
 
 
23
EOPM
 
24
 
 
25
sub pp_deft {
 
26
    my ($name,%hash) = @_;
 
27
##    $hash{Doc} = "=for ref\n\ninternal\n\nonly for internal testing purposes\n";
 
28
    $hash{Doc} = undef;
 
29
    $name = "test_$name";  # prepend test_ to name
 
30
    pp_def($name,%hash);
 
31
}
 
32
 
 
33
pp_addhdr('
 
34
/* to test the $P vaffining */
 
35
void ppcp(PDL_Byte *dst, PDL_Byte *src, int len)
 
36
{
 
37
  int i;
 
38
 
 
39
  for (i=0;i<len;i++)
 
40
     *dst++=*src++;
 
41
}
 
42
');
 
43
 
 
44
# test the $P vaffine behaviour
 
45
# when 'phys' flag is in.
 
46
pp_deft('foop',
 
47
        Pars => 'byte [phys]a1(n); byte [o,phys]b(n)',
 
48
        GenericTypes => [B],
 
49
        Code => 'ppcp($P(b),$P(a1),$SIZE(n));',
 
50
);
 
51
 
 
52
# now in primitive.pd
 
53
#
 
54
# double qualifier
 
55
#pp_deft(
 
56
#       'dsumover',
 
57
#       Pars => 'a1(n); double [o]b();',
 
58
#       Code => 'PDL_Double tmp = 0;
 
59
#        loop(n) %{ tmp += $a1(); %}
 
60
#        $b() = tmp;'
 
61
#);
 
62
 
 
63
# float qualifier
 
64
# and also test if numerals in variable name work
 
65
pp_deft(
 
66
        'fsumover',
 
67
        Pars => 'a1(n); float [o]b();',
 
68
        Code => 'PDL_Float tmp = 0;
 
69
         loop(n) %{ tmp += $a1(); %}
 
70
         $b() = tmp;'
 
71
);
 
72
 
 
73
# test GENERIC with type+ qualifier
 
74
pp_deft(
 
75
        'nsumover',
 
76
        Pars => 'a(n); int+ [o]b();',
 
77
        Code => '$GENERIC(b) tmp = 0;
 
78
         loop(n) %{ tmp += $a(); %}
 
79
         $b() = tmp;'
 
80
);
 
81
 
 
82
# test to set named dim with 'OtherPar'
 
83
pp_deft('setdim',
 
84
        Pars => '[o] a(n)',
 
85
        OtherPars => 'int ns => n',
 
86
        Code => 'loop(n) %{ $a() = n; %}',
 
87
);
 
88
 
 
89
# according to Karl this segvs with certain pdls
 
90
 
 
91
pp_deft('fooseg',
 
92
        Pars => 'a(n);  [o]b(n);',
 
93
        Code => '
 
94
           loop(n) %{ $b() = $a(); %}
 
95
');
 
96
 
 
97
 
 
98
pp_done;