Sha256: 42b663875ce3c5fb6ea51e81b6ddaa1e1276c88185800c00eefab23096e3ca16

Contents?: true

Size: 659 Bytes

Versions: 1

Compression:

Stored size: 659 Bytes

Contents

require 'test_helper'

class NumericTest < Test::Unit::TestCase
  def test_string
    assert "0".numeric?
    assert "-1".numeric?
    assert "1.0".numeric?
    assert "1e1".numeric?
    assert "1/2".numeric?
    assert "0.3-0.5i".numeric?

    assert !"a".numeric?
    assert !"1a".numeric?
    assert !"a1".numeric?
  end

  def test_symbol
    assert :'0'.numeric?

    assert !:a.numeric?
  end

  def test_object
    assert !Object.new.numeric?
    assert !{}.numeric?
  end

  def test_numeric
    assert 1.numeric?
    assert Rational(1,2).numeric?
    assert Complex(1, 1).numeric?
    assert 2.3.numeric?
    assert BigDecimal('1').numeric?
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
numeric-0.2.0 test/numeric_test.rb