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
12 changes: 9 additions & 3 deletions lib/src/module_extensions.dart
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright (C) 2024-2025 Intel Corporation
// Copyright (C) 2024-2026 Intel Corporation
// SPDX-License-Identifier: BSD-3-Clause
//
// module_extensions.dart
Expand Down Expand Up @@ -129,8 +129,9 @@ extension RohdBridgeModuleExtensions on Module {
}
}

/// Returns the common parent of two modules [firstChild] and [secondChild]
/// Assuming at least one common parent exists
/// Returns the common parent of two modules [firstChild] and [secondChild].
/// If the two modules are the same, returns that module.
/// If no common parent is found and they are not the same module, returns null.
Module? findCommonParent(Module firstChild, Module secondChild) {
final firstPath = List<Module>.from(firstChild.hierarchy(), growable: false);
final secondPath =
Expand All @@ -145,6 +146,11 @@ Module? findCommonParent(Module firstChild, Module secondChild) {
return null;
}

if (firstChild == secondChild) {
// if the two modules are the same, return that module as the common parent
Comment thread
sshankar4 marked this conversation as resolved.
return firstChild;
}

if (secondPath.contains(firstChild) && !firstPath.contains(secondChild)) {
// firstChild is in the parent hierarchy of second
return firstChild;
Expand Down
2 changes: 1 addition & 1 deletion lib/src/references/port_reference.dart
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright (C) 2024-2025 Intel Corporation
// Copyright (C) 2024-2026 Intel Corporation
// SPDX-License-Identifier: BSD-3-Clause
//
// port_reference.dart
Expand Down
2 changes: 1 addition & 1 deletion test/collapse_array_test.dart
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright (C) 2024-2025 Intel Corporation
// Copyright (C) 2024-2026 Intel Corporation
// SPDX-License-Identifier: BSD-3-Clause
//
// collapse_array_test.dart
Expand Down
12 changes: 11 additions & 1 deletion test/feedthrough_test.dart
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright (C) 2024-2025 Intel Corporation
// Copyright (C) 2024-2026 Intel Corporation
// SPDX-License-Identifier: BSD-3-Clause
//
// feedthrough_test.dart
Expand Down Expand Up @@ -44,4 +44,14 @@ void main() {

expect(testPass1 && testPass2, true);
});

test('Feedback connection', () {
final top = BridgeModule('Top')
..createPort('x', PortDirection.input)
..createPort('y', PortDirection.output);

connectPorts(top.port('x'), top.port('y'));
top.input('x').put(1);
expect(top.output('y').value.toInt(), 1);
});
}