mirror of
https://github.com/roc-lang/roc.git
synced 2025-12-23 08:48:03 +00:00
Builtins: add some repl snapshot tests for list get and list first
This commit is contained in:
parent
9388bbcac0
commit
c0657280a0
2 changed files with 53 additions and 0 deletions
25
test/snapshots/repl/list_first.md
Normal file
25
test/snapshots/repl/list_first.md
Normal 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
|
||||
28
test/snapshots/repl/list_get.md
Normal file
28
test/snapshots/repl/list_get.md
Normal 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
|
||||
Loading…
Add table
Add a link
Reference in a new issue