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
1 change: 0 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,6 @@ unused_peekable = "warn"
too_long_first_doc_paragraph = "warn"
suspicious_operation_groupings = "warn"
redundant_clone = "warn"
needless_doctest_main = "allow" # FIXME
zero_sized_map_values = "allow" # FIXME https://github.com/rust-lang/rust-clippy/issues/15429
# cargo
cargo = { level = "warn", priority = -1 }
Expand Down
14 changes: 11 additions & 3 deletions crates/oxc_parser/examples/parser_tsx.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ use oxc_parser::{Parser, ParserReturn};
use oxc_span::SourceType;

/// Parse a TypeScript JSX file and validate the results
fn main() {
fn main() -> Result<(), String> {
let source_text = r"
import React from 'react';

Expand Down Expand Up @@ -45,8 +45,16 @@ export const Counter: React.FC = () => {
..
} = Parser::new(&allocator, source_text, source_type).parse();

assert!(!panicked);
assert!(errors.is_empty());
if panicked {
return Err("Parser panicked".to_string());
}

if !errors.is_empty() {
return Err(format!("Parsing errors: {}", errors.len()));
}

assert!(!program.body.is_empty());
assert_eq!(program.comments.len(), 1);

Ok(())
}
Loading