Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
branch: master
Fetching contributors…

Octocat-spinner-32-eaf2f5

Cannot retrieve contributors at this time

executable file 28 lines (20 sloc) 0.503 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
#!/usr/bin/env ruby

require 'test/unit'

class MetaprogramTest < Test::Unit::TestCase

  def test_method_send
    assert_equal(4, "mike".send(:length))
  end

  def test_method_call
    m = "Mike".method(:length)
    assert_equal(4, m.call)
  end

  def test_eval
    code = %q{"Mike".length}
    assert_equal(4, eval(code))
  end

  def test_new_class
    class_name = "Mike"
    mike_class = instance_eval %{Object::#{class_name} = Class.new(Object)}
    assert_kind_of Object, mike_class
  end

end
Something went wrong with that request. Please try again.