diff options
author | Eric Wong <e@80x24.org> | 2018-07-16 20:19:01 +0000 |
---|---|---|
committer | Eric Wong <e@80x24.org> | 2018-07-16 21:14:13 +0000 |
commit | 7e397839dc09800298a8ca2a94855ce73effd52d (patch) | |
tree | fe016a964aea1e864b8f6eb51045cbafaa43eee2 /test/test_mwrap.rb | |
parent | 1f1b644928a1b166b73623691674a45c7e3612a3 (diff) | |
download | mwrap-7e397839dc09800298a8ca2a94855ce73effd52d.tar.gz |
Tracking memory used for monitoring code itself is noise, so give users the power to omit it.
Diffstat (limited to 'test/test_mwrap.rb')
-rw-r--r-- | test/test_mwrap.rb | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/test/test_mwrap.rb b/test/test_mwrap.rb index bc8694e..8425c35 100644 --- a/test/test_mwrap.rb +++ b/test/test_mwrap.rb @@ -252,4 +252,24 @@ class TestMwrap < Test::Unit::TestCase loc.name.frozen? or abort 'SourceLocation#name not frozen' end; end + + def test_quiet + assert_separately(+"#{<<~"begin;"}\n#{<<~'end;'}") + begin; + require 'mwrap' + before = __LINE__ + res = Mwrap.quiet do |depth| + depth == 1 or abort 'depth is not 1' + ('a' * 10000).clear + Mwrap.quiet { |d| d == 2 or abort 'depth is not 2' } + :foo + end + after = __LINE__ - 1 + (before..after).each do |lineno| + Mwrap["#{__FILE__}:#{lineno}"] and + abort "unexpectedly tracked allocation at line #{lineno}" + end + res == :foo or abort 'Mwrap.quiet did not return block result' + end; + end end |