From 7bb1c361a59a34324d58f365b5c867c238e869b1 Mon Sep 17 00:00:00 2001 From: Torsten Ruger Date: Sat, 31 Dec 2016 15:17:45 +0200 Subject: [PATCH] small word test --- lib/typed/parfait/word.rb | 2 +- test/typed/parfait/test_word.rb | 13 ++++++++++++- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/lib/typed/parfait/word.rb b/lib/typed/parfait/word.rb index a787224c..d014417e 100644 --- a/lib/typed/parfait/word.rb +++ b/lib/typed/parfait/word.rb @@ -162,7 +162,7 @@ module Parfait # compare the word to another # currently checks for same class, though really identity of the characters # in right order would suffice - def == other + def compare( other ) return false if other.class != self.class return false if other.length != self.length len = self.length diff --git a/test/typed/parfait/test_word.rb b/test/typed/parfait/test_word.rb index a375bd2d..4a31e2f1 100644 --- a/test/typed/parfait/test_word.rb +++ b/test/typed/parfait/test_word.rb @@ -1,5 +1,5 @@ require_relative "../helper" - +module Parfait class TestEmptyWord < MiniTest::Test def setup @@ -99,4 +99,15 @@ class TestWord < MiniTest::Test assert_equal v , @word.get_char(k) end end + def test_not_same + one = Parfait.new_word("one") + two = Parfait.new_word("two") + assert !one.compare(two) + end + def test_is_same + one = Parfait.new_word("one") + two = Parfait.new_word("one") + assert one.compare(two) + end +end end