From 7e796a8a329db44fd484393c3292c8a5cd4801da Mon Sep 17 00:00:00 2001 From: dkf Date: Mon, 15 Jul 2024 14:29:13 +0000 Subject: Make [self] work inside [$obj eval]. [91b3a5bb14e6e8ae] --- doc/object.n | 5 +++++ generic/tclOOBasic.c | 3 ++- tests/oo.test | 10 ++++++++++ 3 files changed, 17 insertions(+), 1 deletion(-) diff --git a/doc/object.n b/doc/object.n index df657a9..381b963 100644 --- a/doc/object.n +++ b/doc/object.n @@ -64,6 +64,11 @@ The \fBoo::object\fR class supports the following non-exported methods: This method concatenates the arguments, \fIarg\fR, as if with \fBconcat\fR, and then evaluates the resulting script in the namespace that is uniquely associated with \fIobj\fR, returning the result of the evaluation. +.RS +.PP +Note that object-internal commands such as \fBmy\fR and \fBself\fR can be +invoked in this context. +.RE .TP \fIobj \fBunknown ?\fImethodName\fR? ?\fIarg ...\fR? . diff --git a/generic/tclOOBasic.c b/generic/tclOOBasic.c index 792ff9c..13749b2 100644 --- a/generic/tclOOBasic.c +++ b/generic/tclOOBasic.c @@ -415,7 +415,8 @@ TclOO_Object_Eval( */ (void) TclPushStackFrame(interp, (Tcl_CallFrame **) framePtrPtr, - Tcl_GetObjectNamespace(object), 0); + Tcl_GetObjectNamespace(object), FRAME_IS_METHOD); + framePtr->clientData = context; framePtr->objc = objc; framePtr->objv = objv; /* Reference counts do not need to be * incremented here. */ diff --git a/tests/oo.test b/tests/oo.test index a41113d..7210da3 100644 --- a/tests/oo.test +++ b/tests/oo.test @@ -2857,6 +2857,16 @@ test oo-18.11 {OO: define/self command support} -setup { (in definition script for class "::foo" line 1) invoked from within "oo::define foo {rename ::foo {}; self {error foobar}}"} +test oo-18.12 {OO: self callable via eval method} -setup { + oo::class create parent { + export eval + } + parent create ::foo +} -body { + foo eval { self } +} -cleanup { + parent destroy +} -result ::foo test oo-19.1 {OO: varname method} -setup { oo::object create inst -- cgit v0.12 From 2b40376fa31e57a9e8b17ce792cd3cb105fe6988 Mon Sep 17 00:00:00 2001 From: sebres Date: Tue, 16 Jul 2024 16:24:02 +0000 Subject: clock.test: more regression tests: clock-46.[56] cherry-picked from 8.7, clock-46.7 to illustrate regression [3ee8f1c2a785f4d8] (8.6 is not affected) --- tests/clock.test | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/tests/clock.test b/tests/clock.test index b54d9f0..70d527e 100644 --- a/tests/clock.test +++ b/tests/clock.test @@ -36113,6 +36113,25 @@ test clock-46.4 {regression test - month thirteen} \ clock scan 20041301 } -result [clock scan 2005-01-01 -format %Y-%m-%d] +test clock-46.5 {regression test - good time} \ + -body { + # 12:01 apm are valid input strings... + list [clock scan "12:01 am" -base 0 -gmt 1] \ + [clock scan "12:01 pm" -base 0 -gmt 1] + } -result {60 43260} +test clock-46.6 {freescan: regression test - bad time} \ + -body { + # 13:00 am/pm are invalid input strings... + list [clock scan "13:00 am" -base 0 -gmt 1] \ + [clock scan "13:00 pm" -base 0 -gmt 1] + } -result {-1 -1} + +test clock-46.7 {regression test - switch day by large not-valid time, see bug [3ee8f1c2a785f4d8]} { + list [clock scan 23:59:59 -base 0 -gmt 1 -format %H:%M:%S] \ + [clock scan 24:00:00 -base 0 -gmt 1 -format %H:%M:%S] \ + [clock scan 48:00:00 -base 0 -gmt 1 -format %H:%M:%S] +} {86399 86400 172800} + test clock-47.1 {regression test - four-digit time} { clock scan 0012 } [clock scan 0012 -format %H%M] -- cgit v0.12