[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.ruby

case statement not being picked up

aidy

8/14/2006 2:07:00 PM

Hi,

This is my code and I have printed out some de-bug statements. I
haven't a clue why the task = 'validate' switch statement is not being
executed.

<code>
class Form

def initialize
#see if file exists, what file or we going to use?
#@filename = "search.txt"
@filename = "validate.txt"
end

def enter_data
task = nil
count = 1
flag = 0

read_in_test_data.each { |x|
line = x.chomp
#debug
p "line = #{x.chomp}"
case line
when /^\*+ TESTID_\d+$/
p line.gsub(/\*/, '')
flag += 1
if flag > 1
$ie.back
count = 1
end
when /^Address:$/
task = :address
when /^Country:$/
task = :country
when /^Search-Results:$/
task = :search
when /^Validate:$/
task = :validate
when /^Expected-Result:$/
task = :verify
when /^END:$/
$ie.close
else
p "the task = #{task}"
case task
when :address
$ie.text_field(:name, "AL#{count}").set(line)
count += 1
when :country
$ie.text_field(:name, 'C1').set(line)
when :validate
$ie.button(:value, 'Validate').click
when :search
$ie.text_field(:name, 'NR1').set(line)
$ie.button(:value, 'Search').click
when :verify
if $ie.contains_text(line)
p line, "PASS"
else
p line, "FAIL"
end
else
#whatever
end
end
}
end


def read_in_test_data
#check if file exists and give date of last change
File.readlines(@filename, "\n" )
end
private:read_in_test_data
end
<code>


debug statements
"line = *********************************************** TESTID_100"
" TESTID_100"
"line = Address:"
"line = Choyce Close"
"the task = address"
"line = Country:"
"line = GB"
"the task = country"
"line = Validate:"
"line = Expected-Result:"
"line = Is Complete: "
"the task = verify"

the file being read

*********************************************** TESTID_100
Address:
Choyce Close
Country:
GB
Validate:
Expected-Result:
Is Complete:
false
Confidence Level:
0
Address:
Postal Authority Formatted Address:
Choyce Close
United Kingdom
*********************************************** TESTID_200

etc

Much appreciated

Aidy

2 Answers

aidy

8/14/2006 3:01:00 PM

0

I am still struggling without a visual debugger within an IDE, even
though I have ordered a license of Arachno Ruby it may take a couple of
days for that license to be sent.

The Arachno developers have promised that the debugger will work with
Ruby 184x

Cheers

Aidy

Carlos

8/14/2006 3:45:00 PM

0

aidy wrote:
> Hi,
>
> This is my code and I have printed out some de-bug statements. I
> haven't a clue why the task = 'validate' switch statement is not being
> executed.
>
> <code>
[...]

Check your indentation. You read a line. If you recognize it, you set
the task. If you don't recognize it, you print "the task = ..." and do
something related to the task.

Since "Expected-Result" is recognized, you never get to process the
validate action. You need to intercalate a blank line or something (or
change your algorithm).
--