Sync ruby/yarp to 89a00203af
This commit is contained in:
parent
e8fb84265c
commit
711cabec26
@ -3,6 +3,19 @@
|
|||||||
require "yarp_test_helper"
|
require "yarp_test_helper"
|
||||||
|
|
||||||
class ParseTest < Test::Unit::TestCase
|
class ParseTest < Test::Unit::TestCase
|
||||||
|
# Because we're reading the snapshots from disk, we need to make sure that
|
||||||
|
# they're encoded as UTF-8. When certain settings are present this might not
|
||||||
|
# always be the case (e.g., LANG=C or -Eascii-8bit). So here we force the
|
||||||
|
# default external encoding for the duration of the test.
|
||||||
|
def setup
|
||||||
|
@previous_default_external = Encoding.default_external
|
||||||
|
ignore_warnings { Encoding.default_external = Encoding::UTF_8 }
|
||||||
|
end
|
||||||
|
|
||||||
|
def teardown
|
||||||
|
ignore_warnings { Encoding.default_external = @previous_default_external }
|
||||||
|
end
|
||||||
|
|
||||||
def test_Ruby_3_2_plus
|
def test_Ruby_3_2_plus
|
||||||
assert_operator RUBY_VERSION, :>=, "3.2.0", "ParseTest requires Ruby 3.2+"
|
assert_operator RUBY_VERSION, :>=, "3.2.0", "ParseTest requires Ruby 3.2+"
|
||||||
end
|
end
|
||||||
@ -21,7 +34,6 @@ class ParseTest < Test::Unit::TestCase
|
|||||||
# and the line breaks based on the length of the path.
|
# and the line breaks based on the length of the path.
|
||||||
def normalize_printed(printed)
|
def normalize_printed(printed)
|
||||||
printed
|
printed
|
||||||
.b
|
|
||||||
.gsub(
|
.gsub(
|
||||||
/SourceFileNode \s*
|
/SourceFileNode \s*
|
||||||
\(\s* (\d+\.\.\.\d+) \s*\) \s*
|
\(\s* (\d+\.\.\.\d+) \s*\) \s*
|
||||||
@ -75,7 +87,7 @@ class ParseTest < Test::Unit::TestCase
|
|||||||
assert_empty result.errors, value
|
assert_empty result.errors, value
|
||||||
|
|
||||||
if File.exist?(snapshot)
|
if File.exist?(snapshot)
|
||||||
normalized = normalize_printed(File.binread(snapshot))
|
normalized = normalize_printed(File.read(snapshot))
|
||||||
|
|
||||||
# If the snapshot file exists, but the printed value does not match the
|
# If the snapshot file exists, but the printed value does not match the
|
||||||
# snapshot, then update the snapshot file.
|
# snapshot, then update the snapshot file.
|
||||||
@ -115,4 +127,14 @@ class ParseTest < Test::Unit::TestCase
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
private
|
||||||
|
|
||||||
|
def ignore_warnings
|
||||||
|
previous_verbosity = $VERBOSE
|
||||||
|
$VERBOSE = nil
|
||||||
|
yield
|
||||||
|
ensure
|
||||||
|
$VERBOSE = previous_verbosity
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
261
yarp/api_node.c
261
yarp/api_node.c
File diff suppressed because it is too large
Load Diff
@ -1,4 +1,4 @@
|
|||||||
#include "extension.h"
|
#include "yarp/extension.h"
|
||||||
|
|
||||||
static VALUE rb_cYARP;
|
static VALUE rb_cYARP;
|
||||||
static VALUE rb_cYARPPack;
|
static VALUE rb_cYARPPack;
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
#include "extension.h"
|
#include "yarp/extension.h"
|
||||||
|
|
||||||
typedef enum {
|
typedef enum {
|
||||||
YP_ISEQ_TYPE_TOP,
|
YP_ISEQ_TYPE_TOP,
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
#include "extension.h"
|
#include "yarp/extension.h"
|
||||||
|
|
||||||
VALUE rb_cYARP;
|
VALUE rb_cYARP;
|
||||||
VALUE rb_cYARPToken;
|
VALUE rb_cYARPToken;
|
||||||
|
@ -1521,10 +1521,12 @@ yp_serialize_content(yp_parser_t *parser, yp_node_t *node, yp_buffer_t *buffer)
|
|||||||
// index in the buffer.
|
// index in the buffer.
|
||||||
if (constant->id != 0) {
|
if (constant->id != 0) {
|
||||||
size_t buffer_offset = offset + ((constant->id - 1) * 8);
|
size_t buffer_offset = offset + ((constant->id - 1) * 8);
|
||||||
size_t source_offset = yp_long_to_u32(constant->start - parser->start);
|
|
||||||
|
uint32_t source_offset = yp_long_to_u32(constant->start - parser->start);
|
||||||
|
uint32_t constant_length = yp_ulong_to_u32(constant->length);
|
||||||
|
|
||||||
memcpy(buffer->value + buffer_offset, &source_offset, 4);
|
memcpy(buffer->value + buffer_offset, &source_offset, 4);
|
||||||
memcpy(buffer->value + buffer_offset + 4, &constant->length, 4);
|
memcpy(buffer->value + buffer_offset + 4, &constant_length, 4);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -7544,7 +7544,11 @@ parse_target(yp_parser_t *parser, yp_node_t *target, yp_token_t *operator, yp_no
|
|||||||
// If there are arguments on the call node, then it can't be a method
|
// If there are arguments on the call node, then it can't be a method
|
||||||
// call ending with = or a local variable write, so it must be a
|
// call ending with = or a local variable write, so it must be a
|
||||||
// syntax error. In this case we'll fall through to our default
|
// syntax error. In this case we'll fall through to our default
|
||||||
// handling.
|
// handling. We need to free the value that we parsed because there
|
||||||
|
// is no way for us to attach it to the tree at this point.
|
||||||
|
if (value != NULL) {
|
||||||
|
yp_node_destroy(parser, value);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
/* fallthrough */
|
/* fallthrough */
|
||||||
default:
|
default:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user