aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorantirez <antirez>2005-03-29 16:50:22 +0000
committerantirez <antirez>2005-03-29 16:50:22 +0000
commit15dc45ec7c7c6f9e31300b6c025f46d8adec16d8 (patch)
tree47a64fc12e95e714d822b4c9b0bfa7c5e1d8a150
parentb0e3d498bf73bfebe7d1fe92e39518fe8c66e936 (diff)
downloadjimtcl-15dc45ec7c7c6f9e31300b6c025f46d8adec16d8.zip
jimtcl-15dc45ec7c7c6f9e31300b6c025f46d8adec16d8.tar.gz
jimtcl-15dc45ec7c7c6f9e31300b6c025f46d8adec16d8.tar.bz2
[info args] added
-rw-r--r--ChangeLog5
-rw-r--r--jim.c17
-rw-r--r--test.tcl24
3 files changed, 39 insertions, 7 deletions
diff --git a/ChangeLog b/ChangeLog
index 9d60cec..fb49983 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+2005-03-29 16:17 antirez
+
+ * ChangeLog, jim.c: Fixed [range] for the case of unique element
+ possible as output.
+
2005-03-29 16:03 antirez
* ChangeLog, jim.c: random number generator fixed. Was a problem
diff --git a/jim.c b/jim.c
index 8348bfd..24c2255 100644
--- a/jim.c
+++ b/jim.c
@@ -2,7 +2,7 @@
* Copyright 2005 Salvatore Sanfilippo <antirez@invece.org>
* Copyright 2005 Clemens Hintze <c.hintze@gmx.net>
*
- * $Id: jim.c,v 1.136 2005/03/29 14:17:28 antirez Exp $
+ * $Id: jim.c,v 1.137 2005/03/29 16:50:22 antirez Exp $
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -10410,10 +10410,10 @@ static int Jim_InfoCoreCommand(Jim_Interp *interp, int argc,
int cmd, result = JIM_OK;
static const char *commands[] = {
"body", "commands", "exists", "globals", "level", "locals",
- "vars", "version", "complete", NULL
+ "vars", "version", "complete", "args", NULL
};
enum {INFO_BODY, INFO_COMMANDS, INFO_EXISTS, INFO_GLOBALS, INFO_LEVEL,
- INFO_LOCALS, INFO_VARS, INFO_VERSION, INFO_COMPLETE};
+ INFO_LOCALS, INFO_VARS, INFO_VERSION, INFO_COMPLETE, INFO_ARGS};
if (argc < 2) {
Jim_WrongNumArgs(interp, 1, argv, "command ?args ...?");
@@ -10473,7 +10473,7 @@ static int Jim_InfoCoreCommand(Jim_Interp *interp, int argc,
Jim_WrongNumArgs(interp, 2, argv, "?levelNum?");
return JIM_ERR;
}
- } else if (cmd == INFO_BODY) {
+ } else if (cmd == INFO_BODY || cmd == INFO_ARGS) {
if (argc != 3) {
Jim_WrongNumArgs(interp, 2, argv, "procname");
return JIM_ERR;
@@ -10487,7 +10487,12 @@ static int Jim_InfoCoreCommand(Jim_Interp *interp, int argc,
"\" is not a procedure", NULL);
return JIM_ERR;
}
- Jim_SetResult(interp, argv[2]->internalRep.cmdValue.cmdPtr->bodyObjPtr);
+ if (cmd == INFO_BODY)
+ Jim_SetResult(interp,
+ argv[2]->internalRep.cmdValue.cmdPtr->bodyObjPtr);
+ else
+ Jim_SetResult(interp,
+ argv[2]->internalRep.cmdValue.cmdPtr->argListObjPtr);
} else if (cmd == INFO_VERSION) {
char buf[(JIM_INTEGER_SPACE * 2) + 1];
sprintf(buf, "%d.%d",
@@ -11035,7 +11040,7 @@ int Jim_InteractivePrompt(Jim_Interp *interp)
printf("Welcome to Jim version %d.%d, "
"Copyright (c) 2005 Salvatore Sanfilippo\n",
JIM_VERSION / 100, JIM_VERSION % 100);
- printf("CVS ID: $Id: jim.c,v 1.136 2005/03/29 14:17:28 antirez Exp $\n");
+ printf("CVS ID: $Id: jim.c,v 1.137 2005/03/29 16:50:22 antirez Exp $\n");
Jim_SetVariableStrWithStr(interp, "jim_interactive", "1");
while (1) {
char buf[1024];
diff --git a/test.tcl b/test.tcl
index ccd7858..4f0e433 100644
--- a/test.tcl
+++ b/test.tcl
@@ -1,4 +1,4 @@
-# $Id: test.tcl,v 1.28 2005/03/28 17:47:15 antirez Exp $
+# $Id: test.tcl,v 1.29 2005/03/29 16:50:22 antirez Exp $
#
# This are Tcl tests imported into Jim. Tests that will probably not be passed
# in the long term are usually removed (for example all the tests about
@@ -4194,6 +4194,28 @@ catch {unset x}
catch {unset y}
################################################################################
+# RAND
+################################################################################
+test rand-1.0 {Only one output is valid} {
+ list [rand 100 100] [rand 101 101]
+} {100 101}
+
+test rand-1.1 {invalid arguments} {
+ catch {rand 100 50} err
+ set err
+} {Invalid arguments (max < min)}
+
+test rand-1.2 {Check limits} {
+ set sum 0
+ for {set i 0} {$i < 100} {incr i} {
+ incr sum [expr {([rand $i] >= 0)+([rand $i] < 100)}]
+ }
+ set sum
+} {200}
+
+catch {unset sum; unset err; unset i}
+
+################################################################################
# JIM REGRESSION TESTS
################################################################################
test regression-1.0 {Rename against procedures with static vars} {