aboutsummaryrefslogtreecommitdiff
path: root/std/testing.zig
diff options
context:
space:
mode:
authorAndrew Kelley <andrew@ziglang.org>2019-08-15 14:01:01 -0700
committerGitHub <noreply@github.com>2019-08-15 14:01:01 -0700
commit8b97a1aee2b161b9604d3b0c88166d0f0aef7e64 (patch)
tree7a8d65ad3ef59679cf4318a2fea88b6979207de4 /std/testing.zig
parent729807203a4ef162f39656be062dd11a428af8e3 (diff)
parentd3672493cc6ad5085f202df1859b13b4ae4dec96 (diff)
downloadzig-8b97a1aee2b161b9604d3b0c88166d0f0aef7e64.tar.gz
zig-8b97a1aee2b161b9604d3b0c88166d0f0aef7e64.zip
Merge pull request #3033 from ziglang/rewrite-coroutines
rework async function semantics
Diffstat (limited to 'std/testing.zig')
-rw-r--r--std/testing.zig51
1 files changed, 26 insertions, 25 deletions
diff --git a/std/testing.zig b/std/testing.zig
index 4568e024e2..7f347b0c24 100644
--- a/std/testing.zig
+++ b/std/testing.zig
@@ -25,36 +25,37 @@ pub fn expectError(expected_error: anyerror, actual_error_union: var) void {
/// The types must match exactly.
pub fn expectEqual(expected: var, actual: @typeOf(expected)) void {
switch (@typeInfo(@typeOf(actual))) {
- TypeId.NoReturn,
- TypeId.BoundFn,
- TypeId.ArgTuple,
- TypeId.Opaque,
+ .NoReturn,
+ .BoundFn,
+ .ArgTuple,
+ .Opaque,
+ .Frame,
+ .AnyFrame,
=> @compileError("value of type " ++ @typeName(@typeOf(actual)) ++ " encountered"),
- TypeId.Undefined,
- TypeId.Null,
- TypeId.Void,
+ .Undefined,
+ .Null,
+ .Void,
=> return,
- TypeId.Type,
- TypeId.Bool,
- TypeId.Int,
- TypeId.Float,
- TypeId.ComptimeFloat,
- TypeId.ComptimeInt,
- TypeId.EnumLiteral,
- TypeId.Enum,
- TypeId.Fn,
- TypeId.Promise,
- TypeId.Vector,
- TypeId.ErrorSet,
+ .Type,
+ .Bool,
+ .Int,
+ .Float,
+ .ComptimeFloat,
+ .ComptimeInt,
+ .EnumLiteral,
+ .Enum,
+ .Fn,
+ .Vector,
+ .ErrorSet,
=> {
if (actual != expected) {
std.debug.panic("expected {}, found {}", expected, actual);
}
},
- TypeId.Pointer => |pointer| {
+ .Pointer => |pointer| {
switch (pointer.size) {
builtin.TypeInfo.Pointer.Size.One,
builtin.TypeInfo.Pointer.Size.Many,
@@ -76,22 +77,22 @@ pub fn expectEqual(expected: var, actual: @typeOf(expected)) void {
}
},
- TypeId.Array => |array| expectEqualSlices(array.child, &expected, &actual),
+ .Array => |array| expectEqualSlices(array.child, &expected, &actual),
- TypeId.Struct => |structType| {
+ .Struct => |structType| {
inline for (structType.fields) |field| {
expectEqual(@field(expected, field.name), @field(actual, field.name));
}
},
- TypeId.Union => |union_info| {
+ .Union => |union_info| {
if (union_info.tag_type == null) {
@compileError("Unable to compare untagged union values");
}
@compileError("TODO implement testing.expectEqual for tagged unions");
},
- TypeId.Optional => {
+ .Optional => {
if (expected) |expected_payload| {
if (actual) |actual_payload| {
expectEqual(expected_payload, actual_payload);
@@ -105,7 +106,7 @@ pub fn expectEqual(expected: var, actual: @typeOf(expected)) void {
}
},
- TypeId.ErrorUnion => {
+ .ErrorUnion => {
if (expected) |expected_payload| {
if (actual) |actual_payload| {
expectEqual(expected_payload, actual_payload);