test/term_test.rb in polynomials-0.2.0 vs test/term_test.rb in polynomials-0.3.0
- old
+ new
@@ -1,6 +1,7 @@
-require_relative 'test_helper'
+require "#{File.dirname(File.expand_path(__FILE__))}/test_helper"
+
class TestTerm < MiniTest::Unit::TestCase
def test_initializer
assert_equal 0, Term.new.coefficient
assert_equal 0, Term.new.exponent
end
@@ -21,9 +22,15 @@
end
def test_parsing_variable_omitted
assert_equal 6, Term.parse('6').coefficient
assert_equal 0, Term.parse('6').exponent
+ end
+
+ def test_dup
+ term = Term.new(2,10)
+ assert_equal term.coefficient, term.dup.coefficient
+ assert_equal term.exponent, term.dup.exponent
end
def test_invalid_string_raises_not_parsable_error
['6x^ -5', '6^20', '2 2', 'xx', '2 ^ x'].each do |not_parsable_string|
assert_raises NotParsableError do