diff options
author | dkf <donal.k.fellows@manchester.ac.uk> | 2018-07-07 08:45:00 (GMT) |
---|---|---|
committer | dkf <donal.k.fellows@manchester.ac.uk> | 2018-07-07 08:45:00 (GMT) |
commit | 27110774bd87b00612e7c3ff97d7af542d364d42 (patch) | |
tree | 7aa9b0168add76c55eefe2490843dfc998a81a9f | |
parent | 5a06fd4bcf87ea7fc607798714be8886927c1b15 (diff) | |
download | tcl-27110774bd87b00612e7c3ff97d7af542d364d42.zip tcl-27110774bd87b00612e7c3ff97d7af542d364d42.tar.gz tcl-27110774bd87b00612e7c3ff97d7af542d364d42.tar.bz2 |
Added direct tests for [myclass]
-rw-r--r-- | tests/oo.test | 53 |
1 files changed, 53 insertions, 0 deletions
diff --git a/tests/oo.test b/tests/oo.test index 7e0f12e..b2c269b 100644 --- a/tests/oo.test +++ b/tests/oo.test @@ -4845,6 +4845,59 @@ test oo-40.3 {TIP 500: private and unexport} -setup { } -cleanup { cls destroy } -result {{} {} foo {} foo {}} + +test oo-41.1 {TIP 478: myclass command, including class morphing} -setup { + oo::class create parent + set result {} +} -body { + oo::class create cls1 { + superclass parent + self method count {} { + my variable c + incr c + } + method act {} { + myclass count + } + } + cls1 create x + lappend result [x act] [x act] + cls1 create y + lappend result [y act] [y act] [x act] + oo::class create cls2 { + superclass cls1 + self method count {} { + my variable d + expr {1.0 * [incr d]} + } + } + oo::objdefine x {class cls2} + lappend result [x act] [y act] [x act] [y act] +} -cleanup { + parent destroy +} -result {1 2 3 4 5 1.0 6 2.0 7} +test oo-41.2 {TIP 478: myclass command cleanup} -setup { + oo::class create parent + set result {} +} -body { + oo::class create cls1 { + superclass parent + self method hi {} { + return "this is [self]" + } + method hi {} { + return "this is [self]" + } + } + cls1 create x + rename [info object namespace x]::my foo + rename [info object namespace x]::myclass bar + lappend result [cls1 hi] [x hi] [foo hi] [bar hi] + x destroy + lappend result [catch {foo hi}] [catch {bar hi}] +} -cleanup { + parent destroy +} -result {{this is ::cls1} {this is ::x} {this is ::x} {this is ::cls1} 1 1} cleanupTests return |