Use new qt:with-app
Annotate for file /src/undo.lisp
2009-05-31 tobias 1 (in-package :qt.tests)
22:24:46 ' 2
' 3 (5am:in-suite :qt.suite)
' 4
' 5 (defclass reversible-incf (qt:undo-command)
' 6 ((place :accessor place
2009-07-01 tobias 7 :initarg :place))
2009-05-31 tobias 8 (:metaclass cxx:class))
22:24:46 ' 9
' 10 (defmethod cxx:redo ((incf reversible-incf))
' 11 (incf (symbol-value (place incf))))
' 12
' 13 (defmethod cxx:undo ((incf reversible-incf))
' 14 (decf (symbol-value (place incf))))
' 15
' 16 (5am:test undo-stack
2009-07-01 tobias 17 "Test ownership transfer of a undo-command to the undo-stack."
11:02:20 ' 18 (let ((undo-stack (make-instance 'qt:undo-stack))
' 19 (iterations 10)
' 20 (counter 0))
' 21 (declare (special counter))
' 22 (dotimes (i iterations)
' 23 (cxx:push undo-stack
' 24 (make-instance 'reversible-incf :place 'counter))
' 25 (gc :full t)) ;; Test for faulty ownership transfer
' 26 (5am:is (eq t (cxx:can-undo undo-stack)))
' 27 (5am:is (= iterations counter))
2009-05-31 tobias 28
2009-07-01 tobias 29 (dotimes (i iterations)
11:02:20 ' 30 (cxx:undo undo-stack))
' 31 (5am:is (eq nil (cxx:can-undo undo-stack)))
' 32 (5am:is (= 0 counter))))
2009-05-31 tobias 33