Builtins: add some repl snapshot tests for list get and list first

This commit is contained in:
Fabian Schmalzried 2025-11-30 14:53:29 +01:00
parent 9388bbcac0
commit c0657280a0
No known key found for this signature in database
GPG key ID: 11C09844D4A8A012
2 changed files with 53 additions and 0 deletions

View file

@ -0,0 +1,25 @@
# META
~~~ini
description=List.first - getting the first element of a list
type=repl
~~~
# SOURCE
~~~roc
» List.first([1, 2, 3])
» List.first(["hello", "world"])
» List.first(["hello"])
» List.first([])
» List.first(List.with_capacity(10))
~~~
# OUTPUT
Ok(1)
---
Ok("hello")
---
Ok("hello")
---
Err(ListWasEmpty)
---
Err(ListWasEmpty)
# PROBLEMS
NIL

View file

@ -0,0 +1,28 @@
# META
~~~ini
description=List.first - getting the first element of a list
type=repl
~~~
# SOURCE
~~~roc
» List.get([1, 2, 3], 0)
» List.get(["hello", "world"], 1)
» List.get([1, 2, 3, 4, 5, 6, 7, 8, 9, 10], 9)
» List.get(["hello"], 1)
» List.get([], 0)
» List.get(List.with_capacity(10), 5)
~~~
# OUTPUT
Ok(1)
---
Ok("world")
---
Ok(10)
---
Err(OutOfBounds)
---
Err(OutOfBounds)
---
Err(OutOfBounds)
# PROBLEMS
NIL