|
| 1 | +// This test ensures that the macro expansion is generated and working as expected. |
| 2 | +go-to: "file://" + |DOC_PATH| + "/src/macro_expansion/lib.rs.html" |
| 3 | + |
| 4 | +define-function: ( |
| 5 | + "check-expansion", |
| 6 | + [line, original_content], |
| 7 | + block { |
| 8 | + assert-text: ("a[id='" + |line| + "'] + .expansion .original", |original_content|) |
| 9 | + // The "original" content should be expanded. |
| 10 | + assert-css: ("a[id='" + |line| + "'] + .expansion .original", {"display": "inline"}) |
| 11 | + // The expanded macro should be hidden. |
| 12 | + assert-css: ("a[id='" + |line| + "'] + .expansion .expanded", {"display": "none"}) |
| 13 | + |
| 14 | + // We "expand" the macro. |
| 15 | + click: "a[id='" + |line| + "'] + .expansion label" |
| 16 | + // The "original" content is hidden. |
| 17 | + assert-css: ("a[id='" + |line| + "'] + .expansion .original", {"display": "none"}) |
| 18 | + // The expanded macro is visible. |
| 19 | + assert-css: ("a[id='" + |line| + "'] + .expansion .expanded", {"display": "inline"}) |
| 20 | + |
| 21 | + // We collapse the macro. |
| 22 | + click: "a[id='" + |line| + "'] + .expansion label" |
| 23 | + // The "original" content is expanded. |
| 24 | + assert-css: ("a[id='" + |line| + "'] + .expansion .original", {"display": "inline"}) |
| 25 | + // The expanded macro is hidden. |
| 26 | + assert-css: ("a[id='" + |line| + "'] + .expansion .expanded", {"display": "none"}) |
| 27 | + } |
| 28 | +) |
| 29 | + |
| 30 | +// First we check the derive macro expansion at line 12. |
| 31 | +call-function: ("check-expansion", {"line": 12, "original_content": "Debug"}) |
| 32 | +// Then we check the `bar` macro expansion at line 22. |
| 33 | +call-function: ("check-expansion", {"line": 22, "original_content": "bar!(y)"}) |
| 34 | +// Then we check the `println` macro expansion at line 23-25. |
| 35 | +call-function: ("check-expansion", {"line": 23, "original_content": 'println!(" |
| 36 | +24 {y} |
| 37 | +25 ")'}) |
| 38 | + |
| 39 | +// Then finally we check when there are two macro calls on a same line. |
| 40 | +assert-count: ("#expand-27 ~ .original", 2) |
| 41 | +assert-count: ("#expand-27 ~ .expanded", 2) |
| 42 | + |
| 43 | +store-value: (repeat_o, '/following-sibling::*[@class="original"]') |
| 44 | +store-value: (repeat_e, '/following-sibling::*[@class="expanded"]') |
| 45 | +assert-text: ('//*[@id="expand-27"]' + |repeat_o|, "stringify!(foo)") |
| 46 | +assert-text: ('//*[@id="expand-27"]' + |repeat_o| + |repeat_o|, "stringify!(bar)") |
| 47 | +assert-text: ('//*[@id="expand-27"]' + |repeat_e|, '"foo"') |
| 48 | +assert-text: ('//*[@id="expand-27"]' + |repeat_e| + |repeat_e|, '"bar"') |
| 49 | + |
| 50 | +// The "original" content should be expanded. |
| 51 | +assert-css: ('//*[@id="expand-27"]' + |repeat_o|, {"display": "inline"}) |
| 52 | +assert-css: ('//*[@id="expand-27"]' + |repeat_o| + |repeat_o|, {"display": "inline"}) |
| 53 | +// The expanded macro should be hidden. |
| 54 | +assert-css: ('//*[@id="expand-27"]' + |repeat_e|, {"display": "none"}) |
| 55 | +assert-css: ('//*[@id="expand-27"]' + |repeat_e| + |repeat_e|, {"display": "none"}) |
| 56 | + |
| 57 | +// We "expand" the macro (because the line starts with a string, the label is not at the "top |
| 58 | +// level" of the `<code>`, so we need to use a different selector). |
| 59 | +click: ".expansion label[for='expand-27']" |
| 60 | +// The "original" content is hidden. |
| 61 | +assert-css: ('//*[@id="expand-27"]' + |repeat_o|, {"display": "none"}) |
| 62 | +assert-css: ('//*[@id="expand-27"]' + |repeat_o| + |repeat_o|, {"display": "none"}) |
| 63 | +// The expanded macro is visible. |
| 64 | +assert-css: ('//*[@id="expand-27"]' + |repeat_e|, {"display": "inline"}) |
| 65 | +assert-css: ('//*[@id="expand-27"]' + |repeat_e| + |repeat_e|, {"display": "inline"}) |
| 66 | + |
| 67 | +// We collapse the macro. |
| 68 | +click: ".expansion label[for='expand-27']" |
| 69 | +// The "original" content is expanded. |
| 70 | +assert-css: ('//*[@id="expand-27"]' + |repeat_o|, {"display": "inline"}) |
| 71 | +assert-css: ('//*[@id="expand-27"]' + |repeat_o| + |repeat_o|, {"display": "inline"}) |
| 72 | +// The expanded macro is hidden. |
| 73 | +assert-css: ('//*[@id="expand-27"]' + |repeat_e|, {"display": "none"}) |
| 74 | +assert-css: ('//*[@id="expand-27"]' + |repeat_e| + |repeat_e|, {"display": "none"}) |
0 commit comments