diff --git a/documentation/source/release-notes/2024.2.rst b/documentation/source/release-notes/2024.2.rst index 9f43db416..c6043de73 100644 --- a/documentation/source/release-notes/2024.2.rst +++ b/documentation/source/release-notes/2024.2.rst @@ -63,6 +63,12 @@ Tools Library Updates =============== +Dylan +----- + +* The return value of :drm:`push-last` on :drm:`` now matches + that specified in the Dylan Reference Manual. + IO ---- diff --git a/sources/dylan/deque.dylan b/sources/dylan/deque.dylan index 808f08c85..ce42c3bf9 100644 --- a/sources/dylan/deque.dylan +++ b/sources/dylan/deque.dylan @@ -517,7 +517,7 @@ end method pop; // define sealed inline method trusted-push-last - (deque :: , new-element) => (result :: ) + (deque :: , new-element) => (new-element) let rep = deque.representation; let rep-last-index = rep.last-index; while (rep-last-index = (rep.size - 1)) @@ -529,13 +529,13 @@ define sealed inline method trusted-push-last end while; rep.last-index := rep-last-index := rep-last-index + 1; island-deque-element(rep, rep-last-index) := new-element; - deque + new-element end method trusted-push-last; define sealed method push-last - (deque :: , new-element) => (result :: ) + (deque :: , new-element) => (new-element) check-type(new-element, element-type(deque)); - trusted-push-last(deque, new-element); + trusted-push-last(deque, new-element) end method push-last; diff --git a/sources/dylan/tests/collections.dylan b/sources/dylan/tests/collections.dylan index 50d764b4b..8720fea37 100644 --- a/sources/dylan/tests/collections.dylan +++ b/sources/dylan/tests/collections.dylan @@ -62,6 +62,22 @@ define test test- () test-collection-class(, instantiable?: #t); end; +define test test--functions () + let d = make-test-instance(); + for (i from 5 to 1 by -1) + check-equal("push returns new value", i, push(d, i)); + end for; + for (i from 6 to 10) + check-equal("push-last returns new value", i, push-last(d, i)); + end for; + check-equal("first pop is last item inserted at start", 1, pop(d)); + check-equal("first pop-last is last item inserted at end", 10, pop-last(d)); + check-true("add! returns argument", d == add!(d, 1)); + check-equal("add! added new element to front", 1, pop(d)); + check-true("remove! returns argument", d == remove!(d, 9)); + check-equal("remove! removed final element", 8, pop-last(d)); +end; + define test test- () test-collection-class(, instantiable?: #t); end; @@ -108,6 +124,7 @@ define suite dylan-collections-test-suite () test test-; test test-; test test-; + test test--functions; test test-; test test-; test test-;