|
14 | 14 |
|
15 | 15 | """Tests for truth.bzl.""" |
16 | 16 |
|
17 | | -load("@bazel_skylib//lib:unittest.bzl", ut_asserts = "asserts") |
18 | | -load("//lib:truth.bzl", "matching", "subjects", "truth") |
19 | 17 | load("//lib:analysis_test.bzl", "analysis_test", "test_suite") |
| 18 | +load("//lib:truth.bzl", "matching", "subjects", "truth") |
| 19 | +load("@bazel_skylib//lib:unittest.bzl", ut_asserts = "asserts") |
20 | 20 |
|
21 | 21 | # Bazel 5 has a bug where every access of testing.ExecutionInfo is a new |
22 | 22 | # object that isn't equal to itself. This is fixed in Bazel 6. |
@@ -538,6 +538,34 @@ def _collection_contains_exactly_test(env, _target): |
538 | 538 | msg = "check same elements out of order", |
539 | 539 | ) |
540 | 540 |
|
| 541 | + subject = truth.expect(fake_env).that_collection(("one", "four", "three", "two", "five")) |
| 542 | + order = subject.contains_exactly(("one", "two", "three", "four", "five")) |
| 543 | + _assert_no_failures( |
| 544 | + fake_env, |
| 545 | + env = env, |
| 546 | + msg = "check same elements with expected in different order", |
| 547 | + ) |
| 548 | + order.in_order() |
| 549 | + _assert_failure( |
| 550 | + fake_env, |
| 551 | + [ |
| 552 | + "expected values all found, but with incorrect order:", |
| 553 | + "0: one found at offset 0", |
| 554 | + "1: two found at offset 3", |
| 555 | + "2: three found at offset 2", |
| 556 | + "3: four found at offset 1", |
| 557 | + "4: five found at offset 4", |
| 558 | + "actual values:", |
| 559 | + "0: one", |
| 560 | + "1: four", |
| 561 | + "2: three", |
| 562 | + "3: two", |
| 563 | + "4: five", |
| 564 | + ], |
| 565 | + env = env, |
| 566 | + msg = "check same elements out of order", |
| 567 | + ) |
| 568 | + |
541 | 569 | _end(env, fake_env) |
542 | 570 |
|
543 | 571 | _suite.append(collection_contains_exactly_test) |
|
0 commit comments