]> code.delx.au - gnu-emacs-elpa/blob - packages/realgud/test/regexp-helper.el
Add 'packages/realgud/' from commit 'd811316e6a0f4eeee8a1347f504c196c86baa2cb'
[gnu-emacs-elpa] / packages / realgud / test / regexp-helper.el
1 (require 'test-simple)
2 (load-file "../realgud/common/buffer/command.el")
3
4 (eval-when-compile
5 (defvar helper-bps)
6 (defvar helper-loc)
7 (defvar helper-tb)
8 (defvar prompt-pat)
9 )
10
11 (declare-function realgud-loc-pat-regexp 'realgud-backtrace-mode)
12 (declare-function realgud-cmdbuf-info-loc-regexp 'realgud-buffer-command)
13 (declare-function test-simple-start 'test-simple)
14
15
16 (defun setup-regexp-vars(pat-hash)
17 (setq helper-bps (gethash "brkpt-set" pat-hash))
18 (setq helper-loc (gethash "loc" pat-hash))
19 (setq helper-tb (gethash "lang-backtrace" pat-hash))
20 )
21
22 (defun loc-match(text var)
23 "Match TEXT against regexp field VAR"
24 (string-match (realgud-loc-pat-regexp var) text)
25 )
26
27 (defun bp-loc-match(text)
28 (string-match (realgud-loc-pat-regexp helper-bps) text)
29 )
30
31 (defun tb-loc-match(text)
32 (string-match (realgud-loc-pat-regexp helper-tb) text)
33 )
34
35 (defun cmdbuf-loc-match(text dbgr)
36 "Match TEXT against cmdbuf-info-loc field VAR"
37 (string-match (realgud-cmdbuf-info-loc-regexp dbgr) text)
38 )
39
40 (defun prompt-match(prompt-str &optional num-str fmt-str)
41 (unless fmt-str (setq fmt-str "debugger prompt %s"))
42 (assert-equal 0 (string-match (realgud-loc-pat-regexp prompt-pat)
43 prompt-str)
44 (format fmt-str prompt-str))
45 (cond (num-str
46 (assert-equal num-str (substring prompt-str
47 (match-beginning 1) (match-end 1))))
48 ('t 't))
49 )
50 (provide 'realgud-regexp-helper)