From: Tim Vaughan Date: Wed, 28 Apr 2021 16:02:27 +0000 (+0200) Subject: Added simple test. X-Git-Url: https://thelambdalab.xyz/gitweb/index.cgi?a=commitdiff_plain;h=95a59c7a0fee2067061eb8dea350ceb8002b9fb1;p=sam.git Added simple test. --- diff --git a/simple_test.scm b/simple_test.scm new file mode 100644 index 0000000..b1981d7 --- /dev/null +++ b/simple_test.scm @@ -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))))