clean up behavior test names

This commit is contained in:
Andrew Kelley 2017-05-23 21:38:31 -04:00
parent 0065eb7c80
commit 68add5d828
21 changed files with 89 additions and 89 deletions

View File

@ -25,7 +25,7 @@ fn getArrayLen(a: []const u32) -> usize {
a.len
}
test "voidArrays" {
test "void arrays" {
var array: [4]void = undefined;
array[0] = void{};
array[1] = array[2];
@ -33,14 +33,14 @@ test "voidArrays" {
assert(array.len == 4);
}
test "arrayLiteral" {
test "array literal" {
const hex_mult = []u16{4096, 256, 16, 1};
assert(hex_mult.len == 4);
assert(hex_mult[1] == 256);
}
test "arrayDotLenConstExpr" {
test "array dot len const expr" {
assert(comptime {some_array.len == 4});
}
@ -50,7 +50,7 @@ const ArrayDotLenConstExpr = struct {
const some_array = []u8 {0, 1, 2, 3};
test "nestedArrays" {
test "nested arrays" {
const array_of_strings = [][]const u8 {"hello", "this", "is", "my", "thing"};
for (array_of_strings) |s, i| {
if (i == 0) assert(mem.eql(u8, s, "hello"));
@ -69,7 +69,7 @@ const Sub = struct {
const Str = struct {
a: []Sub,
};
test "setGlobalVarArrayViaSliceEmbeddedInStruct" {
test "set global var array via slice embedded in struct" {
var s = Str { .a = s_array[0..]};
s.a[0].b = 1;

View File

@ -1,11 +1,11 @@
const assert = @import("std").debug.assert;
test "boolLiterals" {
test "bool literals" {
assert(true);
assert(!false);
}
test "castBoolToInt" {
test "cast bool to int" {
const t = true;
const f = false;
assert(i32(t) == i32(1));
@ -18,7 +18,7 @@ fn nonConstCastBoolToInt(t: bool, f: bool) {
assert(i32(f) == i32(0));
}
test "boolCmp" {
test "bool cmp" {
assert(testBoolCmp(true, false) == false);
}
fn testBoolCmp(a: bool, b: bool) -> bool {
@ -29,7 +29,7 @@ const global_f = false;
const global_t = true;
const not_global_f = !global_f;
const not_global_t = !global_t;
test "compileTimeBoolnot" {
test "compile time bool not" {
assert(not_global_f);
assert(!not_global_t);
}

View File

@ -8,12 +8,12 @@ test "int to ptr cast" {
assert(z == 13);
}
test "numLitIntToPtrCast" {
test "integer literal to pointer cast" {
const vga_mem = @intToPtr(&u16, 0xB8000);
assert(usize(vga_mem) == 0xB8000);
}
test "pointerReinterpretConstFloatToInt" {
test "pointer reinterpret const float to int" {
const float: f64 = 5.99999999999994648725e-01;
const float_ptr = &float;
const int_ptr = @ptrCast(&i32, float_ptr);

View File

@ -3,7 +3,7 @@ const assert = debug.assert;
var argv: &const &const u8 = undefined;
test "constSliceChild" {
test "const slice child" {
const strs = ([]&const u8) {
c"one",
c"two",

View File

@ -1,7 +1,7 @@
const assert = @import("std").debug.assert;
const mem = @import("std").mem;
test "enumType" {
test "enum type" {
const foo1 = Foo.One {13};
const foo2 = Foo.Two { Point { .x = 1234, .y = 5678, }};
const bar = Bar.B;
@ -14,7 +14,7 @@ test "enumType" {
assert(@sizeOf(Bar) == 1);
}
test "enumAsReturnValue" {
test "enum as return value" {
switch (returnAnInt(13)) {
Foo.One => |value| assert(value == 13),
else => unreachable,
@ -42,7 +42,7 @@ fn returnAnInt(x: i32) -> Foo {
}
test "constantEnumWithPayload" {
test "constant enum with payload" {
var empty = AnEnumWithPayload.Empty;
var full = AnEnumWithPayload.Full {13};
shouldBeEmpty(empty);
@ -78,7 +78,7 @@ const Number = enum {
Four,
};
test "enumToInt" {
test "enum to int" {
shouldEqual(Number.Zero, 0);
shouldEqual(Number.One, 1);
shouldEqual(Number.Two, 2);
@ -91,7 +91,7 @@ fn shouldEqual(n: Number, expected: usize) {
}
test "intToEnum" {
test "int to enum" {
testIntToEnumEval(3);
}
fn testIntToEnumEval(x: i32) {
@ -106,7 +106,7 @@ const IntToEnumNumber = enum {
};
test "enumTagName builtin function" {
test "@enumTagName" {
assert(mem.eql(u8, testEnumTagNameBare(BareNumber.Three), "Three"));
comptime assert(mem.eql(u8, testEnumTagNameBare(BareNumber.Three), "Three"));
}

View File

@ -14,7 +14,7 @@ const ET = enum {
}
};
test "enumWithMembers" {
test "enum with members" {
const a = ET.SINT { -42 };
const b = ET.UINT { 42 };
var buf: [20]u8 = undefined;

View File

@ -15,7 +15,7 @@ pub fn baz() -> %i32 {
return y + 1;
}
test "errorWrapping" {
test "error wrapping" {
assert(%%baz() == 15);
}
@ -24,7 +24,7 @@ fn gimmeItBroke() -> []const u8 {
@errorName(error.ItBroke)
}
test "errorName" {
test "@errorName" {
assert(mem.eql(u8, @errorName(error.AnError), "AnError"));
assert(mem.eql(u8, @errorName(error.ALongerErrorName), "ALongerErrorName"));
}
@ -32,7 +32,7 @@ error AnError;
error ALongerErrorName;
test "errorValues" {
test "error values" {
const a = i32(error.err1);
const b = i32(error.err2);
assert(a != b);
@ -41,7 +41,7 @@ error err1;
error err2;
test "redefinitionOfErrorValuesAllowed" {
test "redefinition of error values allowed" {
shouldBeNotEqual(error.AnError, error.SecondError);
}
error AnError;
@ -52,7 +52,7 @@ fn shouldBeNotEqual(a: error, b: error) {
}
test "errBinaryOperator" {
test "error binary operator" {
const a = errBinaryOperatorG(true) %% 3;
const b = errBinaryOperatorG(false) %% 3;
assert(a == 3);
@ -68,14 +68,14 @@ fn errBinaryOperatorG(x: bool) -> %isize {
}
test "unwrapSimpleValueFromError" {
test "unwrap simple value from error" {
const i = %%unwrapSimpleValueFromErrorDo();
assert(i == 13);
}
fn unwrapSimpleValueFromErrorDo() -> %isize { 13 }
test "errReturnInAssignment" {
test "error return in assignment" {
%%doErrReturnInAssignment();
}

View File

@ -1,7 +1,7 @@
const assert = @import("std").debug.assert;
const builtin = @import("builtin");
test "compileTimeRecursion" {
test "compile time recursion" {
assert(some_data.len == 21);
}
var some_data: [usize(fibonacci(7))]u8 = undefined;
@ -16,11 +16,11 @@ fn unwrapAndAddOne(blah: ?i32) -> i32 {
return ??blah + 1;
}
const should_be_1235 = unwrapAndAddOne(1234);
test "testStaticAddOne" {
test "static add one" {
assert(should_be_1235 == 1235);
}
test "inlinedLoop" {
test "inlined loop" {
comptime var i = 0;
comptime var sum = 0;
inline while (i <= 5) : (i += 1)
@ -34,20 +34,20 @@ fn gimme1or2(comptime a: bool) -> i32 {
comptime var z: i32 = if (a) x else y;
return z;
}
test "inlineVariableGetsResultOfConstIf" {
test "inline variable gets result of const if" {
assert(gimme1or2(true) == 1);
assert(gimme1or2(false) == 2);
}
test "staticFunctionEvaluation" {
test "static function evaluation" {
assert(statically_added_number == 3);
}
const statically_added_number = staticAdd(1, 2);
fn staticAdd(a: i32, b: i32) -> i32 { a + b }
test "constExprEvalOnSingleExprBlocks" {
test "const expr eval on single expr blocks" {
assert(constExprEvalOnSingleExprBlocksFn(1, true) == 3);
}
@ -66,7 +66,7 @@ fn constExprEvalOnSingleExprBlocksFn(x: i32, b: bool) -> i32 {
test "staticallyInitalizedList" {
test "statically initialized list" {
assert(static_point_list[0].x == 1);
assert(static_point_list[0].y == 2);
assert(static_point_list[1].x == 3);
@ -85,7 +85,7 @@ fn makePoint(x: i32, y: i32) -> Point {
}
test "staticEvalListInit" {
test "static eval list init" {
assert(static_vec3.data[2] == 1.0);
assert(vec3(0.0, 0.0, 3.0).data[2] == 3.0);
}
@ -100,14 +100,14 @@ pub fn vec3(x: f32, y: f32, z: f32) -> Vec3 {
}
test "constantExpressions" {
test "constant expressions" {
var array : [array_size]u8 = undefined;
assert(@sizeOf(@typeOf(array)) == 20);
}
const array_size : u8 = 20;
test "constantStructWithNegation" {
test "constant struct with negation" {
assert(vertices[0].x == -0.6);
}
const Vertex = struct {
@ -124,7 +124,7 @@ const vertices = []Vertex {
};
test "staticallyInitalizedStruct" {
test "statically initialized struct" {
st_init_str_foo.x += 1;
assert(st_init_str_foo.x == 14);
}
@ -135,14 +135,14 @@ const StInitStrFoo = struct {
var st_init_str_foo = StInitStrFoo { .x = 13, .y = true, };
test "staticallyInitializedArrayLiteral" {
test "statically initalized array literal" {
const y : [4]u8 = st_init_arr_lit_x;
assert(y[3] == 4);
}
const st_init_arr_lit_x = []u8{1,2,3,4};
test "constSlice" {
test "const slice" {
comptime {
const a = "1234567890";
assert(a.len == 10);
@ -152,7 +152,7 @@ test "constSlice" {
}
}
test "tryToTrickEvalWithRuntimeIf" {
test "try to trick eval with runtime if" {
assert(testTryToTrickEvalWithRuntimeIf(true) == 10);
}
@ -178,7 +178,7 @@ fn max(comptime T: type, a: T, b: T) -> T {
fn letsTryToCompareBools(a: bool, b: bool) -> bool {
max(bool, a, b)
}
test "inlinedBlockAndRuntimeBlockPhi" {
test "inlined block and runtime block phi" {
assert(letsTryToCompareBools(true, true));
assert(letsTryToCompareBools(true, false));
assert(letsTryToCompareBools(false, true));
@ -217,7 +217,7 @@ fn performFn(comptime prefix_char: u8, start_value: i32) -> i32 {
return result;
}
test "comptimeIterateOverFnPtrList" {
test "comptime iterate over fn ptr list" {
assert(performFn('t', 1) == 6);
assert(performFn('o', 0) == 1);
assert(performFn('w', 99) == 99);
@ -256,13 +256,13 @@ var simple_struct = SimpleStruct{ .field = 1234, };
const bound_fn = simple_struct.method;
test "callMethodOnBoundFnReferringToVarInstance" {
test "call method on bound fn referring to var instance" {
assert(bound_fn() == 1237);
}
test "ptrToLocalArrayArgumentAtComptime" {
test "ptr to local array argument at comptime" {
comptime {
var bytes: [10]u8 = undefined;
modifySomeBytes(bytes[0..]);

View File

@ -15,7 +15,7 @@ fn getErrInt() -> %i32 { 0 }
error ItBroke;
test "irBlockDeps" {
test "ir block deps" {
assert(%%foo(1) == 0);
assert(%%foo(2) == 0);
}

View File

@ -85,7 +85,7 @@ test "assignment operators" {
i |= 3; assert(i == 7);
}
test "threeExprInARow" {
test "three expr in a row" {
testThreeExprInARow(false, true);
comptime testThreeExprInARow(false, true);
}

View File

@ -1,7 +1,7 @@
const builtin = @import("builtin");
const assert = @import("std").debug.assert;
test "namespaceDependsOnCompileVar" {
test "namespace depends on compile var" {
if (some_namespace.a_bool) {
assert(some_namespace.a_bool);
} else {

View File

@ -1,6 +1,6 @@
const assert = @import("std").debug.assert;
test "nullableType" {
test "nullable type" {
const x : ?bool = true;
if (x) |y| {
@ -37,7 +37,7 @@ test "test maybe object and get a pointer to the inner value" {
}
test "rhsMaybeUnwrapReturn" {
test "rhs maybe unwrap return" {
const x: ?bool = true;
const y = x ?? return;
}
@ -61,7 +61,7 @@ fn foo(x: ?i32) -> ?bool {
}
test "ifVarMaybePointer" {
test "if var maybe pointer" {
assert(shouldBeAPlus1(Particle {.a = 14, .b = 1, .c = 1, .d = 1}) == 15);
}
fn shouldBeAPlus1(p: &const Particle) -> u64 {
@ -82,7 +82,7 @@ const Particle = struct {
};
test "nullLiteralOutsideFunction" {
test "null literal outside function" {
const is_null = here_is_a_null_literal.context == null;
assert(is_null);
@ -97,7 +97,7 @@ const here_is_a_null_literal = SillyStruct {
};
test "testNullRuntime" {
test "test null runtime" {
testTestNullRuntime(null);
}
fn testTestNullRuntime(x: ?i32) {
@ -105,7 +105,7 @@ fn testTestNullRuntime(x: ?i32) {
assert(!(x != null));
}
test "nullableVoid" {
test "nullable void" {
nullableVoidImpl();
comptime nullableVoidImpl();
}

View File

@ -1,13 +1,13 @@
const other = @import("other.zig");
const assert = @import("std").debug.assert;
test "pubEnum" {
test "pub enum" {
pubEnumTest(other.APubEnum.Two);
}
fn pubEnumTest(foo: other.APubEnum) {
assert(foo == other.APubEnum.Two);
}
test "castWithImportedSymbol" {
test "cast with imported symbol" {
assert(other.size_t(42) == 42);
}

View File

@ -5,12 +5,12 @@ const StructWithNoFields = struct {
};
const empty_global_instance = StructWithNoFields {};
test "callStructStaticMethod" {
test "call struct static method" {
const result = StructWithNoFields.add(3, 4);
assert(result == 7);
}
test "returnEmptyStructInstance" {
test "return empty struct instance" {
_ = returnEmptyStructInstance();
}
fn returnEmptyStructInstance() -> StructWithNoFields {
@ -19,11 +19,11 @@ fn returnEmptyStructInstance() -> StructWithNoFields {
const should_be_11 = StructWithNoFields.add(5, 6);
test "invokeStaticMethodInGlobalScope" {
test "invake static method in global scope" {
assert(should_be_11 == 11);
}
test "voidStructFields" {
test "void struct fields" {
const foo = VoidStructFieldsFoo {
.a = void{},
.b = 1,
@ -39,7 +39,7 @@ const VoidStructFieldsFoo = struct {
};
test "fn" {
test "structs" {
var foo: StructFoo = undefined;
@memset(@ptrCast(&u8, &foo), 0, @sizeOf(StructFoo));
foo.a += 1;
@ -70,7 +70,7 @@ const Val = struct {
x: i32,
};
test "structPointToSelf" {
test "struct point to self" {
var root : Node = undefined;
root.val.x = 1;
@ -83,7 +83,7 @@ test "structPointToSelf" {
assert(node.next.next.next.val.x == 1);
}
test "structByvalAssign" {
test "struct byval assign" {
var foo1 : StructFoo = undefined;
var foo2 : StructFoo = undefined;
@ -100,7 +100,7 @@ fn structInitializer() {
}
test "fnCallOfStructField" {
test "fn call of struct field" {
assert(callStructField(Foo {.ptr = aFunc,}) == 13);
}
@ -115,7 +115,7 @@ fn callStructField(foo: &const Foo) -> i32 {
}
test "storeMemberFunctionInVariable" {
test "store member function in variable" {
const instance = MemberFnTestFoo { .x = 1234, };
const memberFn = MemberFnTestFoo.member;
const result = memberFn(instance);
@ -127,13 +127,13 @@ const MemberFnTestFoo = struct {
};
test "callMemberFunctionDirectly" {
test "call member function directly" {
const instance = MemberFnTestFoo { .x = 1234, };
const result = MemberFnTestFoo.member(instance);
assert(result == 1234);
}
test "memberFunctions" {
test "member functions" {
const r = MemberFnRand {.seed = 1234};
assert(r.getSeed() == 1234);
}
@ -144,7 +144,7 @@ const MemberFnRand = struct {
}
};
test "returnStructByvalFromFunction" {
test "return struct byval from function" {
const bar = makeBar(1234, 5678);
assert(bar.y == 5678);
}
@ -159,7 +159,7 @@ fn makeBar(x: i32, y: i32) -> Bar {
}
}
test "emptyStructMethodCall" {
test "empty struct method call" {
const es = EmptyStruct{};
assert(es.method() == 1234);
}
@ -170,7 +170,7 @@ const EmptyStruct = struct {
};
test "returnEmptyStructFromFn" {
test "return empty struct from fn" {
_ = testReturnEmptyStructFromFn();
}
const EmptyStruct2 = struct {};
@ -178,7 +178,7 @@ fn testReturnEmptyStructFromFn() -> EmptyStruct2 {
EmptyStruct2 {}
}
test "passSliceOfEmptyStructToFn" {
test "pass slice of empty struct to fn" {
assert(testPassSliceOfEmptyStructToFn([]EmptyStruct2{ EmptyStruct2{} }) == 1);
}
fn testPassSliceOfEmptyStructToFn(slice: []const EmptyStruct2) -> usize {
@ -190,7 +190,7 @@ const APackedStruct = packed struct {
y: u8,
};
test "packedStruct" {
test "packed struct" {
var foo = APackedStruct {
.x = 1,
.y = 2,
@ -216,7 +216,7 @@ const bit_field_1 = BitField1 {
.c = 3,
};
test "bitFieldAccess" {
test "bit field access" {
var data = bit_field_1;
assert(getA(&data) == 1);
assert(getB(&data) == 2);
@ -254,7 +254,7 @@ const Foo96Bits = packed struct {
d: u24,
};
test "packedStruct24Bits" {
test "packed struct 24bits" {
comptime {
assert(@sizeOf(Foo24Bits) == 3);
assert(@sizeOf(Foo96Bits) == 12);
@ -297,7 +297,7 @@ const FooArray24Bits = packed struct {
c: u16,
};
test "packedArray24Bits" {
test "packed array 24bits" {
comptime {
assert(@sizeOf([9]Foo24Bits) == 9 * 3);
assert(@sizeOf(FooArray24Bits) == 2 + 2 * 3 + 2);
@ -347,7 +347,7 @@ const FooArrayOfAligned = packed struct {
a: [2]FooStructAligned,
};
test "alignedArrayOfPackedStruct" {
test "aligned array of packed struct" {
comptime {
assert(@sizeOf(FooStructAligned) == 2);
assert(@sizeOf(FooArrayOfAligned) == 2 * 2);

View File

@ -21,7 +21,7 @@ fn doThing(form_id: u64) -> %FormValue {
}
}
test "switchProngReturnsErrorEnum" {
test "switch prong returns error enum" {
switch (%%doThing(17)) {
FormValue.Address => |payload| { assert(payload == 1); },
else => unreachable,

View File

@ -15,7 +15,7 @@ fn foo(id: u64) -> %FormValue {
}
}
test "switchProngImplicitCast" {
test "switch prong implicit cast" {
const result = switch (%%foo(2)) {
FormValue.One => false,
FormValue.Two => |x| x,

View File

@ -28,11 +28,11 @@ fn factorial(x: i32) -> i32 {
}
}
test "thisReferToModuleCallPrivateFn" {
test "this refer to module call private fn" {
assert(module.add(1, 2) == 3);
}
test "thisReferToContainer" {
test "this refer to container" {
var pt = Point(i32) {
.x = 12,
.y = 34,
@ -42,6 +42,6 @@ test "thisReferToContainer" {
assert(pt.y == 35);
}
test "thisReferToFn" {
test "this refer to fn" {
assert(factorial(5) == 120);
}

View File

@ -1,6 +1,6 @@
const assert = @import("std").debug.assert;
test "tryOnErrorUnion" {
test "try on error union" {
tryOnErrorUnionImpl();
comptime tryOnErrorUnionImpl();
@ -24,7 +24,7 @@ fn returnsTen() -> %i32 {
10
}
test "tryWithoutVars" {
test "try without vars" {
const result1 = if (failIfTrue(true)) {
1
} else |_| {

View File

@ -9,7 +9,7 @@ fn initStaticArray() -> [10]i32 {
return array;
}
const static_array = initStaticArray();
test "initStaticArrayToUndefined" {
test "init static array to undefined" {
assert(static_array[0] == 1);
assert(static_array[4] == 2);
assert(static_array[7] == 3);
@ -35,7 +35,7 @@ fn setFooX(foo: &Foo) {
foo.x = 2;
}
test "assignUndefinedToStruct" {
test "assign undefined to struct" {
comptime {
var foo: Foo = undefined;
setFooX(&foo);
@ -48,7 +48,7 @@ test "assignUndefinedToStruct" {
}
}
test "assignUndefinedToStructWithMethod" {
test "assign undefined to struct with method" {
comptime {
var foo: Foo = undefined;
foo.setFooXMethod();

View File

@ -8,7 +8,7 @@ fn add(args: ...) -> i32 {
return sum;
}
test "testAddArbitraryArgs" {
test "add arbitrary args" {
assert(add(i32(1), i32(2), i32(3), i32(4)) == 10);
assert(add(i32(1234)) == 1234);
assert(add() == 0);
@ -18,11 +18,11 @@ fn readFirstVarArg(args: ...) {
const value = args[0];
}
test "sendVoidArgToVarArgs" {
test "send void arg to var args" {
readFirstVarArg({});
}
test "testPassArgsDirectly" {
test "pass args directly" {
assert(addSomeStuff(i32(1), i32(2), i32(3), i32(4)) == 10);
assert(addSomeStuff(i32(1234)) == 1234);
assert(addSomeStuff() == 0);

View File

@ -6,7 +6,7 @@ const Foo = struct {
c: void,
};
test "compareVoidWithVoidCompileTimeKnown" {
test "compare void with void compile time known" {
comptime {
const foo = Foo {
.a = {},