소스 검색

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 12 년 전
부모
커밋
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);