Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 40 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
name: tests

on:
push:
branches: ["master", "phase*/**", "srix"]
pull_request:

jobs:
pytest:
name: pytest (py${{ matrix.python }})
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
python: ["3.10", "3.12"]
steps:
- uses: actions/checkout@v5
- uses: actions/setup-python@v6
with:
python-version: ${{ matrix.python }}
cache: pip
- run: python -m pip install -r requirements.txt
- run: python -m pytest -q

codegen-drift:
# The generated parsers under pytamil/தமிழ்/codegen are committed. Regenerate them
# from the grammars and fail if anything differs, so grammar and codegen cannot drift.
name: codegen matches grammars
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v5
- uses: actions/setup-java@v5
with:
distribution: temurin
java-version: "21"
- run: bash codegen.sh
- name: fail on drift
run: |
git status --porcelain -- pytamil/தமிழ்/codegen
git diff --exit-code --stat -- pytamil/தமிழ்/codegen
8 changes: 2 additions & 6 deletions pytamil/tests/test_ஆசிரியப்பா.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,9 +58,7 @@ def test_நேரிசை_ஆசிரியப்பா(பத்தி):

@pytest.mark.parametrize("பத்தி", \
[
# Known failure: தண்மையும் / வெம்மையும் scan as தேமாங்காய் because சீர்.g4 treats
# word-medial ஐ as நெடில் (should be ஐகாரக்குறுக்கம் = குறில்). See specs/2026-09-20-revival-and-roadmap.md, Phase 1a.
pytest.param('''நீரின் தண்மையும் தீயின் வெம்மையும்
('''நீரின் தண்மையும் தீயின் வெம்மையும்
= தேமா கூவிளம் தேமா கூவிளம்
சாரச் சார்ந்து
= தேமா தேமா
Expand All @@ -71,9 +69,7 @@ def test_நேரிசை_ஆசிரியப்பா(பத்தி):
சாரச் சாரச் சார்ந்து
= தேமா தேமா தேமா
தீரத் தீரத் தீர்பொல் லாதே
= தேமா தேமா தேமா தேமா''',
marks=pytest.mark.xfail(
reason="ஐகாரக்குறுக்கம் scanned as நெடில் in சீர்.g4 (specs/2026-09-20-revival-and-roadmap.md, Phase 1a)", strict=True)),
= தேமா தேமா தேமா தேமா'''),
])
def test_இணைக்குறள்_ஆசிரியப்பா(பத்தி):

Expand Down
35 changes: 30 additions & 5 deletions pytamil/tests/test_சீர்.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,9 @@
[
("வானினும்"),
("நீரினும்"),
# Known failure: சீர்.g4 lists every ஐ syllable only as நெடில், so தண்/மையும் parses as
# நேர் நேர் நேர் = தேமாங்காய். Word-medial ஐ is ஐகாரக்குறுக்கம் and should scan குறில்,
# giving நேர் நிரை = கூவிளம். Fix planned in specs/2026-09-20-revival-and-roadmap.md, Phase 1a.
pytest.param("தண்மையும்", marks=pytest.mark.xfail(
reason="ஐகாரக்குறுக்கம் scanned as நெடில் in சீர்.g4 (specs/2026-09-20-revival-and-roadmap.md, Phase 1a)", strict=True)),
("தண்மையும்"),
("வெம்மையும்"),
("கையினை"), # சீர்முதல் ஐ நெடில்: கை/யினை; புளிமா ஆகக் கூடாது
])
def test_கூவிளம்(பதம்):
புது_சீர்_வாய்பாடு = சீர்.சீர்_வாய்பாடு_கொடு(பதம்)
Expand All @@ -29,3 +27,30 @@ def test_புளிமாங்காய்(பதம்):
புது_சீர்_வாய்பாடு = சீர்.சீர்_வாய்பாடு_கொடு(பதம்)

assert "புளிமாங்காய்" == புது_சீர்_வாய்பாடு


@pytest.mark.parametrize("பதம்", [
("கேண்மை"),
("கையும்"), # சீர்முதல் ஐ நெடிலாகவே நிற்கும்
("மையும்"),
("ஔவை"), # ஔ (U+0B94) முன்பு பிரிக்கவே இயலாதிருந்தது ('ஒள' எழுத்துப்பிழை)
])
def test_தேமா(பதம்):
assert "தேமா" == சீர்.சீர்_வாய்பாடு_கொடு(பதம்)


@pytest.mark.parametrize("பதம்", [
("தலைவன்"),
("ஒளியும்"), # ஒளி/யும்; ஔ பிழை மீண்டும் வராமல் காக்கிறது
("அகர"),
])
def test_புளிமா(பதம்):
assert "புளிமா" == சீர்.சீர்_வாய்பாடு_கொடு(பதம்)


@pytest.mark.parametrize("பதம்", [
("வழிபடுக"), # காய் முன் கனி பின்: வழி/படு/க; புளிமாங்கனி அன்று
("னடியவற்காச்"),
])
def test_கருவிளங்காய்(பதம்):
assert "கருவிளங்காய்" == சீர்.சீர்_வாய்பாடு_கொடு(பதம்)
2 changes: 1 addition & 1 deletion pytamil/tests/test_பாகுபடுத்தி.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ def test_சரியான_உள்ளீடு_பிழையில்லை
பா = பாகுபடுத்தி.மரம்_கொடு(சீர்Lexer, சீர்Parser, 'சீர்', 'வானினும்')
assert பா.பிழைகள் == []
assert பா.parser.ruleNames[பா.மரம்.getRuleIndex()] == 'சீர்'
assert பா.மரம்.getText() == 'வானினும்'
assert பா.மரம்.getText() == 'வானினும்<EOF>' # start rule ends with EOF


def test_தவறான_உள்ளீடு_பிழைகள்_சேகரிக்கப்படும்(capsys):
Expand Down
Loading
Loading