summaryrefslogtreecommitdiff
path: root/test/data
diff options
context:
space:
mode:
Diffstat (limited to 'test/data')
-rw-r--r--test/data/decompress/tg.tar.gzbin0 -> 150 bytes
-rw-r--r--test/data/decompress/zg.zipbin0 -> 182 bytes
-rw-r--r--test/data/emacs-module/mod-test.c79
-rw-r--r--test/data/shr/ol.html29
-rw-r--r--test/data/shr/ol.txt19
-rw-r--r--test/data/vc/diff-mode/hello_emacs.c6
-rw-r--r--test/data/vc/diff-mode/hello_emacs_1.c1
-rw-r--r--test/data/vc/diff-mode/hello_world.c6
-rw-r--r--test/data/vc/diff-mode/hello_world_1.c1
-rw-r--r--test/data/xdg/mimeapps.list9
-rw-r--r--test/data/xdg/mimeinfo.cache4
11 files changed, 148 insertions, 6 deletions
diff --git a/test/data/decompress/tg.tar.gz b/test/data/decompress/tg.tar.gz
new file mode 100644
index 00000000000..3dc8185f56e
--- /dev/null
+++ b/test/data/decompress/tg.tar.gz
Binary files differ
diff --git a/test/data/decompress/zg.zip b/test/data/decompress/zg.zip
new file mode 100644
index 00000000000..c4c998ee63d
--- /dev/null
+++ b/test/data/decompress/zg.zip
Binary files differ
diff --git a/test/data/emacs-module/mod-test.c b/test/data/emacs-module/mod-test.c
index 30dc4fd9245..a39e41afee6 100644
--- a/test/data/emacs-module/mod-test.c
+++ b/test/data/emacs-module/mod-test.c
@@ -17,12 +17,20 @@ GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with GNU Emacs. If not, see <https://www.gnu.org/licenses/>. */
+#include "config.h"
+
#include <assert.h>
+#include <errno.h>
+#include <limits.h>
#include <stdio.h>
#include <stdlib.h>
-#include <limits.h>
+#include <string.h>
+#include <time.h>
+
#include <emacs-module.h>
+#include "timespec.h"
+
int plugin_is_GPL_compatible;
#if INTPTR_MAX <= 0
@@ -86,7 +94,7 @@ Fmod_test_signal (emacs_env *env, ptrdiff_t nargs, emacs_value args[],
assert (env->non_local_exit_check (env) == emacs_funcall_exit_return);
env->non_local_exit_signal (env, env->intern (env, "error"),
env->make_integer (env, 56));
- return env->intern (env, "nil");
+ return NULL;
}
@@ -98,7 +106,7 @@ Fmod_test_throw (emacs_env *env, ptrdiff_t nargs, emacs_value args[],
assert (env->non_local_exit_check (env) == emacs_funcall_exit_return);
env->non_local_exit_throw (env, env->intern (env, "tag"),
env->make_integer (env, 65));
- return env->intern (env, "nil");
+ return NULL;
}
@@ -296,9 +304,67 @@ Fmod_test_invalid_finalizer (emacs_env *env, ptrdiff_t nargs, emacs_value *args,
{
current_env = env;
env->make_user_ptr (env, invalid_finalizer, NULL);
- return env->funcall (env, env->intern (env, "garbage-collect"), 0, NULL);
+ return env->intern (env, "nil");
+}
+
+static void
+signal_wrong_type_argument (emacs_env *env, const char *predicate,
+ emacs_value arg)
+{
+ emacs_value symbol = env->intern (env, "wrong-type-argument");
+ emacs_value elements[2] = {env->intern (env, predicate), arg};
+ emacs_value data = env->funcall (env, env->intern (env, "list"), 2, elements);
+ env->non_local_exit_signal (env, symbol, data);
}
+static void
+signal_errno (emacs_env *env, const char *function)
+{
+ const char *message = strerror (errno);
+ emacs_value message_value = env->make_string (env, message, strlen (message));
+ emacs_value symbol = env->intern (env, "file-error");
+ emacs_value elements[2]
+ = {env->make_string (env, function, strlen (function)), message_value};
+ emacs_value data = env->funcall (env, env->intern (env, "list"), 2, elements);
+ env->non_local_exit_signal (env, symbol, data);
+}
+
+/* A long-running operation that occasionally calls `should_quit' or
+ `process_input'. */
+
+static emacs_value
+Fmod_test_sleep_until (emacs_env *env, ptrdiff_t nargs, emacs_value *args,
+ void *data)
+{
+ assert (nargs == 2);
+ const double until_seconds = env->extract_float (env, args[0]);
+ if (env->non_local_exit_check (env))
+ return NULL;
+ if (until_seconds <= 0)
+ {
+ signal_wrong_type_argument (env, "cl-plusp", args[0]);
+ return NULL;
+ }
+ const bool process_input = env->is_not_nil (env, args[1]);
+ const struct timespec until = dtotimespec (until_seconds);
+ const struct timespec amount = make_timespec(0, 10000000);
+ while (true)
+ {
+ const struct timespec now = current_timespec ();
+ if (timespec_cmp (now, until) >= 0)
+ break;
+ if (nanosleep (&amount, NULL) && errno != EINTR)
+ {
+ signal_errno (env, "nanosleep");
+ return NULL;
+ }
+ if ((process_input
+ && env->process_input (env) == emacs_process_input_quit)
+ || env->should_quit (env))
+ return NULL;
+ }
+ return env->intern (env, "finished");
+}
/* Lisp utilities for easier readability (simple wrappers). */
@@ -317,11 +383,11 @@ provide (emacs_env *env, const char *feature)
static void
bind_function (emacs_env *env, const char *name, emacs_value Sfun)
{
- emacs_value Qfset = env->intern (env, "fset");
+ emacs_value Qdefalias = env->intern (env, "defalias");
emacs_value Qsym = env->intern (env, name);
emacs_value args[] = { Qsym, Sfun };
- env->funcall (env, Qfset, 2, args);
+ env->funcall (env, Qdefalias, 2, args);
}
/* Module init function. */
@@ -367,6 +433,7 @@ emacs_module_init (struct emacs_runtime *ert)
DEFUN ("mod-test-invalid-load", Fmod_test_invalid_load, 0, 0, NULL, NULL);
DEFUN ("mod-test-invalid-finalizer", Fmod_test_invalid_finalizer, 0, 0,
NULL, NULL);
+ DEFUN ("mod-test-sleep-until", Fmod_test_sleep_until, 2, 2, NULL, NULL);
#undef DEFUN
diff --git a/test/data/shr/ol.html b/test/data/shr/ol.html
new file mode 100644
index 00000000000..f9a15f26409
--- /dev/null
+++ b/test/data/shr/ol.html
@@ -0,0 +1,29 @@
+<ol>
+ <li>one</li>
+ <li>two</li>
+ <li>three</li>
+</ol>
+
+<ol start="10">
+ <li>ten</li>
+ <li>eleven</li>
+ <li>twelve</li>
+</ol>
+
+<ol start="0">
+ <li>zero</li>
+ <li>one</li>
+ <li>two</li>
+</ol>
+
+<ol start="-5">
+ <li>minus five</li>
+ <li>minus four</li>
+ <li>minus three</li>
+</ol>
+
+<ol start="notanumber">
+ <li>one</li>
+ <li>two</li>
+ <li>three</li>
+</ol>
diff --git a/test/data/shr/ol.txt b/test/data/shr/ol.txt
new file mode 100644
index 00000000000..0d46e2a8ddb
--- /dev/null
+++ b/test/data/shr/ol.txt
@@ -0,0 +1,19 @@
+1 one
+2 two
+3 three
+
+10 ten
+11 eleven
+12 twelve
+
+0 zero
+1 one
+2 two
+
+-5 minus five
+-4 minus four
+-3 minus three
+
+1 one
+2 two
+3 three
diff --git a/test/data/vc/diff-mode/hello_emacs.c b/test/data/vc/diff-mode/hello_emacs.c
new file mode 100644
index 00000000000..c7ed7538c3a
--- /dev/null
+++ b/test/data/vc/diff-mode/hello_emacs.c
@@ -0,0 +1,6 @@
+#include <stdio.h>
+int main()
+{
+ printf("Hello, Emacs!\n");
+ return 0;
+}
diff --git a/test/data/vc/diff-mode/hello_emacs_1.c b/test/data/vc/diff-mode/hello_emacs_1.c
new file mode 100644
index 00000000000..62145a6b44a
--- /dev/null
+++ b/test/data/vc/diff-mode/hello_emacs_1.c
@@ -0,0 +1 @@
+int main() { printf("Hello, Emacs!\n"); return 0; } \ No newline at end of file
diff --git a/test/data/vc/diff-mode/hello_world.c b/test/data/vc/diff-mode/hello_world.c
new file mode 100644
index 00000000000..dcbe06c6012
--- /dev/null
+++ b/test/data/vc/diff-mode/hello_world.c
@@ -0,0 +1,6 @@
+#include <stdio.h>
+int main()
+{
+ printf("Hello, World!\n");
+ return 0;
+}
diff --git a/test/data/vc/diff-mode/hello_world_1.c b/test/data/vc/diff-mode/hello_world_1.c
new file mode 100644
index 00000000000..606afb371cb
--- /dev/null
+++ b/test/data/vc/diff-mode/hello_world_1.c
@@ -0,0 +1 @@
+int main() { printf("Hello, World!\n"); return 0; } \ No newline at end of file
diff --git a/test/data/xdg/mimeapps.list b/test/data/xdg/mimeapps.list
new file mode 100644
index 00000000000..27fbd94b16b
--- /dev/null
+++ b/test/data/xdg/mimeapps.list
@@ -0,0 +1,9 @@
+[Default Applications]
+x-test/foo=a.desktop
+
+[Added Associations]
+x-test/foo=b.desktop
+x-test/baz=a.desktop
+
+[Removed Associations]
+x-test/foo=c.desktop;d.desktop
diff --git a/test/data/xdg/mimeinfo.cache b/test/data/xdg/mimeinfo.cache
new file mode 100644
index 00000000000..6e54f604fa0
--- /dev/null
+++ b/test/data/xdg/mimeinfo.cache
@@ -0,0 +1,4 @@
+[MIME Cache]
+x-test/foo=c.desktop;d.desktop
+x-test/bar=a.desktop;c.desktop
+x-test/baz=b.desktop;d.desktop