mirror of
https://github.com/Gnucash/gnucash.git
synced 2025-02-25 18:55:30 -06:00
Add unit test for rewritten scheme error handlers
This commit is contained in:
parent
3d910ad2b1
commit
723b51a06d
@ -28,6 +28,7 @@ GNC_ADD_TEST_WITH_GUILE(test-scm-query-string test-scm-query-string.cpp
|
||||
ADD_APP_UTILS_TEST(test-sx test-sx.cpp)
|
||||
|
||||
SET(GUILE_DEPENDS
|
||||
scm-test-engine
|
||||
scm-app-utils
|
||||
gnc-core-utils
|
||||
gnc-module
|
||||
@ -36,6 +37,11 @@ SET(GUILE_DEPENDS
|
||||
gncmod-backend-xml
|
||||
)
|
||||
|
||||
set(test_app_utils_scheme_SOURCES
|
||||
test-c-interface.scm
|
||||
test-load-app-utils-module.scm
|
||||
)
|
||||
|
||||
GNC_ADD_SCHEME_TARGETS(scm-test-load-app-utils-module
|
||||
"test-load-app-utils-module.scm"
|
||||
"gnucash/reports"
|
||||
@ -43,7 +49,14 @@ GNC_ADD_SCHEME_TARGETS(scm-test-load-app-utils-module
|
||||
FALSE
|
||||
)
|
||||
|
||||
GNC_ADD_SCHEME_TESTS("test-load-app-utils-module.scm")
|
||||
GNC_ADD_SCHEME_TARGETS(scm-test-c-interface
|
||||
"test-c-interface.scm"
|
||||
""
|
||||
"${GUILE_DEPENDS}"
|
||||
FALSE
|
||||
)
|
||||
|
||||
GNC_ADD_SCHEME_TESTS(${test_app_utils_scheme_SOURCES})
|
||||
# Doesn't work yet:
|
||||
GNC_ADD_TEST_WITH_GUILE(test-app-utils "${test_app_utils_SOURCES}" APP_UTILS_TEST_INCLUDE_DIRS APP_UTILS_TEST_LIBS)
|
||||
|
||||
@ -56,6 +69,7 @@ SET_DIST_LIST(test_app_utils_DIST
|
||||
test-print-queries.cpp
|
||||
test-scm-query-string.cpp
|
||||
test-sx.cpp
|
||||
test-load-app-utils-module.scm
|
||||
test-c-interface.scm
|
||||
${test_app_utils_scheme_SOURCES}
|
||||
${test_app_utils_SOURCES}
|
||||
)
|
||||
|
@ -16,11 +16,14 @@ test_scm_query_string_SOURCES = test-scm-query-string.cpp
|
||||
test_sx_SOURCES = test-sx.cpp
|
||||
test_print_parse_amount_SOURCES = test-print-parse-amount.cpp
|
||||
|
||||
GNC_TEST_DEPS = --gnc-module-dir ${top_builddir}/libgnucash/engine \
|
||||
GNC_TEST_DEPS = \
|
||||
--gnc-module-dir ${top_builddir}/libgnucash/engine \
|
||||
--gnc-module-dir ${top_builddir}/libgnucash/engine/test \
|
||||
--gnc-module-dir ${top_builddir}/libgnucash/app-utils \
|
||||
--guile-load-dir ${top_builddir}/libgnucash/core-utils \
|
||||
--guile-load-dir ${top_builddir}/libgnucash/gnc-module \
|
||||
--guile-load-dir ${top_builddir}/libgnucash/engine \
|
||||
--guile-load-dir ${top_builddir}/libgnucash/engine/test \
|
||||
--guile-load-dir ${top_builddir}/libgnucash/scm \
|
||||
--guile-load-dir ${top_builddir}/libgnucash/app-utils \
|
||||
--library-dir ${top_builddir}/libgnucash/core-utils \
|
||||
@ -74,7 +77,7 @@ test_app_utils_CXXFLAGS = \
|
||||
-DTESTPROG=test_app_utils \
|
||||
${GLIB_CFLAGS}
|
||||
|
||||
SCM_TESTS = test-load-app-utils-module
|
||||
SCM_TESTS = test-load-app-utils-module test-c-interface
|
||||
SCM_TEST_SRCS = $(SCM_TESTS:%=%.scm)
|
||||
|
||||
$(SCM_TESTS): %: $(srcdir)/%.scm Makefile
|
||||
|
45
libgnucash/app-utils/test/test-c-interface.scm
Normal file
45
libgnucash/app-utils/test/test-c-interface.scm
Normal file
@ -0,0 +1,45 @@
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
;; This program is free software; you can redistribute it and/or
|
||||
;; modify it under the terms of the GNU General Public License as
|
||||
;; published by the Free Software Foundation; either version 2 of
|
||||
;; the License, or (at your option) any later version.
|
||||
;;
|
||||
;; This program is distributed in the hope that it will be useful,
|
||||
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
;; GNU General Public License for more details.
|
||||
;;
|
||||
;; You should have received a copy of the GNU General Public License
|
||||
;; along with this program; if not, contact:
|
||||
;;
|
||||
;; Free Software Foundation Voice: +1-617-542-5942
|
||||
;; 51 Franklin Street, Fifth Floor Fax: +1-617-542-2652
|
||||
;; Boston, MA 02110-1301, USA gnu@gnu.org
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
|
||||
(setenv "GNC_UNINSTALLED" "1")
|
||||
(debug-set! stack 50000)
|
||||
(load-from-path "c-interface")
|
||||
(use-modules (gnucash engine test test-extras))
|
||||
|
||||
(define (test-func a b)
|
||||
(list (/ a b) 6))
|
||||
|
||||
(define (run-test)
|
||||
(and (test test-call-with-error-handling)
|
||||
(test test-eval-string-with-error-handling)
|
||||
(test test-apply-with-error-handling)))
|
||||
|
||||
(define (test-call-with-error-handling)
|
||||
(and (eq? #f (cadr (gnc:call-with-error-handling test-func (list 4 5))))
|
||||
(eq? #f (cadr (gnc:call-with-error-handling "(test-func 4 5)" '())))
|
||||
(eq? #f (car (gnc:call-with-error-handling test-func (list 4 0))))
|
||||
(eq? #f (car (gnc:call-with-error-handling "(test-func 4 0)" '())))))
|
||||
|
||||
(define (test-eval-string-with-error-handling)
|
||||
(and (eq? #f (cadr (gnc:eval-string-with-error-handling "(test-func 4 5)")))
|
||||
(eq? #f (car (gnc:eval-string-with-error-handling "(test-func 4 0)")))))
|
||||
|
||||
(define (test-apply-with-error-handling)
|
||||
(and (eq? #f (cadr (gnc:apply-with-error-handling test-func (list 4 5))))
|
||||
(eq? #f (car (gnc:apply-with-error-handling test-func (list 4 0))))))
|
Loading…
Reference in New Issue
Block a user