From 420fd868691947fd2b5ebb510360ee06e91b31e0 Mon Sep 17 00:00:00 2001 From: Jessica Tallon Date: Thu, 19 Jan 2023 13:42:23 +0100 Subject: [PATCH] Add test for keyword argumnets over CapTP --- goblins/ocapn/captp-test.rkt | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/goblins/ocapn/captp-test.rkt b/goblins/ocapn/captp-test.rkt index d347ae0..35af363 100644 --- a/goblins/ocapn/captp-test.rkt +++ b/goblins/ocapn/captp-test.rkt @@ -563,3 +563,25 @@ #;(collect-garbage) ;; ... damn we actually need to test the messages sent at some point + +;; Test keyword argument sending in CapTP +(define ((^kw-car-factory _bcom brand) model #:color color #:noise noise) + (define (^car _bcom brand color noise) + (format "a ~a ~a ~a goes ~a!" color brand model noise)) + (spawn ^car brand model color noise)) + +(define result-ch (make-async-channel)) +(define fork-factory (a-run (spawn ^kw-car-factory "fork"))) +(define fork-factory-sref (m1-run ($ m1-mycapn 'register fork-factory 'fake))) + +(let* ((fork-factory-vow (m2-run (<- m2-mycapn 'enliven fork-factory-sref))) + (red-explorer-vow (<- fork-factory-vow "explorer" #:color "red" "vroooom"))) + (b-run + (on (<- red-explorer-vow) + (lambda (car-noise) + (async-channel-put result-ch `(ok ,car-noise)))))) + +(test-equal? + "Sending keyword arguments over CapTP works" + (sync/timeout 0.5 result-ch) + '(ok "a red fork explorer goes vroooom! beep"))