rizin/test/db/cmd/cmd_macros
Anton Kochkov 2f638cad1e Convert f commands to rzshell
* Changed behavior of `f` to only add flag if there is none
* Changed behavior of `f+` to add flag in any case
* Moved listing subcommands from `f` to `fl`
* Moved listing subcommands from `f.` to `f.l`
* Added subcommand `f.l*` to list all local flags in all functions
* Listing flags at the current offset became `fl.`
* Moved `f=` to `fl=`
* Old `fl` (flag length) now became `fL`
* Removed original `fe` commands
* Old `f?` (check if flag exists) now became `fe`
* Removed `fV` commands
* Removed `fn` commands in favor of `fl` and `asm.flags.real=true`
* Removed `fS` commands (`fSo` and `fSn`)
* `fo` became `fortune` and moved from "flags" to "shell" category
* Removed oldshell handlers of the `z` commands
2022-02-03 21:46:42 +08:00

207 lines
2.2 KiB
Text

NAME=(msg x;?e $0)
FILE==
CMDS=<<EOF
"(msg x;?e $0)"
.(msg HelloWorld)
EOF
EXPECT=<<EOF
HelloWorld
EOF
RUN
NAME=(msg x;?e $0)
FILE==
CMDS=<<EOF
"(msg x;?e $0)"
.(msg HelloWorld)
EOF
EXPECT=<<EOF
HelloWorld
EOF
RUN
NAME=(msg x;?e $0)
FILE==
CMDS=<<EOF
"(msg x;?e $0)"
.(msg HelloWorld)
?e hiz
EOF
EXPECT=<<EOF
HelloWorld
hiz
EOF
RUN
NAME=.(msg x y;?e $0 $1)
FILE==
CMDS=<<EOF
"(msg x y;?e $0 $1)"
.(msg Hello World)
EOF
EXPECT=<<EOF
Hello World
EOF
RUN
NAME=.(msg "foo bar")
FILE==
CMDS=<<EOF
"(msg x;?e $0)"
.(msg "Hello World")
EOF
EXPECT=<<EOF
Hello World
EOF
RUN
NAME=.(msg foo\ bar)
FILE==
CMDS=<<EOF
"(msg x;?e $0)"
.(msg Hello\ World)
EOF
EXPECT=<<EOF
Hello World
EOF
RUN
NAME=(*~?
FILE==
CMDS=<<EOF
(foo;bar)
(bar;cow)
(*~?
EOF
EXPECT=<<EOF
2
EOF
RUN
NAME=3(foo inc;p8 4;sd +$0)(1)
FILE==
CMDS=<<EOF
wx 010203040506070809
3(foo inc;p8 4;sd +$0)(1)
EOF
EXPECT=<<EOF
01020304
02030405
03040506
EOF
RUN
NAME=3(foo;?e a;?e b)()
FILE==
CMDS=2(foo;?e a;?e b)()
EXPECT=<<EOF
a
b
a
b
EOF
RUN
NAME=?v $$ @@f:foo*
FILE==
CMDS=<<EOF
f foo.one @ 1
f foo.bar @ 2
f foo.cow @ 3
?v $$ @@f:foo*
EOF
EXPECT=<<EOF
0x1
0x2
0x3
EOF
RUN
NAME=?v
FILE==
CMDS=<<EOF
f foo.one @ 1
f foo.bar @ 2
f foo.cow @ 3
(_;?v $$)() @@f:foo*
EOF
EXPECT=<<EOF
0x1
0x2
0x3
EOF
RUN
NAME=multiple commands
FILE==
CMDS=<<EOF
(foo x y; p8 $0 @ $1; ?e Hello $0)(2 0)
(bar x y; p8 $0 @ $1; ?e Hello $0; ?e World $1)(1 0)
(zas x y; .(foo $1 $0))(3 1)
EOF
EXPECT=<<EOF
0000
Hello 2
00
Hello 1
World 0
00
Hello 1
EOF
RUN
NAME=..(
FILE==
CMDS=<<EOF
(foo1 fst; ?e $0)
(foo2 fst snd; ?e $0; ?v $1)
..(foo1 xyz)
?e -----
..(foo1 abc def)
?e -----
..(foo2 xyz 11)
?e -----
..(foo2 abc 10 def 9)
EOF
EXPECT=<<EOF
xyz
-----
abc
def
-----
xyz
0xb
-----
abc
0xa
def
0x9
EOF
RUN
NAME=arity errors
FILE==
CMDS=<<EOF
(foo0; ?e foo0)
(foo1 fst; ?e foo1 $0)
(foo2 fst snd; ?e foo2_0 $0; ?e foo2_1 $1)
.(foo0 1)
.(foo1)
.(foo1 1 2)
..(foo0 1)
..(foo1)
..(foo2 1)
..(foo2)
EOF
EXPECT_ERR=<<EOF
ERROR: Macro 'foo0' expects 0 args, not 1
ERROR: Macro 'foo1' expects 1 args, not 0
ERROR: Macro 'foo1' expects 1 args, not 2
ERROR: Macro 'foo0' expects 0 args, not 1
ERROR: Macro 'foo1' expects 1 args, not 0
ERROR: Macro 'foo2' expects 2 args and 1 is not a multiple of 2
ERROR: Macro 'foo2' expects 2 args, not 0
EOF
RUN