mirror of
https://github.com/Noratrieb/dilaria.git
synced 2026-01-14 17:35:03 +01:00
return try
This commit is contained in:
parent
f2bff066c6
commit
6a8eb89381
8 changed files with 86 additions and 11 deletions
|
|
@ -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 {
|
||||
|
|
|
|||
|
|
@ -1,5 +1,4 @@
|
|||
mod common;
|
||||
use crate::common::_run_test;
|
||||
|
||||
run_test!(
|
||||
single_if,
|
||||
|
|
|
|||
25
tests/functions.rs
Normal file
25
tests/functions.rs
Normal 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";
|
||||
"#
|
||||
);
|
||||
7
tests/snapshots/functions__single_call.snap
Normal file
7
tests/snapshots/functions__single_call.snap
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
---
|
||||
source: tests/functions.rs
|
||||
assertion_line: 3
|
||||
expression: output
|
||||
|
||||
---
|
||||
"correct\n"
|
||||
Loading…
Add table
Add a link
Reference in a new issue