diff options
author | Mike Frysinger <vapier@gentoo.org> | 2013-06-21 23:56:07 +0000 |
---|---|---|
committer | Mike Frysinger <vapier@gentoo.org> | 2013-06-21 23:56:07 +0000 |
commit | c8d897c5c82f5a906f7ff7007704595ee63cc45c (patch) | |
tree | 9d4e2e2ba9abf0712c499e53b507af30805df85a /eclass/tests | |
parent | isdigit: new func for testing if args are all numbers (diff) | |
download | historical-c8d897c5c82f5a906f7ff7007704595ee63cc45c.tar.gz historical-c8d897c5c82f5a906f7ff7007704595ee63cc45c.tar.bz2 historical-c8d897c5c82f5a906f7ff7007704595ee63cc45c.zip |
evar_push/evar_pop: new api for saving/restoring variables on a stack
Diffstat (limited to 'eclass/tests')
-rwxr-xr-x | eclass/tests/eutils:evar.sh | 97 |
1 files changed, 97 insertions, 0 deletions
diff --git a/eclass/tests/eutils:evar.sh b/eclass/tests/eutils:evar.sh new file mode 100755 index 000000000000..837818de6730 --- /dev/null +++ b/eclass/tests/eutils:evar.sh @@ -0,0 +1,97 @@ +#!/bin/bash + +source tests-common.sh + +inherit eutils + +tbegin "simple push/pop" +VAR=1 +evar_push VAR +pu=$? +VAR=2 +evar_pop +po=$? +[[ ${pu}${po}${VAR} == "001" ]] +tend $? + +tbegin "unset push/pop" +unset VAR +evar_push VAR +pu=$? +VAR=2 +evar_pop +po=$? +[[ ${pu}${po}${VAR+set} == "00" ]] +tend $? + +tbegin "empty push/pop" +VAR= +evar_push VAR +pu=$? +VAR=2 +evar_pop +po=$? +[[ ${pu}${po}${VAR+set}${VAR} == "00set" ]] +tend $? + +tbegin "export push/pop" +export VAR=exported +evar_push VAR +pu=$? +VAR=2 +evar_pop +po=$? +var=$(bash -c 'echo ${VAR}') +[[ ${pu}${po}${var} == "00exported" ]] +tend $? + +tbegin "unexport push/pop" +unset VAR +VAR=not-exported +evar_push VAR +pu=$? +VAR=2 +evar_pop +po=$? +var=$(bash -c 'echo ${VAR+set}') +[[ ${pu}${po}${VAR}${var} == "00not-exported" ]] +tend $? + +tbegin "multi push/pop" +A=a B=b C=c +evar_push A B C +pu=$? +A=A B=B C=C +evar_pop 1 +po1=$? +[[ ${A}${B}${C} == "ABc" ]] +po2=$? +evar_pop 2 +po3=$? +var=$(bash -c 'echo ${VAR+set}') +[[ ${pu}${po1}${po2}${po3}${A}${B}${C} == "0000abc" ]] +tend $? + +tbegin "simple push_set/pop" +VAR=1 +evar_push_set VAR 2 +pu=$? +[[ ${VAR} == "2" ]] +po1=$? +evar_pop +po2=$? +[[ ${pu}${po1}${po2}${VAR} == "0001" ]] +tend $? + +tbegin "unset push_set/pop" +VAR=1 +evar_push_set VAR +pu=$? +[[ ${VAR+set} != "set" ]] +po1=$? +evar_pop +po2=$? +[[ ${pu}${po1}${po2}${VAR} == "0001" ]] +tend $? + +texit |