File tree Expand file tree Collapse file tree 2 files changed +42
-1
lines changed Expand file tree Collapse file tree 2 files changed +42
-1
lines changed Original file line number Diff line number Diff line change 12
12
// See the License for the specific language governing permissions and
13
13
// limitations under the License.
14
14
15
+ #[ cfg( test) ]
16
+ mod tests;
17
+
15
18
use std:: fmt:: { Display , Formatter } ;
16
19
17
20
use swimos_form:: structural:: Tag ;
@@ -61,7 +64,10 @@ impl WarpLaneKind {
61
64
62
65
pub fn uplink_kind ( & self ) -> UplinkKind {
63
66
match self {
64
- WarpLaneKind :: Map | WarpLaneKind :: DemandMap | WarpLaneKind :: JoinMap => UplinkKind :: Map ,
67
+ WarpLaneKind :: Map
68
+ | WarpLaneKind :: DemandMap
69
+ | WarpLaneKind :: JoinMap
70
+ | WarpLaneKind :: JoinValue => UplinkKind :: Map ,
65
71
WarpLaneKind :: Supply => UplinkKind :: Supply ,
66
72
WarpLaneKind :: Spatial => todo ! ( "Spatial uplinks not supported." ) ,
67
73
_ => UplinkKind :: Value ,
Original file line number Diff line number Diff line change
1
+ use crate :: agent:: UplinkKind ;
2
+ use crate :: lane:: WarpLaneKind ;
3
+
4
+ // spatial lanes are omitted as they are unimplemented
5
+ const LANE_KINDS : [ WarpLaneKind ; 8 ] = [
6
+ WarpLaneKind :: Command ,
7
+ WarpLaneKind :: Demand ,
8
+ WarpLaneKind :: DemandMap ,
9
+ WarpLaneKind :: Map ,
10
+ WarpLaneKind :: JoinMap ,
11
+ WarpLaneKind :: JoinValue ,
12
+ WarpLaneKind :: Supply ,
13
+ WarpLaneKind :: Value ,
14
+ ] ;
15
+
16
+ #[ test]
17
+ fn uplink_kinds ( ) {
18
+ for kind in LANE_KINDS {
19
+ let uplink_kind = kind. uplink_kind ( ) ;
20
+ if kind. map_like ( ) {
21
+ assert_eq ! ( uplink_kind, UplinkKind :: Map ) ;
22
+ } else if matches ! ( kind, WarpLaneKind :: Supply ) {
23
+ assert_eq ! ( uplink_kind, UplinkKind :: Supply ) ;
24
+ } else {
25
+ assert_eq ! ( uplink_kind, UplinkKind :: Value )
26
+ }
27
+ }
28
+ }
29
+
30
+ // this is here for when spatial lanes are implemented as the test will no longer panic
31
+ #[ test]
32
+ #[ should_panic]
33
+ fn spatial_uplink_kind ( ) {
34
+ WarpLaneKind :: Spatial . uplink_kind ( ) ;
35
+ }
You can’t perform that action at this time.
0 commit comments