diff --git a/Iceberg-Tests.package/IceTreeTests.class/instance/testDetectFoundElement.st b/Iceberg-Tests.package/IceTreeTests.class/instance/testDetectFoundElement.st new file mode 100644 index 0000000000..c8f55eec02 --- /dev/null +++ b/Iceberg-Tests.package/IceTreeTests.class/instance/testDetectFoundElement.st @@ -0,0 +1,7 @@ +tests +testDetectFoundElement + + | selected | + selected := (IceNode value: 2) detect: [ :e | e value even ]. + + self assert: selected equals: 2 \ No newline at end of file diff --git a/Iceberg-Tests.package/IceTreeTests.class/instance/testDetectNotFoundElement.st b/Iceberg-Tests.package/IceTreeTests.class/instance/testDetectNotFoundElement.st new file mode 100644 index 0000000000..0d368778e5 --- /dev/null +++ b/Iceberg-Tests.package/IceTreeTests.class/instance/testDetectNotFoundElement.st @@ -0,0 +1,3 @@ +tests +testDetectNotFoundElement + self should: [ (IceNode value: 1) detect: [ :e | e value even ] ] raise: NotFound \ No newline at end of file diff --git a/Iceberg.package/IceNode.class/instance/firstNodeSuchThat.ifNone..st b/Iceberg.package/IceNode.class/instance/firstNodeSuchThat.ifNone..st index dce4cf2cba..e7ee5eecb7 100644 --- a/Iceberg.package/IceNode.class/instance/firstNodeSuchThat.ifNone..st +++ b/Iceberg.package/IceNode.class/instance/firstNodeSuchThat.ifNone..st @@ -9,6 +9,9 @@ firstNodeSuchThat: conditionBlock ifNone: noneBlock ifFound: [ :found | ^ found ]. ^ self parent - nextChildNodeStartingFrom: self - suchThat: conditionBlock - ifNone: noneBlock \ No newline at end of file + ifNil: noneBlock + ifNotNil: [ + self parent + nextChildNodeStartingFrom: self + suchThat: conditionBlock + ifNone: noneBlock ] \ No newline at end of file