mirror of
https://github.com/wren-lang/wren.git
synced 2026-01-11 22:28:45 +01:00
Make classes know their name.
This commit is contained in:
9
test/class/name.wren
Normal file
9
test/class/name.wren
Normal file
@ -0,0 +1,9 @@
|
||||
class Foo {}
|
||||
|
||||
IO.print(Foo.name) // expect: Foo
|
||||
IO.print(Foo.type.name) // expect: Foo metaclass
|
||||
|
||||
// Make sure the built-in classes have proper names too.
|
||||
IO.print(Object.name) // expect: Object
|
||||
IO.print(Class.name) // expect: Class
|
||||
IO.print(Bool.name) // expect: Bool
|
||||
@ -8,3 +8,8 @@ IO.print(Foo.type is Class) // expect: true
|
||||
|
||||
// The metatype's metatype is Class.
|
||||
IO.print(Foo.type.type == Class) // expect: true
|
||||
|
||||
// And Class's metatype circles back onto itself.
|
||||
IO.print(Foo.type.type.type == Class) // expect: true
|
||||
IO.print(Foo.type.type.type.type == Class) // expect: true
|
||||
IO.print(Foo.type.type.type.type.type == Class) // expect: true
|
||||
|
||||
@ -1,2 +1,2 @@
|
||||
class Foo {}
|
||||
IO.print((new Foo).toString) // expect: <object>
|
||||
IO.print((new Foo).toString == "instance of Foo") // expect: true
|
||||
|
||||
Reference in New Issue
Block a user