mirror of
https://github.com/roc-lang/roc.git
synced 2025-08-03 11:52:19 +00:00
Rename trimLeft to trimStart and trimRight to trimEnd
This commit is contained in:
parent
d10d71cdec
commit
97fa6758d0
16 changed files with 110 additions and 110 deletions
|
@ -171,8 +171,8 @@ comptime {
|
||||||
exportStrFn(str.fromUtf8RangeC, "from_utf8_range");
|
exportStrFn(str.fromUtf8RangeC, "from_utf8_range");
|
||||||
exportStrFn(str.repeat, "repeat");
|
exportStrFn(str.repeat, "repeat");
|
||||||
exportStrFn(str.strTrim, "trim");
|
exportStrFn(str.strTrim, "trim");
|
||||||
exportStrFn(str.strTrimLeft, "trim_left");
|
exportStrFn(str.strTrimStart, "trim_start");
|
||||||
exportStrFn(str.strTrimRight, "trim_right");
|
exportStrFn(str.strTrimEnd, "trim_end");
|
||||||
exportStrFn(str.strCloneTo, "clone_to");
|
exportStrFn(str.strCloneTo, "clone_to");
|
||||||
exportStrFn(str.withCapacity, "with_capacity");
|
exportStrFn(str.withCapacity, "with_capacity");
|
||||||
exportStrFn(str.strGraphemes, "graphemes");
|
exportStrFn(str.strGraphemes, "graphemes");
|
||||||
|
|
|
@ -2302,7 +2302,7 @@ pub fn strTrim(input_string: RocStr) callconv(.C) RocStr {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn strTrimLeft(input_string: RocStr) callconv(.C) RocStr {
|
pub fn strTrimStart(input_string: RocStr) callconv(.C) RocStr {
|
||||||
var string = input_string;
|
var string = input_string;
|
||||||
|
|
||||||
if (string.isEmpty()) {
|
if (string.isEmpty()) {
|
||||||
|
@ -2350,7 +2350,7 @@ pub fn strTrimLeft(input_string: RocStr) callconv(.C) RocStr {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn strTrimRight(input_string: RocStr) callconv(.C) RocStr {
|
pub fn strTrimEnd(input_string: RocStr) callconv(.C) RocStr {
|
||||||
var string = input_string;
|
var string = input_string;
|
||||||
|
|
||||||
if (string.isEmpty()) {
|
if (string.isEmpty()) {
|
||||||
|
@ -2583,22 +2583,22 @@ test "strTrim: small to small" {
|
||||||
try expect(trimmed.isSmallStr());
|
try expect(trimmed.isSmallStr());
|
||||||
}
|
}
|
||||||
|
|
||||||
test "strTrimLeft: empty" {
|
test "strTrimStart: empty" {
|
||||||
const trimmedEmpty = strTrimLeft(RocStr.empty());
|
const trimmedEmpty = strTrimStart(RocStr.empty());
|
||||||
try expect(trimmedEmpty.eq(RocStr.empty()));
|
try expect(trimmedEmpty.eq(RocStr.empty()));
|
||||||
}
|
}
|
||||||
|
|
||||||
test "strTrimLeft: blank" {
|
test "strTrimStart: blank" {
|
||||||
const original_bytes = " ";
|
const original_bytes = " ";
|
||||||
const original = RocStr.init(original_bytes, original_bytes.len);
|
const original = RocStr.init(original_bytes, original_bytes.len);
|
||||||
defer original.decref();
|
defer original.decref();
|
||||||
|
|
||||||
const trimmed = strTrimLeft(original);
|
const trimmed = strTrimStart(original);
|
||||||
|
|
||||||
try expect(trimmed.eq(RocStr.empty()));
|
try expect(trimmed.eq(RocStr.empty()));
|
||||||
}
|
}
|
||||||
|
|
||||||
test "strTrimLeft: large to large" {
|
test "strTrimStart: large to large" {
|
||||||
const original_bytes = " hello even more giant world ";
|
const original_bytes = " hello even more giant world ";
|
||||||
const original = RocStr.init(original_bytes, original_bytes.len);
|
const original = RocStr.init(original_bytes, original_bytes.len);
|
||||||
defer original.decref();
|
defer original.decref();
|
||||||
|
@ -2611,12 +2611,12 @@ test "strTrimLeft: large to large" {
|
||||||
|
|
||||||
try expect(!expected.isSmallStr());
|
try expect(!expected.isSmallStr());
|
||||||
|
|
||||||
const trimmed = strTrimLeft(original);
|
const trimmed = strTrimStart(original);
|
||||||
|
|
||||||
try expect(trimmed.eq(expected));
|
try expect(trimmed.eq(expected));
|
||||||
}
|
}
|
||||||
|
|
||||||
test "strTrimLeft: large to small" {
|
test "strTrimStart: large to small" {
|
||||||
// `original` will be consumed by the concat; do not free explicitly
|
// `original` will be consumed by the concat; do not free explicitly
|
||||||
const original_bytes = " hello ";
|
const original_bytes = " hello ";
|
||||||
const original = RocStr.init(original_bytes, original_bytes.len);
|
const original = RocStr.init(original_bytes, original_bytes.len);
|
||||||
|
@ -2629,14 +2629,14 @@ test "strTrimLeft: large to small" {
|
||||||
|
|
||||||
try expect(expected.isSmallStr());
|
try expect(expected.isSmallStr());
|
||||||
|
|
||||||
const trimmed = strTrimLeft(original);
|
const trimmed = strTrimStart(original);
|
||||||
defer trimmed.decref();
|
defer trimmed.decref();
|
||||||
|
|
||||||
try expect(trimmed.eq(expected));
|
try expect(trimmed.eq(expected));
|
||||||
try expect(!trimmed.isSmallStr());
|
try expect(!trimmed.isSmallStr());
|
||||||
}
|
}
|
||||||
|
|
||||||
test "strTrimLeft: small to small" {
|
test "strTrimStart: small to small" {
|
||||||
const original_bytes = " hello ";
|
const original_bytes = " hello ";
|
||||||
const original = RocStr.init(original_bytes, original_bytes.len);
|
const original = RocStr.init(original_bytes, original_bytes.len);
|
||||||
defer original.decref();
|
defer original.decref();
|
||||||
|
@ -2649,28 +2649,28 @@ test "strTrimLeft: small to small" {
|
||||||
|
|
||||||
try expect(expected.isSmallStr());
|
try expect(expected.isSmallStr());
|
||||||
|
|
||||||
const trimmed = strTrimLeft(original);
|
const trimmed = strTrimStart(original);
|
||||||
|
|
||||||
try expect(trimmed.eq(expected));
|
try expect(trimmed.eq(expected));
|
||||||
try expect(trimmed.isSmallStr());
|
try expect(trimmed.isSmallStr());
|
||||||
}
|
}
|
||||||
|
|
||||||
test "strTrimRight: empty" {
|
test "strTrimEnd: empty" {
|
||||||
const trimmedEmpty = strTrimRight(RocStr.empty());
|
const trimmedEmpty = strTrimEnd(RocStr.empty());
|
||||||
try expect(trimmedEmpty.eq(RocStr.empty()));
|
try expect(trimmedEmpty.eq(RocStr.empty()));
|
||||||
}
|
}
|
||||||
|
|
||||||
test "strTrimRight: blank" {
|
test "strTrimEnd: blank" {
|
||||||
const original_bytes = " ";
|
const original_bytes = " ";
|
||||||
const original = RocStr.init(original_bytes, original_bytes.len);
|
const original = RocStr.init(original_bytes, original_bytes.len);
|
||||||
defer original.decref();
|
defer original.decref();
|
||||||
|
|
||||||
const trimmed = strTrimRight(original);
|
const trimmed = strTrimEnd(original);
|
||||||
|
|
||||||
try expect(trimmed.eq(RocStr.empty()));
|
try expect(trimmed.eq(RocStr.empty()));
|
||||||
}
|
}
|
||||||
|
|
||||||
test "strTrimRight: large to large" {
|
test "strTrimEnd: large to large" {
|
||||||
const original_bytes = " hello even more giant world ";
|
const original_bytes = " hello even more giant world ";
|
||||||
const original = RocStr.init(original_bytes, original_bytes.len);
|
const original = RocStr.init(original_bytes, original_bytes.len);
|
||||||
defer original.decref();
|
defer original.decref();
|
||||||
|
@ -2683,12 +2683,12 @@ test "strTrimRight: large to large" {
|
||||||
|
|
||||||
try expect(!expected.isSmallStr());
|
try expect(!expected.isSmallStr());
|
||||||
|
|
||||||
const trimmed = strTrimRight(original);
|
const trimmed = strTrimEnd(original);
|
||||||
|
|
||||||
try expect(trimmed.eq(expected));
|
try expect(trimmed.eq(expected));
|
||||||
}
|
}
|
||||||
|
|
||||||
test "strTrimRight: large to small" {
|
test "strTrimEnd: large to small" {
|
||||||
// `original` will be consumed by the concat; do not free explicitly
|
// `original` will be consumed by the concat; do not free explicitly
|
||||||
const original_bytes = " hello ";
|
const original_bytes = " hello ";
|
||||||
const original = RocStr.init(original_bytes, original_bytes.len);
|
const original = RocStr.init(original_bytes, original_bytes.len);
|
||||||
|
@ -2701,14 +2701,14 @@ test "strTrimRight: large to small" {
|
||||||
|
|
||||||
try expect(expected.isSmallStr());
|
try expect(expected.isSmallStr());
|
||||||
|
|
||||||
const trimmed = strTrimRight(original);
|
const trimmed = strTrimEnd(original);
|
||||||
defer trimmed.decref();
|
defer trimmed.decref();
|
||||||
|
|
||||||
try expect(trimmed.eq(expected));
|
try expect(trimmed.eq(expected));
|
||||||
try expect(!trimmed.isSmallStr());
|
try expect(!trimmed.isSmallStr());
|
||||||
}
|
}
|
||||||
|
|
||||||
test "strTrimRight: small to small" {
|
test "strTrimEnd: small to small" {
|
||||||
const original_bytes = " hello ";
|
const original_bytes = " hello ";
|
||||||
const original = RocStr.init(original_bytes, original_bytes.len);
|
const original = RocStr.init(original_bytes, original_bytes.len);
|
||||||
defer original.decref();
|
defer original.decref();
|
||||||
|
@ -2721,7 +2721,7 @@ test "strTrimRight: small to small" {
|
||||||
|
|
||||||
try expect(expected.isSmallStr());
|
try expect(expected.isSmallStr());
|
||||||
|
|
||||||
const trimmed = strTrimRight(original);
|
const trimmed = strTrimEnd(original);
|
||||||
|
|
||||||
try expect(trimmed.eq(expected));
|
try expect(trimmed.eq(expected));
|
||||||
try expect(trimmed.isSmallStr());
|
try expect(trimmed.isSmallStr());
|
||||||
|
|
|
@ -103,8 +103,8 @@ interface Str
|
||||||
startsWith,
|
startsWith,
|
||||||
endsWith,
|
endsWith,
|
||||||
trim,
|
trim,
|
||||||
trimLeft,
|
trimStart,
|
||||||
trimRight,
|
trimEnd,
|
||||||
toDec,
|
toDec,
|
||||||
toF64,
|
toF64,
|
||||||
toF32,
|
toF32,
|
||||||
|
@ -448,15 +448,15 @@ trim : Str -> Str
|
||||||
|
|
||||||
## Return the [Str] with all whitespace removed from the beginning.
|
## Return the [Str] with all whitespace removed from the beginning.
|
||||||
## ```
|
## ```
|
||||||
## expect Str.trimLeft " Hello \n\n" == "Hello \n\n"
|
## expect Str.trimStart " Hello \n\n" == "Hello \n\n"
|
||||||
## ```
|
## ```
|
||||||
trimLeft : Str -> Str
|
trimStart : Str -> Str
|
||||||
|
|
||||||
## Return the [Str] with all whitespace removed from the end.
|
## Return the [Str] with all whitespace removed from the end.
|
||||||
## ```
|
## ```
|
||||||
## expect Str.trimRight " Hello \n\n" == " Hello"
|
## expect Str.trimEnd " Hello \n\n" == " Hello"
|
||||||
## ```
|
## ```
|
||||||
trimRight : Str -> Str
|
trimEnd : Str -> Str
|
||||||
|
|
||||||
## Encode a [Str] to a [Dec]. A [Dec] value is a 128-bit decimal
|
## Encode a [Str] to a [Dec]. A [Dec] value is a 128-bit decimal
|
||||||
## [fixed-point number](https://en.wikipedia.org/wiki/Fixed-point_arithmetic).
|
## [fixed-point number](https://en.wikipedia.org/wiki/Fixed-point_arithmetic).
|
||||||
|
|
|
@ -339,8 +339,8 @@ pub const STR_TO_UTF8: &str = "roc_builtins.str.to_utf8";
|
||||||
pub const STR_FROM_UTF8_RANGE: &str = "roc_builtins.str.from_utf8_range";
|
pub const STR_FROM_UTF8_RANGE: &str = "roc_builtins.str.from_utf8_range";
|
||||||
pub const STR_REPEAT: &str = "roc_builtins.str.repeat";
|
pub const STR_REPEAT: &str = "roc_builtins.str.repeat";
|
||||||
pub const STR_TRIM: &str = "roc_builtins.str.trim";
|
pub const STR_TRIM: &str = "roc_builtins.str.trim";
|
||||||
pub const STR_TRIM_LEFT: &str = "roc_builtins.str.trim_left";
|
pub const STR_TRIM_START: &str = "roc_builtins.str.trim_start";
|
||||||
pub const STR_TRIM_RIGHT: &str = "roc_builtins.str.trim_right";
|
pub const STR_TRIM_END: &str = "roc_builtins.str.trim_end";
|
||||||
pub const STR_GET_UNSAFE: &str = "roc_builtins.str.get_unsafe";
|
pub const STR_GET_UNSAFE: &str = "roc_builtins.str.get_unsafe";
|
||||||
pub const STR_RESERVE: &str = "roc_builtins.str.reserve";
|
pub const STR_RESERVE: &str = "roc_builtins.str.reserve";
|
||||||
pub const STR_APPEND_SCALAR: &str = "roc_builtins.str.append_scalar";
|
pub const STR_APPEND_SCALAR: &str = "roc_builtins.str.append_scalar";
|
||||||
|
|
|
@ -118,8 +118,8 @@ map_symbol_to_lowlevel_and_arity! {
|
||||||
StrToUtf8; STR_TO_UTF8; 1,
|
StrToUtf8; STR_TO_UTF8; 1,
|
||||||
StrRepeat; STR_REPEAT; 2,
|
StrRepeat; STR_REPEAT; 2,
|
||||||
StrTrim; STR_TRIM; 1,
|
StrTrim; STR_TRIM; 1,
|
||||||
StrTrimLeft; STR_TRIM_LEFT; 1,
|
StrTrimStart; STR_TRIM_START; 1,
|
||||||
StrTrimRight; STR_TRIM_RIGHT; 1,
|
StrTrimEnd; STR_TRIM_END; 1,
|
||||||
StrToScalars; STR_TO_SCALARS; 1,
|
StrToScalars; STR_TO_SCALARS; 1,
|
||||||
StrGetUnsafe; STR_GET_UNSAFE; 2,
|
StrGetUnsafe; STR_GET_UNSAFE; 2,
|
||||||
StrSubstringUnsafe; STR_SUBSTRING_UNSAFE; 3,
|
StrSubstringUnsafe; STR_SUBSTRING_UNSAFE; 3,
|
||||||
|
|
|
@ -1491,16 +1491,16 @@ trait Backend<'a> {
|
||||||
arg_layouts,
|
arg_layouts,
|
||||||
ret_layout,
|
ret_layout,
|
||||||
),
|
),
|
||||||
LowLevel::StrTrimLeft => self.build_fn_call(
|
LowLevel::StrTrimStart => self.build_fn_call(
|
||||||
sym,
|
sym,
|
||||||
bitcode::STR_TRIM_LEFT.to_string(),
|
bitcode::STR_TRIM_START.to_string(),
|
||||||
args,
|
args,
|
||||||
arg_layouts,
|
arg_layouts,
|
||||||
ret_layout,
|
ret_layout,
|
||||||
),
|
),
|
||||||
LowLevel::StrTrimRight => self.build_fn_call(
|
LowLevel::StrTrimEnd => self.build_fn_call(
|
||||||
sym,
|
sym,
|
||||||
bitcode::STR_TRIM_RIGHT.to_string(),
|
bitcode::STR_TRIM_END.to_string(),
|
||||||
args,
|
args,
|
||||||
arg_layouts,
|
arg_layouts,
|
||||||
ret_layout,
|
ret_layout,
|
||||||
|
|
|
@ -617,7 +617,7 @@ pub(crate) fn run_low_level<'a, 'ctx>(
|
||||||
|
|
||||||
call_str_bitcode_fn(env, &[string], &[], BitcodeReturns::Str, bitcode::STR_TRIM)
|
call_str_bitcode_fn(env, &[string], &[], BitcodeReturns::Str, bitcode::STR_TRIM)
|
||||||
}
|
}
|
||||||
StrTrimLeft => {
|
StrTrimStart => {
|
||||||
// Str.trim : Str -> Str
|
// Str.trim : Str -> Str
|
||||||
arguments!(string);
|
arguments!(string);
|
||||||
|
|
||||||
|
@ -626,10 +626,10 @@ pub(crate) fn run_low_level<'a, 'ctx>(
|
||||||
&[string],
|
&[string],
|
||||||
&[],
|
&[],
|
||||||
BitcodeReturns::Str,
|
BitcodeReturns::Str,
|
||||||
bitcode::STR_TRIM_LEFT,
|
bitcode::STR_TRIM_START,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
StrTrimRight => {
|
StrTrimEnd => {
|
||||||
// Str.trim : Str -> Str
|
// Str.trim : Str -> Str
|
||||||
arguments!(string);
|
arguments!(string);
|
||||||
|
|
||||||
|
@ -638,7 +638,7 @@ pub(crate) fn run_low_level<'a, 'ctx>(
|
||||||
&[string],
|
&[string],
|
||||||
&[],
|
&[],
|
||||||
BitcodeReturns::Str,
|
BitcodeReturns::Str,
|
||||||
bitcode::STR_TRIM_RIGHT,
|
bitcode::STR_TRIM_END,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
StrWithCapacity => {
|
StrWithCapacity => {
|
||||||
|
|
|
@ -281,8 +281,8 @@ impl<'a> LowLevelCall<'a> {
|
||||||
backend.code_builder.i32_const(UPDATE_MODE_IMMUTABLE);
|
backend.code_builder.i32_const(UPDATE_MODE_IMMUTABLE);
|
||||||
backend.call_host_fn_after_loading_args(bitcode::STR_FROM_UTF8_RANGE, 6, false);
|
backend.call_host_fn_after_loading_args(bitcode::STR_FROM_UTF8_RANGE, 6, false);
|
||||||
}
|
}
|
||||||
StrTrimLeft => self.load_args_and_call_zig(backend, bitcode::STR_TRIM_LEFT),
|
StrTrimStart => self.load_args_and_call_zig(backend, bitcode::STR_TRIM_START),
|
||||||
StrTrimRight => self.load_args_and_call_zig(backend, bitcode::STR_TRIM_RIGHT),
|
StrTrimEnd => self.load_args_and_call_zig(backend, bitcode::STR_TRIM_END),
|
||||||
StrToUtf8 => self.load_args_and_call_zig(backend, bitcode::STR_TO_UTF8),
|
StrToUtf8 => self.load_args_and_call_zig(backend, bitcode::STR_TO_UTF8),
|
||||||
StrReserve => self.load_args_and_call_zig(backend, bitcode::STR_RESERVE),
|
StrReserve => self.load_args_and_call_zig(backend, bitcode::STR_RESERVE),
|
||||||
StrReleaseExcessCapacity => {
|
StrReleaseExcessCapacity => {
|
||||||
|
|
|
@ -20,8 +20,8 @@ pub enum LowLevel {
|
||||||
StrRepeat,
|
StrRepeat,
|
||||||
StrFromFloat,
|
StrFromFloat,
|
||||||
StrTrim,
|
StrTrim,
|
||||||
StrTrimLeft,
|
StrTrimStart,
|
||||||
StrTrimRight,
|
StrTrimEnd,
|
||||||
StrToNum,
|
StrToNum,
|
||||||
StrToScalars,
|
StrToScalars,
|
||||||
StrGetUnsafe,
|
StrGetUnsafe,
|
||||||
|
@ -260,8 +260,8 @@ map_symbol_to_lowlevel! {
|
||||||
StrToUtf8 <= STR_TO_UTF8,
|
StrToUtf8 <= STR_TO_UTF8,
|
||||||
StrRepeat <= STR_REPEAT,
|
StrRepeat <= STR_REPEAT,
|
||||||
StrTrim <= STR_TRIM,
|
StrTrim <= STR_TRIM,
|
||||||
StrTrimLeft <= STR_TRIM_LEFT,
|
StrTrimStart <= STR_TRIM_START,
|
||||||
StrTrimRight <= STR_TRIM_RIGHT,
|
StrTrimEnd <= STR_TRIM_END,
|
||||||
StrToScalars <= STR_TO_SCALARS,
|
StrToScalars <= STR_TO_SCALARS,
|
||||||
StrGetUnsafe <= STR_GET_UNSAFE,
|
StrGetUnsafe <= STR_GET_UNSAFE,
|
||||||
StrSubstringUnsafe <= STR_SUBSTRING_UNSAFE,
|
StrSubstringUnsafe <= STR_SUBSTRING_UNSAFE,
|
||||||
|
|
|
@ -1303,8 +1303,8 @@ define_builtins! {
|
||||||
15 STR_FROM_UTF8_RANGE: "fromUtf8Range"
|
15 STR_FROM_UTF8_RANGE: "fromUtf8Range"
|
||||||
16 STR_REPEAT: "repeat"
|
16 STR_REPEAT: "repeat"
|
||||||
17 STR_TRIM: "trim"
|
17 STR_TRIM: "trim"
|
||||||
18 STR_TRIM_LEFT: "trimLeft"
|
18 STR_TRIM_START: "trimStart"
|
||||||
19 STR_TRIM_RIGHT: "trimRight"
|
19 STR_TRIM_END: "trimEnd"
|
||||||
20 STR_TO_DEC: "toDec"
|
20 STR_TO_DEC: "toDec"
|
||||||
21 STR_TO_F64: "toF64"
|
21 STR_TO_F64: "toF64"
|
||||||
22 STR_TO_F32: "toF32"
|
22 STR_TO_F32: "toF32"
|
||||||
|
|
|
@ -962,8 +962,8 @@ pub fn lowlevel_borrow_signature(arena: &Bump, op: LowLevel) -> &[Ownership] {
|
||||||
StrAppendScalar => arena.alloc_slice_copy(&[owned, irrelevant]),
|
StrAppendScalar => arena.alloc_slice_copy(&[owned, irrelevant]),
|
||||||
StrGetScalarUnsafe => arena.alloc_slice_copy(&[borrowed, irrelevant]),
|
StrGetScalarUnsafe => arena.alloc_slice_copy(&[borrowed, irrelevant]),
|
||||||
StrTrim => arena.alloc_slice_copy(&[owned]),
|
StrTrim => arena.alloc_slice_copy(&[owned]),
|
||||||
StrTrimLeft => arena.alloc_slice_copy(&[owned]),
|
StrTrimStart => arena.alloc_slice_copy(&[owned]),
|
||||||
StrTrimRight => arena.alloc_slice_copy(&[owned]),
|
StrTrimEnd => arena.alloc_slice_copy(&[owned]),
|
||||||
StrSplit => arena.alloc_slice_copy(&[borrowed, borrowed]),
|
StrSplit => arena.alloc_slice_copy(&[borrowed, borrowed]),
|
||||||
StrToNum => arena.alloc_slice_copy(&[borrowed]),
|
StrToNum => arena.alloc_slice_copy(&[borrowed]),
|
||||||
ListPrepend => arena.alloc_slice_copy(&[owned, owned]),
|
ListPrepend => arena.alloc_slice_copy(&[owned, owned]),
|
||||||
|
|
|
@ -1583,8 +1583,8 @@ fn low_level_no_rc(lowlevel: &LowLevel) -> RC {
|
||||||
StrAppendScalar => RC::Rc,
|
StrAppendScalar => RC::Rc,
|
||||||
StrGetScalarUnsafe => RC::NoRc,
|
StrGetScalarUnsafe => RC::NoRc,
|
||||||
StrTrim => RC::Rc,
|
StrTrim => RC::Rc,
|
||||||
StrTrimLeft => RC::Rc,
|
StrTrimStart => RC::Rc,
|
||||||
StrTrimRight => RC::Rc,
|
StrTrimEnd => RC::Rc,
|
||||||
StrSplit => RC::NoRc,
|
StrSplit => RC::NoRc,
|
||||||
StrToNum => RC::NoRc,
|
StrToNum => RC::NoRc,
|
||||||
ListPrepend => RC::Rc,
|
ListPrepend => RC::Rc,
|
||||||
|
|
|
@ -3797,11 +3797,11 @@ mod solve_expr {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn str_trim_left() {
|
fn str_trim_start() {
|
||||||
infer_eq_without_problem(
|
infer_eq_without_problem(
|
||||||
indoc!(
|
indoc!(
|
||||||
r#"
|
r#"
|
||||||
Str.trimLeft
|
Str.trimStart
|
||||||
"#
|
"#
|
||||||
),
|
),
|
||||||
"Str -> Str",
|
"Str -> Str",
|
||||||
|
|
|
@ -1218,15 +1218,15 @@ fn str_trim_small_to_small_shared() {
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
#[cfg(any(feature = "gen-llvm", feature = "gen-dev"))]
|
#[cfg(any(feature = "gen-llvm", feature = "gen-dev"))]
|
||||||
fn str_trim_left_small_blank_string() {
|
fn str_trim_start_small_blank_string() {
|
||||||
assert_evals_to!(indoc!(r#"Str.trimLeft " ""#), RocStr::from(""), RocStr);
|
assert_evals_to!(indoc!(r#"Str.trimStart " ""#), RocStr::from(""), RocStr);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
#[cfg(any(feature = "gen-llvm", feature = "gen-dev"))]
|
#[cfg(any(feature = "gen-llvm", feature = "gen-dev"))]
|
||||||
fn str_trim_left_small_to_small() {
|
fn str_trim_start_small_to_small() {
|
||||||
assert_evals_to!(
|
assert_evals_to!(
|
||||||
indoc!(r#"Str.trimLeft " hello world ""#),
|
indoc!(r#"Str.trimStart " hello world ""#),
|
||||||
RocStr::from("hello world "),
|
RocStr::from("hello world "),
|
||||||
RocStr
|
RocStr
|
||||||
);
|
);
|
||||||
|
@ -1234,9 +1234,9 @@ fn str_trim_left_small_to_small() {
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
#[cfg(any(feature = "gen-llvm", feature = "gen-dev"))]
|
#[cfg(any(feature = "gen-llvm", feature = "gen-dev"))]
|
||||||
fn str_trim_left_large_to_large_unique() {
|
fn str_trim_start_large_to_large_unique() {
|
||||||
assert_evals_to!(
|
assert_evals_to!(
|
||||||
indoc!(r#"Str.trimLeft (Str.concat " " "hello world from a large string ")"#),
|
indoc!(r#"Str.trimStart (Str.concat " " "hello world from a large string ")"#),
|
||||||
RocStr::from("hello world from a large string "),
|
RocStr::from("hello world from a large string "),
|
||||||
RocStr
|
RocStr
|
||||||
);
|
);
|
||||||
|
@ -1244,9 +1244,9 @@ fn str_trim_left_large_to_large_unique() {
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
#[cfg(any(feature = "gen-llvm", feature = "gen-dev"))]
|
#[cfg(any(feature = "gen-llvm", feature = "gen-dev"))]
|
||||||
fn str_trim_left_large_to_small_unique() {
|
fn str_trim_start_large_to_small_unique() {
|
||||||
assert_evals_to!(
|
assert_evals_to!(
|
||||||
indoc!(r#"Str.trimLeft (Str.concat " " "hello world ")"#),
|
indoc!(r#"Str.trimStart (Str.concat " " "hello world ")"#),
|
||||||
RocStr::from("hello world "),
|
RocStr::from("hello world "),
|
||||||
RocStr
|
RocStr
|
||||||
);
|
);
|
||||||
|
@ -1254,14 +1254,14 @@ fn str_trim_left_large_to_small_unique() {
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
#[cfg(any(feature = "gen-llvm"))]
|
#[cfg(any(feature = "gen-llvm"))]
|
||||||
fn str_trim_left_large_to_large_shared() {
|
fn str_trim_start_large_to_large_shared() {
|
||||||
assert_evals_to!(
|
assert_evals_to!(
|
||||||
indoc!(
|
indoc!(
|
||||||
r#"
|
r#"
|
||||||
original : Str
|
original : Str
|
||||||
original = " hello world world "
|
original = " hello world world "
|
||||||
|
|
||||||
{ trimmed: Str.trimLeft original, original: original }
|
{ trimmed: Str.trimStart original, original: original }
|
||||||
"#
|
"#
|
||||||
),
|
),
|
||||||
(
|
(
|
||||||
|
@ -1274,14 +1274,14 @@ fn str_trim_left_large_to_large_shared() {
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
#[cfg(any(feature = "gen-llvm"))]
|
#[cfg(any(feature = "gen-llvm"))]
|
||||||
fn str_trim_left_large_to_small_shared() {
|
fn str_trim_start_large_to_small_shared() {
|
||||||
assert_evals_to!(
|
assert_evals_to!(
|
||||||
indoc!(
|
indoc!(
|
||||||
r#"
|
r#"
|
||||||
original : Str
|
original : Str
|
||||||
original = " hello world "
|
original = " hello world "
|
||||||
|
|
||||||
{ trimmed: Str.trimLeft original, original: original }
|
{ trimmed: Str.trimStart original, original: original }
|
||||||
"#
|
"#
|
||||||
),
|
),
|
||||||
(
|
(
|
||||||
|
@ -1294,14 +1294,14 @@ fn str_trim_left_large_to_small_shared() {
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
#[cfg(any(feature = "gen-llvm"))]
|
#[cfg(any(feature = "gen-llvm"))]
|
||||||
fn str_trim_left_small_to_small_shared() {
|
fn str_trim_start_small_to_small_shared() {
|
||||||
assert_evals_to!(
|
assert_evals_to!(
|
||||||
indoc!(
|
indoc!(
|
||||||
r#"
|
r#"
|
||||||
original : Str
|
original : Str
|
||||||
original = " hello world "
|
original = " hello world "
|
||||||
|
|
||||||
{ trimmed: Str.trimLeft original, original: original }
|
{ trimmed: Str.trimStart original, original: original }
|
||||||
"#
|
"#
|
||||||
),
|
),
|
||||||
(RocStr::from(" hello world "), RocStr::from("hello world "),),
|
(RocStr::from(" hello world "), RocStr::from("hello world "),),
|
||||||
|
@ -1311,15 +1311,15 @@ fn str_trim_left_small_to_small_shared() {
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
#[cfg(any(feature = "gen-llvm", feature = "gen-dev"))]
|
#[cfg(any(feature = "gen-llvm", feature = "gen-dev"))]
|
||||||
fn str_trim_right_small_blank_string() {
|
fn str_trim_end_small_blank_string() {
|
||||||
assert_evals_to!(indoc!(r#"Str.trimRight " ""#), RocStr::from(""), RocStr);
|
assert_evals_to!(indoc!(r#"Str.trimEnd " ""#), RocStr::from(""), RocStr);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
#[cfg(any(feature = "gen-llvm", feature = "gen-dev"))]
|
#[cfg(any(feature = "gen-llvm", feature = "gen-dev"))]
|
||||||
fn str_trim_right_small_to_small() {
|
fn str_trim_end_small_to_small() {
|
||||||
assert_evals_to!(
|
assert_evals_to!(
|
||||||
indoc!(r#"Str.trimRight " hello world ""#),
|
indoc!(r#"Str.trimEnd " hello world ""#),
|
||||||
RocStr::from(" hello world"),
|
RocStr::from(" hello world"),
|
||||||
RocStr
|
RocStr
|
||||||
);
|
);
|
||||||
|
@ -1327,9 +1327,9 @@ fn str_trim_right_small_to_small() {
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
#[cfg(any(feature = "gen-llvm", feature = "gen-dev"))]
|
#[cfg(any(feature = "gen-llvm", feature = "gen-dev"))]
|
||||||
fn str_trim_right_large_to_large_unique() {
|
fn str_trim_end_large_to_large_unique() {
|
||||||
assert_evals_to!(
|
assert_evals_to!(
|
||||||
indoc!(r#"Str.trimRight (Str.concat " hello world from a large string" " ")"#),
|
indoc!(r#"Str.trimEnd (Str.concat " hello world from a large string" " ")"#),
|
||||||
RocStr::from(" hello world from a large string"),
|
RocStr::from(" hello world from a large string"),
|
||||||
RocStr
|
RocStr
|
||||||
);
|
);
|
||||||
|
@ -1337,9 +1337,9 @@ fn str_trim_right_large_to_large_unique() {
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
#[cfg(any(feature = "gen-llvm", feature = "gen-dev"))]
|
#[cfg(any(feature = "gen-llvm", feature = "gen-dev"))]
|
||||||
fn str_trim_right_large_to_small_unique() {
|
fn str_trim_end_large_to_small_unique() {
|
||||||
assert_evals_to!(
|
assert_evals_to!(
|
||||||
indoc!(r#"Str.trimRight (Str.concat " hello world" " ")"#),
|
indoc!(r#"Str.trimEnd (Str.concat " hello world" " ")"#),
|
||||||
RocStr::from(" hello world"),
|
RocStr::from(" hello world"),
|
||||||
RocStr
|
RocStr
|
||||||
);
|
);
|
||||||
|
@ -1347,14 +1347,14 @@ fn str_trim_right_large_to_small_unique() {
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
#[cfg(any(feature = "gen-llvm"))]
|
#[cfg(any(feature = "gen-llvm"))]
|
||||||
fn str_trim_right_large_to_large_shared() {
|
fn str_trim_end_large_to_large_shared() {
|
||||||
assert_evals_to!(
|
assert_evals_to!(
|
||||||
indoc!(
|
indoc!(
|
||||||
r#"
|
r#"
|
||||||
original : Str
|
original : Str
|
||||||
original = " hello world world "
|
original = " hello world world "
|
||||||
|
|
||||||
{ trimmed: Str.trimRight original, original: original }
|
{ trimmed: Str.trimEnd original, original: original }
|
||||||
"#
|
"#
|
||||||
),
|
),
|
||||||
(
|
(
|
||||||
|
@ -1367,14 +1367,14 @@ fn str_trim_right_large_to_large_shared() {
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
#[cfg(any(feature = "gen-llvm"))]
|
#[cfg(any(feature = "gen-llvm"))]
|
||||||
fn str_trim_right_large_to_small_shared() {
|
fn str_trim_end_large_to_small_shared() {
|
||||||
assert_evals_to!(
|
assert_evals_to!(
|
||||||
indoc!(
|
indoc!(
|
||||||
r#"
|
r#"
|
||||||
original : Str
|
original : Str
|
||||||
original = " hello world "
|
original = " hello world "
|
||||||
|
|
||||||
{ trimmed: Str.trimRight original, original: original }
|
{ trimmed: Str.trimEnd original, original: original }
|
||||||
"#
|
"#
|
||||||
),
|
),
|
||||||
(
|
(
|
||||||
|
@ -1387,14 +1387,14 @@ fn str_trim_right_large_to_small_shared() {
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
#[cfg(any(feature = "gen-llvm"))]
|
#[cfg(any(feature = "gen-llvm"))]
|
||||||
fn str_trim_right_small_to_small_shared() {
|
fn str_trim_end_small_to_small_shared() {
|
||||||
assert_evals_to!(
|
assert_evals_to!(
|
||||||
indoc!(
|
indoc!(
|
||||||
r#"
|
r#"
|
||||||
original : Str
|
original : Str
|
||||||
original = " hello world "
|
original = " hello world "
|
||||||
|
|
||||||
{ trimmed: Str.trimRight original, original: original }
|
{ trimmed: Str.trimEnd original, original: original }
|
||||||
"#
|
"#
|
||||||
),
|
),
|
||||||
(RocStr::from(" hello world "), RocStr::from(" hello world"),),
|
(RocStr::from(" hello world "), RocStr::from(" hello world"),),
|
||||||
|
|
|
@ -989,78 +989,78 @@ fn str_trim_small_to_small_shared() {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn str_trim_left_small_blank_string() {
|
fn str_trim_start_small_blank_string() {
|
||||||
assert_evals_to!(indoc!(r#"Str.trimLeft " ""#), RocStr::from(""), RocStr);
|
assert_evals_to!(indoc!(r#"Str.trimStart " ""#), RocStr::from(""), RocStr);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn str_trim_left_small_to_small() {
|
fn str_trim_start_small_to_small() {
|
||||||
assert_evals_to!(
|
assert_evals_to!(
|
||||||
indoc!(r#"Str.trimLeft " hello ""#),
|
indoc!(r#"Str.trimStart " hello ""#),
|
||||||
RocStr::from("hello "),
|
RocStr::from("hello "),
|
||||||
RocStr
|
RocStr
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn str_trim_left_large_to_large_unique() {
|
fn str_trim_start_large_to_large_unique() {
|
||||||
assert_evals_to!(
|
assert_evals_to!(
|
||||||
indoc!(r#"Str.trimLeft (Str.concat " " "hello world from a large string ")"#),
|
indoc!(r#"Str.trimStart (Str.concat " " "hello world from a large string ")"#),
|
||||||
RocStr::from("hello world from a large string "),
|
RocStr::from("hello world from a large string "),
|
||||||
RocStr
|
RocStr
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn str_trim_left_large_to_small_unique() {
|
fn str_trim_start_large_to_small_unique() {
|
||||||
assert_evals_to!(
|
assert_evals_to!(
|
||||||
indoc!(r#"Str.trimLeft (Str.concat " " "hello ")"#),
|
indoc!(r#"Str.trimStart (Str.concat " " "hello ")"#),
|
||||||
RocStr::from("hello "),
|
RocStr::from("hello "),
|
||||||
RocStr
|
RocStr
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn str_trim_right_small_blank_string() {
|
fn str_trim_end_small_blank_string() {
|
||||||
assert_evals_to!(indoc!(r#"Str.trimRight " ""#), RocStr::from(""), RocStr);
|
assert_evals_to!(indoc!(r#"Str.trimEnd " ""#), RocStr::from(""), RocStr);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn str_trim_right_small_to_small() {
|
fn str_trim_end_small_to_small() {
|
||||||
assert_evals_to!(
|
assert_evals_to!(
|
||||||
indoc!(r#"Str.trimRight " hello ""#),
|
indoc!(r#"Str.trimEnd " hello ""#),
|
||||||
RocStr::from(" hello"),
|
RocStr::from(" hello"),
|
||||||
RocStr
|
RocStr
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn str_trim_right_large_to_large_unique() {
|
fn str_trim_end_large_to_large_unique() {
|
||||||
assert_evals_to!(
|
assert_evals_to!(
|
||||||
indoc!(r#"Str.trimRight (Str.concat " hello world from a large string" " ")"#),
|
indoc!(r#"Str.trimEnd (Str.concat " hello world from a large string" " ")"#),
|
||||||
RocStr::from(" hello world from a large string"),
|
RocStr::from(" hello world from a large string"),
|
||||||
RocStr
|
RocStr
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn str_trim_right_large_to_small_unique() {
|
fn str_trim_end_large_to_small_unique() {
|
||||||
assert_evals_to!(
|
assert_evals_to!(
|
||||||
indoc!(r#"Str.trimRight (Str.concat " hello" " ")"#),
|
indoc!(r#"Str.trimEnd (Str.concat " hello" " ")"#),
|
||||||
RocStr::from(" hello"),
|
RocStr::from(" hello"),
|
||||||
RocStr
|
RocStr
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn str_trim_right_large_to_large_shared() {
|
fn str_trim_end_large_to_large_shared() {
|
||||||
assert_evals_to!(
|
assert_evals_to!(
|
||||||
indoc!(
|
indoc!(
|
||||||
r#"
|
r#"
|
||||||
original : Str
|
original : Str
|
||||||
original = " hello world world "
|
original = " hello world world "
|
||||||
|
|
||||||
{ trimmed: Str.trimRight original, original: original }
|
{ trimmed: Str.trimEnd original, original: original }
|
||||||
"#
|
"#
|
||||||
),
|
),
|
||||||
(
|
(
|
||||||
|
@ -1072,14 +1072,14 @@ fn str_trim_right_large_to_large_shared() {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn str_trim_right_large_to_small_shared() {
|
fn str_trim_end_large_to_small_shared() {
|
||||||
assert_evals_to!(
|
assert_evals_to!(
|
||||||
indoc!(
|
indoc!(
|
||||||
r#"
|
r#"
|
||||||
original : Str
|
original : Str
|
||||||
original = " hello "
|
original = " hello "
|
||||||
|
|
||||||
{ trimmed: Str.trimRight original, original: original }
|
{ trimmed: Str.trimEnd original, original: original }
|
||||||
"#
|
"#
|
||||||
),
|
),
|
||||||
(RocStr::from(" hello "), RocStr::from(" hello"),),
|
(RocStr::from(" hello "), RocStr::from(" hello"),),
|
||||||
|
@ -1088,14 +1088,14 @@ fn str_trim_right_large_to_small_shared() {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn str_trim_right_small_to_small_shared() {
|
fn str_trim_end_small_to_small_shared() {
|
||||||
assert_evals_to!(
|
assert_evals_to!(
|
||||||
indoc!(
|
indoc!(
|
||||||
r#"
|
r#"
|
||||||
original : Str
|
original : Str
|
||||||
original = " hello "
|
original = " hello "
|
||||||
|
|
||||||
{ trimmed: Str.trimRight original, original: original }
|
{ trimmed: Str.trimEnd original, original: original }
|
||||||
"#
|
"#
|
||||||
),
|
),
|
||||||
(RocStr::from(" hello "), RocStr::from(" hello"),),
|
(RocStr::from(" hello "), RocStr::from(" hello"),),
|
||||||
|
|
|
@ -286,12 +286,12 @@ fn list_concat_empty_list_zero_sized_type() {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn str_trim_right_capacity() {
|
fn str_trim_end_capacity() {
|
||||||
valgrind_test(indoc!(
|
valgrind_test(indoc!(
|
||||||
r#"
|
r#"
|
||||||
(
|
(
|
||||||
str = "a" |> Str.reserve 30
|
str = "a" |> Str.reserve 30
|
||||||
out = str |> Str.trimRight
|
out = str |> Str.trimEnd
|
||||||
|
|
||||||
if out == "" then "A" else "B"
|
if out == "" then "A" else "B"
|
||||||
)
|
)
|
||||||
|
@ -300,12 +300,12 @@ fn str_trim_right_capacity() {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn str_trim_left_capacity() {
|
fn str_trim_start_capacity() {
|
||||||
valgrind_test(indoc!(
|
valgrind_test(indoc!(
|
||||||
r#"
|
r#"
|
||||||
(
|
(
|
||||||
str = " a" |> Str.reserve 30
|
str = " a" |> Str.reserve 30
|
||||||
out = str |> Str.trimLeft
|
out = str |> Str.trimStart
|
||||||
|
|
||||||
if out == "" then "A" else "B"
|
if out == "" then "A" else "B"
|
||||||
)
|
)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue