From 05727bfc3a9cfd45a8e2028dfd0806f7a8f88015 Mon Sep 17 00:00:00 2001 From: Laurenz Date: Sat, 20 Feb 2021 17:53:40 +0100 Subject: =?UTF-8?q?Reorganize=20tests=20=F0=9F=94=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- tests/typ/markup/emph.typ | 14 ++++++++++++ tests/typ/markup/escape.typ | 30 +++++++++++++++++++++++++ tests/typ/markup/heading.typ | 44 ++++++++++++++++++++++++++++++++++++ tests/typ/markup/linebreak.typ | 23 +++++++++++++++++++ tests/typ/markup/nbsp.typ | 5 +++++ tests/typ/markup/raw.typ | 51 ++++++++++++++++++++++++++++++++++++++++++ tests/typ/markup/strong.typ | 14 ++++++++++++ 7 files changed, 181 insertions(+) create mode 100644 tests/typ/markup/emph.typ create mode 100644 tests/typ/markup/escape.typ create mode 100644 tests/typ/markup/heading.typ create mode 100644 tests/typ/markup/linebreak.typ create mode 100644 tests/typ/markup/nbsp.typ create mode 100644 tests/typ/markup/raw.typ create mode 100644 tests/typ/markup/strong.typ (limited to 'tests/typ/markup') diff --git a/tests/typ/markup/emph.typ b/tests/typ/markup/emph.typ new file mode 100644 index 00000000..772e15ab --- /dev/null +++ b/tests/typ/markup/emph.typ @@ -0,0 +1,14 @@ +// Test emphasis toggle. + +--- +// Basic. +_Emphasized!_ + +// Inside of words. +Partly em_phas_ized. + +// Scoped to body. +#box[_Scoped] to body. + +// Unterminated is fine. +_The End diff --git a/tests/typ/markup/escape.typ b/tests/typ/markup/escape.typ new file mode 100644 index 00000000..eeac4997 --- /dev/null +++ b/tests/typ/markup/escape.typ @@ -0,0 +1,30 @@ +// Test escape sequences. + +--- +// Escapable symbols. +\\ \/ \[ \] \{ \} \# \* \_ \= \~ \` \$ + +// No need to escape. +( ) ; < > + +// Unescapable. +\a \: \; \( \) + +// Escaped comments. +\// +\/\* \*\/ +\/* \*/ * + +// Unicode escape sequence. +\u{1F3D5} == 🏕 + +// Escaped escape sequence. +\u{41} vs. \\u\{41\} + +// Unicode codepoint does not exist. +// Error: 1-11 invalid unicode escape sequence +\u{FFFFFF} + +// Unterminated. +// Error: 6 expected closing brace +\u{41*Bold* diff --git a/tests/typ/markup/heading.typ b/tests/typ/markup/heading.typ new file mode 100644 index 00000000..8497ec8f --- /dev/null +++ b/tests/typ/markup/heading.typ @@ -0,0 +1,44 @@ +// Test headings. + +--- +// Different number of hashtags. + +// Valid levels. +=1 +===2 +======6 + +// Too many hashtags. +// Warning: 1-8 should not exceed depth 6 +=======7 + +--- +// Heading continuation over linebreak. + +// Code blocks continue heading. += A{ + "B" +} + +// Function call continues heading. += #box[ + A +] B + +// Without some kind of block, headings end at a line break. += A +B + +--- +// Heading vs. no heading. + +// Parsed as headings if at start of the context. +/**/ = Ok +{[== Ok]} +#box[=== Ok] + +// Not at the start of the context. +No = heading + +// Escaped. +\= No heading diff --git a/tests/typ/markup/linebreak.typ b/tests/typ/markup/linebreak.typ new file mode 100644 index 00000000..e6392992 --- /dev/null +++ b/tests/typ/markup/linebreak.typ @@ -0,0 +1,23 @@ +// Test forced line breaks. + +--- +// Directly after word. +Line\ Break + +// Spaces around. +Line \ Break + +// Directly before word does not work. +No \Break + +--- +// Leading line break. +\ Leading + +// Trailing before paragraph break. +Trailing 1 \ + +Trailing 2 + +// Trailing before end of document. +Trailing 3 \ diff --git a/tests/typ/markup/nbsp.typ b/tests/typ/markup/nbsp.typ new file mode 100644 index 00000000..5af6c84f --- /dev/null +++ b/tests/typ/markup/nbsp.typ @@ -0,0 +1,5 @@ +// Test the non breaking space. + +--- +// Parsed correctly, but not actually doing anything at the moment. +The non-breaking~space does not work. diff --git a/tests/typ/markup/raw.typ b/tests/typ/markup/raw.typ new file mode 100644 index 00000000..f5074c8e --- /dev/null +++ b/tests/typ/markup/raw.typ @@ -0,0 +1,51 @@ +// Test raw blocks. + +--- +// No extra space. +`A``B` + +--- +// Typst syntax inside. +`#let x = 1` \ +`#[f 1]` + +--- +// Multiline block splits paragraphs. + +First +``` +Second +``` +Third + +--- +// Lots of backticks inside. +```` +```backticks``` +```` + +--- +// Trimming. + +// Space between "rust" and "let" is trimmed. +The keyword ```rust let```. + +// Trimming depends on number backticks. +<``> \ +<` untrimmed `> \ +<``` trimmed` ```> \ +<``` trimmed ```> \ +<``` trimmed```> + +// Multiline trimming. +```py +import this + +def hi(): + print("Hi!") +``` + +--- +// Unterminated. +// Error: 2:1 expected backtick(s) +`endless diff --git a/tests/typ/markup/strong.typ b/tests/typ/markup/strong.typ new file mode 100644 index 00000000..b02a55a5 --- /dev/null +++ b/tests/typ/markup/strong.typ @@ -0,0 +1,14 @@ +// Test strong toggle. + +--- +// Basic. +*Strong!* + +// Inside of words. +Partly str*ength*ened. + +// Scoped to body. +#box[*Scoped] to body. + +// Unterminated is fine. +*The End -- cgit v1.2.3