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

ruby_version_is "2.6" do
  describe "#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