accept-case case-c-dsl-context-specific-validation.sh (subr ported)

This commit is contained in:
John Kerl 2020-11-24 13:46:06 -05:00
parent aa58b634a4
commit ec7093c92f
2 changed files with 27 additions and 594 deletions

View file

@ -82,18 +82,6 @@ rrv ./reg-test/cases/case-c-dsl-is-predicates.sh
this.mapval.PutCopy(&key.printrep, value)
}
================================================================
SUBR
rrv -C1 ./reg-test/cases/case-c-dsl-context-specific-validation.sh
* subr and more ... also needs check for filter statement within filter commands
rrv ./reg-test/cases/case-c-dsl-user-defined-functions-and-subroutines.sh
rrv ./reg-test/cases/case-c-dsl-user-defined-subroutines.sh
rrv ./reg-test/cases/case-c-dsl-trailing-commas.sh
rrv ./reg-test/cases/case-c-dsl-argpass-typedecl.sh
rrv ./reg-test/cases/case-c-dsl-multipart-scripts.sh
================================================================
PARTIALLY IMPLEMENTED:
@ -210,587 +198,23 @@ rrv ./reg-test/cases/case-c-uniq.sh
rrv ./reg-test/cases/case-c-utf8-bom.sh
================================================================
Using mlr executable ./reg-test/../../go/mlr
GATING
----------------------------------------------------------------
BEGIN ./reg-test/cases/case-c-dsl-context-specific-validation.sh
mlr put -v begin{begin{@x=1}}
mlr put -v true{begin{@x=1}}
mlr put -v end{end{@x=1}}
mlr put -v true{end{@x=1}}
mlr put -v begin{$x=1}
mlr put -v begin{@x=$y}
mlr put -v end{$x=1}
mlr put -v end{@x=$y}
mlr put -v begin{@v=$*}
mlr put -v end{$*=@v}
mlr put -v begin{unset $x}
mlr put -v end{unset $x}
mlr put -v begin{unset $*}
mlr put -v end{unset $*}
mlr put -v break
mlr put -v continue
mlr filter -v break
mlr filter -v continue
mlr --from ./reg-test/input/abixy filter
begin {
@avoid = 3
}
NR != @avoid
mlr --from ./reg-test/input/abixy filter -x
begin {
@avoid = 3
}
NR != @avoid
mlr --from ./reg-test/input/abixy filter
func f(n) {
return n - 1
}
f(NR) == 5
mlr --from ./reg-test/input/abixy filter
subr s(n) {
print "NR is ".n
}
call s(NR);
false
Exit status was 1; expected 0.
mlr --from ./reg-test/input/abixy filter
int a = 5;
int b = 7;
a <= NR && NR <= b
mlr --from ./reg-test/input/abixy filter filter false
mlr --from ./reg-test/input/abixy filter filter false; true
Case failed due to num_invocations_failed > 0
num_invocations_attempted 25
num_invocations_passed 24
num_invocations_failed 1
diff -a -I ^mlr -I ^Miller: -I ^cat ./reg-test/expected/case-c-dsl-context-specific-validation.sh.out /Users/kerl/pub_http_internet/miller-releases/miller-head/go/output-reg-test/case-c-dsl-context-specific-validation.sh.out
4a5,6
> DSL EXPRESSION:
> begin{begin{@x=1}}
5a8,15
> * statement block
> * begin block
> * statement block
> * begin block
> * statement block
> * assignment "="
> * direct oosvar value "x"
> * int literal "1"
7,29d16
< AST ROOT:
< text="block", type=STATEMENT_BLOCK:
< text="begin", type=BEGIN:
< text="begin_block", type=STATEMENT_BLOCK:
< text="begin", type=BEGIN:
< text="begin_block", type=STATEMENT_BLOCK:
< text="=", type=OOSVAR_ASSIGNMENT:
< text="oosvar_keylist", type=OOSVAR_KEYLIST:
< text="x", type=STRING_LITERAL.
< text="1", type=NUMERIC_LITERAL.
<
< BLOCKED AST:
<
< BEGIN-BLOCK:
< text="begin", type=BEGIN: subframe_var_count=1 max_subframe_depth=2 max_var_depth=1
< text="begin_block", type=STATEMENT_BLOCK:
< text="begin", type=BEGIN:
< text="begin_block", type=STATEMENT_BLOCK: subframe_var_count=0
< text="=", type=OOSVAR_ASSIGNMENT:
< text="oosvar_keylist", type=OOSVAR_KEYLIST:
< text="x", type=STRING_LITERAL.
< text="1", type=NUMERIC_LITERAL.
< mlr: begin statements are only valid at top level.
31a19,20
> DSL EXPRESSION:
> true{begin{@x=1}}
32a22,30
> * statement block
> * cond block
> * bool literal "true"
> * statement block
> * begin block
> * statement block
> * assignment "="
> * direct oosvar value "x"
> * int literal "1"
34,59d31
< AST ROOT:
< text="block", type=STATEMENT_BLOCK:
< text="cond", type=CONDITIONAL_BLOCK:
< text="true", type=BOOLEAN_LITERAL.
< text="cond_block", type=STATEMENT_BLOCK:
< text="begin", type=BEGIN:
< text="begin_block", type=STATEMENT_BLOCK:
< text="=", type=OOSVAR_ASSIGNMENT:
< text="oosvar_keylist", type=OOSVAR_KEYLIST:
< text="x", type=STRING_LITERAL.
< text="1", type=NUMERIC_LITERAL.
<
< BLOCKED AST:
<
< MAIN BLOCK:
< text="main_block", type=STATEMENT_BLOCK: subframe_var_count=1 max_subframe_depth=3 max_var_depth=1
< text="cond", type=CONDITIONAL_BLOCK:
< text="true", type=BOOLEAN_LITERAL.
< text="cond_block", type=STATEMENT_BLOCK: subframe_var_count=0
< text="begin", type=BEGIN:
< text="begin_block", type=STATEMENT_BLOCK: subframe_var_count=0
< text="=", type=OOSVAR_ASSIGNMENT:
< text="oosvar_keylist", type=OOSVAR_KEYLIST:
< text="x", type=STRING_LITERAL.
< text="1", type=NUMERIC_LITERAL.
< mlr: begin statements are only valid at top level.
61a34,35
> DSL EXPRESSION:
> end{end{@x=1}}
62a37,44
> * statement block
> * end block
> * statement block
> * end block
> * statement block
> * assignment "="
> * direct oosvar value "x"
> * int literal "1"
64,86d45
< AST ROOT:
< text="block", type=STATEMENT_BLOCK:
< text="end", type=END:
< text="end_block", type=STATEMENT_BLOCK:
< text="end", type=END:
< text="end_block", type=STATEMENT_BLOCK:
< text="=", type=OOSVAR_ASSIGNMENT:
< text="oosvar_keylist", type=OOSVAR_KEYLIST:
< text="x", type=STRING_LITERAL.
< text="1", type=NUMERIC_LITERAL.
<
< BLOCKED AST:
<
< END-BLOCK:
< text="end", type=END: subframe_var_count=1 max_subframe_depth=2 max_var_depth=1
< text="end_block", type=STATEMENT_BLOCK:
< text="end", type=END:
< text="end_block", type=STATEMENT_BLOCK: subframe_var_count=0
< text="=", type=OOSVAR_ASSIGNMENT:
< text="oosvar_keylist", type=OOSVAR_KEYLIST:
< text="x", type=STRING_LITERAL.
< text="1", type=NUMERIC_LITERAL.
< mlr: end statements are only valid at top level.
88a48,49
> DSL EXPRESSION:
> true{end{@x=1}}
89a51,59
> * statement block
> * cond block
> * bool literal "true"
> * statement block
> * end block
> * statement block
> * assignment "="
> * direct oosvar value "x"
> * int literal "1"
91,116d60
< AST ROOT:
< text="block", type=STATEMENT_BLOCK:
< text="cond", type=CONDITIONAL_BLOCK:
< text="true", type=BOOLEAN_LITERAL.
< text="cond_block", type=STATEMENT_BLOCK:
< text="end", type=END:
< text="end_block", type=STATEMENT_BLOCK:
< text="=", type=OOSVAR_ASSIGNMENT:
< text="oosvar_keylist", type=OOSVAR_KEYLIST:
< text="x", type=STRING_LITERAL.
< text="1", type=NUMERIC_LITERAL.
<
< BLOCKED AST:
<
< MAIN BLOCK:
< text="main_block", type=STATEMENT_BLOCK: subframe_var_count=1 max_subframe_depth=3 max_var_depth=1
< text="cond", type=CONDITIONAL_BLOCK:
< text="true", type=BOOLEAN_LITERAL.
< text="cond_block", type=STATEMENT_BLOCK: subframe_var_count=0
< text="end", type=END:
< text="end_block", type=STATEMENT_BLOCK: subframe_var_count=0
< text="=", type=OOSVAR_ASSIGNMENT:
< text="oosvar_keylist", type=OOSVAR_KEYLIST:
< text="x", type=STRING_LITERAL.
< text="1", type=NUMERIC_LITERAL.
< mlr: end statements are only valid at top level.
120a65,66
> DSL EXPRESSION:
> begin{$x=1}
121a68,73
> * statement block
> * begin block
> * statement block
> * assignment "="
> * direct field value "x"
> * int literal "1"
123,139d74
< AST ROOT:
< text="block", type=STATEMENT_BLOCK:
< text="begin", type=BEGIN:
< text="begin_block", type=STATEMENT_BLOCK:
< text="=", type=SREC_ASSIGNMENT:
< text="x", type=FIELD_NAME.
< text="1", type=NUMERIC_LITERAL.
<
< BLOCKED AST:
<
< BEGIN-BLOCK:
< text="begin", type=BEGIN: subframe_var_count=1 max_subframe_depth=1 max_var_depth=1
< text="begin_block", type=STATEMENT_BLOCK:
< text="=", type=SREC_ASSIGNMENT:
< text="x", type=FIELD_NAME.
< text="1", type=NUMERIC_LITERAL.
< mlr: assignments to $-variables are not valid within begin or end blocks.
141a77,78
> DSL EXPRESSION:
> begin{@x=$y}
142a80,85
> * statement block
> * begin block
> * statement block
> * assignment "="
> * direct oosvar value "x"
> * direct field value "y"
144,162d86
< AST ROOT:
< text="block", type=STATEMENT_BLOCK:
< text="begin", type=BEGIN:
< text="begin_block", type=STATEMENT_BLOCK:
< text="=", type=OOSVAR_ASSIGNMENT:
< text="oosvar_keylist", type=OOSVAR_KEYLIST:
< text="x", type=STRING_LITERAL.
< text="y", type=FIELD_NAME.
<
< BLOCKED AST:
<
< BEGIN-BLOCK:
< text="begin", type=BEGIN: subframe_var_count=1 max_subframe_depth=1 max_var_depth=1
< text="begin_block", type=STATEMENT_BLOCK:
< text="=", type=OOSVAR_ASSIGNMENT:
< text="oosvar_keylist", type=OOSVAR_KEYLIST:
< text="x", type=STRING_LITERAL.
< text="y", type=FIELD_NAME.
< mlr: statements involving $-variables are not valid within begin or end blocks.
164a89,90
> DSL EXPRESSION:
> end{$x=1}
165a92,97
> * statement block
> * end block
> * statement block
> * assignment "="
> * direct field value "x"
> * int literal "1"
167,183d98
< AST ROOT:
< text="block", type=STATEMENT_BLOCK:
< text="end", type=END:
< text="end_block", type=STATEMENT_BLOCK:
< text="=", type=SREC_ASSIGNMENT:
< text="x", type=FIELD_NAME.
< text="1", type=NUMERIC_LITERAL.
<
< BLOCKED AST:
<
< END-BLOCK:
< text="end", type=END: subframe_var_count=1 max_subframe_depth=1 max_var_depth=1
< text="end_block", type=STATEMENT_BLOCK:
< text="=", type=SREC_ASSIGNMENT:
< text="x", type=FIELD_NAME.
< text="1", type=NUMERIC_LITERAL.
< mlr: assignments to $-variables are not valid within begin or end blocks.
185a101,102
> DSL EXPRESSION:
> end{@x=$y}
186a104,109
> * statement block
> * end block
> * statement block
> * assignment "="
> * direct oosvar value "x"
> * direct field value "y"
188,206d110
< AST ROOT:
< text="block", type=STATEMENT_BLOCK:
< text="end", type=END:
< text="end_block", type=STATEMENT_BLOCK:
< text="=", type=OOSVAR_ASSIGNMENT:
< text="oosvar_keylist", type=OOSVAR_KEYLIST:
< text="x", type=STRING_LITERAL.
< text="y", type=FIELD_NAME.
<
< BLOCKED AST:
<
< END-BLOCK:
< text="end", type=END: subframe_var_count=1 max_subframe_depth=1 max_var_depth=1
< text="end_block", type=STATEMENT_BLOCK:
< text="=", type=OOSVAR_ASSIGNMENT:
< text="oosvar_keylist", type=OOSVAR_KEYLIST:
< text="x", type=STRING_LITERAL.
< text="y", type=FIELD_NAME.
< mlr: statements involving $-variables are not valid within begin or end blocks.
208a113,114
> DSL EXPRESSION:
> begin{@v=$*}
209a116,121
> * statement block
> * begin block
> * statement block
> * assignment "="
> * direct oosvar value "v"
> * full record "$*"
211,229d122
< AST ROOT:
< text="block", type=STATEMENT_BLOCK:
< text="begin", type=BEGIN:
< text="begin_block", type=STATEMENT_BLOCK:
< text="=", type=OOSVAR_FROM_FULL_SREC_ASSIGNMENT:
< text="oosvar_keylist", type=OOSVAR_KEYLIST:
< text="v", type=STRING_LITERAL.
< text="$*", type=FULL_SREC.
<
< BLOCKED AST:
<
< BEGIN-BLOCK:
< text="begin", type=BEGIN: subframe_var_count=1 max_subframe_depth=1 max_var_depth=1
< text="begin_block", type=STATEMENT_BLOCK:
< text="=", type=OOSVAR_FROM_FULL_SREC_ASSIGNMENT:
< text="oosvar_keylist", type=OOSVAR_KEYLIST:
< text="v", type=STRING_LITERAL.
< text="$*", type=FULL_SREC.
< mlr: assignments from $-variables are not valid within begin or end blocks.
231a125,126
> DSL EXPRESSION:
> end{$*=@v}
232a128,133
> * statement block
> * end block
> * statement block
> * assignment "="
> * full record "$*"
> * direct oosvar value "v"
234,252d134
< AST ROOT:
< text="block", type=STATEMENT_BLOCK:
< text="end", type=END:
< text="end_block", type=STATEMENT_BLOCK:
< text="=", type=FULL_SREC_ASSIGNMENT:
< text="$*", type=FULL_SREC.
< text="oosvar_keylist", type=OOSVAR_KEYLIST:
< text="v", type=STRING_LITERAL.
<
< BLOCKED AST:
<
< END-BLOCK:
< text="end", type=END: subframe_var_count=1 max_subframe_depth=1 max_var_depth=1
< text="end_block", type=STATEMENT_BLOCK:
< text="=", type=FULL_SREC_ASSIGNMENT:
< text="$*", type=FULL_SREC.
< text="oosvar_keylist", type=OOSVAR_KEYLIST:
< text="v", type=STRING_LITERAL.
< mlr: assignments to $-variables are not valid within begin or end blocks.
254a137,138
> DSL EXPRESSION:
> begin{unset $x}
255a140,144
> * statement block
> * begin block
> * statement block
> * unset "unset"
> * direct field value "x"
257,271d145
< AST ROOT:
< text="block", type=STATEMENT_BLOCK:
< text="begin", type=BEGIN:
< text="begin_block", type=STATEMENT_BLOCK:
< text="unset", type=UNSET:
< text="x", type=FIELD_NAME.
<
< BLOCKED AST:
<
< BEGIN-BLOCK:
< text="begin", type=BEGIN: subframe_var_count=1 max_subframe_depth=1 max_var_depth=1
< text="begin_block", type=STATEMENT_BLOCK:
< text="unset", type=UNSET:
< text="x", type=FIELD_NAME.
< mlr: unset of $-variables is not valid within begin or end blocks.
273a148,149
> DSL EXPRESSION:
> end{unset $x}
274a151,155
> * statement block
> * end block
> * statement block
> * unset "unset"
> * direct field value "x"
276,290d156
< AST ROOT:
< text="block", type=STATEMENT_BLOCK:
< text="end", type=END:
< text="end_block", type=STATEMENT_BLOCK:
< text="unset", type=UNSET:
< text="x", type=FIELD_NAME.
<
< BLOCKED AST:
<
< END-BLOCK:
< text="end", type=END: subframe_var_count=1 max_subframe_depth=1 max_var_depth=1
< text="end_block", type=STATEMENT_BLOCK:
< text="unset", type=UNSET:
< text="x", type=FIELD_NAME.
< mlr: unset of $-variables is not valid within begin or end blocks.
292a159,160
> DSL EXPRESSION:
> begin{unset $*}
293a162,166
> * statement block
> * begin block
> * statement block
> * unset "unset"
> * full record "$*"
295,309d167
< AST ROOT:
< text="block", type=STATEMENT_BLOCK:
< text="begin", type=BEGIN:
< text="begin_block", type=STATEMENT_BLOCK:
< text="unset", type=UNSET:
< text="$*", type=FULL_SREC.
<
< BLOCKED AST:
<
< BEGIN-BLOCK:
< text="begin", type=BEGIN: subframe_var_count=1 max_subframe_depth=1 max_var_depth=1
< text="begin_block", type=STATEMENT_BLOCK:
< text="unset", type=UNSET:
< text="$*", type=FULL_SREC.
< mlr: unset of $-variables is not valid within begin or end blocks.
311a170,171
> DSL EXPRESSION:
> end{unset $*}
312a173,177
> * statement block
> * end block
> * statement block
> * unset "unset"
> * full record "$*"
314,328d178
< AST ROOT:
< text="block", type=STATEMENT_BLOCK:
< text="end", type=END:
< text="end_block", type=STATEMENT_BLOCK:
< text="unset", type=UNSET:
< text="$*", type=FULL_SREC.
<
< BLOCKED AST:
<
< END-BLOCK:
< text="end", type=END: subframe_var_count=1 max_subframe_depth=1 max_var_depth=1
< text="end_block", type=STATEMENT_BLOCK:
< text="unset", type=UNSET:
< text="$*", type=FULL_SREC.
< mlr: unset of $-variables is not valid within begin or end blocks.
332a183,184
> DSL EXPRESSION:
> break
333a186,187
> * statement block
> * break "break"
335,344d188
< AST ROOT:
< text="block", type=STATEMENT_BLOCK:
< text="break", type=BREAK.
<
< BLOCKED AST:
<
< MAIN BLOCK:
< text="main_block", type=STATEMENT_BLOCK: subframe_var_count=1 max_subframe_depth=1 max_var_depth=1
< text="break", type=BREAK.
< mlr: break statements are only valid within for, while, or do-while.
346a191,192
> DSL EXPRESSION:
> continue
347a194,195
> * statement block
> * continue "continue"
349,358d196
< AST ROOT:
< text="block", type=STATEMENT_BLOCK:
< text="continue", type=CONTINUE.
<
< BLOCKED AST:
<
< MAIN BLOCK:
< text="main_block", type=STATEMENT_BLOCK: subframe_var_count=1 max_subframe_depth=1 max_var_depth=1
< text="continue", type=CONTINUE.
< mlr: break statements are only valid within for, while, or do-while.
362a201,202
> DSL EXPRESSION:
> break
363a204,205
> * statement block
> * break "break"
365,374d206
< AST ROOT:
< text="block", type=STATEMENT_BLOCK:
< text="break", type=BREAK.
<
< BLOCKED AST:
<
< MAIN BLOCK:
< text="main_block", type=STATEMENT_BLOCK: subframe_var_count=1 max_subframe_depth=1 max_var_depth=1
< text="break", type=BREAK.
< mlr: filter expressions must end in a final boolean statement.
376a209,210
> DSL EXPRESSION:
> continue
377a212,213
> * statement block
> * continue "continue"
379,388d214
< AST ROOT:
< text="block", type=STATEMENT_BLOCK:
< text="continue", type=CONTINUE.
<
< BLOCKED AST:
<
< MAIN BLOCK:
< text="main_block", type=STATEMENT_BLOCK: subframe_var_count=1 max_subframe_depth=1 max_var_depth=1
< text="continue", type=CONTINUE.
< mlr: filter expressions must end in a final boolean statement.
431,440c257
< NR is 1
< NR is 2
< NR is 3
< NR is 4
< NR is 5
< NR is 6
< NR is 7
< NR is 8
< NR is 9
< NR is 10
---
> Exit status was 1; expected 0.
Case failed due to expected output != actual output
FAIL ./reg-test/cases/case-c-dsl-context-specific-validation.sh
----------------------------------------------------------------
NUMBER OF MILLER RUNS 25
NUMBER OF CASES PASSED 0
NUMBER OF CASES FAILED 1
FAIL
rrv ./reg-test/cases/case-c-dsl-argpass-typedecl.sh
================================================================
:)
rrv ./reg-test/cases/case-c-dsl-multipart-scripts.sh
rrv ./reg-test/cases/case-c-dsl-trailing-commas.sh
MERGE
rrv ./reg-test/cases/case-c-dsl-user-defined-subroutines.sh
================================================================
SUBR
rrv ./reg-test/cases/case-c-dsl-user-defined-functions-and-subroutines.sh

View file

@ -254,7 +254,16 @@ mlr --from ./reg-test/input/abixy filter
call s(NR);
false
Exit status was 1; expected 0.
NR is 1
NR is 2
NR is 3
NR is 4
NR is 5
NR is 6
NR is 7
NR is 8
NR is 9
NR is 10
mlr --from ./reg-test/input/abixy filter
int a = 5;