summaryrefslogtreecommitdiff
path: root/spec/ruby/core/tracepoint/instruction_sequence_spec.rb
blob: 3e3b73cccc575870d657b15cb3c7bc92a654f27b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
require_relative '../../spec_helper'
require_relative 'fixtures/classes'

ruby_version_is "2.6" do
  describe "TracePoint#instruction_sequence" do
    it "is an instruction sequence" do
      ScratchPad.record []

      script = <<-CODE
        def foo
          p :hello
        end
      CODE

      TracePoint.new(:script_compiled) do |e|
        ScratchPad << e.instruction_sequence
      end.enable do
        eval script
      end

      ScratchPad.recorded.size.should == 1
      ScratchPad.recorded[0].class.should == RubyVM::InstructionSequence
    end
  end
end