review comments incorporated
This commit is contained in:
parent
fa28475b71
commit
2e3b614c92
@ -13,7 +13,7 @@ module Parfait
|
|||||||
# Object length is measured in non-type cells though
|
# Object length is measured in non-type cells though
|
||||||
|
|
||||||
class Word < Data8
|
class Word < Data8
|
||||||
attr_reader :char_length , :str, :prefix ,:next_word
|
attr_reader :char_length ,:next_word
|
||||||
|
|
||||||
|
|
||||||
def self.type_length
|
def self.type_length
|
||||||
@ -194,14 +194,14 @@ module Parfait
|
|||||||
end
|
end
|
||||||
def start_with(other)
|
def start_with(other)
|
||||||
return false if other.length > self.length
|
return false if other.length > self.length
|
||||||
@str=self.to_string
|
str=self.to_string
|
||||||
@prefix=other.to_string
|
prefix=other.to_string
|
||||||
s = @str.size()
|
s = str.size()
|
||||||
temp=""
|
temp=""
|
||||||
i=0
|
i=0
|
||||||
while i<=s-1
|
while i<=s-1
|
||||||
temp=temp+@str[i]
|
temp=temp+str[i]
|
||||||
if temp==@prefix
|
if temp==prefix
|
||||||
return true
|
return true
|
||||||
end
|
end
|
||||||
i=i+1
|
i=i+1
|
||||||
|
@ -85,29 +85,27 @@ module Parfait
|
|||||||
assert one.compare(two)
|
assert one.compare(two)
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_start_with
|
def test_start_with1
|
||||||
one = Parfait.new_word("Hello")
|
one = Parfait.new_word("Hello")
|
||||||
two = Parfait.new_word("Hel")
|
two = Parfait.new_word("Hel")
|
||||||
assert one.start_with(two)
|
assert one.start_with(two)
|
||||||
|
end
|
||||||
|
def test_start_with2
|
||||||
one = Parfait.new_word("Vanilla")
|
one = Parfait.new_word("Vanilla")
|
||||||
two = Parfait.new_word("Va")
|
two = Parfait.new_word("Va")
|
||||||
assert one.start_with(two)
|
assert one.start_with(two)
|
||||||
|
end
|
||||||
|
def test_start_with3
|
||||||
one = Parfait.new_word("hello")
|
one = Parfait.new_word("hello")
|
||||||
two = Parfait.new_word("hellooo")
|
two = Parfait.new_word("hellooo")
|
||||||
assert_equal false, one.start_with(two)
|
assert_equal false, one.start_with(two)
|
||||||
|
end
|
||||||
|
def test_start_with4
|
||||||
one = Parfait.new_word("bajjs")
|
one = Parfait.new_word("bajjs")
|
||||||
two = Parfait.new_word("bgjj")
|
two = Parfait.new_word("bgjj")
|
||||||
assert_equal false, one.start_with(two)
|
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
|
end
|
||||||
|
|
||||||
def test_first_char
|
def test_first_char
|
||||||
one = Parfait.new_word("one")
|
one = Parfait.new_word("one")
|
||||||
one.set_char(0 , "T".ord)
|
one.set_char(0 , "T".ord)
|
||||||
|
Loading…
Reference in New Issue
Block a user