mirror of
https://github.com/janet-lang/janet
synced 2024-11-28 11:09:54 +00:00
Fix last for empty collection, add tests
This commit is contained in:
parent
e6d4e729fb
commit
b63a0796fd
@ -648,7 +648,7 @@
|
|||||||
(defn last
|
(defn last
|
||||||
"Get the last element from an indexed data structure."
|
"Get the last element from an indexed data structure."
|
||||||
[xs]
|
[xs]
|
||||||
(in xs (- (length xs) 1)))
|
(get xs (- (length xs) 1)))
|
||||||
|
|
||||||
###
|
###
|
||||||
###
|
###
|
||||||
|
@ -237,4 +237,8 @@ neldb\0\0\0\xD8\x05printG\x01\0\xDE\xDE\xDE'\x03\0marshal_tes/\x02
|
|||||||
load-image-dict))
|
load-image-dict))
|
||||||
(gccollect)
|
(gccollect)
|
||||||
|
|
||||||
|
# in vs get regression
|
||||||
|
(assert (nil? (first @"")) "in vs get 1")
|
||||||
|
(assert (nil? (last @"")) "in vs get 1")
|
||||||
|
|
||||||
(end-suite)
|
(end-suite)
|
||||||
|
Loading…
Reference in New Issue
Block a user