@@ -26,21 +26,26 @@ pub fn eval_amber_code(code: &str) -> Result<String, Message> {
26
26
27
27
/// Tests script output in case of success or failure
28
28
pub fn test_amber ( code : & str , result : & str , target : TestOutcomeTarget ) {
29
+ let evaluated = eval_amber_code ( code) ;
29
30
match target {
30
- TestOutcomeTarget :: Success => {
31
- match eval_amber_code ( code ) {
32
- Ok ( eval_result ) => assert_eq ! (
33
- eval_result . trim_end_matches( '\n' ) ,
31
+ TestOutcomeTarget :: Success => match evaluated {
32
+ Ok ( stdout ) => {
33
+ assert_eq ! (
34
+ stdout . trim_end_matches( '\n' ) ,
34
35
result. trim_end_matches( '\n' ) ,
35
- ) ,
36
- Err ( err) => panic ! ( "ERROR: {}" , err. message. unwrap( ) ) ,
37
- }
36
+ )
37
+ } ,
38
+ Err ( err) => {
39
+ panic ! ( "ERROR: {}" , err. message. unwrap( ) )
40
+ } ,
38
41
}
39
- TestOutcomeTarget :: Failure => {
40
- match eval_amber_code ( code) {
41
- Ok ( eval_result) => panic ! ( "Expected error, got: {}" , eval_result) ,
42
- Err ( err) => assert_eq ! ( err. message. expect( "Error message expected" ) , result) ,
43
- }
42
+ TestOutcomeTarget :: Failure => match evaluated {
43
+ Ok ( stdout) => {
44
+ panic ! ( "Expected error, got: {}" , stdout)
45
+ } ,
46
+ Err ( err) => {
47
+ assert_eq ! ( err. message. expect( "Error message expected" ) , result)
48
+ } ,
44
49
}
45
50
}
46
51
}
0 commit comments