Sha256: a35d594358ad7841a156c28dd94f17ad42a6d73e78aff3b175858cc12c619266

Contents?: true

Size: 954 Bytes

Versions: 65

Compression:

Stored size: 954 Bytes

Contents

# frozen_string_literal: true

require "spec_helper"

RSpec.describe Code::Object::Integer do
  [
    ["10 % 5", "0"],
    ["5 * 2", "10"],
    ["2 ** 2", "4"],
    ["1 + 1", "2"],
    ["1 - 0", "1"],
    ["-1", "1 - 2"],
    ["1 / 2", "0.5"],
    ["1 < 2", "true"],
    ["1 <= 1", "true"],
    ["1 <=> 2", "-1"],
    ["1 > 0", "true"],
    ["1 >= 1", "true"],
    ["1 === 1", "true"],
    %w[-1.abs 1],
    %w[-1.ceil -1],
    %w[1234.ceil(-2) 1300],
    %w[-1.floor -1],
    %w[1234.floor(-2) 1200],
    %w[1.round 1],
    %w[1234.round(-2) 1200],
    %w[1.clone 1],
    %w[0.zero? true],
    %w[1.truncate 1],
    %w[1234.truncate(-2) 1200],
    %w[1.to_string :1],
    %w[1.to_integer 1],
    %w[1.to_decimal 1.0],
    %w[4.sqrt 2.0],
    ["1 + 2", "3"],
    ["2 - 1", "1"],
    ["a = 2 - 1 a", "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/integer_spec.rb
code-ruby-1.1.1 spec/code/object/integer_spec.rb
code-ruby-1.1.0 spec/code/object/integer_spec.rb
code-ruby-1.0.0 spec/code/object/integer_spec.rb
code-ruby-0.15.16 spec/code/object/integer_spec.rb
code-ruby-0.15.15 spec/code/object/integer_spec.rb
code-ruby-0.15.14 spec/code/object/integer_spec.rb
code-ruby-0.15.13 spec/code/object/integer_spec.rb
code-ruby-0.15.12 spec/code/object/integer_spec.rb
code-ruby-0.15.11 spec/code/object/integer_spec.rb
code-ruby-0.15.10 spec/code/object/integer_spec.rb
code-ruby-0.15.9 spec/code/object/integer_spec.rb
code-ruby-0.15.8 spec/code/object/integer_spec.rb
code-ruby-0.15.7 spec/code/object/integer_spec.rb
code-ruby-0.15.6 spec/code/object/integer_spec.rb
code-ruby-0.15.5 spec/code/object/integer_spec.rb
code-ruby-0.15.4 spec/code/object/integer_spec.rb
code-ruby-0.15.3 spec/code/object/integer_spec.rb
code-ruby-0.15.2 spec/code/object/integer_spec.rb
code-ruby-0.15.0 spec/code/object/integer_spec.rb