Skip to content

Commit

Permalink
Add WriteInputOfContainedBank unit test for Rust
Browse files Browse the repository at this point in the history
  • Loading branch information
jhaye committed Aug 11, 2022
1 parent a38447c commit ba624f1
Showing 1 changed file with 32 additions and 0 deletions.
32 changes: 32 additions & 0 deletions test/Rust/src/multiport/WriteInputOfContainedBank.lf
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
// Test writing inputs to a contained reactor bank
target Rust;
reactor Contained(bank_index:usize(0)) {
state bank_index(bank_index);

input inpt:usize;
state count:usize(0);
reaction(inpt) {=
let result = ctx.get(inpt).unwrap();
println!("Instance {} received {}", self.bank_index, result);
if result != self.bank_index * 42 {
println!("FAILURE: expected {}", 42* self.bank_index);
std::process::exit(2);
}
self.count += 1;
=}
reaction(shutdown) {=
if self.count != 1 {
eprintln!("ERROR: One of the reactions failed to trigger.");
std::process::exit(1);
}
=}
}

main reactor {
c = new[4] Contained();
reaction(startup) -> c.inpt {=
for i in 0..c__inpt.len() {
ctx.set(c__inpt.get(i), i * 42);
}
=}
}

0 comments on commit ba624f1

Please sign in to comment.