Skip to content

Commit

Permalink
Add ReadOutputOfContainedBank unit test for Rust
Browse files Browse the repository at this point in the history
Fails right now due to what appears to be a scheduling error
  • Loading branch information
jhaye committed Jul 28, 2022
1 parent 7bc147e commit e7d7379
Showing 1 changed file with 56 additions and 0 deletions.
56 changes: 56 additions & 0 deletions test/Rust/src/multiport/ReadOutputOfContainedBank.lf
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
// Test reacting to and reading outputs from a contained
// reactor bank in various permutations.
target Rust;
reactor Contained(bank_index:usize(0)) {
state bank_index(bank_index);

output out:usize;
reaction(startup) -> out {=
ctx.set(out, 42 * self.bank_index);
=}
}

main reactor {
c = new[4] Contained();
state count:usize(0);
reaction(startup) c.out {=
for i in 0..c__out.len() {
let result = ctx.get(&c__out.get(i)).unwrap();
println!("Startup reaction reading output of contained reactor: {}", result);
if result != 42 * i {
println!("FAILURE: expected {}", 42 * i);
std::process::exit(2);
}
}
self.count += 1;
=}
reaction(c.out) {=
for i in 0..c__out.len() {
let result = ctx.get(&c__out.get(i)).unwrap();
println!("Reading output of contained reactor: {}", result);
if result != 42 * i {
println!("FAILURE: expected {}", 42 * i);
std::process::exit(2);
}
}
self.count += 1;
=}
reaction(startup, c.out) {=
for i in 0..c__out.len() {
let result = ctx.get(&c__out.get(i)).unwrap();
println!("Alternate triggering reading output of contained reactor: {}", result);
if result != 42 * i {
println!("FAILURE: expected {}", 42 * i);
std::process::exit(2);
}
}
self.count += 1;
=}
reaction(shutdown) {=
if self.count != 3 {
println!("count: {}", self.count);
println!("ERROR: One of the reactions failed to trigger.");
std::process::exit(1);
}
=}
}

0 comments on commit e7d7379

Please # to comment.