3 (load-file "../loc-changes.el")
7 (setq sample-buffer (find-file-noselect "./sample.txt"))
9 (note "loc-changes-goto-line error conditions")
10 (assert-raises error (loc-changes-goto-line "foo"))
11 (message "buffer %s" (current-buffer))
12 (assert-raises error (loc-changes-goto-line "0"))
13 (assert-raises error (loc-changes-goto-line 0))
14 (assert-raises error (loc-changes-goto-line 10000))
16 (note "loc-changes-goto-line")
18 (set-buffer sample-buffer)
19 (loc-changes-goto-line 5)
20 (assert-equal 5 (line-number-at-pos (point))))
22 (note "loc-changes-goto-line-with-column")
23 (with-current-buffer sample-buffer
24 (set-buffer sample-buffer)
25 (loc-changes-goto-line 1 3)
26 (assert-equal 1 (line-number-at-pos (point)))
28 ;; (assert-equal 2 (current-column))
31 (note "loc-changes-goto-line-invalid-column")
33 (set-buffer sample-buffer)
34 (loc-changes-goto-line 1 300)
35 (assert-equal 1 (line-number-at-pos (point)))
37 ;; (assert-equal 0 (current-column))
39 (not (current-message))
40 (string-match "^Column ignored." (current-message))))
42 ;; (loc-changes-goto-line 2 -5)
43 ;; (assert-equal 2 (line-number-at-pos (point)))
44 ;; (assert-equal 0 (current-column))
46 ;; (not (current-message))
47 ;; (string-match "^Column ignored." (current-message))))
50 (note "loc-changes-clear-buffer null")
51 (loc-changes-clear-buffer)
52 (assert-equal '() loc-changes-alist)
54 (note "loc-changes-add-and-goto - update")
56 (set-buffer sample-buffer)
57 (loc-changes-add-and-goto 10)
58 (assert-equal 10 (line-number-at-pos)
59 "point should be at line 10")
61 ;; (assert-t (assq 10 loc-changes-alist)
62 ;; "Should find 10 in loc-changes-alist")
63 ;; (assert-t (markerp (cdr (assq 10 loc-changes-alist)))
64 ;; "10 in loc-changes-alist should be a marker")
67 (note "loc-changes-goto - update")
69 (set-buffer sample-buffer)
71 (assert-equal 11 (line-number-at-pos)
72 "point should be at line 11")
74 ;; (assert-t (assq 11 loc-changes-alist)
75 ;; "Should find 11 in loc-changes-alist")
76 ;; (assert-t (markerp (cdr (assq 11 loc-changes-alist)))
77 ;; "11 in loc-changes-alist should be a marker")
80 (note "loc-changes-goto - no update")
82 (set-buffer sample-buffer)
83 (loc-changes-goto 12 nil 't)
84 (assert-equal 12 (line-number-at-pos)
85 "point should be at line 12")
86 (assert-nil (assq 12 loc-changes-alist)
87 "Should not find 12 in loc-changes-alist")