Skip to content

Commit 653b65c

Browse files
committed
add some simple test cases
1 parent 4251886 commit 653b65c

File tree

3 files changed

+44
-0
lines changed

3 files changed

+44
-0
lines changed

pkg/comments/comments_test.go

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
package comments
2+
3+
import (
4+
"testing"
5+
)
6+
7+
func TestJSFiles(t *testing.T) {
8+
var comments Comments
9+
err := SearchDir("testdata/javascript", func(comment *Comment) {
10+
comments = append(comments, comment)
11+
})
12+
if err != nil {
13+
t.Fatal(err)
14+
}
15+
16+
if len(comments) != 2 {
17+
t.Fail()
18+
}
19+
}
20+
21+
func TestLispFiles(t *testing.T) {
22+
var comments Comments
23+
err := SearchDir("testdata/lisp", func(comment *Comment) {
24+
comments = append(comments, comment)
25+
})
26+
if err != nil {
27+
t.Fatal(err)
28+
}
29+
30+
if len(comments) != 1 {
31+
t.Fail()
32+
}
33+
}
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
// this is a js comment
2+
3+
function helloWorld() {
4+
return "hello world"
5+
}
6+
7+
/* this is a block comment
8+
that spans multiple lines
9+
*/
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
; Comment
2+
(+ 1 1)

0 commit comments

Comments
 (0)