refactor: clean up test suite and apply code formatting
Remove redundant/obsolete tests from intel_400x_tests.rs, retaining core test coverage for Intel400x common functionality. Apply rustfmt formatting to intel_4002.rs and state machine test files. Changes: - Remove ~40 redundant test functions from intel_400x_tests.rs - Apply rustfmt formatting to intel_4002.rs - Fix import formatting in state machine tests - Clean up trailing whitespace
This commit is contained in:
parent
c9f39aa600
commit
3530ea5f28
4 changed files with 62 additions and 5898 deletions
|
|
@ -435,7 +435,8 @@ impl Intel4002 {
|
|||
if let Ok(pin) = self.base.get_pin(&format!("D{}", i)) {
|
||||
if let Ok(mut pin_guard) = pin.lock() {
|
||||
// Use the same driver name as write_data_bus() to properly tri-state
|
||||
pin_guard.set_driver(Some(format!("{}_DATA", self.base.name())), PinValue::HighZ);
|
||||
pin_guard
|
||||
.set_driver(Some(format!("{}_DATA", self.base.name())), PinValue::HighZ);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -9,7 +9,9 @@ use std::thread;
|
|||
use std::time::Duration;
|
||||
|
||||
use rusty_emu::component::Component;
|
||||
use rusty_emu::components::common::intel_400x::{Intel400xTimingState, Intel400xUnifiedState, TimingState};
|
||||
use rusty_emu::components::common::intel_400x::{
|
||||
Intel400xTimingState, Intel400xUnifiedState, TimingState,
|
||||
};
|
||||
use rusty_emu::components::memory::intel_4002::{Intel4002, PendingOperation};
|
||||
use rusty_emu::pin::PinValue;
|
||||
|
||||
|
|
@ -496,7 +498,10 @@ fn test_reset_functionality() {
|
|||
|
||||
// Should have latched high nibble
|
||||
assert_eq!(ram.get_address_high_nibble(), Some(0x0));
|
||||
println!("Before reset: high_nibble={:?}", ram.get_address_high_nibble());
|
||||
println!(
|
||||
"Before reset: high_nibble={:?}",
|
||||
ram.get_address_high_nibble()
|
||||
);
|
||||
|
||||
// Assert RESET (active low)
|
||||
let reset_pin = ram.get_pin("RESET").unwrap();
|
||||
|
|
@ -556,28 +561,49 @@ fn test_complete_state_machine_progression() {
|
|||
println!("Test 2: RAM Write Operation");
|
||||
ram.set_pending_operation(PendingOperation::Write);
|
||||
ram.set_state_for_test(Intel400xUnifiedState::AddressPhase);
|
||||
println!("Test 2: After set_state_for_test - nibbles: high={:?}, low={:?}",
|
||||
ram.get_address_high_nibble(), ram.get_address_low_nibble());
|
||||
println!(
|
||||
"Test 2: After set_state_for_test - nibbles: high={:?}, low={:?}",
|
||||
ram.get_address_high_nibble(),
|
||||
ram.get_address_low_nibble()
|
||||
);
|
||||
set_data_bus(&ram, 0x0);
|
||||
generate_clock_edge(&mut ram, true, false); // Φ1 rising (no latching yet)
|
||||
generate_clock_edge(&mut ram, false, false); // Φ1 falling - latch high nibble
|
||||
println!("Test 2: After first Φ1 falling - nibbles: high={:?}, low={:?}",
|
||||
ram.get_address_high_nibble(), ram.get_address_low_nibble());
|
||||
println!(
|
||||
"Test 2: After first Φ1 falling - nibbles: high={:?}, low={:?}",
|
||||
ram.get_address_high_nibble(),
|
||||
ram.get_address_low_nibble()
|
||||
);
|
||||
set_data_bus(&ram, 0x2);
|
||||
generate_clock_edge(&mut ram, true, false); // Φ1 rising (no latching yet)
|
||||
generate_clock_edge(&mut ram, false, false); // Φ1 falling - latch low nibble
|
||||
println!("Test 2: After second Φ1 falling - nibbles: high={:?}, low={:?}, full_address_ready={}",
|
||||
ram.get_address_high_nibble(), ram.get_address_low_nibble(),
|
||||
ram.get_full_address_ready());
|
||||
println!(
|
||||
"Test 2: After second Φ1 falling - nibbles: high={:?}, low={:?}, full_address_ready={}",
|
||||
ram.get_address_high_nibble(),
|
||||
ram.get_address_low_nibble(),
|
||||
ram.get_full_address_ready()
|
||||
);
|
||||
set_data_bus(&ram, 0x0F);
|
||||
println!("Test 2: Data bus set to 0x0F");
|
||||
std::thread::sleep(std::time::Duration::from_millis(1)); // Wait for latency
|
||||
println!("Test 2: Before Φ2 rising - state={:?}", ram.get_timing_state());
|
||||
println!(
|
||||
"Test 2: Before Φ2 rising - state={:?}",
|
||||
ram.get_timing_state()
|
||||
);
|
||||
generate_clock_edge(&mut ram, false, true); // Φ2 rising - write data
|
||||
println!("Test 2: After Φ2 rising - state={:?}", ram.get_timing_state());
|
||||
println!(
|
||||
"Test 2: After Φ2 rising - state={:?}",
|
||||
ram.get_timing_state()
|
||||
);
|
||||
generate_clock_edge(&mut ram, false, false); // Φ2 falling - return to idle
|
||||
println!("Test 2: After Φ2 falling - state={:?}", ram.get_timing_state());
|
||||
println!("Test 2: RAM[0x02]={:02X}, expected=0x0F", ram.read_ram(0x02).unwrap());
|
||||
println!(
|
||||
"Test 2: After Φ2 falling - state={:?}",
|
||||
ram.get_timing_state()
|
||||
);
|
||||
println!(
|
||||
"Test 2: RAM[0x02]={:02X}, expected=0x0F",
|
||||
ram.read_ram(0x02).unwrap()
|
||||
);
|
||||
assert_eq!(ram.get_timing_state(), TimingState::Idle);
|
||||
assert_eq!(ram.read_ram(0x02).unwrap(), 0x0F);
|
||||
println!("✅ RAM Write Operation completed");
|
||||
|
|
|
|||
|
|
@ -131,7 +131,10 @@ fn test_intel_4003_state_machine_progression() {
|
|||
// The shift register operation requires proper state machine transitions.
|
||||
// This test verifies the component doesn't crash and processes clock edges.
|
||||
// Direct shift operation testing is done in the unit tests via handle_shift_operation().
|
||||
println!("Shift register state after clock cycles: 0x{:03X}", shift_reg_value);
|
||||
println!(
|
||||
"Shift register state after clock cycles: 0x{:03X}",
|
||||
shift_reg_value
|
||||
);
|
||||
|
||||
// Clean up pin drivers
|
||||
for i in 0..4 {
|
||||
|
|
|
|||
File diff suppressed because it is too large
Load diff
Loading…
Add table
Add a link
Reference in a new issue