2 (load-file "../realgud/common/loc.el")
3 (load-file "../realgud/common/file.el")
5 ;; Note the below line number is tested so it must match what's listed
7 (declare-function __FILE__ 'load-relative)
9 (declare-function realgud:file-loc-from-line 'realgud-file)
10 (declare-function realgud:file-line-count 'realgud-file)
11 (declare-function realgud:file-column-from-string 'realgud-file)
12 (declare-function realgud-loc? 'realgud-loc)
14 (declare-function realgud-loc-line-number 'realgud-loc)
15 (declare-function realgud-loc-column-number 'realgud-loc)
16 (declare-function realgud-loc-filename 'realgud-loc)
21 (defvar realgud-file-remap)
22 (defvar test-filename)
23 (defvar test-file-loc)
24 (defvar remap-filename)
25 (defvar old-compilation-find-file)
28 (clrhash realgud-file-remap)
30 (setq old-compilation-find-file (symbol-function 'compilation-find-file))
32 (setq test-filename (symbol-file 'test-simple))
34 (note "realgud:file-line-count")
37 (realgud:file-line-count "not-found-file")
40 (assert-t (integerp (realgud:file-line-count test-filename))
44 (note "realgud:file-loc-from-line")
46 (fset 'compilation-find-file (lambda(mark test-filename opt)
47 (get-buffer "*scratch*")))
50 ;; NOTE: this calls compilation-find-file which prompts for a file
52 ;; "File named `not-found-file' not readable"
53 ;; (realgud:file-loc-from-line
54 ;; "not-found-file" 5 (make-marker))
57 (assert-t (stringp (realgud:file-loc-from-line test-filename 5.5))
58 "invalid real line number")
60 (assert-t (stringp (realgud:file-loc-from-line test-filename -1))
63 (note "realgud:file-loc-from-line information")
65 (assert-t (stringp (realgud:file-loc-from-line test-filename 10001))
66 "Line number too large for file")
68 (setq test-file-loc (realgud:file-loc-from-line (__FILE__) 5 nil ";; Note"))
69 (assert-t (realgud-loc? test-file-loc)
70 "Ok loc creation - no cmd marker")
72 (assert-t (realgud-loc?
73 (realgud:file-loc-from-line test-filename 30 (make-marker)))
74 "Ok loc creation - cmd marker")
76 (assert-equal 5 (realgud-loc-line-number test-file-loc))
78 ;; FIXME: don't know why this fails in batch
79 ;; (assert-equal 0 (realgud-loc-column-number test-file-loc))
81 (assert-equal (__FILE__) (realgud-loc-filename test-file-loc))
83 (note "realgud:file-loc-from-line remapping")
85 (setq remap-filename " bogus remap-filename.el")
88 ;; (format "File named `%s' not readable" remap-filename)
89 ;; (realgud:file-loc-from-line
90 ;; remap-filename 5 (make-marker))
95 (puthash remap-filename test-filename realgud-file-remap)
97 (assert-t (realgud-loc?
98 (realgud:file-loc-from-line remap-filename 30))
99 "Ok loc creation with remap - no cmd marker")
101 ;; FIXME: don't know why this fails in batch
104 ;; (realgud:file-column-from-string (__FILE__) 7 "__FILE__")
105 ;; "Should find string in file/line and get column"
109 (realgud:file-column-from-string (__FILE__) 5 "__FILE__")
110 "Should not find string at this line in located file"
114 (realgud:file-column-from-string (concat (__FILE__) "FOO") 7 "__FILE__")
115 "Should not find file"
119 (realgud:file-column-from-string (__FILE__) 10000 "__FILE__")
120 "Should not find line in file at all"
123 (fset 'compilation-find-file old-compilation-find-file)