Skip to content

Commit

Permalink
Avoid using std::time in tests that don't actually need it.
Browse files Browse the repository at this point in the history
  • Loading branch information
kpreid committed May 2, 2024
1 parent 17ffee4 commit a4015e8
Show file tree
Hide file tree
Showing 8 changed files with 21 additions and 21 deletions.
2 changes: 1 addition & 1 deletion all-is-cubes-content/src/template.rs
Original file line number Diff line number Diff line change
Expand Up @@ -513,7 +513,7 @@ mod tests {
if template != UniverseTemplate::Blank {
let _ = u.get_default_character().unwrap().read().unwrap();
}
u.step(false, time::DeadlineStd::Asap);
u.step(false, time::DeadlineNt::Asap);
}
}
}
6 changes: 3 additions & 3 deletions all-is-cubes/src/behavior.rs
Original file line number Diff line number Diff line change
Expand Up @@ -905,8 +905,8 @@ mod tests {
});
let character = u.insert_anonymous(character);

u.step(false, time::DeadlineStd::Whenever);
u.step(false, time::DeadlineStd::Whenever);
u.step(false, time::DeadlineNt::Whenever);
u.step(false, time::DeadlineNt::Whenever);

// Until we have a way to query the behavior set, the best test we can do is to
// read its effects.
Expand Down Expand Up @@ -934,7 +934,7 @@ mod tests {
.count(),
1
);
u.step(false, time::DeadlineStd::Whenever);
u.step(false, time::DeadlineNt::Whenever);
assert_eq!(
character
.read()
Expand Down
2 changes: 1 addition & 1 deletion all-is-cubes/src/block/modifier/move.rs
Original file line number Diff line number Diff line change
Expand Up @@ -340,7 +340,7 @@ mod tests {
// TODO: We need a "step until idle" function, or for the UniverseStepInfo to convey how many blocks were updated / are waiting
// TODO: Some tests will want to look at the partial results
for _ in 0..257 {
universe.step(false, time::DeadlineStd::Whenever);
universe.step(false, time::DeadlineNt::Whenever);
}
checker(&space.read().unwrap(), &block);
}
Expand Down
2 changes: 1 addition & 1 deletion all-is-cubes/src/character/exposure.rs
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,7 @@ mod tests {
// .fill_uniform(space.bounds().expand(FaceMap::repeat(-1)), AIR)
// .unwrap();

space.evaluate_light::<std::time::Instant>(0, |_| {});
space.evaluate_light::<crate::time::NoTime>(0, |_| {});
space
});
let mut character = Character::spawn_default(space);
Expand Down
2 changes: 1 addition & 1 deletion all-is-cubes/src/save/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -749,7 +749,7 @@ fn space_light_queue_remembered() {
);

// Then, when stepped, they are updated
let (_, _) = space2.step(None, Tick::arbitrary(), time::DeadlineStd::Whenever);
let (_, _) = space2.step(None, Tick::arbitrary(), time::DeadlineNt::Whenever);
assert_eq!(
[0, 1, 2].map(|x| space2.get_lighting([x, 0, 0]).status()),
[Opaque, Visible, NoRays]
Expand Down
4 changes: 2 additions & 2 deletions all-is-cubes/src/space/light/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ fn step() {
assert_eq!(space.get_lighting([1, 0, 0]), PackedLight::NO_RAYS);
assert_eq!(space.get_lighting([2, 0, 0]), PackedLight::NO_RAYS);

let (info, _) = space.step(None, time::Tick::arbitrary(), time::DeadlineStd::Whenever);
let (info, _) = space.step(None, time::Tick::arbitrary(), time::DeadlineNt::Whenever);
assert_eq!(
info.light,
LightUpdatesInfo {
Expand Down Expand Up @@ -280,7 +280,7 @@ fn disabled_lighting_does_not_update() {
.light_needs_update(Cube::new(0, 0, 0), Priority::UNINIT);
assert_eq!(
space
.step(None, time::Tick::arbitrary(), time::DeadlineStd::Whenever)
.step(None, time::Tick::arbitrary(), time::DeadlineNt::Whenever)
.0
.light,
LightUpdatesInfo::default()
Expand Down
14 changes: 7 additions & 7 deletions all-is-cubes/src/space/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -420,7 +420,7 @@ fn listens_to_block_changes() {
// computations like reevaluation to happen during the notification process.
assert_eq!(sink.drain(), vec![]);
// Instead, it only happens the next time the space is stepped.
let (_, _) = space.step(None, Tick::arbitrary(), time::DeadlineStd::Whenever);
let (_, _) = space.step(None, Tick::arbitrary(), time::DeadlineNt::Whenever);
// Now we should see a notification and the evaluated block data having changed.
assert_eq!(sink.drain(), vec![SpaceChange::BlockEvaluation(0)]);
assert_eq!(space.get_evaluated([0, 0, 0]), &new_evaluated);
Expand Down Expand Up @@ -450,7 +450,7 @@ fn indirect_becomes_evaluation_error() {
.unwrap();

// Step the space to let it notice.
let (_, _) = space.step(None, Tick::arbitrary(), time::DeadlineStd::Whenever);
let (_, _) = space.step(None, Tick::arbitrary(), time::DeadlineNt::Whenever);

// Now we should see a notification and the evaluated block data having changed.
assert_eq!(sink.drain(), vec![SpaceChange::BlockEvaluation(0)]);
Expand Down Expand Up @@ -586,11 +586,11 @@ fn block_tick_action_does_not_run_paused() {
let mut clock = time::Clock::new(time::TickSchedule::per_second(10), 0);

// No effect when paused
_ = space.step(None, clock.advance(true), time::DeadlineStd::Whenever);
_ = space.step(None, clock.advance(true), time::DeadlineNt::Whenever);
assert_eq!(space[[0, 0, 0]], vanisher);

// Operation applied when unpaused
_ = space.step(None, clock.advance(false), time::DeadlineStd::Whenever);
_ = space.step(None, clock.advance(false), time::DeadlineNt::Whenever);
assert_eq!(space[[0, 0, 0]], AIR);
}

Expand Down Expand Up @@ -631,7 +631,7 @@ fn block_tick_action_timing() {
99
});

let (_info, step_txn) = space.step(None, clock.advance(false), time::DeadlineStd::Whenever);
let (_info, step_txn) = space.step(None, clock.advance(false), time::DeadlineNt::Whenever);
// TODO: the block effect isn't a returned transaction yet but it perhaps should be.
// This test will need reworking at that point.
assert_eq!(step_txn, UniverseTransaction::default());
Expand Down Expand Up @@ -681,7 +681,7 @@ fn block_tick_action_conflict() {
space.set(left, &modifies_px_neighbor).unwrap();
space.set(right, &modifies_nx_neighbor).unwrap();

let (_info, step_txn) = space.step(None, clock.advance(false), time::DeadlineStd::Whenever);
let (_info, step_txn) = space.step(None, clock.advance(false), time::DeadlineNt::Whenever);
assert_eq!(step_txn, UniverseTransaction::default());

assert_eq!(
Expand All @@ -707,7 +707,7 @@ fn block_tick_action_conflict() {
// should take effect.
space.set(right, &AIR).unwrap();

let (_info, step_txn) = space.step(None, clock.advance(false), time::DeadlineStd::Whenever);
let (_info, step_txn) = space.step(None, clock.advance(false), time::DeadlineNt::Whenever);
assert_eq!(step_txn, UniverseTransaction::default());
assert_eq!(fluff_sink.drain(), vec![]);
assert_eq!(
Expand Down
10 changes: 5 additions & 5 deletions all-is-cubes/src/universe/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -330,9 +330,9 @@ fn delete_wrong_universe_fails() {
fn step_time() {
let mut u = Universe::new();
assert_eq!(u.session_step_time, 0);
u.step(false, time::DeadlineStd::Whenever);
u.step(false, time::DeadlineNt::Whenever);
assert_eq!(u.session_step_time, 1);
u.step(true, time::DeadlineStd::Whenever);
u.step(true, time::DeadlineNt::Whenever);
assert_eq!(u.session_step_time, 1);
}

Expand Down Expand Up @@ -370,13 +370,13 @@ fn universe_behavior() {
dbg!(&u);
assert!(u.get_any(&"foo".into()).is_none());

u.step(false, time::DeadlineStd::Whenever);
u.step(false, time::DeadlineNt::Whenever);

// After stepping, the behavior should have done its thing
assert!(u.get_any(&"foo".into()).is_some());

// A further step should not fail since the behavior removed itself
u.step(false, time::DeadlineStd::Whenever);
u.step(false, time::DeadlineNt::Whenever);
}

#[test]
Expand All @@ -393,7 +393,7 @@ fn gc_implicit() {
let mut u = Universe::new();
u.insert_anonymous(BlockDef::new(AIR));
assert_eq!(1, u.iter_by_type::<BlockDef>().count());
u.step(false, time::DeadlineStd::Whenever);
u.step(false, time::DeadlineNt::Whenever);
assert_eq!(0, u.iter_by_type::<BlockDef>().count());
}

Expand Down

0 comments on commit a4015e8

Please sign in to comment.