use sqry_core::graph::unified::build::staging::StagingGraph;
use sqry_core::plugin::LanguagePlugin;
use sqry_lang_php::PhpPlugin;
use sqry_tree_sitter_fuzz_support::MalformedInputBuilder;
use sqry_tree_sitter_fuzz_support::generators::nesting::depths;
use sqry_tree_sitter_fuzz_support::testing::{StackSafeResult, run_with_stack};
use std::path::Path;
#[test]
fn test_truncated_utf8() {
let plugin = PhpPlugin::default();
let malformed = MalformedInputBuilder::truncated_utf8();
let result = plugin.parse_ast(&malformed);
let _ = result;
}
#[test]
fn test_invalid_continuation() {
let plugin = PhpPlugin::default();
let malformed = MalformedInputBuilder::invalid_continuation();
let result = plugin.parse_ast(&malformed);
let _ = result;
}
#[test]
fn test_overlong_encoding() {
let plugin = PhpPlugin::default();
let malformed = MalformedInputBuilder::overlong_encoding();
let result = plugin.parse_ast(&malformed);
let _ = result;
}
#[test]
fn test_surrogate_pairs() {
let plugin = PhpPlugin::default();
let malformed = MalformedInputBuilder::surrogate_pairs();
let result = plugin.parse_ast(&malformed);
let _ = result;
}
#[test]
fn test_null_bytes() {
let plugin = PhpPlugin::default();
let malformed = MalformedInputBuilder::null_bytes();
let result = plugin.parse_ast(&malformed);
let _ = result;
}
#[test]
fn test_deeply_nested_shallow() {
let plugin = PhpPlugin::default();
let nested = MalformedInputBuilder::for_language("php").deeply_nested(depths::SHALLOW);
let result = run_with_stack(move || plugin.parse_ast(&nested));
match result {
StackSafeResult::Ok(parse_result) => {
let _ = parse_result;
}
StackSafeResult::Panicked(_) => {
}
}
}
#[test]
fn test_deeply_nested_medium() {
let plugin = PhpPlugin::default();
let nested = MalformedInputBuilder::for_language("php").deeply_nested(depths::MEDIUM);
let result = run_with_stack(move || plugin.parse_ast(&nested));
match result {
StackSafeResult::Ok(_) => {
}
StackSafeResult::Panicked(_) => {
}
}
}
#[test]
#[ignore] fn test_deeply_nested_deep() {
let plugin = PhpPlugin::default();
let nested = MalformedInputBuilder::for_language("php").deeply_nested(depths::DEEP);
let result = run_with_stack(move || plugin.parse_ast(&nested));
let _ = result;
}
#[test]
fn test_oversized_1mb() {
let plugin = PhpPlugin::default();
let large = MalformedInputBuilder::for_language("php").oversized_1mb();
let result = plugin.parse_ast(&large);
let _ = result;
}
#[test]
#[ignore] fn test_oversized_10mb() {
let plugin = PhpPlugin::default();
let large = MalformedInputBuilder::for_language("php").oversized_10mb();
let result = plugin.parse_ast(&large);
let _ = result; }
#[test]
fn test_random_bytes() {
let plugin = PhpPlugin::default();
let random = MalformedInputBuilder::random_bytes(1024);
let result = plugin.parse_ast(&random);
let _ = result;
}
#[test]
fn test_build_graph_on_malformed() {
let plugin = PhpPlugin::default();
let malformed = MalformedInputBuilder::truncated_utf8();
let path = Path::new("test.php");
let tree = match plugin.parse_ast(&malformed) {
Ok(tree) => tree,
Err(_) => return,
};
let builder = plugin.graph_builder().expect("graph builder");
let mut staging = StagingGraph::new();
let result = builder.build_graph(&tree, &malformed, path, &mut staging);
let _ = result;
}