more tests for expressions

This commit is contained in:
Axel Kohlmeyer
2021-03-23 21:42:45 -04:00
parent 85d1257222
commit 67f1f12c20
3 changed files with 45 additions and 18 deletions

View File

@ -534,12 +534,10 @@ void Variable::set(int narg, char **arg)
if (replaceflag) return;
if (!utils::is_id(arg[0]))
error->all(FLERR,fmt::format("Variable name '{}' must have only alphanu"
"meric characters or underscores",arg[0]));
names[nvar] = utils::strdup(arg[0]);
for (auto c : std::string(arg[0]))
if (!isalnum(c) && (c != '_'))
error->all(FLERR,fmt::format("Variable name '{}' must have only "
"alphanumeric characters or underscores",
names[nvar]));
nvar++;
}
@ -983,9 +981,12 @@ double Variable::compute_equal(int ivar)
don't need to flag eval_in_progress since is an immediate variable
------------------------------------------------------------------------- */
double Variable::compute_equal(char *str)
double Variable::compute_equal(const std::string &str)
{
return evaluate(str,nullptr,-1);
char *ptr = utils::strdup(str);
double val = evaluate(ptr,nullptr,-1);
delete[] ptr;
return val;
}
/* ----------------------------------------------------------------------