1
0
mirror of https://github.com/janet-lang/janet synced 2024-11-24 17:27:18 +00:00

Merge pull request #340 from pepe/get-vs-in-last

Fix last for empty collection, add tests
This commit is contained in:
Calvin Rose 2020-04-10 19:03:21 -05:00 committed by GitHub
commit 1d13095d19
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 5 additions and 1 deletions

View File

@ -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)))
###
###

View File

@ -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)