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
12 changes: 12 additions & 0 deletions test/rbs/method_type_parsing_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,8 @@ def foo: (...) -> void
end

def test_forwarding_parameter
omit_on_jruby! "The WebAssembly parser does not support forwarding parameter syntax"

parse_method_type_with_forwarding("(...) -> void").tap do |type|
assert_equal "(...) -> void", type.to_s
assert_instance_of Types::Function::ForwardingParam, type.type.forwarding
Expand All @@ -100,6 +102,8 @@ def test_forwarding_parameter
end

def test_forwarding_parameter_with_overload_continuation
omit_on_jruby! "The WebAssembly parser does not support forwarding parameter syntax"

_, declarations = parse_signature_with_forwarding(<<~RBS)
class Foo
def foo: (...) -> void
Expand All @@ -113,6 +117,8 @@ def foo: (...) -> void
end

def test_forwarding_parameter_rejects_nonleading_parameters
omit_on_jruby! "The WebAssembly parser does not support forwarding parameter syntax"

[
"(?String value, ...) -> void",
"(*String values, ...) -> void",
Expand All @@ -127,6 +133,8 @@ def test_forwarding_parameter_rejects_nonleading_parameters
end

def test_forwarding_parameter_must_be_last
omit_on_jruby! "The WebAssembly parser does not support forwarding parameter syntax"

[
"(..., String) -> void",
"(..., ...) -> void",
Expand All @@ -139,6 +147,8 @@ def test_forwarding_parameter_must_be_last
end

def test_forwarding_parameter_cannot_have_explicit_block
omit_on_jruby! "The WebAssembly parser does not support forwarding parameter syntax"

[
"(...) { () -> void } -> void",
"(...) ?{ () -> void } -> void",
Expand All @@ -150,6 +160,8 @@ def test_forwarding_parameter_cannot_have_explicit_block
end

def test_forwarding_parameter_is_not_allowed_in_block_types
omit_on_jruby! "The WebAssembly parser does not support forwarding parameter syntax"

error = assert_raise(RBS::ParsingError) do
parse_method_type_with_forwarding("() { (...) -> void } -> void")
end
Expand Down
4 changes: 4 additions & 0 deletions test/rbs/schema_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,10 @@ def test_method_type_schema
JSONValidator.method_type.validate!(
parse_method_type("[G] (A a, ?B, *C, d: D, ?e: E e, **f) ?{ (G) -> void } -> String").to_json
)
end

def test_method_type_schema_with_forwarding_parameter
omit_on_jruby! "The WebAssembly parser does not support forwarding parameter syntax"

# Forwarding parameters are only parsed when explicitly enabled
source = "(String message, ...) -> void"
Expand Down
Loading