From e18d7f592196530ea7602ea21a0a5341f08f960c Mon Sep 17 00:00:00 2001 From: aspect Date: Mon, 27 Mar 2017 13:02:22 +0000 Subject: Correct this use of isWanted to ensure NO_IMPLEMENTATION methods are not listed (bug [900cb0284bc]) --- generic/tclOOCall.c | 1 + tests/oo.test | 38 ++++++++++++++++++++++++++++++++++++++ 2 files changed, 39 insertions(+) diff --git a/generic/tclOOCall.c b/generic/tclOOCall.c index 8003345..c861eb9 100644 --- a/generic/tclOOCall.c +++ b/generic/tclOOCall.c @@ -618,6 +618,7 @@ AddClassMethodNames( if (isNew) { int isWanted = (!(flags & PUBLIC_METHOD) || (mPtr->flags & PUBLIC_METHOD)) ? IN_LIST : 0; + isWanted |= (mPtr->typePtr == NULL ? NO_IMPLEMENTATION : 0); Tcl_SetHashValue(hPtr, INT2PTR(isWanted)); } else if ((PTR2INT(Tcl_GetHashValue(hPtr)) & NO_IMPLEMENTATION) diff --git a/tests/oo.test b/tests/oo.test index ccb05c1..290e41d 100644 --- a/tests/oo.test +++ b/tests/oo.test @@ -2242,6 +2242,44 @@ test oo-17.10 {OO: class introspection} -setup { info class methods foo -all } -result {} +test oo-17.11 {OO: object method unexport (bug 900cb0284bc)} -setup { + oo::object create o + oo::objdefine o unexport m +} -cleanup { + o destroy +} -body { + expr {"m" in [info object methods o -all -private]} +} -result 0 +test oo-17.12 {OO: instance method unexport (bug 900cb0284bc)} -setup { + oo::class create c + c create o + oo::objdefine o unexport m +} -cleanup { + o destroy + c destroy +} -body { + expr {"m" in [info object methods o -all -private]} +} -result 0 +test oo-17.13 {OO: class method unexport (bug 900cb0284bc)} -setup { + oo::class create c + oo::define c unexport m +} -cleanup { + c destroy +} -body { + expr {"m" in [info class methods c -all -private]} +} -result 0 +test oo-17.14 {OO: instance method unexport (bug 900cb0284bc)} -setup { + oo::class create c + oo::define c unexport m + c create o +} -cleanup { + o destroy + c destroy +} -body { + expr {"m" in [info object methods o -all -private]} +} -result 0 + + test oo-18.1 {OO: define command support} { list [catch {oo::define oo::object {error foo}} msg] $msg $errorInfo } {1 foo {foo -- cgit v0.12 From 41c4744202449c4e812732d5ff09104f866c1409 Mon Sep 17 00:00:00 2001 From: dkf Date: Wed, 29 Mar 2017 19:05:17 +0000 Subject: Tweak to make tests a little clearer. --- generic/tclOOCall.c | 2 +- tests/oo.test | 26 +++++++++++++------------- 2 files changed, 14 insertions(+), 14 deletions(-) diff --git a/generic/tclOOCall.c b/generic/tclOOCall.c index c861eb9..ac0b94d 100644 --- a/generic/tclOOCall.c +++ b/generic/tclOOCall.c @@ -618,8 +618,8 @@ AddClassMethodNames( if (isNew) { int isWanted = (!(flags & PUBLIC_METHOD) || (mPtr->flags & PUBLIC_METHOD)) ? IN_LIST : 0; - isWanted |= (mPtr->typePtr == NULL ? NO_IMPLEMENTATION : 0); + isWanted |= (mPtr->typePtr == NULL ? NO_IMPLEMENTATION : 0); Tcl_SetHashValue(hPtr, INT2PTR(isWanted)); } else if ((PTR2INT(Tcl_GetHashValue(hPtr)) & NO_IMPLEMENTATION) && mPtr->typePtr != NULL) { diff --git a/tests/oo.test b/tests/oo.test index 290e41d..e03911b 100644 --- a/tests/oo.test +++ b/tests/oo.test @@ -2241,43 +2241,43 @@ test oo-17.10 {OO: class introspection} -setup { oo::define foo unexport {*}[info class methods foo -all] info class methods foo -all } -result {} - +set stdmethods { destroy eval unknown variable varname} test oo-17.11 {OO: object method unexport (bug 900cb0284bc)} -setup { oo::object create o oo::objdefine o unexport m +} -body { + lsort [info object methods o -all -private] } -cleanup { o destroy -} -body { - expr {"m" in [info object methods o -all -private]} -} -result 0 +} -result $stdmethods test oo-17.12 {OO: instance method unexport (bug 900cb0284bc)} -setup { oo::class create c c create o oo::objdefine o unexport m +} -body { + lsort [info object methods o -all -private] } -cleanup { o destroy c destroy -} -body { - expr {"m" in [info object methods o -all -private]} -} -result 0 +} -result $stdmethods test oo-17.13 {OO: class method unexport (bug 900cb0284bc)} -setup { oo::class create c oo::define c unexport m +} -body { + lsort [info class methods c -all -private] } -cleanup { c destroy -} -body { - expr {"m" in [info class methods c -all -private]} -} -result 0 +} -result $stdmethods test oo-17.14 {OO: instance method unexport (bug 900cb0284bc)} -setup { oo::class create c oo::define c unexport m c create o +} -body { + lsort [info object methods o -all -private] } -cleanup { o destroy c destroy -} -body { - expr {"m" in [info object methods o -all -private]} -} -result 0 +} -result $stdmethods test oo-18.1 {OO: define command support} { -- cgit v0.12