Sha256: 46e5f3315d02830f19a4c3cc22816ac6e6d8cc70491b7964d33a20acc92fb6c8

Contents?: true

Size: 631 Bytes

Versions: 14

Compression:

Stored size: 631 Bytes

Contents

# Test facets/prototype.rb

require 'facets/prototype.rb'

require 'test/unit'

class TestPrototypeKernel < Test::Unit::TestCase

  def test_new
    q = nil
    s = "Testing"
    assert_nothing_raised { q = s.new }
    assert_equal( s, q )
    assert_not_equal( s.object_id, q.object_id )
  end
end

class TestPrototype < Test::Unit::TestCase

  def setup
    @person = prototype do
      @name = ''
      @age = 0
      @announce = fn { |x| "#{x}, #{name} is #{age}" }
    end

    @person.name = 'Tom'
    @person.age = 35
  end

  def test_simple_case
    assert_equal( "Peter, Tom is 35", @person.announce['Peter'])
  end

end

Version data entries

14 entries across 14 versions & 1 rubygems

Version Path
facets-2.6.0 test/more/test_prototype.rb
facets-2.1.3 test/unit/test_prototype.rb
facets-2.3.0 test/more/test_prototype.rb
facets-2.4.0 test/test_prototype.rb
facets-2.2.0 test/unit/test_prototype.rb
facets-2.2.1 test/unit/test_prototype.rb
facets-2.4.1 test/test_prototype.rb
facets-2.4.3 test/more/test_prototype.rb
facets-2.4.2 test/more/test_prototype.rb
facets-2.4.4 test/more/test_prototype.rb
facets-2.5.0 test/more/test_prototype.rb
facets-2.4.5 test/more/test_prototype.rb
facets-2.5.1 test/more/test_prototype.rb
facets-2.5.2 test/more/test_prototype.rb