mirror of
https://github.com/roc-lang/roc.git
synced 2025-12-23 08:48:03 +00:00
Merge pull request #8442 from roc-lang/builtin-str-impls2
More Builtin `Str` implementations
This commit is contained in:
commit
f0310302f3
14 changed files with 736 additions and 9 deletions
|
|
@ -89,7 +89,12 @@ DOES NOT EXIST - Color.md:51:75:51:85
|
|||
DOES NOT EXIST - Color.md:51:93:51:103
|
||||
DOES NOT EXIST - Color.md:68:14:68:27
|
||||
MISSING METHOD - Color.md:22:17:22:24
|
||||
MISSING METHOD - Color.md:29:17:29:24
|
||||
MISSING METHOD - Color.md:35:19:35:39
|
||||
MISSING METHOD - Color.md:36:23:36:43
|
||||
MISSING METHOD - Color.md:37:23:37:43
|
||||
MISSING METHOD - Color.md:38:23:38:43
|
||||
MISSING METHOD - Color.md:39:23:39:43
|
||||
MISSING METHOD - Color.md:40:23:40:43
|
||||
TYPE MISMATCH - Color.md:32:5:45:6
|
||||
MISSING METHOD - Color.md:62:12:62:26
|
||||
MISSING METHOD - Color.md:56:26:56:32
|
||||
|
|
@ -224,18 +229,88 @@ The value's type, which does not have a method named **to_frac**, is:
|
|||
**Hint: **For this to work, the type would need to have a method named **to_frac** associated with it in the type's declaration.
|
||||
|
||||
**MISSING METHOD**
|
||||
This **to_utf8** method is being called on a value whose type doesn't have that method:
|
||||
**Color.md:29:17:29:24:**
|
||||
This **is_char_in_hex_range** method is being called on a value whose type doesn't have that method:
|
||||
**Color.md:35:19:35:39:**
|
||||
```roc
|
||||
bytes = str.to_utf8()
|
||||
a.is_char_in_hex_range()
|
||||
```
|
||||
^^^^^^^
|
||||
^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
The value's type, which does not have a method named **to_utf8**, is:
|
||||
The value's type, which does not have a method named **is_char_in_hex_range**, is:
|
||||
|
||||
_Str_
|
||||
_U8_
|
||||
|
||||
**Hint: **For this to work, the type would need to have a method named **to_utf8** associated with it in the type's declaration.
|
||||
**Hint: **For this to work, the type would need to have a method named **is_char_in_hex_range** associated with it in the type's declaration.
|
||||
|
||||
**MISSING METHOD**
|
||||
This **is_char_in_hex_range** method is being called on a value whose type doesn't have that method:
|
||||
**Color.md:36:23:36:43:**
|
||||
```roc
|
||||
and b.is_char_in_hex_range()
|
||||
```
|
||||
^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
The value's type, which does not have a method named **is_char_in_hex_range**, is:
|
||||
|
||||
_U8_
|
||||
|
||||
**Hint: **For this to work, the type would need to have a method named **is_char_in_hex_range** associated with it in the type's declaration.
|
||||
|
||||
**MISSING METHOD**
|
||||
This **is_char_in_hex_range** method is being called on a value whose type doesn't have that method:
|
||||
**Color.md:37:23:37:43:**
|
||||
```roc
|
||||
and c.is_char_in_hex_range()
|
||||
```
|
||||
^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
The value's type, which does not have a method named **is_char_in_hex_range**, is:
|
||||
|
||||
_U8_
|
||||
|
||||
**Hint: **For this to work, the type would need to have a method named **is_char_in_hex_range** associated with it in the type's declaration.
|
||||
|
||||
**MISSING METHOD**
|
||||
This **is_char_in_hex_range** method is being called on a value whose type doesn't have that method:
|
||||
**Color.md:38:23:38:43:**
|
||||
```roc
|
||||
and d.is_char_in_hex_range()
|
||||
```
|
||||
^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
The value's type, which does not have a method named **is_char_in_hex_range**, is:
|
||||
|
||||
_U8_
|
||||
|
||||
**Hint: **For this to work, the type would need to have a method named **is_char_in_hex_range** associated with it in the type's declaration.
|
||||
|
||||
**MISSING METHOD**
|
||||
This **is_char_in_hex_range** method is being called on a value whose type doesn't have that method:
|
||||
**Color.md:39:23:39:43:**
|
||||
```roc
|
||||
and e.is_char_in_hex_range()
|
||||
```
|
||||
^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
The value's type, which does not have a method named **is_char_in_hex_range**, is:
|
||||
|
||||
_U8_
|
||||
|
||||
**Hint: **For this to work, the type would need to have a method named **is_char_in_hex_range** associated with it in the type's declaration.
|
||||
|
||||
**MISSING METHOD**
|
||||
This **is_char_in_hex_range** method is being called on a value whose type doesn't have that method:
|
||||
**Color.md:40:23:40:43:**
|
||||
```roc
|
||||
and f.is_char_in_hex_range()
|
||||
```
|
||||
^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
The value's type, which does not have a method named **is_char_in_hex_range**, is:
|
||||
|
||||
_U8_
|
||||
|
||||
**Hint: **For this to work, the type would need to have a method named **is_char_in_hex_range** associated with it in the type's declaration.
|
||||
|
||||
**TYPE MISMATCH**
|
||||
This expression is used in an unexpected way:
|
||||
|
|
|
|||
25
test/snapshots/repl/str_count_utf8_bytes.md
Normal file
25
test/snapshots/repl/str_count_utf8_bytes.md
Normal file
|
|
@ -0,0 +1,25 @@
|
|||
# META
|
||||
~~~ini
|
||||
description=Str.count_utf8_bytes should return the number of bytes in the string
|
||||
type=repl
|
||||
~~~
|
||||
# SOURCE
|
||||
~~~roc
|
||||
» Str.count_utf8_bytes("")
|
||||
» Str.count_utf8_bytes("hello")
|
||||
» Str.count_utf8_bytes("hello world")
|
||||
» Str.count_utf8_bytes("é")
|
||||
» Str.count_utf8_bytes("🎉")
|
||||
~~~
|
||||
# OUTPUT
|
||||
0
|
||||
---
|
||||
5
|
||||
---
|
||||
11
|
||||
---
|
||||
2
|
||||
---
|
||||
4
|
||||
# PROBLEMS
|
||||
NIL
|
||||
25
test/snapshots/repl/str_from_utf8_lossy.md
Normal file
25
test/snapshots/repl/str_from_utf8_lossy.md
Normal file
|
|
@ -0,0 +1,25 @@
|
|||
# META
|
||||
~~~ini
|
||||
description=Str.from_utf8_lossy should convert a list of UTF-8 bytes to a string
|
||||
type=repl
|
||||
~~~
|
||||
# SOURCE
|
||||
~~~roc
|
||||
» Str.from_utf8_lossy(Str.to_utf8(""))
|
||||
» Str.from_utf8_lossy(Str.to_utf8("hello"))
|
||||
» Str.from_utf8_lossy(Str.to_utf8("hello world"))
|
||||
» Str.from_utf8_lossy(Str.to_utf8("é"))
|
||||
» Str.from_utf8_lossy(Str.to_utf8("🎉"))
|
||||
~~~
|
||||
# OUTPUT
|
||||
""
|
||||
---
|
||||
"hello"
|
||||
---
|
||||
"hello world"
|
||||
---
|
||||
"é"
|
||||
---
|
||||
"🎉"
|
||||
# PROBLEMS
|
||||
NIL
|
||||
22
test/snapshots/repl/str_join_with.md
Normal file
22
test/snapshots/repl/str_join_with.md
Normal file
|
|
@ -0,0 +1,22 @@
|
|||
# META
|
||||
~~~ini
|
||||
description=Str.join_with should join strings with a separator
|
||||
type=repl
|
||||
~~~
|
||||
# SOURCE
|
||||
~~~roc
|
||||
» Str.join_with(["hello", "world"], " ")
|
||||
» Str.join_with(["a", "b", "c"], ",")
|
||||
» Str.join_with(["single"], "-")
|
||||
» Str.join_with([], ",")
|
||||
~~~
|
||||
# OUTPUT
|
||||
"hello world"
|
||||
---
|
||||
"a,b,c"
|
||||
---
|
||||
"single"
|
||||
---
|
||||
""
|
||||
# PROBLEMS
|
||||
NIL
|
||||
19
test/snapshots/repl/str_release_excess_capacity.md
Normal file
19
test/snapshots/repl/str_release_excess_capacity.md
Normal file
|
|
@ -0,0 +1,19 @@
|
|||
# META
|
||||
~~~ini
|
||||
description=Str.release_excess_capacity should return the same string with excess capacity released
|
||||
type=repl
|
||||
~~~
|
||||
# SOURCE
|
||||
~~~roc
|
||||
» Str.release_excess_capacity("hello")
|
||||
» Str.release_excess_capacity("")
|
||||
» Str.release_excess_capacity("hello world")
|
||||
~~~
|
||||
# OUTPUT
|
||||
"hello"
|
||||
---
|
||||
""
|
||||
---
|
||||
"hello world"
|
||||
# PROBLEMS
|
||||
NIL
|
||||
19
test/snapshots/repl/str_reserve.md
Normal file
19
test/snapshots/repl/str_reserve.md
Normal file
|
|
@ -0,0 +1,19 @@
|
|||
# META
|
||||
~~~ini
|
||||
description=Str.reserve should return the same string with additional capacity reserved
|
||||
type=repl
|
||||
~~~
|
||||
# SOURCE
|
||||
~~~roc
|
||||
» Str.reserve("hello", 0)
|
||||
» Str.reserve("hello", 10)
|
||||
» Str.reserve("", 100)
|
||||
~~~
|
||||
# OUTPUT
|
||||
"hello"
|
||||
---
|
||||
"hello"
|
||||
---
|
||||
""
|
||||
# PROBLEMS
|
||||
NIL
|
||||
22
test/snapshots/repl/str_split_on.md
Normal file
22
test/snapshots/repl/str_split_on.md
Normal file
|
|
@ -0,0 +1,22 @@
|
|||
# META
|
||||
~~~ini
|
||||
description=Str.split_on should split a string on a delimiter
|
||||
type=repl
|
||||
~~~
|
||||
# SOURCE
|
||||
~~~roc
|
||||
» List.len(Str.split_on("hello world", " "))
|
||||
» List.len(Str.split_on("a,b,c", ","))
|
||||
» List.len(Str.split_on("no match", "x"))
|
||||
» List.len(Str.split_on("", ","))
|
||||
~~~
|
||||
# OUTPUT
|
||||
2
|
||||
---
|
||||
3
|
||||
---
|
||||
1
|
||||
---
|
||||
1
|
||||
# PROBLEMS
|
||||
NIL
|
||||
22
test/snapshots/repl/str_to_utf8.md
Normal file
22
test/snapshots/repl/str_to_utf8.md
Normal file
|
|
@ -0,0 +1,22 @@
|
|||
# META
|
||||
~~~ini
|
||||
description=Str.to_utf8 should convert a string to a list of UTF-8 bytes
|
||||
type=repl
|
||||
~~~
|
||||
# SOURCE
|
||||
~~~roc
|
||||
» List.len(Str.to_utf8(""))
|
||||
» List.len(Str.to_utf8("hello"))
|
||||
» List.len(Str.to_utf8("é"))
|
||||
» List.len(Str.to_utf8("🎉"))
|
||||
~~~
|
||||
# OUTPUT
|
||||
0
|
||||
---
|
||||
5
|
||||
---
|
||||
2
|
||||
---
|
||||
4
|
||||
# PROBLEMS
|
||||
NIL
|
||||
19
test/snapshots/repl/str_with_capacity.md
Normal file
19
test/snapshots/repl/str_with_capacity.md
Normal file
|
|
@ -0,0 +1,19 @@
|
|||
# META
|
||||
~~~ini
|
||||
description=Str.with_capacity should create an empty string with preallocated capacity
|
||||
type=repl
|
||||
~~~
|
||||
# SOURCE
|
||||
~~~roc
|
||||
» Str.with_capacity(0)
|
||||
» Str.with_capacity(10)
|
||||
» Str.with_capacity(100)
|
||||
~~~
|
||||
# OUTPUT
|
||||
""
|
||||
---
|
||||
""
|
||||
---
|
||||
""
|
||||
# PROBLEMS
|
||||
NIL
|
||||
Loading…
Add table
Add a link
Reference in a new issue