File tree Expand file tree Collapse file tree 2 files changed +11
-4
lines changed
crates/oxc_parser/examples Expand file tree Collapse file tree 2 files changed +11
-4
lines changed Original file line number Diff line number Diff line change @@ -96,7 +96,6 @@ unused_peekable = "warn"
9696too_long_first_doc_paragraph = " warn"
9797suspicious_operation_groupings = " warn"
9898redundant_clone = " warn"
99- needless_doctest_main = " allow" # FIXME
10099zero_sized_map_values = " allow" # FIXME https://github.com/rust-lang/rust-clippy/issues/15429
101100# cargo
102101cargo = { level = " warn" , priority = -1 }
Original file line number Diff line number Diff line change @@ -14,7 +14,7 @@ use oxc_parser::{Parser, ParserReturn};
1414use oxc_span:: SourceType ;
1515
1616/// Parse a TypeScript JSX file and validate the results
17- fn main ( ) {
17+ fn main ( ) -> Result < ( ) , String > {
1818 let source_text = r"
1919import React from 'react';
2020
@@ -45,8 +45,16 @@ export const Counter: React.FC = () => {
4545 ..
4646 } = Parser :: new ( & allocator, source_text, source_type) . parse ( ) ;
4747
48- assert ! ( !panicked) ;
49- assert ! ( errors. is_empty( ) ) ;
48+ if panicked {
49+ return Err ( "Parser panicked" . to_string ( ) ) ;
50+ }
51+
52+ if !errors. is_empty ( ) {
53+ return Err ( format ! ( "Parsing errors: {}" , errors. len( ) ) ) ;
54+ }
55+
5056 assert ! ( !program. body. is_empty( ) ) ;
5157 assert_eq ! ( program. comments. len( ) , 1 ) ;
58+
59+ Ok ( ( ) )
5260}
You can’t perform that action at this time.
0 commit comments