mirror of
https://github.com/roc-lang/roc.git
synced 2025-09-26 21:39:07 +00:00
Merge pull request #3702 from rtfeldman/test-str-builtins
`roc test` on `Str` builtins
This commit is contained in:
commit
c7f9a39625
4 changed files with 24 additions and 1 deletions
|
@ -330,6 +330,15 @@ splitLast = \haystack, needle ->
|
|||
None ->
|
||||
Err NotFound
|
||||
|
||||
# splitLast when needle isn't in haystack
|
||||
expect Str.splitLast "foo" "z" == Err NotFound
|
||||
|
||||
# splitLast when haystack ends with needle repeated
|
||||
expect Str.splitLast "foo" "o" == Ok { before: "fo", after: "" }
|
||||
|
||||
# splitLast with multi-byte needle
|
||||
expect Str.splitLast "hullabaloo" "ab" == Ok { before: "hull", after: "aloo" }
|
||||
|
||||
lastMatch : Str, Str -> [Some Nat, None]
|
||||
lastMatch = \haystack, needle ->
|
||||
haystackLength = Str.countUtf8Bytes haystack
|
||||
|
|
|
@ -445,6 +445,7 @@ fn start_phase<'a>(
|
|||
|
||||
BuildTask::BuildPendingSpecializations {
|
||||
layout_cache,
|
||||
execution_mode: state.exec_mode,
|
||||
module_id,
|
||||
module_timing,
|
||||
solved_subs,
|
||||
|
@ -1090,6 +1091,7 @@ enum BuildTask<'a> {
|
|||
},
|
||||
BuildPendingSpecializations {
|
||||
module_timing: ModuleTiming,
|
||||
execution_mode: ExecutionMode,
|
||||
layout_cache: LayoutCache<'a>,
|
||||
solved_subs: Solved<Subs>,
|
||||
imported_module_thunks: &'a [Symbol],
|
||||
|
@ -4736,6 +4738,7 @@ fn make_specializations<'a>(
|
|||
#[allow(clippy::too_many_arguments)]
|
||||
fn build_pending_specializations<'a>(
|
||||
arena: &'a Bump,
|
||||
execution_mode: ExecutionMode,
|
||||
solved_subs: Solved<Subs>,
|
||||
imported_module_thunks: &'a [Symbol],
|
||||
home: ModuleId,
|
||||
|
@ -4993,6 +4996,12 @@ fn build_pending_specializations<'a>(
|
|||
// the declarations of this group will be treaded individually by later iterations
|
||||
}
|
||||
Expectation => {
|
||||
// skip expectations if we're not going to run them
|
||||
match execution_mode {
|
||||
ExecutionMode::Test => { /* fall through */ }
|
||||
ExecutionMode::Check | ExecutionMode::Executable => continue,
|
||||
}
|
||||
|
||||
// mark this symbol as a top-level thunk before any other work on the procs
|
||||
module_thunks.push(symbol);
|
||||
|
||||
|
@ -5265,6 +5274,7 @@ fn run_task<'a>(
|
|||
)),
|
||||
BuildPendingSpecializations {
|
||||
module_id,
|
||||
execution_mode,
|
||||
ident_ids,
|
||||
decls,
|
||||
module_timing,
|
||||
|
@ -5277,6 +5287,7 @@ fn run_task<'a>(
|
|||
derived_module,
|
||||
} => Ok(build_pending_specializations(
|
||||
arena,
|
||||
execution_mode,
|
||||
solved_subs,
|
||||
imported_module_thunks,
|
||||
module_id,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue