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-0.6.4 spec/code/object/range_spec.rb
code-ruby-0.6.3 spec/code/object/range_spec.rb
code-ruby-0.6.2 spec/code/object/range_spec.rb
code-ruby-0.6.1 spec/code/object/range_spec.rb
code-ruby-0.6.0 spec/code/object/range_spec.rb