#!/bin/sh # ================================================================ # MILLER REGRESSION SCRIPT # # Miller has some source-code-level unit-test routines -- but the # vast majority of tests (thousands) are invoked here at the # command-line level. # # Output from various mlr command-line invocations, with prepared # inputs, is generated and then compared against stored expected # output. # ================================================================ # ---------------------------------------------------------------- # Path to mlr executable, which for interactive development is # simply "./mlr". # # For building with autoconf: # * in-directory build: # pwd is /path/to/the/tree/c/reg_test # path to mlr is /path/to/the/tree/c/mlr # path to reg_test/run is /path/to/the/tree/c/reg_test/run # # * out-of-directory ("VPATH") build: # pwd is /path/to/build/tree/c/reg_test # path to mlr is /path/to/build/tree/c/mlr # path to reg_test/run is /path/to/source/tree/c/reg_test/run # For building without autoconf: # pwd is /does/not/matter # path to mlr is /path/to/the/tree/c/mlr # path to reg_test/run is /path/to/the/tree/c/reg_test/run ourdir=`dirname $0` srcdir=$ourdir/../.. pwd=`pwd` try1=$pwd/../mlr # For autoconf builds, in-tree or out-of-tree try2=$srcdir/c/mlr # For non-autoconf builds if [ -x "$try1" ]; then path_to_mlr=$try1 elif [ -x "$try2" ]; then path_to_mlr=$try2 else echo "$0: Could not find path to mlr executable." 1>&2 echo "Try 1: $try1" 1>&2 echo "Try 2: $try2" 1>&2 exit 1 fi # mlr lecat, mlr termcvt, etc. do not accept initial '--no-mmap'. path_to_mlr_for_auxents="$path_to_mlr" if [ "$1" = "--valgrind" ]; then # Leak-check the test suite. Needs 'make mlrg' first. # ../tools/clean-valg can be used to filter the output. path_to_mlr="valgrind --leak-check=full ${path_to_mlr}g" path_to_mlr_for_auxents="$path_to_mlr" fi echo Using mlr executable $path_to_mlr # ---------------------------------------------------------------- # Input/output locations indir=$ourdir/input expdir=$ourdir/expected outdir=$pwd/output-regtest reloutdir=./output-regtest outfile=$outdir/out expfile=$expdir/out # ================================================================ # Functions num_completed=0 num_passed=0 num_failed=0 announce() { echo >> $outfile echo "================================================================" >> $outfile echo "$@" >> $outfile echo >> $outfile } mention() { echo >> $outfile echo ---------------------------------------------------------------- "$@" >> $outfile } # A key feature of this regression script is that it can be invoked from any # directory. Depending on the directory it's invoked from, the path to the mlr # executable may vary. Nonetheless for debugging it's crucial that we echo out # each command being executed. See also diff -I below. run_mlr() { # Use just "mlr" for info messages echo mlr "$@" echo mlr "$@" >> $outfile # Use path to mlr for invoking the command $path_to_mlr "$@" >> $outfile status=$? num_completed=`expr $num_completed + 1` if [ $status -eq 0 ]; then num_passed=`expr $num_passed + 1` else num_failed=`expr $num_failed + 1` fi echo >> $outfile } run_cat() { echo cat "$@" echo cat "$@" >> $outfile cat "$@" >> $outfile echo >> $outfile } run_mlr_for_auxents() { # Use just "mlr" for info messages echo mlr "$@" >> $outfile # Use path to mlr for invoking the command $path_to_mlr_for_auxents "$@" >> $outfile status=$? num_completed=`expr $num_completed + 1` if [ $status -eq 0 ]; then num_passed=`expr $num_passed + 1` else num_failed=`expr $num_failed + 1` fi } run_mlr_for_auxents_no_output() { # Use just "mlr" for info messages echo mlr "$@" >> $outfile # Use path to mlr for invoking the command $path_to_mlr_for_auxents "$@" status=$? num_completed=`expr $num_completed + 1` if [ $status -eq 0 ]; then num_passed=`expr $num_passed + 1` else num_failed=`expr $num_failed + 1` fi } # Just cats a file while also announcing that fact. run_cat() { echo cat "$@" echo cat "$@" >> $outfile # for diff at end cat "$@" >> $outfile # for diff at end echo >> $outfile } mlr_expect_fail() { # Use just "mlr" for info messages echo mlr "$@" echo mlr "$@" >> $outfile # Use path to mlr for invoking the command stderr_capture=$( $path_to_mlr "$@" 3>&1 1>&2 2>&3 >>$outfile ) status=$? num_completed=`expr $num_completed + 1` if [ $status -eq 1 ]; then num_passed=`expr $num_passed + 1` else num_failed=`expr $num_failed + 1` fi echo "${stderr_capture}" >> $outfile if [ $status -ne 1 ]; then echo "Exit status was $status; expected 1." echo "Exit status was $status; expected 1." >> $outfile fi echo >> $outfile } # ================================================================ # Start of script mkdir -p $outdir # Don't let the running user's .mlrrc affect the regression test export MLRRC="__none__" rm -rf $outdir mkdir -p $outdir touch $outfile echo # ================================================================ announce STATELESS MAPPERS run_mlr cat $indir/abixy run_mlr cat /dev/null run_mlr cat -n $indir/abixy-het run_mlr cat -N counter $indir/abixy-het run_mlr cat -g a,b $indir/abixy-het 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 run_mlr cut -f a,x $indir/abixy run_mlr cut --complement -f a,x $indir/abixy run_mlr cut -r -f c,e $indir/having-fields-regex.dkvp run_mlr cut -r -f '"C","E"' $indir/having-fields-regex.dkvp run_mlr cut -r -f '"c"i,"e"' $indir/having-fields-regex.dkvp run_mlr cut -r -f '"C"i,"E"' $indir/having-fields-regex.dkvp run_mlr cut -r -x -f c,e $indir/having-fields-regex.dkvp run_mlr cut -r -x -f '"C","E"' $indir/having-fields-regex.dkvp run_mlr cut -r -x -f '"C","E"i' $indir/having-fields-regex.dkvp run_mlr cut -r -x -f '"c","e"i' $indir/having-fields-regex.dkvp run_mlr --csvlite cut -r -f '^Name$,^Date_[0-9].*$' $indir/date1.csv $indir/date2.csv run_mlr having-fields --at-least a,b $indir/abixy run_mlr having-fields --at-least a,c $indir/abixy run_mlr having-fields --at-least a,b,i,x,y $indir/abixy run_mlr having-fields --which-are a,b,i,x $indir/abixy run_mlr having-fields --which-are a,b,i,x,y $indir/abixy run_mlr having-fields --which-are a,b,i,y,x $indir/abixy run_mlr having-fields --which-are a,b,i,x,w $indir/abixy run_mlr having-fields --which-are a,b,i,x,y,z $indir/abixy run_mlr having-fields --at-most a,c $indir/abixy run_mlr having-fields --at-most a,b,i,x,y $indir/abixy run_mlr having-fields --at-most a,b,i,x,y,z $indir/abixy run_mlr having-fields --all-matching '"^[a-z][a-z][a-z]$"' $indir/having-fields-regex.dkvp run_mlr having-fields --any-matching '"^[a-z][a-z][a-z]$"' $indir/having-fields-regex.dkvp run_mlr having-fields --none-matching '"^[a-z][a-z][a-z]$"' $indir/having-fields-regex.dkvp run_mlr having-fields --all-matching '"^[a-z][a-z][a-z]$"i' $indir/having-fields-regex.dkvp run_mlr having-fields --any-matching '"^[a-z][a-z][a-z]$"i' $indir/having-fields-regex.dkvp run_mlr having-fields --none-matching '"^[a-z][a-z][a-z]$"i' $indir/having-fields-regex.dkvp run_mlr rename b,BEE,x,EKS $indir/abixy run_mlr rename nonesuch,nonesuch,x,EKS $indir/abixy run_mlr label NEW $indir/abixy run_mlr label a,NEW,c $indir/abixy run_mlr label 1,2,3,4,5,6,7,8 $indir/abixy run_mlr label d,x,f $indir/abixy mlr_expect_fail label d,x,d $indir/abixy run_mlr --csvlite rename -r '^Date_[0-9].*$,Date' $indir/date1.csv $indir/date2.csv run_mlr --csvlite rename -r '(.*)e(.*),\1EEE\2' $indir/date1.csv $indir/date2.csv run_mlr --csvlite rename -r '"(.*)e(.*)"i,\1EEE\2' $indir/date1.csv $indir/date2.csv run_mlr --csvlite rename -r -g '"(.*)e(.*)"i,\1EEE\2' $indir/date1.csv $indir/date2.csv run_mlr --csvlite rename -r '^(.a.e)(_.*)?,AA\1BB\2CC' $indir/date1.csv run_mlr --csvlite rename -r '"e",EEE' $indir/date1.csv $indir/date2.csv run_mlr --csvlite rename -r -g '"e",EEE' $indir/date1.csv $indir/date2.csv run_mlr --csvlite rename -r '"e"i,EEE' $indir/date1.csv $indir/date2.csv run_mlr --csvlite rename -r -g '"e"i,EEE' $indir/date1.csv $indir/date2.csv run_mlr regularize $indir/regularize.dkvp run_mlr --opprint bar -f x,y --lo 0 --hi 1 $indir/abixy run_mlr --opprint bar -f x,y -c c -x x -b b --lo 0.1 --hi 0.9 -w 20 $indir/abixy run_mlr --opprint bar --auto -f x,y -w 10 $indir/abixy run_mlr altkv < 2 > 3' /dev/null run_mlr filter -v ' 1 > 2 > 3' /dev/null run_mlr put -v '$x = 1 >= 2 >= 3' /dev/null run_mlr filter -v ' 1 >= 2 >= 3' /dev/null run_mlr put -v '$x = 1 < 2 <= 3' /dev/null run_mlr filter -v ' 1 < 2 <= 3' /dev/null run_mlr put -v '$x = 1 <= 2 < 3' /dev/null run_mlr filter -v ' 1 <= 2 < 3' /dev/null run_mlr put -v '$x = 1 | 2 | 3' /dev/null run_mlr filter -v ' 1 | 2 | 3' /dev/null run_mlr put -v '$x = 1 ^ 2 ^ 3' /dev/null run_mlr filter -v ' 1 ^ 2 ^ 3' /dev/null run_mlr put -v '$x = 1 & 2 & 3' /dev/null run_mlr filter -v ' 1 & 2 & 3' /dev/null run_mlr put -v '$x = 1 | 2 & 3' /dev/null run_mlr filter -v ' 1 | 2 & 3' /dev/null run_mlr put -v '$x = 1 | 2 ^ 3' /dev/null run_mlr filter -v ' 1 | 2 ^ 3' /dev/null run_mlr put -v '$x = 1 ^ 2 | 3' /dev/null run_mlr filter -v ' 1 ^ 2 | 3' /dev/null run_mlr put -v '$x = 1 ^ 2 & 3' /dev/null run_mlr filter -v ' 1 ^ 2 & 3' /dev/null run_mlr put -v '$x = 1 & 2 | 3' /dev/null run_mlr filter -v ' 1 & 2 | 3' /dev/null run_mlr put -v '$x = 1 & 2 ^ 3' /dev/null run_mlr filter -v ' 1 & 2 ^ 3' /dev/null run_mlr put -v '$x = 1 << 2 << 3' /dev/null run_mlr filter -v ' 1 << 2 << 3' /dev/null run_mlr put -v '$x = 1 >> 2 >> 3' /dev/null run_mlr filter -v ' 1 >> 2 >> 3' /dev/null run_mlr put -v '$x = 1 << 2 >> 3' /dev/null run_mlr filter -v ' 1 << 2 >> 3' /dev/null run_mlr put -v '$x = 1 >> 2 << 3' /dev/null run_mlr filter -v ' 1 >> 2 << 3' /dev/null run_mlr put -v '$x = 1 + 2 + 3' /dev/null run_mlr filter -v ' 1 + 2 + 3' /dev/null run_mlr put -v '$x = 1 - 2 - 3' /dev/null run_mlr filter -v ' 1 - 2 - 3' /dev/null run_mlr put -v '$x = 1 + 2 - 3' /dev/null run_mlr filter -v ' 1 + 2 - 3' /dev/null run_mlr put -v '$x = 1 - 2 + 3' /dev/null run_mlr filter -v ' 1 - 2 + 3' /dev/null run_mlr put -v '$x = 1 . 2 . 3' /dev/null run_mlr filter -v ' 1 . 2 . 3' /dev/null run_mlr put -v '$x = 1 * 2 * 3' /dev/null run_mlr filter -v ' 1 * 2 * 3' /dev/null run_mlr put -v '$x = 1 / 2 / 3' /dev/null run_mlr filter -v ' 1 / 2 / 3' /dev/null run_mlr put -v '$x = 1 // 2 // 3' /dev/null run_mlr filter -v ' 1 // 2 // 3' /dev/null run_mlr put -v '$x = 1 % 2 % 3' /dev/null run_mlr filter -v ' 1 % 2 % 3' /dev/null run_mlr put -v '$x = 1 ** 2 ** 3' /dev/null run_mlr filter -v ' 1 ** 2 ** 3' /dev/null run_mlr put -v '$x = 1 * 2 / 3' /dev/null run_mlr filter -v ' 1 * 2 / 3' /dev/null run_mlr put -v '$x = 1 * 2 // 3' /dev/null run_mlr filter -v ' 1 * 2 // 3' /dev/null run_mlr put -v '$x = 1 * 2 % 3' /dev/null run_mlr filter -v ' 1 * 2 % 3' /dev/null run_mlr put -v '$x = 1 * 2 ** 3' /dev/null run_mlr filter -v ' 1 * 2 ** 3' /dev/null run_mlr put -v '$x = 1 / 2 * 3' /dev/null run_mlr filter -v ' 1 / 2 * 3' /dev/null run_mlr put -v '$x = 1 / 2 // 3' /dev/null run_mlr filter -v ' 1 / 2 // 3' /dev/null run_mlr put -v '$x = 1 / 2 % 3' /dev/null run_mlr filter -v ' 1 / 2 % 3' /dev/null run_mlr put -v '$x = 1 / 2 ** 3' /dev/null run_mlr filter -v ' 1 / 2 ** 3' /dev/null run_mlr put -v '$x = 1 // 2 * 3' /dev/null run_mlr filter -v ' 1 // 2 * 3' /dev/null run_mlr put -v '$x = 1 // 2 / 3' /dev/null run_mlr filter -v ' 1 // 2 / 3' /dev/null run_mlr put -v '$x = 1 // 2 % 3' /dev/null run_mlr filter -v ' 1 // 2 % 3' /dev/null run_mlr put -v '$x = 1 // 2 ** 3' /dev/null run_mlr filter -v ' 1 // 2 ** 3' /dev/null run_mlr put -v '$x = 1 % 2 * 3' /dev/null run_mlr filter -v ' 1 % 2 * 3' /dev/null run_mlr put -v '$x = 1 % 2 / 3' /dev/null run_mlr filter -v ' 1 % 2 / 3' /dev/null run_mlr put -v '$x = 1 % 2 // 3' /dev/null run_mlr filter -v ' 1 % 2 // 3' /dev/null run_mlr put -v '$x = 1 % 2 ** 3' /dev/null run_mlr filter -v ' 1 % 2 ** 3' /dev/null run_mlr put -v '$x = 1 ** 2 * 3' /dev/null run_mlr filter -v ' 1 ** 2 * 3' /dev/null run_mlr put -v '$x = 1 ** 2 / 3' /dev/null run_mlr filter -v ' 1 ** 2 / 3' /dev/null run_mlr put -v '$x = 1 ** 2 // 3' /dev/null run_mlr filter -v ' 1 ** 2 // 3' /dev/null run_mlr put -v '$x = 1 ** 2 % 3' /dev/null run_mlr filter -v ' 1 ** 2 % 3' /dev/null run_mlr put -v '$x = ++1' /dev/null run_mlr filter -v ' ++1' /dev/null run_mlr put -v '$x = --1' /dev/null run_mlr filter -v ' --1' /dev/null run_mlr put -v '$x = !!1' /dev/null run_mlr filter -v ' !!1' /dev/null run_mlr put -v '$x = ~~1' /dev/null run_mlr filter -v ' ~~1' /dev/null run_mlr put -v '$x = 1 ? 2 : 3' /dev/null run_mlr filter -v ' 1 ? 2 : 3' /dev/null run_mlr put -v '$x = 1 ? 2 ? 3 : 4 : 5' /dev/null run_mlr filter -v ' 1 ? 2 ? 3 : 4 : 5' /dev/null run_mlr put -v '$x = 1 ? 2 : 3 ? 4 : 5' /dev/null run_mlr filter -v ' 1 ? 2 : 3 ? 4 : 5' /dev/null # ---------------------------------------------------------------- announce DSL OPERATOR PRECEDENCE # Note: filter -v and put -v print the AST. run_mlr put -v '$x = 1 || 2 ^^ 3' /dev/null run_mlr filter -v ' 1 || 2 ^^ 3' /dev/null run_mlr put -v '$x = 1 || 2 && 3' /dev/null run_mlr filter -v ' 1 || 2 && 3' /dev/null run_mlr put -v '$x = 1 ^^ 2 || 3' /dev/null run_mlr filter -v ' 1 ^^ 2 || 3' /dev/null run_mlr put -v '$x = 1 ^^ 2 && 3' /dev/null run_mlr filter -v ' 1 ^^ 2 && 3' /dev/null run_mlr put -v '$x = 1 && 2 || 3' /dev/null run_mlr filter -v ' 1 && 2 || 3' /dev/null run_mlr put -v '$x = 1 && 2 ^^ 3' /dev/null run_mlr filter -v ' 1 && 2 ^^ 3' /dev/null run_mlr put -v '$x = 1 == 2 <= 3' /dev/null run_mlr filter -v ' 1 == 2 <= 3' /dev/null run_mlr put -v '$x = 1 <= 2 == 3' /dev/null run_mlr filter -v ' 1 <= 2 == 3' /dev/null run_mlr put -v '$x = 1 <= 2 | 3' /dev/null run_mlr filter -v ' 1 <= 2 | 3' /dev/null run_mlr put -v '$x = 1 | 2 <= 3' /dev/null run_mlr filter -v ' 1 | 2 <= 3' /dev/null run_mlr put -v '$x = 1 | 2 ^ 3' /dev/null run_mlr filter -v ' 1 | 2 ^ 3' /dev/null run_mlr put -v '$x = 1 ^ 2 | 3' /dev/null run_mlr filter -v ' 1 ^ 2 | 3' /dev/null run_mlr put -v '$x = 1 ^ 2 & 3' /dev/null run_mlr filter -v ' 1 ^ 2 & 3' /dev/null run_mlr put -v '$x = 1 & 2 ^ 3' /dev/null run_mlr filter -v ' 1 & 2 ^ 3' /dev/null run_mlr put -v '$x = 1 & 2 << 3' /dev/null run_mlr filter -v ' 1 & 2 << 3' /dev/null run_mlr put -v '$x = 1 << 2 & 3' /dev/null run_mlr filter -v ' 1 << 2 & 3' /dev/null run_mlr put -v '$x = 1 + 2 * 3' /dev/null run_mlr filter -v ' 1 + 2 * 3' /dev/null run_mlr put -v '$x = 1 * 2 + 3' /dev/null run_mlr filter -v ' 1 * 2 + 3' /dev/null run_mlr put -v '$x = 1 + (2 * 3)' /dev/null run_mlr filter -v ' 1 + (2 * 3)' /dev/null run_mlr put -v '$x = 1 * (2 + 3)' /dev/null run_mlr filter -v ' 1 * (2 + 3)' /dev/null run_mlr put -v '$x = (1 + 2) * 3' /dev/null run_mlr filter -v ' (1 + 2) * 3' /dev/null run_mlr put -v '$x = (1 * 2) + 3' /dev/null run_mlr filter -v ' (1 * 2) + 3' /dev/null run_mlr put -v '$x = 1 + 2 ** 3' /dev/null run_mlr filter -v ' 1 + 2 ** 3' /dev/null run_mlr put -v '$x = 1 ** 2 + 3' /dev/null run_mlr filter -v ' 1 ** 2 + 3' /dev/null run_mlr put -v '$x = 1 + (2 ** 3)' /dev/null run_mlr filter -v ' 1 + (2 ** 3)' /dev/null run_mlr put -v '$x = 1 ** (2 + 3)' /dev/null run_mlr filter -v ' 1 ** (2 + 3)' /dev/null run_mlr put -v '$x = (1 + 2) ** 3' /dev/null run_mlr filter -v ' (1 + 2) ** 3' /dev/null run_mlr put -v '$x = (1 ** 2) + 3' /dev/null run_mlr filter -v ' (1 ** 2) + 3' /dev/null run_mlr put -v '$x = 1 * 2 ** 3' /dev/null run_mlr filter -v ' 1 * 2 ** 3' /dev/null run_mlr put -v '$x = 1 ** 2 * 3' /dev/null run_mlr filter -v ' 1 ** 2 * 3' /dev/null run_mlr put -v '$x = 1 * (2 ** 3)' /dev/null run_mlr filter -v ' 1 * (2 ** 3)' /dev/null run_mlr put -v '$x = 1 ** (2 * 3)' /dev/null run_mlr filter -v ' 1 ** (2 * 3)' /dev/null run_mlr put -v '$x = (1 * 2) ** 3' /dev/null run_mlr filter -v ' (1 * 2) ** 3' /dev/null run_mlr put -v '$x = (1 ** 2) * 3' /dev/null run_mlr filter -v ' (1 ** 2) * 3' /dev/null run_mlr put -v '$x = -1 + 2 * 3' /dev/null run_mlr filter -v ' -1 + 2 * 3' /dev/null run_mlr put -v '$x = -1 * 2 + 3' /dev/null run_mlr filter -v ' -1 * 2 + 3' /dev/null run_mlr put -v '$x = 1 + -2 * 3' /dev/null run_mlr filter -v ' 1 + -2 * 3' /dev/null run_mlr put -v '$x = 1 * -2 + 3' /dev/null run_mlr filter -v ' 1 * -2 + 3' /dev/null run_mlr put -v '$x = 1 + 2 * -3' /dev/null run_mlr filter -v ' 1 + 2 * -3' /dev/null run_mlr put -v '$x = 1 * 2 + -3' /dev/null run_mlr filter -v ' 1 * 2 + -3' /dev/null run_mlr put -v '$x = ~1 | 2 & 3' /dev/null run_mlr filter -v ' ~1 | 2 & 3' /dev/null run_mlr put -v '$x = ~1 & 2 | 3' /dev/null run_mlr filter -v ' ~1 & 2 | 3' /dev/null run_mlr put -v '$x = 1 | ~2 & 3' /dev/null run_mlr filter -v ' 1 | ~2 & 3' /dev/null run_mlr put -v '$x = 1 & ~2 | 3' /dev/null run_mlr filter -v ' 1 & ~2 | 3' /dev/null run_mlr put -v '$x = 1 | 2 & ~3' /dev/null run_mlr filter -v ' 1 | 2 & ~3' /dev/null run_mlr put -v '$x = 1 & 2 | ~3' /dev/null run_mlr filter -v ' 1 & 2 | ~3' /dev/null run_mlr put -v '$x = $a==1 && $b == 1 && $c == 1' /dev/null run_mlr filter -v ' $a==1 && $b == 1 && $c == 1' /dev/null run_mlr put -v '$x = $a==1 || $b == 1 && $c == 1' /dev/null run_mlr filter -v ' $a==1 || $b == 1 && $c == 1' /dev/null run_mlr put -v '$x = $a==1 || $b == 1 || $c == 1' /dev/null run_mlr filter -v ' $a==1 || $b == 1 || $c == 1' /dev/null run_mlr put -v '$x = $a==1 && $b == 1 || $c == 1' /dev/null run_mlr filter -v ' $a==1 && $b == 1 || $c == 1' /dev/null run_mlr put -v '$x = $a==1 ? $b == 2 : $c == 3' /dev/null run_mlr filter -v ' $a==1 ? $b == 2 : $c == 3' /dev/null run_mlr put -v '$x = true' /dev/null run_mlr filter -v ' true' /dev/null run_mlr put -v 'true || 1==0; $x = 3' /dev/null run_mlr filter -v ' true || 1==0' /dev/null run_mlr put -v '1==0 || false; $x = 3' /dev/null run_mlr filter -v ' 1==0 || false' /dev/null run_mlr put -v 'true && false; $x = 3' /dev/null run_mlr filter -v ' true && false' /dev/null run_mlr put -v 'true && false && true; $x = 3' /dev/null run_mlr filter -v ' true && false && true' /dev/null run_mlr put -v '$y += $x + 3' /dev/null run_mlr put -v '$y += $x * 3' /dev/null run_mlr put -v '$y ||= $x' /dev/null run_mlr put -v '$y ^^= $x' /dev/null run_mlr put -v '$y &&= $x' /dev/null run_mlr put -v '$y |= $x' /dev/null run_mlr put -v '$y ^= $x' /dev/null run_mlr put -v '$y &= $x' /dev/null run_mlr put -v '$y <<= $x' /dev/null run_mlr put -v '$y >>= $x' /dev/null run_mlr put -v '$y += $x' /dev/null run_mlr put -v '$y -= $x' /dev/null run_mlr put -v '$y .= $x' /dev/null run_mlr put -v '$y *= $x' /dev/null run_mlr put -v '$y /= $x' /dev/null run_mlr put -v '$y //= $x' /dev/null run_mlr put -v '$y %= $x' /dev/null run_mlr put -v '$y **= $x' /dev/null # ---------------------------------------------------------------- announce DSL COMMENTS run_mlr --from $indir/abixy put ' $s = 1; #$t = 2; $u = 3; ' run_mlr --from $indir/abixy filter ' NR == 1 || #NR == 2 || NR == 3 ' run_mlr --from $indir/abixy put ' $s = "here is a pound#sign"; # but this is a comment #$t = 2; $u = 3; ' # ---------------------------------------------------------------- announce DSL EMPTY STATEMENTS run_mlr -n put -v '' mlr_expect_fail -n filter -v '' run_mlr -n put -v 'begin {}' run_mlr -n put -v 'begin {;}' run_mlr -n put -v 'begin {;;}' run_mlr -n put -v 'begin {;;;}' run_mlr -n put -v 'begin {@x=1}' run_mlr -n put -v 'begin {@x=1;}' run_mlr -n put -v 'begin {;@x=1}' run_mlr -n put -v 'begin {@x=1;@y=2}' run_mlr -n put -v 'begin {@x=1;;@y=2}' run_mlr -n put -v 'true {}' run_mlr -n put -v 'true {;}' run_mlr -n put -v 'true {;;}' run_mlr -n put -v 'true {;;;}' run_mlr -n put -v 'true {@x=1}' run_mlr -n put -v 'true {@x=1;}' run_mlr -n put -v 'true {;@x=1}' run_mlr -n put -v 'true {@x=1;@y=2}' run_mlr -n put -v 'true {@x=1;;@y=2}' run_mlr -n put -v 'end {}' run_mlr -n put -v 'end {;}' run_mlr -n put -v 'end {;;}' run_mlr -n put -v 'end {;;;}' run_mlr -n put -v 'end {@x=1}' run_mlr -n put -v 'end {@x=1;}' run_mlr -n put -v 'end {;@x=1}' run_mlr -n put -v 'end {@x=1;@y=2}' run_mlr -n put -v 'end {@x=1;;@y=2}' # ---------------------------------------------------------------- announce DSL CONTEXT-SPECIFIC VALIDATION mention non-top-level begin/end mlr_expect_fail put -v 'begin{begin{@x=1}}' mlr_expect_fail put -v 'true{begin{@x=1}}' mlr_expect_fail put -v 'end{end{@x=1}}' mlr_expect_fail put -v 'true{end{@x=1}}' mention srecs in begin/end mlr_expect_fail put -v 'begin{$x=1}' mlr_expect_fail put -v 'begin{@x=$y}' mlr_expect_fail put -v 'end{$x=1}' mlr_expect_fail put -v 'end{@x=$y}' mlr_expect_fail put -v 'begin{@v=$*}' mlr_expect_fail put -v 'end{$*=@v}' mlr_expect_fail put -v 'begin{unset $x}' mlr_expect_fail put -v 'end{unset $x}' mlr_expect_fail put -v 'begin{unset $*}' mlr_expect_fail put -v 'end{unset $*}' mention break/continue outside loop mlr_expect_fail put -v 'break' mlr_expect_fail put -v 'continue' mention oosvars etc. in mlr filter mlr_expect_fail filter -v 'break' mlr_expect_fail filter -v 'continue' mention expanded filter run_mlr --from $indir/abixy filter ' begin { @avoid = 3 } NR != @avoid ' run_mlr --from $indir/abixy filter -x ' begin { @avoid = 3 } NR != @avoid ' run_mlr --from $indir/abixy filter ' func f(n) { return n - 1 } f(NR) == 5 ' run_mlr --from $indir/abixy filter ' subr s(n) { print "NR is ".n } call s(NR); false ' run_mlr --from $indir/abixy filter ' int a = 5; int b = 7; a <= NR && NR <= b ' mlr_expect_fail --from $indir/abixy filter 'filter false' mlr_expect_fail --from $indir/abixy filter 'filter false; true' # ---------------------------------------------------------------- announce DSL FUNCTIONAL TESTS run_mlr filter '$x>.3' $indir/abixy run_mlr filter '$x>.3;' $indir/abixy run_mlr filter '$x>0.3' $indir/abixy run_mlr filter '$x>0.3 && $y>0.3' $indir/abixy run_mlr filter '$x>0.3 || $y>0.3' $indir/abixy run_mlr filter 'NR>=4 && NR <= 7' $indir/abixy run_mlr filter -x '$x>.3' $indir/abixy run_mlr filter -x '$x>0.3' $indir/abixy run_mlr filter -x '$x>0.3 && $y>0.3' $indir/abixy run_mlr filter -x '$x>0.3 || $y>0.3' $indir/abixy run_mlr filter -x 'NR>=4 && NR <= 7' $indir/abixy run_mlr filter '$nosuchfield>.3' $indir/abixy run_mlr put '$x2 = $x**2' $indir/abixy run_mlr put '$x2 = $x**2;' $indir/abixy run_mlr put '$z = -0.024*$x+0.13' $indir/abixy run_mlr put '$c = $a . $b' $indir/abixy run_mlr put '$ii = $i + $i' $indir/abixy run_mlr put '$emptytest = $i + $nosuch' $indir/abixy run_mlr --opprint put '$nr=NR;$fnr=FNR;$nf=NF;$filenum=FILENUM' $indir/abixy $indir/abixy run_mlr --opprint put '$y=madd($x,10,37)' then put '$z=msub($x,10,37)' $indir/modarith.dat run_mlr --opprint put '$y=mexp($x,35,37)' then put '$z=mmul($x,$y,37)' $indir/modarith.dat 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)' 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 run_mlr --opprint put '$z = $x < 0.5 ? 0 : 1' $indir/abixy run_mlr --csvlite filter 'true && true' $indir/b.csv run_mlr --csvlite filter 'true && false' $indir/b.csv run_mlr --csvlite filter 'false && true' $indir/b.csv run_mlr --csvlite filter 'false && false' $indir/b.csv run_mlr --csvlite filter 'true || true' $indir/b.csv run_mlr --csvlite filter 'true || false' $indir/b.csv run_mlr --csvlite filter 'false || true' $indir/b.csv run_mlr --csvlite filter 'false || false' $indir/b.csv run_mlr --csvlite filter 'true ^^ true' $indir/b.csv run_mlr --csvlite filter 'true ^^ false' $indir/b.csv run_mlr --csvlite filter 'false ^^ true' $indir/b.csv run_mlr --csvlite filter 'false ^^ false' $indir/b.csv # This tests boolean short-circuiting run_mlr put '$x==2 && $a =~ "....." { $y=4 }' $indir/short-circuit.dkvp export X=97 export Y=98 run_mlr put '$x = ENV["X"]; $y = ENV[$name]' $indir/env-var.dkvp export X= export Y= 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)' 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)' 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)' 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' # ---------------------------------------------------------------- announce POSITIONAL INDEXING run_mlr --opprint put '$NEW = $[[3]]' $indir/abixy run_mlr --opprint put '$NEW = $[[[3]]]' $indir/abixy run_mlr --opprint put '$NEW = $[[11]]' $indir/abixy run_mlr --opprint put '$NEW = $[[[11]]]' $indir/abixy run_mlr --opprint put '$[[3]] = "NEW"' $indir/abixy run_mlr --opprint put '$[[[3]]] = "NEW"' $indir/abixy run_mlr --opprint put '$[[11]] = "NEW"' $indir/abixy run_mlr --opprint put '$[[[11]]] = "NEW"' $indir/abixy run_mlr --opprint put '$[[1]] = $[[2]]' $indir/abixy run_mlr --opprint put '$a = $[[2]]; unset $["a"]' $indir/abixy run_mlr --opprint put '$[[1]] = $b; unset $[[1]]' $indir/abixy run_mlr --opprint put '$[[1]] = $[[2]]; unset $["a"]' $indir/abixy # xxx to do -- there is an old bug here with lack of lhmsmv_unset on the typed overlay at unset run_mlr --opprint put 'unset $c' $indir/abixy run_mlr --opprint put 'unset $c; $c="new"' $indir/abixy run_mlr --opprint put '$c=$a.$b; unset $c; $c="new"' $indir/abixy run_mlr --opprint put '$c=$a.$b; unset $c' $indir/abixy # ---------------------------------------------------------------- announce IS-PREDICATES run_mlr --opprint put '$f=is_absent($x)' $indir/nullvals.dkvp run_mlr --opprint put '$f=is_absent($y)' $indir/nullvals.dkvp run_mlr --opprint put '$f=is_absent($z)' $indir/nullvals.dkvp run_mlr --opprint put '$f=is_absent($nosuch)' $indir/nullvals.dkvp run_mlr --opprint put '$f=is_absent(@nosuch)' $indir/nullvals.dkvp run_mlr --opprint put '@somesuch=1;$f=is_absent(@somesuch)' $indir/nullvals.dkvp run_mlr --opprint put '$f=is_bool($x>1)' $indir/nullvals.dkvp run_mlr --opprint put '$f=is_bool($y>1)' $indir/nullvals.dkvp run_mlr --opprint put '$f=is_bool($z>1)' $indir/nullvals.dkvp run_mlr --opprint put '$f=is_bool($nosuch>1)' $indir/nullvals.dkvp run_mlr --opprint put '$f=is_bool(@nosuch>1)' $indir/nullvals.dkvp run_mlr --opprint put '@somesuch=1;$f=is_bool(@somesuch>1)' $indir/nullvals.dkvp run_mlr --opprint put '$f=is_boolean($x>1)' $indir/nullvals.dkvp run_mlr --opprint put '$f=is_boolean($y>1)' $indir/nullvals.dkvp run_mlr --opprint put '$f=is_boolean($z>1)' $indir/nullvals.dkvp run_mlr --opprint put '$f=is_boolean($nosuch>1)' $indir/nullvals.dkvp run_mlr --opprint put '$f=is_boolean(@nosuch>1)' $indir/nullvals.dkvp run_mlr --opprint put '@somesuch=1;$f=is_boolean(@somesuch>1)' $indir/nullvals.dkvp run_mlr --opprint put '$f=is_empty($x)' $indir/nullvals.dkvp run_mlr --opprint put '$f=is_empty($y)' $indir/nullvals.dkvp run_mlr --opprint put '$f=is_empty($z)' $indir/nullvals.dkvp run_mlr --opprint put '$f=is_empty($nosuch)' $indir/nullvals.dkvp run_mlr --opprint put '$f=is_empty(@nosuch)' $indir/nullvals.dkvp run_mlr --opprint put '$f=is_empty($*)' $indir/nullvals.dkvp run_mlr --opprint put '$f=is_empty({1:2})' $indir/nullvals.dkvp run_mlr --opprint put '@somesuch=1;$f=is_empty(@somesuch)' $indir/nullvals.dkvp run_mlr --opprint put '$f=is_empty_map($x)' $indir/nullvals.dkvp run_mlr --opprint put '$f=is_empty_map($y)' $indir/nullvals.dkvp run_mlr --opprint put '$f=is_empty_map($z)' $indir/nullvals.dkvp run_mlr --opprint put '$f=is_empty_map($nosuch)' $indir/nullvals.dkvp run_mlr --opprint put '$f=is_empty_map(@nosuch)' $indir/nullvals.dkvp run_mlr --opprint put '$f=is_empty_map($*)' $indir/nullvals.dkvp run_mlr --opprint put '$f=is_empty_map({1:2})' $indir/nullvals.dkvp run_mlr --opprint put '$f=is_empty_map({})' $indir/nullvals.dkvp run_mlr --opprint put '@somesuch=1;$f=is_empty_map(@somesuch)' $indir/nullvals.dkvp run_mlr --opprint put '$f=is_float($x)' $indir/nullvals.dkvp run_mlr --opprint put '$f=is_float($y)' $indir/nullvals.dkvp run_mlr --opprint put '$f=is_float($z)' $indir/nullvals.dkvp run_mlr --opprint put '$f=is_float($nosuch)' $indir/nullvals.dkvp run_mlr --opprint put '$f=is_float(@nosuch)' $indir/nullvals.dkvp run_mlr --opprint put '$f=is_float($*)' $indir/nullvals.dkvp run_mlr --opprint put '$f=is_float({1:2})' $indir/nullvals.dkvp run_mlr --opprint put '@somesuch=1;$f=is_float(@somesuch)' $indir/nullvals.dkvp run_mlr --opprint put '$f=is_int($x)' $indir/nullvals.dkvp run_mlr --opprint put '$f=is_int($y)' $indir/nullvals.dkvp run_mlr --opprint put '$f=is_int($z)' $indir/nullvals.dkvp run_mlr --opprint put '$f=is_int($nosuch)' $indir/nullvals.dkvp run_mlr --opprint put '$f=is_int(@nosuch)' $indir/nullvals.dkvp run_mlr --opprint put '$f=is_int($*)' $indir/nullvals.dkvp run_mlr --opprint put '$f=is_int({1:2})' $indir/nullvals.dkvp run_mlr --opprint put '@somesuch=1;$f=is_int(@somesuch)' $indir/nullvals.dkvp run_mlr --opprint put '$f=is_map($x)' $indir/nullvals.dkvp run_mlr --opprint put '$f=is_map($y)' $indir/nullvals.dkvp run_mlr --opprint put '$f=is_map($z)' $indir/nullvals.dkvp run_mlr --opprint put '$f=is_map($nosuch)' $indir/nullvals.dkvp run_mlr --opprint put '$f=is_map(@nosuch)' $indir/nullvals.dkvp run_mlr --opprint put '$f=is_map($*)' $indir/nullvals.dkvp run_mlr --opprint put '$f=is_map({1:2})' $indir/nullvals.dkvp run_mlr --opprint put '$f=is_map({})' $indir/nullvals.dkvp run_mlr --opprint put '@somesuch=1;$f=is_map(@somesuch)' $indir/nullvals.dkvp run_mlr --opprint put '$f=is_nonempty_map($x)' $indir/nullvals.dkvp run_mlr --opprint put '$f=is_nonempty_map($y)' $indir/nullvals.dkvp run_mlr --opprint put '$f=is_nonempty_map($z)' $indir/nullvals.dkvp run_mlr --opprint put '$f=is_nonempty_map($nosuch)' $indir/nullvals.dkvp run_mlr --opprint put '$f=is_nonempty_map(@nosuch)' $indir/nullvals.dkvp run_mlr --opprint put '$f=is_nonempty_map($*)' $indir/nullvals.dkvp run_mlr --opprint put '$f=is_nonempty_map({1:2})' $indir/nullvals.dkvp run_mlr --opprint put '$f=is_nonempty_map({})' $indir/nullvals.dkvp run_mlr --opprint put '@somesuch=1;$f=is_nonempty_map(@somesuch)' $indir/nullvals.dkvp run_mlr --opprint put '$f=is_not_empty($x)' $indir/nullvals.dkvp run_mlr --opprint put '$f=is_not_empty($y)' $indir/nullvals.dkvp run_mlr --opprint put '$f=is_not_empty($z)' $indir/nullvals.dkvp run_mlr --opprint put '$f=is_not_empty($nosuch)' $indir/nullvals.dkvp run_mlr --opprint put '$f=is_not_empty(@nosuch)' $indir/nullvals.dkvp run_mlr --opprint put '$f=is_not_empty($*)' $indir/nullvals.dkvp run_mlr --opprint put '$f=is_not_empty({1:2})' $indir/nullvals.dkvp run_mlr --opprint put '@somesuch=1;$f=is_not_empty(@somesuch)' $indir/nullvals.dkvp run_mlr --opprint put '$f=is_not_map($x)' $indir/nullvals.dkvp run_mlr --opprint put '$f=is_not_map($y)' $indir/nullvals.dkvp run_mlr --opprint put '$f=is_not_map($z)' $indir/nullvals.dkvp run_mlr --opprint put '$f=is_not_map($nosuch)' $indir/nullvals.dkvp run_mlr --opprint put '$f=is_not_map(@nosuch)' $indir/nullvals.dkvp run_mlr --opprint put '$f=is_not_map($*)' $indir/nullvals.dkvp run_mlr --opprint put '$f=is_not_map({1:2})' $indir/nullvals.dkvp run_mlr --opprint put '$f=is_not_map({})' $indir/nullvals.dkvp run_mlr --opprint put '@somesuch=1;$f=is_not_map(@somesuch)' $indir/nullvals.dkvp run_mlr --opprint put '$f=is_not_null($x)' $indir/nullvals.dkvp run_mlr --opprint put '$f=is_not_null($y)' $indir/nullvals.dkvp run_mlr --opprint put '$f=is_not_null($z)' $indir/nullvals.dkvp run_mlr --opprint put '$f=is_not_null($nosuch)' $indir/nullvals.dkvp run_mlr --opprint put '$f=is_not_null(@nosuch)' $indir/nullvals.dkvp run_mlr --opprint put '@somesuch=1;$f=is_not_null(@somesuch)' $indir/nullvals.dkvp run_mlr --opprint put '$f=is_null($x)' $indir/nullvals.dkvp run_mlr --opprint put '$f=is_null($y)' $indir/nullvals.dkvp run_mlr --opprint put '$f=is_null($z)' $indir/nullvals.dkvp run_mlr --opprint put '$f=is_null($nosuch)' $indir/nullvals.dkvp run_mlr --opprint put '$f=is_null(@nosuch)' $indir/nullvals.dkvp run_mlr --opprint put '@somesuch=1;$f=is_null(@somesuch)' $indir/nullvals.dkvp run_mlr --opprint put '$f=is_numeric($x)' $indir/nullvals.dkvp run_mlr --opprint put '$f=is_numeric($y)' $indir/nullvals.dkvp run_mlr --opprint put '$f=is_numeric($z)' $indir/nullvals.dkvp run_mlr --opprint put '$f=is_numeric($nosuch)' $indir/nullvals.dkvp run_mlr --opprint put '$f=is_numeric(@nosuch)' $indir/nullvals.dkvp run_mlr --opprint put '@somesuch=1;$f=is_numeric(@somesuch)' $indir/nullvals.dkvp run_mlr --opprint put '$f=is_present($x)' $indir/nullvals.dkvp run_mlr --opprint put '$f=is_present($y)' $indir/nullvals.dkvp run_mlr --opprint put '$f=is_present($z)' $indir/nullvals.dkvp run_mlr --opprint put '$f=is_present($nosuch)' $indir/nullvals.dkvp run_mlr --opprint put '$f=is_present(@nosuch)' $indir/nullvals.dkvp run_mlr --opprint put '@somesuch=1;$f=is_present(@somesuch)' $indir/nullvals.dkvp run_mlr --opprint put '$f=is_string($x)' $indir/nullvals.dkvp run_mlr --opprint put '$f=is_string($y)' $indir/nullvals.dkvp run_mlr --opprint put '$f=is_string($z)' $indir/nullvals.dkvp run_mlr --opprint put '$f=is_string($nosuch)' $indir/nullvals.dkvp run_mlr --opprint put '$f=is_string(@nosuch)' $indir/nullvals.dkvp run_mlr --opprint put '@somesuch=1;$f=is_string(@somesuch)' $indir/nullvals.dkvp # ---------------------------------------------------------------- announce ASSERTION PASS-THROUGHS run_mlr --opprint put '$f=asserting_absent($nosuch)' $indir/nullvals.dkvp run_mlr --opprint put '$f=asserting_absent(@nosuch)' $indir/nullvals.dkvp mlr_expect_fail --opprint put '$f=asserting_absent($x)' $indir/nullvals.dkvp mlr_expect_fail --opprint put '$f=asserting_absent($y)' $indir/nullvals.dkvp mlr_expect_fail --opprint put '$f=asserting_absent($z)' $indir/nullvals.dkvp mlr_expect_fail --opprint put '@somesuch=1;$f=asserting_absent(@somesuch)' $indir/nullvals.dkvp mlr_expect_fail --opprint put 'foo=asserting_absent($*)' $indir/nullvals.dkvp mlr_expect_fail --opprint put 'foo=asserting_absent({1:2})' $indir/nullvals.dkvp run_mlr --opprint put '$f=asserting_empty($z)' $indir/nullvals.dkvp mlr_expect_fail --opprint put '$f=asserting_empty($x)' $indir/nullvals.dkvp mlr_expect_fail --opprint put '$f=asserting_empty($y)' $indir/nullvals.dkvp mlr_expect_fail --opprint put '$f=asserting_empty($nosuch)' $indir/nullvals.dkvp mlr_expect_fail --opprint put '$f=asserting_empty(@nosuch)' $indir/nullvals.dkvp mlr_expect_fail --opprint put '$f=asserting_empty({1:2})' $indir/nullvals.dkvp mlr_expect_fail --opprint put '@somesuch=1;$f=asserting_empty(@somesuch)' $indir/nullvals.dkvp mlr_expect_fail --opprint put 'foo=asserting_empty($*)' $indir/nullvals.dkvp mlr_expect_fail --opprint put 'foo=asserting_empty({1:2})' $indir/nullvals.dkvp run_mlr --opprint put '$f=asserting_empty_map({})' $indir/nullvals.dkvp mlr_expect_fail --opprint put '$f=asserting_empty_map($*)' $indir/nullvals.dkvp mlr_expect_fail --opprint put '$f=asserting_empty_map($x)' $indir/nullvals.dkvp mlr_expect_fail --opprint put '$f=asserting_empty_map($y)' $indir/nullvals.dkvp mlr_expect_fail --opprint put '$f=asserting_empty_map($z)' $indir/nullvals.dkvp mlr_expect_fail --opprint put '$f=asserting_empty_map($nosuch)' $indir/nullvals.dkvp mlr_expect_fail --opprint put '$f=asserting_empty_map(@nosuch)' $indir/nullvals.dkvp mlr_expect_fail --opprint put '$f=asserting_empty_map({1:2})' $indir/nullvals.dkvp mlr_expect_fail --opprint put '@somesuch=1;$f=asserting_empty_map(@somesuch)' $indir/nullvals.dkvp run_mlr --opprint put '$f=asserting_map($*)' $indir/nullvals.dkvp run_mlr --opprint put '$f=asserting_map({1:2})' $indir/nullvals.dkvp run_mlr --opprint put '$f=asserting_map({})' $indir/nullvals.dkvp mlr_expect_fail --opprint put '$f=asserting_map($x)' $indir/nullvals.dkvp mlr_expect_fail --opprint put '$f=asserting_map($y)' $indir/nullvals.dkvp mlr_expect_fail --opprint put '$f=asserting_map($z)' $indir/nullvals.dkvp mlr_expect_fail --opprint put '$f=asserting_map($nosuch)' $indir/nullvals.dkvp mlr_expect_fail --opprint put '$f=asserting_map(@nosuch)' $indir/nullvals.dkvp mlr_expect_fail --opprint put '@somesuch=1;$f=asserting_map(@somesuch)' $indir/nullvals.dkvp run_mlr --opprint put '$f=asserting_nonempty_map($*)' $indir/nullvals.dkvp run_mlr --opprint put '$f=asserting_nonempty_map({1:2})' $indir/nullvals.dkvp mlr_expect_fail --opprint put '$f=asserting_nonempty_map($x)' $indir/nullvals.dkvp mlr_expect_fail --opprint put '$f=asserting_nonempty_map($y)' $indir/nullvals.dkvp mlr_expect_fail --opprint put '$f=asserting_nonempty_map($z)' $indir/nullvals.dkvp mlr_expect_fail --opprint put '$f=asserting_nonempty_map($nosuch)' $indir/nullvals.dkvp mlr_expect_fail --opprint put '$f=asserting_nonempty_map(@nosuch)' $indir/nullvals.dkvp mlr_expect_fail --opprint put '$f=asserting_nonempty_map({})' $indir/nullvals.dkvp mlr_expect_fail --opprint put '@somesuch=1;$f=asserting_nonempty_map(@somesuch)' $indir/nullvals.dkvp run_mlr --opprint put '$*=asserting_not_empty($*)' $indir/nullvals.dkvp run_mlr --opprint put '$f=asserting_not_empty($nosuch)' $indir/nullvals.dkvp run_mlr --opprint put '$f=asserting_not_empty(@nosuch)' $indir/nullvals.dkvp run_mlr --opprint put '$f=asserting_not_empty({1:2})' $indir/nullvals.dkvp run_mlr --opprint put '$nosuch=asserting_not_empty($nosuch)' $indir/nullvals.dkvp run_mlr --opprint put '@somesuch=1;$f=asserting_not_empty(@somesuch)' $indir/nullvals.dkvp run_mlr --opprint put '$*=asserting_not_empty($*)' $indir/nullvals.dkvp run_mlr --opprint put '$*=asserting_not_empty({1:2})' $indir/nullvals.dkvp mlr_expect_fail --opprint put '$f=asserting_not_empty($x)' $indir/nullvals.dkvp mlr_expect_fail --opprint put '$f=asserting_not_empty($y)' $indir/nullvals.dkvp mlr_expect_fail --opprint put '$f=asserting_not_empty($z)' $indir/nullvals.dkvp run_mlr --opprint put '$f=asserting_not_map($x)' $indir/nullvals.dkvp run_mlr --opprint put '$f=asserting_not_map($y)' $indir/nullvals.dkvp run_mlr --opprint put '$f=asserting_not_map($z)' $indir/nullvals.dkvp run_mlr --opprint put '$f=asserting_not_map($nosuch)' $indir/nullvals.dkvp run_mlr --opprint put '$f=asserting_not_map(@nosuch)' $indir/nullvals.dkvp run_mlr --opprint put '@somesuch=1;$f=asserting_not_map(@somesuch)' $indir/nullvals.dkvp mlr_expect_fail --opprint put '$f=asserting_not_map($*)' $indir/nullvals.dkvp mlr_expect_fail --opprint put '$f=asserting_not_map({1:2})' $indir/nullvals.dkvp mlr_expect_fail --opprint put '$f=asserting_not_map({})' $indir/nullvals.dkvp run_mlr --opprint put '@somesuch=1;$f=asserting_not_null(@somesuch)' $indir/nullvals.dkvp run_mlr --opprint put '$*=asserting_not_null($*)' $indir/nullvals.dkvp run_mlr --opprint put '$*=asserting_not_null({1:2})' $indir/nullvals.dkvp mlr_expect_fail --opprint put '$f=asserting_not_null($x)' $indir/nullvals.dkvp mlr_expect_fail --opprint put '$f=asserting_not_null($y)' $indir/nullvals.dkvp mlr_expect_fail --opprint put '$f=asserting_not_null($z)' $indir/nullvals.dkvp mlr_expect_fail --opprint put '$f=asserting_not_null($nosuch)' $indir/nullvals.dkvp mlr_expect_fail --opprint put '$f=asserting_not_null(@nosuch)' $indir/nullvals.dkvp run_mlr --opprint put '$f=asserting_null($z)' $indir/nullvals.dkvp run_mlr --opprint put '$f=asserting_null($nosuch)' $indir/nullvals.dkvp run_mlr --opprint put '$f=asserting_null(@nosuch)' $indir/nullvals.dkvp mlr_expect_fail --opprint put '$f=asserting_null($x)' $indir/nullvals.dkvp mlr_expect_fail --opprint put '$f=asserting_null($y)' $indir/nullvals.dkvp mlr_expect_fail --opprint put '@somesuch=1;$f=asserting_null(@somesuch)' $indir/nullvals.dkvp mlr_expect_fail --opprint put '$*=asserting_null($*)' $indir/nullvals.dkvp mlr_expect_fail --opprint put '$*=asserting_null({1:2})' $indir/nullvals.dkvp mlr_expect_fail --opprint put '$f=asserting_numeric($x)' $indir/nullvals.dkvp mlr_expect_fail --opprint put '$f=asserting_numeric($y)' $indir/nullvals.dkvp mlr_expect_fail --opprint put '$f=asserting_numeric($z)' $indir/nullvals.dkvp mlr_expect_fail --opprint put '$*=asserting_numeric($*)' $indir/nullvals.dkvp mlr_expect_fail --opprint put '$*=asserting_numeric({1:2})' $indir/nullvals.dkvp mlr_expect_fail --opprint put '$f=asserting_numeric($nosuch)' $indir/nullvals.dkvp run_mlr --opprint put '$f=asserting_present($x)' $indir/nullvals.dkvp run_mlr --opprint put '$f=asserting_present($y)' $indir/nullvals.dkvp run_mlr --opprint put '$f=asserting_present($z)' $indir/nullvals.dkvp run_mlr --opprint put '@somesuch=1;$f=asserting_present(@somesuch)' $indir/nullvals.dkvp run_mlr --opprint put '$*=asserting_present($*)' $indir/nullvals.dkvp run_mlr --opprint put '$*=asserting_present({1:2})' $indir/nullvals.dkvp mlr_expect_fail --opprint put '$f=asserting_present($nosuch)' $indir/nullvals.dkvp mlr_expect_fail --opprint put '$f=asserting_present(@nosuch)' $indir/nullvals.dkvp run_mlr --opprint put '$f=asserting_string($z)' $indir/nullvals.dkvp mlr_expect_fail --opprint put '$*=asserting_string($*)' $indir/nullvals.dkvp mlr_expect_fail --opprint put '$*=asserting_string({1:2})' $indir/nullvals.dkvp mlr_expect_fail --opprint put '$f=asserting_string($x)' $indir/nullvals.dkvp mlr_expect_fail --opprint put '$f=asserting_string($y)' $indir/nullvals.dkvp mlr_expect_fail --opprint put '$f=asserting_string($nosuch)' $indir/nullvals.dkvp # ---------------------------------------------------------------- announce DSL NULL/EMPTY HANDLING run_mlr put '$z = $s . $s' $indir/null-vs-empty.dkvp run_mlr put '$z = $s == ""' $indir/null-vs-empty.dkvp run_mlr put '$z = $s == $s' $indir/null-vs-empty.dkvp run_mlr put '$z = is_empty($s)' $indir/null-vs-empty.dkvp run_mlr put '$z = $x + $y' $indir/null-vs-empty.dkvp run_mlr put '$z = $y + $y' $indir/null-vs-empty.dkvp run_mlr put '$z = $x + $nosuch' $indir/null-vs-empty.dkvp run_mlr put '$t = sub($s, "ell", "X")' $indir/null-vs-empty.dkvp run_mlr put '$t = sub($s, "ell", "")' $indir/null-vs-empty.dkvp run_mlr put '$t = sub($nosuch, "ell", "X")' $indir/null-vs-empty.dkvp run_mlr put '$t = gsub($s, "l", "X")' $indir/null-vs-empty.dkvp run_mlr put '$t = gsub($s, "l", "")' $indir/null-vs-empty.dkvp run_mlr put '$t = gsub($nosuch, "l", "X")' $indir/null-vs-empty.dkvp mention EMIT run_mlr put -q '@v=1; @nonesuch {emit @v}' $indir/abixy run_mlr put -q '@v=1; @nonesuch==true {emit @v}' $indir/abixy run_mlr put -q '@v=1; $nonesuch {emit @v}' $indir/abixy run_mlr put -q '@v=1; $nonesuch==true {emit @v}' $indir/abixy mention PLUS run_mlr --ofs tab put 'begin{}; $xy = $x + $y; $sy = @s + $y; $xt = $x + @t; $st = @s + @t' $indir/typeof.dkvp run_mlr --ofs tab put 'begin{@s=3}; $xy = $x + $y; $sy = @s + $y; $xt = $x + @t; $st = @s + @t' $indir/typeof.dkvp run_mlr --ofs tab put 'begin{@t=4}; $xy = $x + $y; $sy = @s + $y; $xt = $x + @t; $st = @s + @t' $indir/typeof.dkvp run_mlr --ofs tab put 'begin{@s=3;@t=4}; $xy = $x + $y; $sy = @s + $y; $xt = $x + @t; $st = @s + @t' $indir/typeof.dkvp mention MINUS run_mlr --ofs tab put 'begin{}; $xy = $x - $y; $sy = @s - $y; $xt = $x - @t; $st = @s - @t' $indir/typeof.dkvp run_mlr --ofs tab put 'begin{@s=3}; $xy = $x - $y; $sy = @s - $y; $xt = $x - @t; $st = @s - @t' $indir/typeof.dkvp run_mlr --ofs tab put 'begin{@t=4}; $xy = $x - $y; $sy = @s - $y; $xt = $x - @t; $st = @s - @t' $indir/typeof.dkvp run_mlr --ofs tab put 'begin{@s=3;@t=4}; $xy = $x - $y; $sy = @s - $y; $xt = $x - @t; $st = @s - @t' $indir/typeof.dkvp mention TIMES run_mlr --ofs tab put 'begin{}; $xy = $x * $y; $sy = @s * $y; $xt = $x * @t; $st = @s * @t' $indir/typeof.dkvp run_mlr --ofs tab put 'begin{@s=3}; $xy = $x * $y; $sy = @s * $y; $xt = $x * @t; $st = @s * @t' $indir/typeof.dkvp run_mlr --ofs tab put 'begin{@t=4}; $xy = $x * $y; $sy = @s * $y; $xt = $x * @t; $st = @s * @t' $indir/typeof.dkvp run_mlr --ofs tab put 'begin{@s=3;@t=4}; $xy = $x * $y; $sy = @s * $y; $xt = $x * @t; $st = @s * @t' $indir/typeof.dkvp mention DIVIDE run_mlr --ofs tab put 'begin{}; $xy = $x / $y; $sy = @s / $y; $xt = $x / @t; $st = @s / @t' $indir/typeof.dkvp run_mlr --ofs tab put 'begin{@s=3}; $xy = $x / $y; $sy = @s / $y; $xt = $x / @t; $st = @s / @t' $indir/typeof.dkvp run_mlr --ofs tab put 'begin{@t=4}; $xy = $x / $y; $sy = @s / $y; $xt = $x / @t; $st = @s / @t' $indir/typeof.dkvp run_mlr --ofs tab put 'begin{@s=3;@t=4}; $xy = $x / $y; $sy = @s / $y; $xt = $x / @t; $st = @s / @t' $indir/typeof.dkvp mention INTEGER DIVIDE run_mlr --ofs tab put 'begin{}; $xy = $x // $y; $sy = @s // $y; $xt = $x // @t; $st = @s // @t' $indir/typeof.dkvp run_mlr --ofs tab put 'begin{@s=3}; $xy = $x // $y; $sy = @s // $y; $xt = $x // @t; $st = @s // @t' $indir/typeof.dkvp run_mlr --ofs tab put 'begin{@t=4}; $xy = $x // $y; $sy = @s // $y; $xt = $x // @t; $st = @s // @t' $indir/typeof.dkvp run_mlr --ofs tab put 'begin{@s=3;@t=4}; $xy = $x // $y; $sy = @s // $y; $xt = $x // @t; $st = @s // @t' $indir/typeof.dkvp mention REMAINDER run_mlr --ofs tab put 'begin{}; $xy = $x % $y; $sy = @s % $y; $xt = $x % @t; $st = @s % @t' $indir/typeof.dkvp run_mlr --ofs tab put 'begin{@s=3}; $xy = $x % $y; $sy = @s % $y; $xt = $x % @t; $st = @s % @t' $indir/typeof.dkvp run_mlr --ofs tab put 'begin{@t=4}; $xy = $x % $y; $sy = @s % $y; $xt = $x % @t; $st = @s % @t' $indir/typeof.dkvp run_mlr --ofs tab put 'begin{@s=3;@t=4}; $xy = $x % $y; $sy = @s % $y; $xt = $x % @t; $st = @s % @t' $indir/typeof.dkvp mention BITWISE AND run_mlr --ofs tab put 'begin{}; $xy = $x & $y; $sy = @s & $y; $xt = $x & @t; $st = @s & @t' $indir/typeof.dkvp run_mlr --ofs tab put 'begin{@s=3}; $xy = $x & $y; $sy = @s & $y; $xt = $x & @t; $st = @s & @t' $indir/typeof.dkvp run_mlr --ofs tab put 'begin{@t=4}; $xy = $x & $y; $sy = @s & $y; $xt = $x & @t; $st = @s & @t' $indir/typeof.dkvp run_mlr --ofs tab put 'begin{@s=3;@t=4}; $xy = $x & $y; $sy = @s & $y; $xt = $x & @t; $st = @s & @t' $indir/typeof.dkvp mention BITWISE OR run_mlr --ofs tab put 'begin{}; $xy = $x | $y; $sy = @s | $y; $xt = $x | @t; $st = @s | @t' $indir/typeof.dkvp run_mlr --ofs tab put 'begin{@s=3}; $xy = $x | $y; $sy = @s | $y; $xt = $x | @t; $st = @s | @t' $indir/typeof.dkvp run_mlr --ofs tab put 'begin{@t=4}; $xy = $x | $y; $sy = @s | $y; $xt = $x | @t; $st = @s | @t' $indir/typeof.dkvp run_mlr --ofs tab put 'begin{@s=3;@t=4}; $xy = $x | $y; $sy = @s | $y; $xt = $x | @t; $st = @s | @t' $indir/typeof.dkvp mention BITWISE XOR run_mlr --ofs tab put 'begin{}; $xy = $x ^ $y; $sy = @s ^ $y; $xt = $x ^ @t; $st = @s ^ @t' $indir/typeof.dkvp run_mlr --ofs tab put 'begin{@s=3}; $xy = $x ^ $y; $sy = @s ^ $y; $xt = $x ^ @t; $st = @s ^ @t' $indir/typeof.dkvp run_mlr --ofs tab put 'begin{@t=4}; $xy = $x ^ $y; $sy = @s ^ $y; $xt = $x ^ @t; $st = @s ^ @t' $indir/typeof.dkvp run_mlr --ofs tab put 'begin{@s=3;@t=4}; $xy = $x ^ $y; $sy = @s ^ $y; $xt = $x ^ @t; $st = @s ^ @t' $indir/typeof.dkvp # ---------------------------------------------------------------- announce DSL TYPE PREDICATES run_mlr --from $indir/abixy --opprint put ' for (k, v in $*) { $[k."_type"] = typeof(v) } ' run_mlr --from $indir/abixy-het put -q 'for (k,v in $*) {if (is_float(v)) {@float[NR][k] = v}} end{ emit @float, "NR", "k" }' run_mlr --from $indir/abixy-het put -q 'for (k,v in $*) {if (is_int(v)) {@int[NR][k] = v}} end{ emit @int, "NR", "k" }' run_mlr --from $indir/abixy-het put -q 'for (k,v in $*) {if (is_numeric(v)) {@numeric[NR][k] = v}} end{ emit @numeric, "NR", "k" }' run_mlr --from $indir/abixy-het put -q 'for (k,v in $*) {if (is_string(v)) {@string[NR][k] = v}} end{ emit @string, "NR", "k" }' run_mlr --from $indir/abixy-het put -q 'for (k,v in $*) {if (is_bool(v)) {@bool[NR][k] = v}} end{ emit @bool, "NR", "k" }' run_mlr --from $indir/abixy-het put -q 'for (k,v in $*) {if (is_bool(NR==2)) {@bool[NR][k] = "NR==2"}} end{ emit @bool, "NR", "k" }' # ---------------------------------------------------------------- announce DSL TYPE-INFERENCE run_mlr --xtab put '$y = $pi1 + $pi2' $indir/mixed-types.xtab run_mlr --xtab put -F '$y = $pi1 + $pi2' $indir/mixed-types.xtab run_mlr --xtab put -S '$y = $pi1 . $pi2' $indir/mixed-types.xtab 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 --xtab put '$y=abs($pf1)' $indir/mixed-types.xtab run_mlr --xtab put '$y=abs($nf1)' $indir/mixed-types.xtab run_mlr --xtab put '$y=abs($zf)' $indir/mixed-types.xtab run_mlr --xtab put '$y=abs($pi1)' $indir/mixed-types.xtab run_mlr --xtab put '$y=abs($ni1)' $indir/mixed-types.xtab run_mlr --xtab put '$y=abs($zi)' $indir/mixed-types.xtab run_mlr --xtab put -F '$y=abs($pf1)' $indir/mixed-types.xtab run_mlr --xtab put -F '$y=abs($nf1)' $indir/mixed-types.xtab run_mlr --xtab put -F '$y=abs($zf)' $indir/mixed-types.xtab run_mlr --xtab put -F '$y=abs($pi1)' $indir/mixed-types.xtab run_mlr --xtab put -F '$y=abs($ni1)' $indir/mixed-types.xtab run_mlr --xtab put -F '$y=abs($zi)' $indir/mixed-types.xtab run_mlr --xtab put '$y=ceil($pf1)' $indir/mixed-types.xtab run_mlr --xtab put '$y=ceil($nf1)' $indir/mixed-types.xtab run_mlr --xtab put '$y=ceil($zf)' $indir/mixed-types.xtab run_mlr --xtab put '$y=ceil($pi1)' $indir/mixed-types.xtab run_mlr --xtab put '$y=ceil($ni1)' $indir/mixed-types.xtab run_mlr --xtab put '$y=ceil($zi)' $indir/mixed-types.xtab run_mlr --xtab put -F '$y=floor($pf1)' $indir/mixed-types.xtab run_mlr --xtab put -F '$y=floor($nf1)' $indir/mixed-types.xtab run_mlr --xtab put -F '$y=floor($zf)' $indir/mixed-types.xtab run_mlr --xtab put -F '$y=floor($pi1)' $indir/mixed-types.xtab run_mlr --xtab put -F '$y=floor($ni1)' $indir/mixed-types.xtab run_mlr --xtab put -F '$y=floor($zi)' $indir/mixed-types.xtab run_mlr --xtab put '$y=round($pf1)' $indir/mixed-types.xtab run_mlr --xtab put '$y=round($nf1)' $indir/mixed-types.xtab run_mlr --xtab put '$y=round($zf)' $indir/mixed-types.xtab run_mlr --xtab put '$y=round($pi1)' $indir/mixed-types.xtab run_mlr --xtab put '$y=round($ni1)' $indir/mixed-types.xtab run_mlr --xtab put '$y=round($zi)' $indir/mixed-types.xtab run_mlr --xtab put -F '$y=round($pf1)' $indir/mixed-types.xtab run_mlr --xtab put -F '$y=round($nf1)' $indir/mixed-types.xtab run_mlr --xtab put -F '$y=round($zf)' $indir/mixed-types.xtab run_mlr --xtab put -F '$y=round($pi1)' $indir/mixed-types.xtab run_mlr --xtab put -F '$y=round($ni1)' $indir/mixed-types.xtab run_mlr --xtab put -F '$y=round($zi)' $indir/mixed-types.xtab run_mlr --xtab put '$y=sgn($pf1)' $indir/mixed-types.xtab run_mlr --xtab put '$y=sgn($nf1)' $indir/mixed-types.xtab run_mlr --xtab put '$y=sgn($zf)' $indir/mixed-types.xtab run_mlr --xtab put '$y=sgn($pi1)' $indir/mixed-types.xtab run_mlr --xtab put '$y=sgn($ni1)' $indir/mixed-types.xtab run_mlr --xtab put '$y=sgn($zi)' $indir/mixed-types.xtab run_mlr --xtab put -F '$y=sgn($pf1)' $indir/mixed-types.xtab run_mlr --xtab put -F '$y=sgn($nf1)' $indir/mixed-types.xtab run_mlr --xtab put -F '$y=sgn($zf)' $indir/mixed-types.xtab run_mlr --xtab put -F '$y=sgn($pi1)' $indir/mixed-types.xtab run_mlr --xtab put -F '$y=sgn($ni1)' $indir/mixed-types.xtab run_mlr --xtab put -F '$y=sgn($zi)' $indir/mixed-types.xtab run_mlr --xtab put '$min=min($pf1,$pf2);$max=max($pf1,$pf2)' $indir/mixed-types.xtab run_mlr --xtab put '$min=min($pf1,$pi2);$max=max($pf1,$pi2)' $indir/mixed-types.xtab run_mlr --xtab put '$min=min($pi1,$pf2);$max=max($pi1,$pf2)' $indir/mixed-types.xtab run_mlr --xtab put '$min=min($pi1,$pi2);$max=max($pi1,$pi2)' $indir/mixed-types.xtab run_mlr --xtab put -F '$min=min($pf1,$pf2);$max=max($pf1,$pf2)' $indir/mixed-types.xtab run_mlr --xtab put -F '$min=min($pf1,$pi2);$max=max($pf1,$pi2)' $indir/mixed-types.xtab run_mlr --xtab put -F '$min=min($pi1,$pf2);$max=max($pi1,$pf2)' $indir/mixed-types.xtab run_mlr --xtab put -F '$min=min($pi1,$pi2);$max=max($pi1,$pi2)' $indir/mixed-types.xtab run_mlr --xtab put '$min=min($pf1,$pf2);$max=max($pf1,$pf2)' $indir/mixed-types.xtab run_mlr --xtab put '$min=min($pf1,$pi2);$max=max($pf1,$pi2)' $indir/mixed-types.xtab run_mlr --xtab put '$min=min($pi1,$pf2);$max=max($pi1,$pf2)' $indir/mixed-types.xtab run_mlr --xtab put '$min=min($pi1,$pi2);$max=max($pi1,$pi2)' $indir/mixed-types.xtab run_mlr --xtab put -F '$min=min($pf1,$pf2);$max=max($pf1,$pf2)' $indir/mixed-types.xtab run_mlr --xtab put -F '$min=min($pf1,$pi2);$max=max($pf1,$pi2)' $indir/mixed-types.xtab run_mlr --xtab put -F '$min=min($pi1,$pf2);$max=max($pi1,$pf2)' $indir/mixed-types.xtab run_mlr --xtab put -F '$min=min($pi1,$pi2);$max=max($pi1,$pi2)' $indir/mixed-types.xtab run_mlr --xtab put '$sum=$pf1+$pf2;$diff=$pf1-$pf2' $indir/mixed-types.xtab run_mlr --xtab put '$sum=$pf1+$pi2;$diff=$pf1-$pi2' $indir/mixed-types.xtab run_mlr --xtab put '$sum=$pi1+$pf2;$diff=$pi1-$pf2' $indir/mixed-types.xtab run_mlr --xtab put '$sum=$pi1+$pi2;$diff=$pi1-$pi2' $indir/mixed-types.xtab run_mlr --xtab put -F '$sum=$pf1+$pf2;$diff=$pf1-$pf2' $indir/mixed-types.xtab run_mlr --xtab put -F '$sum=$pf1+$pi2;$diff=$pf1-$pi2' $indir/mixed-types.xtab run_mlr --xtab put -F '$sum=$pi1+$pf2;$diff=$pi1-$pf2' $indir/mixed-types.xtab run_mlr --xtab put -F '$sum=$pi1+$pi2;$diff=$pi1-$pi2' $indir/mixed-types.xtab run_mlr --xtab put '$prod=$pf1*$pf2;$quot=$pf1/$pf2' $indir/mixed-types.xtab run_mlr --xtab put '$prod=$pf1*$pi2;$quot=$pf1/$pi2' $indir/mixed-types.xtab run_mlr --xtab put '$prod=$pi1*$pf2;$quot=$pi1/$pf2' $indir/mixed-types.xtab run_mlr --xtab put '$prod=$pi1*$pi2;$quot=$pi1/$pi2' $indir/mixed-types.xtab run_mlr --xtab put -F '$prod=$pf1*$pf2;$quot=$pf1/$pf2' $indir/mixed-types.xtab run_mlr --xtab put -F '$prod=$pf1*$pi2;$quot=$pf1/$pi2' $indir/mixed-types.xtab run_mlr --xtab put -F '$prod=$pi1*$pf2;$quot=$pi1/$pf2' $indir/mixed-types.xtab run_mlr --xtab put -F '$prod=$pi1*$pi2;$quot=$pi1/$pi2' $indir/mixed-types.xtab run_mlr --xtab put '$iquot=$pf1//$pf2;$mod=$pf1%$pf2' $indir/mixed-types.xtab run_mlr --xtab put '$iquot=$pf1//$pi2;$mod=$pf1%$pi2' $indir/mixed-types.xtab run_mlr --xtab put '$iquot=$pi1//$pf2;$mod=$pi1%$pf2' $indir/mixed-types.xtab run_mlr --xtab put '$iquot=$pi1//$pi2;$mod=$pi1%$pi2' $indir/mixed-types.xtab run_mlr --xtab put -F '$iquot=$pf1//$pf2;$mod=$pf1%$pf2' $indir/mixed-types.xtab run_mlr --xtab put -F '$iquot=$pf1//$pi2;$mod=$pf1%$pi2' $indir/mixed-types.xtab run_mlr --xtab put -F '$iquot=$pi1//$pf2;$mod=$pi1%$pf2' $indir/mixed-types.xtab run_mlr --xtab put -F '$iquot=$pi1//$pi2;$mod=$pi1%$pi2' $indir/mixed-types.xtab run_mlr --xtab put '$a=roundm($pf1,10.0);$b=roundm($pf1,-10.0)' $indir/mixed-types.xtab run_mlr --xtab put '$a=roundm($pf1,10) ;$b=roundm($pf1,-10) ' $indir/mixed-types.xtab 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' # ---------------------------------------------------------------- announce DSL SCIENTIFIC NOTATION IN FIELD VALUES run_mlr --opprint put '$y=$x+1' $indir/scinot.dkvp # ---------------------------------------------------------------- announce DSL SCIENTIFIC NOTATION IN EXPRESSION LITERALS run_mlr --opprint put '$y = 123 + $i' $indir/scinot1.dkvp run_mlr --opprint put '$y = 123. + $i' $indir/scinot1.dkvp run_mlr --opprint put '$y = 123.4 + $i' $indir/scinot1.dkvp run_mlr --opprint put '$y = .234 + $i' $indir/scinot1.dkvp run_mlr --opprint put '$y = 1e2 + $i' $indir/scinot1.dkvp run_mlr --opprint put '$y = 1e-2 + $i' $indir/scinot1.dkvp run_mlr --opprint put '$y = 1.2e3 + $i' $indir/scinot1.dkvp run_mlr --opprint put '$y = 1.e3 + $i' $indir/scinot1.dkvp run_mlr --opprint put '$y = 1.2e-3 + $i' $indir/scinot1.dkvp run_mlr --opprint put '$y = 1.e-3 + $i' $indir/scinot1.dkvp run_mlr --opprint put '$y = .2e3 + $i' $indir/scinot1.dkvp run_mlr --opprint put '$y = .2e-3 + $i' $indir/scinot1.dkvp run_mlr --opprint put '$y = 1.e-3 + $i' $indir/scinot1.dkvp run_mlr --opprint put '$y = -123 + $i' $indir/scinot1.dkvp run_mlr --opprint put '$y = -123. + $i' $indir/scinot1.dkvp run_mlr --opprint put '$y = -123.4 + $i' $indir/scinot1.dkvp run_mlr --opprint put '$y = -.234 + $i' $indir/scinot1.dkvp run_mlr --opprint put '$y = -1e2 + $i' $indir/scinot1.dkvp run_mlr --opprint put '$y = -1e-2 + $i' $indir/scinot1.dkvp run_mlr --opprint put '$y = -1.2e3 + $i' $indir/scinot1.dkvp run_mlr --opprint put '$y = -1.e3 + $i' $indir/scinot1.dkvp run_mlr --opprint put '$y = -1.2e-3 + $i' $indir/scinot1.dkvp run_mlr --opprint put '$y = -1.e-3 + $i' $indir/scinot1.dkvp run_mlr --opprint put '$y = -.2e3 + $i' $indir/scinot1.dkvp run_mlr --opprint put '$y = -.2e-3 + $i' $indir/scinot1.dkvp run_mlr --opprint put '$y = -1.e-3 + $i' $indir/scinot1.dkvp # ---------------------------------------------------------------- announce DSL FROM-FILE FEATURE run_mlr put -f $indir/put-example.dsl $indir/abixy run_mlr filter -f $indir/filter-example.dsl $indir/abixy run_mlr --from $indir/abixy put -f $indir/put-example.dsl run_mlr --from $indir/abixy filter -f $indir/filter-example.dsl run_mlr --from $indir/abixy --from $indir/abixy-het put -f $indir/put-example.dsl run_mlr --from $indir/abixy --from $indir/abixy-het filter -f $indir/filter-example.dsl # ---------------------------------------------------------------- announce DSL MULTI-PART SCRIPTS run_mlr --opprint --from $indir/abixy put -f $indir/put-script-piece-1 run_mlr --opprint --from $indir/abixy put -f $indir/put-script-piece-1 -f $indir/put-script-piece-2 run_mlr --opprint --from $indir/abixy put -f $indir/put-script-piece-1 -f $indir/put-script-piece-2 -f $indir/put-script-piece-3 run_mlr --opprint --from $indir/abixy put -e '$xy = $x**2 + $y**2' run_mlr --opprint --from $indir/abixy filter -e 'NR == 7' run_mlr --opprint --from $indir/abixy put -e 'print "PRE";' -f $indir/put-script-piece-1 -f $indir/put-script-piece-2 -f $indir/put-script-piece-3 -e 'print "POST"' run_mlr --opprint --from $indir/abixy filter -f $indir/filter-script-piece-1 run_mlr --opprint --from $indir/abixy filter -f $indir/filter-script-piece-1 -f $indir/filter-script-piece-2 # ---------------------------------------------------------------- announce UTF-8 STRLEN run_mlr --inidx --ifs comma --oxtab put '$s1=strlen($1);$s2=strlen($2);$s3=strlen($3);$s4=strlen($4)' $indir/utf8-align.dkvp # ---------------------------------------------------------------- announce TRUNCATE for n in 0 1 2 3 4 5; do echo "x=abcd" | run_mlr put '$y=truncate($x, '$n')' done for n in 0 1 2 3 4 5; do echo "x=abcdefgh" | run_mlr put '$y=truncate($x, '$n')' done # ---------------------------------------------------------------- announce STATS1/STEP INT/FLOAT run_mlr --opprint step -a rsum,delta,counter -f x,y,z $indir/int-float.dkvp run_mlr --opprint step -F -a rsum,delta,counter -f x,y,z $indir/int-float.dkvp run_mlr --oxtab stats1 -a min,max,sum,count -f x,y,z $indir/int-float.dkvp run_mlr --oxtab stats1 -F -a min,max,sum,count -f x,y,z $indir/int-float.dkvp # ---------------------------------------------------------------- announce DSL PYTHONIC DIVISION run_mlr --xtab put '$quot=$pf1/10.0;$iquot=$pf1//10.0;$mod=$pf1%10.0' $indir/mixed-types.xtab run_mlr --xtab put '$quot=$pi1/10 ;$iquot=$pi1//10 ;$mod=$pi1%10 ' $indir/mixed-types.xtab run_mlr --xtab put '$quot=$nf1/10.0;$iquot=$nf1//10.0;$mod=$nf1%10.0' $indir/mixed-types.xtab run_mlr --xtab put '$quot=$ni1/10 ;$iquot=$ni1//10 ;$mod=$ni1%10 ' $indir/mixed-types.xtab run_mlr --xtab put -F '$quot=$pf1/10.0;$iquot=$pf1//10.0;$mod=$pf1%10.0' $indir/mixed-types.xtab run_mlr --xtab put -F '$quot=$pi1/10 ;$iquot=$pi1//10 ;$mod=$pi1%10 ' $indir/mixed-types.xtab run_mlr --xtab put -F '$quot=$nf1/10.0;$iquot=$nf1//10.0;$mod=$nf1%10.0' $indir/mixed-types.xtab run_mlr --xtab put -F '$quot=$ni1/10 ;$iquot=$ni1//10 ;$mod=$ni1%10 ' $indir/mixed-types.xtab run_mlr --xtab put '$quot=$pf1/-10.0;$iquot=$pf1//-10.0;$mod=$pf1%-10.0' $indir/mixed-types.xtab run_mlr --xtab put '$quot=$pi1/-10 ;$iquot=$pi1//-10 ;$mod=$pi1%-10 ' $indir/mixed-types.xtab run_mlr --xtab put '$quot=$nf1/-10.0;$iquot=$nf1//-10.0;$mod=$nf1%-10.0' $indir/mixed-types.xtab run_mlr --xtab put '$quot=$ni1/-10 ;$iquot=$ni1//-10 ;$mod=$ni1%-10 ' $indir/mixed-types.xtab run_mlr --xtab put -F '$quot=$pf1/-10.0;$iquot=$pf1//-10.0;$mod=$pf1%-10.0' $indir/mixed-types.xtab run_mlr --xtab put -F '$quot=$pi1/-10 ;$iquot=$pi1//-10 ;$mod=$pi1%-10 ' $indir/mixed-types.xtab run_mlr --xtab put -F '$quot=$nf1/-10.0;$iquot=$nf1//-10.0;$mod=$nf1%-10.0' $indir/mixed-types.xtab run_mlr --xtab put -F '$quot=$ni1/-10 ;$iquot=$ni1//-10 ;$mod=$ni1%-10 ' $indir/mixed-types.xtab # ---------------------------------------------------------------- announce DSL REGEX MATCHING run_mlr filter -v '$x =~ "bcd"' $indir/regex.dkvp run_mlr filter -v '$x =~ "^bcd"' $indir/regex.dkvp run_mlr filter -v '$x =~ "^abc"' $indir/regex.dkvp run_mlr filter -v '$x =~ "^abc$"' $indir/regex.dkvp run_mlr filter -v '$x =~ "^a.*d$"' $indir/regex.dkvp run_mlr filter -v '$x =~ "^a.*"."d$"' $indir/regex.dkvp run_mlr filter -v '$y =~ "\".."' $indir/regex.dkvp run_mlr filter -v '$x =~ "bcd"i' $indir/regex.dkvp run_mlr filter -v '$x =~ "^bcd"i' $indir/regex.dkvp run_mlr filter -v '$x =~ "^abc"i' $indir/regex.dkvp run_mlr filter -v '$x =~ "^abc$"i' $indir/regex.dkvp run_mlr filter -v '$x =~ "^a.*d$"i' $indir/regex.dkvp run_mlr filter -v '$x =~ "^a.*"."d$"i' $indir/regex.dkvp run_mlr --csv filter '$text =~ "."' $indir/dot-match.csv run_mlr --csv filter '$text =~ "\."' $indir/dot-match.csv # ---------------------------------------------------------------- announce DSL TYPED OVERLAY run_mlr put '$y = string($x); $z=$y.$y' $indir/int-float.dkvp run_mlr put '$z=string($x).string($x)' $indir/int-float.dkvp run_mlr put '$y = string($x)' then put '$z=$y.$y' $indir/int-float.dkvp run_mlr put '$a="hello"' then put '$b=$a." world";$z=$x+$y;$c=$b;$a=sub($b,"hello","farewell")' $indir/int-float.dkvp # ---------------------------------------------------------------- announce DSL REGEX CAPTURES # cat reg_test/input/capture.dkvp # FIELD=ABC123 # FIELD=ABC..123 # FIELD=..ABC..123.. # FIELD=none of the above run_mlr --opprint put '$FIELD =~ "([A-Z]+)([0-9]+)"; $F1="\1"; $F2="\2"; $F3="\3"' $indir/capture.dkvp run_mlr --opprint put '$FIELD =~ "([A-Z]+)[^0-9]*([0-9]+)"; $F1="\1"; $F2="\2"; $F3="\3"' $indir/capture.dkvp run_mlr --opprint put '$FIELD =~ "([A-Z]+)([0-9]+)"' then put '$F1="\1"; $F2="\2"; $F3="\3"' $indir/capture.dkvp run_mlr --opprint put '$FIELD =~ "([A-Z]+)[^0-9]*([0-9]+)"' then put '$F1="\1"; $F2="\2"; $F3="\3"' $indir/capture.dkvp # cat reg_test/input/capture-lengths.dkvp # FIELD= # FIELD=a # FIELD=ab # FIELD=abc # FIELD=abcd # FIELD=abcde # FIELD=abcdef # FIELD=abcdefg # FIELD=abcdefgh # FIELD=abcdefghi # FIELD=abcdefghij # FIELD=abcdefghijk # FIELD=abcdefghijkl run_mlr --opprint put ' $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 ' $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 run_mlr --opprint put '$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 '$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 '$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 '$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 '$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 '$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 '$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 '$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 '$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 '$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 '$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 '$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 '$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 '$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 '$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 '$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 '$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 '$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 '$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 '$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 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 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 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 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 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"}' # ---------------------------------------------------------------- announce DSL FILTER/PATTERN-ACTION run_mlr --opprint put ' $x > 0.5; $z = "flag"' $indir/abixy run_mlr --opprint put ' !($x > 0.5); $z = "flag"' $indir/abixy run_mlr --opprint put 'filter $x > 0.5; $z = "flag"' $indir/abixy run_mlr --opprint put ' $x > 0.5 {$z = "flag"}' $indir/abixy run_mlr --opprint put 'filter !($x > 0.5); $z = "flag"' $indir/abixy run_mlr --opprint put ' !($x > 0.5) {$z = "flag"}' $indir/abixy # ---------------------------------------------------------------- announce DSL GMT DATE/TIME FUNCTIONS run_mlr --csvlite put '$gmt = sec2gmt($sec)' $indir/sec2gmt run_mlr --csvlite put '$gmt = sec2gmt($sec,1)' $indir/sec2gmt run_mlr --csvlite put '$gmt = sec2gmt($sec,3)' $indir/sec2gmt run_mlr --csvlite put '$gmt = sec2gmt($sec,6)' $indir/sec2gmt run_mlr --csvlite put '$sec = gmt2sec($gmt)' $indir/gmt2sec run_mlr --csvlite put '$gmtdate = sec2gmtdate($sec)' $indir/sec2gmt run_mlr --icsv --opprint put '$gmt = strftime($sec, "%Y-%m-%dT%H:%M:%SZ")' $indir/sec2gmt run_mlr --icsv --opprint put '$gmt = strftime($sec, "%Y-%m-%dT%H:%M:%1SZ")' $indir/sec2gmt run_mlr --icsv --opprint put '$gmt = strftime($sec, "%Y-%m-%dT%H:%M:%3SZ")' $indir/sec2gmt run_mlr --icsv --opprint put '$gmt = strftime($sec, "%Y-%m-%dT%H:%M:%6SZ")' $indir/sec2gmt run_mlr --icsv --opprint put '$sec = strptime($gmt, "%Y-%m-%dT%H:%M:%SZ")' $indir/gmt2sec run_mlr --csvlite sec2gmt sec $indir/sec2gmt run_mlr --opprint put '$hms=sec2hms($sec); $resec=hms2sec($hms); $diff=$resec-$sec' $indir/sec2xhms run_mlr --opprint put '$hms=fsec2hms($sec); $resec=hms2fsec($hms); $diff=$resec-$sec' $indir/fsec2xhms run_mlr --opprint put '$hms=sec2dhms($sec); $resec=dhms2sec($hms); $diff=$resec-$sec' $indir/sec2xhms run_mlr --opprint put '$hms=fsec2dhms($sec); $resec=dhms2fsec($hms); $diff=$resec-$sec' $indir/fsec2xhms run_mlr --csvlite sec2gmt sec $indir/sec2gmt run_mlr --csvlite sec2gmtdate sec $indir/sec2gmt # ---------------------------------------------------------------- announce DSL LOCAL DATE/TIME FUNCTIONS # See also the system date command: # export TZ=America/Sao_Paulo; date -j -f "%Y-%m-%d %H:%M:%S %Z" "2017-02-19 00:30:00" +%s # export TZ=America/Sao_Paulo; date -r 86400 +"%Y-%m-%d %H:%M:%S %Z" export TZ=America/Sao_Paulo echo TZ=$TZ run_mlr --opprint put '$b=localtime2sec($a); $c=sec2localtime($b); $d=sec2localdate($b)' <<_EOF a=2017-02-18 23:00:00 a=2017-02-18 23:59:59 a=2017-02-19 00:00:00 a=2017-02-19 00:30:00 a=2017-02-19 01:00:00 a=2017-10-14 23:00:00 a=2017-10-14 23:59:59 a=2017-10-15 00:00:00 a=2017-10-15 00:30:00 a=2017-10-15 01:00:00 _EOF export TZ= export TZ=America/Sao_Paulo echo TZ=$TZ run_mlr --opprint put '$b=localtime2sec($a); $c=sec2localtime($b); $d=sec2localdate($b)' <<_EOF a=2017-02-14 00:00:00 a=2017-02-15 00:00:00 a=2017-02-16 00:00:00 a=2017-02-17 00:00:00 a=2017-02-18 00:00:00 a=2017-02-19 00:00:00 a=2017-02-20 00:00:00 a=2017-10-12 00:00:00 a=2017-10-13 00:00:00 a=2017-10-14 00:00:00 a=2017-10-15 00:00:00 a=2017-10-16 00:00:00 a=2017-10-17 00:00:00 a=2017-10-18 00:00:00 a=2017-10-19 00:00:00 _EOF export TZ= export TZ=America/Sao_Paulo echo TZ=$TZ run_mlr --opprint put '$b=strptime_local($a, "%Y-%m-%d %H:%M:%S"); $c=strftime_local($b, "%Y-%m-%d %H:%M:%S")' <<_EOF a=2017-02-18 23:00:00 a=2017-02-18 23:59:59 a=2017-02-19 00:00:00 a=2017-02-19 00:30:00 a=2017-02-19 01:00:00 a=2017-10-14 23:00:00 a=2017-10-14 23:59:59 a=2017-10-15 00:00:00 a=2017-10-15 00:30:00 a=2017-10-15 01:00:00 _EOF export TZ= export TZ=America/Sao_Paulo echo TZ=$TZ run_mlr --opprint put '$b=strptime_local($a, "%Y-%m-%d %H:%M:%S"); $c=strftime_local($b, "%Y-%m-%d %H:%M:%S")' <<_EOF a=2017-02-18 23:00:00 a=2017-02-18 23:59:59 a=2017-02-19 00:00:00 a=2017-02-19 00:30:00 a=2017-02-19 01:00:00 a=2017-10-14 23:00:00 a=2017-10-14 23:59:59 a=2017-10-15 00:00:00 a=2017-10-15 00:30:00 a=2017-10-15 01:00:00 _EOF export TZ= # ---------------------------------------------------------------- announce DSL SUB/GSUB/REGEX_EXTRACT run_mlr --opprint put '$y = sub($x, "e.*l", "")' $indir/sub.dat run_mlr --opprint put '$y = sub($x, "e.*l"i, "")' $indir/sub.dat run_mlr --opprint put '$y = sub($x, "e.*"."l", "")' $indir/sub.dat run_mlr --opprint put '$y = sub($x, "e.*l", "y123y")' $indir/sub.dat run_mlr --opprint put '$y = sub($x, "e.*l"i, "y123y")' $indir/sub.dat run_mlr --opprint put '$y = sub($x, "e.*"."l", "y123y")' $indir/sub.dat run_mlr --opprint put '$y = sub($x, "([hg])e.*l(.)", "y\1y123\2y")' $indir/sub.dat run_mlr --opprint put '$y = sub($x, "([hg])e.*l.", "y\1y123\2y")' $indir/sub.dat run_mlr --opprint put '$y = sub($x, "([hg])e.*l(.)", "y\1y123.y")' $indir/sub.dat run_mlr --opprint put '$y = sub($x, "a", "aa")' $indir/gsub.dat run_mlr --opprint put '$y = gsub($x, "a", "aa")' $indir/gsub.dat run_mlr --opprint put '$y = gsub($x, "A", "Aa")' $indir/gsub.dat run_mlr --opprint put '$y = gsub($x, "a"i, "Aa")' $indir/gsub.dat run_mlr --opprint put '$y = gsub($x, "A"i, "Aa")' $indir/gsub.dat run_mlr --opprint put '$y = gsub($x, "a(.)", "aa\1\1\1")' $indir/gsub.dat run_mlr --opprint put '$y = sub($x, "a", "")' $indir/gsub.dat run_mlr --opprint put '$y = gsub($x, "a", "")' $indir/gsub.dat run_mlr --opprint put '$y = gsub($x, "A", "")' $indir/gsub.dat run_mlr --opprint put '$y = gsub($x, "a"i, "")' $indir/gsub.dat run_mlr --opprint put '$y = gsub($x, "A"i, "")' $indir/gsub.dat run_mlr --oxtab cat $indir/subtab.dkvp run_mlr --oxtab put -f $indir/subtab1.mlr $indir/subtab.dkvp run_mlr --oxtab put -f $indir/subtab2.mlr $indir/subtab.dkvp run_mlr --oxtab put -f $indir/subtab3.mlr $indir/subtab.dkvp run_mlr --oxtab put -f $indir/subtab4.mlr $indir/subtab.dkvp run_mlr --opprint put '$y = ssub($x, "HE", "")' $indir/sub.dat run_mlr --opprint put '$y = ssub($x, "HE", "HE")' $indir/sub.dat run_mlr --opprint put '$y = ssub($x, "HE", "12345")' $indir/sub.dat run_mlr --opprint put '$y = ssub($x, "LL", "1")' $indir/sub.dat run_mlr --opprint put '$y = ssub($x, "LL", "12")' $indir/sub.dat run_mlr --opprint put '$y = ssub($x, "LL", "12345")' $indir/sub.dat run_mlr --opprint put '$y = ssub($x, "LLO", "")' $indir/sub.dat run_mlr --opprint put '$y = ssub($x, "LLO", "12")' $indir/sub.dat run_mlr --opprint put '$y = ssub($x, "LLO", "123")' $indir/sub.dat run_mlr --opprint put '$y = ssub($x, "LLO", "123456")' $indir/sub.dat run_mlr --opprint put '$y = ssub($x, "HELLO", "")' $indir/sub.dat run_mlr --opprint put '$y = ssub($x, "HELLO", "1234")' $indir/sub.dat run_mlr --opprint put '$y = ssub($x, "HELLO", "12345")' $indir/sub.dat run_mlr --opprint put '$y = ssub($x, "HELLO", "1234678")' $indir/sub.dat run_mlr --opprint put '$y = ssub($x, "nonesuch", "")' $indir/sub.dat run_mlr --opprint put '$y = ssub($x, "nonesuch", "1234")' $indir/sub.dat run_mlr --opprint put '$y = ssub($x, "nonesuch", "1234567890")' $indir/sub.dat run_mlr --oxtab put '$y = regextract($x, "[A-Z]+")' $indir/sub.dat run_mlr --oxtab put '$y = regextract($x, "[A-Z]*")' $indir/sub.dat run_mlr --oxtab put '$y = regextract($x, "[a-z]+")' $indir/sub.dat run_mlr --oxtab put '$y = regextract($x, "[a-z]*")' $indir/sub.dat run_mlr --oxtab put '$y = regextract($x, "[0-9]+")' $indir/sub.dat run_mlr --oxtab put '$y = regextract($x, "[0-9]*")' $indir/sub.dat run_mlr --oxtab put '$y = regextract($x, "[ef]+")' $indir/sub.dat run_mlr --oxtab put '$y = regextract($x, "[ef]*")' $indir/sub.dat run_mlr --oxtab put '$y = regextract($x, "[hi]+")' $indir/sub.dat run_mlr --oxtab put '$y = regextract($x, "[hi]*")' $indir/sub.dat run_mlr --oxtab put '$y = regextract($x, "[op]+")' $indir/sub.dat run_mlr --oxtab put '$y = regextract($x, "[op]*")' $indir/sub.dat run_mlr --oxtab put '$y = regextract_or_else($x, "[A-Z]+", "DEFAULT")' $indir/sub.dat run_mlr --oxtab put '$y = regextract_or_else($x, "[A-Z]*", "DEFAULT")' $indir/sub.dat run_mlr --oxtab put '$y = regextract_or_else($x, "[a-z]+", "DEFAULT")' $indir/sub.dat run_mlr --oxtab put '$y = regextract_or_else($x, "[a-z]*", "DEFAULT")' $indir/sub.dat run_mlr --oxtab put '$y = regextract_or_else($x, "[0-9]+", "DEFAULT")' $indir/sub.dat run_mlr --oxtab put '$y = regextract_or_else($x, "[0-9]*", "DEFAULT")' $indir/sub.dat run_mlr --oxtab put '$y = regextract_or_else($x, "[ef]+", "DEFAULT")' $indir/sub.dat run_mlr --oxtab put '$y = regextract_or_else($x, "[ef]*", "DEFAULT")' $indir/sub.dat run_mlr --oxtab put '$y = regextract_or_else($x, "[hi]+", "DEFAULT")' $indir/sub.dat run_mlr --oxtab put '$y = regextract_or_else($x, "[hi]*", "DEFAULT")' $indir/sub.dat 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")' # ---------------------------------------------------------------- announce DSL SUBSTR run_mlr put -q ' int n = strlen($x); print "input= <<".$x.">>"; for (i = -n-2; i <= n+2; i += 1) { for (j = -n-2; j <= n+2; j += 1) { print "i: ".fmtnum(i,"%3lld") ." j:".fmtnum(j,"%3lld") ." substr(".$x.",".fmtnum(i,"%3lld").",".fmtnum(j,"%3lld")."): <<" .substr($x, i, j) .">>"; } print; } ' << EOF x= x=o x=o1 x=o123456789 EOF # ---------------------------------------------------------------- announce DSL SYSTEM run_mlr put '$counter = system("echo X".NR."Y")' $indir/abixy # ---------------------------------------------------------------- announce DSL OOSVARS run_mlr --opprint put -v 'begin{@ox=0}; $d=$x-@ox; @ox=$x' $indir/abixy run_mlr --opprint put -v 'begin{@ox="no"}; $d=@ox == "no" ? 1.0 : $x/@ox; @ox=$x' then step -a ratio -f x $indir/abixy run_mlr --opprint put -v '$d=$x/@ox; @ox=$x' then step -a ratio -f x $indir/abixy run_mlr --opprint put -v 'begin{@ox="no"}; $d=@ox == "no" ? 1.0 : $x/@ox; @ox=$x' then step -a ratio -f x $indir/abixy run_mlr --opprint put -v 'begin{@rsum = 0}; @rsum = @rsum + $x; $rsum = @rsum' $indir/abixy run_mlr --opprint put -v 'begin{@a=0; @b=0; @c=0}; $za=@a; $zb=@b; $zc=@c; $d=@a+@b+@c; @a=@b; @b=@c; @c=$i' $indir/abixy run_mlr --opprint put -v 'begin {@a=0; @b=0; @c=0}; $za=@a; $zb=@b; $zc=@c; $d=@a+@b+@c; @a=@b; @b=@c; @c=$i' $indir/abixy run_mlr --opprint put -v 'begin{@ox=0}; $d=$x-@ox; @ox=$x' $indir/abixy run_mlr put -v '@a=$a; @b=$b; @c=$x; end {emitf @a; emitf @b; emitf @c}' $indir/abixy run_mlr put -v '@a=$a; @b=$b; @c=$x; end{emitf @a, @b, @c}' $indir/abixy run_mlr --opprint put -v 'begin {@count=0; @sum=0.0}; @count=@count+1; @sum=@sum+$x; end{@mean=@sum/@count; emitf @mean}' $indir/abixy run_mlr --opprint put -v 'end{@mean=@sum/@count; emitf @mean}; begin {@count=0; @sum=0.0}; @count=@count+1; @sum=@sum+$x' $indir/abixy run_mlr put -v 'begin{ @a = @b[1] }; $c = @d; @e[$i][2+$j][3] = $4; end{@f[@g[5][@h]] = 6}' /dev/null run_mlr put '@y[$a]=$y; end{dump}' $indir/abixy run_mlr stats1 -a sum -f y -g a $indir/abixy run_mlr put '@y_sum[$a] = $y; end{dump}' $indir/abixy run_mlr put -q '@s=$x; @t[$a]=$x; @u[$a][$b]=$x; end{dump; unset @s ; dump}' $indir/unset1.dkvp run_mlr put -q '@s=$x; @t[$a]=$x; @u[$a][$b]=$x; end{dump; unset @t ; dump}' $indir/unset1.dkvp run_mlr put -q '@s=$x; @t[$a]=$x; @u[$a][$b]=$x; end{dump; unset @t[1] ; dump}' $indir/unset1.dkvp run_mlr put -q '@s=$x; @t[$a]=$x; @u[$a][$b]=$x; end{dump; unset @u ; dump}' $indir/unset1.dkvp run_mlr put -q '@s=$x; @t[$a]=$x; @u[$a][$b]=$x; end{dump; unset @u[1] ; dump}' $indir/unset1.dkvp run_mlr put -q '@s=$x; @t[$a]=$x; @u[$a][$b]=$x; end{dump; unset @u[1][2]; dump}' $indir/unset1.dkvp run_mlr put -q '@s=$x; @t[$a]=$x; @u[$a][$b]=$x; end{dump; unset @s ; dump}' $indir/unset4.dkvp run_mlr put -q '@s=$x; @t[$a]=$x; @u[$a][$b]=$x; end{dump; unset @t ; dump}' $indir/unset4.dkvp run_mlr put -q '@s=$x; @t[$a]=$x; @u[$a][$b]=$x; end{dump; unset @t[1] ; dump}' $indir/unset4.dkvp run_mlr put -q '@s=$x; @t[$a]=$x; @u[$a][$b]=$x; end{dump; unset @u ; dump}' $indir/unset4.dkvp run_mlr put -q '@s=$x; @t[$a]=$x; @u[$a][$b]=$x; end{dump; unset @u[1] ; dump}' $indir/unset4.dkvp run_mlr put -q '@s=$x; @t[$a]=$x; @u[$a][$b]=$x; end{dump; unset @u[1][2]; dump}' $indir/unset4.dkvp run_mlr put -q '@s=$x; @t[$a]=$x; @u[$a][$b]=$x; end{dump; unset all; dump}' $indir/unset4.dkvp run_mlr put -q '@s=$x; @t[$a]=$x; @u[$a][$b]=$x; end{dump; unset @*; dump}' $indir/unset4.dkvp run_mlr put 'unset $x' $indir/unset4.dkvp run_mlr put 'unset $*; $aaa = 999' $indir/unset4.dkvp run_mlr --from $indir/abixy put 'x = 1; print "OX=".x; unset x; print "NX=".x' run_mlr put -q '@{variable.name} += $x; end{emit @{variable.name}}' $indir/abixy run_mlr put -q '@{variable.name}[$a] += $x; end{emit @{variable.name},"a"}' $indir/abixy run_mlr put 'for (k,v in $*) { if (k == "i") {unset $[k]}}' $indir/abixy run_mlr --opprint --from $indir/abixy put -q ' @output[NR] = $*; end { for ((nr, k), v in @output) { if (nr == 4 || k == "i") { unset @output[nr][k] } } emitp @output, "NR", "k" } ' # ---------------------------------------------------------------- announce DSL PATTERN-ACTION BLOCKS run_mlr put -v 'begin{@a=1}; $e=2; $f==$g||$h==$i {}; $x=6; end{@z=9}' /dev/null run_mlr put -v 'begin{@a=1}; $e=2; $f==$g||$h==$i {$s=1}; $x=6; end{@z=9}' /dev/null run_mlr put -v 'begin{@a=1}; $e=2; $f==$g||$h==$i {$s=1;$t=2}; $x=6; end{@z=9}' /dev/null run_mlr put -v 'begin{@a=1}; $e=2; $f==$g||$h==$i {$s=1;$t=2;$u=3}; $x=6; end{@z=9}' /dev/null run_mlr put -v 'begin{@a=1}; $e=2; $f==$g||$h==$i {$s=1;@t["u".$5]=2;emitf @v,@w;dump}; $x=6; end{@z=9}' /dev/null run_mlr put -v 'begin{true{@x=1}}; true{@x=2}; end{true{@x=3}}' /dev/null # ---------------------------------------------------------------- announce DSL STACK-ALLOCATION # This important test validates the local-stack allocator: which variables are # assigned which offsets in the stack, and how the local-extent contract is # satisfied by the clear-at-enter-subframe logic. The -v flag gives context on # the AST; the -a flag provides the essential output on variable placement; the # Miller script per se validates semantics. run_mlr --from $indir/abixy put -v -a -f $indir/test-dsl-stack-allocation.mlr # These test absent-null handing for as-yet-undefined localvars in expression RHSs. run_mlr --from $indir/abixy put 'a=a; $oa = a' run_mlr --from $indir/abixy put 'a=a; $oa = a; a = a; $ob = a' run_mlr --from $indir/abixy put 'a=a; $oa = a; a = a; $ob = a; a = b; $oc = a' run_mlr --from $indir/abixy put 'a=a; $oa = a; a = a; $ob = a; a = b; $oc = a; b = 3; b = a; $od = a' run_mlr --from $indir/abixy put 'a=a; $oa = a; a = a; $ob = a; a = b; $oc = a; b = 3; b = a; $od = a; b = 4;a = b; $oe= a' # ---------------------------------------------------------------- announce DSL IF-CHAINING mention IF/ELIF WITH ELSE run_mlr --from $indir/xy40.dkvp put -v ' if (NR==1) { $x = 2; $y = 3 }' run_mlr --from $indir/xy40.dkvp put -v ' if (NR == 4) { $x = 5; $y = 6 } else { $x = 1007; $y = 1008 }' run_mlr --from $indir/xy40.dkvp put -v ' if (NR == 9) { $x = 10; $y = 11 } elif (NR == 12) { $x = 13; $y = 14 } else { $x = 1015; $y = 1016 }' run_mlr --from $indir/xy40.dkvp put -v ' if (NR == 17) { $x = 18; $y = 19 } elif (NR == 20) { $x = 21; $y = 22 } elif (NR == 23) { $x = 24; $y = 25 } else { $x = 1026; $y = 1027 }' run_mlr --from $indir/xy40.dkvp put -v ' if (NR == 28) { $x = 29; $y = 30 } elif (NR == 31) { $x = 32; $y = 33 } elif (NR == 34) { $x = 35; $y = 36 } elif (NR == 37) { $x = 38; $y = 39 } else { $x = 1040; $y = 1041 }' mention IF/ELIF WITHOUT ELSE run_mlr --from $indir/xy40.dkvp put -v ' if (NR == 1) { $x = 2; $y = 3 }' run_mlr --from $indir/xy40.dkvp put -v ' if (NR == 4) { $x = 5; $y = 6 } elif (NR == 7) { $x = 8; $y = 9 }' run_mlr --from $indir/xy40.dkvp put -v ' if (NR == 10) { $x = 11; $y = 12 } elif (NR == 13) { $x = 14; $y = 15 } elif (NR == 16) { $x = 17; $y = 18 }' run_mlr --from $indir/xy40.dkvp put -v ' if (NR == 19) { $x = 20; $y = 21 } elif (NR == 22) { $x = 23; $y = 24 } elif (NR == 25) { $x = 26; $y = 37 } elif (NR == 28) { $x = 29; $y = 30 }' # ---------------------------------------------------------------- announce DSL INDIRECT SREC ASSIGNMENTS run_mlr put -v '$["a"] = $["b"]; $["x"] = 10 * $["y"]' $indir/abixy run_mlr --from $indir/abixy put 'while (NF < 256) { $["k".string(NF+1)] = "v".string(NF) }' # ---------------------------------------------------------------- announce DSL INDIRECT OOSVAR ASSIGNMENTS run_mlr --opprint put -v '@s = NR; $t = @s; $u=@["s"]; $v = $t - $u' $indir/abixy run_mlr put -v '@t["u"] = NR; $tu = @["t"]["u"]; emitp all' $indir/abixy run_mlr put -v '@t["u"] = NR; $tu = @["t"]["u"]; emitp @*' $indir/abixy run_mlr put -v '@["s"] = $x; emitp all' $indir/abixy run_mlr put -v '@["t"]["u"] = $y; emitp all' $indir/abixy # xxx @* on the right # xxx @* on the left # ---------------------------------------------------------------- announce OOSVAR-FROM-SREC ASSIGNMENT run_mlr put -v '@v = $*' /dev/null run_mlr put -v '@v[1] = $*' /dev/null run_mlr put -v '@v[$2] = $*' /dev/null run_mlr put -v 'NR == 3 {@v = $*}' /dev/null run_mlr put -v 'NR == 3 {@v[1] = $*}' /dev/null run_mlr put -v 'NR == 3 {@v[$2] = $*}' /dev/null run_mlr --oxtab put -q '@v = $*; end {emitp @v }' $indir/abixy-het run_mlr --oxtab put -q '@v[$a] = $*; end {emitp @v }' $indir/abixy-het run_mlr --oxtab put -q '@v[$a] = $*; end {emitp @v, "a" }' $indir/abixy-het run_mlr --oxtab put -q '@v[$a][$b] = $*; end {emitp @v }' $indir/abixy-het run_mlr --oxtab put -q '@v[$a][$b] = $*; end {emitp @v, "a" }' $indir/abixy-het run_mlr --oxtab put -q '@v[$a][$b] = $*; end {emitp @v, "a", "b"}' $indir/abixy-het # ---------------------------------------------------------------- announce SREC-FROM-OOSVAR ASSIGNMENT run_mlr put -v '$* = @v ' /dev/null run_mlr put -v '$* = @v[1] ' /dev/null run_mlr put -v '$* = @v[$2]' /dev/null run_mlr put -v 'NR == 3 {$* = @v }' /dev/null run_mlr put -v 'NR == 3 {$* = @v[1] }' /dev/null run_mlr put -v 'NR == 3 {$* = @v[$2]}' /dev/null run_mlr put '@v[NR] = $a; NR == 7 { @v = $*} ; $* = @v' $indir/abixy-het # ---------------------------------------------------------------- announce OOSVAR-FROM-OOSVAR ASSIGNMENT run_mlr put -v '@u = @v' /dev/null run_mlr put -v '@u = @v[1]' /dev/null run_mlr put -v '@u[2] = @v' /dev/null run_mlr put -v '@u[2] = @v[1]' /dev/null run_mlr put -v 'begin { @u = @v }' /dev/null run_mlr put -v 'begin { @u = @v[1] }' /dev/null run_mlr put -v 'begin { @u[2] = @v }' /dev/null run_mlr put -v 'begin { @u[2] = @v[1] }' /dev/null run_mlr put -v 'NR == 3 { @u = @v }' /dev/null run_mlr put -v 'NR == 3 { @u = @v[1] }' /dev/null run_mlr put -v 'NR == 3 { @u[2] = @v }' /dev/null run_mlr put -v 'NR == 3 { @u[2] = @v[1] }' /dev/null run_mlr put -v 'end { @u = @v }' /dev/null run_mlr put -v 'end { @u = @v[1] }' /dev/null run_mlr put -v 'end { @u[2] = @v }' /dev/null run_mlr put -v 'end { @u[2] = @v[1] }' /dev/null run_mlr put -q '@s += $i; @t=@s; end{dump; emitp@s; emitp @t}' $indir/abixy run_mlr put -q '@s[1] += $i; @t=@s; end{dump; emitp@s; emitp @t}' $indir/abixy run_mlr put -q '@s[1] += $i; @t=@s[1]; end{dump; emitp@s; emitp @t}' $indir/abixy run_mlr put -q '@s[1] += $i; @t[3]=@s; end{dump; emitp@s; emitp @t}' $indir/abixy run_mlr put -q '@s[1] += $i; @t[3]=@s[1]; end{dump; emitp@s; emitp @t}' $indir/abixy run_mlr put -q '@s[1][2] += $i; @t=@s; end{dump; emitp@s; emitp @t}' $indir/abixy run_mlr put -q '@s[1][2] += $i; @t=@s[1]; end{dump; emitp@s; emitp @t}' $indir/abixy run_mlr put -q '@s[1][2] += $i; @t=@s[1][2]; end{dump; emitp@s; emitp @t}' $indir/abixy run_mlr put -q '@s[1][2] += $i; @t[3]=@s; end{dump; emitp@s; emitp @t}' $indir/abixy run_mlr put -q '@s[1][2] += $i; @t[3]=@s[1]; end{dump; emitp@s; emitp @t}' $indir/abixy run_mlr put -q '@s[1][2] += $i; @t[3]=@s[1][2]; end{dump; emitp@s; emitp @t}' $indir/abixy run_mlr put -q '@s[1][2] += $i; @t[3][4]=@s; end{dump; emitp@s; emitp @t}' $indir/abixy run_mlr put -q '@s[1][2] += $i; @t[3][4]=@s[1]; end{dump; emitp@s; emitp @t}' $indir/abixy run_mlr put -q '@s[1][2] += $i; @t[3][4]=@s[1][2]; end{dump; emitp@s; emitp @t}' $indir/abixy run_mlr --opprint put -q '@s[NR][NR] = $i/100; @t[NR*10]=@s; end{emitp@s,"A","B"; emitp @t,"C","D","E"}' $indir/abixy # ---------------------------------------------------------------- announce DSL WHILE/DO-WHILE LOOPS run_mlr put -v 'while($i < 5) { $i += 1}' $indir/abixy run_mlr put -v 'do {$i += 1} while($i < 5)' $indir/abixy # ---------------------------------------------------------------- announce DSL FOR-SREC LOOPS mention empty for-srec run_mlr --from $indir/abixy put -v 'for(k,v in $*) { }' mention for-srec without boundvars run_mlr --from $indir/abixy put -v 'for(k,v in $*) {$nr= NR}' mention for-srec modifying the srec run_mlr --from $indir/abixy put -v 'for(k,v in $*) {unset $[k]}; $j = NR' run_mlr --from $indir/abixy put -v 'for(k,v in $*) {if (k != "x") {unset $[k]}}; $j = NR' run_mlr --from $indir/abixy --opprint put -S -v 'for(k,v in $*) {$[k."_orig"]=v; $[k] = "other"}' run_mlr --from $indir/abixy put -S -v 'for(k,v in $*) {$[v]=k}' run_mlr --from $indir/abixy put -v ' $sum = 0; for(k,v in $*) { if (k =~ "^[xy]$") { $sum += $[k] } }' run_mlr --from $indir/abixy put -S -v ' $sum = float(0); for(k,v in $*) { if (k =~ "^[xy]$") { $sum += float($[k]) } }' # ---------------------------------------------------------------- announce DSL FOR-OOSVAR LOOPS run_mlr --opprint -n put -v ' @o[1][1]["text1"][NR] = $a; @o[1][2]["text2"][NR] = $b; @o[1][2][$a][$i*100] = $x; for((k1,k2),v in @o[1][2]) { @n[3][4][k2][k1] = v; } end { emit @n, "a", "b", "c", "d" } ' run_mlr --opprint --from $indir/abixy put -q ' @o[1][1]["text1"][NR] = $a; @o[1][2]["text2"][NR] = $b; @o[1][2][$a][$i*100] = $x; for((k1,k2),v in @o[1][2]) { @n[3][4][k2][k1] = v; } end { emit @n, "a", "b", "c", "d" } ' run_mlr --opprint --from $indir/abixy put -q ' @sum[$a][$b] += $x; @count[$a][$b] += 1; end { for ((k1, k2), v in @sum) { @mean[k1][k2] = @sum[k1][k2] / @count[k1][k2] } emitp @sum, "a", "b"; emitp @count, "a", "b"; emitp @mean, "a", "b" } ' run_mlr --opprint --from $indir/abixy-wide put -q ' @value["sum"][$a][$b] += $x; @value["count"][$a][$b] += 1; end { for ((k1, k2), v in @value["sum"]) { @value["mean"][k1][k2] = @value["sum"][k1][k2] / @value["count"][k1][k2] } emitp @value, "stat", "a", "b"; } ' mlr_expect_fail -n put -v 'for (k, k in $*) {}' mlr_expect_fail -n put -v 'for (k, k in @*) {}' mlr_expect_fail -n put -v 'for ((a,a), c in @*) {}' mlr_expect_fail -n put -v 'for ((a,b), a in @*) {}' mlr_expect_fail -n put -v 'for ((a,b), b in @*) {}' mlr_expect_fail -n put -v 'for ((a,a,c), d in @*) {}' mlr_expect_fail -n put -v 'for ((a,b,a), d in @*) {}' mlr_expect_fail -n put -v 'for ((a,b,c), a in @*) {}' mlr_expect_fail -n put -v 'for ((a,b,b), d in @*) {}' mlr_expect_fail -n put -v 'for ((a,b,c), b in @*) {}' mlr_expect_fail -n put -v 'for ((a,b,c), c in @*) {}' run_mlr --from $indir/xyz2 put -q 'func f() { return {"a"."b":"c"."d",3:4}}; for (k,v in f()){print "k=".k.",v=".v}' run_mlr --from $indir/xyz2 put -q 'for (k,v in {"a"."b":"c"."d",3:"c"}) {print "k=".k.",v=".v}' run_mlr --from $indir/xyz2 put -q 'o["a"."b"]="c"."d"; for (k,v in o) {print "k=".k.",v=".v}' run_mlr --from $indir/xyz2 put -q '@o["a"."b"]="c"."d"; for (k,v in @o) {print "k=".k.",v=".v}' run_mlr --from $indir/xyz2 put 'for (k in $*) { print k}' run_mlr --from $indir/xyz2 put 'm=$*; for (k in m) { print k}' # ---------------------------------------------------------------- announce DSL FOR-BIND LOOPS FOR VALGRIND mention key-only fors run_mlr --from $indir/abixy-het put ' ab = $a . "_" . $b; xy = $x . "_" . $y; map o = {}; o[ab] = xy; for (k in o) { print "k is " . k; } ' run_mlr --from $indir/abixy-het put ' ab = $a . "_" . $b; xy = $x . "_" . $y; unset @o; @o[ab] = xy; for (k in @o) { print "k is " . k; } ' run_mlr --from $indir/abixy-het put ' ab = $a . "_" . $b; xy = $x . "_" . $y; for (k in {ab : xy}) { print "k is " . k; } ' run_mlr --from $indir/abixy-het put ' func f(a, b, x, y): map { ab = $a . "_" . $b; xy = $x . "_" . $y; return {ab : xy}; } for (k in f($a, $b, $x, $y)) { print "k is " . k; } ' mention key-value fors with scalar values run_mlr --from $indir/abixy-het put ' ab = $a . "_" . $b; xy = $x . "_" . $y; map o = {}; o[ab] = xy; for (k, v in o) { print "k is " . k . " v is " . v; } ' run_mlr --from $indir/abixy-het put ' ab = $a . "_" . $b; xy = $x . "_" . $y; unset @o; @o[ab] = xy; for (k, v in @o) { print "k is " . k . " v is " . v; } ' run_mlr --from $indir/abixy-het put ' ab = $a . "_" . $b; xy = $x . "_" . $y; for (k, v in {ab : xy}) { print "k is " . k . " v is " . v; } ' run_mlr --from $indir/abixy-het put ' func f(a, b, x, y): map { ab = $a . "_" . $b; xy = $x . "_" . $y; return {ab : xy}; } for (k, v in f($a, $b, $x, $y)) { print "k is " . k . " v is " . v; } ' mention key-value fors with map values run_mlr --from $indir/abixy-het put ' ab = $a . "_" . $b; xy = $x . "_" . $y; map o = {}; o[ab] = {"foo": xy}; for (k, v in o) { print "k is " . k . " v is "; dump v; } ' run_mlr --from $indir/abixy-het put ' ab = $a . "_" . $b; xy = $x . "_" . $y; unset @o; @o[ab]["foo"] = xy; for (k, v in @o) { print "k is " . k . " v is "; dump v; } ' run_mlr --from $indir/abixy-het put ' ab = $a . "_" . $b; xy = $x . "_" . $y; for (k, v in {ab : {"foo": xy}}) { print "k is " . k . " v is "; dump v; } ' run_mlr --from $indir/abixy-het put ' func f(a, b, x, y): map { ab = $a . "_" . $b; xy = $x . "_" . $y; return {ab : {"foo" : xy}}; } for (k, v in f($a, $b, $x, $y)) { print "k is " . k . " v is "; dump v; } ' # ---------------------------------------------------------------- announce DSL BREAK/CONTINUE IN SINGLE WHILE/DO-WHILE run_mlr --opprint --from $indir/abixy put ' while ($i < 5) { $i += 1; break; $a = "ERROR"; } ' run_mlr --opprint --from $indir/abixy put ' while ($i < 5) { $i += 1; continue; $a = "ERROR"; } ' run_mlr --opprint --from $indir/abixy put ' do { $i += 1; break; $a = "ERROR"; } while ($i < 5); ' run_mlr --opprint --from $indir/abixy put ' do { $i += 1; continue; $a = "ERROR"; } while ($i < 5); ' run_mlr --opprint --from $indir/abixy put ' $NR = NR; while ($i < 5) { $i += 1; if (NR == 2) { break; } $a = "reached"; } ' run_mlr --opprint --from $indir/abixy put ' $NR = NR; while ($i < 5) { $i += 1; if (NR == 2) { continue; } $a = "reached"; } ' run_mlr --opprint --from $indir/abixy put ' $NR = NR; do { $i += 1; if (NR == 2) { break; } $a = "reached"; } while ($i < 5); ' run_mlr --opprint --from $indir/abixy put ' $NR = NR; do { $i += 1; if (NR == 2) { continue; } $a = "reached"; } while ($i < 5); ' # ---------------------------------------------------------------- announce DSL BREAK/CONTINUE IN NESTED WHILE/DO-WHILE run_mlr --opprint --from $indir/abixy put ' $j = NR; while ($j < 4) { $k = NR; $j += 1; break; while ($k < 7) { $k += 1 } } ' run_mlr --opprint --from $indir/abixy put ' $j = NR; while ($j < 4) { $k = NR; $j += 1; continue; while ($k < 7) { $k += 1 } } ' run_mlr --opprint --from $indir/abixy put ' $j = NR; while ($j < 4) { $k = NR; $j += 1; while ($k < 7) { $k += 1; break; $k += 10000; } } ' run_mlr --opprint --from $indir/abixy put ' $j = NR; while ($j < 4) { $k = NR; $j += 1; while ($k < 7) { $k += 1; continue; $k += 10000; } } ' run_mlr --opprint --from $indir/abixy put ' $j = NR; while ($j < 4) { $k = NR; $j += 1; if (NR == 2 || NR == 8) { break; } while ($k < 7) { $k += 1 } } ' run_mlr --opprint --from $indir/abixy put ' $j = NR; while ($j < 4) { $k = NR; $j += 1; if (NR == 2 || NR == 8) { continue; } while ($k < 7) { $k += 1 } } ' run_mlr --opprint --from $indir/abixy put ' $j = NR; while ($j < 4) { $k = NR; $j += 1; while ($k < 7) { $k += 1; if (NR == 2 || NR == 8) { break; } $k += 10000; } } ' run_mlr --opprint --from $indir/abixy put ' $j = NR; while ($j < 4) { $k = NR; $j += 1; while ($k < 7) { $k += 1; if (NR == 2 || NR == 8) { continue; } $k += 10000; } } ' run_mlr --opprint --from $indir/abixy put ' $j = NR; do { $k = NR; $j += 1; break; do { $k += 1 } while ($k < 7); } while ($j < 4); ' run_mlr --opprint --from $indir/abixy put ' $j = NR; do { $k = NR; $j += 1; continue; do { $k += 1 } while ($k < 7); } while ($j < 4); ' run_mlr --opprint --from $indir/abixy put ' $j = NR; do { $k = NR; $j += 1; do { $k += 1; break; $k += 10000; } while ($k < 7); } while ($j < 4); ' run_mlr --opprint --from $indir/abixy put ' $j = NR; do { $k = NR; $j += 1; do { $k += 1; continue; $k += 10000; } while ($k < 7); } while ($j < 4); ' run_mlr --opprint --from $indir/abixy put ' $j = NR; do { $k = NR; $j += 1; if (NR == 2 || NR == 8) { break; } do { $k += 1 } while ($k < 7); } while ($j < 4); ' run_mlr --opprint --from $indir/abixy put ' $j = NR; do { $k = NR; $j += 1; if (NR == 2 || NR == 8) { continue; } do { $k += 1 } while ($k < 7); } while ($j < 4); ' run_mlr --opprint --from $indir/abixy put ' $j = NR; do { $k = NR; $j += 1; do { $k += 1; if (NR == 2 || NR == 8) { break; } $k += 10000; } while ($k < 7); } while ($j < 4); ' run_mlr --opprint --from $indir/abixy put ' $j = NR; do { $k = NR; $j += 1; do { $k += 1; if (NR == 2 || NR == 8) { continue; } $k += 10000; } while ($k < 7); } while ($j < 4); ' # ---------------------------------------------------------------- announce DSL BREAK/CONTINUE IN SINGLE FOR-SREC run_mlr --opprint --from $indir/abixy put -q ' for (k,v in $*) { @logging1[NR][k] = v; if (k == "x") { break; } } end { emitp @logging1, "NR", "k"; } ' run_mlr --opprint --from $indir/abixy put -q ' for (k,v in $*) { if (k == "x") { break; } @logging2[NR][k] = v; } end { emitp @logging2, "NR", "k"; } ' run_mlr --opprint --from $indir/abixy put -q ' for (k,v in $*) { @logging3[NR][k] = v; if (k == "x") { continue; } } end { emitp @logging3, "NR", "k"; } ' run_mlr --opprint --from $indir/abixy put -q ' for (k,v in $*) { if (k == "x") { continue; } @logging4[NR][k] = v; } end { emitp @logging4, "NR", "k" } ' run_mlr --opprint --from $indir/abixy put -q ' for (k,v in $*) { @logging1[NR][k] = v; if (k == "x") { break; } } for (k,v in $*) { if (k == "x") { break; } @logging2[NR][k] = v; } for (k,v in $*) { @logging3[NR][k] = v; if (k == "x") { continue; } } for (k,v in $*) { if (k == "x") { continue; } @logging4[NR][k] = v; } end { emitp @logging1, "NR", "k"; emitp @logging2, "NR", "k"; emitp @logging3, "NR", "k"; emitp @logging4, "NR", "k" } ' # ---------------------------------------------------------------- announce DSL BREAK/CONTINUE IN NESTED FOR-SREC run_mlr --opprint --from $indir/abixy put -q ' for (k1, v1 in $*) { @output1[NR][k1] = "before"; break; @output1[NR][k1] = v1; for (k2, v2 in $*) { @output2[NR][k1."_".k2] = "before"; @output2[NR][k1."_".k2] = v2; } } end { emit @output1, "NR", "name"; emit @output2, "NR", "names"; } ' run_mlr --opprint --from $indir/abixy put -q ' for (k1, v1 in $*) { @output1[NR][k1] = "before"; continue; @output1[NR][k1] = v1; for (k2, v2 in $*) { @output2[NR][k1."_".k2] = "before"; @output2[NR][k1."_".k2] = v2; } } end { emit @output1, "NR", "name"; emit @output2, "NR", "names"; } ' run_mlr --opprint --from $indir/abixy put -q ' for (k1, v1 in $*) { @output1[NR][k1] = "before"; @output1[NR][k1] = v1; for (k2, v2 in $*) { @output2[NR][k1."_".k2] = "before"; break; @output2[NR][k1."_".k2] = v2; } } end { emit @output1, "NR", "name"; emit @output2, "NR", "names"; } ' run_mlr --opprint --from $indir/abixy put -q ' for (k1, v1 in $*) { @output1[NR][k1] = "before"; @output1[NR][k1] = v1; for (k2, v2 in $*) { @output2[NR][k1."_".k2] = "before"; continue; @output2[NR][k1."_".k2] = v2; } } end { emit @output1, "NR", "name"; emit @output2, "NR", "names"; } ' run_mlr --opprint --from $indir/abixy put -q ' for (k1, v1 in $*) { @output1[NR][k1] = "before"; break; @output1[NR][k1] = v1; for (k2, v2 in $*) { @output2[NR][k1."_".k2] = "before"; break; @output2[NR][k1."_".k2] = v2; } } end { emit @output1, "NR", "name"; emit @output2, "NR", "names"; } ' run_mlr --opprint --from $indir/abixy put -q ' for (k1, v1 in $*) { @output1[NR][k1] = "before"; continue; @output1[NR][k1] = v1; for (k2, v2 in $*) { @output2[NR][k1."_".k2] = "before"; break; @output2[NR][k1."_".k2] = v2; } } end { emit @output1, "NR", "name"; emit @output2, "NR", "names"; } ' run_mlr --opprint --from $indir/abixy put -q ' for (k1, v1 in $*) { @output1[NR][k1] = "before"; break; @output1[NR][k1] = v1; for (k2, v2 in $*) { @output2[NR][k1."_".k2] = "before"; continue; @output2[NR][k1."_".k2] = v2; } } end { emit @output1, "NR", "name"; emit @output2, "NR", "names"; } ' run_mlr --opprint --from $indir/abixy put -q ' for (k1, v1 in $*) { @output1[NR][k1] = "before"; continue; @output1[NR][k1] = v1; for (k2, v2 in $*) { @output2[NR][k1."_".k2] = "before"; continue; @output2[NR][k1."_".k2] = v2; } } end { emit @output1, "NR", "name"; emit @output2, "NR", "names"; } ' run_mlr --opprint --from $indir/abixy put -q ' for (k1, v1 in $*) { @output1[NR][k1] = "before"; if (k1 == "b") { break } @output1[NR][k1] = v1; for (k2, v2 in $*) { @output2[NR][k1."_".k2] = "before"; @output2[NR][k1."_".k2] = v2; } } end { emit @output1, "NR", "name"; emit @output2, "NR", "names"; } ' run_mlr --opprint --from $indir/abixy put -q ' for (k1, v1 in $*) { @output1[NR][k1] = "before"; if (k1 == "b") { continue } @output1[NR][k1] = v1; for (k2, v2 in $*) { @output2[NR][k1."_".k2] = "before"; @output2[NR][k1."_".k2] = v2; } } end { emit @output1, "NR", "name"; emit @output2, "NR", "names"; } ' run_mlr --opprint --from $indir/abixy put -q ' for (k1, v1 in $*) { @output1[NR][k1] = "before"; @output1[NR][k1] = v1; for (k2, v2 in $*) { @output2[NR][k1."_".k2] = "before"; if (k2 == "a") { break } @output2[NR][k1."_".k2] = v2; } } end { emit @output1, "NR", "name"; emit @output2, "NR", "names"; } ' run_mlr --opprint --from $indir/abixy put -q ' for (k1, v1 in $*) { @output1[NR][k1] = "before"; @output1[NR][k1] = v1; for (k2, v2 in $*) { @output2[NR][k1."_".k2] = "before"; if (k2 == "b") { continue } @output2[NR][k1."_".k2] = v2; } } end { emit @output1, "NR", "name"; emit @output2, "NR", "names"; } ' run_mlr --opprint --from $indir/abixy put -q ' for (k1, v1 in $*) { @output1[NR][k1] = "before"; if (k1 == "b") { break } @output1[NR][k1] = v1; for (k2, v2 in $*) { @output2[NR][k1."_".k2] = "before"; if (k2 == "a") { break } @output2[NR][k1."_".k2] = v2; } } end { emit @output1, "NR", "name"; emit @output2, "NR", "names"; } ' run_mlr --opprint --from $indir/abixy put -q ' for (k1, v1 in $*) { @output1[NR][k1] = "before"; if (k1 == "b") { continue } @output1[NR][k1] = v1; for (k2, v2 in $*) { @output2[NR][k1."_".k2] = "before"; if (k2 == "a") { break } @output2[NR][k1."_".k2] = v2; } } end { emit @output1, "NR", "name"; emit @output2, "NR", "names"; } ' run_mlr --opprint --from $indir/abixy put -q ' for (k1, v1 in $*) { @output1[NR][k1] = "before"; if (k1 == "b") { break } @output1[NR][k1] = v1; for (k2, v2 in $*) { @output2[NR][k1."_".k2] = "before"; if (k2 == "a") { continue } @output2[NR][k1."_".k2] = v2; } } end { emit @output1, "NR", "name"; emit @output2, "NR", "names"; } ' run_mlr --opprint --from $indir/abixy put -q ' for (k1, v1 in $*) { @output1[NR][k1] = "before"; if (k1 == "b") { continue } @output1[NR][k1] = v1; for (k2, v2 in $*) { @output2[NR][k1."_".k2] = "before"; if (k2 == "a") { continue } @output2[NR][k1."_".k2] = v2; } } end { emit @output1, "NR", "name"; emit @output2, "NR", "names"; } ' # ---------------------------------------------------------------- announce FOR-MAP DEPTH TESTS mention 'for full oosvar' run_mlr --from $indir/abixy put '@o[1][2] = 7; for(k1,v in @*) {$x+=10;$y+=100}' run_mlr --from $indir/abixy put '@o[1][2] = 7; for((k1),v in @*) {$x+=10;$y+=100}' run_mlr --from $indir/abixy put '@o[1][2] = 7; for((k1,k2),v in @*) {$x+=10;$y+=100}' run_mlr --from $indir/abixy put '@o[1][2] = 7; for((k1,k2,k3),v in @*) {$x+=10;$y+=100}' mention 'for oosvar submap' run_mlr --from $indir/abixy put '@o[1][2][3] = 7; for(k1,v in @o[1][2]) {$x+=10;$y+=100}' run_mlr --from $indir/abixy put '@o[1][2][3] = 7; for((k1),v in @o[1][2]) {$x+=10;$y+=100}' run_mlr --from $indir/abixy put '@o[1][2][3] = 7; for((k1,k2),v in @o[1][2]) {$x+=10;$y+=100}' run_mlr --from $indir/abixy put '@o[1][2][3] = 7; for((k1,k2,k3),v in @o[1][2]) {$x+=10;$y+=100}' mention 'for local' run_mlr --from $indir/abixy put 'o[1][2] = 7; for(k1,v in o) {$x+=10;$y+=100}' run_mlr --from $indir/abixy put 'o[1][2] = 7; for((k1),v in o) {$x+=10;$y+=100}' run_mlr --from $indir/abixy put 'o[1][2] = 7; for((k1,k2),v in o) {$x+=10;$y+=100}' run_mlr --from $indir/abixy put 'o[1][2] = 7; for((k1,k2,k3),v in o) {$x+=10;$y+=100}' mention 'for map-literal' run_mlr --from $indir/abixy put 'for(k1,v in {1:{2:7}}) {$x+=10;$y+=100}' run_mlr --from $indir/abixy put 'for((k1),v in {1:{2:7}}) {$x+=10;$y+=100}' run_mlr --from $indir/abixy put 'for((k1,k2),v in {1:{2:7}}) {$x+=10;$y+=100}' run_mlr --from $indir/abixy put 'for((k1,k2,k3),v in {1:{2:7}}) {$x+=10;$y+=100}' # ---------------------------------------------------------------- announce DSL BREAK/CONTINUE IN SINGLE FOR-OOSVAR mention single-key tests, direct break/continue run_mlr --opprint --from $indir/abixy put -q ' @logging[NR] = $*; end { for (k1, v in @logging[2]) { break; @output[k1] = v; } emit @output, "NR", "name" } ' run_mlr --opprint --from $indir/abixy put -q ' @logging[NR] = $*; end { for (k1, v in @logging[2]) { @output[k1] = v; break; @output[k1] = "ERROR"; } emit @output, "NR", "name" } ' run_mlr --opprint --from $indir/abixy put -q ' @logging[NR] = $*; end { for (k1, v in @logging[2]) { continue; @output[k1] = v } emit @output, "NR", "name" } ' run_mlr --opprint --from $indir/abixy put -q ' @logging[NR] = $*; end { for (k1, v in @logging[2]) { @output[k1] = v; continue; @output[k1] = "ERROR"; } emit @output, "NR", "name" } ' mention single-key tests, indirect break/continue run_mlr --opprint --from $indir/abixy put -q ' @logging[NR] = $*; end { for (k1, v in @logging[2]) { if (k1 == "i") { break; } @output[k1] = v; } emit @output, "NR", "name" } ' run_mlr --opprint --from $indir/abixy put -q ' @logging[NR] = $*; end { for (k1, v in @logging[2]) { @output[k1] = v; if (k1 == "i") { break; } } emit @output, "NR", "name" } ' run_mlr --opprint --from $indir/abixy put -q ' @logging[NR] = $*; end { for (k1, v in @logging[2]) { if (k1 == "i") { continue; } @output[k1] = v } emit @output, "NR", "name" } ' run_mlr --opprint --from $indir/abixy put -q ' @logging[NR] = $*; end { for (k1, v in @logging[2]) { @output[k1] = v; if (k1 == "i") { continue; } @output[k1] = "reached"; } emit @output, "NR", "name" } ' mention multiple-key tests, direct break/continue run_mlr --opprint --from $indir/abixy put -q ' @logging[NR] = $*; end { for ((k1, k2), v in @logging) { break; @output[k1][k2] = v; } emit @output, "NR", "name" } ' run_mlr --opprint --from $indir/abixy put -q ' @logging[NR] = $*; end { for ((k1, k2), v in @logging) { @output[k1][k2] = v; break; @output[k1][k2] = "ERROR" } emit @output, "NR", "name" } ' run_mlr --opprint --from $indir/abixy put -q ' @logging[NR] = $*; end { for ((k1, k2), v in @logging) { continue; @output[k1][k2] = v } emit @output, "NR", "name" } ' run_mlr --opprint --from $indir/abixy put -q ' @logging[NR] = $*; end { for ((k1, k2), v in @logging) { @output[k1][k2] = v; continue; @output[k1][k2] = "ERROR"; } emit @output, "NR", "name" } ' mention multiple-key tests, indirect break/continue run_mlr --opprint --from $indir/abixy put -q ' @logging[NR] = $*; end { for ((k1, k2), v in @logging) { if (k1 == 5) { break; } @output[k1][k2] = v; } emit @output, "NR", "name" } ' run_mlr --opprint --from $indir/abixy put -q ' @logging[NR] = $*; end { for ((k1, k2), v in @logging) { if (k2 == "i") { break; } @output[k1][k2] = v; } emit @output, "NR", "name" } ' run_mlr --opprint --from $indir/abixy put -q ' @logging[NR] = $*; end { for ((k1, k2), v in @logging) { @output[k1][k2] = v; if (k1 == 5) { break; } } emit @output, "NR", "name" } ' run_mlr --opprint --from $indir/abixy put -q ' @logging[NR] = $*; end { for ((k1, k2), v in @logging) { @output[k1][k2] = v; if (k2 == "i") { break; } } emit @output, "NR", "name" } ' run_mlr --opprint --from $indir/abixy put -q ' @logging[NR] = $*; end { for ((k1, k2), v in @logging) { if (k1 == 5) { continue; } @output[k1][k2] = v } emit @output, "NR", "name" } ' run_mlr --opprint --from $indir/abixy put -q ' @logging[NR] = $*; end { for ((k1, k2), v in @logging) { if (k2 == "i") { continue; } @output[k1][k2] = v } emit @output, "NR", "name" } ' run_mlr --opprint --from $indir/abixy put -q ' @logging[NR] = $*; end { for ((k1, k2), v in @logging) { @output[k1][k2] = "before"; if (k1 == 5) { continue; } @output[k1][k2] = v; } emit @output, "NR", "name" } ' run_mlr --opprint --from $indir/abixy put -q ' @logging[NR] = $*; end { for ((k1, k2), v in @logging) { @output[k1][k2] = "before"; if (k2 == "i") { continue; } @output[k1][k2] = v; } emit @output, "NR", "name" } ' # ---------------------------------------------------------------- announce DSL BREAK/CONTINUE IN NESTED FOR-OOSVAR run_mlr --opprint --from $indir/abixy put -q ' @logging[NR] = $*; end { for ((k1, k2), v in @logging) { if (k1 != 2) { continue } for ((k3, k4), v in @logging) { if (k3 != 4) { continue } @output[k1][k2][k3][k4] = v; } } emit @output, "NR1", "name1", "NR2", "name2" } ' # ---------------------------------------------------------------- announce DSL PRINT run_mlr put -q 'print 1; print "two"; print $a; print; print $i < 4; print "y is ".string($y); print ""' $indir/abixy run_mlr put -q 'printn 1; printn "two"; printn $a; printn; printn $i < 4; printn "y is ".string($y); print ""' $indir/abixy run_mlr put -q 'print $*; print $*; print {}; print' $indir/abixy run_mlr put -q 'printn $*; printn $*; printn {}; print' $indir/abixy # ---------------------------------------------------------------- announce ABSENT/EMPTY run_mlr put -q '@sum += $x; end{emitp @sum}' $indir/abixy run_mlr put -q '@sum[$a] += $x; end{emitp @sum, "a"}' $indir/abixy run_mlr put '$nonesuch = @nonesuch' $indir/abixy run_mlr put -q '@sum += $x; end{emitp @sum}' $indir/abixy-het run_mlr put -q '@sum[$a] += $x; end{emitp @sum, "a"}' $indir/abixy-het run_mlr put '$nonesuch = @nonesuch' $indir/abixy-het run_mlr put -q '@sum += $x; @sumtype = typeof(@sum); @xtype = typeof($x); emitf @sumtype, @xtype, @sum; end{emitp @sum}' $indir/abixy run_mlr put -q '@sum += $x; @sumtype = typeof(@sum); @xtype = typeof($x); emitf @sumtype, @xtype, @sum; end{emitp @sum}' $indir/abixy-het run_mlr put '$z = $x + $y' $indir/typeof.dkvp run_mlr put '$z = $x + $u' $indir/typeof.dkvp run_mlr put '@s = @s + $y; emitp @s' $indir/typeof.dkvp run_mlr put '@s = @s + $u; emitp @s' $indir/typeof.dkvp run_mlr put '$z = $x + $y; $x=typeof($x);$y=typeof($y);$z=typeof($z)' $indir/typeof.dkvp run_mlr put '$z = $x + $u; $x=typeof($x);$y=typeof($y);$z=typeof($z)' $indir/typeof.dkvp run_mlr put '@s = @s + $y; $x=typeof($x);$y=typeof($y);$z=typeof($z);$s=typeof(@s)' $indir/typeof.dkvp run_mlr put '@s = @s + $u; $x=typeof($x);$y=typeof($y);$z=typeof($z);$s=typeof(@s)' $indir/typeof.dkvp run_mlr cat << EOF x=1 x= x=7 EOF run_mlr --ofs tab put '$osum=@sum; $ostype=typeof(@sum);$xtype=typeof($x);@sum+=$x; $nstype=typeof(@sum);$nsum=@sum; end { emit @sum }' < "'$tee2'/out.".$a, $*' $indir/abixy run_cat $tee2/out.eks run_cat $tee2/out.hat run_cat $tee2/out.pan run_cat $tee2/out.wye run_cat $tee2/out.zee run_mlr put -q --no-fflush 'tee > "'$tee2'/out.".$a, $*' $indir/abixy run_cat $tee2/out.eks run_cat $tee2/out.hat run_cat $tee2/out.pan run_cat $tee2/out.wye run_cat $tee2/out.zee run_mlr put -q 'tee >> "'$tee2'/out.".$a, $*' $indir/abixy run_cat $tee2/out.eks run_cat $tee2/out.hat run_cat $tee2/out.pan run_cat $tee2/out.wye run_cat $tee2/out.zee run_mlr put -q -o json 'tee > "'$tee2'/out.".$a, $*' $indir/abixy run_cat $tee2/out.eks run_cat $tee2/out.hat run_cat $tee2/out.pan run_cat $tee2/out.wye run_cat $tee2/out.zee run_mlr put -q 'tee | "tr \[a-z\] \[A-Z\]", $*' $indir/abixy run_mlr put -q -o json 'tee | "tr \[a-z\] \[A-Z\]", $*' $indir/abixy touch $tee2/err1 run_mlr put -q 'tee > stdout, $*' $indir/abixy 2> $tee2/err1 run_cat $tee2/err1 touch $tee2/err2 run_mlr put -q 'tee > stderr, $*' $indir/abixy 2> $tee2/err2 run_cat $tee2/err2 # ---------------------------------------------------------------- announce DSL PRINT REDIRECTS print1=$reloutdir/print1 mkdir -p $print1 run_mlr put -q 'print > "'$print1'/out.".$a, "abi:".$a.$b.$i' $indir/abixy run_cat $print1/out.eks run_cat $print1/out.hat run_cat $print1/out.pan run_cat $print1/out.wye run_cat $print1/out.zee run_mlr put -q 'print > "'$print1'/out.".$a, "abi:".$a.$b.$i' $indir/abixy run_cat $print1/out.eks run_cat $print1/out.hat run_cat $print1/out.pan run_cat $print1/out.wye run_cat $print1/out.zee run_mlr put -q 'print >> "'$print1'/out.".$a, "abi:".$a.$b.$i' $indir/abixy run_cat $print1/out.eks run_cat $print1/out.hat run_cat $print1/out.pan run_cat $print1/out.wye run_cat $print1/out.zee run_mlr put -q 'print | "tr \[a-z\] \[A-Z\]", "abi:".$a.$b.$i' $indir/abixy touch $print1/err1 run_mlr put -q 'print > stdout, "abi:".$a.$b.$i' $indir/abixy 2> $print1/err1 run_cat $print1/err1 touch $print1/err2 run_mlr put -q 'print > stderr, "abi:".$a.$b.$i' $indir/abixy 2> $print1/err2 run_cat $print1/err2 # ---------------------------------------------------------------- announce DSL PRINTN REDIRECTS printn1=$reloutdir/printn1 mkdir -p $printn1 run_mlr put -q 'printn > "'$printn1'/out.".$a, "abi:".$a.$b.$i' $indir/abixy run_cat $printn1/out.eks run_cat $printn1/out.hat run_cat $printn1/out.pan run_cat $printn1/out.wye run_cat $printn1/out.zee run_mlr put -q 'printn > "'$printn1'/out.".$a, "abi:".$a.$b.$i' $indir/abixy run_cat $printn1/out.eks run_cat $printn1/out.hat run_cat $printn1/out.pan run_cat $printn1/out.wye run_cat $printn1/out.zee run_mlr put -q 'printn >> "'$printn1'/out.".$a, "abi:".$a.$b.$i' $indir/abixy run_cat $printn1/out.eks run_cat $printn1/out.hat run_cat $printn1/out.pan run_cat $printn1/out.wye run_cat $printn1/out.zee run_mlr put -q 'printn | "tr \[a-z\] \[A-Z\]", "abi:".$a.$b.$i' $indir/abixy touch $printn1/err1 run_mlr put -q 'printn > stdout, "abi:".$a.$b.$i' $indir/abixy 2> $printn1/err1 run_cat $printn1/err1 touch $printn1/err2 run_mlr put -q 'printn > stderr, "abi:".$a.$b.$i' $indir/abixy 2> $printn1/err2 run_cat $printn1/err2 # ---------------------------------------------------------------- announce DSL DUMP REDIRECTS dump1=$reloutdir/dump1 mkdir -p $dump1 run_mlr put -q '@v=$*; dump > "'$dump1'/out.".$a' $indir/abixy run_cat $dump1/out.eks run_cat $dump1/out.hat run_cat $dump1/out.pan run_cat $dump1/out.wye run_cat $dump1/out.zee run_mlr put -q '@v=$*; dump > "'$dump1'/out.".$a' $indir/abixy run_cat $dump1/out.eks run_cat $dump1/out.hat run_cat $dump1/out.pan run_cat $dump1/out.wye run_cat $dump1/out.zee run_mlr put -q '@v=$*; dump >> "'$dump1'/out.".$a' $indir/abixy run_cat $dump1/out.eks run_cat $dump1/out.hat run_cat $dump1/out.pan run_cat $dump1/out.wye run_cat $dump1/out.zee run_mlr put -q '@v=$*; dump | "tr \[a-z\] \[A-Z\]"' $indir/abixy touch $dump1/err1 run_mlr put -q '@v[NR] = $*; NR == 2 { dump > stdout }' $indir/abixy 2> $dump1/err1 run_cat $dump1/err1 touch $dump1/err2 run_mlr put -q '@v[NR] = $*; NR == 2 { dump > stderr }' $indir/abixy 2> $dump1/err2 run_cat $dump1/err2 # ---------------------------------------------------------------- announce DSL EMITF REDIRECTS emitf1=$reloutdir/emitf1 mkdir -p $emitf1 run_mlr put -q '@a=$a; @b=$b; emitf > "'$emitf1'/out.".$a.$b, @a, @b' $indir/abixy run_cat $emitf1/out.ekspan run_cat $emitf1/out.ekswye run_cat $emitf1/out.ekszee run_cat $emitf1/out.hatwye run_cat $emitf1/out.panpan run_cat $emitf1/out.panwye run_cat $emitf1/out.wyepan run_cat $emitf1/out.wyewye run_cat $emitf1/out.zeepan run_cat $emitf1/out.zeewye run_mlr put -q '@a=$a; @b=$b; emitf > "'$emitf1'/out.".$a.$b, @a, @b' $indir/abixy run_cat $emitf1/out.ekspan run_cat $emitf1/out.ekswye run_cat $emitf1/out.ekszee run_cat $emitf1/out.hatwye run_cat $emitf1/out.panpan run_cat $emitf1/out.panwye run_cat $emitf1/out.wyepan run_cat $emitf1/out.wyewye run_cat $emitf1/out.zeepan run_cat $emitf1/out.zeewye run_mlr put -q '@a=$a; @b=$b; emitf >> "'$emitf1'/out.".$a.$b, @a, @b' $indir/abixy run_cat $emitf1/out.ekspan run_cat $emitf1/out.ekswye run_cat $emitf1/out.ekszee run_cat $emitf1/out.hatwye run_cat $emitf1/out.panpan run_cat $emitf1/out.panwye run_cat $emitf1/out.wyepan run_cat $emitf1/out.wyewye run_cat $emitf1/out.zeepan run_cat $emitf1/out.zeewye run_mlr put -q -o json '@a=$a; @b=$b; emitf > "'$emitf1'/out.".$a.$b, @a, @b' $indir/abixy run_cat $emitf1/out.ekspan run_cat $emitf1/out.ekswye run_cat $emitf1/out.ekszee run_cat $emitf1/out.hatwye run_cat $emitf1/out.panpan run_cat $emitf1/out.panwye run_cat $emitf1/out.wyepan run_cat $emitf1/out.wyewye run_cat $emitf1/out.zeepan run_cat $emitf1/out.zeewye run_mlr put -q '@a=$a; @b=$b; emitf | "tr \[a-z\] \[A-Z\]", @a, @b' $indir/abixy touch $emitf1/err1 run_mlr put -q '@a=$a; @b=$b; emitf > stdout, @a, @b' $indir/abixy 2> $emitf1/err1 run_cat $emitf1/err1 touch $emitf1/err2 run_mlr put -q '@a=$a; @b=$b; emitf > stderr, @a, @b' $indir/abixy 2> $emitf1/err2 run_cat $emitf1/err2 # ---------------------------------------------------------------- announce DSL EMITP REDIRECTS emitp1=$reloutdir/emitp1 mkdir -p $emitp1 run_mlr head -n 4 then put -q '@a[NR]=$a; @b[NR]=$b; emitp > "'$emitp1'/out.".$a.$b, @a' $indir/abixy run_cat $emitp1/out.ekspan run_cat $emitp1/out.ekswye run_cat $emitp1/out.panpan run_cat $emitp1/out.wyewye run_mlr head -n 4 then put -q '@a[NR]=$a; @b[NR]=$b; emitp > "'$emitp1'/out.".$a.$b, @a' $indir/abixy run_cat $emitp1/out.ekspan run_cat $emitp1/out.ekswye run_cat $emitp1/out.panpan run_cat $emitp1/out.wyewye run_mlr head -n 4 then put -q '@a[NR]=$a; @b[NR]=$b; emitp >> "'$emitp1'/out.".$a.$b, @a' $indir/abixy run_cat $emitp1/out.ekspan run_cat $emitp1/out.ekswye run_cat $emitp1/out.panpan run_cat $emitp1/out.wyewye run_mlr head -n 4 then put -q -o json '@a[NR]=$a; @b[NR]=$b; emitp > "'$emitp1'/out.".$a.$b, @a' $indir/abixy run_cat $emitp1/out.ekspan run_cat $emitp1/out.ekswye run_cat $emitp1/out.panpan run_cat $emitp1/out.wyewye run_mlr head -n 4 then put -q '@a[NR]=$a; @b[NR]=$b; emitp | "tr \[a-z\] \[A-Z\]", @a' $indir/abixy touch $emitp1/err1 run_mlr head -n 4 then put -q '@a[NR]=$a; @b[NR]=$b; emitp > stdout, @a' $indir/abixy 2> $emitp1/err1 run_cat $emitp1/err1 touch $emitp1/err2 run_mlr head -n 4 then put -q '@a[NR]=$a; @b[NR]=$b; emitp > stderr, @a' $indir/abixy 2> $emitp1/err2 run_cat $emitp1/err2 emitp2=$reloutdir/emitp2 mkdir -p $emitp2 run_mlr head -n 4 then put -q '@a[NR]=$a; @b[NR]=$b; emitp > "'$emitp2'/out.".$a.$b, @a, "NR"' $indir/abixy run_cat $emitp2/out.ekspan run_cat $emitp2/out.ekswye run_cat $emitp2/out.panpan run_cat $emitp2/out.wyewye run_mlr head -n 4 then put -q '@a[NR]=$a; @b[NR]=$b; emitp > "'$emitp2'/out.".$a.$b, @a, "NR"' $indir/abixy run_cat $emitp2/out.ekspan run_cat $emitp2/out.ekswye run_cat $emitp2/out.panpan run_cat $emitp2/out.wyewye run_mlr head -n 4 then put -q '@a[NR]=$a; @b[NR]=$b; emitp >> "'$emitp2'/out.".$a.$b, @a, "NR"' $indir/abixy run_cat $emitp2/out.ekspan run_cat $emitp2/out.ekswye run_cat $emitp2/out.panpan run_cat $emitp2/out.wyewye run_mlr head -n 4 then put -q -o json '@a[NR]=$a; @b[NR]=$b; emitp > "'$emitp2'/out.".$a.$b, @a, "NR"' $indir/abixy run_cat $emitp2/out.ekspan run_cat $emitp2/out.ekswye run_cat $emitp2/out.panpan run_cat $emitp2/out.wyewye run_mlr head -n 4 then put -q '@a[NR]=$a; @b[NR]=$b; emitp | "tr \[a-z\] \[A-Z\]", @a, "NR"' $indir/abixy touch $emitp2/err1 run_mlr head -n 4 then put -q '@a[NR]=$a; @b[NR]=$b; emitp > stdout, @a, "NR"' $indir/abixy 2> $emitp2/err1 run_cat $emitp2/err1 touch $emitp2/err2 run_mlr head -n 4 then put -q '@a[NR]=$a; @b[NR]=$b; emitp > stderr, @a, "NR"' $indir/abixy 2> $emitp2/err2 run_cat $emitp2/err2 emitp3=$reloutdir/emitp3 mkdir -p $emitp3 run_mlr head -n 4 then put -q '@a[NR]=$a; @b[NR]=$b; emitp > "'$emitp3'/out.".$a.$b, (@a, @b)' $indir/abixy run_cat $emitp3/out.ekspan run_cat $emitp3/out.ekswye run_cat $emitp3/out.panpan run_cat $emitp3/out.wyewye run_mlr head -n 4 then put -q '@a[NR]=$a; @b[NR]=$b; emitp > "'$emitp3'/out.".$a.$b, (@a, @b)' $indir/abixy run_cat $emitp3/out.ekspan run_cat $emitp3/out.ekswye run_cat $emitp3/out.panpan run_cat $emitp3/out.wyewye run_mlr head -n 4 then put -q '@a[NR]=$a; @b[NR]=$b; emitp >> "'$emitp3'/out.".$a.$b, (@a, @b)' $indir/abixy run_cat $emitp3/out.ekspan run_cat $emitp3/out.ekswye run_cat $emitp3/out.panpan run_cat $emitp3/out.wyewye run_mlr head -n 4 then put -q -o json '@a[NR]=$a; @b[NR]=$b; emitp > "'$emitp3'/out.".$a.$b, (@a, @b)' $indir/abixy run_cat $emitp3/out.ekspan run_cat $emitp3/out.ekswye run_cat $emitp3/out.panpan run_cat $emitp3/out.wyewye run_mlr head -n 4 then put -q '@a[NR]=$a; @b[NR]=$b; emitp | "tr \[a-z\] \[A-Z\]", (@a, @b)' $indir/abixy touch $emitp3/err1 run_mlr head -n 4 then put -q '@a[NR]=$a; @b[NR]=$b; emitp > stdout, (@a, @b)' $indir/abixy 2> $emitp3/err1 run_cat $emitp3/err1 touch $emitp3/err2 run_mlr head -n 4 then put -q '@a[NR]=$a; @b[NR]=$b; emitp > stderr, (@a, @b)' $indir/abixy 2> $emitp3/err2 run_cat $emitp3/err2 emitp4=$reloutdir/emitp4 mkdir -p $emitp4 run_mlr head -n 4 then put -q '@a[NR]=$a; @b[NR]=$b; emitp > "'$emitp4'/out.".$a.$b, (@a, @b), "NR"' $indir/abixy run_cat $emitp4/out.ekspan run_cat $emitp4/out.ekswye run_cat $emitp4/out.panpan run_cat $emitp4/out.wyewye run_mlr head -n 4 then put -q '@a[NR]=$a; @b[NR]=$b; emitp > "'$emitp4'/out.".$a.$b, (@a, @b), "NR"' $indir/abixy run_cat $emitp4/out.ekspan run_cat $emitp4/out.ekswye run_cat $emitp4/out.panpan run_cat $emitp4/out.wyewye run_mlr head -n 4 then put -q '@a[NR]=$a; @b[NR]=$b; emitp >> "'$emitp4'/out.".$a.$b, (@a, @b), "NR"' $indir/abixy run_cat $emitp4/out.ekspan run_cat $emitp4/out.ekswye run_cat $emitp4/out.panpan run_cat $emitp4/out.wyewye run_mlr head -n 4 then put -q -o json '@a[NR]=$a; @b[NR]=$b; emitp > "'$emitp4'/out.".$a.$b, (@a, @b), "NR"' $indir/abixy run_cat $emitp4/out.ekspan run_cat $emitp4/out.ekswye run_cat $emitp4/out.panpan run_cat $emitp4/out.wyewye run_mlr head -n 4 then put -q '@a[NR]=$a; @b[NR]=$b; emitp | "tr \[a-z\] \[A-Z\]", (@a, @b), "NR"' $indir/abixy touch $emitp4/err1 run_mlr head -n 4 then put -q '@a[NR]=$a; @b[NR]=$b; emitp > stdout, (@a, @b), "NR"' $indir/abixy 2> $emitp4/err1 run_cat $emitp4/err1 touch $emitp4/err2 run_mlr head -n 4 then put -q '@a[NR]=$a; @b[NR]=$b; emitp > stderr, (@a, @b), "NR"' $indir/abixy 2> $emitp4/err2 run_cat $emitp4/err2 emitp5=$reloutdir/emitp5 mkdir -p $emitp5 run_mlr head -n 4 then put -q '@a[NR]=$a; @b[NR]=$b; emitp > "'$emitp5'/out.".$a.$b, @*' $indir/abixy run_cat $emitp5/out.ekspan run_cat $emitp5/out.ekswye run_cat $emitp5/out.panpan run_cat $emitp5/out.wyewye run_mlr head -n 4 then put -q '@a[NR]=$a; @b[NR]=$b; emitp | "tr \[a-z\] \[A-Z\]", @*' $indir/abixy touch $emitp5/err1 run_mlr head -n 4 then put -q '@a[NR]=$a; @b[NR]=$b; emitp > stdout, @*' $indir/abixy 2> $emitp5/err1 run_cat $emitp5/err1 touch $emitp5/err2 run_mlr head -n 4 then put -q '@a[NR]=$a; @b[NR]=$b; emitp > stderr, @*' $indir/abixy 2> $emitp5/err2 run_cat $emitp5/err2 emitp6=$reloutdir/emitp6 mkdir -p $emitp6 run_mlr head -n 4 then put -q '@a[NR]=$a; @b[NR]=$b; emitp > "'$emitp6'/out.".$a.$b, all' $indir/abixy run_cat $emitp6/out.ekspan run_cat $emitp6/out.ekswye run_cat $emitp6/out.panpan run_cat $emitp6/out.wyewye run_mlr head -n 4 then put -q '@a[NR]=$a; @b[NR]=$b; emitp | "tr \[a-z\] \[A-Z\]", all' $indir/abixy touch $emitp6/err1 run_mlr head -n 4 then put -q '@a[NR]=$a; @b[NR]=$b; emitp > stdout, all' $indir/abixy 2> $emitp6/err1 run_cat $emitp6/err1 touch $emitp6/err2 run_mlr head -n 4 then put -q '@a[NR]=$a; @b[NR]=$b; emitp > stderr, all' $indir/abixy 2> $emitp6/err2 run_cat $emitp6/err2 emitp7=$reloutdir/emitp7 mkdir -p $emitp7 run_mlr head -n 4 then put -q '@a[NR]=$a; @b[NR]=$b; emitp > "'$emitp7'/out.".$a.$b, @*, "NR"' $indir/abixy run_cat $emitp7/out.ekspan run_cat $emitp7/out.ekswye run_cat $emitp7/out.panpan run_cat $emitp7/out.wyewye run_mlr head -n 4 then put -q '@a[NR]=$a; @b[NR]=$b; emitp | "tr \[a-z\] \[A-Z\]", @*, "NR"' $indir/abixy touch $emitp7/err1 run_mlr head -n 4 then put -q '@a[NR]=$a; @b[NR]=$b; emitp > stdout, @*, "NR"' $indir/abixy 2> $emitp7/err1 run_cat $emitp7/err1 touch $emitp7/err2 run_mlr head -n 4 then put -q '@a[NR]=$a; @b[NR]=$b; emitp > stderr, @*, "NR"' $indir/abixy 2> $emitp7/err2 run_cat $emitp7/err2 emitp8=$reloutdir/emitp8 mkdir -p $emitp8 run_mlr head -n 4 then put -q '@a[NR]=$a; @b[NR]=$b; emitp > "'$emitp8'/out.".$a.$b, all, "NR"' $indir/abixy run_cat $emitp8/out.ekspan run_cat $emitp8/out.ekswye run_cat $emitp8/out.panpan run_cat $emitp8/out.wyewye run_mlr head -n 4 then put -q '@a[NR]=$a; @b[NR]=$b; emitp | "tr \[a-z\] \[A-Z\]", all, "NR"' $indir/abixy touch $emitp8/err1 run_mlr head -n 4 then put -q '@a[NR]=$a; @b[NR]=$b; emitp > stdout, all, "NR"' $indir/abixy 2> $emitp8/err1 run_cat $emitp8/err1 touch $emitp8/err2 run_mlr head -n 4 then put -q '@a[NR]=$a; @b[NR]=$b; emitp > stderr, all, "NR"' $indir/abixy 2> $emitp8/err2 run_cat $emitp8/err2 # ---------------------------------------------------------------- announce DSL EMIT REDIRECTS emit1=$reloutdir/emit1 mkdir -p $emit1 run_mlr head -n 4 then put -q '@a[NR]=$a; @b[NR]=$b; emit > "'$emit1'/out.".$a.$b, @a' $indir/abixy run_cat $emit1/out.ekspan run_cat $emit1/out.ekswye run_cat $emit1/out.panpan run_cat $emit1/out.wyewye run_mlr head -n 4 then put -q '@a[NR]=$a; @b[NR]=$b; emit > "'$emit1'/out.".$a.$b, @a' $indir/abixy run_cat $emit1/out.ekspan run_cat $emit1/out.ekswye run_cat $emit1/out.panpan run_cat $emit1/out.wyewye run_mlr head -n 4 then put -q '@a[NR]=$a; @b[NR]=$b; emit >> "'$emit1'/out.".$a.$b, @a' $indir/abixy run_cat $emit1/out.ekspan run_cat $emit1/out.ekswye run_cat $emit1/out.panpan run_cat $emit1/out.wyewye run_mlr head -n 4 then put -q -o json '@a[NR]=$a; @b[NR]=$b; emit > "'$emit1'/out.".$a.$b, @a' $indir/abixy run_cat $emit1/out.ekspan run_cat $emit1/out.ekswye run_cat $emit1/out.panpan run_cat $emit1/out.wyewye run_mlr head -n 4 then put -q '@a[NR]=$a; @b[NR]=$b; emit | "tr \[a-z\] \[A-Z\]", @a' $indir/abixy touch $emit1/err1 run_mlr head -n 4 then put -q '@a[NR]=$a; @b[NR]=$b; emit > stdout, @a' $indir/abixy 2> $emit1/err1 run_cat $emit1/err1 touch $emit1/err2 run_mlr head -n 4 then put -q '@a[NR]=$a; @b[NR]=$b; emit > stderr, @a' $indir/abixy 2> $emit1/err2 run_cat $emit1/err2 emit2=$reloutdir/emit2 mkdir -p $emit2 run_mlr head -n 4 then put -q '@a[NR]=$a; @b[NR]=$b; emit > "'$emit2'/out.".$a.$b, @a, "NR"' $indir/abixy run_cat $emit2/out.ekspan run_cat $emit2/out.ekswye run_cat $emit2/out.panpan run_cat $emit2/out.wyewye run_mlr head -n 4 then put -q '@a[NR]=$a; @b[NR]=$b; emit > "'$emit2'/out.".$a.$b, @a, "NR"' $indir/abixy run_cat $emit2/out.ekspan run_cat $emit2/out.ekswye run_cat $emit2/out.panpan run_cat $emit2/out.wyewye run_mlr head -n 4 then put -q '@a[NR]=$a; @b[NR]=$b; emit >> "'$emit2'/out.".$a.$b, @a, "NR"' $indir/abixy run_cat $emit2/out.ekspan run_cat $emit2/out.ekswye run_cat $emit2/out.panpan run_cat $emit2/out.wyewye run_mlr head -n 4 then put -q -o pprint '@a[NR]=$a; @b[NR]=$b; emit > "'$emit2'/out.".$a.$b, @a, "NR"' $indir/abixy run_cat $emit2/out.ekspan run_cat $emit2/out.ekswye run_cat $emit2/out.panpan run_cat $emit2/out.wyewye run_mlr head -n 4 then put -q '@a[NR]=$a; @b[NR]=$b; emit | "tr \[a-z\] \[A-Z\]", @a, "NR"' $indir/abixy touch $emit2/err1 run_mlr head -n 4 then put -q '@a[NR]=$a; @b[NR]=$b; emit > stdout, @a, "NR"' $indir/abixy 2> $emit2/err1 run_cat $emit2/err1 touch $emit2/err2 run_mlr head -n 4 then put -q '@a[NR]=$a; @b[NR]=$b; emit > stderr, @a, "NR"' $indir/abixy 2> $emit2/err2 run_cat $emit2/err2 emit3=$reloutdir/emit3 mkdir -p $emit3 run_mlr head -n 4 then put -q '@a[NR]=$a; @b[NR]=$b; emit > "'$emit3'/out.".$a.$b, (@a, @b)' $indir/abixy run_cat $emit3/out.ekspan run_cat $emit3/out.ekswye run_cat $emit3/out.panpan run_cat $emit3/out.wyewye run_mlr head -n 4 then put -q '@a[NR]=$a; @b[NR]=$b; emit > "'$emit3'/out.".$a.$b, (@a, @b)' $indir/abixy run_cat $emit3/out.ekspan run_cat $emit3/out.ekswye run_cat $emit3/out.panpan run_cat $emit3/out.wyewye run_mlr head -n 4 then put -q '@a[NR]=$a; @b[NR]=$b; emit >> "'$emit3'/out.".$a.$b, (@a, @b)' $indir/abixy run_cat $emit3/out.ekspan run_cat $emit3/out.ekswye run_cat $emit3/out.panpan run_cat $emit3/out.wyewye run_mlr head -n 4 then put -q --oxtab '@a[NR]=$a; @b[NR]=$b; emit > "'$emit3'/out.".$a.$b, (@a, @b)' $indir/abixy run_cat $emit3/out.ekspan run_cat $emit3/out.ekswye run_cat $emit3/out.panpan run_cat $emit3/out.wyewye run_mlr head -n 4 then put -q '@a[NR]=$a; @b[NR]=$b; emit | "tr \[a-z\] \[A-Z\]", (@a, @b)' $indir/abixy touch $emit3/err1 run_mlr head -n 4 then put -q '@a[NR]=$a; @b[NR]=$b; emit > stdout, (@a, @b)' $indir/abixy 2> $emit3/err1 run_cat $emit3/err1 touch $emit3/err2 run_mlr head -n 4 then put -q '@a[NR]=$a; @b[NR]=$b; emit > stderr, (@a, @b)' $indir/abixy 2> $emit3/err2 run_cat $emit3/err2 emit4=$reloutdir/emit4 mkdir -p $emit4 run_mlr head -n 4 then put -q '@a[NR]=$a; @b[NR]=$b; emit > "'$emit4'/out.".$a.$b, (@a, @b), "NR"' $indir/abixy run_cat $emit4/out.ekspan run_cat $emit4/out.ekswye run_cat $emit4/out.panpan run_cat $emit4/out.wyewye run_mlr head -n 4 then put -q '@a[NR]=$a; @b[NR]=$b; emit > "'$emit4'/out.".$a.$b, (@a, @b), "NR"' $indir/abixy run_cat $emit4/out.ekspan run_cat $emit4/out.ekswye run_cat $emit4/out.panpan run_cat $emit4/out.wyewye run_mlr head -n 4 then put -q '@a[NR]=$a; @b[NR]=$b; emit >> "'$emit4'/out.".$a.$b, (@a, @b), "NR"' $indir/abixy run_cat $emit4/out.ekspan run_cat $emit4/out.ekswye run_cat $emit4/out.panpan run_cat $emit4/out.wyewye run_mlr head -n 4 then put -q --ojson '@a[NR]=$a; @b[NR]=$b; emit > "'$emit4'/out.".$a.$b, (@a, @b), "NR"' $indir/abixy run_cat $emit4/out.ekspan run_cat $emit4/out.ekswye run_cat $emit4/out.panpan run_cat $emit4/out.wyewye run_mlr head -n 4 then put -q '@a[NR]=$a; @b[NR]=$b; emit | "tr \[a-z\] \[A-Z\]", (@a, @b), "NR"' $indir/abixy touch $emit4/err1 run_mlr head -n 4 then put -q '@a[NR]=$a; @b[NR]=$b; emit > stdout, (@a, @b), "NR"' $indir/abixy 2> $emit4/err1 run_cat $emit4/err1 touch $emit4/err2 run_mlr head -n 4 then put -q '@a[NR]=$a; @b[NR]=$b; emit > stderr, (@a, @b), "NR"' $indir/abixy 2> $emit4/err2 run_cat $emit4/err2 emit5=$reloutdir/emit5 mkdir -p $emit5 run_mlr head -n 4 then put -q '@a[NR]=$a; @b[NR]=$b; emit > "'$emit5'/out.".$a.$b, @*' $indir/abixy run_cat $emit5/out.ekspan run_cat $emit5/out.ekswye run_cat $emit5/out.panpan run_cat $emit5/out.wyewye run_mlr head -n 4 then put -q '@a[NR]=$a; @b[NR]=$b; emit | "tr \[a-z\] \[A-Z\]", @*' $indir/abixy touch $emit5/err1 run_mlr head -n 4 then put -q '@a[NR]=$a; @b[NR]=$b; emit > stdout, @*' $indir/abixy 2> $emit5/err1 run_cat $emit5/err1 touch $emit5/err2 run_mlr head -n 4 then put -q '@a[NR]=$a; @b[NR]=$b; emit > stderr, @*' $indir/abixy 2> $emit5/err2 run_cat $emit5/err2 emit6=$reloutdir/emit6 mkdir -p $emit6 run_mlr head -n 4 then put -q '@a[NR]=$a; @b[NR]=$b; emit > "'$emit6'/out.".$a.$b, all' $indir/abixy run_cat $emit6/out.ekspan run_cat $emit6/out.ekswye run_cat $emit6/out.panpan run_cat $emit6/out.wyewye run_mlr head -n 4 then put -q '@a[NR]=$a; @b[NR]=$b; emit | "tr \[a-z\] \[A-Z\]", all' $indir/abixy touch $emit6/err1 run_mlr head -n 4 then put -q '@a[NR]=$a; @b[NR]=$b; emit > stdout, all' $indir/abixy 2> $emit6/err1 run_cat $emit6/err1 touch $emit6/err2 run_mlr head -n 4 then put -q '@a[NR]=$a; @b[NR]=$b; emit > stderr, all' $indir/abixy 2> $emit6/err2 run_cat $emit6/err2 emit7=$reloutdir/emit7 mkdir -p $emit7 run_mlr head -n 4 then put -q '@a[NR]=$a; @b[NR]=$b; emit > "'$emit7'/out.".$a.$b, @*, "NR"' $indir/abixy run_cat $emit7/out.ekspan run_cat $emit7/out.ekswye run_cat $emit7/out.panpan run_cat $emit7/out.wyewye run_mlr head -n 4 then put -q '@a[NR]=$a; @b[NR]=$b; emit | "tr \[a-z\] \[A-Z\]", @*, "NR"' $indir/abixy touch $emit7/err1 run_mlr head -n 4 then put -q '@a[NR]=$a; @b[NR]=$b; emit > stdout, @*, "NR"' $indir/abixy 2> $emit7/err1 run_cat $emit7/err1 touch $emit7/err2 run_mlr head -n 4 then put -q '@a[NR]=$a; @b[NR]=$b; emit > stderr, @*, "NR"' $indir/abixy 2> $emit7/err2 run_cat $emit7/err2 emit8=$reloutdir/emit8 mkdir -p $emit8 run_mlr head -n 4 then put -q '@a[NR]=$a; @b[NR]=$b; emit > "'$emit8'/out.".$a.$b, all, "NR"' $indir/abixy run_cat $emit8/out.ekspan run_cat $emit8/out.ekswye run_cat $emit8/out.panpan run_cat $emit8/out.wyewye run_mlr head -n 4 then put -q '@a[NR]=$a; @b[NR]=$b; emit | "tr \[a-z\] \[A-Z\]", all, "NR"' $indir/abixy touch $emit8/err1 run_mlr head -n 4 then put -q '@a[NR]=$a; @b[NR]=$b; emit > stdout, all, "NR"' $indir/abixy 2> $emit8/err1 run_cat $emit8/err1 touch $emit8/err2 run_mlr head -n 4 then put -q '@a[NR]=$a; @b[NR]=$b; emit > stderr, all, "NR"' $indir/abixy 2> $emit8/err2 run_cat $emit8/err2 emit9=$reloutdir/emit9 mkdir -p $emit9 run_mlr head -n 4 then put -q 'emit > "'$emit9'/out.".$a.$b, $*' $indir/abixy run_cat $emit9/out.ekspan run_cat $emit9/out.ekswye run_cat $emit9/out.panpan run_cat $emit9/out.wyewye run_mlr head -n 4 then put -q '@a[NR]=$a; @b[NR]=$b; emit | "tr \[a-z\] \[A-Z\]", $*, "NR"' $indir/abixy touch $emit9/err1 run_mlr head -n 4 then put -q '@a[NR]=$a; @b[NR]=$b; emit > stdout, $*, "NR"' $indir/abixy 2> $emit9/err1 run_cat $emit9/err1 touch $emit9/err2 run_mlr head -n 4 then put -q '@a[NR]=$a; @b[NR]=$b; emit > stderr, $*, "NR"' $indir/abixy 2> $emit9/err2 run_cat $emit9/err2 emit10=$reloutdir/emit10 mkdir -p $emit10 run_mlr head -n 4 then put -q 'emit > "'$emit10'/out.".$a.$b, mapexcept($*, "a", "b")' $indir/abixy run_cat $emit10/out.ekspan run_cat $emit10/out.ekswye run_cat $emit10/out.panpan run_cat $emit10/out.wyewye run_mlr head -n 4 then put -q '@a[NR]=$a; @b[NR]=$b; emit | "tr \[a-z\] \[A-Z\]", mapexcept($*, "a", "b"), "NR"' $indir/abixy touch $emit10/err1 run_mlr head -n 4 then put -q '@a[NR]=$a; @b[NR]=$b; emit > stdout, mapexcept($*, "a", "b"), "NR"' $indir/abixy 2> $emit10/err1 run_cat $emit10/err1 touch $emit10/err2 run_mlr head -n 4 then put -q '@a[NR]=$a; @b[NR]=$b; emit > stderr, mapexcept($*, "a", "b"), "NR"' $indir/abixy 2> $emit10/err2 run_cat $emit10/err2 # ---------------------------------------------------------------- announce USER-DEFINED FUNCTIONS AND SUBROUTINES run_mlr --opprint --from $indir/abixy put 'func f(u,v){return u+v} $o=f(NR*1000,$x)' mlr_expect_fail --opprint --from $indir/abixy put 'func f(x,y,z){$nnn=999; int n=10; return $y} $o=f($i,$x,$y)' run_mlr --opprint --from $indir/abixy put 'subr s(a,b) { $[a] = b } call s("W", 999)' run_mlr --opprint --from $indir/abixy put ' func f(x,y,z) { return x + y + z } subr s(a,b) { $[a] = b; $DID = "YES"; } $o = f($x, $y, $i); call s("W", NR); ' run_mlr --opprint --from $indir/abixy put ' func f(x,y,z) { return x + y + z } subr s(a,b) { $[a] = b; return; $DID = "YES"; } $o = f($x, $y, $i); call s("W", NR); ' mlr_expect_fail --from $indir/abixy put ' func f(x,y,z) { return x + y + z } subr s(a,b) { $[a] = b; return 1 # subr must not return value } $o = f($x, $y, $i); call s("W", NR); ' mlr_expect_fail --from $indir/abixy put ' func f(x,y,z) { return # func must return value } subr s(a,b) { $[a] = b; } $o = f($x, $y, $i); call s("W", NR); ' # Test fencing: function f should not have access to boundvar k from the callsite. run_mlr --from $indir/abixy --opprint put 'func f(x) {return k} for (k,v in $*) {$o=f($x)}' run_mlr --from $indir/abixy --opprint put 'subr foo() {print "k is [".k."]"} for (k,v in $*) {call foo()}' # Test overriding built-ins mlr_expect_fail --opprint --from $indir/abixy put 'func log(x) { return 0 } $o = log($x)' run_mlr --from $indir/abixy put 'subr log() { print "hello record ". NR } call log()' # Test variable-clear at scope exit; test read of unset locals. run_mlr --opprint --from $indir/abixy put '$o1 = a; int a=1000+NR; $o2 = a; a=2000+NR; $o3 = a' # Test recursion run_mlr --opprint --from $indir/abixy put ' func f(n) { if (is_numeric(n)) { if (n > 0) { return n * f(n-1) } else { return 1 } } # implicitly return absent } $o = f(NR) ' run_mlr --opprint --from $indir/abixy head -n 5 then put ' subr s(n) { print "n = " . n; if (is_numeric(n)) { if (n > 0) { call s(n-1) } } } print ""; call s(NR) ' run_mlr --from $indir/abixy --opprint put ' func f(n) { return n+1; } $o1 = f(NR); $o2 = f(f(NR)); $o3 = f(f(f(NR))); $o4 = f(f(f(f(NR)))); $o5 = f(f(f(f(f(NR))))); $o6 = f(f(f(f(f(f(NR)))))); ' run_mlr --from $indir/abixy --opprint put ' func f(n) { if (n < 2) { return 1 } else { return f(n-1) + f(n-2) } } $o = f(NR) ' run_mlr --from $indir/abixy --opprint put ' func f(n) { if (is_present(@fcache[n])) { return @fcache[n] } else { num rv = 1; if (n >= 2) { rv = f(n-1) + f(n-2) } @fcache[n] = rv; return rv } } $o = f(NR) ' # No nesting of top-levels mlr_expect_fail --from $indir/abixy --opprint put 'func f(x) { begin {} }' mlr_expect_fail --from $indir/abixy --opprint put 'func f(x) { end {} }' mlr_expect_fail --from $indir/abixy --opprint put 'subr s(x) { begin {} }' mlr_expect_fail --from $indir/abixy --opprint put 'subr s(x) { end {} }' mlr_expect_fail --from $indir/abixy --opprint put 'func f(x) { func g(y) {} }' mlr_expect_fail --from $indir/abixy --opprint put 'func f(x) { subr t(y) {} }' mlr_expect_fail --from $indir/abixy --opprint put 'subr s(x) { func g(y) {} }' mlr_expect_fail --from $indir/abixy --opprint put 'subr s(x) { subr t(y) {} }' mlr_expect_fail --from $indir/abixy --opprint filter 'func f(x) { begin {} }; true' mlr_expect_fail --from $indir/abixy --opprint filter 'func f(x) { end {} }; true' mlr_expect_fail --from $indir/abixy --opprint filter 'subr s(x) { begin {} }; true' mlr_expect_fail --from $indir/abixy --opprint filter 'subr s(x) { end {} }; true' mlr_expect_fail --from $indir/abixy --opprint filter 'func f(x) { func g(y) {} }; true' mlr_expect_fail --from $indir/abixy --opprint filter 'func f(x) { subr t(y) {} }; true' mlr_expect_fail --from $indir/abixy --opprint filter 'subr s(x) { func g(y) {} }; true' mlr_expect_fail --from $indir/abixy --opprint filter 'subr s(x) { subr t(y) {} }; true' # Disallow redefines mlr_expect_fail --from $indir/abixy --opprint put 'func log(x) { return $x + 1 }' mlr_expect_fail --from $indir/abixy --opprint put 'func f(x) { return $x + 1 } func f(x) { return $x + 1}' mlr_expect_fail --from $indir/abixy --opprint put 'subr s() { } subr s() { }' mlr_expect_fail --from $indir/abixy --opprint put 'subr s() { } subr s(x) { }' run_mlr --from $indir/abixy --opprint put 'subr log(text) { print "TEXT IS ".text } call log("NR is ".NR)' # print/dump from subr/func; no tee/emit from func run_mlr --from $indir/abixy --opprint put 'subr log(text) { print "TEXT IS ".text } call log("NR is ".NR)' run_mlr --from $indir/abixy --opprint put 'func f(text) { print "TEXT IS ".text; return text.text } $o = f($a)' run_mlr --from $indir/abixy put 'begin{@x=1} func f(x) { dump; print "hello" } $o=f($i)' mlr_expect_fail --from $indir/abixy put 'begin{@x=1} func f(x) { dump; print "hello"; tee > "x", $* } $o=f($i)' mlr_expect_fail --from $indir/abixy put 'begin{@x=1} func f(x) { dump; print "hello"; emit > "x", @* } $o=f($i)' # not use all args (for valgrind) run_mlr --from $indir/abixy put 'func f(x,y) { return 2*y } $o = f($x,$y) ' # general programming-language stuff run_mlr -n put -q -f $indir/sieve.mlr run_mlr -n put -q -f $indir/mand.mlr -e 'begin {@verbose = true}' # scoping within distinct begin/end blocks run_mlr --from $indir/abixy put -v ' func f(x) { return x**2 } func g(y) { return y+1 } subr s(a,b,c) { print a.b.c } begin { @a = 0; var ell = 1; print "local1 = ".ell; } end { emit @a; var emm = 2; print "local2 = ".emm; } @a += 1; begin { @b = 0; @c = 0; print "local3 = ".ell; } @b += 2; @c += 3; end { emit @b; emit @c; print "local4 = ".emm; } ' # ---------------------------------------------------------------- announce LOCALVAR SCOPE AND EXTENT run_mlr --opprint --from $indir/abixy put ' func f() { var a = 1; if (NR > 5) { a = 2; } return a; } func g() { var b = 1; if (NR > 5) { var b = 2; } return b; } func h() { var a = 1; if (NR > 5) { a = 2; return a; } return a; } func i() { var b = 1; if (NR > 5) { var b = 2; return b; } return b; } $of = f(); $og = g(); $oh = h(); $oi = i(); ' # test fencing at function entry run_mlr --opprint --from $indir/abixy put ' func f() { var a = 2; var b = 2; if (NR > 5) { var a = 3; b = 3; } return 1000 * a + b; } a = 1; b = 1; $ab = f(); $oa = a; $ob = b; ' # ---------------------------------------------------------------- announce LOCALVAR UNSETS run_mlr put -q 's=$x; t[$a]=$x; u[$a][$b]=$x; dump s; dump t; dump u; unset s ; dump s; dump t; dump u' $indir/unset1.dkvp run_mlr put -q 's=$x; t[$a]=$x; u[$a][$b]=$x; dump s; dump t; dump u; unset t ; dump s; dump t; dump u' $indir/unset1.dkvp run_mlr put -q 's=$x; t[$a]=$x; u[$a][$b]=$x; dump s; dump t; dump u; unset t[1] ; dump s; dump t; dump u' $indir/unset1.dkvp run_mlr put -q 's=$x; t[$a]=$x; u[$a][$b]=$x; dump s; dump t; dump u; unset u ; dump s; dump t; dump u' $indir/unset1.dkvp run_mlr put -q 's=$x; t[$a]=$x; u[$a][$b]=$x; dump s; dump t; dump u; unset u[1] ; dump s; dump t; dump u' $indir/unset1.dkvp run_mlr put -q 's=$x; t[$a]=$x; u[$a][$b]=$x; dump s; dump t; dump u; unset u[1][2]; dump s; dump t; dump u' $indir/unset1.dkvp run_mlr put -q 's=$x; t[$a]=$x; u[$a][$b]=$x; dump s; dump t; dump u; unset s ; dump s; dump t; dump u' $indir/unset4.dkvp run_mlr put -q 's=$x; t[$a]=$x; u[$a][$b]=$x; dump s; dump t; dump u; unset t ; dump s; dump t; dump u' $indir/unset4.dkvp run_mlr put -q 's=$x; t[$a]=$x; u[$a][$b]=$x; dump s; dump t; dump u; unset t[1] ; dump s; dump t; dump u' $indir/unset4.dkvp run_mlr put -q 's=$x; t[$a]=$x; u[$a][$b]=$x; dump s; dump t; dump u; unset u ; dump s; dump t; dump u' $indir/unset4.dkvp run_mlr put -q 's=$x; t[$a]=$x; u[$a][$b]=$x; dump s; dump t; dump u; unset u[1] ; dump s; dump t; dump u' $indir/unset4.dkvp run_mlr put -q 's=$x; t[$a]=$x; u[$a][$b]=$x; dump s; dump t; dump u; unset u[1][2]; dump s; dump t; dump u' $indir/unset4.dkvp # ---------------------------------------------------------------- announce LOCALVAR TYPEDECLs run_mlr --from $indir/abixy put ' str a = $a; a = "a:".NR; $c = a; ' mlr_expect_fail --from $indir/abixy put ' str a = $a; a = NR; $c = a; ' mlr_expect_fail --from $indir/abixy put ' int a = $a; a = NR; $c = a; ' run_mlr --from $indir/abixy put ' int i = $i; i = NR; $c = a; ' # ---------------------------------------------------------------- announce FORBIND TYPEDECLs run_mlr --from $indir/abixy put ' for (int i = 0; i < $i; i += 1) { $c = i * 10; } ' mlr_expect_fail --from $indir/abixy put ' for (float i = 0; i < $i; i += 1) { $c = i * 10; } ' run_mlr --from $indir/abixy put ' for (int i = 0; i < $i; i += 1) { i += 2; $c = i; } ' mlr_expect_fail --from $indir/abixy put ' for (int i = 0; i < $i; i += 1) { i += 1.5; $c = i; } ' mlr_expect_fail --from $indir/abixy put ' for (int i = 0; i < $i; i += 1) { i += 1.0; $c = i; } ' run_mlr --from $indir/abixy put ' for (num i = 0; i < $i; i += 1) { i += 1.0; $c = i; } ' # ---------------------------------------------------------------- announce ARGPASS TYPEDECLs run_mlr --from $indir/abixy put ' func f(int i) { return i+3; } $c = f($i); ' mlr_expect_fail --from $indir/abixy put ' func f(int i) { return i+3; } $c = f($x); ' mlr_expect_fail --from $indir/abixy put ' func f(num i): int { return i+3.45; } $c = f($x); ' mlr_expect_fail --from $indir/abixy put ' func f(num i): int { return i+3.45; } $c = f($i); ' mlr_expect_fail --from $indir/abixy put ' func f(num i): int { i = "a"; return 2; } $c = f($x); ' run_mlr --from $indir/abixy put ' subr s(int i) { print i+3; } call s($i); ' mlr_expect_fail --from $indir/abixy put ' subr s(int i) { print i+3; } call s($x); ' mlr_expect_fail --from $indir/abixy put ' subr s(num i) { i = "a"; print 2; } call s($x); ' # ---------------------------------------------------------------- announce LOCAL MAP-VARIABLE WRITE/READ run_mlr --from $indir/xyz345 put -v -a ' $s = a; $t = b[$x]; $u = c[$x][$y]; $v = d[$x][$y][$z]; ' run_mlr --from $indir/xyz345 put -v -a ' d[$x][$y][$z] = 9; $d = d[$x][$y][$z]; ' run_mlr --from $indir/xyz345 put -v -a ' a = 6; b[$x] = 7; c[$x][$y] = 8; d[$x][$y][$z] = 9; $a = a; $b = b[$x]; $c = c[$x][$y]; $d = d[$x][$y][$z]; ' run_mlr --from $indir/xyz345 put -v -a ' a = 6; b[$x] = 7; c[$x][$y] = 8; d[$x][$y][$z] = 9; $a0 = a; $a1 = a[$x]; $a2 = a[$x][$y]; $a3 = a[$x][$y][$z]; $b0 = b; $b1 = b[$x]; $b2 = b[$x][$y]; $b3 = b[$x][$y][$z]; $c0 = c; $c1 = c[$x]; $c2 = c[$x][$y]; $c3 = c[$x][$y][$z]; $d0 = d; $d1 = d[$x]; $d2 = d[$x][$y]; $d3 = d[$x][$y][$z]; ' # ---------------------------------------------------------------- announce LOCAL MAP-VARIABLE TYPE-DECL run_mlr --from $indir/xyz345 put ' map a = {}; ' run_mlr --from $indir/xyz345 put ' map a = {}; a[1]=2; a[3][4]=5; ' mlr_expect_fail --from $indir/xyz345 put ' map a = {}; a=2; a[3][4]=5; ' mlr_expect_fail --from $indir/xyz345 put ' map a = {}; a[3][4]=5; a=2; ' # ---------------------------------------------------------------- announce TRIPLE-FORs run_mlr --opprint --from $indir/abixy put ' num sum = 0; num a = 1; for (;;) { if (a > NR) { break; } sum += a; a += 1 } $z = sum ' run_mlr --opprint --from $indir/abixy put ' num sum = 0; num a = 1; for (;;) { if (a > NR) { break; } sum += a; a += 1 } $z = sum ' run_mlr --opprint --from $indir/abixy put ' num sum = 0; for (num a = 1; ;) { if (a > NR) { break; } sum += a; a += 1 } $z = sum ' run_mlr --opprint --from $indir/abixy put ' num sum = 0; num a = 1; for (; ; a += 1) { if (a > NR) { break; } sum += a; } $z = sum ' run_mlr --opprint --from $indir/abixy put ' num sum = 0; for (num a=1; ; a += 1) { if (a > NR) { break; } sum += a; } $z = sum ' run_mlr --opprint --from $indir/abixy put ' num sum = 0; for (num a=1; a <= NR; a += 1) { sum += a; } $z = sum ' echo x=1 | run_mlr put ' num a = 100; num b = 100; for (num a = 200, b = 300; a <= 210; a += 1, b += 1) { print "a:".a.",b:".b } $oa = a; $ob = b; ' run_mlr --from $indir/abixy put ' for ( ; $x <= 10; $x += 1) { } ' run_mlr --opprint --from $indir/abixy put ' num a = 100; b = 200; @c = 300; $d = 400; for (num i = 1; i < 1024; i *= 2) { a += 1; b += 1; @c += 1; $d += 1; $oa = a; $ob = b; $oc = @c; $od = $d; } ' run_mlr --opprint --from $indir/abixy put ' num sum = 0; for (num a = 1; a <= 10; a += 1) { continue; sum += a; } $z = sum ' run_mlr --opprint --from $indir/abixy put ' num sum = 0; for (num a = 1; a <= 10; a += 1) { sum += a; break; } $z = sum ' run_mlr --opprint --from $indir/abixy put ' num sum = 0; for (num a = 1; a <= NR; a += 1) { if (a == 4 || a == 5) { continue; } if (a == 8) { break; } sum += a; } $z = sum ' # Multi-continutation cases run_mlr --opprint --from $indir/abixy put ' for ($o1 = 1; ; $o3 = 3) { break; } ' run_mlr --opprint --from $indir/abixy put ' for ($o1 = 1; $o1 < NR; $o1 += 1) { } ' mlr_expect_fail --opprint --from $indir/abixy put ' for ($o1 = 1, $o2 = 2; $o3 = 3; $o4 = 4) { } ' mlr_expect_fail --opprint --from $indir/abixy put ' for ($o1 = 1, $o2 = 2; $o3 < 3, $o4 = 4; $o5 = 5) { break; } ' run_mlr --opprint --from $indir/abixy put ' $o4 = 0; for ($o1 = 1, $o2 = 2; $o3 = 3, $o4 < 4; $o5 = 5) { break; } ' # ---------------------------------------------------------------- announce MAPVARS IN SCALAR FUNCTION-CALL CONTEXTS mlr_expect_fail --from $indir/abixy put '$z=strlen($*)' mlr_expect_fail --from $indir/abixy put '$z=strlen({})' run_mlr --from $indir/abixy put 'a={}; $z=strlen(a)' # ---------------------------------------------------------------- announce MAPVAR ASSIGNMENTS TO FULL SREC run_mlr --from $indir/xyz2 put '$* = {"a":1, "b": {"x":8,"y":9}, "c":3}' run_mlr --from $indir/xyz2 put '$* = $*' run_mlr --from $indir/xyz2 put '@a = 1; $* = @a' run_mlr --from $indir/xyz2 put '@b[1] = 2; $* = @b' run_mlr --from $indir/xyz2 put '@c[1][2] = 3; $* = @c' run_mlr --from $indir/xyz2 put '@a = 1; $* = @*' run_mlr --from $indir/xyz2 put '@b[1] = 2; $* = @*' run_mlr --from $indir/xyz2 put '@c[1][2] = 3; $* = @*' run_mlr --from $indir/xyz2 put 'a = 1; $* = a' run_mlr --from $indir/xyz2 put 'b[1] = 2; $* = b' run_mlr --from $indir/xyz2 put 'c[1][2] = 3; $* = c' run_mlr --from $indir/xyz2 put '$* = 3' run_mlr --from $indir/xyz2 put ' func map_valued_func() { return {"a":1,"b":2} } map m = map_valued_func(); $* = m; ' run_mlr --from $indir/xyz2 put ' func map_valued_func() { return {"a":1,"b":2} } $* = map_valued_func(); ' # ---------------------------------------------------------------- announce MAPVAR ASSIGNMENTS TO FULL OOSVAR run_mlr --from $indir/xyz2 put '@* = {"a":1, "b": {"x":8,"y":9}, "c":3}; dump' run_mlr --from $indir/xyz2 put '@* = $*; dump' run_mlr --from $indir/xyz2 put '@* = {"a":1, "b": {"x":8,"y":9}, "c":3}; dump; @* = @*; dump' run_mlr --from $indir/xyz2 put '@a = 1; @* = @a; dump' run_mlr --from $indir/xyz2 put '@b[1] = 2; @* = @b; dump' run_mlr --from $indir/xyz2 put '@c[1][2] = 3; @* = @c; dump' run_mlr --from $indir/xyz2 put '@a = 1; @* = @*; dump' run_mlr --from $indir/xyz2 put '@b[1] = 2; @* = @*; dump' run_mlr --from $indir/xyz2 put '@c[1][2] = 3; @* = @*; dump' run_mlr --from $indir/xyz2 put 'a = 1; @* = a; dump' run_mlr --from $indir/xyz2 put 'b[1] = 2; @* = b; dump' run_mlr --from $indir/xyz2 put 'c[1][2] = 3; @* = c; dump' run_mlr --from $indir/xyz2 put '@* = 3' run_mlr --from $indir/xyz2 put ' func map_valued_func() { return {"a":1,"b":2} } map m = map_valued_func(); @* = m; dump ' run_mlr --from $indir/xyz2 put ' func map_valued_func() { return {"a":1,"b":2} } @* = map_valued_func(); dump ' # ---------------------------------------------------------------- announce MAPVAR ASSIGNMENTS TO OOSVAR run_mlr --from $indir/xyz2 put -q '@o = {"a":1, "b": {"x":8,"y":9}, "c":3}; dump @o' run_mlr --from $indir/xyz2 put -q '@o = @o; dump @o' run_mlr --from $indir/xyz2 put -q '@o = {"a":1, "b": {"x":8,"y":9}, "c":3}; dump; @o = @*; dump' run_mlr --from $indir/xyz2 put -q '@o = $*; dump @o' run_mlr --from $indir/xyz2 put -q '@o = {"a":1, "b": {"x":8,"y":9}, "c":3}; dump @o; @o = @o; dump @o' run_mlr --from $indir/xyz2 put -q '@o = {"a":1, "b": {"x":8,"y":9}, "c":3}; @o = @o; dump @o' run_mlr --from $indir/xyz2 put -q '@a = 1; @o = @a; dump @o' run_mlr --from $indir/xyz2 put -q '@b[1] = 2; @o = @b; dump @o' run_mlr --from $indir/xyz2 put -q '@c[1][2] = 3; @o = @c; dump @o' run_mlr --from $indir/xyz2 put -q '@a = 1; @o = @*; dump @o' run_mlr --from $indir/xyz2 put -q '@b[1] = 2; @o = @*; dump @o' run_mlr --from $indir/xyz2 put -q '@c[1][2] = 3; @o = @*; dump @o' run_mlr --from $indir/xyz2 put -q 'a = 1; @o = a; dump @o' run_mlr --from $indir/xyz2 put -q 'b[1] = 2; @o = b; dump @o' run_mlr --from $indir/xyz2 put -q 'c[1][2] = 3; @o = c; dump @o' run_mlr --from $indir/xyz2 put -q 'func map_valued_func() { return {"a":1,"b":2}} @o = map_valued_func(); dump @o' # ---------------------------------------------------------------- announce MAPVAR ASSIGNMENTS TO MAP-TYPED LOCAL run_mlr --from $indir/xyz2 put -q 'map o = {"a":1, "b": {"x":8,"y":9}, "c":3}; dump o' mlr_expect_fail --from $indir/xyz2 put -q 'map o = @o; dump o' run_mlr --from $indir/xyz2 put -q 'map o = $*; dump o' run_mlr --from $indir/xyz2 put -q 'map o = {"a":1, "b": {"x":8,"y":9}, "c":3}; o = o; dump o' mlr_expect_fail --from $indir/xyz2 put -q '@a = 1; map o = @a; dump o' run_mlr --from $indir/xyz2 put -q '@b[1] = 2; map o = @b; dump o' run_mlr --from $indir/xyz2 put -q '@c[1][2] = 3; map o = @c; dump o' run_mlr --from $indir/xyz2 put -q '@a = 1; map o = @*; dump o' run_mlr --from $indir/xyz2 put -q '@b[1] = 2; map o = @*; dump o' run_mlr --from $indir/xyz2 put -q '@c[1][2] = 3; map o = @*; dump o' mlr_expect_fail --from $indir/xyz2 put -q 'a = 1; map o = a; dump o' run_mlr --from $indir/xyz2 put -q 'b[1] = 2; map o = b; dump o' run_mlr --from $indir/xyz2 put -q 'c[1][2] = 3; map o = c; dump o' run_mlr --from $indir/xyz2 put -q 'func map_valued_func() { return {"a":1,"b":2}} map o = map_valued_func(); dump o' # ---------------------------------------------------------------- announce MAPVAR ASSIGNMENTS TO VAR-TYPED LOCAL run_mlr --from $indir/xyz2 put -q 'var o = {"a":1, "b": {"x":8,"y":9}, "c":3}; dump o' run_mlr --from $indir/xyz2 put -q 'var o = @o; dump o' run_mlr --from $indir/xyz2 put -q 'var o = $*; dump o' run_mlr --from $indir/xyz2 put -q 'var o = {"a":1, "b": {"x":8,"y":9}, "c":3}; o = o; dump o' run_mlr --from $indir/xyz2 put -q '@a = 1; var o = @a; dump o' run_mlr --from $indir/xyz2 put -q '@b[1] = 2; var o = @b; dump o' run_mlr --from $indir/xyz2 put -q '@c[1][2] = 3; var o = @c; dump o' run_mlr --from $indir/xyz2 put -q '@a = 1; var o = @*; dump o' run_mlr --from $indir/xyz2 put -q '@b[1] = 2; var o = @*; dump o' run_mlr --from $indir/xyz2 put -q '@c[1][2] = 3; var o = @*; dump o' run_mlr --from $indir/xyz2 put -q 'a = 1; var o = a; dump o' run_mlr --from $indir/xyz2 put -q 'b[1] = 2; var o = b; dump o' run_mlr --from $indir/xyz2 put -q 'c[1][2] = 3; var o = c; dump o' run_mlr --from $indir/xyz2 put -q 'func map_valued_func() { return {"a":1,"b":2}} var o = map_valued_func(); dump o' # ---------------------------------------------------------------- announce MAPVAR ASSIGNMENTS TO UNTYPED LOCAL run_mlr --from $indir/xyz2 put -q 'o = {"a":1, "b": {"x":8,"y":9}, "c":3}; dump o' run_mlr --from $indir/xyz2 put -q 'o = @o; dump o' run_mlr --from $indir/xyz2 put -q 'o = $*; dump o' run_mlr --from $indir/xyz2 put -q 'o = {"a":1, "b": {"x":8,"y":9}, "c":3}; o = o; dump o' run_mlr --from $indir/xyz2 put -q '@a = 1; o = @a; dump o' run_mlr --from $indir/xyz2 put -q '@b[1] = 2; o = @b; dump o' run_mlr --from $indir/xyz2 put -q '@c[1][2] = 3; o = @c; dump o' run_mlr --from $indir/xyz2 put -q '@a = 1; o = @*; dump o' run_mlr --from $indir/xyz2 put -q '@b[1] = 2; o = @*; dump o' run_mlr --from $indir/xyz2 put -q '@c[1][2] = 3; o = @*; dump o' run_mlr --from $indir/xyz2 put -q 'a = 1; o = a; dump o' run_mlr --from $indir/xyz2 put -q 'b[1] = 2; o = b; dump o' run_mlr --from $indir/xyz2 put -q 'c[1][2] = 3; o = c; dump o' run_mlr --from $indir/xyz2 put -q 'func map_valued_func() { return {"a":1,"b":2}} o = map_valued_func(); dump o' # ---------------------------------------------------------------- announce SPLIT/JOIN run_mlr --from $indir/abixy-het put -q 'o = joink($*, ":"); print o' run_mlr --from $indir/abixy-het put -q 'o = joinv($*, ":"); print o' run_mlr --from $indir/abixy-het put -q 'o = joinkv($*, ":", ";"); print o' run_mlr --from $indir/abixy-het put -q 'o = joink({1:2, "abc":4, 5:"xyz"}, ":"); print o' run_mlr --from $indir/abixy-het put -q 'o = joinv({1:2, "abc":4, 5:"xyz"}, ":"); print o' run_mlr --from $indir/abixy-het put -q 'o = joinkv({1:2, "abc":4, 5:"xyz"}, ":", ";"); print o' run_mlr --from $indir/abixy-het put '$* = splitnv("a,b,c" , ","); for (k,v in $*) { print k.":".typeof(k)." ".v.":".typeof(v)}' run_mlr --from $indir/abixy-het put '$* = splitkv("a=1,b=2,c", "=", ","); for (k, v in $*) {print k.":".typeof(k)." ".v.":".typeof(v)}' run_mlr --from $indir/abixy-het put '$* = splitnv("a,b,c", IFS); print ">>".IRS."<<"; for (k, v in $*) {print k.":".typeof(k)." ".v.":".typeof(v)}' run_mlr --from $indir/abixy-het put '$* = splitkv("a=1,b=2,c", IPS, IFS); print ">>".IRS."<<"; for (k, v in $*) {print k.":".typeof(k)." ".v.":".typeof(v)}' run_mlr --from $indir/abixy-het put '$* = splitnv("a,b,c", OFS); print ">>".ORS."<<"; for (k, v in $*) {print k.":".typeof(k)." ".v.":".typeof(v)}' run_mlr --from $indir/abixy-het put '$* = splitkv("a=1,b=2,c", OPS, OFS); print ">>".ORS."<<"; for (k, v in $*) {print k.":".typeof(k)." ".v.":".typeof(v)}' run_mlr --from $indir/abixy-het put '$* = splitnvx("a,b,c" , ","); for (k, v in $*) {print k.":".typeof(k)." ".v.":".typeof(v)}' run_mlr --from $indir/abixy-het put '$* = splitkvx("a=1,b=2,c", "=", ","); for (k, v in $*) {print k.":".typeof(k)." ".v.":".typeof(v)}' run_mlr --from $indir/abixy-het put '$* = splitnvx("a,b,c", IFS); print ">>".IRS."<<"; for (k, v in $*) {print k.":".typeof(k)." ".v.":".typeof(v)}' run_mlr --from $indir/abixy-het put '$* = splitkvx("a=1,b=2,c", IPS, IFS); print ">>".IRS."<<"; for (k, v in $*) {print k.":".typeof(k)." ".v.":".typeof(v)}' run_mlr --from $indir/abixy-het put '$* = splitnvx("a,b,c", OFS); print ">>".ORS."<<"; for (k, v in $*) {print k.":".typeof(k)." ".v.":".typeof(v)}' run_mlr --from $indir/abixy-het put '$* = splitkvx("a=1,b=2,c", OPS, OFS); print ">>".ORS."<<"; for (k, v in $*) {print k.":".typeof(k)." ".v.":".typeof(v)}' run_mlr --oxtab --from $indir/abixy-het put 's = joink($*, ":"); $* = splitnv(s, ":")' run_mlr --oxtab --from $indir/abixy-het put 's = joinv($*, ":"); $* = splitnv(s, ":")' run_mlr --oxtab --from $indir/abixy-het put 's = joinkv($*, ":", ";"); $* = splitkv(s, ":", ";"); for (k,v in $*) { print k.":".typeof(k)." ".v.":".typeof(v)}' run_mlr --oxtab --from $indir/abixy-het put 's = joinkv($*, ":", ";"); $* = splitkvx(s, ":", ";"); for (k,v in $*) { print k.":".typeof(k)." ".v.":".typeof(v)}' run_mlr --oxtab --from $indir/abixy-het put 's = joink({1:2, "abc":4, 5:"xyz"}, ":"); $* = splitnv(s, ":")' run_mlr --oxtab --from $indir/abixy-het put 's = joinv({1:2, "abc":4, 5:"xyz"}, ":"); $* = splitnv(s, ":")' run_mlr --oxtab --from $indir/abixy-het put 's = joinkv({1:2, "abc":4, 5:"xyz"}, ":", ";"); $* = splitkv(s, ":", ";"); for (k,v in $*) { print k.":".typeof(k)." ".v.":".typeof(v)}' run_mlr --oxtab --from $indir/abixy-het put 's = joinkv({1:2, "abc":4, 5:"xyz"}, ":", ";"); $* = splitkvx(s, ":", ";"); for (k,v in $*) { print k.":".typeof(k)." ".v.":".typeof(v)}' # ---------------------------------------------------------------- announce MAPSUM/MAPDIFF/MAPEXCEPT run_mlr --from $indir/abixy-het put -q 'o = mapsum(); dump o' run_mlr --from $indir/abixy-het put -q 'o = mapdiff(); dump o' mlr_expect_fail --from $indir/abixy-het put -q 'o = mapexcept(); dump o' mlr_expect_fail --from $indir/abixy-het put -q 'o = mapselect(); dump o' run_mlr --from $indir/abixy-het put -q 'o = mapsum($*); dump o' run_mlr --from $indir/abixy-het put -q 'o = mapsum({"a":999}); dump o' run_mlr --from $indir/abixy-het put -q 'o = mapdiff($*); dump o' run_mlr --from $indir/abixy-het put -q 'o = mapdiff({"a":999}); dump o' run_mlr --from $indir/abixy-het put -q 'o = mapexcept($*); dump o' run_mlr --from $indir/abixy-het put -q 'o = mapexcept({"a":999}); dump o' run_mlr --from $indir/abixy-het put -q 'o = mapselect($*); dump o' run_mlr --from $indir/abixy-het put -q 'o = mapselect({"a":999}); dump o' run_mlr --from $indir/abixy-het put -q 'o = mapsum($*, {"a":999}); dump o' run_mlr --from $indir/abixy-het put -q 'o = mapsum({"a":999}, $*); dump o' run_mlr --from $indir/abixy-het put -q 'o = mapdiff($*, {"a":999}); dump o' run_mlr --from $indir/abixy-het put -q 'o = mapdiff({"a":999}, $*); dump o' run_mlr --from $indir/abixy-het put -q 'o = mapexcept($*, "a"); dump o' run_mlr --from $indir/abixy-het put -q 'o = mapexcept({"a":999}, "a"); dump o' run_mlr --from $indir/abixy-het put -q 'o = mapexcept({"a":999}, "nonesuch"); dump o' run_mlr --from $indir/abixy-het put -q 'o = mapselect($*, "a"); dump o' run_mlr --from $indir/abixy-het put -q 'o = mapselect({"a":999}, "a"); dump o' run_mlr --from $indir/abixy-het put -q 'o = mapselect({"a":999}, "nonesuch"); dump o' run_mlr --from $indir/abixy-het put -q 'o = mapsum($*, {"a":999}, {"b": 444}); dump o' run_mlr --from $indir/abixy-het put -q 'o = mapsum({"a":999}, $*, {"b": 444}); dump o' run_mlr --from $indir/abixy-het put -q 'o = mapdiff($*, {"a":999}, {"b": 444}); dump o' run_mlr --from $indir/abixy-het put -q 'o = mapdiff({"a":999}, $*, {"b": 444}); dump o' run_mlr --from $indir/abixy-het put -q 'o = mapexcept($*, "a", "b"); dump o' run_mlr --from $indir/abixy-het put -q 'o = mapselect({"a":999}, "b", "nonesuch"); dump o' run_mlr --from $indir/abixy-het put -q 'o = mapselect($*, "a", "b"); dump o' run_mlr --from $indir/abixy-het put -q 'o = mapselect({"a":999}, "b", "nonesuch"); dump o' # ---------------------------------------------------------------- announce EXTENDED TYPEOF run_mlr --from $indir/xyz2 --oxtab put ' a = {1:2, 3:4}; b = {1: {2:3, 4:5}}; @c = {1:2, 3:4}; @d = {1: {2:3, 4:5}}; $ta = typeof(a); $ta1 = typeof(a[1]); $ta7 = typeof(a[7]); $tb = typeof(b); $tb1 = typeof(b[1]); $tb7 = typeof(b[7]); $tc = typeof(@c); $tc1 = typeof(@c[1]); $tc7 = typeof(@c[7]); $td = typeof(@d); $td1 = typeof(@d[1]); $td7 = typeof(@d[7]); $te1 = typeof(6); $te2 = typeof({6:4}); $tsa = typeof($a); $tsx = typeof($x); $ts = typeof($*); ' # ---------------------------------------------------------------- announce HASKEY run_mlr --from $indir/abixy-het put '$haskeya = haskey($*, "a")' run_mlr --from $indir/abixy-het put '$haskey3 = haskey($*, 3)' run_mlr --from $indir/xyz2 put '$haskeya = haskey({3:4}, "a")' run_mlr --from $indir/xyz2 put '$haskey3 = haskey({3:4}, 3)' run_mlr --from $indir/xyz2 put '$haskey3 = haskey({3:4}, 4)' run_mlr --from $indir/xyz2 put 'o = {3:4}; $haskeya = haskey(o, "a")' run_mlr --from $indir/xyz2 put 'o = {3:4}; $haskey3 = haskey(o, 3)' run_mlr --from $indir/xyz2 put 'o = {3:4}; $haskey3 = haskey(o, 4)' run_mlr --from $indir/xyz2 put '@o = {3:4}; $haskeya = haskey(@o, "a")' run_mlr --from $indir/xyz2 put '@o = {3:4}; $haskey3 = haskey(@o, 3)' run_mlr --from $indir/xyz2 put '@o = {3:4}; $haskey3 = haskey(@o, 4)' run_mlr --from $indir/xyz2 put 'o = "3:4"; $haskeya = haskey(@o, "a")' run_mlr --from $indir/xyz2 put 'o = "3:4"; $haskey3 = haskey(@o, 3)' run_mlr --from $indir/xyz2 put 'o = "3:4"; $haskey3 = haskey(@o, 4)' # ---------------------------------------------------------------- announce LENGTH/DEPTH/LEAFCOUNT run_mlr --from $indir/abixy-het put '$length = length($a)' run_mlr --from $indir/abixy-het put '$length = length($*)' run_mlr --from $indir/xyz2 put '$length= length({3:4, 5:{6:7}, 8:{9:{10:11}}})' run_mlr --from $indir/xyz2 put 'o = {3:4, 5:{6:7}, 8:{9:{10:11}}}; $length = length(o)' run_mlr --from $indir/xyz2 put '@o = {3:4, 5:{6:7}, 8:{9:{10:11}}}; $length = length(@o)' run_mlr --from $indir/abixy-het put '$depth = depth($a)' run_mlr --from $indir/abixy-het put '$depth = depth($*)' run_mlr --from $indir/xyz2 put '$depth= depth({3:4, 5:{6:7}, 8:{9:{10:11}}})' run_mlr --from $indir/xyz2 put 'o = {3:4, 5:{6:7}, 8:{9:{10:11}}}; $depth = depth(o)' run_mlr --from $indir/xyz2 put '@o = {3:4, 5:{6:7}, 8:{9:{10:11}}}; $depth = depth(@o)' run_mlr --from $indir/abixy-het put '$leafcount = leafcount($a)' run_mlr --from $indir/abixy-het put '$leafcount = leafcount($*)' run_mlr --from $indir/xyz2 put '$leafcount= leafcount({3:4, 5:{6:7}, 8:{9:{10:11}}})' run_mlr --from $indir/xyz2 put 'o = {3:4, 5:{6:7}, 8:{9:{10:11}}}; $leafcount = leafcount(o)' run_mlr --from $indir/xyz2 put '@o = {3:4, 5:{6:7}, 8:{9:{10:11}}}; $leafcount = leafcount(@o)' # xxx ternary operator (and most RHS expressions in the grammar) doesn't handle maps. # run_mlr --from $indir/abixy-het put -q 'o = haskey(NR==4 ? {"a": NF} : {"b": NF}, "a"); print "NR=".NR.",haskeya=".o' # ---------------------------------------------------------------- announce MAPVAR EMIT run_mlr -n put 'end { @a[2][3] = 4; b[2][3] = 8; emit (@a, b, {2:{3:12}}); emitp (@a, b, {2:{3:12}}); emit {}; emit (@a, b, {2:{3:12}}), "t"; emitp (@a, b, {2:{3:12}}), "t"; emit {}; emit (@a, b, {2:{3:12}}), "t", "u"; emitp (@a, b, {2:{3:12}}), "t", "u"; }' run_mlr -n put 'end { @a[2][3] = 4; b[2][3] = 8; emitp (@a, b, {2:{3:12}}); emit (@a, b, {2:{3:12}}); emit {}; emitp (@a, b, {2:{3:12}}), "t"; emit (@a, b, {2:{3:12}}), "t"; emit {}; emitp (@a, b, {2:{3:12}}), "t", "u"; emit (@a, b, {2:{3:12}}), "t", "u"; }' # ---------------------------------------------------------------- announce MAPVAR FOR-LOOPS run_mlr --from $indir/abixy put -q ' func f() { return { "a:".$a: $i, "b:".$b: $y, NR: NF, } } for (k,v in f()) { print "k=".k; print "v=".v; } print ' # ---------------------------------------------------------------- announce TRAILING COMMAS run_mlr --from $indir/abixy put ' $* = { "a": $a, "x": $x, } ' run_mlr --from $indir/xyz345 put 'func f(): int { return 999 } $y=f()' mlr_expect_fail --from $indir/xyz345 put 'func f(): int { return 999 } $y=f(,)' run_mlr --from $indir/xyz345 put 'func f(a,): int { return a*2 } $y=f(NR)' mlr_expect_fail --from $indir/xyz345 put 'func f(a,,): int { return a*2 } $y=f(NR)' run_mlr --from $indir/xyz345 put 'func f(int a,): int { return a*2 } $y=f(NR)' mlr_expect_fail --from $indir/xyz345 put 'func f(int a,,): int { return a*2 } $y=f(NR)' run_mlr --from $indir/xyz345 put 'subr s() { print 999 } call s()' mlr_expect_fail --from $indir/xyz345 put 'subr s() { print 999 } call s(,)' run_mlr --from $indir/xyz345 put 'subr s(a,) { print a*2 } call s(NR)' mlr_expect_fail --from $indir/xyz345 put 'subr s(a,,) { print a*2 } call s(NR)' run_mlr --from $indir/xyz345 put 'subr s(int a,) { print a*2 } call s(NR)' mlr_expect_fail --from $indir/xyz345 put 'subr s(int a,,) { print a*2 } call s(NR)' run_mlr --from $indir/xyz345 put '$y=log10($x)' run_mlr --from $indir/xyz345 put '$y=log10($x,)' mlr_expect_fail --from $indir/xyz345 put '$y=log10($x,,)' mlr_expect_fail --from $indir/xyz345 put '$y=log10(,$x)' run_mlr --from $indir/xyz345 put '$y=pow($x,2)' run_mlr --from $indir/xyz345 put '$y=pow($x,2,)' # ---------------------------------------------------------------- announce MAPVARS/UDFs/SUBROUTINES run_mlr --from $indir/abixy put ' func f(m) { dump m; sum = 0; for (k, v in m) { sum += k } return sum } @v[$i] = $a; $y = f(@v) ' run_mlr --from $indir/abixy put ' subr s(m) { dump m; sum = 0; for (k, v in m) { sum += k } @sum = sum; } @v[$i] = $a; call s(@v); $y = @sum; ' run_mlr --from $indir/abixy-het put 'func f(x) {return {"a":x,"b":x**2}}; map o = f($x); $* = o' run_mlr --from $indir/abixy-het put -q 'func f(x) {return x**2}; var z = f($x); dump z' run_mlr --from $indir/abixy-het put -q 'func f(x) {map m = {NR:x};return m}; z = f($y); dump z' mlr_expect_fail --from $indir/abixy put ' func f(int x): map { if (NR==2) { return 2 } else { return {} } } $y=f($x) ' run_mlr --from $indir/abixy put ' func f(int x): map { if (NR==200) { return 2 } else { return {} } } $y=f($i) ' mlr_expect_fail --from $indir/abixy put ' func f(int x): map { if (NR==200) { return 2 } else { return {} } } $y=f($x) ' run_mlr --from $indir/abixy put ' func f(int x): var { if (NR==2) { return 2 } else { return {} } } $y=f($i) ' mlr_expect_fail --from $indir/abixy put ' func f(int x): var { if (NR==2) { return 2 } else { return {} } } $y=f($x) ' mlr_expect_fail --from $indir/abixy put ' func f(x): int { # fall-through return value is absent-null } $y=f($x) ' mlr_expect_fail --from $indir/abixy put ' int a = 1; var b = a[2]; # cannot index localvar declared non-map ' # This one is intended to particularly look at freeing, e.g. with './reg_test/run --valgrind'. run_mlr --oxtab --from $indir/abixy-het put ' $* = mapdiff( mapsum($*, {"a": "newval"}), {"b": "nonesuch"}, ) ' # ---------------------------------------------------------------- announce NUMBER FORMATTING run_mlr --opprint stats1 -a sum -f x $indir/ofmt.dat run_mlr --ofmt '%.3lf' --opprint stats1 -a sum -f x $indir/ofmt.dat run_mlr --opprint --ofmt '%.3lf' stats1 -a sum -f x $indir/ofmt.dat # ---------------------------------------------------------------- announce IMPLICIT-HEADER-CSV INPUT run_mlr --irs crlf --icsvlite --ifs , --opprint cut -x -f b/ $indir/multi-sep.csv-crlf run_mlr --irs crlf --implicit-csv-header --icsvlite --ifs , --opprint cut -x -f 2 $indir/multi-sep.csv-crlf run_mlr --irs crlf --icsvlite --ifs /, --opprint cut -x -f b $indir/multi-sep.csv-crlf run_mlr --irs crlf --implicit-csv-header --icsvlite --ifs /, --opprint cut -x -f 2 $indir/multi-sep.csv-crlf run_mlr --icsv --ifs , --opprint cut -x -f b/ $indir/multi-sep.csv-crlf run_mlr --implicit-csv-header --icsv --ifs , --opprint cut -x -f 2 $indir/multi-sep.csv-crlf run_mlr --icsv --ifs /, --opprint cut -x -f b $indir/multi-sep.csv-crlf run_mlr --implicit-csv-header --icsv --ifs /, --opprint cut -x -f 2 $indir/multi-sep.csv-crlf run_mlr --csv -N reorder -f 1,3,2,5,4 $indir/multi-sep.csv-crlf run_mlr --csv -N reorder -f 5,4,3,2,1 $indir/multi-sep.csv-crlf run_mlr --icsv --otsv -N cat < $outdir/comments1-crlf.dkvp mention input comments1-crlf.dkvp run_cat $outdir/comments1-crlf.dkvp mention skip comments1-crlf.dkvp run_mlr --skip-comments --idkvp --oxtab cat < $outdir/comments1-crlf.dkvp run_mlr --skip-comments --idkvp --oxtab cat $outdir/comments1-crlf.dkvp mention pass comments1-crlf.dkvp run_mlr --pass-comments --idkvp --oxtab cat < $outdir/comments1-crlf.dkvp run_mlr --pass-comments --idkvp --oxtab cat $outdir/comments1-crlf.dkvp # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - announce SKIP/PASS COMMENTS DKVP WITH ALTERNATE PREFIX mention input comments1-atat.dkvp run_cat $indir/comments/comments1-atat.dkvp mention skip comments1-atat.dkvp run_mlr --skip-comments-with @@ --idkvp --oxtab cat < $indir/comments/comments1-atat.dkvp run_mlr --skip-comments-with @@ --idkvp --oxtab cat $indir/comments/comments1-atat.dkvp mention pass comments1-atat.dkvp run_mlr --pass-comments-with @@ --idkvp --oxtab cat < $indir/comments/comments1-atat.dkvp run_mlr --pass-comments-with @@ --idkvp --oxtab cat $indir/comments/comments1-atat.dkvp mention input comments2-atat.dkvp run_cat $indir/comments/comments2-atat.dkvp mention skip comments2-atat.dkvp run_mlr --skip-comments-with @@ --idkvp --oxtab cat < $indir/comments/comments2-atat.dkvp run_mlr --skip-comments-with @@ --idkvp --oxtab cat $indir/comments/comments2-atat.dkvp mention pass comments2-atat.dkvp run_mlr --pass-comments-with @@ --idkvp --oxtab cat < $indir/comments/comments2-atat.dkvp run_mlr --pass-comments-with @@ --idkvp --oxtab cat $indir/comments/comments2-atat.dkvp mention input comments3-atat.dkvp run_cat $indir/comments/comments3-atat.dkvp mention skip comments3-atat.dkvp run_mlr --skip-comments-with @@ --idkvp --oxtab cat < $indir/comments/comments3-atat.dkvp run_mlr --skip-comments-with @@ --idkvp --oxtab cat $indir/comments/comments3-atat.dkvp mention pass comments3-atat.dkvp run_mlr --pass-comments-with @@ --idkvp --oxtab cat < $indir/comments/comments3-atat.dkvp run_mlr --pass-comments-with @@ --idkvp --oxtab cat $indir/comments/comments3-atat.dkvp # ---------------------------------------------------------------- announce SKIP/PASS COMMENTS NIDX mention input comments1.nidx run_cat $indir/comments/comments1.nidx mention skip comments1.nidx run_mlr --skip-comments --inidx --oxtab cat < $indir/comments/comments1.nidx run_mlr --skip-comments --inidx --oxtab cat $indir/comments/comments1.nidx mention pass comments1.nidx run_mlr --pass-comments --inidx --oxtab cat < $indir/comments/comments1.nidx run_mlr --pass-comments --inidx --oxtab cat $indir/comments/comments1.nidx mention input comments2.nidx run_cat $indir/comments/comments2.nidx mention skip comments2.nidx run_mlr --skip-comments --inidx --oxtab cat < $indir/comments/comments2.nidx run_mlr --skip-comments --inidx --oxtab cat $indir/comments/comments2.nidx mention pass comments2.nidx run_mlr --pass-comments --inidx --oxtab cat < $indir/comments/comments2.nidx run_mlr --pass-comments --inidx --oxtab cat $indir/comments/comments2.nidx mention input comments3.nidx run_cat $indir/comments/comments3.nidx mention skip comments3.nidx run_mlr --skip-comments --inidx --oxtab cat < $indir/comments/comments3.nidx run_mlr --skip-comments --inidx --oxtab cat $indir/comments/comments3.nidx mention pass comments3.nidx run_mlr --pass-comments --inidx --oxtab cat < $indir/comments/comments3.nidx run_mlr --pass-comments --inidx --oxtab cat $indir/comments/comments3.nidx # It's annoying trying to check in text files (especially CSV) with CRLF # to Git, given that it likes to 'fix' line endings for multi-platform use. # It's easy to simply create CRLF on the fly. run_mlr_for_auxents_no_output termcvt --lf2crlf < $indir/comments/comments1.nidx > $outdir/comments1-crlf.nidx mention input comments1-crlf.nidx run_cat $outdir/comments1-crlf.nidx mention skip comments1-crlf.nidx run_mlr --skip-comments --inidx --oxtab cat < $outdir/comments1-crlf.nidx run_mlr --skip-comments --inidx --oxtab cat $outdir/comments1-crlf.nidx mention pass comments1-crlf.nidx run_mlr --pass-comments --inidx --oxtab cat < $outdir/comments1-crlf.nidx run_mlr --pass-comments --inidx --oxtab cat $outdir/comments1-crlf.nidx # ---------------------------------------------------------------- announce SKIP/PASS COMMENTS JSON mention input comments1.json run_cat $indir/comments/comments1.json mention skip comments1.json run_mlr --skip-comments --ijson --odkvp cat < $indir/comments/comments1.json run_mlr --skip-comments --ijson --odkvp cat $indir/comments/comments1.json mention pass comments1.json run_mlr --pass-comments --ijson --odkvp cat < $indir/comments/comments1.json run_mlr --pass-comments --ijson --odkvp cat $indir/comments/comments1.json mention input comments2.json run_cat $indir/comments/comments2.json mention skip comments2.json run_mlr --skip-comments --ijson --odkvp cat < $indir/comments/comments2.json run_mlr --skip-comments --ijson --odkvp cat $indir/comments/comments2.json mention pass comments2.json run_mlr --pass-comments --ijson --odkvp cat < $indir/comments/comments2.json run_mlr --pass-comments --ijson --odkvp cat $indir/comments/comments2.json mention input comments3.json run_cat $indir/comments/comments3.json mention skip comments3.json run_mlr --skip-comments --ijson --odkvp cat < $indir/comments/comments3.json run_mlr --skip-comments --ijson --odkvp cat $indir/comments/comments3.json mention pass comments3.json run_mlr --pass-comments --ijson --odkvp cat < $indir/comments/comments3.json run_mlr --pass-comments --ijson --odkvp cat $indir/comments/comments3.json # It's annoying trying to check in text files (especially CSV) with CRLF # to Git, given that it likes to 'fix' line endings for multi-platform use. # It's easy to simply create CRLF on the fly. run_mlr_for_auxents_no_output termcvt --lf2crlf < $indir/comments/comments1.json > $outdir/comments1-crlf.json mention input comments1-crlf.json run_cat $outdir/comments1-crlf.json mention skip comments1-crlf.json run_mlr --skip-comments --ijson --odkvp cat < $outdir/comments1-crlf.json run_mlr --skip-comments --ijson --odkvp cat $outdir/comments1-crlf.json mention pass comments1-crlf.json run_mlr --pass-comments --ijson --odkvp cat < $outdir/comments1-crlf.json run_mlr --pass-comments --ijson --odkvp cat $outdir/comments1-crlf.json # ---------------------------------------------------------------- announce SKIP/PASS COMMENTS XTAB mention input comments1.xtab run_cat $indir/comments/comments1.xtab mention skip comments1.xtab run_mlr --skip-comments --ixtab --odkvp cat < $indir/comments/comments1.xtab run_mlr --skip-comments --ixtab --odkvp cat $indir/comments/comments1.xtab mention pass comments1.xtab run_mlr --pass-comments --ixtab --odkvp cat < $indir/comments/comments1.xtab run_mlr --pass-comments --ixtab --odkvp cat $indir/comments/comments1.xtab mention input comments2.xtab run_cat $indir/comments/comments2.xtab mention skip comments2.xtab run_mlr --skip-comments --ixtab --odkvp cat < $indir/comments/comments2.xtab run_mlr --skip-comments --ixtab --odkvp cat $indir/comments/comments2.xtab mention pass comments2.xtab run_mlr --pass-comments --ixtab --odkvp cat < $indir/comments/comments2.xtab run_mlr --pass-comments --ixtab --odkvp cat $indir/comments/comments2.xtab # It's annoying trying to check in text files (especially CSV) with CRLF # to Git, given that it likes to 'fix' line endings for multi-platform use. # It's easy to simply create CRLF on the fly. run_mlr_for_auxents_no_output termcvt --lf2crlf < $indir/comments/comments1.xtab > $outdir/comments1-crlf.xtab mention input comments1-crlf.xtab run_cat $outdir/comments1-crlf.xtab mention skip comments1-crlf.xtab run_mlr --skip-comments --ixtab --odkvp cat < $outdir/comments1-crlf.xtab run_mlr --skip-comments --ixtab --odkvp cat $outdir/comments1-crlf.xtab mention pass comments1-crlf.xtab run_mlr --pass-comments --ixtab --odkvp cat < $outdir/comments1-crlf.xtab run_mlr --pass-comments --ixtab --odkvp cat $outdir/comments1-crlf.xtab # ---------------------------------------------------------------- announce SKIP/PASS COMMENTS CSVLITE mention input comments1.csv run_cat $indir/comments/comments1.csv mention skip comments1.csv run_mlr --skip-comments --icsvlite --odkvp cat < $indir/comments/comments1.csv run_mlr --skip-comments --icsvlite --odkvp cat $indir/comments/comments1.csv mention pass comments1.csv run_mlr --pass-comments --icsvlite --odkvp cat < $indir/comments/comments1.csv run_mlr --pass-comments --icsvlite --odkvp cat $indir/comments/comments1.csv mention input comments2.csv run_cat $indir/comments/comments2.csv mention skip comments2.csv run_mlr --skip-comments --icsvlite --odkvp cat < $indir/comments/comments2.csv run_mlr --skip-comments --icsvlite --odkvp cat $indir/comments/comments2.csv mention pass comments2.csv run_mlr --pass-comments --icsvlite --odkvp cat < $indir/comments/comments2.csv run_mlr --pass-comments --icsvlite --odkvp cat $indir/comments/comments2.csv # It's annoying trying to check in text files (especially CSV) with CRLF # to Git, given that it likes to 'fix' line endings for multi-platform use. # It's easy to simply create CRLF on the fly. run_mlr_for_auxents_no_output termcvt --lf2crlf < $indir/comments/comments1.csv > $outdir/comments1-crlf.csv mention input comments1-crlf.csv run_cat $outdir/comments1-crlf.csv mention skip comments1-crlf.csv run_mlr --skip-comments --icsvlite --odkvp cat < $outdir/comments1-crlf.csv run_mlr --skip-comments --icsvlite --odkvp cat $outdir/comments1-crlf.csv mention pass comments1-crlf.csv run_mlr --pass-comments --icsvlite --odkvp cat < $outdir/comments1-crlf.csv run_mlr --pass-comments --icsvlite --odkvp cat $outdir/comments1-crlf.csv # ---------------------------------------------------------------- announce SKIP/PASS COMMENTS CSV mention input comments1.csv run_cat $indir/comments/comments1.csv mention skip comments1.csv run_mlr --skip-comments --icsv --odkvp cat < $indir/comments/comments1.csv run_mlr --skip-comments --icsv --odkvp cat $indir/comments/comments1.csv mention pass comments1.csv run_mlr --pass-comments --icsv --odkvp cat < $indir/comments/comments1.csv run_mlr --pass-comments --icsv --odkvp cat $indir/comments/comments1.csv mention input comments2.csv run_cat $indir/comments/comments2.csv mention skip comments2.csv run_mlr --skip-comments --icsv --odkvp cat < $indir/comments/comments2.csv run_mlr --skip-comments --icsv --odkvp cat $indir/comments/comments2.csv mention pass comments2.csv run_mlr --pass-comments --icsv --odkvp cat < $indir/comments/comments2.csv run_mlr --pass-comments --icsv --odkvp cat $indir/comments/comments2.csv # It's annoying trying to check in text files (especially CSV) with CRLF # to Git, given that it likes to 'fix' line endings for multi-platform use. # It's easy to simply create CRLF on the fly. run_mlr_for_auxents_no_output termcvt --lf2crlf < $indir/comments/comments1.csv > $outdir/comments1-crlf.csv mention input comments1-crlf.csv run_cat $outdir/comments1-crlf.csv mention skip comments1-crlf.csv run_mlr --skip-comments --icsv --odkvp cat < $outdir/comments1-crlf.csv run_mlr --skip-comments --icsv --odkvp cat $outdir/comments1-crlf.csv mention pass comments1-crlf.csv run_mlr --pass-comments --icsv --odkvp cat < $outdir/comments1-crlf.csv run_mlr --pass-comments --icsv --odkvp cat $outdir/comments1-crlf.csv # ---------------------------------------------------------------- announce INT64 I/O run_mlr --oxtab put '$c=$a;$d=$b;$e=hexfmt($a);$f=hexfmt($b)' $indir/int64io.dkvp # There is different rounding on i386 vs. x86_64 but the essential check is # that overflow has been avoided. Hence the %g output format here. run_mlr --oxtab --ofmt '%.8g' put '$p0=$p+0;$p1=$p+1;$p2=$p+2;$p3=$p+3' $indir/int64arith.dkvp run_mlr --oxtab --ofmt '%.8g' put '$p0=$p-0;$p1=$p-1;$p2=$p-2;$p3=$p-3' $indir/int64arith.dkvp run_mlr --oxtab --ofmt '%.8g' put '$p0=$p*0;$p1=$p*1;$p2=$p*2;$p3=$p*3' $indir/int64arith.dkvp run_mlr --oxtab --ofmt '%.8g' put '$n0=$n+0;$n1=$n+1;$n2=$n+2;$n3=$n+3' $indir/int64arith.dkvp run_mlr --oxtab --ofmt '%.8g' put '$n0=$n-0;$n1=$n-1;$n2=$n-2;$n3=$n-3' $indir/int64arith.dkvp run_mlr --oxtab --ofmt '%.8g' put '$n0=$n*0;$n1=$n*1;$n2=$n*2;$n3=$n*3' $indir/int64arith.dkvp # ---------------------------------------------------------------- announce COMPRESSED INPUT run_mlr --csv --prepipe 'cat' cat $indir/rfc-csv/simple.csv-crlf run_mlr --dkvp --prepipe 'cat' cat $indir/abixy run_mlr --csv --prepipe 'cat' cat < $indir/rfc-csv/simple.csv-crlf run_mlr --dkvp --prepipe 'cat' cat < $indir/abixy # ---------------------------------------------------------------- announce STDIN run_mlr --csv cat < $indir/rfc-csv/simple.csv-crlf # ---------------------------------------------------------------- announce RFC-CSV run_mlr --csv cat $indir/rfc-csv/simple.csv-crlf run_mlr --csv cat $indir/rfc-csv/simple-truncated.csv run_mlr --csv cat $indir/rfc-csv/narrow.csv run_mlr --csv cat $indir/rfc-csv/narrow-truncated.csv run_mlr --csv cat $indir/rfc-csv/quoted-comma.csv run_mlr --csv cat $indir/rfc-csv/quoted-comma-truncated.csv run_mlr --csv cat $indir/rfc-csv/quoted-crlf.csv run_mlr --csv cat $indir/rfc-csv/quoted-crlf-truncated.csv run_mlr --csv cat $indir/rfc-csv/simple-truncated.csv $indir/rfc-csv/simple.csv-crlf run_mlr --csv --ifs semicolon --ofs pipe --irs lf --ors lflf cut -x -f b $indir/rfc-csv/modify-defaults.csv run_mlr --csv --rs lf --quote-original cut -o -f c,b,a $indir/quote-original.csv run_mlr --icsv --oxtab cat $indir/comma-at-eof.csv run_mlr --csv --quote-all cat $indir/rfc-csv/simple.csv-crlf run_mlr --csv --quote-original cat $indir/rfc-csv/simple.csv-crlf run_mlr --itsv --rs lf --oxtab cat $indir/simple.tsv run_mlr --iusv --oxtab cat $indir/example.usv # ---------------------------------------------------------------- announce RAGGED NON-RFC CSV run_mlr --icsv --oxtab --ragged cat $indir/ragged.csv run_mlr --icsvlite --oxtab --ragged cat $indir/ragged.csv # ---------------------------------------------------------------- announce MARKDOWN OUTPUT run_mlr --itsv --rs lf --omd cat $indir/simple.tsv # ---------------------------------------------------------------- announce CSV/RS ENVIRONMENT DEFAULTS run_mlr --csv cut -f a $indir/rfc-csv/simple.csv-crlf run_mlr --csv --rs crlf cut -f a $indir/rfc-csv/simple.csv-crlf mlr_expect_fail --csv --rs lf cut -f a $indir/rfc-csv/simple.csv-crlf # ---------------------------------------------------------------- announce MULTI-CHARACTER IRS/IFS/IPS FOR DKVP run_mlr --oxtab --idkvp --irs lf --ifs , --ips = cut -o -f x,a,i $indir/multi-sep.dkvp-crlf run_mlr --oxtab --idkvp --irs lf --ifs /, --ips =: cut -o -f x,a,i $indir/multi-sep.dkvp-crlf run_mlr --oxtab --idkvp --irs crlf --ifs , --ips = cut -o -f x,a,i $indir/multi-sep.dkvp-crlf run_mlr --oxtab --idkvp --irs crlf --ifs /, --ips =: cut -o -f x,a,i $indir/multi-sep.dkvp-crlf # ---------------------------------------------------------------- announce MULTI-CHARACTER IRS/IFS FOR NIDX run_mlr --oxtab --inidx --irs lf --ifs , cut -o -f 4,1,3 $indir/multi-sep.dkvp-crlf run_mlr --oxtab --inidx --irs lf --ifs /, cut -o -f 4,1,3 $indir/multi-sep.dkvp-crlf run_mlr --oxtab --inidx --irs crlf --ifs , cut -o -f 4,1,3 $indir/multi-sep.dkvp-crlf run_mlr --oxtab --inidx --irs crlf --ifs /, cut -o -f 4,1,3 $indir/multi-sep.dkvp-crlf # ---------------------------------------------------------------- announce MULTI-CHARACTER IRS/IFS FOR CSVLITE run_mlr --oxtab --icsvlite --irs lf --ifs , cut -o -f x/,a/,i/ $indir/multi-sep.csv-crlf run_mlr --oxtab --icsvlite --irs lf --ifs /, cut -o -f x,a,i $indir/multi-sep.csv-crlf run_mlr --oxtab --icsvlite --irs crlf --ifs , cut -o -f x/,a/,i/ $indir/multi-sep.csv-crlf run_mlr --oxtab --icsvlite --irs crlf --ifs /, cut -o -f x,a,i $indir/multi-sep.csv-crlf # ---------------------------------------------------------------- announce MULTI-CHARACTER SEPARATORS FOR XTAB run_mlr --xtab --ifs crlf --ofs Z cut -x -f b $indir/truncated.xtab-crlf run_mlr --xtab --ips . --ops @ cut -x -f b $indir/dots.xtab run_mlr --xtab --ips ": " --ops '@@@@' put '$sum=int($a+$b)' $indir/multi-ips.dkvp # ---------------------------------------------------------------- announce EMBEDDED IPS FOR XTAB run_mlr --xtab cat $indir/embedded-ips.xtab # ---------------------------------------------------------------- announce MULTI-CHARACTER IRS FOR PPRINT run_mlr --pprint --irs crlf --ifs / --ofs @ cut -x -f b $indir/dots.pprint-crlf # ---------------------------------------------------------------- announce BARRED PPRINT run_mlr --opprint --barred cat $indir/abixy run_mlr --opprint --barred --right cat $indir/abixy run_mlr --opprint --barred cat $indir/abixy-het run_mlr --opprint --barred --right cat $indir/abixy-het # ---------------------------------------------------------------- announce MULTI-CHARACTER IXS SPECIFIERS run_mlr --oxtab --idkvp --irs lf --ifs '\x2c' --ips '\075' cut -o -f x,a,i $indir/multi-sep.dkvp-crlf run_mlr --oxtab --idkvp --irs lf --ifs /, --ips '\x3d\x3a' cut -o -f x,a,i $indir/multi-sep.dkvp-crlf # ---------------------------------------------------------------- announce JSON I/O run_mlr --ijson --opprint cat $indir/small-non-nested.json run_mlr --ijson --opprint cat $indir/small-non-nested-wrapped.json run_mlr --ijson --oxtab cat $indir/small-nested.json run_mlr --ojson cat $indir/json-output-options.dkvp run_mlr --ojson --jvstack cat $indir/json-output-options.dkvp run_mlr --ojson --jlistwrap cat $indir/json-output-options.dkvp run_mlr --ojson --jvstack --jlistwrap cat $indir/json-output-options.dkvp run_mlr --ojson --jquoteall cat $indir/json-output-options.dkvp run_mlr --ojson --jvstack --jquoteall cat $indir/json-output-options.dkvp run_mlr --ojson --jlistwrap --jquoteall cat $indir/json-output-options.dkvp run_mlr --ojson --jvstack --jlistwrap --jquoteall cat $indir/json-output-options.dkvp run_mlr --ojson --jvquoteall cat $indir/json-output-options.dkvp run_mlr --ojson --jvstack --jvquoteall cat $indir/json-output-options.dkvp run_mlr --ojson --jlistwrap --jvquoteall cat $indir/json-output-options.dkvp run_mlr --ojson --jvstack --jlistwrap --jvquoteall cat $indir/json-output-options.dkvp run_mlr --ojson --jknquoteint cat $indir/json-output-options.dkvp run_mlr --ojson --jvstack --jknquoteint cat $indir/json-output-options.dkvp run_mlr --ojson --jlistwrap --jknquoteint cat $indir/json-output-options.dkvp run_mlr --ojson --jvstack --jlistwrap --jknquoteint cat $indir/json-output-options.dkvp run_mlr put -q --jvquoteall 'dump $*' $indir/json-output-options.dkvp run_mlr put -q --jvquoteall 'o = $*; o[7] = 8; dump o' $indir/json-output-options.dkvp run_mlr put -q --jknquoteint 'dump $*' $indir/json-output-options.dkvp run_mlr put -q --jknquoteint 'o = $*; o[7] = 8; dump o' $indir/json-output-options.dkvp run_mlr --ijson --opprint cat $indir/small-non-nested-wrapped.json $indir/small-non-nested-wrapped.json run_mlr --icsv --ojson --rs lf cat < $outdir/line-ending-temp-1.bin run_mlr_for_auxents_no_output termcvt --cr2crlf < $indir/line-ending-cr.bin > $outdir/line-ending-temp-2.bin run_mlr_for_auxents_no_output termcvt --lf2cr < $indir/line-ending-lf.bin > $outdir/line-ending-temp-3.bin run_mlr_for_auxents_no_output termcvt --lf2crlf < $indir/line-ending-lf.bin > $outdir/line-ending-temp-4.bin run_mlr_for_auxents_no_output termcvt --crlf2cr < $indir/line-ending-crlf.bin > $outdir/line-ending-temp-5.bin run_mlr_for_auxents_no_output termcvt --crlf2lf < $indir/line-ending-crlf.bin > $outdir/line-ending-temp-6.bin run_mlr_for_auxents hex < $outdir/line-ending-temp-1.bin run_mlr_for_auxents hex < $outdir/line-ending-temp-2.bin run_mlr_for_auxents hex < $outdir/line-ending-temp-3.bin run_mlr_for_auxents hex < $outdir/line-ending-temp-4.bin run_mlr_for_auxents hex < $outdir/line-ending-temp-5.bin run_mlr_for_auxents hex < $outdir/line-ending-temp-6.bin # ================================================================ # A key feature of this regression script is that it can be invoked from any # directory. Depending on the directory it's invoked from, the path to $outdir # may vary. Nonetheless for debugging it's crucial that we echo out each # command being executed -- here we use diff -I to skip the info lines and # focus the test on program output per se. echo echo ================================================================ echo "Differences between $expfile and $outfile:" # We run with 'set -e' all the way through this script, to die on error -- but # for the diff command we want to trap the error and die with a message, especially # when the diff is long. set +e diff -a -I '^mlr' -I '^cat' -C5 $expfile $outfile status=$? if [ $status -eq 0 ]; then echo "No differences were found between $expfile and $outfile" echo ================================================================ echo echo ALL REGRESSION TESTS PASSED echo Tests completed: $num_completed exit 0 else echo echo "Differences were found between $expfile and $outfile !" echo echo Tests completed: $num_completed exit 1 fi