summaryrefslogtreecommitdiff
path: root/t
diff options
context:
space:
mode:
authordakkar <dakkar@thenautilus.net>2023-07-22 12:26:18 +0100
committerdakkar <dakkar@thenautilus.net>2023-07-22 12:26:18 +0100
commitef2ab079df0a0971dee99547a31a021874e95077 (patch)
tree90794d43988e1056d757471665b5199c873e9c17 /t
parentnotes for next steps (diff)
downloadbash-object-system-ef2ab079df0a0971dee99547a31a021874e95077.tar.gz
bash-object-system-ef2ab079df0a0971dee99547a31a021874e95077.tar.bz2
bash-object-system-ef2ab079df0a0971dee99547a31a021874e95077.zip
move tests to actual test programs
yes, TAP
Diffstat (limited to 't')
-rw-r--r--t/inherit.t46
-rw-r--r--t/testlib.sh12
2 files changed, 58 insertions, 0 deletions
diff --git a/t/inherit.t b/t/inherit.t
new file mode 100644
index 0000000..58f7e22
--- /dev/null
+++ b/t/inherit.t
@@ -0,0 +1,46 @@
+#!/bin/bash
+
+. t/testlib.sh
+
+class A; do
+
+ function thing() {
+ echo "<$self> A/thing ($*)"
+ }
+
+done
+
+class B; do
+ extends A
+
+ function other() {
+ echo "<$self> B/other ($*)"
+ }
+
+done
+
+class C; do
+ extends B
+
+ function thing() {
+ echo "<$self> C/thing ($*)"
+
+ $self next/method "$@"
+ }
+
+done
+
+A new-into objA
+B new-into objB
+C new-into objC
+
+[[ -n "$objA" ]]; should-succeed simple instantiation
+[[ -n "$objB" ]]; should-succeed instantiation with inheritance
+
+is "$($objA thing 1 2 3)" "<*A*> A/thing (1 2 3)" direct call
+is "$($objB other a b c)" "<*B*> B/other (a b c)" direct call
+is "$($objB thing 4 5 6)" "<*B*> A/thing (4 5 6)" inherited call
+is "$($objC thing 7 8 9)" $'<*C*> C/thing (7 8 9)\n<*C*> A/thing (7 8 9)' next/method
+
+
+done-testing
diff --git a/t/testlib.sh b/t/testlib.sh
new file mode 100644
index 0000000..6da46f5
--- /dev/null
+++ b/t/testlib.sh
@@ -0,0 +1,12 @@
+#!/bin/bash
+
+PS4='[${#FUNCNAME[*]}] ${BASH_SOURCE[0]}:${LINENO} (${FUNCNAME[0]}) +'
+
+. bos-namespaces.sh
+. bos-object-id.sh
+. bos-mop.sh
+. bos-dispatch.sh
+. bos-mop-inheritance.sh
+. bos-sugar.sh
+
+. minitap.sh