#97: sto+, sto-, sto*, sto/, sneg, sinv

This commit is contained in:
Louis Rubet 2017-05-29 16:02:52 +02:00
parent a60484cf34
commit 61ac6555e7
3 changed files with 98 additions and 0 deletions

View file

@ -105,6 +105,12 @@ program::keyword_t program::s_keywords[] =
{ cmd_keyword, "purge", &program::purge, "delete a variable. ex: 'name' purge" },
{ cmd_keyword, "vars", &program::vars, "list all variables" },
{ cmd_keyword, "edit", &program::edit, "edit a variable content" },
{ cmd_keyword, "sto+", &program::stoadd, "add to a stored variable. ex: 1 'name' sto+ 'name' 2 sto+" },
{ cmd_keyword, "sto-", &program::stosub, "substract to a stored variable. ex: 1 'name' sto- 'name' 2 sto-" },
{ cmd_keyword, "sto*", &program::stomul, "multiply a stored variable. ex: 3 'name' sto* 'name' 2 sto*" },
{ cmd_keyword, "sto/", &program::stodiv, "divide a stored variable. ex: 3 'name' sto/ 'name' 2 sto/" },
{ cmd_keyword, "sneg", &program::stoneg, "negate a variable. ex: 'name' sneg" },
{ cmd_keyword, "sinv", &program::stoinv, "inverse a variable. ex: 1 'name' sinv" },
//PROGRAM
{ cmd_undef, "", NULL, "\nPROGRAM"},

View file

@ -9,6 +9,22 @@ void sto(void)
(void)_stack->pop_back();
}
//
void stoadd(void)
{
MIN_ARGUMENTS(2);
if ((_stack->get_type(0) == cmd_symbol && _stack->get_type(1) == cmd_number)
|| (_stack->get_type(1) == cmd_symbol && _stack->get_type(0) == cmd_number))
{
}
else
{
}
}
void rcl(void)
{
MIN_ARGUMENTS(1);

View file

@ -61,3 +61,79 @@ erase
'a' purge
-> error should be 5
-> stack size should be 0
# sto+ (1)
2 'a' sto
2 'a' sto+
a
-> stack should be 4
erase
# sto+ (2)
'a' sto+
-> stack size should be 1
-> error should be 2
erase
# sto- (1)
2 'a' sto
2 'a' sto-
a
-> stack should be 0
erase
# sto- (2)
'a' sto-
-> stack size should be 1
-> error should be 2
erase
# sto* (1)
2 'a' sto
3 'a' sto*
a
-> stack should be 6
erase
# sto* (2)
'a' sto*
-> stack size should be 1
-> error should be 2
erase
# sto/ (1)
6 'a' sto
2 'a' sto/
a
-> stack should be 3
erase
# sto/ (2)
'a' sto/
-> stack size should be 1
-> error should be 2
erase
# sneg (1)
7 'a' sto
'a' sneg
a
-> stack should be -7
erase
# sneg (2)
sneg
-> error should be 2
erase
# sinv (1)
4 'a' sto
'a' sneg
a
-> stack should be 0.25
erase
# sinv (2)
sinv
-> error should be 2
erase