Commit graph

976 commits

Author SHA1 Message Date
Nobuyoshi Nakada
174ddc79c5
Skip File.atime/File.mtime tests randomly failing on Travis
Not only powerpc64le, also s390x and arm32 seem failing too.  These
failures are probably caused by filesystem settings on Travis, but
unrelated to CPUs.
2022-10-24 09:32:13 +09:00
Stephen Ierodiaconou
54cad3123a
[Bug #19004] Complex.polar handles complex singular abs argument
`Complex.polar` accepts Complex values as arguments for the polar form as long
as the value of the complex has no imaginary part (ie it is 'real'). In
`f_complex_polar` this is handled by extracting the real part of the arguments.
However in the case `polar` is called with only a single argument, the absolute
value (abs), then the Complex is created without applying a check on the type
of abs, meaning it is possible to create a Complex where the real part is itself
an instance of a Complex. This change removes the short circuit for the single
argument case meaning the real part extraction is performed correctly
(by f_complex_polar).

Also adds an example to `spec/ruby/core/complex/polar_spec.rb` to check that
the real part of a complex argument is correctly extracted and used in the
resulting Complex real and imaginary parts.
2022-10-23 12:59:06 +09:00
Yusuke Endoh
e026368061 Range#size returns nil for (.."a") and (nil..)
Fixes [Bug #18983]
2022-10-21 16:35:46 +09:00
Ufuk Kayserilioglu
0378e2f4a8 Add Class#attached_object
Implements [Feature #12084]

Returns the object for which the receiver is the singleton class, or
raises TypeError if the receiver is not a singleton class.
2022-10-20 17:30:17 +02:00
Jemma Issroff
0aaa6133ed Transition frozen string to frozen root shape
Co-Authored-By: Aaron Patterson <tenderlove@ruby-lang.org>
2022-10-19 11:06:19 -07:00
Jean Boussier
60defe0a68 thread_sync.c: Clarify and document the behavior of timeout == 0
[Feature #18982]

Instead of introducing an `exception: false` argument to have `non_block`
return nil rather than raise, we can clearly document that a timeout of 0
immediately returns.

The code is refactored a bit to avoid doing a time calculation in
such case.
2022-10-17 16:56:00 +02:00
Hiroshi SHIBATA
b734832883
Skip utime example with Intel C Compiler suite 2022-10-13 13:42:22 +09:00
Nobuyoshi Nakada
6c5a8c2043 Ignore excessive precisions 2022-10-10 13:41:46 +09:00
Samuel Williams
24f3e397e9
Add spec for Coverage.supported? and start(eval: true). (#6499)
* Don't emit coverage for eval when eval coverage is disabled.
2022-10-08 00:33:40 +13:00
Samuel Williams
e4f91bbdba
Add IO#timeout attribute and use it for blocking IO operations. (#5653) 2022-10-07 21:48:38 +13:00
Samuel Williams
e696ec67ac
Introduce Fiber.blocking{} for bypassing the fiber scheduler. (#6498) 2022-10-06 23:00:49 +13:00
Victor Shepelev
ad651925e3
Add Data class implementation: Simple immutable value object 2022-09-30 18:23:19 +09:00
Benoit Daloze
aa53d69aa2 Add specs for {Method,UnboundMethod}#owner of a zsuper method 2022-09-29 15:48:35 +02:00
Benoit Daloze
94cea3e4d0 Fix {Method,UnboundMethod}#super_method for zsuper methods
* We need to resolve the zsuper method first, and then look the super
  method of that.
2022-09-29 15:48:35 +02:00
Hiroshi SHIBATA
9948b8bfec
Skip unpack_sockaddr_in with http at Solaris platform
20220929T050003Z.fail.html.gz
2022-09-29 15:47:08 +09:00
Benoit Daloze
31cf1bb525 Update to ruby/spec@1d9d5c6 2022-09-28 18:37:17 +02:00
Jemma Issroff
d594a5a8bd
This commit implements the Object Shapes technique in CRuby.
Object Shapes is used for accessing instance variables and representing the
"frozenness" of objects.  Object instances have a "shape" and the shape
represents some attributes of the object (currently which instance variables are
set and the "frozenness").  Shapes form a tree data structure, and when a new
instance variable is set on an object, that object "transitions" to a new shape
in the shape tree.  Each shape has an ID that is used for caching. The shape
structure is independent of class, so objects of different types can have the
same shape.

For example:

```ruby
class Foo
  def initialize
    # Starts with shape id 0
    @a = 1 # transitions to shape id 1
    @b = 1 # transitions to shape id 2
  end
end

class Bar
  def initialize
    # Starts with shape id 0
    @a = 1 # transitions to shape id 1
    @b = 1 # transitions to shape id 2
  end
end

foo = Foo.new # `foo` has shape id 2
bar = Bar.new # `bar` has shape id 2
```

Both `foo` and `bar` instances have the same shape because they both set
instance variables of the same name in the same order.

This technique can help to improve inline cache hits as well as generate more
efficient machine code in JIT compilers.

This commit also adds some methods for debugging shapes on objects.  See
`RubyVM::Shape` for more details.

For more context on Object Shapes, see [Feature: #18776]

Co-Authored-By: Aaron Patterson <tenderlove@ruby-lang.org>
Co-Authored-By: Eileen M. Uchitelle <eileencodes@gmail.com>
Co-Authored-By: John Hawthorn <john@hawthorn.email>
2022-09-28 08:26:21 -07:00
Vít Ondruch
bcd30fb961 Re-enable TZ test missed due to merge conflict.
This was disabled by b7577b4d9e, while properly fixed upstream by:

https://github.com/ruby/spec/pull/939
2022-09-27 19:32:46 +02:00
Aaron Patterson
06abfa5be6
Revert this until we can figure out WB issues or remove shapes from GC
Revert "* expand tabs. [ci skip]"

This reverts commit 830b5b5c35.

Revert "This commit implements the Object Shapes technique in CRuby."

This reverts commit 9ddfd2ca00.
2022-09-26 16:10:11 -07:00
Jemma Issroff
9ddfd2ca00 This commit implements the Object Shapes technique in CRuby.
Object Shapes is used for accessing instance variables and representing the
"frozenness" of objects.  Object instances have a "shape" and the shape
represents some attributes of the object (currently which instance variables are
set and the "frozenness").  Shapes form a tree data structure, and when a new
instance variable is set on an object, that object "transitions" to a new shape
in the shape tree.  Each shape has an ID that is used for caching. The shape
structure is independent of class, so objects of different types can have the
same shape.

For example:

```ruby
class Foo
  def initialize
    # Starts with shape id 0
    @a = 1 # transitions to shape id 1
    @b = 1 # transitions to shape id 2
  end
end

class Bar
  def initialize
    # Starts with shape id 0
    @a = 1 # transitions to shape id 1
    @b = 1 # transitions to shape id 2
  end
end

foo = Foo.new # `foo` has shape id 2
bar = Bar.new # `bar` has shape id 2
```

Both `foo` and `bar` instances have the same shape because they both set
instance variables of the same name in the same order.

This technique can help to improve inline cache hits as well as generate more
efficient machine code in JIT compilers.

This commit also adds some methods for debugging shapes on objects.  See
`RubyVM::Shape` for more details.

For more context on Object Shapes, see [Feature: #18776]

Co-Authored-By: Aaron Patterson <tenderlove@ruby-lang.org>
Co-Authored-By: Eileen M. Uchitelle <eileencodes@gmail.com>
Co-Authored-By: John Hawthorn <john@hawthorn.email>
2022-09-26 09:21:30 -07:00
Chris Salzberg
82ac4a2399 Support using at toplevel in wrapped script
Allow refinements to be used at the toplevel within a script that is
loaded under a module.

Fixes [Bug #18960]
2022-09-24 09:41:15 +09:00
Samuel Williams
9434a7333c Enable coverage for eval. 2022-09-22 22:19:12 +12:00
Benoit Daloze
14bcf69c9c Deprecate Encoding#replicate
* See [Feature #18949].
2022-09-10 19:02:15 +02:00
Jean Boussier
bbe5ec7846 rb_int_range_last: properly handle non-exclusive range
[Bug #18994]
2022-09-04 11:16:11 +02:00
Takashi Kokubun
737402e938
Skip a couple of chroot spec faillures
I don't come up with a way to fix it right away. We'd need some
experiments on a pull request.
2022-08-29 09:55:57 -07:00
Benoit Daloze
1315c5aad9 Update to ruby/spec@b8a8240 2022-08-29 18:18:23 +02:00
Benoit Daloze
4ee1a68776 Update to ruby/spec@d01709f 2022-08-29 15:36:29 +02:00
Jean Boussier
b2d0f78869 Fix private methods reported as protected when called via Symbol#to_proc
Ref: bfa6a8ddc8
Ref: [Bug #18826]
2022-08-25 17:49:50 +02:00
Benoit Daloze
209631a45f Consider resolved-through-zsuper methods equal for compatibility
* Fixes https://bugs.ruby-lang.org/issues/18751
2022-08-20 13:44:00 +02:00
Nobuyoshi Nakada
1ef49de834 [Bug #18955] format single character for %c 2022-08-20 03:57:13 +09:00
Jean Boussier
fe61cad749 Implement SizedQueue#push(timeout: sec)
[Feature #18944]

If both `non_block=true` and `timeout:` are supplied, ArgumentError
is raised.
2022-08-18 10:07:37 +02:00
Nobuyoshi Nakada
b7577b4d9e
The tzdata 2022c removed Amsterdam Mean Time 2022-08-17 00:45:27 +09:00
Jeremy Evans
cfb9624460
Fix Array#[] with ArithmeticSequence with negative steps (#5739)
* Fix Array#[] with ArithmeticSequence with negative steps

Previously, Array#[] when called with an ArithmeticSequence
with a negative step did not handle all cases correctly,
especially cases involving infinite ranges, inverted ranges,
and/or exclusive ends.

Fixes [Bug #18247]

* Add Array#slice tests for ArithmeticSequence with negative step to test_array

Add tests of rb_arithmetic_sequence_beg_len_step C-API function.

* Fix ext/-test-/arith_seq/beg_len_step/depend

* Rename local variables

* Fix a variable name

Co-authored-by: Kenta Murata <3959+mrkn@users.noreply.github.com>
2022-08-11 19:16:49 +09:00
Jeremy Evans
bfa6a8ddc8
Only allow procs created by Symbol#to_proc to call public methods
Fixes [Bug #18826]

Co-authored-by: Nobuyoshi Nakada <nobu@ruby-lang.org>
2022-08-10 13:02:19 -07:00
Nobuyoshi Nakada
43239b23b4
[Bug #18946] New tests for fixed Time/DateTime conversions 2022-08-08 23:48:13 +09:00
Nobuyoshi Nakada
e0dfa5967e
[Bug #18946] Use Gregorian dates to test 2022-08-08 23:48:09 +09:00
Nobuyoshi Nakada
03f86565a6
Silent backtrace from cve_2019_8325_spec.rb
Since the change at f310ac1cb2 to show
the backtraces by default, this test started to show the backtraces.
As the backtraces are not the subject of this test, silence them by
using Gem::SilentUI.
2022-08-07 17:57:52 +09:00
Alan Wu
c433d36b5b Test that File.read defaults to text mode
Co-authored-by: Nobuyoshi Nakada <nobu@ruby-lang.org>
2022-08-05 14:34:08 -04:00
Jean Boussier
e3aabe93aa Implement Queue#pop(timeout: sec)
[Feature #18774]

As well as `SizedQueue#pop(timeout: sec)`

If both `non_block=true` and `timeout:` are supplied, ArgumentError
is raised.
2022-08-02 11:04:28 +02:00
Benoit Daloze
6582df26dc Update to ruby/spec@cbfaf51 2022-07-27 17:18:25 +02:00
Jeremy Evans
7223c0da15 Do not chomp trailing line separator IO#each with nil separator and chomp
nil separator means no sepator, so chomp should not remove a line
separator.

Partially Fixes [Bug #18770]
2022-07-21 12:55:24 -07:00
Jeremy Evans
12ac8971a3 Do not have class/module keywords look up ancestors of Object
Fixes case where Object includes a module that defines a constant,
then using class/module keyword to define the same constant on
Object itself.

Implements [Feature #18832]
2022-07-21 08:28:05 -07:00
Nobuyoshi Nakada
0f06b8fa3e Relax not_before limit
Use the value as similar as other tests below.
Trying to fix sporadic “not yet valid” failures on some CIs.
2022-07-02 14:46:38 +09:00
Nobuyoshi Nakada
c684b1aa26
Fix TODO in stringio/truncate_spec.rb 2022-07-01 09:08:25 +09:00
Koichi Sasada
5df20a5da5 stop CI failures.
302f353fd9 seems break the rubyspec.

@nobu please check it.
2022-07-01 01:45:39 +09:00
Kazuhiro NISHIYAMA
4b1f337ef2
Add more check to debug failures 2022-06-30 15:36:34 +09:00
Jeremy Evans
c3eb0437f2 Fix Process.clock_gettime specs on OpenBSD 2022-06-26 12:39:16 -07:00
Benoit Daloze
d3d5ef0cca Update to ruby/spec@ab32a1a 2022-06-26 14:50:14 +02:00
Nobuyoshi Nakada
883d13dc41 [Feature #18788] Spec for options as String to Regexp.new
Co-Authored-By: Janosch Müller <janosch.mueller@betterplace.org>
2022-06-20 19:35:12 +09:00
Nobuyoshi Nakada
39dc455b51 Spec update for warnning suspicious flag to Regexp.new 2022-06-20 19:35:12 +09:00