Introduce a new static method `Object.same(obj1, obj2)` that exposes the VM's built-in equality semantics (`wrenValuesEqual`) directly, bypassing any user-defined `==` overrides. This required creating a dedicated metaclass for Object (subclass of Class) to host the static method without polluting every class with a `same` method. The implementation wires up a new `Object metaclass` in the core initialization sequence, adjusts the class hierarchy setup order, and adds comprehensive tests covering value types, identity comparison, and verification that `Object.same` ignores custom `==` operators.
14 lines
400 B
Plaintext
14 lines
400 B
Plaintext
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(Bool.name) // expect: Bool
|
|
IO.print(Class.name) // expect: Class
|
|
|
|
// And metaclass names.
|
|
IO.print(Object.type.name) // expect: Object metaclass
|
|
IO.print(Bool.type.name) // expect: Bool metaclass
|