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