cli: add bounded std copy/search and checked arithmetic
This commit is contained in:
36 files changed
+1533
-7
No files matched your search
@@ -0,0 +1,23 @@
|
||||
// expect: run
|
||||
// result: [5,5,5,165]
|
||||
// equivalent: std/bounded_copy.air
|
||||
// phase: 6
|
||||
// spec: docs/spec/16-standard-library.md §2.4
|
||||
module test.bounded_copy
|
||||
import std.bytes;
|
||||
|
||||
fn main() -> [u8; 4]
|
||||
effects []
|
||||
{
|
||||
let src: [u8; 3] = [5; 3];
|
||||
var dst: [u8; 4] = [165; 4];
|
||||
match std.bytes.copy(mut dst[0..2], ref src) {
|
||||
std.bytes.WriteResult::ok => { trap; }
|
||||
std.bytes.WriteResult::short_output => { assert(dst[0] == 165); }
|
||||
}
|
||||
match std.bytes.copy(mut dst, ref src) {
|
||||
std.bytes.WriteResult::ok => {}
|
||||
std.bytes.WriteResult::short_output => { trap; }
|
||||
}
|
||||
return dst;
|
||||
}
|
||||
Reference in new issue
Block a user