Ver código fonte

Added useful warning for undecided condition

If step has a conition based on var but var has not been
specified in params, it is not possible to decide if this
condition is fulfilled.

This case cannot be copletely avoided, byu now it will
generate a useful warning.

Functional behavor is that such steps are *allowed* and
eventually revealed to tester.  (Possibly in a helpful manner.)
Alois Mahdal 11 anos atrás
pai
commit
2a9f9cb747
1 arquivos alterados com 9 adições e 0 exclusões
  1. 9
    0
      lib/SugarTrail/Template/Condition.pm

+ 9
- 0
lib/SugarTrail/Template/Condition.pm Ver arquivo

76
     my $have    = $self->{v};       # what we have in this step
76
     my $have    = $self->{v};       # what we have in this step
77
     my $want    = $params->{$name}; # what they want
77
     my $want    = $params->{$name}; # what they want
78
 
78
 
79
+    unless ($want) {
80
+        warn sprintf (
81
+            "undecided condition: %s; did you forget to specify %s?\n",
82
+            $self->{string},
83
+            $name
84
+        );
85
+        return 1;
86
+    }
87
+
79
     # execute the right handler
88
     # execute the right handler
80
     if (exists $self->{handlers}->{$op}) {
89
     if (exists $self->{handlers}->{$op}) {
81
         return &{ $self->{handlers}->{$op} }($want, $have);
90
         return &{ $self->{handlers}->{$op} }($want, $have);