aboutsummaryrefslogtreecommitdiffstats
path: root/test/data
diff options
context:
space:
mode:
authorPhilipp Stephani2020-07-26 22:54:33 +0200
committerPhilipp Stephani2020-07-26 22:54:33 +0200
commit73a2f5104331264656ac830c848912af9389a04b (patch)
treea0ca4c2daf6987300048cabd890c93060e69dd7c /test/data
parent3838aeb7397ce80134c70fd49f7e9e5ef7aff3e5 (diff)
downloademacs-73a2f5104331264656ac830c848912af9389a04b.tar.gz
emacs-73a2f5104331264656ac830c848912af9389a04b.zip
Add another test for global module references
* test/src/emacs-module-tests.el (mod-test-globref-reordered): New unit test. * test/data/emacs-module/mod-test.c (Fmod_test_globref_reordered): New test module function. (emacs_module_init): Export it.
Diffstat (limited to 'test/data')
-rw-r--r--test/data/emacs-module/mod-test.c31
1 files changed, 31 insertions, 0 deletions
diff --git a/test/data/emacs-module/mod-test.c b/test/data/emacs-module/mod-test.c
index 986c20ae8f9..8d1b421bb40 100644
--- a/test/data/emacs-module/mod-test.c
+++ b/test/data/emacs-module/mod-test.c
@@ -205,6 +205,35 @@ Fmod_test_globref_invalid_free (emacs_env *env, ptrdiff_t nargs,
205 return env->intern (env, "nil"); 205 return env->intern (env, "nil");
206} 206}
207 207
208/* Allocate and free global references in a different order. */
209
210static emacs_value
211Fmod_test_globref_reordered (emacs_env *env, ptrdiff_t nargs,
212 emacs_value *args, void *data)
213{
214 emacs_value booleans[2] = {
215 env->intern (env, "nil"),
216 env->intern (env, "t"),
217 };
218 emacs_value local = env->intern (env, "foo");
219 emacs_value globals[4] = {
220 env->make_global_ref (env, local),
221 env->make_global_ref (env, local),
222 env->make_global_ref (env, env->intern (env, "foo")),
223 env->make_global_ref (env, env->intern (env, "bar")),
224 };
225 emacs_value elements[4];
226 for (int i = 0; i < 4; ++i)
227 elements[i] = booleans[env->eq (env, globals[i], local)];
228 emacs_value ret = env->funcall (env, env->intern (env, "list"), 4, elements);
229 env->free_global_ref (env, globals[2]);
230 env->free_global_ref (env, globals[1]);
231 env->free_global_ref (env, globals[3]);
232 env->free_global_ref (env, globals[0]);
233 return ret;
234}
235
236
208/* Return a copy of the argument string where every 'a' is replaced 237/* Return a copy of the argument string where every 'a' is replaced
209 with 'b'. */ 238 with 'b'. */
210static emacs_value 239static emacs_value
@@ -583,6 +612,8 @@ emacs_module_init (struct emacs_runtime *ert)
583 DEFUN ("mod-test-globref-free", Fmod_test_globref_free, 4, 4, NULL, NULL); 612 DEFUN ("mod-test-globref-free", Fmod_test_globref_free, 4, 4, NULL, NULL);
584 DEFUN ("mod-test-globref-invalid-free", Fmod_test_globref_invalid_free, 0, 0, 613 DEFUN ("mod-test-globref-invalid-free", Fmod_test_globref_invalid_free, 0, 0,
585 NULL, NULL); 614 NULL, NULL);
615 DEFUN ("mod-test-globref-reordered", Fmod_test_globref_reordered, 0, 0, NULL,
616 NULL);
586 DEFUN ("mod-test-string-a-to-b", Fmod_test_string_a_to_b, 1, 1, NULL, NULL); 617 DEFUN ("mod-test-string-a-to-b", Fmod_test_string_a_to_b, 1, 1, NULL, NULL);
587 DEFUN ("mod-test-userptr-make", Fmod_test_userptr_make, 1, 1, NULL, NULL); 618 DEFUN ("mod-test-userptr-make", Fmod_test_userptr_make, 1, 1, NULL, NULL);
588 DEFUN ("mod-test-userptr-get", Fmod_test_userptr_get, 1, 1, NULL, NULL); 619 DEFUN ("mod-test-userptr-get", Fmod_test_userptr_get, 1, 1, NULL, NULL);