File: helper.rb

package info (click to toggle)
ruby-oj 3.16.12-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 14,192 kB
  • sloc: ansic: 19,659; ruby: 11,750; sh: 70; makefile: 17
file content (35 lines) | stat: -rw-r--r-- 1,119 bytes parent folder | download | duplicates (2)
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
26
27
28
29
30
31
32
33
34
35
# frozen_string_literal: true

# Ubuntu does not accept arguments to ruby when called using env. To get warnings to show up the -w options is
# required. That can be set in the RUBYOPT environment variable.
# export RUBYOPT=-w

$VERBOSE = true

require 'minitest'
require 'minitest/autorun'
require 'stringio'
require 'date'
require 'bigdecimal'
require 'oj'

def verify_gc_compaction
  # This method was added in Ruby 3.0.0. Calling it this way asks the GC to
  # move objects around, helping to find object movement bugs.
  if defined?(GC.verify_compaction_references) == 'method' && RbConfig::CONFIG['host_os'] !~ /(mingw|mswin)/
    if Gem::Version.new(RUBY_VERSION) >= Gem::Version.new('3.2.0')
      GC.verify_compaction_references(expand_heap: true, toward: :empty)
    else
      GC.verify_compaction_references(double_heap: true, toward: :empty)
    end
  end
end

$ruby = RUBY_DESCRIPTION.split(' ')[0]
$ruby = 'ree' if 'ruby' == $ruby && RUBY_DESCRIPTION.include?('Ruby Enterprise Edition')

class Range
  def to_hash
    { 'begin' => self.begin, 'end' => self.end, 'exclude_end' => exclude_end? }
  end
end