зеркало из https://github.com/github/ruby.git
[PRISM] Account for ImplicitRestNode
Prism introduced a new ImplicitRestNode. This adds tests for the ImplicitRestNode cases, and changes one assert which is no longer accurate.
This commit is contained in:
Родитель
53841941f0
Коммит
2233204cc1
|
@ -3313,14 +3313,11 @@ pm_compile_node(rb_iseq_t *iseq, const pm_node_t *node, LINK_ANCHOR *const ret,
|
|||
PM_DUP_UNLESS_POPPED;
|
||||
|
||||
pm_node_t *rest_expression = NULL;
|
||||
if (multi_write_node->rest) {
|
||||
RUBY_ASSERT(PM_NODE_TYPE_P(multi_write_node->rest, PM_SPLAT_NODE));
|
||||
|
||||
if (multi_write_node->rest && PM_NODE_TYPE_P(multi_write_node->rest, PM_SPLAT_NODE)) {
|
||||
pm_splat_node_t *rest_splat = ((pm_splat_node_t *)multi_write_node->rest);
|
||||
rest_expression = rest_splat->expression;
|
||||
}
|
||||
|
||||
|
||||
if (lefts->size) {
|
||||
ADD_INSN2(ret, &dummy_line_node, expandarray, INT2FIX(lefts->size), INT2FIX((int) (bool) (rights->size || rest_expression)));
|
||||
for (size_t index = 0; index < lefts->size; index++) {
|
||||
|
|
|
@ -435,6 +435,7 @@ module Prism
|
|||
|
||||
def test_MultiWriteNode
|
||||
assert_prism_eval("foo, bar = [1, 2]")
|
||||
assert_prism_eval("foo, = [1, 2]")
|
||||
assert_prism_eval("foo, *, bar = [1, 2]")
|
||||
assert_prism_eval("foo, bar = 1, 2")
|
||||
assert_prism_eval("foo, *, bar = 1, 2")
|
||||
|
@ -679,8 +680,9 @@ module Prism
|
|||
assert_prism_eval("for @i in [1,2] do; @i; end")
|
||||
assert_prism_eval("for $i in [1,2] do; $i; end")
|
||||
|
||||
# TODO: multiple assignment in ForNode index
|
||||
#assert_prism_eval("for i, j in {a: 'b'} do; i; j; end")
|
||||
assert_prism_eval("for foo, in [1,2,3] do end")
|
||||
|
||||
assert_prism_eval("for i, j in {a: 'b'} do; i; j; end")
|
||||
end
|
||||
|
||||
############################################################################
|
||||
|
@ -766,6 +768,8 @@ module Prism
|
|||
assert_prism_eval("[1, 2, 3].each { |num| num }")
|
||||
|
||||
assert_prism_eval("[].tap { _1 }")
|
||||
|
||||
assert_prism_eval("[].each { |a,| }")
|
||||
end
|
||||
|
||||
def test_ClassNode
|
||||
|
|
Загрузка…
Ссылка в новой задаче