1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
//! AST formatting smoke tests — snapshot the `--ast` dump.
//!
//! One minimal test per top-level `Expression`/`Term` variant (plus the
//! `TriviaPiece` shapes and `Binder`/`Parameter` smoke) so a regression in any
//! variant fails fast with a small diff. Anything more complex lives in
//! `regression_tests/`.
use crate::oracle_tests;
oracle_tests! {
test_ast_format;
// -----------------------------------------------------------------------
// Term variants
// -----------------------------------------------------------------------
// Term::Token
test_integer => ["42"],
// Term::SimpleString
test_simple_string => ["\"hello\""],
// Term::IndentedString
test_indented_string => ["''hello''"],
// Term::Path
test_relative_path => ["./foo/bar"],
// Term::List
test_simple_list => ["[1 2 3]"],
// Term::Set / Binder::Assignment
test_simple_set => ["{a=1;}"],
// Selector list inside a Binder::Assignment key
test_dotted_path => ["{a.b.c=1;}"],
// Binder::Inherit
test_inherit => ["{inherit a;}"],
// Term::Selection (with `or` default)
test_selection_with_default => ["x.y or 42"],
// Term::Parenthesized
test_parenthesized => ["(1 + 2)"],
// -----------------------------------------------------------------------
// Expression variants
// -----------------------------------------------------------------------
test_with => ["with x; y"],
test_let_simple => ["let a=1; in a"],
test_assert => ["assert true; 42"],
test_if_then_else => ["if true then 1 else 2"],
// Expression::Lambda / Parameter::ID
test_simple_lambda => ["x: x"],
// Parameter::Set
test_set_pattern => ["{x}: x"],
test_function_application => ["f x"],
// Expression::Operation
test_addition => ["1 + 2"],
// `<=` / `>=` are not exercised by any other oracle test; keep one
// smoke so the corresponding Token Display / pretty arms stay covered.
test_comparison_operators => ["a <= b && c >= d"],
test_member_check => ["x ? y"],
test_negation => ["-5"],
// Expression::Not
test_boolean_not => ["!true"],
// -----------------------------------------------------------------------
// TriviaPiece shapes
// -----------------------------------------------------------------------
test_line_comment => ["# comment\n42"],
test_block_comment => ["/* block */ 42"],
// -----------------------------------------------------------------------
// Non-redundant regression kept here (no equivalent in regression_tests/)
// -----------------------------------------------------------------------
// Inside multi-line strings, # starts literal text, not a comment.
// The hash and text should be a TextPart, not LineComment trivia.
test_string_hash_not_comment => [
r"''
foo ${bar}
# TODO: comment
badFiles=$(find ${filteredHead})
''",
],
}