Added simple test.
authorTim Vaughan <plugd@thelambdalab.xyz>
Wed, 28 Apr 2021 16:02:27 +0000 (18:02 +0200)
committerTim Vaughan <plugd@thelambdalab.xyz>
Wed, 28 Apr 2021 16:02:27 +0000 (18:02 +0200)
simple_test.scm [new file with mode: 0644]

diff --git a/simple_test.scm b/simple_test.scm
new file mode 100644 (file)
index 0000000..b1981d7
--- /dev/null
@@ -0,0 +1,35 @@
+(import sam
+        matchable
+        (chicken process-context)
+        srfi-18)
+
+(define (send-startup-messages)
+  (send-message system 'print "Hello, what is your name?")
+  (send-message system 'read
+                (make-actor (lambda (self . message)
+                              (print message)
+                              (match message
+                                ((name)
+                                 (send-message system 'print "Hello, " name "!")
+                                 'done)))))
+
+  (thread-start!
+   (lambda ()
+     (thread-sleep! 10)
+     (send-message system 'print "Boo!"))))
+
+(let loop ((args (cdr (argv)))
+           (host "localhost")
+           (port 8000))
+  (match args
+    (((or "-h" "--help"))
+     (print "Usage: simple_test [ -h ] [ --port PORT ] [ --hostname host ]"))
+    (((or "-p" "--port") pstr rest ...)
+     (loop rest host (string->number pstr)))
+    (("--hostname" hstr rest ...)
+     (loop rest hstr port))
+    (()
+     (init-sam host port)
+     (print "-- Started SAM on " host ":" port " --\n")
+     (send-startup-messages)
+     (start-console))))