Translate Types and Utilities parity tests
Some checks failed
Rust API gates / api-gates (push) Has been cancelled
Some checks failed
Rust API gates / api-gates (push) Has been cancelled
This commit is contained in:
@@ -4,10 +4,37 @@ import unittest
|
||||
from pathlib import Path
|
||||
from unittest.mock import patch
|
||||
|
||||
from generate_surface import check_test_parity, extract_tests, generate_tests
|
||||
from generate_surface import check_test_parity, extract_tests, generate_tests, mask_csharp_comments
|
||||
|
||||
|
||||
class ParityGenerationTests(unittest.TestCase):
|
||||
def test_comment_masking_preserves_offsets_and_ignores_fake_tests(self) -> None:
|
||||
source = '''var url = "https://example.com/[Test]"; // [Test]\n/* [TestCase(1)] */\n[Test]\n'''
|
||||
masked = mask_csharp_comments(source)
|
||||
self.assertEqual(len(masked), len(source))
|
||||
self.assertEqual(masked.count("\n"), source.count("\n"))
|
||||
self.assertIn('"https://example.com/[Test]"', masked)
|
||||
self.assertEqual(masked.count("[Test]"), 2)
|
||||
|
||||
with tempfile.TemporaryDirectory() as temporary:
|
||||
upstream = Path(temporary)
|
||||
tests = upstream / "LibreMetaverse.Tests"
|
||||
tests.mkdir()
|
||||
(upstream / "LibreMetaverse.Rendering.Tests").mkdir()
|
||||
(tests / "Comments.cs").write_text(
|
||||
"""public class Comments
|
||||
{
|
||||
// [Test]
|
||||
// public void CommentedOut() {}
|
||||
[Test]
|
||||
[TestCase(1)]
|
||||
[TestCase(2)]
|
||||
public void Cases(int value) {}
|
||||
}
|
||||
"""
|
||||
)
|
||||
self.assertEqual([case["parameter_case"] for case in extract_tests(upstream)], ["1", "2"])
|
||||
|
||||
def test_reviewed_rust_test_is_preserved_and_excluded_from_placeholders(self) -> None:
|
||||
with tempfile.TemporaryDirectory() as temporary:
|
||||
root = Path(temporary)
|
||||
|
||||
Reference in New Issue
Block a user