ruby-lsp 0.26.5 → 0.26.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/VERSION +1 -1
- data/exe/ruby-lsp-launcher +5 -1
- data/lib/ruby_indexer/lib/ruby_indexer/configuration.rb +3 -2
- data/lib/ruby_lsp/requests/support/rubocop_diagnostic.rb +7 -1
- data/lib/ruby_lsp/setup_bundler.rb +16 -12
- data/lib/ruby_lsp/test_reporters/lsp_reporter.rb +43 -28
- data/lib/ruby_lsp/test_reporters/minitest_reporter.rb +1 -1
- data/lib/ruby_lsp/test_reporters/test_unit_reporter.rb +1 -1
- metadata +1 -15
- data/lib/ruby_indexer/test/class_variables_test.rb +0 -140
- data/lib/ruby_indexer/test/classes_and_modules_test.rb +0 -790
- data/lib/ruby_indexer/test/configuration_test.rb +0 -277
- data/lib/ruby_indexer/test/constant_test.rb +0 -402
- data/lib/ruby_indexer/test/enhancements_test.rb +0 -325
- data/lib/ruby_indexer/test/global_variable_test.rb +0 -49
- data/lib/ruby_indexer/test/index_test.rb +0 -2273
- data/lib/ruby_indexer/test/instance_variables_test.rb +0 -264
- data/lib/ruby_indexer/test/method_test.rb +0 -990
- data/lib/ruby_indexer/test/prefix_tree_test.rb +0 -150
- data/lib/ruby_indexer/test/rbs_indexer_test.rb +0 -381
- data/lib/ruby_indexer/test/reference_finder_test.rb +0 -395
- data/lib/ruby_indexer/test/test_case.rb +0 -57
- data/lib/ruby_indexer/test/uri_test.rb +0 -85
|
@@ -1,395 +0,0 @@
|
|
|
1
|
-
# typed: true
|
|
2
|
-
# frozen_string_literal: true
|
|
3
|
-
|
|
4
|
-
require "test_helper"
|
|
5
|
-
|
|
6
|
-
module RubyIndexer
|
|
7
|
-
class ReferenceFinderTest < Minitest::Test
|
|
8
|
-
def test_finds_constant_references
|
|
9
|
-
refs = find_const_references("Foo::Bar", <<~RUBY)
|
|
10
|
-
module Foo
|
|
11
|
-
class Bar
|
|
12
|
-
end
|
|
13
|
-
|
|
14
|
-
Bar
|
|
15
|
-
end
|
|
16
|
-
|
|
17
|
-
Foo::Bar
|
|
18
|
-
RUBY
|
|
19
|
-
|
|
20
|
-
assert_equal("Bar", refs[0].name)
|
|
21
|
-
assert_equal(2, refs[0].location.start_line)
|
|
22
|
-
|
|
23
|
-
assert_equal("Bar", refs[1].name)
|
|
24
|
-
assert_equal(5, refs[1].location.start_line)
|
|
25
|
-
|
|
26
|
-
assert_equal("Foo::Bar", refs[2].name)
|
|
27
|
-
assert_equal(8, refs[2].location.start_line)
|
|
28
|
-
end
|
|
29
|
-
|
|
30
|
-
def test_finds_constant_references_inside_singleton_contexts
|
|
31
|
-
refs = find_const_references("Foo::<Class:Foo>::Bar", <<~RUBY)
|
|
32
|
-
class Foo
|
|
33
|
-
class << self
|
|
34
|
-
class Bar
|
|
35
|
-
end
|
|
36
|
-
|
|
37
|
-
Bar
|
|
38
|
-
end
|
|
39
|
-
end
|
|
40
|
-
RUBY
|
|
41
|
-
|
|
42
|
-
assert_equal("Bar", refs[0].name)
|
|
43
|
-
assert_equal(3, refs[0].location.start_line)
|
|
44
|
-
|
|
45
|
-
assert_equal("Bar", refs[1].name)
|
|
46
|
-
assert_equal(6, refs[1].location.start_line)
|
|
47
|
-
end
|
|
48
|
-
|
|
49
|
-
def test_finds_top_level_constant_references
|
|
50
|
-
refs = find_const_references("Bar", <<~RUBY)
|
|
51
|
-
class Bar
|
|
52
|
-
end
|
|
53
|
-
|
|
54
|
-
class Foo
|
|
55
|
-
::Bar
|
|
56
|
-
|
|
57
|
-
class << self
|
|
58
|
-
::Bar
|
|
59
|
-
end
|
|
60
|
-
end
|
|
61
|
-
RUBY
|
|
62
|
-
|
|
63
|
-
assert_equal("Bar", refs[0].name)
|
|
64
|
-
assert_equal(1, refs[0].location.start_line)
|
|
65
|
-
|
|
66
|
-
assert_equal("::Bar", refs[1].name)
|
|
67
|
-
assert_equal(5, refs[1].location.start_line)
|
|
68
|
-
|
|
69
|
-
assert_equal("::Bar", refs[2].name)
|
|
70
|
-
assert_equal(8, refs[2].location.start_line)
|
|
71
|
-
end
|
|
72
|
-
|
|
73
|
-
def test_finds_method_references
|
|
74
|
-
refs = find_method_references("foo", <<~RUBY)
|
|
75
|
-
class Bar
|
|
76
|
-
def foo
|
|
77
|
-
end
|
|
78
|
-
|
|
79
|
-
def baz
|
|
80
|
-
foo
|
|
81
|
-
end
|
|
82
|
-
end
|
|
83
|
-
RUBY
|
|
84
|
-
|
|
85
|
-
assert_equal(2, refs.size)
|
|
86
|
-
|
|
87
|
-
assert_equal("foo", refs[0].name)
|
|
88
|
-
assert_equal(2, refs[0].location.start_line)
|
|
89
|
-
|
|
90
|
-
assert_equal("foo", refs[1].name)
|
|
91
|
-
assert_equal(6, refs[1].location.start_line)
|
|
92
|
-
end
|
|
93
|
-
|
|
94
|
-
def test_does_not_mismatch_on_readers_and_writers
|
|
95
|
-
refs = find_method_references("foo", <<~RUBY)
|
|
96
|
-
class Bar
|
|
97
|
-
def foo
|
|
98
|
-
end
|
|
99
|
-
|
|
100
|
-
def foo=(value)
|
|
101
|
-
end
|
|
102
|
-
|
|
103
|
-
def baz
|
|
104
|
-
self.foo = 1
|
|
105
|
-
self.foo
|
|
106
|
-
end
|
|
107
|
-
end
|
|
108
|
-
RUBY
|
|
109
|
-
|
|
110
|
-
# We want to match `foo` but not `foo=`
|
|
111
|
-
assert_equal(2, refs.size)
|
|
112
|
-
|
|
113
|
-
assert_equal("foo", refs[0].name)
|
|
114
|
-
assert_equal(2, refs[0].location.start_line)
|
|
115
|
-
|
|
116
|
-
assert_equal("foo", refs[1].name)
|
|
117
|
-
assert_equal(10, refs[1].location.start_line)
|
|
118
|
-
end
|
|
119
|
-
|
|
120
|
-
def test_matches_writers
|
|
121
|
-
refs = find_method_references("foo=", <<~RUBY)
|
|
122
|
-
class Bar
|
|
123
|
-
def foo
|
|
124
|
-
end
|
|
125
|
-
|
|
126
|
-
def foo=(value)
|
|
127
|
-
end
|
|
128
|
-
|
|
129
|
-
def baz
|
|
130
|
-
self.foo = 1
|
|
131
|
-
self.foo
|
|
132
|
-
end
|
|
133
|
-
end
|
|
134
|
-
RUBY
|
|
135
|
-
|
|
136
|
-
# We want to match `foo=` but not `foo`
|
|
137
|
-
assert_equal(2, refs.size)
|
|
138
|
-
|
|
139
|
-
assert_equal("foo=", refs[0].name)
|
|
140
|
-
assert_equal(5, refs[0].location.start_line)
|
|
141
|
-
|
|
142
|
-
assert_equal("foo=", refs[1].name)
|
|
143
|
-
assert_equal(9, refs[1].location.start_line)
|
|
144
|
-
end
|
|
145
|
-
|
|
146
|
-
def test_find_inherited_methods
|
|
147
|
-
refs = find_method_references("foo", <<~RUBY)
|
|
148
|
-
class Bar
|
|
149
|
-
def foo
|
|
150
|
-
end
|
|
151
|
-
end
|
|
152
|
-
|
|
153
|
-
class Baz < Bar
|
|
154
|
-
super.foo
|
|
155
|
-
end
|
|
156
|
-
RUBY
|
|
157
|
-
|
|
158
|
-
assert_equal(2, refs.size)
|
|
159
|
-
|
|
160
|
-
assert_equal("foo", refs[0].name)
|
|
161
|
-
assert_equal(2, refs[0].location.start_line)
|
|
162
|
-
|
|
163
|
-
assert_equal("foo", refs[1].name)
|
|
164
|
-
assert_equal(7, refs[1].location.start_line)
|
|
165
|
-
end
|
|
166
|
-
|
|
167
|
-
def test_finds_methods_created_in_mixins
|
|
168
|
-
refs = find_method_references("foo", <<~RUBY)
|
|
169
|
-
module Mixin
|
|
170
|
-
def foo
|
|
171
|
-
end
|
|
172
|
-
end
|
|
173
|
-
|
|
174
|
-
class Bar
|
|
175
|
-
include Mixin
|
|
176
|
-
end
|
|
177
|
-
|
|
178
|
-
Bar.foo
|
|
179
|
-
RUBY
|
|
180
|
-
|
|
181
|
-
assert_equal(2, refs.size)
|
|
182
|
-
|
|
183
|
-
assert_equal("foo", refs[0].name)
|
|
184
|
-
assert_equal(2, refs[0].location.start_line)
|
|
185
|
-
|
|
186
|
-
assert_equal("foo", refs[1].name)
|
|
187
|
-
assert_equal(10, refs[1].location.start_line)
|
|
188
|
-
end
|
|
189
|
-
|
|
190
|
-
def test_finds_singleton_methods
|
|
191
|
-
# The current implementation matches on both `Bar.foo` and `Bar#foo` even though they are different
|
|
192
|
-
|
|
193
|
-
refs = find_method_references("foo", <<~RUBY)
|
|
194
|
-
class Bar
|
|
195
|
-
class << self
|
|
196
|
-
def foo
|
|
197
|
-
end
|
|
198
|
-
end
|
|
199
|
-
|
|
200
|
-
def foo
|
|
201
|
-
end
|
|
202
|
-
end
|
|
203
|
-
|
|
204
|
-
Bar.foo
|
|
205
|
-
RUBY
|
|
206
|
-
|
|
207
|
-
assert_equal(3, refs.size)
|
|
208
|
-
|
|
209
|
-
assert_equal("foo", refs[0].name)
|
|
210
|
-
assert_equal(3, refs[0].location.start_line)
|
|
211
|
-
|
|
212
|
-
assert_equal("foo", refs[1].name)
|
|
213
|
-
assert_equal(7, refs[1].location.start_line)
|
|
214
|
-
|
|
215
|
-
assert_equal("foo", refs[2].name)
|
|
216
|
-
assert_equal(11, refs[2].location.start_line)
|
|
217
|
-
end
|
|
218
|
-
|
|
219
|
-
def test_finds_instance_variable_references
|
|
220
|
-
refs = find_instance_variable_references("@name", ["Foo"], <<~RUBY)
|
|
221
|
-
class Foo
|
|
222
|
-
def initialize
|
|
223
|
-
@name = "foo"
|
|
224
|
-
end
|
|
225
|
-
def name
|
|
226
|
-
@name
|
|
227
|
-
end
|
|
228
|
-
def name_capital
|
|
229
|
-
@name[0]
|
|
230
|
-
end
|
|
231
|
-
end
|
|
232
|
-
|
|
233
|
-
class Bar
|
|
234
|
-
def initialize
|
|
235
|
-
@name = "foo"
|
|
236
|
-
end
|
|
237
|
-
def name
|
|
238
|
-
@name
|
|
239
|
-
end
|
|
240
|
-
end
|
|
241
|
-
RUBY
|
|
242
|
-
assert_equal(3, refs.size)
|
|
243
|
-
|
|
244
|
-
assert_equal("@name", refs[0].name)
|
|
245
|
-
assert_equal(3, refs[0].location.start_line)
|
|
246
|
-
|
|
247
|
-
assert_equal("@name", refs[1].name)
|
|
248
|
-
assert_equal(6, refs[1].location.start_line)
|
|
249
|
-
|
|
250
|
-
assert_equal("@name", refs[2].name)
|
|
251
|
-
assert_equal(9, refs[2].location.start_line)
|
|
252
|
-
end
|
|
253
|
-
|
|
254
|
-
def test_finds_instance_variable_write_references
|
|
255
|
-
refs = find_instance_variable_references("@foo", ["Foo"], <<~RUBY)
|
|
256
|
-
class Foo
|
|
257
|
-
def write
|
|
258
|
-
@foo = 1
|
|
259
|
-
@foo &&= 2
|
|
260
|
-
@foo ||= 3
|
|
261
|
-
@foo += 4
|
|
262
|
-
@foo, @bar = []
|
|
263
|
-
end
|
|
264
|
-
end
|
|
265
|
-
RUBY
|
|
266
|
-
assert_equal(5, refs.size)
|
|
267
|
-
|
|
268
|
-
assert_equal(["@foo"], refs.map(&:name).uniq)
|
|
269
|
-
assert_equal(3, refs[0].location.start_line)
|
|
270
|
-
assert_equal(4, refs[1].location.start_line)
|
|
271
|
-
assert_equal(5, refs[2].location.start_line)
|
|
272
|
-
assert_equal(6, refs[3].location.start_line)
|
|
273
|
-
assert_equal(7, refs[4].location.start_line)
|
|
274
|
-
end
|
|
275
|
-
|
|
276
|
-
def test_finds_instance_variable_references_in_owner_ancestors
|
|
277
|
-
refs = find_instance_variable_references("@name", ["Foo", "Base", "Top", "Parent"], <<~RUBY)
|
|
278
|
-
module Base
|
|
279
|
-
def change_name(name)
|
|
280
|
-
@name = name
|
|
281
|
-
end
|
|
282
|
-
def name
|
|
283
|
-
@name
|
|
284
|
-
end
|
|
285
|
-
|
|
286
|
-
module ::Top
|
|
287
|
-
def name
|
|
288
|
-
@name
|
|
289
|
-
end
|
|
290
|
-
end
|
|
291
|
-
end
|
|
292
|
-
|
|
293
|
-
class Parent
|
|
294
|
-
def initialize
|
|
295
|
-
@name = "parent"
|
|
296
|
-
end
|
|
297
|
-
def name_capital
|
|
298
|
-
@name[0]
|
|
299
|
-
end
|
|
300
|
-
end
|
|
301
|
-
|
|
302
|
-
class Foo < Parent
|
|
303
|
-
include Base
|
|
304
|
-
def initialize
|
|
305
|
-
@name = "foo"
|
|
306
|
-
end
|
|
307
|
-
def name
|
|
308
|
-
@name
|
|
309
|
-
end
|
|
310
|
-
end
|
|
311
|
-
|
|
312
|
-
class Bar
|
|
313
|
-
def name
|
|
314
|
-
@name = "bar"
|
|
315
|
-
end
|
|
316
|
-
end
|
|
317
|
-
RUBY
|
|
318
|
-
assert_equal(7, refs.size)
|
|
319
|
-
|
|
320
|
-
assert_equal("@name", refs[0].name)
|
|
321
|
-
assert_equal(3, refs[0].location.start_line)
|
|
322
|
-
|
|
323
|
-
assert_equal("@name", refs[1].name)
|
|
324
|
-
assert_equal(6, refs[1].location.start_line)
|
|
325
|
-
|
|
326
|
-
assert_equal("@name", refs[2].name)
|
|
327
|
-
assert_equal(11, refs[2].location.start_line)
|
|
328
|
-
|
|
329
|
-
assert_equal("@name", refs[3].name)
|
|
330
|
-
assert_equal(18, refs[3].location.start_line)
|
|
331
|
-
|
|
332
|
-
assert_equal("@name", refs[4].name)
|
|
333
|
-
assert_equal(21, refs[4].location.start_line)
|
|
334
|
-
|
|
335
|
-
assert_equal("@name", refs[5].name)
|
|
336
|
-
assert_equal(28, refs[5].location.start_line)
|
|
337
|
-
|
|
338
|
-
assert_equal("@name", refs[6].name)
|
|
339
|
-
assert_equal(31, refs[6].location.start_line)
|
|
340
|
-
end
|
|
341
|
-
|
|
342
|
-
def test_accounts_for_reopened_classes
|
|
343
|
-
refs = find_const_references("Foo", <<~RUBY)
|
|
344
|
-
class Foo
|
|
345
|
-
end
|
|
346
|
-
class Foo
|
|
347
|
-
class Bar
|
|
348
|
-
end
|
|
349
|
-
end
|
|
350
|
-
|
|
351
|
-
Foo.new
|
|
352
|
-
RUBY
|
|
353
|
-
|
|
354
|
-
assert_equal(3, refs.size)
|
|
355
|
-
|
|
356
|
-
assert_equal("Foo", refs[0].name)
|
|
357
|
-
assert_equal(1, refs[0].location.start_line)
|
|
358
|
-
|
|
359
|
-
assert_equal("Foo", refs[1].name)
|
|
360
|
-
assert_equal(3, refs[1].location.start_line)
|
|
361
|
-
|
|
362
|
-
assert_equal("Foo", refs[2].name)
|
|
363
|
-
assert_equal(8, refs[2].location.start_line)
|
|
364
|
-
end
|
|
365
|
-
|
|
366
|
-
private
|
|
367
|
-
|
|
368
|
-
def find_const_references(const_name, source)
|
|
369
|
-
target = ReferenceFinder::ConstTarget.new(const_name)
|
|
370
|
-
find_references(target, source)
|
|
371
|
-
end
|
|
372
|
-
|
|
373
|
-
def find_method_references(method_name, source)
|
|
374
|
-
target = ReferenceFinder::MethodTarget.new(method_name)
|
|
375
|
-
find_references(target, source)
|
|
376
|
-
end
|
|
377
|
-
|
|
378
|
-
def find_instance_variable_references(instance_variable_name, owner_ancestors, source)
|
|
379
|
-
target = ReferenceFinder::InstanceVariableTarget.new(instance_variable_name, owner_ancestors)
|
|
380
|
-
find_references(target, source)
|
|
381
|
-
end
|
|
382
|
-
|
|
383
|
-
def find_references(target, source)
|
|
384
|
-
file_path = "/fake.rb"
|
|
385
|
-
uri = URI::Generic.from_path(path: file_path)
|
|
386
|
-
index = Index.new
|
|
387
|
-
index.index_single(uri, source)
|
|
388
|
-
parse_result = Prism.parse(source)
|
|
389
|
-
dispatcher = Prism::Dispatcher.new
|
|
390
|
-
finder = ReferenceFinder.new(target, index, dispatcher, uri)
|
|
391
|
-
dispatcher.visit(parse_result.value)
|
|
392
|
-
finder.references
|
|
393
|
-
end
|
|
394
|
-
end
|
|
395
|
-
end
|
|
@@ -1,57 +0,0 @@
|
|
|
1
|
-
# typed: true
|
|
2
|
-
# frozen_string_literal: true
|
|
3
|
-
|
|
4
|
-
require "test_helper"
|
|
5
|
-
|
|
6
|
-
module RubyIndexer
|
|
7
|
-
class TestCase < Minitest::Test
|
|
8
|
-
def setup
|
|
9
|
-
@index = Index.new
|
|
10
|
-
RBSIndexer.new(@index).index_ruby_core
|
|
11
|
-
@default_indexed_entries = @index.instance_variable_get(:@entries).dup
|
|
12
|
-
end
|
|
13
|
-
|
|
14
|
-
def teardown
|
|
15
|
-
entries = @index.instance_variable_get(:@entries).values.flatten
|
|
16
|
-
entries.each do |entry|
|
|
17
|
-
assert_includes([:public, :private, :protected], entry.visibility)
|
|
18
|
-
end
|
|
19
|
-
end
|
|
20
|
-
|
|
21
|
-
private
|
|
22
|
-
|
|
23
|
-
def index(source, uri: URI::Generic.from_path(path: "/fake/path/foo.rb"))
|
|
24
|
-
@index.index_single(uri, source)
|
|
25
|
-
end
|
|
26
|
-
|
|
27
|
-
def assert_entry(expected_name, type, expected_location, visibility: nil)
|
|
28
|
-
entries = @index[expected_name] #: as !nil
|
|
29
|
-
refute_nil(entries, "Expected #{expected_name} to be indexed")
|
|
30
|
-
refute_empty(entries, "Expected #{expected_name} to be indexed")
|
|
31
|
-
|
|
32
|
-
entry = entries.first #: as !nil
|
|
33
|
-
assert_instance_of(type, entry, "Expected #{expected_name} to be a #{type}")
|
|
34
|
-
|
|
35
|
-
location = entry.location
|
|
36
|
-
location_string =
|
|
37
|
-
"#{entry.file_path}:#{location.start_line - 1}-#{location.start_column}" \
|
|
38
|
-
":#{location.end_line - 1}-#{location.end_column}"
|
|
39
|
-
|
|
40
|
-
assert_equal(expected_location, location_string)
|
|
41
|
-
assert_equal(visibility, entry.visibility) if visibility
|
|
42
|
-
end
|
|
43
|
-
|
|
44
|
-
def refute_entry(expected_name)
|
|
45
|
-
entries = @index[expected_name]
|
|
46
|
-
assert_nil(entries, "Expected #{expected_name} to not be indexed")
|
|
47
|
-
end
|
|
48
|
-
|
|
49
|
-
def assert_no_indexed_entries
|
|
50
|
-
assert_equal(@default_indexed_entries, @index.instance_variable_get(:@entries))
|
|
51
|
-
end
|
|
52
|
-
|
|
53
|
-
def assert_no_entry(entry)
|
|
54
|
-
refute(@index.indexed?(entry), "Expected '#{entry}' to not be indexed")
|
|
55
|
-
end
|
|
56
|
-
end
|
|
57
|
-
end
|
|
@@ -1,85 +0,0 @@
|
|
|
1
|
-
# typed: true
|
|
2
|
-
# frozen_string_literal: true
|
|
3
|
-
|
|
4
|
-
require "test_helper"
|
|
5
|
-
|
|
6
|
-
module RubyIndexer
|
|
7
|
-
class URITest < Minitest::Test
|
|
8
|
-
def test_from_path_on_unix
|
|
9
|
-
uri = URI::Generic.from_path(path: "/some/unix/path/to/file.rb")
|
|
10
|
-
assert_equal("/some/unix/path/to/file.rb", uri.path)
|
|
11
|
-
end
|
|
12
|
-
|
|
13
|
-
def test_from_path_on_windows
|
|
14
|
-
uri = URI::Generic.from_path(path: "C:/some/windows/path/to/file.rb")
|
|
15
|
-
assert_equal("/C%3A/some/windows/path/to/file.rb", uri.path)
|
|
16
|
-
end
|
|
17
|
-
|
|
18
|
-
def test_from_path_on_windows_with_lowercase_drive
|
|
19
|
-
uri = URI::Generic.from_path(path: "c:/some/windows/path/to/file.rb")
|
|
20
|
-
assert_equal("/c%3A/some/windows/path/to/file.rb", uri.path)
|
|
21
|
-
end
|
|
22
|
-
|
|
23
|
-
def test_to_standardized_path_on_unix
|
|
24
|
-
uri = URI::Generic.from_path(path: "/some/unix/path/to/file.rb")
|
|
25
|
-
assert_equal(uri.path, uri.to_standardized_path)
|
|
26
|
-
end
|
|
27
|
-
|
|
28
|
-
def test_to_standardized_path_on_windows
|
|
29
|
-
uri = URI::Generic.from_path(path: "C:/some/windows/path/to/file.rb")
|
|
30
|
-
assert_equal("C:/some/windows/path/to/file.rb", uri.to_standardized_path)
|
|
31
|
-
end
|
|
32
|
-
|
|
33
|
-
def test_to_standardized_path_on_windows_with_lowercase_drive
|
|
34
|
-
uri = URI::Generic.from_path(path: "c:/some/windows/path/to/file.rb")
|
|
35
|
-
assert_equal("c:/some/windows/path/to/file.rb", uri.to_standardized_path)
|
|
36
|
-
end
|
|
37
|
-
|
|
38
|
-
def test_to_standardized_path_on_windows_with_received_uri
|
|
39
|
-
uri = URI("file:///c%3A/some/windows/path/to/file.rb")
|
|
40
|
-
assert_equal("c:/some/windows/path/to/file.rb", uri.to_standardized_path)
|
|
41
|
-
end
|
|
42
|
-
|
|
43
|
-
def test_plus_signs_are_properly_unescaped
|
|
44
|
-
path = "/opt/rubies/3.3.0/lib/ruby/3.3.0+0/pathname.rb"
|
|
45
|
-
uri = URI::Generic.from_path(path: path)
|
|
46
|
-
assert_equal(path, uri.to_standardized_path)
|
|
47
|
-
end
|
|
48
|
-
|
|
49
|
-
def test_from_path_with_fragment
|
|
50
|
-
uri = URI::Generic.from_path(path: "/some/unix/path/to/file.rb", fragment: "L1,3-2,9")
|
|
51
|
-
assert_equal("file:///some/unix/path/to/file.rb#L1,3-2,9", uri.to_s)
|
|
52
|
-
end
|
|
53
|
-
|
|
54
|
-
def test_from_path_windows_long_file_paths
|
|
55
|
-
uri = URI::Generic.from_path(path: "//?/C:/hostedtoolcache/windows/Ruby/3.3.1/x64/lib/ruby/3.3.0/open-uri.rb")
|
|
56
|
-
assert_equal("C:/hostedtoolcache/windows/Ruby/3.3.1/x64/lib/ruby/3.3.0/open-uri.rb", uri.to_standardized_path)
|
|
57
|
-
end
|
|
58
|
-
|
|
59
|
-
def test_from_path_computes_require_path_when_load_path_entry_is_given
|
|
60
|
-
uri = URI::Generic.from_path(path: "/some/unix/path/to/file.rb", load_path_entry: "/some/unix/path")
|
|
61
|
-
assert_equal("to/file", uri.require_path)
|
|
62
|
-
end
|
|
63
|
-
|
|
64
|
-
def test_allows_adding_require_path_with_load_path_entry
|
|
65
|
-
uri = URI::Generic.from_path(path: "/some/unix/path/to/file.rb")
|
|
66
|
-
assert_nil(uri.require_path)
|
|
67
|
-
|
|
68
|
-
uri.add_require_path_from_load_entry("/some/unix/path")
|
|
69
|
-
assert_equal("to/file", uri.require_path)
|
|
70
|
-
end
|
|
71
|
-
|
|
72
|
-
def test_from_path_escapes_colon_characters
|
|
73
|
-
uri = URI::Generic.from_path(path: "c:/some/windows/path with/spaces/file.rb")
|
|
74
|
-
assert_equal("c:/some/windows/path with/spaces/file.rb", uri.to_standardized_path)
|
|
75
|
-
assert_equal("file:///c%3A/some/windows/path%20with/spaces/file.rb", uri.to_s)
|
|
76
|
-
end
|
|
77
|
-
|
|
78
|
-
def test_from_path_with_unicode_characters
|
|
79
|
-
path = "/path/with/unicode/文件.rb"
|
|
80
|
-
uri = URI::Generic.from_path(path: path)
|
|
81
|
-
assert_equal(path, uri.to_standardized_path)
|
|
82
|
-
assert_equal("file:///path/with/unicode/%E6%96%87%E4%BB%B6.rb", uri.to_s)
|
|
83
|
-
end
|
|
84
|
-
end
|
|
85
|
-
end
|