poke-devel
[Top][All Lists]
Advanced

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

Re: [PATCH 2/2] testsuite,pickles: Re-write test for pickles using `unit


From: Jose E. Marchesi
Subject: Re: [PATCH 2/2] testsuite,pickles: Re-write test for pickles using `unittest.pk`
Date: Tue, 08 Dec 2020 10:09:22 +0100
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (gnu/linux)

Hi Mohammad.

> 2020-12-08  Mohammad-Reza Nabipoor  <m.nabipoor@yahoo.com>
>
>       * testsuite/poke.pickles/argp.test.pk: New unit test.
>       * testsuite/poke.pickles/color.test.pk: Likewise.
>       * testsuite/poke.pickles/id3v1.test.pk: Likewise.
>       * testsuite/poke.pickles/rgb24.test.pk: Likewise.
>       * testsuite/poke.pickles/std.test.pk: Likewise.
>       * testsuite/poke.argp/: Remove test directory.
>       * testsuite/poke.color/: Likewise.
>       * testsuite/poke.id3v1/: Likewise.
>       * testsuite/poke.rgb24/: Likewise.
>       * testsuite/poke.std/: Likewise.
>       * testsuite/Makefile.am: Add new unit tests and remove old tests.

The std.pk file is not really a pickle, so I don't think its tests
pertain in a poke.pickles testsuite.

Also, what do you think about using FOO-test.pk instead of FOO.test.pk?
That will avoid problems in dumb systems not supporting having more than
one dot in filenames.


>       * pickles/color.pk: Use `assert` for integrity check.
>       * pickles/rgb24.pk: Likewise.

These changes are unrelated to unit testing.  Please submit these in a
separated patch :)

Other than that, I LOVE the approach :D

The dejagnu tests should be restricted to the basic language features.
Everything written in Poke should be tested using this new test harness.

Comments:

1) Is the counting of PASS/FAIL correct?  Have you tried to make a
   single test fail and see if the total # of pass tests is the expected
   one?

2) What about XFAIL, XPASS and the like.  Right now the test harness
   catches E_assert and assumes it is a fail, but we have to cover the
   other possibilities too.  We need to find a way to convey that
   information to the test harness.  I have a change for the Exception
   struct in mind, to put the location information in its own field
   instead of `msg'.  But for now we are ok with just FAIL and PASS.

> diff --git a/testsuite/poke.pickles/id3v1.test.pk 
> b/testsuite/poke.pickles/id3v1.test.pk
> new file mode 100644
> index 00000000..f9e0425b
> --- /dev/null
> +++ b/testsuite/poke.pickles/id3v1.test.pk
> @@ -0,0 +1,69 @@
> +
> +load unittest;
> +load id3v1;
> +
> +var data = open ("*data*");
> +
> +uint<8>[128] @ data : 0#B = [
> +  0x54UB, 0x41UB, 0x47UB, 0x30UB, 0x31UB, 0x20UB, 0x2dUB, 0x20UB, 0x45UB,
> +  0x63UB, 0x6cUB, 0x69UB, 0x70UB, 0x73UB, 0x65UB, 0x20UB, 0x44UB, 0x65UB,
> +  0x20UB, 0x4dUB, 0x61UB, 0x72UB, 0x20UB, 0x20UB, 0x20UB, 0x20UB, 0x20UB,
> +  0x20UB, 0x20UB, 0x20UB, 0x20UB, 0x20UB, 0x20UB, 0x4aUB, 0x6fUB, 0x61UB,
> +  0x71UB, 0x75UB, 0x69UB, 0x6eUB, 0x20UB, 0x53UB, 0x61UB, 0x62UB, 0x69UB,
> +  0x6eUB, 0x61UB, 0x20UB, 0x20UB, 0x20UB, 0x20UB, 0x20UB, 0x20UB, 0x20UB,
> +  0x20UB, 0x20UB, 0x20UB, 0x20UB, 0x20UB, 0x20UB, 0x20UB, 0x20UB, 0x20UB,
> +  0x4dUB, 0x65UB, 0x6eUB, 0x74UB, 0x69UB, 0x72UB, 0x61UB, 0x73UB, 0x20UB,
> +  0x50UB, 0x69UB, 0x61UB, 0x64UB, 0x6fUB, 0x73UB, 0x61UB, 0x73UB, 0x20UB,
> +  0x20UB, 0x20UB, 0x20UB, 0x20UB, 0x20UB, 0x20UB, 0x20UB, 0x20UB, 0x20UB,
> +  0x20UB, 0x20UB, 0x20UB, 0x31UB, 0x39UB, 0x38UB, 0x30UB, 0x76UB, 0x65UB,
> +  0x72UB, 0x79UB, 0x20UB, 0x67UB, 0x6fUB, 0x6fUB, 0x64UB, 0x20UB, 0x73UB,
> +  0x6fUB, 0x6eUB, 0x67UB, 0x20UB, 0x20UB, 0x20UB, 0x20UB, 0x20UB, 0x20UB,
> +  0x20UB, 0x20UB, 0x20UB, 0x20UB, 0x20UB, 0x20UB, 0x20UB, 0x20UB, 0x00UB,
> +  0x01UB, 0x11UB
> +];
> +
> +var tests = [
> +  Test {
> +    name = "retrieve info",
> +    func = lambda (string name) void:
> +      {
> +        var tag = ID3V1_Tag @ data : 0#B;
> +
> +        assert (tag.id == ['T','A','G']);
> +        assert (tag.get_title == "01 - Eclipse De Mar");
> +        assert (tag.get_artist == "Joaquin Sabina");
> +        assert (tag.get_album == "Mentiras Piadosas");
> +        assert (tag.get_year == 1980);
> +        assert (tag.get_genre == "rock");
> +        assert (tag.get_comment == "very good song");
> +      },
> +  },

Nifty! :)

It was very clever to include the 128 bound in the array type in order
to detect careless editing of the data.



reply via email to

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