-
-
Notifications
You must be signed in to change notification settings - Fork 194
/
Copy pathsmartparens-get-comment-bounds-test.el
69 lines (65 loc) · 2.27 KB
/
smartparens-get-comment-bounds-test.el
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
;; #399
(ert-deftest sp-test-get-comment-bounds-c ()
(sp-test-with-temp-buffer
"int foo; /* foo|bar */"
(progn
(c++-mode)
;; because emacs doesn't return proper info on the very first
;; call of syntax-ppss, we must call it before we do actual
;; parsing .____________.
(save-excursion (syntax-ppss 1)))
(should (equal (sp-get-comment-bounds) '(10 . 22))))
(sp-test-with-temp-buffer
"int foo; |/* foobar */"
(progn
(c++-mode)
;; because emacs doesn't return proper info on the very first
;; call of syntax-ppss, we must call it before we do actual
;; parsing .____________.
(save-excursion (syntax-ppss 1)))
(should (equal (sp-get-comment-bounds) '(10 . 22))))
(sp-test-with-temp-buffer
"int foo; // foo|bar"
(progn
(c++-mode)
(save-excursion (syntax-ppss 1)))
(should (equal (sp-get-comment-bounds) '(10 . 19)))))
(ert-deftest sp-test-get-comment-bounds-elisp ()
(sp-test-with-temp-elisp-buffer
"(foo bar) ;; foo| bar"
(should (equal (sp-get-comment-bounds) '(13 . 23)))
)
(sp-test-with-temp-elisp-buffer
"(foo bar)
;; foo| bar
;; foo bar
(bar)"
(should (equal (sp-get-comment-bounds) '(11 . 40))))
(sp-test-with-temp-elisp-buffer
"(foo bar)
;; foo bar
;; foo| bar
(bar)"
(should (equal (sp-get-comment-bounds) '(11 . 40)))))
(ert-deftest sp-test-get-comment-bounds-elisp-with-comment-starting-at-bobp ()
(sp-test-with-temp-elisp-buffer ";; |foobar"
(should (equal (sp-get-comment-bounds) '(1 . 10)))))
(ert-deftest sp-test-get-comment-bounds-pascal ()
(sp-test-with-temp-buffer
"var foo:integer; (* foo|bar *)"
(progn
(pascal-mode)
(save-excursion (syntax-ppss 1)))
(should (equal (sp-get-comment-bounds) '(18 . 30))))
(sp-test-with-temp-buffer
"var foo:integer; { foo|bar }"
(progn
(pascal-mode)
(save-excursion (syntax-ppss 1)))
(should (equal (sp-get-comment-bounds) '(18 . 28)))))
(ert-deftest sp-test-get-comment-bounds-pascal-with-comment-starting-at-bobp ()
(sp-test-with-temp-buffer "(* foo|bar *)"
(progn
(pascal-mode)
(save-excursion (syntax-ppss 1)))
(should (equal (sp-get-comment-bounds) '(1 . 13)))))