Class ExtensionsTest
In: test/extensionsTest.rb
Parent: Test::Unit::TestCase
ExtensionsTest Test::Unit::TestCase dot/f_0.png

Methods

Public Instance methods

[Source]

# File test/extensionsTest.rb, line 11
    def setup
        @array = Array.new([ 1, 2, 3, 4 ])
    end

[Source]

# File test/extensionsTest.rb, line 26
    def testEachAfter
        res = Array.new
        @array.eachAfter(2) { |x| res << x }
        assert_equal([ 3, 4 ], res)
        res = Array.new
        @array.eachAfter(4) { |x| res << x }
        assert_equal(true, res.empty?)
    end

[Source]

# File test/extensionsTest.rb, line 20
    def testFoldLeft
        assert_equal(6, [ 1, 2, 3 ].foldLeft(Proc.new { |a,b| a + b }))
        assert_equal(false, [ false, false, false ].foldLeft(Proc.new { |a,b| a & b }))
        assert_equal(true, [ false, true, false ].foldLeft(Proc.new { |a,b| a | b }))
    end

[Source]

# File test/extensionsTest.rb, line 15
    def testRest
        assert_equal([ 2, 3, 4 ], @array.rest)
        assert_equal([ true, true ], [ true, true, true ].rest)
    end

[Validate]