<commit_before>require 'spec_helper'

describe Location do
  let(:location) {
    Location.new(
      lat: BigDecimal.new('2.0'),
      lng: BigDecimal.new('3.0'),
      radius: 300,
      speed: 2,
      course: 30)
  }

  it "converts values to Float" do
    expect(location.lat).to equal 2.0
    expect(location.lng).to equal 3.0
    expect(location.radius).to equal 300.0
    expect(location.speed).to equal 2.0
    expect(location.course).to equal 30.0
  end

  it "provides hash-style access to its properties with both symbol and string keys" do
    expect(location[:lat]).to equal 2.0
    expect(location['lat']).to equal 2.0
  end

  it "does not allow hash-style assignment" do
    expect {
      location[:lat] = 2.0
    }.to raise_error
  end

  it "ignores invalid values" do
    location2 = Location.new(
      lat: 2,
      lng: 3,
      radius: -1,
      speed: -1,
      course: -1)
    expect(location2.radius).to be_nil
    expect(location2.speed).to be_nil
    expect(location2.course).to be_nil
  end

  it "considers a location empty if either latitude or longitude is missing" do
    expect(Location.new.empty?).to be_truthy
    expect(Location.new(lat: 2, radius: 1).present?).to be_falsy
    expect(Location.new(lng: 3, radius: 1).present?).to be_falsy<commit_msg>OK, Ruby 2.1 has introduced flonum, so do not expect identity.<commit_after>require 'spec_helper'

describe Location do
  let(:location) {
    Location.new(
      lat: BigDecimal.new('2.0'),
      lng: BigDecimal.new('3.0'),
      radius: 300,
      speed: 2,
      course: 30)
  }

  it "converts values to Float" do
    expect(location.lat).to be_a Float
    expect(location.lat).to be 2.0
    expect(location.lng).to be_a Float
    expect(location.lng).to be 3.0
    expect(location.radius).to be_a Float
    expect(location.radius).to be 300.0
    expect(location.speed).to be_a Float
    expect(location.speed).to be 2.0
    expect(location.course).to be_a Float
    expect(location.course).to be 30.0
  end

  it "provides hash-style access to its properties with both symbol and string keys" do
    expect(location[:lat]).to be_a Float
    expect(location[:lat]).to be 2.0
    expect(location['lat']).to be_a Float
    expect(location['lat']).to be 2.0
  end

  it "does not allow hash-style assignment" do
    expect {
      location[:lat] = 2.0
    }.to raise_error
  end

  it "ignores invalid values" do
    location2 = Location.new(
      lat: 2,
      lng: 3,
      radius: -1,
      speed: -1,
      course: -1)
    expect(location2.radius).to be_nil
    expect(location2.speed).to be_nil
    expect(location2.course).to be_nil
  end

  it "considers a location empty if either latitude or longitude is missing" do
    expect(Location.new.empty?).to be_truthy
    expect(Location.new(lat: 2, radius: 1).present?).to be_falsy
    expect(Location.new(lng: 3, radius: 1).present?).to be_falsy
{'fraction_non_alphanumeric': 0.1165283540802213, 'fraction_numerical': 0.029737206085753802, 'mean_word_length': 2.888440860215054, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6686888', 'n_tokens_mistral': 1033, 'n_tokens_neox': 961, 'n_words': 274}