slint/tests/doctests/main.rs
Tobias Hunger 4230ac2572
Update copyright information to reflect name change
Also run resue over the codebase and fix complaints from that tool.
2022-02-09 10:27:47 +01:00

30 lines
912 B
Rust

// Copyright © SixtyFPS GmbH <info@slint-ui.com>
// SPDX-License-Identifier: GPL-3.0-only OR LicenseRef-Slint-commercial
#[cfg(test)]
fn do_test(snippet: &str) -> Result<(), Box<dyn std::error::Error>> {
let mut compiler = slint_interpreter::ComponentCompiler::default();
let component =
spin_on::spin_on(compiler.build_from_source(snippet.into(), Default::default()));
#[cfg(feature = "display-diagnostics")]
slint_interpreter::print_diagnostics(&compiler.diagnostics());
for d in compiler.diagnostics() {
if d.level() == slint_interpreter::DiagnosticLevel::Error {
return Err(d.message().to_owned().into());
}
}
if component.is_none() {
Err(String::from("Failure").into())
} else {
Ok(())
}
}
include!(env!("TEST_FUNCTIONS"));
fn main() {
println!("Nothing to see here, please run me through cargo test :)");
}