diff options
| author | Philipp Stephani | 2020-07-25 23:23:19 +0200 |
|---|---|---|
| committer | Philipp Stephani | 2020-07-26 14:33:59 +0200 |
| commit | 3838aeb7397ce80134c70fd49f7e9e5ef7aff3e5 (patch) | |
| tree | 0e38c2b6668f603e9a2f127164b230219fe77621 /test/data | |
| parent | bde5f5f8978f704f24cce2fc7beec8c740d0e331 (diff) | |
| download | emacs-3838aeb7397ce80134c70fd49f7e9e5ef7aff3e5.tar.gz emacs-3838aeb7397ce80134c70fd49f7e9e5ef7aff3e5.zip | |
Backport: add another test case for module assertions.
This backports commit 9f01ce6327 from master. Since the bug isn’t
present on emacs-27, just backport the new test case.
* test/data/emacs-module/mod-test.c (Fmod_test_globref_invalid_free):
New test module function.
(emacs_module_init): Export it.
* test/src/emacs-module-tests.el
(module--test-assertions--globref-invalid-free): New unit test.
Diffstat (limited to 'test/data')
| -rw-r--r-- | test/data/emacs-module/mod-test.c | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/test/data/emacs-module/mod-test.c b/test/data/emacs-module/mod-test.c index f6c1c7cf3d2..986c20ae8f9 100644 --- a/test/data/emacs-module/mod-test.c +++ b/test/data/emacs-module/mod-test.c | |||
| @@ -191,7 +191,19 @@ Fmod_test_globref_free (emacs_env *env, ptrdiff_t nargs, emacs_value args[], | |||
| 191 | return env->intern (env, "ok"); | 191 | return env->intern (env, "ok"); |
| 192 | } | 192 | } |
| 193 | 193 | ||
| 194 | /* Treat a local reference as global and free it. Module assertions | ||
| 195 | should detect this case even if a global reference representing the | ||
| 196 | same object also exists. */ | ||
| 194 | 197 | ||
| 198 | static emacs_value | ||
| 199 | Fmod_test_globref_invalid_free (emacs_env *env, ptrdiff_t nargs, | ||
| 200 | emacs_value *args, void *data) | ||
| 201 | { | ||
| 202 | emacs_value local = env->make_integer (env, 9876); | ||
| 203 | env->make_global_ref (env, local); | ||
| 204 | env->free_global_ref (env, local); /* Not allowed. */ | ||
| 205 | return env->intern (env, "nil"); | ||
| 206 | } | ||
| 195 | 207 | ||
| 196 | /* Return a copy of the argument string where every 'a' is replaced | 208 | /* Return a copy of the argument string where every 'a' is replaced |
| 197 | with 'b'. */ | 209 | with 'b'. */ |
| @@ -569,6 +581,8 @@ emacs_module_init (struct emacs_runtime *ert) | |||
| 569 | 1, 1, NULL, NULL); | 581 | 1, 1, NULL, NULL); |
| 570 | DEFUN ("mod-test-globref-make", Fmod_test_globref_make, 0, 0, NULL, NULL); | 582 | DEFUN ("mod-test-globref-make", Fmod_test_globref_make, 0, 0, NULL, NULL); |
| 571 | DEFUN ("mod-test-globref-free", Fmod_test_globref_free, 4, 4, NULL, NULL); | 583 | 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, | ||
| 585 | NULL, NULL); | ||
| 572 | DEFUN ("mod-test-string-a-to-b", Fmod_test_string_a_to_b, 1, 1, NULL, NULL); | 586 | DEFUN ("mod-test-string-a-to-b", Fmod_test_string_a_to_b, 1, 1, NULL, NULL); |
| 573 | DEFUN ("mod-test-userptr-make", Fmod_test_userptr_make, 1, 1, NULL, NULL); | 587 | DEFUN ("mod-test-userptr-make", Fmod_test_userptr_make, 1, 1, NULL, NULL); |
| 574 | DEFUN ("mod-test-userptr-get", Fmod_test_userptr_get, 1, 1, NULL, NULL); | 588 | DEFUN ("mod-test-userptr-get", Fmod_test_userptr_get, 1, 1, NULL, NULL); |