Updating copyright headers to be more "modern"
[8sync.git] / tests / test-agenda.scm
index 6918c992818c625336fe4febfe41d6fa3d448dfa..3011a86ac03607d2f081ca54a71ee4f36d3ae74c 100644 (file)
@@ -1,19 +1,20 @@
-;; Copyright (C) 2015 Christopher Allan Webber <cwebber@dustycloud.org>
-
-;; This library is free software; you can redistribute it and/or
-;; modify it under the terms of the GNU Lesser General Public
-;; License as published by the Free Software Foundation; either
-;; version 3 of the License, or (at your option) any later version.
-;;
-;; This library is distributed in the hope that it will be useful,
-;; but WITHOUT ANY WARRANTY; without even the implied warranty of
-;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-;; Lesser General Public License for more details.
-;;
-;; You should have received a copy of the GNU Lesser General Public
-;; License along with this library; if not, write to the Free Software
-;; Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
-;; 02110-1301 USA
+;;; 8sync --- Asynchronous programming for Guile
+;;; Copyright (C) 2015 Christopher Allan Webber <cwebber@dustycloud.org>
+;;;
+;;; This library is free software; you can redistribute it and/or
+;;; modify it under the terms of the GNU Lesser General Public
+;;; License as published by the Free Software Foundation; either
+;;; version 3 of the License, or (at your option) any later version.
+;;;
+;;; This library is distributed in the hope that it will be useful,
+;;; but WITHOUT ANY WARRANTY; without even the implied warranty of
+;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+;;; Lesser General Public License for more details.
+;;;
+;;; You should have received a copy of the GNU Lesser General Public
+;;; License along with this library; if not, write to the Free Software
+;;; Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+;;; 02110-1301 USA
 
 #!/usr/bin/guile \
 -s
       messages)))
 
 \f
-;; Timer tests
-;; ===========
+;;; queue helpers
+;;; =============
+
+(define test-q (list->q '(1 2 3)))
+(test-equal (deq! test-q) 1)
+(test-equal (deq! test-q) 2)
+(test-equal (deq! test-q) 3)
+(test-assert (q-empty? test-q))
+
+(define test-q (make-q* 'apple 'banana 'carrot))
+(test-equal (deq! test-q) 'apple)
+(test-equal (deq! test-q) 'banana)
+(test-equal (deq! test-q) 'carrot)
+(test-assert (q-empty? test-q))
+
+
+\f
+;;; Timer tests
+;;; ===========
 
 (test-assert (time= '(1 . 1) '(1 . 1)))
 (test-assert (not (time= '(1 . 1) '(1 . 0))))
 (define* (local-func-gets-break #:key with-indirection)
   (speaker "Time for exception fun!\n")
   (let ((caught-exception #f))
-    (catch '%8sync-caught-error
-      (lambda ()
-        (%8sync (%run (if with-indirection
-                          (indirection-remote-func-breaks)
-                          (remote-func-breaks)))))
-      (lambda (_ orig-key orig-args orig-stacks)
-        (set! caught-exception #t)
-        (speaker "in here now!\n")
-        (test-equal orig-key 'numerical-overflow)
-        (test-equal orig-args '("/" "Numerical overflow" #f #f))
-        (test-assert (list? orig-stacks))
-        (test-equal (length orig-stacks)
-                    (if with-indirection 2 1))
-        (for-each
-         (lambda (x)
-           (test-assert (stack? x)))
-         orig-stacks)))
+    (catch-8sync
+     (%8sync (%run (if with-indirection
+                       (indirection-remote-func-breaks)
+                       (remote-func-breaks))))
+      ('numerical-overflow
+       (lambda (orig-stacks . orig-args)
+         (set! caught-exception #t)
+         (speaker "in here now!\n")
+         (test-equal orig-args '("/" "Numerical overflow" #f #f))
+         (test-assert (list? orig-stacks))
+         (test-equal (length orig-stacks)
+                     (if with-indirection 2 1))
+         (for-each
+          (lambda (x)
+            (test-assert (stack? x)))
+          orig-stacks))))
     (test-assert caught-exception))
   (speaker "Well that was fun :)\n"))
 
   (catch-8sync
    (begin
      (speaker "hello")
-     (throw '%8sync-caught-error
+     (throw '8sync-caught-error
             'my-orig-key '(apple orange banana) '(*fake-stack* *fake-stack* *fake-stack*))
      (speaker "no goodbyes"))
    ('some-key