[add SumFile regression test. make regress.prl pass stdin to programs when it exists
John Meacham <john@repetae.net>**20070302025019] adddir ./regress/tests/3_shootout
hunk ./regress/regress.prl 9
+use Cwd;
hunk ./regress/regress.prl 21
+my $opt_clean;
hunk ./regress/regress.prl 24
-GetOptions( 'm=s' => \@mopts, 'f=s' => \@fopts, 'o=s' => \@opts, l => \$opt_l, n => \$opt_n, p => \$opt_p, 'rts=s' =>\@opt_rts  ) or die "Invalid options";
+GetOptions(
+    'm=s' => \@mopts,
+    'f=s' => \@fopts,
+    'o=s' => \@opts,
+    l => \$opt_l,
+    n => \$opt_n,
+    p => \$opt_p,
+    'rts=s' =>\@opt_rts,
+    clean => \$opt_clean
+    ) or die "Invalid options";
hunk ./regress/regress.prl 46
-my $pwd = `pwd`;
-chomp $pwd;
+my $pwd = cwd();
hunk ./regress/regress.prl 176
-            my $run_cmd = "$fbase " . join(" ",@args) . " > $result->{run_stdout}";
+            my $stdin = " < $fbase.stdin" if -f "$fbase.stdin";
+            my $run_cmd = "$fbase " . join(" ",@args) . " > $result->{run_stdout}" . $stdin;
addfile ./regress/tests/3_shootout/SumFile.expected_stdout
hunk ./regress/tests/3_shootout/SumFile.expected_stdout 1
+12
addfile ./regress/tests/3_shootout/SumFile.hs
hunk ./regress/tests/3_shootout/SumFile.hs 1
+--
+-- The Computer Language Shootout
+-- http://shootout.alioth.debian.org/
+--
+-- compile with : ghc fastest.hs -o fastest
+--
+-- contributed by Greg Buchholz
+-- Modified by Mirko Rahn, Don Stewart, Chris Kuklewicz and Lemmih
+--
+import Data.Char
+
+main = print . new 0 =<< getContents
+
+new i []       = i
+new i ('-':xs) = neg 0 xs
+    where neg n ('\n':xs) = new (i - n) xs
+          neg n (x   :xs) = neg (parse x + (10 * n)) xs
+new i (x:xs) = pos (parse x) xs
+    where pos n ('\n':xs) = new (i + n) xs
+          pos n (x   :xs) = pos (parse x + (10 * n)) xs
+
+parse c = ord c - ord '0'
addfile ./regress/tests/3_shootout/SumFile.stdin
hunk ./regress/tests/3_shootout/SumFile.stdin 1
+3
+4
+5