cli: add supplied-buffer decimal integer formatting to std
This commit is contained in:
30 files changed
+3609
-11
No files matched your search
@@ -0,0 +1,30 @@
|
||||
// expect: run
|
||||
// result: 1
|
||||
// phase: 6
|
||||
// spec: docs/spec/16-standard-library.md §2.8; docs/spec/15-source-language.md §13
|
||||
module test.fmt_namespace
|
||||
import std.fmt;
|
||||
import std.bytes;
|
||||
enum __aji_std_fmt_WriteResult { local }
|
||||
fn __aji_std_fmt_write_u64() -> u8 effects [] { return 7; }
|
||||
fn check(result: std.fmt.WriteResult) -> usize effects [] {
|
||||
match result {
|
||||
std.fmt.WriteResult::ok(count) => { return count; }
|
||||
std.fmt.WriteResult::short_output => { return 0; }
|
||||
}
|
||||
}
|
||||
fn main() -> u8 effects [] {
|
||||
var buf: [u8; 6] = [165; 6];
|
||||
let std = 7u8;
|
||||
{ mut all = buf;
|
||||
let (left, right) = all.split_at(3);
|
||||
ref held = right;
|
||||
let result: std.fmt.WriteResult = std.fmt.write_i64(mut left, -12);
|
||||
assert(check(result) == 3);
|
||||
assert(held[0] == 165);
|
||||
}
|
||||
assert(std.bytes.equal(ref buf[0..3], b"-12"));
|
||||
assert(__aji_std_fmt_write_u64() == std);
|
||||
assert(check(std.fmt.WriteResult::short_output) == 0);
|
||||
return 1;
|
||||
}
|
||||
Reference in new issue
Block a user