~patrickb/guile-pcb/trunk

« back to all changes in this revision

Viewing changes to tests/action.test

  • Committer: Patrick Bernaud
  • Date: 2012-07-01 07:27:01 UTC
  • mto: This revision was merged to the branch mainline in revision 78.
  • Revision ID: patrickb@chez.com-20120701072701-fxlufo9gzv2imz1q
Catch exceptions from action callbacks and report them as errors.

* guile-pcb/guile-pcb-action.c (guile_action_trigger_cb): Tweak for a
  catch on any exceptions from callback procedure.
  (trigger_cb_handler): Adapt the error formatting for any error.

* pcb/action.scm:
* doc/action.texi: Update documentation of register-action.

* tests/action.test:
* examples/print-assembly.scm: Update for new error reporting.

Show diffs side-by-side

added added

removed removed

Lines of Context:
51
51
  (assert-true (action-exists? "TestAction2")))
52
52
 
53
53
(define-method (test-execute-action (self <test-action>))
54
 
  (register-action (lambda args (noop) #t) #:name "TestAction3")
 
54
  (register-action (lambda args (noop '())) #:name "TestAction3")
55
55
  (assert-equal 0 (execute-action "TestAction3"))
56
56
  (assert-equal 0 (execute-action 'test-action3))
57
57
  (assert-equal 0 (execute-action 'test-action3 1 2 3))
60
60
  (assert-equal 1 (execute-action 'no-such-action)))
61
61
 
62
62
(define-method (test-parse-actions (self <test-action>))
63
 
  (register-action (lambda args (noop) #t) #:name "TestActionOk")
64
 
  (register-action (lambda args (noop) #f) #:name "TestActionError")
 
63
  (register-action (lambda args (noop '()))        #:name "TestActionOk")
 
64
  (register-action (lambda args (throw 'my-error)) #:name "TestActionError")
65
65
 
66
66
  (assert-equal 0 (parse-actions "TestActionOk()"))
67
67
  (assert-equal 1 (parse-actions "TestActionError()"))