diff options
author | Akira TAGOH <akira@tagoh.org> | 2006-09-23 14:33:06 +0000 |
---|---|---|
committer | Akira TAGOH <akira@tagoh.org> | 2006-09-23 14:33:06 +0000 |
commit | 5e84d6e6989baeed31d4ebecdf99b8d9e441b531 (patch) | |
tree | 4c1c23107377340f927b3f89d01043c34c163cef | |
parent | eb3c03df98615de3d3dd9be4a4ee613ae6a3863a (diff) |
2006-09-23 Akira TAGOH <at@gclab.org>
* hieroglyph/operator.c (_hg_operator_op_add): fixed a overflow.
* hieroglyph/hgvaluenode.c (hg_value_node_compare): use macro.
* tests/ps/test-add.ps: new test case.
* src/hgs.c (main): returns an error code.
* plugins/test/hg_unittest.ps (unittestresult): stop with an error code
when unit test failed.
-rw-r--r-- | ChangeLog | 13 | ||||
-rw-r--r-- | hieroglyph/hgvaluenode.c | 2 | ||||
-rw-r--r-- | hieroglyph/operator.c | 9 | ||||
-rw-r--r-- | hieroglyph/version.h.in | 2 | ||||
-rw-r--r-- | plugins/test/hg_unittest.ps | 3 | ||||
-rw-r--r-- | src/hgs.c | 5 | ||||
-rw-r--r-- | tests/ps/test-add.ps | 20 | ||||
-rwxr-xr-x | tests/ps/test-ps.sh | 2 |
8 files changed, 49 insertions, 7 deletions
@@ -1,3 +1,16 @@ +2006-09-23 Akira TAGOH <at@gclab.org> + + * hieroglyph/operator.c (_hg_operator_op_add): fixed a overflow. + + * hieroglyph/hgvaluenode.c (hg_value_node_compare): use macro. + + * tests/ps/test-add.ps: new test case. + + * src/hgs.c (main): returns an error code. + + * plugins/test/hg_unittest.ps (unittestresult): stop with an error code + when unit test failed. + 2006-09-20 Akira TAGOH <at@gclab.org> * tests/ps/test-ps.sh: depends on hgs instead of pse. diff --git a/hieroglyph/hgvaluenode.c b/hieroglyph/hgvaluenode.c index 3662f25..dd49963 100644 --- a/hieroglyph/hgvaluenode.c +++ b/hieroglyph/hgvaluenode.c @@ -640,7 +640,7 @@ hg_value_node_compare(const HgValueNode *a, retval = (HG_VALUE_GET_INTEGER (a) == HG_VALUE_GET_INTEGER (b)); break; case HG_TYPE_VALUE_REAL: - retval = (fabs(HG_VALUE_GET_REAL (a) - HG_VALUE_GET_REAL (b)) <= fabs(DBL_EPSILON * HG_VALUE_GET_REAL (a))); + retval = HG_VALUE_REAL_SIMILAR (HG_VALUE_GET_REAL (a), HG_VALUE_GET_REAL (b)); break; case HG_TYPE_VALUE_NAME: retval = (strcmp(HG_VALUE_GET_NAME (a), HG_VALUE_GET_NAME (b)) == 0); diff --git a/hieroglyph/operator.c b/hieroglyph/operator.c index 6a6b92b..71cf9a9 100644 --- a/hieroglyph/operator.c +++ b/hieroglyph/operator.c @@ -653,7 +653,7 @@ G_STMT_START HgMemPool *pool = hg_vm_get_current_pool(vm); guint depth = hg_stack_depth(ostack); gboolean integer = TRUE; - gdouble d1, d2; + gdouble d1, d2, dr; while (1) { if (depth < 2) { @@ -680,10 +680,11 @@ G_STMT_START _hg_operator_set_error(vm, op, VM_e_typecheck); break; } - if (integer) { - HG_VALUE_MAKE_INTEGER (pool, n1, (gint32)(d1 + d2)); + dr = d1 + d2; + if (integer && dr < G_MAXINT32) { + HG_VALUE_MAKE_INTEGER (pool, n1, (gint32)dr); } else { - HG_VALUE_MAKE_REAL (pool, n1, d1 + d2); + HG_VALUE_MAKE_REAL (pool, n1, dr); } if (n1 == NULL) { _hg_operator_set_error(vm, op, VM_e_VMerror); diff --git a/hieroglyph/version.h.in b/hieroglyph/version.h.in index 35c5f16..d1ea339 100644 --- a/hieroglyph/version.h.in +++ b/hieroglyph/version.h.in @@ -29,7 +29,7 @@ G_BEGIN_DECLS #define HIEROGLYPH_VERSION "@VERSION@" -#define HIEROGLYPH_UUID "0a0650a2-df83-486d-80f1-692dd3a4ab6e" +#define HIEROGLYPH_UUID "9d61fdd7-4469-4500-9ded-61ad8d7a5c1f" const char *__hg_rcsid G_GNUC_UNUSED = "$Rev$"; diff --git a/plugins/test/hg_unittest.ps b/plugins/test/hg_unittest.ps index 4930e3c..2220fdc 100644 --- a/plugins/test/hg_unittest.ps +++ b/plugins/test/hg_unittest.ps @@ -74,5 +74,8 @@ end /.unittestdict exch def nfailure 128 string cvs ( Failure(s)) .concatstring .concatstring .concatstring .concatstring .concatstring = + nfailure 0 gt { + 1 .quit + } if end } bind odef @@ -88,6 +88,7 @@ main(int argc, }; GError *error = NULL; const gchar *psfile = NULL; + gint32 errcode = 0; HG_MEM_INIT; hg_vm_init(); @@ -139,8 +140,10 @@ main(int argc, } } + errcode = hg_vm_get_error_code(vm); + hg_vm_finalize(); g_option_context_free(ctxt); - return 0; + return errcode; } diff --git a/tests/ps/test-add.ps b/tests/ps/test-add.ps new file mode 100644 index 0000000..6c05e4c --- /dev/null +++ b/tests/ps/test-add.ps @@ -0,0 +1,20 @@ +initunittest + +[7] null true initunittestdict {3 4 add} unittest +[11.0] null true initunittestdict {9.9 1.1 add} unittest +[/foo 1] /typecheck true initunittestdict {/foo 1 add} unittest +[1 /foo] /typecheck true initunittestdict {1 /foo add} unittest +[[] 1] /typecheck true initunittestdict {[] 1 add} unittest +[1 []] /typecheck true initunittestdict {1 [] add} unittest +[1 dict 1] /typecheck true initunittestdict {1 dict 1 add} unittest +[1 1 dict] /typecheck true initunittestdict {1 1 dict add} unittest +{//mark 1} cvlit /typecheck true initunittestdict {mark 1 add} unittest +{1 //mark} cvlit /typecheck true initunittestdict {1 mark add} unittest +[null 1] /typecheck true initunittestdict {null 1 add} unittest +[1 null] /typecheck true initunittestdict {1 null add} unittest +[] /stackunderflow true initunittestdict {add} unittest +[1] /stackunderflow true initunittestdict {1 add} unittest +[4.29490176e+09] null true initunittestdict {2147450880 2147450880 add} unittest +[] null true initunittestdict {2.25176549e+38 2.25176549e+38 add} unittest + +unittestresult diff --git a/tests/ps/test-ps.sh b/tests/ps/test-ps.sh index 5b83c23..b4bbd53 100755 --- a/tests/ps/test-ps.sh +++ b/tests/ps/test-ps.sh @@ -1,5 +1,7 @@ #! /bin/sh +set -e + rootdir=`dirname $0`/../.. export HIEROGLYPH_LIB_PATH=$rootdir/plugins/test for i in `dirname $0`/test-*.ps; do |