[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: SRFI 64: How do I create a test-runner stub
From: |
Christopher Lam |
Subject: |
Re: SRFI 64: How do I create a test-runner stub |
Date: |
Thu, 7 Mar 2019 23:40:05 +0000 |
Hi
In gnucash I've resorted to writing my own srfi-64 test-runner. See the
entry point at (run-test-proper) at
https://github.com/Gnucash/gnucash/blob/maint/gnucash/report/standard-reports/test/test-transaction.scm
Its definition is at
https://github.com/Gnucash/gnucash/blob/maint/libgnucash/engine/test/srfi64
-extras.scm and takes care of both returning #f if any test fails, and also
doing an IMHO better job at logging tests.
On Thu, 7 Mar 2019 at 21:03, sirgazil <address@hidden> wrote:
> Hello,
>
> I'm trying to implement a procedure that takes a test-runner object and
> returns a string with information about the most recently run test. For
> example, calling
>
> (format-test-result (make-runner #:test-name "A is not B."
> #:result-kind 'fail))
>
> is expected to return:
>
> ✖ FAIL A is not B.
>
> In the example, `make-runner` is a procedure that is supposed to create
> a test-runner stub with the given values, so that I can test the
> `format-test-result` procedure.
>
> I thought I could define `make-runner` body like this:
>
> (let ((runner-stub (test-runner-null)))
> (test-runner-test-name! runner-stub test-name)
> (test-result-set! runner-stub 'result-kind result-kind)
> stub-runner))
>
> The problem is, the `test-runner-test-name!` setter does not exist. And
> test-runner objects don't seem to have a `test-name` slot. They do
> provide a `test-runner-test-name` getter, though.
>
> So I don't know how to create a test-runner stub to test my procedure.
>
> What would you do in this case?
>
>
> --
> Luis Felipe López Acevedo
> http://sirgazil.bitbucket.io/
>
>
>
>