Skip to content

Commit 9137a8e

Browse files
committed
Fix tests
1 parent e533650 commit 9137a8e

File tree

4 files changed

+21
-49
lines changed

4 files changed

+21
-49
lines changed

test/multiple_error.rbs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
class TypeArg[T]
2-
def foo: (void) -> void
3-
def bar: (void) -> void
2+
def foo: () -> void
3+
def bar: () -> void
44
end
55
class InvalidTypeApplication
66
def foo: () -> TypeArg
@@ -76,3 +76,4 @@ interface _CyclicTypeParameterBound[A]
7676
end
7777
class InconsistentClassModuleAlias = Nothing
7878
class CyclicClassAliasDefinition = CyclicClassAliasDefinition
79+
type unknownTypeName = UNKNOWN_TYPE_NAME

test/rbs/cli_test.rb

Lines changed: 17 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -655,17 +655,17 @@ def test_validate_multiple
655655
Dir.mktmpdir do |dir|
656656
(Pathname(dir) + 'a.rbs').write(<<~RBS)
657657
class Foo
658-
def foo: (void) -> void
659-
def bar: (void) -> void
658+
type foo = self
659+
type bar = instance
660660
end
661661
RBS
662662

663663
assert_cli_success do
664664
cli.run(["-I", dir, "--log-level=warn", "validate"])
665665
end
666666

667-
assert_include stdout.string, "a.rbs:2:11...2:25: `void` type is only allowed in return type or generics parameter (RBS::WillSyntaxError)"
668-
assert_include stdout.string, "a.rbs:3:11...3:25: `void` type is only allowed in return type or generics parameter (RBS::WillSyntaxError)"
667+
assert_include stdout.string, "a.rbs:2:13...2:17: `self` type is not allowed in this context (RBS::WillSyntaxError)"
668+
assert_include stdout.string, "a.rbs:3:13...3:21: `instance` or `class` type is not allowed in this context (RBS::WillSyntaxError)"
669669
end
670670
end
671671
end
@@ -675,16 +675,16 @@ def test_validate_multiple_with_fail_fast
675675
Dir.mktmpdir do |dir|
676676
(Pathname(dir) + 'a.rbs').write(<<~RBS)
677677
class Foo
678-
def foo: (void) -> void
679-
def bar: (void) -> void
678+
type foo = self
679+
type bar = instance
680680
end
681681
RBS
682682

683683
assert_cli_success do
684684
cli.run(["-I", dir, "--log-level=warn", "validate", "--fail-fast"])
685685
end
686-
assert_include stdout.string, "a.rbs:2:11...2:25: `void` type is only allowed in return type or generics parameter (RBS::WillSyntaxError)"
687-
assert_include stdout.string, "a.rbs:3:11...3:25: `void` type is only allowed in return type or generics parameter (RBS::WillSyntaxError)"
686+
assert_include stdout.string, "a.rbs:2:13...2:17: `self` type is not allowed in this context (RBS::WillSyntaxError)"
687+
assert_include stdout.string, "a.rbs:3:13...3:21: `instance` or `class` type is not allowed in this context (RBS::WillSyntaxError)"
688688
end
689689
end
690690
end
@@ -694,16 +694,16 @@ def test_validate_multiple_with_exit_error_on_syntax_error
694694
Dir.mktmpdir do |dir|
695695
(Pathname(dir) + 'a.rbs').write(<<~RBS)
696696
class Foo
697-
def foo: (void) -> void
698-
def bar: (void) -> void
697+
type foo = self
698+
type bar = instance
699699
end
700700
RBS
701701

702702
refute_cli_success do
703703
cli.run(["-I", dir, "--log-level=warn", "validate", "--exit-error-on-syntax-error"])
704704
end
705-
assert_include stdout.string, "a.rbs:2:11...2:25: `void` type is only allowed in return type or generics parameter (RBS::WillSyntaxError)"
706-
assert_include stdout.string, "a.rbs:3:11...3:25: `void` type is only allowed in return type or generics parameter (RBS::WillSyntaxError)"
705+
assert_include stdout.string, "a.rbs:2:13...2:17: `self` type is not allowed in this context (RBS::WillSyntaxError)"
706+
assert_include stdout.string, "a.rbs:3:13...3:21: `instance` or `class` type is not allowed in this context (RBS::WillSyntaxError)"
707707
end
708708
end
709709
end
@@ -713,16 +713,16 @@ def test_validate_multiple_with_fail_fast_and_exit_error_on_syntax_error
713713
Dir.mktmpdir do |dir|
714714
(Pathname(dir) + 'a.rbs').write(<<~RBS)
715715
class Foo
716-
def foo: (void) -> void
717-
def bar: (void) -> void
716+
def foo: (T) -> void
717+
def bar: (T) -> void
718718
end
719719
RBS
720720

721721
refute_cli_success do
722722
cli.run(["-I", dir, "--log-level=warn", "validate", "--fail-fast", "--exit-error-on-syntax-error"])
723723
end
724-
assert_include stdout.string, "a.rbs:2:11...2:25: `void` type is only allowed in return type or generics parameter (RBS::WillSyntaxError)"
725-
assert_not_include stdout.string, "a.rbs:3:11...3:25: `void` type is only allowed in return type or generics parameter (RBS::WillSyntaxError)"
724+
assert_include stdout.string, "/a.rbs:2:12...2:13: Could not find T (RBS::NoTypeFoundError)"
725+
assert_not_include stdout.string, "/a.rbs:3:12...3:13: Could not find T (RBS::NoTypeFoundError)"
726726
end
727727
end
728728
end
@@ -732,7 +732,6 @@ def test_validate_multiple_with_many_errors
732732
refute_cli_success do
733733
cli.run(%w(--log-level=warn -I test/multiple_error.rbs validate))
734734
end
735-
assert_include(stdout.string, "`void` type is only allowed in return type or generics parameter")
736735
assert_include(stdout.string, "test/multiple_error.rbs:6:17...6:24: ::TypeArg expects parameters [T], but given args [] (RBS::InvalidTypeApplicationError)")
737736
assert_include(stdout.string, "test/multiple_error.rbs:8:0...9:3: Detected recursive ancestors: ::RecursiveAncestor < ::RecursiveAncestor (RBS::RecursiveAncestorError)")
738737
assert_include(stdout.string, "test/multiple_error.rbs:11:15...11:22: Could not find Nothing (RBS::NoTypeFoundError)")
@@ -762,8 +761,6 @@ def test_validate_multiple_fail_fast
762761
refute_cli_success do
763762
cli.run(%w(--log-level=warn -I test/multiple_error.rbs validate --fail-fast))
764763
end
765-
assert_include(stdout.string, "test/multiple_error.rbs:2:11...2:25: `void` type is only allowed in return type or generics parameter (RBS::WillSyntaxError)")
766-
assert_include(stdout.string, "test/multiple_error.rbs:3:11...3:25: `void` type is only allowed in return type or generics parameter (RBS::WillSyntaxError)")
767764
assert_include(stdout.string, "test/multiple_error.rbs:6:17...6:24: ::TypeArg expects parameters [T], but given args []")
768765
end
769766
end
@@ -773,17 +770,12 @@ def test_validate_multiple_fail_fast_and_exit_error_on_syntax_error
773770
refute_cli_success do
774771
cli.run(%w(--log-level=warn -I test/multiple_error.rbs validate --fail-fast --exit-error-on-syntax-error))
775772
end
776-
assert_include(stdout.string, "test/multiple_error.rbs:2:11...2:25: `void` type is only allowed in return type or generics parameter (RBS::WillSyntaxError)")
773+
assert_include(stdout.string, "test/multiple_error.rbs:6:17...6:24: ::TypeArg expects parameters [T], but given args [] (RBS::InvalidTypeApplicationError)")
777774
end
778775
end
779776

780777
def test_context_validation
781778
tests = [
782-
<<~RBS,
783-
class Foo
784-
def foo: (void) -> untyped
785-
end
786-
RBS
787779
<<~RBS,
788780
class Bar[A]
789781
end

test/rbs/signature_parsing_test.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1005,7 +1005,7 @@ def ===: (untyped) -> bool
10051005
assert_valid_signature do
10061006
<<-EOS
10071007
class X
1008-
def foo: (type: untyped, class: untyped, module: untyped, if: untyped, include: untyped, yield: untyped, def: untyped, self: untyped, instance: untyped, any: untyped, void: void) -> untyped
1008+
def foo: (type: untyped, class: untyped, module: untyped, if: untyped, include: untyped, yield: untyped, def: untyped, self: untyped, instance: untyped, any: untyped, void: untyped) -> untyped
10091009
def bar: (untyped `type`, void: untyped `void`) -> untyped
10101010
end
10111011
EOS

test/rbs/types_test.rb

Lines changed: 0 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -77,25 +77,4 @@ def test_has_classish_type?
7777
refute_predicate type, :has_classish_type?
7878
end
7979
end
80-
81-
def test_with_nonreturn_void?
82-
[
83-
"void",
84-
"[void]",
85-
"void?",
86-
"^() [self: void] -> void"
87-
].each do |str|
88-
type = parse_type(str)
89-
assert_predicate type, :with_nonreturn_void?
90-
end
91-
92-
[
93-
"^() -> void",
94-
"[Integer, String]",
95-
"Enumerator[Integer, void]"
96-
].each do |str|
97-
type = parse_type(str)
98-
refute_predicate type, :with_nonreturn_void?
99-
end
100-
end
10180
end

0 commit comments

Comments
 (0)