Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 31 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
name: CI

on:
push:
branches: [main]
pull_request:
branches: [main]

env:
CARGO_TERM_COLOR: always

jobs:
test:
name: Test
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@stable
- run: cargo build --all-targets
- run: cargo test

lint:
name: Lint
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@stable
with:
components: rustfmt, clippy
- run: cargo fmt --all -- --check
- run: cargo clippy -- -D warnings
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
target/
14 changes: 7 additions & 7 deletions tests/integration.rs
Original file line number Diff line number Diff line change
Expand Up @@ -51,36 +51,36 @@ mod tests {
#[test]
fn engine_survive_at_critical_energy() {
let mut eng = InstinctEngine::new(Thresholds::default());
let refs = eng.tick(0.1, 0.0, 0.0, true, false);
let _refs = eng.tick(0.1, 0.0, 0.0, true, false);
assert!(eng.is_firing(InstinctType::Survive));
}

#[test]
fn engine_flee_at_high_threat() {
let mut eng = InstinctEngine::new(Thresholds::default());
let refs = eng.tick(0.9, 0.8, 0.0, true, false);
let _refs = eng.tick(0.9, 0.8, 0.0, true, false);
assert!(eng.is_firing(InstinctType::Flee));
}

#[test]
fn engine_hoard_at_low_but_not_critical() {
let mut eng = InstinctEngine::new(Thresholds::default());
let refs = eng.tick(0.3, 0.0, 0.0, true, false);
let _refs = eng.tick(0.3, 0.0, 0.0, true, false);
assert!(eng.is_firing(InstinctType::Hoard));
assert!(!eng.is_firing(InstinctType::Survive));
}

#[test]
fn engine_cooperate_with_high_trust() {
let mut eng = InstinctEngine::new(Thresholds::default());
let refs = eng.tick(0.9, 0.0, 0.7, true, false);
let _refs = eng.tick(0.9, 0.0, 0.7, true, false);
assert!(eng.is_firing(InstinctType::Cooperate));
}

#[test]
fn engine_teach_with_very_high_trust() {
let mut eng = InstinctEngine::new(Thresholds::default());
let refs = eng.tick(0.9, 0.0, 0.9, true, false);
let _refs = eng.tick(0.9, 0.0, 0.9, true, false);
assert!(eng.is_firing(InstinctType::Teach));
}

Expand All @@ -106,15 +106,15 @@ mod tests {
#[test]
fn engine_guard_when_has_work() {
let mut eng = InstinctEngine::new(Thresholds::default());
let refs = eng.tick(0.8, 0.0, 0.0, true, true);
let _refs = eng.tick(0.8, 0.0, 0.0, true, true);
assert!(eng.is_firing(InstinctType::Guard));
}

#[test]
fn engine_mourn_on_peer_death() {
let mut eng = InstinctEngine::new(Thresholds::default());
eng.tick(0.8, 0.0, 0.0, true, false); // peer alive
let refs = eng.tick(0.8, 0.0, 0.0, false, false); // peer dies
let _refs = eng.tick(0.8, 0.0, 0.0, false, false); // peer dies
assert!(eng.is_firing(InstinctType::Mourn));
}

Expand Down
Loading