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