]> git.donarmstrong.com Git - biopieces.git/blobdiff - code_ruby/test/maasha/seq/test_dynamic.rb
changed Seq.new argument to hash
[biopieces.git] / code_ruby / test / maasha / seq / test_dynamic.rb
index 8e1121e28fd60ea8c301c83da48d0bee0843e62f..9879c7565dc11f18dc1d99d4c04e2b2e78519791 100755 (executable)
@@ -1,5 +1,5 @@
 #!/usr/bin/env ruby
-$:.unshift File.join(File.dirname(__FILE__),'..','lib')
+$:.unshift File.join(File.dirname(__FILE__), '..', '..', '..')
 
 # Copyright (C) 2007-2010 Martin A. Hansen.
 
@@ -26,24 +26,20 @@ $:.unshift File.join(File.dirname(__FILE__),'..','lib')
 # >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>><<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
 
 require 'maasha/seq'
-require 'maasha/seq/dynamic'
 require 'test/unit'
-require 'pp'
-
-class Seq
-  include Dynamic
-end
+require 'test/helper'
 
 class TestDynamic < Test::Unit::TestCase
   def setup
-    @p = Seq.new("test", "atcg")
+    @p = Seq.new(seq_name: "test", seq: "atcg")
+    @p.extend(Dynamic)
   end
 
-  def test_Dynamic_no_match_returns_nil
+  test "#patmatch with no match returns nil" do
     assert_nil(@p.patmatch("gggg"))
   end
 
-  def test_Dynamic_patmatch_perfect_returns_correctly
+  test "#patmatch with perfect match returns correctly" do
     m = @p.patmatch("atcg")
     assert_equal(0, m.beg)
     assert_equal("atcg", m.match)
@@ -53,7 +49,7 @@ class TestDynamic < Test::Unit::TestCase
     assert_equal(4, m.length)
   end
 
-  def test_Dynamic_patmatch_perfect_with_ambiguity_codes_returns_correctly
+  test "#patmatch with perfect match with ambiguity codes returns correctly" do
     m = @p.patmatch("nnnn")
     assert_equal(0, m.beg)
     assert_equal("atcg", m.match)
@@ -63,11 +59,11 @@ class TestDynamic < Test::Unit::TestCase
     assert_equal(4, m.length)
   end
 
-  def test_Dynamic_patmatch_with_one_mismatch_and_edit_dist_zero_returns_nil
+  test "#patmatch with one mismatch and edit dist zero returns nil" do
     assert_nil(@p.patmatch("aCcg"))
   end
 
-  def test_Dynamic_patmatch_with_one_mismatch_and_edit_dist_one_returns_correctly
+  test "#patmatch with one mismatch and edit dist one returns correctly" do
     m = @p.patmatch("aCcg", 0, 1)
     assert_equal(0, m.beg)
     assert_equal("atcg", m.match)
@@ -77,15 +73,15 @@ class TestDynamic < Test::Unit::TestCase
     assert_equal(4, m.length)
   end
 
-  def test_Dynamic_patmatch_with_two_mismatch_and_edit_dist_one_returns_nil
+  test "#patmatch with two mismatch and edit dist one returns nil" do
     assert_nil(@p.patmatch("aGcA", 0, 1))
   end
 
-  def test_Dynamic_patmatch_with_one_insertion_and_edit_dist_zero_returns_nil
+  test "#patmatch with one insertion and edit dist zero returns nil" do
     assert_nil(@p.patmatch("atGcg"))
   end
 
-  def test_Dynamic_patmatch_with_one_insertion_and_edit_dist_one_returns_correctly
+  test "#patmatch with one insertion and edit dist one returns correctly" do
     m = @p.patmatch("atGcg", 0, 1)
     assert_equal(0, m.beg)
     assert_equal("atcg", m.match)
@@ -95,11 +91,11 @@ class TestDynamic < Test::Unit::TestCase
     assert_equal(4, m.length)
   end
 
-  def test_Dynamic_patmatch_with_two_insertions_and_edit_dist_one_returns_nil
+  test "#patmatch with two insertions and edit dist one returns nil" do
     assert_nil(@p.patmatch("atGcTg", 0, 1))
   end
 
-  def test_Dynamic_patmatch_with_two_insertions_and_edit_dist_two_returns_correctly
+  test "#patmatch with two insertions and edit dist two returns correctly" do
     m = @p.patmatch("atGcTg", 0, 2)
     assert_equal(0, m.beg)
     assert_equal("atcg", m.match)
@@ -109,11 +105,11 @@ class TestDynamic < Test::Unit::TestCase
     assert_equal(4, m.length)
   end
 
-  def test_Dynamic_patmatch_with_one_deletion_and_edit_distance_zero_returns_nil
+  test "#patmatch with one deletion and edit distance zero returns nil" do
     assert_nil(@p.patmatch("acg"))
   end
 
-  def test_Dynamic_patmatch_with_one_deletion_and_edit_distance_one_returns_correctly
+  test "#patmatch with one deletion and edit distance one returns correctly" do
     m = @p.patmatch("acg", 0, 1)
     assert_equal(0, m.beg)
     assert_equal("atcg", m.match)
@@ -123,13 +119,15 @@ class TestDynamic < Test::Unit::TestCase
     assert_equal(4, m.length)
   end
 
-  def test_Dynamic_patscan_locates_three_patterns_ok
-    p = Seq.new("test", "ataacgagctagctagctagctgactac")
+  test "#patscan locates three patterns ok" do
+    p = Seq.new(seq_name: "test", seq: "ataacgagctagctagctagctgactac")
+    p.extend(Dynamic)
     assert_equal(3, p.patscan("tag").count)
   end
 
-  def test_Dynamic_patscan_with_pos_locates_two_patterns_ok
-    p = Seq.new("test", "ataacgagctagctagctagctgactac")
+  test "#patscan with pos locates two patterns ok" do
+    p = Seq.new(seq_name: "test", seq: "ataacgagctagctagctagctgactac")
+    p.extend(Dynamic)
     assert_equal(2, p.patscan("tag", 10).count)
   end
 end