From 34d3750e3ce6bd9d08b641e6f99b992ad80740b1 Mon Sep 17 00:00:00 2001 From: "jan.nijtmans" Date: Mon, 26 Oct 2020 15:07:03 +0000 Subject: Fix [48898ab5f6a0d957]: Too few is better than not enough? (Inconsistent error messages) --- ChangeLog.2001 | 2 +- doc/clock.n | 8 ++++---- doc/lassign.n | 2 +- generic/tclBasic.c | 4 ++-- generic/tclCompCmdsGR.c | 2 +- library/init.tcl | 4 ++-- tests/apply.test | 2 +- tests/compExpr-old.test | 6 +++--- tests/compExpr.test | 4 ++-- tests/expr-old.test | 8 ++++---- tests/expr.test | 6 +++--- tests/string.test | 22 +++++++++++----------- 12 files changed, 35 insertions(+), 35 deletions(-) diff --git a/ChangeLog.2001 b/ChangeLog.2001 index 9d6d541..5fdff46 100644 --- a/ChangeLog.2001 +++ b/ChangeLog.2001 @@ -3525,7 +3525,7 @@ * generic/tclVar.c (Tcl_UnsetObjCmd): Rewrote argument parser to avoid a read off the end of the argument array that could occur when executing something like [unset -nocomplain] was executed. Improved - the error message given when too few arguments are given (-nocomplain + the error message given when not enough arguments are given (-nocomplain should obviously be *before* --, not after it) and also modified the test suite to take account of that and the documentation to use the same improvement. [Bug 405769] diff --git a/doc/clock.n b/doc/clock.n index a8c6d29..18f921c 100644 --- a/doc/clock.n +++ b/doc/clock.n @@ -265,10 +265,10 @@ converts the given time to a calendar date and time of day. It then adds the requisite number of months or years, and reconverts the resulting date and time of day to an absolute time. .PP -If the resulting date is impossible because the month has too few days -(for example, when adding 1 month to 31 January), the last day of the -month is substituted. Thus, adding 1 month to 31 January will result in -28 February in a common year or 29 February in a leap year. +If the resulting date is impossible because the month has not enough +days (for example, when adding 1 month to 31 January), the last day +of the month is substituted. Thus, adding 1 month to 31 January will +result in 28 February in a common year or 29 February in a leap year. .PP The rules for handling anomalies relating to summer time and to the Gregorian calendar are the same when adding/subtracting months and diff --git a/doc/lassign.n b/doc/lassign.n index 5620de6..2c57937 100644 --- a/doc/lassign.n +++ b/doc/lassign.n @@ -25,7 +25,7 @@ unassigned elements is returned. .SH EXAMPLES .PP An illustration of how multiple assignment works, and what happens -when there are either too few or too many elements. +when there are either not enough or too many elements. .PP .CS \fBlassign\fR {a b c} x y z ;# Empty return diff --git a/generic/tclBasic.c b/generic/tclBasic.c index cca87ce..895d160 100644 --- a/generic/tclBasic.c +++ b/generic/tclBasic.c @@ -8007,8 +8007,8 @@ MathFuncWrongNumArgs( } } Tcl_SetObjResult(interp, Tcl_ObjPrintf( - "too %s arguments for math function \"%s\"", - (found < expected ? "few" : "many"), name)); + "%s arguments for math function \"%s\"", + (found < expected ? "not enough" : "too many"), name)); Tcl_SetErrorCode(interp, "TCL", "WRONGARGS", NULL); } diff --git a/generic/tclCompCmdsGR.c b/generic/tclCompCmdsGR.c index 990be2a..c453878 100644 --- a/generic/tclCompCmdsGR.c +++ b/generic/tclCompCmdsGR.c @@ -1073,7 +1073,7 @@ TclCompileLindexCmd( int i, idx, numWords = parsePtr->numWords; /* - * Quit if too few args. + * Quit if not enough args. */ /* TODO: Consider support for compiling expanded args. */ diff --git a/library/init.tcl b/library/init.tcl index da1850c..0713aa2 100644 --- a/library/init.tcl +++ b/library/init.tcl @@ -84,7 +84,7 @@ namespace eval tcl { proc min {args} { if {![llength $args]} { return -code error \ - "too few arguments to math function \"min\"" + "not enough arguments to math function \"min\"" } set val Inf foreach arg $args { @@ -100,7 +100,7 @@ namespace eval tcl { proc max {args} { if {![llength $args]} { return -code error \ - "too few arguments to math function \"max\"" + "not enough arguments to math function \"max\"" } set val -Inf foreach arg $args { diff --git a/tests/apply.test b/tests/apply.test index 5fed6ec..0a64aa0 100644 --- a/tests/apply.test +++ b/tests/apply.test @@ -25,7 +25,7 @@ testConstraint memory [llength [info commands memory]] # Tests for wrong number of arguments -test apply-1.1 {too few arguments} -returnCodes error -body { +test apply-1.1 {not enough arguments} -returnCodes error -body { apply } -result {wrong # args: should be "apply lambdaExpr ?arg ...?"} diff --git a/tests/compExpr-old.test b/tests/compExpr-old.test index d4525e6..826fbc6 100644 --- a/tests/compExpr-old.test +++ b/tests/compExpr-old.test @@ -590,13 +590,13 @@ test compExpr-old-15.3 {CompileMathFuncCall: too many arguments} -body { test compExpr-old-15.4 {CompileMathFuncCall: ')' found before last required arg} -body { catch {expr sin()} msg set ::errorInfo -} -match glob -result {too few arguments for math function* +} -match glob -result {not enough arguments for math function* while *ing "expr sin()"} -test compExpr-old-15.5 {CompileMathFuncCall: too few arguments} -body { +test compExpr-old-15.5 {CompileMathFuncCall: not enough arguments} -body { catch {expr pow(1)} msg set ::errorInfo -} -match glob -result {too few arguments for math function* +} -match glob -result {not enough arguments for math function* while *ing "expr pow(1)"} test compExpr-old-15.6 {CompileMathFuncCall: missing ')'} -body { diff --git a/tests/compExpr.test b/tests/compExpr.test index 677266c..d3f1345 100644 --- a/tests/compExpr.test +++ b/tests/compExpr.test @@ -325,9 +325,9 @@ test compExpr-5.3 {CompileMathFuncCall: call registered math function} testmathf test compExpr-5.4 {CompileMathFuncCall: call registered math function} testmathfunctions { expr T2()*3 } 1035 -test compExpr-5.5 {CompileMathFuncCall procedure, too few arguments} -body { +test compExpr-5.5 {CompileMathFuncCall procedure, not enough arguments} -body { expr {atan2(1.0)} -} -returnCodes error -match glob -result {too few arguments for math function*} +} -returnCodes error -match glob -result {not enough arguments for math function*} test compExpr-5.6 {CompileMathFuncCall procedure, complex argument} { format %.6g [expr pow(2.1, 27.5-(24.4*(5%2)))] } 9.97424 diff --git a/tests/expr-old.test b/tests/expr-old.test index 06a00ba..28ec346 100644 --- a/tests/expr-old.test +++ b/tests/expr-old.test @@ -861,7 +861,7 @@ test expr-old-32.46 {math functions in expressions} -body { } -match glob -result {1 {too many arguments for math function*}} test expr-old-32.47 {math functions in expressions} -body { list [catch {expr srand()} msg] $msg -} -match glob -result {1 {too few arguments for math function*}} +} -match glob -result {1 {not enough arguments for math function*}} test expr-old-32.48 {math functions in expressions} -body { expr srand(3.79) } -returnCodes error -match glob -result * @@ -918,7 +918,7 @@ test expr-old-34.6 {errors in math functions} -body { } -returnCodes error -match glob -result * test expr-old-34.7 {errors in math functions} -body { list [catch {expr hypot(1.0)} msg] $msg -} -match glob -result {1 {too few arguments for math function*}} +} -match glob -result {1 {not enough arguments for math function*}} test expr-old-34.8 {errors in math functions} -body { list [catch {expr hypot(1.0, 2.0, 3.0)} msg] $msg } -match glob -result {1 {too many arguments for math function*}} @@ -1160,7 +1160,7 @@ test expr-old-40.2 {min math function} -body { } -result 0.0 test expr-old-40.3 {min math function} -body { list [catch {expr {min()}} msg] $msg -} -result {1 {too few arguments to math function "min"}} +} -result {1 {not enough arguments to math function "min"}} test expr-old-40.4 {min math function} -body { expr {min(wide(-1) << 30, 4.5, -10)} } -result [expr {wide(-1) << 30}] @@ -1179,7 +1179,7 @@ test expr-old-41.2 {max math function} -body { } -result 0.0 test expr-old-41.3 {max math function} -body { list [catch {expr {max()}} msg] $msg -} -result {1 {too few arguments to math function "max"}} +} -result {1 {not enough arguments to math function "max"}} test expr-old-41.4 {max math function} -body { expr {max(wide(1) << 30, 4.5, -10)} } -result [expr {wide(1) << 30}] diff --git a/tests/expr.test b/tests/expr.test index d2f767d..37d8fe3 100644 --- a/tests/expr.test +++ b/tests/expr.test @@ -673,13 +673,13 @@ test expr-15.3 {CompileMathFuncCall: too many arguments} -body { test expr-15.4 {CompileMathFuncCall: ')' found before last required arg} -body { catch {expr sin()} msg set ::errorInfo -} -match glob -result {too few arguments for math function* +} -match glob -result {not enough arguments for math function* while *ing "expr sin()"} -test expr-15.5 {CompileMathFuncCall: too few arguments} -body { +test expr-15.5 {CompileMathFuncCall: not enough arguments} -body { catch {expr pow(1)} msg set ::errorInfo -} -match glob -result {too few arguments for math function* +} -match glob -result {not enough arguments for math function* while *ing "expr pow(1)"} test expr-15.6 {CompileMathFuncCall: missing ')'} -body { diff --git a/tests/string.test b/tests/string.test index 12108ca..18faa51 100644 --- a/tests/string.test +++ b/tests/string.test @@ -37,7 +37,7 @@ test string-1.2 {error conditions} { list [catch {string} msg] $msg } {1 {wrong # args: should be "string subcommand ?arg ...?"}} -test string-2.1 {string compare, too few args} { +test string-2.1 {string compare, not enough args} { list [catch {string compare a} msg] $msg } {1 {wrong # args: should be "string compare ?-nocase? ?-length int? string1 string2"}} test string-2.2 {string compare, bad args} { @@ -177,7 +177,7 @@ test string-3.8 {string equal with length, unequal strings} { string equal -length 2 abc abde } 1 -test string-4.1 {string first, too few args} { +test string-4.1 {string first, not enough args} { list [catch {string first a} msg] $msg } {1 {wrong # args: should be "string first needleString haystackString ?startIndex?"}} test string-4.2 {string first, bad args} { @@ -321,10 +321,10 @@ proc largest_int {} { return [expr {$int-1}] } -test string-6.1 {string is, too few args} { +test string-6.1 {string is, not enough args} { list [catch {string is} msg] $msg } {1 {wrong # args: should be "string is class ?-strict? ?-failindex var? str"}} -test string-6.2 {string is, too few args} { +test string-6.2 {string is, not enough args} { list [catch {string is alpha} msg] $msg } {1 {wrong # args: should be "string is class ?-strict? ?-failindex var? str"}} test string-6.3 {string is, bad args} { @@ -774,7 +774,7 @@ test string-6.131 {string is entier, false on bad hex} { catch {rename largest_int {}} -test string-7.1 {string last, too few args} { +test string-7.1 {string last, not enough args} { list [catch {string last a} msg] $msg } {1 {wrong # args: should be "string last needleString haystackString ?startIndex?"}} test string-7.2 {string last, bad args} { @@ -860,7 +860,7 @@ test string-9.7 {string length, bytearray object} { string length [binary format I* {0x50515253 0x52}] } 8 -test string-10.1 {string map, too few args} { +test string-10.1 {string map, not enough args} { list [catch {string map} msg] $msg } {1 {wrong # args: should be "string map ?-nocase? charMap string"}} test string-10.2 {string map, bad args} { @@ -960,7 +960,7 @@ test string-10.31 {string map, nasty sharing crash from [Bug 1018562]} { string map $a $a } {b b} -test string-11.1 {string match, too few args} { +test string-11.1 {string match, not enough args} { list [catch {string match a} msg] $msg } {1 {wrong # args: should be "string match ?-nocase? pattern string"}} test string-11.2 {string match, too many args} { @@ -1404,7 +1404,7 @@ test string-14.19 {string replace} { string replace {} -1 0 A } A -test string-15.1 {string tolower too few args} { +test string-15.1 {string tolower not enough args} { list [catch {string tolower} msg] $msg } {1 {wrong # args: should be "string tolower string ?first? ?last?"}} test string-15.2 {string tolower bad args} { @@ -1839,7 +1839,7 @@ test string-25.14 {string is list} { list [string is list -failindex x "\uABCD {b c}d e"] $x } {0 2} -test string-26.1 {tcl::prefix, too few args} -body { +test string-26.1 {tcl::prefix, not enough args} -body { tcl::prefix match a } -returnCodes 1 -result {wrong # args: should be "tcl::prefix match ?options? table string"} test string-26.2 {tcl::prefix, bad args} -body { @@ -1966,7 +1966,7 @@ test string-26.13 {tcl::prefix: testing for leaks} -body { } } -constraints memory -result {0} -test string-27.1 {tcl::prefix all, too few args} -body { +test string-27.1 {tcl::prefix all, not enough args} -body { tcl::prefix all a } -returnCodes 1 -result {wrong # args: should be "tcl::prefix all table string"} test string-27.2 {tcl::prefix all, bad args} -body { @@ -1997,7 +1997,7 @@ test string-27.10 {tcl::prefix all} { tcl::prefix all {apa aska appa} {} } {apa aska appa} -test string-28.1 {tcl::prefix longest, too few args} -body { +test string-28.1 {tcl::prefix longest, not enough args} -body { tcl::prefix longest a } -returnCodes 1 -result {wrong # args: should be "tcl::prefix longest table string"} test string-28.2 {tcl::prefix longest, bad args} -body { -- cgit v0.12