summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rw-r--r--tests/012/oop.expected17
-rw-r--r--tests/012/oop.tl66
2 files changed, 83 insertions, 0 deletions
diff --git a/tests/012/oop.expected b/tests/012/oop.expected
new file mode 100644
index 00000000..f0bb554f
--- /dev/null
+++ b/tests/012/oop.expected
@@ -0,0 +1,17 @@
+n/a
+dog
+collie
+animal
+dog
+collie
+animal
+canine
+collie
+animal
+canine
+collie
+poodle
+#S(b a 1 b 2 c 3)
+#S(d a nil b -2 c 3)
+(10 20 300 42 42)
+(10 -20 300 42 0)
diff --git a/tests/012/oop.tl b/tests/012/oop.tl
new file mode 100644
index 00000000..24cf2726
--- /dev/null
+++ b/tests/012/oop.tl
@@ -0,0 +1,66 @@
+(load "../common")
+
+(defstruct animal nil
+ (:function whoami () "n/a")
+ (:method print (self stream) (put-string self.[whoami] stream)))
+
+(defstruct dog animal
+ (:function whoami () "dog"))
+
+(defstruct collie dog
+ (:function whoami () "collie"))
+
+(defstruct poodle dog)
+
+(defvarl a (new animal))
+(defvarl d (new dog))
+(defvarl c (new collie))
+
+(defun print-all ()
+ (pprinl a)
+ (pprinl d)
+ (pprinl c))
+
+(print-all)
+
+(defmeth animal whoami ()
+ "animal")
+
+(print-all)
+
+(defmeth dog whoami ()
+ "canine")
+
+(print-all)
+
+(defmeth poodle whoami ()
+ "poodle")
+
+(print-all)
+
+(pprinl (new poodle))
+
+(defstruct b nil
+ (:instance a 1)
+ (:instance b 2)
+ (:instance c 3)
+ (:static sa 10)
+ (:static sb 20)
+ (:static sc 30))
+
+(defstruct d b
+ (a)
+ (b -2)
+ (:static sa)
+ (:static sb -20)
+ (:static y 0))
+
+(static-slot-ensure 'b 'x 42)
+(static-slot-ensure 'b 'y 42)
+
+(let ((b (new b sc 300))
+ (d (new d)))
+ (prinl b)
+ (prinl d)
+ (prinl (list b.sa b.sb b.sc b.x b.y))
+ (prinl (list d.sa d.sb d.sc d.x d.y)))