From ab8ddedd6ca3afa05df64efae039b07475e6884e Mon Sep 17 00:00:00 2001 From: Genta Kamitani Date: Fri, 12 Jul 2019 11:39:40 +0900 Subject: [PATCH] add test for removing constants that are already removed --- padrino-core/test/fixtures/dependencies/gc/t.rb | 5 +++++ padrino-core/test/fixtures/dependencies/gc/u.rb | 3 +++ padrino-core/test/fixtures/dependencies/gc/v.rb | 10 ++++++++++ padrino-core/test/fixtures/dependencies/gc/w.rb | 2 ++ padrino-core/test/fixtures/dependencies/gc/x.rb | 2 ++ padrino-core/test/fixtures/dependencies/gc/y.rb | 2 ++ padrino-core/test/test_dependencies.rb | 9 +++++++++ 7 files changed, 33 insertions(+) create mode 100644 padrino-core/test/fixtures/dependencies/gc/t.rb create mode 100644 padrino-core/test/fixtures/dependencies/gc/u.rb create mode 100644 padrino-core/test/fixtures/dependencies/gc/v.rb create mode 100644 padrino-core/test/fixtures/dependencies/gc/w.rb create mode 100644 padrino-core/test/fixtures/dependencies/gc/x.rb create mode 100644 padrino-core/test/fixtures/dependencies/gc/y.rb diff --git a/padrino-core/test/fixtures/dependencies/gc/t.rb b/padrino-core/test/fixtures/dependencies/gc/t.rb new file mode 100644 index 000000000..59dca3de5 --- /dev/null +++ b/padrino-core/test/fixtures/dependencies/gc/t.rb @@ -0,0 +1,5 @@ +Padrino.require_dependencies( + Padrino.root("fixtures/dependencies/gc/v.rb"), + Padrino.root("fixtures/dependencies/gc/w.rb"), + Padrino.root("fixtures/dependencies/gc/x.rb") +) diff --git a/padrino-core/test/fixtures/dependencies/gc/u.rb b/padrino-core/test/fixtures/dependencies/gc/u.rb new file mode 100644 index 000000000..fe2de5dc4 --- /dev/null +++ b/padrino-core/test/fixtures/dependencies/gc/u.rb @@ -0,0 +1,3 @@ +Padrino.require_dependencies( + Padrino.root("fixtures/dependencies/gc/y.rb") +) diff --git a/padrino-core/test/fixtures/dependencies/gc/v.rb b/padrino-core/test/fixtures/dependencies/gc/v.rb new file mode 100644 index 000000000..1642773cb --- /dev/null +++ b/padrino-core/test/fixtures/dependencies/gc/v.rb @@ -0,0 +1,10 @@ +class V + $prevent_from_being_gced ||= [] + $prevent_from_being_gced.push(self) + + def self.hello + "hello" + end + + W +end diff --git a/padrino-core/test/fixtures/dependencies/gc/w.rb b/padrino-core/test/fixtures/dependencies/gc/w.rb new file mode 100644 index 000000000..60d58c7c3 --- /dev/null +++ b/padrino-core/test/fixtures/dependencies/gc/w.rb @@ -0,0 +1,2 @@ +class W +end diff --git a/padrino-core/test/fixtures/dependencies/gc/x.rb b/padrino-core/test/fixtures/dependencies/gc/x.rb new file mode 100644 index 000000000..d9d8a6699 --- /dev/null +++ b/padrino-core/test/fixtures/dependencies/gc/x.rb @@ -0,0 +1,2 @@ +class X < Y +end diff --git a/padrino-core/test/fixtures/dependencies/gc/y.rb b/padrino-core/test/fixtures/dependencies/gc/y.rb new file mode 100644 index 000000000..f0452c6f6 --- /dev/null +++ b/padrino-core/test/fixtures/dependencies/gc/y.rb @@ -0,0 +1,2 @@ +class Y +end diff --git a/padrino-core/test/test_dependencies.rb b/padrino-core/test/test_dependencies.rb index c5a3c06fb..fe3373027 100644 --- a/padrino-core/test/test_dependencies.rb +++ b/padrino-core/test/test_dependencies.rb @@ -77,6 +77,15 @@ assert_equal "hello", M.hello end + it 'should not remove constants that are already `remove_const`ed' do + capture_io do + Padrino.require_dependencies( + Padrino.root("fixtures/dependencies/gc/t.rb"), + Padrino.root("fixtures/dependencies/gc/u.rb") + ) + end + assert_equal "hello", V.hello + end describe "change log level for :devel" do before do