mirror of
https://github.com/johnkerl/miller.git
synced 2026-07-29 02:30:12 +00:00
fail in reg-test/run on num_invocations_attempted==0, and count those correctly
This commit is contained in:
parent
6d37d42288
commit
5781be4cd5
18 changed files with 509 additions and 113 deletions
|
|
@ -1,4 +1,15 @@
|
|||
echo 'a,b,c,d,e,f' | run_mlr
|
||||
echo 'a,b,c,d,e,f,g' | run_mlr
|
||||
echo 'a,b,c,d,e,f' | run_mlr --inidx --ifs comma altkv
|
||||
echo 'a,b,c,d,e,f,g' | run_mlr --inidx --ifs comma altkv
|
||||
run_mlr altkv <<EOF
|
||||
a,b,c,d,e,f
|
||||
EOF
|
||||
|
||||
run_mlr altkv <<EOF
|
||||
a,b,c,d,e,f,g
|
||||
EOF
|
||||
|
||||
run_mlr --inidx --ifs comma altkv <<EOF
|
||||
a,b,c,d,e,f
|
||||
EOF
|
||||
|
||||
run_mlr --inidx --ifs comma altkv <<EOF
|
||||
a,b,c,d,e,f,g
|
||||
EOF
|
||||
|
|
|
|||
|
|
@ -83,7 +83,18 @@ run_mlr --oxtab put '$y = regextract_or_else($x, "[hi]*", "DEFAULT")' $indir/sub
|
|||
run_mlr --oxtab put '$y = regextract_or_else($x, "[op]+", "DEFAULT")' $indir/sub.dat
|
||||
run_mlr --oxtab put '$y = regextract_or_else($x, "[op]*", "DEFAULT")' $indir/sub.dat
|
||||
|
||||
echo 'abcdefg' | run_mlr --nidx put '$1 = sub($1, "ab(.)d(..)g", "ab<<\1>>d<<\2>>g")'
|
||||
echo 'abcdefg' | run_mlr --nidx put '$1 = sub($1, "ab(c)?d(..)g", "ab<<\1>>d<<\2>>g")'
|
||||
echo 'abXdefg' | run_mlr --nidx put '$1 = sub($1, "ab(c)?d(..)g", "ab<<\1>>d<<\2>>g")'
|
||||
echo 'abdefg' | run_mlr --nidx put '$1 = sub($1, "ab(c)?d(..)g", "ab<<\1>>d<<\2>>g")'
|
||||
run_mlr --nidx put '$1 = sub($1, "ab(.)d(..)g", "ab<<\1>>d<<\2>>g")' <<EOF
|
||||
abcdefg
|
||||
EOF
|
||||
|
||||
run_mlr --nidx put '$1 = sub($1, "ab(c)?d(..)g", "ab<<\1>>d<<\2>>g")' <<EOF
|
||||
abcdefg
|
||||
EOF
|
||||
|
||||
run_mlr --nidx put '$1 = sub($1, "ab(c)?d(..)g", "ab<<\1>>d<<\2>>g")' <<EOF
|
||||
abXdefg
|
||||
EOF
|
||||
|
||||
run_mlr --nidx put '$1 = sub($1, "ab(c)?d(..)g", "ab<<\1>>d<<\2>>g")' <<EOF
|
||||
abdefg
|
||||
EOF
|
||||
|
|
|
|||
|
|
@ -29,18 +29,51 @@ run_mlr --opprint put '$y=mexp($x,35,37)' then put '$z=mmul($x,$y,37)' $indir/mo
|
|||
run_mlr put '$z=min($x, $y)' $indir/minmax.dkvp
|
||||
run_mlr put '$z=max($x, $y)' $indir/minmax.dkvp
|
||||
|
||||
echo 'x=1,y=2,z=3' | run_mlr put '$o=min()'
|
||||
echo 'x=1,y=2,z=3' | run_mlr put '$o=max()'
|
||||
echo 'x=1,y=2,z=3' | run_mlr put '$o=min($x)'
|
||||
echo 'x=1,y=2,z=3' | run_mlr put '$o=max($x)'
|
||||
echo 'x=1,y=2,z=3' | run_mlr put '$o=min($x,$y)'
|
||||
echo 'x=1,y=2,z=3' | run_mlr put '$o=max($x,$y)'
|
||||
echo 'x=1,y=2,z=3' | run_mlr put '$o=min($x,$y,$z)'
|
||||
echo 'x=1,y=2,z=3' | run_mlr put '$o=max($x,$y,$z)'
|
||||
run_mlr put '$o=min()' <<EOF
|
||||
x=1,y=2,z=3
|
||||
EOF
|
||||
|
||||
run_mlr put '$o=max()' <<EOF
|
||||
x=1,y=2,z=3
|
||||
EOF
|
||||
|
||||
run_mlr put '$o=min($x)' <<EOF
|
||||
x=1,y=2,z=3
|
||||
EOF
|
||||
|
||||
run_mlr put '$o=max($x)' <<EOF
|
||||
x=1,y=2,z=3
|
||||
EOF
|
||||
|
||||
run_mlr put '$o=min($x,$y)' <<EOF
|
||||
x=1,y=2,z=3
|
||||
EOF
|
||||
|
||||
run_mlr put '$o=max($x,$y)' <<EOF
|
||||
x=1,y=2,z=3
|
||||
EOF
|
||||
|
||||
run_mlr put '$o=min($x,$y,$z)' <<EOF
|
||||
x=1,y=2,z=3
|
||||
EOF
|
||||
|
||||
run_mlr put '$o=max($x,$y,$z)' <<EOF
|
||||
x=1,y=2,z=3
|
||||
EOF
|
||||
|
||||
|
||||
run_mlr put '$u=min($x,$y);$v=max($x,$y)' <<EOF
|
||||
x=1,y=b
|
||||
EOF
|
||||
|
||||
run_mlr put '$u=min($x,$y);$v=max($x,$y)' <<EOF
|
||||
x=a,y=2
|
||||
EOF
|
||||
|
||||
run_mlr put '$u=min($x,$y);$v=max($x,$y)' <<EOF
|
||||
x=a,y=b
|
||||
EOF
|
||||
|
||||
echo 'x=1,y=b' | run_mlr put '$u=min($x,$y);$v=max($x,$y)'
|
||||
echo 'x=a,y=2' | run_mlr put '$u=min($x,$y);$v=max($x,$y)'
|
||||
echo 'x=a,y=b' | run_mlr put '$u=min($x,$y);$v=max($x,$y)'
|
||||
|
||||
run_mlr --icsvlite --oxtab put '${x+y} = ${name.x} + ${name.y}; ${x*y} = ${name.x} * ${name.y}' $indir/braced.csv
|
||||
run_mlr --icsvlite --oxtab filter '${name.y} < ${z}' $indir/braced.csv
|
||||
|
|
@ -74,20 +107,55 @@ run_mlr put '$x = ENV["X"]; $y = ENV[$name]' $indir/env-var.dkvp
|
|||
|
||||
run_mlr -n put 'begin{ENV["HOME"]="foobar"} end{print ENV["HOME"]}'
|
||||
|
||||
echo 'x=hello' | run_mlr put '$y = toupper($x)'
|
||||
echo 'x=HELLO' | run_mlr put '$y = toupper($x)'
|
||||
echo 'x=' | run_mlr put '$y = toupper($x)'
|
||||
echo 'x=hello' | run_mlr put '$y = toupper($z)'
|
||||
run_mlr put '$y = toupper($x)' <<EOF
|
||||
x=hello
|
||||
EOF
|
||||
|
||||
echo 'x=hello' | run_mlr put '$y = tolower($x)'
|
||||
echo 'x=HELLO' | run_mlr put '$y = tolower($x)'
|
||||
echo 'x=' | run_mlr put '$y = tolower($x)'
|
||||
echo 'x=hello' | run_mlr put '$y = tolower($z)'
|
||||
run_mlr put '$y = toupper($x)' <<EOF
|
||||
x=HELLO
|
||||
EOF
|
||||
|
||||
echo 'x=hello' | run_mlr put '$y = capitalize($x)'
|
||||
echo 'x=HELLO' | run_mlr put '$y = capitalize($x)'
|
||||
echo 'x=' | run_mlr put '$y = capitalize($x)'
|
||||
echo 'x=hello' | run_mlr put '$y = capitalize($z)'
|
||||
run_mlr put '$y = toupper($x)' <<EOF
|
||||
x=
|
||||
EOF
|
||||
|
||||
run_mlr put '$y = toupper($z)' <<EOF
|
||||
x=hello
|
||||
EOF
|
||||
|
||||
|
||||
run_mlr put '$y = tolower($x)' <<EOF
|
||||
x=hello
|
||||
EOF
|
||||
|
||||
run_mlr put '$y = tolower($x)' <<EOF
|
||||
x=HELLO
|
||||
EOF
|
||||
|
||||
run_mlr put '$y = tolower($x)' <<EOF
|
||||
x=
|
||||
EOF
|
||||
|
||||
run_mlr put '$y = tolower($z)' <<EOF
|
||||
x=hello
|
||||
EOF
|
||||
|
||||
|
||||
run_mlr put '$y = capitalize($x)' <<EOF
|
||||
x=hello
|
||||
EOF
|
||||
|
||||
run_mlr put '$y = capitalize($x)' <<EOF
|
||||
x=HELLO
|
||||
EOF
|
||||
|
||||
run_mlr put '$y = capitalize($x)' <<EOF
|
||||
x=
|
||||
EOF
|
||||
|
||||
run_mlr put '$y = capitalize($z)' <<EOF
|
||||
x=hello
|
||||
EOF
|
||||
|
||||
mention LHS value on first record should result in ZYX for process creation
|
||||
export indir; run_mlr --from $indir/abixy put -q 'ENV["ZYX"]="CBA".NR; print | ENV["indir"]."/env-assign.sh" , "a is " . $a'
|
||||
|
|
|
|||
|
|
@ -63,7 +63,18 @@ run_mlr --opprint put 'filter $FIELD =~ "(.)(.)(.)(.)(.)(.)(.)(.)"; $F0="\
|
|||
run_mlr --opprint put 'filter $FIELD =~ "(.)(.)(.)(.)(.)(.)(.)(.)(.)"; $F0="\0";$F1="\1";$F2="\2";$F3="\3";$F4="\4";$F5="\5";$F6="\6";$F7="\7";$F8="\8";$F9="\9"' $indir/capture-lengths.dkvp
|
||||
run_mlr --opprint put 'filter $FIELD =~ "(.)(.)(.)(.)(.)(.)(.)(.)(.)(.)"; $F0="\0";$F1="\1";$F2="\2";$F3="\3";$F4="\4";$F5="\5";$F6="\6";$F7="\7";$F8="\8";$F9="\9"' $indir/capture-lengths.dkvp
|
||||
|
||||
echo 'abcdefg' | run_mlr --inidx --odkvp put '$1 =~ "ab(.)d(..)g" { $c1 = "\1"; $c2 = "\2"}'
|
||||
echo 'abcdefg' | run_mlr --inidx --odkvp put '$1 =~ "ab(.)?d(..)g" { $c1 = "\1"; $c2 = "\2"}'
|
||||
echo 'abXdefg' | run_mlr --inidx --odkvp put '$1 =~ "ab(c)?d(..)g" { $c1 = "\1"; $c2 = "\2"}'
|
||||
echo 'abdefg' | run_mlr --inidx --odkvp put '$1 =~ "ab(c)?d(..)g" { $c1 = "\1"; $c2 = "\2"}'
|
||||
run_mlr --inidx --odkvp put '$1 =~ "ab(.)d(..)g" { $c1 = "\1"; $c2 = "\2"}' <<EOF
|
||||
abcdefg
|
||||
EOF
|
||||
|
||||
run_mlr --inidx --odkvp put '$1 =~ "ab(.)?d(..)g" { $c1 = "\1"; $c2 = "\2"}' <<EOF
|
||||
abcdefg
|
||||
EOF
|
||||
|
||||
run_mlr --inidx --odkvp put '$1 =~ "ab(c)?d(..)g" { $c1 = "\1"; $c2 = "\2"}' <<EOF
|
||||
abXdefg
|
||||
EOF
|
||||
|
||||
run_mlr --inidx --odkvp put '$1 =~ "ab(c)?d(..)g" { $c1 = "\1"; $c2 = "\2"}' <<EOF
|
||||
abdefg
|
||||
EOF
|
||||
|
|
|
|||
|
|
@ -67,7 +67,7 @@ run_mlr --opprint --from $indir/abixy put '
|
|||
$z = sum
|
||||
'
|
||||
|
||||
echo x=1 | run_mlr put '
|
||||
run_mlr put '
|
||||
num a = 100;
|
||||
num b = 100;
|
||||
for (num a = 200, b = 300; a <= 210; a += 1, b += 1) {
|
||||
|
|
@ -75,7 +75,9 @@ echo x=1 | run_mlr put '
|
|||
}
|
||||
$oa = a;
|
||||
$ob = b;
|
||||
'
|
||||
' <<EOF
|
||||
x=1
|
||||
EOF
|
||||
|
||||
run_mlr --from $indir/abixy put '
|
||||
for ( ; $x <= 10; $x += 1) {
|
||||
|
|
|
|||
|
|
@ -6,9 +6,15 @@ run_mlr --xtab filter '999 != $pi1 + $pi2' $indir/mixed-types.xtab
|
|||
run_mlr --xtab filter -F '999 != $pi1 + $pi2' $indir/mixed-types.xtab
|
||||
run_mlr --xtab filter -S '"999" != $pi1 . $pi2' $indir/mixed-types.xtab
|
||||
|
||||
echo a=1,b=2.0 | run_mlr --oxtab put '$s = $a; $t = $b; $u = 3; $v = 4.0; $ts=typeof($s); $tt=typeof($t); $tu=typeof($u); $tv=typeof($v);'
|
||||
echo a=1,b=2.0 | run_mlr --oxtab put -F '$s = $a; $t = $b; $u = 3; $v = 4.0; $ts=typeof($s); $tt=typeof($t); $tu=typeof($u); $tv=typeof($v);'
|
||||
echo a=1,b=2.0 | run_mlr --oxtab put -S '$s = $a; $t = $b; $u = 3; $v = 4.0; $ts=typeof($s); $tt=typeof($t); $tu=typeof($u); $tv=typeof($v);'
|
||||
run_mlr --oxtab put '$s = $a; $t = $b; $u = 3; $v = 4.0; $ts=typeof($s); $tt=typeof($t); $tu=typeof($u); $tv=typeof($v);' <<EOF
|
||||
a=1,b=2.0
|
||||
EOF
|
||||
run_mlr --oxtab put -F '$s = $a; $t = $b; $u = 3; $v = 4.0; $ts=typeof($s); $tt=typeof($t); $tu=typeof($u); $tv=typeof($v);' <<EOF
|
||||
a=1,b=2.0
|
||||
EOF
|
||||
run_mlr --oxtab put -S '$s = $a; $t = $b; $u = 3; $v = 4.0; $ts=typeof($s); $tt=typeof($t); $tu=typeof($u); $tv=typeof($v);' <<EOF
|
||||
a=1,b=2.0
|
||||
EOF
|
||||
|
||||
run_mlr --xtab put '$y=abs($pf1)' $indir/mixed-types.xtab
|
||||
run_mlr --xtab put '$y=abs($nf1)' $indir/mixed-types.xtab
|
||||
|
|
@ -121,4 +127,6 @@ run_mlr --xtab put '$a=roundm($pf1,10) ;$b=roundm($pf1,-10) ' $indir/mixed-
|
|||
run_mlr --xtab put '$a=roundm($pi1,10.0);$b=roundm($pi1,-10.0)' $indir/mixed-types.xtab
|
||||
run_mlr --xtab put '$a=roundm($pi1,10) ;$b=roundm($pi1,-10) ' $indir/mixed-types.xtab
|
||||
|
||||
echo 'x=3,y=4' | run_mlr --oxtab put '$z=$x+$y; $a=3+4; $b="3"."4"; $c="3"+4'
|
||||
run_mlr --oxtab put '$z=$x+$y; $a=3+4; $b="3"."4"; $c="3"+4' <<EOF
|
||||
x=3,y=4
|
||||
EOF
|
||||
|
|
|
|||
|
|
@ -1,7 +1,12 @@
|
|||
|
||||
for n in 0 1 2 3 4 5; do
|
||||
echo "x=abcd" | run_mlr put '$y=truncate($x, '$n')'
|
||||
run_mlr put '$y=truncate($x, '$n')' <<EOF
|
||||
x=abcd
|
||||
EOF
|
||||
done
|
||||
|
||||
for n in 0 1 2 3 4 5; do
|
||||
echo "x=abcdefgh" | run_mlr put '$y=truncate($x, '$n')'
|
||||
run_mlr put '$y=truncate($x, '$n')' <<EOF
|
||||
x=abcdefgh
|
||||
EOF
|
||||
done
|
||||
|
|
|
|||
|
|
@ -10,8 +10,12 @@ run_mlr cat -g a,b $indir/abixy-het
|
|||
run_mlr cat -g a,b -n $indir/abixy-het
|
||||
run_mlr cat -g a,b -N counter $indir/abixy-het
|
||||
|
||||
echo a,b,c,d,e,f | run_mlr cat
|
||||
echo a,b,c,d,e,f,g | run_mlr cat
|
||||
run_mlr cat <<EOF
|
||||
a,b,c,d,e,f
|
||||
EOF
|
||||
run_mlr cat <<EOF
|
||||
a,b,c,d,e,f,g
|
||||
EOF
|
||||
|
||||
run_mlr --opprint cat $indir/s.dkvp
|
||||
run_mlr --opprint cat -n $indir/s.dkvp
|
||||
|
|
|
|||
|
|
@ -1,25 +1,87 @@
|
|||
echo '{"x":1}' | run_mlr --json cat
|
||||
echo '{"x":[1,2,3]}' | run_mlr --json cat
|
||||
echo '{"x":[1,[2,3,4],5]}' | run_mlr --json cat
|
||||
echo '{"x":[1,[2,[3,4,5],6],7]}' | run_mlr --json cat
|
||||
|
||||
echo '{"x":{}}' | run_mlr --json cat
|
||||
echo '{"x":{"a":1,"b":2,"c":3}}' | run_mlr --json cat
|
||||
echo '{"x":{"a":1,"b":{"c":3,"d":4,"e":5},"f":6}}' | run_mlr --json cat
|
||||
run_mlr --json cat <<EOF
|
||||
{"x":1}
|
||||
EOF
|
||||
|
||||
echo '{"x":{},"y":1}' | run_mlr --json cat
|
||||
echo '{"x":{"a":1,"b":2,"c":3},"y":4}' | run_mlr --json cat
|
||||
echo '{"x":{"a":1,"b":{"c":3,"d":4,"e":5},"f":6},"y":7}' | run_mlr --json cat
|
||||
run_mlr --json cat <<EOF
|
||||
{"x":[1,2,3]}
|
||||
EOF
|
||||
|
||||
echo '{"x":1}' | $path_to_mlr --json cat | run_mlr --json cat
|
||||
echo '{"x":[1,2,3]}' | $path_to_mlr --json cat | run_mlr --json cat
|
||||
echo '{"x":[1,[2,3,4],5]}' | $path_to_mlr --json cat | run_mlr --json cat
|
||||
echo '{"x":[1,[2,[3,4,5],6],7]}' | $path_to_mlr --json cat | run_mlr --json cat
|
||||
run_mlr --json cat <<EOF
|
||||
{"x":[1,[2,3,4],5]}
|
||||
EOF
|
||||
|
||||
run_mlr --json cat <<EOF
|
||||
{"x":[1,[2,[3,4,5],6],7]}
|
||||
EOF
|
||||
|
||||
|
||||
run_mlr --json cat <<EOF
|
||||
{"x":{}}
|
||||
EOF
|
||||
|
||||
run_mlr --json cat <<EOF
|
||||
{"x":{"a":1,"b":2,"c":3}}
|
||||
EOF
|
||||
|
||||
run_mlr --json cat <<EOF
|
||||
{"x":{"a":1,"b":{"c":3,"d":4,"e":5},"f":6}}
|
||||
EOF
|
||||
|
||||
|
||||
run_mlr --json cat <<EOF
|
||||
{"x":{},"y":1}
|
||||
EOF
|
||||
|
||||
run_mlr --json cat <<EOF
|
||||
{"x":{"a":1,"b":2,"c":3},"y":4}
|
||||
EOF
|
||||
|
||||
run_mlr --json cat <<EOF
|
||||
{"x":{"a":1,"b":{"c":3,"d":4,"e":5},"f":6},"y":7}
|
||||
EOF
|
||||
|
||||
|
||||
$path_to_mlr --json cat <<EOF | run_mlr --json cat
|
||||
{"x":1}
|
||||
EOF
|
||||
|
||||
$path_to_mlr --json cat <<EOF | run_mlr --json cat
|
||||
{"x":[1,2,3]}
|
||||
EOF
|
||||
|
||||
$path_to_mlr --json cat <<EOF | run_mlr --json cat
|
||||
{"x":[1,[2,3,4],5]}
|
||||
EOF
|
||||
|
||||
$path_to_mlr --json cat <<EOF | run_mlr --json cat
|
||||
{"x":[1,[2,[3,4,5],6],7]}
|
||||
EOF
|
||||
|
||||
|
||||
$path_to_mlr --json cat <<EOF | run_mlr --json cat
|
||||
{"x":{}}
|
||||
EOF
|
||||
|
||||
$path_to_mlr --json cat <<EOF | run_mlr --json cat
|
||||
{"x":{"a":1,"b":2,"c":3}}
|
||||
EOF
|
||||
|
||||
$path_to_mlr --json cat <<EOF | run_mlr --json cat
|
||||
{"x":{"a":1,"b":{"c":3,"d":4,"e":5},"f":6}}
|
||||
EOF
|
||||
|
||||
|
||||
$path_to_mlr --json cat <<EOF | run_mlr --json cat
|
||||
{"x":{},"y":1}
|
||||
EOF
|
||||
|
||||
$path_to_mlr --json cat <<EOF | run_mlr --json cat
|
||||
{"x":{"a":1,"b":2,"c":3},"y":4}
|
||||
EOF
|
||||
|
||||
$path_to_mlr --json cat <<EOF | run_mlr --json cat
|
||||
{"x":{"a":1,"b":{"c":3,"d":4,"e":5},"f":6},"y":7}
|
||||
EOF
|
||||
|
||||
echo '{"x":{}}' | $path_to_mlr --json cat | run_mlr --json cat
|
||||
echo '{"x":{"a":1,"b":2,"c":3}}' | $path_to_mlr --json cat | run_mlr --json cat
|
||||
echo '{"x":{"a":1,"b":{"c":3,"d":4,"e":5},"f":6}}' | $path_to_mlr --json cat | run_mlr --json cat
|
||||
|
||||
echo '{"x":{},"y":1}' | $path_to_mlr --json cat | run_mlr --json cat
|
||||
echo '{"x":{"a":1,"b":2,"c":3},"y":4}' | $path_to_mlr --json cat | run_mlr --json cat
|
||||
echo '{"x":{"a":1,"b":{"c":3,"d":4,"e":5},"f":6},"y":7}' | $path_to_mlr --json cat | run_mlr --json cat
|
||||
|
|
|
|||
|
|
@ -1,8 +1,31 @@
|
|||
echo "x=1,y=abcdefg,z=3" | run_mlr put '$n = length($x)'
|
||||
echo "x=1,y=abcdefg,z=3" | run_mlr put '$n = length($y)'
|
||||
echo "x=1,y=abcdefg,z=3" | run_mlr put '$n = length($nonesuch)'
|
||||
echo "x=1,y=abcdefg,z=3" | run_mlr put '$n = length($*)'
|
||||
echo "x=1,y=abcdefg,z=3" | run_mlr put '$n = length([])'
|
||||
echo "x=1,y=abcdefg,z=3" | run_mlr put '$n = length([5,6,7])'
|
||||
echo "x=1,y=abcdefg,z=3" | run_mlr put '$n = length({})'
|
||||
echo "x=1,y=abcdefg,z=3" | run_mlr put '$n = length({"a":5,"b":6,"c":7})'
|
||||
run_mlr put '$n = length($x)' <<EOF
|
||||
x=1,y=abcdefg,z=3
|
||||
EOF
|
||||
|
||||
run_mlr put '$n = length($y)' <<EOF
|
||||
x=1,y=abcdefg,z=3
|
||||
EOF
|
||||
|
||||
run_mlr put '$n = length($nonesuch)' <<EOF
|
||||
x=1,y=abcdefg,z=3
|
||||
EOF
|
||||
|
||||
run_mlr put '$n = length($*)' <<EOF
|
||||
x=1,y=abcdefg,z=3
|
||||
EOF
|
||||
|
||||
run_mlr put '$n = length([])' <<EOF
|
||||
x=1,y=abcdefg,z=3
|
||||
EOF
|
||||
|
||||
run_mlr put '$n = length([5,6,7])' <<EOF
|
||||
x=1,y=abcdefg,z=3
|
||||
EOF
|
||||
|
||||
run_mlr put '$n = length({})' <<EOF
|
||||
x=1,y=abcdefg,z=3
|
||||
EOF
|
||||
|
||||
run_mlr put '$n = length({"a":5,"b":6,"c":7})' <<EOF
|
||||
x=1,y=abcdefg,z=3
|
||||
EOF
|
||||
|
|
|
|||
|
|
@ -1,3 +1,11 @@
|
|||
echo x=eeee | run_mlr put '$y=ssub($x, "e", "X")'
|
||||
echo x=eeee | run_mlr put '$y=sub($x, "e", "X")'
|
||||
echo x=eeee | run_mlr put '$y=gsub($x, "e", "X")'
|
||||
run_mlr put '$y=ssub($x, "e", "X")' <<EOF
|
||||
x=eeee
|
||||
EOF
|
||||
|
||||
run_mlr put '$y=sub($x, "e", "X")' <<EOF
|
||||
x=eeee
|
||||
EOF
|
||||
|
||||
run_mlr put '$y=gsub($x, "e", "X")' <<EOF
|
||||
x=eeee
|
||||
EOF
|
||||
|
|
|
|||
|
|
@ -1,9 +1,35 @@
|
|||
echo "x=abcdefg" | run_mlr put '$y = substr($x, 0, 0)'
|
||||
echo "x=abcdefg" | run_mlr put '$y = substr($x, 0, 7)'
|
||||
echo "x=abcdefg" | run_mlr put '$y = substr($x, 1, 7)'
|
||||
echo "x=abcdefg" | run_mlr put '$y = substr($x, 1, 6)'
|
||||
echo "x=abcdefg" | run_mlr put '$y = substr($x, 2, 5)'
|
||||
echo "x=abcdefg" | run_mlr put '$y = substr($x, 2, 3)'
|
||||
echo "x=abcdefg" | run_mlr put '$y = substr($x, 3, 3)'
|
||||
echo "x=abcdefg" | run_mlr put '$y = substr($x, 4, 3)'
|
||||
echo "x=1234567" | run_mlr put '$y = substr($x, 2, 5)'
|
||||
run_mlr put '$y = substr($x, 0, 0)' <<EOF
|
||||
x=abcdefg
|
||||
EOF
|
||||
|
||||
run_mlr put '$y = substr($x, 0, 7)' <<EOF
|
||||
x=abcdefg
|
||||
EOF
|
||||
|
||||
run_mlr put '$y = substr($x, 1, 7)' <<EOF
|
||||
x=abcdefg
|
||||
EOF
|
||||
|
||||
run_mlr put '$y = substr($x, 1, 6)' <<EOF
|
||||
x=abcdefg
|
||||
EOF
|
||||
|
||||
run_mlr put '$y = substr($x, 2, 5)' <<EOF
|
||||
x=abcdefg
|
||||
EOF
|
||||
|
||||
run_mlr put '$y = substr($x, 2, 3)' <<EOF
|
||||
x=abcdefg
|
||||
EOF
|
||||
|
||||
run_mlr put '$y = substr($x, 3, 3)' <<EOF
|
||||
x=abcdefg
|
||||
EOF
|
||||
|
||||
run_mlr put '$y = substr($x, 4, 3)' <<EOF
|
||||
x=abcdefg
|
||||
EOF
|
||||
|
||||
run_mlr put '$y = substr($x, 2, 5)' <<EOF
|
||||
x=1234567
|
||||
EOF
|
||||
|
|
|
|||
|
|
@ -1,5 +1,22 @@
|
|||
echo 'x= a b '| run_mlr --ojson put '$y = strip($x)'
|
||||
echo 'x= a b '| run_mlr --ojson put '$y = lstrip($x)'
|
||||
echo 'x= a b '| run_mlr --ojson put '$y = rstrip($x)'
|
||||
echo 'x= a b '| run_mlr --ojson put '$y = collapse_whitespace($x)'
|
||||
echo 'x= a b '| run_mlr --ojson put '$y = clean_whitespace($x)'
|
||||
# If you edit this file, make sure to keep the space after the b.
|
||||
#
|
||||
# Note that echoing input piped to run_mr would be much nicer, but, I had
|
||||
# issues with the $num_invocations_attempted not tracking correctly in
|
||||
# reg-test/run when run_mlr is at the end of a pipe :(. This no-echo rule is
|
||||
# enforced by reg-test/run.
|
||||
|
||||
run_mlr --ojson put '$y = strip($x)' <<EOF
|
||||
x= a b
|
||||
EOF
|
||||
run_mlr --ojson put '$y = lstrip($x)' <<EOF
|
||||
x= a b
|
||||
EOF
|
||||
run_mlr --ojson put '$y = rstrip($x)' <<EOF
|
||||
x= a b
|
||||
EOF
|
||||
run_mlr --ojson put '$y = collapse_whitespace($x)' <<EOF
|
||||
x= a b
|
||||
EOF
|
||||
run_mlr --ojson put '$y = clean_whitespace($x)' <<EOF
|
||||
x= a b
|
||||
EOF
|
||||
|
|
|
|||
|
|
@ -53,18 +53,39 @@ run_mlr --opprint --barred cat $indir/het.dkvp
|
|||
|
||||
# To-do: port format-specific default separators from C.
|
||||
# E.g. NIDX's IFS should default to space.
|
||||
echo 'a,b,c,d,e,f' | run_mlr --inidx --oxtab cat
|
||||
echo 'a b c d e f' | run_mlr --inidx --oxtab cat
|
||||
|
||||
echo 'a,b,c,d,e,f' | run_mlr --inidx --ifs , --oxtab cat
|
||||
echo 'a b c d e f' | run_mlr --inidx --ifs , --oxtab cat
|
||||
echo 'a,b,c,d,e,f' | run_mlr --inidx --ifs ' ' --oxtab cat
|
||||
echo 'a b c d e f' | run_mlr --inidx --ifs ' ' --oxtab cat
|
||||
run_mlr --inidx --oxtab cat <<EOF
|
||||
a,b,c,d,e,f
|
||||
EOF
|
||||
run_mlr --inidx --oxtab cat <<EOF
|
||||
a b c d e f
|
||||
EOF
|
||||
|
||||
echo 'a,b,c,d,e,f' | run_mlr --inidx --ifs comma --oxtab cat
|
||||
echo 'a b c d e f' | run_mlr --inidx --ifs comma --oxtab cat
|
||||
echo 'a,b,c,d,e,f' | run_mlr --inidx --ifs space --oxtab cat
|
||||
echo 'a b c d e f' | run_mlr --inidx --ifs space --oxtab cat
|
||||
run_mlr --inidx --ifs , --oxtab cat <<EOF
|
||||
a,b,c,d,e,f
|
||||
EOF
|
||||
run_mlr --inidx --ifs , --oxtab cat <<EOF
|
||||
a b c d e f
|
||||
EOF
|
||||
run_mlr --inidx --ifs ' ' --oxtab cat <<EOF
|
||||
a,b,c,d,e,f
|
||||
EOF
|
||||
run_mlr --inidx --ifs ' ' --oxtab cat <<EOF
|
||||
a b c d e f
|
||||
EOF
|
||||
|
||||
run_mlr --inidx --ifs comma --oxtab cat <<EOF
|
||||
a,b,c,d,e,f
|
||||
EOF
|
||||
run_mlr --inidx --ifs comma --oxtab cat <<EOF
|
||||
a b c d e f
|
||||
EOF
|
||||
run_mlr --inidx --ifs space --oxtab cat <<EOF
|
||||
a,b,c,d,e,f
|
||||
EOF
|
||||
run_mlr --inidx --ifs space --oxtab cat <<EOF
|
||||
a b c d e f
|
||||
EOF
|
||||
|
||||
run_mlr --itsv --ocsv cat $indir/s.tsv
|
||||
run_mlr --icsv --otsv cat $indir/s.tsv
|
||||
|
|
|
|||
89
go/reg-test/cases/case-min-max-types.sh
Normal file
89
go/reg-test/cases/case-min-max-types.sh
Normal file
|
|
@ -0,0 +1,89 @@
|
|||
# NUMERICS < BOOL < VOID < STRING
|
||||
|
||||
run_mlr --ojson put '
|
||||
$lt["n"]["n"] = $n < $n;
|
||||
$lt["n"]["b"] = $n < $b;
|
||||
$lt["n"]["v"] = $n < $v;
|
||||
$lt["n"]["s"] = $n < $s;
|
||||
|
||||
$lt["b"]["n"] = $b < $n;
|
||||
$lt["b"]["b"] = $b < $b;
|
||||
$lt["b"]["v"] = $b < $v;
|
||||
$lt["b"]["s"] = $b < $s;
|
||||
|
||||
$lt["v"]["n"] = $v < $n;
|
||||
$lt["v"]["b"] = $v < $b;
|
||||
$lt["v"]["v"] = $v < $v;
|
||||
$lt["v"]["s"] = $v < $s;
|
||||
|
||||
$lt["s"]["n"] = $s < $n;
|
||||
$lt["s"]["b"] = $s < $b;
|
||||
$lt["s"]["s"] = $s < $s;
|
||||
$lt["s"]["v"] = $s < $v;
|
||||
|
||||
$gt["n"]["n"] = $n > $n;
|
||||
$gt["n"]["b"] = $n > $b;
|
||||
$gt["n"]["v"] = $n > $v;
|
||||
$gt["n"]["s"] = $n > $s;
|
||||
|
||||
$gt["b"]["n"] = $b > $n;
|
||||
$gt["b"]["b"] = $b > $b;
|
||||
$gt["b"]["v"] = $b > $v;
|
||||
$gt["b"]["s"] = $b > $s;
|
||||
|
||||
$gt["v"]["n"] = $v > $n;
|
||||
$gt["v"]["b"] = $v > $b;
|
||||
$gt["v"]["v"] = $v > $v;
|
||||
$gt["v"]["s"] = $v > $s;
|
||||
|
||||
$gt["s"]["n"] = $s > $n;
|
||||
$gt["s"]["b"] = $s > $b;
|
||||
$gt["s"]["v"] = $s > $v;
|
||||
$gt["s"]["s"] = $s > $s;
|
||||
' <<EOF
|
||||
n=1,b=true,v=,s=abc
|
||||
EOF
|
||||
|
||||
run_mlr --ojson put '
|
||||
$min["n"]["n"] = min($n,$n);
|
||||
$min["n"]["b"] = min($n,$b);
|
||||
$min["n"]["v"] = min($n,$v);
|
||||
$min["n"]["s"] = min($n,$s);
|
||||
|
||||
$min["b"]["n"] = min($b,$n);
|
||||
$min["b"]["b"] = min($b,$b);
|
||||
$min["b"]["v"] = min($b,$v);
|
||||
$min["b"]["s"] = min($b,$s);
|
||||
|
||||
$min["v"]["n"] = min($v,$n);
|
||||
$min["v"]["b"] = min($v,$b);
|
||||
$min["v"]["v"] = min($v,$v);
|
||||
$min["v"]["s"] = min($v,$s);
|
||||
|
||||
$min["s"]["n"] = min($s,$n);
|
||||
$min["s"]["b"] = min($s,$b);
|
||||
$min["s"]["s"] = min($s,$s);
|
||||
$min["s"]["v"] = min($s,$v);
|
||||
|
||||
$max["n"]["n"] = max($n,$n);
|
||||
$max["n"]["b"] = max($n,$b);
|
||||
$max["n"]["v"] = max($n,$v);
|
||||
$max["n"]["s"] = max($n,$s);
|
||||
|
||||
$max["b"]["n"] = max($b,$n);
|
||||
$max["b"]["b"] = max($b,$b);
|
||||
$max["b"]["v"] = max($b,$v);
|
||||
$max["b"]["s"] = max($b,$s);
|
||||
|
||||
$max["v"]["n"] = max($v,$n);
|
||||
$max["v"]["b"] = max($v,$b);
|
||||
$max["v"]["v"] = max($v,$v);
|
||||
$max["v"]["s"] = max($v,$s);
|
||||
|
||||
$max["s"]["n"] = max($s,$n);
|
||||
$max["s"]["b"] = max($s,$b);
|
||||
$max["s"]["v"] = max($s,$v);
|
||||
$max["s"]["s"] = max($s,$s);
|
||||
' <<EOF
|
||||
n=1,b=true,v=,s=abc
|
||||
EOF
|
||||
|
|
@ -1,9 +1,9 @@
|
|||
|
||||
mlr
|
||||
Exit status was 1; expected 0.
|
||||
mlr altkv
|
||||
a=b,c=d,e=f
|
||||
|
||||
mlr
|
||||
Exit status was 1; expected 0.
|
||||
mlr altkv
|
||||
a=b,c=d,e=f,4=g
|
||||
|
||||
mlr --inidx --ifs comma altkv
|
||||
a=b,c=d,e=f
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
#!/bin/sh
|
||||
|
||||
# TODO: NEEDS A FULL RE-COMMENT PASS
|
||||
set -uo pipefail
|
||||
|
||||
# ================================================================
|
||||
# MILLER REGRESSION SCRIPT
|
||||
|
|
@ -38,6 +38,7 @@
|
|||
# $num_invocations_passed as side-outputs.
|
||||
#
|
||||
# * Each case can fail in the following ways:
|
||||
# o Zero invocatios were attempted.
|
||||
# o A given 'run_mlr ...' invocation exits with non-zero when it should exit
|
||||
# with zero.
|
||||
# o A given 'mlr_expect_fail ...' invocation exits with zero when it should
|
||||
|
|
@ -295,20 +296,42 @@ for case_file in $case_file_names; do
|
|||
errfile=$outdir/$case_name.err
|
||||
expfile=$expdir/$case_name.out
|
||||
|
||||
case_passed=true
|
||||
|
||||
echo > $outfile
|
||||
num_cases_attempted=`expr $num_cases_attempted + 1`
|
||||
|
||||
# Note that 'echo "..." | run_mlr ... ' would be nice in case-files, but, I had
|
||||
# issues with the $num_invocations_attempted not tracking correctly in
|
||||
# reg-test/run when run_mlr is at the end of a pipe :(. So, I enforce
|
||||
# the discipline of always using here-documents ("<<EOF").
|
||||
grep 'echo.*|' $case_file > /dev/null 2> /dev/null
|
||||
status=$?
|
||||
if [ $status -eq 0 ]; then
|
||||
echo "$0: Please edit $case_file and replace 'echo ... | run_mlr ...' lines with 'run_mlr ... <EOF'"
|
||||
case_passed=false
|
||||
fi
|
||||
|
||||
# ----------------------------------------------------------------
|
||||
# Run all invocations in the case:
|
||||
. $case_file
|
||||
# ----------------------------------------------------------------
|
||||
|
||||
# There are two ways to fail:
|
||||
# There are two ways to fail here:
|
||||
# * Miller-command code was 0 not 1 (or vice versa) -- checked per-invocation
|
||||
# * Expected/actual output mismatch -- checked per-case
|
||||
|
||||
case_passed=true
|
||||
if [ $num_invocations_failed -ne 0 ]; then
|
||||
if [ "$verbose" = "true" ]; then
|
||||
echo "Case failed due to num_invocations_failed > 0"
|
||||
fi
|
||||
case_passed=false
|
||||
fi
|
||||
|
||||
if [ $num_invocations_attempted -eq 0 ]; then
|
||||
if [ "$verbose" = "true" ]; then
|
||||
echo "Case failed due to num_invocations_attempted == 0"
|
||||
fi
|
||||
case_passed=false
|
||||
fi
|
||||
|
||||
|
|
@ -326,6 +349,9 @@ for case_file in $case_file_names; do
|
|||
fi
|
||||
status=$?
|
||||
if [ $status -ne 0 ]; then
|
||||
if [ "$verbose" = "true" ]; then
|
||||
echo "Case failed due to expected output != actual output"
|
||||
fi
|
||||
case_passed=false
|
||||
fi
|
||||
|
||||
|
|
|
|||
16
go/todo.txt
16
go/todo.txt
|
|
@ -11,17 +11,19 @@ o iterate on a parser-generator with JSON config file
|
|||
no need to bootstrap a parser for the parser-generator language
|
||||
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
|
||||
!!! ^H two aliases ... one for paragraph one for line
|
||||
|
||||
* reg-test:
|
||||
- awkish-cond -> pattern-action everywhere
|
||||
- "format-" prefix etc for format-specific case; other prefixes ... ?
|
||||
- diff the *.err files -- ?
|
||||
- double-check c/go sieve.mlr parse/execute ok
|
||||
- mlr label: check unique
|
||||
- remove ././ from expecteds
|
||||
|
||||
! jvstack as no-op
|
||||
! int map keys: what to do with:
|
||||
o '{1:2}' treat as '{"1":2}'
|
||||
o 'm[1]' treat as 'm["1"]'
|
||||
o positional indexing for maps -- use [[]] [[[]]] ?
|
||||
o pothole: auto-extend of foo[NR] -- this now creates an array not a map
|
||||
|
||||
! --jvstack as no-op
|
||||
! reconsider OFMT -- %.6f is not really OK when inputs have far more digits.
|
||||
|
||||
* justWroteEmptyLine -> pprint too ...
|
||||
|
|
@ -31,7 +33,6 @@ no need to bootstrap a parser for the parser-generator language
|
|||
! nidx @ 10-min
|
||||
! text-put @ 10-min
|
||||
|
||||
|
||||
! JSON null needs to be passed through as-is ... somehow ... new mlrval type??
|
||||
o https://stedolan.github.io/jq/manual/#Builtinoperatorsandfunctions
|
||||
o "null can be added to any value, and returns the other value unchanged."
|
||||
|
|
@ -340,3 +341,6 @@ NITS/NON-IMMEDIATE:
|
|||
* for-multi: C semantics 'k1: data k2: a:x v:1', sigh ...
|
||||
* neaten mlr gap -g (default) print
|
||||
* case-c-* / case-go-* -> case-* eventually
|
||||
* implement min/max for array/map ... using cmp rules
|
||||
! write out thorough min/max/cmp cases for all orderings by type
|
||||
* note on <<EOF vs echo| for reg-tests ... sigh ...
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue