[Tkabber-dev] [tclgpg] r67 committed - Make [set] check the number of arguments it is passed...

codesite-noreply at google.com codesite-noreply at google.com
Thu Aug 20 18:49:41 MSD 2009


Revision: 67
Author: khomoutov
Date: Thu Aug 20 07:48:34 2009
Log: Make [set] check the number of arguments it is passed

The [set] command now checks if it is passed exactly
  two or four arguments, and fails with an appropriate
  error message if this is not true.

http://code.google.com/p/tclgpg/source/detail?r=67

Modified:
  /trunk/ChangeLog
  /trunk/tclgpg.tcl
  /trunk/tclgpg.test

=======================================
--- /trunk/ChangeLog	Thu Aug 20 07:36:01 2009
+++ /trunk/ChangeLog	Thu Aug 20 07:48:34 2009
@@ -10,9 +10,9 @@

  	* doc/gpg.man: Enclosed section heading in quotes.

-	* tclgpg.tcl: [unset] command now checks if its
-	  the number of arguments it is passed and
-	  returns an error if it is wrong.
+	* tclgpg.tcl: Make [set] and [unset] commands
+	  check the number of arguments they are passed
+	  and return an error message if this number is wrong.

  2009-08-16  Sergei Golovan  <sgolovan at nes.ru>

=======================================
--- /trunk/tclgpg.tcl	Thu Aug 20 07:36:01 2009
+++ /trunk/tclgpg.tcl	Thu Aug 20 07:48:34 2009
@@ -204,6 +204,12 @@

      Debug 2 "$token $args"

+    if {[llength $args] != 2 && [llength $args] != 4} {
+        return -code error \
+            "wrong # args: should be set -property propertyName\
+                ?-value value?"
+    }
+
      foreach {key val} $args {
          switch -- $key {
              -property { set prop  $val }
=======================================
--- /trunk/tclgpg.test	Thu Aug 20 07:36:01 2009
+++ /trunk/tclgpg.test	Thu Aug 20 07:48:34 2009
@@ -95,13 +95,12 @@
      -result {invalid textmode value "v": must be boolean} \
      -cleanup {$c free}

-test set-1.10 {Set without a property} -body {
+test set-1.10 {Set with no arguments} -body {
      set c [::gpg::new]
      $c set
  } -returnCodes error \
-    -result {missing property: must be armor, textmode,\
-        passphrase-callback, signers, encoding,\
-        passphrase-encoding, or last-op-info} \
+    -result {wrong # args: should be set -property propertyName\
+        ?-value value?} \
      -cleanup {$c free}

  test set-1.11 {Set with an incorrect option} -body {
@@ -110,6 +109,14 @@
  } -returnCodes error \
      -result {unknown option "-prop": must be -property or -value} \
      -cleanup {$c free}
+
+test set-1.12 {Set with extraneous arguments} -body {
+    set c [::gpg::new]
+    $c set -property textmode -value true -property armor -value true
+} -returnCodes error \
+    -result {wrong # args: should be set -property propertyName\
+        ?-value value?} \
+    -cleanup {$c free}

  test unset-1.1 {Unset armor property} -body {
      set c [::gpg::new]


More information about the Tkabber-dev mailing list