summaryrefslogtreecommitdiffstats
path: root/tests/oo.test
diff options
context:
space:
mode:
authordkf <donal.k.fellows@manchester.ac.uk>2018-05-19 08:38:42 (GMT)
committerdkf <donal.k.fellows@manchester.ac.uk>2018-05-19 08:38:42 (GMT)
commitd431841a06870d53eb32d3ae2e11339e58094aad (patch)
tree449e70058f76d1d2909a2c38fab68a0858a24159 /tests/oo.test
parente6fdfbe93b022e8ac8dc26c7de9706b7b45d422f (diff)
downloadtcl-d431841a06870d53eb32d3ae2e11339e58094aad.zip
tcl-d431841a06870d53eb32d3ae2e11339e58094aad.tar.gz
tcl-d431841a06870d53eb32d3ae2e11339e58094aad.tar.bz2
Corrections for a number of small things to align with TIP
Diffstat (limited to 'tests/oo.test')
-rw-r--r--tests/oo.test88
1 files changed, 87 insertions, 1 deletions
diff --git a/tests/oo.test b/tests/oo.test
index 9563b4f..24f23ae 100644
--- a/tests/oo.test
+++ b/tests/oo.test
@@ -4298,7 +4298,7 @@ test oo-38.2 {TIP 500: private variables introspection} -setup {
} -cleanup {
parent destroy
} -result {{y1 y2} {x1 x2} {b1 b2} {a1 a2}}
-test oo-38.3 {TIP 500: private variables and obj·varname} -setup {
+test oo-38.3 {TIP 500: private variables and oo::object·varname} -setup {
oo::class create parent
} -body {
oo::class create clsA {
@@ -4372,6 +4372,65 @@ test oo-38.4 {TIP 500: private variables introspection} -setup {
} -cleanup {
parent destroy
} -result {ok {ok x1 x2 y1 y2 z} 0 yes {a1 a2 b1 b2 yes z} 0}
+test oo-38.5 {TIP 500: private variables and oo::object·variable} -setup {
+ oo::class create parent
+} -body {
+ oo::class create cls1 {
+ superclass parent
+ private variable x
+ method abc val {
+ my variable x
+ set x $val
+ }
+ method def val {
+ my variable y
+ set y $val
+ }
+ method get1 {} {
+ my variable x y
+ return [list $x $y]
+ }
+ }
+ oo::class create cls2 {
+ superclass cls1
+ private variable x
+ method x-exists {} {
+ return [info exists x],[uplevel 1 {info exists x}]
+ }
+ method ghi x {
+ # Additional instrumentation to show that we're not using the
+ # resolved variable until we ask for it; the argument nixed that
+ # happening by default.
+ set val $x
+ set before [my x-exists]
+ unset x
+ set x $val
+ set mid [my x-exists]
+ unset x
+ set mid2 [my x-exists]
+ my variable x
+ set x $val
+ set after [my x-exists]
+ return "$before;$mid;$mid2;$after"
+ }
+ method jkl val {
+ my variable y
+ set y $val
+ }
+ method get2 {} {
+ my variable x y
+ return [list $x $y]
+ }
+ }
+ cls2 create a
+ a abc 123
+ a def 234
+ set tmp [a ghi 345]
+ a jkl 456
+ list $tmp [a get1] [a get2]
+} -cleanup {
+ parent destroy
+} -result {{0,1;0,1;0,0;1,1} {123 456} {345 456}}
test oo-39.1 {TIP 500: private methods internal call; class private} -setup {
oo::class create parent
@@ -4727,6 +4786,33 @@ test oo-39.12 {TIP 500: private methods; introspection} -setup {
} -cleanup {
parent destroy
} -result {a: {{} {} {}} b: {foo ABC ghi} cls: {chain {} abc} cls2: {chain2 chain3 def}}
+
+test oo-40.1 {TIP 500: private and self} -setup {
+ oo::class create cls
+} -body {
+ oo::define cls {
+ self {
+ private {
+ variable a
+ }
+ variable b
+ }
+ private {
+ self {
+ variable c
+ }
+ variable d
+ }
+ variable e
+ }
+ list \
+ [lsort [info class variables cls]] \
+ [lsort [info class variables cls -private]] \
+ [lsort [info object variables cls]] \
+ [lsort [info object variables cls -private]]
+} -cleanup {
+ cls destroy
+} -result {e d b {a c}}
cleanupTests
return