poke-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH 1/2] pickles: Add new pickle `unittest.pk`


From: Jose E. Marchesi
Subject: Re: [PATCH 1/2] pickles: Add new pickle `unittest.pk`
Date: Tue, 08 Dec 2020 09:51:27 +0100
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (gnu/linux)

Hi Mohammad.
Thanks for the patches.

> 2020-12-08  Mohammad-Reza Nabipoor  <m.nabipoor@yahoo.com>
>
>       * pickles/unittest.pk: New file.
>       * pickles/Makefile.am (dist_pickles_DATA): Add `unittest.pk`.
> ---
>
> Hi, Jose.
>
> This patch lacks the documentation for `unittest.pk`.
> I'd be very glad if you help with writing the documentation :)

What do you think about using utest as the canonical name for this?
i.e. utest.pk, utest_run, utest_run_exit, UTest, UTest_Fn, etc.

> +/* unittest.pk - Facilities to write unit tests for pickles.  */
> +
> +/* Copyright (C) 2020 The poke authors */
> +
> +/* This program is free software: you can redistribute it and/or modify
> + * it under the terms of the GNU General Public License as published by
> + * the Free Software Foundation, either version 3 of the License, or
> + * (at your option) any later version.
> + *
> + * This program 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 General Public License for more details.
> + *
> + * You should have received a copy of the GNU General Public License
> + * along with this program.  If not, see <http://www.gnu.org/licenses/>.
> + */
> +
> +type TestFn = (string) void;
> +type Test = struct
> +  {
> +    string name;
> +    TestFn func;
> +  };
> +
> +fun tests_run = (Test[] tests) int:
> +  {
> +    var ok = 1;
> +
> +    for (t in tests)
> +      {
> +        try t.func(t.name);
> +        catch (Exception ex)
> +          {
> +            ok = 0;
> +            printf "FAIL %s: %s\n", t.name, ex.msg;
> +            continue;
> +          }
> +        printf "PASS %s\n", t.name;
> +      }
> +
> +    return ok;
> +  }
> +fun tests_run_exit = (Test[] tests) void:
> +  {
> +    exit (tests_run (tests) ? 0 : 1);
> +  }

Is tests_run_exit really necessary?



reply via email to

[Prev in Thread] Current Thread [Next in Thread]