Sha256: 78b015aa37e05cf617286a5536a0526e8bc4d3833562e67e6bcb81b798572889

Contents?: true

Size: 635 Bytes

Versions: 65

Compression:

Stored size: 635 Bytes

Contents

# frozen_string_literal: true

require "spec_helper"

RSpec.describe Code::Object::Range do
  [
    %w[(0..1).any?(&:even?) true],
    %w[(0..1).all?(&:even?) false],
    ["a = 0 (0..1).each { a += 1 } a", "2"],
    ["(0..1).select(&:even?)", "[0]"],
    ["(0..1).map(&:increment)", "[1, 2]"],
    ["(0..10).step(3)", "[0, 3, 6, 9]"],
    ["(0...9).step(3)", "[0, 3, 6]"],
    ["(0..1).to_list", "[0, 1]"],
    ["(0...1).to_list", "[0]"],
    %w[(0..1).first 0],
    %w[(0..1).last 1]
  ].each do |input, expected|
    it "#{input} == #{expected}" do
      expect(Code.evaluate(input)).to eq(Code.evaluate(expected))
    end
  end
end

Version data entries

65 entries across 65 versions & 1 rubygems

Version Path
code-ruby-1.1.3 spec/code/object/range_spec.rb
code-ruby-1.1.1 spec/code/object/range_spec.rb
code-ruby-1.1.0 spec/code/object/range_spec.rb
code-ruby-1.0.0 spec/code/object/range_spec.rb
code-ruby-0.15.16 spec/code/object/range_spec.rb
code-ruby-0.15.15 spec/code/object/range_spec.rb
code-ruby-0.15.14 spec/code/object/range_spec.rb
code-ruby-0.15.13 spec/code/object/range_spec.rb
code-ruby-0.15.12 spec/code/object/range_spec.rb
code-ruby-0.15.11 spec/code/object/range_spec.rb
code-ruby-0.15.10 spec/code/object/range_spec.rb
code-ruby-0.15.9 spec/code/object/range_spec.rb
code-ruby-0.15.8 spec/code/object/range_spec.rb
code-ruby-0.15.7 spec/code/object/range_spec.rb
code-ruby-0.15.6 spec/code/object/range_spec.rb
code-ruby-0.15.5 spec/code/object/range_spec.rb
code-ruby-0.15.4 spec/code/object/range_spec.rb
code-ruby-0.15.3 spec/code/object/range_spec.rb
code-ruby-0.15.2 spec/code/object/range_spec.rb
code-ruby-0.15.0 spec/code/object/range_spec.rb