Sha256: da98834a3fb0d4fa09892f546b9ed7f0813ee223a05b7f644657e92f16ee247d

Contents?: true

Size: 725 Bytes

Versions: 1

Compression:

Stored size: 725 Bytes

Contents

require 'test_helper'

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

    # MRI's BigDecimal is too relaxed in what it accepts
    #pending !"a".decimal?
    #pending !"1a".decimal?
    #pending !"a1".decimal?
  end

  def test_symbol
    assert :'0'.decimal?

    #pend !:a.decimal?
  end

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

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

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
numeric-0.2.0 test/decimal_test.rb