From: martinahansen Date: Wed, 1 Sep 2010 14:18:50 +0000 (+0000) Subject: reverting ruby unit test to old school X-Git-Url: https://git.donarmstrong.com/?a=commitdiff_plain;h=656eab3e49925bb78efa33267fcceb65b49a5bf5;p=biopieces.git reverting ruby unit test to old school git-svn-id: http://biopieces.googlecode.com/svn/trunk@1074 74ccb610-7750-0410-82ae-013aeee3265d --- diff --git a/code_ruby/Maasha/test/test_fasta.rb b/code_ruby/Maasha/test/test_fasta.rb index dc59f58..23672af 100755 --- a/code_ruby/Maasha/test/test_fasta.rb +++ b/code_ruby/Maasha/test/test_fasta.rb @@ -31,59 +31,59 @@ require 'stringio' require 'pp' class FastaTest < Test::Unit::TestCase - test "Fasta#get_entry obtains the correct seq_name" do + def test_Fasta_get_entry_obtains_the_correct_seq_name fasta = Fasta.new(StringIO.new(">test\nATCG\n")) assert_equal(fasta.get_entry.seq_name, "test") end - test "Fasta#get_entry obtains the correct seq without trailing newlines" do + def test_Fasta_get_entry_obtains_the_correct_seq_without_trailing_newlines fasta = Fasta.new(StringIO.new(">test\nATCG")) assert_equal(fasta.get_entry.seq, "ATCG") end - test "Fasta#get_entry obtains the correct seq with trailing newlines" do + def test_Fasta_get_entry_obtains_the_correct_seq_with_trailing_newlines fasta = Fasta.new(StringIO.new(">test\nATCG\n\n\n")) assert_equal(fasta.get_entry.seq, "ATCG") end - test "Fasta#get_entry obtains the correct type" do + def test_Fasta_get_entry_obtains_the_correct_type fasta = Fasta.new(StringIO.new(">test\nATCG\n"), 'DNA') assert_equal(fasta.get_entry.type, "dna") end - test "Fasta#get_entry rstrips whitespace from seq_name" do + def test_Fasta_get_entry_rstrips_whitespace_from_seq_name fasta = Fasta.new(StringIO.new(">test\n\r\t ATCG\n")) assert_equal(fasta.get_entry.seq_name, "test") end - test "Fasta#get_entry strips whitespace from seq" do + def test_Fasta_get_entry_strips_whitespace_from_seq fasta = Fasta.new(StringIO.new(">test\n\r\t AT\n\r\t CG\n\r\t ")) assert_equal(fasta.get_entry.seq, "ATCG") end - test "Fasta#get_entry with two entries obtain correct" do + def test_Fasta_get_entry_with_two_entries_obtain_correct fasta = Fasta.new(StringIO.new(">test1\n\r\t AT\n\r\t CG\n\r\t \n>test2\n\r\t atcg\n")) assert_equal(fasta.get_entry.seq, "ATCG") assert_equal(fasta.get_entry.seq, "atcg") end - test "Fasta#get_entry without seq_name raises" do + def test_Fasta_get_entry_without_seq_name_raises fasta = Fasta.new(StringIO.new("ATCG\n")) assert_raise( FastaError ) { fasta.get_entry } end - test "Fasta#get_entry without seq raises" do + def test_Fasta_get_entry_without_seq_raises fasta = Fasta.new(StringIO.new(">test\n\n")) assert_raise( FastaError ) { fasta.get_entry } end - test "Fasta#get_entry with leading newline raises" do + def test_Fasta_get_entry_with_leading_newline_raises fasta = Fasta.new(StringIO.new("\n>test\nATCG\n")) assert_raise( FastaError ) { fasta.get_entry } end # FIXME -# test "Fasta#get_entry raises on missing > in seq_name" do +# def test_Fasta_get_entry raises on missing > in seq_name # fasta = Fasta.new(StringIO.new("test\nATCG\n")) # assert_raise( FastaError ) { fasta.get_entry } # end diff --git a/code_ruby/Maasha/test/test_seq.rb b/code_ruby/Maasha/test/test_seq.rb index b8841ac..5fcea28 100755 --- a/code_ruby/Maasha/test/test_seq.rb +++ b/code_ruby/Maasha/test/test_seq.rb @@ -9,141 +9,141 @@ class TestSeq < Test::Unit::TestCase @entry = Seq.new end - # test "Seq# autoremoves whitespace, newlines, and carriage returns" do + # def test_Seq# autoremoves whitespace, newlines, and carriage returns # dna = Seq.new # dna.seq = "A\tT\r\tC\nG " # assert_equal(dna.seq, "ATCG") # end - test "Seq#is_dna with no sequence type returns false" do - assert_false(@entry.is_dna) + def test_Seq_is_dna_with_no_sequence_type_returns_false + assert(@entry.is_dna == false) end - test "Seq#is_dna with dna sequence type returns true" do + def test_Seq_is_dna_with_dna_sequence_type_returns_true @entry.type = 'dna' - assert_true(@entry.is_dna) + assert(@entry.is_dna == true) end - test "Seq#is_rna with no sequence type returns false" do - assert_false(@entry.is_rna) + def test_Seq_is_rna_with_no_sequence_type_returns_false + assert(@entry.is_rna == false) end - test "Seq#is_rna with rna sequence type returns true" do + def test_Seq_is_rna_with_rna_sequence_type_returns_true @entry.type = 'rna' - assert_true(@entry.is_rna) + assert(@entry.is_rna == true) end - test "Seq#is_protein with no sequence type returns false" do - assert_false(@entry.is_protein) + def test_Seq_is_protein_with_no_sequence_type_returns_false + assert(@entry.is_protein == false) end - test "Seq#is_protein with protein sequence type returns true" do + def test_Seq_is_protein_with_protein_sequence_type_returns_true @entry.type = 'protein' - assert_true(@entry.is_protein) + assert(@entry.is_protein == true) end - test "Sequence length is correct" do + def test_Sequence_length_is_correct @entry.seq = 'ATCG' assert_equal(@entry.length, 4) end - test "Seq#to_rna raises if no sequence" do + def test_Seq_to_rna_raises_if_no_sequence @entry.type = 'dna' assert_raise(SeqError) { @entry.to_rna } end - test "Seq#to_rna raises on bad type" do + def test_Seq_to_rna_raises_on_bad_type @entry.seq = 'ATCG' @entry.type = 'rna' assert_raise(SeqError) { @entry.to_rna } end - test "Seq#to_rna transcribes correctly" do + def test_Seq_to_rna_transcribes_correctly @entry.seq = 'ATCGatcg' @entry.type = 'dna' assert_equal(@entry.to_rna, "AUCGaucg") end - test "Seq#to_rna changes entry type to rna" do + def test_Seq_to_rna_changes_entry_type_to_rna @entry.seq = 'ATCGatcg' @entry.type = 'dna' @entry.to_rna assert_equal(@entry.type, "rna") end - test "Seq#to_dna raises if no sequence" do + def test_Seq_to_dna_raises_if_no_sequence @entry.type = 'rna' assert_raise(SeqError) { @entry.to_dna } end - test "Seq#to_dna raises on bad type" do + def test_Seq_to_dna_raises_on_bad_type @entry.seq = 'AUCG' @entry.type = 'dna' assert_raise(SeqError) { @entry.to_dna } end - test "Seq#to_dna transcribes correctly" do + def test_Seq_to_dna_transcribes_correctly @entry.seq = 'AUCGaucg' @entry.type = 'rna' assert_equal(@entry.to_dna, "ATCGatcg") end - test "Seq#to_dna changes entry type to dna" do + def test_Seq_to_dna_changes_entry_type_to_dna @entry.seq = 'AUCGaucg' @entry.type = 'rna' @entry.to_dna assert_equal(@entry.type, "dna") end - test "Seq#to_bp returns correct record" do + def test_Seq_to_bp_returns_correct_record @entry.seq_name = 'test' @entry.seq = 'ATCG' assert_equal(@entry.to_bp, {"SEQ_NAME"=>"test", "SEQ"=>"ATCG", "SEQ_LEN"=>4}) end - test "Seq#to_bp raises on missing seq_name" do + def test_Seq_to_bp_raises_on_missing_seq_name @entry.seq = 'ATCG' assert_raise(SeqError) { @entry.to_bp } end - test "Seq#to_bp raises on missing sequence" do + def test_Seq_to_bp_raises_on_missing_sequence @entry.seq_name = 'test' assert_raise(SeqError) { @entry.to_bp } end - test "Seq#complement raises if no sequence" do + def test_Seq_complement_raises_if_no_sequence @entry.type = 'dna' assert_raise(SeqError) { @entry.complement } end - test "Seq#complement raises on bad type" do + def test_Seq_complement_raises_on_bad_type @entry.seq = 'ATCG' @entry.type = 'protein' assert_raise(SeqError) { @entry.complement } end - test "Seq#complement for DNA is correct" do + def test_Seq_complement_for_DNA_is_correct @entry.seq = 'ATCGatcg' @entry.type = 'dna' assert_equal(@entry.complement, "TAGCtagc") end - test "Seq#complement for RNA is correct" do + def test_Seq_complement_for_RNA_is_correct @entry.seq = 'AUCGaucg' @entry.type = 'rna' assert_equal(@entry.complement, "UAGCuagc") end - test "Seq#generate raises if length <= 0" do + def test_Seq_generate_raises_if_length_lt_0 assert_raise(SeqError) { @entry.generate(-10, "dna") } assert_raise(SeqError) { @entry.generate(0, "dna") } end - test "Seq#generate raises on bad type" do + def test_Seq_generate_raises_on_bad_type assert_raise(SeqError) { @entry.generate(10, "foo") } end - test "Seq#generate don't raise on ok type" do + def test_Seq_generate_dont_raise_on_ok_type %w[ dna DNA rna RNA protein Protein ].each do |type| assert_nothing_raised { @entry.generate(10, type) } end