Browse Source

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 years ago
parent
commit
2a9f9cb747
1 changed files with 9 additions and 0 deletions
  1. 9
    0
      lib/SugarTrail/Template/Condition.pm

+ 9
- 0
lib/SugarTrail/Template/Condition.pm View File

@@ -76,6 +76,15 @@ sub match {
76 76
     my $have    = $self->{v};       # what we have in this step
77 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 88
     # execute the right handler
80 89
     if (exists $self->{handlers}->{$op}) {
81 90
         return &{ $self->{handlers}->{$op} }($want, $have);