diff options
Diffstat (limited to 'tests/ooNext2.test')
-rw-r--r-- | tests/ooNext2.test | 195 |
1 files changed, 95 insertions, 100 deletions
diff --git a/tests/ooNext2.test b/tests/ooNext2.test index 6c4f1ad..6a48d28 100644 --- a/tests/ooNext2.test +++ b/tests/ooNext2.test @@ -874,25 +874,29 @@ test oo-call-3.4 {current call introspection: in destructors} -setup { # A method ought to work "the same" whether or not it has been overridden by # a subclass. A tailcalled command ought to have as parent stack the same # thing you'd get with uplevel 1. A subclass will often expect the -# superclass's result to be the result that would be returned if the subclass -# was not there. -# +# superclass's result to be the result that would be returned if the +# subclass was not there. -# common setup: -# any invocation of bar should emit "abc\nhi\n" then return to its caller +# Common setup: +# any invocation of bar should emit "abc\nhi\n" then return to its +# caller set testopts { -setup { - oo::class create Foo { - method bar {} { - puts abc - tailcall puts hi - puts xyz - } - } + oo::class create Master + oo::class create Foo { + superclass Master + method bar {} { + puts abc + tailcall puts hi + puts xyz + } + } + oo::class create Foo2 { + superclass Master + } } -cleanup { - catch {Foo destroy} - catch {Foo2 destroy} ;# created by some tests + Master destroy } } @@ -900,68 +904,63 @@ set testopts { test next-tailcall-simple-1 "trivial case with one method" {*}$testopts -body { [Foo create foo] bar } -output [join {abc hi} \n]\n - test next-tailcall-simple-2 "my bar" {*}$testopts -body { oo::define Foo method baz {} { - puts a - my bar - puts b + puts a + my bar + puts b } [Foo create foo] baz } -output [join {a abc hi b} \n]\n - test next-tailcall-simple-3 "\[self\] bar" {*}$testopts -body { oo::define Foo method baz {} { - puts a - [self] bar - puts b + puts a + [self] bar + puts b } [Foo create foo] baz } -output [join {a abc hi b} \n]\n - test next-tailcall-simple-4 "foo bar" {*}$testopts -body { oo::define Foo method baz {} { - puts a - foo bar - puts b + puts a + foo bar + puts b } [Foo create foo] baz } -output [join {a abc hi b} \n]\n # everything from here on uses [next], and fails on 8.6.4 with compilation test next-tailcall-superclass-1 "next superclass" {*}$testopts -body { - oo::class create Foo2 { - superclass Foo - method bar {} { - puts a - next - puts b - } + oo::define Foo2 { + superclass Foo + method bar {} { + puts a + next + puts b + } } [Foo2 create foo] bar } -output [join {a abc hi b} \n]\n - test next-tailcall-superclass-2 "nextto superclass" {*}$testopts -body { - oo::class create Foo2 { - superclass Foo - method bar {} { - puts a - nextto Foo - puts b - } + oo::define Foo2 { + superclass Foo + method bar {} { + puts a + nextto Foo + puts b + } } [Foo2 create foo] bar } -output [join {a abc hi b} \n]\n - test next-tailcall-mixin-1 "class mixin" {*}$testopts -body { - oo::class create Foo2 { - method Bar {} { - puts a - next - puts b - } - filter Bar + oo::define Foo2 { + method Bar {} { + puts a + next + puts b + } + filter Bar } oo::define Foo mixin Foo2 Foo create foo @@ -969,13 +968,13 @@ test next-tailcall-mixin-1 "class mixin" {*}$testopts -body { } -output [join {a abc hi b} \n]\n test next-tailcall-objmixin-1 "object mixin" {*}$testopts -body { - oo::class create Foo2 { - method Bar {} { - puts a - next - puts b - } - filter Bar + oo::define Foo2 { + method Bar {} { + puts a + next + puts b + } + filter Bar } Foo create foo oo::objdefine foo mixin Foo2 @@ -984,9 +983,9 @@ test next-tailcall-objmixin-1 "object mixin" {*}$testopts -body { test next-tailcall-filter-1 "filter method" {*}$testopts -body { oo::define Foo method Filter {} { - puts a - next - puts b + puts a + next + puts b } oo::define Foo filter Filter [Foo new] bar @@ -994,37 +993,37 @@ test next-tailcall-filter-1 "filter method" {*}$testopts -body { test next-tailcall-forward-1 "forward method" {*}$testopts -body { proc foobar {} { - puts "abc" - tailcall puts "hi" - puts "xyz" + puts "abc" + tailcall puts "hi" + puts "xyz" } oo::define Foo forward foobar foobar - oo::class create Foo2 { - superclass Foo - method foobar {} { - puts a - next - puts b - } + oo::define Foo2 { + superclass Foo + method foobar {} { + puts a + next + puts b + } } [Foo2 new] foobar } -output [join {a abc hi b} \n]\n test next-tailcall-constructor-1 "next in constructor" -body { oo::class create Foo { - constructor {} { - puts abc - tailcall puts hi - puts xyz - } + constructor {} { + puts abc + tailcall puts hi + puts xyz + } } oo::class create Foo2 { - superclass Foo - constructor {} { - puts a - next - puts b - } + superclass Foo + constructor {} { + puts a + next + puts b + } } list [Foo new] [Foo2 new] return "" @@ -1032,35 +1031,31 @@ test next-tailcall-constructor-1 "next in constructor" -body { Foo destroy } -output [join {abc hi a abc hi b} \n]\n - test next-tailcall-destructor-1 "next in destructor" -body { oo::class create Foo { - destructor { - puts abc - tailcall puts hi - puts xyz - } + destructor { + puts abc + tailcall puts hi + puts xyz + } } oo::class create Foo2 { - superclass Foo - destructor { - puts a - next - puts b - } - } - Foo create foo + superclass Foo + destructor { + puts a + next + puts b + } + } + Foo create foo Foo2 create foo2 foo destroy foo2 destroy -} -output [join {abc hi a abc hi b} \n]\n - - - +} -output [join {abc hi a abc hi b} \n]\n -cleanup { + Foo destroy +} unset testopts - - cleanupTests return |