hawk/t/test.txt

194 lines
8.0 KiB
Plaintext
Raw Permalink Normal View History

#### TODO: create test cases using the following data
BEGIN { @local abc; abc(); }'
HAWK_ENOTFUN -> ERROR: CODE 97 LINE 1 COLUMN 21 - non-function value in abc
BEGIN { @local x; abc(); }
HAWK_EFUNNF -> ERROR: CODE 96 LINE 1 COLUMN 19 - function 'abc' not found
hawk --implicit=off 'BEGIN { @local x; abc(); }'
HAWK_EFUNNF -> ERROR: CODE 96 LINE 1 COLUMN 19 - function 'abc' not defined ===> same as the above. but it's a parse-time error.
BEGIN { @local x; x=sys::getpid(); delete x;}
HAWK_ENOTDEL -> ERROR: CODE 98 LINE 1 COLUMN 43 - 'x' not deletable
hawk --flexmap=off 'BEGIN { ARGV = 30; }'
HAWK_ENMAPTOSCALAR -> ERROR: CODE 110 LINE 1 COLUMN 10 - not allowed to change a map 'ARGV' to a scalar
hawk --flexmap=off 'BEGIN { @local x; x = 10; x[1] = "hello"; }'
HAWK_ESCALARTOMAP -> ERROR: CODE 108 LINE 1 COLUMN 28 - not allowed to change a scalar 'x' to a map
hawk --flexmap=off 'BEGIN { @local x, y; x[1]=20; ARGC = x; }'
HAWK_ESCALARTOMAP -> ERROR: CODE 108 LINE 1 COLUMN 32 - not allowed to achange a scalar 'ARGC' to a map
hawk --flexmap=off 'BEGIN { ARGC[1] = "hello"; }'
HAWK_ESCALARTOMAP -> ERROR: CODE 108 LINE 1 COLUMN 10 - not allowed to change a scalar 'ARGC' to a map
hawk --flexmap=off 'BEGIN { @local x, y; x[1]=20; CONVFMT = x; }'
HAWK_ESCALARTOMAP -> ERROR: CODE 108 LINE 1 COLUMN 32 - not allowed to change a scalar 'CONVFMT' to a map
hawk --flexmap=on 'BEGIN { @local x, y; x[1]=20; CONVFMT = x; }'
HAWK_ESCALARTOMAP -> ERROR: CODE 108 LINE 1 COLUMN 32 - not allowed to change a scalar 'CONVFMT' to a map
$ hawk --flexmap=off 'BEGIN { @local x, y; x[1] = 10; y[1] = 20; x = y; }'
HAWK_EMAPTOMAP -> ERROR: CODE 108 LINE 1 COLUMN 45 - not allowed to change a map 'x' to another map => x is a local variable
$ hawk --flexmap=off 'BEGIN { @local y; x[1] = 10; y[1] = 20; x = y; }'
HAWK_EMAPTOMAP -> ERROR: CODE 108 LINE 1 COLUMN 42 - jnot allowed to change a map 'x' to another map => x is a global variable
$ hawk --flexmap=off 'function abc(x) { @local j; j[1] = 20; x = j; } BEGIN { @local q; q[1]=20; abc(q); }'
HAWK_EMAPTOMAP -> ERROR: CODE 108 LINE 1 COLUMN 40 - not allowed to change a map 'x' to another map => x is an argument
$ hawk --flexmap=off 'function abc(x) { x = 20; } BEGIN { @local q; q[1]=20; abc(q); }'
HAWK_EMAPTOSCALAR -> ERROR: CODE 107 LINE 1 COLUMN 19 - not allowed to change a map 'x' to a scalar
$ hawk --flexmap=off 'BEGIN { @local y; x[1] = 10; x = 20; }'
HAWK_EMAPTOSCALAR -> ERROR: CODE 107 LINE 1 COLUMN 32 - not allowed to change a map 'x' to a scalar
$ hawk --flexmap=off 'BEGIN { x[1] = 10; x = 20; }'
HAWK_EMAPTOSCALAR -> ERROR: CODE 107 LINE 1 COLUMN 22 - not allowed to change a map 'x' to a scalar
$ hawk --flexmap=off 'BEGIN { x[1] = 10; jx=x; }'
HAWK_EMAPTOMAP -> ERROR: CODE 106 LINE 1 COLUMN 22 - not allowed to assign a map to a variable 'jx'
$ hawk --flexmap=off 'BEGIN { @local x, jx; x[1] = 10; jx=x; }'
HAWK_EMAPTOMAP -> ERROR: CODE 106 LINE 1 COLUMN 36 - not allowed to assign a map to a variable 'jx'
$ hawk --flexmap=off 'function abc(jx) { @local x; x[1]= 20; jx = x; } BEGIN { abc(10); }'
HAWK_EMAPTOMAP -> ERROR: CODE 106 LINE 1 COLUMN 40 - not allowed to assign a map to a variable 'jx'
$ hawk 'BEGIN { print 0192; }'
HAWK_ELXDIG -> ERROR: CODE 32 LINE 1 COLUMN 15 - invalid digit '9'
$ hawk 'BEGIN { +
> }'
HAWK_EEXPRNR -> ERROR: CODE 49 LINE 1 COLUMN 9 - expression not recognized around '+'
$ ~/xxx/bin/hawk '@pragma stack_limit "99"; BEGIN { }'
HAWK_EINTLIT -> ERROR: CODE 45 LINE 1 COLUMN 21 - integer literal expected in place of '99'
$ ~/xxx/bin/hawk --pablock=off '{ print $0; }'
HAWK_EKWFNC -> ERROR: CODE 50 LINE 1 COLUMN 1 - keyword 'function' expected in place of '{'
$ ~/xxx/bin/hawk --pablock=off 'BEGIN { print $0; }'
HAWK_EKWFNC -> ERROR: CODE 50 LINE 1 COLUMN 1 - keyword 'function' expected in place of 'BEGIN'
$ ~/xxx/bin/hawk '@include "a\0b"; function; BEGIN { function=10; }'
HAWK_EIONMNL -> ERROR: CODE 122 LINE 1 COLUMN 10 - invalid I/O name of length 3 containing '\0'
$ ~/xxx/bin/hawk 'function add(a,b) { return a + b; } @global add; BEGIN { add = 10; }'
HAWK_EFUNRED -> ERROR: CODE 59 LINE 1 COLUMN 45 - function 'add' redefined
$ ~/xxx/bin/hawk '@global add; function add(a,b) { return a + b; } BEGIN { add = 10; }'
HAWK_EGBLRED -> ERROR: CODE 60 LINE 1 COLUMN 23 - global variable 'add' redefined
$ ~/xxx/bin/hawk 'BEGIN { @local length; }'
HAWK_EFNCRED -> ERROR: CODE 58 LINE 1 COLUMN 16 - intrinsic function 'length' redefined
$ ~/xxx/bin/hawk '@global length;'
HAWK_EFNCRED -> ERROR: CODE 58 LINE 1 COLUMN 9 - intrinsic function 'length' redefined
$ ~/xxx/bin/hawk 'function length(x) { return 10; }'
HAWK_EFNCRED -> ERROR: CODE 58 LINE 1 COLUMN 10 - intrinsic function 'length' redefined
$ ~/xxx/bin/hawk 'function test(ax) { @local ax; }'
HAWK_EPARRED -> ERROR: CODE 61 LINE 1 COLUMN 28 - parameter 'ax' redefined
$ ~/xxx/bin/hawk 'function test(ax, bx, ax) { return ax * bx; }'
HAWK_EDUPPAR -> ERROR: CODE 63 LINE 1 COLUMN 23 - duplicate parameter name 'ax'
$ ~/xxx/bin/hawk '@global x, y, x; '
HAWK_EDUPGBL -> ERROR: CODE 64 LINE 1 COLUMN 15 - duplicate global variable name 'x'
$ ~/xxx/bin/hawk 'function test(ax, bx) { @local x, y, x; }'
HAWK_EDUPLCL -> ERROR: CODE 65 LINE 1 COLUMN 38 - duplicate local variable name - x
$ ~/xxx/bin/hawk 'function test(ax, bx) { @local ARGC; }'
ERROR: CODE 65 LINE 1 COLUMN 32 - duplicate local variable name - ARGC
$ ~/xxx/bin/hawk '@global 10; '
HAWK_EBADVAR -> ERROR: CODE 67 LINE 1 COLUMN 9 - '10' not a valid variable name
$ ~/xxx/bin/hawk '{ @local 10; }'
HAWK_EBADVAR -> ERROR: CODE 67 LINE 1 COLUMN 10 - '10' not a valid variable name
$ ~/xxx/bin/hawk 'function test(10) {} '
HAWK_EBADPAR -> ERROR: CODE 66 LINE 1 COLUMN 15 - '10' not a valid parameter name
$ ~/xxx/bin/hawk 'BEGIN { print B"abc^Bdef"; }'
HAWK_EMBSCHR -> ERROR: CODE 37 LINE 1 COLUMN 15 - invalid mbs character ''
$ ~/xxx/bin/hawk "BEGIN { print B'abf^Bdef'; }"
HAWK_EMBSCHR -> ERROR: CODE 37 LINE 1 COLUMN 16 - invalid mbs character ''
$ ~/xxx/bin/hawk --implicit=off 'BEGIN { print kcx[10]; }'
HAWK_EUNDEF -> ERROR: CODE 69 LINE 1 COLUMN 16 - undefined identifier 'kcx'
$ ~/xxx/bin/hawk --implicit=off 'BEGIN { print ax; }'
HAWK_EUNDEF -> ERROR: CODE 69 LINE 1 COLUMN 16 - undefined identifier 'ax'
$ ~/xxx/bin/hawk 'function 1.2(a) {}'
HAWK_EFUNNAM -> ERROR: CODE 54 LINE 1 COLUMN 10 - '1.2' not a valid function name
$ ~/xxx/bin/hawk 'function abc(x) print t; }'
HAWK_ELBRACE -> ERROR: CODE 38 LINE 1 COLUMN 17 - left brace expected in place of 'print'
$ ~/xxx/bin/hawk 'function abc(x) { print a[10; }'
HAWK_ERBRACK -> ERROR: CODE 41 LINE 1 COLUMN 29 - right bracket expected in place of ';'
$ ~/xxx/bin/hawk 'function abc x) { print 10; }'
HAWK_ELPAREN -> ERROR: CODE 39 LINE 1 COLUMN 14 - left parenthesis expected in place of 'x'
$ ~/xxx/bin/hawk 'function abc (x) { print (x; }'
HAWK_EPAREN -> ERROR: CODE 40 LINE 1 COLUMN 28 - right parenthesis expected in place of ';'
$ ~/xxx/bin/hawk 'function abc (x { print 10; }'
HAWK_ECOMMA -> ERROR: CODE 42 LINE 1 COLUMN 17 - comma expected in place of '{'
$ ~/xxx/bin/hawk 'function abc (x) { for (i = 10) print i; }'
HAWK_ESCOLON -> ERROR: CODE 43 LINE 1 COLUMN 31 - semicolon expected in place of ')'
$ ~/xxx/bin/hawk 'function abc (x) { print (i? 20, 30); }'
HAWK_ECOLON -> ERROR: CODE 44 LINE 1 COLUMN 32 - colon expected in place of ','
$ ~/xxx/bin/hawk '@includ "xxx.inc"; BEGIN {}'
HAWK_EXKWNR -> ERROR: CODE 88 LINE 1 COLUMN 1 - '@includ' not recognized
$ ~/xxx/bin/hawk 'function abc (x) { do { print x }; }'
HAWK_EKWWHL -> ERROR: CODE 51 LINE 1 COLUMN 34 - keyword 'while' expected in place of ';'
$ ~/xxx/bin/hawk 'function abc (x) { do { print sysxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxtt::xx }; }'
HAWK_ESEGTL -> ERROR: CODE 75 LINE 1 COLUMN 31 - segment 'sysxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxtt' too long
$ ~/xxx/bin/hawk --tolerant=off 'function abc (x) { (1, 2, 3) }'
HAWK_EKWIN -> ERROR: CODE 47 LINE 1 COLUMN 30 - keyword 'in' expected in place of '}'