Skip to content

Commit edc469b

Browse files
committed
Remove compatibility layers and outdated tests for runtime and standard library, streamline namespace registration, and improve IO and datetime library handling.
1 parent 096570b commit edc469b

169 files changed

Lines changed: 1707 additions & 2094 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

pkg/file/helpers_test.go

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -13,43 +13,43 @@ func TestSkipWhitespaceForward(t *testing.T) {
1313
result := SkipWhitespaceForward(content, 0)
1414
So(result, ShouldEqual, 6)
1515
})
16-
16+
1717
Convey("Should skip newlines and carriage returns", func() {
1818
content := " \n\r\t world"
1919
result := SkipWhitespaceForward(content, 0)
2020
So(result, ShouldEqual, 6)
2121
})
22-
22+
2323
Convey("Should handle empty string", func() {
2424
content := ""
2525
result := SkipWhitespaceForward(content, 0)
2626
So(result, ShouldEqual, 0)
2727
})
28-
28+
2929
Convey("Should handle offset at end of string", func() {
3030
content := "hello"
3131
result := SkipWhitespaceForward(content, 5)
3232
So(result, ShouldEqual, 5)
3333
})
34-
34+
3535
Convey("Should handle offset beyond end of string", func() {
3636
content := "hello"
3737
result := SkipWhitespaceForward(content, 10)
3838
So(result, ShouldEqual, 10) // Should not access out of bounds
3939
})
40-
40+
4141
Convey("Should handle string with no whitespace", func() {
4242
content := "hello"
4343
result := SkipWhitespaceForward(content, 0)
4444
So(result, ShouldEqual, 0)
4545
})
46-
46+
4747
Convey("Should handle string with only whitespace", func() {
4848
content := " \t\n\r "
4949
result := SkipWhitespaceForward(content, 0)
5050
So(result, ShouldEqual, len(content))
5151
})
52-
52+
5353
Convey("Should start from given offset", func() {
5454
content := "abc def"
5555
result := SkipWhitespaceForward(content, 3)
@@ -65,47 +65,47 @@ func TestSkipHorizontalWhitespaceForward(t *testing.T) {
6565
result := SkipHorizontalWhitespaceForward(content, 0)
6666
So(result, ShouldEqual, 6)
6767
})
68-
68+
6969
Convey("Should stop at newlines", func() {
7070
content := " \nworld"
7171
result := SkipHorizontalWhitespaceForward(content, 0)
7272
So(result, ShouldEqual, 2) // Should stop at \n
7373
})
74-
74+
7575
Convey("Should stop at carriage returns", func() {
7676
content := " \rworld"
7777
result := SkipHorizontalWhitespaceForward(content, 0)
7878
So(result, ShouldEqual, 2) // Should stop at \r
7979
})
80-
80+
8181
Convey("Should handle empty string", func() {
8282
content := ""
8383
result := SkipHorizontalWhitespaceForward(content, 0)
8484
So(result, ShouldEqual, 0)
8585
})
86-
86+
8787
Convey("Should handle offset at end of string", func() {
8888
content := "hello"
8989
result := SkipHorizontalWhitespaceForward(content, 5)
9090
So(result, ShouldEqual, 5)
9191
})
92-
92+
9393
Convey("Should handle offset beyond end of string", func() {
9494
content := "hello"
9595
result := SkipHorizontalWhitespaceForward(content, 10)
9696
So(result, ShouldEqual, 10) // Should not access out of bounds
9797
})
98-
98+
9999
Convey("Should handle string with no whitespace", func() {
100100
content := "hello"
101101
result := SkipHorizontalWhitespaceForward(content, 0)
102102
So(result, ShouldEqual, 0)
103103
})
104-
104+
105105
Convey("Should handle string with only horizontal whitespace", func() {
106106
content := " \t "
107107
result := SkipHorizontalWhitespaceForward(content, 0)
108108
So(result, ShouldEqual, len(content))
109109
})
110110
})
111-
}
111+
}

pkg/file/os_test.go

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -15,67 +15,67 @@ func TestRead(t *testing.T) {
1515
tmpDir := t.TempDir()
1616
testFile := filepath.Join(tmpDir, "test.txt")
1717
testContent := "hello world\nline 2"
18-
18+
1919
err := os.WriteFile(testFile, []byte(testContent), 0644)
2020
So(err, ShouldBeNil)
21-
21+
2222
// Test reading the file
2323
source, err := Read(testFile)
24-
24+
2525
So(err, ShouldBeNil)
2626
So(source, ShouldNotBeNil)
2727
So(source.Name(), ShouldEqual, testFile)
2828
So(source.Content(), ShouldEqual, testContent)
2929
So(source.Empty(), ShouldBeFalse)
3030
})
31-
31+
3232
Convey("Should handle non-existent file", func() {
3333
nonExistentFile := "/path/that/does/not/exist/file.txt"
34-
34+
3535
source, err := Read(nonExistentFile)
36-
36+
3737
So(err, ShouldNotBeNil)
3838
So(source, ShouldBeNil)
3939
})
40-
40+
4141
Convey("Should handle empty file", func() {
4242
tmpDir := t.TempDir()
4343
testFile := filepath.Join(tmpDir, "empty.txt")
44-
44+
4545
err := os.WriteFile(testFile, []byte(""), 0644)
4646
So(err, ShouldBeNil)
47-
47+
4848
source, err := Read(testFile)
49-
49+
5050
So(err, ShouldBeNil)
5151
So(source, ShouldNotBeNil)
5252
So(source.Name(), ShouldEqual, testFile)
5353
So(source.Content(), ShouldEqual, "")
5454
So(source.Empty(), ShouldBeTrue)
5555
})
56-
56+
5757
Convey("Should handle file with special characters", func() {
5858
tmpDir := t.TempDir()
5959
testFile := filepath.Join(tmpDir, "special.txt")
6060
testContent := "Hello 世界\n\tTab\r\nWindows line ending"
61-
61+
6262
err := os.WriteFile(testFile, []byte(testContent), 0644)
6363
So(err, ShouldBeNil)
64-
64+
6565
source, err := Read(testFile)
66-
66+
6767
So(err, ShouldBeNil)
6868
So(source, ShouldNotBeNil)
6969
So(source.Content(), ShouldEqual, testContent)
7070
})
71-
71+
7272
Convey("Should handle directory instead of file", func() {
7373
tmpDir := t.TempDir()
74-
74+
7575
source, err := Read(tmpDir)
76-
76+
7777
So(err, ShouldNotBeNil)
7878
So(source, ShouldBeNil)
7979
})
8080
})
81-
}
81+
}

pkg/file/snippet.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ func NewSnippet(src []string, line int) Snippet {
1212
if line <= 0 || line > len(src) {
1313
return Snippet{Line: line}
1414
}
15-
15+
1616
text := src[line-1]
1717

1818
return Snippet{

pkg/file/snippet_test.go

Lines changed: 40 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -10,41 +10,41 @@ func TestNewSnippet(t *testing.T) {
1010
Convey("NewSnippet", t, func() {
1111
Convey("Should create snippet from valid line", func() {
1212
src := []string{"line1", "line2", "line3"}
13-
13+
1414
snippet := NewSnippet(src, 2)
15-
15+
1616
So(snippet.Line, ShouldEqual, 2)
1717
So(snippet.Text, ShouldEqual, "line2")
1818
So(snippet.Caret, ShouldEqual, "")
1919
})
20-
20+
2121
Convey("Should create snippet for first line", func() {
2222
src := []string{"first line", "second line"}
23-
23+
2424
snippet := NewSnippet(src, 1)
25-
25+
2626
So(snippet.Line, ShouldEqual, 1)
2727
So(snippet.Text, ShouldEqual, "first line")
2828
})
29-
29+
3030
Convey("Should create snippet for last line", func() {
3131
src := []string{"first line", "last line"}
32-
32+
3333
snippet := NewSnippet(src, 2)
34-
34+
3535
So(snippet.Line, ShouldEqual, 2)
3636
So(snippet.Text, ShouldEqual, "last line")
3737
})
38-
38+
3939
Convey("Should handle bounds issues gracefully", func() {
4040
src := []string{"line1", "line2"}
41-
41+
4242
Convey("Line number 0 should return empty snippet with line number", func() {
4343
snippet := NewSnippet(src, 0)
4444
So(snippet.Line, ShouldEqual, 0)
4545
So(snippet.Text, ShouldEqual, "")
4646
})
47-
47+
4848
Convey("Line number beyond bounds should return empty snippet with line number", func() {
4949
snippet := NewSnippet(src, 10)
5050
So(snippet.Line, ShouldEqual, 10)
@@ -59,108 +59,108 @@ func TestNewSnippetWithCaret(t *testing.T) {
5959
Convey("Should create snippet with single character caret", func() {
6060
lines := []string{"hello world"}
6161
span := Span{Start: 6, End: 7} // Single character 'w'
62-
62+
6363
snippet := NewSnippetWithCaret(lines, span, 1)
64-
64+
6565
So(snippet.Line, ShouldEqual, 1)
6666
So(snippet.Text, ShouldEqual, "hello world")
6767
So(snippet.Caret, ShouldEqual, " ^")
6868
})
69-
69+
7070
Convey("Should create snippet with multi-character caret", func() {
7171
lines := []string{"hello world"}
7272
span := Span{Start: 6, End: 11} // "world"
73-
73+
7474
snippet := NewSnippetWithCaret(lines, span, 1)
75-
75+
7676
So(snippet.Line, ShouldEqual, 1)
7777
So(snippet.Text, ShouldEqual, "hello world")
7878
So(snippet.Caret, ShouldEqual, " ~~~~~")
7979
})
80-
80+
8181
Convey("Should handle multi-line text", func() {
8282
lines := []string{"first line", "second line", "third line"}
8383
span := Span{Start: 11, End: 17} // "second" in "second line" (starts at position 11)
84-
84+
8585
snippet := NewSnippetWithCaret(lines, span, 2)
86-
86+
8787
So(snippet.Line, ShouldEqual, 2)
8888
So(snippet.Text, ShouldEqual, "second line")
8989
So(snippet.Caret, ShouldEqual, "~~~~~~")
9090
})
91-
91+
9292
Convey("Should handle tabs in visual offset", func() {
9393
lines := []string{"\thello world"}
9494
span := Span{Start: 5, End: 10} // "world" after tab
95-
95+
9696
snippet := NewSnippetWithCaret(lines, span, 1)
97-
97+
9898
So(snippet.Line, ShouldEqual, 1)
9999
So(snippet.Text, ShouldEqual, "\thello world")
100100
// Tab should expand to 4 spaces, so caret starts at position 4+5=9
101101
So(snippet.Caret, ShouldEqual, " ~~~~~")
102102
})
103-
103+
104104
Convey("Should handle line number out of bounds", func() {
105105
lines := []string{"line1", "line2"}
106106
span := Span{Start: 0, End: 5}
107-
107+
108108
Convey("Line number too small", func() {
109109
snippet := NewSnippetWithCaret(lines, span, 0)
110-
110+
111111
So(snippet, ShouldResemble, Snippet{})
112112
})
113-
113+
114114
Convey("Line number too large", func() {
115115
snippet := NewSnippetWithCaret(lines, span, 3)
116-
116+
117117
So(snippet, ShouldResemble, Snippet{})
118118
})
119119
})
120-
120+
121121
Convey("Should handle empty lines", func() {
122122
lines := []string{""}
123123
span := Span{Start: 0, End: 0}
124-
124+
125125
snippet := NewSnippetWithCaret(lines, span, 1)
126-
126+
127127
So(snippet.Line, ShouldEqual, 1)
128128
So(snippet.Text, ShouldEqual, "")
129129
So(snippet.Caret, ShouldEqual, "^")
130130
})
131-
131+
132132
Convey("Should handle span at line start", func() {
133133
lines := []string{"hello world"}
134134
span := Span{Start: 0, End: 1} // First character
135-
135+
136136
snippet := NewSnippetWithCaret(lines, span, 1)
137-
137+
138138
So(snippet.Line, ShouldEqual, 1)
139139
So(snippet.Text, ShouldEqual, "hello world")
140140
So(snippet.Caret, ShouldEqual, "^")
141141
})
142-
142+
143143
Convey("Should handle span at line end", func() {
144144
lines := []string{"hello world"}
145145
span := Span{Start: 10, End: 11} // Last character
146-
146+
147147
snippet := NewSnippetWithCaret(lines, span, 1)
148-
148+
149149
So(snippet.Line, ShouldEqual, 1)
150150
So(snippet.Text, ShouldEqual, "hello world")
151151
So(snippet.Caret, ShouldEqual, " ^")
152152
})
153-
153+
154154
Convey("Should handle mixed whitespace", func() {
155155
lines := []string{" \t hello"}
156156
span := Span{Start: 5, End: 6} // First character of "hello"
157-
157+
158158
snippet := NewSnippetWithCaret(lines, span, 1)
159-
159+
160160
So(snippet.Line, ShouldEqual, 1)
161161
So(snippet.Text, ShouldEqual, " \t hello")
162162
// space(1) + tab(3 more to align to 4) + space(1) = 5 spaces before caret
163163
So(snippet.Caret, ShouldEqual, " ^")
164164
})
165165
})
166-
}
166+
}

0 commit comments

Comments
 (0)