Test yul code blocks in documentation.

This commit is contained in:
Marenz
2021-07-08 14:59:05 +02:00
parent 9a0da17a6d
commit d844d84b51
8 changed files with 199 additions and 52 deletions
+1 -1
View File
@@ -364,7 +364,7 @@ SOLTMPDIR=$(mktemp -d)
"$REPO_ROOT"/scripts/isolate_tests.py "$REPO_ROOT"/docs/
developmentVersion=$("$REPO_ROOT/scripts/get_version.sh")
for f in *.sol
for f in *.yul *.sol
do
# The contributors guide uses syntax tests, but we cannot
# really handle them here.
+22
View File
@@ -20,3 +20,25 @@ Some text
contract C {}
More text.
.. code-block:: yul
let x := add(1, 5)
.. code-block:: yul
// Yul code wrapped in object
{
{
let y := mul(3, 5)
}
}
.. code-block:: yul
// Yul code wrapped in named object
object "Test" {
{
let y := mul(6, 9)
}
}
@@ -46,3 +46,26 @@ Sphinx does not complain about these.
contract E {}
More text.
.. code-block:: yul
:force:
let x := add(1, 5)
.. code-block:: yul
:linenos:
:language: Yul
// Yul code wrapped in object
{
let y := mul(3, 5)
}
.. code-block:: yul
// Yul code wrapped in named object
object "Test" {
let y := mul(3, 5)
:linenos:
}
+54 -3
View File
@@ -8,7 +8,7 @@ from unittest_helpers import FIXTURE_DIR, load_fixture
# NOTE: This test file file only works with scripts/ added to PYTHONPATH so pylint can't find the imports
# pragma pylint: disable=import-error
from isolate_tests import extract_docs_cases
from isolate_tests import extract_solidity_docs_cases, extract_yul_docs_cases
# pragma pylint: enable=import-error
CODE_BLOCK_RST_PATH = FIXTURE_DIR / 'code_block.rst'
@@ -41,7 +41,7 @@ class TestExtractDocsCases(unittest.TestCase):
""",
]]
self.assertEqual(extract_docs_cases(CODE_BLOCK_RST_PATH), expected_cases)
self.assertEqual(extract_solidity_docs_cases(CODE_BLOCK_RST_PATH), expected_cases)
def test_solidity_block_with_directives(self):
expected_cases = [formatCase(case) for case in [
@@ -66,4 +66,55 @@ class TestExtractDocsCases(unittest.TestCase):
""",
]]
self.assertEqual(extract_docs_cases(CODE_BLOCK_WITH_DIRECTIVES_RST_PATH), expected_cases)
self.assertEqual(extract_solidity_docs_cases(CODE_BLOCK_WITH_DIRECTIVES_RST_PATH), expected_cases)
def test_yul_block(self):
expected_cases = [formatCase(case) for case in [
"""
{
let x := add(1, 5)
}
""",
"""
// Yul code wrapped in object
{
{
let y := mul(3, 5)
}
}
""",
"""
// Yul code wrapped in named object
object "Test" {
{
let y := mul(6, 9)
}
}
""",
]]
self.assertEqual(extract_yul_docs_cases(CODE_BLOCK_RST_PATH), expected_cases)
def test_yul_block_with_directives(self):
expected_cases = [formatCase(case) for case in [
"""
{
let x := add(1, 5)
}
""",
"""
// Yul code wrapped in object
{
let y := mul(3, 5)
}
""",
"""
// Yul code wrapped in named object
object "Test" {
let y := mul(3, 5)
:linenos:
}
""",
]]
self.assertEqual(extract_yul_docs_cases(CODE_BLOCK_WITH_DIRECTIVES_RST_PATH), expected_cases)