Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix missing GC.add_finalizer throughout the stdlib (#5367)
- Loading branch information
1 parent
b549408
commit 0e48aac
Showing
9 changed files
with
107 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
class State | ||
@@count = {} of Symbol => Int64 | ||
|
||
def self.inc(key) | ||
@@count[key] = @@count.fetch(key, 0i64) + 1 | ||
end | ||
|
||
def self.count(key) | ||
@@count.fetch(key, 0i64) | ||
end | ||
|
||
def self.reset | ||
@@count.clear | ||
end | ||
end | ||
|
||
def assert_finalizes(key) | ||
State.reset | ||
State.count(key).should eq(0) | ||
|
||
10.times do | ||
obj = yield | ||
obj.key = key | ||
end | ||
|
||
GC.collect | ||
|
||
State.count(key).should be > 0 | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters