Commit graph

52 commits

Author SHA1 Message Date
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
Hiroshi SHIBATA
166c4a6a28
Revert "[ruby/irb] Add test_complete_symbol"
This reverts commit 3af3431c2c.
2020-02-12 14:38:40 +09:00
aycabta
0719e1be11 [ruby/irb] Check doc namespace correctly
IRB::InputCompletor::PerfectMatchedProc crashes when doc not found because a
variable name was incorrect.

889fd4928f
2020-02-12 13:14:28 +09:00
aycabta
3af3431c2c [ruby/irb] Add test_complete_symbol
dbbf086c1f
2020-02-12 13:14:28 +09:00
aycabta
4325f08086 Add require "irb" to test/irb/test_completion.rb 2019-11-28 15:32:21 +09:00
aycabta
7d75e94ea9 Fix regexp to complete complex literal
IRB completion logic always needed exponential notation for complex literal
such as 3e6i but it's bug. I fixed to support complex literal without
exponential notation such as 3i.
2019-11-28 15:22:38 +09:00
Takashi Kokubun
1808029061
make sync-default-gems GEM=irb
Upgrade IRB to 41ea43a4a7

Mostly backport changes.
2019-06-13 00:32:20 +09:00
Takashi Kokubun
9348643575
make sync-default-gems GEM=irb
Synced from 5feb361ed8.
This includes a support to colorize named Class instance on IRB inspect.
2019-04-27 22:01:11 +09:00
Takashi Kokubun
52cfb17086
make sync-default-gems GEM=irb
from e6739d8c66
2019-04-26 18:28:57 +09:00
aycabta
3863b7776f Remove IRB's old test files
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@67649 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2019-04-20 09:32:44 +00:00
naruse
3e92b635fb Add frozen_string_literal: false for all files
When you change this to true, you may need to add more tests.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@53141 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-12-16 05:07:31 +00:00
akr
fb2008a73a * test/lib/envutil.rb: Moved from test/ruby/.
* test/lib/find_executable.rb: Ditto.

* test/lib/memory_status.rb: Ditto.

* test/lib/test/unit.rb: require envutil.

* test/: Don't require envutil in test files.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@48409 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-11-13 16:05:37 +00:00