fedora-migrator /vendor/gems/facets-2.4.5/test/more/test_prototype.rb

Language Ruby Lines 36
MD5 Hash 10842930928d458c553bde20032248cc Estimated Cost $562 (why?)
Repository https://bitbucket.org/mediashelf/fedora-migrator View Raw File
 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
# 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
Back to Top