review comments incorporated

This commit is contained in:
chhavikirtani2000 2020-03-28 18:57:29 +05:30 committed by Torsten Rüger
parent fa28475b71
commit 2e3b614c92
2 changed files with 14 additions and 16 deletions

View File

@ -13,7 +13,7 @@ module Parfait
# Object length is measured in non-type cells though
class Word < Data8
attr_reader :char_length , :str, :prefix ,:next_word
attr_reader :char_length ,:next_word
def self.type_length
@ -194,14 +194,14 @@ module Parfait
end
def start_with(other)
return false if other.length > self.length
@str=self.to_string
@prefix=other.to_string
s = @str.size()
str=self.to_string
prefix=other.to_string
s = str.size()
temp=""
i=0
while i<=s-1
temp=temp+@str[i]
if temp==@prefix
temp=temp+str[i]
if temp==prefix
return true
end
i=i+1

View File

@ -85,29 +85,27 @@ module Parfait
assert one.compare(two)
end
def test_start_with
def test_start_with1
one = Parfait.new_word("Hello")
two = Parfait.new_word("Hel")
assert one.start_with(two)
end
def test_start_with2
one = Parfait.new_word("Vanilla")
two = Parfait.new_word("Va")
assert one.start_with(two)
end
def test_start_with3
one = Parfait.new_word("hello")
two = Parfait.new_word("hellooo")
assert_equal false, one.start_with(two)
end
def test_start_with4
one = Parfait.new_word("bajjs")
two = Parfait.new_word("bgjj")
assert_equal false, one.start_with(two)
#one = Parfait.new_word("hel")
#two = Parfait.new_word("hellooo")
#assert_equal false, one.start_with(two)
#one = Parfait.new_word("Vanilla")
#two = Parfait.new_word("vani")
#assert one.start_with(two)
#assert_equal true , @word.start_with("hello","hell")
#assert_equal true , @word.start_with("Adbfgsj","Adbf")
#assert_equal false , @word.start_with("Vanila","van")
end
def test_first_char
one = Parfait.new_word("one")
one.set_char(0 , "T".ord)