diff options
author | Daniel Pepper <pepper.daniel@gmail.com> | 2023-06-02 17:35:11 -0700 |
---|---|---|
committer | git <svn-admin@ruby-lang.org> | 2023-06-03 00:35:18 +0000 |
commit | bebd05fb51ea65bc57344b67100748200f8311eb (patch) | |
tree | 371c2ab64251e480df6b6e7f5b03e2313c4de95c /test | |
parent | 4e26ae3cb93d6f22edef9d4fa1221e94b7abded2 (diff) | |
download | ruby-bebd05fb51ea65bc57344b67100748200f8311eb.tar.gz |
[ruby/singleton] Simplify the implementation
(https://github.com/ruby/singleton/pull/7)
Remove `__init__` and move logic to `included`.
Diffstat (limited to 'test')
-rw-r--r-- | test/test_singleton.rb | 11 |
1 files changed, 11 insertions, 0 deletions
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 |