@@ -556,32 +556,6 @@ module X7 : A[String, untyped]
556556 end
557557 end
558558
559- def test_validate__generics_default_self
560- with_cli do |cli |
561- Dir . mktmpdir do |dir |
562- ( Pathname ( dir ) + 'a.rbs' ) . write ( <<~RBS )
563- module A[T = self]
564- end
565-
566- class B[S = self]
567- end
568-
569- interface _C[T = self]
570- end
571-
572- type t[T = self] = untyped
573- RBS
574-
575- cli . run ( [ "-I" , dir , "validate" ] )
576-
577- assert_include stdout . string , "/a.rbs:1:13...1:17: `self` type is not allowed in this context (RBS::WillSyntaxError)\n "
578- assert_include stdout . string , "/a.rbs:4:12...4:16: `self` type is not allowed in this context (RBS::WillSyntaxError)\n "
579- assert_include stdout . string , "/a.rbs:7:17...7:21: `self` type is not allowed in this context (RBS::WillSyntaxError)\n "
580- assert_include stdout . string , "/a.rbs:10:11...10:15: `self` type is not allowed in this context (RBS::WillSyntaxError)\n "
581- end
582- end
583- end
584-
585559 def test_validate__generics_default_ref
586560 with_cli do |cli |
587561 Dir . mktmpdir do |dir |
@@ -615,15 +589,20 @@ def test_validate_multiple
615589 Dir . mktmpdir do |dir |
616590 ( Pathname ( dir ) + 'a.rbs' ) . write ( <<~RBS )
617591 class Foo
618- def foo: (void) -> void
619- def bar: (void) -> void
592+ def foo: () -> Nothing
593+ end
594+
595+ class Bar
596+ def bar: () -> Nothing
620597 end
621598 RBS
622599
623- cli . run ( [ "-I" , dir , "--log-level=warn" , "validate" ] )
600+ assert_raises SystemExit do
601+ cli . run ( [ "-I" , dir , "--log-level=warn" , "validate" ] )
602+ end
624603
625- assert_include stdout . string , "a.rbs:2:11 ...2:25: `void` type is only allowed in return type or generics parameter (RBS::WillSyntaxError )"
626- assert_include stdout . string , "a.rbs:3:11 ...3:25: `void` type is only allowed in return type or generics parameter (RBS::WillSyntaxError )"
604+ assert_include stdout . string , "a.rbs:2:17 ...2:24: Could not find Nothing (RBS::NoTypeFoundError )"
605+ assert_include stdout . string , "a.rbs:6:17 ...6:24: Could not find Nothing (RBS::NoTypeFoundError )"
627606 end
628607 end
629608 end
@@ -633,52 +612,20 @@ def test_validate_multiple_with_fail_fast
633612 Dir . mktmpdir do |dir |
634613 ( Pathname ( dir ) + 'a.rbs' ) . write ( <<~RBS )
635614 class Foo
636- def foo: (void) -> void
637- def bar: (void) -> void
615+ def foo: () -> Nothing
638616 end
639- RBS
640-
641- cli . run ( [ "-I" , dir , "--log-level=warn" , "validate" , "--fail-fast" ] )
642- assert_include stdout . string , "a.rbs:2:11...2:25: `void` type is only allowed in return type or generics parameter (RBS::WillSyntaxError)"
643- assert_include stdout . string , "a.rbs:3:11...3:25: `void` type is only allowed in return type or generics parameter (RBS::WillSyntaxError)"
644- end
645- end
646- end
647617
648- def test_validate_multiple_with_exit_error_on_syntax_error
649- with_cli do |cli |
650- Dir . mktmpdir do |dir |
651- ( Pathname ( dir ) + 'a.rbs' ) . write ( <<~RBS )
652- class Foo
653- def foo: (void) -> void
654- def bar: (void) -> void
618+ class Bar
619+ def bar: () -> Nothing
655620 end
656621 RBS
657622
658623 assert_raises SystemExit do
659- cli . run ( [ "-I" , dir , "--log-level=warn" , "validate" , "--exit-error-on-syntax-error " ] )
624+ cli . run ( [ "-I" , dir , "--log-level=warn" , "validate" , "--fail-fast " ] )
660625 end
661- assert_include stdout . string , "a.rbs:2:11...2:25: `void` type is only allowed in return type or generics parameter (RBS::WillSyntaxError)"
662- assert_include stdout . string , "a.rbs:3:11...3:25: `void` type is only allowed in return type or generics parameter (RBS::WillSyntaxError)"
663- end
664- end
665- end
666-
667- def test_validate_multiple_with_fail_fast_and_exit_error_on_syntax_error
668- with_cli do |cli |
669- Dir . mktmpdir do |dir |
670- ( Pathname ( dir ) + 'a.rbs' ) . write ( <<~RBS )
671- class Foo
672- def foo: (void) -> void
673- def bar: (void) -> void
674- end
675- RBS
676626
677- assert_raises SystemExit do
678- cli . run ( [ "-I" , dir , "--log-level=warn" , "validate" , "--fail-fast" , "--exit-error-on-syntax-error" ] )
679- end
680- assert_include stdout . string , "a.rbs:2:11...2:25: `void` type is only allowed in return type or generics parameter (RBS::WillSyntaxError)"
681- assert_not_include stdout . string , "a.rbs:3:11...3:25: `void` type is only allowed in return type or generics parameter (RBS::WillSyntaxError)"
627+ assert_include stdout . string , "a.rbs:2:17...2:24: Could not find Nothing (RBS::NoTypeFoundError)"
628+ assert_not_include stdout . string , "a.rbs:6:17...6:24: Could not find Nothing (RBS::NoTypeFoundError)"
682629 end
683630 end
684631 end
@@ -688,7 +635,6 @@ def test_validate_multiple_with_many_errors
688635 assert_raise SystemExit do
689636 cli . run ( %w( --log-level=warn -I test/multiple_error.rbs validate ) )
690637 end
691- assert_include ( stdout . string , "`void` type is only allowed in return type or generics parameter" )
692638 assert_include ( stdout . string , "test/multiple_error.rbs:6:17...6:24: ::TypeArg expects parameters [T], but given args [] (RBS::InvalidTypeApplicationError)" )
693639 assert_include ( stdout . string , "test/multiple_error.rbs:8:0...9:3: Detected recursive ancestors: ::RecursiveAncestor < ::RecursiveAncestor (RBS::RecursiveAncestorError)" )
694640 assert_include ( stdout . string , "test/multiple_error.rbs:11:15...11:22: Could not find Nothing (RBS::NoTypeFoundError)" )
@@ -718,81 +664,10 @@ def test_validate_multiple_fail_fast
718664 assert_raise SystemExit do
719665 cli . run ( %w( --log-level=warn -I test/multiple_error.rbs validate --fail-fast ) )
720666 end
721- 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)" )
722- 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)" )
723667 assert_include ( stdout . string , "test/multiple_error.rbs:6:17...6:24: ::TypeArg expects parameters [T], but given args []" )
724668 end
725669 end
726670
727- def test_validate_multiple_fail_fast_and_exit_error_on_syntax_error
728- with_cli do |cli |
729- assert_raise SystemExit do
730- cli . run ( %w( --log-level=warn -I test/multiple_error.rbs validate --fail-fast --exit-error-on-syntax-error ) )
731- end
732- 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)" )
733- end
734- end
735-
736- def test_context_validation
737- tests = [
738- <<~RBS ,
739- class Foo
740- def foo: (void) -> untyped
741- end
742- RBS
743- <<~RBS ,
744- class Bar[A]
745- end
746- class Foo < Bar[instance]
747- end
748- RBS
749- <<~RBS ,
750- module Bar : _Each[instance]
751- end
752- RBS
753- <<~RBS ,
754- module Foo[A < _Each[self]]
755- end
756- RBS
757- <<~RBS ,
758- class Foo
759- @@bar: self
760- end
761- RBS
762- <<~RBS ,
763- type foo = instance
764- RBS
765- <<~RBS ,
766- BAR: instance
767- RBS
768- <<~RBS ,
769- class Foo
770- include Enumerable[self]
771- end
772- RBS
773- <<~RBS ,
774- $FOO: instance
775- RBS
776- ]
777-
778- tests . each do |rbs |
779- with_cli do |cli |
780- Dir . mktmpdir do |dir |
781- ( Pathname ( dir ) + 'a.rbs' ) . write ( rbs )
782-
783- cli . run ( [ "-I" , dir , "validate" ] )
784-
785- assert_match ( /void|self|instance|class/ , stdout . string )
786-
787- cli . run ( [ "-I" , dir , "validate" , "--no-exit-error-on-syntax-error" ] )
788- assert_raises SystemExit do
789- cli . run ( [ "-I" , dir , "validate" , "--exit-error-on-syntax-error" ] )
790- end
791- end
792- end
793- end
794- end
795-
796671 def test_validate_878
797672 with_cli do |cli |
798673 Dir . mktmpdir do |dir |
0 commit comments