Skip to content

Commit

Permalink
Add specs for
Browse files Browse the repository at this point in the history
  • Loading branch information
ytjmt committed Jan 4, 2023
1 parent 71a3af7 commit ee33456
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions library/objectspace/trace_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
require_relative '../../spec_helper'

ruby_version_is "3.1" do
describe 'require "objspace/trace"' do
it "shows object allocation sites" do
code = <<-RUBY
require "objspace/trace"
a = "foo"
b = "b" + "a" + "r"
c = 42
p a, b, c
RUBY

lines = ruby_exe(code, args: "2>&1").lines(chomp: true)
lines.size.should == 4
lines[0].should == "objspace/trace is enabled"
lines[1].should =~ /\A"foo" @ .*:2\z/
lines[2].should =~ /\A"bar" @ .*:3\z/
lines[3].should == "42"
end
end
end

0 comments on commit ee33456

Please sign in to comment.