aboutsummaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
Diffstat (limited to 'test')
-rw-r--r--test/compile_errors.zig25
-rw-r--r--test/stage1/behavior/align.zig2
-rw-r--r--test/stage1/behavior/array.zig10
-rw-r--r--test/stage1/behavior/async_fn.zig6
-rw-r--r--test/stage1/behavior/bit_shifting.zig12
-rw-r--r--test/stage1/behavior/bugs/5487.zig4
-rw-r--r--test/stage1/behavior/error.zig4
-rw-r--r--test/stage1/behavior/misc.zig10
-rw-r--r--test/stage1/behavior/reflection.zig22
9 files changed, 30 insertions, 65 deletions
diff --git a/test/compile_errors.zig b/test/compile_errors.zig
index f6e00e1dbb..31f2b57dc8 100644
--- a/test/compile_errors.zig
+++ b/test/compile_errors.zig
@@ -176,11 +176,11 @@ pub fn addCases(cases: *tests.CompileErrorContext) void {
, &[_][]const u8{
"tmp.zig:2:17: error: expected type 'u32', found 'error{Ohno}'",
"tmp.zig:1:17: note: function cannot return an error",
- "tmp.zig:8:5: error: expected type 'void', found '@TypeOf(bar).ReturnType.ErrorSet'",
+ "tmp.zig:8:5: error: expected type 'void', found '@typeInfo(@typeInfo(@TypeOf(bar)).Fn.return_type.?).ErrorUnion.error_set'",
"tmp.zig:7:17: note: function cannot return an error",
- "tmp.zig:11:15: error: expected type 'u32', found '@TypeOf(bar).ReturnType.ErrorSet!u32'",
+ "tmp.zig:11:15: error: expected type 'u32', found '@typeInfo(@typeInfo(@TypeOf(bar)).Fn.return_type.?).ErrorUnion.error_set!u32'",
"tmp.zig:10:17: note: function cannot return an error",
- "tmp.zig:15:14: error: expected type 'u32', found '@TypeOf(bar).ReturnType.ErrorSet!u32'",
+ "tmp.zig:15:14: error: expected type 'u32', found '@typeInfo(@typeInfo(@TypeOf(bar)).Fn.return_type.?).ErrorUnion.error_set!u32'",
"tmp.zig:14:5: note: cannot store an error in type 'u32'",
});
@@ -899,7 +899,7 @@ pub fn addCases(cases: *tests.CompileErrorContext) void {
\\ _ = @cmpxchgWeak(f32, &x, 1, 2, .SeqCst, .SeqCst);
\\}
, &[_][]const u8{
- "tmp.zig:3:22: error: expected integer, enum or pointer type, found 'f32'",
+ "tmp.zig:3:22: error: expected bool, integer, enum or pointer type, found 'f32'",
});
cases.add("atomicrmw with float op not .Xchg, .Add or .Sub",
@@ -1224,7 +1224,7 @@ pub fn addCases(cases: *tests.CompileErrorContext) void {
\\ };
\\}
, &[_][]const u8{
- "tmp.zig:11:25: error: expected type 'u32', found '@TypeOf(get_uval).ReturnType.ErrorSet!u32'",
+ "tmp.zig:11:25: error: expected type 'u32', found '@typeInfo(@typeInfo(@TypeOf(get_uval)).Fn.return_type.?).ErrorUnion.error_set!u32'",
});
cases.add("assigning to struct or union fields that are not optionals with a function that returns an optional",
@@ -1929,7 +1929,7 @@ pub fn addCases(cases: *tests.CompileErrorContext) void {
\\ const info = @TypeOf(slice).unknown;
\\}
, &[_][]const u8{
- "tmp.zig:3:32: error: type '[]i32' does not support field access",
+ "tmp.zig:3:32: error: type 'type' does not support field access",
});
cases.add("peer cast then implicit cast const pointer to mutable C pointer",
@@ -3542,7 +3542,7 @@ pub fn addCases(cases: *tests.CompileErrorContext) void {
\\ }
\\}
, &[_][]const u8{
- "tmp.zig:5:14: error: duplicate switch value: '@TypeOf(foo).ReturnType.ErrorSet.Foo'",
+ "tmp.zig:5:14: error: duplicate switch value: '@typeInfo(@typeInfo(@TypeOf(foo)).Fn.return_type.?).ErrorUnion.error_set.Foo'",
"tmp.zig:3:14: note: other value is here",
});
@@ -3674,7 +3674,7 @@ pub fn addCases(cases: *tests.CompileErrorContext) void {
\\ try foo();
\\}
, &[_][]const u8{
- "tmp.zig:5:5: error: cannot resolve inferred error set '@TypeOf(foo).ReturnType.ErrorSet': function 'foo' not fully analyzed yet",
+ "tmp.zig:5:5: error: cannot resolve inferred error set '@typeInfo(@typeInfo(@TypeOf(foo)).Fn.return_type.?).ErrorUnion.error_set': function 'foo' not fully analyzed yet",
});
cases.add("implicit cast of error set not a subset",
@@ -7206,15 +7206,6 @@ pub fn addCases(cases: *tests.CompileErrorContext) void {
"tmp.zig:7:24: error: accessing union field 'Bar' while field 'Baz' is set",
});
- cases.add("getting return type of generic function",
- \\fn generic(a: anytype) void {}
- \\comptime {
- \\ _ = @TypeOf(generic).ReturnType;
- \\}
- , &[_][]const u8{
- "tmp.zig:3:25: error: ReturnType has not been resolved because 'fn(anytype) anytype' is generic",
- });
-
cases.add("unsupported modifier at start of asm output constraint",
\\export fn foo() void {
\\ var bar: u32 = 3;
diff --git a/test/stage1/behavior/align.zig b/test/stage1/behavior/align.zig
index 62f439d6df..0a0cc3bcc0 100644
--- a/test/stage1/behavior/align.zig
+++ b/test/stage1/behavior/align.zig
@@ -5,7 +5,7 @@ const builtin = @import("builtin");
var foo: u8 align(4) = 100;
test "global variable alignment" {
- comptime expect(@TypeOf(&foo).alignment == 4);
+ comptime expect(@typeInfo(@TypeOf(&foo)).Pointer.alignment == 4);
comptime expect(@TypeOf(&foo) == *align(4) u8);
{
const slice = @as(*[1]u8, &foo)[0..];
diff --git a/test/stage1/behavior/array.zig b/test/stage1/behavior/array.zig
index d5ca44f0a2..9e1d2cbac4 100644
--- a/test/stage1/behavior/array.zig
+++ b/test/stage1/behavior/array.zig
@@ -136,16 +136,6 @@ test "array literal with specified size" {
expect(array[1] == 2);
}
-test "array child property" {
- var x: [5]i32 = undefined;
- expect(@TypeOf(x).Child == i32);
-}
-
-test "array len property" {
- var x: [5]i32 = undefined;
- expect(@TypeOf(x).len == 5);
-}
-
test "array len field" {
var arr = [4]u8{ 0, 0, 0, 0 };
var ptr = &arr;
diff --git a/test/stage1/behavior/async_fn.zig b/test/stage1/behavior/async_fn.zig
index 807e4c6275..e2cececf69 100644
--- a/test/stage1/behavior/async_fn.zig
+++ b/test/stage1/behavior/async_fn.zig
@@ -331,7 +331,7 @@ test "async fn with inferred error set" {
fn doTheTest() void {
var frame: [1]@Frame(middle) = undefined;
var fn_ptr = middle;
- var result: @TypeOf(fn_ptr).ReturnType.ErrorSet!void = undefined;
+ var result: @typeInfo(@typeInfo(@TypeOf(fn_ptr)).Fn.return_type.?).ErrorUnion.error_set!void = undefined;
_ = @asyncCall(std.mem.sliceAsBytes(frame[0..]), &result, fn_ptr, .{});
resume global_frame;
std.testing.expectError(error.Fail, result);
@@ -950,7 +950,7 @@ test "@asyncCall with comptime-known function, but not awaited directly" {
fn doTheTest() void {
var frame: [1]@Frame(middle) = undefined;
- var result: @TypeOf(middle).ReturnType.ErrorSet!void = undefined;
+ var result: @typeInfo(@typeInfo(@TypeOf(middle)).Fn.return_type.?).ErrorUnion.error_set!void = undefined;
_ = @asyncCall(std.mem.sliceAsBytes(frame[0..]), &result, middle, .{});
resume global_frame;
std.testing.expectError(error.Fail, result);
@@ -1018,7 +1018,7 @@ test "@TypeOf an async function call of generic fn with error union type" {
const S = struct {
fn func(comptime x: anytype) anyerror!i32 {
const T = @TypeOf(async func(x));
- comptime expect(T == @TypeOf(@frame()).Child);
+ comptime expect(T == @typeInfo(@TypeOf(@frame())).Pointer.child);
return undefined;
}
};
diff --git a/test/stage1/behavior/bit_shifting.zig b/test/stage1/behavior/bit_shifting.zig
index 7306acba4a..786cef0802 100644
--- a/test/stage1/behavior/bit_shifting.zig
+++ b/test/stage1/behavior/bit_shifting.zig
@@ -2,16 +2,18 @@ const std = @import("std");
const expect = std.testing.expect;
fn ShardedTable(comptime Key: type, comptime mask_bit_count: comptime_int, comptime V: type) type {
- expect(Key == std.meta.Int(false, Key.bit_count));
- expect(Key.bit_count >= mask_bit_count);
+ const key_bits = @typeInfo(Key).Int.bits;
+ expect(Key == std.meta.Int(false, key_bits));
+ expect(key_bits >= mask_bit_count);
+ const shard_key_bits = mask_bit_count;
const ShardKey = std.meta.Int(false, mask_bit_count);
- const shift_amount = Key.bit_count - ShardKey.bit_count;
+ const shift_amount = key_bits - shard_key_bits;
return struct {
const Self = @This();
- shards: [1 << ShardKey.bit_count]?*Node,
+ shards: [1 << shard_key_bits]?*Node,
pub fn create() Self {
- return Self{ .shards = [_]?*Node{null} ** (1 << ShardKey.bit_count) };
+ return Self{ .shards = [_]?*Node{null} ** (1 << shard_key_bits) };
}
fn getShardKey(key: Key) ShardKey {
diff --git a/test/stage1/behavior/bugs/5487.zig b/test/stage1/behavior/bugs/5487.zig
index 05967b6de4..02fa677a44 100644
--- a/test/stage1/behavior/bugs/5487.zig
+++ b/test/stage1/behavior/bugs/5487.zig
@@ -3,8 +3,8 @@ const io = @import("std").io;
pub fn write(_: void, bytes: []const u8) !usize {
return 0;
}
-pub fn outStream() io.OutStream(void, @TypeOf(write).ReturnType.ErrorSet, write) {
- return io.OutStream(void, @TypeOf(write).ReturnType.ErrorSet, write){ .context = {} };
+pub fn outStream() io.OutStream(void, @typeInfo(@typeInfo(@TypeOf(write)).Fn.return_type.?).ErrorUnion.error_set, write) {
+ return io.OutStream(void, @typeInfo(@typeInfo(@TypeOf(write)).Fn.return_type.?).ErrorUnion.error_set, write){ .context = {} };
}
test "crash" {
diff --git a/test/stage1/behavior/error.zig b/test/stage1/behavior/error.zig
index 975e08b04f..9635f2870c 100644
--- a/test/stage1/behavior/error.zig
+++ b/test/stage1/behavior/error.zig
@@ -84,8 +84,8 @@ fn testErrorUnionType() void {
const x: anyerror!i32 = 1234;
if (x) |value| expect(value == 1234) else |_| unreachable;
expect(@typeInfo(@TypeOf(x)) == .ErrorUnion);
- expect(@typeInfo(@TypeOf(x).ErrorSet) == .ErrorSet);
- expect(@TypeOf(x).ErrorSet == anyerror);
+ expect(@typeInfo(@typeInfo(@TypeOf(x)).ErrorUnion.error_set) == .ErrorSet);
+ expect(@typeInfo(@TypeOf(x)).ErrorUnion.error_set == anyerror);
}
test "error set type" {
diff --git a/test/stage1/behavior/misc.zig b/test/stage1/behavior/misc.zig
index 57a9ba2576..a71d6f86f3 100644
--- a/test/stage1/behavior/misc.zig
+++ b/test/stage1/behavior/misc.zig
@@ -24,12 +24,6 @@ test "call disabled extern fn" {
disabledExternFn();
}
-test "floating point primitive bit counts" {
- expect(f16.bit_count == 16);
- expect(f32.bit_count == 32);
- expect(f64.bit_count == 64);
-}
-
test "short circuit" {
testShortCircuit(false, true);
comptime testShortCircuit(false, true);
@@ -577,10 +571,6 @@ test "slice string literal has correct type" {
comptime expect(@TypeOf(array[runtime_zero..]) == []const i32);
}
-test "pointer child field" {
- expect((*u32).Child == u32);
-}
-
test "struct inside function" {
testStructInFn();
comptime testStructInFn();
diff --git a/test/stage1/behavior/reflection.zig b/test/stage1/behavior/reflection.zig
index ab0a55092c..6d1c341713 100644
--- a/test/stage1/behavior/reflection.zig
+++ b/test/stage1/behavior/reflection.zig
@@ -2,23 +2,15 @@ const expect = @import("std").testing.expect;
const mem = @import("std").mem;
const reflection = @This();
-test "reflection: array, pointer, optional, error union type child" {
- comptime {
- expect(([10]u8).Child == u8);
- expect((*u8).Child == u8);
- expect((anyerror!u8).Payload == u8);
- expect((?u8).Child == u8);
- }
-}
-
test "reflection: function return type, var args, and param types" {
comptime {
- expect(@TypeOf(dummy).ReturnType == i32);
- expect(!@TypeOf(dummy).is_var_args);
- expect(@TypeOf(dummy).arg_count == 3);
- expect(@typeInfo(@TypeOf(dummy)).Fn.args[0].arg_type.? == bool);
- expect(@typeInfo(@TypeOf(dummy)).Fn.args[1].arg_type.? == i32);
- expect(@typeInfo(@TypeOf(dummy)).Fn.args[2].arg_type.? == f32);
+ const info = @typeInfo(@TypeOf(dummy)).Fn;
+ expect(info.return_type.? == i32);
+ expect(!info.is_var_args);
+ expect(info.args.len == 3);
+ expect(info.args[0].arg_type.? == bool);
+ expect(info.args[1].arg_type.? == i32);
+ expect(info.args[2].arg_type.? == f32);
}
}