Introduction
Introduction Statistics Contact Development Disclaimer Help
tadd regression tests and sync man examples to current output - numtools - perf…
git clone git://src.adamsgaard.dk/numtools
Log
Files
Refs
README
LICENSE
---
commit 9f42d7162848c39ca7c71a57aa9e2d9a5fd3c5e3
parent 8787e852ca96ee9c18d4ed1a45016996e464940a
Author: Anders Damsgaard <[email protected]>
Date: Wed, 11 May 2022 15:57:48 +0200
add regression tests and sync man examples to current output
Diffstat:
A condfail | 7 +++++++
M max.1 | 2 +-
M mean.1 | 2 +-
M min.1 | 2 +-
M randcounts.1 | 2 +-
M randnum.1 | 2 +-
M range.1 | 2 +-
M rangetest.1 | 8 ++++----
M stddev.1 | 2 +-
M stdvar.1 | 2 +-
M sum.1 | 2 +-
A test.sh | 95 ++++++++++++++++++++++++++++++
12 files changed, 115 insertions(+), 13 deletions(-)
---
diff --git a/condfail b/condfail
t@@ -0,0 +1,7 @@
+#!/usr/bin/awk -f
+BEGIN {
+ if (ARGV[1] < 1.5)
+ exit 0
+ else
+ exit 1
+}
diff --git a/max.1 b/max.1
t@@ -24,7 +24,7 @@ Separate output values by
The default delimiter is tab characters.
.It Fl n
Do not print a newline after the final value.
-.It Fl p prec
+.It Fl p Ar prec
Print the output values with
.Ar prec
digits of precision.
diff --git a/mean.1 b/mean.1
t@@ -23,7 +23,7 @@ Separate output values by
The default delimiter is tab characters.
.It Fl n
Do not print a newline after the final value.
-.It Fl p prec
+.It Fl p Ar prec
Print the output values with
.Ar prec
digits of precision.
diff --git a/min.1 b/min.1
t@@ -24,7 +24,7 @@ Separate output values by
The default delimiter is tab characters.
.It Fl n
Do not print a newline after the final value.
-.It Fl p prec
+.It Fl p Ar prec
Print the output values with
.Ar prec
digits of precision.
diff --git a/randcounts.1 b/randcounts.1
t@@ -46,7 +46,7 @@ The default is 1.
Repeat the binning several times, with one realization per line of output.
.It Fl R
Show the output as ratios (in the range [0;1]) instead of counts.
-.It Fl p prec
+.It Fl p Ar prec
Print the output values with
.Ar prec
digits of precision.
diff --git a/randnum.1 b/randnum.1
t@@ -49,7 +49,7 @@ The default delimiter is newlines.
Do not print a newline after the final value.
.It Fl N num
Number of random points to generate.
-.It Fl p prec
+.It Fl p Ar prec
Print the output values with
.Ar prec
digits of precision.
diff --git a/range.1 b/range.1
t@@ -66,7 +66,7 @@ Do not print a newline after the final value.
.It Fl N Ar num
Number of values to produce within the specified range.
The default is 10.
-.It Fl p prec
+.It Fl p Ar prec
Print the output values with
.Ar prec
digits of precision.
diff --git a/rangetest.1 b/rangetest.1
t@@ -54,8 +54,8 @@ shows all parameter values which result in a successful invo…
.Dl 0
.Dl 1.25
.Dl 1.40625
-.Dl 1.48438
-.Dl 1.49414
+.Dl 1.484375
+.Dl 1.494140625
.Pp
The values associated with failed invocations are printed in standard error:
.Dl $ rangetest './condfail @VAL@' 0.0 10.0 >/dev/null
t@@ -64,8 +64,8 @@ The values associated with failed invocations are printed in…
.Dl 2.5
.Dl 1.875
.Dl 1.5625
-.Dl 1.52344
-.Dl 1.50391
+.Dl 1.5234375
+.Dl 1.50390625
.Pp
While the above values all result in a successful invocation of
.Ar cmd ,
diff --git a/stddev.1 b/stddev.1
t@@ -26,7 +26,7 @@ Separate output values by
The default delimiter is tab characters.
.It Fl n
Do not print a newline after the final value.
-.It Fl p prec
+.It Fl p Ar prec
Print the output values with
.Ar prec
digits of precision.
diff --git a/stdvar.1 b/stdvar.1
t@@ -26,7 +26,7 @@ Separate output values by
The default delimiter is tab characters.
.It Fl n
Do not print a newline after the final value.
-.It Fl p prec
+.It Fl p Ar prec
Print the output values with
.Ar prec
digits of precision.
diff --git a/sum.1 b/sum.1
t@@ -23,7 +23,7 @@ Separate output values by
The default delimiter is tab characters.
.It Fl n
Do not print a newline after the final value.
-.It Fl p prec
+.It Fl p Ar prec
Print the output values with
.Ar prec
digits of precision.
diff --git a/test.sh b/test.sh
t@@ -0,0 +1,95 @@
+#!/bin/sh
+
+strtest()
+{
+ if ! test "$2" = "$3"
+ then
+ printf 'FAIL: %s: %s != %s\n' "$1" "$2" "$3"
+ fi
+}
+
+strtest range_man "0.20000000000000001
+0.40000000000000002
+0.60000000000000009
+0.80000000000000004" "$(./range -be -N 4)"
+strtest range_man "1 2 3" "$(./range -d' ' -N 3 1 3)"
+strtest range_man "1
+10
+100" "$(./range -l -N 3 0 2)"
+strtest range_man "-2
+-1.5
+-1" "$(./range -N 3 -- -2 -1)"
+strtest range "0
+0.1111111111111111
+0.22222222222222221
+0.33333333333333331
+0.44444444444444442
+0.55555555555555558
+0.66666666666666663
+0.77777777777777768
+0.88888888888888884
+1" "$(./range)"
+strtest range "0 0.33333333333333331 0.66666666666666663 1" "$(./range -n -d' …
+strtest range "0 0.33 0.67 1" "$(./range -n -p 2 -d' ' -N 4)"
+strtest range "0.25 0.5 0.75 1" "$(./range -b -p 2 -d' ' -N 4)"
+strtest range "0 0.25 0.5 0.75" "$(./range -e -p 2 -d' ' -N 4)"
+strtest range_man "0
+0.33333333333333331
+0.66666666666666663
+1" "$(./range -N 4)"
+
+strtest max_man "4 5 6" "$(printf '1\t2\t3\n4\t5\t6\n' | ./max)"
+strtest max "4,5,6" "$(printf '1\t2\t3\n4\t5\t6\n' | ./max -d',')"
+strtest max "1" "$(./range | ./max)"
+strtest max "0.90909090909090917" "$(./range -be | ./max)"
+strtest max "0.909" "$(./range -be | ./max -p 3 )"
+
+strtest mean_man "2.5 3.5 4.5" "$(printf '1\t2\t3\n4\t5\t6\n' | …
+strtest mean "2.5,3.5,4.5" "$(printf '1\t2\t3\n4\t5\t6\n' | ./mean -d',')"
+strtest mean "0.5" "$(./range | ./mean)"
+strtest mean "0.5" "$(./range -be | ./mean)"
+strtest mean "0.5" "$(./range -be | ./mean -p 3 )"
+
+strtest min_man "1 2 3" "$(printf '1\t2\t3\n4\t5\t6\n' | ./min)"
+strtest min "1,2,3" "$(printf '1\t2\t3\n4\t5\t6\n' | ./min -d',')"
+strtest min "0" "$(./range | ./min)"
+strtest min "0.090909090909090912" "$(./range -be | ./min)"
+strtest min "0.0909" "$(./range -be | ./min -p 3 )"
+
+strtest rangetest_man "0
+1.25
+1.40625
+1.484375
+1.494140625" "$(./rangetest './condfail @VAL@' 0.0 10.0 2>/dev/null)"
+
+strtest rangetest_man "10
+5
+2.5
+1.875
+1.5625
+1.5234375
+1.50390625" "$(./rangetest './condfail @VAL@' 0.0 10.0 2>&1 >/dev/null)"
+
+strtest stddev_man "2.1908902300206643" "$(printf '10\n8\n10\n8\n8\n4\n' | ./s…
+strtest stddev_man "2" "$(printf '10\n8\n10\n8\n8\n4\n' | ./stddev -u)"
+strtest stddev "2.2" "$(printf '10\n8\n10\n8\n8\n4\n' | ./stddev -p 2)"
+strtest stddev "2.1213203435596424 2.1213203435596424 2.12132034…
+strtest stddev "2.1 2.1 2.1" "$(printf '1\t2\t3\n4\t5\t6\n' | ./…
+strtest stddev "2.1,2.1,2.1" "$(printf '1\t2\t3\n4\t5\t6\n' | ./stddev -p 2 -d…
+
+strtest stdvar_man "4.7999999999999998" "$(printf '10\n8\n10\n8\n8\n4\n' | ./s…
+strtest stdvar_man "4" "$(printf '10\n8\n10\n8\n8\n4\n' | ./stdvar -u)"
+strtest stdvar "4.8" "$(printf '10\n8\n10\n8\n8\n4\n' | ./stdvar -p 2)"
+strtest stdvar "4.5 4.5 4.5" "$(printf '1\t2\t3\n4\t5\t6\n' | ./…
+strtest stdvar "4.5 4.5 4.5" "$(printf '1\t2\t3\n4\t5\t6\n' | ./…
+strtest stdvar "4.5,4.5,4.5" "$(printf '1\t2\t3\n4\t5\t6\n' | ./stdvar -p 2 -d…
+
+strtest sum_man "5 7 9" "$(printf '1\t2\t3\n4\t5\t6\n' | ./sum)"
+strtest sum "48" "$(printf '10\n8\n10\n8\n8\n4\n' | ./sum)"
+strtest sum "5e+01" "$(printf '10\n8\n10\n8\n8\n4\n' | ./sum -p 1)"
+strtest sum "5 7 9" "$(printf '1\t2\t3\n4\t5\t6\n' | ./sum)"
+strtest sum "5,7,9" "$(printf '1\t2\t3\n4\t5\t6\n' | ./sum -d',' )"
+
+strtest transpose_man "1 4
+2 5
+3 6" "$(printf '1\t2\t3\n4\t5\t6\n' | ./transpose)"
You are viewing proxied material from mx1.adamsgaard.dk. The copyright of proxied material belongs to its original authors. Any comments or complaints in relation to proxied material should be directed to the original authors of the content concerned. Please see the disclaimer for more details.