authorgravatar for datamanrb@gmail.comdata-man <datamanrb@gmail.com> 2020-05-28 16:39:00+05:00
committergravatar for datamanrb@gmail.comdata-man <datamanrb@gmail.com> 2020-05-28 16:39:00+05:00
logf9bdf325d318347547b3ea7735367b56b4a26cd2
treefeb3fa2371096055fb3bfe011123b4f7acd91360
parent78a1f6976d625d23142f68ac47558b9766874276

Added tests with tuple


1 files changed, 10 insertions(+), 0 deletions(-)

lib/std/meta/trait.zig+10
...@@ -363,10 +363,13 @@ test "std.meta.trait.hasDecls" {...@@ -363,10 +363,13 @@ test "std.meta.trait.hasDecls" {
363 pub fn useless() void {}363 pub fn useless() void {}
364 };364 };
365365
366 const tuple = .{"a", "b", "c"};
367
366 testing.expect(!hasDecls(TestStruct1, .{"a"}));368 testing.expect(!hasDecls(TestStruct1, .{"a"}));
367 testing.expect(hasDecls(TestStruct2, .{"a", "b"}));369 testing.expect(hasDecls(TestStruct2, .{"a", "b"}));
368 testing.expect(hasDecls(TestStruct2, .{"a", "b", "useless"}));370 testing.expect(hasDecls(TestStruct2, .{"a", "b", "useless"}));
369 testing.expect(!hasDecls(TestStruct2, .{"a", "b", "c"}));371 testing.expect(!hasDecls(TestStruct2, .{"a", "b", "c"}));
372 testing.expect(!hasDecls(TestStruct2, tuple));
370}373}
371374
372pub fn hasFields(comptime T: type, comptime names: var) bool {375pub fn hasFields(comptime T: type, comptime names: var) bool {
...@@ -386,9 +389,13 @@ test "std.meta.trait.hasFields" {...@@ -386,9 +389,13 @@ test "std.meta.trait.hasFields" {
386 pub fn useless() void {}389 pub fn useless() void {}
387 };390 };
388391
392
393 const tuple = .{"a", "b", "c"};
394
389 testing.expect(!hasFields(TestStruct1, .{"a"}));395 testing.expect(!hasFields(TestStruct1, .{"a"}));
390 testing.expect(hasFields(TestStruct2, .{"a", "b"}));396 testing.expect(hasFields(TestStruct2, .{"a", "b"}));
391 testing.expect(hasFields(TestStruct2, .{"a", "b", "c"}));397 testing.expect(hasFields(TestStruct2, .{"a", "b", "c"}));
398 testing.expect(hasFields(TestStruct2, tuple));
392 testing.expect(!hasFields(TestStruct2, .{"a", "b", "useless"}));399 testing.expect(!hasFields(TestStruct2, .{"a", "b", "useless"}));
393}400}
394401
...@@ -407,7 +414,10 @@ test "std.meta.trait.hasFunctions" {...@@ -407,7 +414,10 @@ test "std.meta.trait.hasFunctions" {
407 fn b() void {}414 fn b() void {}
408 };415 };
409416
417 const tuple = .{"a", "b", "c"};
418
410 testing.expect(!hasFunctions(TestStruct1, .{"a"}));419 testing.expect(!hasFunctions(TestStruct1, .{"a"}));
411 testing.expect(hasFunctions(TestStruct2, .{"a", "b"}));420 testing.expect(hasFunctions(TestStruct2, .{"a", "b"}));
412 testing.expect(!hasFunctions(TestStruct2, .{"a", "b", "c"}));421 testing.expect(!hasFunctions(TestStruct2, .{"a", "b", "c"}));
422 testing.expect(!hasFunctions(TestStruct2, tuple));
413}423}