@@ -11,6 +11,9 @@ use expect_test::expect_file;
1111
1212use crate :: { Edition , LexedStr , TopEntryPoint } ;
1313
14+ #[ path = "../test_data/generated/runner.rs" ]
15+ mod runner;
16+
1417#[ test]
1518fn lex_ok ( ) {
1619 for case in TestCase :: list ( "lexer/ok" ) {
@@ -54,16 +57,6 @@ fn parse_ok() {
5457 }
5558}
5659
57- #[ test]
58- fn parse_inline_ok ( ) {
59- for case in TestCase :: list ( "parser/inline/ok" ) {
60- let _guard = stdx:: panic_context:: enter ( format ! ( "{:?}" , case. rs) ) ;
61- let ( actual, errors) = parse ( TopEntryPoint :: SourceFile , & case. text ) ;
62- assert ! ( !errors, "errors in an OK file {}:\n {actual}" , case. rs. display( ) ) ;
63- expect_file ! [ case. rast] . assert_eq ( & actual) ;
64- }
65- }
66-
6760#[ test]
6861fn parse_err ( ) {
6962 for case in TestCase :: list ( "parser/err" ) {
@@ -74,16 +67,6 @@ fn parse_err() {
7467 }
7568}
7669
77- #[ test]
78- fn parse_inline_err ( ) {
79- for case in TestCase :: list ( "parser/inline/err" ) {
80- let _guard = stdx:: panic_context:: enter ( format ! ( "{:?}" , case. rs) ) ;
81- let ( actual, errors) = parse ( TopEntryPoint :: SourceFile , & case. text ) ;
82- assert ! ( errors, "no errors in an ERR file {}:\n {actual}" , case. rs. display( ) ) ;
83- expect_file ! [ case. rast] . assert_eq ( & actual)
84- }
85- }
86-
8770fn parse ( entry : TopEntryPoint , text : & str ) -> ( String , bool ) {
8871 let lexed = LexedStr :: new ( Edition :: CURRENT , text) ;
8972 let input = lexed. to_input ( ) ;
@@ -167,3 +150,27 @@ impl TestCase {
167150 res
168151 }
169152}
153+
154+ #[ track_caller]
155+ fn run_and_expect_no_errors ( path : & str ) {
156+ let path = PathBuf :: from ( path) ;
157+ let text = std:: fs:: read_to_string ( & path) . unwrap ( ) ;
158+ let ( actual, errors) = parse ( TopEntryPoint :: SourceFile , & text) ;
159+ assert ! ( !errors, "errors in an OK file {}:\n {actual}" , path. display( ) ) ;
160+ let mut p = PathBuf :: from ( ".." ) ;
161+ p. push ( path) ;
162+ p. set_extension ( "rast" ) ;
163+ expect_file ! [ p] . assert_eq ( & actual)
164+ }
165+
166+ #[ track_caller]
167+ fn run_and_expect_errors ( path : & str ) {
168+ let path = PathBuf :: from ( path) ;
169+ let text = std:: fs:: read_to_string ( & path) . unwrap ( ) ;
170+ let ( actual, errors) = parse ( TopEntryPoint :: SourceFile , & text) ;
171+ assert ! ( errors, "no errors in an ERR file {}:\n {actual}" , path. display( ) ) ;
172+ let mut p = PathBuf :: from ( ".." ) ;
173+ p. push ( path) ;
174+ p. set_extension ( "rast" ) ;
175+ expect_file ! [ p] . assert_eq ( & actual)
176+ }
0 commit comments