Reputation: 1234
I'm trying to update variable. ${value} and ${value_count}:
test with FOR
${value} evaluate 2
@{list} set variable 1 2 3 4 5
FOR ${i} IN @{list}
${type_value} evaluate type(${value})
log ${type_value}
${value} run keyword if $i in $list evaluate ${value} - 1
log ${value}
END
the first passes but following fails.
another test
@{value} set variable 2 4
@{result} set variable 1 2 3 4 5
${list_length} get length ${result}
${value_count} get length ${value}
FOR ${i} IN @{result}
${type_value} evaluate type(${value_count})
log ${type_value}
log ${value_count}
${value_count}= run keyword if $i in $value evaluate ${value_count} - 1
log ${value_count}
exit for loop if $i in $value and $value_count == 0
${list_length} evaluate ${list_length} - 1
END
should not be equal as integers ${list_length} 0
Upvotes: 0
Views: 984
Reputation: 134
I am not sure what is the objective of the test cases but when performing following line
${value_count}= run keyword if $i in $value evaluate ${value_count} - 1
if the condition is False then your variable will be set to None so when trying to subtract 1 from None you get an error. I have added an Else to that line so if the condition is False then the variable keeps the same value.
test with FOR
${value} evaluate 2
@{list} set variable 1 2 3 4 5
FOR ${i} IN @{list}
${type_value} evaluate type(${value})
log ${type_value}
${value} run keyword if $i in $list evaluate ${value} - 1
... ELSE set variable ${value}
log ${value}
END
another test
@{value} set variable 2 4
@{result} set variable 1 2 3 4 5
${list_length} get length ${result}
${value_count} get length ${value}
FOR ${i} IN @{result}
${type_value} evaluate type(${value_count})
log ${type_value}
log ${value_count}
${value_count}= run keyword if $i in $value evaluate ${value_count} - 1
... ELSE set variable ${value_count}
log ${value_count}
exit for loop if $i in $value and ${value_count} == 0
${list_length} evaluate ${list_length} - 1
END
should not be equal as integers ${list_length} 0
Upvotes: 1