Modify all tests to use the Test::Simple lib

All tests now use the Test::Simple library.  We keep the distinction between
pl (pure perl) and plt (perl + Test::Simple) in case someone wants to write a
perl tests without this lib.

- t/pm/*: All tests now use the plt extension and the Test::Simple library.
- t/pm/CondStack.pl: Remove it as it was not well built and the test results
  were false.
diff --git a/t/list-of-tests.mk b/t/list-of-tests.mk
index c91bd8c..c4e3844 100644
--- a/t/list-of-tests.mk
+++ b/t/list-of-tests.mk
@@ -34,19 +34,17 @@
 t/remake-m4-pr10111.sh
 
 perl_tap_TESTS = \
-t/pm/File.plt
-
-perl_TESTS = \
-t/pm/Channels.pl \
-t/pm/Condition.pl \
-t/pm/Condition-t.pl \
-t/pm/CondStack.pl \
-t/pm/DisjConditions.pl \
-t/pm/DisjConditions-t.pl \
-t/pm/General.pl \
-t/pm/Utils.pl \
-t/pm/Version.pl \
-t/pm/Wrap.pl
+t/pm/Channels.plt \
+t/pm/Condition.plt \
+t/pm/Condition-t.plt \
+t/pm/DisjConditions.plt \
+t/pm/DisjConditions-t.plt \
+t/pm/File.plt \
+t/pm/General.plt \
+t/pm/SilentRules.plt \
+t/pm/Utils.plt \
+t/pm/Version.plt \
+t/pm/Wrap.plt
 
 perf_TESTS = \
 t/perf/cond.sh \
diff --git a/t/pm/Channels.pl b/t/pm/Channels.plt
similarity index 91%
rename from t/pm/Channels.pl
rename to t/pm/Channels.plt
index b7d0b0a..4014ebf 100644
--- a/t/pm/Channels.pl
+++ b/t/pm/Channels.plt
@@ -1,3 +1,4 @@
+# -*- mode:perl -*-
 # Copyright (C) 2018  Matthias Paulmier
 
 # This program is free software; you can redistribute it and/or
@@ -17,10 +18,10 @@
 
 use Automake::Channels;
 use Automake::Location;
+use Test::Simple tests => 1;
 
 eval { msg ('test-fatal', new Automake::Location ('.'), "Test Message") };
 
 warn $@ if $@;
 
-exit 0 if $@;
-exit 1;
+ok ($@, "Test fatal error");
diff --git a/t/pm/CondStack.pl b/t/pm/CondStack.pl
deleted file mode 100644
index 5e28e69..0000000
--- a/t/pm/CondStack.pl
+++ /dev/null
@@ -1,76 +0,0 @@
-# Copyright (C) 2018  Free Software Foundation, Inc.
-
-# 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 2
-# 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/>.
-
-use Automake::CondStack;
-use Automake::Condition qw (TRUE FALSE);
-use Automake::Location;
-
-# The different test cases.  What happens with IF alone?
-my @tests = (['IF', 'ELSE', 'ENDIF'],
-	     ['ELSE', 'ENDIF'],
-	     ['IF', 'ENDIF'],
-	     ['ENDIF'],
-	     ['IF', 'ELSE', 'IF', 'ELSE', 'ENDIF']);
-
-my @exp_res = (0, 1, 0, 1, 0);
-
-my $where = new Automake::Location "/dev/null:0";
-
-sub test_cond_stack ()
-{
-  my @real_res = ();
-  for (@tests)
-    {
-      # Reset conditional stack for each test case
-      @cond_stack = ();
-      my $res = 0;
-      my $else_called = 0;
-      for my $test (@$_)
-        {
-	  if ($test eq 'IF')
-	    {
-	      cond_stack_if (undef, 'FALSE', $where);
-	    }
-	  if ($test eq 'ELSE')
-            {
-              $else_called = 1;
-	      if (cond_stack_else ('!', 'FALSE', $where) == FALSE)
-		{
-		  $res = 1;
-		  last;
-		}
-	    }
-	  if ($test eq 'ENDIF')
-            {
-              my $cond = ($else_called ? TRUE : FALSE);
-	      if (cond_stack_else (undef, undef, $where) == $cond)
-                {
-		  $res = 1;
-		  last;
-		}
-	    }
-        }
-      push @real_res, $res;
-    }
-  print "@real_res\n";
-  print "@exp_res\n";
-  for my $i (0 .. $#exp_res)
-    {
-      return 1 if $real_res[$i] ne $exp_res[$i];
-    }
-  return 0;
-}
-
-exit (test_cond_stack);
diff --git a/t/pm/Condition-t.pl b/t/pm/Condition-t.plt
similarity index 96%
rename from t/pm/Condition-t.pl
rename to t/pm/Condition-t.plt
index 18d30ea..364230d 100644
--- a/t/pm/Condition-t.pl
+++ b/t/pm/Condition-t.plt
@@ -1,3 +1,4 @@
+# -*- mode:perl -*-
 # Copyright (C) 2001-2018 Free Software Foundation, Inc.
 #
 # This program is free software; you can redistribute it and/or modify
@@ -28,6 +29,7 @@
     }
 }
 use Automake::Condition qw/TRUE FALSE/;
+use Test::Simple tests => 5;
 
 sub test_basics ()
 {
@@ -303,8 +305,8 @@
   return 0;
 }
 
-exit (test_basics
-      || test_true_when
-      || test_reduce_and
-      || test_reduce_or
-      || test_merge);
+ok (test_basics == 0, 'Test basic conditions');
+ok (test_true_when == 0, 'Test implied conditions when declaring a new one');
+ok (test_reduce_and == 0, 'Test "and" reduction');
+ok (test_reduce_or == 0, 'Test "or" reduction');
+ok (test_merge == 0, 'Test the merge method');
diff --git a/t/pm/Condition.pl b/t/pm/Condition.plt
similarity index 95%
rename from t/pm/Condition.pl
rename to t/pm/Condition.plt
index 58f89b3..c019b5f 100644
--- a/t/pm/Condition.pl
+++ b/t/pm/Condition.plt
@@ -1,3 +1,4 @@
+# -*- mode:perl -*-
 # Copyright (C) 2001-2018 Free Software Foundation, Inc.
 #
 # This program is free software; you can redistribute it and/or modify
@@ -14,6 +15,7 @@
 # along with this program.  If not, see <https://www.gnu.org/licenses/>.
 
 use Automake::Condition qw/TRUE FALSE/;
+use Test::Simple tests => 6;
 
 sub test_basics ()
 {
@@ -262,7 +264,6 @@
   my $cond1 = new Automake::Condition ('TRUE');
   eval { new Automake::Condition ($cond1) };
 
-  warn $@ if $@;
   $failed = 1 unless $@;
   $@ = '';
 
@@ -271,14 +272,13 @@
   my $cond2 = new Automake::Condition ("COND1_TRUE");
   eval { new Automake::Condition ("$cond2") };
 
-  warn $@ if $@;
   $failed = 1 unless $@;
   return $failed;
 }
 
-exit (test_basics
-      || test_true_when
-      || test_reduce_and
-      || test_reduce_or
-      || test_merge
-      || test_bad_declarations);
+ok (test_basics == 0, 'Test basic conditions');
+ok (test_true_when == 0, 'Test implied conditions when declaring a new one');
+ok (test_reduce_and == 0, 'Test "and" reduction');
+ok (test_reduce_or == 0, 'Test "or" reduction');
+ok (test_merge == 0, 'Test the merge method');
+ok (test_bad_declarations == 0, 'Test bad condition declarations');
diff --git a/t/pm/DisjConditions-t.pl b/t/pm/DisjConditions-t.plt
similarity index 97%
rename from t/pm/DisjConditions-t.pl
rename to t/pm/DisjConditions-t.plt
index 33c6c2d..976d7a8 100644
--- a/t/pm/DisjConditions-t.pl
+++ b/t/pm/DisjConditions-t.plt
@@ -1,3 +1,4 @@
+# -*- mode:perl -*-
 # Copyright (C) 2001-2018 Free Software Foundation, Inc.
 #
 # This program is free software; you can redistribute it and/or modify
@@ -29,6 +30,7 @@
 }
 use Automake::Condition qw/TRUE FALSE/;
 use Automake::DisjConditions;
+use Test::Simple tests => 5;
 
 sub test_basics ()
 {
@@ -437,8 +439,8 @@
   return $failed;
 }
 
-exit (test_basics
-      || test_invert
-      || test_simplify
-      || test_sub_conditions
-      || test_ambig);
+ok (test_basics == 0, 'Basic tests');
+ok (test_invert == 0, 'Test inverts');
+ok (test_simplify == 0, 'Test condition simplifications');
+ok (test_sub_conditions == 0, 'Test sub conditions');
+ok (test_ambig == 0, 'Test ambiguous conditions');
diff --git a/t/pm/DisjConditions.pl b/t/pm/DisjConditions.plt
similarity index 96%
rename from t/pm/DisjConditions.pl
rename to t/pm/DisjConditions.plt
index bdcafd2..c5ec25b 100644
--- a/t/pm/DisjConditions.pl
+++ b/t/pm/DisjConditions.plt
@@ -1,3 +1,4 @@
+# -*- mode:perl -*-
 # Copyright (C) 2001-2018 Free Software Foundation, Inc.
 #
 # This program is free software; you can redistribute it and/or modify
@@ -15,6 +16,7 @@
 
 use Automake::Condition qw/TRUE FALSE/;
 use Automake::DisjConditions;
+use Test::Simple tests => 6;
 
 sub test_basics ()
 {
@@ -403,9 +405,9 @@
   return $failed;
 }
 
-exit (test_basics
-      || test_invert
-      || test_simplify
-      || test_sub_conditions
-      || test_ambig
-      || test_bad_declarations);
+ok (test_basics == 0, 'Basic tests');
+ok (test_invert == 0, 'Test inverts');
+ok (test_simplify == 0, 'Test condition simplifications');
+ok (test_sub_conditions == 0, 'Test sub conditions');
+ok (test_ambig == 0, 'Test ambiguous conditions');
+ok (test_bad_declarations == 0, 'Test wrong condition declarations');
diff --git a/t/pm/General.pl b/t/pm/General.plt
similarity index 83%
rename from t/pm/General.pl
rename to t/pm/General.plt
index 0caefe7..645886d 100644
--- a/t/pm/General.pl
+++ b/t/pm/General.plt
@@ -1,3 +1,4 @@
+# -*- mode:perl -*-
 # Copyright (C) 2018 Free Software Foundation, Inc.
 #
 # This program is free software; you can redistribute it and/or modify
@@ -14,14 +15,11 @@
 # along with this program.  If not, see <https://www.gnu.org/licenses/>.
 
 use Automake::General;
-
-my $failed = 0;
+use Test::Simple tests => 2;
 
 # Check 'none'.
 my $none_positive = none { $_[0] < 0 } (1, 7, 3, 8, 9);
-$failed = 1 if ($none_positive == 0);
+ok ($none_positive != 0, 'Test none on positive values');
 
 my $none_gt_8 = none { $_[0] >= 8 } (1, 7, 3, 8, 9);
-$failed = 1 if ($none_gt_8 == 1);
-
-exit $failed;
+ok ($none_gt_8 == 0, 'Test none on values > 8');
diff --git a/t/pm/SilentRules.pl b/t/pm/SilentRules.pl
deleted file mode 100644
index 7397c3a..0000000
--- a/t/pm/SilentRules.pl
+++ /dev/null
@@ -1,60 +0,0 @@
-# Copyright (C) 2018  Free Software Foundation, Inc.
-
-# 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 2
-# 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/>.
-
-use Automake::SilentRules;
-
-my @test_vars = qw (FOO BAR BAZ TEST);
-
-
-sub test_verbose_flag
-{
-  my @res = map { verbose_flag $_ } @test_vars;
-  print "Test verbose_flag:\n";
-  print "Variable names: @test_vars\n";
-  print "Result: @res\n\n";
-  for my $i (0 .. $#res)
-    {
-      return 1
-          unless $res[$i] eq '$(AM_V_' . $test_vars[$i] . ')';
-    }
-  return 0;
-}
-
-
-sub test_verbose_nodep_flag
-{
-  my @res = map { verbose_nodep_flag $_ } @test_vars;
-  print "Test verbose_nodep_flag:\n";
-  print "Variable names: @test_vars\n";
-  print "Result: @res\n\n";
-  for my $i (0 .. $#res)
-    {
-      return 1
-          unless $res[$i] eq '$(AM_V_' . $test_vars[$i] . '@am__nodep@)';
-    }
-  return 0;
-}
-
-
-sub test_silent_flag
-{
-  return 1 
-      unless silent_flag eq '$(AM_V_at)';
-  print "silent_flag: OK\n\n";
-  return 0;
-}
-
-
-exit (test_verbose_flag | test_verbose_nodep_flag | test_silent_flag);
diff --git a/t/pm/Channels.pl b/t/pm/SilentRules.plt
similarity index 66%
copy from t/pm/Channels.pl
copy to t/pm/SilentRules.plt
index b7d0b0a..506d4b2 100644
--- a/t/pm/Channels.pl
+++ b/t/pm/SilentRules.plt
@@ -1,4 +1,5 @@
-# Copyright (C) 2018  Matthias Paulmier
+# -*- mode:perl -*-
+# Copyright (C) 2018  Free Software Foundation, Inc.
 
 # This program is free software; you can redistribute it and/or
 # modify it under the terms of the GNU General Public License
@@ -13,14 +14,9 @@
 # You should have received a copy of the GNU General Public License
 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
-# This test should end in a fatal error because the channel doesn't exist
+use Automake::SilentRules;
+use Test::Simple tests => 3;
 
-use Automake::Channels;
-use Automake::Location;
-
-eval { msg ('test-fatal', new Automake::Location ('.'), "Test Message") };
-
-warn $@ if $@;
-
-exit 0 if $@;
-exit 1;
+ok (verbose_flag 'FOO' eq '$(AM_V_FOO)', 'verbose_flag');
+ok (verbose_nodep_flag 'FOO' eq '$(AM_V_FOO@am__nodep@)', 'verbose_nodep_flag');
+ok (silent_flag eq '$(AM_V_at)', 'silent_flag');
diff --git a/t/pm/Utils.pl b/t/pm/Utils.pl
deleted file mode 100644
index ad8fc35..0000000
--- a/t/pm/Utils.pl
+++ /dev/null
@@ -1,67 +0,0 @@
-# Copyright (C) 2018  Free Software Foundation, Inc.
-
-# 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 2
-# 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/>.
-
-use Automake::Utils;
-
-sub check_subst
-{
-  my @inputs = qw (AC_FOO AC_BAR AC_BAZ);
-  my @expected_outputs = map {
-    (my $exp = $_) =~ s/(.*)/\@$1\@/;
-    $exp;
-  } @inputs;
-
-  for my $i (0 .. $#inputs)
-    {
-      return 1 if (subst $inputs[$i]) ne $expected_outputs[$i];
-    }
-  return 0;
-}
-
-sub check_flatten
-{
-  my $test_str = "\
-
-  Aliquam posuere.  Nunc aliquet, augue nec adipiscing interdum, lacus tellus
-malesuada massa, quis varius mi purus     non odio.  Pellentesque condimentum,
-
-magna ut suscipit hendrerit, ipsum augue ornare nulla,  non luctus diam neque
-
-sit amet urna.  Curabitur vulputate vestibulum lorem.  Fusce sagittis, libero
-  non molestie mollis, magna orci ultrices dolor, at vulputate neque nulla
-lacinia eros.
-";
-
-  my $expected_res = "Aliquam posuere. Nunc aliquet, augue nec adipiscing " .
-      "interdum, lacus tellus malesuada massa, quis varius mi purus non " .
-      "odio. Pellentesque condimentum, magna ut suscipit hendrerit, ipsum " .
-      "augue ornare nulla, non luctus diam neque sit amet urna. Curabitur " .
-      "vulputate vestibulum lorem. Fusce sagittis, libero non molestie " .
-      "mollis, magna orci ultrices dolor, at vulputate neque nulla lacinia " .
-      "eros.";
-
-  return 1 if (flatten $test_str) ne $expected_res;
-  return 0;
-}
-
-sub check_locate_aux_dir
-{
-  locate_aux_dir;
-  # The install-sh script is located in $(top_scrdir)/lib/
-  return 1 if ($am_config_aux_dir ne "$(top_srcdir)/lib/");
-  return 0;
-}
-
-exit (check_subst || check_flatten);
diff --git a/t/pm/Utils.plt b/t/pm/Utils.plt
new file mode 100644
index 0000000..7bb0fe7
--- /dev/null
+++ b/t/pm/Utils.plt
@@ -0,0 +1,51 @@
+# -*- mode:perl -*-
+# Copyright (C) 2018  Free Software Foundation, Inc.
+
+# 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 2
+# 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/>.
+
+use Automake::Utils;
+use Test::Simple tests => 3;
+
+ok (subst 'AC_FOO' eq '@AC_FOO@', 'subst');
+
+##########################################
+
+my $test_str = "\
+
+  Aliquam posuere.  Nunc aliquet, augue nec adipiscing interdum, lacus tellus
+malesuada massa, quis varius mi purus     non odio.  Pellentesque condimentum,
+
+magna ut suscipit hendrerit, ipsum augue ornare nulla,  non luctus diam neque
+
+sit amet urna.  Curabitur vulputate vestibulum lorem.  Fusce sagittis, libero
+  non molestie mollis, magna orci ultrices dolor, at vulputate neque nulla
+lacinia eros.
+";
+
+my $expected_res = "Aliquam posuere. Nunc aliquet, augue nec adipiscing " .
+    "interdum, lacus tellus malesuada massa, quis varius mi purus non " .
+    "odio. Pellentesque condimentum, magna ut suscipit hendrerit, ipsum " .
+    "augue ornare nulla, non luctus diam neque sit amet urna. Curabitur " .
+    "vulputate vestibulum lorem. Fusce sagittis, libero non molestie " .
+    "mollis, magna orci ultrices dolor, at vulputate neque nulla lacinia " .
+    "eros.";
+
+ok ((flatten $test_str) eq $expected_res, 'flatten');
+
+#####################################################
+
+locate_aux_dir;
+# The install-sh script is located in $(top_scrdir)/lib/
+print "$am_config_aux_dir\n";
+ok ($am_config_aux_dir eq '$(top_srcdir)', 'locate_aux_dir');
diff --git a/t/pm/Version.pl b/t/pm/Version.pl
deleted file mode 100644
index e4372ff..0000000
--- a/t/pm/Version.pl
+++ /dev/null
@@ -1,127 +0,0 @@
-# Copyright (C) 2002-2018 Free Software Foundation, Inc.
-#
-# 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 2, 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 <https://www.gnu.org/licenses/>.
-
-use Automake::Version;
-
-my $failed = 0;
-
-sub test_version_compare
-{
-  my ($left, $right, $result) = @_;
-  my @leftver = Automake::Version::split ($left);
-  my @rightver = Automake::Version::split ($right);
-  if ($#leftver == -1)
-  {
-    print "can't grok \"$left\"\n";
-    $failed = 1;
-    return;
-  }
-  if ($#rightver == -1)
-  {
-    print "can't grok \"$right\"\n";
-    $failed = 1;
-    return;
-  }
-  my $res = Automake::Version::compare (@leftver, @rightver);
-  if ($res != $result)
-  {
-    print "compare (\"$left\", \"$right\") = $res! (not $result?)\n";
-    $failed = 1;
-  }
-
-  my $check_expected = ($result == 0 || $result == 1) ? 0 : 1;
-  # Exception for 'foo' fork.
-  $check_expected = 1
-    if ($right =~ /foo/ && !($left =~ /foo/));
-
-  my $check = Automake::Version::check ($left, $right);
-  if ($check != $check_expected)
-  {
-    print "check (\"$left\", \"$right\") = $check! (not $check_expected?)\n";
-    $failed = 1;
-  }
-}
-
-sub test_bad_versions
-{
-  my ($ver) = @_;
-  my @version = Automake::Version::split ($ver);
-  if ($#version != -1)
-  {
-    print "shouldn't grok \"$ver\"\n";
-    $failed = 1;
-  }
-}
-
-sub test_bad_declarations
-{
-  eval { Automake::Version::check ('', '1.2.3') };
-
-  warn $@ if $@;
-  $failed = 1 unless $@;
-
-  $@ = '';
-
-  eval { Automake::Version::check ('1.2.3', '') };
-
-  warn $@ if $@;
-  $failed = 1 unless $@;
-}
-
-my @tests = (
-# basics
-  ['1.0', '2.0', -1],
-  ['2.0', '1.0', 1],
-  ['1.2', '1.2', 0],
-  ['1.1', '1.2', -1],
-  ['1.2', '1.1', 1],
-# alphas
-  ['1.4', '1.4g', -1],
-  ['1.4g', '1.5', -1],
-  ['1.4g', '1.4', 1],
-  ['1.5', '1.4g', 1],
-  ['1.4a', '1.4g', -1],
-  ['1.5a', '1.3g', 1],
-  ['1.6a', '1.6a', 0],
-# micros
-  ['1.5.1', '1.5', 1],
-  ['1.5.0', '1.5', 0],
-  ['1.5.4', '1.6.1', -1],
-# micros and alphas
-  ['1.5a', '1.5.1', 1],
-  ['1.5a', '1.5.1a', 1],
-  ['1.5a', '1.5.1f', 1],
-  ['1.5', '1.5.1a', -1],
-  ['1.5.1a', '1.5.1f', -1],
-  ['1.5.1f', '1.5.1a', 1],
-  ['1.5.1f', '1.5.1f', 0],
-# special exceptions
-  ['1.6-p5a', '1.6.5a', 0],
-  ['1.6', '1.6-p5a', -1],
-  ['1.6-p4b', '1.6-p5a', -1],
-  ['1.6-p4b', '1.6-foo', 1],
-  ['1.6-p4b', '1.6a-foo', -1],
-  ['1.6-p5', '1.6.5', 0],
-  ['1.6a-foo', '1.6a-foo', 0],
-);
-
-my @bad_versions = (
-  '', 'a', '1', '1a', '1.2.3.4', '-1.2'
-);
-
-test_version_compare (@{$_}) foreach @tests;
-test_bad_versions ($_) foreach @bad_versions;
-
-exit $failed;
diff --git a/t/pm/Version.plt b/t/pm/Version.plt
new file mode 100644
index 0000000..4684453
--- /dev/null
+++ b/t/pm/Version.plt
@@ -0,0 +1,122 @@
+# -*- mode:perl -*-
+# Copyright (C) 2002-2018 Free Software Foundation, Inc.
+#
+# 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 2, 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 <https://www.gnu.org/licenses/>.
+
+use Automake::Version;
+use Test::Simple tests => 34;
+
+sub test_version_compare
+{
+  my ($left, $right, $result) = @_;
+  my @leftver = Automake::Version::split ($left);
+  my @rightver = Automake::Version::split ($right);
+  if ($#leftver == -1)
+  {
+    print "can't grok \"$left\"\n";
+    return 1;
+  }
+  if ($#rightver == -1)
+  {
+    print "can't grok \"$right\"\n";
+    return 1;
+  }
+  my $res = Automake::Version::compare (@leftver, @rightver);
+  if ($res != $result)
+  {
+    print "compare (\"$left\", \"$right\") = $res! (not $result?)\n";
+    return 1;
+  }
+
+  my $check_expected = ($result == 0 || $result == 1) ? 0 : 1;
+  # Exception for 'foo' fork.
+  $check_expected = 1
+    if ($right =~ /foo/ && !($left =~ /foo/));
+
+  my $check = Automake::Version::check ($left, $right);
+  if ($check != $check_expected)
+    {
+      print "check (\"$left\", \"$right\") = $check! (not $check_expected?)\n";
+      return 1;
+    }
+  return 0;
+}
+
+sub test_bad_versions
+{
+  my ($ver) = @_;
+  my @version = Automake::Version::split ($ver);
+  if ($#version != -1)
+    {
+      print "shouldn't grok \"$ver\"\n";
+      return 1;
+    }
+  return 0;
+}
+
+sub test_bad_declarations
+{
+  eval { Automake::Version::check ('', '1.2.3') };
+
+  warn $@ if $@;
+  $failed = 1 unless $@;
+
+  $@ = '';
+
+  eval { Automake::Version::check ('1.2.3', '') };
+
+  warn $@ if $@;
+  return 1 unless $@;
+  return 0;
+}
+
+ok (test_version_compare ('2.0', '1.0', 1) == 0, 'Test comparing versions basics 2');
+ok (test_version_compare ('1.2', '1.2', 0) == 0, 'Test comparing versions basics 3');
+ok (test_version_compare ('1.1', '1.2', -1) == 0, 'Test comparing versions basics 4');
+ok (test_version_compare ('1.2', '1.1', 1) == 0, 'Test comparing versions basics 5');
+
+ok (test_version_compare ('1.4', '1.4g', -1) == 0, 'Test comparing versions with alphas 1');
+ok (test_version_compare ('1.4g', '1.5', -1) == 0, 'Test comparing versions with alphas 2');
+ok (test_version_compare ('1.4g', '1.4', 1) == 0, 'Test comparing versions with alphas 3');
+ok (test_version_compare ('1.5', '1.4g', 1) == 0, 'Test comparing versions with alphas 4');
+ok (test_version_compare ('1.4a', '1.4g', -1) == 0, 'Test comparing versions with alphas 5');
+ok (test_version_compare ('1.5a', '1.3g', 1) == 0, 'Test comparing versions with alphas 6');
+ok (test_version_compare ('1.6a', '1.6a', 0) == 0, 'Test comparing versions with alphas 7');
+
+ok (test_version_compare ('1.5.1', '1.5', 1) == 0, 'Test comparing versions micros 1');
+ok (test_version_compare ('1.5.0', '1.5', 0) == 0, 'Test comparing versions micros 2');
+ok (test_version_compare ('1.5.4', '1.6.1', -1) == 0, 'Test comparing versions micros 3');
+
+ok (test_version_compare ('1.5a', '1.5.1', 1) == 0, 'Test comparing versions micros and alphas 1');
+ok (test_version_compare ('1.5a', '1.5.1a', 1) == 0, 'Test comparing versions micros and alphas 2');
+ok (test_version_compare ('1.5a', '1.5.1f', 1) == 0, 'Test comparing versions micros and alphas 3');
+ok (test_version_compare ('1.5', '1.5.1a', -1) == 0, 'Test comparing versions micros and alphas 4');
+ok (test_version_compare ('1.5.1a', '1.5.1f', -1) == 0, 'Test comparing versions micros and alphas 5');
+ok (test_version_compare ('1.5.1f', '1.5.1a', 1) == 0, 'Test comparing versions micros and alphas 6');
+ok (test_version_compare ('1.5.1f', '1.5.1f', 0) == 0, 'Test comparing versions micros and alphas 7');
+
+ok (test_version_compare ('1.6-p5a', '1.6.5a', 0) == 0, 'Test comparing versions special exceptions 1');
+ok (test_version_compare ('1.6', '1.6-p5a', -1) == 0, 'Test comparing versions special exceptions 1');
+ok (test_version_compare ('1.6-p4b', '1.6-p5a', -1) == 0, 'Test comparing versions special exceptions 1');
+ok (test_version_compare ('1.6-p4b', '1.6-foo', 1) == 0, 'Test comparing versions special exceptions 1');
+ok (test_version_compare ('1.6-p4b', '1.6a-foo', -1) == 0, 'Test comparing versions special exceptions 1');
+ok (test_version_compare ('1.6-p5', '1.6.5', 0) == 0, 'Test comparing versions special exceptions 1');
+ok (test_version_compare ('1.6a-foo', '1.6a-foo', 0) == 0, 'Test comparing versions special exceptions 1');
+
+ok (test_bad_versions ('') == 0, 'Test bad version numbers empty str');
+ok (test_bad_versions ('a') == 0, 'Test bad version numbers only alpha');
+ok (test_bad_versions ('1') == 0, 'Test bad version numbers only major');
+ok (test_bad_versions ('1a') == 0, 'Test bad version numbers only major with alpha');
+ok (test_bad_versions ('1.2.3.4') == 0, 'Test bad version numbers to many minor versions');
+ok (test_bad_versions ('-1.2') == 0, 'Test bad version numbers negative');
diff --git a/t/pm/Wrap.pl b/t/pm/Wrap.plt
similarity index 77%
rename from t/pm/Wrap.pl
rename to t/pm/Wrap.plt
index 995569a..fdfdab3 100644
--- a/t/pm/Wrap.pl
+++ b/t/pm/Wrap.plt
@@ -1,3 +1,4 @@
+# -*- mode:perl -*-
 # Copyright (C) 2003-2018 Free Software Foundation, Inc.
 #
 # This program is free software; you can redistribute it and/or modify
@@ -14,8 +15,7 @@
 # along with this program.  If not, see <https://www.gnu.org/licenses/>.
 
 use Automake::Wrap qw/wrap makefile_wrap/;
-
-my $failed = 0;
+use Test::Simple tests => 9;
 
 sub test_wrap
 {
@@ -25,20 +25,21 @@
   if ($out ne $exp_out)
     {
       print STDERR "For: @$in\nGot:\n$out\nInstead of:\n$exp_out\n---\n";
-      ++$failed;
+      return 1;
     }
+  return 0;
 }
 
 sub test_makefile_wrap
 {
   my ($in, $exp_out) = @_;
-
   my $out = &makefile_wrap (@$in);
   if ($out ne $exp_out)
     {
       print STDERR "For: @$in\nGot:\n$out\nInstead of:\n$exp_out\n---\n";
-      ++$failed;
+      return 1;
     }
+  return 0;
 }
 
 my @tests = (
@@ -89,7 +90,13 @@
 \tunlike in the second line
 "]);
 
-test_wrap (@{$_}) foreach @tests;
-test_makefile_wrap (@{$_}) foreach @makefile_tests;
+ok (test_wrap (@{$tests[0]}) == 0, 'test_wrap 0');
+ok (test_wrap (@{$tests[1]}) == 0, 'test_wrap 1');
+ok (test_wrap (@{$tests[2]}) == 0, 'test_wrap 2');
+ok (test_wrap (@{$tests[3]}) == 0, 'test_wrap 3');
+ok (test_wrap (@{$tests[4]}) == 0, 'test_wrap 4');
 
-exit $failed;
+ok (test_makefile_wrap (@{$makefile_tests[0]}) == 0, 'test_makefile_wrap 0');
+ok (test_makefile_wrap (@{$makefile_tests[1]}) == 0, 'test_makefile_wrap 1');
+ok (test_makefile_wrap (@{$makefile_tests[2]}) == 0, 'test_makefile_wrap 2');
+ok (test_makefile_wrap (@{$makefile_tests[3]}) == 0, 'test_makefile_wrap 3');