return try

This commit is contained in:
nora 2022-01-18 21:43:16 +01:00
parent f2bff066c6
commit 6a8eb89381
8 changed files with 86 additions and 11 deletions

View file

@ -4,13 +4,12 @@ macro_rules! run_test {
#[test]
fn $name() {
let code = $code;
let output = _run_test(code);
let output = crate::common::_run_test(code);
insta::assert_debug_snapshot!(output);
}
};
}
#[doc(hidden)]
pub fn _run_test(code: &str) -> String {
let mut stdout = Vec::<u8>::new();
let mut cfg = dilaria::Config {

View file

@ -1,5 +1,4 @@
mod common;
use crate::common::_run_test;
run_test!(
single_if,

25
tests/functions.rs Normal file
View file

@ -0,0 +1,25 @@
mod common;
run_test!(
single_call,
r#"
fn test() {
print "correct";
}
test();
"#
);
run_test!(
single_call_expect_return,
r#"
fn test() {
print "correct1";
}
test();
print "correct2";
"#
);

View file

@ -0,0 +1,7 @@
---
source: tests/functions.rs
assertion_line: 3
expression: output
---
"correct\n"