From 847c2c1580e386b8e85961d2d5b39d386adc551a Mon Sep 17 00:00:00 2001 From: cflmy Date: Fri, 20 Nov 2026 10:54:16 +0800 Subject: [PATCH] fix: float wire precision, native stack safety, refs diagnostics and fixtures Findings from the conformance corpus workstream, all fixed at the source: - value/wire: enable serde_json's float_roundtrip so typed wire floats keep their exact digits across foreign/plugin boundaries (Python pi*9 now stays 28.274333882308138). - host: default interpreter stack budget lowered to 128 frames so deeply recursive documents hit a structured resource.exhausted instead of exhausting the native debug-build Rust stack; --stack remains available. - frontend/map: calling an external HTTP(S) link is reported as ref.unresolved (consistent with other unresolvable call targets) instead of math.unsupported. - frontend/analyze: invalid front matter emits a single frontmatter.invalid diagnostic (the YAML error is not repeated by the imports pass). - spec/mapping: clarify that would-be execution nodes outside any function body are inert with a markdown.inert_executable warning (no "return outside a function" hard-error claim). - tests: add the conformance corpus and harness (150 AST goldens, 36 semantic goldens, 48 hard-error + 6 warning + 10 runtime-error negatives, CLI/module/ plugin integration tests, prose-invariance properties) and update the three reported observations to the fixed behaviour. --- Cargo.toml | 2 +- crates/cli/tests/conformance_ast.rs | 215 ++++++ crates/cli/tests/conformance_semantics.rs | 265 +++++++ crates/cli/tests/integration_cli.rs | 684 ++++++++++++++++++ crates/cli/tests/negative.rs | 286 ++++++++ crates/cli/tests/properties.rs | 412 +++++++++++ crates/marqdo-frontend/src/analyze.rs | 42 +- crates/marqdo-frontend/src/map.rs | 2 +- crates/marqdo-host/src/budget.rs | 6 +- spec/mapping.md | 8 +- tests/README.md | 167 +++++ tests/conformance/ast/001-atx-h1.ast.json | 28 + tests/conformance/ast/001-atx-h1.mq.md | 1 + tests/conformance/ast/002-atx-h2.ast.json | 28 + tests/conformance/ast/002-atx-h2.mq.md | 1 + tests/conformance/ast/003-atx-h3.ast.json | 28 + tests/conformance/ast/003-atx-h3.mq.md | 1 + tests/conformance/ast/004-atx-h4.ast.json | 28 + tests/conformance/ast/004-atx-h4.mq.md | 1 + tests/conformance/ast/005-atx-h5.ast.json | 28 + tests/conformance/ast/005-atx-h5.mq.md | 1 + tests/conformance/ast/006-atx-h6.ast.json | 28 + tests/conformance/ast/006-atx-h6.mq.md | 1 + .../ast/007-atx-closing-hashes.ast.json | 28 + .../ast/007-atx-closing-hashes.mq.md | 1 + .../ast/008-setext-level1.ast.json | 28 + tests/conformance/ast/008-setext-level1.mq.md | 2 + .../ast/009-setext-level2.ast.json | 28 + tests/conformance/ast/009-setext-level2.mq.md | 2 + .../ast/010-unicode-chinese-heading.ast.json | 47 ++ .../ast/010-unicode-chinese-heading.mq.md | 3 + .../ast/011-heading-cjk-emoji.ast.json | 28 + .../ast/011-heading-cjk-emoji.mq.md | 1 + .../ast/012-heading-empty.ast.json | 35 + tests/conformance/ast/012-heading-empty.mq.md | 3 + .../ast/013-heading-inline-markup.ast.json | 70 ++ .../ast/013-heading-inline-markup.mq.md | 1 + .../ast/014-heading-in-blockquote.ast.json | 37 + .../ast/014-heading-in-blockquote.mq.md | 1 + .../ast/015-heading-in-list-item.ast.json | 48 ++ .../ast/015-heading-in-list-item.mq.md | 1 + .../ast/016-heading-in-fenced-code.ast.json | 19 + .../ast/016-heading-in-fenced-code.mq.md | 3 + ...017-heading-whitespace-normalised.ast.json | 28 + .../017-heading-whitespace-normalised.mq.md | 1 + .../ast/018-heading-level-jump.ast.json | 66 ++ .../ast/018-heading-level-jump.mq.md | 5 + .../ast/019-paragraph-single.ast.json | 26 + .../ast/019-paragraph-single.mq.md | 1 + ...020-paragraph-multiline-softbreak.ast.json | 56 ++ .../020-paragraph-multiline-softbreak.mq.md | 3 + .../ast/021-hard-break-two-spaces.ast.json | 41 ++ .../ast/021-hard-break-two-spaces.mq.md | 2 + .../ast/022-hard-break-backslash.ast.json | 41 ++ .../ast/022-hard-break-backslash.mq.md | 2 + .../ast/023-empty-document.ast.json | 7 + .../conformance/ast/023-empty-document.mq.md | 0 .../ast/024-whitespace-only-document.ast.json | 7 + .../ast/024-whitespace-only-document.mq.md | 3 + .../conformance/ast/025-bom-document.ast.json | 45 ++ tests/conformance/ast/025-bom-document.mq.md | 3 + .../ast/026-mixed-paragraph-blocks.ast.json | 62 ++ .../ast/026-mixed-paragraph-blocks.mq.md | 5 + .../ast/027-strong-asterisk.ast.json | 35 + .../conformance/ast/027-strong-asterisk.mq.md | 1 + .../ast/028-strong-underscore.ast.json | 35 + .../ast/028-strong-underscore.mq.md | 1 + .../ast/029-emph-asterisk.ast.json | 35 + tests/conformance/ast/029-emph-asterisk.mq.md | 1 + .../ast/030-emph-underscore.ast.json | 35 + .../conformance/ast/030-emph-underscore.mq.md | 1 + .../ast/031-strong-emph-nested.ast.json | 44 ++ .../ast/031-strong-emph-nested.mq.md | 1 + .../ast/032-emph-in-strong.ast.json | 60 ++ .../conformance/ast/032-emph-in-strong.mq.md | 1 + .../ast/033-strong-in-emph.ast.json | 60 ++ .../conformance/ast/033-strong-in-emph.mq.md | 1 + .../ast/034-intraword-underscore.ast.json | 26 + .../ast/034-intraword-underscore.mq.md | 1 + .../ast/035-multiline-emphasis.ast.json | 50 ++ .../ast/035-multiline-emphasis.mq.md | 2 + .../036-emphasis-with-punctuation.ast.json | 76 ++ .../ast/036-emphasis-with-punctuation.mq.md | 1 + .../ast/037-strong-with-code-span.ast.json | 36 + .../ast/037-strong-with-code-span.mq.md | 1 + .../ast/038-emph-with-code-span.ast.json | 36 + .../ast/038-emph-with-code-span.mq.md | 1 + .../ast/039-code-single-tick.ast.json | 27 + .../ast/039-code-single-tick.mq.md | 1 + .../ast/040-code-double-tick.ast.json | 27 + .../ast/040-code-double-tick.mq.md | 1 + .../ast/041-code-triple-tick.ast.json | 27 + .../ast/041-code-triple-tick.mq.md | 1 + .../ast/042-code-with-spaces.ast.json | 27 + .../ast/042-code-with-spaces.mq.md | 1 + tests/conformance/ast/043-code-empty.ast.json | 26 + tests/conformance/ast/043-code-empty.mq.md | 1 + .../ast/044-code-with-special-chars.ast.json | 27 + .../ast/044-code-with-special-chars.mq.md | 1 + .../ast/045-code-multiline-payload.ast.json | 27 + .../ast/045-code-multiline-payload.mq.md | 2 + .../ast/046-fenced-no-language.ast.json | 19 + .../ast/046-fenced-no-language.mq.md | 3 + .../ast/047-fenced-with-language.ast.json | 19 + .../ast/047-fenced-with-language.mq.md | 3 + .../ast/048-fenced-info-multiword.ast.json | 19 + .../ast/048-fenced-info-multiword.mq.md | 3 + .../conformance/ast/049-fenced-tilde.ast.json | 19 + tests/conformance/ast/049-fenced-tilde.mq.md | 3 + .../ast/050-indented-code.ast.json | 19 + tests/conformance/ast/050-indented-code.mq.md | 2 + .../ast/051-fenced-unclosed.ast.json | 19 + .../conformance/ast/051-fenced-unclosed.mq.md | 2 + .../ast/052-fenced-with-tabs.ast.json | 19 + .../ast/052-fenced-with-tabs.mq.md | 3 + ...053-indented-code-after-paragraph.ast.json | 36 + .../053-indented-code-after-paragraph.mq.md | 3 + .../ast/054-fenced-in-list.ast.json | 56 ++ .../conformance/ast/054-fenced-in-list.mq.md | 5 + .../conformance/ast/055-inline-math.ast.json | 43 ++ tests/conformance/ast/055-inline-math.mq.md | 1 + .../ast/056-inline-display-math.ast.json | 43 ++ .../ast/056-inline-display-math.mq.md | 1 + tests/conformance/ast/057-block-math.ast.json | 17 + tests/conformance/ast/057-block-math.mq.md | 3 + .../ast/058-block-math-fraction.ast.json | 17 + .../ast/058-block-math-fraction.mq.md | 3 + .../ast/059-math-unclosed.ast.json | 26 + tests/conformance/ast/059-math-unclosed.mq.md | 1 + .../ast/060-math-escaped-dollar.ast.json | 26 + .../ast/060-math-escaped-dollar.mq.md | 1 + .../ast/061-math-in-paragraph-mixed.ast.json | 68 ++ .../ast/061-math-in-paragraph-mixed.mq.md | 1 + .../conformance/ast/062-table-basic.ast.json | 154 ++++ tests/conformance/ast/062-table-basic.mq.md | 4 + .../ast/063-table-alignments.ast.json | 145 ++++ .../ast/063-table-alignments.mq.md | 3 + .../ast/064-table-escaped-pipe.ast.json | 111 +++ .../ast/064-table-escaped-pipe.mq.md | 3 + .../ast/065-table-missing-cells.ast.json | 196 +++++ .../ast/065-table-missing-cells.mq.md | 4 + .../ast/066-table-inline-markup.ast.json | 128 ++++ .../ast/066-table-inline-markup.mq.md | 3 + .../ast/067-table-no-leading-pipes.ast.json | 110 +++ .../ast/067-table-no-leading-pipes.mq.md | 3 + .../ast/068-table-empty-cells.ast.json | 90 +++ .../ast/068-table-empty-cells.mq.md | 3 + .../conformance/ast/069-bullet-dash.ast.json | 72 ++ tests/conformance/ast/069-bullet-dash.mq.md | 2 + .../ast/070-bullet-markers-mixed.ast.json | 120 +++ .../ast/070-bullet-markers-mixed.mq.md | 3 + .../ast/071-bullet-nested.ast.json | 135 ++++ tests/conformance/ast/071-bullet-nested.mq.md | 4 + .../ast/072-ordered-start-3.ast.json | 73 ++ .../conformance/ast/072-ordered-start-3.mq.md | 2 + .../ast/073-ordered-paren-delimiter.ast.json | 73 ++ .../ast/073-ordered-paren-delimiter.mq.md | 2 + .../ast/074-ordered-nested.ast.json | 137 ++++ .../conformance/ast/074-ordered-nested.mq.md | 4 + tests/conformance/ast/075-list-tight.ast.json | 98 +++ tests/conformance/ast/075-list-tight.mq.md | 3 + tests/conformance/ast/076-list-loose.ast.json | 98 +++ tests/conformance/ast/076-list-loose.mq.md | 5 + tests/conformance/ast/077-task-list.ast.json | 74 ++ tests/conformance/ast/077-task-list.mq.md | 2 + ...078-list-item-multiple-paragraphs.ast.json | 89 +++ .../078-list-item-multiple-paragraphs.mq.md | 4 + .../079-list-item-with-blockquote.ast.json | 72 ++ .../ast/079-list-item-with-blockquote.mq.md | 3 + .../ast/080-list-item-with-fence.ast.json | 57 ++ .../ast/080-list-item-with-fence.mq.md | 5 + .../ast/081-list-item-multiline.ast.json | 87 +++ .../ast/081-list-item-multiline.mq.md | 3 + .../082-ordered-item-branch-shape.ast.json | 127 ++++ .../ast/082-ordered-item-branch-shape.mq.md | 7 + .../ast/083-bullet-item-loop-shape.ast.json | 99 +++ .../ast/083-bullet-item-loop-shape.mq.md | 5 + .../ast/084-quote-single-paragraph.ast.json | 35 + .../ast/084-quote-single-paragraph.mq.md | 1 + .../conformance/ast/085-quote-nested.ast.json | 61 ++ tests/conformance/ast/085-quote-nested.mq.md | 3 + .../086-quote-multiple-paragraphs.ast.json | 52 ++ .../ast/086-quote-multiple-paragraphs.mq.md | 3 + .../ast/087-quote-with-code.ast.json | 28 + .../conformance/ast/087-quote-with-code.mq.md | 3 + .../ast/088-quote-with-list.ast.json | 81 +++ .../conformance/ast/088-quote-with-list.mq.md | 2 + .../ast/089-quote-call-shape.ast.json | 35 + .../ast/089-quote-call-shape.mq.md | 1 + .../ast/090-quote-lazy-continuation.ast.json | 50 ++ .../ast/090-quote-lazy-continuation.mq.md | 2 + .../conformance/ast/091-link-inline.ast.json | 37 + tests/conformance/ast/091-link-inline.mq.md | 1 + .../ast/092-link-with-title.ast.json | 37 + .../conformance/ast/092-link-with-title.mq.md | 1 + .../ast/093-reference-link.ast.json | 37 + .../conformance/ast/093-reference-link.mq.md | 3 + .../ast/094-reference-link-collapsed.ast.json | 37 + .../ast/094-reference-link-collapsed.mq.md | 3 + .../ast/095-reference-link-shortcut.ast.json | 37 + .../ast/095-reference-link-shortcut.mq.md | 3 + .../conformance/ast/096-image-basic.ast.json | 37 + tests/conformance/ast/096-image-basic.mq.md | 1 + .../ast/097-image-with-title.ast.json | 37 + .../ast/097-image-with-title.mq.md | 1 + .../ast/098-link-with-emphasis.ast.json | 46 ++ .../ast/098-link-with-emphasis.mq.md | 1 + .../ast/099-link-in-strong.ast.json | 54 ++ .../conformance/ast/099-link-in-strong.mq.md | 1 + .../100-autolinks-disabled-behaviour.ast.json | 64 ++ .../100-autolinks-disabled-behaviour.mq.md | 1 + .../ast/101-link-with-fragment.ast.json | 37 + .../ast/101-link-with-fragment.mq.md | 1 + .../conformance/ast/102-inline-html.ast.json | 58 ++ tests/conformance/ast/102-inline-html.mq.md | 1 + tests/conformance/ast/103-block-html.ast.json | 17 + tests/conformance/ast/103-block-html.mq.md | 3 + .../conformance/ast/104-html-comment.ast.json | 34 + tests/conformance/ast/104-html-comment.mq.md | 3 + .../ast/105-html-script-block.ast.json | 17 + .../ast/105-html-script-block.mq.md | 3 + .../ast/106-html-inline-break.ast.json | 42 ++ .../ast/106-html-inline-break.mq.md | 1 + .../ast/107-thematic-break-dashes.ast.json | 16 + .../ast/107-thematic-break-dashes.mq.md | 1 + .../ast/108-thematic-break-stars.ast.json | 16 + .../ast/108-thematic-break-stars.mq.md | 1 + .../109-thematic-break-underscores.ast.json | 16 + .../ast/109-thematic-break-underscores.mq.md | 1 + ...thematic-break-between-paragraphs.ast.json | 50 ++ ...10-thematic-break-between-paragraphs.mq.md | 5 + .../ast/111-frontmatter-valid.ast.json | 62 ++ .../ast/111-frontmatter-valid.mq.md | 9 + .../ast/112-frontmatter-empty.ast.json | 40 + .../ast/112-frontmatter-empty.mq.md | 4 + .../ast/113-frontmatter-imports.ast.json | 62 ++ .../ast/113-frontmatter-imports.mq.md | 8 + ...ontmatter-later-is-thematic-break.ast.json | 50 ++ ...-frontmatter-later-is-thematic-break.mq.md | 5 + .../ast/115-frontmatter-invalid-yaml.ast.json | 34 + .../ast/115-frontmatter-invalid-yaml.mq.md | 5 + .../ast/116-frontmatter-with-bom.ast.json | 34 + .../ast/116-frontmatter-with-bom.mq.md | 5 + .../ast/117-entities-named.ast.json | 26 + .../conformance/ast/117-entities-named.mq.md | 1 + .../ast/118-entities-numeric.ast.json | 26 + .../ast/118-entities-numeric.mq.md | 1 + .../ast/119-backslash-escapes.ast.json | 26 + .../ast/119-backslash-escapes.mq.md | 1 + .../ast/120-escaped-pipe-in-table.ast.json | 75 ++ .../ast/120-escaped-pipe-in-table.mq.md | 3 + .../ast/121-cjk-paragraph.ast.json | 26 + tests/conformance/ast/121-cjk-paragraph.mq.md | 1 + tests/conformance/ast/122-emoji-text.ast.json | 26 + tests/conformance/ast/122-emoji-text.mq.md | 1 + .../conformance/ast/123-cjk-emphasis.ast.json | 60 ++ tests/conformance/ast/123-cjk-emphasis.mq.md | 1 + .../ast/124-mixed-scripts.ast.json | 26 + tests/conformance/ast/124-mixed-scripts.mq.md | 1 + .../ast/125-prose-with-executable.ast.json | 95 +++ .../ast/125-prose-with-executable.mq.md | 7 + .../ast/126-prose-and-control-flow.ast.json | 222 ++++++ .../ast/126-prose-and-control-flow.mq.md | 15 + .../127-invalid-strong-nested-markup.ast.json | 79 ++ .../127-invalid-strong-nested-markup.mq.md | 3 + .../128-invalid-emph-nested-markup.ast.json | 79 ++ .../ast/128-invalid-emph-nested-markup.mq.md | 3 + .../129-invalid-list-no-condition.ast.json | 66 ++ .../ast/129-invalid-list-no-condition.mq.md | 3 + .../ast/130-invalid-quote-not-call.ast.json | 54 ++ .../ast/130-invalid-quote-not-call.mq.md | 3 + .../ast/131-invalid-empty-payloads.ast.json | 53 ++ .../ast/131-invalid-empty-payloads.mq.md | 5 + ...inert-executable-outside-function.ast.json | 80 ++ ...32-inert-executable-outside-function.mq.md | 5 + .../ast/133-strikethrough.ast.json | 35 + tests/conformance/ast/133-strikethrough.mq.md | 1 + .../134-strikethrough-with-strong.ast.json | 52 ++ .../ast/134-strikethrough-with-strong.mq.md | 1 + .../135-tight-vs-loose-equivalence.ast.json | 72 ++ .../ast/135-tight-vs-loose-equivalence.mq.md | 2 + .../ast/136-nested-container-blocks.ast.json | 65 ++ .../ast/136-nested-container-blocks.mq.md | 5 + .../ast/137-multiple-levels-document.ast.json | 128 ++++ .../ast/137-multiple-levels-document.mq.md | 11 + .../ast/138-footnotes-disabled.ast.json | 45 ++ .../ast/138-footnotes-disabled.mq.md | 3 + .../139-code-fence-info-attributes.ast.json | 19 + .../ast/139-code-fence-info-attributes.mq.md | 3 + .../ast/140-table-and-list-mixed.ast.json | 147 ++++ .../ast/140-table-and-list-mixed.mq.md | 5 + .../ast/141-html-block-in-list.ast.json | 54 ++ .../ast/141-html-block-in-list.mq.md | 5 + .../ast/142-math-and-code-mixed.ast.json | 53 ++ .../ast/142-math-and-code-mixed.mq.md | 9 + .../143-heading-setext-with-emphasis.ast.json | 37 + .../143-heading-setext-with-emphasis.mq.md | 2 + .../ast/144-multi-byte-span-check.ast.json | 45 ++ .../ast/144-multi-byte-span-check.mq.md | 3 + .../ast/145-frontmatter-then-heading.ast.json | 81 +++ .../ast/145-frontmatter-then-heading.mq.md | 8 + .../ast/146-crlf-line-endings.ast.json | 45 ++ .../ast/146-crlf-line-endings.mq.md | 3 + .../ast/147-tab-indented-list.ast.json | 46 ++ .../ast/147-tab-indented-list.mq.md | 1 + .../ast/148-blockquote-heading-mixed.ast.json | 54 ++ .../ast/148-blockquote-heading-mixed.mq.md | 3 + .../ast/149-table-with-header-only.ast.json | 66 ++ .../ast/149-table-with-header-only.mq.md | 2 + .../150-document-only-frontmatter.ast.json | 17 + .../ast/150-document-only-frontmatter.mq.md | 3 + .../01-constant-return.expected.json | 9 + .../semantics/01-constant-return.mq.md | 3 + .../semantics/02-text-return.expected.json | 9 + .../semantics/02-text-return.mq.md | 3 + .../03-float-arithmetic.expected.json | 9 + .../semantics/03-float-arithmetic.mq.md | 3 + .../04-big-int-arithmetic.expected.json | 9 + .../semantics/04-big-int-arithmetic.mq.md | 3 + .../05-factorio-recursion.expected.json | 14 + .../semantics/05-factorio-recursion.mq.md | 13 + .../06-fibonacci-recursion.expected.json | 14 + .../semantics/06-fibonacci-recursion.mq.md | 11 + .../07-euclid-iterative.expected.json | 18 + .../semantics/07-euclid-iterative.mq.md | 15 + .../semantics/08-loop-sum.expected.json | 14 + tests/conformance/semantics/08-loop-sum.mq.md | 13 + .../09-nested-control-flow.expected.json | 14 + .../semantics/09-nested-control-flow.mq.md | 19 + ...xplicit-positional-signature.expected.json | 9 + .../10-explicit-positional-signature.mq.md | 9 + .../11-default-parameters.expected.json | 9 + .../semantics/11-default-parameters.mq.md | 9 + .../12-named-arguments.expected.json | 9 + .../semantics/12-named-arguments.mq.md | 9 + .../13-function-ref-call.expected.json | 9 + .../semantics/13-function-ref-call.mq.md | 11 + .../14-function-ref-value.expected.json | 10 + .../semantics/14-function-ref-value.mq.md | 9 + .../15-string-builtins.expected.json | 18 + .../semantics/15-string-builtins.mq.md | 3 + .../semantics/16-int-builtins.expected.json | 9 + .../semantics/16-int-builtins.mq.md | 3 + .../semantics/17-float-builtins.expected.json | 9 + .../semantics/17-float-builtins.mq.md | 3 + .../semantics/18-table-builtin.expected.json | 34 + .../semantics/18-table-builtin.mq.md | 3 + .../semantics/19-type-builtin.expected.json | 26 + .../semantics/19-type-builtin.mq.md | 3 + .../semantics/20-math-eval-ref.expected.json | 9 + .../semantics/20-math-eval-ref.mq.md | 9 + .../21-math-eval-positional.expected.json | 9 + .../semantics/21-math-eval-positional.mq.md | 9 + .../semantics/22-print-stdout.expected.json | 8 + .../semantics/22-print-stdout.mq.md | 9 + .../23-unit-fallthrough.expected.json | 8 + .../semantics/23-unit-fallthrough.mq.md | 5 + .../semantics/24-none-value.expected.json | 8 + .../conformance/semantics/24-none-value.mq.md | 3 + .../semantics/25-bool-operators.expected.json | 9 + .../semantics/25-bool-operators.mq.md | 3 + .../26-mixed-comparison.expected.json | 9 + .../semantics/26-mixed-comparison.mq.md | 3 + .../27-floor-division-modulo.expected.json | 9 + .../semantics/27-floor-division-modulo.mq.md | 3 + .../28-index-and-member.expected.json | 30 + .../semantics/28-index-and-member.mq.md | 3 + .../29-map-record-literal.expected.json | 26 + .../semantics/29-map-record-literal.mq.md | 3 + .../30-print-list-and-map.expected.json | 8 + .../semantics/30-print-list-and-map.mq.md | 7 + .../semantics/31-string-concat.expected.json | 9 + .../semantics/31-string-concat.mq.md | 3 + .../semantics/32-recursive-sum.expected.json | 14 + .../semantics/32-recursive-sum.mq.md | 11 + ...3-conditional-return-in-loop.expected.json | 14 + .../33-conditional-return-in-loop.mq.md | 9 + .../semantics/34-elif-chain.expected.json | 14 + .../conformance/semantics/34-elif-chain.mq.md | 13 + .../35-default-and-named-mixed.expected.json | 9 + .../35-default-and-named-mixed.mq.md | 9 + .../36-foreign-call-python.expected.json | 12 + .../semantics/36-foreign-call-python.mq.md | 16 + ...1-invalid-strong-nested-emph.expected.json | 5 + .../01-invalid-strong-nested-emph.mq.md | 3 + ...invalid-strong-nested-strong.expected.json | 5 + .../02-invalid-strong-nested-strong.mq.md | 3 + ...3-invalid-strong-nested-link.expected.json | 5 + .../03-invalid-strong-nested-link.mq.md | 3 + ...4-invalid-strong-nested-math.expected.json | 5 + .../04-invalid-strong-nested-math.mq.md | 3 + ...-strong-nested-strikethrough.expected.json | 5 + ...-invalid-strong-nested-strikethrough.mq.md | 3 + .../06-invalid-strong-linebreak.expected.json | 5 + .../06-invalid-strong-linebreak.mq.md | 4 + ...7-invalid-emph-nested-strong.expected.json | 5 + .../07-invalid-emph-nested-strong.mq.md | 3 + .../08-invalid-emph-nested-emph.expected.json | 5 + .../08-invalid-emph-nested-emph.mq.md | 3 + ...invalid-strong-empty-payload.expected.json | 5 + .../09-invalid-strong-empty-payload.mq.md | 3 + ...0-invalid-emph-empty-payload.expected.json | 5 + .../10-invalid-emph-empty-payload.mq.md | 3 + ...11-invalid-strong-expression.expected.json | 5 + .../11-invalid-strong-expression.mq.md | 3 + .../12-invalid-emph-expression.expected.json | 5 + .../negative/12-invalid-emph-expression.mq.md | 3 + ...13-ordered-item-no-condition.expected.json | 5 + .../13-ordered-item-no-condition.mq.md | 3 + .../14-bullet-item-no-condition.expected.json | 5 + .../14-bullet-item-no-condition.mq.md | 3 + ...em-first-block-not-paragraph.expected.json | 5 + ...dered-item-first-block-not-paragraph.mq.md | 3 + ...d-item-first-inline-not-code.expected.json | 5 + ...6-ordered-item-first-inline-not-code.mq.md | 3 + ...condition-invalid-expression.expected.json | 5 + ...ordered-condition-invalid-expression.mq.md | 3 + .../18-quote-not-a-call.expected.json | 5 + tests/negative/18-quote-not-a-call.mq.md | 3 + .../19-quote-multi-paragraph.expected.json | 5 + tests/negative/19-quote-multi-paragraph.mq.md | 5 + tests/negative/20-quote-nested.expected.json | 5 + tests/negative/20-quote-nested.mq.md | 3 + tests/negative/21-quote-empty.expected.json | 5 + tests/negative/21-quote-empty.mq.md | 3 + ...uote-two-calls-one-paragraph.expected.json | 5 + .../22-quote-two-calls-one-paragraph.mq.md | 3 + ...23-quote-non-call-expression.expected.json | 5 + .../23-quote-non-call-expression.mq.md | 3 + ...-link-form-without-arguments.expected.json | 5 + ...24-quote-link-form-without-arguments.mq.md | 7 + .../25-quote-external-link-call.expected.json | 5 + .../25-quote-external-link-call.mq.md | 3 + ...quote-cross-module-link-call.expected.json | 5 + .../26-quote-cross-module-link-call.mq.md | 3 + .../27-quote-unresolved-anchor.expected.json | 5 + .../negative/27-quote-unresolved-anchor.mq.md | 3 + .../28-duplicate-function-name.expected.json | 5 + .../negative/28-duplicate-function-name.mq.md | 7 + .../29-duplicate-namespace-name.expected.json | 5 + .../29-duplicate-namespace-name.mq.md | 7 + .../30-empty-function-heading.expected.json | 5 + .../negative/30-empty-function-heading.mq.md | 3 + .../31-empty-namespace-heading.expected.json | 5 + .../negative/31-empty-namespace-heading.mq.md | 5 + .../32-unknown-function.expected.json | 5 + tests/negative/32-unknown-function.mq.md | 3 + ...nferred-signature-positional.expected.json | 5 + .../33-inferred-signature-positional.mq.md | 9 + ...34-missing-required-argument.expected.json | 5 + .../34-missing-required-argument.mq.md | 9 + .../35-unknown-named-argument.expected.json | 5 + .../negative/35-unknown-named-argument.mq.md | 9 + .../36-malformed-signature-name.expected.json | 5 + .../36-malformed-signature-name.mq.md | 5 + ...ed-signature-duplicate-param.expected.json | 5 + ...-malformed-signature-duplicate-param.mq.md | 5 + ...gnature-non-constant-default.expected.json | 6 + .../38-signature-non-constant-default.mq.md | 5 + ...-variable-explicit-signature.expected.json | 5 + ...-unknown-variable-explicit-signature.mq.md | 5 + ...-branch-assignment-ambiguity.expected.json | 5 + ...-partial-branch-assignment-ambiguity.mq.md | 7 + .../41-frontmatter-invalid-yaml.expected.json | 5 + .../41-frontmatter-invalid-yaml.mq.md | 7 + ...tmatter-invalid-import-shape.expected.json | 5 + .../42-frontmatter-invalid-import-shape.mq.md | 7 + .../43-unknown-callee-in-quote.expected.json | 5 + .../negative/43-unknown-callee-in-quote.mq.md | 3 + .../44-link-call-bad-arguments.expected.json | 5 + .../negative/44-link-call-bad-arguments.mq.md | 7 + ...condition-invalid-expression.expected.json | 5 + ...-branch-condition-invalid-expression.mq.md | 5 + ...ate-import-alias-frontmatter.expected.json | 5 + ...6-duplicate-import-alias-frontmatter.mq.md | 9 + ...-unsupported-quote-statement.expected.json | 5 + .../47-unsupported-quote-statement.mq.md | 3 + ...strong-assignment-bad-target.expected.json | 5 + .../48-strong-assignment-bad-target.mq.md | 3 + .../runtime/01-division-by-zero.expected.json | 7 + .../runtime/01-division-by-zero.mq.md | 3 + .../runtime/02-type-error.expected.json | 7 + tests/negative/runtime/02-type-error.mq.md | 3 + .../03-index-out-of-bounds.expected.json | 7 + .../runtime/03-index-out-of-bounds.mq.md | 3 + .../runtime/04-unknown-field.expected.json | 7 + tests/negative/runtime/04-unknown-field.mq.md | 3 + .../runtime/05-not-callable.expected.json | 7 + tests/negative/runtime/05-not-callable.mq.md | 5 + ...06-permission-denied-foreign.expected.json | 7 + .../06-permission-denied-foreign.mq.md | 9 + .../runtime/07-math-unsupported.expected.json | 7 + .../runtime/07-math-unsupported.mq.md | 9 + .../runtime/08-stack-overflow.expected.json | 8 + .../negative/runtime/08-stack-overflow.mq.md | 3 + ...09-branch-condition-not-bool.expected.json | 7 + .../09-branch-condition-not-bool.mq.md | 5 + ...10-function-ref-bad-argument.expected.json | 7 + .../10-function-ref-bad-argument.mq.md | 11 + .../01-return-outside-function.expected.json | 6 + .../warnings/01-return-outside-function.mq.md | 1 + .../02-strong-outside-function.expected.json | 6 + .../warnings/02-strong-outside-function.mq.md | 1 + ...rdered-list-outside-function.expected.json | 6 + .../03-ordered-list-outside-function.mq.md | 3 + ...bullet-list-outside-function.expected.json | 6 + .../04-bullet-list-outside-function.mq.md | 3 + .../05-quote-outside-function.expected.json | 6 + .../warnings/05-quote-outside-function.mq.md | 1 + ...cutable-in-module-root-prose.expected.json | 7 + .../06-executable-in-module-root-prose.mq.md | 5 + 511 files changed, 11678 insertions(+), 26 deletions(-) create mode 100644 crates/cli/tests/conformance_ast.rs create mode 100644 crates/cli/tests/conformance_semantics.rs create mode 100644 crates/cli/tests/integration_cli.rs create mode 100644 crates/cli/tests/negative.rs create mode 100644 crates/cli/tests/properties.rs create mode 100644 tests/README.md create mode 100644 tests/conformance/ast/001-atx-h1.ast.json create mode 100644 tests/conformance/ast/001-atx-h1.mq.md create mode 100644 tests/conformance/ast/002-atx-h2.ast.json create mode 100644 tests/conformance/ast/002-atx-h2.mq.md create mode 100644 tests/conformance/ast/003-atx-h3.ast.json create mode 100644 tests/conformance/ast/003-atx-h3.mq.md create mode 100644 tests/conformance/ast/004-atx-h4.ast.json create mode 100644 tests/conformance/ast/004-atx-h4.mq.md create mode 100644 tests/conformance/ast/005-atx-h5.ast.json create mode 100644 tests/conformance/ast/005-atx-h5.mq.md create mode 100644 tests/conformance/ast/006-atx-h6.ast.json create mode 100644 tests/conformance/ast/006-atx-h6.mq.md create mode 100644 tests/conformance/ast/007-atx-closing-hashes.ast.json create mode 100644 tests/conformance/ast/007-atx-closing-hashes.mq.md create mode 100644 tests/conformance/ast/008-setext-level1.ast.json create mode 100644 tests/conformance/ast/008-setext-level1.mq.md create mode 100644 tests/conformance/ast/009-setext-level2.ast.json create mode 100644 tests/conformance/ast/009-setext-level2.mq.md create mode 100644 tests/conformance/ast/010-unicode-chinese-heading.ast.json create mode 100644 tests/conformance/ast/010-unicode-chinese-heading.mq.md create mode 100644 tests/conformance/ast/011-heading-cjk-emoji.ast.json create mode 100644 tests/conformance/ast/011-heading-cjk-emoji.mq.md create mode 100644 tests/conformance/ast/012-heading-empty.ast.json create mode 100644 tests/conformance/ast/012-heading-empty.mq.md create mode 100644 tests/conformance/ast/013-heading-inline-markup.ast.json create mode 100644 tests/conformance/ast/013-heading-inline-markup.mq.md create mode 100644 tests/conformance/ast/014-heading-in-blockquote.ast.json create mode 100644 tests/conformance/ast/014-heading-in-blockquote.mq.md create mode 100644 tests/conformance/ast/015-heading-in-list-item.ast.json create mode 100644 tests/conformance/ast/015-heading-in-list-item.mq.md create mode 100644 tests/conformance/ast/016-heading-in-fenced-code.ast.json create mode 100644 tests/conformance/ast/016-heading-in-fenced-code.mq.md create mode 100644 tests/conformance/ast/017-heading-whitespace-normalised.ast.json create mode 100644 tests/conformance/ast/017-heading-whitespace-normalised.mq.md create mode 100644 tests/conformance/ast/018-heading-level-jump.ast.json create mode 100644 tests/conformance/ast/018-heading-level-jump.mq.md create mode 100644 tests/conformance/ast/019-paragraph-single.ast.json create mode 100644 tests/conformance/ast/019-paragraph-single.mq.md create mode 100644 tests/conformance/ast/020-paragraph-multiline-softbreak.ast.json create mode 100644 tests/conformance/ast/020-paragraph-multiline-softbreak.mq.md create mode 100644 tests/conformance/ast/021-hard-break-two-spaces.ast.json create mode 100644 tests/conformance/ast/021-hard-break-two-spaces.mq.md create mode 100644 tests/conformance/ast/022-hard-break-backslash.ast.json create mode 100644 tests/conformance/ast/022-hard-break-backslash.mq.md create mode 100644 tests/conformance/ast/023-empty-document.ast.json create mode 100644 tests/conformance/ast/023-empty-document.mq.md create mode 100644 tests/conformance/ast/024-whitespace-only-document.ast.json create mode 100644 tests/conformance/ast/024-whitespace-only-document.mq.md create mode 100644 tests/conformance/ast/025-bom-document.ast.json create mode 100644 tests/conformance/ast/025-bom-document.mq.md create mode 100644 tests/conformance/ast/026-mixed-paragraph-blocks.ast.json create mode 100644 tests/conformance/ast/026-mixed-paragraph-blocks.mq.md create mode 100644 tests/conformance/ast/027-strong-asterisk.ast.json create mode 100644 tests/conformance/ast/027-strong-asterisk.mq.md create mode 100644 tests/conformance/ast/028-strong-underscore.ast.json create mode 100644 tests/conformance/ast/028-strong-underscore.mq.md create mode 100644 tests/conformance/ast/029-emph-asterisk.ast.json create mode 100644 tests/conformance/ast/029-emph-asterisk.mq.md create mode 100644 tests/conformance/ast/030-emph-underscore.ast.json create mode 100644 tests/conformance/ast/030-emph-underscore.mq.md create mode 100644 tests/conformance/ast/031-strong-emph-nested.ast.json create mode 100644 tests/conformance/ast/031-strong-emph-nested.mq.md create mode 100644 tests/conformance/ast/032-emph-in-strong.ast.json create mode 100644 tests/conformance/ast/032-emph-in-strong.mq.md create mode 100644 tests/conformance/ast/033-strong-in-emph.ast.json create mode 100644 tests/conformance/ast/033-strong-in-emph.mq.md create mode 100644 tests/conformance/ast/034-intraword-underscore.ast.json create mode 100644 tests/conformance/ast/034-intraword-underscore.mq.md create mode 100644 tests/conformance/ast/035-multiline-emphasis.ast.json create mode 100644 tests/conformance/ast/035-multiline-emphasis.mq.md create mode 100644 tests/conformance/ast/036-emphasis-with-punctuation.ast.json create mode 100644 tests/conformance/ast/036-emphasis-with-punctuation.mq.md create mode 100644 tests/conformance/ast/037-strong-with-code-span.ast.json create mode 100644 tests/conformance/ast/037-strong-with-code-span.mq.md create mode 100644 tests/conformance/ast/038-emph-with-code-span.ast.json create mode 100644 tests/conformance/ast/038-emph-with-code-span.mq.md create mode 100644 tests/conformance/ast/039-code-single-tick.ast.json create mode 100644 tests/conformance/ast/039-code-single-tick.mq.md create mode 100644 tests/conformance/ast/040-code-double-tick.ast.json create mode 100644 tests/conformance/ast/040-code-double-tick.mq.md create mode 100644 tests/conformance/ast/041-code-triple-tick.ast.json create mode 100644 tests/conformance/ast/041-code-triple-tick.mq.md create mode 100644 tests/conformance/ast/042-code-with-spaces.ast.json create mode 100644 tests/conformance/ast/042-code-with-spaces.mq.md create mode 100644 tests/conformance/ast/043-code-empty.ast.json create mode 100644 tests/conformance/ast/043-code-empty.mq.md create mode 100644 tests/conformance/ast/044-code-with-special-chars.ast.json create mode 100644 tests/conformance/ast/044-code-with-special-chars.mq.md create mode 100644 tests/conformance/ast/045-code-multiline-payload.ast.json create mode 100644 tests/conformance/ast/045-code-multiline-payload.mq.md create mode 100644 tests/conformance/ast/046-fenced-no-language.ast.json create mode 100644 tests/conformance/ast/046-fenced-no-language.mq.md create mode 100644 tests/conformance/ast/047-fenced-with-language.ast.json create mode 100644 tests/conformance/ast/047-fenced-with-language.mq.md create mode 100644 tests/conformance/ast/048-fenced-info-multiword.ast.json create mode 100644 tests/conformance/ast/048-fenced-info-multiword.mq.md create mode 100644 tests/conformance/ast/049-fenced-tilde.ast.json create mode 100644 tests/conformance/ast/049-fenced-tilde.mq.md create mode 100644 tests/conformance/ast/050-indented-code.ast.json create mode 100644 tests/conformance/ast/050-indented-code.mq.md create mode 100644 tests/conformance/ast/051-fenced-unclosed.ast.json create mode 100644 tests/conformance/ast/051-fenced-unclosed.mq.md create mode 100644 tests/conformance/ast/052-fenced-with-tabs.ast.json create mode 100644 tests/conformance/ast/052-fenced-with-tabs.mq.md create mode 100644 tests/conformance/ast/053-indented-code-after-paragraph.ast.json create mode 100644 tests/conformance/ast/053-indented-code-after-paragraph.mq.md create mode 100644 tests/conformance/ast/054-fenced-in-list.ast.json create mode 100644 tests/conformance/ast/054-fenced-in-list.mq.md create mode 100644 tests/conformance/ast/055-inline-math.ast.json create mode 100644 tests/conformance/ast/055-inline-math.mq.md create mode 100644 tests/conformance/ast/056-inline-display-math.ast.json create mode 100644 tests/conformance/ast/056-inline-display-math.mq.md create mode 100644 tests/conformance/ast/057-block-math.ast.json create mode 100644 tests/conformance/ast/057-block-math.mq.md create mode 100644 tests/conformance/ast/058-block-math-fraction.ast.json create mode 100644 tests/conformance/ast/058-block-math-fraction.mq.md create mode 100644 tests/conformance/ast/059-math-unclosed.ast.json create mode 100644 tests/conformance/ast/059-math-unclosed.mq.md create mode 100644 tests/conformance/ast/060-math-escaped-dollar.ast.json create mode 100644 tests/conformance/ast/060-math-escaped-dollar.mq.md create mode 100644 tests/conformance/ast/061-math-in-paragraph-mixed.ast.json create mode 100644 tests/conformance/ast/061-math-in-paragraph-mixed.mq.md create mode 100644 tests/conformance/ast/062-table-basic.ast.json create mode 100644 tests/conformance/ast/062-table-basic.mq.md create mode 100644 tests/conformance/ast/063-table-alignments.ast.json create mode 100644 tests/conformance/ast/063-table-alignments.mq.md create mode 100644 tests/conformance/ast/064-table-escaped-pipe.ast.json create mode 100644 tests/conformance/ast/064-table-escaped-pipe.mq.md create mode 100644 tests/conformance/ast/065-table-missing-cells.ast.json create mode 100644 tests/conformance/ast/065-table-missing-cells.mq.md create mode 100644 tests/conformance/ast/066-table-inline-markup.ast.json create mode 100644 tests/conformance/ast/066-table-inline-markup.mq.md create mode 100644 tests/conformance/ast/067-table-no-leading-pipes.ast.json create mode 100644 tests/conformance/ast/067-table-no-leading-pipes.mq.md create mode 100644 tests/conformance/ast/068-table-empty-cells.ast.json create mode 100644 tests/conformance/ast/068-table-empty-cells.mq.md create mode 100644 tests/conformance/ast/069-bullet-dash.ast.json create mode 100644 tests/conformance/ast/069-bullet-dash.mq.md create mode 100644 tests/conformance/ast/070-bullet-markers-mixed.ast.json create mode 100644 tests/conformance/ast/070-bullet-markers-mixed.mq.md create mode 100644 tests/conformance/ast/071-bullet-nested.ast.json create mode 100644 tests/conformance/ast/071-bullet-nested.mq.md create mode 100644 tests/conformance/ast/072-ordered-start-3.ast.json create mode 100644 tests/conformance/ast/072-ordered-start-3.mq.md create mode 100644 tests/conformance/ast/073-ordered-paren-delimiter.ast.json create mode 100644 tests/conformance/ast/073-ordered-paren-delimiter.mq.md create mode 100644 tests/conformance/ast/074-ordered-nested.ast.json create mode 100644 tests/conformance/ast/074-ordered-nested.mq.md create mode 100644 tests/conformance/ast/075-list-tight.ast.json create mode 100644 tests/conformance/ast/075-list-tight.mq.md create mode 100644 tests/conformance/ast/076-list-loose.ast.json create mode 100644 tests/conformance/ast/076-list-loose.mq.md create mode 100644 tests/conformance/ast/077-task-list.ast.json create mode 100644 tests/conformance/ast/077-task-list.mq.md create mode 100644 tests/conformance/ast/078-list-item-multiple-paragraphs.ast.json create mode 100644 tests/conformance/ast/078-list-item-multiple-paragraphs.mq.md create mode 100644 tests/conformance/ast/079-list-item-with-blockquote.ast.json create mode 100644 tests/conformance/ast/079-list-item-with-blockquote.mq.md create mode 100644 tests/conformance/ast/080-list-item-with-fence.ast.json create mode 100644 tests/conformance/ast/080-list-item-with-fence.mq.md create mode 100644 tests/conformance/ast/081-list-item-multiline.ast.json create mode 100644 tests/conformance/ast/081-list-item-multiline.mq.md create mode 100644 tests/conformance/ast/082-ordered-item-branch-shape.ast.json create mode 100644 tests/conformance/ast/082-ordered-item-branch-shape.mq.md create mode 100644 tests/conformance/ast/083-bullet-item-loop-shape.ast.json create mode 100644 tests/conformance/ast/083-bullet-item-loop-shape.mq.md create mode 100644 tests/conformance/ast/084-quote-single-paragraph.ast.json create mode 100644 tests/conformance/ast/084-quote-single-paragraph.mq.md create mode 100644 tests/conformance/ast/085-quote-nested.ast.json create mode 100644 tests/conformance/ast/085-quote-nested.mq.md create mode 100644 tests/conformance/ast/086-quote-multiple-paragraphs.ast.json create mode 100644 tests/conformance/ast/086-quote-multiple-paragraphs.mq.md create mode 100644 tests/conformance/ast/087-quote-with-code.ast.json create mode 100644 tests/conformance/ast/087-quote-with-code.mq.md create mode 100644 tests/conformance/ast/088-quote-with-list.ast.json create mode 100644 tests/conformance/ast/088-quote-with-list.mq.md create mode 100644 tests/conformance/ast/089-quote-call-shape.ast.json create mode 100644 tests/conformance/ast/089-quote-call-shape.mq.md create mode 100644 tests/conformance/ast/090-quote-lazy-continuation.ast.json create mode 100644 tests/conformance/ast/090-quote-lazy-continuation.mq.md create mode 100644 tests/conformance/ast/091-link-inline.ast.json create mode 100644 tests/conformance/ast/091-link-inline.mq.md create mode 100644 tests/conformance/ast/092-link-with-title.ast.json create mode 100644 tests/conformance/ast/092-link-with-title.mq.md create mode 100644 tests/conformance/ast/093-reference-link.ast.json create mode 100644 tests/conformance/ast/093-reference-link.mq.md create mode 100644 tests/conformance/ast/094-reference-link-collapsed.ast.json create mode 100644 tests/conformance/ast/094-reference-link-collapsed.mq.md create mode 100644 tests/conformance/ast/095-reference-link-shortcut.ast.json create mode 100644 tests/conformance/ast/095-reference-link-shortcut.mq.md create mode 100644 tests/conformance/ast/096-image-basic.ast.json create mode 100644 tests/conformance/ast/096-image-basic.mq.md create mode 100644 tests/conformance/ast/097-image-with-title.ast.json create mode 100644 tests/conformance/ast/097-image-with-title.mq.md create mode 100644 tests/conformance/ast/098-link-with-emphasis.ast.json create mode 100644 tests/conformance/ast/098-link-with-emphasis.mq.md create mode 100644 tests/conformance/ast/099-link-in-strong.ast.json create mode 100644 tests/conformance/ast/099-link-in-strong.mq.md create mode 100644 tests/conformance/ast/100-autolinks-disabled-behaviour.ast.json create mode 100644 tests/conformance/ast/100-autolinks-disabled-behaviour.mq.md create mode 100644 tests/conformance/ast/101-link-with-fragment.ast.json create mode 100644 tests/conformance/ast/101-link-with-fragment.mq.md create mode 100644 tests/conformance/ast/102-inline-html.ast.json create mode 100644 tests/conformance/ast/102-inline-html.mq.md create mode 100644 tests/conformance/ast/103-block-html.ast.json create mode 100644 tests/conformance/ast/103-block-html.mq.md create mode 100644 tests/conformance/ast/104-html-comment.ast.json create mode 100644 tests/conformance/ast/104-html-comment.mq.md create mode 100644 tests/conformance/ast/105-html-script-block.ast.json create mode 100644 tests/conformance/ast/105-html-script-block.mq.md create mode 100644 tests/conformance/ast/106-html-inline-break.ast.json create mode 100644 tests/conformance/ast/106-html-inline-break.mq.md create mode 100644 tests/conformance/ast/107-thematic-break-dashes.ast.json create mode 100644 tests/conformance/ast/107-thematic-break-dashes.mq.md create mode 100644 tests/conformance/ast/108-thematic-break-stars.ast.json create mode 100644 tests/conformance/ast/108-thematic-break-stars.mq.md create mode 100644 tests/conformance/ast/109-thematic-break-underscores.ast.json create mode 100644 tests/conformance/ast/109-thematic-break-underscores.mq.md create mode 100644 tests/conformance/ast/110-thematic-break-between-paragraphs.ast.json create mode 100644 tests/conformance/ast/110-thematic-break-between-paragraphs.mq.md create mode 100644 tests/conformance/ast/111-frontmatter-valid.ast.json create mode 100644 tests/conformance/ast/111-frontmatter-valid.mq.md create mode 100644 tests/conformance/ast/112-frontmatter-empty.ast.json create mode 100644 tests/conformance/ast/112-frontmatter-empty.mq.md create mode 100644 tests/conformance/ast/113-frontmatter-imports.ast.json create mode 100644 tests/conformance/ast/113-frontmatter-imports.mq.md create mode 100644 tests/conformance/ast/114-frontmatter-later-is-thematic-break.ast.json create mode 100644 tests/conformance/ast/114-frontmatter-later-is-thematic-break.mq.md create mode 100644 tests/conformance/ast/115-frontmatter-invalid-yaml.ast.json create mode 100644 tests/conformance/ast/115-frontmatter-invalid-yaml.mq.md create mode 100644 tests/conformance/ast/116-frontmatter-with-bom.ast.json create mode 100644 tests/conformance/ast/116-frontmatter-with-bom.mq.md create mode 100644 tests/conformance/ast/117-entities-named.ast.json create mode 100644 tests/conformance/ast/117-entities-named.mq.md create mode 100644 tests/conformance/ast/118-entities-numeric.ast.json create mode 100644 tests/conformance/ast/118-entities-numeric.mq.md create mode 100644 tests/conformance/ast/119-backslash-escapes.ast.json create mode 100644 tests/conformance/ast/119-backslash-escapes.mq.md create mode 100644 tests/conformance/ast/120-escaped-pipe-in-table.ast.json create mode 100644 tests/conformance/ast/120-escaped-pipe-in-table.mq.md create mode 100644 tests/conformance/ast/121-cjk-paragraph.ast.json create mode 100644 tests/conformance/ast/121-cjk-paragraph.mq.md create mode 100644 tests/conformance/ast/122-emoji-text.ast.json create mode 100644 tests/conformance/ast/122-emoji-text.mq.md create mode 100644 tests/conformance/ast/123-cjk-emphasis.ast.json create mode 100644 tests/conformance/ast/123-cjk-emphasis.mq.md create mode 100644 tests/conformance/ast/124-mixed-scripts.ast.json create mode 100644 tests/conformance/ast/124-mixed-scripts.mq.md create mode 100644 tests/conformance/ast/125-prose-with-executable.ast.json create mode 100644 tests/conformance/ast/125-prose-with-executable.mq.md create mode 100644 tests/conformance/ast/126-prose-and-control-flow.ast.json create mode 100644 tests/conformance/ast/126-prose-and-control-flow.mq.md create mode 100644 tests/conformance/ast/127-invalid-strong-nested-markup.ast.json create mode 100644 tests/conformance/ast/127-invalid-strong-nested-markup.mq.md create mode 100644 tests/conformance/ast/128-invalid-emph-nested-markup.ast.json create mode 100644 tests/conformance/ast/128-invalid-emph-nested-markup.mq.md create mode 100644 tests/conformance/ast/129-invalid-list-no-condition.ast.json create mode 100644 tests/conformance/ast/129-invalid-list-no-condition.mq.md create mode 100644 tests/conformance/ast/130-invalid-quote-not-call.ast.json create mode 100644 tests/conformance/ast/130-invalid-quote-not-call.mq.md create mode 100644 tests/conformance/ast/131-invalid-empty-payloads.ast.json create mode 100644 tests/conformance/ast/131-invalid-empty-payloads.mq.md create mode 100644 tests/conformance/ast/132-inert-executable-outside-function.ast.json create mode 100644 tests/conformance/ast/132-inert-executable-outside-function.mq.md create mode 100644 tests/conformance/ast/133-strikethrough.ast.json create mode 100644 tests/conformance/ast/133-strikethrough.mq.md create mode 100644 tests/conformance/ast/134-strikethrough-with-strong.ast.json create mode 100644 tests/conformance/ast/134-strikethrough-with-strong.mq.md create mode 100644 tests/conformance/ast/135-tight-vs-loose-equivalence.ast.json create mode 100644 tests/conformance/ast/135-tight-vs-loose-equivalence.mq.md create mode 100644 tests/conformance/ast/136-nested-container-blocks.ast.json create mode 100644 tests/conformance/ast/136-nested-container-blocks.mq.md create mode 100644 tests/conformance/ast/137-multiple-levels-document.ast.json create mode 100644 tests/conformance/ast/137-multiple-levels-document.mq.md create mode 100644 tests/conformance/ast/138-footnotes-disabled.ast.json create mode 100644 tests/conformance/ast/138-footnotes-disabled.mq.md create mode 100644 tests/conformance/ast/139-code-fence-info-attributes.ast.json create mode 100644 tests/conformance/ast/139-code-fence-info-attributes.mq.md create mode 100644 tests/conformance/ast/140-table-and-list-mixed.ast.json create mode 100644 tests/conformance/ast/140-table-and-list-mixed.mq.md create mode 100644 tests/conformance/ast/141-html-block-in-list.ast.json create mode 100644 tests/conformance/ast/141-html-block-in-list.mq.md create mode 100644 tests/conformance/ast/142-math-and-code-mixed.ast.json create mode 100644 tests/conformance/ast/142-math-and-code-mixed.mq.md create mode 100644 tests/conformance/ast/143-heading-setext-with-emphasis.ast.json create mode 100644 tests/conformance/ast/143-heading-setext-with-emphasis.mq.md create mode 100644 tests/conformance/ast/144-multi-byte-span-check.ast.json create mode 100644 tests/conformance/ast/144-multi-byte-span-check.mq.md create mode 100644 tests/conformance/ast/145-frontmatter-then-heading.ast.json create mode 100644 tests/conformance/ast/145-frontmatter-then-heading.mq.md create mode 100644 tests/conformance/ast/146-crlf-line-endings.ast.json create mode 100644 tests/conformance/ast/146-crlf-line-endings.mq.md create mode 100644 tests/conformance/ast/147-tab-indented-list.ast.json create mode 100644 tests/conformance/ast/147-tab-indented-list.mq.md create mode 100644 tests/conformance/ast/148-blockquote-heading-mixed.ast.json create mode 100644 tests/conformance/ast/148-blockquote-heading-mixed.mq.md create mode 100644 tests/conformance/ast/149-table-with-header-only.ast.json create mode 100644 tests/conformance/ast/149-table-with-header-only.mq.md create mode 100644 tests/conformance/ast/150-document-only-frontmatter.ast.json create mode 100644 tests/conformance/ast/150-document-only-frontmatter.mq.md create mode 100644 tests/conformance/semantics/01-constant-return.expected.json create mode 100644 tests/conformance/semantics/01-constant-return.mq.md create mode 100644 tests/conformance/semantics/02-text-return.expected.json create mode 100644 tests/conformance/semantics/02-text-return.mq.md create mode 100644 tests/conformance/semantics/03-float-arithmetic.expected.json create mode 100644 tests/conformance/semantics/03-float-arithmetic.mq.md create mode 100644 tests/conformance/semantics/04-big-int-arithmetic.expected.json create mode 100644 tests/conformance/semantics/04-big-int-arithmetic.mq.md create mode 100644 tests/conformance/semantics/05-factorio-recursion.expected.json create mode 100644 tests/conformance/semantics/05-factorio-recursion.mq.md create mode 100644 tests/conformance/semantics/06-fibonacci-recursion.expected.json create mode 100644 tests/conformance/semantics/06-fibonacci-recursion.mq.md create mode 100644 tests/conformance/semantics/07-euclid-iterative.expected.json create mode 100644 tests/conformance/semantics/07-euclid-iterative.mq.md create mode 100644 tests/conformance/semantics/08-loop-sum.expected.json create mode 100644 tests/conformance/semantics/08-loop-sum.mq.md create mode 100644 tests/conformance/semantics/09-nested-control-flow.expected.json create mode 100644 tests/conformance/semantics/09-nested-control-flow.mq.md create mode 100644 tests/conformance/semantics/10-explicit-positional-signature.expected.json create mode 100644 tests/conformance/semantics/10-explicit-positional-signature.mq.md create mode 100644 tests/conformance/semantics/11-default-parameters.expected.json create mode 100644 tests/conformance/semantics/11-default-parameters.mq.md create mode 100644 tests/conformance/semantics/12-named-arguments.expected.json create mode 100644 tests/conformance/semantics/12-named-arguments.mq.md create mode 100644 tests/conformance/semantics/13-function-ref-call.expected.json create mode 100644 tests/conformance/semantics/13-function-ref-call.mq.md create mode 100644 tests/conformance/semantics/14-function-ref-value.expected.json create mode 100644 tests/conformance/semantics/14-function-ref-value.mq.md create mode 100644 tests/conformance/semantics/15-string-builtins.expected.json create mode 100644 tests/conformance/semantics/15-string-builtins.mq.md create mode 100644 tests/conformance/semantics/16-int-builtins.expected.json create mode 100644 tests/conformance/semantics/16-int-builtins.mq.md create mode 100644 tests/conformance/semantics/17-float-builtins.expected.json create mode 100644 tests/conformance/semantics/17-float-builtins.mq.md create mode 100644 tests/conformance/semantics/18-table-builtin.expected.json create mode 100644 tests/conformance/semantics/18-table-builtin.mq.md create mode 100644 tests/conformance/semantics/19-type-builtin.expected.json create mode 100644 tests/conformance/semantics/19-type-builtin.mq.md create mode 100644 tests/conformance/semantics/20-math-eval-ref.expected.json create mode 100644 tests/conformance/semantics/20-math-eval-ref.mq.md create mode 100644 tests/conformance/semantics/21-math-eval-positional.expected.json create mode 100644 tests/conformance/semantics/21-math-eval-positional.mq.md create mode 100644 tests/conformance/semantics/22-print-stdout.expected.json create mode 100644 tests/conformance/semantics/22-print-stdout.mq.md create mode 100644 tests/conformance/semantics/23-unit-fallthrough.expected.json create mode 100644 tests/conformance/semantics/23-unit-fallthrough.mq.md create mode 100644 tests/conformance/semantics/24-none-value.expected.json create mode 100644 tests/conformance/semantics/24-none-value.mq.md create mode 100644 tests/conformance/semantics/25-bool-operators.expected.json create mode 100644 tests/conformance/semantics/25-bool-operators.mq.md create mode 100644 tests/conformance/semantics/26-mixed-comparison.expected.json create mode 100644 tests/conformance/semantics/26-mixed-comparison.mq.md create mode 100644 tests/conformance/semantics/27-floor-division-modulo.expected.json create mode 100644 tests/conformance/semantics/27-floor-division-modulo.mq.md create mode 100644 tests/conformance/semantics/28-index-and-member.expected.json create mode 100644 tests/conformance/semantics/28-index-and-member.mq.md create mode 100644 tests/conformance/semantics/29-map-record-literal.expected.json create mode 100644 tests/conformance/semantics/29-map-record-literal.mq.md create mode 100644 tests/conformance/semantics/30-print-list-and-map.expected.json create mode 100644 tests/conformance/semantics/30-print-list-and-map.mq.md create mode 100644 tests/conformance/semantics/31-string-concat.expected.json create mode 100644 tests/conformance/semantics/31-string-concat.mq.md create mode 100644 tests/conformance/semantics/32-recursive-sum.expected.json create mode 100644 tests/conformance/semantics/32-recursive-sum.mq.md create mode 100644 tests/conformance/semantics/33-conditional-return-in-loop.expected.json create mode 100644 tests/conformance/semantics/33-conditional-return-in-loop.mq.md create mode 100644 tests/conformance/semantics/34-elif-chain.expected.json create mode 100644 tests/conformance/semantics/34-elif-chain.mq.md create mode 100644 tests/conformance/semantics/35-default-and-named-mixed.expected.json create mode 100644 tests/conformance/semantics/35-default-and-named-mixed.mq.md create mode 100644 tests/conformance/semantics/36-foreign-call-python.expected.json create mode 100644 tests/conformance/semantics/36-foreign-call-python.mq.md create mode 100644 tests/negative/01-invalid-strong-nested-emph.expected.json create mode 100644 tests/negative/01-invalid-strong-nested-emph.mq.md create mode 100644 tests/negative/02-invalid-strong-nested-strong.expected.json create mode 100644 tests/negative/02-invalid-strong-nested-strong.mq.md create mode 100644 tests/negative/03-invalid-strong-nested-link.expected.json create mode 100644 tests/negative/03-invalid-strong-nested-link.mq.md create mode 100644 tests/negative/04-invalid-strong-nested-math.expected.json create mode 100644 tests/negative/04-invalid-strong-nested-math.mq.md create mode 100644 tests/negative/05-invalid-strong-nested-strikethrough.expected.json create mode 100644 tests/negative/05-invalid-strong-nested-strikethrough.mq.md create mode 100644 tests/negative/06-invalid-strong-linebreak.expected.json create mode 100644 tests/negative/06-invalid-strong-linebreak.mq.md create mode 100644 tests/negative/07-invalid-emph-nested-strong.expected.json create mode 100644 tests/negative/07-invalid-emph-nested-strong.mq.md create mode 100644 tests/negative/08-invalid-emph-nested-emph.expected.json create mode 100644 tests/negative/08-invalid-emph-nested-emph.mq.md create mode 100644 tests/negative/09-invalid-strong-empty-payload.expected.json create mode 100644 tests/negative/09-invalid-strong-empty-payload.mq.md create mode 100644 tests/negative/10-invalid-emph-empty-payload.expected.json create mode 100644 tests/negative/10-invalid-emph-empty-payload.mq.md create mode 100644 tests/negative/11-invalid-strong-expression.expected.json create mode 100644 tests/negative/11-invalid-strong-expression.mq.md create mode 100644 tests/negative/12-invalid-emph-expression.expected.json create mode 100644 tests/negative/12-invalid-emph-expression.mq.md create mode 100644 tests/negative/13-ordered-item-no-condition.expected.json create mode 100644 tests/negative/13-ordered-item-no-condition.mq.md create mode 100644 tests/negative/14-bullet-item-no-condition.expected.json create mode 100644 tests/negative/14-bullet-item-no-condition.mq.md create mode 100644 tests/negative/15-ordered-item-first-block-not-paragraph.expected.json create mode 100644 tests/negative/15-ordered-item-first-block-not-paragraph.mq.md create mode 100644 tests/negative/16-ordered-item-first-inline-not-code.expected.json create mode 100644 tests/negative/16-ordered-item-first-inline-not-code.mq.md create mode 100644 tests/negative/17-ordered-condition-invalid-expression.expected.json create mode 100644 tests/negative/17-ordered-condition-invalid-expression.mq.md create mode 100644 tests/negative/18-quote-not-a-call.expected.json create mode 100644 tests/negative/18-quote-not-a-call.mq.md create mode 100644 tests/negative/19-quote-multi-paragraph.expected.json create mode 100644 tests/negative/19-quote-multi-paragraph.mq.md create mode 100644 tests/negative/20-quote-nested.expected.json create mode 100644 tests/negative/20-quote-nested.mq.md create mode 100644 tests/negative/21-quote-empty.expected.json create mode 100644 tests/negative/21-quote-empty.mq.md create mode 100644 tests/negative/22-quote-two-calls-one-paragraph.expected.json create mode 100644 tests/negative/22-quote-two-calls-one-paragraph.mq.md create mode 100644 tests/negative/23-quote-non-call-expression.expected.json create mode 100644 tests/negative/23-quote-non-call-expression.mq.md create mode 100644 tests/negative/24-quote-link-form-without-arguments.expected.json create mode 100644 tests/negative/24-quote-link-form-without-arguments.mq.md create mode 100644 tests/negative/25-quote-external-link-call.expected.json create mode 100644 tests/negative/25-quote-external-link-call.mq.md create mode 100644 tests/negative/26-quote-cross-module-link-call.expected.json create mode 100644 tests/negative/26-quote-cross-module-link-call.mq.md create mode 100644 tests/negative/27-quote-unresolved-anchor.expected.json create mode 100644 tests/negative/27-quote-unresolved-anchor.mq.md create mode 100644 tests/negative/28-duplicate-function-name.expected.json create mode 100644 tests/negative/28-duplicate-function-name.mq.md create mode 100644 tests/negative/29-duplicate-namespace-name.expected.json create mode 100644 tests/negative/29-duplicate-namespace-name.mq.md create mode 100644 tests/negative/30-empty-function-heading.expected.json create mode 100644 tests/negative/30-empty-function-heading.mq.md create mode 100644 tests/negative/31-empty-namespace-heading.expected.json create mode 100644 tests/negative/31-empty-namespace-heading.mq.md create mode 100644 tests/negative/32-unknown-function.expected.json create mode 100644 tests/negative/32-unknown-function.mq.md create mode 100644 tests/negative/33-inferred-signature-positional.expected.json create mode 100644 tests/negative/33-inferred-signature-positional.mq.md create mode 100644 tests/negative/34-missing-required-argument.expected.json create mode 100644 tests/negative/34-missing-required-argument.mq.md create mode 100644 tests/negative/35-unknown-named-argument.expected.json create mode 100644 tests/negative/35-unknown-named-argument.mq.md create mode 100644 tests/negative/36-malformed-signature-name.expected.json create mode 100644 tests/negative/36-malformed-signature-name.mq.md create mode 100644 tests/negative/37-malformed-signature-duplicate-param.expected.json create mode 100644 tests/negative/37-malformed-signature-duplicate-param.mq.md create mode 100644 tests/negative/38-signature-non-constant-default.expected.json create mode 100644 tests/negative/38-signature-non-constant-default.mq.md create mode 100644 tests/negative/39-unknown-variable-explicit-signature.expected.json create mode 100644 tests/negative/39-unknown-variable-explicit-signature.mq.md create mode 100644 tests/negative/40-partial-branch-assignment-ambiguity.expected.json create mode 100644 tests/negative/40-partial-branch-assignment-ambiguity.mq.md create mode 100644 tests/negative/41-frontmatter-invalid-yaml.expected.json create mode 100644 tests/negative/41-frontmatter-invalid-yaml.mq.md create mode 100644 tests/negative/42-frontmatter-invalid-import-shape.expected.json create mode 100644 tests/negative/42-frontmatter-invalid-import-shape.mq.md create mode 100644 tests/negative/43-unknown-callee-in-quote.expected.json create mode 100644 tests/negative/43-unknown-callee-in-quote.mq.md create mode 100644 tests/negative/44-link-call-bad-arguments.expected.json create mode 100644 tests/negative/44-link-call-bad-arguments.mq.md create mode 100644 tests/negative/45-branch-condition-invalid-expression.expected.json create mode 100644 tests/negative/45-branch-condition-invalid-expression.mq.md create mode 100644 tests/negative/46-duplicate-import-alias-frontmatter.expected.json create mode 100644 tests/negative/46-duplicate-import-alias-frontmatter.mq.md create mode 100644 tests/negative/47-unsupported-quote-statement.expected.json create mode 100644 tests/negative/47-unsupported-quote-statement.mq.md create mode 100644 tests/negative/48-strong-assignment-bad-target.expected.json create mode 100644 tests/negative/48-strong-assignment-bad-target.mq.md create mode 100644 tests/negative/runtime/01-division-by-zero.expected.json create mode 100644 tests/negative/runtime/01-division-by-zero.mq.md create mode 100644 tests/negative/runtime/02-type-error.expected.json create mode 100644 tests/negative/runtime/02-type-error.mq.md create mode 100644 tests/negative/runtime/03-index-out-of-bounds.expected.json create mode 100644 tests/negative/runtime/03-index-out-of-bounds.mq.md create mode 100644 tests/negative/runtime/04-unknown-field.expected.json create mode 100644 tests/negative/runtime/04-unknown-field.mq.md create mode 100644 tests/negative/runtime/05-not-callable.expected.json create mode 100644 tests/negative/runtime/05-not-callable.mq.md create mode 100644 tests/negative/runtime/06-permission-denied-foreign.expected.json create mode 100644 tests/negative/runtime/06-permission-denied-foreign.mq.md create mode 100644 tests/negative/runtime/07-math-unsupported.expected.json create mode 100644 tests/negative/runtime/07-math-unsupported.mq.md create mode 100644 tests/negative/runtime/08-stack-overflow.expected.json create mode 100644 tests/negative/runtime/08-stack-overflow.mq.md create mode 100644 tests/negative/runtime/09-branch-condition-not-bool.expected.json create mode 100644 tests/negative/runtime/09-branch-condition-not-bool.mq.md create mode 100644 tests/negative/runtime/10-function-ref-bad-argument.expected.json create mode 100644 tests/negative/runtime/10-function-ref-bad-argument.mq.md create mode 100644 tests/negative/warnings/01-return-outside-function.expected.json create mode 100644 tests/negative/warnings/01-return-outside-function.mq.md create mode 100644 tests/negative/warnings/02-strong-outside-function.expected.json create mode 100644 tests/negative/warnings/02-strong-outside-function.mq.md create mode 100644 tests/negative/warnings/03-ordered-list-outside-function.expected.json create mode 100644 tests/negative/warnings/03-ordered-list-outside-function.mq.md create mode 100644 tests/negative/warnings/04-bullet-list-outside-function.expected.json create mode 100644 tests/negative/warnings/04-bullet-list-outside-function.mq.md create mode 100644 tests/negative/warnings/05-quote-outside-function.expected.json create mode 100644 tests/negative/warnings/05-quote-outside-function.mq.md create mode 100644 tests/negative/warnings/06-executable-in-module-root-prose.expected.json create mode 100644 tests/negative/warnings/06-executable-in-module-root-prose.mq.md diff --git a/Cargo.toml b/Cargo.toml index 2714828..810a4cf 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -42,7 +42,7 @@ marqdo-package = { path = "crates/marqdo-package" } marqdo-sandbox = { path = "crates/marqdo-sandbox" } comrak = { version = "=1.0.0", default-features = false } serde = { version = "1", features = ["derive"] } -serde_json = "1" +serde_json = { version = "1", features = ["float_roundtrip"] } serde_yaml = "0.9" num-bigint = { version = "0.4", features = ["serde"] } num-rational = { version = "0.4", features = ["serde"] } diff --git a/crates/cli/tests/conformance_ast.rs b/crates/cli/tests/conformance_ast.rs new file mode 100644 index 0000000..9d7d0eb --- /dev/null +++ b/crates/cli/tests/conformance_ast.rs @@ -0,0 +1,215 @@ +//! AST conformance golden tests for the frozen `marqdo.md.v1` Markdown profile. +//! +//! Each `tests/conformance/ast/*.mq.md` fixture is parsed with +//! [`marqdo_markdown::parse`] and the canonical AST root is serialized to +//! pretty JSON. The result is compared byte-for-byte with the sibling +//! `*.ast.json` golden. +//! +//! Regenerate goldens deliberately with: +//! +//! ```text +//! UPDATE_GOLDENS=1 cargo test -p marqdo-cli --test conformance_ast +//! ``` +//! +//! Updating is the *only* way goldens change; the test fails if a fixture has +//! no golden and if a golden has no fixture. + +use std::fs; +use std::path::{Path, PathBuf}; + +/// Repository root (the workspace above `crates/cli`). +fn repo_root() -> PathBuf { + Path::new(env!("CARGO_MANIFEST_DIR")) + .parent() + .expect("crates/cli has a parent") + .parent() + .expect("crates has a parent") + .to_path_buf() +} + +fn ast_dir() -> PathBuf { + repo_root().join("tests").join("conformance").join("ast") +} + +/// All fixture paths, sorted by file name for deterministic ordering. +fn fixture_paths() -> Vec { + let dir = ast_dir(); + let mut paths: Vec = fs::read_dir(&dir) + .unwrap_or_else(|error| panic!("cannot read {}: {error}", dir.display())) + .filter_map(Result::ok) + .map(|entry| entry.path()) + .filter(|path| path.extension().is_some_and(|ext| ext == "md")) + .collect(); + paths.sort(); + paths +} + +/// Serialize the canonical AST view with a trailing newline. +fn golden_text(source: &str) -> String { + let document = marqdo_markdown::parse(source); + let mut text = serde_json::to_string_pretty(&document.root) + .expect("the canonical AST view is always serializable"); + text.push('\n'); + text +} + +/// Golden path for a fixture: `foo.mq.md` -> `foo.ast.json` (the extension +/// replacement must keep the `.mq` marker, not overwrite `md` only). +fn golden_path(fixture: &Path) -> PathBuf { + let name = fixture + .file_name() + .expect("fixture has a file name") + .to_string_lossy(); + let stem = name + .strip_suffix(".mq.md") + .unwrap_or_else(|| panic!("fixture `{}` must end in .mq.md", fixture.display())); + fixture.with_file_name(format!("{stem}.ast.json")) +} + +fn write_golden(path: &Path, text: &str) { + fs::write(path, text) + .unwrap_or_else(|error| panic!("cannot write golden {}: {error}", path.display())); +} + +/// Report a compact, line-based diff summary for one fixture. +fn report_mismatch(fixture: &Path, expected: &str, actual: &str) { + let expected_lines: Vec<&str> = expected.lines().collect(); + let actual_lines: Vec<&str> = actual.lines().collect(); + let mut differences = 0usize; + let mut first: Option = None; + for index in 0..expected_lines.len().max(actual_lines.len()) { + if expected_lines.get(index) != actual_lines.get(index) { + differences += 1; + if first.is_none() { + first = Some(index); + } + } + } + let first = first.unwrap_or(0); + let start = first.saturating_sub(3); + let end = (first + 8).min(expected_lines.len().max(actual_lines.len())); + let mut message = format!( + "AST golden mismatch for `{}`.\n\ + {} line(s) differ (first at line {}).\n\ + --- expected (golden) ---\n", + fixture.display(), + differences, + first + 1 + ); + for index in start..end { + message.push_str(&format!( + "{:>4} | {}\n", + index + 1, + expected_lines.get(index).copied().unwrap_or("") + )); + } + message.push_str("--- actual (parser) ---\n"); + for index in start..end { + message.push_str(&format!( + "{:>4} | {}\n", + index + 1, + actual_lines.get(index).copied().unwrap_or("") + )); + } + + // The most common cause is an executable payload of the wrong shape. Point + // at the offending source region so authors can fix the fixture quickly. + if let Ok(source) = fs::read_to_string(fixture) { + if let Ok(value) = serde_json::from_str::(expected) { + if let Some(span) = value.get("span") { + let start = span.get("start").and_then(serde_json::Value::as_u64); + let end = span.get("end").and_then(serde_json::Value::as_u64); + if let (Some(start), Some(end)) = (start, end) { + let slice = source.get(start as usize..end as usize).unwrap_or(""); + message.push_str(&format!("first node source: {slice:?}\n")); + } + } + } + } + + message.push_str( + "Run `UPDATE_GOLDENS=1 cargo test -p marqdo-cli --test conformance_ast` \ + only for an intentional profile change.\n", + ); + panic!("{message}"); +} + +#[test] +fn ast_goldens_match_the_frozen_profile() { + let fixtures = fixture_paths(); + assert!( + fixtures.len() >= 100, + "the P0 corpus must keep at least 100 AST fixtures, found {}", + fixtures.len() + ); + + let update = std::env::var_os("UPDATE_GOLDENS").is_some_and(|value| value == "1"); + let mut updated = 0usize; + let mut failures: Vec = Vec::new(); + + for fixture in &fixtures { + let source = fs::read_to_string(fixture) + .unwrap_or_else(|error| panic!("cannot read fixture {}: {error}", fixture.display())); + let golden = golden_path(fixture); + let actual = golden_text(&source); + + if update { + write_golden(&golden, &actual); + updated += 1; + continue; + } + + let expected = fs::read_to_string(&golden).unwrap_or_else(|error| { + panic!( + "missing AST golden for `{}` ({error}).\n\ + Run `UPDATE_GOLDENS=1 cargo test -p marqdo-cli --test conformance_ast`.", + fixture.display() + ) + }); + if expected != actual { + failures.push(fixture.display().to_string()); + } + } + + if update { + println!( + "UPDATE_GOLDENS=1: rewrote {updated} AST golden(s) under {}", + ast_dir().display() + ); + return; + } + + // A golden without a fixture is stale corpus output; fail rather than keep + // silently ignored files. + let golden_count = fs::read_dir(ast_dir()) + .expect("ast fixture directory is readable") + .filter_map(Result::ok) + .filter(|entry| { + entry + .path() + .extension() + .is_some_and(|extension| extension == "json") + }) + .count(); + assert_eq!( + golden_count, + fixtures.len(), + "every AST fixture needs exactly one golden (orphan *.ast.json files?)" + ); + + if failures.is_empty() { + return; + } + + // Re-read the mismatching fixtures to produce a detailed, line-based diff. + // This keeps the common pass path cheap and the failure path informative. + for fixture in &fixtures { + let source = fs::read_to_string(fixture).expect("fixture is readable"); + let golden = golden_path(fixture); + let expected = fs::read_to_string(&golden).expect("golden is readable"); + let actual = golden_text(&source); + if expected != actual { + report_mismatch(fixture, &expected, &actual); + } + } +} diff --git a/crates/cli/tests/conformance_semantics.rs b/crates/cli/tests/conformance_semantics.rs new file mode 100644 index 0000000..89d8cfb --- /dev/null +++ b/crates/cli/tests/conformance_semantics.rs @@ -0,0 +1,265 @@ +//! End-to-end semantic conformance tests. +//! +//! Each `tests/conformance/semantics/*.mq.md` fixture is analysed by +//! [`marqdo_frontend::analyze_source`], assembled into an +//! [`marqdo_ir::Program`] and executed through [`marqdo_runtime::run`] with a +//! [`marqdo_host::StdHost`] in `project` mode. The typed wire representation +//! ([`marqdo_value::to_wire`]) of the returned value and the captured program +//! stdout are compared with the sibling `*.expected.json`: +//! +//! ```json +//! {"function": "", "args": {"name": }, +//! "value": , "stdout": "..."} +//! ``` +//! +//! Fixtures that need an explicit grant declare it as +//! `"grants": ["foreign"]`; they are skipped when the kernel is unavailable. +//! +//! Developer note: `UPDATE_SEMANTICS_GOLDENS=1` rewrites `value`/`stdout` from +//! the implementation. Never use it without hand-checking every rewritten +//! expectation; the checked-in goldens were reviewed individually. + +use std::fs; +use std::path::{Path, PathBuf}; +use std::process::Command; + +use marqdo_host::{Capabilities, Host, StdHost}; +use marqdo_ir::ModuleId; +use marqdo_runtime::{run, EvaluatedArg}; +use marqdo_sandbox::SandboxMode; + +fn repo_root() -> PathBuf { + Path::new(env!("CARGO_MANIFEST_DIR")) + .parent() + .expect("crates/cli has a parent") + .parent() + .expect("crates has a parent") + .to_path_buf() +} + +fn semantics_dir() -> PathBuf { + repo_root() + .join("tests") + .join("conformance") + .join("semantics") +} + +fn fixture_paths() -> Vec { + let dir = semantics_dir(); + let mut paths: Vec = fs::read_dir(&dir) + .unwrap_or_else(|error| panic!("cannot read {}: {error}", dir.display())) + .filter_map(Result::ok) + .map(|entry| entry.path()) + .filter(|path| path.extension().is_some_and(|extension| extension == "md")) + .collect(); + paths.sort(); + paths +} + +fn expected_path(fixture: &Path) -> PathBuf { + let name = fixture + .file_name() + .expect("fixture has a file name") + .to_string_lossy(); + let stem = name + .strip_suffix(".mq.md") + .unwrap_or_else(|| panic!("fixture `{}` must end in .mq.md", fixture.display())); + fixture.with_file_name(format!("{stem}.expected.json")) +} + +fn python_available() -> bool { + Command::new("python3") + .arg("--version") + .output() + .map(|output| output.status.success()) + .unwrap_or(false) +} + +/// Unique scratch directory for the host project root. Program fixtures are +/// pure, so nothing is read from or written to it; it only satisfies the host +/// constructor contract. +fn scratch_project_root() -> PathBuf { + let nanos = std::time::SystemTime::now() + .duration_since(std::time::UNIX_EPOCH) + .map(|duration| duration.as_nanos()) + .unwrap_or(0); + let dir = std::env::temp_dir().join(format!( + "marqdo-conformance-semantics-{}-{nanos}", + std::process::id() + )); + fs::create_dir_all(&dir).unwrap_or_else(|error| { + panic!( + "cannot create scratch project root {}: {error}", + dir.display() + ) + }); + dir +} + +fn render_diagnostics(result: &marqdo_frontend::AnalysisResult) -> String { + let mut out = String::new(); + for diagnostic in &result.diagnostics { + out.push_str(&format!( + " {}[{}]: {}\n", + diagnostic.severity, diagnostic.code, diagnostic.message + )); + } + out +} + +#[test] +fn semantic_goldens_match_end_to_end_execution() { + let fixtures = fixture_paths(); + assert!( + fixtures.len() >= 25, + "the P0 corpus must keep at least 25 semantic fixtures, found {}", + fixtures.len() + ); + let update = std::env::var_os("UPDATE_SEMANTICS_GOLDENS").is_some_and(|value| value == "1"); + let has_python = python_available(); + let project_root = scratch_project_root(); + let mut skipped = 0usize; + let mut updated = 0usize; + + for fixture in &fixtures { + let expected_path = expected_path(fixture); + let expected_text = fs::read_to_string(&expected_path).unwrap_or_else(|error| { + panic!( + "missing semantic golden {}: {error}", + expected_path.display() + ) + }); + let mut expected: serde_json::Value = serde_json::from_str(&expected_text) + .unwrap_or_else(|error| panic!("invalid JSON in {}: {error}", expected_path.display())); + let object = expected + .as_object() + .unwrap_or_else(|| panic!("{} must be a JSON object", expected_path.display())); + + let function = object + .get("function") + .and_then(serde_json::Value::as_str) + .unwrap_or_else(|| panic!("{} has no `function`", expected_path.display())) + .to_string(); + let grant_foreign = object + .get("grants") + .and_then(serde_json::Value::as_array) + .is_some_and(|grants| grants.iter().any(|grant| grant == "foreign")); + if grant_foreign && !has_python { + skipped += 1; + println!( + "skipping {}: python3 is unavailable (foreign kernel fixture)", + fixture.display() + ); + continue; + } + + let source = fs::read_to_string(fixture) + .unwrap_or_else(|error| panic!("cannot read {}: {error}", fixture.display())); + let module_id = ModuleId::from("index.mq.md"); + let analysis = marqdo_frontend::analyze_source(&module_id.0, &source); + if analysis.has_errors() { + panic!( + "semantic fixture `{}` must compile without errors:\n{}", + fixture.display(), + render_diagnostics(&analysis) + ); + } + + let mut program = marqdo_ir::Program::default(); + program.insert(analysis.module.clone()); + program.main_module = Some(module_id.clone()); + + let mut capabilities = Capabilities::pure(); + if grant_foreign { + capabilities = capabilities.allow_foreign(); + } + let mut host = StdHost::new(SandboxMode::Project, capabilities, project_root.clone()); + + let args_value = object + .get("args") + .cloned() + .unwrap_or_else(|| serde_json::json!({})); + let args_object = args_value + .as_object() + .unwrap_or_else(|| panic!("`args` of {} must be an object", expected_path.display())); + let mut runtime_args = Vec::new(); + // BTreeMap-backed JSON objects iterate in sorted key order; argument + // evaluation order is irrelevant here because arguments are constants. + for (name, wire) in args_object { + let value = marqdo_value::from_wire(wire).unwrap_or_else(|error| { + panic!( + "invalid wire argument `{name}` in {}: {error}", + expected_path.display() + ) + }); + runtime_args.push(EvaluatedArg::named( + name.clone(), + value, + marqdo_span::Span::default(), + )); + } + + let outcome = + run(&program, &mut host, &module_id, &function, runtime_args).unwrap_or_else(|error| { + panic!( + "semantic fixture `{}` failed with {}: {}\nframes: {:?}", + fixture.display(), + error.code(), + error.message, + error.frames + ) + }); + let stdout = String::from_utf8_lossy(&host.take_output()).to_string(); + let value = marqdo_value::to_wire(&outcome.value); + + if update { + let mut object = expected.as_object().cloned().expect("object"); + object.insert("value".into(), value); + object.insert("stdout".into(), serde_json::Value::String(stdout)); + expected = serde_json::Value::Object(object); + let mut text = serde_json::to_string_pretty(&expected).expect("serializable"); + text.push('\n'); + fs::write(&expected_path, text).unwrap_or_else(|error| { + panic!("cannot write {}: {error}", expected_path.display()) + }); + updated += 1; + continue; + } + + let expected_value = object.get("value").unwrap_or_else(|| { + panic!( + "{} has no `value`; regenerate it with UPDATE_SEMANTICS_GOLDENS=1 \ + after reviewing the behaviour", + expected_path.display() + ) + }); + let expected_stdout = object + .get("stdout") + .and_then(serde_json::Value::as_str) + .unwrap_or_else(|| panic!("{} has no `stdout`", expected_path.display())); + assert_eq!( + &value, + expected_value, + "value mismatch for `{}`\n expected: {}\n actual: {}", + fixture.display(), + expected_value, + value + ); + assert_eq!( + stdout, + expected_stdout, + "stdout mismatch for `{}`", + fixture.display() + ); + } + + if update { + println!("UPDATE_SEMANTICS_GOLDENS=1: rewrote {updated} semantic golden(s)"); + return; + } + let _ = fs::remove_dir_all(&project_root); + println!( + "semantic conformance: {} fixture(s) checked, {skipped} skipped", + fixtures.len() + ); +} diff --git a/crates/cli/tests/integration_cli.rs b/crates/cli/tests/integration_cli.rs new file mode 100644 index 0000000..d9d95f1 --- /dev/null +++ b/crates/cli/tests/integration_cli.rs @@ -0,0 +1,684 @@ +//! CLI integration tests. +//! +//! These tests drive the real `marqdo` binary (`CARGO_BIN_EXE_marqdo`) with +//! [`std::process::Command`] in throw-away temporary directories. They cover +//! the public contract from `spec`/blueprint section 13: `init`, `check`, +//! `run`, `call`, `inspect`, `fmt`, multi-module imports and cycles, lock/sync +//! reproducibility, plugin inspection and plugin invocation. +//! +//! Temporary directories live under the OS temp directory and are removed on +//! drop; the repository itself is never modified. + +use std::fs; +use std::path::{Path, PathBuf}; +use std::process::{Command, Output}; + +use sha2::Digest; + +fn repo_root() -> PathBuf { + Path::new(env!("CARGO_MANIFEST_DIR")) + .parent() + .expect("crates/cli has a parent") + .parent() + .expect("crates has a parent") + .to_path_buf() +} + +/// Remove a directory tree on drop. +struct TempDir { + path: PathBuf, +} + +impl TempDir { + fn new(tag: &str) -> Self { + let nanos = std::time::SystemTime::now() + .duration_since(std::time::UNIX_EPOCH) + .map(|duration| duration.as_nanos()) + .unwrap_or(0); + let path = std::env::temp_dir().join(format!( + "marqdo-cli-integration-{tag}-{}-{nanos}", + std::process::id() + )); + fs::create_dir_all(&path) + .unwrap_or_else(|error| panic!("cannot create {}: {error}", path.display())); + Self { path } + } + + fn path(&self) -> &Path { + &self.path + } + + fn write(&self, relative: &str, contents: &str) { + let path = self.path.join(relative); + if let Some(parent) = path.parent() { + fs::create_dir_all(parent) + .unwrap_or_else(|error| panic!("cannot create {}: {error}", parent.display())); + } + fs::write(&path, contents) + .unwrap_or_else(|error| panic!("cannot write {}: {error}", path.display())); + } + + fn read(&self, relative: &str) -> String { + fs::read_to_string(self.path.join(relative)) + .unwrap_or_else(|error| panic!("cannot read `{relative}`: {error}")) + } +} + +impl Drop for TempDir { + fn drop(&mut self) { + let _ = fs::remove_dir_all(&self.path); + } +} + +/// Run the CLI in `dir`. +fn cli(dir: &Path, args: &[&str]) -> Output { + Command::new(env!("CARGO_BIN_EXE_marqdo")) + .args(args) + .current_dir(dir) + .output() + .unwrap_or_else(|error| panic!("cannot run marqdo {args:?}: {error}")) +} + +fn stdout_text(output: &Output) -> String { + String::from_utf8_lossy(&output.stdout).to_string() +} + +fn stderr_text(output: &Output) -> String { + String::from_utf8_lossy(&output.stderr).to_string() +} + +fn exit_code(output: &Output) -> i32 { + output + .status + .code() + .unwrap_or_else(|| panic!("marqdo terminated by a signal: {:?}", output.status)) +} + +fn assert_exit(output: &Output, expected: i32, context: &str) { + assert_eq!( + exit_code(output), + expected, + "{context}\n stdout: {}\n stderr: {}", + stdout_text(output), + stderr_text(output) + ); +} + +fn json_stdout(output: &Output) -> serde_json::Value { + let text = stdout_text(output); + serde_json::from_str(&text).unwrap_or_else(|error| { + panic!("stdout is not a single JSON document: {error}\nstdout: {text}") + }) +} + +fn python_available() -> bool { + Command::new("python3") + .arg("--version") + .output() + .map(|output| output.status.success()) + .unwrap_or(false) +} + +fn cc_available() -> bool { + Command::new("cc") + .arg("--version") + .output() + .map(|output| output.status.success()) + .unwrap_or(false) +} + +#[test] +fn init_creates_a_runnable_project() { + let dir = TempDir::new("init"); + let output = cli(dir.path(), &["init", "proj"]); + assert_exit(&output, 0, "init must succeed"); + assert!(stdout_text(&output).contains("Initialized Marqdo project")); + let project = dir.path().join("proj"); + assert!(project.join("marqdo.yaml").is_file(), "manifest missing"); + assert!( + project.join("index.mq.md").is_file(), + "entry document missing" + ); + + let check = cli(&project, &["check", "index.mq.md"]); + assert_exit(&check, 0, "generated project must check cleanly"); + assert!(stdout_text(&check).contains("checked 1 module(s): ok")); + assert!(stderr_text(&check).is_empty()); + + let run = cli(&project, &["run", "index.mq.md"]); + assert_exit(&run, 0, "generated project must run"); + assert_eq!(stdout_text(&run), "你好,Marqdo\n"); + + let json = cli(&project, &["check", "index.mq.md", "--json"]); + assert_exit(&json, 0, "check --json must succeed"); + let value = json_stdout(&json); + assert_eq!(value["command"], "check"); + assert_eq!(value["success"], true); + assert_eq!(value["errors"], 0); + assert!(value["diagnostics"].as_array().is_some()); + assert!( + stderr_text(&json).is_empty(), + "--json must not mix stderr text" + ); + + // `init` refuses to overwrite an existing project. + let again = cli(dir.path(), &["init", "proj"]); + assert_exit(&again, 1, "init must refuse an existing manifest"); + assert!(stderr_text(&again).contains("already contains")); +} + +#[test] +fn check_exit_codes_and_diagnostics() { + let dir = TempDir::new("check"); + dir.write("good.mq.md", "## main\n\n*1 + 1*\n"); + dir.write("bad.mq.md", "## f\n\n**a *b* c**\n"); + dir.write("warning.mq.md", "**x = 1**\n\n## main\n\n*1*\n"); + + let good = cli(dir.path(), &["check", "good.mq.md"]); + assert_exit(&good, 0, "clean document"); + assert!(stdout_text(&good).contains("checked 1 module(s): ok")); + + let bad = cli(dir.path(), &["check", "bad.mq.md"]); + assert_exit(&bad, 1, "invalid executable shape is a hard error"); + let bad_stderr = stderr_text(&bad); + assert!(bad_stderr.contains("error[markdown.invalid_construct]")); + assert!(bad_stderr.contains("check failed")); + assert!(stdout_text(&bad).is_empty()); + + let bad_json = cli(dir.path(), &["check", "bad.mq.md", "--json"]); + assert_exit(&bad_json, 1, "check --json keeps the exit code"); + let value = json_stdout(&bad_json); + assert_eq!(value["command"], "check"); + assert_eq!(value["success"], false); + assert_eq!(value["errors"], 1); + let diagnostics = value["diagnostics"].as_array().expect("diagnostics array"); + assert_eq!(diagnostics.len(), 1); + assert_eq!(diagnostics[0]["code"], "markdown.invalid_construct"); + assert_eq!(diagnostics[0]["severity"], "error"); + assert_eq!(diagnostics[0]["line"], 3); + assert!(stderr_text(&bad_json).is_empty()); + + let warning = cli(dir.path(), &["check", "warning.mq.md"]); + assert_exit(&warning, 0, "a warning does not fail check"); + assert!(stdout_text(&warning).contains("checked 1 module(s): ok")); + assert!(stderr_text(&warning).contains("warning[markdown.inert_executable]")); + let warning_json = cli(dir.path(), &["check", "warning.mq.md", "--json"]); + let value = json_stdout(&warning_json); + assert_eq!(value["success"], true); + assert_eq!(value["diagnostics"][0]["severity"], "warning"); + + let missing = cli(dir.path(), &["check", "missing.mq.md"]); + assert_exit(&missing, 2, "missing file is a usage/IO error"); + assert!(stderr_text(&missing).contains("error")); +} + +#[test] +fn run_json_embeds_program_stdout() { + let dir = TempDir::new("run-json"); + dir.write( + "print.mq.md", + "## main\n\n> 打印(\"你好\")\n\n> 打印(42)\n\n*None*\n", + ); + let output = cli(dir.path(), &["run", "print.mq.md", "--json"]); + assert_exit(&output, 0, "run --json must succeed"); + // Exactly one JSON document on stdout: program output is embedded, never + // interleaved with the machine-readable envelope. + let value = json_stdout(&output); + assert_eq!(value["command"], "run"); + assert_eq!(value["success"], true); + assert_eq!(value["stdout"], "你好\n42\n"); + assert_eq!(value["value"]["type"], "none"); + assert!(value["trace"].as_array().is_some()); + assert!(stderr_text(&output).is_empty()); + + // Text mode writes program output only to stdout, no JSON envelope. + let text = cli(dir.path(), &["run", "print.mq.md"]); + assert_exit(&text, 0, "run must succeed"); + assert_eq!(stdout_text(&text), "你好\n42\n"); +} + +#[test] +fn run_refuses_documents_with_compile_errors() { + let dir = TempDir::new("run-errors"); + dir.write("bad.mq.md", "## f\n\n**a *b* c**\n"); + let output = cli(dir.path(), &["run", "bad.mq.md"]); + assert_exit(&output, 1, "compile errors must prevent execution"); + let stderr = stderr_text(&output); + assert!(stderr.contains("markdown.invalid_construct")); + assert!(stderr.contains("refusing to run")); + assert!(stdout_text(&output).is_empty()); +} + +#[test] +fn call_executes_examples_with_typed_arguments() { + let root = repo_root(); + let examples = root.join("examples"); + let factorial = examples.join("factorial.mq.md"); + + let output = cli( + &root, + &[ + "call", + factorial.to_str().unwrap(), + "数学.阶乘", + "--arg", + "n=5", + "--json", + ], + ); + assert_exit(&output, 0, "call must execute factorial"); + let value = json_stdout(&output); + assert_eq!(value["success"], true); + assert_eq!(value["value"]["type"], "int"); + assert_eq!(value["value"]["decimal"], "120"); + + let math = examples.join("math.mq.md"); + let output = cli( + &root, + &["call", math.to_str().unwrap(), "计算圆面积", "--json"], + ); + assert_exit(&output, 0, "call must execute the math example"); + let value = json_stdout(&output); + assert_eq!(value["value"]["type"], "float"); + let area = value["value"]["value"].as_f64().expect("float value"); + assert!( + (area - std::f64::consts::PI * 16.0).abs() < 1e-12, + "area={area}" + ); + + let references = examples.join("references.mq.md"); + let output = cli( + &root, + &["call", references.to_str().unwrap(), "计算作用力", "--json"], + ); + assert_exit(&output, 0, "call must execute the references example"); + let value = json_stdout(&output); + assert_eq!(value["value"]["decimal"], "6"); + + let hello = examples.join("hello.mq.md"); + let output = cli(&root, &["run", hello.to_str().unwrap()]); + assert_exit(&output, 0, "hello example"); + assert_eq!(stdout_text(&output), "你好,Marqdo\n"); +} + +#[test] +fn examples_run_end_to_end_including_foreign_when_available() { + let root = repo_root(); + let multi = root + .join("examples") + .join("multi-module") + .join("index.mq.md"); + let output = cli(&root, &["run", multi.to_str().unwrap()]); + assert_exit(&output, 0, "multi-module example"); + let printed = stdout_text(&output); + let area: f64 = printed.trim().parse().expect("printed float"); + assert!((area - std::f64::consts::PI * 4.0).abs() < 1e-12); + + if !python_available() { + println!("skipping python foreign example: python3 is unavailable"); + return; + } + let foreign = root.join("examples").join("python-foreign.mq.md"); + let output = cli( + &root, + &["run", foreign.to_str().unwrap(), "--allow-foreign"], + ); + assert_exit(&output, 0, "python foreign example"); + let printed = stdout_text(&output); + assert!( + printed.starts_with("28.27"), + "unexpected foreign output: {printed:?}" + ); +} + +#[test] +fn strict_mode_refuses_without_isolation() { + let root = repo_root(); + let hello = root.join("examples").join("hello.mq.md"); + let output = cli(&root, &["run", hello.to_str().unwrap(), "--mode", "strict"]); + assert_exit( + &output, + 1, + "strict mode must refuse when isolation is absent", + ); + let stderr = stderr_text(&output); + assert!( + stderr.contains("refusing to run in strict mode"), + "stderr: {stderr}" + ); + assert!(stderr.contains("isolation"), "stderr: {stderr}"); + assert!(stdout_text(&output).is_empty()); + + let json = cli( + &root, + &["run", hello.to_str().unwrap(), "--mode", "strict", "--json"], + ); + assert_exit(&json, 1, "strict refusal keeps exit code 1 in JSON mode"); + let value = json_stdout(&json); + assert_eq!(value["success"], false); + assert!(value["error"] + .as_str() + .expect("error string") + .contains("strict mode")); +} + +#[test] +fn inspect_outputs_ast_units_signatures_ir_and_refs() { + let root = repo_root(); + let factorial = root.join("examples").join("factorial.mq.md"); + let factorial = factorial.to_str().unwrap(); + + let ast = cli(&root, &["inspect", factorial, "--ast", "--json"]); + assert_exit(&ast, 0, "inspect --ast"); + let value = json_stdout(&ast); + assert_eq!(value["command"], "inspect"); + assert_eq!(value["ast"]["kind"], "document"); + + let units = cli(&root, &["inspect", factorial, "--units", "--json"]); + assert_exit(&units, 0, "inspect --units"); + let value = json_stdout(&units); + let units = value["units"].as_array().expect("units array"); + assert!(units.iter().any(|unit| unit["kind"] == "function")); + + let signatures = cli(&root, &["inspect", factorial, "--signature", "--json"]); + assert_exit(&signatures, 0, "inspect --signature"); + let value = json_stdout(&signatures); + let signature = value["signatures"] + .as_array() + .expect("signatures array") + .iter() + .find(|entry| entry["name"] == "数学.阶乘") + .expect("factorial signature"); + assert_eq!(signature["signature"], "inferred"); + assert_eq!(signature["params"][0]["name"], "n"); + + let ir = cli(&root, &["inspect", factorial, "--ir", "--json"]); + assert_exit(&ir, 0, "inspect --ir"); + let value = json_stdout(&ir); + let functions = value["ir"].as_array().expect("IR array"); + assert!(!functions.is_empty()); + assert!(functions[0]["body"].is_array()); + + // A link that resolves cleanly. + let references = root.join("examples").join("references.mq.md"); + let refs = cli( + &root, + &["inspect", references.to_str().unwrap(), "--refs", "--json"], + ); + assert_exit(&refs, 0, "inspect --refs"); + let value = json_stdout(&refs); + let edges = value["refs"].as_array().expect("refs array"); + assert!(edges.iter().any(|edge| edge["resolved"] == true)); + + // A broken #anchor is reported as unresolved by `inspect --refs`. + let dir = TempDir::new("refs"); + dir.write( + "broken.mq.md", + "## main\n\n见[断链](#不存在的标题)。\n\n*1*\n", + ); + let broken = cli(dir.path(), &["inspect", "broken.mq.md", "--refs", "--json"]); + assert_exit(&broken, 0, "inspect --refs never executes the document"); + let value = json_stdout(&broken); + let edges = value["refs"].as_array().expect("refs array"); + assert_eq!(edges.len(), 1); + assert_eq!(edges[0]["url"], "#不存在的标题"); + assert_eq!(edges[0]["resolved"], false); +} + +#[test] +fn fmt_normalises_line_endings_and_trailing_newlines() { + let dir = TempDir::new("fmt"); + dir.write("doc.mq.md", "## main\r\n\r\n*1*\r\n\r\n\r\n"); + let before = cli(dir.path(), &["fmt", "--check", "doc.mq.md"]); + assert_exit(&before, 1, "unformatted document is detected"); + assert!(stderr_text(&before).contains("is not formatted")); + + let format = cli(dir.path(), &["fmt", "doc.mq.md"]); + assert_exit(&format, 0, "fmt must rewrite the document"); + let formatted = dir.read("doc.mq.md"); + assert_eq!(formatted, "## main\n\n*1*\n"); + assert!(!formatted.contains('\r')); + + let after = cli(dir.path(), &["fmt", "--check", "doc.mq.md"]); + assert_exit(&after, 0, "formatted document is accepted"); +} + +#[test] +fn multi_module_imports_and_cycles() { + let dir = TempDir::new("modules"); + dir.write( + "geometry.mq.md", + "## 圆面积\n\n`(r: Number)`\n\n*math.eval(ref(\"#公式\"), {\"r\": r}, target=\"A\")*\n\n### 公式\n\n$$\nA = \\pi r^2\n$$\n", + ); + dir.write( + "index.mq.md", + "---\nimport:\n geometry: \"./geometry.mq.md\"\n---\n\n## main\n\n**面积 = geometry.圆面积(r=2)**\n\n> 打印(面积)\n", + ); + let run = cli(dir.path(), &["run", "index.mq.md"]); + assert_exit(&run, 0, "multi-module import must run"); + let printed: f64 = stdout_text(&run).trim().parse().expect("printed float"); + assert!((printed - std::f64::consts::PI * 4.0).abs() < 1e-12); + let check = cli(dir.path(), &["check", "index.mq.md"]); + assert_exit(&check, 0, "multi-module import must check"); + + // Import cycle diagnostics. + let cycle = TempDir::new("cycle"); + cycle.write( + "a.mq.md", + "---\nimport:\n b: \"./b.mq.md\"\n---\n\n## main\n\n*1*\n", + ); + cycle.write( + "b.mq.md", + "---\nimport:\n a: \"./a.mq.md\"\n---\n\n## f\n\n*1*\n", + ); + let output = cli(cycle.path(), &["check", "a.mq.md"]); + assert_exit(&output, 1, "import cycle is an error"); + let stderr = stderr_text(&output); + assert!(stderr.contains("module.cycle"), "stderr: {stderr}"); + assert!(stderr.contains("import cycle"), "stderr: {stderr}"); + + // A missing import target is a module.unresolved error. + let missing = TempDir::new("missing-import"); + missing.write( + "index.mq.md", + "---\nimport:\n gone: \"./gone.mq.md\"\n---\n\n## main\n\n*1*\n", + ); + let output = cli(missing.path(), &["check", "index.mq.md"]); + assert_exit(&output, 1, "missing import target is an error"); + assert!(stderr_text(&output).contains("module.unresolved")); +} + +#[test] +fn lock_and_sync_locked_detect_dependency_tampering() { + let dir = TempDir::new("lock"); + dir.write( + "marqdo.yaml", + "project:\n name: locktest\n version: 0.1.0\ndependencies:\n dep:\n path: \"./dep\"\n", + ); + dir.write("index.mq.md", "## main\n\n*1*\n"); + dir.write("dep/index.mq.md", "## main\n\n*1*\n"); + + let lock = cli(dir.path(), &["lock"]); + assert_exit(&lock, 0, "lock must succeed"); + assert!(stdout_text(&lock).contains("locked 1 package(s)")); + let lockfile = dir.read("marqdo.lock"); + assert!(lockfile.contains("name: dep")); + + let sync = cli(dir.path(), &["sync", "--locked"]); + assert_exit(&sync, 0, "sync --locked must succeed after lock"); + assert!(stdout_text(&sync).contains("synchronized 1 package(s)")); + + // Tamper with the dependency contents: `sync --locked` must fail. + dir.write("dep/index.mq.md", "## main\n\n*2*\n"); + let tampered = cli(dir.path(), &["sync", "--locked"]); + assert_exit(&tampered, 1, "tampered dependency must fail sync --locked"); + assert!(stderr_text(&tampered).contains("lockfile is out of date")); + + // Re-locking restores a consistent state. + let relock = cli(dir.path(), &["lock"]); + assert_exit(&relock, 0, "re-lock after tampering"); + let synced = cli(dir.path(), &["sync", "--locked"]); + assert_exit(&synced, 0, "sync --locked after re-lock"); +} + +/// Build the C demo plugin in a temporary copy and refresh the manifest hash in +/// that copy only. The repository copy is never touched and the `.so` is never +/// committed. +fn build_plugin_copy(tag: &str) -> Option<(TempDir, PathBuf)> { + if !cc_available() { + println!("skipping plugin test: `cc` is unavailable"); + return None; + } + let dir = TempDir::new(tag); + let source = repo_root().join("examples").join("plugin-demo"); + let target = dir.path().join("plugin-demo"); + fs::create_dir_all(&target).expect("create plugin copy"); + for entry in fs::read_dir(&source).expect("read plugin-demo") { + let entry = entry.expect("plugin-demo entry"); + if !entry.path().is_file() { + continue; + } + // Copy manifest/source/readme but never a stale compiled artifact. + if entry + .path() + .extension() + .is_some_and(|extension| extension == "so") + { + continue; + } + fs::copy(entry.path(), target.join(entry.file_name())) + .unwrap_or_else(|error| panic!("copy plugin file: {error}")); + } + + let include = repo_root().join("include"); + let status = Command::new("cc") + .args([ + "-shared", + "-fPIC", + "-I", + include.to_str().expect("utf-8 include path"), + "-o", + target.join("solver.so").to_str().expect("utf-8 path"), + target.join("solver.c").to_str().expect("utf-8 path"), + ]) + .status() + .unwrap_or_else(|error| panic!("cannot run cc: {error}")); + assert!(status.success(), "building the demo plugin failed"); + + let bytes = fs::read(target.join("solver.so")).expect("read solver.so"); + let digest = hex::encode(sha2::Sha256::digest(&bytes)); + let manifest_path = target.join("plugin.yaml"); + let manifest = fs::read_to_string(&manifest_path).expect("read plugin.yaml"); + let placeholder = "0000000000000000000000000000000000000000000000000000000000000000"; + assert!( + manifest.contains(placeholder), + "manifest placeholder missing" + ); + fs::write(&manifest_path, manifest.replace(placeholder, &digest)) + .expect("refresh plugin.yaml sha256"); + Some((dir, target)) +} + +#[test] +fn plugin_inspect_and_explicit_trusted_invocation() { + let Some((_dir, plugin_dir)) = build_plugin_copy("plugin") else { + return; + }; + // Inspection never loads plugin code and verifies the artifact hash. + let inspect = cli( + repo_root().as_path(), + &["plugin", "inspect", plugin_dir.to_str().unwrap(), "--json"], + ); + assert_exit(&inspect, 0, "plugin inspect"); + let value = json_stdout(&inspect); + assert_eq!(value["command"], "plugin.inspect"); + assert_eq!(value["success"], true); + assert_eq!(value["loaded"], false); + assert_eq!(value["artifact"]["verified"], true); + assert_eq!(value["exports"][0]["name"], "solver.add"); + + // Invoking a plugin export from a document requires an explicit trust + // decision, a permission grant and the plugin load itself. + let dir = TempDir::new("plugin-run"); + dir.write( + "doc.mq.md", + "## main\n\n**结果 = solver.add(a=20, b=22)**\n\n> 打印(结果)\n", + ); + let plugin_path = plugin_dir.to_str().unwrap(); + let doc = dir.path().join("doc.mq.md"); + let doc = doc.to_str().unwrap(); + + let output = cli( + dir.path(), + &[ + "run", + doc, + "--plugin", + plugin_path, + "--trust-native-plugin", + "--allow-plugin", + "demo.solver", + ], + ); + assert_exit(&output, 0, "trusted plugin invocation"); + assert_eq!(stdout_text(&output), "42\n"); + + let untrusted = cli( + dir.path(), + &[ + "run", + doc, + "--plugin", + plugin_path, + "--allow-plugin", + "demo.solver", + ], + ); + assert_exit(&untrusted, 1, "in-process loading needs explicit trust"); + assert!(stderr_text(&untrusted).contains("--trust-native-plugin")); + + let ungranted = cli( + dir.path(), + &["run", doc, "--plugin", plugin_path, "--trust-native-plugin"], + ); + assert_exit(&ungranted, 1, "plugin permission is required"); + assert!(stderr_text(&ungranted).contains("permission.denied")); + + // Unknown plugin namespace is a hard runtime symbol error. + dir.write( + "unknown.mq.md", + "## main\n\n**结果 = other.add(a=1, b=1)**\n", + ); + let unknown = cli( + dir.path(), + &[ + "run", + "unknown.mq.md", + "--plugin", + plugin_path, + "--trust-native-plugin", + "--allow-plugin", + "demo.solver", + ], + ); + assert_exit(&unknown, 1, "unknown plugin namespace"); + assert!(stderr_text(&unknown).contains("symbol.unknown")); + + // The export signature requires both named arguments: a missing argument + // becomes a structured plugin failure, never a panic. + dir.write("args.mq.md", "## main\n\n**结果 = solver.add(a=1)**\n"); + let bad_args = cli( + dir.path(), + &[ + "run", + "args.mq.md", + "--plugin", + plugin_path, + "--trust-native-plugin", + "--allow-plugin", + "demo.solver", + ], + ); + assert_exit(&bad_args, 1, "plugin argument failure"); + assert!(stderr_text(&bad_args).contains("plugin.failure")); +} diff --git a/crates/cli/tests/negative.rs b/crates/cli/tests/negative.rs new file mode 100644 index 0000000..23c833a --- /dev/null +++ b/crates/cli/tests/negative.rs @@ -0,0 +1,286 @@ +//! Negative conformance tests: executable shapes that must be hard errors. +//! +//! Three suites share this file: +//! +//! * `tests/negative/*.mq.md` — compile-time errors (`marqdo_frontend`). The +//! expected `*.expected.json` is `{"codes": [...]}` and must match the exact +//! sorted list of **error** codes. Warnings emitted by the same document are +//! ignored here (they are asserted separately) so the contract is precise. +//! * `tests/negative/warnings/*.mq.md` — inert-executable warnings. Expected +//! shape is `{"severity": "warning", "codes": [...]}`; the document must +//! compile without errors and the exact sorted warning-code multiset must +//! match. +//! * `tests/negative/runtime/*.mq.md` — documents that compile but fail at +//! runtime. Expected shape is +//! `{"function": "...", "args": {...}, "codes": [...]}` plus the optional +//! `"stack_limit"` budget override. Every entry is executed and the first +//! runtime error code must match. +//! +//! No fallback to prose is ever accepted: each fixture must produce at least +//! one diagnostic or runtime error with the expected stable code. + +use std::fs; +use std::path::{Path, PathBuf}; + +use marqdo_host::{Capabilities, StdHost}; +use marqdo_ir::ModuleId; +use marqdo_runtime::{run, EvaluatedArg}; +use marqdo_sandbox::SandboxMode; + +fn repo_root() -> PathBuf { + Path::new(env!("CARGO_MANIFEST_DIR")) + .parent() + .expect("crates/cli has a parent") + .parent() + .expect("crates has a parent") + .to_path_buf() +} + +fn fixtures_in(dir: &Path) -> Vec { + let mut paths: Vec = fs::read_dir(dir) + .unwrap_or_else(|error| panic!("cannot read {}: {error}", dir.display())) + .filter_map(Result::ok) + .map(|entry| entry.path()) + .filter(|path| path.extension().is_some_and(|extension| extension == "md")) + .collect(); + paths.sort(); + paths +} + +fn expected_path(fixture: &Path) -> PathBuf { + let name = fixture + .file_name() + .expect("fixture has a file name") + .to_string_lossy(); + let stem = name + .strip_suffix(".mq.md") + .unwrap_or_else(|| panic!("fixture `{}` must end in .mq.md", fixture.display())); + fixture.with_file_name(format!("{stem}.expected.json")) +} + +fn read_expected(fixture: &Path) -> serde_json::Value { + let path = expected_path(fixture); + let text = fs::read_to_string(&path) + .unwrap_or_else(|error| panic!("missing expectation {}: {error}", path.display())); + serde_json::from_str(&text) + .unwrap_or_else(|error| panic!("invalid JSON in {}: {error}", path.display())) +} + +fn expected_codes(expected: &serde_json::Value, fixture: &Path) -> Vec { + expected + .get("codes") + .and_then(serde_json::Value::as_array) + .unwrap_or_else(|| panic!("{} has no `codes` array", expected_path(fixture).display())) + .iter() + .map(|code| { + code.as_str() + .unwrap_or_else(|| { + panic!("non-string code in {}", expected_path(fixture).display()) + }) + .to_string() + }) + .collect() +} + +/// Compile-time hard errors, exact sorted error-code multiset. +#[test] +fn compile_time_negative_goldens() { + let dir = repo_root().join("tests").join("negative"); + let fixtures = fixtures_in(&dir); + assert!( + fixtures.len() >= 30, + "the P0 corpus must keep at least 30 hard-error fixtures, found {}", + fixtures.len() + ); + + for fixture in &fixtures { + let source = fs::read_to_string(fixture) + .unwrap_or_else(|error| panic!("cannot read {}: {error}", fixture.display())); + let analysis = marqdo_frontend::analyze_source("index.mq.md", &source); + let mut actual: Vec = analysis + .diagnostics + .iter() + .filter(|diagnostic| diagnostic.is_error()) + .map(|diagnostic| diagnostic.code.clone()) + .collect(); + actual.sort(); + + let expected = expected_codes(&read_expected(fixture), fixture); + assert!( + !actual.is_empty(), + "negative fixture `{}` produced no error; invalid executable shapes must \ + never fall back to prose", + fixture.display() + ); + assert_eq!( + actual, + expected, + "error-code mismatch for `{}`\n expected: {expected:?}\n actual: {actual:?}", + fixture.display() + ); + // Code lists are contract data: every expected code must really be an + // error severity (never a warning or info diagnostic). + for diagnostic in &analysis.diagnostics { + if expected.contains(&diagnostic.code) { + assert_eq!( + diagnostic.severity, + marqdo_value::Severity::Error, + "code `{}` in `{}` is not an error", + diagnostic.code, + fixture.display() + ); + } + } + } +} + +/// Inert-executable warnings inside/outside functions. +#[test] +fn warning_goldens() { + let dir = repo_root().join("tests").join("negative").join("warnings"); + let fixtures = fixtures_in(&dir); + assert!(!fixtures.is_empty(), "warning corpus must not be empty"); + + for fixture in &fixtures { + let expected = read_expected(fixture); + assert_eq!( + expected.get("severity").and_then(serde_json::Value::as_str), + Some("warning"), + "{} must declare `\"severity\": \"warning\"`", + expected_path(fixture).display() + ); + let source = fs::read_to_string(fixture) + .unwrap_or_else(|error| panic!("cannot read {}: {error}", fixture.display())); + let analysis = marqdo_frontend::analyze_source("index.mq.md", &source); + assert!( + !analysis.has_errors(), + "warning fixture `{}` must compile without errors", + fixture.display() + ); + let mut actual: Vec = analysis + .diagnostics + .iter() + .map(|diagnostic| diagnostic.code.clone()) + .collect(); + actual.sort(); + let expected = expected_codes(&expected, fixture); + assert_eq!( + actual, + expected, + "warning-code mismatch for `{}`: expected {expected:?}, actual {actual:?}", + fixture.display() + ); + for diagnostic in &analysis.diagnostics { + assert!( + diagnostic.severity == marqdo_value::Severity::Warning, + "`{}` emitted non-warning diagnostic {}: {}", + fixture.display(), + diagnostic.code, + diagnostic.message + ); + } + } +} + +/// Runtime error codes for documents that compile but fail while executing. +#[test] +fn runtime_negative_goldens() { + let dir = repo_root().join("tests").join("negative").join("runtime"); + let fixtures = fixtures_in(&dir); + assert!( + !fixtures.is_empty(), + "runtime negative corpus must not be empty" + ); + + let project_root = std::env::temp_dir().join(format!( + "marqdo-conformance-negative-{}", + std::process::id() + )); + fs::create_dir_all(&project_root) + .unwrap_or_else(|error| panic!("cannot create {}: {error}", project_root.display())); + + for fixture in &fixtures { + let expected = read_expected(fixture); + let function = expected + .get("function") + .and_then(serde_json::Value::as_str) + .unwrap_or_else(|| panic!("{} has no `function`", expected_path(fixture).display())) + .to_string(); + let source = fs::read_to_string(fixture) + .unwrap_or_else(|error| panic!("cannot read {}: {error}", fixture.display())); + let module_id = ModuleId::from("index.mq.md"); + let analysis = marqdo_frontend::analyze_source(&module_id.0, &source); + assert!( + !analysis.has_errors(), + "runtime fixture `{}` must compile; diagnostics: {:?}", + fixture.display(), + analysis + .diagnostics + .iter() + .map(|diagnostic| (diagnostic.code.clone(), diagnostic.message.clone())) + .collect::>() + ); + + let mut program = marqdo_ir::Program::default(); + program.insert(analysis.module.clone()); + program.main_module = Some(module_id.clone()); + let mut host = StdHost::new( + SandboxMode::Project, + Capabilities::pure(), + project_root.clone(), + ); + if let Some(stack_limit) = expected + .get("stack_limit") + .and_then(serde_json::Value::as_u64) + { + host.budget.stack_limit = stack_limit as usize; + } + + let args_value = expected + .get("args") + .cloned() + .unwrap_or_else(|| serde_json::json!({})); + let args_object = args_value + .as_object() + .unwrap_or_else(|| panic!("`args` must be an object")); + let mut runtime_args = Vec::new(); + for (name, wire) in args_object { + let value = marqdo_value::from_wire(wire).unwrap_or_else(|error| { + panic!( + "invalid wire argument `{name}` in {}: {error}", + expected_path(fixture).display() + ) + }); + runtime_args.push(EvaluatedArg::named( + name.clone(), + value, + marqdo_span::Span::default(), + )); + } + + let expected_codes = expected_codes(&expected, fixture); + match run( + &program, + &mut host, + &module_id, + &function, + runtime_args, + ) { + Ok(outcome) => panic!( + "runtime fixture `{}` unexpectedly succeeded with {:?}; expected error {expected_codes:?}", + fixture.display(), + outcome.value + ), + Err(error) => { + let codes = vec![error.code().to_string()]; + assert_eq!( + codes, + expected_codes, + "runtime error-code mismatch for `{}`: expected {expected_codes:?}, actual {codes:?}", + fixture.display() + ); + } + } + } + let _ = fs::remove_dir_all(&project_root); +} diff --git a/crates/cli/tests/properties.rs b/crates/cli/tests/properties.rs new file mode 100644 index 0000000..30c13ba --- /dev/null +++ b/crates/cli/tests/properties.rs @@ -0,0 +1,412 @@ +//! Prose invariance property tests (blueprint section 14.2). +//! +//! For every base document the executable projection `ExecutableProjection(D)` +//! (the frontend IR) must be unchanged by pure narrative edits: +//! +//! * inserting a narration paragraph between top-level blocks/after headings, +//! * prepending/appending narration at the document boundaries, +//! * removing narration paragraphs that were already present. +//! +//! The comparison strips source spans (`span`, `heading_span`, `name_span`, +//! `condition_span`) because narration edits shift byte offsets. The test also +//! asserts that every variant still compiles without errors. The precondition +//! from the blueprint is respected: the transformations only touch `Text` +//! nodes and never add headings, lists, emphasis, links or code, so the +//! Markdown block structure — and therefore the executable structure — cannot +//! change. + +use std::collections::BTreeMap; + +/// A base program plus the narration fragments it contains. +struct Base { + name: &'static str, + source: &'static str, + /// Narration fragments safe to delete: removing them leaves the block + /// structure intact and only affects text payloads. + narration: &'static [&'static str], +} + +const BASES: &[Base] = &[ + Base { + name: "factorial", + source: r##"# 数学 + +## 阶乘 + +计算阶乘的叙述一。 + +1. `n <= 1` + + 递归终点叙述。 + + *1* + +2. `n > 1` + + 递归步骤叙述。 + + **结果 = n * 阶乘(n=n-1)** + + *结果* +"##, + narration: &["计算阶乘的叙述一。", "递归终点叙述。", "递归步骤叙述。"], + }, + Base { + name: "explicit-signature", + source: r##"## 圆面积 + +`(r: Number)` + +半径叙述。 + +*math.eval(ref("#公式"), {"r": r}, target="A")* + +### 公式 + +$$ +A = \pi r^2 +$$ +"##, + narration: &["半径叙述。"], + }, + Base { + name: "countdown-loop", + source: r##"## 倒计时 + +循环叙述。 + +**n = 3** + +- `n > 0` + + 循环体叙述。 + + > 打印(n) + + **n = n - 1** + +*n* +"##, + narration: &["循环叙述。", "循环体叙述。"], + }, + Base { + name: "branch-classification", + source: r##"## 分类 + +背景叙述。 + +**结果 = 0** + +1. `n < 0` + + 负数分支叙述。 + + **结果 = -1** + +2. `n >= 0` + + 非负分支叙述。 + + **结果 = 1** + +*结果* +"##, + narration: &["背景叙述。", "负数分支叙述。", "非负分支叙述。"], + }, + Base { + name: "call-and-print", + source: r##"## 问候 + +说明为什么这样写。 + +> 打印("你好") + +**问候 = "你好,Marqdo"** + +再补充一句叙述。 + +*问候* +"##, + narration: &["说明为什么这样写。", "再补充一句叙述。"], + }, + Base { + name: "inline-prose-in-executable-paragraph", + source: r##"## 加一 + +这是行内叙述 **结果 = 1 + 1** 后面继续叙述。 + +*结果* +"##, + narration: &["这是行内叙述 ", " 后面继续叙述。"], + }, + Base { + name: "nested-control-flow", + source: r##"## 嵌套 + +说明嵌套结构。 + +**total = 0** + +1. `n > 0` + + **m = 3** + + - `m > 0` + + **total = total + m** + + **m = m - 1** + +2. `n <= 0` + + **total = 0** + +*total* +"##, + narration: &["说明嵌套结构。"], + }, + Base { + name: "two-namespaces", + source: r##"# 数学 + +命名空间叙述。 + +## 平方 + +**结果 = n * n** + +*结果* + +# 文本 + +## 长度 + +*长度(s)* +"##, + narration: &["命名空间叙述。"], + }, +]; + +const INSERTED_PROSE: &str = "这是一段与执行结构无关的纯叙述文字,它只改变 Markdown 文本节点。"; + +fn repo_root() -> std::path::PathBuf { + std::path::Path::new(env!("CARGO_MANIFEST_DIR")) + .parent() + .expect("crates/cli has a parent") + .parent() + .expect("crates has a parent") + .to_path_buf() +} + +/// Strip source spans so narrative edits (which shift byte offsets) compare +/// equal. This mirrors the invariance definition in blueprint section 14.2. +fn without_spans(value: &serde_json::Value) -> serde_json::Value { + match value { + serde_json::Value::Object(map) => { + let mut out = serde_json::Map::new(); + for (key, value) in map { + if matches!( + key.as_str(), + "span" | "heading_span" | "name_span" | "condition_span" | "key_span" + ) { + continue; + } + out.insert(key.clone(), without_spans(value)); + } + serde_json::Value::Object(out) + } + serde_json::Value::Array(items) => { + serde_json::Value::Array(items.iter().map(without_spans).collect()) + } + other => other.clone(), + } +} + +/// Executable projection of one source: the function IR, span-free. +fn executable_projection(source: &str) -> serde_json::Value { + let analysis = marqdo_frontend::analyze_source("index.mq.md", source); + if analysis.has_errors() { + let diagnostics: Vec = analysis + .diagnostics + .iter() + .filter(|diagnostic| diagnostic.is_error()) + .map(|diagnostic| format!("{}: {}", diagnostic.code, diagnostic.message)) + .collect(); + panic!("prose-invariance variant must compile without errors: {diagnostics:?}"); + } + let json = serde_json::to_value(&analysis.module.functions) + .expect("function IR is always serializable"); + without_spans(&json) +} + +/// Whether a line is an ATX heading. +fn is_heading(line: &str) -> bool { + let mut chars = line.chars(); + if chars.next() != Some('#') { + return false; + } + let mut hashes = 1; + for ch in chars { + if ch == '#' { + hashes += 1; + if hashes > 6 { + return false; + } + } else { + return ch == ' '; + } + } + false +} + +/// Insert a narration paragraph after every heading. When the heading is +/// followed by an explicit signature paragraph, the narration goes *after* the +/// signature so the signature is still the first paragraph of the function. +fn insert_prose_after_headings(source: &str) -> String { + let lines: Vec<&str> = source.lines().collect(); + let mut out: Vec = Vec::new(); + let mut index = 0usize; + while index < lines.len() { + let line = lines[index]; + out.push(line.to_string()); + if is_heading(line) { + let mut next = index + 1; + while next < lines.len() && lines[next].trim().is_empty() { + next += 1; + } + let signature = next < lines.len() && lines[next].trim_start().starts_with("`("); + if signature { + while index + 1 < lines.len() && lines[index + 1].trim().is_empty() { + index += 1; + out.push(lines[index].to_string()); + } + index += 1; + out.push(lines[index].to_string()); + out.push(String::new()); + out.push(INSERTED_PROSE.to_string()); + } else { + out.push(String::new()); + out.push(INSERTED_PROSE.to_string()); + } + } + index += 1; + } + let mut text = out.join("\n"); + text.push('\n'); + text +} + +fn variants(base: &Base) -> BTreeMap { + let mut map = BTreeMap::new(); + map.insert( + "prepend-narration".to_string(), + format!("{INSERTED_PROSE}\n\n{}", base.source), + ); + map.insert( + "append-narration".to_string(), + format!("{}\n\n{INSERTED_PROSE}\n", base.source), + ); + map.insert( + "insert-after-headings".to_string(), + insert_prose_after_headings(base.source), + ); + // Remove each known narration fragment in turn. + for (position, fragment) in base.narration.iter().enumerate() { + map.insert( + format!("remove-narration-{position}"), + base.source.replace(fragment, ""), + ); + } + map +} + +#[test] +fn pure_prose_edits_do_not_change_executable_ir() { + // Keep the fixture root meaningful for the documented layout even though + // these tests are generated in code: assert the directory exists so a typo + // in the workspace layout is caught. + assert!(repo_root().join("tests").join("properties").is_dir()); + + let mut checked = 0usize; + for base in BASES { + let expected = executable_projection(base.source); + let generated = variants(base); + assert!( + generated.len() >= 4, + "base `{}` produced too few variants", + base.name + ); + for (variant, source) in generated { + let actual = executable_projection(&source); + assert_eq!( + actual, expected, + "prose edit `{variant}` changed the executable IR of base `{}`", + base.name + ); + checked += 1; + } + } + println!( + "prose invariance: checked {checked} variant(s) across {} base program(s)", + BASES.len() + ); +} + +/// Removing narration must also keep the program runnable: execute the +/// factorial base (and its narration-free form) with the same arguments and +/// compare values. This guards against prose accidentally becoming a +/// parameter or a statement. +#[test] +fn narration_removal_preserves_execution() { + use marqdo_host::{Capabilities, StdHost}; + use marqdo_ir::ModuleId; + use marqdo_runtime::{run, EvaluatedArg}; + use marqdo_sandbox::SandboxMode; + + let base = &BASES[0]; + let clean = base + .narration + .iter() + .fold(base.source.to_string(), |text, fragment| { + text.replace(fragment, "") + }); + let project_root = std::env::temp_dir().join(format!( + "marqdo-conformance-properties-{}", + std::process::id() + )); + std::fs::create_dir_all(&project_root).expect("scratch project root"); + let module_id = ModuleId::from("index.mq.md"); + + let mut values = Vec::new(); + for source in [base.source, clean.as_str()] { + let analysis = marqdo_frontend::analyze_source(&module_id.0, source); + assert!(!analysis.has_errors(), "{:?}", analysis.diagnostics); + let mut program = marqdo_ir::Program::default(); + program.insert(analysis.module.clone()); + program.main_module = Some(module_id.clone()); + let mut host = StdHost::new( + SandboxMode::Project, + Capabilities::pure(), + project_root.clone(), + ); + let outcome = run( + &program, + &mut host, + &module_id, + "阶乘", + vec![EvaluatedArg::named( + "n", + marqdo_value::Value::int(5), + marqdo_span::Span::default(), + )], + ) + .expect("factorial runs"); + values.push(outcome.value); + } + let _ = std::fs::remove_dir_all(&project_root); + assert_eq!( + values[0], values[1], + "removing narration changed execution result" + ); + assert_eq!(values[0], marqdo_value::Value::int(120)); +} diff --git a/crates/marqdo-frontend/src/analyze.rs b/crates/marqdo-frontend/src/analyze.rs index ffbd390..6c4073f 100644 --- a/crates/marqdo-frontend/src/analyze.rs +++ b/crates/marqdo-frontend/src/analyze.rs @@ -48,34 +48,34 @@ pub fn analyze_source(module_id: &str, source: &str) -> AnalysisResult { // Explicit front matter imports. Nothing is inferred. let mut imports: Vec = Vec::new(); if let Some(frontmatter) = document.frontmatter() { - if let Err(error) = &frontmatter.yaml { - diagnostics.push( + match &frontmatter.yaml { + Err(error) => diagnostics.push( Diagnostic::error( codes::FRONTMATTER_INVALID, Some(frontmatter.yaml_span), format!("invalid YAML front matter: {error}"), ) .with_hint("front matter must be valid YAML between `---` delimiters"), - ); - } - match frontmatter.imports() { - Ok(mapping) => { - for (alias, target) in mapping { - imports.push(ImportDecl { - alias, - target, - span: frontmatter.span, - }); - } - } - Err(error) => diagnostics.push( - Diagnostic::error( - codes::FRONTMATTER_INVALID, - Some(frontmatter.span), - format!("invalid import declaration: {error}"), - ) - .with_hint("imports are an explicit mapping: `import: { alias: \"@module\" }`"), ), + Ok(_) => match frontmatter.imports() { + Ok(mapping) => { + for (alias, target) in mapping { + imports.push(ImportDecl { + alias, + target, + span: frontmatter.span, + }); + } + } + Err(error) => diagnostics.push( + Diagnostic::error( + codes::FRONTMATTER_INVALID, + Some(frontmatter.span), + format!("invalid import declaration: {error}"), + ) + .with_hint("imports are an explicit mapping: `import: { alias: \"@module\" }`"), + ), + }, } } diff --git a/crates/marqdo-frontend/src/map.rs b/crates/marqdo-frontend/src/map.rs index 50d2fca..65d6354 100644 --- a/crates/marqdo-frontend/src/map.rs +++ b/crates/marqdo-frontend/src/map.rs @@ -475,7 +475,7 @@ impl<'a> Mapper<'a> { }) } else if url.starts_with("http://") || url.starts_with("https://") { self.error_with_hint( - codes::MATH_UNSUPPORTED, + codes::REF_UNRESOLVED, Some(span), "external links cannot be called", "link targets used as calls must resolve to a Marqdo function", diff --git a/crates/marqdo-host/src/budget.rs b/crates/marqdo-host/src/budget.rs index 2bbb2c2..106ac75 100644 --- a/crates/marqdo-host/src/budget.rs +++ b/crates/marqdo-host/src/budget.rs @@ -8,7 +8,11 @@ use marqdo_value::{ErrorCategory, RuntimeError}; /// Default evaluation fuel for one run. pub const DEFAULT_FUEL: u64 = 5_000_000; /// Default call-stack depth. -pub const DEFAULT_STACK_LIMIT: usize = 256; +/// +/// Kept conservative so that the cooperative budget triggers a structured +/// `resource.exhausted` error before a debug-build native Rust stack can +/// overflow; the CLI exposes `--stack` for callers that need deeper recursion. +pub const DEFAULT_STACK_LIMIT: usize = 128; /// Default program output limit (bytes). pub const DEFAULT_OUTPUT_BYTES: usize = 1 << 20; diff --git a/spec/mapping.md b/spec/mapping.md index 843c2bb..2acf792 100644 --- a/spec/mapping.md +++ b/spec/mapping.md @@ -161,7 +161,9 @@ The call result is discarded by the statement form; use `strong` to bind it * `*表达式*` used in a branch is a return from the whole function. * A function that ends without a return evaluates to `Unit`. `None` is an explicit empty value and is distinct from `Unit`. -* Return at module top level (outside any function) is an error. +* An `emph` node outside any function body is inert document content and emits + a `markdown.inert_executable` warning (ADR-0002); it is not executed and is + not a hard error. Inside a function body, every `emph` is a return. ## 6. Function signatures and parameter inference @@ -238,5 +240,7 @@ The following are compile errors with source spans, never prose fallbacks: * block quote that is not exactly one complete call; * duplicate function names in a scope; * empty heading names; -* return outside a function; +* `emph`/`strong`/control structures outside any function body are inert and + produce a `markdown.inert_executable` warning (see §4); they never return + from or execute anything at module level; * executable node inside a lazy region being interpreted (must not happen). diff --git a/tests/README.md b/tests/README.md new file mode 100644 index 0000000..0316df4 --- /dev/null +++ b/tests/README.md @@ -0,0 +1,167 @@ +# Marqdo conformance and integration test corpus + +This directory holds the P0/P1 conformance corpus required by +`docs/DEVELOPMENT_BLUEPRINT.md` §13/§14. The Rust harnesses live in +`crates/cli/tests/` (they use the workspace libraries directly and the +`marqdo` binary via `CARGO_BIN_EXE_marqdo`); the fixtures are plain files here +so they can be rendered, diffed and reviewed like Markdown documents. + +Everything here is data. Nothing in this directory modifies the repository, and +no test commits, copies or rewrites files outside a throw-away temp directory. + +## Layout + +```text +tests/ +├── conformance/ +│ ├── ast/ 150 × *.mq.md + sibling *.ast.json goldens +│ └── semantics/ 36 × *.mq.md + sibling *.expected.json goldens +├── negative/ +│ ├── *.mq.md 48 × compile-time hard-error fixtures + *.expected.json +│ ├── warnings/ 6 × inert-executable warning fixtures + *.expected.json +│ └── runtime/ 10 × runtime-error fixtures + *.expected.json +└── README.md this file +``` + +Rust harnesses (all in `crates/cli/tests/`): + +| Harness | What it proves | +|---|---| +| `conformance_ast.rs` | The frozen `marqdo.md.v1` profile parses each fixture into exactly the checked-in AST (node kinds, attributes, literals, byte spans, order). | +| `conformance_semantics.rs` | Each semantic fixture compiles through `marqdo_frontend`, is assembled into `marqdo_ir::Program` and executed with `marqdo_runtime` + `marqdo_host::StdHost`; returned wire value and program stdout match. | +| `negative.rs` | Invalid executable shapes are **hard errors** (never prose fallbacks), exact sorted diagnostic-code lists; warnings and runtime error codes are asserted in their own suites. | +| `properties.rs` | Blueprint §14.2 prose invariance: inserting/removing pure narration paragraphs never changes the executable function IR (modulo source spans) and diagnostics stay error-free. | +| `integration_cli.rs` | Real CLI contract: `init`, `check`, `run`, `call`, `inspect`, `fmt`, multi-module imports/cycles, `lock`/`sync --locked`, plugin inspection and explicitly trusted plugin invocation. | + +## Running + +Use the workspace cargo cache/target as documented in `AGENTS.md`: + +```bash +export PATH=/root/.cargo/bin:$PATH +export CARGO_HOME=/root/work/marqdo-cli/.cache/cargo +export CARGO_TARGET_DIR=/root/work/marqdo-cli/.cache/target + +cargo test -p marqdo-cli # all conformance + integration harnesses +cargo test --workspace # whole workspace (includes crate unit tests) +``` + +Individual harnesses: + +```bash +cargo test -p marqdo-cli --test conformance_ast +cargo test -p marqdo-cli --test conformance_semantics +cargo test -p marqdo-cli --test negative +cargo test -p marqdo-cli --test properties +cargo test -p marqdo-cli --test integration_cli +``` + +Fixture discovery is directory-based and sorted by file name, so the order is +deterministic on every platform. The AST and semantic suites fail loudly if the +corpus shrinks below 100 / 25 fixtures, and the negative suite fails below 30 +compile-time hard-error fixtures. + +## AST goldens and `UPDATE_GOLDENS` + +`*.ast.json` files are the pretty-printed canonical AST view +(`marqdo_markdown::parse(source).root`), exactly as `marqdo inspect --ast --json` +would print it. They pin parser version, extension flags and span arithmetic. + +Regenerate **only** for an intentional, ADR-backed profile change (the profile +is frozen in `spec/markdown-profile.md`): + +```bash +UPDATE_GOLDENS=1 cargo test -p marqdo-cli --test conformance_ast +``` + +The update run rewrites every golden, prints how many it rewrote and **passes**. +Re-run without the variable to verify, and review the golden diff: a golden +change is a language change, not a bug fix. + +A fixture without a golden is an error, and a golden without a fixture is an +error (stale corpus output), so add/remove both together. + +## Semantic goldens + +Each `*.expected.json` has the shape: + +```json +{ + "function": "", + "args": { "": }, + "value": , + "stdout": "..." +} +``` + +* `args` and `value` use the typed wire encoding from `marqdo_value::to_wire` + (`{"type":"int","decimal":"42"}`, `{"type":"text","value":"…"}`, …). +* `stdout` is the program output captured from the host (never diagnostics). +* Optional `"grants": ["foreign"]` enables `foreign.call`; that fixture is + skipped with a printed notice when `python3` is unavailable. + +All values were produced by running the implementation and then checked by +hand against the fixture source. `UPDATE_SEMANTICS_GOLDENS=1` exists for +authoring convenience, but it must not be used blindly: rewriting a semantic +golden without verifying the value would defeat the purpose of the corpus. + +## Negative fixtures + +Compile-time (`tests/negative/*.mq.md`): + +```json +{"codes": ["markdown.invalid_construct"]} +``` + +The expected list is the exact sorted multiset of **error** diagnostic codes +produced by `marqdo_frontend::analyze_source`. Warnings emitted by the same +document are ignored here. Every listed code is additionally asserted to have +`error` severity, and every fixture must produce at least one error — invalid +executable shapes never fall back to prose. + +Warnings (`tests/negative/warnings/*.mq.md`): + +```json +{"severity": "warning", "codes": ["markdown.inert_executable"]} +``` + +These documents must compile **without errors**; the sorted multiset of warning +codes must match exactly. `return`/`strong`/lists/block quotes outside a +function body are inert content (warning), not hard errors. + +Runtime (`tests/negative/runtime/*.mq.md`): + +```json +{"function": "main", "args": {}, "codes": ["runtime.division_by_zero"]} +``` + +These documents compile, then must fail at runtime with the expected stable +error code. Optional keys: `"grants": ["foreign"]` and `"stack_limit": 24` +(used for the recursion-depth fixture so the budget — not the host process +stack — is what fails). + +## CLI integration notes + +`integration_cli.rs` never leaves the repository dirty: + +* temporary projects are created under `std::env::temp_dir()` and removed on + drop; +* the demo C plugin is built **in a temp copy** of `examples/plugin-demo` + (`cc -shared -fPIC -I /include`), and the `sha256` in the copied + `plugin.yaml` is refreshed there. The repo copy and its `.so` (gitignored) are + never touched; +* tests that need `python3` or `cc` print a skip notice and return when the tool + is unavailable. + +## Notes discovered while authoring (all since fixed) + +The fixtures initially pinned three observations that were reported and then +fixed in the implementation; the goldens below reflect the fixed behaviour: + +* wire floats round-trip exactly (`serde_json/float_roundtrip` is enabled), so + Python `math.pi * 9` keeps `28.274333882308138`; +* the default interpreter stack budget is 128 frames so a deeply recursive + document returns a structured `resource.exhausted` instead of exhausting the + native debug-build stack (`--stack` can raise it deliberately); +* an external-link call form (`> [x](https://example.com)()`) is rejected with + `ref.unresolved`, the same code used for other unresolvable call targets. diff --git a/tests/conformance/ast/001-atx-h1.ast.json b/tests/conformance/ast/001-atx-h1.ast.json new file mode 100644 index 0000000..33d4e46 --- /dev/null +++ b/tests/conformance/ast/001-atx-h1.ast.json @@ -0,0 +1,28 @@ +{ + "kind": "document", + "span": { + "start": 0, + "end": 14 + }, + "children": [ + { + "kind": "heading", + "level": 1, + "setext": false, + "span": { + "start": 0, + "end": 14 + }, + "children": [ + { + "kind": "text", + "span": { + "start": 2, + "end": 14 + }, + "literal": "一级标题" + } + ] + } + ] +} diff --git a/tests/conformance/ast/001-atx-h1.mq.md b/tests/conformance/ast/001-atx-h1.mq.md new file mode 100644 index 0000000..897f7ee --- /dev/null +++ b/tests/conformance/ast/001-atx-h1.mq.md @@ -0,0 +1 @@ +# 一级标题 diff --git a/tests/conformance/ast/002-atx-h2.ast.json b/tests/conformance/ast/002-atx-h2.ast.json new file mode 100644 index 0000000..8c46914 --- /dev/null +++ b/tests/conformance/ast/002-atx-h2.ast.json @@ -0,0 +1,28 @@ +{ + "kind": "document", + "span": { + "start": 0, + "end": 15 + }, + "children": [ + { + "kind": "heading", + "level": 2, + "setext": false, + "span": { + "start": 0, + "end": 15 + }, + "children": [ + { + "kind": "text", + "span": { + "start": 3, + "end": 15 + }, + "literal": "二级标题" + } + ] + } + ] +} diff --git a/tests/conformance/ast/002-atx-h2.mq.md b/tests/conformance/ast/002-atx-h2.mq.md new file mode 100644 index 0000000..77be76e --- /dev/null +++ b/tests/conformance/ast/002-atx-h2.mq.md @@ -0,0 +1 @@ +## 二级标题 diff --git a/tests/conformance/ast/003-atx-h3.ast.json b/tests/conformance/ast/003-atx-h3.ast.json new file mode 100644 index 0000000..543d0e0 --- /dev/null +++ b/tests/conformance/ast/003-atx-h3.ast.json @@ -0,0 +1,28 @@ +{ + "kind": "document", + "span": { + "start": 0, + "end": 16 + }, + "children": [ + { + "kind": "heading", + "level": 3, + "setext": false, + "span": { + "start": 0, + "end": 16 + }, + "children": [ + { + "kind": "text", + "span": { + "start": 4, + "end": 16 + }, + "literal": "三级标题" + } + ] + } + ] +} diff --git a/tests/conformance/ast/003-atx-h3.mq.md b/tests/conformance/ast/003-atx-h3.mq.md new file mode 100644 index 0000000..a3425f5 --- /dev/null +++ b/tests/conformance/ast/003-atx-h3.mq.md @@ -0,0 +1 @@ +### 三级标题 diff --git a/tests/conformance/ast/004-atx-h4.ast.json b/tests/conformance/ast/004-atx-h4.ast.json new file mode 100644 index 0000000..f5e1a15 --- /dev/null +++ b/tests/conformance/ast/004-atx-h4.ast.json @@ -0,0 +1,28 @@ +{ + "kind": "document", + "span": { + "start": 0, + "end": 17 + }, + "children": [ + { + "kind": "heading", + "level": 4, + "setext": false, + "span": { + "start": 0, + "end": 17 + }, + "children": [ + { + "kind": "text", + "span": { + "start": 5, + "end": 17 + }, + "literal": "四级标题" + } + ] + } + ] +} diff --git a/tests/conformance/ast/004-atx-h4.mq.md b/tests/conformance/ast/004-atx-h4.mq.md new file mode 100644 index 0000000..5a8ac31 --- /dev/null +++ b/tests/conformance/ast/004-atx-h4.mq.md @@ -0,0 +1 @@ +#### 四级标题 diff --git a/tests/conformance/ast/005-atx-h5.ast.json b/tests/conformance/ast/005-atx-h5.ast.json new file mode 100644 index 0000000..4c317a8 --- /dev/null +++ b/tests/conformance/ast/005-atx-h5.ast.json @@ -0,0 +1,28 @@ +{ + "kind": "document", + "span": { + "start": 0, + "end": 18 + }, + "children": [ + { + "kind": "heading", + "level": 5, + "setext": false, + "span": { + "start": 0, + "end": 18 + }, + "children": [ + { + "kind": "text", + "span": { + "start": 6, + "end": 18 + }, + "literal": "五级标题" + } + ] + } + ] +} diff --git a/tests/conformance/ast/005-atx-h5.mq.md b/tests/conformance/ast/005-atx-h5.mq.md new file mode 100644 index 0000000..5884bbe --- /dev/null +++ b/tests/conformance/ast/005-atx-h5.mq.md @@ -0,0 +1 @@ +##### 五级标题 diff --git a/tests/conformance/ast/006-atx-h6.ast.json b/tests/conformance/ast/006-atx-h6.ast.json new file mode 100644 index 0000000..76b3726 --- /dev/null +++ b/tests/conformance/ast/006-atx-h6.ast.json @@ -0,0 +1,28 @@ +{ + "kind": "document", + "span": { + "start": 0, + "end": 19 + }, + "children": [ + { + "kind": "heading", + "level": 6, + "setext": false, + "span": { + "start": 0, + "end": 19 + }, + "children": [ + { + "kind": "text", + "span": { + "start": 7, + "end": 19 + }, + "literal": "六级标题" + } + ] + } + ] +} diff --git a/tests/conformance/ast/006-atx-h6.mq.md b/tests/conformance/ast/006-atx-h6.mq.md new file mode 100644 index 0000000..ebccaf4 --- /dev/null +++ b/tests/conformance/ast/006-atx-h6.mq.md @@ -0,0 +1 @@ +###### 六级标题 diff --git a/tests/conformance/ast/007-atx-closing-hashes.ast.json b/tests/conformance/ast/007-atx-closing-hashes.ast.json new file mode 100644 index 0000000..28e0494 --- /dev/null +++ b/tests/conformance/ast/007-atx-closing-hashes.ast.json @@ -0,0 +1,28 @@ +{ + "kind": "document", + "span": { + "start": 0, + "end": 12 + }, + "children": [ + { + "kind": "heading", + "level": 2, + "setext": false, + "span": { + "start": 0, + "end": 12 + }, + "children": [ + { + "kind": "text", + "span": { + "start": 3, + "end": 9 + }, + "literal": "函数" + } + ] + } + ] +} diff --git a/tests/conformance/ast/007-atx-closing-hashes.mq.md b/tests/conformance/ast/007-atx-closing-hashes.mq.md new file mode 100644 index 0000000..4dbbae5 --- /dev/null +++ b/tests/conformance/ast/007-atx-closing-hashes.mq.md @@ -0,0 +1 @@ +## 函数 ## diff --git a/tests/conformance/ast/008-setext-level1.ast.json b/tests/conformance/ast/008-setext-level1.ast.json new file mode 100644 index 0000000..aa8e075 --- /dev/null +++ b/tests/conformance/ast/008-setext-level1.ast.json @@ -0,0 +1,28 @@ +{ + "kind": "document", + "span": { + "start": 0, + "end": 21 + }, + "children": [ + { + "kind": "heading", + "level": 1, + "setext": true, + "span": { + "start": 0, + "end": 21 + }, + "children": [ + { + "kind": "text", + "span": { + "start": 0, + "end": 12 + }, + "literal": "一级标题" + } + ] + } + ] +} diff --git a/tests/conformance/ast/008-setext-level1.mq.md b/tests/conformance/ast/008-setext-level1.mq.md new file mode 100644 index 0000000..67fe590 --- /dev/null +++ b/tests/conformance/ast/008-setext-level1.mq.md @@ -0,0 +1,2 @@ +一级标题 +======== diff --git a/tests/conformance/ast/009-setext-level2.ast.json b/tests/conformance/ast/009-setext-level2.ast.json new file mode 100644 index 0000000..cf823d9 --- /dev/null +++ b/tests/conformance/ast/009-setext-level2.ast.json @@ -0,0 +1,28 @@ +{ + "kind": "document", + "span": { + "start": 0, + "end": 21 + }, + "children": [ + { + "kind": "heading", + "level": 2, + "setext": true, + "span": { + "start": 0, + "end": 21 + }, + "children": [ + { + "kind": "text", + "span": { + "start": 0, + "end": 12 + }, + "literal": "函数标题" + } + ] + } + ] +} diff --git a/tests/conformance/ast/009-setext-level2.mq.md b/tests/conformance/ast/009-setext-level2.mq.md new file mode 100644 index 0000000..b5c4e86 --- /dev/null +++ b/tests/conformance/ast/009-setext-level2.mq.md @@ -0,0 +1,2 @@ +函数标题 +-------- diff --git a/tests/conformance/ast/010-unicode-chinese-heading.ast.json b/tests/conformance/ast/010-unicode-chinese-heading.ast.json new file mode 100644 index 0000000..225e460 --- /dev/null +++ b/tests/conformance/ast/010-unicode-chinese-heading.ast.json @@ -0,0 +1,47 @@ +{ + "kind": "document", + "span": { + "start": 0, + "end": 25 + }, + "children": [ + { + "kind": "heading", + "level": 1, + "setext": false, + "span": { + "start": 0, + "end": 8 + }, + "children": [ + { + "kind": "text", + "span": { + "start": 2, + "end": 8 + }, + "literal": "数学" + } + ] + }, + { + "kind": "heading", + "level": 2, + "setext": false, + "span": { + "start": 10, + "end": 25 + }, + "children": [ + { + "kind": "text", + "span": { + "start": 13, + "end": 25 + }, + "literal": "阶乘计算" + } + ] + } + ] +} diff --git a/tests/conformance/ast/010-unicode-chinese-heading.mq.md b/tests/conformance/ast/010-unicode-chinese-heading.mq.md new file mode 100644 index 0000000..721be5f --- /dev/null +++ b/tests/conformance/ast/010-unicode-chinese-heading.mq.md @@ -0,0 +1,3 @@ +# 数学 + +## 阶乘计算 diff --git a/tests/conformance/ast/011-heading-cjk-emoji.ast.json b/tests/conformance/ast/011-heading-cjk-emoji.ast.json new file mode 100644 index 0000000..10cbda2 --- /dev/null +++ b/tests/conformance/ast/011-heading-cjk-emoji.ast.json @@ -0,0 +1,28 @@ +{ + "kind": "document", + "span": { + "start": 0, + "end": 20 + }, + "children": [ + { + "kind": "heading", + "level": 1, + "setext": false, + "span": { + "start": 0, + "end": 20 + }, + "children": [ + { + "kind": "text", + "span": { + "start": 2, + "end": 20 + }, + "literal": "统计 📊 报告" + } + ] + } + ] +} diff --git a/tests/conformance/ast/011-heading-cjk-emoji.mq.md b/tests/conformance/ast/011-heading-cjk-emoji.mq.md new file mode 100644 index 0000000..b29207f --- /dev/null +++ b/tests/conformance/ast/011-heading-cjk-emoji.mq.md @@ -0,0 +1 @@ +# 统计 📊 报告 diff --git a/tests/conformance/ast/012-heading-empty.ast.json b/tests/conformance/ast/012-heading-empty.ast.json new file mode 100644 index 0000000..ac66ddd --- /dev/null +++ b/tests/conformance/ast/012-heading-empty.ast.json @@ -0,0 +1,35 @@ +{ + "kind": "document", + "span": { + "start": 0, + "end": 13 + }, + "children": [ + { + "kind": "heading", + "level": 2, + "setext": false, + "span": { + "start": 0, + "end": 5 + } + }, + { + "kind": "paragraph", + "span": { + "start": 7, + "end": 13 + }, + "children": [ + { + "kind": "text", + "span": { + "start": 7, + "end": 13 + }, + "literal": "正文" + } + ] + } + ] +} diff --git a/tests/conformance/ast/012-heading-empty.mq.md b/tests/conformance/ast/012-heading-empty.mq.md new file mode 100644 index 0000000..4c21ee3 --- /dev/null +++ b/tests/conformance/ast/012-heading-empty.mq.md @@ -0,0 +1,3 @@ +## + +正文 diff --git a/tests/conformance/ast/013-heading-inline-markup.ast.json b/tests/conformance/ast/013-heading-inline-markup.ast.json new file mode 100644 index 0000000..3b23e5f --- /dev/null +++ b/tests/conformance/ast/013-heading-inline-markup.ast.json @@ -0,0 +1,70 @@ +{ + "kind": "document", + "span": { + "start": 0, + "end": 33 + }, + "children": [ + { + "kind": "heading", + "level": 2, + "setext": false, + "span": { + "start": 0, + "end": 33 + }, + "children": [ + { + "kind": "strong", + "span": { + "start": 3, + "end": 13 + }, + "children": [ + { + "kind": "text", + "span": { + "start": 5, + "end": 11 + }, + "literal": "加粗" + } + ] + }, + { + "kind": "text", + "span": { + "start": 13, + "end": 18 + }, + "literal": " 与 " + }, + { + "kind": "emph", + "span": { + "start": 18, + "end": 26 + }, + "children": [ + { + "kind": "text", + "span": { + "start": 19, + "end": 25 + }, + "literal": "斜体" + } + ] + }, + { + "kind": "text", + "span": { + "start": 26, + "end": 33 + }, + "literal": " 标题" + } + ] + } + ] +} diff --git a/tests/conformance/ast/013-heading-inline-markup.mq.md b/tests/conformance/ast/013-heading-inline-markup.mq.md new file mode 100644 index 0000000..af36b41 --- /dev/null +++ b/tests/conformance/ast/013-heading-inline-markup.mq.md @@ -0,0 +1 @@ +## **加粗** 与 *斜体* 标题 diff --git a/tests/conformance/ast/014-heading-in-blockquote.ast.json b/tests/conformance/ast/014-heading-in-blockquote.ast.json new file mode 100644 index 0000000..46122f2 --- /dev/null +++ b/tests/conformance/ast/014-heading-in-blockquote.ast.json @@ -0,0 +1,37 @@ +{ + "kind": "document", + "span": { + "start": 0, + "end": 22 + }, + "children": [ + { + "kind": "block_quote", + "span": { + "start": 0, + "end": 22 + }, + "children": [ + { + "kind": "heading", + "level": 1, + "setext": false, + "span": { + "start": 2, + "end": 22 + }, + "children": [ + { + "kind": "text", + "span": { + "start": 4, + "end": 22 + }, + "literal": "引用中的标题" + } + ] + } + ] + } + ] +} diff --git a/tests/conformance/ast/014-heading-in-blockquote.mq.md b/tests/conformance/ast/014-heading-in-blockquote.mq.md new file mode 100644 index 0000000..837706b --- /dev/null +++ b/tests/conformance/ast/014-heading-in-blockquote.mq.md @@ -0,0 +1 @@ +> # 引用中的标题 diff --git a/tests/conformance/ast/015-heading-in-list-item.ast.json b/tests/conformance/ast/015-heading-in-list-item.ast.json new file mode 100644 index 0000000..ed139f9 --- /dev/null +++ b/tests/conformance/ast/015-heading-in-list-item.ast.json @@ -0,0 +1,48 @@ +{ + "kind": "document", + "span": { + "start": 0, + "end": 23 + }, + "children": [ + { + "kind": "list", + "ordered": false, + "tight": true, + "span": { + "start": 0, + "end": 23 + }, + "children": [ + { + "kind": "item", + "span": { + "start": 0, + "end": 23 + }, + "children": [ + { + "kind": "heading", + "level": 2, + "setext": false, + "span": { + "start": 2, + "end": 23 + }, + "children": [ + { + "kind": "text", + "span": { + "start": 5, + "end": 23 + }, + "literal": "列表中的标题" + } + ] + } + ] + } + ] + } + ] +} diff --git a/tests/conformance/ast/015-heading-in-list-item.mq.md b/tests/conformance/ast/015-heading-in-list-item.mq.md new file mode 100644 index 0000000..aa3d7f7 --- /dev/null +++ b/tests/conformance/ast/015-heading-in-list-item.mq.md @@ -0,0 +1 @@ +- ## 列表中的标题 diff --git a/tests/conformance/ast/016-heading-in-fenced-code.ast.json b/tests/conformance/ast/016-heading-in-fenced-code.ast.json new file mode 100644 index 0000000..401b099 --- /dev/null +++ b/tests/conformance/ast/016-heading-in-fenced-code.ast.json @@ -0,0 +1,19 @@ +{ + "kind": "document", + "span": { + "start": 0, + "end": 30 + }, + "children": [ + { + "kind": "code_block", + "fenced": true, + "info": "markdown", + "span": { + "start": 0, + "end": 30 + }, + "literal": "# 不是标题\n" + } + ] +} diff --git a/tests/conformance/ast/016-heading-in-fenced-code.mq.md b/tests/conformance/ast/016-heading-in-fenced-code.mq.md new file mode 100644 index 0000000..e5e0b7d --- /dev/null +++ b/tests/conformance/ast/016-heading-in-fenced-code.mq.md @@ -0,0 +1,3 @@ +```markdown +# 不是标题 +``` diff --git a/tests/conformance/ast/017-heading-whitespace-normalised.ast.json b/tests/conformance/ast/017-heading-whitespace-normalised.ast.json new file mode 100644 index 0000000..65802c0 --- /dev/null +++ b/tests/conformance/ast/017-heading-whitespace-normalised.ast.json @@ -0,0 +1,28 @@ +{ + "kind": "document", + "span": { + "start": 0, + "end": 23 + }, + "children": [ + { + "kind": "heading", + "level": 2, + "setext": false, + "span": { + "start": 0, + "end": 23 + }, + "children": [ + { + "kind": "text", + "span": { + "start": 5, + "end": 21 + }, + "literal": "多个 空格" + } + ] + } + ] +} diff --git a/tests/conformance/ast/017-heading-whitespace-normalised.mq.md b/tests/conformance/ast/017-heading-whitespace-normalised.mq.md new file mode 100644 index 0000000..5fedf6a --- /dev/null +++ b/tests/conformance/ast/017-heading-whitespace-normalised.mq.md @@ -0,0 +1 @@ +## 多个 空格 diff --git a/tests/conformance/ast/018-heading-level-jump.ast.json b/tests/conformance/ast/018-heading-level-jump.ast.json new file mode 100644 index 0000000..94fd3a6 --- /dev/null +++ b/tests/conformance/ast/018-heading-level-jump.ast.json @@ -0,0 +1,66 @@ +{ + "kind": "document", + "span": { + "start": 0, + "end": 49 + }, + "children": [ + { + "kind": "heading", + "level": 1, + "setext": false, + "span": { + "start": 0, + "end": 14 + }, + "children": [ + { + "kind": "text", + "span": { + "start": 2, + "end": 14 + }, + "literal": "命名空间" + } + ] + }, + { + "kind": "heading", + "level": 3, + "setext": false, + "span": { + "start": 16, + "end": 38 + }, + "children": [ + { + "kind": "text", + "span": { + "start": 20, + "end": 38 + }, + "literal": "直接跳到三级" + } + ] + }, + { + "kind": "heading", + "level": 2, + "setext": false, + "span": { + "start": 40, + "end": 49 + }, + "children": [ + { + "kind": "text", + "span": { + "start": 43, + "end": 49 + }, + "literal": "函数" + } + ] + } + ] +} diff --git a/tests/conformance/ast/018-heading-level-jump.mq.md b/tests/conformance/ast/018-heading-level-jump.mq.md new file mode 100644 index 0000000..71c60b3 --- /dev/null +++ b/tests/conformance/ast/018-heading-level-jump.mq.md @@ -0,0 +1,5 @@ +# 命名空间 + +### 直接跳到三级 + +## 函数 diff --git a/tests/conformance/ast/019-paragraph-single.ast.json b/tests/conformance/ast/019-paragraph-single.ast.json new file mode 100644 index 0000000..332d618 --- /dev/null +++ b/tests/conformance/ast/019-paragraph-single.ast.json @@ -0,0 +1,26 @@ +{ + "kind": "document", + "span": { + "start": 0, + "end": 30 + }, + "children": [ + { + "kind": "paragraph", + "span": { + "start": 0, + "end": 30 + }, + "children": [ + { + "kind": "text", + "span": { + "start": 0, + "end": 30 + }, + "literal": "一段普通的中文叙述。" + } + ] + } + ] +} diff --git a/tests/conformance/ast/019-paragraph-single.mq.md b/tests/conformance/ast/019-paragraph-single.mq.md new file mode 100644 index 0000000..3d831a4 --- /dev/null +++ b/tests/conformance/ast/019-paragraph-single.mq.md @@ -0,0 +1 @@ +一段普通的中文叙述。 diff --git a/tests/conformance/ast/020-paragraph-multiline-softbreak.ast.json b/tests/conformance/ast/020-paragraph-multiline-softbreak.ast.json new file mode 100644 index 0000000..bb1f07f --- /dev/null +++ b/tests/conformance/ast/020-paragraph-multiline-softbreak.ast.json @@ -0,0 +1,56 @@ +{ + "kind": "document", + "span": { + "start": 0, + "end": 47 + }, + "children": [ + { + "kind": "paragraph", + "span": { + "start": 0, + "end": 47 + }, + "children": [ + { + "kind": "text", + "span": { + "start": 0, + "end": 15 + }, + "literal": "第一行叙述" + }, + { + "kind": "soft_break", + "span": { + "start": 15, + "end": 16 + } + }, + { + "kind": "text", + "span": { + "start": 16, + "end": 31 + }, + "literal": "第二行叙述" + }, + { + "kind": "soft_break", + "span": { + "start": 31, + "end": 32 + } + }, + { + "kind": "text", + "span": { + "start": 32, + "end": 47 + }, + "literal": "第三行叙述" + } + ] + } + ] +} diff --git a/tests/conformance/ast/020-paragraph-multiline-softbreak.mq.md b/tests/conformance/ast/020-paragraph-multiline-softbreak.mq.md new file mode 100644 index 0000000..cd67286 --- /dev/null +++ b/tests/conformance/ast/020-paragraph-multiline-softbreak.mq.md @@ -0,0 +1,3 @@ +第一行叙述 +第二行叙述 +第三行叙述 diff --git a/tests/conformance/ast/021-hard-break-two-spaces.ast.json b/tests/conformance/ast/021-hard-break-two-spaces.ast.json new file mode 100644 index 0000000..0a18025 --- /dev/null +++ b/tests/conformance/ast/021-hard-break-two-spaces.ast.json @@ -0,0 +1,41 @@ +{ + "kind": "document", + "span": { + "start": 0, + "end": 21 + }, + "children": [ + { + "kind": "paragraph", + "span": { + "start": 0, + "end": 21 + }, + "children": [ + { + "kind": "text", + "span": { + "start": 0, + "end": 9 + }, + "literal": "第一行" + }, + { + "kind": "line_break", + "span": { + "start": 9, + "end": 12 + } + }, + { + "kind": "text", + "span": { + "start": 12, + "end": 21 + }, + "literal": "第二行" + } + ] + } + ] +} diff --git a/tests/conformance/ast/021-hard-break-two-spaces.mq.md b/tests/conformance/ast/021-hard-break-two-spaces.mq.md new file mode 100644 index 0000000..368496d --- /dev/null +++ b/tests/conformance/ast/021-hard-break-two-spaces.mq.md @@ -0,0 +1,2 @@ +第一行 +第二行 diff --git a/tests/conformance/ast/022-hard-break-backslash.ast.json b/tests/conformance/ast/022-hard-break-backslash.ast.json new file mode 100644 index 0000000..908ebf2 --- /dev/null +++ b/tests/conformance/ast/022-hard-break-backslash.ast.json @@ -0,0 +1,41 @@ +{ + "kind": "document", + "span": { + "start": 0, + "end": 20 + }, + "children": [ + { + "kind": "paragraph", + "span": { + "start": 0, + "end": 20 + }, + "children": [ + { + "kind": "text", + "span": { + "start": 0, + "end": 9 + }, + "literal": "第一行" + }, + { + "kind": "line_break", + "span": { + "start": 9, + "end": 11 + } + }, + { + "kind": "text", + "span": { + "start": 11, + "end": 20 + }, + "literal": "第二行" + } + ] + } + ] +} diff --git a/tests/conformance/ast/022-hard-break-backslash.mq.md b/tests/conformance/ast/022-hard-break-backslash.mq.md new file mode 100644 index 0000000..84ae7c4 --- /dev/null +++ b/tests/conformance/ast/022-hard-break-backslash.mq.md @@ -0,0 +1,2 @@ +第一行\ +第二行 diff --git a/tests/conformance/ast/023-empty-document.ast.json b/tests/conformance/ast/023-empty-document.ast.json new file mode 100644 index 0000000..af147a4 --- /dev/null +++ b/tests/conformance/ast/023-empty-document.ast.json @@ -0,0 +1,7 @@ +{ + "kind": "document", + "span": { + "start": 0, + "end": 0 + } +} diff --git a/tests/conformance/ast/023-empty-document.mq.md b/tests/conformance/ast/023-empty-document.mq.md new file mode 100644 index 0000000..e69de29 diff --git a/tests/conformance/ast/024-whitespace-only-document.ast.json b/tests/conformance/ast/024-whitespace-only-document.ast.json new file mode 100644 index 0000000..3787d38 --- /dev/null +++ b/tests/conformance/ast/024-whitespace-only-document.ast.json @@ -0,0 +1,7 @@ +{ + "kind": "document", + "span": { + "start": 0, + "end": 5 + } +} diff --git a/tests/conformance/ast/024-whitespace-only-document.mq.md b/tests/conformance/ast/024-whitespace-only-document.mq.md new file mode 100644 index 0000000..55b029f --- /dev/null +++ b/tests/conformance/ast/024-whitespace-only-document.mq.md @@ -0,0 +1,3 @@ + + + diff --git a/tests/conformance/ast/025-bom-document.ast.json b/tests/conformance/ast/025-bom-document.ast.json new file mode 100644 index 0000000..637f759 --- /dev/null +++ b/tests/conformance/ast/025-bom-document.ast.json @@ -0,0 +1,45 @@ +{ + "kind": "document", + "span": { + "start": 3, + "end": 30 + }, + "children": [ + { + "kind": "heading", + "level": 1, + "setext": false, + "span": { + "start": 3, + "end": 22 + }, + "children": [ + { + "kind": "text", + "span": { + "start": 5, + "end": 22 + }, + "literal": "带 BOM 的文档" + } + ] + }, + { + "kind": "paragraph", + "span": { + "start": 24, + "end": 30 + }, + "children": [ + { + "kind": "text", + "span": { + "start": 24, + "end": 30 + }, + "literal": "正文" + } + ] + } + ] +} diff --git a/tests/conformance/ast/025-bom-document.mq.md b/tests/conformance/ast/025-bom-document.mq.md new file mode 100644 index 0000000..9469875 --- /dev/null +++ b/tests/conformance/ast/025-bom-document.mq.md @@ -0,0 +1,3 @@ +# 带 BOM 的文档 + +正文 diff --git a/tests/conformance/ast/026-mixed-paragraph-blocks.ast.json b/tests/conformance/ast/026-mixed-paragraph-blocks.ast.json new file mode 100644 index 0000000..4af1672 --- /dev/null +++ b/tests/conformance/ast/026-mixed-paragraph-blocks.ast.json @@ -0,0 +1,62 @@ +{ + "kind": "document", + "span": { + "start": 0, + "end": 43 + }, + "children": [ + { + "kind": "paragraph", + "span": { + "start": 0, + "end": 15 + }, + "children": [ + { + "kind": "text", + "span": { + "start": 0, + "end": 15 + }, + "literal": "引言段落。" + } + ] + }, + { + "kind": "heading", + "level": 2, + "setext": false, + "span": { + "start": 17, + "end": 26 + }, + "children": [ + { + "kind": "text", + "span": { + "start": 20, + "end": 26 + }, + "literal": "函数" + } + ] + }, + { + "kind": "paragraph", + "span": { + "start": 28, + "end": 43 + }, + "children": [ + { + "kind": "text", + "span": { + "start": 28, + "end": 43 + }, + "literal": "正文段落。" + } + ] + } + ] +} diff --git a/tests/conformance/ast/026-mixed-paragraph-blocks.mq.md b/tests/conformance/ast/026-mixed-paragraph-blocks.mq.md new file mode 100644 index 0000000..27acd7c --- /dev/null +++ b/tests/conformance/ast/026-mixed-paragraph-blocks.mq.md @@ -0,0 +1,5 @@ +引言段落。 + +## 函数 + +正文段落。 diff --git a/tests/conformance/ast/027-strong-asterisk.ast.json b/tests/conformance/ast/027-strong-asterisk.ast.json new file mode 100644 index 0000000..9ff6a24 --- /dev/null +++ b/tests/conformance/ast/027-strong-asterisk.ast.json @@ -0,0 +1,35 @@ +{ + "kind": "document", + "span": { + "start": 0, + "end": 10 + }, + "children": [ + { + "kind": "paragraph", + "span": { + "start": 0, + "end": 10 + }, + "children": [ + { + "kind": "strong", + "span": { + "start": 0, + "end": 10 + }, + "children": [ + { + "kind": "text", + "span": { + "start": 2, + "end": 8 + }, + "literal": "粗体" + } + ] + } + ] + } + ] +} diff --git a/tests/conformance/ast/027-strong-asterisk.mq.md b/tests/conformance/ast/027-strong-asterisk.mq.md new file mode 100644 index 0000000..e8388cd --- /dev/null +++ b/tests/conformance/ast/027-strong-asterisk.mq.md @@ -0,0 +1 @@ +**粗体** diff --git a/tests/conformance/ast/028-strong-underscore.ast.json b/tests/conformance/ast/028-strong-underscore.ast.json new file mode 100644 index 0000000..9ff6a24 --- /dev/null +++ b/tests/conformance/ast/028-strong-underscore.ast.json @@ -0,0 +1,35 @@ +{ + "kind": "document", + "span": { + "start": 0, + "end": 10 + }, + "children": [ + { + "kind": "paragraph", + "span": { + "start": 0, + "end": 10 + }, + "children": [ + { + "kind": "strong", + "span": { + "start": 0, + "end": 10 + }, + "children": [ + { + "kind": "text", + "span": { + "start": 2, + "end": 8 + }, + "literal": "粗体" + } + ] + } + ] + } + ] +} diff --git a/tests/conformance/ast/028-strong-underscore.mq.md b/tests/conformance/ast/028-strong-underscore.mq.md new file mode 100644 index 0000000..b8f1cca --- /dev/null +++ b/tests/conformance/ast/028-strong-underscore.mq.md @@ -0,0 +1 @@ +__粗体__ diff --git a/tests/conformance/ast/029-emph-asterisk.ast.json b/tests/conformance/ast/029-emph-asterisk.ast.json new file mode 100644 index 0000000..0a1c951 --- /dev/null +++ b/tests/conformance/ast/029-emph-asterisk.ast.json @@ -0,0 +1,35 @@ +{ + "kind": "document", + "span": { + "start": 0, + "end": 8 + }, + "children": [ + { + "kind": "paragraph", + "span": { + "start": 0, + "end": 8 + }, + "children": [ + { + "kind": "emph", + "span": { + "start": 0, + "end": 8 + }, + "children": [ + { + "kind": "text", + "span": { + "start": 1, + "end": 7 + }, + "literal": "斜体" + } + ] + } + ] + } + ] +} diff --git a/tests/conformance/ast/029-emph-asterisk.mq.md b/tests/conformance/ast/029-emph-asterisk.mq.md new file mode 100644 index 0000000..d0f4eb0 --- /dev/null +++ b/tests/conformance/ast/029-emph-asterisk.mq.md @@ -0,0 +1 @@ +*斜体* diff --git a/tests/conformance/ast/030-emph-underscore.ast.json b/tests/conformance/ast/030-emph-underscore.ast.json new file mode 100644 index 0000000..0a1c951 --- /dev/null +++ b/tests/conformance/ast/030-emph-underscore.ast.json @@ -0,0 +1,35 @@ +{ + "kind": "document", + "span": { + "start": 0, + "end": 8 + }, + "children": [ + { + "kind": "paragraph", + "span": { + "start": 0, + "end": 8 + }, + "children": [ + { + "kind": "emph", + "span": { + "start": 0, + "end": 8 + }, + "children": [ + { + "kind": "text", + "span": { + "start": 1, + "end": 7 + }, + "literal": "斜体" + } + ] + } + ] + } + ] +} diff --git a/tests/conformance/ast/030-emph-underscore.mq.md b/tests/conformance/ast/030-emph-underscore.mq.md new file mode 100644 index 0000000..a7536b5 --- /dev/null +++ b/tests/conformance/ast/030-emph-underscore.mq.md @@ -0,0 +1 @@ +_斜体_ diff --git a/tests/conformance/ast/031-strong-emph-nested.ast.json b/tests/conformance/ast/031-strong-emph-nested.ast.json new file mode 100644 index 0000000..909c539 --- /dev/null +++ b/tests/conformance/ast/031-strong-emph-nested.ast.json @@ -0,0 +1,44 @@ +{ + "kind": "document", + "span": { + "start": 0, + "end": 15 + }, + "children": [ + { + "kind": "paragraph", + "span": { + "start": 0, + "end": 15 + }, + "children": [ + { + "kind": "emph", + "span": { + "start": 0, + "end": 15 + }, + "children": [ + { + "kind": "strong", + "span": { + "start": 1, + "end": 14 + }, + "children": [ + { + "kind": "text", + "span": { + "start": 3, + "end": 12 + }, + "literal": "粗斜体" + } + ] + } + ] + } + ] + } + ] +} diff --git a/tests/conformance/ast/031-strong-emph-nested.mq.md b/tests/conformance/ast/031-strong-emph-nested.mq.md new file mode 100644 index 0000000..2c6c627 --- /dev/null +++ b/tests/conformance/ast/031-strong-emph-nested.mq.md @@ -0,0 +1 @@ +***粗斜体*** diff --git a/tests/conformance/ast/032-emph-in-strong.ast.json b/tests/conformance/ast/032-emph-in-strong.ast.json new file mode 100644 index 0000000..fd7d414 --- /dev/null +++ b/tests/conformance/ast/032-emph-in-strong.ast.json @@ -0,0 +1,60 @@ +{ + "kind": "document", + "span": { + "start": 0, + "end": 32 + }, + "children": [ + { + "kind": "paragraph", + "span": { + "start": 0, + "end": 32 + }, + "children": [ + { + "kind": "strong", + "span": { + "start": 0, + "end": 32 + }, + "children": [ + { + "kind": "text", + "span": { + "start": 2, + "end": 15 + }, + "literal": "粗体中的 " + }, + { + "kind": "emph", + "span": { + "start": 15, + "end": 23 + }, + "children": [ + { + "kind": "text", + "span": { + "start": 16, + "end": 22 + }, + "literal": "斜体" + } + ] + }, + { + "kind": "text", + "span": { + "start": 23, + "end": 30 + }, + "literal": " 文本" + } + ] + } + ] + } + ] +} diff --git a/tests/conformance/ast/032-emph-in-strong.mq.md b/tests/conformance/ast/032-emph-in-strong.mq.md new file mode 100644 index 0000000..68424fa --- /dev/null +++ b/tests/conformance/ast/032-emph-in-strong.mq.md @@ -0,0 +1 @@ +**粗体中的 *斜体* 文本** diff --git a/tests/conformance/ast/033-strong-in-emph.ast.json b/tests/conformance/ast/033-strong-in-emph.ast.json new file mode 100644 index 0000000..2cde3e5 --- /dev/null +++ b/tests/conformance/ast/033-strong-in-emph.ast.json @@ -0,0 +1,60 @@ +{ + "kind": "document", + "span": { + "start": 0, + "end": 32 + }, + "children": [ + { + "kind": "paragraph", + "span": { + "start": 0, + "end": 32 + }, + "children": [ + { + "kind": "emph", + "span": { + "start": 0, + "end": 32 + }, + "children": [ + { + "kind": "text", + "span": { + "start": 1, + "end": 14 + }, + "literal": "斜体中的 " + }, + { + "kind": "strong", + "span": { + "start": 14, + "end": 24 + }, + "children": [ + { + "kind": "text", + "span": { + "start": 16, + "end": 22 + }, + "literal": "粗体" + } + ] + }, + { + "kind": "text", + "span": { + "start": 24, + "end": 31 + }, + "literal": " 文本" + } + ] + } + ] + } + ] +} diff --git a/tests/conformance/ast/033-strong-in-emph.mq.md b/tests/conformance/ast/033-strong-in-emph.mq.md new file mode 100644 index 0000000..cc380ab --- /dev/null +++ b/tests/conformance/ast/033-strong-in-emph.mq.md @@ -0,0 +1 @@ +*斜体中的 **粗体** 文本* diff --git a/tests/conformance/ast/034-intraword-underscore.ast.json b/tests/conformance/ast/034-intraword-underscore.ast.json new file mode 100644 index 0000000..6037bfc --- /dev/null +++ b/tests/conformance/ast/034-intraword-underscore.ast.json @@ -0,0 +1,26 @@ +{ + "kind": "document", + "span": { + "start": 0, + "end": 28 + }, + "children": [ + { + "kind": "paragraph", + "span": { + "start": 0, + "end": 28 + }, + "children": [ + { + "kind": "text", + "span": { + "start": 0, + "end": 28 + }, + "literal": "snake_case_name 不是强调" + } + ] + } + ] +} diff --git a/tests/conformance/ast/034-intraword-underscore.mq.md b/tests/conformance/ast/034-intraword-underscore.mq.md new file mode 100644 index 0000000..b48927d --- /dev/null +++ b/tests/conformance/ast/034-intraword-underscore.mq.md @@ -0,0 +1 @@ +snake_case_name 不是强调 diff --git a/tests/conformance/ast/035-multiline-emphasis.ast.json b/tests/conformance/ast/035-multiline-emphasis.ast.json new file mode 100644 index 0000000..9a93477 --- /dev/null +++ b/tests/conformance/ast/035-multiline-emphasis.ast.json @@ -0,0 +1,50 @@ +{ + "kind": "document", + "span": { + "start": 0, + "end": 15 + }, + "children": [ + { + "kind": "paragraph", + "span": { + "start": 0, + "end": 15 + }, + "children": [ + { + "kind": "emph", + "span": { + "start": 0, + "end": 15 + }, + "children": [ + { + "kind": "text", + "span": { + "start": 1, + "end": 7 + }, + "literal": "多行" + }, + { + "kind": "soft_break", + "span": { + "start": 7, + "end": 8 + } + }, + { + "kind": "text", + "span": { + "start": 8, + "end": 14 + }, + "literal": "斜体" + } + ] + } + ] + } + ] +} diff --git a/tests/conformance/ast/035-multiline-emphasis.mq.md b/tests/conformance/ast/035-multiline-emphasis.mq.md new file mode 100644 index 0000000..04c0e8b --- /dev/null +++ b/tests/conformance/ast/035-multiline-emphasis.mq.md @@ -0,0 +1,2 @@ +*多行 +斜体* diff --git a/tests/conformance/ast/036-emphasis-with-punctuation.ast.json b/tests/conformance/ast/036-emphasis-with-punctuation.ast.json new file mode 100644 index 0000000..2a3ad15 --- /dev/null +++ b/tests/conformance/ast/036-emphasis-with-punctuation.ast.json @@ -0,0 +1,76 @@ +{ + "kind": "document", + "span": { + "start": 0, + "end": 36 + }, + "children": [ + { + "kind": "paragraph", + "span": { + "start": 0, + "end": 36 + }, + "children": [ + { + "kind": "text", + "span": { + "start": 0, + "end": 6 + }, + "literal": "这是" + }, + { + "kind": "strong", + "span": { + "start": 6, + "end": 16 + }, + "children": [ + { + "kind": "text", + "span": { + "start": 8, + "end": 14 + }, + "literal": "加粗" + } + ] + }, + { + "kind": "text", + "span": { + "start": 16, + "end": 25 + }, + "literal": ",这是" + }, + { + "kind": "emph", + "span": { + "start": 25, + "end": 33 + }, + "children": [ + { + "kind": "text", + "span": { + "start": 26, + "end": 32 + }, + "literal": "斜体" + } + ] + }, + { + "kind": "text", + "span": { + "start": 33, + "end": 36 + }, + "literal": "。" + } + ] + } + ] +} diff --git a/tests/conformance/ast/036-emphasis-with-punctuation.mq.md b/tests/conformance/ast/036-emphasis-with-punctuation.mq.md new file mode 100644 index 0000000..b2c1bab --- /dev/null +++ b/tests/conformance/ast/036-emphasis-with-punctuation.mq.md @@ -0,0 +1 @@ +这是**加粗**,这是*斜体*。 diff --git a/tests/conformance/ast/037-strong-with-code-span.ast.json b/tests/conformance/ast/037-strong-with-code-span.ast.json new file mode 100644 index 0000000..5a85250 --- /dev/null +++ b/tests/conformance/ast/037-strong-with-code-span.ast.json @@ -0,0 +1,36 @@ +{ + "kind": "document", + "span": { + "start": 0, + "end": 11 + }, + "children": [ + { + "kind": "paragraph", + "span": { + "start": 0, + "end": 11 + }, + "children": [ + { + "kind": "strong", + "span": { + "start": 0, + "end": 11 + }, + "children": [ + { + "kind": "code", + "ticks": 1, + "span": { + "start": 2, + "end": 9 + }, + "literal": "x = 1" + } + ] + } + ] + } + ] +} diff --git a/tests/conformance/ast/037-strong-with-code-span.mq.md b/tests/conformance/ast/037-strong-with-code-span.mq.md new file mode 100644 index 0000000..18ffd17 --- /dev/null +++ b/tests/conformance/ast/037-strong-with-code-span.mq.md @@ -0,0 +1 @@ +**`x = 1`** diff --git a/tests/conformance/ast/038-emph-with-code-span.ast.json b/tests/conformance/ast/038-emph-with-code-span.ast.json new file mode 100644 index 0000000..72308f0 --- /dev/null +++ b/tests/conformance/ast/038-emph-with-code-span.ast.json @@ -0,0 +1,36 @@ +{ + "kind": "document", + "span": { + "start": 0, + "end": 9 + }, + "children": [ + { + "kind": "paragraph", + "span": { + "start": 0, + "end": 9 + }, + "children": [ + { + "kind": "emph", + "span": { + "start": 0, + "end": 9 + }, + "children": [ + { + "kind": "code", + "ticks": 1, + "span": { + "start": 1, + "end": 8 + }, + "literal": "n - 1" + } + ] + } + ] + } + ] +} diff --git a/tests/conformance/ast/038-emph-with-code-span.mq.md b/tests/conformance/ast/038-emph-with-code-span.mq.md new file mode 100644 index 0000000..0b6c1ee --- /dev/null +++ b/tests/conformance/ast/038-emph-with-code-span.mq.md @@ -0,0 +1 @@ +*`n - 1`* diff --git a/tests/conformance/ast/039-code-single-tick.ast.json b/tests/conformance/ast/039-code-single-tick.ast.json new file mode 100644 index 0000000..c7bdbd1 --- /dev/null +++ b/tests/conformance/ast/039-code-single-tick.ast.json @@ -0,0 +1,27 @@ +{ + "kind": "document", + "span": { + "start": 0, + "end": 7 + }, + "children": [ + { + "kind": "paragraph", + "span": { + "start": 0, + "end": 7 + }, + "children": [ + { + "kind": "code", + "ticks": 1, + "span": { + "start": 0, + "end": 7 + }, + "literal": "x = 1" + } + ] + } + ] +} diff --git a/tests/conformance/ast/039-code-single-tick.mq.md b/tests/conformance/ast/039-code-single-tick.mq.md new file mode 100644 index 0000000..c7cf909 --- /dev/null +++ b/tests/conformance/ast/039-code-single-tick.mq.md @@ -0,0 +1 @@ +`x = 1` diff --git a/tests/conformance/ast/040-code-double-tick.ast.json b/tests/conformance/ast/040-code-double-tick.ast.json new file mode 100644 index 0000000..8b28ea3 --- /dev/null +++ b/tests/conformance/ast/040-code-double-tick.ast.json @@ -0,0 +1,27 @@ +{ + "kind": "document", + "span": { + "start": 0, + "end": 7 + }, + "children": [ + { + "kind": "paragraph", + "span": { + "start": 0, + "end": 7 + }, + "children": [ + { + "kind": "code", + "ticks": 2, + "span": { + "start": 0, + "end": 7 + }, + "literal": "a`b" + } + ] + } + ] +} diff --git a/tests/conformance/ast/040-code-double-tick.mq.md b/tests/conformance/ast/040-code-double-tick.mq.md new file mode 100644 index 0000000..d15d385 --- /dev/null +++ b/tests/conformance/ast/040-code-double-tick.mq.md @@ -0,0 +1 @@ +``a`b`` diff --git a/tests/conformance/ast/041-code-triple-tick.ast.json b/tests/conformance/ast/041-code-triple-tick.ast.json new file mode 100644 index 0000000..5b3296e --- /dev/null +++ b/tests/conformance/ast/041-code-triple-tick.ast.json @@ -0,0 +1,27 @@ +{ + "kind": "document", + "span": { + "start": 0, + "end": 10 + }, + "children": [ + { + "kind": "paragraph", + "span": { + "start": 0, + "end": 10 + }, + "children": [ + { + "kind": "code", + "ticks": 3, + "span": { + "start": 0, + "end": 10 + }, + "literal": "a``b" + } + ] + } + ] +} diff --git a/tests/conformance/ast/041-code-triple-tick.mq.md b/tests/conformance/ast/041-code-triple-tick.mq.md new file mode 100644 index 0000000..99965b1 --- /dev/null +++ b/tests/conformance/ast/041-code-triple-tick.mq.md @@ -0,0 +1 @@ +```a``b``` diff --git a/tests/conformance/ast/042-code-with-spaces.ast.json b/tests/conformance/ast/042-code-with-spaces.ast.json new file mode 100644 index 0000000..81befae --- /dev/null +++ b/tests/conformance/ast/042-code-with-spaces.ast.json @@ -0,0 +1,27 @@ +{ + "kind": "document", + "span": { + "start": 0, + "end": 16 + }, + "children": [ + { + "kind": "paragraph", + "span": { + "start": 0, + "end": 16 + }, + "children": [ + { + "kind": "code", + "ticks": 1, + "span": { + "start": 0, + "end": 16 + }, + "literal": "保留空格" + } + ] + } + ] +} diff --git a/tests/conformance/ast/042-code-with-spaces.mq.md b/tests/conformance/ast/042-code-with-spaces.mq.md new file mode 100644 index 0000000..7de9bdb --- /dev/null +++ b/tests/conformance/ast/042-code-with-spaces.mq.md @@ -0,0 +1 @@ +` 保留空格 ` diff --git a/tests/conformance/ast/043-code-empty.ast.json b/tests/conformance/ast/043-code-empty.ast.json new file mode 100644 index 0000000..fe1f02a --- /dev/null +++ b/tests/conformance/ast/043-code-empty.ast.json @@ -0,0 +1,26 @@ +{ + "kind": "document", + "span": { + "start": 0, + "end": 2 + }, + "children": [ + { + "kind": "paragraph", + "span": { + "start": 0, + "end": 2 + }, + "children": [ + { + "kind": "text", + "span": { + "start": 0, + "end": 2 + }, + "literal": "``" + } + ] + } + ] +} diff --git a/tests/conformance/ast/043-code-empty.mq.md b/tests/conformance/ast/043-code-empty.mq.md new file mode 100644 index 0000000..cf637de --- /dev/null +++ b/tests/conformance/ast/043-code-empty.mq.md @@ -0,0 +1 @@ +`` diff --git a/tests/conformance/ast/044-code-with-special-chars.ast.json b/tests/conformance/ast/044-code-with-special-chars.ast.json new file mode 100644 index 0000000..7544bca --- /dev/null +++ b/tests/conformance/ast/044-code-with-special-chars.ast.json @@ -0,0 +1,27 @@ +{ + "kind": "document", + "span": { + "start": 0, + "end": 16 + }, + "children": [ + { + "kind": "paragraph", + "span": { + "start": 0, + "end": 16 + }, + "children": [ + { + "kind": "code", + "ticks": 1, + "span": { + "start": 0, + "end": 16 + }, + "literal": "a * b / c ** d" + } + ] + } + ] +} diff --git a/tests/conformance/ast/044-code-with-special-chars.mq.md b/tests/conformance/ast/044-code-with-special-chars.mq.md new file mode 100644 index 0000000..6516cf9 --- /dev/null +++ b/tests/conformance/ast/044-code-with-special-chars.mq.md @@ -0,0 +1 @@ +`a * b / c ** d` diff --git a/tests/conformance/ast/045-code-multiline-payload.ast.json b/tests/conformance/ast/045-code-multiline-payload.ast.json new file mode 100644 index 0000000..ae13c39 --- /dev/null +++ b/tests/conformance/ast/045-code-multiline-payload.ast.json @@ -0,0 +1,27 @@ +{ + "kind": "document", + "span": { + "start": 0, + "end": 21 + }, + "children": [ + { + "kind": "paragraph", + "span": { + "start": 0, + "end": 21 + }, + "children": [ + { + "kind": "code", + "ticks": 1, + "span": { + "start": 0, + "end": 21 + }, + "literal": "第一行 第二行" + } + ] + } + ] +} diff --git a/tests/conformance/ast/045-code-multiline-payload.mq.md b/tests/conformance/ast/045-code-multiline-payload.mq.md new file mode 100644 index 0000000..0738840 --- /dev/null +++ b/tests/conformance/ast/045-code-multiline-payload.mq.md @@ -0,0 +1,2 @@ +`第一行 +第二行` diff --git a/tests/conformance/ast/046-fenced-no-language.ast.json b/tests/conformance/ast/046-fenced-no-language.ast.json new file mode 100644 index 0000000..9ada4c9 --- /dev/null +++ b/tests/conformance/ast/046-fenced-no-language.ast.json @@ -0,0 +1,19 @@ +{ + "kind": "document", + "span": { + "start": 0, + "end": 13 + }, + "children": [ + { + "kind": "code_block", + "fenced": true, + "info": "", + "span": { + "start": 0, + "end": 13 + }, + "literal": "x = 1\n" + } + ] +} diff --git a/tests/conformance/ast/046-fenced-no-language.mq.md b/tests/conformance/ast/046-fenced-no-language.mq.md new file mode 100644 index 0000000..d5a7c6b --- /dev/null +++ b/tests/conformance/ast/046-fenced-no-language.mq.md @@ -0,0 +1,3 @@ +``` +x = 1 +``` diff --git a/tests/conformance/ast/047-fenced-with-language.ast.json b/tests/conformance/ast/047-fenced-with-language.ast.json new file mode 100644 index 0000000..c07f086 --- /dev/null +++ b/tests/conformance/ast/047-fenced-with-language.ast.json @@ -0,0 +1,19 @@ +{ + "kind": "document", + "span": { + "start": 0, + "end": 24 + }, + "children": [ + { + "kind": "code_block", + "fenced": true, + "info": "rust", + "span": { + "start": 0, + "end": 24 + }, + "literal": "fn main() {}\n" + } + ] +} diff --git a/tests/conformance/ast/047-fenced-with-language.mq.md b/tests/conformance/ast/047-fenced-with-language.mq.md new file mode 100644 index 0000000..3199642 --- /dev/null +++ b/tests/conformance/ast/047-fenced-with-language.mq.md @@ -0,0 +1,3 @@ +```rust +fn main() {} +``` diff --git a/tests/conformance/ast/048-fenced-info-multiword.ast.json b/tests/conformance/ast/048-fenced-info-multiword.ast.json new file mode 100644 index 0000000..33aae85 --- /dev/null +++ b/tests/conformance/ast/048-fenced-info-multiword.ast.json @@ -0,0 +1,19 @@ +{ + "kind": "document", + "span": { + "start": 0, + "end": 29 + }, + "children": [ + { + "kind": "code_block", + "fenced": true, + "info": "rust ignore", + "span": { + "start": 0, + "end": 29 + }, + "literal": "let x = 1;\n" + } + ] +} diff --git a/tests/conformance/ast/048-fenced-info-multiword.mq.md b/tests/conformance/ast/048-fenced-info-multiword.mq.md new file mode 100644 index 0000000..2cf23b7 --- /dev/null +++ b/tests/conformance/ast/048-fenced-info-multiword.mq.md @@ -0,0 +1,3 @@ +```rust ignore +let x = 1; +``` diff --git a/tests/conformance/ast/049-fenced-tilde.ast.json b/tests/conformance/ast/049-fenced-tilde.ast.json new file mode 100644 index 0000000..69cbad8 --- /dev/null +++ b/tests/conformance/ast/049-fenced-tilde.ast.json @@ -0,0 +1,19 @@ +{ + "kind": "document", + "span": { + "start": 0, + "end": 22 + }, + "children": [ + { + "kind": "code_block", + "fenced": true, + "info": "python", + "span": { + "start": 0, + "end": 22 + }, + "literal": "print(1)\n" + } + ] +} diff --git a/tests/conformance/ast/049-fenced-tilde.mq.md b/tests/conformance/ast/049-fenced-tilde.mq.md new file mode 100644 index 0000000..718f47e --- /dev/null +++ b/tests/conformance/ast/049-fenced-tilde.mq.md @@ -0,0 +1,3 @@ +~~~python +print(1) +~~~ diff --git a/tests/conformance/ast/050-indented-code.ast.json b/tests/conformance/ast/050-indented-code.ast.json new file mode 100644 index 0000000..2137dde --- /dev/null +++ b/tests/conformance/ast/050-indented-code.ast.json @@ -0,0 +1,19 @@ +{ + "kind": "document", + "span": { + "start": 0, + "end": 33 + }, + "children": [ + { + "kind": "code_block", + "fenced": false, + "info": "", + "span": { + "start": 4, + "end": 33 + }, + "literal": "indented code\nsecond line\n" + } + ] +} diff --git a/tests/conformance/ast/050-indented-code.mq.md b/tests/conformance/ast/050-indented-code.mq.md new file mode 100644 index 0000000..335708f --- /dev/null +++ b/tests/conformance/ast/050-indented-code.mq.md @@ -0,0 +1,2 @@ + indented code + second line diff --git a/tests/conformance/ast/051-fenced-unclosed.ast.json b/tests/conformance/ast/051-fenced-unclosed.ast.json new file mode 100644 index 0000000..bb4797d --- /dev/null +++ b/tests/conformance/ast/051-fenced-unclosed.ast.json @@ -0,0 +1,19 @@ +{ + "kind": "document", + "span": { + "start": 0, + "end": 25 + }, + "children": [ + { + "kind": "code_block", + "fenced": true, + "info": "", + "span": { + "start": 0, + "end": 25 + }, + "literal": "未闭合的代码块\n" + } + ] +} diff --git a/tests/conformance/ast/051-fenced-unclosed.mq.md b/tests/conformance/ast/051-fenced-unclosed.mq.md new file mode 100644 index 0000000..f017114 --- /dev/null +++ b/tests/conformance/ast/051-fenced-unclosed.mq.md @@ -0,0 +1,2 @@ +``` +未闭合的代码块 diff --git a/tests/conformance/ast/052-fenced-with-tabs.ast.json b/tests/conformance/ast/052-fenced-with-tabs.ast.json new file mode 100644 index 0000000..81362ab --- /dev/null +++ b/tests/conformance/ast/052-fenced-with-tabs.ast.json @@ -0,0 +1,19 @@ +{ + "kind": "document", + "span": { + "start": 0, + "end": 26 + }, + "children": [ + { + "kind": "code_block", + "fenced": true, + "info": "", + "span": { + "start": 0, + "end": 26 + }, + "literal": "\tindented with tab\n" + } + ] +} diff --git a/tests/conformance/ast/052-fenced-with-tabs.mq.md b/tests/conformance/ast/052-fenced-with-tabs.mq.md new file mode 100644 index 0000000..f06a360 --- /dev/null +++ b/tests/conformance/ast/052-fenced-with-tabs.mq.md @@ -0,0 +1,3 @@ +``` + indented with tab +``` diff --git a/tests/conformance/ast/053-indented-code-after-paragraph.ast.json b/tests/conformance/ast/053-indented-code-after-paragraph.ast.json new file mode 100644 index 0000000..f5c6cc1 --- /dev/null +++ b/tests/conformance/ast/053-indented-code-after-paragraph.ast.json @@ -0,0 +1,36 @@ +{ + "kind": "document", + "span": { + "start": 0, + "end": 24 + }, + "children": [ + { + "kind": "paragraph", + "span": { + "start": 0, + "end": 9 + }, + "children": [ + { + "kind": "text", + "span": { + "start": 0, + "end": 9 + }, + "literal": "叙述:" + } + ] + }, + { + "kind": "code_block", + "fenced": false, + "info": "", + "span": { + "start": 15, + "end": 24 + }, + "literal": "code line\n" + } + ] +} diff --git a/tests/conformance/ast/053-indented-code-after-paragraph.mq.md b/tests/conformance/ast/053-indented-code-after-paragraph.mq.md new file mode 100644 index 0000000..5e8f973 --- /dev/null +++ b/tests/conformance/ast/053-indented-code-after-paragraph.mq.md @@ -0,0 +1,3 @@ +叙述: + + code line diff --git a/tests/conformance/ast/054-fenced-in-list.ast.json b/tests/conformance/ast/054-fenced-in-list.ast.json new file mode 100644 index 0000000..25328da --- /dev/null +++ b/tests/conformance/ast/054-fenced-in-list.ast.json @@ -0,0 +1,56 @@ +{ + "kind": "document", + "span": { + "start": 0, + "end": 36 + }, + "children": [ + { + "kind": "list", + "ordered": false, + "tight": false, + "span": { + "start": 0, + "end": 36 + }, + "children": [ + { + "kind": "item", + "span": { + "start": 0, + "end": 36 + }, + "children": [ + { + "kind": "paragraph", + "span": { + "start": 2, + "end": 8 + }, + "children": [ + { + "kind": "text", + "span": { + "start": 2, + "end": 8 + }, + "literal": "项目" + } + ] + }, + { + "kind": "code_block", + "fenced": true, + "info": "js", + "span": { + "start": 12, + "end": 36 + }, + "literal": "let a = 1;\n" + } + ] + } + ] + } + ] +} diff --git a/tests/conformance/ast/054-fenced-in-list.mq.md b/tests/conformance/ast/054-fenced-in-list.mq.md new file mode 100644 index 0000000..9d801b0 --- /dev/null +++ b/tests/conformance/ast/054-fenced-in-list.mq.md @@ -0,0 +1,5 @@ +- 项目 + + ```js + let a = 1; + ``` diff --git a/tests/conformance/ast/055-inline-math.ast.json b/tests/conformance/ast/055-inline-math.ast.json new file mode 100644 index 0000000..1e791fa --- /dev/null +++ b/tests/conformance/ast/055-inline-math.ast.json @@ -0,0 +1,43 @@ +{ + "kind": "document", + "span": { + "start": 0, + "end": 34 + }, + "children": [ + { + "kind": "paragraph", + "span": { + "start": 0, + "end": 34 + }, + "children": [ + { + "kind": "text", + "span": { + "start": 0, + "end": 13 + }, + "literal": "行内公式 " + }, + { + "kind": "math", + "display": false, + "span": { + "start": 13, + "end": 24 + }, + "literal": "a + b = c" + }, + { + "kind": "text", + "span": { + "start": 24, + "end": 34 + }, + "literal": " 结束。" + } + ] + } + ] +} diff --git a/tests/conformance/ast/055-inline-math.mq.md b/tests/conformance/ast/055-inline-math.mq.md new file mode 100644 index 0000000..68fc93a --- /dev/null +++ b/tests/conformance/ast/055-inline-math.mq.md @@ -0,0 +1 @@ +行内公式 $a + b = c$ 结束。 diff --git a/tests/conformance/ast/056-inline-display-math.ast.json b/tests/conformance/ast/056-inline-display-math.ast.json new file mode 100644 index 0000000..404a1b0 --- /dev/null +++ b/tests/conformance/ast/056-inline-display-math.ast.json @@ -0,0 +1,43 @@ +{ + "kind": "document", + "span": { + "start": 0, + "end": 42 + }, + "children": [ + { + "kind": "paragraph", + "span": { + "start": 0, + "end": 42 + }, + "children": [ + { + "kind": "text", + "span": { + "start": 0, + "end": 19 + }, + "literal": "行内显示公式 " + }, + { + "kind": "math", + "display": true, + "span": { + "start": 19, + "end": 32 + }, + "literal": "x^2 + y^2" + }, + { + "kind": "text", + "span": { + "start": 32, + "end": 42 + }, + "literal": " 结束。" + } + ] + } + ] +} diff --git a/tests/conformance/ast/056-inline-display-math.mq.md b/tests/conformance/ast/056-inline-display-math.mq.md new file mode 100644 index 0000000..f4aba74 --- /dev/null +++ b/tests/conformance/ast/056-inline-display-math.mq.md @@ -0,0 +1 @@ +行内显示公式 $$x^2 + y^2$$ 结束。 diff --git a/tests/conformance/ast/057-block-math.ast.json b/tests/conformance/ast/057-block-math.ast.json new file mode 100644 index 0000000..e76dfa2 --- /dev/null +++ b/tests/conformance/ast/057-block-math.ast.json @@ -0,0 +1,17 @@ +{ + "kind": "document", + "span": { + "start": 0, + "end": 14 + }, + "children": [ + { + "kind": "math_block", + "span": { + "start": 0, + "end": 14 + }, + "literal": "E = mc^2\n" + } + ] +} diff --git a/tests/conformance/ast/057-block-math.mq.md b/tests/conformance/ast/057-block-math.mq.md new file mode 100644 index 0000000..f8597c7 --- /dev/null +++ b/tests/conformance/ast/057-block-math.mq.md @@ -0,0 +1,3 @@ +$$ +E = mc^2 +$$ diff --git a/tests/conformance/ast/058-block-math-fraction.ast.json b/tests/conformance/ast/058-block-math-fraction.ast.json new file mode 100644 index 0000000..8739715 --- /dev/null +++ b/tests/conformance/ast/058-block-math-fraction.ast.json @@ -0,0 +1,17 @@ +{ + "kind": "document", + "span": { + "start": 0, + "end": 17 + }, + "children": [ + { + "kind": "math_block", + "span": { + "start": 0, + "end": 17 + }, + "literal": "\\frac{a}{b}\n" + } + ] +} diff --git a/tests/conformance/ast/058-block-math-fraction.mq.md b/tests/conformance/ast/058-block-math-fraction.mq.md new file mode 100644 index 0000000..a2412ad --- /dev/null +++ b/tests/conformance/ast/058-block-math-fraction.mq.md @@ -0,0 +1,3 @@ +$$ +\frac{a}{b} +$$ diff --git a/tests/conformance/ast/059-math-unclosed.ast.json b/tests/conformance/ast/059-math-unclosed.ast.json new file mode 100644 index 0000000..f3318ca --- /dev/null +++ b/tests/conformance/ast/059-math-unclosed.ast.json @@ -0,0 +1,26 @@ +{ + "kind": "document", + "span": { + "start": 0, + "end": 19 + }, + "children": [ + { + "kind": "paragraph", + "span": { + "start": 0, + "end": 19 + }, + "children": [ + { + "kind": "text", + "span": { + "start": 0, + "end": 19 + }, + "literal": "未闭合的 $x + y" + } + ] + } + ] +} diff --git a/tests/conformance/ast/059-math-unclosed.mq.md b/tests/conformance/ast/059-math-unclosed.mq.md new file mode 100644 index 0000000..c6ed7c4 --- /dev/null +++ b/tests/conformance/ast/059-math-unclosed.mq.md @@ -0,0 +1 @@ +未闭合的 $x + y diff --git a/tests/conformance/ast/060-math-escaped-dollar.ast.json b/tests/conformance/ast/060-math-escaped-dollar.ast.json new file mode 100644 index 0000000..ac7ce2e --- /dev/null +++ b/tests/conformance/ast/060-math-escaped-dollar.ast.json @@ -0,0 +1,26 @@ +{ + "kind": "document", + "span": { + "start": 0, + "end": 31 + }, + "children": [ + { + "kind": "paragraph", + "span": { + "start": 0, + "end": 31 + }, + "children": [ + { + "kind": "text", + "span": { + "start": 0, + "end": 31 + }, + "literal": "价格是 $5,不是公式。" + } + ] + } + ] +} diff --git a/tests/conformance/ast/060-math-escaped-dollar.mq.md b/tests/conformance/ast/060-math-escaped-dollar.mq.md new file mode 100644 index 0000000..2968611 --- /dev/null +++ b/tests/conformance/ast/060-math-escaped-dollar.mq.md @@ -0,0 +1 @@ +价格是 \$5,不是公式。 diff --git a/tests/conformance/ast/061-math-in-paragraph-mixed.ast.json b/tests/conformance/ast/061-math-in-paragraph-mixed.ast.json new file mode 100644 index 0000000..2f18c72 --- /dev/null +++ b/tests/conformance/ast/061-math-in-paragraph-mixed.ast.json @@ -0,0 +1,68 @@ +{ + "kind": "document", + "span": { + "start": 0, + "end": 35 + }, + "children": [ + { + "kind": "paragraph", + "span": { + "start": 0, + "end": 35 + }, + "children": [ + { + "kind": "text", + "span": { + "start": 0, + "end": 7 + }, + "literal": "公式 " + }, + { + "kind": "math", + "display": false, + "span": { + "start": 7, + "end": 10 + }, + "literal": "x" + }, + { + "kind": "text", + "span": { + "start": 10, + "end": 15 + }, + "literal": " 与 " + }, + { + "kind": "strong", + "span": { + "start": 15, + "end": 25 + }, + "children": [ + { + "kind": "text", + "span": { + "start": 17, + "end": 23 + }, + "literal": "粗体" + } + ] + }, + { + "kind": "text", + "span": { + "start": 25, + "end": 35 + }, + "literal": " 混排。" + } + ] + } + ] +} diff --git a/tests/conformance/ast/061-math-in-paragraph-mixed.mq.md b/tests/conformance/ast/061-math-in-paragraph-mixed.mq.md new file mode 100644 index 0000000..dfe5b46 --- /dev/null +++ b/tests/conformance/ast/061-math-in-paragraph-mixed.mq.md @@ -0,0 +1 @@ +公式 $x$ 与 **粗体** 混排。 diff --git a/tests/conformance/ast/062-table-basic.ast.json b/tests/conformance/ast/062-table-basic.ast.json new file mode 100644 index 0000000..fb8fc07 --- /dev/null +++ b/tests/conformance/ast/062-table-basic.ast.json @@ -0,0 +1,154 @@ +{ + "kind": "document", + "span": { + "start": 0, + "end": 60 + }, + "children": [ + { + "kind": "table", + "alignments": [ + "none", + "none" + ], + "span": { + "start": 0, + "end": 60 + }, + "children": [ + { + "kind": "table_row", + "header": true, + "span": { + "start": 0, + "end": 19 + }, + "children": [ + { + "kind": "table_cell", + "span": { + "start": 1, + "end": 9 + }, + "children": [ + { + "kind": "text", + "span": { + "start": 2, + "end": 8 + }, + "literal": "名称" + } + ] + }, + { + "kind": "table_cell", + "span": { + "start": 10, + "end": 18 + }, + "children": [ + { + "kind": "text", + "span": { + "start": 11, + "end": 17 + }, + "literal": "数量" + } + ] + } + ] + }, + { + "kind": "table_row", + "header": false, + "span": { + "start": 34, + "end": 48 + }, + "children": [ + { + "kind": "table_cell", + "span": { + "start": 35, + "end": 43 + }, + "children": [ + { + "kind": "text", + "span": { + "start": 36, + "end": 42 + }, + "literal": "苹果" + } + ] + }, + { + "kind": "table_cell", + "span": { + "start": 44, + "end": 47 + }, + "children": [ + { + "kind": "text", + "span": { + "start": 45, + "end": 46 + }, + "literal": "3" + } + ] + } + ] + }, + { + "kind": "table_row", + "header": false, + "span": { + "start": 49, + "end": 60 + }, + "children": [ + { + "kind": "table_cell", + "span": { + "start": 50, + "end": 55 + }, + "children": [ + { + "kind": "text", + "span": { + "start": 51, + "end": 54 + }, + "literal": "梨" + } + ] + }, + { + "kind": "table_cell", + "span": { + "start": 56, + "end": 59 + }, + "children": [ + { + "kind": "text", + "span": { + "start": 57, + "end": 58 + }, + "literal": "5" + } + ] + } + ] + } + ] + } + ] +} diff --git a/tests/conformance/ast/062-table-basic.mq.md b/tests/conformance/ast/062-table-basic.mq.md new file mode 100644 index 0000000..8f4be84 --- /dev/null +++ b/tests/conformance/ast/062-table-basic.mq.md @@ -0,0 +1,4 @@ +| 名称 | 数量 | +| --- | --- | +| 苹果 | 3 | +| 梨 | 5 | diff --git a/tests/conformance/ast/063-table-alignments.ast.json b/tests/conformance/ast/063-table-alignments.ast.json new file mode 100644 index 0000000..7939cab --- /dev/null +++ b/tests/conformance/ast/063-table-alignments.ast.json @@ -0,0 +1,145 @@ +{ + "kind": "document", + "span": { + "start": 0, + "end": 57 + }, + "children": [ + { + "kind": "table", + "alignments": [ + "left", + "center", + "right" + ], + "span": { + "start": 0, + "end": 57 + }, + "children": [ + { + "kind": "table_row", + "header": true, + "span": { + "start": 0, + "end": 19 + }, + "children": [ + { + "kind": "table_cell", + "span": { + "start": 1, + "end": 6 + }, + "children": [ + { + "kind": "text", + "span": { + "start": 2, + "end": 5 + }, + "literal": "左" + } + ] + }, + { + "kind": "table_cell", + "span": { + "start": 7, + "end": 12 + }, + "children": [ + { + "kind": "text", + "span": { + "start": 8, + "end": 11 + }, + "literal": "中" + } + ] + }, + { + "kind": "table_cell", + "span": { + "start": 13, + "end": 18 + }, + "children": [ + { + "kind": "text", + "span": { + "start": 14, + "end": 17 + }, + "literal": "右" + } + ] + } + ] + }, + { + "kind": "table_row", + "header": false, + "span": { + "start": 44, + "end": 57 + }, + "children": [ + { + "kind": "table_cell", + "span": { + "start": 45, + "end": 48 + }, + "children": [ + { + "kind": "text", + "span": { + "start": 46, + "end": 47 + }, + "literal": "a" + } + ] + }, + { + "kind": "table_cell", + "span": { + "start": 49, + "end": 52 + }, + "children": [ + { + "kind": "text", + "span": { + "start": 50, + "end": 51 + }, + "literal": "b" + } + ] + }, + { + "kind": "table_cell", + "span": { + "start": 53, + "end": 56 + }, + "children": [ + { + "kind": "text", + "span": { + "start": 54, + "end": 55 + }, + "literal": "c" + } + ] + } + ] + } + ] + } + ] +} diff --git a/tests/conformance/ast/063-table-alignments.mq.md b/tests/conformance/ast/063-table-alignments.mq.md new file mode 100644 index 0000000..6438e7f --- /dev/null +++ b/tests/conformance/ast/063-table-alignments.mq.md @@ -0,0 +1,3 @@ +| 左 | 中 | 右 | +| :--- | :---: | ---: | +| a | b | c | diff --git a/tests/conformance/ast/064-table-escaped-pipe.ast.json b/tests/conformance/ast/064-table-escaped-pipe.ast.json new file mode 100644 index 0000000..70bf1bf --- /dev/null +++ b/tests/conformance/ast/064-table-escaped-pipe.ast.json @@ -0,0 +1,111 @@ +{ + "kind": "document", + "span": { + "start": 0, + "end": 61 + }, + "children": [ + { + "kind": "table", + "alignments": [ + "none", + "none" + ], + "span": { + "start": 0, + "end": 61 + }, + "children": [ + { + "kind": "table_row", + "header": true, + "span": { + "start": 0, + "end": 22 + }, + "children": [ + { + "kind": "table_cell", + "span": { + "start": 1, + "end": 12 + }, + "children": [ + { + "kind": "text", + "span": { + "start": 2, + "end": 11 + }, + "literal": "表达式" + } + ] + }, + { + "kind": "table_cell", + "span": { + "start": 13, + "end": 21 + }, + "children": [ + { + "kind": "text", + "span": { + "start": 14, + "end": 20 + }, + "literal": "说明" + } + ] + } + ] + }, + { + "kind": "table_row", + "header": false, + "span": { + "start": 37, + "end": 61 + }, + "children": [ + { + "kind": "table_cell", + "span": { + "start": 38, + "end": 48 + }, + "children": [ + { + "kind": "code", + "ticks": 1, + "span": { + "start": 39, + "end": 47 + }, + "literal": "a | b" + } + ] + }, + { + "kind": "table_cell", + "span": { + "start": 49, + "end": 60 + }, + "children": [ + { + "kind": "text", + "span": { + "start": 50, + "end": 59 + }, + "literal": "按位或" + } + ] + } + ] + } + ] + } + ] +} diff --git a/tests/conformance/ast/064-table-escaped-pipe.mq.md b/tests/conformance/ast/064-table-escaped-pipe.mq.md new file mode 100644 index 0000000..09a65ca --- /dev/null +++ b/tests/conformance/ast/064-table-escaped-pipe.mq.md @@ -0,0 +1,3 @@ +| 表达式 | 说明 | +| --- | --- | +| `a \| b` | 按位或 | diff --git a/tests/conformance/ast/065-table-missing-cells.ast.json b/tests/conformance/ast/065-table-missing-cells.ast.json new file mode 100644 index 0000000..e6f9ad7 --- /dev/null +++ b/tests/conformance/ast/065-table-missing-cells.ast.json @@ -0,0 +1,196 @@ +{ + "kind": "document", + "span": { + "start": 0, + "end": 57 + }, + "children": [ + { + "kind": "table", + "alignments": [ + "none", + "none", + "none" + ], + "span": { + "start": 0, + "end": 57 + }, + "children": [ + { + "kind": "table_row", + "header": true, + "span": { + "start": 0, + "end": 13 + }, + "children": [ + { + "kind": "table_cell", + "span": { + "start": 1, + "end": 4 + }, + "children": [ + { + "kind": "text", + "span": { + "start": 2, + "end": 3 + }, + "literal": "a" + } + ] + }, + { + "kind": "table_cell", + "span": { + "start": 5, + "end": 8 + }, + "children": [ + { + "kind": "text", + "span": { + "start": 6, + "end": 7 + }, + "literal": "b" + } + ] + }, + { + "kind": "table_cell", + "span": { + "start": 9, + "end": 12 + }, + "children": [ + { + "kind": "text", + "span": { + "start": 10, + "end": 11 + }, + "literal": "c" + } + ] + } + ] + }, + { + "kind": "table_row", + "header": false, + "span": { + "start": 34, + "end": 43 + }, + "children": [ + { + "kind": "table_cell", + "span": { + "start": 35, + "end": 38 + }, + "children": [ + { + "kind": "text", + "span": { + "start": 36, + "end": 37 + }, + "literal": "1" + } + ] + }, + { + "kind": "table_cell", + "span": { + "start": 39, + "end": 42 + }, + "children": [ + { + "kind": "text", + "span": { + "start": 40, + "end": 41 + }, + "literal": "2" + } + ] + }, + { + "kind": "table_cell", + "span": { + "start": 42, + "end": 42 + } + } + ] + }, + { + "kind": "table_row", + "header": false, + "span": { + "start": 44, + "end": 57 + }, + "children": [ + { + "kind": "table_cell", + "span": { + "start": 45, + "end": 48 + }, + "children": [ + { + "kind": "text", + "span": { + "start": 46, + "end": 47 + }, + "literal": "3" + } + ] + }, + { + "kind": "table_cell", + "span": { + "start": 49, + "end": 52 + }, + "children": [ + { + "kind": "text", + "span": { + "start": 50, + "end": 51 + }, + "literal": "4" + } + ] + }, + { + "kind": "table_cell", + "span": { + "start": 53, + "end": 56 + }, + "children": [ + { + "kind": "text", + "span": { + "start": 54, + "end": 55 + }, + "literal": "5" + } + ] + } + ] + } + ] + } + ] +} diff --git a/tests/conformance/ast/065-table-missing-cells.mq.md b/tests/conformance/ast/065-table-missing-cells.mq.md new file mode 100644 index 0000000..2223056 --- /dev/null +++ b/tests/conformance/ast/065-table-missing-cells.mq.md @@ -0,0 +1,4 @@ +| a | b | c | +| --- | --- | --- | +| 1 | 2 | +| 3 | 4 | 5 | diff --git a/tests/conformance/ast/066-table-inline-markup.ast.json b/tests/conformance/ast/066-table-inline-markup.ast.json new file mode 100644 index 0000000..41c89bc --- /dev/null +++ b/tests/conformance/ast/066-table-inline-markup.ast.json @@ -0,0 +1,128 @@ +{ + "kind": "document", + "span": { + "start": 0, + "end": 59 + }, + "children": [ + { + "kind": "table", + "alignments": [ + "none", + "none" + ], + "span": { + "start": 0, + "end": 59 + }, + "children": [ + { + "kind": "table_row", + "header": true, + "span": { + "start": 0, + "end": 19 + }, + "children": [ + { + "kind": "table_cell", + "span": { + "start": 1, + "end": 9 + }, + "children": [ + { + "kind": "text", + "span": { + "start": 2, + "end": 8 + }, + "literal": "名称" + } + ] + }, + { + "kind": "table_cell", + "span": { + "start": 10, + "end": 18 + }, + "children": [ + { + "kind": "text", + "span": { + "start": 11, + "end": 17 + }, + "literal": "说明" + } + ] + } + ] + }, + { + "kind": "table_row", + "header": false, + "span": { + "start": 34, + "end": 59 + }, + "children": [ + { + "kind": "table_cell", + "span": { + "start": 35, + "end": 47 + }, + "children": [ + { + "kind": "strong", + "span": { + "start": 36, + "end": 46 + }, + "children": [ + { + "kind": "text", + "span": { + "start": 38, + "end": 44 + }, + "literal": "加粗" + } + ] + } + ] + }, + { + "kind": "table_cell", + "span": { + "start": 48, + "end": 58 + }, + "children": [ + { + "kind": "emph", + "span": { + "start": 49, + "end": 57 + }, + "children": [ + { + "kind": "text", + "span": { + "start": 50, + "end": 56 + }, + "literal": "斜体" + } + ] + } + ] + } + ] + } + ] + } + ] +} diff --git a/tests/conformance/ast/066-table-inline-markup.mq.md b/tests/conformance/ast/066-table-inline-markup.mq.md new file mode 100644 index 0000000..01a6432 --- /dev/null +++ b/tests/conformance/ast/066-table-inline-markup.mq.md @@ -0,0 +1,3 @@ +| 名称 | 说明 | +| --- | --- | +| **加粗** | *斜体* | diff --git a/tests/conformance/ast/067-table-no-leading-pipes.ast.json b/tests/conformance/ast/067-table-no-leading-pipes.ast.json new file mode 100644 index 0000000..d832342 --- /dev/null +++ b/tests/conformance/ast/067-table-no-leading-pipes.ast.json @@ -0,0 +1,110 @@ +{ + "kind": "document", + "span": { + "start": 0, + "end": 21 + }, + "children": [ + { + "kind": "table", + "alignments": [ + "none", + "none" + ], + "span": { + "start": 0, + "end": 21 + }, + "children": [ + { + "kind": "table_row", + "header": true, + "span": { + "start": 0, + "end": 5 + }, + "children": [ + { + "kind": "table_cell", + "span": { + "start": 0, + "end": 2 + }, + "children": [ + { + "kind": "text", + "span": { + "start": 0, + "end": 1 + }, + "literal": "a" + } + ] + }, + { + "kind": "table_cell", + "span": { + "start": 3, + "end": 5 + }, + "children": [ + { + "kind": "text", + "span": { + "start": 4, + "end": 5 + }, + "literal": "b" + } + ] + } + ] + }, + { + "kind": "table_row", + "header": false, + "span": { + "start": 16, + "end": 21 + }, + "children": [ + { + "kind": "table_cell", + "span": { + "start": 16, + "end": 18 + }, + "children": [ + { + "kind": "text", + "span": { + "start": 16, + "end": 17 + }, + "literal": "1" + } + ] + }, + { + "kind": "table_cell", + "span": { + "start": 19, + "end": 21 + }, + "children": [ + { + "kind": "text", + "span": { + "start": 20, + "end": 21 + }, + "literal": "2" + } + ] + } + ] + } + ] + } + ] +} diff --git a/tests/conformance/ast/067-table-no-leading-pipes.mq.md b/tests/conformance/ast/067-table-no-leading-pipes.mq.md new file mode 100644 index 0000000..3572e0e --- /dev/null +++ b/tests/conformance/ast/067-table-no-leading-pipes.mq.md @@ -0,0 +1,3 @@ +a | b +--- | --- +1 | 2 diff --git a/tests/conformance/ast/068-table-empty-cells.ast.json b/tests/conformance/ast/068-table-empty-cells.ast.json new file mode 100644 index 0000000..8eb3c84 --- /dev/null +++ b/tests/conformance/ast/068-table-empty-cells.ast.json @@ -0,0 +1,90 @@ +{ + "kind": "document", + "span": { + "start": 0, + "end": 29 + }, + "children": [ + { + "kind": "table", + "alignments": [ + "none", + "none" + ], + "span": { + "start": 0, + "end": 29 + }, + "children": [ + { + "kind": "table_row", + "header": true, + "span": { + "start": 0, + "end": 9 + }, + "children": [ + { + "kind": "table_cell", + "span": { + "start": 1, + "end": 4 + }, + "children": [ + { + "kind": "text", + "span": { + "start": 2, + "end": 3 + }, + "literal": "a" + } + ] + }, + { + "kind": "table_cell", + "span": { + "start": 5, + "end": 8 + }, + "children": [ + { + "kind": "text", + "span": { + "start": 6, + "end": 7 + }, + "literal": "b" + } + ] + } + ] + }, + { + "kind": "table_row", + "header": false, + "span": { + "start": 24, + "end": 29 + }, + "children": [ + { + "kind": "table_cell", + "span": { + "start": 25, + "end": 26 + } + }, + { + "kind": "table_cell", + "span": { + "start": 27, + "end": 28 + } + } + ] + } + ] + } + ] +} diff --git a/tests/conformance/ast/068-table-empty-cells.mq.md b/tests/conformance/ast/068-table-empty-cells.mq.md new file mode 100644 index 0000000..c33a7a6 --- /dev/null +++ b/tests/conformance/ast/068-table-empty-cells.mq.md @@ -0,0 +1,3 @@ +| a | b | +| --- | --- | +| | | diff --git a/tests/conformance/ast/069-bullet-dash.ast.json b/tests/conformance/ast/069-bullet-dash.ast.json new file mode 100644 index 0000000..ac96a5e --- /dev/null +++ b/tests/conformance/ast/069-bullet-dash.ast.json @@ -0,0 +1,72 @@ +{ + "kind": "document", + "span": { + "start": 0, + "end": 23 + }, + "children": [ + { + "kind": "list", + "ordered": false, + "tight": true, + "span": { + "start": 0, + "end": 23 + }, + "children": [ + { + "kind": "item", + "span": { + "start": 0, + "end": 11 + }, + "children": [ + { + "kind": "paragraph", + "span": { + "start": 2, + "end": 11 + }, + "children": [ + { + "kind": "text", + "span": { + "start": 2, + "end": 11 + }, + "literal": "第一项" + } + ] + } + ] + }, + { + "kind": "item", + "span": { + "start": 12, + "end": 23 + }, + "children": [ + { + "kind": "paragraph", + "span": { + "start": 14, + "end": 23 + }, + "children": [ + { + "kind": "text", + "span": { + "start": 14, + "end": 23 + }, + "literal": "第二项" + } + ] + } + ] + } + ] + } + ] +} diff --git a/tests/conformance/ast/069-bullet-dash.mq.md b/tests/conformance/ast/069-bullet-dash.mq.md new file mode 100644 index 0000000..ab00696 --- /dev/null +++ b/tests/conformance/ast/069-bullet-dash.mq.md @@ -0,0 +1,2 @@ +- 第一项 +- 第二项 diff --git a/tests/conformance/ast/070-bullet-markers-mixed.ast.json b/tests/conformance/ast/070-bullet-markers-mixed.ast.json new file mode 100644 index 0000000..7158018 --- /dev/null +++ b/tests/conformance/ast/070-bullet-markers-mixed.ast.json @@ -0,0 +1,120 @@ +{ + "kind": "document", + "span": { + "start": 0, + "end": 26 + }, + "children": [ + { + "kind": "list", + "ordered": false, + "tight": true, + "span": { + "start": 0, + "end": 8 + }, + "children": [ + { + "kind": "item", + "span": { + "start": 0, + "end": 8 + }, + "children": [ + { + "kind": "paragraph", + "span": { + "start": 2, + "end": 8 + }, + "children": [ + { + "kind": "text", + "span": { + "start": 2, + "end": 8 + }, + "literal": "短横" + } + ] + } + ] + } + ] + }, + { + "kind": "list", + "ordered": false, + "tight": true, + "span": { + "start": 9, + "end": 17 + }, + "children": [ + { + "kind": "item", + "span": { + "start": 9, + "end": 17 + }, + "children": [ + { + "kind": "paragraph", + "span": { + "start": 11, + "end": 17 + }, + "children": [ + { + "kind": "text", + "span": { + "start": 11, + "end": 17 + }, + "literal": "星号" + } + ] + } + ] + } + ] + }, + { + "kind": "list", + "ordered": false, + "tight": true, + "span": { + "start": 18, + "end": 26 + }, + "children": [ + { + "kind": "item", + "span": { + "start": 18, + "end": 26 + }, + "children": [ + { + "kind": "paragraph", + "span": { + "start": 20, + "end": 26 + }, + "children": [ + { + "kind": "text", + "span": { + "start": 20, + "end": 26 + }, + "literal": "加号" + } + ] + } + ] + } + ] + } + ] +} diff --git a/tests/conformance/ast/070-bullet-markers-mixed.mq.md b/tests/conformance/ast/070-bullet-markers-mixed.mq.md new file mode 100644 index 0000000..8ba5ed6 --- /dev/null +++ b/tests/conformance/ast/070-bullet-markers-mixed.mq.md @@ -0,0 +1,3 @@ +- 短横 +* 星号 ++ 加号 diff --git a/tests/conformance/ast/071-bullet-nested.ast.json b/tests/conformance/ast/071-bullet-nested.ast.json new file mode 100644 index 0000000..6172116 --- /dev/null +++ b/tests/conformance/ast/071-bullet-nested.ast.json @@ -0,0 +1,135 @@ +{ + "kind": "document", + "span": { + "start": 0, + "end": 48 + }, + "children": [ + { + "kind": "list", + "ordered": false, + "tight": true, + "span": { + "start": 0, + "end": 48 + }, + "children": [ + { + "kind": "item", + "span": { + "start": 0, + "end": 36 + }, + "children": [ + { + "kind": "paragraph", + "span": { + "start": 2, + "end": 8 + }, + "children": [ + { + "kind": "text", + "span": { + "start": 2, + "end": 8 + }, + "literal": "外层" + } + ] + }, + { + "kind": "list", + "ordered": false, + "tight": true, + "span": { + "start": 11, + "end": 36 + }, + "children": [ + { + "kind": "item", + "span": { + "start": 11, + "end": 22 + }, + "children": [ + { + "kind": "paragraph", + "span": { + "start": 13, + "end": 22 + }, + "children": [ + { + "kind": "text", + "span": { + "start": 13, + "end": 22 + }, + "literal": "内层一" + } + ] + } + ] + }, + { + "kind": "item", + "span": { + "start": 25, + "end": 36 + }, + "children": [ + { + "kind": "paragraph", + "span": { + "start": 27, + "end": 36 + }, + "children": [ + { + "kind": "text", + "span": { + "start": 27, + "end": 36 + }, + "literal": "内层二" + } + ] + } + ] + } + ] + } + ] + }, + { + "kind": "item", + "span": { + "start": 37, + "end": 48 + }, + "children": [ + { + "kind": "paragraph", + "span": { + "start": 39, + "end": 48 + }, + "children": [ + { + "kind": "text", + "span": { + "start": 39, + "end": 48 + }, + "literal": "外层二" + } + ] + } + ] + } + ] + } + ] +} diff --git a/tests/conformance/ast/071-bullet-nested.mq.md b/tests/conformance/ast/071-bullet-nested.mq.md new file mode 100644 index 0000000..637fbb3 --- /dev/null +++ b/tests/conformance/ast/071-bullet-nested.mq.md @@ -0,0 +1,4 @@ +- 外层 + - 内层一 + - 内层二 +- 外层二 diff --git a/tests/conformance/ast/072-ordered-start-3.ast.json b/tests/conformance/ast/072-ordered-start-3.ast.json new file mode 100644 index 0000000..beb7bfb --- /dev/null +++ b/tests/conformance/ast/072-ordered-start-3.ast.json @@ -0,0 +1,73 @@ +{ + "kind": "document", + "span": { + "start": 0, + "end": 19 + }, + "children": [ + { + "kind": "list", + "ordered": true, + "start": 3, + "tight": true, + "span": { + "start": 0, + "end": 19 + }, + "children": [ + { + "kind": "item", + "span": { + "start": 0, + "end": 9 + }, + "children": [ + { + "kind": "paragraph", + "span": { + "start": 3, + "end": 9 + }, + "children": [ + { + "kind": "text", + "span": { + "start": 3, + "end": 9 + }, + "literal": "第三" + } + ] + } + ] + }, + { + "kind": "item", + "span": { + "start": 10, + "end": 19 + }, + "children": [ + { + "kind": "paragraph", + "span": { + "start": 13, + "end": 19 + }, + "children": [ + { + "kind": "text", + "span": { + "start": 13, + "end": 19 + }, + "literal": "第四" + } + ] + } + ] + } + ] + } + ] +} diff --git a/tests/conformance/ast/072-ordered-start-3.mq.md b/tests/conformance/ast/072-ordered-start-3.mq.md new file mode 100644 index 0000000..2e2119f --- /dev/null +++ b/tests/conformance/ast/072-ordered-start-3.mq.md @@ -0,0 +1,2 @@ +3. 第三 +4. 第四 diff --git a/tests/conformance/ast/073-ordered-paren-delimiter.ast.json b/tests/conformance/ast/073-ordered-paren-delimiter.ast.json new file mode 100644 index 0000000..3f77bbf --- /dev/null +++ b/tests/conformance/ast/073-ordered-paren-delimiter.ast.json @@ -0,0 +1,73 @@ +{ + "kind": "document", + "span": { + "start": 0, + "end": 19 + }, + "children": [ + { + "kind": "list", + "ordered": true, + "start": 1, + "tight": true, + "span": { + "start": 0, + "end": 19 + }, + "children": [ + { + "kind": "item", + "span": { + "start": 0, + "end": 9 + }, + "children": [ + { + "kind": "paragraph", + "span": { + "start": 3, + "end": 9 + }, + "children": [ + { + "kind": "text", + "span": { + "start": 3, + "end": 9 + }, + "literal": "第一" + } + ] + } + ] + }, + { + "kind": "item", + "span": { + "start": 10, + "end": 19 + }, + "children": [ + { + "kind": "paragraph", + "span": { + "start": 13, + "end": 19 + }, + "children": [ + { + "kind": "text", + "span": { + "start": 13, + "end": 19 + }, + "literal": "第二" + } + ] + } + ] + } + ] + } + ] +} diff --git a/tests/conformance/ast/073-ordered-paren-delimiter.mq.md b/tests/conformance/ast/073-ordered-paren-delimiter.mq.md new file mode 100644 index 0000000..9f2651b --- /dev/null +++ b/tests/conformance/ast/073-ordered-paren-delimiter.mq.md @@ -0,0 +1,2 @@ +1) 第一 +2) 第二 diff --git a/tests/conformance/ast/074-ordered-nested.ast.json b/tests/conformance/ast/074-ordered-nested.ast.json new file mode 100644 index 0000000..bbd5a20 --- /dev/null +++ b/tests/conformance/ast/074-ordered-nested.ast.json @@ -0,0 +1,137 @@ +{ + "kind": "document", + "span": { + "start": 0, + "end": 51 + }, + "children": [ + { + "kind": "list", + "ordered": true, + "start": 1, + "tight": true, + "span": { + "start": 0, + "end": 51 + }, + "children": [ + { + "kind": "item", + "span": { + "start": 0, + "end": 38 + }, + "children": [ + { + "kind": "paragraph", + "span": { + "start": 3, + "end": 9 + }, + "children": [ + { + "kind": "text", + "span": { + "start": 3, + "end": 9 + }, + "literal": "外层" + } + ] + }, + { + "kind": "list", + "ordered": true, + "start": 1, + "tight": true, + "span": { + "start": 13, + "end": 38 + }, + "children": [ + { + "kind": "item", + "span": { + "start": 13, + "end": 22 + }, + "children": [ + { + "kind": "paragraph", + "span": { + "start": 16, + "end": 22 + }, + "children": [ + { + "kind": "text", + "span": { + "start": 16, + "end": 22 + }, + "literal": "内层" + } + ] + } + ] + }, + { + "kind": "item", + "span": { + "start": 26, + "end": 38 + }, + "children": [ + { + "kind": "paragraph", + "span": { + "start": 29, + "end": 38 + }, + "children": [ + { + "kind": "text", + "span": { + "start": 29, + "end": 38 + }, + "literal": "内层二" + } + ] + } + ] + } + ] + } + ] + }, + { + "kind": "item", + "span": { + "start": 39, + "end": 51 + }, + "children": [ + { + "kind": "paragraph", + "span": { + "start": 42, + "end": 51 + }, + "children": [ + { + "kind": "text", + "span": { + "start": 42, + "end": 51 + }, + "literal": "外层二" + } + ] + } + ] + } + ] + } + ] +} diff --git a/tests/conformance/ast/074-ordered-nested.mq.md b/tests/conformance/ast/074-ordered-nested.mq.md new file mode 100644 index 0000000..4721295 --- /dev/null +++ b/tests/conformance/ast/074-ordered-nested.mq.md @@ -0,0 +1,4 @@ +1. 外层 + 1. 内层 + 2. 内层二 +2. 外层二 diff --git a/tests/conformance/ast/075-list-tight.ast.json b/tests/conformance/ast/075-list-tight.ast.json new file mode 100644 index 0000000..5a71cdc --- /dev/null +++ b/tests/conformance/ast/075-list-tight.ast.json @@ -0,0 +1,98 @@ +{ + "kind": "document", + "span": { + "start": 0, + "end": 11 + }, + "children": [ + { + "kind": "list", + "ordered": false, + "tight": true, + "span": { + "start": 0, + "end": 11 + }, + "children": [ + { + "kind": "item", + "span": { + "start": 0, + "end": 3 + }, + "children": [ + { + "kind": "paragraph", + "span": { + "start": 2, + "end": 3 + }, + "children": [ + { + "kind": "text", + "span": { + "start": 2, + "end": 3 + }, + "literal": "a" + } + ] + } + ] + }, + { + "kind": "item", + "span": { + "start": 4, + "end": 7 + }, + "children": [ + { + "kind": "paragraph", + "span": { + "start": 6, + "end": 7 + }, + "children": [ + { + "kind": "text", + "span": { + "start": 6, + "end": 7 + }, + "literal": "b" + } + ] + } + ] + }, + { + "kind": "item", + "span": { + "start": 8, + "end": 11 + }, + "children": [ + { + "kind": "paragraph", + "span": { + "start": 10, + "end": 11 + }, + "children": [ + { + "kind": "text", + "span": { + "start": 10, + "end": 11 + }, + "literal": "c" + } + ] + } + ] + } + ] + } + ] +} diff --git a/tests/conformance/ast/075-list-tight.mq.md b/tests/conformance/ast/075-list-tight.mq.md new file mode 100644 index 0000000..d729eb6 --- /dev/null +++ b/tests/conformance/ast/075-list-tight.mq.md @@ -0,0 +1,3 @@ +- a +- b +- c diff --git a/tests/conformance/ast/076-list-loose.ast.json b/tests/conformance/ast/076-list-loose.ast.json new file mode 100644 index 0000000..4e51e2b --- /dev/null +++ b/tests/conformance/ast/076-list-loose.ast.json @@ -0,0 +1,98 @@ +{ + "kind": "document", + "span": { + "start": 0, + "end": 13 + }, + "children": [ + { + "kind": "list", + "ordered": false, + "tight": false, + "span": { + "start": 0, + "end": 13 + }, + "children": [ + { + "kind": "item", + "span": { + "start": 0, + "end": 3 + }, + "children": [ + { + "kind": "paragraph", + "span": { + "start": 2, + "end": 3 + }, + "children": [ + { + "kind": "text", + "span": { + "start": 2, + "end": 3 + }, + "literal": "a" + } + ] + } + ] + }, + { + "kind": "item", + "span": { + "start": 5, + "end": 8 + }, + "children": [ + { + "kind": "paragraph", + "span": { + "start": 7, + "end": 8 + }, + "children": [ + { + "kind": "text", + "span": { + "start": 7, + "end": 8 + }, + "literal": "b" + } + ] + } + ] + }, + { + "kind": "item", + "span": { + "start": 10, + "end": 13 + }, + "children": [ + { + "kind": "paragraph", + "span": { + "start": 12, + "end": 13 + }, + "children": [ + { + "kind": "text", + "span": { + "start": 12, + "end": 13 + }, + "literal": "c" + } + ] + } + ] + } + ] + } + ] +} diff --git a/tests/conformance/ast/076-list-loose.mq.md b/tests/conformance/ast/076-list-loose.mq.md new file mode 100644 index 0000000..6504014 --- /dev/null +++ b/tests/conformance/ast/076-list-loose.mq.md @@ -0,0 +1,5 @@ +- a + +- b + +- c diff --git a/tests/conformance/ast/077-task-list.ast.json b/tests/conformance/ast/077-task-list.ast.json new file mode 100644 index 0000000..00c6048 --- /dev/null +++ b/tests/conformance/ast/077-task-list.ast.json @@ -0,0 +1,74 @@ +{ + "kind": "document", + "span": { + "start": 0, + "end": 28 + }, + "children": [ + { + "kind": "list", + "ordered": false, + "tight": true, + "span": { + "start": 0, + "end": 28 + }, + "children": [ + { + "kind": "item", + "task": true, + "span": { + "start": 0, + "end": 12 + }, + "children": [ + { + "kind": "paragraph", + "span": { + "start": 6, + "end": 12 + }, + "children": [ + { + "kind": "text", + "span": { + "start": 6, + "end": 12 + }, + "literal": "完成" + } + ] + } + ] + }, + { + "kind": "item", + "task": false, + "span": { + "start": 13, + "end": 28 + }, + "children": [ + { + "kind": "paragraph", + "span": { + "start": 19, + "end": 28 + }, + "children": [ + { + "kind": "text", + "span": { + "start": 19, + "end": 28 + }, + "literal": "未完成" + } + ] + } + ] + } + ] + } + ] +} diff --git a/tests/conformance/ast/077-task-list.mq.md b/tests/conformance/ast/077-task-list.mq.md new file mode 100644 index 0000000..4d17d8e --- /dev/null +++ b/tests/conformance/ast/077-task-list.mq.md @@ -0,0 +1,2 @@ +- [x] 完成 +- [ ] 未完成 diff --git a/tests/conformance/ast/078-list-item-multiple-paragraphs.ast.json b/tests/conformance/ast/078-list-item-multiple-paragraphs.ast.json new file mode 100644 index 0000000..69a1d8a --- /dev/null +++ b/tests/conformance/ast/078-list-item-multiple-paragraphs.ast.json @@ -0,0 +1,89 @@ +{ + "kind": "document", + "span": { + "start": 0, + "end": 36 + }, + "children": [ + { + "kind": "list", + "ordered": false, + "tight": false, + "span": { + "start": 0, + "end": 36 + }, + "children": [ + { + "kind": "item", + "span": { + "start": 0, + "end": 24 + }, + "children": [ + { + "kind": "paragraph", + "span": { + "start": 2, + "end": 11 + }, + "children": [ + { + "kind": "text", + "span": { + "start": 2, + "end": 11 + }, + "literal": "第一段" + } + ] + }, + { + "kind": "paragraph", + "span": { + "start": 15, + "end": 24 + }, + "children": [ + { + "kind": "text", + "span": { + "start": 15, + "end": 24 + }, + "literal": "第二段" + } + ] + } + ] + }, + { + "kind": "item", + "span": { + "start": 25, + "end": 36 + }, + "children": [ + { + "kind": "paragraph", + "span": { + "start": 27, + "end": 36 + }, + "children": [ + { + "kind": "text", + "span": { + "start": 27, + "end": 36 + }, + "literal": "下一项" + } + ] + } + ] + } + ] + } + ] +} diff --git a/tests/conformance/ast/078-list-item-multiple-paragraphs.mq.md b/tests/conformance/ast/078-list-item-multiple-paragraphs.mq.md new file mode 100644 index 0000000..bcda685 --- /dev/null +++ b/tests/conformance/ast/078-list-item-multiple-paragraphs.mq.md @@ -0,0 +1,4 @@ +- 第一段 + + 第二段 +- 下一项 diff --git a/tests/conformance/ast/079-list-item-with-blockquote.ast.json b/tests/conformance/ast/079-list-item-with-blockquote.ast.json new file mode 100644 index 0000000..dd24b6d --- /dev/null +++ b/tests/conformance/ast/079-list-item-with-blockquote.ast.json @@ -0,0 +1,72 @@ +{ + "kind": "document", + "span": { + "start": 0, + "end": 26 + }, + "children": [ + { + "kind": "list", + "ordered": false, + "tight": false, + "span": { + "start": 0, + "end": 26 + }, + "children": [ + { + "kind": "item", + "span": { + "start": 0, + "end": 26 + }, + "children": [ + { + "kind": "paragraph", + "span": { + "start": 2, + "end": 8 + }, + "children": [ + { + "kind": "text", + "span": { + "start": 2, + "end": 8 + }, + "literal": "项目" + } + ] + }, + { + "kind": "block_quote", + "span": { + "start": 12, + "end": 26 + }, + "children": [ + { + "kind": "paragraph", + "span": { + "start": 14, + "end": 26 + }, + "children": [ + { + "kind": "text", + "span": { + "start": 14, + "end": 26 + }, + "literal": "引用内容" + } + ] + } + ] + } + ] + } + ] + } + ] +} diff --git a/tests/conformance/ast/079-list-item-with-blockquote.mq.md b/tests/conformance/ast/079-list-item-with-blockquote.mq.md new file mode 100644 index 0000000..99ed778 --- /dev/null +++ b/tests/conformance/ast/079-list-item-with-blockquote.mq.md @@ -0,0 +1,3 @@ +- 项目 + + > 引用内容 diff --git a/tests/conformance/ast/080-list-item-with-fence.ast.json b/tests/conformance/ast/080-list-item-with-fence.ast.json new file mode 100644 index 0000000..7ecbcdf --- /dev/null +++ b/tests/conformance/ast/080-list-item-with-fence.ast.json @@ -0,0 +1,57 @@ +{ + "kind": "document", + "span": { + "start": 0, + "end": 37 + }, + "children": [ + { + "kind": "list", + "ordered": true, + "start": 1, + "tight": false, + "span": { + "start": 0, + "end": 37 + }, + "children": [ + { + "kind": "item", + "span": { + "start": 0, + "end": 37 + }, + "children": [ + { + "kind": "paragraph", + "span": { + "start": 3, + "end": 9 + }, + "children": [ + { + "kind": "text", + "span": { + "start": 3, + "end": 9 + }, + "literal": "步骤" + } + ] + }, + { + "kind": "code_block", + "fenced": true, + "info": "sh", + "span": { + "start": 14, + "end": 37 + }, + "literal": "echo hi\n" + } + ] + } + ] + } + ] +} diff --git a/tests/conformance/ast/080-list-item-with-fence.mq.md b/tests/conformance/ast/080-list-item-with-fence.mq.md new file mode 100644 index 0000000..d547935 --- /dev/null +++ b/tests/conformance/ast/080-list-item-with-fence.mq.md @@ -0,0 +1,5 @@ +1. 步骤 + + ```sh + echo hi + ``` diff --git a/tests/conformance/ast/081-list-item-multiline.ast.json b/tests/conformance/ast/081-list-item-multiline.ast.json new file mode 100644 index 0000000..f3ee08f --- /dev/null +++ b/tests/conformance/ast/081-list-item-multiline.ast.json @@ -0,0 +1,87 @@ +{ + "kind": "document", + "span": { + "start": 0, + "end": 35 + }, + "children": [ + { + "kind": "list", + "ordered": false, + "tight": true, + "span": { + "start": 0, + "end": 35 + }, + "children": [ + { + "kind": "item", + "span": { + "start": 0, + "end": 23 + }, + "children": [ + { + "kind": "paragraph", + "span": { + "start": 2, + "end": 23 + }, + "children": [ + { + "kind": "text", + "span": { + "start": 2, + "end": 11 + }, + "literal": "第一行" + }, + { + "kind": "soft_break", + "span": { + "start": 11, + "end": 12 + } + }, + { + "kind": "text", + "span": { + "start": 14, + "end": 23 + }, + "literal": "第二行" + } + ] + } + ] + }, + { + "kind": "item", + "span": { + "start": 24, + "end": 35 + }, + "children": [ + { + "kind": "paragraph", + "span": { + "start": 26, + "end": 35 + }, + "children": [ + { + "kind": "text", + "span": { + "start": 26, + "end": 35 + }, + "literal": "下一项" + } + ] + } + ] + } + ] + } + ] +} diff --git a/tests/conformance/ast/081-list-item-multiline.mq.md b/tests/conformance/ast/081-list-item-multiline.mq.md new file mode 100644 index 0000000..79edea9 --- /dev/null +++ b/tests/conformance/ast/081-list-item-multiline.mq.md @@ -0,0 +1,3 @@ +- 第一行 + 第二行 +- 下一项 diff --git a/tests/conformance/ast/082-ordered-item-branch-shape.ast.json b/tests/conformance/ast/082-ordered-item-branch-shape.ast.json new file mode 100644 index 0000000..a6749d8 --- /dev/null +++ b/tests/conformance/ast/082-ordered-item-branch-shape.ast.json @@ -0,0 +1,127 @@ +{ + "kind": "document", + "span": { + "start": 0, + "end": 62 + }, + "children": [ + { + "kind": "list", + "ordered": true, + "start": 1, + "tight": false, + "span": { + "start": 0, + "end": 62 + }, + "children": [ + { + "kind": "item", + "span": { + "start": 0, + "end": 30 + }, + "children": [ + { + "kind": "paragraph", + "span": { + "start": 3, + "end": 10 + }, + "children": [ + { + "kind": "code", + "ticks": 1, + "span": { + "start": 3, + "end": 10 + }, + "literal": "n < 0" + } + ] + }, + { + "kind": "paragraph", + "span": { + "start": 15, + "end": 30 + }, + "children": [ + { + "kind": "strong", + "span": { + "start": 15, + "end": 30 + }, + "children": [ + { + "kind": "text", + "span": { + "start": 17, + "end": 28 + }, + "literal": "结果 = -1" + } + ] + } + ] + } + ] + }, + { + "kind": "item", + "span": { + "start": 32, + "end": 62 + }, + "children": [ + { + "kind": "paragraph", + "span": { + "start": 35, + "end": 43 + }, + "children": [ + { + "kind": "code", + "ticks": 1, + "span": { + "start": 35, + "end": 43 + }, + "literal": "n == 0" + } + ] + }, + { + "kind": "paragraph", + "span": { + "start": 48, + "end": 62 + }, + "children": [ + { + "kind": "strong", + "span": { + "start": 48, + "end": 62 + }, + "children": [ + { + "kind": "text", + "span": { + "start": 50, + "end": 60 + }, + "literal": "结果 = 0" + } + ] + } + ] + } + ] + } + ] + } + ] +} diff --git a/tests/conformance/ast/082-ordered-item-branch-shape.mq.md b/tests/conformance/ast/082-ordered-item-branch-shape.mq.md new file mode 100644 index 0000000..322663a --- /dev/null +++ b/tests/conformance/ast/082-ordered-item-branch-shape.mq.md @@ -0,0 +1,7 @@ +1. `n < 0` + + **结果 = -1** + +2. `n == 0` + + **结果 = 0** diff --git a/tests/conformance/ast/083-bullet-item-loop-shape.ast.json b/tests/conformance/ast/083-bullet-item-loop-shape.ast.json new file mode 100644 index 0000000..df21ed2 --- /dev/null +++ b/tests/conformance/ast/083-bullet-item-loop-shape.ast.json @@ -0,0 +1,99 @@ +{ + "kind": "document", + "span": { + "start": 0, + "end": 41 + }, + "children": [ + { + "kind": "list", + "ordered": false, + "tight": false, + "span": { + "start": 0, + "end": 41 + }, + "children": [ + { + "kind": "item", + "span": { + "start": 0, + "end": 41 + }, + "children": [ + { + "kind": "paragraph", + "span": { + "start": 2, + "end": 9 + }, + "children": [ + { + "kind": "code", + "ticks": 1, + "span": { + "start": 2, + "end": 9 + }, + "literal": "n > 0" + } + ] + }, + { + "kind": "block_quote", + "span": { + "start": 13, + "end": 24 + }, + "children": [ + { + "kind": "paragraph", + "span": { + "start": 15, + "end": 24 + }, + "children": [ + { + "kind": "text", + "span": { + "start": 15, + "end": 24 + }, + "literal": "打印(n)" + } + ] + } + ] + }, + { + "kind": "paragraph", + "span": { + "start": 28, + "end": 41 + }, + "children": [ + { + "kind": "strong", + "span": { + "start": 28, + "end": 41 + }, + "children": [ + { + "kind": "text", + "span": { + "start": 30, + "end": 39 + }, + "literal": "n = n - 1" + } + ] + } + ] + } + ] + } + ] + } + ] +} diff --git a/tests/conformance/ast/083-bullet-item-loop-shape.mq.md b/tests/conformance/ast/083-bullet-item-loop-shape.mq.md new file mode 100644 index 0000000..fe7c6fd --- /dev/null +++ b/tests/conformance/ast/083-bullet-item-loop-shape.mq.md @@ -0,0 +1,5 @@ +- `n > 0` + + > 打印(n) + + **n = n - 1** diff --git a/tests/conformance/ast/084-quote-single-paragraph.ast.json b/tests/conformance/ast/084-quote-single-paragraph.ast.json new file mode 100644 index 0000000..ec87e9d --- /dev/null +++ b/tests/conformance/ast/084-quote-single-paragraph.ast.json @@ -0,0 +1,35 @@ +{ + "kind": "document", + "span": { + "start": 0, + "end": 20 + }, + "children": [ + { + "kind": "block_quote", + "span": { + "start": 0, + "end": 20 + }, + "children": [ + { + "kind": "paragraph", + "span": { + "start": 2, + "end": 20 + }, + "children": [ + { + "kind": "text", + "span": { + "start": 2, + "end": 20 + }, + "literal": "引用一段话。" + } + ] + } + ] + } + ] +} diff --git a/tests/conformance/ast/084-quote-single-paragraph.mq.md b/tests/conformance/ast/084-quote-single-paragraph.mq.md new file mode 100644 index 0000000..1a65750 --- /dev/null +++ b/tests/conformance/ast/084-quote-single-paragraph.mq.md @@ -0,0 +1 @@ +> 引用一段话。 diff --git a/tests/conformance/ast/085-quote-nested.ast.json b/tests/conformance/ast/085-quote-nested.ast.json new file mode 100644 index 0000000..c8e981d --- /dev/null +++ b/tests/conformance/ast/085-quote-nested.ast.json @@ -0,0 +1,61 @@ +{ + "kind": "document", + "span": { + "start": 0, + "end": 33 + }, + "children": [ + { + "kind": "block_quote", + "span": { + "start": 0, + "end": 33 + }, + "children": [ + { + "kind": "paragraph", + "span": { + "start": 2, + "end": 14 + }, + "children": [ + { + "kind": "text", + "span": { + "start": 2, + "end": 14 + }, + "literal": "外层引用" + } + ] + }, + { + "kind": "block_quote", + "span": { + "start": 19, + "end": 33 + }, + "children": [ + { + "kind": "paragraph", + "span": { + "start": 21, + "end": 33 + }, + "children": [ + { + "kind": "text", + "span": { + "start": 21, + "end": 33 + }, + "literal": "内层引用" + } + ] + } + ] + } + ] + } + ] +} diff --git a/tests/conformance/ast/085-quote-nested.mq.md b/tests/conformance/ast/085-quote-nested.mq.md new file mode 100644 index 0000000..5929ed1 --- /dev/null +++ b/tests/conformance/ast/085-quote-nested.mq.md @@ -0,0 +1,3 @@ +> 外层引用 +> +> > 内层引用 diff --git a/tests/conformance/ast/086-quote-multiple-paragraphs.ast.json b/tests/conformance/ast/086-quote-multiple-paragraphs.ast.json new file mode 100644 index 0000000..2563760 --- /dev/null +++ b/tests/conformance/ast/086-quote-multiple-paragraphs.ast.json @@ -0,0 +1,52 @@ +{ + "kind": "document", + "span": { + "start": 0, + "end": 25 + }, + "children": [ + { + "kind": "block_quote", + "span": { + "start": 0, + "end": 25 + }, + "children": [ + { + "kind": "paragraph", + "span": { + "start": 2, + "end": 11 + }, + "children": [ + { + "kind": "text", + "span": { + "start": 2, + "end": 11 + }, + "literal": "第一段" + } + ] + }, + { + "kind": "paragraph", + "span": { + "start": 16, + "end": 25 + }, + "children": [ + { + "kind": "text", + "span": { + "start": 16, + "end": 25 + }, + "literal": "第二段" + } + ] + } + ] + } + ] +} diff --git a/tests/conformance/ast/086-quote-multiple-paragraphs.mq.md b/tests/conformance/ast/086-quote-multiple-paragraphs.mq.md new file mode 100644 index 0000000..775bdbb --- /dev/null +++ b/tests/conformance/ast/086-quote-multiple-paragraphs.mq.md @@ -0,0 +1,3 @@ +> 第一段 +> +> 第二段 diff --git a/tests/conformance/ast/087-quote-with-code.ast.json b/tests/conformance/ast/087-quote-with-code.ast.json new file mode 100644 index 0000000..521263f --- /dev/null +++ b/tests/conformance/ast/087-quote-with-code.ast.json @@ -0,0 +1,28 @@ +{ + "kind": "document", + "span": { + "start": 0, + "end": 18 + }, + "children": [ + { + "kind": "block_quote", + "span": { + "start": 0, + "end": 18 + }, + "children": [ + { + "kind": "code_block", + "fenced": true, + "info": "", + "span": { + "start": 2, + "end": 18 + }, + "literal": "code\n" + } + ] + } + ] +} diff --git a/tests/conformance/ast/087-quote-with-code.mq.md b/tests/conformance/ast/087-quote-with-code.mq.md new file mode 100644 index 0000000..adfdc1d --- /dev/null +++ b/tests/conformance/ast/087-quote-with-code.mq.md @@ -0,0 +1,3 @@ +> ``` +> code +> ``` diff --git a/tests/conformance/ast/088-quote-with-list.ast.json b/tests/conformance/ast/088-quote-with-list.ast.json new file mode 100644 index 0000000..9cda731 --- /dev/null +++ b/tests/conformance/ast/088-quote-with-list.ast.json @@ -0,0 +1,81 @@ +{ + "kind": "document", + "span": { + "start": 0, + "end": 27 + }, + "children": [ + { + "kind": "block_quote", + "span": { + "start": 0, + "end": 27 + }, + "children": [ + { + "kind": "list", + "ordered": false, + "tight": true, + "span": { + "start": 2, + "end": 27 + }, + "children": [ + { + "kind": "item", + "span": { + "start": 2, + "end": 13 + }, + "children": [ + { + "kind": "paragraph", + "span": { + "start": 4, + "end": 13 + }, + "children": [ + { + "kind": "text", + "span": { + "start": 4, + "end": 13 + }, + "literal": "项目一" + } + ] + } + ] + }, + { + "kind": "item", + "span": { + "start": 16, + "end": 27 + }, + "children": [ + { + "kind": "paragraph", + "span": { + "start": 18, + "end": 27 + }, + "children": [ + { + "kind": "text", + "span": { + "start": 18, + "end": 27 + }, + "literal": "项目二" + } + ] + } + ] + } + ] + } + ] + } + ] +} diff --git a/tests/conformance/ast/088-quote-with-list.mq.md b/tests/conformance/ast/088-quote-with-list.mq.md new file mode 100644 index 0000000..e087375 --- /dev/null +++ b/tests/conformance/ast/088-quote-with-list.mq.md @@ -0,0 +1,2 @@ +> - 项目一 +> - 项目二 diff --git a/tests/conformance/ast/089-quote-call-shape.ast.json b/tests/conformance/ast/089-quote-call-shape.ast.json new file mode 100644 index 0000000..148c2ee --- /dev/null +++ b/tests/conformance/ast/089-quote-call-shape.ast.json @@ -0,0 +1,35 @@ +{ + "kind": "document", + "span": { + "start": 0, + "end": 18 + }, + "children": [ + { + "kind": "block_quote", + "span": { + "start": 0, + "end": 18 + }, + "children": [ + { + "kind": "paragraph", + "span": { + "start": 2, + "end": 18 + }, + "children": [ + { + "kind": "text", + "span": { + "start": 2, + "end": 18 + }, + "literal": "打印(\"你好\")" + } + ] + } + ] + } + ] +} diff --git a/tests/conformance/ast/089-quote-call-shape.mq.md b/tests/conformance/ast/089-quote-call-shape.mq.md new file mode 100644 index 0000000..ee8e485 --- /dev/null +++ b/tests/conformance/ast/089-quote-call-shape.mq.md @@ -0,0 +1 @@ +> 打印("你好") diff --git a/tests/conformance/ast/090-quote-lazy-continuation.ast.json b/tests/conformance/ast/090-quote-lazy-continuation.ast.json new file mode 100644 index 0000000..9b7d965 --- /dev/null +++ b/tests/conformance/ast/090-quote-lazy-continuation.ast.json @@ -0,0 +1,50 @@ +{ + "kind": "document", + "span": { + "start": 0, + "end": 21 + }, + "children": [ + { + "kind": "block_quote", + "span": { + "start": 0, + "end": 21 + }, + "children": [ + { + "kind": "paragraph", + "span": { + "start": 2, + "end": 21 + }, + "children": [ + { + "kind": "text", + "span": { + "start": 2, + "end": 11 + }, + "literal": "第一行" + }, + { + "kind": "soft_break", + "span": { + "start": 11, + "end": 12 + } + }, + { + "kind": "text", + "span": { + "start": 12, + "end": 21 + }, + "literal": "继续行" + } + ] + } + ] + } + ] +} diff --git a/tests/conformance/ast/090-quote-lazy-continuation.mq.md b/tests/conformance/ast/090-quote-lazy-continuation.mq.md new file mode 100644 index 0000000..68e88f2 --- /dev/null +++ b/tests/conformance/ast/090-quote-lazy-continuation.mq.md @@ -0,0 +1,2 @@ +> 第一行 +继续行 diff --git a/tests/conformance/ast/091-link-inline.ast.json b/tests/conformance/ast/091-link-inline.ast.json new file mode 100644 index 0000000..210457b --- /dev/null +++ b/tests/conformance/ast/091-link-inline.ast.json @@ -0,0 +1,37 @@ +{ + "kind": "document", + "span": { + "start": 0, + "end": 29 + }, + "children": [ + { + "kind": "paragraph", + "span": { + "start": 0, + "end": 29 + }, + "children": [ + { + "kind": "link", + "url": "https://example.com", + "title": "", + "span": { + "start": 0, + "end": 29 + }, + "children": [ + { + "kind": "text", + "span": { + "start": 1, + "end": 7 + }, + "literal": "示例" + } + ] + } + ] + } + ] +} diff --git a/tests/conformance/ast/091-link-inline.mq.md b/tests/conformance/ast/091-link-inline.mq.md new file mode 100644 index 0000000..9c6d775 --- /dev/null +++ b/tests/conformance/ast/091-link-inline.mq.md @@ -0,0 +1 @@ +[示例](https://example.com) diff --git a/tests/conformance/ast/092-link-with-title.ast.json b/tests/conformance/ast/092-link-with-title.ast.json new file mode 100644 index 0000000..e544ba6 --- /dev/null +++ b/tests/conformance/ast/092-link-with-title.ast.json @@ -0,0 +1,37 @@ +{ + "kind": "document", + "span": { + "start": 0, + "end": 38 + }, + "children": [ + { + "kind": "paragraph", + "span": { + "start": 0, + "end": 38 + }, + "children": [ + { + "kind": "link", + "url": "https://example.com", + "title": "标题", + "span": { + "start": 0, + "end": 38 + }, + "children": [ + { + "kind": "text", + "span": { + "start": 1, + "end": 7 + }, + "literal": "示例" + } + ] + } + ] + } + ] +} diff --git a/tests/conformance/ast/092-link-with-title.mq.md b/tests/conformance/ast/092-link-with-title.mq.md new file mode 100644 index 0000000..0dccaae --- /dev/null +++ b/tests/conformance/ast/092-link-with-title.mq.md @@ -0,0 +1 @@ +[示例](https://example.com "标题") diff --git a/tests/conformance/ast/093-reference-link.ast.json b/tests/conformance/ast/093-reference-link.ast.json new file mode 100644 index 0000000..35dab8f --- /dev/null +++ b/tests/conformance/ast/093-reference-link.ast.json @@ -0,0 +1,37 @@ +{ + "kind": "document", + "span": { + "start": 0, + "end": 56 + }, + "children": [ + { + "kind": "paragraph", + "span": { + "start": 0, + "end": 13 + }, + "children": [ + { + "kind": "link", + "url": "https://example.com", + "title": "引用标题", + "span": { + "start": 0, + "end": 13 + }, + "children": [ + { + "kind": "text", + "span": { + "start": 1, + "end": 7 + }, + "literal": "示例" + } + ] + } + ] + } + ] +} diff --git a/tests/conformance/ast/093-reference-link.mq.md b/tests/conformance/ast/093-reference-link.mq.md new file mode 100644 index 0000000..22a6045 --- /dev/null +++ b/tests/conformance/ast/093-reference-link.mq.md @@ -0,0 +1,3 @@ +[示例][ref] + +[ref]: https://example.com "引用标题" diff --git a/tests/conformance/ast/094-reference-link-collapsed.ast.json b/tests/conformance/ast/094-reference-link-collapsed.ast.json new file mode 100644 index 0000000..45ef8ac --- /dev/null +++ b/tests/conformance/ast/094-reference-link-collapsed.ast.json @@ -0,0 +1,37 @@ +{ + "kind": "document", + "span": { + "start": 0, + "end": 41 + }, + "children": [ + { + "kind": "paragraph", + "span": { + "start": 0, + "end": 10 + }, + "children": [ + { + "kind": "link", + "url": "https://example.com", + "title": "", + "span": { + "start": 0, + "end": 10 + }, + "children": [ + { + "kind": "text", + "span": { + "start": 1, + "end": 7 + }, + "literal": "示例" + } + ] + } + ] + } + ] +} diff --git a/tests/conformance/ast/094-reference-link-collapsed.mq.md b/tests/conformance/ast/094-reference-link-collapsed.mq.md new file mode 100644 index 0000000..38f056e --- /dev/null +++ b/tests/conformance/ast/094-reference-link-collapsed.mq.md @@ -0,0 +1,3 @@ +[示例][] + +[示例]: https://example.com diff --git a/tests/conformance/ast/095-reference-link-shortcut.ast.json b/tests/conformance/ast/095-reference-link-shortcut.ast.json new file mode 100644 index 0000000..8fb6fdf --- /dev/null +++ b/tests/conformance/ast/095-reference-link-shortcut.ast.json @@ -0,0 +1,37 @@ +{ + "kind": "document", + "span": { + "start": 0, + "end": 39 + }, + "children": [ + { + "kind": "paragraph", + "span": { + "start": 0, + "end": 8 + }, + "children": [ + { + "kind": "link", + "url": "https://example.com", + "title": "", + "span": { + "start": 0, + "end": 8 + }, + "children": [ + { + "kind": "text", + "span": { + "start": 1, + "end": 7 + }, + "literal": "示例" + } + ] + } + ] + } + ] +} diff --git a/tests/conformance/ast/095-reference-link-shortcut.mq.md b/tests/conformance/ast/095-reference-link-shortcut.mq.md new file mode 100644 index 0000000..ba5442e --- /dev/null +++ b/tests/conformance/ast/095-reference-link-shortcut.mq.md @@ -0,0 +1,3 @@ +[示例] + +[示例]: https://example.com diff --git a/tests/conformance/ast/096-image-basic.ast.json b/tests/conformance/ast/096-image-basic.ast.json new file mode 100644 index 0000000..16db36d --- /dev/null +++ b/tests/conformance/ast/096-image-basic.ast.json @@ -0,0 +1,37 @@ +{ + "kind": "document", + "span": { + "start": 0, + "end": 28 + }, + "children": [ + { + "kind": "paragraph", + "span": { + "start": 0, + "end": 28 + }, + "children": [ + { + "kind": "image", + "url": "./image.png", + "title": "", + "span": { + "start": 0, + "end": 28 + }, + "children": [ + { + "kind": "text", + "span": { + "start": 2, + "end": 14 + }, + "literal": "替代文本" + } + ] + } + ] + } + ] +} diff --git a/tests/conformance/ast/096-image-basic.mq.md b/tests/conformance/ast/096-image-basic.mq.md new file mode 100644 index 0000000..44bd4a5 --- /dev/null +++ b/tests/conformance/ast/096-image-basic.mq.md @@ -0,0 +1 @@ +![替代文本](./image.png) diff --git a/tests/conformance/ast/097-image-with-title.ast.json b/tests/conformance/ast/097-image-with-title.ast.json new file mode 100644 index 0000000..3236aab --- /dev/null +++ b/tests/conformance/ast/097-image-with-title.ast.json @@ -0,0 +1,37 @@ +{ + "kind": "document", + "span": { + "start": 0, + "end": 43 + }, + "children": [ + { + "kind": "paragraph", + "span": { + "start": 0, + "end": 43 + }, + "children": [ + { + "kind": "image", + "url": "./image.png", + "title": "图片标题", + "span": { + "start": 0, + "end": 43 + }, + "children": [ + { + "kind": "text", + "span": { + "start": 2, + "end": 14 + }, + "literal": "替代文本" + } + ] + } + ] + } + ] +} diff --git a/tests/conformance/ast/097-image-with-title.mq.md b/tests/conformance/ast/097-image-with-title.mq.md new file mode 100644 index 0000000..be6639b --- /dev/null +++ b/tests/conformance/ast/097-image-with-title.mq.md @@ -0,0 +1 @@ +![替代文本](./image.png "图片标题") diff --git a/tests/conformance/ast/098-link-with-emphasis.ast.json b/tests/conformance/ast/098-link-with-emphasis.ast.json new file mode 100644 index 0000000..78b9ca4 --- /dev/null +++ b/tests/conformance/ast/098-link-with-emphasis.ast.json @@ -0,0 +1,46 @@ +{ + "kind": "document", + "span": { + "start": 0, + "end": 39 + }, + "children": [ + { + "kind": "paragraph", + "span": { + "start": 0, + "end": 39 + }, + "children": [ + { + "kind": "link", + "url": "https://example.com", + "title": "", + "span": { + "start": 0, + "end": 39 + }, + "children": [ + { + "kind": "strong", + "span": { + "start": 1, + "end": 17 + }, + "children": [ + { + "kind": "text", + "span": { + "start": 3, + "end": 15 + }, + "literal": "加粗链接" + } + ] + } + ] + } + ] + } + ] +} diff --git a/tests/conformance/ast/098-link-with-emphasis.mq.md b/tests/conformance/ast/098-link-with-emphasis.mq.md new file mode 100644 index 0000000..3821520 --- /dev/null +++ b/tests/conformance/ast/098-link-with-emphasis.mq.md @@ -0,0 +1 @@ +[**加粗链接**](https://example.com) diff --git a/tests/conformance/ast/099-link-in-strong.ast.json b/tests/conformance/ast/099-link-in-strong.ast.json new file mode 100644 index 0000000..6be9a00 --- /dev/null +++ b/tests/conformance/ast/099-link-in-strong.ast.json @@ -0,0 +1,54 @@ +{ + "kind": "document", + "span": { + "start": 0, + "end": 36 + }, + "children": [ + { + "kind": "paragraph", + "span": { + "start": 0, + "end": 36 + }, + "children": [ + { + "kind": "strong", + "span": { + "start": 0, + "end": 36 + }, + "children": [ + { + "kind": "text", + "span": { + "start": 2, + "end": 5 + }, + "literal": "见" + }, + { + "kind": "link", + "url": "https://example.com", + "title": "", + "span": { + "start": 5, + "end": 34 + }, + "children": [ + { + "kind": "text", + "span": { + "start": 6, + "end": 12 + }, + "literal": "文档" + } + ] + } + ] + } + ] + } + ] +} diff --git a/tests/conformance/ast/099-link-in-strong.mq.md b/tests/conformance/ast/099-link-in-strong.mq.md new file mode 100644 index 0000000..6c1a016 --- /dev/null +++ b/tests/conformance/ast/099-link-in-strong.mq.md @@ -0,0 +1 @@ +**见[文档](https://example.com)** diff --git a/tests/conformance/ast/100-autolinks-disabled-behaviour.ast.json b/tests/conformance/ast/100-autolinks-disabled-behaviour.ast.json new file mode 100644 index 0000000..6383137 --- /dev/null +++ b/tests/conformance/ast/100-autolinks-disabled-behaviour.ast.json @@ -0,0 +1,64 @@ +{ + "kind": "document", + "span": { + "start": 0, + "end": 55 + }, + "children": [ + { + "kind": "paragraph", + "span": { + "start": 0, + "end": 55 + }, + "children": [ + { + "kind": "link", + "url": "https://example.com", + "title": "", + "span": { + "start": 0, + "end": 21 + }, + "children": [ + { + "kind": "text", + "span": { + "start": 1, + "end": 20 + }, + "literal": "https://example.com" + } + ] + }, + { + "kind": "text", + "span": { + "start": 21, + "end": 46 + }, + "literal": " 和 www.example.com 和 " + }, + { + "kind": "link", + "url": "mailto:a@b.com", + "title": "", + "span": { + "start": 46, + "end": 55 + }, + "children": [ + { + "kind": "text", + "span": { + "start": 47, + "end": 54 + }, + "literal": "a@b.com" + } + ] + } + ] + } + ] +} diff --git a/tests/conformance/ast/100-autolinks-disabled-behaviour.mq.md b/tests/conformance/ast/100-autolinks-disabled-behaviour.mq.md new file mode 100644 index 0000000..26aab42 --- /dev/null +++ b/tests/conformance/ast/100-autolinks-disabled-behaviour.mq.md @@ -0,0 +1 @@ + 和 www.example.com 和 diff --git a/tests/conformance/ast/101-link-with-fragment.ast.json b/tests/conformance/ast/101-link-with-fragment.ast.json new file mode 100644 index 0000000..37b027d --- /dev/null +++ b/tests/conformance/ast/101-link-with-fragment.ast.json @@ -0,0 +1,37 @@ +{ + "kind": "document", + "span": { + "start": 0, + "end": 35 + }, + "children": [ + { + "kind": "paragraph", + "span": { + "start": 0, + "end": 35 + }, + "children": [ + { + "kind": "link", + "url": "./math.mq.md#计算面积", + "title": "", + "span": { + "start": 0, + "end": 35 + }, + "children": [ + { + "kind": "text", + "span": { + "start": 1, + "end": 7 + }, + "literal": "函数" + } + ] + } + ] + } + ] +} diff --git a/tests/conformance/ast/101-link-with-fragment.mq.md b/tests/conformance/ast/101-link-with-fragment.mq.md new file mode 100644 index 0000000..88632b4 --- /dev/null +++ b/tests/conformance/ast/101-link-with-fragment.mq.md @@ -0,0 +1 @@ +[函数](./math.mq.md#计算面积) diff --git a/tests/conformance/ast/102-inline-html.ast.json b/tests/conformance/ast/102-inline-html.ast.json new file mode 100644 index 0000000..1bc1009 --- /dev/null +++ b/tests/conformance/ast/102-inline-html.ast.json @@ -0,0 +1,58 @@ +{ + "kind": "document", + "span": { + "start": 0, + "end": 44 + }, + "children": [ + { + "kind": "paragraph", + "span": { + "start": 0, + "end": 44 + }, + "children": [ + { + "kind": "text", + "span": { + "start": 0, + "end": 7 + }, + "literal": "行内 " + }, + { + "kind": "html_inline", + "span": { + "start": 7, + "end": 23 + }, + "literal": "" + }, + { + "kind": "text", + "span": { + "start": 23, + "end": 27 + }, + "literal": "HTML" + }, + { + "kind": "html_inline", + "span": { + "start": 27, + "end": 34 + }, + "literal": "" + }, + { + "kind": "text", + "span": { + "start": 34, + "end": 44 + }, + "literal": " 结束。" + } + ] + } + ] +} diff --git a/tests/conformance/ast/102-inline-html.mq.md b/tests/conformance/ast/102-inline-html.mq.md new file mode 100644 index 0000000..90f6cea --- /dev/null +++ b/tests/conformance/ast/102-inline-html.mq.md @@ -0,0 +1 @@ +行内 HTML 结束。 diff --git a/tests/conformance/ast/103-block-html.ast.json b/tests/conformance/ast/103-block-html.ast.json new file mode 100644 index 0000000..92262b1 --- /dev/null +++ b/tests/conformance/ast/103-block-html.ast.json @@ -0,0 +1,17 @@ +{ + "kind": "document", + "span": { + "start": 0, + "end": 37 + }, + "children": [ + { + "kind": "html_block", + "span": { + "start": 0, + "end": 37 + }, + "literal": "
\n块级 HTML\n
\n" + } + ] +} diff --git a/tests/conformance/ast/103-block-html.mq.md b/tests/conformance/ast/103-block-html.mq.md new file mode 100644 index 0000000..b61ff4c --- /dev/null +++ b/tests/conformance/ast/103-block-html.mq.md @@ -0,0 +1,3 @@ +
+块级 HTML +
diff --git a/tests/conformance/ast/104-html-comment.ast.json b/tests/conformance/ast/104-html-comment.ast.json new file mode 100644 index 0000000..8351986 --- /dev/null +++ b/tests/conformance/ast/104-html-comment.ast.json @@ -0,0 +1,34 @@ +{ + "kind": "document", + "span": { + "start": 0, + "end": 23 + }, + "children": [ + { + "kind": "html_block", + "span": { + "start": 0, + "end": 15 + }, + "literal": "\n" + }, + { + "kind": "paragraph", + "span": { + "start": 17, + "end": 23 + }, + "children": [ + { + "kind": "text", + "span": { + "start": 17, + "end": 23 + }, + "literal": "正文" + } + ] + } + ] +} diff --git a/tests/conformance/ast/104-html-comment.mq.md b/tests/conformance/ast/104-html-comment.mq.md new file mode 100644 index 0000000..0f59587 --- /dev/null +++ b/tests/conformance/ast/104-html-comment.mq.md @@ -0,0 +1,3 @@ + + +正文 diff --git a/tests/conformance/ast/105-html-script-block.ast.json b/tests/conformance/ast/105-html-script-block.ast.json new file mode 100644 index 0000000..924a6dc --- /dev/null +++ b/tests/conformance/ast/105-html-script-block.ast.json @@ -0,0 +1,17 @@ +{ + "kind": "document", + "span": { + "start": 0, + "end": 34 + }, + "children": [ + { + "kind": "html_block", + "span": { + "start": 0, + "end": 34 + }, + "literal": "\n" + } + ] +} diff --git a/tests/conformance/ast/105-html-script-block.mq.md b/tests/conformance/ast/105-html-script-block.mq.md new file mode 100644 index 0000000..0ab96c2 --- /dev/null +++ b/tests/conformance/ast/105-html-script-block.mq.md @@ -0,0 +1,3 @@ + diff --git a/tests/conformance/ast/106-html-inline-break.ast.json b/tests/conformance/ast/106-html-inline-break.ast.json new file mode 100644 index 0000000..6148de8 --- /dev/null +++ b/tests/conformance/ast/106-html-inline-break.ast.json @@ -0,0 +1,42 @@ +{ + "kind": "document", + "span": { + "start": 0, + "end": 16 + }, + "children": [ + { + "kind": "paragraph", + "span": { + "start": 0, + "end": 16 + }, + "children": [ + { + "kind": "text", + "span": { + "start": 0, + "end": 6 + }, + "literal": "开始" + }, + { + "kind": "html_inline", + "span": { + "start": 6, + "end": 10 + }, + "literal": "
" + }, + { + "kind": "text", + "span": { + "start": 10, + "end": 16 + }, + "literal": "结束" + } + ] + } + ] +} diff --git a/tests/conformance/ast/106-html-inline-break.mq.md b/tests/conformance/ast/106-html-inline-break.mq.md new file mode 100644 index 0000000..fb7e9c9 --- /dev/null +++ b/tests/conformance/ast/106-html-inline-break.mq.md @@ -0,0 +1 @@ +开始
结束 diff --git a/tests/conformance/ast/107-thematic-break-dashes.ast.json b/tests/conformance/ast/107-thematic-break-dashes.ast.json new file mode 100644 index 0000000..f875640 --- /dev/null +++ b/tests/conformance/ast/107-thematic-break-dashes.ast.json @@ -0,0 +1,16 @@ +{ + "kind": "document", + "span": { + "start": 0, + "end": 3 + }, + "children": [ + { + "kind": "thematic_break", + "span": { + "start": 0, + "end": 3 + } + } + ] +} diff --git a/tests/conformance/ast/107-thematic-break-dashes.mq.md b/tests/conformance/ast/107-thematic-break-dashes.mq.md new file mode 100644 index 0000000..ed97d53 --- /dev/null +++ b/tests/conformance/ast/107-thematic-break-dashes.mq.md @@ -0,0 +1 @@ +--- diff --git a/tests/conformance/ast/108-thematic-break-stars.ast.json b/tests/conformance/ast/108-thematic-break-stars.ast.json new file mode 100644 index 0000000..f875640 --- /dev/null +++ b/tests/conformance/ast/108-thematic-break-stars.ast.json @@ -0,0 +1,16 @@ +{ + "kind": "document", + "span": { + "start": 0, + "end": 3 + }, + "children": [ + { + "kind": "thematic_break", + "span": { + "start": 0, + "end": 3 + } + } + ] +} diff --git a/tests/conformance/ast/108-thematic-break-stars.mq.md b/tests/conformance/ast/108-thematic-break-stars.mq.md new file mode 100644 index 0000000..6a7e452 --- /dev/null +++ b/tests/conformance/ast/108-thematic-break-stars.mq.md @@ -0,0 +1 @@ +*** diff --git a/tests/conformance/ast/109-thematic-break-underscores.ast.json b/tests/conformance/ast/109-thematic-break-underscores.ast.json new file mode 100644 index 0000000..f875640 --- /dev/null +++ b/tests/conformance/ast/109-thematic-break-underscores.ast.json @@ -0,0 +1,16 @@ +{ + "kind": "document", + "span": { + "start": 0, + "end": 3 + }, + "children": [ + { + "kind": "thematic_break", + "span": { + "start": 0, + "end": 3 + } + } + ] +} diff --git a/tests/conformance/ast/109-thematic-break-underscores.mq.md b/tests/conformance/ast/109-thematic-break-underscores.mq.md new file mode 100644 index 0000000..88f351d --- /dev/null +++ b/tests/conformance/ast/109-thematic-break-underscores.mq.md @@ -0,0 +1 @@ +___ diff --git a/tests/conformance/ast/110-thematic-break-between-paragraphs.ast.json b/tests/conformance/ast/110-thematic-break-between-paragraphs.ast.json new file mode 100644 index 0000000..efde5a4 --- /dev/null +++ b/tests/conformance/ast/110-thematic-break-between-paragraphs.ast.json @@ -0,0 +1,50 @@ +{ + "kind": "document", + "span": { + "start": 0, + "end": 19 + }, + "children": [ + { + "kind": "paragraph", + "span": { + "start": 0, + "end": 6 + }, + "children": [ + { + "kind": "text", + "span": { + "start": 0, + "end": 6 + }, + "literal": "上文" + } + ] + }, + { + "kind": "thematic_break", + "span": { + "start": 8, + "end": 11 + } + }, + { + "kind": "paragraph", + "span": { + "start": 13, + "end": 19 + }, + "children": [ + { + "kind": "text", + "span": { + "start": 13, + "end": 19 + }, + "literal": "下文" + } + ] + } + ] +} diff --git a/tests/conformance/ast/110-thematic-break-between-paragraphs.mq.md b/tests/conformance/ast/110-thematic-break-between-paragraphs.mq.md new file mode 100644 index 0000000..c5c8352 --- /dev/null +++ b/tests/conformance/ast/110-thematic-break-between-paragraphs.mq.md @@ -0,0 +1,5 @@ +上文 + +--- + +下文 diff --git a/tests/conformance/ast/111-frontmatter-valid.ast.json b/tests/conformance/ast/111-frontmatter-valid.ast.json new file mode 100644 index 0000000..bb7e2dc --- /dev/null +++ b/tests/conformance/ast/111-frontmatter-valid.ast.json @@ -0,0 +1,62 @@ +{ + "kind": "document", + "span": { + "start": 0, + "end": 56 + }, + "children": [ + { + "kind": "front_matter", + "span": { + "start": 0, + "end": 42 + }, + "literal": "---\ntitle: 示例文档\ntags:\n - demo\n---\n\n" + }, + { + "kind": "heading", + "level": 2, + "setext": false, + "span": { + "start": 44, + "end": 51 + }, + "children": [ + { + "kind": "text", + "span": { + "start": 47, + "end": 51 + }, + "literal": "main" + } + ] + }, + { + "kind": "paragraph", + "span": { + "start": 53, + "end": 56 + }, + "children": [ + { + "kind": "emph", + "span": { + "start": 53, + "end": 56 + }, + "children": [ + { + "kind": "text", + "span": { + "start": 54, + "end": 55 + }, + "literal": "1" + } + ] + } + ] + } + ] +} diff --git a/tests/conformance/ast/111-frontmatter-valid.mq.md b/tests/conformance/ast/111-frontmatter-valid.mq.md new file mode 100644 index 0000000..6659cf2 --- /dev/null +++ b/tests/conformance/ast/111-frontmatter-valid.mq.md @@ -0,0 +1,9 @@ +--- +title: 示例文档 +tags: + - demo +--- + +## main + +*1* diff --git a/tests/conformance/ast/112-frontmatter-empty.ast.json b/tests/conformance/ast/112-frontmatter-empty.ast.json new file mode 100644 index 0000000..7e53630 --- /dev/null +++ b/tests/conformance/ast/112-frontmatter-empty.ast.json @@ -0,0 +1,40 @@ +{ + "kind": "document", + "span": { + "start": 0, + "end": 15 + }, + "children": [ + { + "kind": "thematic_break", + "span": { + "start": 0, + "end": 3 + } + }, + { + "kind": "thematic_break", + "span": { + "start": 4, + "end": 7 + } + }, + { + "kind": "paragraph", + "span": { + "start": 9, + "end": 15 + }, + "children": [ + { + "kind": "text", + "span": { + "start": 9, + "end": 15 + }, + "literal": "正文" + } + ] + } + ] +} diff --git a/tests/conformance/ast/112-frontmatter-empty.mq.md b/tests/conformance/ast/112-frontmatter-empty.mq.md new file mode 100644 index 0000000..bbf4361 --- /dev/null +++ b/tests/conformance/ast/112-frontmatter-empty.mq.md @@ -0,0 +1,4 @@ +--- +--- + +正文 diff --git a/tests/conformance/ast/113-frontmatter-imports.ast.json b/tests/conformance/ast/113-frontmatter-imports.ast.json new file mode 100644 index 0000000..92358cc --- /dev/null +++ b/tests/conformance/ast/113-frontmatter-imports.ast.json @@ -0,0 +1,62 @@ +{ + "kind": "document", + "span": { + "start": 0, + "end": 60 + }, + "children": [ + { + "kind": "front_matter", + "span": { + "start": 0, + "end": 46 + }, + "literal": "---\nimport:\n geometry: \"./geometry.mq.md\"\n---\n\n" + }, + { + "kind": "heading", + "level": 2, + "setext": false, + "span": { + "start": 48, + "end": 55 + }, + "children": [ + { + "kind": "text", + "span": { + "start": 51, + "end": 55 + }, + "literal": "main" + } + ] + }, + { + "kind": "paragraph", + "span": { + "start": 57, + "end": 60 + }, + "children": [ + { + "kind": "emph", + "span": { + "start": 57, + "end": 60 + }, + "children": [ + { + "kind": "text", + "span": { + "start": 58, + "end": 59 + }, + "literal": "1" + } + ] + } + ] + } + ] +} diff --git a/tests/conformance/ast/113-frontmatter-imports.mq.md b/tests/conformance/ast/113-frontmatter-imports.mq.md new file mode 100644 index 0000000..b938d8f --- /dev/null +++ b/tests/conformance/ast/113-frontmatter-imports.mq.md @@ -0,0 +1,8 @@ +--- +import: + geometry: "./geometry.mq.md" +--- + +## main + +*1* diff --git a/tests/conformance/ast/114-frontmatter-later-is-thematic-break.ast.json b/tests/conformance/ast/114-frontmatter-later-is-thematic-break.ast.json new file mode 100644 index 0000000..f0be383 --- /dev/null +++ b/tests/conformance/ast/114-frontmatter-later-is-thematic-break.ast.json @@ -0,0 +1,50 @@ +{ + "kind": "document", + "span": { + "start": 0, + "end": 25 + }, + "children": [ + { + "kind": "paragraph", + "span": { + "start": 0, + "end": 6 + }, + "children": [ + { + "kind": "text", + "span": { + "start": 0, + "end": 6 + }, + "literal": "正文" + } + ] + }, + { + "kind": "thematic_break", + "span": { + "start": 8, + "end": 11 + } + }, + { + "kind": "paragraph", + "span": { + "start": 13, + "end": 25 + }, + "children": [ + { + "kind": "text", + "span": { + "start": 13, + "end": 25 + }, + "literal": "更多正文" + } + ] + } + ] +} diff --git a/tests/conformance/ast/114-frontmatter-later-is-thematic-break.mq.md b/tests/conformance/ast/114-frontmatter-later-is-thematic-break.mq.md new file mode 100644 index 0000000..5bc425c --- /dev/null +++ b/tests/conformance/ast/114-frontmatter-later-is-thematic-break.mq.md @@ -0,0 +1,5 @@ +正文 + +--- + +更多正文 diff --git a/tests/conformance/ast/115-frontmatter-invalid-yaml.ast.json b/tests/conformance/ast/115-frontmatter-invalid-yaml.ast.json new file mode 100644 index 0000000..3636367 --- /dev/null +++ b/tests/conformance/ast/115-frontmatter-invalid-yaml.ast.json @@ -0,0 +1,34 @@ +{ + "kind": "document", + "span": { + "start": 0, + "end": 33 + }, + "children": [ + { + "kind": "front_matter", + "span": { + "start": 0, + "end": 25 + }, + "literal": "---\nimport: [unclosed\n---\n\n" + }, + { + "kind": "paragraph", + "span": { + "start": 27, + "end": 33 + }, + "children": [ + { + "kind": "text", + "span": { + "start": 27, + "end": 33 + }, + "literal": "正文" + } + ] + } + ] +} diff --git a/tests/conformance/ast/115-frontmatter-invalid-yaml.mq.md b/tests/conformance/ast/115-frontmatter-invalid-yaml.mq.md new file mode 100644 index 0000000..991d2f7 --- /dev/null +++ b/tests/conformance/ast/115-frontmatter-invalid-yaml.mq.md @@ -0,0 +1,5 @@ +--- +import: [unclosed +--- + +正文 diff --git a/tests/conformance/ast/116-frontmatter-with-bom.ast.json b/tests/conformance/ast/116-frontmatter-with-bom.ast.json new file mode 100644 index 0000000..782769a --- /dev/null +++ b/tests/conformance/ast/116-frontmatter-with-bom.ast.json @@ -0,0 +1,34 @@ +{ + "kind": "document", + "span": { + "start": 3, + "end": 29 + }, + "children": [ + { + "kind": "front_matter", + "span": { + "start": 3, + "end": 21 + }, + "literal": "---\ntitle: bom\n---\n\n" + }, + { + "kind": "paragraph", + "span": { + "start": 23, + "end": 29 + }, + "children": [ + { + "kind": "text", + "span": { + "start": 23, + "end": 29 + }, + "literal": "正文" + } + ] + } + ] +} diff --git a/tests/conformance/ast/116-frontmatter-with-bom.mq.md b/tests/conformance/ast/116-frontmatter-with-bom.mq.md new file mode 100644 index 0000000..01159b6 --- /dev/null +++ b/tests/conformance/ast/116-frontmatter-with-bom.mq.md @@ -0,0 +1,5 @@ +--- +title: bom +--- + +正文 diff --git a/tests/conformance/ast/117-entities-named.ast.json b/tests/conformance/ast/117-entities-named.ast.json new file mode 100644 index 0000000..e2ff55d --- /dev/null +++ b/tests/conformance/ast/117-entities-named.ast.json @@ -0,0 +1,26 @@ +{ + "kind": "document", + "span": { + "start": 0, + "end": 29 + }, + "children": [ + { + "kind": "paragraph", + "span": { + "start": 0, + "end": 29 + }, + "children": [ + { + "kind": "text", + "span": { + "start": 0, + "end": 29 + }, + "literal": "& < > \" ©" + } + ] + } + ] +} diff --git a/tests/conformance/ast/117-entities-named.mq.md b/tests/conformance/ast/117-entities-named.mq.md new file mode 100644 index 0000000..dc5154e --- /dev/null +++ b/tests/conformance/ast/117-entities-named.mq.md @@ -0,0 +1 @@ +& < > " © diff --git a/tests/conformance/ast/118-entities-numeric.ast.json b/tests/conformance/ast/118-entities-numeric.ast.json new file mode 100644 index 0000000..39a100c --- /dev/null +++ b/tests/conformance/ast/118-entities-numeric.ast.json @@ -0,0 +1,26 @@ +{ + "kind": "document", + "span": { + "start": 0, + "end": 23 + }, + "children": [ + { + "kind": "paragraph", + "span": { + "start": 0, + "end": 23 + }, + "children": [ + { + "kind": "text", + "span": { + "start": 0, + "end": 23 + }, + "literal": "A 中 你" + } + ] + } + ] +} diff --git a/tests/conformance/ast/118-entities-numeric.mq.md b/tests/conformance/ast/118-entities-numeric.mq.md new file mode 100644 index 0000000..4b7d003 --- /dev/null +++ b/tests/conformance/ast/118-entities-numeric.mq.md @@ -0,0 +1 @@ +A 中 你 diff --git a/tests/conformance/ast/119-backslash-escapes.ast.json b/tests/conformance/ast/119-backslash-escapes.ast.json new file mode 100644 index 0000000..07badf5 --- /dev/null +++ b/tests/conformance/ast/119-backslash-escapes.ast.json @@ -0,0 +1,26 @@ +{ + "kind": "document", + "span": { + "start": 0, + "end": 37 + }, + "children": [ + { + "kind": "paragraph", + "span": { + "start": 0, + "end": 37 + }, + "children": [ + { + "kind": "text", + "span": { + "start": 1, + "end": 37 + }, + "literal": "*不是强调* 和 `不是代码`" + } + ] + } + ] +} diff --git a/tests/conformance/ast/119-backslash-escapes.mq.md b/tests/conformance/ast/119-backslash-escapes.mq.md new file mode 100644 index 0000000..39c7cc2 --- /dev/null +++ b/tests/conformance/ast/119-backslash-escapes.mq.md @@ -0,0 +1 @@ +\*不是强调\* 和 \`不是代码\` diff --git a/tests/conformance/ast/120-escaped-pipe-in-table.ast.json b/tests/conformance/ast/120-escaped-pipe-in-table.ast.json new file mode 100644 index 0000000..e2cc506 --- /dev/null +++ b/tests/conformance/ast/120-escaped-pipe-in-table.ast.json @@ -0,0 +1,75 @@ +{ + "kind": "document", + "span": { + "start": 0, + "end": 29 + }, + "children": [ + { + "kind": "table", + "alignments": [ + "none" + ], + "span": { + "start": 0, + "end": 29 + }, + "children": [ + { + "kind": "table_row", + "header": true, + "span": { + "start": 0, + "end": 10 + }, + "children": [ + { + "kind": "table_cell", + "span": { + "start": 1, + "end": 9 + }, + "children": [ + { + "kind": "text", + "span": { + "start": 2, + "end": 8 + }, + "literal": "a | b" + } + ] + } + ] + }, + { + "kind": "table_row", + "header": false, + "span": { + "start": 19, + "end": 29 + }, + "children": [ + { + "kind": "table_cell", + "span": { + "start": 20, + "end": 28 + }, + "children": [ + { + "kind": "text", + "span": { + "start": 21, + "end": 27 + }, + "literal": "c | d" + } + ] + } + ] + } + ] + } + ] +} diff --git a/tests/conformance/ast/120-escaped-pipe-in-table.mq.md b/tests/conformance/ast/120-escaped-pipe-in-table.mq.md new file mode 100644 index 0000000..ae5618c --- /dev/null +++ b/tests/conformance/ast/120-escaped-pipe-in-table.mq.md @@ -0,0 +1,3 @@ +| a \| b | +| --- | +| c \| d | diff --git a/tests/conformance/ast/121-cjk-paragraph.ast.json b/tests/conformance/ast/121-cjk-paragraph.ast.json new file mode 100644 index 0000000..b41eafa --- /dev/null +++ b/tests/conformance/ast/121-cjk-paragraph.ast.json @@ -0,0 +1,26 @@ +{ + "kind": "document", + "span": { + "start": 0, + "end": 63 + }, + "children": [ + { + "kind": "paragraph", + "span": { + "start": 0, + "end": 63 + }, + "children": [ + { + "kind": "text", + "span": { + "start": 0, + "end": 63 + }, + "literal": "中文段落包含标点,以及「引号」和《书名》。" + } + ] + } + ] +} diff --git a/tests/conformance/ast/121-cjk-paragraph.mq.md b/tests/conformance/ast/121-cjk-paragraph.mq.md new file mode 100644 index 0000000..a4ae977 --- /dev/null +++ b/tests/conformance/ast/121-cjk-paragraph.mq.md @@ -0,0 +1 @@ +中文段落包含标点,以及「引号」和《书名》。 diff --git a/tests/conformance/ast/122-emoji-text.ast.json b/tests/conformance/ast/122-emoji-text.ast.json new file mode 100644 index 0000000..2ef7d1b --- /dev/null +++ b/tests/conformance/ast/122-emoji-text.ast.json @@ -0,0 +1,26 @@ +{ + "kind": "document", + "span": { + "start": 0, + "end": 63 + }, + "children": [ + { + "kind": "paragraph", + "span": { + "start": 0, + "end": 63 + }, + "children": [ + { + "kind": "text", + "span": { + "start": 0, + "end": 63 + }, + "literal": "😀 🎉 👨‍👩‍👧‍👦 文本中的表情符号。" + } + ] + } + ] +} diff --git a/tests/conformance/ast/122-emoji-text.mq.md b/tests/conformance/ast/122-emoji-text.mq.md new file mode 100644 index 0000000..b76c04a --- /dev/null +++ b/tests/conformance/ast/122-emoji-text.mq.md @@ -0,0 +1 @@ +😀 🎉 👨‍👩‍👧‍👦 文本中的表情符号。 diff --git a/tests/conformance/ast/123-cjk-emphasis.ast.json b/tests/conformance/ast/123-cjk-emphasis.ast.json new file mode 100644 index 0000000..8ac4d47 --- /dev/null +++ b/tests/conformance/ast/123-cjk-emphasis.ast.json @@ -0,0 +1,60 @@ +{ + "kind": "document", + "span": { + "start": 0, + "end": 35 + }, + "children": [ + { + "kind": "paragraph", + "span": { + "start": 0, + "end": 35 + }, + "children": [ + { + "kind": "strong", + "span": { + "start": 0, + "end": 16 + }, + "children": [ + { + "kind": "text", + "span": { + "start": 2, + "end": 14 + }, + "literal": "中文加粗" + } + ] + }, + { + "kind": "text", + "span": { + "start": 16, + "end": 21 + }, + "literal": " 与 " + }, + { + "kind": "emph", + "span": { + "start": 21, + "end": 35 + }, + "children": [ + { + "kind": "text", + "span": { + "start": 22, + "end": 34 + }, + "literal": "中文斜体" + } + ] + } + ] + } + ] +} diff --git a/tests/conformance/ast/123-cjk-emphasis.mq.md b/tests/conformance/ast/123-cjk-emphasis.mq.md new file mode 100644 index 0000000..28c09a9 --- /dev/null +++ b/tests/conformance/ast/123-cjk-emphasis.mq.md @@ -0,0 +1 @@ +**中文加粗** 与 *中文斜体* diff --git a/tests/conformance/ast/124-mixed-scripts.ast.json b/tests/conformance/ast/124-mixed-scripts.ast.json new file mode 100644 index 0000000..c4bfa53 --- /dev/null +++ b/tests/conformance/ast/124-mixed-scripts.ast.json @@ -0,0 +1,26 @@ +{ + "kind": "document", + "span": { + "start": 0, + "end": 44 + }, + "children": [ + { + "kind": "paragraph", + "span": { + "start": 0, + "end": 44 + }, + "children": [ + { + "kind": "text", + "span": { + "start": 0, + "end": 44 + }, + "literal": "English 中文 123 العربية emoji 🚀" + } + ] + } + ] +} diff --git a/tests/conformance/ast/124-mixed-scripts.mq.md b/tests/conformance/ast/124-mixed-scripts.mq.md new file mode 100644 index 0000000..5350c71 --- /dev/null +++ b/tests/conformance/ast/124-mixed-scripts.mq.md @@ -0,0 +1 @@ +English 中文 123 العربية emoji 🚀 diff --git a/tests/conformance/ast/125-prose-with-executable.ast.json b/tests/conformance/ast/125-prose-with-executable.ast.json new file mode 100644 index 0000000..6500979 --- /dev/null +++ b/tests/conformance/ast/125-prose-with-executable.ast.json @@ -0,0 +1,95 @@ +{ + "kind": "document", + "span": { + "start": 0, + "end": 83 + }, + "children": [ + { + "kind": "paragraph", + "span": { + "start": 0, + "end": 27 + }, + "children": [ + { + "kind": "text", + "span": { + "start": 0, + "end": 27 + }, + "literal": "计算前先说明意图。" + } + ] + }, + { + "kind": "paragraph", + "span": { + "start": 29, + "end": 47 + }, + "children": [ + { + "kind": "strong", + "span": { + "start": 29, + "end": 47 + }, + "children": [ + { + "kind": "text", + "span": { + "start": 31, + "end": 45 + }, + "literal": "结果 = 1 + 2" + } + ] + } + ] + }, + { + "kind": "paragraph", + "span": { + "start": 49, + "end": 73 + }, + "children": [ + { + "kind": "text", + "span": { + "start": 49, + "end": 73 + }, + "literal": "再补充一句叙述。" + } + ] + }, + { + "kind": "paragraph", + "span": { + "start": 75, + "end": 83 + }, + "children": [ + { + "kind": "emph", + "span": { + "start": 75, + "end": 83 + }, + "children": [ + { + "kind": "text", + "span": { + "start": 76, + "end": 82 + }, + "literal": "结果" + } + ] + } + ] + } + ] +} diff --git a/tests/conformance/ast/125-prose-with-executable.mq.md b/tests/conformance/ast/125-prose-with-executable.mq.md new file mode 100644 index 0000000..aea035f --- /dev/null +++ b/tests/conformance/ast/125-prose-with-executable.mq.md @@ -0,0 +1,7 @@ +计算前先说明意图。 + +**结果 = 1 + 2** + +再补充一句叙述。 + +*结果* diff --git a/tests/conformance/ast/126-prose-and-control-flow.ast.json b/tests/conformance/ast/126-prose-and-control-flow.ast.json new file mode 100644 index 0000000..944ed84 --- /dev/null +++ b/tests/conformance/ast/126-prose-and-control-flow.ast.json @@ -0,0 +1,222 @@ +{ + "kind": "document", + "span": { + "start": 0, + "end": 156 + }, + "children": [ + { + "kind": "heading", + "level": 2, + "setext": false, + "span": { + "start": 0, + "end": 9 + }, + "children": [ + { + "kind": "text", + "span": { + "start": 3, + "end": 9 + }, + "literal": "分类" + } + ] + }, + { + "kind": "paragraph", + "span": { + "start": 11, + "end": 29 + }, + "children": [ + { + "kind": "text", + "span": { + "start": 11, + "end": 29 + }, + "literal": "先说明背景。" + } + ] + }, + { + "kind": "list", + "ordered": true, + "start": 1, + "tight": false, + "span": { + "start": 31, + "end": 129 + }, + "children": [ + { + "kind": "item", + "span": { + "start": 31, + "end": 79 + }, + "children": [ + { + "kind": "paragraph", + "span": { + "start": 34, + "end": 59 + }, + "children": [ + { + "kind": "code", + "ticks": 1, + "span": { + "start": 34, + "end": 41 + }, + "literal": "n < 0" + }, + { + "kind": "text", + "span": { + "start": 41, + "end": 59 + }, + "literal": ",负数分支。" + } + ] + }, + { + "kind": "paragraph", + "span": { + "start": 64, + "end": 79 + }, + "children": [ + { + "kind": "strong", + "span": { + "start": 64, + "end": 79 + }, + "children": [ + { + "kind": "text", + "span": { + "start": 66, + "end": 77 + }, + "literal": "结果 = -1" + } + ] + } + ] + } + ] + }, + { + "kind": "item", + "span": { + "start": 81, + "end": 129 + }, + "children": [ + { + "kind": "paragraph", + "span": { + "start": 84, + "end": 110 + }, + "children": [ + { + "kind": "code", + "ticks": 1, + "span": { + "start": 84, + "end": 92 + }, + "literal": "n >= 0" + }, + { + "kind": "text", + "span": { + "start": 92, + "end": 110 + }, + "literal": ",非负分支。" + } + ] + }, + { + "kind": "paragraph", + "span": { + "start": 115, + "end": 129 + }, + "children": [ + { + "kind": "strong", + "span": { + "start": 115, + "end": 129 + }, + "children": [ + { + "kind": "text", + "span": { + "start": 117, + "end": 127 + }, + "literal": "结果 = 1" + } + ] + } + ] + } + ] + } + ] + }, + { + "kind": "paragraph", + "span": { + "start": 131, + "end": 146 + }, + "children": [ + { + "kind": "text", + "span": { + "start": 131, + "end": 146 + }, + "literal": "说明结束。" + } + ] + }, + { + "kind": "paragraph", + "span": { + "start": 148, + "end": 156 + }, + "children": [ + { + "kind": "emph", + "span": { + "start": 148, + "end": 156 + }, + "children": [ + { + "kind": "text", + "span": { + "start": 149, + "end": 155 + }, + "literal": "结果" + } + ] + } + ] + } + ] +} diff --git a/tests/conformance/ast/126-prose-and-control-flow.mq.md b/tests/conformance/ast/126-prose-and-control-flow.mq.md new file mode 100644 index 0000000..bbbfacc --- /dev/null +++ b/tests/conformance/ast/126-prose-and-control-flow.mq.md @@ -0,0 +1,15 @@ +## 分类 + +先说明背景。 + +1. `n < 0`,负数分支。 + + **结果 = -1** + +2. `n >= 0`,非负分支。 + + **结果 = 1** + +说明结束。 + +*结果* diff --git a/tests/conformance/ast/127-invalid-strong-nested-markup.ast.json b/tests/conformance/ast/127-invalid-strong-nested-markup.ast.json new file mode 100644 index 0000000..092b822 --- /dev/null +++ b/tests/conformance/ast/127-invalid-strong-nested-markup.ast.json @@ -0,0 +1,79 @@ +{ + "kind": "document", + "span": { + "start": 0, + "end": 17 + }, + "children": [ + { + "kind": "heading", + "level": 2, + "setext": false, + "span": { + "start": 0, + "end": 4 + }, + "children": [ + { + "kind": "text", + "span": { + "start": 3, + "end": 4 + }, + "literal": "f" + } + ] + }, + { + "kind": "paragraph", + "span": { + "start": 6, + "end": 17 + }, + "children": [ + { + "kind": "strong", + "span": { + "start": 6, + "end": 17 + }, + "children": [ + { + "kind": "text", + "span": { + "start": 8, + "end": 10 + }, + "literal": "a " + }, + { + "kind": "emph", + "span": { + "start": 10, + "end": 13 + }, + "children": [ + { + "kind": "text", + "span": { + "start": 11, + "end": 12 + }, + "literal": "b" + } + ] + }, + { + "kind": "text", + "span": { + "start": 13, + "end": 15 + }, + "literal": " c" + } + ] + } + ] + } + ] +} diff --git a/tests/conformance/ast/127-invalid-strong-nested-markup.mq.md b/tests/conformance/ast/127-invalid-strong-nested-markup.mq.md new file mode 100644 index 0000000..58254fe --- /dev/null +++ b/tests/conformance/ast/127-invalid-strong-nested-markup.mq.md @@ -0,0 +1,3 @@ +## f + +**a *b* c** diff --git a/tests/conformance/ast/128-invalid-emph-nested-markup.ast.json b/tests/conformance/ast/128-invalid-emph-nested-markup.ast.json new file mode 100644 index 0000000..0f77e41 --- /dev/null +++ b/tests/conformance/ast/128-invalid-emph-nested-markup.ast.json @@ -0,0 +1,79 @@ +{ + "kind": "document", + "span": { + "start": 0, + "end": 17 + }, + "children": [ + { + "kind": "heading", + "level": 2, + "setext": false, + "span": { + "start": 0, + "end": 4 + }, + "children": [ + { + "kind": "text", + "span": { + "start": 3, + "end": 4 + }, + "literal": "f" + } + ] + }, + { + "kind": "paragraph", + "span": { + "start": 6, + "end": 17 + }, + "children": [ + { + "kind": "emph", + "span": { + "start": 6, + "end": 17 + }, + "children": [ + { + "kind": "text", + "span": { + "start": 7, + "end": 9 + }, + "literal": "a " + }, + { + "kind": "strong", + "span": { + "start": 9, + "end": 14 + }, + "children": [ + { + "kind": "text", + "span": { + "start": 11, + "end": 12 + }, + "literal": "b" + } + ] + }, + { + "kind": "text", + "span": { + "start": 14, + "end": 16 + }, + "literal": " c" + } + ] + } + ] + } + ] +} diff --git a/tests/conformance/ast/128-invalid-emph-nested-markup.mq.md b/tests/conformance/ast/128-invalid-emph-nested-markup.mq.md new file mode 100644 index 0000000..2e55e7f --- /dev/null +++ b/tests/conformance/ast/128-invalid-emph-nested-markup.mq.md @@ -0,0 +1,3 @@ +## f + +*a **b** c* diff --git a/tests/conformance/ast/129-invalid-list-no-condition.ast.json b/tests/conformance/ast/129-invalid-list-no-condition.ast.json new file mode 100644 index 0000000..fee7702 --- /dev/null +++ b/tests/conformance/ast/129-invalid-list-no-condition.ast.json @@ -0,0 +1,66 @@ +{ + "kind": "document", + "span": { + "start": 0, + "end": 21 + }, + "children": [ + { + "kind": "heading", + "level": 2, + "setext": false, + "span": { + "start": 0, + "end": 4 + }, + "children": [ + { + "kind": "text", + "span": { + "start": 3, + "end": 4 + }, + "literal": "f" + } + ] + }, + { + "kind": "list", + "ordered": true, + "start": 1, + "tight": true, + "span": { + "start": 6, + "end": 21 + }, + "children": [ + { + "kind": "item", + "span": { + "start": 6, + "end": 21 + }, + "children": [ + { + "kind": "paragraph", + "span": { + "start": 9, + "end": 21 + }, + "children": [ + { + "kind": "text", + "span": { + "start": 9, + "end": 21 + }, + "literal": "没有条件" + } + ] + } + ] + } + ] + } + ] +} diff --git a/tests/conformance/ast/129-invalid-list-no-condition.mq.md b/tests/conformance/ast/129-invalid-list-no-condition.mq.md new file mode 100644 index 0000000..ed4c17a --- /dev/null +++ b/tests/conformance/ast/129-invalid-list-no-condition.mq.md @@ -0,0 +1,3 @@ +## f + +1. 没有条件 diff --git a/tests/conformance/ast/130-invalid-quote-not-call.ast.json b/tests/conformance/ast/130-invalid-quote-not-call.ast.json new file mode 100644 index 0000000..f11e4c8 --- /dev/null +++ b/tests/conformance/ast/130-invalid-quote-not-call.ast.json @@ -0,0 +1,54 @@ +{ + "kind": "document", + "span": { + "start": 0, + "end": 23 + }, + "children": [ + { + "kind": "heading", + "level": 2, + "setext": false, + "span": { + "start": 0, + "end": 4 + }, + "children": [ + { + "kind": "text", + "span": { + "start": 3, + "end": 4 + }, + "literal": "f" + } + ] + }, + { + "kind": "block_quote", + "span": { + "start": 6, + "end": 23 + }, + "children": [ + { + "kind": "paragraph", + "span": { + "start": 8, + "end": 23 + }, + "children": [ + { + "kind": "text", + "span": { + "start": 8, + "end": 23 + }, + "literal": "这不是调用" + } + ] + } + ] + } + ] +} diff --git a/tests/conformance/ast/130-invalid-quote-not-call.mq.md b/tests/conformance/ast/130-invalid-quote-not-call.mq.md new file mode 100644 index 0000000..1b20bb7 --- /dev/null +++ b/tests/conformance/ast/130-invalid-quote-not-call.mq.md @@ -0,0 +1,3 @@ +## f + +> 这不是调用 diff --git a/tests/conformance/ast/131-invalid-empty-payloads.ast.json b/tests/conformance/ast/131-invalid-empty-payloads.ast.json new file mode 100644 index 0000000..7119ac3 --- /dev/null +++ b/tests/conformance/ast/131-invalid-empty-payloads.ast.json @@ -0,0 +1,53 @@ +{ + "kind": "document", + "span": { + "start": 0, + "end": 14 + }, + "children": [ + { + "kind": "heading", + "level": 2, + "setext": false, + "span": { + "start": 0, + "end": 4 + }, + "children": [ + { + "kind": "text", + "span": { + "start": 3, + "end": 4 + }, + "literal": "f" + } + ] + }, + { + "kind": "thematic_break", + "span": { + "start": 6, + "end": 11 + } + }, + { + "kind": "list", + "ordered": false, + "tight": true, + "span": { + "start": 13, + "end": 14 + }, + "children": [ + { + "kind": "item", + "span": { + "start": 13, + "end": 14 + } + } + ] + } + ] +} diff --git a/tests/conformance/ast/131-invalid-empty-payloads.mq.md b/tests/conformance/ast/131-invalid-empty-payloads.mq.md new file mode 100644 index 0000000..de74ada --- /dev/null +++ b/tests/conformance/ast/131-invalid-empty-payloads.mq.md @@ -0,0 +1,5 @@ +## f + +** ** + +* diff --git a/tests/conformance/ast/132-inert-executable-outside-function.ast.json b/tests/conformance/ast/132-inert-executable-outside-function.ast.json new file mode 100644 index 0000000..c496825 --- /dev/null +++ b/tests/conformance/ast/132-inert-executable-outside-function.ast.json @@ -0,0 +1,80 @@ +{ + "kind": "document", + "span": { + "start": 0, + "end": 31 + }, + "children": [ + { + "kind": "paragraph", + "span": { + "start": 0, + "end": 20 + }, + "children": [ + { + "kind": "strong", + "span": { + "start": 0, + "end": 20 + }, + "children": [ + { + "kind": "text", + "span": { + "start": 2, + "end": 18 + }, + "literal": "顶层赋值 = 1" + } + ] + } + ] + }, + { + "kind": "heading", + "level": 2, + "setext": false, + "span": { + "start": 22, + "end": 26 + }, + "children": [ + { + "kind": "text", + "span": { + "start": 25, + "end": 26 + }, + "literal": "f" + } + ] + }, + { + "kind": "paragraph", + "span": { + "start": 28, + "end": 31 + }, + "children": [ + { + "kind": "emph", + "span": { + "start": 28, + "end": 31 + }, + "children": [ + { + "kind": "text", + "span": { + "start": 29, + "end": 30 + }, + "literal": "1" + } + ] + } + ] + } + ] +} diff --git a/tests/conformance/ast/132-inert-executable-outside-function.mq.md b/tests/conformance/ast/132-inert-executable-outside-function.mq.md new file mode 100644 index 0000000..e6608fd --- /dev/null +++ b/tests/conformance/ast/132-inert-executable-outside-function.mq.md @@ -0,0 +1,5 @@ +**顶层赋值 = 1** + +## f + +*1* diff --git a/tests/conformance/ast/133-strikethrough.ast.json b/tests/conformance/ast/133-strikethrough.ast.json new file mode 100644 index 0000000..652a8c2 --- /dev/null +++ b/tests/conformance/ast/133-strikethrough.ast.json @@ -0,0 +1,35 @@ +{ + "kind": "document", + "span": { + "start": 0, + "end": 13 + }, + "children": [ + { + "kind": "paragraph", + "span": { + "start": 0, + "end": 13 + }, + "children": [ + { + "kind": "strikethrough", + "span": { + "start": 0, + "end": 13 + }, + "children": [ + { + "kind": "text", + "span": { + "start": 2, + "end": 11 + }, + "literal": "删除线" + } + ] + } + ] + } + ] +} diff --git a/tests/conformance/ast/133-strikethrough.mq.md b/tests/conformance/ast/133-strikethrough.mq.md new file mode 100644 index 0000000..44602d1 --- /dev/null +++ b/tests/conformance/ast/133-strikethrough.mq.md @@ -0,0 +1 @@ +~~删除线~~ diff --git a/tests/conformance/ast/134-strikethrough-with-strong.ast.json b/tests/conformance/ast/134-strikethrough-with-strong.ast.json new file mode 100644 index 0000000..299895b --- /dev/null +++ b/tests/conformance/ast/134-strikethrough-with-strong.ast.json @@ -0,0 +1,52 @@ +{ + "kind": "document", + "span": { + "start": 0, + "end": 21 + }, + "children": [ + { + "kind": "paragraph", + "span": { + "start": 0, + "end": 21 + }, + "children": [ + { + "kind": "strikethrough", + "span": { + "start": 0, + "end": 21 + }, + "children": [ + { + "kind": "text", + "span": { + "start": 2, + "end": 9 + }, + "literal": "删除 " + }, + { + "kind": "strong", + "span": { + "start": 9, + "end": 19 + }, + "children": [ + { + "kind": "text", + "span": { + "start": 11, + "end": 17 + }, + "literal": "粗体" + } + ] + } + ] + } + ] + } + ] +} diff --git a/tests/conformance/ast/134-strikethrough-with-strong.mq.md b/tests/conformance/ast/134-strikethrough-with-strong.mq.md new file mode 100644 index 0000000..a601ff5 --- /dev/null +++ b/tests/conformance/ast/134-strikethrough-with-strong.mq.md @@ -0,0 +1 @@ +~~删除 **粗体**~~ diff --git a/tests/conformance/ast/135-tight-vs-loose-equivalence.ast.json b/tests/conformance/ast/135-tight-vs-loose-equivalence.ast.json new file mode 100644 index 0000000..dcd7816 --- /dev/null +++ b/tests/conformance/ast/135-tight-vs-loose-equivalence.ast.json @@ -0,0 +1,72 @@ +{ + "kind": "document", + "span": { + "start": 0, + "end": 19 + }, + "children": [ + { + "kind": "list", + "ordered": false, + "tight": true, + "span": { + "start": 0, + "end": 19 + }, + "children": [ + { + "kind": "item", + "span": { + "start": 0, + "end": 9 + }, + "children": [ + { + "kind": "paragraph", + "span": { + "start": 2, + "end": 9 + }, + "children": [ + { + "kind": "text", + "span": { + "start": 2, + "end": 9 + }, + "literal": "tight a" + } + ] + } + ] + }, + { + "kind": "item", + "span": { + "start": 10, + "end": 19 + }, + "children": [ + { + "kind": "paragraph", + "span": { + "start": 12, + "end": 19 + }, + "children": [ + { + "kind": "text", + "span": { + "start": 12, + "end": 19 + }, + "literal": "tight b" + } + ] + } + ] + } + ] + } + ] +} diff --git a/tests/conformance/ast/135-tight-vs-loose-equivalence.mq.md b/tests/conformance/ast/135-tight-vs-loose-equivalence.mq.md new file mode 100644 index 0000000..d784e3e --- /dev/null +++ b/tests/conformance/ast/135-tight-vs-loose-equivalence.mq.md @@ -0,0 +1,2 @@ +- tight a +- tight b diff --git a/tests/conformance/ast/136-nested-container-blocks.ast.json b/tests/conformance/ast/136-nested-container-blocks.ast.json new file mode 100644 index 0000000..61e4c09 --- /dev/null +++ b/tests/conformance/ast/136-nested-container-blocks.ast.json @@ -0,0 +1,65 @@ +{ + "kind": "document", + "span": { + "start": 0, + "end": 49 + }, + "children": [ + { + "kind": "block_quote", + "span": { + "start": 0, + "end": 49 + }, + "children": [ + { + "kind": "list", + "ordered": false, + "tight": false, + "span": { + "start": 2, + "end": 49 + }, + "children": [ + { + "kind": "item", + "span": { + "start": 2, + "end": 49 + }, + "children": [ + { + "kind": "paragraph", + "span": { + "start": 4, + "end": 22 + }, + "children": [ + { + "kind": "text", + "span": { + "start": 4, + "end": 22 + }, + "literal": "引用中的列表" + } + ] + }, + { + "kind": "code_block", + "fenced": true, + "info": "", + "span": { + "start": 29, + "end": 49 + }, + "literal": "code\n" + } + ] + } + ] + } + ] + } + ] +} diff --git a/tests/conformance/ast/136-nested-container-blocks.mq.md b/tests/conformance/ast/136-nested-container-blocks.mq.md new file mode 100644 index 0000000..4a56ad5 --- /dev/null +++ b/tests/conformance/ast/136-nested-container-blocks.mq.md @@ -0,0 +1,5 @@ +> - 引用中的列表 +> +> ``` +> code +> ``` diff --git a/tests/conformance/ast/137-multiple-levels-document.ast.json b/tests/conformance/ast/137-multiple-levels-document.ast.json new file mode 100644 index 0000000..59a73a4 --- /dev/null +++ b/tests/conformance/ast/137-multiple-levels-document.ast.json @@ -0,0 +1,128 @@ +{ + "kind": "document", + "span": { + "start": 0, + "end": 67 + }, + "children": [ + { + "kind": "heading", + "level": 1, + "setext": false, + "span": { + "start": 0, + "end": 14 + }, + "children": [ + { + "kind": "text", + "span": { + "start": 2, + "end": 14 + }, + "literal": "命名空间" + } + ] + }, + { + "kind": "heading", + "level": 2, + "setext": false, + "span": { + "start": 16, + "end": 28 + }, + "children": [ + { + "kind": "text", + "span": { + "start": 19, + "end": 28 + }, + "literal": "函数一" + } + ] + }, + { + "kind": "heading", + "level": 3, + "setext": false, + "span": { + "start": 30, + "end": 40 + }, + "children": [ + { + "kind": "text", + "span": { + "start": 34, + "end": 40 + }, + "literal": "小节" + } + ] + }, + { + "kind": "paragraph", + "span": { + "start": 42, + "end": 48 + }, + "children": [ + { + "kind": "text", + "span": { + "start": 42, + "end": 48 + }, + "literal": "正文" + } + ] + }, + { + "kind": "heading", + "level": 2, + "setext": false, + "span": { + "start": 50, + "end": 62 + }, + "children": [ + { + "kind": "text", + "span": { + "start": 53, + "end": 62 + }, + "literal": "函数二" + } + ] + }, + { + "kind": "paragraph", + "span": { + "start": 64, + "end": 67 + }, + "children": [ + { + "kind": "emph", + "span": { + "start": 64, + "end": 67 + }, + "children": [ + { + "kind": "text", + "span": { + "start": 65, + "end": 66 + }, + "literal": "1" + } + ] + } + ] + } + ] +} diff --git a/tests/conformance/ast/137-multiple-levels-document.mq.md b/tests/conformance/ast/137-multiple-levels-document.mq.md new file mode 100644 index 0000000..b1ec0d5 --- /dev/null +++ b/tests/conformance/ast/137-multiple-levels-document.mq.md @@ -0,0 +1,11 @@ +# 命名空间 + +## 函数一 + +### 小节 + +正文 + +## 函数二 + +*1* diff --git a/tests/conformance/ast/138-footnotes-disabled.ast.json b/tests/conformance/ast/138-footnotes-disabled.ast.json new file mode 100644 index 0000000..df22264 --- /dev/null +++ b/tests/conformance/ast/138-footnotes-disabled.ast.json @@ -0,0 +1,45 @@ +{ + "kind": "document", + "span": { + "start": 0, + "end": 36 + }, + "children": [ + { + "kind": "paragraph", + "span": { + "start": 0, + "end": 16 + }, + "children": [ + { + "kind": "text", + "span": { + "start": 0, + "end": 12 + }, + "literal": "脚注引用" + }, + { + "kind": "link", + "url": "脚注内容", + "title": "", + "span": { + "start": 12, + "end": 16 + }, + "children": [ + { + "kind": "text", + "span": { + "start": 13, + "end": 15 + }, + "literal": "^1" + } + ] + } + ] + } + ] +} diff --git a/tests/conformance/ast/138-footnotes-disabled.mq.md b/tests/conformance/ast/138-footnotes-disabled.mq.md new file mode 100644 index 0000000..c30a054 --- /dev/null +++ b/tests/conformance/ast/138-footnotes-disabled.mq.md @@ -0,0 +1,3 @@ +脚注引用[^1] + +[^1]: 脚注内容 diff --git a/tests/conformance/ast/139-code-fence-info-attributes.ast.json b/tests/conformance/ast/139-code-fence-info-attributes.ast.json new file mode 100644 index 0000000..0181b2a --- /dev/null +++ b/tests/conformance/ast/139-code-fence-info-attributes.ast.json @@ -0,0 +1,19 @@ +{ + "kind": "document", + "span": { + "start": 0, + "end": 34 + }, + "children": [ + { + "kind": "code_block", + "fenced": true, + "info": "rust {#id .class}", + "span": { + "start": 0, + "end": 34 + }, + "literal": "fn x() {}\n" + } + ] +} diff --git a/tests/conformance/ast/139-code-fence-info-attributes.mq.md b/tests/conformance/ast/139-code-fence-info-attributes.mq.md new file mode 100644 index 0000000..b080cdf --- /dev/null +++ b/tests/conformance/ast/139-code-fence-info-attributes.mq.md @@ -0,0 +1,3 @@ +```rust {#id .class} +fn x() {} +``` diff --git a/tests/conformance/ast/140-table-and-list-mixed.ast.json b/tests/conformance/ast/140-table-and-list-mixed.ast.json new file mode 100644 index 0000000..4b94cab --- /dev/null +++ b/tests/conformance/ast/140-table-and-list-mixed.ast.json @@ -0,0 +1,147 @@ +{ + "kind": "document", + "span": { + "start": 0, + "end": 46 + }, + "children": [ + { + "kind": "table", + "alignments": [ + "none", + "none" + ], + "span": { + "start": 0, + "end": 33 + }, + "children": [ + { + "kind": "table_row", + "header": true, + "span": { + "start": 0, + "end": 9 + }, + "children": [ + { + "kind": "table_cell", + "span": { + "start": 1, + "end": 4 + }, + "children": [ + { + "kind": "text", + "span": { + "start": 2, + "end": 3 + }, + "literal": "a" + } + ] + }, + { + "kind": "table_cell", + "span": { + "start": 5, + "end": 8 + }, + "children": [ + { + "kind": "text", + "span": { + "start": 6, + "end": 7 + }, + "literal": "b" + } + ] + } + ] + }, + { + "kind": "table_row", + "header": false, + "span": { + "start": 24, + "end": 33 + }, + "children": [ + { + "kind": "table_cell", + "span": { + "start": 25, + "end": 28 + }, + "children": [ + { + "kind": "text", + "span": { + "start": 26, + "end": 27 + }, + "literal": "1" + } + ] + }, + { + "kind": "table_cell", + "span": { + "start": 29, + "end": 32 + }, + "children": [ + { + "kind": "text", + "span": { + "start": 30, + "end": 31 + }, + "literal": "2" + } + ] + } + ] + } + ] + }, + { + "kind": "list", + "ordered": false, + "tight": true, + "span": { + "start": 35, + "end": 46 + }, + "children": [ + { + "kind": "item", + "span": { + "start": 35, + "end": 46 + }, + "children": [ + { + "kind": "paragraph", + "span": { + "start": 37, + "end": 46 + }, + "children": [ + { + "kind": "text", + "span": { + "start": 37, + "end": 46 + }, + "literal": "列表项" + } + ] + } + ] + } + ] + } + ] +} diff --git a/tests/conformance/ast/140-table-and-list-mixed.mq.md b/tests/conformance/ast/140-table-and-list-mixed.mq.md new file mode 100644 index 0000000..5a2a808 --- /dev/null +++ b/tests/conformance/ast/140-table-and-list-mixed.mq.md @@ -0,0 +1,5 @@ +| a | b | +| --- | --- | +| 1 | 2 | + +- 列表项 diff --git a/tests/conformance/ast/141-html-block-in-list.ast.json b/tests/conformance/ast/141-html-block-in-list.ast.json new file mode 100644 index 0000000..e5d55ee --- /dev/null +++ b/tests/conformance/ast/141-html-block-in-list.ast.json @@ -0,0 +1,54 @@ +{ + "kind": "document", + "span": { + "start": 0, + "end": 33 + }, + "children": [ + { + "kind": "list", + "ordered": false, + "tight": false, + "span": { + "start": 0, + "end": 33 + }, + "children": [ + { + "kind": "item", + "span": { + "start": 0, + "end": 33 + }, + "children": [ + { + "kind": "paragraph", + "span": { + "start": 2, + "end": 8 + }, + "children": [ + { + "kind": "text", + "span": { + "start": 2, + "end": 8 + }, + "literal": "项目" + } + ] + }, + { + "kind": "html_block", + "span": { + "start": 12, + "end": 33 + }, + "literal": "
\nhtml\n
\n" + } + ] + } + ] + } + ] +} diff --git a/tests/conformance/ast/141-html-block-in-list.mq.md b/tests/conformance/ast/141-html-block-in-list.mq.md new file mode 100644 index 0000000..a7c355b --- /dev/null +++ b/tests/conformance/ast/141-html-block-in-list.mq.md @@ -0,0 +1,5 @@ +- 项目 + +
+ html +
diff --git a/tests/conformance/ast/142-math-and-code-mixed.ast.json b/tests/conformance/ast/142-math-and-code-mixed.ast.json new file mode 100644 index 0000000..f88f0dc --- /dev/null +++ b/tests/conformance/ast/142-math-and-code-mixed.ast.json @@ -0,0 +1,53 @@ +{ + "kind": "document", + "span": { + "start": 0, + "end": 35 + }, + "children": [ + { + "kind": "paragraph", + "span": { + "start": 0, + "end": 12 + }, + "children": [ + { + "kind": "text", + "span": { + "start": 0, + "end": 7 + }, + "literal": "公式 " + }, + { + "kind": "math", + "display": false, + "span": { + "start": 7, + "end": 12 + }, + "literal": "x^2" + } + ] + }, + { + "kind": "code_block", + "fenced": true, + "info": "", + "span": { + "start": 14, + "end": 26 + }, + "literal": "code\n" + }, + { + "kind": "math_block", + "span": { + "start": 28, + "end": 35 + }, + "literal": "y\n" + } + ] +} diff --git a/tests/conformance/ast/142-math-and-code-mixed.mq.md b/tests/conformance/ast/142-math-and-code-mixed.mq.md new file mode 100644 index 0000000..3273322 --- /dev/null +++ b/tests/conformance/ast/142-math-and-code-mixed.mq.md @@ -0,0 +1,9 @@ +公式 $x^2$ + +``` +code +``` + +$$ +y +$$ diff --git a/tests/conformance/ast/143-heading-setext-with-emphasis.ast.json b/tests/conformance/ast/143-heading-setext-with-emphasis.ast.json new file mode 100644 index 0000000..fba1c80 --- /dev/null +++ b/tests/conformance/ast/143-heading-setext-with-emphasis.ast.json @@ -0,0 +1,37 @@ +{ + "kind": "document", + "span": { + "start": 0, + "end": 21 + }, + "children": [ + { + "kind": "heading", + "level": 1, + "setext": true, + "span": { + "start": 0, + "end": 21 + }, + "children": [ + { + "kind": "strong", + "span": { + "start": 0, + "end": 16 + }, + "children": [ + { + "kind": "text", + "span": { + "start": 2, + "end": 14 + }, + "literal": "加粗标题" + } + ] + } + ] + } + ] +} diff --git a/tests/conformance/ast/143-heading-setext-with-emphasis.mq.md b/tests/conformance/ast/143-heading-setext-with-emphasis.mq.md new file mode 100644 index 0000000..2373e7a --- /dev/null +++ b/tests/conformance/ast/143-heading-setext-with-emphasis.mq.md @@ -0,0 +1,2 @@ +**加粗标题** +==== diff --git a/tests/conformance/ast/144-multi-byte-span-check.ast.json b/tests/conformance/ast/144-multi-byte-span-check.ast.json new file mode 100644 index 0000000..e53cc11 --- /dev/null +++ b/tests/conformance/ast/144-multi-byte-span-check.ast.json @@ -0,0 +1,45 @@ +{ + "kind": "document", + "span": { + "start": 0, + "end": 16 + }, + "children": [ + { + "kind": "heading", + "level": 1, + "setext": false, + "span": { + "start": 0, + "end": 8 + }, + "children": [ + { + "kind": "text", + "span": { + "start": 2, + "end": 8 + }, + "literal": "数学" + } + ] + }, + { + "kind": "paragraph", + "span": { + "start": 10, + "end": 16 + }, + "children": [ + { + "kind": "text", + "span": { + "start": 10, + "end": 16 + }, + "literal": "正文" + } + ] + } + ] +} diff --git a/tests/conformance/ast/144-multi-byte-span-check.mq.md b/tests/conformance/ast/144-multi-byte-span-check.mq.md new file mode 100644 index 0000000..c3ccbd3 --- /dev/null +++ b/tests/conformance/ast/144-multi-byte-span-check.mq.md @@ -0,0 +1,3 @@ +# 数学 + +正文 diff --git a/tests/conformance/ast/145-frontmatter-then-heading.ast.json b/tests/conformance/ast/145-frontmatter-then-heading.ast.json new file mode 100644 index 0000000..f2718d0 --- /dev/null +++ b/tests/conformance/ast/145-frontmatter-then-heading.ast.json @@ -0,0 +1,81 @@ +{ + "kind": "document", + "span": { + "start": 0, + "end": 42 + }, + "children": [ + { + "kind": "front_matter", + "span": { + "start": 0, + "end": 16 + }, + "literal": "---\ntitle: t\n---\n" + }, + { + "kind": "heading", + "level": 1, + "setext": false, + "span": { + "start": 17, + "end": 31 + }, + "children": [ + { + "kind": "text", + "span": { + "start": 19, + "end": 31 + }, + "literal": "命名空间" + } + ] + }, + { + "kind": "heading", + "level": 2, + "setext": false, + "span": { + "start": 33, + "end": 37 + }, + "children": [ + { + "kind": "text", + "span": { + "start": 36, + "end": 37 + }, + "literal": "f" + } + ] + }, + { + "kind": "paragraph", + "span": { + "start": 39, + "end": 42 + }, + "children": [ + { + "kind": "emph", + "span": { + "start": 39, + "end": 42 + }, + "children": [ + { + "kind": "text", + "span": { + "start": 40, + "end": 41 + }, + "literal": "1" + } + ] + } + ] + } + ] +} diff --git a/tests/conformance/ast/145-frontmatter-then-heading.mq.md b/tests/conformance/ast/145-frontmatter-then-heading.mq.md new file mode 100644 index 0000000..e478b63 --- /dev/null +++ b/tests/conformance/ast/145-frontmatter-then-heading.mq.md @@ -0,0 +1,8 @@ +--- +title: t +--- +# 命名空间 + +## f + +*1* diff --git a/tests/conformance/ast/146-crlf-line-endings.ast.json b/tests/conformance/ast/146-crlf-line-endings.ast.json new file mode 100644 index 0000000..90b1d8c --- /dev/null +++ b/tests/conformance/ast/146-crlf-line-endings.ast.json @@ -0,0 +1,45 @@ +{ + "kind": "document", + "span": { + "start": 0, + "end": 18 + }, + "children": [ + { + "kind": "heading", + "level": 1, + "setext": false, + "span": { + "start": 0, + "end": 8 + }, + "children": [ + { + "kind": "text", + "span": { + "start": 2, + "end": 8 + }, + "literal": "标题" + } + ] + }, + { + "kind": "paragraph", + "span": { + "start": 12, + "end": 18 + }, + "children": [ + { + "kind": "text", + "span": { + "start": 12, + "end": 18 + }, + "literal": "段落" + } + ] + } + ] +} diff --git a/tests/conformance/ast/146-crlf-line-endings.mq.md b/tests/conformance/ast/146-crlf-line-endings.mq.md new file mode 100644 index 0000000..821bb65 --- /dev/null +++ b/tests/conformance/ast/146-crlf-line-endings.mq.md @@ -0,0 +1,3 @@ +# 标题 + +段落 diff --git a/tests/conformance/ast/147-tab-indented-list.ast.json b/tests/conformance/ast/147-tab-indented-list.ast.json new file mode 100644 index 0000000..19cfb73 --- /dev/null +++ b/tests/conformance/ast/147-tab-indented-list.ast.json @@ -0,0 +1,46 @@ +{ + "kind": "document", + "span": { + "start": 0, + "end": 8 + }, + "children": [ + { + "kind": "list", + "ordered": false, + "tight": true, + "span": { + "start": 0, + "end": 8 + }, + "children": [ + { + "kind": "item", + "span": { + "start": 0, + "end": 8 + }, + "children": [ + { + "kind": "paragraph", + "span": { + "start": 2, + "end": 8 + }, + "children": [ + { + "kind": "text", + "span": { + "start": 2, + "end": 8 + }, + "literal": "项目" + } + ] + } + ] + } + ] + } + ] +} diff --git a/tests/conformance/ast/147-tab-indented-list.mq.md b/tests/conformance/ast/147-tab-indented-list.mq.md new file mode 100644 index 0000000..b0e15e2 --- /dev/null +++ b/tests/conformance/ast/147-tab-indented-list.mq.md @@ -0,0 +1 @@ +- 项目 diff --git a/tests/conformance/ast/148-blockquote-heading-mixed.ast.json b/tests/conformance/ast/148-blockquote-heading-mixed.ast.json new file mode 100644 index 0000000..a2510c1 --- /dev/null +++ b/tests/conformance/ast/148-blockquote-heading-mixed.ast.json @@ -0,0 +1,54 @@ +{ + "kind": "document", + "span": { + "start": 0, + "end": 24 + }, + "children": [ + { + "kind": "block_quote", + "span": { + "start": 0, + "end": 14 + }, + "children": [ + { + "kind": "paragraph", + "span": { + "start": 2, + "end": 14 + }, + "children": [ + { + "kind": "text", + "span": { + "start": 2, + "end": 14 + }, + "literal": "引用段落" + } + ] + } + ] + }, + { + "kind": "heading", + "level": 1, + "setext": false, + "span": { + "start": 16, + "end": 24 + }, + "children": [ + { + "kind": "text", + "span": { + "start": 18, + "end": 24 + }, + "literal": "标题" + } + ] + } + ] +} diff --git a/tests/conformance/ast/148-blockquote-heading-mixed.mq.md b/tests/conformance/ast/148-blockquote-heading-mixed.mq.md new file mode 100644 index 0000000..5370c4b --- /dev/null +++ b/tests/conformance/ast/148-blockquote-heading-mixed.mq.md @@ -0,0 +1,3 @@ +> 引用段落 + +# 标题 diff --git a/tests/conformance/ast/149-table-with-header-only.ast.json b/tests/conformance/ast/149-table-with-header-only.ast.json new file mode 100644 index 0000000..a180f05 --- /dev/null +++ b/tests/conformance/ast/149-table-with-header-only.ast.json @@ -0,0 +1,66 @@ +{ + "kind": "document", + "span": { + "start": 0, + "end": 23 + }, + "children": [ + { + "kind": "table", + "alignments": [ + "none", + "none" + ], + "span": { + "start": 0, + "end": 23 + }, + "children": [ + { + "kind": "table_row", + "header": true, + "span": { + "start": 0, + "end": 9 + }, + "children": [ + { + "kind": "table_cell", + "span": { + "start": 1, + "end": 4 + }, + "children": [ + { + "kind": "text", + "span": { + "start": 2, + "end": 3 + }, + "literal": "a" + } + ] + }, + { + "kind": "table_cell", + "span": { + "start": 5, + "end": 8 + }, + "children": [ + { + "kind": "text", + "span": { + "start": 6, + "end": 7 + }, + "literal": "b" + } + ] + } + ] + } + ] + } + ] +} diff --git a/tests/conformance/ast/149-table-with-header-only.mq.md b/tests/conformance/ast/149-table-with-header-only.mq.md new file mode 100644 index 0000000..c3fdb6f --- /dev/null +++ b/tests/conformance/ast/149-table-with-header-only.mq.md @@ -0,0 +1,2 @@ +| a | b | +| --- | --- | diff --git a/tests/conformance/ast/150-document-only-frontmatter.ast.json b/tests/conformance/ast/150-document-only-frontmatter.ast.json new file mode 100644 index 0000000..9f408fe --- /dev/null +++ b/tests/conformance/ast/150-document-only-frontmatter.ast.json @@ -0,0 +1,17 @@ +{ + "kind": "document", + "span": { + "start": 0, + "end": 18 + }, + "children": [ + { + "kind": "front_matter", + "span": { + "start": 0, + "end": 18 + }, + "literal": "---\nkey: value\n---\n" + } + ] +} diff --git a/tests/conformance/ast/150-document-only-frontmatter.mq.md b/tests/conformance/ast/150-document-only-frontmatter.mq.md new file mode 100644 index 0000000..28227f9 --- /dev/null +++ b/tests/conformance/ast/150-document-only-frontmatter.mq.md @@ -0,0 +1,3 @@ +--- +key: value +--- diff --git a/tests/conformance/semantics/01-constant-return.expected.json b/tests/conformance/semantics/01-constant-return.expected.json new file mode 100644 index 0000000..301b92e --- /dev/null +++ b/tests/conformance/semantics/01-constant-return.expected.json @@ -0,0 +1,9 @@ +{ + "args": {}, + "function": "main", + "stdout": "", + "value": { + "decimal": "3", + "type": "int" + } +} diff --git a/tests/conformance/semantics/01-constant-return.mq.md b/tests/conformance/semantics/01-constant-return.mq.md new file mode 100644 index 0000000..498dcf1 --- /dev/null +++ b/tests/conformance/semantics/01-constant-return.mq.md @@ -0,0 +1,3 @@ +## main + +*1 + 2* diff --git a/tests/conformance/semantics/02-text-return.expected.json b/tests/conformance/semantics/02-text-return.expected.json new file mode 100644 index 0000000..d1d9a29 --- /dev/null +++ b/tests/conformance/semantics/02-text-return.expected.json @@ -0,0 +1,9 @@ +{ + "args": {}, + "function": "main", + "stdout": "", + "value": { + "type": "text", + "value": "你好,Marqdo" + } +} diff --git a/tests/conformance/semantics/02-text-return.mq.md b/tests/conformance/semantics/02-text-return.mq.md new file mode 100644 index 0000000..18e6dff --- /dev/null +++ b/tests/conformance/semantics/02-text-return.mq.md @@ -0,0 +1,3 @@ +## main + +*"你好,Marqdo"* diff --git a/tests/conformance/semantics/03-float-arithmetic.expected.json b/tests/conformance/semantics/03-float-arithmetic.expected.json new file mode 100644 index 0000000..1442a3d --- /dev/null +++ b/tests/conformance/semantics/03-float-arithmetic.expected.json @@ -0,0 +1,9 @@ +{ + "args": {}, + "function": "main", + "stdout": "", + "value": { + "type": "float", + "value": 3.0 + } +} diff --git a/tests/conformance/semantics/03-float-arithmetic.mq.md b/tests/conformance/semantics/03-float-arithmetic.mq.md new file mode 100644 index 0000000..49102be --- /dev/null +++ b/tests/conformance/semantics/03-float-arithmetic.mq.md @@ -0,0 +1,3 @@ +## main + +*1.5 * 2.0* diff --git a/tests/conformance/semantics/04-big-int-arithmetic.expected.json b/tests/conformance/semantics/04-big-int-arithmetic.expected.json new file mode 100644 index 0000000..ca7bb62 --- /dev/null +++ b/tests/conformance/semantics/04-big-int-arithmetic.expected.json @@ -0,0 +1,9 @@ +{ + "args": {}, + "function": "main", + "stdout": "", + "value": { + "decimal": "1234567890123456789012345678900", + "type": "int" + } +} diff --git a/tests/conformance/semantics/04-big-int-arithmetic.mq.md b/tests/conformance/semantics/04-big-int-arithmetic.mq.md new file mode 100644 index 0000000..e65fc8b --- /dev/null +++ b/tests/conformance/semantics/04-big-int-arithmetic.mq.md @@ -0,0 +1,3 @@ +## main + +*123456789012345678901234567890 * 10* diff --git a/tests/conformance/semantics/05-factorio-recursion.expected.json b/tests/conformance/semantics/05-factorio-recursion.expected.json new file mode 100644 index 0000000..fe3e0de --- /dev/null +++ b/tests/conformance/semantics/05-factorio-recursion.expected.json @@ -0,0 +1,14 @@ +{ + "args": { + "n": { + "decimal": "5", + "type": "int" + } + }, + "function": "阶乘", + "stdout": "", + "value": { + "decimal": "120", + "type": "int" + } +} diff --git a/tests/conformance/semantics/05-factorio-recursion.mq.md b/tests/conformance/semantics/05-factorio-recursion.mq.md new file mode 100644 index 0000000..d189a3f --- /dev/null +++ b/tests/conformance/semantics/05-factorio-recursion.mq.md @@ -0,0 +1,13 @@ +# 数学 + +## 阶乘 + +1. `n <= 1` + + *1* + +2. `n > 1` + + **结果 = n * 阶乘(n=n-1)** + + *结果* diff --git a/tests/conformance/semantics/06-fibonacci-recursion.expected.json b/tests/conformance/semantics/06-fibonacci-recursion.expected.json new file mode 100644 index 0000000..3768d59 --- /dev/null +++ b/tests/conformance/semantics/06-fibonacci-recursion.expected.json @@ -0,0 +1,14 @@ +{ + "args": { + "n": { + "decimal": "8", + "type": "int" + } + }, + "function": "斐波那契", + "stdout": "", + "value": { + "decimal": "21", + "type": "int" + } +} diff --git a/tests/conformance/semantics/06-fibonacci-recursion.mq.md b/tests/conformance/semantics/06-fibonacci-recursion.mq.md new file mode 100644 index 0000000..10cd4f0 --- /dev/null +++ b/tests/conformance/semantics/06-fibonacci-recursion.mq.md @@ -0,0 +1,11 @@ +## 斐波那契 + +1. `n < 2` + + *n* + +2. `n >= 2` + + **结果 = 斐波那契(n=n-1) + 斐波那契(n=n-2)** + + *结果* diff --git a/tests/conformance/semantics/07-euclid-iterative.expected.json b/tests/conformance/semantics/07-euclid-iterative.expected.json new file mode 100644 index 0000000..e0c8964 --- /dev/null +++ b/tests/conformance/semantics/07-euclid-iterative.expected.json @@ -0,0 +1,18 @@ +{ + "args": { + "乙": { + "decimal": "36", + "type": "int" + }, + "甲": { + "decimal": "48", + "type": "int" + } + }, + "function": "最大公约数", + "stdout": "", + "value": { + "decimal": "12", + "type": "int" + } +} diff --git a/tests/conformance/semantics/07-euclid-iterative.mq.md b/tests/conformance/semantics/07-euclid-iterative.mq.md new file mode 100644 index 0000000..4a59c95 --- /dev/null +++ b/tests/conformance/semantics/07-euclid-iterative.mq.md @@ -0,0 +1,15 @@ +## 最大公约数 + +**a = 甲** + +**b = 乙** + +- `b > 0` + + **t = b** + + **b = a % b** + + **a = t** + +*a* diff --git a/tests/conformance/semantics/08-loop-sum.expected.json b/tests/conformance/semantics/08-loop-sum.expected.json new file mode 100644 index 0000000..7490f19 --- /dev/null +++ b/tests/conformance/semantics/08-loop-sum.expected.json @@ -0,0 +1,14 @@ +{ + "args": { + "n": { + "decimal": "10", + "type": "int" + } + }, + "function": "求和", + "stdout": "", + "value": { + "decimal": "55", + "type": "int" + } +} diff --git a/tests/conformance/semantics/08-loop-sum.mq.md b/tests/conformance/semantics/08-loop-sum.mq.md new file mode 100644 index 0000000..8d08130 --- /dev/null +++ b/tests/conformance/semantics/08-loop-sum.mq.md @@ -0,0 +1,13 @@ +## 求和 + +**i = 1** + +**total = 0** + +- `i <= n` + + **total = total + i** + + **i = i + 1** + +*total* diff --git a/tests/conformance/semantics/09-nested-control-flow.expected.json b/tests/conformance/semantics/09-nested-control-flow.expected.json new file mode 100644 index 0000000..0ac5114 --- /dev/null +++ b/tests/conformance/semantics/09-nested-control-flow.expected.json @@ -0,0 +1,14 @@ +{ + "args": { + "n": { + "decimal": "2", + "type": "int" + } + }, + "function": "嵌套", + "stdout": "", + "value": { + "decimal": "6", + "type": "int" + } +} diff --git a/tests/conformance/semantics/09-nested-control-flow.mq.md b/tests/conformance/semantics/09-nested-control-flow.mq.md new file mode 100644 index 0000000..90a580b --- /dev/null +++ b/tests/conformance/semantics/09-nested-control-flow.mq.md @@ -0,0 +1,19 @@ +## 嵌套 + +**total = 0** + +1. `n > 0` + + **m = 3** + + - `m > 0` + + **total = total + m** + + **m = m - 1** + +2. `n <= 0` + + **total = 0** + +*total* diff --git a/tests/conformance/semantics/10-explicit-positional-signature.expected.json b/tests/conformance/semantics/10-explicit-positional-signature.expected.json new file mode 100644 index 0000000..c6e8339 --- /dev/null +++ b/tests/conformance/semantics/10-explicit-positional-signature.expected.json @@ -0,0 +1,9 @@ +{ + "args": {}, + "function": "main", + "stdout": "", + "value": { + "decimal": "5", + "type": "int" + } +} diff --git a/tests/conformance/semantics/10-explicit-positional-signature.mq.md b/tests/conformance/semantics/10-explicit-positional-signature.mq.md new file mode 100644 index 0000000..a43abd5 --- /dev/null +++ b/tests/conformance/semantics/10-explicit-positional-signature.mq.md @@ -0,0 +1,9 @@ +## 加法 + +`(a: Int, b: Int)` + +*a + b* + +## main + +*加法(2, 3)* diff --git a/tests/conformance/semantics/11-default-parameters.expected.json b/tests/conformance/semantics/11-default-parameters.expected.json new file mode 100644 index 0000000..7367369 --- /dev/null +++ b/tests/conformance/semantics/11-default-parameters.expected.json @@ -0,0 +1,9 @@ +{ + "args": {}, + "function": "main", + "stdout": "", + "value": { + "decimal": "12", + "type": "int" + } +} diff --git a/tests/conformance/semantics/11-default-parameters.mq.md b/tests/conformance/semantics/11-default-parameters.mq.md new file mode 100644 index 0000000..eedcc83 --- /dev/null +++ b/tests/conformance/semantics/11-default-parameters.mq.md @@ -0,0 +1,9 @@ +## 默认 + +`(x: Int, y: Int = 10)` + +*x + y* + +## main + +*默认(x=2)* diff --git a/tests/conformance/semantics/12-named-arguments.expected.json b/tests/conformance/semantics/12-named-arguments.expected.json new file mode 100644 index 0000000..215cd8a --- /dev/null +++ b/tests/conformance/semantics/12-named-arguments.expected.json @@ -0,0 +1,9 @@ +{ + "args": {}, + "function": "main", + "stdout": "", + "value": { + "decimal": "7", + "type": "int" + } +} diff --git a/tests/conformance/semantics/12-named-arguments.mq.md b/tests/conformance/semantics/12-named-arguments.mq.md new file mode 100644 index 0000000..93890a6 --- /dev/null +++ b/tests/conformance/semantics/12-named-arguments.mq.md @@ -0,0 +1,9 @@ +## 减法 + +`(a: Int, b: Int)` + +*a - b* + +## main + +*减法(b=3, a=10)* diff --git a/tests/conformance/semantics/13-function-ref-call.expected.json b/tests/conformance/semantics/13-function-ref-call.expected.json new file mode 100644 index 0000000..94f69d8 --- /dev/null +++ b/tests/conformance/semantics/13-function-ref-call.expected.json @@ -0,0 +1,9 @@ +{ + "args": {}, + "function": "main", + "stdout": "", + "value": { + "decimal": "42", + "type": "int" + } +} diff --git a/tests/conformance/semantics/13-function-ref-call.mq.md b/tests/conformance/semantics/13-function-ref-call.mq.md new file mode 100644 index 0000000..ab2611c --- /dev/null +++ b/tests/conformance/semantics/13-function-ref-call.mq.md @@ -0,0 +1,11 @@ +## 加一 + +**n = n + 1** + +*n* + +## main + +**f = ref("#加一")** + +*f(n=41)* diff --git a/tests/conformance/semantics/14-function-ref-value.expected.json b/tests/conformance/semantics/14-function-ref-value.expected.json new file mode 100644 index 0000000..7f5c09d --- /dev/null +++ b/tests/conformance/semantics/14-function-ref-value.expected.json @@ -0,0 +1,10 @@ +{ + "args": {}, + "function": "main", + "stdout": "", + "value": { + "module": "index.mq.md", + "name": "加一", + "type": "function_ref" + } +} diff --git a/tests/conformance/semantics/14-function-ref-value.mq.md b/tests/conformance/semantics/14-function-ref-value.mq.md new file mode 100644 index 0000000..5ea20fa --- /dev/null +++ b/tests/conformance/semantics/14-function-ref-value.mq.md @@ -0,0 +1,9 @@ +## 加一 + +**n = n + 1** + +*n* + +## main + +*ref("#加一")* diff --git a/tests/conformance/semantics/15-string-builtins.expected.json b/tests/conformance/semantics/15-string-builtins.expected.json new file mode 100644 index 0000000..9d67a3a --- /dev/null +++ b/tests/conformance/semantics/15-string-builtins.expected.json @@ -0,0 +1,18 @@ +{ + "args": {}, + "function": "main", + "stdout": "", + "value": { + "entries": { + "文本": { + "type": "text", + "value": "42" + }, + "长度": { + "decimal": "2", + "type": "int" + } + }, + "type": "map" + } +} diff --git a/tests/conformance/semantics/15-string-builtins.mq.md b/tests/conformance/semantics/15-string-builtins.mq.md new file mode 100644 index 0000000..fe040db --- /dev/null +++ b/tests/conformance/semantics/15-string-builtins.mq.md @@ -0,0 +1,3 @@ +## main + +*{"长度": 长度("你好"), "文本": 文本(42)}* diff --git a/tests/conformance/semantics/16-int-builtins.expected.json b/tests/conformance/semantics/16-int-builtins.expected.json new file mode 100644 index 0000000..94f69d8 --- /dev/null +++ b/tests/conformance/semantics/16-int-builtins.expected.json @@ -0,0 +1,9 @@ +{ + "args": {}, + "function": "main", + "stdout": "", + "value": { + "decimal": "42", + "type": "int" + } +} diff --git a/tests/conformance/semantics/16-int-builtins.mq.md b/tests/conformance/semantics/16-int-builtins.mq.md new file mode 100644 index 0000000..d3fd99b --- /dev/null +++ b/tests/conformance/semantics/16-int-builtins.mq.md @@ -0,0 +1,3 @@ +## main + +*整数("40") + 整数(2.0)* diff --git a/tests/conformance/semantics/17-float-builtins.expected.json b/tests/conformance/semantics/17-float-builtins.expected.json new file mode 100644 index 0000000..1442a3d --- /dev/null +++ b/tests/conformance/semantics/17-float-builtins.expected.json @@ -0,0 +1,9 @@ +{ + "args": {}, + "function": "main", + "stdout": "", + "value": { + "type": "float", + "value": 3.0 + } +} diff --git a/tests/conformance/semantics/17-float-builtins.mq.md b/tests/conformance/semantics/17-float-builtins.mq.md new file mode 100644 index 0000000..12f0171 --- /dev/null +++ b/tests/conformance/semantics/17-float-builtins.mq.md @@ -0,0 +1,3 @@ +## main + +*小数("1.5") * 小数("2")* diff --git a/tests/conformance/semantics/18-table-builtin.expected.json b/tests/conformance/semantics/18-table-builtin.expected.json new file mode 100644 index 0000000..a02c857 --- /dev/null +++ b/tests/conformance/semantics/18-table-builtin.expected.json @@ -0,0 +1,34 @@ +{ + "args": {}, + "function": "main", + "stdout": "", + "value": { + "header": [ + "名称", + "数量" + ], + "rows": [ + [ + { + "type": "text", + "value": "苹果" + }, + { + "decimal": "42", + "type": "int" + } + ], + [ + { + "type": "text", + "value": "梨" + }, + { + "decimal": "7", + "type": "int" + } + ] + ], + "type": "table" + } +} diff --git a/tests/conformance/semantics/18-table-builtin.mq.md b/tests/conformance/semantics/18-table-builtin.mq.md new file mode 100644 index 0000000..c7b2f08 --- /dev/null +++ b/tests/conformance/semantics/18-table-builtin.mq.md @@ -0,0 +1,3 @@ +## main + +*表(["名称", "数量"], [["苹果", 42], ["梨", 7]])* diff --git a/tests/conformance/semantics/19-type-builtin.expected.json b/tests/conformance/semantics/19-type-builtin.expected.json new file mode 100644 index 0000000..e51a365 --- /dev/null +++ b/tests/conformance/semantics/19-type-builtin.expected.json @@ -0,0 +1,26 @@ +{ + "args": {}, + "function": "main", + "stdout": "", + "value": { + "entries": { + "a": { + "type": "text", + "value": "Int" + }, + "b": { + "type": "text", + "value": "Text" + }, + "c": { + "type": "text", + "value": "None" + }, + "d": { + "type": "text", + "value": "Float" + } + }, + "type": "map" + } +} diff --git a/tests/conformance/semantics/19-type-builtin.mq.md b/tests/conformance/semantics/19-type-builtin.mq.md new file mode 100644 index 0000000..3d9df6b --- /dev/null +++ b/tests/conformance/semantics/19-type-builtin.mq.md @@ -0,0 +1,3 @@ +## main + +*{"a": 类型(1), "b": 类型("x"), "c": 类型(None), "d": 类型(1.5)}* diff --git a/tests/conformance/semantics/20-math-eval-ref.expected.json b/tests/conformance/semantics/20-math-eval-ref.expected.json new file mode 100644 index 0000000..3300391 --- /dev/null +++ b/tests/conformance/semantics/20-math-eval-ref.expected.json @@ -0,0 +1,9 @@ +{ + "args": {}, + "function": "main", + "stdout": "", + "value": { + "type": "float", + "value": 12.566370614359172 + } +} diff --git a/tests/conformance/semantics/20-math-eval-ref.mq.md b/tests/conformance/semantics/20-math-eval-ref.mq.md new file mode 100644 index 0000000..478507f --- /dev/null +++ b/tests/conformance/semantics/20-math-eval-ref.mq.md @@ -0,0 +1,9 @@ +## 公式 + +$$ +A = \pi r^2 +$$ + +## main + +*math.eval(ref("#公式"), {"r": 2}, target="A")* diff --git a/tests/conformance/semantics/21-math-eval-positional.expected.json b/tests/conformance/semantics/21-math-eval-positional.expected.json new file mode 100644 index 0000000..301b92e --- /dev/null +++ b/tests/conformance/semantics/21-math-eval-positional.expected.json @@ -0,0 +1,9 @@ +{ + "args": {}, + "function": "main", + "stdout": "", + "value": { + "decimal": "3", + "type": "int" + } +} diff --git a/tests/conformance/semantics/21-math-eval-positional.mq.md b/tests/conformance/semantics/21-math-eval-positional.mq.md new file mode 100644 index 0000000..e65c8d7 --- /dev/null +++ b/tests/conformance/semantics/21-math-eval-positional.mq.md @@ -0,0 +1,9 @@ +## 公式 + +$$ +A = r + 1 +$$ + +## main + +*math.eval(ref("#公式"), {"r": 2}, target="A")* diff --git a/tests/conformance/semantics/22-print-stdout.expected.json b/tests/conformance/semantics/22-print-stdout.expected.json new file mode 100644 index 0000000..efc6235 --- /dev/null +++ b/tests/conformance/semantics/22-print-stdout.expected.json @@ -0,0 +1,8 @@ +{ + "args": {}, + "function": "main", + "stdout": "你好\n42\n2.5\n", + "value": { + "type": "none" + } +} diff --git a/tests/conformance/semantics/22-print-stdout.mq.md b/tests/conformance/semantics/22-print-stdout.mq.md new file mode 100644 index 0000000..13d2b87 --- /dev/null +++ b/tests/conformance/semantics/22-print-stdout.mq.md @@ -0,0 +1,9 @@ +## main + +> 打印("你好") + +> 打印(42) + +> 打印(2.5) + +*None* diff --git a/tests/conformance/semantics/23-unit-fallthrough.expected.json b/tests/conformance/semantics/23-unit-fallthrough.expected.json new file mode 100644 index 0000000..c00f171 --- /dev/null +++ b/tests/conformance/semantics/23-unit-fallthrough.expected.json @@ -0,0 +1,8 @@ +{ + "args": {}, + "function": "main", + "stdout": "1\n", + "value": { + "type": "unit" + } +} diff --git a/tests/conformance/semantics/23-unit-fallthrough.mq.md b/tests/conformance/semantics/23-unit-fallthrough.mq.md new file mode 100644 index 0000000..b3fcc03 --- /dev/null +++ b/tests/conformance/semantics/23-unit-fallthrough.mq.md @@ -0,0 +1,5 @@ +## main + +**x = 1** + +> 打印(x) diff --git a/tests/conformance/semantics/24-none-value.expected.json b/tests/conformance/semantics/24-none-value.expected.json new file mode 100644 index 0000000..ab5a4ea --- /dev/null +++ b/tests/conformance/semantics/24-none-value.expected.json @@ -0,0 +1,8 @@ +{ + "args": {}, + "function": "main", + "stdout": "", + "value": { + "type": "none" + } +} diff --git a/tests/conformance/semantics/24-none-value.mq.md b/tests/conformance/semantics/24-none-value.mq.md new file mode 100644 index 0000000..ddc878d --- /dev/null +++ b/tests/conformance/semantics/24-none-value.mq.md @@ -0,0 +1,3 @@ +## main + +*None* diff --git a/tests/conformance/semantics/25-bool-operators.expected.json b/tests/conformance/semantics/25-bool-operators.expected.json new file mode 100644 index 0000000..5264f06 --- /dev/null +++ b/tests/conformance/semantics/25-bool-operators.expected.json @@ -0,0 +1,9 @@ +{ + "args": {}, + "function": "main", + "stdout": "", + "value": { + "type": "bool", + "value": true + } +} diff --git a/tests/conformance/semantics/25-bool-operators.mq.md b/tests/conformance/semantics/25-bool-operators.mq.md new file mode 100644 index 0000000..9ed3366 --- /dev/null +++ b/tests/conformance/semantics/25-bool-operators.mq.md @@ -0,0 +1,3 @@ +## main + +*(true and false) or (not false)* diff --git a/tests/conformance/semantics/26-mixed-comparison.expected.json b/tests/conformance/semantics/26-mixed-comparison.expected.json new file mode 100644 index 0000000..5264f06 --- /dev/null +++ b/tests/conformance/semantics/26-mixed-comparison.expected.json @@ -0,0 +1,9 @@ +{ + "args": {}, + "function": "main", + "stdout": "", + "value": { + "type": "bool", + "value": true + } +} diff --git a/tests/conformance/semantics/26-mixed-comparison.mq.md b/tests/conformance/semantics/26-mixed-comparison.mq.md new file mode 100644 index 0000000..3f4cae3 --- /dev/null +++ b/tests/conformance/semantics/26-mixed-comparison.mq.md @@ -0,0 +1,3 @@ +## main + +*(1 < 1.5) and (2.0 == 2) and not (1 != 1)* diff --git a/tests/conformance/semantics/27-floor-division-modulo.expected.json b/tests/conformance/semantics/27-floor-division-modulo.expected.json new file mode 100644 index 0000000..8ab56da --- /dev/null +++ b/tests/conformance/semantics/27-floor-division-modulo.expected.json @@ -0,0 +1,9 @@ +{ + "args": {}, + "function": "main", + "stdout": "", + "value": { + "decimal": "31", + "type": "int" + } +} diff --git a/tests/conformance/semantics/27-floor-division-modulo.mq.md b/tests/conformance/semantics/27-floor-division-modulo.mq.md new file mode 100644 index 0000000..ffabc09 --- /dev/null +++ b/tests/conformance/semantics/27-floor-division-modulo.mq.md @@ -0,0 +1,3 @@ +## main + +*7 // 2 * 10 + 7 % 2* diff --git a/tests/conformance/semantics/28-index-and-member.expected.json b/tests/conformance/semantics/28-index-and-member.expected.json new file mode 100644 index 0000000..f7bdd6e --- /dev/null +++ b/tests/conformance/semantics/28-index-and-member.expected.json @@ -0,0 +1,30 @@ +{ + "args": {}, + "function": "main", + "stdout": "", + "value": { + "entries": { + "first": { + "decimal": "10", + "type": "int" + }, + "key": { + "decimal": "2", + "type": "int" + }, + "last": { + "decimal": "30", + "type": "int" + }, + "member": { + "decimal": "42", + "type": "int" + }, + "text": { + "type": "text", + "value": "好" + } + }, + "type": "map" + } +} diff --git a/tests/conformance/semantics/28-index-and-member.mq.md b/tests/conformance/semantics/28-index-and-member.mq.md new file mode 100644 index 0000000..c63f080 --- /dev/null +++ b/tests/conformance/semantics/28-index-and-member.mq.md @@ -0,0 +1,3 @@ +## main + +*{"first": [10, 20, 30][0], "last": [10, 20, 30][-1], "text": "你好"[1], "member": {"a": 42}.a, "key": {"b": 2}["b"]}* diff --git a/tests/conformance/semantics/29-map-record-literal.expected.json b/tests/conformance/semantics/29-map-record-literal.expected.json new file mode 100644 index 0000000..783d37d --- /dev/null +++ b/tests/conformance/semantics/29-map-record-literal.expected.json @@ -0,0 +1,26 @@ +{ + "args": {}, + "function": "main", + "stdout": "", + "value": { + "entries": { + "a": { + "decimal": "1", + "type": "int" + }, + "b": { + "items": [ + { + "type": "bool", + "value": true + }, + { + "type": "none" + } + ], + "type": "list" + } + }, + "type": "map" + } +} diff --git a/tests/conformance/semantics/29-map-record-literal.mq.md b/tests/conformance/semantics/29-map-record-literal.mq.md new file mode 100644 index 0000000..4f0382a --- /dev/null +++ b/tests/conformance/semantics/29-map-record-literal.mq.md @@ -0,0 +1,3 @@ +## main + +*{"a": 1, "b": [true, None]}* diff --git a/tests/conformance/semantics/30-print-list-and-map.expected.json b/tests/conformance/semantics/30-print-list-and-map.expected.json new file mode 100644 index 0000000..44ceb5b --- /dev/null +++ b/tests/conformance/semantics/30-print-list-and-map.expected.json @@ -0,0 +1,8 @@ +{ + "args": {}, + "function": "main", + "stdout": "[1, 2, 3]\n{a: 1}\n", + "value": { + "type": "none" + } +} diff --git a/tests/conformance/semantics/30-print-list-and-map.mq.md b/tests/conformance/semantics/30-print-list-and-map.mq.md new file mode 100644 index 0000000..91f1f86 --- /dev/null +++ b/tests/conformance/semantics/30-print-list-and-map.mq.md @@ -0,0 +1,7 @@ +## main + +> 打印([1, 2, 3]) + +> 打印({"a": 1}) + +*None* diff --git a/tests/conformance/semantics/31-string-concat.expected.json b/tests/conformance/semantics/31-string-concat.expected.json new file mode 100644 index 0000000..0ddf77c --- /dev/null +++ b/tests/conformance/semantics/31-string-concat.expected.json @@ -0,0 +1,9 @@ +{ + "args": {}, + "function": "main", + "stdout": "", + "value": { + "type": "text", + "value": "你好,世界" + } +} diff --git a/tests/conformance/semantics/31-string-concat.mq.md b/tests/conformance/semantics/31-string-concat.mq.md new file mode 100644 index 0000000..15dd111 --- /dev/null +++ b/tests/conformance/semantics/31-string-concat.mq.md @@ -0,0 +1,3 @@ +## main + +*"你好" + "," + "世界"* diff --git a/tests/conformance/semantics/32-recursive-sum.expected.json b/tests/conformance/semantics/32-recursive-sum.expected.json new file mode 100644 index 0000000..68fb6f3 --- /dev/null +++ b/tests/conformance/semantics/32-recursive-sum.expected.json @@ -0,0 +1,14 @@ +{ + "args": { + "n": { + "decimal": "5", + "type": "int" + } + }, + "function": "递归和", + "stdout": "", + "value": { + "decimal": "15", + "type": "int" + } +} diff --git a/tests/conformance/semantics/32-recursive-sum.mq.md b/tests/conformance/semantics/32-recursive-sum.mq.md new file mode 100644 index 0000000..ea97945 --- /dev/null +++ b/tests/conformance/semantics/32-recursive-sum.mq.md @@ -0,0 +1,11 @@ +## 递归和 + +1. `n <= 0` + + *0* + +2. `n > 0` + + **结果 = n + 递归和(n=n-1)** + + *结果* diff --git a/tests/conformance/semantics/33-conditional-return-in-loop.expected.json b/tests/conformance/semantics/33-conditional-return-in-loop.expected.json new file mode 100644 index 0000000..d5ca324 --- /dev/null +++ b/tests/conformance/semantics/33-conditional-return-in-loop.expected.json @@ -0,0 +1,14 @@ +{ + "args": { + "target": { + "decimal": "10", + "type": "int" + } + }, + "function": "找平方", + "stdout": "", + "value": { + "decimal": "16", + "type": "int" + } +} diff --git a/tests/conformance/semantics/33-conditional-return-in-loop.mq.md b/tests/conformance/semantics/33-conditional-return-in-loop.mq.md new file mode 100644 index 0000000..7847ae2 --- /dev/null +++ b/tests/conformance/semantics/33-conditional-return-in-loop.mq.md @@ -0,0 +1,9 @@ +## 找平方 + +**i = 0** + +- `i * i < target` + + **i = i + 1** + +*i * i* diff --git a/tests/conformance/semantics/34-elif-chain.expected.json b/tests/conformance/semantics/34-elif-chain.expected.json new file mode 100644 index 0000000..9ca34ed --- /dev/null +++ b/tests/conformance/semantics/34-elif-chain.expected.json @@ -0,0 +1,14 @@ +{ + "args": { + "n": { + "decimal": "-5", + "type": "int" + } + }, + "function": "符号", + "stdout": "", + "value": { + "decimal": "-1", + "type": "int" + } +} diff --git a/tests/conformance/semantics/34-elif-chain.mq.md b/tests/conformance/semantics/34-elif-chain.mq.md new file mode 100644 index 0000000..04734c5 --- /dev/null +++ b/tests/conformance/semantics/34-elif-chain.mq.md @@ -0,0 +1,13 @@ +## 符号 + +1. `n < 0` + + *-1* + +2. `n == 0` + + *0* + +3. `n > 0` + + *1* diff --git a/tests/conformance/semantics/35-default-and-named-mixed.expected.json b/tests/conformance/semantics/35-default-and-named-mixed.expected.json new file mode 100644 index 0000000..54e416b --- /dev/null +++ b/tests/conformance/semantics/35-default-and-named-mixed.expected.json @@ -0,0 +1,9 @@ +{ + "args": {}, + "function": "main", + "stdout": "", + "value": { + "decimal": "13", + "type": "int" + } +} diff --git a/tests/conformance/semantics/35-default-and-named-mixed.mq.md b/tests/conformance/semantics/35-default-and-named-mixed.mq.md new file mode 100644 index 0000000..d727ef4 --- /dev/null +++ b/tests/conformance/semantics/35-default-and-named-mixed.mq.md @@ -0,0 +1,9 @@ +## 混合 + +`(x: Int, y: Int = 5, z: Int = 1)` + +*x * y + z* + +## main + +*混合(x=2, z=3)* diff --git a/tests/conformance/semantics/36-foreign-call-python.expected.json b/tests/conformance/semantics/36-foreign-call-python.expected.json new file mode 100644 index 0000000..5c4631c --- /dev/null +++ b/tests/conformance/semantics/36-foreign-call-python.expected.json @@ -0,0 +1,12 @@ +{ + "args": {}, + "function": "main", + "grants": [ + "foreign" + ], + "stdout": "", + "value": { + "type": "float", + "value": 28.274333882308138 + } +} diff --git a/tests/conformance/semantics/36-foreign-call-python.mq.md b/tests/conformance/semantics/36-foreign-call-python.mq.md new file mode 100644 index 0000000..2f9f7bb --- /dev/null +++ b/tests/conformance/semantics/36-foreign-call-python.mq.md @@ -0,0 +1,16 @@ +## Python 校验 + +```python +import json, math, sys + +envelope = json.load(sys.stdin) +r = int(envelope["input"]["entries"]["r"]["decimal"]) +area = math.pi * r ** 2 +print(json.dumps({"type": "map", "entries": {"area": {"type": "float", "value": area}}})) +``` + +## main + +**结果 = foreign.call(ref("#python-校验"), {"r": 3})** + +*结果.area* diff --git a/tests/negative/01-invalid-strong-nested-emph.expected.json b/tests/negative/01-invalid-strong-nested-emph.expected.json new file mode 100644 index 0000000..c30f3be --- /dev/null +++ b/tests/negative/01-invalid-strong-nested-emph.expected.json @@ -0,0 +1,5 @@ +{ + "codes": [ + "markdown.invalid_construct" + ] +} diff --git a/tests/negative/01-invalid-strong-nested-emph.mq.md b/tests/negative/01-invalid-strong-nested-emph.mq.md new file mode 100644 index 0000000..58254fe --- /dev/null +++ b/tests/negative/01-invalid-strong-nested-emph.mq.md @@ -0,0 +1,3 @@ +## f + +**a *b* c** diff --git a/tests/negative/02-invalid-strong-nested-strong.expected.json b/tests/negative/02-invalid-strong-nested-strong.expected.json new file mode 100644 index 0000000..c30f3be --- /dev/null +++ b/tests/negative/02-invalid-strong-nested-strong.expected.json @@ -0,0 +1,5 @@ +{ + "codes": [ + "markdown.invalid_construct" + ] +} diff --git a/tests/negative/02-invalid-strong-nested-strong.mq.md b/tests/negative/02-invalid-strong-nested-strong.mq.md new file mode 100644 index 0000000..8b35ef1 --- /dev/null +++ b/tests/negative/02-invalid-strong-nested-strong.mq.md @@ -0,0 +1,3 @@ +## f + +**a __b__ c** diff --git a/tests/negative/03-invalid-strong-nested-link.expected.json b/tests/negative/03-invalid-strong-nested-link.expected.json new file mode 100644 index 0000000..c30f3be --- /dev/null +++ b/tests/negative/03-invalid-strong-nested-link.expected.json @@ -0,0 +1,5 @@ +{ + "codes": [ + "markdown.invalid_construct" + ] +} diff --git a/tests/negative/03-invalid-strong-nested-link.mq.md b/tests/negative/03-invalid-strong-nested-link.mq.md new file mode 100644 index 0000000..2fa0008 --- /dev/null +++ b/tests/negative/03-invalid-strong-nested-link.mq.md @@ -0,0 +1,3 @@ +## f + +**见[链接](https://example.com)** diff --git a/tests/negative/04-invalid-strong-nested-math.expected.json b/tests/negative/04-invalid-strong-nested-math.expected.json new file mode 100644 index 0000000..c30f3be --- /dev/null +++ b/tests/negative/04-invalid-strong-nested-math.expected.json @@ -0,0 +1,5 @@ +{ + "codes": [ + "markdown.invalid_construct" + ] +} diff --git a/tests/negative/04-invalid-strong-nested-math.mq.md b/tests/negative/04-invalid-strong-nested-math.mq.md new file mode 100644 index 0000000..01b113a --- /dev/null +++ b/tests/negative/04-invalid-strong-nested-math.mq.md @@ -0,0 +1,3 @@ +## f + +**$x + y$** diff --git a/tests/negative/05-invalid-strong-nested-strikethrough.expected.json b/tests/negative/05-invalid-strong-nested-strikethrough.expected.json new file mode 100644 index 0000000..c30f3be --- /dev/null +++ b/tests/negative/05-invalid-strong-nested-strikethrough.expected.json @@ -0,0 +1,5 @@ +{ + "codes": [ + "markdown.invalid_construct" + ] +} diff --git a/tests/negative/05-invalid-strong-nested-strikethrough.mq.md b/tests/negative/05-invalid-strong-nested-strikethrough.mq.md new file mode 100644 index 0000000..3982134 --- /dev/null +++ b/tests/negative/05-invalid-strong-nested-strikethrough.mq.md @@ -0,0 +1,3 @@ +## f + +**~~删除~~** diff --git a/tests/negative/06-invalid-strong-linebreak.expected.json b/tests/negative/06-invalid-strong-linebreak.expected.json new file mode 100644 index 0000000..c30f3be --- /dev/null +++ b/tests/negative/06-invalid-strong-linebreak.expected.json @@ -0,0 +1,5 @@ +{ + "codes": [ + "markdown.invalid_construct" + ] +} diff --git a/tests/negative/06-invalid-strong-linebreak.mq.md b/tests/negative/06-invalid-strong-linebreak.mq.md new file mode 100644 index 0000000..fae8caf --- /dev/null +++ b/tests/negative/06-invalid-strong-linebreak.mq.md @@ -0,0 +1,4 @@ +## f + +**a +b** diff --git a/tests/negative/07-invalid-emph-nested-strong.expected.json b/tests/negative/07-invalid-emph-nested-strong.expected.json new file mode 100644 index 0000000..c30f3be --- /dev/null +++ b/tests/negative/07-invalid-emph-nested-strong.expected.json @@ -0,0 +1,5 @@ +{ + "codes": [ + "markdown.invalid_construct" + ] +} diff --git a/tests/negative/07-invalid-emph-nested-strong.mq.md b/tests/negative/07-invalid-emph-nested-strong.mq.md new file mode 100644 index 0000000..2e55e7f --- /dev/null +++ b/tests/negative/07-invalid-emph-nested-strong.mq.md @@ -0,0 +1,3 @@ +## f + +*a **b** c* diff --git a/tests/negative/08-invalid-emph-nested-emph.expected.json b/tests/negative/08-invalid-emph-nested-emph.expected.json new file mode 100644 index 0000000..c30f3be --- /dev/null +++ b/tests/negative/08-invalid-emph-nested-emph.expected.json @@ -0,0 +1,5 @@ +{ + "codes": [ + "markdown.invalid_construct" + ] +} diff --git a/tests/negative/08-invalid-emph-nested-emph.mq.md b/tests/negative/08-invalid-emph-nested-emph.mq.md new file mode 100644 index 0000000..9cbc3c4 --- /dev/null +++ b/tests/negative/08-invalid-emph-nested-emph.mq.md @@ -0,0 +1,3 @@ +## f + +*a _b_ c* diff --git a/tests/negative/09-invalid-strong-empty-payload.expected.json b/tests/negative/09-invalid-strong-empty-payload.expected.json new file mode 100644 index 0000000..c30f3be --- /dev/null +++ b/tests/negative/09-invalid-strong-empty-payload.expected.json @@ -0,0 +1,5 @@ +{ + "codes": [ + "markdown.invalid_construct" + ] +} diff --git a/tests/negative/09-invalid-strong-empty-payload.mq.md b/tests/negative/09-invalid-strong-empty-payload.mq.md new file mode 100644 index 0000000..198e407 --- /dev/null +++ b/tests/negative/09-invalid-strong-empty-payload.mq.md @@ -0,0 +1,3 @@ +## f + +**`` ``** diff --git a/tests/negative/10-invalid-emph-empty-payload.expected.json b/tests/negative/10-invalid-emph-empty-payload.expected.json new file mode 100644 index 0000000..c30f3be --- /dev/null +++ b/tests/negative/10-invalid-emph-empty-payload.expected.json @@ -0,0 +1,5 @@ +{ + "codes": [ + "markdown.invalid_construct" + ] +} diff --git a/tests/negative/10-invalid-emph-empty-payload.mq.md b/tests/negative/10-invalid-emph-empty-payload.mq.md new file mode 100644 index 0000000..252e11d --- /dev/null +++ b/tests/negative/10-invalid-emph-empty-payload.mq.md @@ -0,0 +1,3 @@ +## f + +*`` ``* diff --git a/tests/negative/11-invalid-strong-expression.expected.json b/tests/negative/11-invalid-strong-expression.expected.json new file mode 100644 index 0000000..8f17ea3 --- /dev/null +++ b/tests/negative/11-invalid-strong-expression.expected.json @@ -0,0 +1,5 @@ +{ + "codes": [ + "expr.parse" + ] +} diff --git a/tests/negative/11-invalid-strong-expression.mq.md b/tests/negative/11-invalid-strong-expression.mq.md new file mode 100644 index 0000000..ea1296c --- /dev/null +++ b/tests/negative/11-invalid-strong-expression.mq.md @@ -0,0 +1,3 @@ +## f + +**1 +** diff --git a/tests/negative/12-invalid-emph-expression.expected.json b/tests/negative/12-invalid-emph-expression.expected.json new file mode 100644 index 0000000..8f17ea3 --- /dev/null +++ b/tests/negative/12-invalid-emph-expression.expected.json @@ -0,0 +1,5 @@ +{ + "codes": [ + "expr.parse" + ] +} diff --git a/tests/negative/12-invalid-emph-expression.mq.md b/tests/negative/12-invalid-emph-expression.mq.md new file mode 100644 index 0000000..71f6df2 --- /dev/null +++ b/tests/negative/12-invalid-emph-expression.mq.md @@ -0,0 +1,3 @@ +## f + +*1 +* diff --git a/tests/negative/13-ordered-item-no-condition.expected.json b/tests/negative/13-ordered-item-no-condition.expected.json new file mode 100644 index 0000000..c30f3be --- /dev/null +++ b/tests/negative/13-ordered-item-no-condition.expected.json @@ -0,0 +1,5 @@ +{ + "codes": [ + "markdown.invalid_construct" + ] +} diff --git a/tests/negative/13-ordered-item-no-condition.mq.md b/tests/negative/13-ordered-item-no-condition.mq.md new file mode 100644 index 0000000..ed4c17a --- /dev/null +++ b/tests/negative/13-ordered-item-no-condition.mq.md @@ -0,0 +1,3 @@ +## f + +1. 没有条件 diff --git a/tests/negative/14-bullet-item-no-condition.expected.json b/tests/negative/14-bullet-item-no-condition.expected.json new file mode 100644 index 0000000..c30f3be --- /dev/null +++ b/tests/negative/14-bullet-item-no-condition.expected.json @@ -0,0 +1,5 @@ +{ + "codes": [ + "markdown.invalid_construct" + ] +} diff --git a/tests/negative/14-bullet-item-no-condition.mq.md b/tests/negative/14-bullet-item-no-condition.mq.md new file mode 100644 index 0000000..3251afe --- /dev/null +++ b/tests/negative/14-bullet-item-no-condition.mq.md @@ -0,0 +1,3 @@ +## f + +- 没有条件 diff --git a/tests/negative/15-ordered-item-first-block-not-paragraph.expected.json b/tests/negative/15-ordered-item-first-block-not-paragraph.expected.json new file mode 100644 index 0000000..c30f3be --- /dev/null +++ b/tests/negative/15-ordered-item-first-block-not-paragraph.expected.json @@ -0,0 +1,5 @@ +{ + "codes": [ + "markdown.invalid_construct" + ] +} diff --git a/tests/negative/15-ordered-item-first-block-not-paragraph.mq.md b/tests/negative/15-ordered-item-first-block-not-paragraph.mq.md new file mode 100644 index 0000000..9e73c86 --- /dev/null +++ b/tests/negative/15-ordered-item-first-block-not-paragraph.mq.md @@ -0,0 +1,3 @@ +## f + +1. > 引用不是条件 diff --git a/tests/negative/16-ordered-item-first-inline-not-code.expected.json b/tests/negative/16-ordered-item-first-inline-not-code.expected.json new file mode 100644 index 0000000..c30f3be --- /dev/null +++ b/tests/negative/16-ordered-item-first-inline-not-code.expected.json @@ -0,0 +1,5 @@ +{ + "codes": [ + "markdown.invalid_construct" + ] +} diff --git a/tests/negative/16-ordered-item-first-inline-not-code.mq.md b/tests/negative/16-ordered-item-first-inline-not-code.mq.md new file mode 100644 index 0000000..9860de9 --- /dev/null +++ b/tests/negative/16-ordered-item-first-inline-not-code.mq.md @@ -0,0 +1,3 @@ +## f + +1. 普通文本 diff --git a/tests/negative/17-ordered-condition-invalid-expression.expected.json b/tests/negative/17-ordered-condition-invalid-expression.expected.json new file mode 100644 index 0000000..8f17ea3 --- /dev/null +++ b/tests/negative/17-ordered-condition-invalid-expression.expected.json @@ -0,0 +1,5 @@ +{ + "codes": [ + "expr.parse" + ] +} diff --git a/tests/negative/17-ordered-condition-invalid-expression.mq.md b/tests/negative/17-ordered-condition-invalid-expression.mq.md new file mode 100644 index 0000000..7e5e717 --- /dev/null +++ b/tests/negative/17-ordered-condition-invalid-expression.mq.md @@ -0,0 +1,3 @@ +## f + +1. `n >` diff --git a/tests/negative/18-quote-not-a-call.expected.json b/tests/negative/18-quote-not-a-call.expected.json new file mode 100644 index 0000000..c30f3be --- /dev/null +++ b/tests/negative/18-quote-not-a-call.expected.json @@ -0,0 +1,5 @@ +{ + "codes": [ + "markdown.invalid_construct" + ] +} diff --git a/tests/negative/18-quote-not-a-call.mq.md b/tests/negative/18-quote-not-a-call.mq.md new file mode 100644 index 0000000..1b20bb7 --- /dev/null +++ b/tests/negative/18-quote-not-a-call.mq.md @@ -0,0 +1,3 @@ +## f + +> 这不是调用 diff --git a/tests/negative/19-quote-multi-paragraph.expected.json b/tests/negative/19-quote-multi-paragraph.expected.json new file mode 100644 index 0000000..c30f3be --- /dev/null +++ b/tests/negative/19-quote-multi-paragraph.expected.json @@ -0,0 +1,5 @@ +{ + "codes": [ + "markdown.invalid_construct" + ] +} diff --git a/tests/negative/19-quote-multi-paragraph.mq.md b/tests/negative/19-quote-multi-paragraph.mq.md new file mode 100644 index 0000000..1d59665 --- /dev/null +++ b/tests/negative/19-quote-multi-paragraph.mq.md @@ -0,0 +1,5 @@ +## f + +> 打印(1) +> +> 打印(2) diff --git a/tests/negative/20-quote-nested.expected.json b/tests/negative/20-quote-nested.expected.json new file mode 100644 index 0000000..c30f3be --- /dev/null +++ b/tests/negative/20-quote-nested.expected.json @@ -0,0 +1,5 @@ +{ + "codes": [ + "markdown.invalid_construct" + ] +} diff --git a/tests/negative/20-quote-nested.mq.md b/tests/negative/20-quote-nested.mq.md new file mode 100644 index 0000000..419a1a6 --- /dev/null +++ b/tests/negative/20-quote-nested.mq.md @@ -0,0 +1,3 @@ +## f + +> > 打印(1) diff --git a/tests/negative/21-quote-empty.expected.json b/tests/negative/21-quote-empty.expected.json new file mode 100644 index 0000000..c30f3be --- /dev/null +++ b/tests/negative/21-quote-empty.expected.json @@ -0,0 +1,5 @@ +{ + "codes": [ + "markdown.invalid_construct" + ] +} diff --git a/tests/negative/21-quote-empty.mq.md b/tests/negative/21-quote-empty.mq.md new file mode 100644 index 0000000..dcf6a4d --- /dev/null +++ b/tests/negative/21-quote-empty.mq.md @@ -0,0 +1,3 @@ +## f + +> diff --git a/tests/negative/22-quote-two-calls-one-paragraph.expected.json b/tests/negative/22-quote-two-calls-one-paragraph.expected.json new file mode 100644 index 0000000..8f17ea3 --- /dev/null +++ b/tests/negative/22-quote-two-calls-one-paragraph.expected.json @@ -0,0 +1,5 @@ +{ + "codes": [ + "expr.parse" + ] +} diff --git a/tests/negative/22-quote-two-calls-one-paragraph.mq.md b/tests/negative/22-quote-two-calls-one-paragraph.mq.md new file mode 100644 index 0000000..70a2566 --- /dev/null +++ b/tests/negative/22-quote-two-calls-one-paragraph.mq.md @@ -0,0 +1,3 @@ +## f + +> 打印(1) 打印(2) diff --git a/tests/negative/23-quote-non-call-expression.expected.json b/tests/negative/23-quote-non-call-expression.expected.json new file mode 100644 index 0000000..c30f3be --- /dev/null +++ b/tests/negative/23-quote-non-call-expression.expected.json @@ -0,0 +1,5 @@ +{ + "codes": [ + "markdown.invalid_construct" + ] +} diff --git a/tests/negative/23-quote-non-call-expression.mq.md b/tests/negative/23-quote-non-call-expression.mq.md new file mode 100644 index 0000000..b297cdd --- /dev/null +++ b/tests/negative/23-quote-non-call-expression.mq.md @@ -0,0 +1,3 @@ +## f + +> 1 + 2 diff --git a/tests/negative/24-quote-link-form-without-arguments.expected.json b/tests/negative/24-quote-link-form-without-arguments.expected.json new file mode 100644 index 0000000..c30f3be --- /dev/null +++ b/tests/negative/24-quote-link-form-without-arguments.expected.json @@ -0,0 +1,5 @@ +{ + "codes": [ + "markdown.invalid_construct" + ] +} diff --git a/tests/negative/24-quote-link-form-without-arguments.mq.md b/tests/negative/24-quote-link-form-without-arguments.mq.md new file mode 100644 index 0000000..9c2f588 --- /dev/null +++ b/tests/negative/24-quote-link-form-without-arguments.mq.md @@ -0,0 +1,7 @@ +## f + +*1* + +## main + +> [f](#f) diff --git a/tests/negative/25-quote-external-link-call.expected.json b/tests/negative/25-quote-external-link-call.expected.json new file mode 100644 index 0000000..73e646b --- /dev/null +++ b/tests/negative/25-quote-external-link-call.expected.json @@ -0,0 +1,5 @@ +{ + "codes": [ + "ref.unresolved" + ] +} diff --git a/tests/negative/25-quote-external-link-call.mq.md b/tests/negative/25-quote-external-link-call.mq.md new file mode 100644 index 0000000..d5bab71 --- /dev/null +++ b/tests/negative/25-quote-external-link-call.mq.md @@ -0,0 +1,3 @@ +## main + +> [x](https://example.com)() diff --git a/tests/negative/26-quote-cross-module-link-call.expected.json b/tests/negative/26-quote-cross-module-link-call.expected.json new file mode 100644 index 0000000..e6a5e73 --- /dev/null +++ b/tests/negative/26-quote-cross-module-link-call.expected.json @@ -0,0 +1,5 @@ +{ + "codes": [ + "module.unresolved" + ] +} diff --git a/tests/negative/26-quote-cross-module-link-call.mq.md b/tests/negative/26-quote-cross-module-link-call.mq.md new file mode 100644 index 0000000..5e25beb --- /dev/null +++ b/tests/negative/26-quote-cross-module-link-call.mq.md @@ -0,0 +1,3 @@ +## main + +> [f](./other.mq.md#f)() diff --git a/tests/negative/27-quote-unresolved-anchor.expected.json b/tests/negative/27-quote-unresolved-anchor.expected.json new file mode 100644 index 0000000..73e646b --- /dev/null +++ b/tests/negative/27-quote-unresolved-anchor.expected.json @@ -0,0 +1,5 @@ +{ + "codes": [ + "ref.unresolved" + ] +} diff --git a/tests/negative/27-quote-unresolved-anchor.mq.md b/tests/negative/27-quote-unresolved-anchor.mq.md new file mode 100644 index 0000000..f7f6016 --- /dev/null +++ b/tests/negative/27-quote-unresolved-anchor.mq.md @@ -0,0 +1,3 @@ +## main + +> [f](#不存在)() diff --git a/tests/negative/28-duplicate-function-name.expected.json b/tests/negative/28-duplicate-function-name.expected.json new file mode 100644 index 0000000..c30f3be --- /dev/null +++ b/tests/negative/28-duplicate-function-name.expected.json @@ -0,0 +1,5 @@ +{ + "codes": [ + "markdown.invalid_construct" + ] +} diff --git a/tests/negative/28-duplicate-function-name.mq.md b/tests/negative/28-duplicate-function-name.mq.md new file mode 100644 index 0000000..78decb3 --- /dev/null +++ b/tests/negative/28-duplicate-function-name.mq.md @@ -0,0 +1,7 @@ +## f + +*1* + +## f + +*2* diff --git a/tests/negative/29-duplicate-namespace-name.expected.json b/tests/negative/29-duplicate-namespace-name.expected.json new file mode 100644 index 0000000..c30f3be --- /dev/null +++ b/tests/negative/29-duplicate-namespace-name.expected.json @@ -0,0 +1,5 @@ +{ + "codes": [ + "markdown.invalid_construct" + ] +} diff --git a/tests/negative/29-duplicate-namespace-name.mq.md b/tests/negative/29-duplicate-namespace-name.mq.md new file mode 100644 index 0000000..fcbe79a --- /dev/null +++ b/tests/negative/29-duplicate-namespace-name.mq.md @@ -0,0 +1,7 @@ +# a + +## f + +*1* + +# a diff --git a/tests/negative/30-empty-function-heading.expected.json b/tests/negative/30-empty-function-heading.expected.json new file mode 100644 index 0000000..c30f3be --- /dev/null +++ b/tests/negative/30-empty-function-heading.expected.json @@ -0,0 +1,5 @@ +{ + "codes": [ + "markdown.invalid_construct" + ] +} diff --git a/tests/negative/30-empty-function-heading.mq.md b/tests/negative/30-empty-function-heading.mq.md new file mode 100644 index 0000000..d040b05 --- /dev/null +++ b/tests/negative/30-empty-function-heading.mq.md @@ -0,0 +1,3 @@ +## + +*1* diff --git a/tests/negative/31-empty-namespace-heading.expected.json b/tests/negative/31-empty-namespace-heading.expected.json new file mode 100644 index 0000000..c30f3be --- /dev/null +++ b/tests/negative/31-empty-namespace-heading.expected.json @@ -0,0 +1,5 @@ +{ + "codes": [ + "markdown.invalid_construct" + ] +} diff --git a/tests/negative/31-empty-namespace-heading.mq.md b/tests/negative/31-empty-namespace-heading.mq.md new file mode 100644 index 0000000..4e53868 --- /dev/null +++ b/tests/negative/31-empty-namespace-heading.mq.md @@ -0,0 +1,5 @@ +# + +## f + +*1* diff --git a/tests/negative/32-unknown-function.expected.json b/tests/negative/32-unknown-function.expected.json new file mode 100644 index 0000000..51b6565 --- /dev/null +++ b/tests/negative/32-unknown-function.expected.json @@ -0,0 +1,5 @@ +{ + "codes": [ + "symbol.unknown" + ] +} diff --git a/tests/negative/32-unknown-function.mq.md b/tests/negative/32-unknown-function.mq.md new file mode 100644 index 0000000..ecdf743 --- /dev/null +++ b/tests/negative/32-unknown-function.mq.md @@ -0,0 +1,3 @@ +## f + +*nope(1)* diff --git a/tests/negative/33-inferred-signature-positional.expected.json b/tests/negative/33-inferred-signature-positional.expected.json new file mode 100644 index 0000000..79d7da1 --- /dev/null +++ b/tests/negative/33-inferred-signature-positional.expected.json @@ -0,0 +1,5 @@ +{ + "codes": [ + "call.arity" + ] +} diff --git a/tests/negative/33-inferred-signature-positional.mq.md b/tests/negative/33-inferred-signature-positional.mq.md new file mode 100644 index 0000000..548d063 --- /dev/null +++ b/tests/negative/33-inferred-signature-positional.mq.md @@ -0,0 +1,9 @@ +## g + +**n = n + 1** + +*n* + +## f + +*g(1)* diff --git a/tests/negative/34-missing-required-argument.expected.json b/tests/negative/34-missing-required-argument.expected.json new file mode 100644 index 0000000..79d7da1 --- /dev/null +++ b/tests/negative/34-missing-required-argument.expected.json @@ -0,0 +1,5 @@ +{ + "codes": [ + "call.arity" + ] +} diff --git a/tests/negative/34-missing-required-argument.mq.md b/tests/negative/34-missing-required-argument.mq.md new file mode 100644 index 0000000..0fb01b4 --- /dev/null +++ b/tests/negative/34-missing-required-argument.mq.md @@ -0,0 +1,9 @@ +## g + +`(a: Int, b: Int)` + +*a + b* + +## f + +*g(a=1)* diff --git a/tests/negative/35-unknown-named-argument.expected.json b/tests/negative/35-unknown-named-argument.expected.json new file mode 100644 index 0000000..79d7da1 --- /dev/null +++ b/tests/negative/35-unknown-named-argument.expected.json @@ -0,0 +1,5 @@ +{ + "codes": [ + "call.arity" + ] +} diff --git a/tests/negative/35-unknown-named-argument.mq.md b/tests/negative/35-unknown-named-argument.mq.md new file mode 100644 index 0000000..c42269d --- /dev/null +++ b/tests/negative/35-unknown-named-argument.mq.md @@ -0,0 +1,9 @@ +## g + +`(a: Int)` + +*a* + +## f + +*g(nope=1, a=2)* diff --git a/tests/negative/36-malformed-signature-name.expected.json b/tests/negative/36-malformed-signature-name.expected.json new file mode 100644 index 0000000..8f17ea3 --- /dev/null +++ b/tests/negative/36-malformed-signature-name.expected.json @@ -0,0 +1,5 @@ +{ + "codes": [ + "expr.parse" + ] +} diff --git a/tests/negative/36-malformed-signature-name.mq.md b/tests/negative/36-malformed-signature-name.mq.md new file mode 100644 index 0000000..7862947 --- /dev/null +++ b/tests/negative/36-malformed-signature-name.mq.md @@ -0,0 +1,5 @@ +## f + +`(1x)` + +*1* diff --git a/tests/negative/37-malformed-signature-duplicate-param.expected.json b/tests/negative/37-malformed-signature-duplicate-param.expected.json new file mode 100644 index 0000000..8f17ea3 --- /dev/null +++ b/tests/negative/37-malformed-signature-duplicate-param.expected.json @@ -0,0 +1,5 @@ +{ + "codes": [ + "expr.parse" + ] +} diff --git a/tests/negative/37-malformed-signature-duplicate-param.mq.md b/tests/negative/37-malformed-signature-duplicate-param.mq.md new file mode 100644 index 0000000..4571968 --- /dev/null +++ b/tests/negative/37-malformed-signature-duplicate-param.mq.md @@ -0,0 +1,5 @@ +## f + +`(a, a)` + +*a* diff --git a/tests/negative/38-signature-non-constant-default.expected.json b/tests/negative/38-signature-non-constant-default.expected.json new file mode 100644 index 0000000..c09be1b --- /dev/null +++ b/tests/negative/38-signature-non-constant-default.expected.json @@ -0,0 +1,6 @@ +{ + "codes": [ + "expr.parse", + "symbol.unknown" + ] +} diff --git a/tests/negative/38-signature-non-constant-default.mq.md b/tests/negative/38-signature-non-constant-default.mq.md new file mode 100644 index 0000000..a2fc2b2 --- /dev/null +++ b/tests/negative/38-signature-non-constant-default.mq.md @@ -0,0 +1,5 @@ +## f + +`(a = f())` + +*a* diff --git a/tests/negative/39-unknown-variable-explicit-signature.expected.json b/tests/negative/39-unknown-variable-explicit-signature.expected.json new file mode 100644 index 0000000..51b6565 --- /dev/null +++ b/tests/negative/39-unknown-variable-explicit-signature.expected.json @@ -0,0 +1,5 @@ +{ + "codes": [ + "symbol.unknown" + ] +} diff --git a/tests/negative/39-unknown-variable-explicit-signature.mq.md b/tests/negative/39-unknown-variable-explicit-signature.mq.md new file mode 100644 index 0000000..da547d9 --- /dev/null +++ b/tests/negative/39-unknown-variable-explicit-signature.mq.md @@ -0,0 +1,5 @@ +## f + +`(r: Number)` + +*r * typo* diff --git a/tests/negative/40-partial-branch-assignment-ambiguity.expected.json b/tests/negative/40-partial-branch-assignment-ambiguity.expected.json new file mode 100644 index 0000000..b08cfd9 --- /dev/null +++ b/tests/negative/40-partial-branch-assignment-ambiguity.expected.json @@ -0,0 +1,5 @@ +{ + "codes": [ + "symbol.uninitialized" + ] +} diff --git a/tests/negative/40-partial-branch-assignment-ambiguity.mq.md b/tests/negative/40-partial-branch-assignment-ambiguity.mq.md new file mode 100644 index 0000000..e790fff --- /dev/null +++ b/tests/negative/40-partial-branch-assignment-ambiguity.mq.md @@ -0,0 +1,7 @@ +## f + +1. `true` + + **x = 1** + +*x* diff --git a/tests/negative/41-frontmatter-invalid-yaml.expected.json b/tests/negative/41-frontmatter-invalid-yaml.expected.json new file mode 100644 index 0000000..5843bab --- /dev/null +++ b/tests/negative/41-frontmatter-invalid-yaml.expected.json @@ -0,0 +1,5 @@ +{ + "codes": [ + "frontmatter.invalid" + ] +} diff --git a/tests/negative/41-frontmatter-invalid-yaml.mq.md b/tests/negative/41-frontmatter-invalid-yaml.mq.md new file mode 100644 index 0000000..a35bc11 --- /dev/null +++ b/tests/negative/41-frontmatter-invalid-yaml.mq.md @@ -0,0 +1,7 @@ +--- +import: [unclosed +--- + +## main + +*1* diff --git a/tests/negative/42-frontmatter-invalid-import-shape.expected.json b/tests/negative/42-frontmatter-invalid-import-shape.expected.json new file mode 100644 index 0000000..5843bab --- /dev/null +++ b/tests/negative/42-frontmatter-invalid-import-shape.expected.json @@ -0,0 +1,5 @@ +{ + "codes": [ + "frontmatter.invalid" + ] +} diff --git a/tests/negative/42-frontmatter-invalid-import-shape.mq.md b/tests/negative/42-frontmatter-invalid-import-shape.mq.md new file mode 100644 index 0000000..68b48ba --- /dev/null +++ b/tests/negative/42-frontmatter-invalid-import-shape.mq.md @@ -0,0 +1,7 @@ +--- +import: 42 +--- + +## main + +*1* diff --git a/tests/negative/43-unknown-callee-in-quote.expected.json b/tests/negative/43-unknown-callee-in-quote.expected.json new file mode 100644 index 0000000..51b6565 --- /dev/null +++ b/tests/negative/43-unknown-callee-in-quote.expected.json @@ -0,0 +1,5 @@ +{ + "codes": [ + "symbol.unknown" + ] +} diff --git a/tests/negative/43-unknown-callee-in-quote.mq.md b/tests/negative/43-unknown-callee-in-quote.mq.md new file mode 100644 index 0000000..fc71c96 --- /dev/null +++ b/tests/negative/43-unknown-callee-in-quote.mq.md @@ -0,0 +1,3 @@ +## f + +> nope(1) diff --git a/tests/negative/44-link-call-bad-arguments.expected.json b/tests/negative/44-link-call-bad-arguments.expected.json new file mode 100644 index 0000000..8f17ea3 --- /dev/null +++ b/tests/negative/44-link-call-bad-arguments.expected.json @@ -0,0 +1,5 @@ +{ + "codes": [ + "expr.parse" + ] +} diff --git a/tests/negative/44-link-call-bad-arguments.mq.md b/tests/negative/44-link-call-bad-arguments.mq.md new file mode 100644 index 0000000..7d3b23f --- /dev/null +++ b/tests/negative/44-link-call-bad-arguments.mq.md @@ -0,0 +1,7 @@ +## f + +*1* + +## main + +> [f](#f)(a=) diff --git a/tests/negative/45-branch-condition-invalid-expression.expected.json b/tests/negative/45-branch-condition-invalid-expression.expected.json new file mode 100644 index 0000000..8f17ea3 --- /dev/null +++ b/tests/negative/45-branch-condition-invalid-expression.expected.json @@ -0,0 +1,5 @@ +{ + "codes": [ + "expr.parse" + ] +} diff --git a/tests/negative/45-branch-condition-invalid-expression.mq.md b/tests/negative/45-branch-condition-invalid-expression.mq.md new file mode 100644 index 0000000..0cb32c0 --- /dev/null +++ b/tests/negative/45-branch-condition-invalid-expression.mq.md @@ -0,0 +1,5 @@ +## f + +1. `n >` + + *1* diff --git a/tests/negative/46-duplicate-import-alias-frontmatter.expected.json b/tests/negative/46-duplicate-import-alias-frontmatter.expected.json new file mode 100644 index 0000000..5843bab --- /dev/null +++ b/tests/negative/46-duplicate-import-alias-frontmatter.expected.json @@ -0,0 +1,5 @@ +{ + "codes": [ + "frontmatter.invalid" + ] +} diff --git a/tests/negative/46-duplicate-import-alias-frontmatter.mq.md b/tests/negative/46-duplicate-import-alias-frontmatter.mq.md new file mode 100644 index 0000000..68e441b --- /dev/null +++ b/tests/negative/46-duplicate-import-alias-frontmatter.mq.md @@ -0,0 +1,9 @@ +--- +import: + a: "x" + a: "y" +--- + +## main + +*1* diff --git a/tests/negative/47-unsupported-quote-statement.expected.json b/tests/negative/47-unsupported-quote-statement.expected.json new file mode 100644 index 0000000..8f17ea3 --- /dev/null +++ b/tests/negative/47-unsupported-quote-statement.expected.json @@ -0,0 +1,5 @@ +{ + "codes": [ + "expr.parse" + ] +} diff --git a/tests/negative/47-unsupported-quote-statement.mq.md b/tests/negative/47-unsupported-quote-statement.mq.md new file mode 100644 index 0000000..4bc8c94 --- /dev/null +++ b/tests/negative/47-unsupported-quote-statement.mq.md @@ -0,0 +1,3 @@ +## f + +> `x = 1` diff --git a/tests/negative/48-strong-assignment-bad-target.expected.json b/tests/negative/48-strong-assignment-bad-target.expected.json new file mode 100644 index 0000000..8f17ea3 --- /dev/null +++ b/tests/negative/48-strong-assignment-bad-target.expected.json @@ -0,0 +1,5 @@ +{ + "codes": [ + "expr.parse" + ] +} diff --git a/tests/negative/48-strong-assignment-bad-target.mq.md b/tests/negative/48-strong-assignment-bad-target.mq.md new file mode 100644 index 0000000..0a2e8a4 --- /dev/null +++ b/tests/negative/48-strong-assignment-bad-target.mq.md @@ -0,0 +1,3 @@ +## f + +**1x = 2** diff --git a/tests/negative/runtime/01-division-by-zero.expected.json b/tests/negative/runtime/01-division-by-zero.expected.json new file mode 100644 index 0000000..18c5e25 --- /dev/null +++ b/tests/negative/runtime/01-division-by-zero.expected.json @@ -0,0 +1,7 @@ +{ + "function": "main", + "args": {}, + "codes": [ + "runtime.division_by_zero" + ] +} diff --git a/tests/negative/runtime/01-division-by-zero.mq.md b/tests/negative/runtime/01-division-by-zero.mq.md new file mode 100644 index 0000000..9e7872f --- /dev/null +++ b/tests/negative/runtime/01-division-by-zero.mq.md @@ -0,0 +1,3 @@ +## main + +*1 // 0* diff --git a/tests/negative/runtime/02-type-error.expected.json b/tests/negative/runtime/02-type-error.expected.json new file mode 100644 index 0000000..deec1d6 --- /dev/null +++ b/tests/negative/runtime/02-type-error.expected.json @@ -0,0 +1,7 @@ +{ + "function": "main", + "args": {}, + "codes": [ + "runtime.type" + ] +} diff --git a/tests/negative/runtime/02-type-error.mq.md b/tests/negative/runtime/02-type-error.mq.md new file mode 100644 index 0000000..8069839 --- /dev/null +++ b/tests/negative/runtime/02-type-error.mq.md @@ -0,0 +1,3 @@ +## main + +*1 + "x"* diff --git a/tests/negative/runtime/03-index-out-of-bounds.expected.json b/tests/negative/runtime/03-index-out-of-bounds.expected.json new file mode 100644 index 0000000..6ab53b5 --- /dev/null +++ b/tests/negative/runtime/03-index-out-of-bounds.expected.json @@ -0,0 +1,7 @@ +{ + "function": "main", + "args": {}, + "codes": [ + "runtime.index" + ] +} diff --git a/tests/negative/runtime/03-index-out-of-bounds.mq.md b/tests/negative/runtime/03-index-out-of-bounds.mq.md new file mode 100644 index 0000000..4fc331b --- /dev/null +++ b/tests/negative/runtime/03-index-out-of-bounds.mq.md @@ -0,0 +1,3 @@ +## main + +*[1, 2][5]* diff --git a/tests/negative/runtime/04-unknown-field.expected.json b/tests/negative/runtime/04-unknown-field.expected.json new file mode 100644 index 0000000..81ab429 --- /dev/null +++ b/tests/negative/runtime/04-unknown-field.expected.json @@ -0,0 +1,7 @@ +{ + "function": "main", + "args": {}, + "codes": [ + "runtime.unknown_field" + ] +} diff --git a/tests/negative/runtime/04-unknown-field.mq.md b/tests/negative/runtime/04-unknown-field.mq.md new file mode 100644 index 0000000..7a99061 --- /dev/null +++ b/tests/negative/runtime/04-unknown-field.mq.md @@ -0,0 +1,3 @@ +## main + +*{"a": 1}.b* diff --git a/tests/negative/runtime/05-not-callable.expected.json b/tests/negative/runtime/05-not-callable.expected.json new file mode 100644 index 0000000..af4dbfd --- /dev/null +++ b/tests/negative/runtime/05-not-callable.expected.json @@ -0,0 +1,7 @@ +{ + "function": "main", + "args": {}, + "codes": [ + "call.not_callable" + ] +} diff --git a/tests/negative/runtime/05-not-callable.mq.md b/tests/negative/runtime/05-not-callable.mq.md new file mode 100644 index 0000000..de123e6 --- /dev/null +++ b/tests/negative/runtime/05-not-callable.mq.md @@ -0,0 +1,5 @@ +## main + +**x = 1** + +*x(1)* diff --git a/tests/negative/runtime/06-permission-denied-foreign.expected.json b/tests/negative/runtime/06-permission-denied-foreign.expected.json new file mode 100644 index 0000000..0d8ddc6 --- /dev/null +++ b/tests/negative/runtime/06-permission-denied-foreign.expected.json @@ -0,0 +1,7 @@ +{ + "function": "main", + "args": {}, + "codes": [ + "permission.denied" + ] +} diff --git a/tests/negative/runtime/06-permission-denied-foreign.mq.md b/tests/negative/runtime/06-permission-denied-foreign.mq.md new file mode 100644 index 0000000..89dde49 --- /dev/null +++ b/tests/negative/runtime/06-permission-denied-foreign.mq.md @@ -0,0 +1,9 @@ +## 代码 + +```python +print(1) +``` + +## main + +*foreign.call(ref("#代码"), None)* diff --git a/tests/negative/runtime/07-math-unsupported.expected.json b/tests/negative/runtime/07-math-unsupported.expected.json new file mode 100644 index 0000000..ceb9105 --- /dev/null +++ b/tests/negative/runtime/07-math-unsupported.expected.json @@ -0,0 +1,7 @@ +{ + "function": "main", + "args": {}, + "codes": [ + "math.unsupported" + ] +} diff --git a/tests/negative/runtime/07-math-unsupported.mq.md b/tests/negative/runtime/07-math-unsupported.mq.md new file mode 100644 index 0000000..afc6166 --- /dev/null +++ b/tests/negative/runtime/07-math-unsupported.mq.md @@ -0,0 +1,9 @@ +## 公式 + +$$ +\sin(x) +$$ + +## main + +*math.eval(ref("#公式"), {})* diff --git a/tests/negative/runtime/08-stack-overflow.expected.json b/tests/negative/runtime/08-stack-overflow.expected.json new file mode 100644 index 0000000..9e222e2 --- /dev/null +++ b/tests/negative/runtime/08-stack-overflow.expected.json @@ -0,0 +1,8 @@ +{ + "function": "递归", + "args": {}, + "codes": [ + "resource.exhausted" + ], + "stack_limit": 24 +} diff --git a/tests/negative/runtime/08-stack-overflow.mq.md b/tests/negative/runtime/08-stack-overflow.mq.md new file mode 100644 index 0000000..d373f54 --- /dev/null +++ b/tests/negative/runtime/08-stack-overflow.mq.md @@ -0,0 +1,3 @@ +## 递归 + +*递归()* diff --git a/tests/negative/runtime/09-branch-condition-not-bool.expected.json b/tests/negative/runtime/09-branch-condition-not-bool.expected.json new file mode 100644 index 0000000..deec1d6 --- /dev/null +++ b/tests/negative/runtime/09-branch-condition-not-bool.expected.json @@ -0,0 +1,7 @@ +{ + "function": "main", + "args": {}, + "codes": [ + "runtime.type" + ] +} diff --git a/tests/negative/runtime/09-branch-condition-not-bool.mq.md b/tests/negative/runtime/09-branch-condition-not-bool.mq.md new file mode 100644 index 0000000..2cf43db --- /dev/null +++ b/tests/negative/runtime/09-branch-condition-not-bool.mq.md @@ -0,0 +1,5 @@ +## main + +1. `1` + + *1* diff --git a/tests/negative/runtime/10-function-ref-bad-argument.expected.json b/tests/negative/runtime/10-function-ref-bad-argument.expected.json new file mode 100644 index 0000000..2f5e44b --- /dev/null +++ b/tests/negative/runtime/10-function-ref-bad-argument.expected.json @@ -0,0 +1,7 @@ +{ + "function": "main", + "args": {}, + "codes": [ + "call.arity" + ] +} diff --git a/tests/negative/runtime/10-function-ref-bad-argument.mq.md b/tests/negative/runtime/10-function-ref-bad-argument.mq.md new file mode 100644 index 0000000..ef984de --- /dev/null +++ b/tests/negative/runtime/10-function-ref-bad-argument.mq.md @@ -0,0 +1,11 @@ +## f + +**n = n + 1** + +*n* + +## main + +**g = ref("#f")** + +*g(bad=1)* diff --git a/tests/negative/warnings/01-return-outside-function.expected.json b/tests/negative/warnings/01-return-outside-function.expected.json new file mode 100644 index 0000000..60cb3cb --- /dev/null +++ b/tests/negative/warnings/01-return-outside-function.expected.json @@ -0,0 +1,6 @@ +{ + "severity": "warning", + "codes": [ + "markdown.inert_executable" + ] +} diff --git a/tests/negative/warnings/01-return-outside-function.mq.md b/tests/negative/warnings/01-return-outside-function.mq.md new file mode 100644 index 0000000..10fd998 --- /dev/null +++ b/tests/negative/warnings/01-return-outside-function.mq.md @@ -0,0 +1 @@ +*1* diff --git a/tests/negative/warnings/02-strong-outside-function.expected.json b/tests/negative/warnings/02-strong-outside-function.expected.json new file mode 100644 index 0000000..60cb3cb --- /dev/null +++ b/tests/negative/warnings/02-strong-outside-function.expected.json @@ -0,0 +1,6 @@ +{ + "severity": "warning", + "codes": [ + "markdown.inert_executable" + ] +} diff --git a/tests/negative/warnings/02-strong-outside-function.mq.md b/tests/negative/warnings/02-strong-outside-function.mq.md new file mode 100644 index 0000000..c33dc3b --- /dev/null +++ b/tests/negative/warnings/02-strong-outside-function.mq.md @@ -0,0 +1 @@ +**x = 1** diff --git a/tests/negative/warnings/03-ordered-list-outside-function.expected.json b/tests/negative/warnings/03-ordered-list-outside-function.expected.json new file mode 100644 index 0000000..60cb3cb --- /dev/null +++ b/tests/negative/warnings/03-ordered-list-outside-function.expected.json @@ -0,0 +1,6 @@ +{ + "severity": "warning", + "codes": [ + "markdown.inert_executable" + ] +} diff --git a/tests/negative/warnings/03-ordered-list-outside-function.mq.md b/tests/negative/warnings/03-ordered-list-outside-function.mq.md new file mode 100644 index 0000000..8787ffc --- /dev/null +++ b/tests/negative/warnings/03-ordered-list-outside-function.mq.md @@ -0,0 +1,3 @@ +1. `true` + + *1* diff --git a/tests/negative/warnings/04-bullet-list-outside-function.expected.json b/tests/negative/warnings/04-bullet-list-outside-function.expected.json new file mode 100644 index 0000000..60cb3cb --- /dev/null +++ b/tests/negative/warnings/04-bullet-list-outside-function.expected.json @@ -0,0 +1,6 @@ +{ + "severity": "warning", + "codes": [ + "markdown.inert_executable" + ] +} diff --git a/tests/negative/warnings/04-bullet-list-outside-function.mq.md b/tests/negative/warnings/04-bullet-list-outside-function.mq.md new file mode 100644 index 0000000..a454281 --- /dev/null +++ b/tests/negative/warnings/04-bullet-list-outside-function.mq.md @@ -0,0 +1,3 @@ +- `true` + + *1* diff --git a/tests/negative/warnings/05-quote-outside-function.expected.json b/tests/negative/warnings/05-quote-outside-function.expected.json new file mode 100644 index 0000000..60cb3cb --- /dev/null +++ b/tests/negative/warnings/05-quote-outside-function.expected.json @@ -0,0 +1,6 @@ +{ + "severity": "warning", + "codes": [ + "markdown.inert_executable" + ] +} diff --git a/tests/negative/warnings/05-quote-outside-function.mq.md b/tests/negative/warnings/05-quote-outside-function.mq.md new file mode 100644 index 0000000..d9a57b4 --- /dev/null +++ b/tests/negative/warnings/05-quote-outside-function.mq.md @@ -0,0 +1 @@ +> 打印(1) diff --git a/tests/negative/warnings/06-executable-in-module-root-prose.expected.json b/tests/negative/warnings/06-executable-in-module-root-prose.expected.json new file mode 100644 index 0000000..6baa22a --- /dev/null +++ b/tests/negative/warnings/06-executable-in-module-root-prose.expected.json @@ -0,0 +1,7 @@ +{ + "severity": "warning", + "codes": [ + "markdown.inert_executable", + "markdown.inert_executable" + ] +} diff --git a/tests/negative/warnings/06-executable-in-module-root-prose.mq.md b/tests/negative/warnings/06-executable-in-module-root-prose.mq.md new file mode 100644 index 0000000..8a2e95e --- /dev/null +++ b/tests/negative/warnings/06-executable-in-module-root-prose.mq.md @@ -0,0 +1,5 @@ +模块开头的叙述。 + +**结果 = 1** + +继续叙述,*返回表达式* 也在函数外。