use dever::{ compiler::{check, model::Program}, syntax::{diagnostic::Diagnostic, source::Source}, }; fn linked(text: &str) -> Result { let main = dever::syntax::parse(&Source::new(0, "main.dever", text.into()))?; let library = dever::syntax::parse(&Source::new( 1, "uuid.dever", include_str!("../../../lib/uuid.dever").into(), ))?; check::check(vec![main, library], &["main".into(), "uuid".into()]) } #[test] fn uuids_are_distinct_values_with_typed_nullable_parsing() { assert!(linked("main(value: Uuid) (answer: Int?) pure { values = { value = 42 }\n answer = get(values, value) }").is_ok()); for (source, code) in [ ( "main() (value: Uuid) { value = \"550e8400-e29b-41d4-a716-446655440000\" }", "C005", ), ( "main(value: Uuid, other: Id) (answer: Bool) { answer = value == other }", "C005", ), ( "main(value: Uuid) (answer: Bool) { answer = value < value }", "C005", ), ("main() () { value = dever.system.uuidParse(\"\") }", "C006"), ("main() (value: Uuid) { value = uuid.parse(\"\") }", "C005"), ] { assert_eq!(linked(source).unwrap_err().code, code, "{source}"); } }