Commits

David Krentzlin committed 6815019

fixed bug that messed up the execution order or hooks when used in nested contexts

  • Participants
  • Parent commits 301c2fd
  • Tags 0.11

Comments (0)

Files changed (3)

File missbehave.scm

 (define (context-ancestors context)
   (let loop ((parent (context-parent context)) (ancestors '()))
     (cond
-     ((not parent) (reverse (cons context ancestors)))
+     ((not parent)  (append ancestors (list context)))
      (else (loop (context-parent parent) (cons parent ancestors))))))
 
 (define (all-hooks-with-parent-traversal context)

File missbehave.setup

 (install-extension
   'missheave
   '("missbehave.import.so" "missbehave.so")
-  `((version "0.9")))
+  `((version "0.10")
 
 (compile -o behave -O2 -d1 -S behave.scm)
 
 (install-program
  'behave
  '("behave")
- `((version "0.9")))
+ `((version "0.10")
 

File tests/run.scm

                            (it "should succeed"
                                (expect 1 (be 1)))))))
             reporter: values)
-           result)))
+           result))
+
+   (test "Runs hooks in order from grand-parents to parents to children"
+         '(grandpa pa kid)
+         (let ((result (list)))
+           (run-specification
+            (call-with-specification
+             (make-empty-specification)
+             (lambda ()
+               (context "grandpa"
+                        (before each:
+                                (set! result (cons 'grandpa result)))
+
+                        (context "pa"
+                                 (before each:
+                                         (set! result (cons 'pa result)))
+                                 (context "kid"
+                                          (before each:
+                                                  (set! result (cons 'kid result)))
+                                          (it "should succeed"
+                                              (expect 1 (be 1))))))))
+            reporter: values)
+           (reverse result)))
+
+   )
 
 
 (test-group "Filtering"