mirror of
https://github.com/roc-lang/roc.git
synced 2024-09-11 18:58:24 +03:00
Merge pull request #6158 from roc-lang/expect-seamless-slice
Support seamless slice in expects
This commit is contained in:
commit
6dddb7b348
@ -554,13 +554,13 @@ mod cli_run {
|
||||
r#"
|
||||
This expectation failed:
|
||||
|
||||
18│ expect x != x
|
||||
^^^^^^
|
||||
19│ expect words == []
|
||||
^^^^^^^^^^^
|
||||
|
||||
When it failed, these variables had these values:
|
||||
|
||||
x : Num *
|
||||
x = 42
|
||||
words : List Str
|
||||
words = ["this", "will", "for", "sure", "be", "a", "large", "string", "so", "when", "we", "split", "it", "it", "will", "use", "seamless", "slices", "which", "affect", "printing"]
|
||||
|
||||
[#UserApp] 42
|
||||
[#UserApp] "Fjoer en ferdjer frieten oan dyn geve lea"
|
||||
|
2
crates/cli_testing_examples/.gitignore
vendored
2
crates/cli_testing_examples/.gitignore
vendored
@ -4,8 +4,8 @@ libapp.so
|
||||
dynhost
|
||||
preprocessedhost
|
||||
metadata
|
||||
expects
|
||||
|
||||
expects/expects
|
||||
benchmarks/rbtree-ck
|
||||
benchmarks/rbtree-insert
|
||||
benchmarks/test-astar
|
||||
|
@ -14,8 +14,11 @@ polyDbg = \x ->
|
||||
x
|
||||
|
||||
main =
|
||||
str = "this will for sure be a large string so when we split it it will use seamless slices which affect printing"
|
||||
words = Str.split str " "
|
||||
expect words == []
|
||||
|
||||
x = 42
|
||||
expect x != x
|
||||
dbg x
|
||||
dbg "Fjoer en ferdjer frieten oan dyn geve lea"
|
||||
|
||||
|
@ -59,7 +59,9 @@ impl ReplAppMemory for ExpectMemory {
|
||||
roc_str.as_str()
|
||||
} else {
|
||||
let offset = self.deref_usize(addr);
|
||||
let length = self.deref_usize(addr + std::mem::size_of::<usize>());
|
||||
let seamless_slice_mask = usize::MAX >> 1;
|
||||
let length =
|
||||
self.deref_usize(addr + std::mem::size_of::<usize>()) & seamless_slice_mask;
|
||||
let _capacity = self.deref_usize(addr + 2 * std::mem::size_of::<usize>());
|
||||
|
||||
unsafe {
|
||||
|
@ -87,7 +87,8 @@ impl<'a> ReplAppMemory for WasmMemory<'a> {
|
||||
&self.copied_bytes[addr..][..len]
|
||||
} else {
|
||||
let chars_index = self.deref_usize(addr);
|
||||
let len = self.deref_usize(addr + 4);
|
||||
let seamless_slice_mask = u32::MAX as usize >> 1;
|
||||
let len = self.deref_usize(addr + 4) & seamless_slice_mask;
|
||||
&self.copied_bytes[chars_index..][..len]
|
||||
};
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user