<?xml version="1.0" encoding="UTF-8"?><rss version="2.0" xmlns:content="http://purl.org/rss/1.0/modules/content/">
  <channel>
    <title>guilespec &amp;mdash; Jeko</title>
    <link>https://write.as/jeko/tag:guilespec</link>
    <description>Crafting happiness with Free Software &amp; Hardware</description>
    <pubDate>Thu, 27 Aug 2026 04:39:10 +0000</pubDate>
    <item>
      <title>Specification-based testing framework for Guile</title>
      <link>https://write.as/jeko/specification-based-testing-framework-for-guile?pk_campaign=rss-feed</link>
      <description>&lt;![CDATA[Guile Logo&#xA;&#xA;I like to write tests in a specification based fashion. So I started to work on Guile-Spec.&#xA;&#xA;At the time of writing this post, it&#39;s no more than a set of syntax-rules on top of SRFI-64.&#xA;&#xA;Let&#39;s see how it feels…&#xA;!--more--&#xA;Introductory tutorial&#xA;&#xA;Let&#39;s say I want to make sure I understand correctly the Guile API for lists.&#xA;&#xA;One basic test&#xA;&#xA;Here is a minimal program, with a Guile-Spec test suite, where I ensure the empty list is the empty list (you can never be too careful) :&#xA;(use-modules (spec))&#xA;&#xA;(install-spec-runner-term)&#xA;&#xA;(describe &#34;Guile API - Lists&#34;&#xA;  (it &#34;is null&#34;&#xA;    (should (null? &#39;()))))&#xA;It will produces the following ouput when interpreted :&#xA;$ guile --no-auto-compile t.scm&#xA;Guile API - Lists&#xA;    PASS is null&#xA;The test suite wants to be read as a conversation.&#xA;The describe form lets you tell what you are testing. It will contains your spec units (at least one) like the it form which contains the assertion (here a should form which accepts an expression that evaluates to a boolean).&#xA;&#xA;Hack on!&#xA;&#xA;You can try this example and hack on it ! You can try another predicate (i.e. list?) or another list (i.e. &#39;(1 2 3), maybe something more sophisticated) or change the names, etc. And see what happens !&#xA;&#xA;Troubleshoting&#xA;&#xA;You might encounter errors while hacking. Here are a few list with mighty reasons :&#xA;&#xA;This error tells you Guile-Spec is not installed on your system or is not it the GUILELOAD_PATH.&#xA;&#xA;ice-9/boot-9.scm:3329:6: In procedure resolve-interface:&#xA;no code for module (spec)&#xA;&#xA;This error tells you the it form is invalid. It should contain only one should.&#xA;&#xA;ice-9/boot-9.scm:1685:16: In procedure raise-exception:&#xA;Syntax error:&#xA;unknown file:66:6: source expression failed to match any pattern in form (it &#34;should not be false&#34; (should-not #f) (should-not #f))&#xA;&#xA;This error tells you (implicitely) the describe form is missing :&#xA;&#xA;ice-9/boot-9.scm:1685:16: In procedure raise-exception:&#xA;test-runner not initialized - test-begin missing?&#xA;&#xA;This is not an error but the indication that you forget to install the test runner from Guile-Spec :&#xA;&#xA;%%%% Starting test Guile API - Lists  (Writing full log to &#34;Guile API - Lists.log&#34;)&#xA;of expected passes      1&#xA;&#xA;Two tidy tests&#xA;&#xA;I want to continue to challenge my understanding of the Guile API (or do I want to challenge the Guile API?). So I&#39;m gonna add a test and explicit the common context between the two tests.&#xA;&#xA;(use-modules (spec))&#xA;&#xA;(install-spec-runner-term)&#xA;&#xA;(describe &#34;Guile API - Lists&#34;&#xA;  (context &#34;the empty list&#34;&#xA;    (it &#34;is null&#34;&#xA;      (should (null? &#39;())))&#xA;    (it &#34;is a list&#34;&#xA;      (should (list? &#39;())))))&#xA;It will produces the following ouput when interpreted :&#xA;$ guile --no-auto-compile t.scm&#xA;Guile API - Lists&#xA;the empty list&#xA;     PASS is null&#xA;     PASS is a list&#xA;&#xA;Thank you very much for reading this article!&#xA;&#xA;Don&#39;t hesitate to give me your opinion, suggest an idea for improvement, report an error, or ask a question ! I would be so glad to discuss about the topic covered here with you ! You can reach me here.&#xA;&#xA;Don&#39;t miss out on the next ones !&#xA;&#xA;And more importantly, share this blog and tell your friends it&#39;s the best blog in the history of Free Software! No kidding!&#xA;&#xA;#gnu #guile #tdd #guilespec #tutorial #english&#xA;]]&gt;</description>
      <content:encoded><![CDATA[<p><img src="https://upload.wikimedia.org/wikipedia/commons/thumb/b/b3/GNU-Guile-logo.svg/220px-GNU-Guile-logo.svg.png" alt="Guile Logo"/></p>

<p>I like to write tests in a specification based fashion. So I started to work on <a href="https://framagit.org/Jeko/guile-spec" rel="nofollow">Guile-Spec</a>.</p>

<p>At the time of writing this post, it&#39;s no more than a set of syntax-rules on top of SRFI-64.</p>

<p>Let&#39;s see how it feels…
</p>

<h2 id="introductory-tutorial">Introductory tutorial</h2>

<p>Let&#39;s say I want to make sure I understand correctly the <a href="https://www.gnu.org/software/guile/manual/html_node/Lists.html" rel="nofollow">Guile API for lists</a>.</p>

<h3 id="one-basic-test">One basic test</h3>

<p>Here is a minimal program, with a Guile-Spec test suite, where I ensure the empty list is the empty list (you can never be too careful) :</p>

<pre><code class="language-scheme">(use-modules (spec))

(install-spec-runner-term)

(describe &#34;Guile API - Lists&#34;
  (it &#34;is null&#34;
    (should (null? &#39;()))))
</code></pre>

<p>It will produces the following ouput when interpreted :</p>

<pre><code class="language-bash">$ guile --no-auto-compile t.scm
Guile API - Lists
    PASS is null
</code></pre>

<p>The test suite wants to be read as a conversation.
The <code>describe</code> form lets you tell what you are testing. It will contains your <em>spec units</em> (at least one) like the <code>it</code> form which contains the assertion (here a <code>should</code> form which accepts an expression that evaluates to a boolean).</p>

<h4 id="hack-on">Hack on!</h4>

<p>You can try this example and hack on it ! You can try another predicate (i.e. <code>list?</code>) or another list (i.e. <code>&#39;(1 2 3)</code>, maybe something more sophisticated) or change the names, etc. And see what happens !</p>

<h4 id="troubleshoting">Troubleshoting</h4>

<p>You might encounter errors while hacking. Here are a few list with mighty reasons :</p>
<ul><li>This error tells you Guile-Spec is not installed on your system or is not it the <code>GUILE_LOAD_PATH</code>.</li></ul>

<pre><code>ice-9/boot-9.scm:3329:6: In procedure resolve-interface:
no code for module (spec)
</code></pre>
<ul><li>This error tells you the <code>it</code> form is invalid. It should contain only one <code>should</code>.</li></ul>

<pre><code>ice-9/boot-9.scm:1685:16: In procedure raise-exception:
Syntax error:
unknown file:66:6: source expression failed to match any pattern in form (it &#34;should not be false&#34; (should-not #f) (should-not #f))
</code></pre>
<ul><li>This error tells you (implicitely) the <code>describe</code> form is missing :</li></ul>

<pre><code>ice-9/boot-9.scm:1685:16: In procedure raise-exception:
test-runner not initialized - test-begin missing?
</code></pre>
<ul><li>This is not an error but the indication that you forget to install the test runner from Guile-Spec :</li></ul>

<pre><code>%%%% Starting test Guile API - Lists  (Writing full log to &#34;Guile API - Lists.log&#34;)
# of expected passes      1
</code></pre>

<h3 id="two-tidy-tests">Two tidy tests</h3>

<p>I want to continue to challenge my understanding of the Guile API (or do I want to challenge the Guile API?). So I&#39;m gonna add a test and explicit the common context between the two tests.</p>

<pre><code class="language-scheme">(use-modules (spec))

(install-spec-runner-term)

(describe &#34;Guile API - Lists&#34;
  (context &#34;the empty list&#34;
    (it &#34;is null&#34;
      (should (null? &#39;())))
    (it &#34;is a list&#34;
      (should (list? &#39;())))))
</code></pre>

<p>It will produces the following ouput when interpreted :</p>

<pre><code class="language-bash">$ guile --no-auto-compile t.scm
Guile API - Lists
- the empty list
     PASS is null
     PASS is a list
</code></pre>

<p><em>Thank you very much for reading this article!</em></p>

<p><em>Don&#39;t hesitate to give me your opinion, suggest an idea for improvement, report an error, or ask a question ! I would be so glad to discuss about the topic covered here with you ! You can reach me <a href="https://linktr.ee/jeko" rel="nofollow">here</a>.</em></p>

<p><em>Don&#39;t miss out on the next ones !</em></p>

<p><em>And more importantly, share this blog and tell your friends it&#39;s the best blog in the history of Free Software! No kidding!</em></p>

<p><a href="https://write.as/jeko/tag:gnu" class="hashtag" rel="nofollow"><span>#</span><span class="p-category">gnu</span></a> <a href="https://write.as/jeko/tag:guile" class="hashtag" rel="nofollow"><span>#</span><span class="p-category">guile</span></a> <a href="https://write.as/jeko/tag:tdd" class="hashtag" rel="nofollow"><span>#</span><span class="p-category">tdd</span></a> <a href="https://write.as/jeko/tag:guilespec" class="hashtag" rel="nofollow"><span>#</span><span class="p-category">guilespec</span></a> <a href="https://write.as/jeko/tag:tutorial" class="hashtag" rel="nofollow"><span>#</span><span class="p-category">tutorial</span></a> <a href="https://write.as/jeko/tag:english" class="hashtag" rel="nofollow"><span>#</span><span class="p-category">english</span></a></p>
]]></content:encoded>
      <guid>https://write.as/jeko/specification-based-testing-framework-for-guile</guid>
      <pubDate>Wed, 02 Feb 2022 16:42:25 +0000</pubDate>
    </item>
  </channel>
</rss>