-
Notifications
You must be signed in to change notification settings - Fork 41
/
inline-comment-test.t
105 lines (85 loc) · 2.74 KB
/
inline-comment-test.t
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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
# This test checks that multiline comments in user code does not cause
# compilation errors. Strictly speaking, this is not really an Inline test,
# but Inline happens to provide the simplest framework for performing these
# tests. :-)
# -- DCM, April 16, 2012
use strict;
use warnings;
use Test::More;
use PDL::LiteF;
# First some Inline administivia.
BEGIN {
# Check for BSD platforms
plan skip_all => 'Known problem: sf.net bug #3518190, t/inline-comment-test.t fails for BSD'
if $^O =~ /(bsd|dragonfly)$/i;
# Test for Inline and set options
my $inline_test_dir = './.inlinepdlpp';
mkdir $inline_test_dir unless -d $inline_test_dir;
# See if Inline loads without trouble, or bail out
eval {
require Inline;
Inline->import (Config => DIRECTORY => $inline_test_dir , FORCE_BUILD => 1);
1;
} or do {
plan skip_all => "Skipped: Inline not installed";
};
# Make sure we have a recent enough version of Inline
eval q{
use Inline 0.43;
1;
} or do {
plan skip_all => 'Unable to load a new enough version of Inline';
};
# All clear, so declare the three tests
plan tests => 3;
}
SKIP: {
# use Inline 'INFO'; # use to generate lots of info
eval { Inline->bind(Pdlpp => <<'EOF') };
# simple PP definition with user irritation tests :-)
pp_def('testinc',
Pars => 'a(); [o] b()',
Code => q{
/* emulate user debugging */
/* Why doesn't this work???!!!! */
threadloop %{
/* printf(" %f, %f\r", $a(), $b());
printf(" Here\n");
*/
/* Sanity check */
$b() = $a() + 1;
%}
},
);
# make sure that if the word "threadloop" appears, later automatic threadloops
# will not be generated, even if the original threadloop was commented-out
pp_def('testinc2',
Pars => 'a(); [o] b()',
Code => q{
/* emulate user debugging */
/* Why doesn't this work???!!!! */
/* threadloop %{
printf(" %f, %f\r", $a(), $b());
printf(" Here\n");
%}
*/
/* Sanity check */
$b() = $a() + 1;
},
);
EOF
is $@, '', 'compiled' or skip 'bind failed', 2;
$a = sequence(3,3);
$b = $a->testinc;
ok(all ($b == $a+1), 'Sanity check runs correctly');
# Test the inability to comment-out a threadloop. This is documented on the
# 11th page of the PDL::PP chapter of the PDL book. If somebody ever fixes this
# wart, this test will fail, in which case the book's text should be updated.
$b = $a->testinc2;
TODO: {
# Note: This test appears to fail on Cygwin and some flavors of Linux.
local $TODO = 'This test inexplicably passes on some machines';
ok(not (all $b == $a + 1), 'WART: commenting out a threadloop does not work')
or diag("\$a is $a and \$b is $b");
}
}