Skip to content

Commit 723b51a

Browse files
committed
Add unit test for rewritten scheme error handlers
1 parent 3d910ad commit 723b51a

File tree

3 files changed

+66
-4
lines changed

3 files changed

+66
-4
lines changed

libgnucash/app-utils/test/CMakeLists.txt

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ GNC_ADD_TEST_WITH_GUILE(test-scm-query-string test-scm-query-string.cpp
2828
ADD_APP_UTILS_TEST(test-sx test-sx.cpp)
2929

3030
SET(GUILE_DEPENDS
31+
scm-test-engine
3132
scm-app-utils
3233
gnc-core-utils
3334
gnc-module
@@ -36,14 +37,26 @@ SET(GUILE_DEPENDS
3637
gncmod-backend-xml
3738
)
3839

40+
set(test_app_utils_scheme_SOURCES
41+
test-c-interface.scm
42+
test-load-app-utils-module.scm
43+
)
44+
3945
GNC_ADD_SCHEME_TARGETS(scm-test-load-app-utils-module
4046
"test-load-app-utils-module.scm"
4147
"gnucash/reports"
4248
"${GUILE_DEPENDS}"
4349
FALSE
4450
)
4551

46-
GNC_ADD_SCHEME_TESTS("test-load-app-utils-module.scm")
52+
GNC_ADD_SCHEME_TARGETS(scm-test-c-interface
53+
"test-c-interface.scm"
54+
""
55+
"${GUILE_DEPENDS}"
56+
FALSE
57+
)
58+
59+
GNC_ADD_SCHEME_TESTS(${test_app_utils_scheme_SOURCES})
4760
# Doesn't work yet:
4861
GNC_ADD_TEST_WITH_GUILE(test-app-utils "${test_app_utils_SOURCES}" APP_UTILS_TEST_INCLUDE_DIRS APP_UTILS_TEST_LIBS)
4962

@@ -56,6 +69,7 @@ SET_DIST_LIST(test_app_utils_DIST
5669
test-print-queries.cpp
5770
test-scm-query-string.cpp
5871
test-sx.cpp
59-
test-load-app-utils-module.scm
72+
test-c-interface.scm
73+
${test_app_utils_scheme_SOURCES}
6074
${test_app_utils_SOURCES}
6175
)

libgnucash/app-utils/test/Makefile.am

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,14 @@ test_scm_query_string_SOURCES = test-scm-query-string.cpp
1616
test_sx_SOURCES = test-sx.cpp
1717
test_print_parse_amount_SOURCES = test-print-parse-amount.cpp
1818

19-
GNC_TEST_DEPS = --gnc-module-dir ${top_builddir}/libgnucash/engine \
19+
GNC_TEST_DEPS = \
20+
--gnc-module-dir ${top_builddir}/libgnucash/engine \
21+
--gnc-module-dir ${top_builddir}/libgnucash/engine/test \
2022
--gnc-module-dir ${top_builddir}/libgnucash/app-utils \
2123
--guile-load-dir ${top_builddir}/libgnucash/core-utils \
2224
--guile-load-dir ${top_builddir}/libgnucash/gnc-module \
2325
--guile-load-dir ${top_builddir}/libgnucash/engine \
26+
--guile-load-dir ${top_builddir}/libgnucash/engine/test \
2427
--guile-load-dir ${top_builddir}/libgnucash/scm \
2528
--guile-load-dir ${top_builddir}/libgnucash/app-utils \
2629
--library-dir ${top_builddir}/libgnucash/core-utils \
@@ -74,7 +77,7 @@ test_app_utils_CXXFLAGS = \
7477
-DTESTPROG=test_app_utils \
7578
${GLIB_CFLAGS}
7679

77-
SCM_TESTS = test-load-app-utils-module
80+
SCM_TESTS = test-load-app-utils-module test-c-interface
7881
SCM_TEST_SRCS = $(SCM_TESTS:%=%.scm)
7982

8083
$(SCM_TESTS): %: $(srcdir)/%.scm Makefile
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
2+
;; This program is free software; you can redistribute it and/or
3+
;; modify it under the terms of the GNU General Public License as
4+
;; published by the Free Software Foundation; either version 2 of
5+
;; the License, or (at your option) any later version.
6+
;;
7+
;; This program is distributed in the hope that it will be useful,
8+
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
9+
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10+
;; GNU General Public License for more details.
11+
;;
12+
;; You should have received a copy of the GNU General Public License
13+
;; along with this program; if not, contact:
14+
;;
15+
;; Free Software Foundation Voice: +1-617-542-5942
16+
;; 51 Franklin Street, Fifth Floor Fax: +1-617-542-2652
17+
;; Boston, MA 02110-1301, USA gnu@gnu.org
18+
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
19+
20+
(setenv "GNC_UNINSTALLED" "1")
21+
(debug-set! stack 50000)
22+
(load-from-path "c-interface")
23+
(use-modules (gnucash engine test test-extras))
24+
25+
(define (test-func a b)
26+
(list (/ a b) 6))
27+
28+
(define (run-test)
29+
(and (test test-call-with-error-handling)
30+
(test test-eval-string-with-error-handling)
31+
(test test-apply-with-error-handling)))
32+
33+
(define (test-call-with-error-handling)
34+
(and (eq? #f (cadr (gnc:call-with-error-handling test-func (list 4 5))))
35+
(eq? #f (cadr (gnc:call-with-error-handling "(test-func 4 5)" '())))
36+
(eq? #f (car (gnc:call-with-error-handling test-func (list 4 0))))
37+
(eq? #f (car (gnc:call-with-error-handling "(test-func 4 0)" '())))))
38+
39+
(define (test-eval-string-with-error-handling)
40+
(and (eq? #f (cadr (gnc:eval-string-with-error-handling "(test-func 4 5)")))
41+
(eq? #f (car (gnc:eval-string-with-error-handling "(test-func 4 0)")))))
42+
43+
(define (test-apply-with-error-handling)
44+
(and (eq? #f (cadr (gnc:apply-with-error-handling test-func (list 4 5))))
45+
(eq? #f (car (gnc:apply-with-error-handling test-func (list 4 0))))))

0 commit comments

Comments
 (0)