feat: add String.fromByte primitive with validation and unit tests
Implement a new String.fromByte(_) static method that creates a single-byte string from an integer 0-255. Includes runtime validation for non-integer, non-numeric, negative, and out-of-range values. Adds the underlying wrenStringFromByte helper in wren_value.c and exposes it via a new DEF_PRIMITIVE in wren_core.c. Documents the method in the core string markdown and provides six test cases covering happy path and all error conditions.
This commit is contained in:
@@ -57,6 +57,15 @@ Creates a new string containing the UTF-8 encoding of `codePoint`.
|
||||
It is a runtime error if `codePoint` is not an integer between `0` and
|
||||
`0x10ffff`, inclusive.
|
||||
|
||||
### String.**fromByte**(byte)
|
||||
|
||||
Creates a new string containing the single byte `byte`.
|
||||
|
||||
:::wren
|
||||
String.fromByte(255) //> �
|
||||
|
||||
It is a runtime error if `byte` is not an integer between `0` and `0xff`, inclusive.
|
||||
|
||||
## Methods
|
||||
|
||||
### **bytes**
|
||||
|
||||
Reference in New Issue
Block a user