cli: bootstrap verified std bytes and math with source imports
This commit is contained in:
52 files changed
+1000
-22
No files matched your search
@@ -0,0 +1,45 @@
|
||||
// expect: run
|
||||
// result: 0
|
||||
// phase: 6
|
||||
// spec: docs/spec/16-standard-library.md; docs/spec/15-source-language.md §13
|
||||
module test.standard
|
||||
import std.bytes;
|
||||
|
||||
fn main() -> u8
|
||||
effects []
|
||||
{
|
||||
var storage: [u8; 1] = zero;
|
||||
ref empty = storage[0..0];
|
||||
assert(std.bytes.equal(ref empty, ref empty));
|
||||
assert(std.bytes.equal(b"a\0\xff", b"a\0\xff"));
|
||||
assert(not std.bytes.equal(b"a", b"ab"));
|
||||
assert(not std.bytes.equal(b"ab", b"ax"));
|
||||
assert(std.bytes.compare(ref empty, ref empty) == 0);
|
||||
assert(std.bytes.compare(ref empty, b"a") == -1);
|
||||
assert(std.bytes.compare(b"a", ref empty) == 1);
|
||||
assert(std.bytes.compare(b"ab", b"ab") == 0);
|
||||
assert(std.bytes.compare(b"a", b"ab") == -1);
|
||||
assert(std.bytes.compare(b"ab", b"a") == 1);
|
||||
assert(std.bytes.compare(b"abc", b"abd") == -1);
|
||||
assert(std.bytes.compare(b"abd", b"abc") == 1);
|
||||
assert(std.bytes.compare(b"\x80", b"\x7f") == 1);
|
||||
assert(std.bytes.compare(b"\0", b"\xff") == -1);
|
||||
assert(std.bytes.find(ref empty, 0) == 0usize);
|
||||
assert(std.bytes.find(b"aba", 97) == 0usize);
|
||||
assert(std.bytes.find(b"abc", 99) == 2usize);
|
||||
assert(std.bytes.find(b"abc", 100) == 3usize);
|
||||
assert(std.bytes.find(b"a\0\xff", 0) == 1usize);
|
||||
assert(std.bytes.starts_with(ref empty, ref empty));
|
||||
assert(std.bytes.ends_with(ref empty, ref empty));
|
||||
assert(std.bytes.starts_with(b"abc", ref empty));
|
||||
assert(std.bytes.ends_with(b"abc", ref empty));
|
||||
assert(std.bytes.starts_with(b"abc", b"abc"));
|
||||
assert(std.bytes.ends_with(b"abc", b"abc"));
|
||||
assert(std.bytes.starts_with(b"abc", b"ab"));
|
||||
assert(std.bytes.ends_with(b"abc", b"bc"));
|
||||
assert(not std.bytes.starts_with(b"a", b"ab"));
|
||||
assert(not std.bytes.ends_with(b"a", b"ab"));
|
||||
assert(not std.bytes.starts_with(b"abc", b"x"));
|
||||
assert(not std.bytes.ends_with(b"abc", b"x"));
|
||||
return 0;
|
||||
}
|
||||
Reference in new issue
Block a user