|
| 1 | +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT |
| 2 | +// file at the top-level directory of this distribution and at |
| 3 | +// http://rust-lang.org/COPYRIGHT. |
| 4 | +// |
| 5 | +// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or |
| 6 | +// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license |
| 7 | +// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your |
| 8 | +// option. This file may not be copied, modified, or distributed |
| 9 | +// except according to those terms. |
| 10 | + |
1 | 11 | use super::*;
|
2 | 12 |
|
3 | 13 | #[test]
|
@@ -45,12 +55,17 @@ fn edge_order1() {
|
45 | 55 | let mut reduce = GraphReduce::new(&graph, |n| inputs.contains(n), |n| outputs.contains(n));
|
46 | 56 | Classify::new(&mut reduce).walk();
|
47 | 57 |
|
48 |
| - assert!(reduce.in_cycle(nodes("B"), nodes("C"))); |
49 |
| - |
50 |
| - assert!(!reduce.in_cycle(nodes("IN"), nodes("A"))); |
51 |
| - assert!(!reduce.in_cycle(nodes("IN"), nodes("B"))); |
52 |
| - assert!(!reduce.in_cycle(nodes("IN"), nodes("C"))); |
53 |
| - assert!(!reduce.in_cycle(nodes("IN"), nodes("OUT"))); |
| 58 | + // A, B, and C are mutually in a cycle, but IN/OUT are not participating. |
| 59 | + let names = ["A", "B", "C", "IN", "OUT"]; |
| 60 | + let cycle_names = ["A", "B", "C"]; |
| 61 | + for &i in &names { |
| 62 | + for &j in names.iter().filter(|&&j| j != i) { |
| 63 | + let in_cycle = cycle_names.contains(&i) && cycle_names.contains(&j); |
| 64 | + assert_eq!(reduce.in_cycle(nodes(i), nodes(j)), in_cycle, |
| 65 | + "cycle status for nodes {} and {} is incorrect", |
| 66 | + i, j); |
| 67 | + } |
| 68 | + } |
54 | 69 | }
|
55 | 70 |
|
56 | 71 | /// Same as `edge_order1` but in reverse order so as to detect a failure
|
|
0 commit comments