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
10 changes: 6 additions & 4 deletions ext/openssl/ossl_asn1.c
Original file line number Diff line number Diff line change
Expand Up @@ -130,15 +130,17 @@ asn1integer_to_num(const ASN1_INTEGER *ai)
if (!ai) {
ossl_raise(rb_eTypeError, "ASN1_INTEGER is NULL!");
}

num = ossl_bn_new(BN_value_one());
bn = GetBNPtr(num);

if (ASN1_STRING_type(ai) == V_ASN1_ENUMERATED)
bn = ASN1_ENUMERATED_to_BN(ai, NULL);
bn = ASN1_ENUMERATED_to_BN(ai, bn);
else
bn = ASN1_INTEGER_to_BN(ai, NULL);
bn = ASN1_INTEGER_to_BN(ai, bn);

if (!bn)
ossl_raise(eOSSLError, NULL);
num = ossl_bn_new(bn);
BN_free(bn);

return num;
}
Expand Down
2 changes: 1 addition & 1 deletion hash.c
Original file line number Diff line number Diff line change
Expand Up @@ -5332,7 +5332,7 @@ static VALUE
env_fetch(int argc, VALUE *argv, VALUE _)
{
VALUE key;
long block_given;
int block_given;
const char *nam;
VALUE env;

Expand Down
8 changes: 1 addition & 7 deletions parse.y
Original file line number Diff line number Diff line change
Expand Up @@ -11708,16 +11708,10 @@ rb_node_match3_new(struct parser_params *p, NODE *nd_recv, NODE *nd_value, const
return n;
}

/* TODO: Use union for NODE_LIST2 */
static rb_node_list_t *
rb_node_list_new(struct parser_params *p, NODE *nd_head, const YYLTYPE *loc)
{
rb_node_list_t *n = NODE_NEWNODE(NODE_LIST, rb_node_list_t, loc);
n->nd_head = nd_head;
n->as.nd_alen = 1;
n->nd_next = 0;

return n;
return rb_node_list_new2(p, nd_head, 1, 0, loc);
}

static rb_node_list_t *
Expand Down
13 changes: 13 additions & 0 deletions prism/prism.c
Original file line number Diff line number Diff line change
Expand Up @@ -21740,6 +21740,19 @@ parse_expression(pm_parser_t *parser, pm_binding_power_t binding_power, bool acc
return node;
}
break;
case PM_RESCUE_MODIFIER_NODE:
// A rescue modifier whose handler is a one-liner pattern match
// (=> or in) produces a statement. That means it cannot be
// extended by operators above the modifier level.
if (pm_binding_powers[parser->current.type].left > PM_BINDING_POWER_MODIFIER) {
pm_rescue_modifier_node_t *cast = (pm_rescue_modifier_node_t *) node;
pm_node_t *rescue_expression = cast->rescue_expression;

if (PM_NODE_TYPE_P(rescue_expression, PM_MATCH_REQUIRED_NODE) || PM_NODE_TYPE_P(rescue_expression, PM_MATCH_PREDICATE_NODE)) {
return node;
}
}
break;
default:
break;
}
Expand Down
20 changes: 10 additions & 10 deletions shape.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,33 +14,33 @@ STATIC_ASSERT(shape_id_num_bits, SHAPE_ID_NUM_BITS == sizeof(shape_id_t) * CHAR_
#define SHAPE_BUFFER_SIZE (1 << SHAPE_ID_OFFSET_NUM_BITS)
#define SHAPE_ID_OFFSET_MASK (SHAPE_BUFFER_SIZE - 1)

#define SHAPE_ID_HEAP_INDEX_BITS 3
#define SHAPE_ID_HEAP_INDEX_BITS 5
#define SHAPE_ID_HEAP_INDEX_MAX ((1 << SHAPE_ID_HEAP_INDEX_BITS) - 1)

#define SHAPE_ID_HEAP_INDEX_OFFSET SHAPE_ID_OFFSET_NUM_BITS
#define SHAPE_ID_FL_USHIFT (SHAPE_ID_OFFSET_NUM_BITS + SHAPE_ID_HEAP_INDEX_BITS)
#define SHAPE_ID_HEAP_INDEX_OFFSET SHAPE_ID_FL_USHIFT

// shape_id_t bits:
// 0-18 SHAPE_ID_OFFSET_MASK
// index in rb_shape_tree.shape_list. Allow to access `rb_shape_t *`.
// 19-21 SHAPE_ID_HEAP_INDEX_MASK
// 19-23 SHAPE_ID_HEAP_INDEX_MASK
// index in rb_shape_tree.capacities. Allow to access slot size.
// Always 0 except for T_OBJECT.
// 22 SHAPE_ID_FL_FROZEN
// 24 SHAPE_ID_FL_FROZEN
// Whether the object is frozen or not.
// 23 SHAPE_ID_FL_HAS_OBJECT_ID
// 25 SHAPE_ID_FL_HAS_OBJECT_ID
// Whether the object has an `SHAPE_OBJ_ID` transition.
// 24 SHAPE_ID_FL_TOO_COMPLEX
// 26 SHAPE_ID_FL_TOO_COMPLEX
// The object is backed by a `st_table`.

enum shape_id_fl_type {
#define RBIMPL_SHAPE_ID_FL(n) (1<<(SHAPE_ID_FL_USHIFT+n))

SHAPE_ID_HEAP_INDEX_MASK = RBIMPL_SHAPE_ID_FL(0) | RBIMPL_SHAPE_ID_FL(1) | RBIMPL_SHAPE_ID_FL(2),
SHAPE_ID_HEAP_INDEX_MASK = ((1 << SHAPE_ID_HEAP_INDEX_BITS) - 1) << SHAPE_ID_HEAP_INDEX_OFFSET,

SHAPE_ID_FL_FROZEN = RBIMPL_SHAPE_ID_FL(3),
SHAPE_ID_FL_HAS_OBJECT_ID = RBIMPL_SHAPE_ID_FL(4),
SHAPE_ID_FL_TOO_COMPLEX = RBIMPL_SHAPE_ID_FL(5),
SHAPE_ID_FL_FROZEN = RBIMPL_SHAPE_ID_FL(0),
SHAPE_ID_FL_HAS_OBJECT_ID = RBIMPL_SHAPE_ID_FL(1),
SHAPE_ID_FL_TOO_COMPLEX = RBIMPL_SHAPE_ID_FL(2),

SHAPE_ID_FL_NON_CANONICAL_MASK = SHAPE_ID_FL_FROZEN | SHAPE_ID_FL_HAS_OBJECT_ID,
SHAPE_ID_FLAGS_MASK = SHAPE_ID_HEAP_INDEX_MASK | SHAPE_ID_FL_NON_CANONICAL_MASK | SHAPE_ID_FL_TOO_COMPLEX,
Expand Down
1 change: 1 addition & 0 deletions spec/mspec/lib/mspec/commands/mspec-tag.rb
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,7 @@ def register
MSpec.register_mode :pretend
MSpec.register_mode :unguarded
config[:formatter] = false
config[:xtags] = []
else
raise ArgumentError, "No recognized action given"
end
Expand Down
2 changes: 1 addition & 1 deletion spec/mspec/lib/mspec/runner/formatters/base.rb
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ def register
LeakCheckerAction.new.register
end

if ENV['CHECK_LEAKS'] || ENV['CHECK_CONSTANT_LEAKS']
if (ENV['CHECK_LEAKS'] || ENV['CHECK_CONSTANT_LEAKS']) && ENV['CHECK_CONSTANT_LEAKS'] != 'false'
save = ENV['CHECK_LEAKS'] == 'save' || ENV['CHECK_CONSTANT_LEAKS'] == 'save'
ConstantsLeakCheckerAction.new(save).register
end
Expand Down
1 change: 1 addition & 0 deletions spec/mspec/lib/mspec/runner/mspec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -365,6 +365,7 @@ def self.make_tag_dir(path)
# Writes each tag in +tags+ to the tag file. Overwrites the
# tag file if it exists.
def self.write_tags(tags)
return delete_tags if tags.empty?
file = tags_file
make_tag_dir(file)
File.open(file, "w:utf-8") do |f|
Expand Down
9 changes: 8 additions & 1 deletion spec/mspec/tool/remove_old_guards.rb
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,12 @@ def each_spec_file(&block)
Dir["*/**/*.rb"].each(&block)
end

def each_file(&block)
Dir["**/*"].each { |path|
yield path if File.file?(path)
}
end

def remove_guards(guard, keep)
each_spec_file do |file|
contents = File.binread(file)
Expand Down Expand Up @@ -109,7 +115,7 @@ def remove_unused_shared_specs
end

def search(regexp)
each_spec_file do |file|
each_file do |file|
contents = File.binread(file)
if contents =~ regexp
puts file
Expand All @@ -136,3 +142,4 @@ def search(regexp)
puts "Search:"
search(/(["'])#{version}\1/)
search(/^\s*#.+#{version}/)
search(/RUBY_VERSION_IS_#{version.tr('.', '_')}/)
4 changes: 2 additions & 2 deletions spec/ruby/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@ ruby/spec is known to be tested in these implementations for every commit:
* [Opal](https://github.com/opal/opal/tree/master/spec)
* [Artichoke](https://github.com/artichoke/spec/tree/artichoke-vendor)

ruby/spec describes the behavior of Ruby 3.2 and more recent Ruby versions.
More precisely, every latest stable MRI release should [pass](https://github.com/ruby/spec/actions/workflows/ci.yml) all specs of ruby/spec (3.2.x, 3.3.x, etc), and those are tested in CI.
ruby/spec describes the behavior of Ruby 3.3 and more recent Ruby versions.
More precisely, every latest stable MRI release should [pass](https://github.com/ruby/spec/actions/workflows/ci.yml) all specs of ruby/spec (3.3.x, 3.4.x, etc), and those are tested in CI.

### Synchronization with Ruby Implementations

Expand Down
5 changes: 5 additions & 0 deletions spec/ruby/command_line/error_message_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,9 @@
out = ruby_exe("end #syntax error", args: "2> #{File::NULL}", exit_status: 1)
out.chomp.should.empty?
end

it "is not modified with extra escaping of control characters and backslashes" do
out = ruby_exe('raise "\e[31mRed\e[0m error\\\\message"', args: "2>&1", exit_status: 1)
out.chomp.should include("\e[31mRed\e[0m error\\message")
end
end
7 changes: 7 additions & 0 deletions spec/ruby/core/data/fixtures/classes.rb
Original file line number Diff line number Diff line change
@@ -1,13 +1,20 @@
module DataSpecs
if Data.respond_to?(:define)
Measure = Data.define(:amount, :unit)
Single = Data.define(:value)

class MeasureWithOverriddenName < Measure
def self.name
"A"
end
end

class SingleWithOverriddenName < Single
def self.name
"A"
end
end

class DataSubclass < Data; end

MeasureSubclass = Class.new(Measure) do
Expand Down
32 changes: 32 additions & 0 deletions spec/ruby/core/data/initialize_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,16 @@
require_relative 'fixtures/classes'

describe "Data#initialize" do
context "with no members" do
ruby_bug "#21819", ""..."4.0.1" do
it "is frozen" do
data = Data.define

data.new.should.frozen?
end
end
end

it "accepts positional arguments" do
data = DataSpecs::Measure.new(42, "km")

Expand Down Expand Up @@ -37,6 +47,17 @@
data.unit.should == "km"
end

it "accepts positional arguments with empty keyword arguments" do
data = DataSpecs::Single.new(42, **{})

data.value.should == 42

data = DataSpecs::Measure.new(42, "km", **{})

data.amount.should == 42
data.unit.should == "km"
end

it "raises ArgumentError if no arguments are given" do
-> {
DataSpecs::Measure.new
Expand Down Expand Up @@ -111,6 +132,17 @@ def initialize(*, **)
ScratchPad.recorded.should == [:initialize, [], {amount: 42, unit: "m"}]
end

it "accepts positional arguments with empty keyword arguments" do
data = DataSpecs::SingleWithOverriddenName.new(42, **{})

data.value.should == 42

data = DataSpecs::MeasureWithOverriddenName.new(42, "km", **{})

data.amount.should == 42
data.unit.should == "km"
end

# See https://github.com/ruby/psych/pull/765
it "can be deserialized by calling Data.instance_method(:initialize)" do
d1 = DataSpecs::Area.new(width: 2, height: 3)
Expand Down
74 changes: 37 additions & 37 deletions spec/ruby/core/encoding/locale_charmap_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,52 +5,52 @@
Encoding.locale_charmap.should be_an_instance_of(String)
end

# FIXME: Get this working on Windows
platform_is :linux do
platform_is_not :android do
it "returns a value based on the LC_ALL environment variable" do
old_lc_all = ENV['LC_ALL']
ENV['LC_ALL'] = 'C'
ruby_exe("print Encoding.locale_charmap").should == 'ANSI_X3.4-1968'
ENV['LC_ALL'] = old_lc_all
describe "when setting LC_ALL=C" do
before :each do
@old_lc_all = ENV['LC_ALL']
end

after :each do
ENV['LC_ALL'] = @old_lc_all
end

# FIXME: Get this working on Windows
platform_is :linux do
platform_is_not :android do
it "returns a value based on the LC_ALL environment variable" do
ENV['LC_ALL'] = 'C'
ruby_exe("print Encoding.locale_charmap").should == 'ANSI_X3.4-1968'
end
end
end
end

platform_is :freebsd, :openbsd, :darwin do
it "returns a value based on the LC_ALL environment variable" do
old_lc_all = ENV['LC_ALL']
ENV['LC_ALL'] = 'C'
ruby_exe("print Encoding.locale_charmap").should == 'US-ASCII'
ENV['LC_ALL'] = old_lc_all
platform_is :freebsd, :openbsd, :darwin do
it "returns a value based on the LC_ALL environment variable" do
ENV['LC_ALL'] = 'C'
ruby_exe("print Encoding.locale_charmap").should == 'US-ASCII'
end
end
end

platform_is :netbsd do
it "returns a value based on the LC_ALL environment variable" do
old_lc_all = ENV['LC_ALL']
ENV['LC_ALL'] = 'C'
ruby_exe("print Encoding.locale_charmap").should == '646'
ENV['LC_ALL'] = old_lc_all
platform_is :netbsd do
it "returns a value based on the LC_ALL environment variable" do
ENV['LC_ALL'] = 'C'
ruby_exe("print Encoding.locale_charmap").should == '646'
end
end
end

platform_is :android do
it "always returns UTF-8" do
old_lc_all = ENV['LC_ALL']
ENV['LC_ALL'] = 'C'
ruby_exe("print Encoding.locale_charmap").should == 'UTF-8'
ENV['LC_ALL'] = old_lc_all
platform_is :android do
it "always returns UTF-8" do
ENV['LC_ALL'] = 'C'
ruby_exe("print Encoding.locale_charmap").should == 'UTF-8'
end
end
end

platform_is :bsd, :darwin, :linux do
it "is unaffected by assigning to ENV['LC_ALL'] in the same process" do
old_charmap = Encoding.locale_charmap
old_lc_all = ENV['LC_ALL']
ENV['LC_ALL'] = 'C'
Encoding.locale_charmap.should == old_charmap
ENV['LC_ALL'] = old_lc_all
platform_is :bsd, :darwin, :linux do
it "is unaffected by assigning to ENV['LC_ALL'] in the same process" do
old_charmap = Encoding.locale_charmap
ENV['LC_ALL'] = 'C'
Encoding.locale_charmap.should == old_charmap
end
end
end
end
12 changes: 7 additions & 5 deletions spec/ruby/core/fiber/raise_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,16 @@
require_relative '../../shared/kernel/raise'

describe "Fiber#raise" do
it "is a public method" do
Fiber.public_instance_methods.should include(:raise)
end

it_behaves_like :kernel_raise, :raise, FiberSpecs::NewFiberToRaise
it_behaves_like :kernel_raise_across_contexts, :raise, FiberSpecs::NewFiberToRaise
end
ruby_version_is "4.0" do
it_behaves_like :kernel_raise_with_cause, :raise, FiberSpecs::NewFiberToRaise
end

describe "Fiber#raise" do
it 'raises RuntimeError by default' do
-> { FiberSpecs::NewFiberToRaise.raise }.should raise_error(RuntimeError)
end
Expand Down Expand Up @@ -126,10 +131,7 @@
end.should raise_error(RuntimeError, "Expected error")
end
end
end


describe "Fiber#raise" do
it "transfers and raises on a transferring fiber" do
root = Fiber.current
fiber = Fiber.new { root.transfer }
Expand Down
Loading