[BioRuby-cvs] bioruby/test/unit/bio test_map.rb,1.5,1.6

Jan Aerts aerts at dev.open-bio.org
Thu Apr 12 12:19:19 UTC 2007


Update of /home/repository/bioruby/bioruby/test/unit/bio
In directory dev.open-bio.org:/tmp/cvs-serv32200/test/unit/bio

Modified Files:
	test_map.rb 
Log Message:
* Added mappings_on method to Bio::Map::ActsLikeMarker.
* Extended unit tests to get 100% coverage.


Index: test_map.rb
===================================================================
RCS file: /home/repository/bioruby/bioruby/test/unit/bio/test_map.rb,v
retrieving revision 1.5
retrieving revision 1.6
diff -C2 -d -r1.5 -r1.6
*** test_map.rb	5 Apr 2007 23:35:42 -0000	1.5
--- test_map.rb	12 Apr 2007 12:19:16 -0000	1.6
***************
*** 41,44 ****
--- 41,45 ----
        @marker3 = Bio::Map::Marker.new('marker3')
        @map1 = Bio::Map::SimpleMap.new('map1', 'some_type', 'some_unit')
+       @map2 = Bio::Map::SimpleMap.new('map2', 'some_other_type', 'some_other_unit')
      end
  
***************
*** 101,104 ****
--- 102,108 ----
        @marker1.add_mapping_as_marker(@map1, '53')  # This mapping should _not_ be added, because it's already defined.
        assert_equal(3, @marker1.mappings_as_marker.length)
+       
+       @map1.add_mapping_as_map(@marker1, '53')
+       assert_equal(3, @marker1.mappings_as_marker.length)
      end
      
***************
*** 110,113 ****
--- 114,159 ----
        assert_equal('5,37', @marker1.positions_on(@map1).collect{|p| p.first.from.to_s}.sort{|a,b| a.to_i <=> b.to_i}.join(',')) # FIXME: Test is not correct (uses Location.first)
      end
+     
+     def test_mappings_on
+       @map1.add_mapping_as_map(@marker1, '5')
+       @map1.add_mapping_as_map(@marker1, '37')
+       assert_equal('5,37', @marker1.mappings_on(@map1).sort{|a,b| a.location[0].from.to_i <=> b.location[0].from.to_i}.collect{|m| m.location[0].from}.join(',')) # FIXME: Test is not correct (uses Location.first)
+     end    
+     
+     def test_mapping_location_comparison
+       @map1.add_mapping_as_map(@marker1, '5')
+       @map1.add_mapping_as_map(@marker2, '5')
+       @map1.add_mapping_as_map(@marker3, '17')
+       
+       mapping1 = @marker1.mappings_on(@map1)[0]
+       mapping2 = @marker2.mappings_on(@map1)[0]
+       mapping3 = @marker3.mappings_on(@map1)[0]
+       assert_equal(true, mapping1 == mapping2)
+       assert_equal(false, mapping1 < mapping2)
+       assert_equal(false, mapping1 > mapping2)
+       assert_equal(false, mapping1 == mapping3)
+       assert_equal(true, mapping1 < mapping3)
+       assert_equal(false, mapping1 > mapping3)
+       
+       @map2.add_mapping_as_map(@marker1, '23')
+       mapping4 = @marker1.mappings_on(@map2)[0]
+       assert_raise(RuntimeError) { mapping2 < mapping4 }
+     end
+     
+     def test_raise_error_kind_of
+       marker_without_class = 'marker1'
+       assert_raise(RuntimeError) { @map1.add_mapping_as_map(marker_without_class, '5') }
+       assert_raise(RuntimeError) { @map1.contains_marker?(marker_without_class) }
+       
+       map_without_class = 'map1'
+       assert_raise(RuntimeError) { @marker1.add_mapping_as_marker(map_without_class, '5') }
+       assert_raise(RuntimeError) { @marker1.mapped_to?(map_without_class) }
+       assert_raise(RuntimeError) { @marker1.positions_on(map_without_class) }
+       assert_raise(RuntimeError) { @marker1.mappings_on(map_without_class) }
+       
+       @map1.add_mapping_as_map(@marker1, '5')
+       mapping1 = @marker1.mappings_on(@map1)[0]
+       assert_raise(RuntimeError) { mapping1 > 'some_mapping' }
+     end
    end
  	




More information about the bioruby-cvs mailing list