| ... | @@ -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 | }; |
| 365 | | 365 | |
| | 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 | } |
| 371 | | 374 | |
| 372 | pub fn hasFields(comptime T: type, comptime names: var) bool { | 375 | pub 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 | }; |
| 388 | | 391 | |
| | 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 | } |
| 394 | | 401 | |
| ... | @@ -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 | }; |
| 409 | | 416 | |
| | 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 | } |