Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 37 additions & 0 deletions test/net/imap/test_data_lite.rb
Original file line number Diff line number Diff line change
Expand Up @@ -340,6 +340,43 @@ def other
assert_equal("test", data.name)
assert_equal("other", data.other)
end

class Abstract < Data
end

class Inherited < Abstract.define(:foo)
end

def test_subclass_can_create
assert_equal 1, Inherited[1] .foo
assert_equal 2, Inherited[foo: 2].foo
assert_equal 3, Inherited.new(3).foo
assert_equal 4, Inherited.new(foo: 4).foo
end

class AbstractWithClassMethod < Data
def self.inherited_class_method; :ok end
end

class InheritsClassMethod < AbstractWithClassMethod.define(:foo)
end

def test_subclass_class_method
assert_equal :ok, InheritsClassMethod.inherited_class_method
end

class AbstractWithOverride < Data
def deconstruct; [:ok, *super] end
end

class InheritsOverride < AbstractWithOverride.define(:foo)
end

def test_subclass_override_deconstruct
data = InheritsOverride[:foo]
assert_equal %i[ok foo], data.deconstruct
end

end
end
end