Commit graph

12086 commits

Author SHA1 Message Date
Alfonso Jiménez
0acbdd1ed0
Adding Enumerable#filter_map
[Feature #15323]
Closes: https://github.com/ruby/ruby/pull/2017
2019-05-23 14:39:16 +09:00
Jeremy Evans
c05eaa9325 Fix mixed encoding in heredoc
Heredocs are parsed line-by-line, so we need to keep track of the
temporary encoding of the string.  Previously, a heredoc would
only detect mixed encoding errors if they were on the same line,
this changes things so they will be caught on different lines.

Fixes [Bug #15839]
2019-05-22 21:52:20 -07:00
Jeremy Evans
f91b1ab33d Skip assertion in readline test if Readline version is 4.3
Previously, the entire method was not run for Readline 4.3, probably
because it was known to fail. Commit
c754e979d3 removed the check for
Readline 4.3.  Other than this one assertion, which also doesn't
work when using Reline, the method runs correctly when using
Readline 4.3.

Fixes [Bug #15853].
2019-05-22 21:32:31 -07:00
Koichi Sasada
136ae55892 Do not kick finalizers on rb_gc().
rb_gc() kicks gc_finalize_deferred(), which invokes finalizers.
This means that any Ruby program can be run this point and
it may be thread switching points and so on.

However, it is difficult to think it invokes any Ruby programs.
For example, `GC.compact` use `rb_gc()` to implement it, howver,
any Ruby program must not be run on this timing.

For this reason (it is difficult to image it run any Ruby program),
I removed `gc_finalize_deferred()` line in rb_gc().

This patch solves GC.compact issue.
[Bug #15809] and re-enable GC.compact test.
2019-05-23 11:26:33 +09:00
Yusuke Endoh
9d39eb6b40 range.c (inspect_range): omit beginless "nil"
except the special case `(nil..nil)`.

```
(1..).inspect      #=> "1.."
(..5).inspect      #=> "..5"
(nil..nil).inspect #=> "nil..nil"
```

[Bug #15745]
2019-05-23 00:48:32 +09:00
Yusuke Endoh
d3f1c615c5 hash.c (rb_hash_s_create): Reject Hash[[nil]]
The behavior of `Hash[[nil]] #=> {}` was a bug until 1.9.3, but had been
remained with a warning because some programs depended upon it.
Now, six years passed.  We can remove the compatibility behavior.
[Bug #7300]
2019-05-23 00:19:56 +09:00
aycabta
ca435ed04a Use Reline.test_mode in Reline's test too 2019-05-22 03:12:37 +09:00
Takashi Kokubun
32ed85f601
Copy config to make IRB::Context#use_colorize? functional
on initialize

This fixes https://github.com/ruby/ruby/pull/2188
2019-05-21 04:32:17 -07:00
Koichi Sasada
3f6b5f447c re-skip tests of GC.compact. 2019-05-21 18:35:10 +09:00
aycabta
6d93baaedd Support DEL key 2019-05-21 17:46:41 +09:00
Koichi Sasada
8c004c7123 enable test for GC.compact to reproduce an issue on CI 2019-05-21 09:45:28 +01:00
Nobuyoshi Nakada
ac00bdc8a8
Do not modify shared array
[Bug #15821]
2019-05-21 14:17:51 +09:00
Nobuyoshi Nakada
f9696ca6cb
Simplified the guard against old versions 2019-05-21 13:49:31 +09:00
aycabta
be0d9c0d26 Add "require 'irb'" to use IRB.conf 2019-05-21 09:24:09 +09:00
aycabta
16917cc3cb Add Reline.test_mode to use with special I/O 2019-05-18 12:48:27 +09:00
Koichi Sasada
b165bedcbd skip a test to pass CIs.
I'm debugging [Bug #15821] but my patch introduces another issue.
So I simply skip this test and re-enable it later.
2019-05-18 12:17:02 +09:00
Nobuyoshi Nakada
6ae1c596f0
Add test for UNTIL 2019-05-18 09:41:22 +09:00
Nobuyoshi Nakada
c4bad9f74e
Distinguish pre-condition and post-condition loops 2019-05-18 09:35:40 +09:00
aycabta
9858d74a12 Remove parent namespace from Readline test classes
The namespace "Readline" doesn't exist when running tests if readline.so
doesn't exist and Reline exists. So test classes shouldn't be at nested
namespaces under "Readline".
2019-05-18 02:32:25 +09:00
Koichi Sasada
32e8b42852 skip tests for GC.compact to pass CI.
Now, GC.compact has issues which makes rubyci RED, so I skip this test
and debug soon.
2019-05-17 12:59:49 +09:00
Nobuyoshi Nakada
0971cab4d0
Test to disable ASCII-only optimization
Examples why ASCII-only optimization cannot apply multi-byte
encodings which have 7-bit trailing bytes.

Suggested by @duerst at https://github.com/ruby/ruby/pull/2187#issuecomment-492949218
2019-05-17 10:05:57 +09:00
Nobuyoshi Nakada
18e43e8231
Fix fd leak
merged https://github.com/rubygems/rubygems/pull/2765
2019-05-16 14:58:57 +09:00
Nobuyoshi Nakada
c9b28fd7ae
Allow --enable/--disable options to take an argument
[Bug #15850]
2019-05-15 17:31:11 +09:00
Aaron Patterson
c70ceb5992
Add object packing strategies for compaction
This commit adds an alternative packing strategy for compaction.
Instead of packing towards "most pinned" pages, we can pack towards
"most empty" pages.  The idea is that we can double the heap size, then
pack all objects towards the empty side of the heap.  This will ensure
maximum chaos for testing / verification.
2019-05-14 20:21:03 -07:00
aycabta
80c968c571 Rename Reline's test file name because of typo 2019-05-14 17:06:38 +09:00
aycabta
c754e979d3 Test ext/readline and lib/reline by test/readline 2019-05-14 15:37:45 +09:00
aycabta
07e7ae9ed7 Add an assertion message to test of Readline's class variables 2019-05-14 15:37:17 +09:00
aycabta
1e65196b54 Check encoding when Readline completion 2019-05-14 14:53:34 +09:00
Urabe, Shyouhei
5bab1304af fix visibility of SecureRandom.gen_random
Aliasing a method preserves its visibility.  These aliases turn
formerly-public methods into private.  Should make them public
again.  [Bug #15847]
2019-05-14 11:44:20 +09:00
Étienne Barrié
2dc613815d
delegate.rb: don't look for methods on Kernel
Instead, look for instance methods of Kernel.
Otherwise, instance methods of Module (which are methods of Kernel
itself) are mistakenly believed to exist, and it fails when calling
Kernel.instance_method().

Closes: https://github.com/ruby/ruby/pull/1422
2019-05-13 11:29:42 +09:00
aycabta
24964fff92 Check that Reline exists on test 2019-05-13 04:22:15 +09:00
aycabta
75f196ce75 Skip tests depend on Readline's special behaviors 2019-05-13 03:29:18 +09:00
aycabta
bb56b89900 Add ed_search_prev_history to Reline 2019-05-13 01:51:05 +09:00
aycabta
33bce2585f Use LineEditor#reset on test 2019-05-13 00:31:32 +09:00
aycabta
fc57e10569 Revert "Add a test for em_capitol_case of Reline"
This reverts commit b1767e56b1.
2019-05-12 20:43:38 +09:00
aycabta
b1767e56b1 Add a test for em_capitol_case of Reline 2019-05-12 17:25:28 +09:00
Nobuyoshi Nakada
dc65e75101
Adjust indent 2019-05-10 22:00:22 +09:00
Takashi Kokubun
bef5829482
Add one more retry for win32ole event matcher
to fix
24438615/job/yld1utsltxag9dr2
2019-05-10 11:54:21 +09:00
Alan Wu
c06ddfee87
str_duplicate: Don't share with a frozen shared string
This is a follow up for 3f9562015e.
Before this commit, it was possible to create a shared string which
shares with another shared string by passing a frozen shared string
to `str_duplicate`.

Such string looks like:

```
 --------                    -----------------
 | root | ------ owns -----> | root's buffer |
 --------                    -----------------
     ^                             ^   ^
 -----------                       |   |
 | shared1 | ------ references -----   |
 -----------                           |
     ^                                 |
 -----------                           |
 | shared2 | ------ references ---------
 -----------
```

This is bad news because `rb_fstring(shared2)` can make `shared1`
independent, which severs the reference from `shared1` to `root`:

```c
/* from fstr_update_callback() */
str = str_new_frozen(rb_cString, shared2);  /* can return shared1 */
if (STR_SHARED_P(str)) { /* shared1 is also a shared string */
    str_make_independent(str);  /* no frozen check */
}
```

If `shared1` was the only reference to `root`, then `root` can be
reclaimed by the GC, leaving `shared2` in a corrupted state:

```
 -----------                         --------------------
 | shared1 | -------- owns --------> | shared1's buffer |
 -----------                         --------------------
      ^
      |
 -----------                         -------------------------
 | shared2 | ------ references ----> | root's buffer (freed) |
 -----------                         -------------------------
```

Here is a reproduction script for the situation this commit fixes.

```ruby
a = ('a' * 24).strip.freeze.strip
-a
p a
4.times { GC.start }
p a
```

 - string.c (str_duplicate): always share with the root string when
   the original is a shared string.
 - test_rb_str_dup.rb: specifically test `rb_str_dup` to make
   sure it does not try to share with a shared string.

[Bug #15792]

Closes: https://github.com/ruby/ruby/pull/2159
2019-05-09 10:04:19 +09:00
NARUSE, Yui
f1486fea46 require 'stringio' 2019-05-09 09:23:44 +09:00
Takashi Kokubun
a95ca6d5e9
Trim MJIT output from TestHideSkip
to prevent failure like
5cd28aa6ab
with --jit-verbose=1.
2019-05-08 17:30:15 +09:00
Jean Boussier
7d805e67f3
Avoid triggering autoload in Module#const_defined?(String)
[Bug #15780]
2019-05-07 21:20:01 +09:00
Jeremy Evans
0c0ed1cee8
Fix use of numbered parameter inside proc that is default value of optarg
This allows cases such as:

```ruby
m ->(a = ->{@1}) {a}
m.call.call(1)

m2 ->(a: ->{@1}) {a}
m2.call.call(2)
```

Previously, this would cause a syntax error.

[Bug#15789]
2019-05-05 15:33:10 +09:00
Jeremy Evans
b8f3be295b
Fix a case where numbered parameters should not be allowed
Because `proc{|| @1}` is a syntax error, the following should
also be syntax errors:

```ruby
proc { |
| @1}
```

```ruby
proc { |; a| @1 }
```

This fixes both cases.

[Bug #15825]
2019-05-05 14:46:39 +09:00
Nobuyoshi Nakada
ff21e75d32
parse.y: duplicated when clause warning
* parse.y (case_args): moved "duplicated when clause" warning from
  compile phase, so that `ruby -wc` shows them.
2019-05-05 00:29:12 +09:00
Masatoshi SEKI
848edb03f8 ignore test_RangeError 2019-05-04 23:32:13 +09:00
Masatoshi SEKI
8980b53a48 add DRb::WeakIdConv (Bug #15711) 2019-05-04 19:28:57 +09:00
Nobuyoshi Nakada
71952440ad
Silence a (probable) debug print 2019-05-01 20:55:08 +09:00
NAKAMURA Usaku
dcb6a6ae3e
Windows simply causes an error to open invalid path 2019-05-01 17:38:45 +09:00
manga_osyo
4e88e86928 Add exception support in Range#first.
Closes: https://github.com/ruby/ruby/pull/2163
2019-05-01 00:03:30 +09:00