瀏覽代碼

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 年之前
父節點
當前提交
2a9f9cb747
共有 1 個文件被更改,包括 9 次插入0 次删除
  1. 9
    0
      lib/SugarTrail/Template/Condition.pm

+ 9
- 0
lib/SugarTrail/Template/Condition.pm 查看文件

@@ -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);