Variable

De Software testing
Ir para: navegação, pesquisa

Facts

Fact

Consider the following notation:

Three possibilities exist for the first occurrence of a variable through a program path:

  • d the variable does not exist, then it is defined (correct)
  • u the variable does not exist, then it is used (incorrect - depends on the language)
  • k the variable does not exist, then it is killed or destroyed (probably incorrect)

Now consider the following time-sequenced pairs of defined (d), used (u), and killed (k):

dd Defined and defined again Not invalid, but suspicious
du Defined and used Perfectly correct
dk Defined and then killed Not invalid, but suspicious
ud Used and defined Acceptable
uu Used and used again Acceptable
uk Used and killed Acceptable
kd Killed and defined Acceptable
ku Killed and used A serious defect
kk Killed and killed Probably a programming error

References

  • <bib>copeland:2004</bib>
  • <bib>vincenzi-maldonado:slides:2007</bib>