Commit graph

63 commits

Author SHA1 Message Date
Hiroshi SHIBATA
395a240b7c
Try to use irb instead of rubygems for completion test
I'm not sure why OpenBSD suggest `rubygems_plugin` file for this.

20240126T013005Z.fail.html.gz

It seems environmental issue, not irb.
2024-01-26 13:40:05 +09:00
Hiroshi SHIBATA
706eea9d3c
Fixup 2e69137dbe 2024-01-23 08:45:45 +09:00
Hiroshi SHIBATA
2e69137dbe Use version dependant library for completion test 2024-01-22 18:23:05 +09:00
Stan Lo
66e0d92de5 [ruby/irb] Avoid completing empty input
(https://github.com/ruby/irb/pull/832)

The candidate list for empty input is all methods + all variables +
all constants + all keywords. It's a long list that is not useful.

812dc2df7b
2024-01-03 13:47:51 +00:00
tomoya ishida
631b500dd5 [ruby/irb] Fix irb crash on {}. completion
(https://github.com/ruby/irb/pull/764)

07e4d540cc
2023-11-18 17:49:06 +00:00
Nobuyoshi Nakada
06a4011964 [ruby/irb] Suppress "Switch to inspect mode" messages
This message is displayed if STDIN is not a tty.  The parallel test is
the case.

e26e90e3fb
2023-10-16 12:09:05 +00:00
tomoya ishida
75fb3cf458 [ruby/irb] Restore encoding in InputCompletor test
(https://github.com/ruby/irb/pull/732)

ef77c232cf
2023-10-14 15:02:38 +00:00
tomoya ishida
4e5c505bad [ruby/irb] Restore IRB::InputCompletor for compatibility
(https://github.com/ruby/irb/pull/730)

77265efc5f
2023-10-14 14:12:43 +00:00
tomoya ishida
1126bd8c65 [ruby/irb] Fix require path completion disturbing string method
completion
(https://github.com/ruby/irb/pull/726)

e42dc74ce0
2023-10-12 16:54:09 +00:00
tomoya ishida
cf21c72cdb [ruby/irb] Fix test runner exit bug
(https://github.com/ruby/irb/pull/728)

* Remove useless test setup and teardown that sets MAIN_CONTEXT to nil

* Avoid adding command methods to main object in test

f204829a08
2023-10-12 13:55:47 +00:00
tomoya ishida
94cb5765e2 [ruby/irb] Rename current completor to RegexpCompletor and
refactored for future extension
(https://github.com/ruby/irb/pull/707)

* Move completion implementation to completion/regexp_completor for future extension

* Remove constant CompletionProc and PerfectMatchedProc and add a class method

* Move document display logic to InputCompletor. Each completor only need to implement `completion_caididates` and `doc_namespace`

* Move display_document logic to RelineInputMethod

* Use RegexpCompletor directly. Not through class method of InputCompletor.

* RegexpCompletor extends BaseCompletor, move back definition to completion.rb

* Move display_document test to input_method test

* Stop re-initialize completor on each completion phase

* Store completor to ReadlineInputMethod's iver

1e98521483
2023-10-11 17:09:05 +00:00
Stan Lo
91b106fe4b [ruby/irb] Stanardise test class names with Test postfix instead
of prefix
(https://github.com/ruby/irb/pull/603)

359cb28def
2023-06-13 11:02:26 +00:00
tomoya ishida
5d91be7c1f [ruby/irb] Use symbol.inspect instead of ":"+symbol.id2name to avoid
completion candidates including newline characters
(https://github.com/ruby/irb/pull/539)

aaf0c46645
2023-06-13 10:46:38 +00:00
ima1zumi
76ee4edb97 [ruby/irb] Fixed string escaping omissions
(https://github.com/ruby/irb/pull/599)

I received a `RegexpError` when I typed `::Array[`.
::Array[/Users/mi/ghq/github.com/ruby/irb/lib/irb/completion.rb:236:in `retrieve_completion_data': premature end of char-class: /^Array[/ (RegexpError)
2023-06-05 18:34:10 +00:00
tomoya ishida
0463c5806a [ruby/irb] Improve method completion for string and regexp that
includes word break characters
(https://github.com/ruby/irb/pull/523)

* Improve method completion for string and regexp that includes word break characters

* Remove completion-test's assert_not_include because candidates no longer include every possible methods

* Add comment about string's method completion regexp

Co-authored-by: Stan Lo <stan001212@gmail.com>

* Add comment about regexp's method completion regexp

Co-authored-by: Stan Lo <stan001212@gmail.com>

---------

aa8128c533

Co-authored-by: Stan Lo <stan001212@gmail.com>
2023-03-06 05:52:46 +00:00
Stan Lo
191e4ae33f [ruby/irb] Drop chained methods' completion support
(https://github.com/ruby/irb/pull/529)

Consider completion for this example: `foo.bar.b`

Without type information, it is hard to know the return value of the `bar`
method, so the current implementation interates through `ObjectSpace` to
get all possible candidates for the second method.

In small projects, the performance and accuracy are acceptable. But in
bigger projects, the performance is unacceptable and the accuracy is mostly
poor.

So this commit drops the support for chained methods' completion.
2023-03-04 15:34:49 +00:00
tomoya ishida
b49053a6be [ruby/irb] Avoid slow symbol completion when completion target is an
empty symbol
(https://github.com/ruby/irb/pull/534)

35697f3ef3
2023-03-03 13:41:21 +00:00
Stan Lo
07403de5a8 [ruby/irb] Cleanup completion tests
(https://github.com/ruby/irb/pull/520)

* Remove redundant completion test

The test case was introduced to guard an old implementation, which relied
on `Module#name`. Commit:

8827d18274

However, the current implementation has avoided calling `Module#name`
completely, so the test case is no longer necessary. Commit:

88311ce3c8

* Remove unnecessary pend
2023-02-24 13:34:40 +00:00
Stan Lo
a923203811 [ruby/irb] Provide a base test class and let tests restore encodings
conveniently
(https://github.com/ruby/irb/pull/429)

* Create a base TestIRB::TestCase class

* Save/restore encodings for tests that initializes InputMethod classes

Because `RelineInputMethod#initializes` calls `set_encoding`, which
changes stdio/out/err and Encoding's default encoding values, we need to
make sure any test that directly or indirectly (e.g. through Context)
initializes `RelineInputMethod` restores encodings.

`ReadlineInputMethod` also changes encodings but currently no tests
cover it.

* Remove unnecessary TestHelper module

Since we now have a base TestCase, without_rdoc can just live there.

c2874ec121
2022-11-03 22:13:11 +00:00
Stan Lo
7cf7e6c332 [ruby/irb] Add missing require 2022-10-27 15:36:18 +00:00
st0012
26b913c88b [ruby/irb] Add test for IRB::InputCompletor::PerfectMatchedProc
This proc displays rdoc document when the input matches certain symbols
perfectly, like "String". It's commonly triggered with autocompletion
but only has 1 test case. So this commit increases its test coverage.

d85d719313
2022-10-27 15:25:39 +00:00
st0012
5b3079a8a5 [ruby/irb] Sort constant completion's candidates
ee9b33c817
2022-10-08 03:17:42 +09:00
st0012
7be5e9b971 [ruby/irb] Correct assert_equal's usage in completion tests
https://test-unit.github.io/test-unit/en/Test/Unit/Assertions.html#assert_equal-instance_method

00f90d40ad
2022-10-08 03:17:41 +09:00
st0012
afc1f4fba4 [ruby/irb] Add constant completion test
39f8fcb058
2022-10-08 03:17:40 +09:00
st0012
3e18bb916f [ruby/irb] Regroup completion tests
71631287c8
2022-10-08 03:17:39 +09:00
st0012
83a9b91522 [ruby/irb] Add tests for primitive types' method completion
2e12fac38e
2022-10-08 03:17:38 +09:00
Imir Kiyamov
83a6213f31 [ruby/irb] Fixed sort of variables in completion
5842888255
2022-10-05 19:22:13 +09:00
osyo-manga
7b88ffb34f [ruby/irb] Change to explicit method call in completion (https://github.com/ruby/irb/pull/369)
Ensure that methods are called even when local variables are defined.
see: https://github.com/ruby/irb/issues/368

c34d54b8bb
2022-10-03 06:55:53 +09:00
Stan Lo
c21f820b49 [ruby/irb] Fix completion tests
eb1691f636
2022-09-21 22:59:45 +09:00
st0012
6325fc8854 [ruby/irb] Handle non-String $LOAD_PATH values more carefully
In addition to String values, $LOAD_PATH can also take objects that
respond_to the `to_path` method, like Pathname objects. So `irb` should
be able to handle those objects too.

And if $LOAD_PATH contains objects that can't be converted into String,
`irb` should simply ignore it.

b2f562176b
2022-09-21 22:24:27 +09:00
Kaíque Kandy Koga
5c646ca0a0 [ruby/irb] Ignore parenthesis during completion
Rename method

619aecb412
2021-10-13 06:33:48 +09:00
aycabta
40a65030e5 Pend test_complete_require_library_name_first 2021-09-24 22:56:38 +09:00
Nobuyoshi Nakada
ede95f541b [ruby/irb] Ignore any encoding errors while symbol completion
daa65cded1
2021-09-23 18:01:36 +09:00
Nobuyoshi Nakada
4576cdca73 [ruby/irb] Fix argument order
05c65858a0
2021-09-21 23:28:02 +09:00
aycabta
3e038ab1c7 [ruby/irb] Ignore invalid 3 colons in completion
5e29e3e39c
2021-09-11 04:41:20 +09:00
aycabta
580f340c33 [ruby/irb] Use "csv" for test
The "csv" doesn't conflict with other stdlib names in any Ruby processing
system.

49203a1c83
2021-09-08 05:24:04 +09:00
aycabta
bc24af0f35 [ruby/irb] Show lib name first because it's the most common use case
74d635758b
2021-09-08 05:23:56 +09:00
aycabta
ff372ed74b [ruby/irb] Suppress "assigned but unused variable" warning
a1ddf64c69
2021-09-04 17:48:31 +09:00
aycabta
9ac32e87bb [ruby/irb] Add an assertion to check completion "var.method" to get correct "class.method"
cc1ddb37a9
2021-09-04 17:48:26 +09:00
aycabta
6fa37d2666 [ruby/irb] Retrieve completed receiver that is a module or class correctly
b2324727e1
2021-09-04 17:48:20 +09:00
aycabta
4e40b7ddb0 [ruby/irb] Detect the variable class to show doc
33b9bec954
2021-09-02 21:39:55 +09:00
Hiroshi SHIBATA
598f4f4219 [ruby/irb] Use pend instead of skip
f441ce35bf
2021-08-30 12:39:23 +09:00
aycabta
ad8842c06d [ruby/irb] Cache completion files to require
612ebcb311
2021-03-25 18:54:02 +09:00
Nobuyoshi Nakada
2dcbc6ef96
[ruby/irb] fix completion test when out-of-place build 2021-03-24 16:10:27 +09:00
aycabta
0927756e58 [ruby/irb] Complete require and require_relative
1c61178b4c
2021-03-24 15:11:41 +09:00
Koichi Sasada
d4b7e967b6 should use assert_include here.
Random ordering test can introduce antoher candidate so it should be
`assert_include`.
2021-01-08 14:44:26 +09:00
Nobuhiro IMAI
f594775230 [ruby/irb] do not escape a predicate method for doc namespace
* Fixes #88

d431a30af4
2021-01-08 13:25:18 +09:00
Nobuhiro IMAI
961630126b [ruby/irb] fix reserved words and completion for them
6184b227ad
2020-02-15 21:52:03 +09:00
Yusuke Endoh
fad98c6c61 test/irb/test_completion.rb: suppress a warning: unused literal ignored 2020-02-14 00:07:28 +09:00
aycabta
15cacf1f55 Add test_complete_symbol
The previous version of the test method used a symbol, ":abcdefg" to complete
but longer symbols that can be completed are defined by other test methods of
other libs.
2020-02-12 19:40:10 +09:00