summaryrefslogtreecommitdiff
path: root/tests/examplefiles/classes.dylan
diff options
context:
space:
mode:
Diffstat (limited to 'tests/examplefiles/classes.dylan')
-rw-r--r--tests/examplefiles/classes.dylan20
1 files changed, 20 insertions, 0 deletions
diff --git a/tests/examplefiles/classes.dylan b/tests/examplefiles/classes.dylan
new file mode 100644
index 00000000..a77956d4
--- /dev/null
+++ b/tests/examplefiles/classes.dylan
@@ -0,0 +1,20 @@
+define class <car> (<object>)
+ slot serial-number :: <integer> = unique-serial-number();
+ slot model-name :: <string>,
+ required-init-keyword: model:;
+ slot has-sunroof? :: <boolean>,
+ init-keyword: sunroof?:,
+ init-value: #f;
+end class <car>;
+
+define variable *unique-serial-number* = 0;
+
+define function unique-serial-number() => (usn :: <integer>)
+ let serial = *unique-serial-number*;
+ *unique-serial-number* := *unique-serial-number* + 1;
+ serial;
+end function;
+
+define constant $blue-car = make(<car>, model: "Viper");
+define constant $black-car = make(<car>, model: "Town Car", sunroof?: #t);
+define constant $red-car = make(<car>, model: "F40", sunroof?: #f);