#set square 0
if { [isdraw result] } {
   #check if result is valid

   puts [checkshape result]
   set prop "square"
   set mass $square
   regexp {Mass +: +([-0-9.+eE]+)} [sprops result] full m      

   if { [string compare "$mass" "empty"] != 0 } {
      if { $m == 0 } {
       	 puts "Error : The $command is not valid. The $prop is 0."
      }
      if { $mass > 0 } {
      	 puts "The expected $prop is $mass"
      }
      #check of change of square is < 1%
      if { ($mass != 0 && [expr 1.*abs($mass - $m)/$mass] > 0.01) || ($mass == 0 && $m != 0) } {
      	 puts "Error : The $prop of the resulting shape is $m"
      }
   } else {
      if { $m != 0 } {
       	 puts "Error : The $command is not valid. The $prop is $m"
      }
   }

   set glob_inf [info global nb_*_good]
   if { [regexp "nb_.*_good" $glob_inf] == 1 } {
      if { [info exists nbsh_t] } {
      	 set nb_info [nbshapes result -t]
      } else {
      	 set nb_info [nbshapes result]
      }
   }

   if { [info exists nb_v_good] } {
      regexp {VERTEX +: +([-0-9.+eE]+)} $nb_info full nb_v
      if { ${nb_v} != ${nb_v_good} } {
      	 puts "Error : The resulting shape is WRONG because it must contains ${nb_v_good} vertexes instead of ${nb_v}"
      } else {
         puts "The resulting shape contains ${nb_v} vertexes"
      }
   }

   if { [info exists nb_e_good] } {
      regexp {EDGE +: +([-0-9.+eE]+)} $nb_info full nb_e
      if { ${nb_e} != ${nb_e_good} } {
      	 puts "Error : The resulting shape is WRONG because it must contains ${nb_e_good} edges instead of ${nb_e}"
      } else {
      	 puts "The resulting shape contains ${nb_e} edges"
      }
   }

   if { [info exists nb_w_good] } {
      regexp {WIRE +: +([-0-9.+eE]+)} $nb_info full nb_w
      if { ${nb_w} != ${nb_w_good} } {
      	 puts "Error : The resulting shape is WRONG because it must contains ${nb_w_good} wires instead of ${nb_w}"
      } else {
      	 puts "The resulting shape contains ${nb_w} wires"
      }
   }

   if { [info exists nb_f_good] } {
      regexp {FACE +: +([-0-9.+eE]+)} $nb_info full nb_f
      if { ${nb_f} != ${nb_f_good} } {
      	 puts "Error : The resulting shape is WRONG because it must contains ${nb_f_good} faces instead of ${nb_f}"
      } else {
       	 puts "The resulting shape contains ${nb_f} faces"
      }
   }

   if { [info exists nb_sh_good] } {
      regexp {SHELL +: +([-0-9.+eE]+)} $nb_info full nb_sh
      if { ${nb_sh} != ${nb_sh_good} } {
      	 puts "Error : The resulting shape is WRONG because it must contains ${nb_sh_good} shells instead of ${nb_sh}"
      } else {
      	 puts "The resulting shape contains ${nb_sh} shells"
      }
   }

   if { [info exists nb_sol_good] } {
      regexp {SOLID +: +([-0-9.+eE]+)} $nb_info full nb_sol
      if { ${nb_sol} != ${nb_sol_good} } {
      	 puts "Error : The resulting shape is WRONG because it must contains ${nb_sol_good} solids instead of ${nb_sol}"
      } else {
      	 puts "The resulting shape contains ${nb_sol} solids"
      }
   }

   if { [info exists nb_compsol_good] } {
      regexp {COMPSOLID +: +([-0-9.+eE]+)} $nb_info full nb_compsol
      if { ${nb_compsol} != ${nb_compsol_good} } {
      	 puts "Error : The resulting shape is WRONG because it must contains ${nb_compsol_good} compsolids instead of ${nb_compsol}"
      } else {
      	 puts "The resulting shape contains ${nb_compsol} compsolids"
      }
   }

   if { [info exists nb_compound_good] } {
      regexp {COMPOUND +: +([-0-9.+eE]+)} $nb_info full nb_compound
      if { ${nb_compound} != ${nb_compound_good} } {
      	 puts "Error : The resulting shape is WRONG because it must contains ${nb_compound_good} compounds instead of ${nb_compound}"
      } else {
      	 puts "The resulting shape contains ${nb_compound} compounds"
      }
   }

   if { [info exists nb_shape_good] } {
      regexp {SHAPE +: +([-0-9.+eE]+)} $nb_info full nb_shape
      if { ${nb_shape} != ${nb_shape_good} } {
      	 puts "Error : The resulting shape is WRONG because it must contains ${nb_shape_good} shapes instead of ${nb_shape}"
      } else {
      	 puts "The resulting shape contains ${nb_shape} shapes"
      }
   }


   if { $m > 0 } {
      smallview
      clear
      donly result
      fit
      xwd $imagedir/${test_image}.png
   } else {
      smallview
      clear
      fit
      xwd $imagedir/${test_image}.png
   }
} else {
   puts "Error : The $command cannot be built."
}

# to end a test script
puts "TEST COMPLETED"
