Skip to content
This repository
tree: 7152c1834a
Fetching contributors…

Cannot retrieve contributors at this time

file 40 lines (35 sloc) 0.964 kb
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40
require 'test/unit'

# Test that core class methods are correctly raising errors for incorrect call
# arities.
class TestCoreArities < Test::Unit::TestCase
  def assert_argerr(&b)
    assert_raises(ArgumentError, &b)
  end

  def test_fixnum
    assert_argerr { 1.+(1,2) }
    assert_argerr { 1.-(1,2) }
    assert_argerr { 1.<(1,2) }
  end

  def test_array
    assert_argerr { [].+(1,2) }
    assert_argerr { [].pop(1,2) }
    assert_argerr { [].nil?(1) }
    assert_argerr { [].==(1,2) }
    assert_argerr { [].<<(1,2) }
    assert_argerr { [].empty?(1) }
  end

  def test_bignum
    assert_argerr { (2**500).+(1,2) }
    assert_argerr { (2**500).-(1,2) }
    assert_argerr { (2**500).<(1,2) }
  end

  def test_string
    assert_argerr { "".+(1,2) }
    assert_argerr { "".<(1,2) }
    assert_argerr { "".nil?(1) }
    assert_argerr { "".==(1,2) }
    assert_argerr { "".>=(1,2) }
    assert_argerr { "".<<(1,2) }
    assert_argerr { "".empty?(1) }
  end
end
Something went wrong with that request. Please try again.