From b63a0796fd781b39dea48b6b919e8d63c2d7e185 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Josef=20Pospi=CC=81s=CC=8Cil?= Date: Thu, 9 Apr 2020 14:35:57 +0200 Subject: [PATCH] Fix last for empty collection, add tests --- src/boot/boot.janet | 2 +- test/suite8.janet | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/src/boot/boot.janet b/src/boot/boot.janet index 7332b428..26e99b47 100644 --- a/src/boot/boot.janet +++ b/src/boot/boot.janet @@ -648,7 +648,7 @@ (defn last "Get the last element from an indexed data structure." [xs] - (in xs (- (length xs) 1))) + (get xs (- (length xs) 1))) ### ### diff --git a/test/suite8.janet b/test/suite8.janet index 5accdcc0..591427ee 100644 --- a/test/suite8.janet +++ b/test/suite8.janet @@ -237,4 +237,8 @@ neldb\0\0\0\xD8\x05printG\x01\0\xDE\xDE\xDE'\x03\0marshal_tes/\x02 load-image-dict)) (gccollect) +# in vs get regression +(assert (nil? (first @"")) "in vs get 1") +(assert (nil? (last @"")) "in vs get 1") + (end-suite)