<commit_before>require 'test_helper'

describe Slop::BoolOption do
  before do
    @options  = Slop::Options.new
    @verbose  = @options.bool "--verbose"
    @quiet    = @options.bool "--quiet"
    @inversed = @options.bool "--inversed", default: true
    @bloc     = @options.bool("--bloc"){|val| (@bloc_val ||= []) << val}
    @result   = @options.parse %w(--verbose --no-inversed
                                  --bloc --no-bloc)
  end

  it "returns true if used" do
    assert_equal true, @result[:verbose]
  end

  it "returns false if not used" do
    assert_equal false, @result[:quiet]
  end

  it "can be inversed via --no- prefix" do
    assert_equal false, @result[:inversed]
  end

  it "will invert the value passed to &block via --no- prefix" do
    assert_equal [true, false], @bloc_val
  end
end

describe Slop::IntegerOption do
  before do
    @options = Slop::Options.new
    @age     = @options.integer "--age"
    @result  = @options.parse %w(--age 20)
  end

  it "returns the value as an integer" do
    assert_equal 20, @result[:age]
  end

  it "returns nil for non-numbers by default" do<commit_msg>Test integer with plus sign as prefix<commit_after>require 'test_helper'

describe Slop::BoolOption do
  before do
    @options  = Slop::Options.new
    @verbose  = @options.bool "--verbose"
    @quiet    = @options.bool "--quiet"
    @inversed = @options.bool "--inversed", default: true
    @bloc     = @options.bool("--bloc"){|val| (@bloc_val ||= []) << val}
    @result   = @options.parse %w(--verbose --no-inversed
                                  --bloc --no-bloc)
  end

  it "returns true if used" do
    assert_equal true, @result[:verbose]
  end

  it "returns false if not used" do
    assert_equal false, @result[:quiet]
  end

  it "can be inversed via --no- prefix" do
    assert_equal false, @result[:inversed]
  end

  it "will invert the value passed to &block via --no- prefix" do
    assert_equal [true, false], @bloc_val
  end
end

describe Slop::IntegerOption do
  before do
    @options = Slop::Options.new
    @age     = @options.integer "--age"
    @minus   = @options.integer "--minus"
    @plus    = @options.integer "--plus"
    @result  = @options.parse %w(--age 20 --minus -10 --plus +30)
  end

  it "returns the value as an integer" do
    assert_equal 20, @result[:age]
    assert_equal -10, @result[:minus]
    assert_equal 30, @result[:plus]
  end

  it "returns nil for non-numbers by default" do
{'fraction_non_alphanumeric': 0.13373983739837397, 'fraction_numerical': 0.0065040650406504065, 'mean_word_length': 2.629793510324484, 'pattern_counts': {'":': 0, '<': 7, '<?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': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1157901', 'n_tokens_mistral': 853, 'n_tokens_neox': 799, 'n_words': 255}