<?xml version="1.0" encoding="UTF-8"?><rss version="2.0" xmlns:content="http://purl.org/rss/1.0/modules/content/">
  <channel>
    <title>femtounit — Paolo Amoroso&#39;s Journal</title>
    <link>https://journal.paoloamoroso.com/tag:femtounit</link>
    <description>Tech projects, hobby programming, and geeky thoughts of Paolo Amoroso</description>
    <pubDate>Tue, 24 Nov 2026 00:37:44 +0000</pubDate>
    <image>
      <url>https://i.snap.as/68i8povn.jpg</url>
      <title>femtounit — Paolo Amoroso&#39;s Journal</title>
      <link>https://journal.paoloamoroso.com/tag:femtounit</link>
    </image>
    <item>
      <title>A fix for duplicate definitions in Femtounit</title>
      <link>https://journal.paoloamoroso.com/a-fix-for-duplicate-definitions-in-femtounit?pk_campaign=rss-feed</link>
      <description>I finally fixed a longstanding duplicate definitions issue with Femtounit, my Interlisp unit test framework. Femtounit creates a new File...</description>
      <content:encoded><![CDATA[<p>I finally fixed a longstanding duplicate definitions issue with <a href="https://github.com/pamoroso/femtounit">Femtounit</a>, my <a href="https://interlisp.org">Interlisp</a> unit test framework.</p>

<p><a href="https://journal.paoloamoroso.com/integrating-femtounit-with-the-file-manager-and-sedit">Femtounit creates a new File Manager type</a> for unit tests, <code>TESTS</code>. <code>DEFTEST</code>, which defines a test, adds an entry of type <code>TESTS</code> and expands into an internal function that carries out the test when called. The problem was <a href="https://journal.paoloamoroso.com/the-downside-of-adding-a-file-manager-type-to-femtounit">the File Manager noticed and tracked two objects</a> for each <code>DEFTEST</code>, the <code>TESTS</code> entry and the function. But the function is an implementation detail that shouldn&#39;t be tracked by the File Manager or seen directly by the user.</p>

<p>To fix the issue, in the <code>DEFDEFINER</code> that creates the new type I <a href="https://github.com/pamoroso/femtounit/blob/18bc3a1f163925ec59fd1449717085169870d4bd/FEMTOUNIT#L63">added a call</a> to <code>UNMARKASCHANGED</code> immediately after the definition of the internal function. <code>UNMARKASCHANGED</code> undoes the association with the File Manager the creation of the internal function establishes. I had tried <code>DELDEF</code> but it removes both the association and the internal function.</p>

<p>I also refactored the definition of the internal function to use <code>DEFINEQ</code> instead of assigning a <code>LAMBDA</code> to the function cell of the symbol naming the test, which is less clear and obscures the intent.</p>

<p><a href="https://journal.paoloamoroso.com/tag:femtounit" class="hashtag"><span>#</span><span class="p-category">femtounit</span></a> <a href="https://journal.paoloamoroso.com/tag:Interlisp" class="hashtag"><span>#</span><span class="p-category">Interlisp</span></a> <a href="https://journal.paoloamoroso.com/tag:Lisp" class="hashtag"><span>#</span><span class="p-category">Lisp</span></a></p>

<p><a href="https://remark.as/p/journal.paoloamoroso.com/a-fix-for-duplicate-definitions-in-femtounit">Discuss...</a>
<a href="mailto:info@paoloamoroso.com?subject=Reply%20to%20Paolo%20Amoroso%27s%20Journal">Email</a> | Reply <a href="/@/amoroso@oldbytes.space" class="u-url mention">@<span>amoroso@oldbytes.space</span></a></p>


]]></content:encoded>
      <guid>https://journal.paoloamoroso.com/a-fix-for-duplicate-definitions-in-femtounit</guid>
      <pubDate>Sat, 23 Mar 2024 11:38:44 +0000</pubDate>
    </item>
    <item>
      <title>The downside of adding a File Manager type to Femtounit</title>
      <link>https://journal.paoloamoroso.com/the-downside-of-adding-a-file-manager-type-to-femtounit?pk_campaign=rss-feed</link>
      <description>I integrated Femtounit with the File Manager by defining the new type TESTS for Femtounit tests and redefining DEFTEST in terms of it. It...</description>
      <content:encoded><![CDATA[<p>I <a href="https://journal.paoloamoroso.com/integrating-femtounit-with-the-file-manager-and-sedit">integrated Femtounit with the File Manager</a> by defining the new type <code>TESTS</code> for Femtounit tests and redefining <code>DEFTEST</code> in terms of it.</p>

<p>It turns out it&#39;s not a good idea as the tests get duplicated. The <code>DEFTEST</code> macro expands into a <code>DEFINEQ</code> function definition and the File Manager notices both, the <code>DEFTEST</code> form of type <code>TESTS</code> and the function of type <code>FNS</code>.</p>

<p>The fix seemed simple, assigning tests to an existing type such as <code>FNS</code>. First I removed <code>TESTS</code> with <code>(DELDEF &#39;TESTS &#39;DEFINE-TYPES)</code>, then replaced the type argument <code>TESTS</code> with <code>FNS</code> in the <code>XCL:DEFDEFINER</code> form. But when I tried to edit a sample test <code>TEST.PLUS</code> for the <code>PLUS</code> function with <code>(ED &#39;TEST.PLUS :DONTWAIT)</code>, SEdit quit with the error:</p>

<pre><code>Warning: Couldn&#39;t find a hash-table for FNS definitions.
One will be created.
Could not find fns definition for TEST.PLUS.
Could not find fns definition for
TEST.PLUS
</code></pre>

<p>Back to the drawing board.</p>

<p><a href="https://journal.paoloamoroso.com/tag:femtounit" class="hashtag"><span>#</span><span class="p-category">femtounit</span></a> <a href="https://journal.paoloamoroso.com/tag:Interlisp" class="hashtag"><span>#</span><span class="p-category">Interlisp</span></a> <a href="https://journal.paoloamoroso.com/tag:Lisp" class="hashtag"><span>#</span><span class="p-category">Lisp</span></a></p>

<p><a href="https://remark.as/p/journal.paoloamoroso.com/the-downside-of-adding-a-file-manager-type-to-femtounit">Discuss...</a>
<a href="mailto:info@paoloamoroso.com?subject=Reply%20to%20Paolo%20Amoroso%27s%20Journal">Email</a> | Reply <a href="/@/amoroso@oldbytes.space" class="u-url mention">@<span>amoroso@oldbytes.space</span></a></p>


]]></content:encoded>
      <guid>https://journal.paoloamoroso.com/the-downside-of-adding-a-file-manager-type-to-femtounit</guid>
      <pubDate>Sat, 26 Aug 2023 12:00:43 +0000</pubDate>
    </item>
    <item>
      <title>Integrating Femtounit with the File Manager and SEdit</title>
      <link>https://journal.paoloamoroso.com/integrating-femtounit-with-the-file-manager-and-sedit?pk_campaign=rss-feed</link>
      <description>I integrated Femtounit, my Interlisp unit test framework, with the File Manager and the SEdit structure editor. To achieve this I defined...</description>
      <content:encoded><![CDATA[<p>I integrated <a href="https://journal.paoloamoroso.com/tag:femtounit">Femtounit</a>, my <a href="https://interlisp.org">Interlisp</a> unit test framework, with the File Manager and the SEdit structure editor.</p>

<p>To achieve this I defined the new File Manager type <code>TESTS</code> for Femtounit tests and redefined <code>DEFTEST</code> in terms of it, then tweaked the code formatting of tests in SEdit. Now the system notices and keeps track of new and modified tests.</p>

<p>Here&#39;s the File Manager type menu, which SEdit pops up when opening a test, with the <code>DEFTEST</code> option highlighted under <code>TESTS</code>:</p>

<p><a href="https://i.snap.as/ukRW3ih5.png"><img src="https://i.snap.as/ukRW3ih5.png" alt="Interlisp File Manager menu with the Femtounit types."/></a></p>

<p>Also, now SEdit handles and properly formats test definitions like this of a function <code>SQUARE</code> to compute the square of its argument:</p>

<p><a href="https://i.snap.as/7KyJ6fc9.png"><img src="https://i.snap.as/7KyJ6fc9.png" alt="SEdit editing a Femtounit unit test definition on Interlisp."/></a></p>

<p>Implementing the new features was much easier than expected.</p>

<p>The traditional way of adding types to the File Manager, described in the <em>Interlisp Reference Manual</em>, involves writing a dozen functions for most of which it&#39;s not clear how they&#39;re supposed to work. Medley 1.0 added support for two easy to use File Manager type defining forms that replace all that, <code>XCL:DEF-DEFINE-TYPE</code> and <code>XCL:DEFDEFINER</code>. This code is all it took for Femtounit&#39;s new <code>TESTS</code> type:</p>

<pre><code class="language-lisp">(XCL:DEF-DEFINE-TYPE TESTS &#34;Femtounit unit tests&#34;)

(XCL:DEFDEFINER (DEFTEST (:PROTOTYPE
                            (LAMBDA (NAME)
                              (AND (LITATOM NAME)
                                   `(DEFTEST ,NAME (&#34;Arg List&#34;)
                                      &#34;Body&#34;)))))
                TESTS
                (NAME PARAMETERS &amp;BODY BODY)
   `(DEFINEQ (,NAME ,PARAMETERS
      (LET ((FTU.TEST.NAME (APPEND FTU.TEST.NAME (LIST &#39;,NAME]
        ,@BODY))))
</code></pre>

<p>This additional tweak makes SEdit format and indent <code>DEFTEST</code> unit test definitions the same way as <code>DEFUN</code> function definitions in Common Lisp:</p>

<pre><code class="language-lisp">(SEDIT:DEF-LIST-FORMAT DEFTEST CL:DEFUN)
</code></pre>

<p>The simplified process is not discussed in the <em>Interlisp Reference Manual</em>, where I&#39;d have expected, but in a more obscure source, the <a href="http://www.bitsavers.org/pdf/xerox/interlisp-d/198809_Medley_1.0/400006_Lisp_Release_Notes_Medley_Release_1.0_Sep88.pdf">Medley 1.0 release notes</a> from page 52 of the PDF document. My proactive reading of all the documentation paid off as it let me spot such crucial information and save a lot of work.</p>

<p><a href="https://journal.paoloamoroso.com/tag:femtounit" class="hashtag"><span>#</span><span class="p-category">femtounit</span></a> <a href="https://journal.paoloamoroso.com/tag:Interlisp" class="hashtag"><span>#</span><span class="p-category">Interlisp</span></a> <a href="https://journal.paoloamoroso.com/tag:Lisp" class="hashtag"><span>#</span><span class="p-category">Lisp</span></a></p>

<p><a href="https://remark.as/p/journal.paoloamoroso.com/integrating-femtounit-with-the-file-manager-and-sedit">Discuss...</a>
<a href="mailto:info@paoloamoroso.com?subject=Reply%20to%20Paolo%20Amoroso%27s%20Journal">Email</a> | Reply <a href="/@/amoroso@oldbytes.space" class="u-url mention">@<span>amoroso@oldbytes.space</span></a></p>


]]></content:encoded>
      <guid>https://journal.paoloamoroso.com/integrating-femtounit-with-the-file-manager-and-sedit</guid>
      <pubDate>Mon, 21 Aug 2023 09:41:51 +0000</pubDate>
    </item>
    <item>
      <title>Femtounit, a unit test framework for Interlisp</title>
      <link>https://journal.paoloamoroso.com/femtounit-a-unit-test-framework-for-interlisp?pk_campaign=rss-feed</link>
      <description>Medley is a rich development environment but it&#39;s missing a test framework. Or so I thought. To fill the supposed gap I wrote Femtounit, ...</description>
      <content:encoded><![CDATA[<p><a href="https://interlisp.org">Medley</a> is a rich development environment but it&#39;s missing a test framework. Or so I thought. To fill the supposed gap I wrote <a href="https://github.com/pamoroso/femtounit">Femtounit</a>, a tiny — hence femto — unit test framework for Interlisp.</p>

<p>I wanted a small framework simple to port to or write for Interlisp, yet useful in practice. At less than a couple dozen lines of code, Femtounit took very little effort to design and write as it&#39;s based on the PCL test framework <a href="https://gigamonkeys.com">Peter Seibel</a> described in <a href="https://gigamonkeys.com/book/practical-building-a-unit-test-framework.html">Chapter 9</a> of his book <a href="https://gigamonkeys.com/book"><em>Practical Common Lisp</em></a>.</p>

<p>I reused much of Peter&#39;s design and code, adapting it to Interlisp and tweaking the reporting of tests. Femtounit outputs a single period character for every passed test, unlike the full report his framework prints.</p>

<p>Using Femtounit looks like this:</p>

<p><a href="https://i.snap.as/nSAgOZwc.png"><img src="https://i.snap.as/nSAgOZwc.png" alt="Usage of the Femtounit unit test framework for Interlisp."/></a></p>

<p>Suppose you want to test this function that returns the square of its argument:</p>

<pre><code class="language-lisp">(DEFINEQ (SQUARE (X) (TIMES X X)))
</code></pre>

<p>You may define a <code>TEST.SQUARE</code> test function like this:</p>

<pre><code class="language-lisp">(DEFTEST TEST.SQUARE ()
  (CHECK.EXPECT (EQP (SQUARE 1) 1)
                (EQP (SQUARE 2) 4)
                (EQP (SQUARE 3) 9)
                (EQP (SQUARE 4) 16)))
</code></pre>

<p>To run the tests, just call the function:</p>

<pre><code class="language-lisp">(TEST.SQUARE)
</code></pre>

<p>which will print a period character for every passed test:</p>

<pre><code>....
</code></pre>

<p>Some documentation is at the <a href="https://github.com/pamoroso/femtounit">project repo</a>.</p>

<p>After I finished the initial code of Femtounit, <a href="https://groups.google.com/g/interlisp/c/g6CZ3DnURvU/m/4QHeZMvLAQAJ">Larry Masinter pointed out Medley does have a test framework</a>, and quite an advanced one. This system, which the Medley documentation simply calls <em>test system</em> and is much more than a framework, was originally designed to test Interlisp and its environment. <a href="https://github.com/Interlisp/test/tree/master/tools">The code</a> is now in one of the Medley repos.</p>

<p>I thought I explored every nook and cranny of Medley and its documentation, yet I missed the test system. The system is interesting in itself and I&#39;ll use it for most of my code.</p>

<p>But Femtounit is a fun little learning project I still want to proceed with. It&#39;ll teach me how to integrate the framework with Interlisp for editing unit test definitions with the <a href="https://journal.paoloamoroso.com/demonstrating-interlisp-structure-editing">SEdit structure editor</a>, as well as saving the definitions to files and managing them with the <code>make</code>-like File Manager tool.</p>

<p><a href="https://journal.paoloamoroso.com/tag:femtounit" class="hashtag"><span>#</span><span class="p-category">femtounit</span></a> <a href="https://journal.paoloamoroso.com/tag:Interlisp" class="hashtag"><span>#</span><span class="p-category">Interlisp</span></a> <a href="https://journal.paoloamoroso.com/tag:Lisp" class="hashtag"><span>#</span><span class="p-category">Lisp</span></a></p>

<p><a href="https://remark.as/p/journal.paoloamoroso.com/femtounit-a-unit-test-framework-for-interlisp">Discuss...</a>
<a href="mailto:info@paoloamoroso.com?subject=Reply%20to%20Paolo%20Amoroso%27s%20Journal">Email</a> | Reply <a href="/@/amoroso@oldbytes.space" class="u-url mention">@<span>amoroso@oldbytes.space</span></a></p>


]]></content:encoded>
      <guid>https://journal.paoloamoroso.com/femtounit-a-unit-test-framework-for-interlisp</guid>
      <pubDate>Tue, 06 Jun 2023 09:37:27 +0000</pubDate>
    </item>
  </channel>
</rss>