aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorStefan Kangas2020-04-26 01:00:39 +0200
committerStefan Kangas2020-04-26 01:11:05 +0200
commit7b82650c60bd044c046601fc337c8a46b4fb853c (patch)
tree0c11be32408477af80bcd3c14787230e15571b7f
parent0e2cd5f5ab8e3e870fde7c70cbc75fdd2b405746 (diff)
downloademacs-7b82650c60bd044c046601fc337c8a46b4fb853c.tar.gz
emacs-7b82650c60bd044c046601fc337c8a46b4fb853c.zip
Use lexical-binding in dig.el and add tests
* lisp/net/dig.el: Use lexical-binding. (dig-program, dig-dns-server, dig-font-lock-keywords): Remove redundant :group args. * test/lisp/net/dig-tests.el: New file.
-rw-r--r--lisp/net/dig.el11
-rw-r--r--test/lisp/net/dig-tests.el56
2 files changed, 60 insertions, 7 deletions
diff --git a/lisp/net/dig.el b/lisp/net/dig.el
index 852d8ae0491..f36999119f2 100644
--- a/lisp/net/dig.el
+++ b/lisp/net/dig.el
@@ -1,4 +1,4 @@
1;;; dig.el --- Domain Name System dig interface 1;;; dig.el --- Domain Name System dig interface -*- lexical-binding:t -*-
2 2
3;; Copyright (C) 2000-2020 Free Software Foundation, Inc. 3;; Copyright (C) 2000-2020 Free Software Foundation, Inc.
4 4
@@ -42,15 +42,13 @@
42 42
43(defcustom dig-program "dig" 43(defcustom dig-program "dig"
44 "Name of dig (domain information groper) binary." 44 "Name of dig (domain information groper) binary."
45 :type 'file 45 :type 'file)
46 :group 'dig)
47 46
48(defcustom dig-dns-server nil 47(defcustom dig-dns-server nil
49 "DNS server to query. 48 "DNS server to query.
50If nil, use system defaults." 49If nil, use system defaults."
51 :type '(choice (const :tag "System defaults") 50 :type '(choice (const :tag "System defaults")
52 string) 51 string))
53 :group 'dig)
54 52
55(defcustom dig-font-lock-keywords 53(defcustom dig-font-lock-keywords
56 '(("^;; [A-Z]+ SECTION:" 0 font-lock-keyword-face) 54 '(("^;; [A-Z]+ SECTION:" 0 font-lock-keyword-face)
@@ -58,8 +56,7 @@ If nil, use system defaults."
58 ("^; <<>>.*" 0 font-lock-type-face) 56 ("^; <<>>.*" 0 font-lock-type-face)
59 ("^;.*" 0 font-lock-function-name-face)) 57 ("^;.*" 0 font-lock-function-name-face))
60 "Default expressions to highlight in dig mode." 58 "Default expressions to highlight in dig mode."
61 :type 'sexp 59 :type 'sexp)
62 :group 'dig)
63 60
64(defun dig-invoke (domain &optional 61(defun dig-invoke (domain &optional
65 query-type query-class query-option 62 query-type query-class query-option
diff --git a/test/lisp/net/dig-tests.el b/test/lisp/net/dig-tests.el
new file mode 100644
index 00000000000..1b14384634e
--- /dev/null
+++ b/test/lisp/net/dig-tests.el
@@ -0,0 +1,56 @@
1;;; dig-tests.el --- Tests for dig.el -*- lexical-binding:t -*-
2
3;; Copyright (C) 2020 Free Software Foundation, Inc.
4
5;; This file is part of GNU Emacs.
6
7;; GNU Emacs is free software: you can redistribute it and/or modify
8;; it under the terms of the GNU General Public License as published by
9;; the Free Software Foundation, either version 3 of the License, or
10;; (at your option) any later version.
11
12;; GNU Emacs is distributed in the hope that it will be useful,
13;; but WITHOUT ANY WARRANTY; without even the implied warranty of
14;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15;; GNU General Public License for more details.
16
17;; You should have received a copy of the GNU General Public License
18;; along with GNU Emacs. If not, see <https://www.gnu.org/licenses/>.
19
20;;; Commentary:
21
22;;; Code:
23
24(require 'ert)
25(require 'dig)
26
27(defvar dig-test-result-data "
28; <<>> DiG 9.11.16-2-Debian <<>> gnu.org
29;; global options: +cmd
30;; Got answer:
31;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 7777
32;; flags: qr rd ra; QUERY: 1, ANSWER: 1, AUTHORITY: 0, ADDITIONAL: 1
33
34;; OPT PSEUDOSECTION:
35; EDNS: version: 0, flags:; udp: 4096
36;; QUESTION SECTION:
37;gnu.org. IN A
38
39;; ANSWER SECTION:
40gnu.org. 300 IN A 111.11.111.111
41
42;; Query time: 127 msec
43;; SERVER: 192.168.0.1#53(192.168.0.1)
44;; WHEN: Sun Apr 26 00:47:55 CEST 2020
45;; MSG SIZE rcvd: 52
46
47" "Data used to test dig.el.")
48
49(ert-deftest dig-test-dig-extract-rr ()
50 (with-temp-buffer
51 (insert dig-test-result-data)
52 (should (equal (dig-extract-rr "gnu.org")
53 "gnu.org. 300 IN A 111.11.111.111"))))
54
55(provide 'dig-tests)
56;;; dig-tests.el ends here