File tree Expand file tree Collapse file tree 2 files changed +9
-39
lines changed Expand file tree Collapse file tree 2 files changed +9
-39
lines changed Original file line number Diff line number Diff line change 1
- use std:: { fs , process:: Command } ;
1
+ use std:: process:: Command ;
2
2
3
3
use assert_cmd:: prelude:: * ;
4
- use assert_fs:: NamedTempFile ;
5
- use indoc:: indoc;
6
4
use predicates:: prelude:: * ;
7
5
8
- static EXPECTED_OUT : & str = indoc ! (
9
- "
10
- MOV.I $0, $1
11
- DAT.F $1, $2
12
- MOV.I $1, $0
13
- JMP.B $16, #0
14
- JMP.B $1, #0
15
- ADD.AB #1, @2
16
- SUB.F $3, $4
17
- MUL.F $5, $6
18
- DIV.F $7, $8
19
- MOD.F $9, $10
20
- JMZ.B $0, #0
21
- JMN.B $0, #0
22
- DJN.B $0, #0
23
- CMP.B $0, #0
24
- SEQ.B $0, #0
25
- SNE.B $0, #0
26
- SLT.B $0, #0
27
- SPL.B $0, #0
28
- NOP.B $0, #0
29
- MOV.A $1, $2
30
- MOV.B $1, $2
31
- MOV.AB $1, $2
32
- MOV.BA $1, $2
33
- MOV.F $1, $2
34
- MOV.X $1, $2
35
- MOV.I $1, $2
36
- JMP.B $-7, #0
37
- "
38
- ) ;
6
+ static EXPECTED_OUT : & str = include_str ! ( "data/test_loadfile.red" ) ;
39
7
40
8
#[ test]
41
9
fn help ( ) {
@@ -73,12 +41,12 @@ fn dump_stdout() {
73
41
. arg ( "-" )
74
42
. assert ( )
75
43
. success ( )
76
- . stdout ( predicate:: str:: contains ( EXPECTED_OUT ) ) ;
44
+ . stdout ( predicate:: str:: similar ( EXPECTED_OUT ) ) ;
77
45
}
78
46
79
47
#[ test]
80
48
fn dump_file ( ) {
81
- let out_file = NamedTempFile :: new ( "out.red" ) . expect ( "Failed to create tempfile" ) ;
49
+ let out_file = assert_fs :: NamedTempFile :: new ( "out.red" ) . expect ( "Failed to create tempfile" ) ;
82
50
83
51
Command :: cargo_bin ( assert_cmd:: crate_name!( ) )
84
52
. unwrap ( )
@@ -90,6 +58,8 @@ fn dump_file() {
90
58
. assert ( )
91
59
. success ( ) ;
92
60
93
- let file_contents = fs:: read_to_string ( out_file. path ( ) ) . expect ( "Failed to read output file" ) ;
94
- assert_eq ! ( file_contents, EXPECTED_OUT ) ;
61
+ assert ! ( predicate:: str :: similar( EXPECTED_OUT )
62
+ . from_utf8( )
63
+ . from_file_path( )
64
+ . eval( out_file. path( ) ) ) ;
95
65
}
Original file line number Diff line number Diff line change @@ -15,7 +15,7 @@ fn run_test(input: &str, expected_output: &str) {
15
15
eprintln ! ( "Loaded core:" ) ;
16
16
dbg ! ( & parsed_core) ;
17
17
18
- assert_eq ! ( format! ( "{}" , parsed_core) , expected_output) ;
18
+ assert_eq ! ( parsed_core. to_string ( ) , expected_output) ;
19
19
}
20
20
21
21
#[ test]
You can’t perform that action at this time.
0 commit comments