poke-devel
[Top][All Lists]
Advanced

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

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


From: Mohammad-Reza Nabipoor
Subject: [PATCH 1/2] pickles: Add new pickle `unittest.pk`
Date: Tue, 8 Dec 2020 04:44:46 +0330

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 :)


Regards,
Mohammad-Reza


 ChangeLog           |  5 +++++
 pickles/Makefile.am |  2 +-
 pickles/unittest.pk | 47 +++++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 53 insertions(+), 1 deletion(-)
 create mode 100644 pickles/unittest.pk

diff --git a/ChangeLog b/ChangeLog
index ae7bb406..1573b124 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+2020-12-08  Mohammad-Reza Nabipoor  <m.nabipoor@yahoo.com>
+
+       * pickles/unittest.pk: New file.
+       * pickles/Makefile.am (dist_pickles_DATA): Add `unittest.pk`.
+
 2020-12-06  Jose E. Marchesi  <jemarch@gnu.org>
 
        * libpoke/pkl-asm.pks (eqa): Fix lexical context handling when the
diff --git a/pickles/Makefile.am b/pickles/Makefile.am
index aece5326..a9112f0b 100644
--- a/pickles/Makefile.am
+++ b/pickles/Makefile.am
@@ -2,4 +2,4 @@ picklesdir = $(pkgdatadir)/pickles
 dist_pickles_DATA = elf.pk ctf.pk leb128.pk bpf.pk btf.pk bmp.pk \
                     color.pk rgb24.pk id3v1.pk \
                     dwarf.pk dwarf-common.pk dwarf-frame.pk dwarf-pubnames.pk \
-                    dwarf-types.pk time.pk argp.pk
+                    dwarf-types.pk time.pk argp.pk unittest.pk
diff --git a/pickles/unittest.pk b/pickles/unittest.pk
new file mode 100644
index 00000000..a3a9b044
--- /dev/null
+++ b/pickles/unittest.pk
@@ -0,0 +1,47 @@
+/* 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);
+  }
-- 
2.29.2



reply via email to

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