From f42d056812d4c1766d75bd8ab6d871e06a700302 Mon Sep 17 00:00:00 2001 From: Nathan Gass Date: Tue, 25 Aug 2020 15:57:32 +0200 Subject: test for unexpected optional positinal arguments --- test/getopt.t | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) (limited to 'test') diff --git a/test/getopt.t b/test/getopt.t index e74e925..aa2de52 100755 --- a/test/getopt.t +++ b/test/getopt.t @@ -3,7 +3,7 @@ # Tests for getopt in it.class -$GLOBALS['usage'] = "Usage: doesnotexist.php [OPTIONS] POSITIONAL +$GLOBALS['usage'] = "Usage: doesnotexist.php [OPTIONS] POSITIONAL [VARARGS] Some help to a not existing program -h,--help the help argument -a,--argument=ARG the arg argument @@ -37,3 +37,11 @@ getopt_ok(['posarg', '-u'], false, "Unknown short named argument fails"); getopt_ok([], false, "Missing positional argument fails"); getopt_ok(['posarg', '--argument'], false, "Missing long named argument fails"); getopt_ok(['posarg', '-a'], false, "Missing short named argument fails"); + +// FIXME 2020-10 NG enable after fixme in it.class +// $GLOBALS['usage'] = it::replace('\s*\[VARARGS\]' => '', $GLOBALS['usage']); +// getopt_ok(['posargs', 'vararg'], false, "Extra positional argument fails"); +// getopt_ok(['posargs', '--zero', 'vararg'], false, "Extra positional argument fails after long argument"); +// getopt_ok(['posargs', '-0', 'vararg'], false, "Extra positional argument fails after short argument"); +// getopt_ok(['posargs', '--argument', 'value', 'vararg'], false, "Extra positional argument fails after long argument with value"); +// getopt_ok(['posargs', '-a', 'value', 'vararg'], false, "Extra positional argument fails after short argument with value"); -- cgit v1.2.3