2017-11-02 21:00:57 -07:00
|
|
|
const assert = @import("std").debug.assert;
|
|
|
|
const mem = @import("std").mem;
|
|
|
|
|
|
|
|
test "reflection: array, pointer, nullable, error union type child" {
|
|
|
|
comptime {
|
|
|
|
assert(([10]u8).Child == u8);
|
|
|
|
assert((&u8).Child == u8);
|
|
|
|
assert((%u8).Child == u8);
|
|
|
|
assert((?u8).Child == u8);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-11-04 13:19:43 -07:00
|
|
|
test "reflection: function return type, var args, and param types" {
|
2017-11-02 21:00:57 -07:00
|
|
|
comptime {
|
|
|
|
assert(@typeOf(dummy).ReturnType == i32);
|
|
|
|
assert(!@typeOf(dummy).is_var_args);
|
|
|
|
assert(@typeOf(dummy_varargs).is_var_args);
|
2017-11-04 13:19:43 -07:00
|
|
|
assert(@typeOf(dummy).arg_count == 3);
|
|
|
|
assert(@ArgType(@typeOf(dummy), 0) == bool);
|
|
|
|
assert(@ArgType(@typeOf(dummy), 1) == i32);
|
|
|
|
assert(@ArgType(@typeOf(dummy), 2) == f32);
|
2017-11-02 21:00:57 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-11-04 13:19:43 -07:00
|
|
|
fn dummy(a: bool, b: i32, c: f32) -> i32 { 1234 }
|
2017-11-02 21:00:57 -07:00
|
|
|
fn dummy_varargs(args: ...) {}
|
2017-11-04 13:19:43 -07:00
|
|
|
|