/[ff3d]/ff3d/testsuite/check.ph
ViewVC logotype

Diff of /ff3d/testsuite/check.ph

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.1 by lehyaric, Fri Jul 18 08:34:01 2003 UTC revision 1.2 by lehyaric, Fri Jul 18 12:37:50 2003 UTC
# Line 7  $errors = 0; Line 7  $errors = 0;
7  # ff3d execution trace  # ff3d execution trace
8  $output = '';  $output = '';
9    
10    # Creates a file with the given filename and contents
11    
12    sub WriteFile{
13        my($name,$contents) = @_;
14    
15        open FILE,"> $name";
16        print FILE $contents;
17        close FILE;
18    }
19    
20  # Runs ff3d on the program given as parameter  # Runs ff3d on the program given as parameter
21    
22  sub Run{  sub Run{
# Line 23  sub Run{ Line 33  sub Run{
33  }  }
34    
35  # Checks that one expected result (expressed as a regexp) is present  # Checks that one expected result (expressed as a regexp) is present
36  # in $output.  # in $output. Regexp matches use the /m modifier so that ^ and $
37    # identify to he extremities of one line.
38    
39  sub Check{  sub LineCheck{
40      my ($expect) = @_;      my ($expect) = @_;
41      if($output !~ /$expect/){      if($output !~ /$expect/m){
42          print "*** Error: \"$expect\" not found\n";          print "*** Error: \"$expect\" not found\n";
43          $errors += 1;          $errors += 1;
44      }      }
# Line 86  sub Report{ Line 97  sub Report{
97      }      }
98  }  }
99    
100    # Builds the given povray scene, read it in ff3d and checks wether the
101    # given signature is ok.
102    
103    sub SceneCheck{
104        my ($povray,$signature)  =@_;
105        WriteFile('test.pov',$povray);
106    
107        # Builds a ff3d script that loads the scene in and checks its
108        # indicator function on points spread evenly on a unit cube (from
109        # (-1,-1,-1) to (1,1,1)).
110    
111        my $script = "scene S = pov(\"test.pov\");\n";
112        for(my $x = -1;$x <= 1;$x++){
113            for(my $y = -1;$y <= 1;$y++){
114                for(my $z = -1;$z <= 1;$z++){
115                    $script .= "cout << $x << \",\" << $y << \",\" << $z;\n"
116                        ."cout << \":\" << one(<1,0,0>)($x,$y,$z) << \"\\n\";\n\n";
117                }
118            }
119        }
120    
121        Run($script);
122    
123        # Tests all lines in the signature separately, just to make error
124        # reports more precise.
125        my @sig = split /\n/,$signature;
126        foreach my $line (@sig){
127            LineCheck('^'.$line.'$');
128        }
129    }
130    
131  1;  1;

Legend:
Removed from v.1.1  
changed lines
  Added in v.1.2

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26