From 021284e5afd831938eae55759b11e3603fd5aa84 Mon Sep 17 00:00:00 2001 From: Anton Bachin Date: Sat, 17 Aug 2019 10:01:55 +0300 Subject: [PATCH] Parser: test comments nested in code blocks See #375. --- test/parser/expect/code-block/comment.txt | 3 +++ .../code-block/docstring-with-code-block.txt | 19 +++++++++++++++++++ test/parser/expect/code-block/docstring.txt | 3 +++ test/parser/test.ml | 3 +++ 4 files changed, 28 insertions(+) create mode 100644 test/parser/expect/code-block/comment.txt create mode 100644 test/parser/expect/code-block/docstring-with-code-block.txt create mode 100644 test/parser/expect/code-block/docstring.txt diff --git a/test/parser/expect/code-block/comment.txt b/test/parser/expect/code-block/comment.txt new file mode 100644 index 0000000000..05c6254d5b --- /dev/null +++ b/test/parser/expect/code-block/comment.txt @@ -0,0 +1,3 @@ +((output (((f.ml (1 0) (2 14)) (code_block "(* foo *)\ + \nlet bar = ()")))) + (warnings ())) diff --git a/test/parser/expect/code-block/docstring-with-code-block.txt b/test/parser/expect/code-block/docstring-with-code-block.txt new file mode 100644 index 0000000000..9ff4220410 --- /dev/null +++ b/test/parser/expect/code-block/docstring-with-code-block.txt @@ -0,0 +1,19 @@ +((output + (((f.ml (1 0) (1 13)) (code_block "(** {[foo")) + ((f.ml (1 14) (2 13)) + (paragraph + (((f.ml (1 14) (1 16)) (word "*)")) ((f.ml (1 16) (2 0)) space) + ((f.ml (2 0) (2 3)) (word let)) ((f.ml (2 3) (2 4)) space) + ((f.ml (2 4) (2 7)) (word bar)) ((f.ml (2 7) (2 8)) space) + ((f.ml (2 8) (2 9)) (word =)) ((f.ml (2 9) (2 10)) space) + ((f.ml (2 10) (2 12)) (word "()")) ((f.ml (2 12) (2 13)) (word ]))))) + ((f.ml (2 13) (2 14)) (paragraph (((f.ml (2 13) (2 14)) (word }))))))) + (warnings + ( "File \"f.ml\", line 1, characters 14-16:\ + \nParagraph should begin on its own line." + "File \"f.ml\", line 2, characters 12-13:\ + \nUnpaired ']' (end of code).\ + \nSuggestion: try '\\]'." + "File \"f.ml\", line 2, characters 13-14:\ + \nUnpaired '}' (end of markup).\ + \nSuggestion: try '\\}'."))) diff --git a/test/parser/expect/code-block/docstring.txt b/test/parser/expect/code-block/docstring.txt new file mode 100644 index 0000000000..ae31aef4ed --- /dev/null +++ b/test/parser/expect/code-block/docstring.txt @@ -0,0 +1,3 @@ +((output (((f.ml (1 0) (2 14)) (code_block "(** foo *)\ + \nlet bar = ()")))) + (warnings ())) diff --git a/test/parser/test.ml b/test/parser/test.ml index 576b05887c..5f31a0b3e6 100644 --- a/test/parser/test.ml +++ b/test/parser/test.ml @@ -334,6 +334,9 @@ let tests : test_suite list = [ t "unterminated" "{[foo"; t "unterminated-bracket" "{[foo]"; t "trailing-cr" "{[foo\r]}"; + t "comment" "{[(* foo *)\nlet bar = ()]}"; + t "docstring" "{[(** foo *)\nlet bar = ()]}"; + t "docstring-with-code-block" "{[(** {[foo]} *)\nlet bar = ()]}"; ]; "verbatim", [