diff --git a/crates/oxc_query/src/tests.rs b/crates/oxc_query/src/tests.rs index 3012ebd89..fde5ca742 100644 --- a/crates/oxc_query/src/tests.rs +++ b/crates/oxc_query/src/tests.rs @@ -4,7 +4,7 @@ use oxc_allocator::Allocator; use oxc_parser::Parser; use oxc_semantic::SemanticBuilder; use oxc_span::SourceType; -use trustfall::{execute_query, FieldValue, TryIntoStruct}; +use trustfall::{execute_query, provider::check_adapter_invariants, FieldValue, TryIntoStruct}; use crate::{adapter::schema, Adapter}; @@ -205,3 +205,19 @@ query { results ); } + +#[test] +fn test_invariants() { + let file_path = "/apple/orange.tsx"; + let source_text = "const apple = 1;"; + + let allocator = Allocator::default(); + let source_type = SourceType::from_path(file_path).unwrap(); + let ret = Parser::new(&allocator, source_text, source_type).parse(); + let program = allocator.alloc(ret.program); + let semantic_ret = + SemanticBuilder::new(source_text, source_type).with_trivias(&ret.trivias).build(program); + + let adapter = Adapter { path_components: vec![], semantic: Rc::new(semantic_ret.semantic) }; + check_adapter_invariants(schema(), &adapter); +}