use std::sync::Arc;
use hamelin_legacy::Compiler;
use hamelin_lib::catalog::{CatalogBuilder, CatalogProvider};
use rstest::rstest;
use crate::shared;
fn compiler() -> Arc<Compiler> {
let catalog = CatalogBuilder::default().build();
let mut compiler = Compiler::new();
compiler.set_environment_provider(Arc::new(CatalogProvider::try_from(catalog).unwrap()));
Arc::new(compiler)
}
#[rstest]
#[case::map_key_types_do_not_match(
r#"map('one': 'two', 3: 'four') "#,
"The types are not mergeable"
)]
#[case::map_value_types_do_not_match("map(1: 2, 3: 'four')", "The types are not mergeable")]
#[case::must_be_pairs("map((1, 2, 3))", "could not find a matching function definition")]
#[case::keys_cant_be_array("map([1]: 2)", "could not find a matching function definition")]
#[case::keys_cant_be_struct("map({x: 1}: 2)", "could not find a matching function definition")]
#[case::bad_type_lhs("2 IN map('one': 2)", "The types are not mergeable")]
pub fn test_map_err(#[case] hamelin: String, #[case] error: &str) {
shared::specific_error(compiler(), hamelin, error);
}