-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathposition_test.go
51 lines (41 loc) · 1.09 KB
/
position_test.go
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
// Copyright (c) 2017 Opsidian Ltd.
//
// This Source Code Form is subject to the terms of the Mozilla Public
// License, v. 2.0. If a copy of the MPL was not distributed with this
// file, You can obtain one at http://mozilla.org/MPL/2.0/.
package text_test
import (
. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"
"github.com/conflowio/parsley/parsley"
"github.com/conflowio/parsley/text"
)
var _ = Describe("Position", func() {
var (
pos *text.Position
line, column int
filename string
)
BeforeEach(func() {
line = 1
column = 2
filename = "testfile"
})
JustBeforeEach(func() {
pos = text.NewPosition(filename, line, column)
})
It("should implement the parsley.Position interface", func() {
var _ parsley.Position = text.Position{}
})
It("should return with a string containing all information", func() {
Expect(pos.String()).To(Equal("testfile:1:2"))
})
Context("no filename", func() {
BeforeEach(func() {
filename = ""
})
It("should return with a string without the filename", func() {
Expect(pos.String()).To(Equal("1:2"))
})
})
})