aboutsummaryrefslogtreecommitdiff
path: root/bash/tests/common.sh
diff options
context:
space:
mode:
Diffstat (limited to 'bash/tests/common.sh')
-rw-r--r--bash/tests/common.sh25
1 files changed, 25 insertions, 0 deletions
diff --git a/bash/tests/common.sh b/bash/tests/common.sh
new file mode 100644
index 0000000..9924107
--- /dev/null
+++ b/bash/tests/common.sh
@@ -0,0 +1,25 @@
+
+assert () {
+ if ! eval "${2}"; then
+ echo "assert failure line ${1}"
+ exit 1
+ fi
+}
+
+assert_eq () {
+ if eval "${3}"; then
+ if [[ "${2}" != "${r}" ]]; then
+ echo "assert_eq failure line ${1}: '${2}' != '${r}'"
+ exit 1
+ fi
+ else
+ echo "assert_eq failure line ${1}: could not evaluate '${3}'"
+ exit 1
+ fi
+}
+
+TEST_RE () {
+ r=
+ READ_STR "${1}"
+ EVAL "${r}" ${REPL_ENV}
+}