mirror of
https://github.com/roc-lang/roc.git
synced 2025-09-26 13:29:12 +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
|
@ -89,6 +89,9 @@ test-rust:
|
||||||
# gen-wasm has some multithreading problems to do with the wasmer runtime. Run it single-threaded as a separate job
|
# gen-wasm has some multithreading problems to do with the wasmer runtime. Run it single-threaded as a separate job
|
||||||
RUN --mount=type=cache,target=$SCCACHE_DIR \
|
RUN --mount=type=cache,target=$SCCACHE_DIR \
|
||||||
cargo test --locked --release --package test_gen --no-default-features --features gen-wasm -- --test-threads=1 && sccache --show-stats
|
cargo test --locked --release --package test_gen --no-default-features --features gen-wasm -- --test-threads=1 && sccache --show-stats
|
||||||
|
# run `roc test` on Str builtins
|
||||||
|
RUN --mount=type=cache,target=$SCCACHE_DIR \
|
||||||
|
cargo run --release -- test crates/compiler/builtins/roc/Str.roc && sccache --show-stats
|
||||||
# repl_test: build the compiler for wasm target, then run the tests on native target
|
# repl_test: build the compiler for wasm target, then run the tests on native target
|
||||||
RUN --mount=type=cache,target=$SCCACHE_DIR \
|
RUN --mount=type=cache,target=$SCCACHE_DIR \
|
||||||
crates/repl_test/test_wasm.sh && sccache --show-stats
|
crates/repl_test/test_wasm.sh && sccache --show-stats
|
||||||
|
|
|
@ -330,6 +330,15 @@ splitLast = \haystack, needle ->
|
||||||
None ->
|
None ->
|
||||||
Err NotFound
|
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 : Str, Str -> [Some Nat, None]
|
||||||
lastMatch = \haystack, needle ->
|
lastMatch = \haystack, needle ->
|
||||||
haystackLength = Str.countUtf8Bytes haystack
|
haystackLength = Str.countUtf8Bytes haystack
|
||||||
|
|
|
@ -445,6 +445,7 @@ fn start_phase<'a>(
|
||||||
|
|
||||||
BuildTask::BuildPendingSpecializations {
|
BuildTask::BuildPendingSpecializations {
|
||||||
layout_cache,
|
layout_cache,
|
||||||
|
execution_mode: state.exec_mode,
|
||||||
module_id,
|
module_id,
|
||||||
module_timing,
|
module_timing,
|
||||||
solved_subs,
|
solved_subs,
|
||||||
|
@ -1090,6 +1091,7 @@ enum BuildTask<'a> {
|
||||||
},
|
},
|
||||||
BuildPendingSpecializations {
|
BuildPendingSpecializations {
|
||||||
module_timing: ModuleTiming,
|
module_timing: ModuleTiming,
|
||||||
|
execution_mode: ExecutionMode,
|
||||||
layout_cache: LayoutCache<'a>,
|
layout_cache: LayoutCache<'a>,
|
||||||
solved_subs: Solved<Subs>,
|
solved_subs: Solved<Subs>,
|
||||||
imported_module_thunks: &'a [Symbol],
|
imported_module_thunks: &'a [Symbol],
|
||||||
|
@ -4736,6 +4738,7 @@ fn make_specializations<'a>(
|
||||||
#[allow(clippy::too_many_arguments)]
|
#[allow(clippy::too_many_arguments)]
|
||||||
fn build_pending_specializations<'a>(
|
fn build_pending_specializations<'a>(
|
||||||
arena: &'a Bump,
|
arena: &'a Bump,
|
||||||
|
execution_mode: ExecutionMode,
|
||||||
solved_subs: Solved<Subs>,
|
solved_subs: Solved<Subs>,
|
||||||
imported_module_thunks: &'a [Symbol],
|
imported_module_thunks: &'a [Symbol],
|
||||||
home: ModuleId,
|
home: ModuleId,
|
||||||
|
@ -4993,6 +4996,12 @@ fn build_pending_specializations<'a>(
|
||||||
// the declarations of this group will be treaded individually by later iterations
|
// the declarations of this group will be treaded individually by later iterations
|
||||||
}
|
}
|
||||||
Expectation => {
|
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
|
// mark this symbol as a top-level thunk before any other work on the procs
|
||||||
module_thunks.push(symbol);
|
module_thunks.push(symbol);
|
||||||
|
|
||||||
|
@ -5265,6 +5274,7 @@ fn run_task<'a>(
|
||||||
)),
|
)),
|
||||||
BuildPendingSpecializations {
|
BuildPendingSpecializations {
|
||||||
module_id,
|
module_id,
|
||||||
|
execution_mode,
|
||||||
ident_ids,
|
ident_ids,
|
||||||
decls,
|
decls,
|
||||||
module_timing,
|
module_timing,
|
||||||
|
@ -5277,6 +5287,7 @@ fn run_task<'a>(
|
||||||
derived_module,
|
derived_module,
|
||||||
} => Ok(build_pending_specializations(
|
} => Ok(build_pending_specializations(
|
||||||
arena,
|
arena,
|
||||||
|
execution_mode,
|
||||||
solved_subs,
|
solved_subs,
|
||||||
imported_module_thunks,
|
imported_module_thunks,
|
||||||
module_id,
|
module_id,
|
||||||
|
|
|
@ -108,7 +108,7 @@ mod test {
|
||||||
target_info,
|
target_info,
|
||||||
render: RenderTarget::ColorTerminal,
|
render: RenderTarget::ColorTerminal,
|
||||||
threading: Threading::Single,
|
threading: Threading::Single,
|
||||||
exec_mode: ExecutionMode::Executable,
|
exec_mode: ExecutionMode::Test,
|
||||||
};
|
};
|
||||||
let loaded = roc_load::load_and_monomorphize_from_str(
|
let loaded = roc_load::load_and_monomorphize_from_str(
|
||||||
arena,
|
arena,
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue