]> code.delx.au - gnu-emacs-elpa/blob - packages/realgud/test/test-regexp-nodejs.el
c1f4064f940e76260578c8216cadf7d06a7653e1
[gnu-emacs-elpa] / packages / realgud / test / test-regexp-nodejs.el
1 (require 'test-simple)
2 (load-file "../realgud/debugger/nodejs/init.el")
3 (load-file "./regexp-helper.el")
4
5 (declare-function realgud-cmdbuf-info-loc-regexp 'realgud-buffer-command)
6 (declare-function cmdbuf-loc-match 'realgud-regexp)
7 (declare-function loc-match 'realgud-helper)
8 (declare-function prompt-match 'regexp-helper)
9 (declare-function realgud-loc-pat-num 'realgud-regexp)
10 (declare-function realgud-loc-pat-regexp 'realgud-regexp)
11 (declare-function realgud-loc-pat-file-group 'realgud-regexp)
12 (declare-function realgud-loc-pat-line-group 'realgud-regexp)
13 (declare-function __FILE__ 'load-relative)
14
15 (test-simple-start)
16
17 (eval-when-compile
18 (defvar dbg-name)
19 (defvar loc-pat)
20 (defvar prompt-pat)
21 (defvar realgud:nodejs-pat-hash)
22 (defvar realgud-pat-hash)
23 (defvar test-dbgr)
24 (defvar test-text)
25 )
26
27 (note "nodejs prompt matching")
28 (set (make-local-variable 'prompt-pat)
29 (gethash "prompt" realgud:nodejs-pat-hash))
30 (prompt-match "debug> ")
31 (prompt-match "\e[1G\e[0Jdebug> \e[8G\e[1G\e[0Kconnecting... ok")
32
33 (note "nodejs location matching")
34 (setq dbg-name "nodejs")
35 (setq loc-pat (gethash "loc" (gethash dbg-name realgud-pat-hash)))
36
37 (setq test-dbgr (make-realgud-cmdbuf-info
38 :debugger-name dbg-name
39 :loc-regexp (realgud-loc-pat-regexp loc-pat)
40 :file-group (realgud-loc-pat-file-group loc-pat)
41 :line-group (realgud-loc-pat-line-group loc-pat)))
42
43 (setq test-text "break in test/fixtures/break-in-module/main.js:1\n")
44 (assert-t (numberp (cmdbuf-loc-match test-text test-dbgr)) "basic location")
45
46 (string-match (realgud-cmdbuf-info-loc-regexp test-dbgr) test-text)
47 (assert-equal "test/fixtures/break-in-module/main.js"
48 (match-string (realgud-cmdbuf-info-file-group test-dbgr)
49 test-text))
50
51 (string-match (realgud-cmdbuf-info-loc-regexp test-dbgr) test-text)
52 (assert-equal "1"
53 (match-string
54 (realgud-cmdbuf-info-line-group test-dbgr)
55 test-text) "extract line number")
56
57 (end-tests)