Skip to content

Commit 47e55ab

Browse files
committed
[assembler] modify a driver test to verify the whole executable.
1 parent 6e05e0c commit 47e55ab

File tree

2 files changed

+71
-6
lines changed

2 files changed

+71
-6
lines changed

assembler/src/asmlib/driver/tests.rs

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@ use super::super::span::*;
1313
use super::super::symbol::{SymbolContext, SymbolName};
1414
use super::super::symtab::LookupOperation;
1515
use super::super::types::BlockIdentifier;
16-
use super::assemble_pass1;
1716
use super::{assemble_nonempty_valid_input, assemble_source};
17+
use super::{assemble_pass1, Binary, BinaryChunk};
1818
use base::{
1919
charset::Script,
2020
prelude::{u18, u36, Address, Unsigned18Bit, Unsigned36Bit},
@@ -535,11 +535,19 @@ fn test_440_330_220_110_with_commas() {
535535

536536
#[test]
537537
fn test_alternate_base_with_commas() {
538-
let input = "10·,11·,,12,13· ** Note that 12 is in the default, octal, base\n";
539-
let program = assemble_source(input, Default::default()).expect("program is valid");
540-
dbg!(&program);
541-
assert_eq!(program.chunks.len(), 1); // one chunk (no RC-block needed).
542-
assert_eq!(program.chunks[0].words[0], u36!(0o012_013_012_015));
538+
assert_eq!(
539+
assemble_source(
540+
"10·,11·,,12,13· ** Note that 12 is in the default, octal, base\n",
541+
Default::default(),
542+
),
543+
Ok(Binary {
544+
entry_point: None,
545+
chunks: vec![BinaryChunk {
546+
address: Address::from(u18!(0o00200000)),
547+
words: vec![u36!(0o012_013_012_015)]
548+
}]
549+
})
550+
);
543551
}
544552

545553
#[test]

assembler/src/asmlib/types.rs

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -171,6 +171,63 @@ pub enum AssemblerFailure {
171171
MachineLimitExceeded(MachineLimitExceededFailure),
172172
}
173173

174+
impl PartialEq<AssemblerFailure> for AssemblerFailure {
175+
fn eq(&self, other: &AssemblerFailure) -> bool {
176+
use AssemblerFailure::*;
177+
match (self, other) {
178+
(InternalError(s1), InternalError(s2)) if s1 == s2 => true,
179+
(BadTapeBlock(s1), BadTapeBlock(s2)) if s1 == s2 => true,
180+
(IoErrorOnStdout { error: e1 }, IoErrorOnStdout { error: e2 })
181+
if e1.to_string() == e2.to_string() =>
182+
{
183+
true
184+
}
185+
(
186+
IoErrorOnInput {
187+
error: e1,
188+
filename: f1,
189+
},
190+
IoErrorOnInput {
191+
error: e2,
192+
filename: f2,
193+
},
194+
) => e1.to_string() == e2.to_string() && f1 == f2,
195+
(
196+
IoErrorOnOutput {
197+
error: e1,
198+
filename: f1,
199+
},
200+
IoErrorOnOutput {
201+
error: e2,
202+
filename: f2,
203+
},
204+
) => e1.to_string() == e2.to_string() && f1 == f2,
205+
(
206+
InvalidProgram {
207+
span: span1,
208+
msg: msg1,
209+
},
210+
InvalidProgram {
211+
span: span2,
212+
msg: msg2,
213+
},
214+
) => span1 == span2 && msg1 == msg2,
215+
(
216+
SyntaxError {
217+
location: loc1,
218+
msg: msg1,
219+
},
220+
SyntaxError {
221+
location: loc2,
222+
msg: msg2,
223+
},
224+
) => loc1 == loc2 && msg1 == msg2,
225+
(MachineLimitExceeded(e1), MachineLimitExceeded(e2)) if e1 == e2 => true,
226+
_ => false,
227+
}
228+
}
229+
}
230+
174231
impl From<MachineLimitExceededFailure> for AssemblerFailure {
175232
fn from(f: MachineLimitExceededFailure) -> AssemblerFailure {
176233
AssemblerFailure::MachineLimitExceeded(f)

0 commit comments

Comments
 (0)