Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions gc/default/default.c
Original file line number Diff line number Diff line change
Expand Up @@ -5965,7 +5965,6 @@ gc_marks_start(rb_objspace_t *objspace, int full_mark)
static bool
gc_marks(rb_objspace_t *objspace, int full_mark)
{
gc_prof_mark_timer_start(objspace);
gc_marking_enter(objspace);

bool marking_finished = false;
Expand All @@ -5986,7 +5985,6 @@ gc_marks(rb_objspace_t *objspace, int full_mark)
#endif

gc_marking_exit(objspace);
gc_prof_mark_timer_stop(objspace);

return marking_finished;
}
Expand Down Expand Up @@ -6882,6 +6880,8 @@ gc_marking_enter(rb_objspace_t *objspace)
{
GC_ASSERT(during_gc != 0);

gc_prof_mark_timer_start(objspace);

if (MEASURE_GC) {
gc_clock_start(&objspace->profile.marking_start_time);
}
Expand All @@ -6897,6 +6897,8 @@ gc_marking_exit(rb_objspace_t *objspace)
if (MEASURE_GC) {
objspace->profile.marking_time_ns += gc_clock_end(&objspace->profile.marking_start_time);
}

gc_prof_mark_timer_stop(objspace);
}

static void
Expand Down
4 changes: 2 additions & 2 deletions prism/prism.c
Original file line number Diff line number Diff line change
Expand Up @@ -15486,7 +15486,7 @@ parse_conditional(pm_parser_t *parser, pm_context_t context, size_t opening_newl
pm_token_t keyword = parser->previous;
pm_token_t then_keyword = { 0 };

pm_node_t *predicate = parse_predicate(parser, PM_BINDING_POWER_MODIFIER, context, &then_keyword, (uint16_t) (depth + 1));
pm_node_t *predicate = parse_predicate(parser, PM_BINDING_POWER_COMPOSITION, context, &then_keyword, (uint16_t) (depth + 1));
pm_statements_node_t *statements = NULL;

if (!match3(parser, PM_TOKEN_KEYWORD_ELSIF, PM_TOKEN_KEYWORD_ELSE, PM_TOKEN_KEYWORD_END)) {
Expand Down Expand Up @@ -15524,7 +15524,7 @@ parse_conditional(pm_parser_t *parser, pm_context_t context, size_t opening_newl
pm_token_t elsif_keyword = parser->current;
parser_lex(parser);

pm_node_t *predicate = parse_predicate(parser, PM_BINDING_POWER_MODIFIER, PM_CONTEXT_ELSIF, &then_keyword, (uint16_t) (depth + 1));
pm_node_t *predicate = parse_predicate(parser, PM_BINDING_POWER_COMPOSITION, PM_CONTEXT_ELSIF, &then_keyword, (uint16_t) (depth + 1));
pm_accepts_block_stack_push(parser, true);

pm_statements_node_t *statements = parse_statements(parser, PM_CONTEXT_ELSIF, (uint16_t) (depth + 1));
Expand Down
4 changes: 0 additions & 4 deletions spec/ruby/.rubocop.yml
Original file line number Diff line number Diff line change
Expand Up @@ -54,10 +54,6 @@ Lint/RedundantRequireStatement:
- library/fiber/**/*.rb
- optional/capi/fiber_spec.rb

Lint/RedundantSafeNavigation:
Exclude:
- language/safe_navigator_spec.rb

Lint/RedundantSplatExpansion:
Enabled: false

Expand Down
36 changes: 26 additions & 10 deletions spec/ruby/.rubocop_todo.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# This configuration was generated by
# `rubocop --auto-gen-config`
# on 2024-10-12 16:01:45 UTC using RuboCop version 1.66.1.
# on 2026-05-29 08:10:07 UTC using RuboCop version 1.86.2.
# The point is for the user to remove these configuration records
# one by one as the offenses are removed from the code base.
# Note that changes in the inspected code, or installation of new
Expand All @@ -11,17 +11,22 @@ Lint/DuplicateCaseCondition:
Exclude:
- 'language/case_spec.rb'

# Offense count: 6
# Offense count: 20
Lint/DuplicateMethods:
Exclude:
- 'core/array/fixtures/encoded_strings.rb'
- 'core/method/fixtures/classes.rb'
- 'core/module/const_added_spec.rb'
- 'core/module/define_method_spec.rb'
- 'core/module/fixtures/classes.rb'
- 'core/module/method_added_spec.rb'
- 'core/module/name_spec.rb'
- 'core/proc/new_spec.rb'
- 'core/unboundmethod/fixtures/classes.rb'
- 'fixtures/class.rb'
- 'language/assignments_spec.rb'

# Offense count: 8
# This cop supports safe autocorrection (--autocorrect).
Lint/EnsureReturn:
Exclude:
- 'language/fixtures/ensure.rb'
Expand All @@ -39,12 +44,12 @@ Lint/FloatOutOfRange:
Exclude:
- 'core/string/modulo_spec.rb'

# Offense count: 2
# Offense count: 3
# This cop supports safe autocorrection (--autocorrect).
Lint/ImplicitStringConcatenation:
Exclude:
- 'language/string_spec.rb'
- 'core/string/chilled_string_spec.rb'
- 'language/string_spec.rb'

# Offense count: 4
Lint/IneffectiveAccessModifier:
Expand All @@ -53,12 +58,11 @@ Lint/IneffectiveAccessModifier:
- 'core/module/fixtures/classes.rb'
- 'language/fixtures/private.rb'

# Offense count: 71
# Offense count: 12
# This cop supports safe autocorrection (--autocorrect).
Lint/LiteralInInterpolation:
Exclude:
- 'core/module/refine_spec.rb'
- 'core/regexp/shared/new.rb'
- 'core/string/shared/to_sym.rb'
- 'language/alias_spec.rb'
- 'language/defined_spec.rb'
Expand All @@ -80,13 +84,24 @@ Lint/ParenthesesAsGroupedExpression:
- 'language/block_spec.rb'
- 'language/method_spec.rb'

# Offense count: 1
# This cop supports unsafe autocorrection (--autocorrect-all).
# Configuration parameters: AllowedMethods, InferNonNilReceiver, AdditionalNilMethods.
# AllowedMethods: instance_of?, kind_of?, is_a?, eql?, respond_to?, equal?
# AdditionalNilMethods: present?, blank?, try, try!
Lint/RedundantSafeNavigation:
Exclude:
- 'language/safe_navigator_spec.rb'
- 'language/fixtures/rescue_captures.rb'

# Offense count: 2
# This cop supports safe autocorrection (--autocorrect).
Lint/RedundantStringCoercion:
Exclude:
- 'core/io/print_spec.rb'

# Offense count: 1
# Configuration parameters: AllowRBSInlineAnnotation.
Lint/SelfAssignment:
Exclude:
- 'core/gc/auto_compact_spec.rb'
Expand All @@ -97,7 +112,7 @@ Lint/ShadowedArgument:
Exclude:
- 'language/fixtures/super.rb'

# Offense count: 45
# Offense count: 49
# Configuration parameters: AllowComments, AllowNil.
Lint/SuppressedException:
Enabled: false
Expand All @@ -110,13 +125,14 @@ Lint/UnderscorePrefixedVariableName:
- 'core/io/popen_spec.rb'
- 'language/block_spec.rb'

# Offense count: 7
# Offense count: 9
# This cop supports safe autocorrection (--autocorrect).
# Configuration parameters: AutoCorrect, ContextCreatingMethods, MethodCreatingMethods.
# Configuration parameters: ContextCreatingMethods, MethodCreatingMethods.
Lint/UselessAccessModifier:
Exclude:
- 'core/module/define_method_spec.rb'
- 'core/module/fixtures/classes.rb'
- 'core/module/module_function_spec.rb'
- 'core/module/private_class_method_spec.rb'
- 'language/fixtures/def.rb'
- 'language/fixtures/send.rb'
24 changes: 12 additions & 12 deletions spec/ruby/CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -229,7 +229,7 @@ to avoid duplication of specs, we have shared specs that are re-used in other sp
bit tricky however, so let's go over it.

Commonly, if a shared spec is only reused within its own module, the shared spec will live within a
shared directory inside that module's directory. For example, the `core/hash/shared/key.rb` spec is
shared directory inside that module's directory. For example, the `core/hash/shared/iteration.rb` spec is
only used by `Hash` specs, and so it lives inside `core/hash/shared/`.

When a shared spec is used across multiple modules or classes, it lives within the `shared/` directory.
Expand All @@ -243,25 +243,25 @@ variables from the implementor spec: `@method` and `@object`, which the implemen
Here's an example of a snippet of a shared spec and two specs which integrates it:

```ruby
# core/hash/shared/key.rb
describe :hash_key_p, shared: true do
it "returns true if the key's matching value was false" do
{ xyz: false }.send(@method, :xyz).should == true
# core/hash/shared/iteration.rb
describe :hash_iteration_no_block, shared: true do
it "returns an Enumerator if called on a non-empty hash without a block" do
{ 1 => 2 }.send(@method).should.instance_of?(Enumerator)
end
end

# core/hash/key_spec.rb
describe "Hash#key?" do
it_behaves_like :hash_key_p, :key?
# core/hash/select_spec.rb
describe "Hash#select" do
it_behaves_like :hash_iteration_no_block, :select
end

# core/hash/include_spec.rb
describe "Hash#include?" do
it_behaves_like :hash_key_p, :include?
# core/hash/reject_spec.rb
describe "Hash#reject" do
it_behaves_like :hash_iteration_no_block, :reject
end
```

In the example, the first `describe` defines the shared spec `:hash_key_p`, which defines a spec that
In the example, the first `describe` defines the shared spec `:hash_iteration_no_block`, which defines a spec that
calls the `@method` method with an expectation. In the implementor spec, we use `it_behaves_like` to
integrate the shared spec. `it_behaves_like` takes 3 parameters: the key of the shared spec, a method,
and an object. These last two parameters are accessible via `@method` and `@object` in the shared spec.
Expand Down
2 changes: 1 addition & 1 deletion spec/ruby/bin/rubocop
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ require 'bundler/inline'
gemfile do
source 'https://rubygems.org'

gem 'rubocop', '1.66.1'
gem 'rubocop', '1.86.2'
end

exec(Gem.bin_path('rubocop', 'rubocop'), *ARGV)
2 changes: 1 addition & 1 deletion spec/ruby/command_line/fixtures/bin/bad_embedded_ruby.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
@@@This line is not value Ruby
@@@This line is not valid Ruby
#!rub_y
puts 'success'
2 changes: 1 addition & 1 deletion spec/ruby/command_line/fixtures/bin/embedded_ruby.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
@@@This line is not value Ruby
@@@This line is not valid Ruby
#!ruby
puts 'success'
58 changes: 56 additions & 2 deletions spec/ruby/core/argf/each_byte_spec.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,60 @@
require_relative '../../spec_helper'
require_relative 'shared/each_byte'

describe "ARGF.each_byte" do
it_behaves_like :argf_each_byte, :each_byte
before :each do
@file1_name = fixture __FILE__, "file1.txt"
@file2_name = fixture __FILE__, "file2.txt"

@bytes = []
File.read(@file1_name).each_byte { |b| @bytes << b }
File.read(@file2_name).each_byte { |b| @bytes << b }
end

it "yields each byte of all streams to the passed block" do
argf [@file1_name, @file2_name] do
bytes = []
@argf.each_byte { |b| bytes << b }
bytes.should == @bytes
end
end

it "returns self when passed a block" do
argf [@file1_name, @file2_name] do
@argf.each_byte {}.should.equal?(@argf)
end
end

it "returns an Enumerator when passed no block" do
argf [@file1_name, @file2_name] do
enum = @argf.each_byte
enum.should.instance_of?(Enumerator)

bytes = []
enum.each { |b| bytes << b }
bytes.should == @bytes
end
end

describe "when no block is given" do
it "returns an Enumerator" do
argf [@file1_name, @file2_name] do
enum = @argf.each_byte
enum.should.instance_of?(Enumerator)

bytes = []
enum.each { |b| bytes << b }
bytes.should == @bytes
end
end

describe "returned Enumerator" do
describe "size" do
it "should return nil" do
argf [@file1_name, @file2_name] do
@argf.each_byte.size.should == nil
end
end
end
end
end
end
58 changes: 56 additions & 2 deletions spec/ruby/core/argf/each_char_spec.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,60 @@
require_relative '../../spec_helper'
require_relative 'shared/each_char'

describe "ARGF.each_char" do
it_behaves_like :argf_each_char, :each_char
before :each do
@file1_name = fixture __FILE__, "file1.txt"
@file2_name = fixture __FILE__, "file2.txt"

@chars = []
File.read(@file1_name).each_char { |c| @chars << c }
File.read(@file2_name).each_char { |c| @chars << c }
end

it "yields each char of all streams to the passed block" do
argf [@file1_name, @file2_name] do
chars = []
@argf.each_char { |c| chars << c }
chars.should == @chars
end
end

it "returns self when passed a block" do
argf [@file1_name, @file2_name] do
@argf.each_char {}.should.equal?(@argf)
end
end

it "returns an Enumerator when passed no block" do
argf [@file1_name, @file2_name] do
enum = @argf.each_char
enum.should.instance_of?(Enumerator)

chars = []
enum.each { |c| chars << c }
chars.should == @chars
end
end

describe "when no block is given" do
it "returns an Enumerator" do
argf [@file1_name, @file2_name] do
enum = @argf.each_char
enum.should.instance_of?(Enumerator)

chars = []
enum.each { |c| chars << c }
chars.should == @chars
end
end

describe "returned Enumerator" do
describe "size" do
it "should return nil" do
argf [@file1_name, @file2_name] do
@argf.each_char.size.should == nil
end
end
end
end
end
end
Loading