conformance: gc skip header and sampled per-step siblings for vector suites
This commit is contained in:
1 parent
3f1dc84676
commit
0d6566632c
15 files changed
+442
-2
No files matched your search
@@ -1,6 +1,7 @@
|
||||
// expect: run
|
||||
// result: 1
|
||||
// fuel: 20000000
|
||||
// gc: skip
|
||||
// phase: 6
|
||||
// spec: docs/spec/16-standard-library.md §2.8
|
||||
// Decimal oracle: Python str(value); fixed seed 202010. Small values, powers
|
||||
|
||||
@@ -0,0 +1,59 @@
|
||||
// expect: run
|
||||
// result: 1
|
||||
// fuel: 20000000
|
||||
// phase: 6
|
||||
// spec: docs/spec/16-standard-library.md §2.8
|
||||
// Sampled copy of fmt_i64_vectors.aji (21 of 984 vectors: limits, tail, evenly spaced)
|
||||
// for `--collect-every-step`; the full suite carries `// gc: skip`.
|
||||
// Decimal oracle: Python str(value); fixed seed 202010. Small values, powers
|
||||
// of ten/two and their neighbors, signed limits, and 48 seeded unsigned inputs.
|
||||
module test.fmt_i64_gc
|
||||
import std.fmt;
|
||||
|
||||
fn check(value: i64, expected: slice<u8>) -> void
|
||||
effects []
|
||||
{
|
||||
for capacity in 0usize..23usize {
|
||||
var storage: [u8; 26] = [165; 26];
|
||||
match std.fmt.write_i64(mut storage[1..1 + capacity], value as! i64) {
|
||||
std.fmt.WriteResult::ok(count) => {
|
||||
assert(capacity >= expected.len);
|
||||
assert(count == expected.len);
|
||||
for i in 0..count { assert(storage[1 + i] == expected[i]); }
|
||||
for i in count + 1..storage.len { assert(storage[i] == 165); }
|
||||
}
|
||||
std.fmt.WriteResult::short_output => {
|
||||
assert(capacity < expected.len);
|
||||
for i in 0..storage.len { assert(storage[i] == 165); }
|
||||
}
|
||||
}
|
||||
assert(storage[0] == 165);
|
||||
}
|
||||
}
|
||||
|
||||
fn main() -> u8
|
||||
effects []
|
||||
{
|
||||
check((-9223372036854775807i64 - 1i64), b"-9223372036854775808");
|
||||
check(-9223372036854775807i64, b"-9223372036854775807");
|
||||
check(-8840889545696419459i64, b"-8840889545696419459");
|
||||
check(-8741427099435404153i64, b"-8741427099435404153");
|
||||
check(-8601570958497122972i64, b"-8601570958497122972");
|
||||
check(-100000000000001i64, b"-100000000000001");
|
||||
check(-67108865i64, b"-67108865");
|
||||
check(-245i64, b"-245");
|
||||
check(-164i64, b"-164");
|
||||
check(-83i64, b"-83");
|
||||
check(-2i64, b"-2");
|
||||
check(79i64, b"79");
|
||||
check(160i64, b"160");
|
||||
check(241i64, b"241");
|
||||
check(33554432i64, b"33554432");
|
||||
check(70368744177664i64, b"70368744177664");
|
||||
check(6472241654744496554i64, b"6472241654744496554");
|
||||
check(8601570958497122972i64, b"8601570958497122972");
|
||||
check(8741427099435404153i64, b"8741427099435404153");
|
||||
check(8840889545696419459i64, b"8840889545696419459");
|
||||
check(9223372036854775807i64, b"9223372036854775807");
|
||||
return 1;
|
||||
}
|
||||
@@ -1,6 +1,7 @@
|
||||
// expect: run
|
||||
// result: 1
|
||||
// fuel: 20000000
|
||||
// gc: skip
|
||||
// phase: 6
|
||||
// spec: docs/spec/16-standard-library.md §2.8
|
||||
// Decimal oracle: Python str(value); fixed seed 202010. Small values, powers
|
||||
|
||||
@@ -0,0 +1,62 @@
|
||||
// expect: run
|
||||
// result: 1
|
||||
// fuel: 20000000
|
||||
// phase: 6
|
||||
// spec: docs/spec/16-standard-library.md §2.8
|
||||
// Sampled copy of fmt_isize_vectors.aji (21 of 984 vectors: limits, tail, evenly spaced)
|
||||
// for `--collect-every-step`; the full suite carries `// gc: skip`.
|
||||
// Decimal oracle: Python str(value); fixed seed 202010. Small values, powers
|
||||
// of ten/two and their neighbors, signed limits, and 48 seeded unsigned inputs.
|
||||
module test.fmt_isize_gc
|
||||
import std.fmt;
|
||||
|
||||
fn check(value: i64, expected: slice<u8>) -> void
|
||||
effects []
|
||||
{
|
||||
let maximum = ((0usize -% 1usize) >> 1) as! isize;
|
||||
let minimum = -maximum - 1isize;
|
||||
if value < minimum as! i64 or value > maximum as! i64 { return; }
|
||||
for capacity in 0usize..23usize {
|
||||
var storage: [u8; 26] = [165; 26];
|
||||
match std.fmt.write_isize(mut storage[1..1 + capacity], value as! isize) {
|
||||
std.fmt.WriteResult::ok(count) => {
|
||||
assert(capacity >= expected.len);
|
||||
assert(count == expected.len);
|
||||
for i in 0..count { assert(storage[1 + i] == expected[i]); }
|
||||
for i in count + 1..storage.len { assert(storage[i] == 165); }
|
||||
}
|
||||
std.fmt.WriteResult::short_output => {
|
||||
assert(capacity < expected.len);
|
||||
for i in 0..storage.len { assert(storage[i] == 165); }
|
||||
}
|
||||
}
|
||||
assert(storage[0] == 165);
|
||||
}
|
||||
}
|
||||
|
||||
fn main() -> u8
|
||||
effects []
|
||||
{
|
||||
check((-9223372036854775807i64 - 1i64), b"-9223372036854775808");
|
||||
check(-9223372036854775807i64, b"-9223372036854775807");
|
||||
check(-8840889545696419459i64, b"-8840889545696419459");
|
||||
check(-8741427099435404153i64, b"-8741427099435404153");
|
||||
check(-8601570958497122972i64, b"-8601570958497122972");
|
||||
check(-100000000000001i64, b"-100000000000001");
|
||||
check(-67108865i64, b"-67108865");
|
||||
check(-245i64, b"-245");
|
||||
check(-164i64, b"-164");
|
||||
check(-83i64, b"-83");
|
||||
check(-2i64, b"-2");
|
||||
check(79i64, b"79");
|
||||
check(160i64, b"160");
|
||||
check(241i64, b"241");
|
||||
check(33554432i64, b"33554432");
|
||||
check(70368744177664i64, b"70368744177664");
|
||||
check(6472241654744496554i64, b"6472241654744496554");
|
||||
check(8601570958497122972i64, b"8601570958497122972");
|
||||
check(8741427099435404153i64, b"8741427099435404153");
|
||||
check(8840889545696419459i64, b"8840889545696419459");
|
||||
check(9223372036854775807i64, b"9223372036854775807");
|
||||
return 1;
|
||||
}
|
||||
@@ -1,6 +1,7 @@
|
||||
// expect: run
|
||||
// result: 1
|
||||
// fuel: 20000000
|
||||
// gc: skip
|
||||
// phase: 6
|
||||
// spec: docs/spec/16-standard-library.md §2.8
|
||||
// Decimal oracle: Python str(value); fixed seed 202010. Small values, powers
|
||||
|
||||
@@ -0,0 +1,59 @@
|
||||
// expect: run
|
||||
// result: 1
|
||||
// fuel: 20000000
|
||||
// phase: 6
|
||||
// spec: docs/spec/16-standard-library.md §2.8
|
||||
// Sampled copy of fmt_u64_vectors.aji (21 of 523 vectors: limits, tail, evenly spaced)
|
||||
// for `--collect-every-step`; the full suite carries `// gc: skip`.
|
||||
// Decimal oracle: Python str(value); fixed seed 202010. Small values, powers
|
||||
// of ten/two and their neighbors, signed limits, and 48 seeded unsigned inputs.
|
||||
module test.fmt_u64_gc
|
||||
import std.fmt;
|
||||
|
||||
fn check(value: u64, expected: slice<u8>) -> void
|
||||
effects []
|
||||
{
|
||||
for capacity in 0usize..23usize {
|
||||
var storage: [u8; 26] = [165; 26];
|
||||
match std.fmt.write_u64(mut storage[1..1 + capacity], value as! u64) {
|
||||
std.fmt.WriteResult::ok(count) => {
|
||||
assert(capacity >= expected.len);
|
||||
assert(count == expected.len);
|
||||
for i in 0..count { assert(storage[1 + i] == expected[i]); }
|
||||
for i in count + 1..storage.len { assert(storage[i] == 165); }
|
||||
}
|
||||
std.fmt.WriteResult::short_output => {
|
||||
assert(capacity < expected.len);
|
||||
for i in 0..storage.len { assert(storage[i] == 165); }
|
||||
}
|
||||
}
|
||||
assert(storage[0] == 165);
|
||||
}
|
||||
}
|
||||
|
||||
fn main() -> u8
|
||||
effects []
|
||||
{
|
||||
check(0u64, b"0");
|
||||
check(1u64, b"1");
|
||||
check(2u64, b"2");
|
||||
check(3u64, b"3");
|
||||
check(4u64, b"4");
|
||||
check(46u64, b"46");
|
||||
check(88u64, b"88");
|
||||
check(130u64, b"130");
|
||||
check(172u64, b"172");
|
||||
check(214u64, b"214");
|
||||
check(256u64, b"256");
|
||||
check(524288u64, b"524288");
|
||||
check(1000000000u64, b"1000000000");
|
||||
check(1099511627776u64, b"1099511627776");
|
||||
check(2251799813685248u64, b"2251799813685248");
|
||||
check(2181996174858958743u64, b"2181996174858958743");
|
||||
check(14322322805036888198u64, b"14322322805036888198");
|
||||
check(16856184049892812909u64, b"16856184049892812909");
|
||||
check(16995872497743105300u64, b"16995872497743105300");
|
||||
check(17599502550275446939u64, b"17599502550275446939");
|
||||
check(18446744073709551615u64, b"18446744073709551615");
|
||||
return 1;
|
||||
}
|
||||
@@ -1,6 +1,7 @@
|
||||
// expect: run
|
||||
// result: 1
|
||||
// fuel: 20000000
|
||||
// gc: skip
|
||||
// phase: 6
|
||||
// spec: docs/spec/16-standard-library.md §2.8
|
||||
// Decimal oracle: Python str(value); fixed seed 202010. Small values, powers
|
||||
|
||||
@@ -0,0 +1,60 @@
|
||||
// expect: run
|
||||
// result: 1
|
||||
// fuel: 20000000
|
||||
// phase: 6
|
||||
// spec: docs/spec/16-standard-library.md §2.8
|
||||
// Sampled copy of fmt_usize_vectors.aji (21 of 523 vectors: limits, tail, evenly spaced)
|
||||
// for `--collect-every-step`; the full suite carries `// gc: skip`.
|
||||
// Decimal oracle: Python str(value); fixed seed 202010. Small values, powers
|
||||
// of ten/two and their neighbors, signed limits, and 48 seeded unsigned inputs.
|
||||
module test.fmt_usize_gc
|
||||
import std.fmt;
|
||||
|
||||
fn check(value: u64, expected: slice<u8>) -> void
|
||||
effects []
|
||||
{
|
||||
if value > (0usize -% 1usize) as! u64 { return; }
|
||||
for capacity in 0usize..23usize {
|
||||
var storage: [u8; 26] = [165; 26];
|
||||
match std.fmt.write_usize(mut storage[1..1 + capacity], value as! usize) {
|
||||
std.fmt.WriteResult::ok(count) => {
|
||||
assert(capacity >= expected.len);
|
||||
assert(count == expected.len);
|
||||
for i in 0..count { assert(storage[1 + i] == expected[i]); }
|
||||
for i in count + 1..storage.len { assert(storage[i] == 165); }
|
||||
}
|
||||
std.fmt.WriteResult::short_output => {
|
||||
assert(capacity < expected.len);
|
||||
for i in 0..storage.len { assert(storage[i] == 165); }
|
||||
}
|
||||
}
|
||||
assert(storage[0] == 165);
|
||||
}
|
||||
}
|
||||
|
||||
fn main() -> u8
|
||||
effects []
|
||||
{
|
||||
check(0u64, b"0");
|
||||
check(1u64, b"1");
|
||||
check(2u64, b"2");
|
||||
check(3u64, b"3");
|
||||
check(4u64, b"4");
|
||||
check(46u64, b"46");
|
||||
check(88u64, b"88");
|
||||
check(130u64, b"130");
|
||||
check(172u64, b"172");
|
||||
check(214u64, b"214");
|
||||
check(256u64, b"256");
|
||||
check(524288u64, b"524288");
|
||||
check(1000000000u64, b"1000000000");
|
||||
check(1099511627776u64, b"1099511627776");
|
||||
check(2251799813685248u64, b"2251799813685248");
|
||||
check(2181996174858958743u64, b"2181996174858958743");
|
||||
check(14322322805036888198u64, b"14322322805036888198");
|
||||
check(16856184049892812909u64, b"16856184049892812909");
|
||||
check(16995872497743105300u64, b"16995872497743105300");
|
||||
check(17599502550275446939u64, b"17599502550275446939");
|
||||
check(18446744073709551615u64, b"18446744073709551615");
|
||||
return 1;
|
||||
}
|
||||
@@ -1,6 +1,7 @@
|
||||
// expect: run
|
||||
// result: 0
|
||||
// fuel: 20000000
|
||||
// gc: skip
|
||||
// phase: 6
|
||||
// spec: docs/spec/16-standard-library.md §2.6
|
||||
module test.text
|
||||
|
||||
@@ -0,0 +1,82 @@
|
||||
// expect: run
|
||||
// result: 0
|
||||
// fuel: 20000000
|
||||
// phase: 6
|
||||
// spec: docs/spec/16-standard-library.md §2.6
|
||||
// Sampled copy of text_base64_vectors.aji (20 of 572 vectors: limits, tail, evenly spaced)
|
||||
// for `--collect-every-step`; the full suite carries `// gc: skip`.
|
||||
module test.text_gc
|
||||
import std.encoding.base64;
|
||||
import std.bytes;
|
||||
|
||||
fn fixture(data: slice<u8>, encoded: slice<u8>) -> void
|
||||
effects []
|
||||
{
|
||||
for capacity in 0usize..encoded.len + 2 {
|
||||
var dst: [u8; 132] = [165; 132];
|
||||
match std.encoding.base64.encode(mut dst[1..1 + capacity], ref data) {
|
||||
std.encoding.base64.EncodeResult::ok(count) => {
|
||||
assert(capacity >= encoded.len); assert(count == encoded.len);
|
||||
assert(std.bytes.equal(ref dst[1..1 + count], ref encoded));
|
||||
}
|
||||
std.encoding.base64.EncodeResult::short_output => { assert(capacity < encoded.len); }
|
||||
}
|
||||
for i in 0..dst.len {
|
||||
if capacity < encoded.len or i == 0 or i > encoded.len { assert(dst[i] == 165); }
|
||||
}
|
||||
}
|
||||
for capacity in 0usize..data.len + 2 {
|
||||
var dst: [u8; 132] = [165; 132];
|
||||
match std.encoding.base64.decode(mut dst[1..1 + capacity], ref encoded) {
|
||||
std.encoding.base64.DecodeResult::ok(count) => {
|
||||
assert(capacity >= data.len); assert(count == data.len);
|
||||
assert(std.bytes.equal(ref dst[1..1 + count], ref data));
|
||||
}
|
||||
std.encoding.base64.DecodeResult::invalid_input => { trap; }
|
||||
std.encoding.base64.DecodeResult::short_output => { assert(capacity < data.len); }
|
||||
}
|
||||
for i in 0..dst.len {
|
||||
if capacity < data.len or i == 0 or i > data.len { assert(dst[i] == 165); }
|
||||
}
|
||||
}
|
||||
}
|
||||
fn invalid(encoded: slice<u8>) -> void
|
||||
effects []
|
||||
{
|
||||
// Invalid input takes precedence over insufficient capacity, without writes.
|
||||
for capacity in 0usize..12usize {
|
||||
var dst: [u8; 16] = [165; 16];
|
||||
match std.encoding.base64.decode(mut dst[1..1 + capacity], ref encoded) {
|
||||
std.encoding.base64.DecodeResult::invalid_input => {}
|
||||
std.encoding.base64.DecodeResult::ok(count) => { trap; }
|
||||
std.encoding.base64.DecodeResult::short_output => { trap; }
|
||||
}
|
||||
for i in 0..dst.len { assert(dst[i] == 165); }
|
||||
}
|
||||
}
|
||||
fn main() -> u8
|
||||
effects []
|
||||
{
|
||||
var empty: [u8; 1] = zero;
|
||||
fixture(ref empty[0..0], ref empty[0..0]);
|
||||
fixture(b"\x00", b"\x41\x41\x3d\x3d");
|
||||
fixture(b"\x01", b"\x41\x51\x3d\x3d");
|
||||
fixture(b"\x02", b"\x41\x67\x3d\x3d");
|
||||
fixture(b"\x03", b"\x41\x77\x3d\x3d");
|
||||
fixture(b"\x32", b"\x4d\x67\x3d\x3d");
|
||||
fixture(b"\x61", b"\x59\x51\x3d\x3d");
|
||||
fixture(b"\x90", b"\x6b\x41\x3d\x3d");
|
||||
fixture(b"\xbf", b"\x76\x77\x3d\x3d");
|
||||
fixture(b"\xee", b"\x37\x67\x3d\x3d");
|
||||
invalid(b"\x5a\x67");
|
||||
invalid(b"\x5a\x6d\x39\x76\x41\x25\x41\x41");
|
||||
invalid(b"\x5a\x6d\x39\x76\x41\x94\x41\x41");
|
||||
invalid(b"\x5a\x6d\x39\x76\x41\xc3\x41\x41");
|
||||
invalid(b"\x5a\x6d\x39\x76\x41\xf2\x41\x41");
|
||||
invalid(b"\x66\x30\x3d\x3d");
|
||||
invalid(b"\x66\x2f\x2f\x3d");
|
||||
invalid(b"\x2f\x2f\x39\x3d");
|
||||
invalid(b"\x2f\x2f\x2b\x3d");
|
||||
invalid(b"\x2f\x2f\x2f\x3d");
|
||||
return 0;
|
||||
}
|
||||
@@ -1,6 +1,7 @@
|
||||
// expect: run
|
||||
// result: 0
|
||||
// fuel: 20000000
|
||||
// gc: skip
|
||||
// phase: 6
|
||||
// spec: docs/spec/16-standard-library.md §2.6
|
||||
module test.text
|
||||
|
||||
@@ -0,0 +1,89 @@
|
||||
// expect: run
|
||||
// result: 0
|
||||
// fuel: 20000000
|
||||
// phase: 6
|
||||
// spec: docs/spec/16-standard-library.md §2.6
|
||||
// Sampled copy of text_hex_vectors.aji (21 of 518 vectors: limits, tail, evenly spaced)
|
||||
// for `--collect-every-step`; the full suite carries `// gc: skip`.
|
||||
module test.text_gc
|
||||
import std.encoding.hex;
|
||||
import std.bytes;
|
||||
|
||||
fn fixture(data: slice<u8>, encoded: slice<u8>) -> void
|
||||
effects []
|
||||
{
|
||||
for capacity in 0usize..encoded.len + 2 {
|
||||
var dst: [u8; 132] = [165; 132];
|
||||
match std.encoding.hex.encode(mut dst[1..1 + capacity], ref data) {
|
||||
std.encoding.hex.EncodeResult::ok(count) => {
|
||||
assert(capacity >= encoded.len); assert(count == encoded.len);
|
||||
assert(std.bytes.equal(ref dst[1..1 + count], ref encoded));
|
||||
}
|
||||
std.encoding.hex.EncodeResult::short_output => { assert(capacity < encoded.len); }
|
||||
}
|
||||
for i in 0..dst.len {
|
||||
if capacity < encoded.len or i == 0 or i > encoded.len { assert(dst[i] == 165); }
|
||||
}
|
||||
}
|
||||
for capacity in 0usize..data.len + 2 {
|
||||
var dst: [u8; 132] = [165; 132];
|
||||
match std.encoding.hex.decode(mut dst[1..1 + capacity], ref encoded) {
|
||||
std.encoding.hex.DecodeResult::ok(count) => {
|
||||
assert(capacity >= data.len); assert(count == data.len);
|
||||
assert(std.bytes.equal(ref dst[1..1 + count], ref data));
|
||||
}
|
||||
std.encoding.hex.DecodeResult::invalid_input => { trap; }
|
||||
std.encoding.hex.DecodeResult::short_output => { assert(capacity < data.len); }
|
||||
}
|
||||
for i in 0..dst.len {
|
||||
if capacity < data.len or i == 0 or i > data.len { assert(dst[i] == 165); }
|
||||
}
|
||||
}
|
||||
}
|
||||
fn invalid(encoded: slice<u8>) -> void
|
||||
effects []
|
||||
{
|
||||
// Invalid input takes precedence over insufficient capacity, without writes.
|
||||
for capacity in 0usize..12usize {
|
||||
var dst: [u8; 16] = [165; 16];
|
||||
match std.encoding.hex.decode(mut dst[1..1 + capacity], ref encoded) {
|
||||
std.encoding.hex.DecodeResult::invalid_input => {}
|
||||
std.encoding.hex.DecodeResult::ok(count) => { trap; }
|
||||
std.encoding.hex.DecodeResult::short_output => { trap; }
|
||||
}
|
||||
for i in 0..dst.len { assert(dst[i] == 165); }
|
||||
}
|
||||
}
|
||||
fn main() -> u8
|
||||
effects []
|
||||
{
|
||||
var empty: [u8; 1] = zero;
|
||||
fixture(ref empty[0..0], ref empty[0..0]);
|
||||
fixture(b"\x00", b"\x30\x30");
|
||||
fixture(b"\x01", b"\x30\x31");
|
||||
fixture(b"\x02", b"\x30\x32");
|
||||
fixture(b"\x03", b"\x30\x33");
|
||||
fixture(b"\x2d", b"\x32\x64");
|
||||
fixture(b"\x57", b"\x35\x37");
|
||||
fixture(b"\x81", b"\x38\x31");
|
||||
fixture(b"\xab", b"\x61\x62");
|
||||
fixture(b"\xd5", b"\x64\x35");
|
||||
fixture(b"\xff", b"\x66\x66");
|
||||
invalid(b"\x30\x0e");
|
||||
invalid(b"\x30\x48");
|
||||
invalid(b"\x30\x78");
|
||||
invalid(b"\x30\xa2");
|
||||
invalid(b"\x30\xcc");
|
||||
invalid(b"\x30\xf6");
|
||||
invalid(b"\x30\xfc");
|
||||
invalid(b"\x30\xfd");
|
||||
invalid(b"\x30\xfe");
|
||||
invalid(b"\x30\xff");
|
||||
var dst: [u8; 4] = zero;
|
||||
match std.encoding.hex.decode(mut dst, b"aBcD01fF") {
|
||||
std.encoding.hex.DecodeResult::ok(count) => { assert(count == 4); assert(std.bytes.equal(ref dst, b"\xab\xcd\x01\xff")); }
|
||||
std.encoding.hex.DecodeResult::invalid_input => { trap; }
|
||||
std.encoding.hex.DecodeResult::short_output => { trap; }
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
Reference in new issue
Block a user