Граф коммитов

74 Коммитов

Автор SHA1 Сообщение Дата
Stan Lo 91b106fe4b [ruby/irb] Stanardise test class names with `Test` postfix instead
of prefix
(https://github.com/ruby/irb/pull/603)

https://github.com/ruby/irb/commit/359cb28def
2023-06-13 11:02:26 +00:00
Stan Lo 2f8e5c80e6 [ruby/irb] Drop Ruby 2.6 support
(https://github.com/ruby/irb/pull/555)

* Remove all Ruby 2.6 support

* Drop Ruby 2.6 specific testing conditions

* Only run Ruby 2.7+ on CI

* Bump Ruby requirement to 2.7+

https://github.com/ruby/irb/commit/3f714b616c
2023-04-05 21:40:40 +00:00
tomoya ishida f313514563 [ruby/irb] Fix colorize backtick symbol
(https://github.com/ruby/irb/pull/508)

https://github.com/ruby/irb/commit/dd7f25cd45

Co-authored-by: Stan Lo <stan001212@gmail.com>
2023-02-12 20:27:32 +00:00
Nobuyoshi Nakada a968d783a3 [ruby/irb] Test colors with enabling colors
https://github.com/ruby/irb/commit/998b7a74fa
2022-12-26 15:28:38 +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.

https://github.com/ruby/irb/commit/c2874ec121
2022-11-03 22:13:11 +00:00
tomoya ishida a09f764ce5 [ruby/irb] Always use local variables in current context to parse code (https://github.com/ruby/irb/pull/397)
* Use local_variables for colorize, code_block_open check, nesting_level and assignment_expression check

* Check if expression is an assignment BEFORE evaluating it. evaluate might define new localvars and change result of assignment_expression?

* Add local_variables dependent code test

* pend local variable dependent test on truffleruby

code_block_open is not working on truffleruby

* Always pass context to RubyLex#lex

* Rename local_variable_assign_code generator method name

* Add assignment expression truncate test

* Add Context#local_variables and make generate_local_variables_assign_code more simple

* Update lib/irb/input-method.rb

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

* Add a comment why assignment expression check should be done before evaluate

https://github.com/ruby/irb/commit/c8b3877281

Co-authored-by: Stan Lo <stan001212@gmail.com>
Co-authored-by: Takashi Kokubun <takashikkbn@gmail.com>
2022-10-18 05:44:07 +00:00
st0012 1c83469fc6 [ruby/irb] Remove unnecessary coloring support check
https://github.com/ruby/irb/commit/ddd7dbe2c5
2022-10-17 21:14:50 +00:00
yui-knk 4bfdf6d06d Move `error` from top_stmts and top_stmt to stmt
By this change, syntax error is recovered smaller units.
In the case below, "DEFN :bar" is same level with "CLASS :Foo"
now.

```
module Z
  class Foo
    foo.
  end

  def bar
  end
end
```

[Feature #19013]
2022-10-08 17:59:11 +09:00
tompng 78cb638002 [ruby/irb] Update expected colorize result that were uncolored before
https://github.com/ruby/irb/commit/52446eb77f
2022-09-22 00:37:39 +09:00
tompng 9f68687879 [ruby/irb] Scan every single characters in IRB::Color.scan
https://github.com/ruby/irb/commit/d14e56a65d
2022-09-22 00:37:38 +09:00
Hiroshi SHIBATA 598f4f4219 [ruby/irb] Use pend instead of skip
https://github.com/ruby/irb/commit/f441ce35bf
2021-08-30 12:39:23 +09:00
Nobuyoshi Nakada 8fdc45c894 [ruby/irb] Added `colorable` keyword option
Currently `IRB::Color.colorize` and `IRB::Color.colorize_code`
refer `$stdin.tty?` internally.
This patch adds `colorable` keyword option which overrides it.

https://github.com/ruby/irb/commit/402e3f1907
2021-04-26 21:14:52 +09:00
Nobuyoshi Nakada 687ab5dcad [ruby/irb] Assertions on non-tty
https://github.com/ruby/irb/commit/ede12890d2
2021-04-26 21:14:44 +09:00
Nobuyoshi Nakada 75f1ad8cb3 [ruby/irb] Added test_colorize
https://github.com/ruby/irb/commit/10e290fc3a
2021-04-26 21:14:37 +09:00
Nobuyoshi Nakada 6ddaad606e [ruby/irb] Added assert_equal_with_term
https://github.com/ruby/irb/commit/b690da96d8
2021-04-26 21:14:31 +09:00
Nobuyoshi Nakada 79af8ce6d7 [ruby/irb] Colorize `__END__` as keyword
https://github.com/ruby/irb/commit/9b84018311
2021-04-02 10:52:53 +09:00
Takashi Kokubun f4a556f4f1 [ruby/irb] Remove pp-specific stub from TestColor
because it was for TestColorPrinter

https://github.com/ruby/irb/commit/7569206fd4
2021-01-20 18:10:20 +09:00
Takashi Kokubun 328df00712 [ruby/irb] Split test files for IRB::Color and IRB::ColorPrinter
https://github.com/ruby/irb/commit/d95e8daab3
2021-01-20 18:03:37 +09:00
Takashi Kokubun e6af81bde1 [ruby/irb] Stub a screen size for test_context
http://ci.rvm.jp/logfiles/brlog.trunk-random1.20210119-074232

https://github.com/ruby/irb/commit/ea87592d4a
2021-01-19 00:14:48 -08:00
Takashi Kokubun b2159f7c38 [ruby/irb] Stub a screen size for tests
https://github.com/ruby/irb/commit/6663057083
2021-01-18 23:35:50 -08:00
Nobuhiro IMAI 3f0b4665df [ruby/irb] handle `__ENCODING__` as a keyword as well
https://github.com/ruby/irb/commit/a6a33d908f
2021-01-18 02:12:43 +09:00
Nobuyoshi Nakada 480f436dac
Suppress constant redefinition warnings 2021-01-11 00:33:26 +09:00
Takashi Kokubun 98bd7e87a0 [ruby/irb] Make IRB::ColorPrinter.pp compatible with PP.pp
The incompatible interface is not helpful, again if you want to use it
as a standalone library, falling it back to PP.

Original PP.pp also ends with `out << "\n"`.

https://github.com/ruby/irb/commit/4c74c7d84c
2021-01-07 22:43:40 -08:00
aycabta 515d6b47ad [ruby/irb] Stringify when a non-object is passed to PP#text
If a nested object is passed to #pp, it may be sometimes passed to the #text
method as an object without being stringified.

This is fixed on the Ruby main repository;
433a3be86a
but it was a bug of Ripper so still needs this workaround for using irb
as a gem on Ruby 3.0.0 or earlier.

Co-authored-by: k0kubun <takashikkbn@gmail.com>

https://github.com/ruby/irb/commit/8d13df22ee
2021-01-04 20:14:31 -08:00
Nobuhiro IMAI 9b7ceb6765
irb: add more syntax errors colorizing support (#3967) 2020-12-28 23:07:20 -08:00
Nobuyoshi Nakada 1f7b557890
Update expected IRB result 2020-11-20 18:30:05 +09:00
Nobuyoshi Nakada 5e7322b866 [ruby/irb] `yield` outside method definition is a syntax error
https://github.com/ruby/irb/commit/dbc7b059c7
2020-02-21 23:16:15 +09:00
Takashi Kokubun fcd9bc28e3
qsymbols and symbols should be colored as Symbol 2019-11-10 13:54:44 -08:00
Takashi Kokubun 25c53a8eec
Colorize on_symbols_beg (%I) 2019-11-10 13:41:41 -08:00
Takashi Kokubun b5996b25ae
Colorize string quotes as bold
like pry
2019-11-10 13:33:23 -08:00
Ary Borenszweig 96617ad1d5 IRB colorize: take into account recursive arrays and hashes (#2555)
[Bug #16250]
2019-10-14 21:25:05 -07:00
Nobuyoshi Nakada ea68bb914a Changed numbered parameter prefix 2019-09-24 21:57:54 +09:00
Takashi Kokubun 2a26c1ea24
Clarify the Ruby version support status in IRB more 2019-06-13 00:41:00 +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
Nobuyoshi Nakada 88411d350e
Another incomplete string case 2019-06-12 15:30:07 +09:00
Nobuyoshi Nakada 9593e76ac2
Ripper::Lexer: fallback parse error token to the previous one 2019-06-12 15:25:06 +09:00
Takashi Kokubun 0da9205f15
Remove conflict resolution mistake [ci skip]
in de541fe196 🙇
2019-06-04 00:32:17 +09:00
Takashi Kokubun d21a694075
Improve test_color to prevent regression
Actually de541fe196 was still needed.
This commit would improve the test coverage using the branch.
2019-06-04 00:29:54 +09:00
Takashi Kokubun de541fe196
colorize_code must return escaped text
This was needed before 0c459af7c2 but it
could be actually useless now. But I added this anyway just in case.
2019-06-04 00:26:02 +09:00
Nobuyoshi Nakada 0c459af7c2
Colorize error characters
* lib/irb/color.rb (IRB::Color.scan): ignore "incomplete end of
  input" error only, to colorize invalid characters, e.g., control
  characters, and invalid symbols, as errors.
2019-06-04 00:14:55 +09:00
Takashi Kokubun cb40a21da0
Warn compile_error only when input is finished
Let's say we are in progress to write `"foo"`:

```
irb> "fo
```

at this moment, nothing is wrong.
It would be just a normal way to write `"foo"`.

Prior to this commit, the `fo` part was warned because of
5b64d7ac6e. But I think warning such a
normal input is not valuable for users.

However, we'd like to warn `:@1` or `@@1` which is also a syntax error.
Then this commit switches the syntax highlight based on whether the
input text is finished or not. When it's not finished yet, it does not
warn compile_error.
2019-05-31 06:54:00 +09:00
Nobuyoshi Nakada 5b64d7ac6e
Colorize errors more
* lib/irb/color.rb (IRB::Color.colorize_code): colorize
  `compile_error` part as same as `on_parse_error`.
2019-05-29 22:09:54 +09:00
Nobuyoshi Nakada 068d327595
Colorize compile_error as same as on_parse_error 2019-05-29 13:34:19 +09:00
Nobuyoshi Nakada 8a2a5822ca
Colorize error part 2019-05-27 23:08:51 +09:00
Takashi Kokubun 64ee8900c8
Highlight global variable on IRB 2019-05-26 11:32:23 -07:00
Takashi Kokubun 897901283c
Refactor IRB color dispatch
The reason why we were checking lexer state in addition to token was
that we do not want to colorize local variable, method call, etc., while
they share the :on_ident token with a name of method definition which
should be colored as blue.

It means that we're concerned about the lexer state only for :on_ident.
Thus we can skip checking lexer state for non-:on_ident tokens. This
refactoring is based on that idea.

Also, now we manage Ripper's lexer state as Integer (use `|` if you
need to check multiple states). It should be faster than using Array of
Integer because #any? block call is not needed.
2019-05-26 11:03:57 -07:00
aycabta 1226791368 Support :@@cvar and : on colorize 2019-05-27 02:56:05 +09:00
Takashi Kokubun e50aa359de
Make the imaginary color on IRB close to pry
and sorted the token names alphabetically.
2019-05-26 10:23:04 -07:00
Nobuyoshi Nakada 4f2a7b8001
Colorize imaginary and rational literals 2019-05-26 23:46:14 +09:00
Nobuyoshi Nakada 2ce6365f9c
parse.y: adjust error indicator
* parse.y (parser_yylex): adjust the error indicator of unexpected
  fraction part.

before:
~~~
1.2.3
^~~
~~~

after:
~~~
1.2.3
   ^~
~~~
2019-05-26 18:47:52 +09:00