Initial Dever 0.0.1

This commit is contained in:
Codex committed 2026-11-03 03:32:07 +00:00
commit 81233d098c
1479 files changed
+163782

No files matched your search

+37
View File
@@ -0,0 +1,37 @@
use dever::{
compiler::{check, model::Program},
syntax::{diagnostic::Diagnostic, source::Source},
};
fn linked(text: &str) -> Result<Program, Diagnostic> {
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}");
}
}