Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge commit '6753bc586300f70a63cf6ae59829b40e25030145'
- Loading branch information
Showing
4 changed files
with
57 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
package require "TclOO" | ||
package provide "TclOO::ext::autorelease_pool" "1.0" | ||
|
||
oo::class create AutoreleasePool { | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
package require "TclOO::ext::class" | ||
|
||
ext::class create TestClass { | ||
meta method defined_on_meta {} { | ||
return "meta" | ||
} | ||
|
||
self method defined_on_self {} { | ||
return "self" | ||
} | ||
|
||
method defined_on_instance {} { | ||
return "instance" | ||
} | ||
} | ||
|
||
ext::class create SubClass { | ||
superclass TestClass | ||
} | ||
|
||
ext::class create OtherTestClass { | ||
|
||
} | ||
|
||
ext::class create MultipleSuperClasses { | ||
superclass SubClass OtherTestClass | ||
} | ||
|
||
describe "ext::class" { | ||
specify "meta methods are available on classes" { | ||
expect [TestClass defined_on_meta] to equal "meta" | ||
} | ||
|
||
specify "subclasses inherit meta methods" { | ||
expect [SubClass defined_on_meta] to equal "meta" | ||
} | ||
|
||
specify "each class is an instance of its metaclass" { | ||
expect [info object class TestClass] to equal "::TestClass.Meta" | ||
expect [info object class SubClass] to equal "::SubClass.Meta" | ||
} | ||
|
||
specify "the metaclass of a subclass is a subclass of the superclass metaclass" { | ||
expect [info class superclass [info object class SubClass]] to equal [list "::TestClass.Meta" "::oo::class"] | ||
} | ||
|
||
specify "the metaclass contains all superclass metaclasses" { | ||
expect [info class superclass [info object class MultipleSuperClasses]] to equal [list "::SubClass.Meta" "::OtherTestClass.Meta" "::oo::class"] | ||
} | ||
} |