From bebd05fb51ea65bc57344b67100748200f8311eb Mon Sep 17 00:00:00 2001 From: Daniel Pepper Date: Fri, 2 Jun 2023 17:35:11 -0700 Subject: [ruby/singleton] Simplify the implementation (https://github.com/ruby/singleton/pull/7) Remove `__init__` and move logic to `included`. --- test/test_singleton.rb | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'test') diff --git a/test/test_singleton.rb b/test/test_singleton.rb index b3c48bb5f5..b08972b9d5 100644 --- a/test/test_singleton.rb +++ b/test/test_singleton.rb @@ -94,6 +94,13 @@ class TestSingleton < Test::Unit::TestCase assert_same a, b end + def test_inheritance_creates_separate_singleton + a = SingletonTest.instance + b = Class.new(SingletonTest).instance + + assert_not_same a, b + end + def test_class_level_cloning_preserves_singleton_behavior klass = SingletonTest.clone @@ -101,4 +108,8 @@ class TestSingleton < Test::Unit::TestCase b = klass.instance assert_same a, b end + + def test_class_level_cloning_creates_separate_singleton + assert_not_same SingletonTest.instance, SingletonTest.clone.instance + end end -- cgit v1.2.3