zig/test/self_hosted.zig
2016-12-26 17:11:36 -05:00

41 lines
938 B
Zig

// TODO not passing
fn genericFnWithImplicitCast() {
@setFnTest(this);
assert(getFirstByte(u8, []u8 {13}) == 13);
assert(getFirstByte(u16, []u16 {0, 13}) == 0);
}
fn getByte(ptr: ?&u8) -> u8 {*??ptr}
fn getFirstByte(inline T: type, mem: []T) -> u8 {
getByte((&u8)(&mem[0]))
}
// TODO not passing
fn pointerToVoidReturnType() {
@setFnTest(this);
%%testPointerToVoidReturnType();
}
fn testPointerToVoidReturnType() -> %void {
const a = testPointerToVoidReturnType2();
return *a;
}
const test_pointer_to_void_return_type_x = void{};
fn testPointerToVoidReturnType2() -> &const void {
return &test_pointer_to_void_return_type_x;
}
// TODO not passing (goes in struct.zig)
fn passSliceOfEmptyStructToFn() {
@setFnTest(this);
assert(testPassSliceOfEmptyStructToFn([]EmptyStruct2{ EmptyStruct2{} }) == 1);
}
fn testPassSliceOfEmptyStructToFn(slice: []EmptyStruct2) -> usize {
slice.len
}