Skip to content

Commit 6468464

Browse files
committed
Fix to Signals_test
1 parent e4397d9 commit 6468464

File tree

2 files changed

+41
-68
lines changed

2 files changed

+41
-68
lines changed

CHANGELOG.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
11
# Changelog
22

3-
## [Latest](https://github.com/cortex-lab/signals/commits/master) [1.3.0]
3+
## [Latest](https://github.com/cortex-lab/signals/commits/master) [1.3.1]
4+
5+
- HOTFIX: Duplicate test name in Signals_test; added test for `then` method
6+
7+
## [1.3.0]
48

59
- vis.checker6 is renamed to vis.checker, all others have been removed
610
- A new filter method was added that filters its input signal's values using a function handle

tests/Signals_test.m

Lines changed: 36 additions & 67 deletions
Original file line numberDiff line numberDiff line change
@@ -738,103 +738,72 @@ function test_at(testCase)
738738
s = a.at(b);
739739
testCase.verifyMatches(s.Name, '\w.at(\w+\)', 'Unexpected Name')
740740

741-
% Post a value to signal a
742-
v = rand;
743-
affectedIdxs = submit(testCase.net.Id, a.Node.Id, v);
744-
changed = applyNodes(testCase.net.Id, affectedIdxs);
745-
% Check only a changed
746-
testCase.verifyTrue(isequal(affectedIdxs, changed, a.Node.Id), ...
747-
'Unexpected network behaviour upon posting value to signal a')
748-
749-
% Post a truthy value to b
750-
affectedIdxs = submit(testCase.net.Id, b.Node.Id, true);
751-
changed = applyNodes(testCase.net.Id, affectedIdxs);
752-
% Check b and s nodes changed
753-
testCase.verifyTrue(isequal(affectedIdxs, changed, [b.Node.Id;s.Node.Id]), ...
754-
'Unexpected network behaviour upon posting value to signal b')
755-
testCase.verifyTrue(isequal(v, a.Node.CurrValue, s.Node.CurrValue), ...
756-
'Unexpected values of signals a and s')
757-
758-
% Post a value to signal a
759-
v = rand;
760-
affectedIdxs = submit(testCase.net.Id, a.Node.Id, v);
761-
changed = applyNodes(testCase.net.Id, affectedIdxs);
762-
% Check only a's node affected: unlike keepwhen, s will not be
763-
% updated as b (dispite being true) has not changed since last update
764-
testCase.verifyTrue(isequal(affectedIdxs, changed, a.Node.Id), ...
765-
'Unexpected network behaviour upon posting value to signal a')
766-
testCase.verifyTrue(v == a.Node.CurrValue && s.Node.CurrValue ~= v, ...
767-
'Unexpected values of signals a and s')
768-
769-
% Post a non-truthy value to b
770-
affectedIdxs = submit(testCase.net.Id, b.Node.Id, false);
771-
changed = applyNodes(testCase.net.Id, affectedIdxs);
772-
% Check only b's node affected
773-
testCase.verifyTrue(isequal(affectedIdxs, changed, b.Node.Id), ...
774-
'Unexpected nodes affected when predicate signal false')
775-
776-
% Post a value to signal a
777-
v = rand;
778-
affectedIdxs = submit(testCase.net.Id, a.Node.Id, v);
779-
changed = applyNodes(testCase.net.Id, affectedIdxs);
780-
% Check only a's node affected
781-
testCase.verifyTrue(isequal(affectedIdxs, changed, a.Node.Id), ...
782-
'Unexpected network behaviour upon posting value to signal a')
783-
testCase.verifyTrue(v == a.Node.CurrValue && s.Node.CurrValue ~= v, ...
784-
'Unexpected values of signals a and s')
741+
testCase.at_then_test(s)
785742
end
786743

787-
function test_at(testCase)
788-
% Test for the at method
744+
function test_then(testCase)
745+
% Test for the then method
789746
[a, b] = deal(testCase.A, testCase.B);
790-
s = a.at(b);
791-
testCase.verifyMatches(s.Name, '\w.at(\w+\)', 'Unexpected Name')
747+
s = b.then(a);
748+
testCase.verifyMatches(s.Name, '\w.then(\w+\)', 'Unexpected Name')
792749

793-
% Post a value to signal a
750+
testCase.at_then_test(s)
751+
end
752+
753+
end
754+
755+
methods (Access = private)
756+
function at_then_test(testCase, s)
757+
% AT_THEN_TEST Common tests for `at` and `then` methods
758+
% This function is called by both the test_at and test_then methods
759+
760+
[parent, child] = distribute(s.Node.Inputs);
761+
762+
% Post a value to parent node (a)
794763
v = rand;
795-
affectedIdxs = submit(testCase.net, a.Node.Id, v);
764+
affectedIdxs = submit(testCase.net, parent.Id, v);
796765
changed = applyNodes(testCase.net, affectedIdxs);
797766
% Check only a changed
798-
testCase.verifyTrue(isequal(affectedIdxs, changed, a.Node.Id), ...
767+
testCase.verifyTrue(isequal(affectedIdxs, changed, parent.Id), ...
799768
'Unexpected network behaviour upon posting value to signal a')
800769

801-
% Post a truthy value to b
802-
affectedIdxs = submit(testCase.net, b.Node.Id, true);
770+
% Post a truthy value to child node (b)
771+
affectedIdxs = submit(testCase.net, child.Id, true);
803772
changed = applyNodes(testCase.net, affectedIdxs);
804773
% Check b and s nodes changed
805-
testCase.verifyTrue(isequal(affectedIdxs, changed, [b.Node.Id;s.Node.Id]), ...
774+
testCase.verifyTrue(isequal(affectedIdxs, changed, [child.Id;s.Node.Id]), ...
806775
'Unexpected network behaviour upon posting value to signal b')
807-
testCase.verifyTrue(isequal(v, a.Node.CurrValue, s.Node.CurrValue), ...
776+
testCase.verifyTrue(isequal(v, parent.CurrValue, s.Node.CurrValue), ...
808777
'Unexpected values of signals a and s')
809778

810-
% Post a value to signal a
779+
% Post a value to signal parent node (a)
811780
v = rand;
812-
affectedIdxs = submit(testCase.net, a.Node.Id, v);
781+
affectedIdxs = submit(testCase.net, parent.Id, v);
813782
changed = applyNodes(testCase.net, affectedIdxs);
814783
% Check only a's node affected: unlike keepwhen, s will not be
815784
% updated as b (dispite being true) has not changed since last update
816-
testCase.verifyTrue(isequal(affectedIdxs, changed, a.Node.Id), ...
785+
testCase.verifyTrue(isequal(affectedIdxs, changed, parent.Id), ...
817786
'Unexpected network behaviour upon posting value to signal a')
818-
testCase.verifyTrue(v == a.Node.CurrValue && s.Node.CurrValue ~= v, ...
787+
testCase.verifyTrue(v == parent.CurrValue && s.Node.CurrValue ~= v, ...
819788
'Unexpected values of signals a and s')
820789

821-
% Post a non-truthy value to b
822-
affectedIdxs = submit(testCase.net, b.Node.Id, false);
790+
% Post a non-truthy value to child node (b)
791+
affectedIdxs = submit(testCase.net, child.Id, false);
823792
changed = applyNodes(testCase.net, affectedIdxs);
824793
% Check only b's node affected
825-
testCase.verifyTrue(isequal(affectedIdxs, changed, b.Node.Id), ...
794+
testCase.verifyTrue(isequal(affectedIdxs, changed, child.Id), ...
826795
'Unexpected nodes affected when predicate signal false')
827796

828-
% Post a value to signal a
797+
% Post a value to signal parent node (a)
829798
v = rand;
830-
affectedIdxs = submit(testCase.net, a.Node.Id, v);
799+
affectedIdxs = submit(testCase.net, parent.Id, v);
831800
changed = applyNodes(testCase.net, affectedIdxs);
832801
% Check only a's node affected
833-
testCase.verifyTrue(isequal(affectedIdxs, changed, a.Node.Id), ...
802+
testCase.verifyTrue(isequal(affectedIdxs, changed, parent.Id), ...
834803
'Unexpected network behaviour upon posting value to signal a')
835-
testCase.verifyTrue(v == a.Node.CurrValue && s.Node.CurrValue ~= v, ...
804+
testCase.verifyTrue(v == parent.CurrValue && s.Node.CurrValue ~= v, ...
836805
'Unexpected values of signals a and s')
837806
end
838-
807+
839808
end
840809
end

0 commit comments

Comments
 (0)