Sha256: be513467ac730c2b3e063d73a1ae21a6b64d32fef2197188fd03417be09846c3
Contents?: true
Size: 1.49 KB
Versions: 1
Compression:
Stored size: 1.49 KB
Contents
#!/usr/bin/ruby $:.unshift File.join(File.dirname(__FILE__), "..", "lib") require 'test/unit' require 'extensions' require 'Variable' require 'Domain' class ExtensionsTest < Test::Unit::TestCase def setup @array = Array.new([ 1, 2, 3, 4 ]) end def testRest assert_equal([ 2, 3, 4 ], @array.rest) assert_equal([ true, true ], [ true, true, true ].rest) end 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 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?) res = Array.new @array.eachAfter(5) { |x| res << x } assert_equal([ 1, 2, 3, 4 ], res) end def testEachStartWith res = Array.new @array.eachStartWith(2) { |x| res << x } assert_equal([ 2, 3, 4 ], res) end def testIncludeAny set = [ 1, 2, 3 ].to_set assert_equal(true, set.include_any?([ 1 ])) assert_equal(false, set.include_any?([ 4, 5, 6 ])) end def testIncludeHash hash = { 1 => 2, 3 => 4, 4 => 5 } assert_equal(false, hash.include_hash?({ 2 => 3 })) assert_equal(false, hash.include_hash?({ 1 => 2, 2 => 3, 3 => 4, 4 => 5 })) assert_equal(true, hash.include_hash?({ 1 => 2 })) assert_equal(true, hash.include_hash?({ 4 => 5, 3 => 4, 1 => 2 })) end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
ConstraintSolver-0.1 | test/extensionsTest.rb |