diff options
| author | Bruce Hill <bruce@bruce-hill.com> | 2025-09-21 16:54:36 -0400 |
|---|---|---|
| committer | Bruce Hill <bruce@bruce-hill.com> | 2025-09-21 16:54:36 -0400 |
| commit | 1cec086a6034ad546977cae7aeaf4bb876d21970 (patch) | |
| tree | cd2889aea7ca830359ba329a3f82b96e706bcdee /src/formatter | |
| parent | 0ab878ff4f72f7f6f6f64c1fc5d8023cd19fbe82 (diff) | |
Deprecate `>> x ... = val` form of doctests and rename them to 'debugdoctests-to-debuglog
logs', also add multi-expression support
Diffstat (limited to 'src/formatter')
| -rw-r--r-- | src/formatter/formatter.c | 16 | ||||
| -rw-r--r-- | src/formatter/utils.c | 8 |
2 files changed, 12 insertions, 12 deletions
diff --git a/src/formatter/formatter.c b/src/formatter/formatter.c index 69c1a213..42204b01 100644 --- a/src/formatter/formatter.c +++ b/src/formatter/formatter.c @@ -119,7 +119,7 @@ OptionalText_t format_inline_code(ast_t *ast, Table_t comments) { /*inline*/ case Extend: /*inline*/ case FunctionDef: /*inline*/ case ConvertDef: - /*inline*/ case DocTest: + /*inline*/ case DebugLog: return NONE_TEXT; /*inline*/ case Assert: { DeclareMatch(assert, ast, Assert); @@ -775,13 +775,13 @@ Text_t format_code(ast_t *ast, Table_t comments, Text_t indent) { return Texts(termify(call->self, comments, indent), ".", Text$from_str(call->name), "(", args, Text$has(args, Text("\n")) ? Texts("\n", indent) : EMPTY_TEXT, ")"); } - /*multiline*/ case DocTest: { - DeclareMatch(test, ast, DocTest); - Text_t expr = fmt(test->expr, comments, indent); - Text_t code = Texts(">> ", expr); - if (test->expected) { - Text_t expected = fmt(test->expected, comments, indent); - code = Texts(code, "\n", indent, "= ", expected); + /*multiline*/ case DebugLog: { + DeclareMatch(debug, ast, DebugLog); + Text_t code = Texts(">> "); + for (ast_list_t *value = debug->values; value; value = value->next) { + Text_t expr = fmt(value->ast, comments, indent); + code = Texts(code, expr); + if (value->next) code = Texts(code, ", "); } return code; } diff --git a/src/formatter/utils.c b/src/formatter/utils.c index bbe74d7f..9cd0227d 100644 --- a/src/formatter/utils.c +++ b/src/formatter/utils.c @@ -44,16 +44,16 @@ CONSTFUNC int suggested_blank_lines(ast_t *first, ast_t *second) { for (;;) { if (first->tag == Declare && Match(first, Declare)->value) { first = Match(first, Declare)->value; - } else if (first->tag == DocTest && Match(first, DocTest)->expr && Match(first, DocTest)->expected == NULL) { - first = Match(first, DocTest)->expr; + } else if (first->tag == DebugLog) { + return 1; } else break; } for (;;) { if (second->tag == Declare && Match(second, Declare)->value) { second = Match(second, Declare)->value; - } else if (second->tag == DocTest && Match(second, DocTest)->expr && Match(second, DocTest)->expected == NULL) { - second = Match(second, DocTest)->expr; + } else if (second->tag == DebugLog) { + return 1; } else break; } |
